mirror of
https://github.com/vcmi/vcmi.git
synced 2025-07-17 01:32:21 +02:00
Move CGameState::setupBattle code to CGameHandler::setupBattle
No reason to keep this code in GS.
This commit is contained in:
@ -727,19 +727,6 @@ CGameState::~CGameState()
|
|||||||
ptr.second.dellNull();
|
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)
|
void CGameState::init(StartInfo * si)
|
||||||
{
|
{
|
||||||
logGlobal->infoStream() << "\tUsing random seed: "<< si->seedToBeUsed;
|
logGlobal->infoStream() << "\tUsing random seed: "<< si->seedToBeUsed;
|
||||||
|
@ -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
|
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
|
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(int3 pos, PlayerColor player);
|
||||||
bool isVisible(const CGObjectInstance *obj, boost::optional<PlayerColor> player);
|
bool isVisible(const CGObjectInstance *obj, boost::optional<PlayerColor> player);
|
||||||
|
@ -1863,9 +1863,18 @@ void CGameHandler::setupBattle( int3 tile, const CArmedInstance *armies[2], cons
|
|||||||
{
|
{
|
||||||
battleResult.set(nullptr);
|
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
|
//send info about battles
|
||||||
BattleStart bs;
|
BattleStart bs;
|
||||||
bs.info = gs->setupBattle(tile, armies, heroes, creatureBank, town);
|
bs.info = BattleInfo::setupBattle(tile, terrain, terType, armies, heroes, creatureBank, town);
|
||||||
sendAndApply(&bs);
|
sendAndApply(&bs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user