From e83b9fa8fa9d1f95c4db5acb3c3328e094bf2db2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20W=2E=20Urba=C5=84czyk?= Date: Sat, 30 Oct 2010 19:26:39 +0000 Subject: [PATCH] Fixed battles for network MP. --- client/CBattleInterface.cpp | 5 ++++- server/NetPacksServer.cpp | 8 +++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/client/CBattleInterface.cpp b/client/CBattleInterface.cpp index b1ce4e5f3..1146812f6 100644 --- a/client/CBattleInterface.cpp +++ b/client/CBattleInterface.cpp @@ -1102,6 +1102,8 @@ CBattleInterface::CBattleInterface(const CCreatureSet * army1, const CCreatureSe { ObjectConstruction h__l__p(this); + if(!curInt) curInt = LOCPLINT; //may happen when we are defending during network MP game + animsAreDisplayed.setn(false); pos = myRect; strongInterest = true; @@ -2916,7 +2918,8 @@ void CBattleInterface::activateStack() stackToActivate = -1; myTurn = true; - curInt = attackerInt->playerID == LOCPLINT->cb->battleGetStackByID(activeStack)->owner ? attackerInt : defenderInt; + if(attackerInt && defenderInt) //hotseat -> need to pick which interface "takes over" as active + curInt = attackerInt->playerID == LOCPLINT->cb->battleGetStackByID(activeStack)->owner ? attackerInt : defenderInt; queue->update(); redrawBackgroundWithHexes(activeStack); diff --git a/server/NetPacksServer.cpp b/server/NetPacksServer.cpp index 955c008be..37d7d8a7a 100644 --- a/server/NetPacksServer.cpp +++ b/server/NetPacksServer.cpp @@ -6,11 +6,11 @@ #define PLAYER_OWNS(id) (gh->getPlayerAt(c)==gh->getOwner(id)) -#define ERROR_AND_RETURN {if(c) *c << &SystemMessage("You are not allowed to perform this action!"); \ +#define ERROR_AND_RETURN do {if(c) *c << &SystemMessage("You are not allowed to perform this action!"); \ tlog1<<"Player is not allowed to perform this action!\n"; \ - return false;} + return false;} while(0) #define ERROR_IF_NOT_OWNS(id) if(!PLAYER_OWNS(id)) ERROR_AND_RETURN -#define COMPLAIN_AND_RETURN(txt) { gh->complain(txt); ERROR_AND_RETURN } +#define COMPLAIN_AND_RETURN(txt) { gh->complain(txt); ERROR_AND_RETURN; } /* * NetPacksServer.cpp, part of VCMI engine @@ -43,6 +43,8 @@ bool CloseServer::applyGh( CGameHandler *gh ) bool EndTurn::applyGh( CGameHandler *gh ) { + if(gh->getPlayerAt(c) != GS(gh)->currentPlayer) + ERROR_AND_RETURN; gh->states.setFlag(GS(gh)->currentPlayer,&PlayerStatus::makingTurn,false); return true; }