瀏覽代碼

* fixed crash on visiting Sirens
* fixed race condition on the new turn, #729 should be gone
* fixed crashes in AI-only game mode

Michał W. Urbańczyk 14 年之前
父節點
當前提交
bb1bdcb0a7
共有 4 個文件被更改,包括 12 次插入6 次删除
  1. 1 1
      client/NetPacksClient.cpp
  2. 1 1
      lib/CObjectHandler.cpp
  3. 9 3
      server/CGameHandler.cpp
  4. 1 1
      server/CGameHandler.h

+ 1 - 1
client/NetPacksClient.cpp

@@ -552,7 +552,7 @@ void GarrisonDialog::applyCl(CClient *cl)
 	if(!vstd::contains(cl->playerint,h->getOwner()))
 		return;
 
-	boost::function<void()> callback = boost::bind(&CCallback::selectionMade,LOCPLINT->cb,0,id);
+	boost::function<void()> callback = boost::bind(&CCallback::selectionMade,cl->callbacks[h->getOwner()].get(),0,id);
 	cl->playerint[h->getOwner()]->showGarrisonDialog(obj,h,removableUnits,callback);
 }
 

+ 1 - 1
lib/CObjectHandler.cpp

@@ -6291,7 +6291,7 @@ void CGSirens::onHeroVisit( const CGHeroInstance * h ) const
 			xp = h->calculateXp(xp);
 			iw.text.addTxt(11,132);
 			iw.text.addReplacement(xp);
-			cb->changePrimSkill(h->ID, 4, xp, false);
+			cb->changePrimSkill(h->id, 4, xp, false);
 		}
 		else
 		{

+ 9 - 3
server/CGameHandler.cpp

@@ -1244,7 +1244,7 @@ void CGameHandler::run(bool resume)
 			{
 				YourTurn yt;
 				yt.player = i->first;
-				sendAndApply(&yt);
+				applyAndSend(&yt);
 			}
 
 			//wait till turn is done
@@ -1939,13 +1939,18 @@ void CGameHandler::sendToAllClients( CPackForClient * info )
 	}
 }
 
-void CGameHandler::sendAndApply( CPackForClient * info )
+void CGameHandler::sendAndApply(CPackForClient * info)
 {
-	//TODO? mutex
 	sendToAllClients(info);
 	gs->apply(info);
 }
 
+void CGameHandler::applyAndSend(CPackForClient * info)
+{
+	gs->apply(info);
+	sendToAllClients(info);
+}
+
 void CGameHandler::sendAndApply(CGarrisonOperationPack * info)
 {
 	sendAndApply((CPackForClient*)info);
@@ -5231,6 +5236,7 @@ void CGameHandler::spawnWanderingMonsters(int creatureID)
 		tiles.erase(tile); //not use it again
 	}
 }
+
 CasualtiesAfterBattle::CasualtiesAfterBattle(const CArmedInstance *army, BattleInfo *bat)
 {
 	int color = army->tempOwner;

+ 1 - 1
server/CGameHandler.h

@@ -242,8 +242,8 @@ public:
 	void ask(Query * sel, ui8 player, const CFunctionList<void(ui32)> &callback);
 	void sendToAllClients(CPackForClient * info);
 	void sendAndApply(CPackForClient * info);
+	void applyAndSend(CPackForClient * info);
 	void sendAndApply(CGarrisonOperationPack * info);
-	//void sendAndApply(SetGarrisons * info);
 	void sendAndApply(SetResource * info);
 	void sendAndApply(SetResources * info);
 	void sendAndApply(NewStructures * info);