1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-08-13 19:54:17 +02:00

#1965 - treat dwelling defenders as neutrals

This commit is contained in:
Andrii Danylchenko
2023-07-24 22:21:15 +03:00
parent be3ed014a7
commit ec8898a0e7
4 changed files with 20 additions and 11 deletions

View File

@@ -19,6 +19,14 @@ void SideInBattle::init(const CGHeroInstance * Hero, const CArmedInstance * Army
armyObject = Army; armyObject = Army;
color = armyObject->getOwner(); color = armyObject->getOwner();
if(armyObject->ID == Obj::CREATURE_GENERATOR1
|| armyObject->ID == Obj::CREATURE_GENERATOR2
|| armyObject->ID == Obj::CREATURE_GENERATOR3
|| armyObject->ID == Obj::CREATURE_GENERATOR4)
{
color = PlayerColor::NEUTRAL;
}
if(color == PlayerColor::UNFLAGGABLE) if(color == PlayerColor::UNFLAGGABLE)
color = PlayerColor::NEUTRAL; color = PlayerColor::NEUTRAL;
} }

View File

@@ -107,6 +107,10 @@ int3 IBoatGenerator::bestLocation() const
IBoatGenerator::EGeneratorState IBoatGenerator::shipyardStatus() const IBoatGenerator::EGeneratorState IBoatGenerator::shipyardStatus() const
{ {
int3 tile = bestLocation(); int3 tile = bestLocation();
if(!tile.valid())
return TILE_BLOCKED; //no available water
const TerrainTile *t = IObjectInterface::cb->getTile(tile); const TerrainTile *t = IObjectInterface::cb->getTile(tile);
if(!t) if(!t)
return TILE_BLOCKED; //no available water return TILE_BLOCKED; //no available water

View File

@@ -635,11 +635,9 @@ void CGameHandler::endBattleConfirm(const BattleInfo * battleInfo)
return; return;
} }
const CArmedInstance *bEndArmy1 = battleInfo->sides.at(0).armyObject;
const CArmedInstance *bEndArmy2 = battleInfo->sides.at(1).armyObject;
const BattleResult::EResult result = battleResult.get()->result; const BattleResult::EResult result = battleResult.get()->result;
CasualtiesAfterBattle cab1(bEndArmy1, battleInfo), cab2(bEndArmy2, battleInfo); //calculate casualties before deleting battle CasualtiesAfterBattle cab1(battleInfo->sides.at(0), battleInfo), cab2(battleInfo->sides.at(1), battleInfo); //calculate casualties before deleting battle
ChangeSpells cs; //for Eagle Eye ChangeSpells cs; //for Eagle Eye
if(!finishingBattle->isDraw() && finishingBattle->winnerHero) if(!finishingBattle->isDraw() && finishingBattle->winnerHero)
@@ -816,8 +814,8 @@ void CGameHandler::endBattleConfirm(const BattleInfo * battleInfo)
changePrimSkill(finishingBattle->winnerHero, PrimarySkill::EXPERIENCE, battleResult.data->exp[finishingBattle->winnerSide]); changePrimSkill(finishingBattle->winnerHero, PrimarySkill::EXPERIENCE, battleResult.data->exp[finishingBattle->winnerSide]);
BattleResultAccepted raccepted; BattleResultAccepted raccepted;
raccepted.heroResult[0].army = const_cast<CArmedInstance*>(bEndArmy1); raccepted.heroResult[0].army = const_cast<CArmedInstance*>(battleInfo->sides.at(0).armyObject);
raccepted.heroResult[1].army = const_cast<CArmedInstance*>(bEndArmy2); raccepted.heroResult[1].army = const_cast<CArmedInstance*>(battleInfo->sides.at(1).armyObject);
raccepted.heroResult[0].hero = const_cast<CGHeroInstance*>(battleInfo->sides.at(0).hero); raccepted.heroResult[0].hero = const_cast<CGHeroInstance*>(battleInfo->sides.at(0).hero);
raccepted.heroResult[1].hero = const_cast<CGHeroInstance*>(battleInfo->sides.at(1).hero); raccepted.heroResult[1].hero = const_cast<CGHeroInstance*>(battleInfo->sides.at(1).hero);
raccepted.heroResult[0].exp = battleResult.data->exp[0]; raccepted.heroResult[0].exp = battleResult.data->exp[0];
@@ -6684,14 +6682,12 @@ void CGameHandler::showInfoDialog(const std::string & msg, PlayerColor player)
showInfoDialog(&iw); showInfoDialog(&iw);
} }
CasualtiesAfterBattle::CasualtiesAfterBattle(const CArmedInstance * _army, const BattleInfo * bat): CasualtiesAfterBattle::CasualtiesAfterBattle(const SideInBattle & battleSide, const BattleInfo * bat):
army(_army) army(battleSide.armyObject)
{ {
heroWithDeadCommander = ObjectInstanceID(); heroWithDeadCommander = ObjectInstanceID();
PlayerColor color = army->tempOwner; PlayerColor color = battleSide.color;
if(color == PlayerColor::UNFLAGGABLE)
color = PlayerColor::NEUTRAL;
for(CStack * st : bat->stacks) for(CStack * st : bat->stacks)
{ {

View File

@@ -23,6 +23,7 @@ VCMI_LIB_NAMESPACE_BEGIN
class CGameState; class CGameState;
struct StartInfo; struct StartInfo;
struct BattleResult; struct BattleResult;
struct SideInBattle;
struct BattleAttack; struct BattleAttack;
struct BattleStackAttacked; struct BattleStackAttacked;
struct CPack; struct CPack;
@@ -90,7 +91,7 @@ struct CasualtiesAfterBattle
TSummoned summoned; TSummoned summoned;
ObjectInstanceID heroWithDeadCommander; //TODO: unify stack locations ObjectInstanceID heroWithDeadCommander; //TODO: unify stack locations
CasualtiesAfterBattle(const CArmedInstance * _army, const BattleInfo * bat); CasualtiesAfterBattle(const SideInBattle & battleSide, const BattleInfo * bat);
void updateArmy(CGameHandler *gh); void updateArmy(CGameHandler *gh);
}; };