mirror of
https://github.com/vcmi/vcmi.git
synced 2024-11-24 08:32:34 +02:00
Merge pull request #2405 from vcmi/fix-2389
#1965 - treat dwelling defenders as neutrals
This commit is contained in:
commit
ae1aa816d3
@ -17,7 +17,18 @@ void SideInBattle::init(const CGHeroInstance * Hero, const CArmedInstance * Army
|
||||
{
|
||||
hero = Hero;
|
||||
armyObject = Army;
|
||||
color = armyObject->getOwner();
|
||||
|
||||
switch(armyObject->ID)
|
||||
{
|
||||
case Obj::CREATURE_GENERATOR1:
|
||||
case Obj::CREATURE_GENERATOR2:
|
||||
case Obj::CREATURE_GENERATOR3:
|
||||
case Obj::CREATURE_GENERATOR4:
|
||||
color = PlayerColor::NEUTRAL;
|
||||
break;
|
||||
default:
|
||||
color = armyObject->getOwner();
|
||||
}
|
||||
|
||||
if(color == PlayerColor::UNFLAGGABLE)
|
||||
color = PlayerColor::NEUTRAL;
|
||||
|
@ -107,6 +107,10 @@ int3 IBoatGenerator::bestLocation() const
|
||||
IBoatGenerator::EGeneratorState IBoatGenerator::shipyardStatus() const
|
||||
{
|
||||
int3 tile = bestLocation();
|
||||
|
||||
if(!tile.valid())
|
||||
return TILE_BLOCKED; //no available water
|
||||
|
||||
const TerrainTile *t = IObjectInterface::cb->getTile(tile);
|
||||
if(!t)
|
||||
return TILE_BLOCKED; //no available water
|
||||
|
@ -635,11 +635,9 @@ void CGameHandler::endBattleConfirm(const BattleInfo * battleInfo)
|
||||
return;
|
||||
}
|
||||
|
||||
const CArmedInstance *bEndArmy1 = battleInfo->sides.at(0).armyObject;
|
||||
const CArmedInstance *bEndArmy2 = battleInfo->sides.at(1).armyObject;
|
||||
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
|
||||
|
||||
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]);
|
||||
|
||||
BattleResultAccepted raccepted;
|
||||
raccepted.heroResult[0].army = const_cast<CArmedInstance*>(bEndArmy1);
|
||||
raccepted.heroResult[1].army = const_cast<CArmedInstance*>(bEndArmy2);
|
||||
raccepted.heroResult[0].army = const_cast<CArmedInstance*>(battleInfo->sides.at(0).armyObject);
|
||||
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[1].hero = const_cast<CGHeroInstance*>(battleInfo->sides.at(1).hero);
|
||||
raccepted.heroResult[0].exp = battleResult.data->exp[0];
|
||||
@ -6684,14 +6682,12 @@ void CGameHandler::showInfoDialog(const std::string & msg, PlayerColor player)
|
||||
showInfoDialog(&iw);
|
||||
}
|
||||
|
||||
CasualtiesAfterBattle::CasualtiesAfterBattle(const CArmedInstance * _army, const BattleInfo * bat):
|
||||
army(_army)
|
||||
CasualtiesAfterBattle::CasualtiesAfterBattle(const SideInBattle & battleSide, const BattleInfo * bat):
|
||||
army(battleSide.armyObject)
|
||||
{
|
||||
heroWithDeadCommander = ObjectInstanceID();
|
||||
|
||||
PlayerColor color = army->tempOwner;
|
||||
if(color == PlayerColor::UNFLAGGABLE)
|
||||
color = PlayerColor::NEUTRAL;
|
||||
PlayerColor color = battleSide.color;
|
||||
|
||||
for(CStack * st : bat->stacks)
|
||||
{
|
||||
|
@ -23,6 +23,7 @@ VCMI_LIB_NAMESPACE_BEGIN
|
||||
class CGameState;
|
||||
struct StartInfo;
|
||||
struct BattleResult;
|
||||
struct SideInBattle;
|
||||
struct BattleAttack;
|
||||
struct BattleStackAttacked;
|
||||
struct CPack;
|
||||
@ -90,7 +91,7 @@ struct CasualtiesAfterBattle
|
||||
TSummoned summoned;
|
||||
ObjectInstanceID heroWithDeadCommander; //TODO: unify stack locations
|
||||
|
||||
CasualtiesAfterBattle(const CArmedInstance * _army, const BattleInfo * bat);
|
||||
CasualtiesAfterBattle(const SideInBattle & battleSide, const BattleInfo * bat);
|
||||
void updateArmy(CGameHandler *gh);
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user