1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-11-28 08:48:48 +02:00

Fixed few more discovered regressions

This commit is contained in:
Ivan Savenko 2023-08-17 20:20:12 +03:00
parent 013417fb7e
commit 67eaef3520
5 changed files with 47 additions and 37 deletions

View File

@ -2284,32 +2284,35 @@ void StartAction::applyGs(CGameState *gs)
return;
}
[[maybe_unused]] bool heroAction = ba.actionType == EActionType::HERO_SPELL || ba.actionType ==EActionType::SURRENDER || ba.actionType ==EActionType::RETREAT || ba.actionType == EActionType::END_TACTIC_PHASE;
assert(st || heroAction); // stack must exists for all non-hero actions
if(ba.actionType == EActionType::HERO_SPELL)
gs->curB->sides[ba.side].usedSpellsHistory.push_back(ba.spell);
switch(ba.actionType)
if (ba.isUnitAction())
{
case EActionType::DEFEND:
st->waiting = false;
st->defending = true;
st->defendingAnim = true;
break;
case EActionType::WAIT:
st->defendingAnim = false;
st->waiting = true;
st->waitedThisTurn = true;
break;
case EActionType::HERO_SPELL: //no change in current stack state
break;
default: //any active stack action - attack, catapult, heal, spell...
st->waiting = false;
st->defendingAnim = false;
st->movedThisRound = true;
break;
assert(st); // stack must exists for all non-hero actions
switch(ba.actionType)
{
case EActionType::DEFEND:
st->waiting = false;
st->defending = true;
st->defendingAnim = true;
break;
case EActionType::WAIT:
st->defendingAnim = false;
st->waiting = true;
st->waitedThisTurn = true;
break;
case EActionType::HERO_SPELL: //no change in current stack state
break;
default: //any active stack action - attack, catapult, heal, spell...
st->waiting = false;
st->defendingAnim = false;
st->movedThisRound = true;
break;
}
}
else
{
if(ba.actionType == EActionType::HERO_SPELL)
gs->curB->sides[ba.side].usedSpellsHistory.push_back(ba.spell);
}
}

View File

@ -58,11 +58,6 @@ bool BattleActionProcessor::doEmptyAction(const BattleAction & ba)
bool BattleActionProcessor::doEndTacticsAction(const BattleAction & ba)
{
if (gameHandler->gameState()->curB->tacticDistance == 0)
{
gameHandler->complain("Cannot end tactics mode - no tactics!");
return false;
}
return true;
}

View File

@ -547,7 +547,7 @@ void BattleFlowProcessor::onActionMade(const BattleAction &ba)
{
// this is action made by hero AND unit is alive (e.g. not killed by casted spell)
// keep current active stack for next action
setActiveStack(actedStack);
setActiveStack(activeStack);
return;
}
}

View File

@ -213,15 +213,27 @@ void PlayerMessageProcessor::cheatGiveMachines(PlayerColor player, const CGHeroI
gameHandler->giveHeroNewArtifact(hero, VLC->arth->objects[ArtifactID::FIRST_AID_TENT], ArtifactPosition::MACH3);
}
void PlayerMessageProcessor::cheatGiveArtifacts(PlayerColor player, const CGHeroInstance * hero)
void PlayerMessageProcessor::cheatGiveArtifacts(PlayerColor player, const CGHeroInstance * hero, std::vector<std::string> words)
{
if (!hero)
return;
for(int g = 7; g < VLC->arth->objects.size(); ++g) //including artifacts from mods
if (!words.empty())
{
if(VLC->arth->objects[g]->canBePutAt(hero))
gameHandler->giveHeroNewArtifact(hero, VLC->arth->objects[g], ArtifactPosition::FIRST_AVAILABLE);
for (auto const & word : words)
{
auto artID = VLC->identifiers()->getIdentifier(ModScope::scopeGame(), "artifact", word, false);
if(artID && VLC->arth->objects[*artID])
gameHandler->giveHeroNewArtifact(hero, VLC->arth->objects[*artID], ArtifactPosition::FIRST_AVAILABLE);
}
}
else
{
for(int g = 7; g < VLC->arth->objects.size(); ++g) //including artifacts from mods
{
if(VLC->arth->objects[g]->canBePutAt(hero))
gameHandler->giveHeroNewArtifact(hero, VLC->arth->objects[g], ArtifactPosition::FIRST_AVAILABLE);
}
}
}
@ -434,7 +446,7 @@ void PlayerMessageProcessor::executeCheatCode(const std::string & cheatName, Pla
const auto & doCheatGiveArmyCustom = [&]() { cheatGiveArmy(player, hero, words); };
const auto & doCheatGiveArmyFixed = [&](std::vector<std::string> customWords) { cheatGiveArmy(player, hero, customWords); };
const auto & doCheatGiveMachines = [&]() { cheatGiveMachines(player, hero); };
const auto & doCheatGiveArtifacts = [&]() { cheatGiveArtifacts(player, hero); };
const auto & doCheatGiveArtifacts = [&]() { cheatGiveArtifacts(player, hero, words); };
const auto & doCheatLevelup = [&]() { cheatLevelup(player, hero, words); };
const auto & doCheatExperience = [&]() { cheatExperience(player, hero, words); };
const auto & doCheatMovement = [&]() { cheatMovement(player, hero, words); };

View File

@ -31,7 +31,7 @@ class PlayerMessageProcessor
void cheatBuildTown(PlayerColor player, const CGTownInstance * town);
void cheatGiveArmy(PlayerColor player, const CGHeroInstance * hero, std::vector<std::string> words);
void cheatGiveMachines(PlayerColor player, const CGHeroInstance * hero);
void cheatGiveArtifacts(PlayerColor player, const CGHeroInstance * hero);
void cheatGiveArtifacts(PlayerColor player, const CGHeroInstance * hero, std::vector<std::string> words);
void cheatLevelup(PlayerColor player, const CGHeroInstance * hero, std::vector<std::string> words);
void cheatExperience(PlayerColor player, const CGHeroInstance * hero, std::vector<std::string> words);
void cheatMovement(PlayerColor player, const CGHeroInstance * hero, std::vector<std::string> words);