Browse Source

Merge pull request #565 from dydzio0614/moralewaitfix

Fix lack of unit action with morale+wait
Alexander Shishkin 6 years ago
parent
commit
34f934370b
4 changed files with 9 additions and 2 deletions
  1. 1 1
      client/battle/CBattleInterface.cpp
  2. 1 0
      lib/NetPacksLib.cpp
  3. 6 1
      lib/battle/CUnitState.cpp
  4. 1 0
      lib/battle/CUnitState.h

+ 1 - 1
client/battle/CBattleInterface.cpp

@@ -1917,7 +1917,7 @@ void CBattleInterface::blockUI(bool on)
 		canCastSpells = spellcastingProblem == ESpellCastProblem::OK || spellcastingProblem == ESpellCastProblem::MAGIC_IS_BLOCKED;
 	}
 
-	bool canWait = activeStack ? !activeStack->waited() : false;
+	bool canWait = activeStack ? !activeStack->waitedThisTurn : false;
 
 	bOptions->block(on);
 	bFlee->block(on || !curInt->cb->battleCanFlee());

+ 1 - 0
lib/NetPacksLib.cpp

@@ -1422,6 +1422,7 @@ DLL_LINKAGE void StartAction::applyGs(CGameState *gs)
 	case EActionType::WAIT:
 		st->defendingAnim = false;
 		st->waiting = true;
+		st->waitedThisTurn = true;
 		break;
 	case EActionType::HERO_SPELL: //no change in current stack state
 		break;

+ 6 - 1
lib/battle/CUnitState.cpp

@@ -476,6 +476,7 @@ CUnitState::CUnitState()
 	movedThisRound(false),
 	summoned(false),
 	waiting(false),
+	waitedThisTurn(false),
 	casts(this),
 	counterAttacks(this),
 	health(this),
@@ -508,6 +509,7 @@ CUnitState & CUnitState::operator=(const CUnitState & other)
 	movedThisRound = other.movedThisRound;
 	summoned = other.summoned;
 	waiting = other.waiting;
+	waitedThisTurn = other.waitedThisTurn;
 	casts = other.casts;
 	counterAttacks = other.counterAttacks;
 	health = other.health;
@@ -727,7 +729,7 @@ bool CUnitState::defended(int turn) const
 
 bool CUnitState::moved(int turn) const
 {
-	if(!turn)
+	if(!turn && !waiting)
 		return movedThisRound;
 	else
 		return false;
@@ -843,6 +845,7 @@ void CUnitState::serializeJson(JsonSerializeFormat & handler)
 	handler.serializeBool("moved", movedThisRound);
 	handler.serializeBool("summoned", summoned);
 	handler.serializeBool("waiting", waiting);
+	handler.serializeBool("waitedThisTurn", waitedThisTurn);
 
 	handler.serializeStruct("casts", casts);
 	handler.serializeStruct("counterAttacks", counterAttacks);
@@ -876,6 +879,7 @@ void CUnitState::reset()
 	movedThisRound = false;
 	summoned = false;
 	waiting = false;
+	waitedThisTurn = false;
 
 	casts.reset();
 	counterAttacks.reset();
@@ -946,6 +950,7 @@ void CUnitState::afterNewRound()
 {
 	defending = false;
 	waiting = false;
+	waitedThisTurn = false;
 	movedThisRound = false;
 	hadMorale = false;
 	fear = false;

+ 1 - 0
lib/battle/CUnitState.h

@@ -181,6 +181,7 @@ public:
 	bool movedThisRound;
 	bool summoned;
 	bool waiting;
+	bool waitedThisTurn; //"waited()" that stays true for full turn after wait - needed as UI button hackfix
 
 	CCasts casts;
 	CRetaliations counterAttacks;