1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-01-12 02:28:11 +02:00

Move CGameState::setupBattle code to CGameHandler::setupBattle

No reason to keep this code in GS.
This commit is contained in:
Arseniy Shestakov 2016-08-29 04:46:01 +03:00
parent 53502e84e3
commit ea63497b19
3 changed files with 10 additions and 15 deletions

View File

@ -727,19 +727,6 @@ CGameState::~CGameState()
ptr.second.dellNull();
}
BattleInfo * CGameState::setupBattle(int3 tile, const CArmedInstance *armies[2], const CGHeroInstance * heroes[2], bool creatureBank, const CGTownInstance *town)
{
const TerrainTile &t = map->getTile(tile);
ETerrainType terrain = t.terType;
if(map->isCoastalTile(tile)) //coastal tile is always ground
terrain = ETerrainType::SAND;
BFieldType terType = battleGetBattlefieldType(tile);
if (heroes[0] && heroes[0]->boat && heroes[1] && heroes[1]->boat)
terType = BFieldType::SHIP_TO_SHIP;
return BattleInfo::setupBattle(tile, terrain, terType, armies, heroes, creatureBank, town);
}
void CGameState::init(StartInfo * si)
{
logGlobal->infoStream() << "\tUsing random seed: "<< si->seedToBeUsed;

View File

@ -236,7 +236,6 @@ public:
void obtainPlayersStats(SThievesGuildInfo & tgi, int level); //fills tgi with info about other players that is available at given level of thieves' guild
std::map<ui32, ConstTransitivePtr<CGHeroInstance> > unusedHeroesFromPool(); //heroes pool without heroes that are available in taverns
BattleInfo * setupBattle(int3 tile, const CArmedInstance *armies[2], const CGHeroInstance * heroes[2], bool creatureBank, const CGTownInstance *town);
bool isVisible(int3 pos, PlayerColor player);
bool isVisible(const CGObjectInstance *obj, boost::optional<PlayerColor> player);

View File

@ -1863,9 +1863,18 @@ void CGameHandler::setupBattle( int3 tile, const CArmedInstance *armies[2], cons
{
battleResult.set(nullptr);
const auto t = gs->getTile(tile);
ETerrainType terrain = t->terType;
if(gs->map->isCoastalTile(tile)) //coastal tile is always ground
terrain = ETerrainType::SAND;
BFieldType terType = gs->battleGetBattlefieldType(tile);
if (heroes[0] && heroes[0]->boat && heroes[1] && heroes[1]->boat)
terType = BFieldType::SHIP_TO_SHIP;
//send info about battles
BattleStart bs;
bs.info = gs->setupBattle(tile, armies, heroes, creatureBank, town);
bs.info = BattleInfo::setupBattle(tile, terrain, terType, armies, heroes, creatureBank, town);
sendAndApply(&bs);
}