From ea63497b19bcf5d5bf0400cc64625853f0ff4afe Mon Sep 17 00:00:00 2001 From: Arseniy Shestakov Date: Mon, 29 Aug 2016 04:46:01 +0300 Subject: [PATCH] Move CGameState::setupBattle code to CGameHandler::setupBattle No reason to keep this code in GS. --- lib/CGameState.cpp | 13 ------------- lib/CGameState.h | 1 - server/CGameHandler.cpp | 11 ++++++++++- 3 files changed, 10 insertions(+), 15 deletions(-) diff --git a/lib/CGameState.cpp b/lib/CGameState.cpp index 54779b2ab..9f905aca9 100644 --- a/lib/CGameState.cpp +++ b/lib/CGameState.cpp @@ -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; diff --git a/lib/CGameState.h b/lib/CGameState.h index 783c468c2..dd82517b8 100644 --- a/lib/CGameState.h +++ b/lib/CGameState.h @@ -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 > 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 player); diff --git a/server/CGameHandler.cpp b/server/CGameHandler.cpp index f7f601779..908e2d50f 100644 --- a/server/CGameHandler.cpp +++ b/server/CGameHandler.cpp @@ -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); }