mirror of
https://github.com/vcmi/vcmi.git
synced 2025-08-10 22:31:40 +02:00
CGameState::map is now a private, unique_ptr with accessors
This commit is contained in:
@@ -140,7 +140,7 @@ void AINodeStorage::initialize(const PathfinderOptions & options, const CGameSta
|
||||
{
|
||||
for(pos.y = 0; pos.y < sizes.y; ++pos.y)
|
||||
{
|
||||
const TerrainTile & tile = gs->map->getTile(pos);
|
||||
const TerrainTile & tile = gs->getMap().getTile(pos);
|
||||
if (!tile.getTerrain()->isPassable())
|
||||
continue;
|
||||
|
||||
|
@@ -46,7 +46,7 @@ void AINodeStorage::initialize(const PathfinderOptions & options, const CGameSta
|
||||
{
|
||||
for(pos.y=0; pos.y < sizes.y; ++pos.y)
|
||||
{
|
||||
const TerrainTile & tile = gs->map->getTile(pos);
|
||||
const TerrainTile & tile = gs->getMap().getTile(pos);
|
||||
if(!tile.getTerrain()->isPassable())
|
||||
continue;
|
||||
|
||||
|
@@ -379,7 +379,7 @@ CCallback::~CCallback() = default;
|
||||
bool CCallback::canMoveBetween(const int3 &a, const int3 &b)
|
||||
{
|
||||
//bidirectional
|
||||
return gs->map->canMoveBetween(a, b);
|
||||
return gs->getMap().canMoveBetween(a, b);
|
||||
}
|
||||
|
||||
std::optional<PlayerColor> CCallback::getPlayerID() const
|
||||
@@ -389,10 +389,10 @@ std::optional<PlayerColor> CCallback::getPlayerID() const
|
||||
|
||||
int3 CCallback::getGuardingCreaturePosition(int3 tile)
|
||||
{
|
||||
if (!gs->map->isInTheMap(tile))
|
||||
if (!gs->getMap().isInTheMap(tile))
|
||||
return int3(-1,-1,-1);
|
||||
|
||||
return gs->map->guardingCreaturePositions[tile.z][tile.x][tile.y];
|
||||
return gs->getMap().guardingCreaturePositions[tile.z][tile.x][tile.y];
|
||||
}
|
||||
|
||||
void CCallback::dig( const CGObjectInstance *hero )
|
||||
|
@@ -218,7 +218,7 @@ void CClient::initMapHandler()
|
||||
// During loading CPlayerInterface from serialized state it's depend on MH
|
||||
if(!settings["session"]["headless"].Bool())
|
||||
{
|
||||
GAME->setMapInstance(std::make_unique<CMapHandler>(gs->map));
|
||||
GAME->setMapInstance(std::make_unique<CMapHandler>(&gs->getMap()));
|
||||
logNetwork->trace("Creating mapHandler: %d ms", GAME->server().th->getDiff());
|
||||
}
|
||||
}
|
||||
|
@@ -624,7 +624,7 @@ void ApplyClientNetPackVisitor::visitSetHeroesInTown(SetHeroesInTown & pack)
|
||||
|
||||
void ApplyClientNetPackVisitor::visitHeroRecruited(HeroRecruited & pack)
|
||||
{
|
||||
CGHeroInstance *h = gs.map->heroesOnMap.back();
|
||||
CGHeroInstance *h = gs.getMap().heroesOnMap.back();
|
||||
if(h->getHeroTypeID() != pack.hid)
|
||||
{
|
||||
logNetwork->error("Something wrong with hero recruited!");
|
||||
|
@@ -58,17 +58,17 @@ const PlayerSettings * CGameInfoCallback::getPlayerSettings(PlayerColor color) c
|
||||
|
||||
bool CGameInfoCallback::isAllowed(SpellID id) const
|
||||
{
|
||||
return gs->map->allowedSpells.count(id) != 0;
|
||||
return gs->getMap().allowedSpells.count(id) != 0;
|
||||
}
|
||||
|
||||
bool CGameInfoCallback::isAllowed(ArtifactID id) const
|
||||
{
|
||||
return gs->map->allowedArtifact.count(id) != 0;
|
||||
return gs->getMap().allowedArtifact.count(id) != 0;
|
||||
}
|
||||
|
||||
bool CGameInfoCallback::isAllowed(SecondarySkill id) const
|
||||
{
|
||||
return gs->map->allowedAbilities.count(id) != 0;
|
||||
return gs->getMap().allowedAbilities.count(id) != 0;
|
||||
}
|
||||
|
||||
std::optional<PlayerColor> CGameInfoCallback::getPlayerID() const
|
||||
@@ -132,14 +132,14 @@ TurnTimerInfo CGameInfoCallback::getPlayerTurnTime(PlayerColor color) const
|
||||
const CGObjectInstance* CGameInfoCallback::getObj(ObjectInstanceID objid, bool verbose) const
|
||||
{
|
||||
si32 oid = objid.num;
|
||||
if(oid < 0 || oid >= gs->map->objects.size())
|
||||
if(oid < 0 || oid >= gs->getMap().objects.size())
|
||||
{
|
||||
if(verbose)
|
||||
logGlobal->error("Cannot get object with id %d", oid);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const CGObjectInstance *ret = gs->map->objects[oid];
|
||||
const CGObjectInstance *ret = gs->getMap().objects[oid];
|
||||
if(!ret)
|
||||
{
|
||||
if(verbose)
|
||||
@@ -483,7 +483,7 @@ std::vector <const CGObjectInstance *> CGameInfoCallback::getVisitableObjs(int3
|
||||
std::vector<const CGObjectInstance *> CGameInfoCallback::getAllVisitableObjs() const
|
||||
{
|
||||
std::vector<const CGObjectInstance *> ret;
|
||||
for(auto & obj : gs->map->objects)
|
||||
for(auto & obj : gs->getMap().objects)
|
||||
if(obj && obj->isVisitable() && obj->ID != Obj::EVENT && isVisible(obj))
|
||||
ret.push_back(obj);
|
||||
|
||||
@@ -508,7 +508,7 @@ std::vector <const CGObjectInstance *> CGameInfoCallback::getFlaggableObjects(in
|
||||
|
||||
int3 CGameInfoCallback::getMapSize() const
|
||||
{
|
||||
return int3(gs->map->width, gs->map->height, gs->map->twoLevel ? 2 : 1);
|
||||
return int3(gs->getMap().width, gs->getMap().height, gs->getMap().twoLevel ? 2 : 1);
|
||||
}
|
||||
|
||||
std::vector<const CGHeroInstance *> CGameInfoCallback::getAvailableHeroes(const CGObjectInstance * townOrTavern) const
|
||||
@@ -528,7 +528,7 @@ std::vector<const CGHeroInstance *> CGameInfoCallback::getAvailableHeroes(const
|
||||
const TerrainTile * CGameInfoCallback::getTile(int3 tile, bool verbose) const
|
||||
{
|
||||
if(isVisible(tile))
|
||||
return &gs->map->getTile(tile);
|
||||
return &gs->getMap().getTile(tile);
|
||||
|
||||
if(verbose)
|
||||
logGlobal->error("\r\n%s: %s\r\n", BOOST_CURRENT_FUNCTION, tile.toString() + " is not visible!");
|
||||
@@ -538,7 +538,7 @@ const TerrainTile * CGameInfoCallback::getTile(int3 tile, bool verbose) const
|
||||
const TerrainTile * CGameInfoCallback::getTileUnchecked(int3 tile) const
|
||||
{
|
||||
if (isInTheMap(tile))
|
||||
return &gs->map->getTile(tile);
|
||||
return &gs->getMap().getTile(tile);
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
@@ -548,7 +548,7 @@ EDiggingStatus CGameInfoCallback::getTileDigStatus(int3 tile, bool verbose) cons
|
||||
if(!isVisible(tile))
|
||||
return EDiggingStatus::UNKNOWN;
|
||||
|
||||
for(const auto & object : gs->map->objects)
|
||||
for(const auto & object : gs->getMap().objects)
|
||||
{
|
||||
if(object && object->ID == Obj::HOLE && object->anchorPos() == tile)
|
||||
return EDiggingStatus::TILE_OCCUPIED;
|
||||
@@ -562,9 +562,9 @@ std::shared_ptr<const boost::multi_array<TerrainTile*, 3>> CGameInfoCallback::ge
|
||||
assert(getPlayerID().has_value());
|
||||
const auto * team = getPlayerTeam(getPlayerID().value());
|
||||
|
||||
size_t width = gs->map->width;
|
||||
size_t height = gs->map->height;
|
||||
size_t levels = gs->map->levels();
|
||||
size_t width = gs->getMap().width;
|
||||
size_t height = gs->getMap().height;
|
||||
size_t levels = gs->getMap().levels();
|
||||
|
||||
auto * ptr = new boost::multi_array<TerrainTile *, 3>(boost::extents[levels][width][height]);
|
||||
|
||||
@@ -574,7 +574,7 @@ std::shared_ptr<const boost::multi_array<TerrainTile*, 3>> CGameInfoCallback::ge
|
||||
for(tile.y = 0; tile.y < height; tile.y++)
|
||||
{
|
||||
if (team->fogOfWarMap[tile.z][tile.x][tile.y])
|
||||
(*ptr)[tile.z][tile.x][tile.y] = &gs->map->getTile(tile);
|
||||
(*ptr)[tile.z][tile.x][tile.y] = &gs->getMap().getTile(tile);
|
||||
else
|
||||
(*ptr)[tile.z][tile.x][tile.y] = nullptr;
|
||||
}
|
||||
@@ -653,7 +653,7 @@ EBuildingState CGameInfoCallback::canBuildStructure( const CGTownInstance *t, Bu
|
||||
|
||||
const CMapHeader * CGameInfoCallback::getMapHeader() const
|
||||
{
|
||||
return gs->map;
|
||||
return &gs->getMap();
|
||||
}
|
||||
|
||||
bool CGameInfoCallback::hasAccess(std::optional<PlayerColor> playerId) const
|
||||
@@ -690,7 +690,7 @@ std::string CGameInfoCallback::getTavernRumor(const CGObjectInstance * townOrTav
|
||||
|
||||
break;
|
||||
case RumorState::TYPE_MAP:
|
||||
text.replaceRawString(gs->map->rumors[rumor.first].text.toString());
|
||||
text.replaceRawString(gs->getMap().rumors[rumor.first].text.toString());
|
||||
break;
|
||||
|
||||
case RumorState::TYPE_RAND:
|
||||
@@ -778,7 +778,7 @@ std::vector < const CGHeroInstance *> CPlayerSpecificInfoCallback::getHeroesInfo
|
||||
{
|
||||
//std::shared_lock<std::shared_mutex> lock(*gs->mx);
|
||||
std::vector < const CGHeroInstance *> ret;
|
||||
for(auto hero : gs->map->heroesOnMap)
|
||||
for(auto hero : gs->getMap().heroesOnMap)
|
||||
{
|
||||
// !player || // - why would we even get access to hero not owned by any player?
|
||||
if((hero->tempOwner == *getPlayerID()) ||
|
||||
@@ -811,7 +811,7 @@ int CPlayerSpecificInfoCallback::getHeroSerial(const CGHeroInstance * hero, bool
|
||||
|
||||
int3 CPlayerSpecificInfoCallback::getGrailPos( double *outKnownRatio )
|
||||
{
|
||||
if (!getPlayerID() || gs->map->obeliskCount == 0)
|
||||
if (!getPlayerID() || gs->getMap().obeliskCount == 0)
|
||||
{
|
||||
*outKnownRatio = 0.0;
|
||||
}
|
||||
@@ -819,12 +819,12 @@ int3 CPlayerSpecificInfoCallback::getGrailPos( double *outKnownRatio )
|
||||
{
|
||||
TeamID t = gs->getPlayerTeam(*getPlayerID())->id;
|
||||
double visited = 0.0;
|
||||
if(gs->map->obelisksVisited.count(t))
|
||||
visited = static_cast<double>(gs->map->obelisksVisited[t]);
|
||||
if(gs->getMap().obelisksVisited.count(t))
|
||||
visited = static_cast<double>(gs->getMap().obelisksVisited[t]);
|
||||
|
||||
*outKnownRatio = visited / gs->map->obeliskCount;
|
||||
*outKnownRatio = visited / gs->getMap().obeliskCount;
|
||||
}
|
||||
return gs->map->grailPos;
|
||||
return gs->getMap().grailPos;
|
||||
}
|
||||
|
||||
std::vector < const CGObjectInstance * > CPlayerSpecificInfoCallback::getMyObjects() const
|
||||
@@ -928,15 +928,15 @@ const CGHeroInstance * CGameInfoCallback::getHeroWithSubid( int subid ) const
|
||||
{
|
||||
if(subid<0)
|
||||
return nullptr;
|
||||
if(subid>= gs->map->allHeroes.size())
|
||||
if(subid>= gs->getMap().allHeroes.size())
|
||||
return nullptr;
|
||||
|
||||
return gs->map->allHeroes.at(subid).get();
|
||||
return gs->getMap().allHeroes.at(subid).get();
|
||||
}
|
||||
|
||||
bool CGameInfoCallback::isInTheMap(const int3 &pos) const
|
||||
{
|
||||
return gs->map->isInTheMap(pos);
|
||||
return gs->getMap().isInTheMap(pos);
|
||||
}
|
||||
|
||||
void CGameInfoCallback::getVisibleTilesInRange(std::unordered_set<int3> &tiles, int3 pos, int radious, int3::EDistanceFormula distanceFormula) const
|
||||
@@ -951,12 +951,12 @@ void CGameInfoCallback::calculatePaths(const std::shared_ptr<PathfinderConfig> &
|
||||
|
||||
const CArtifactInstance * CGameInfoCallback::getArtInstance( ArtifactInstanceID aid ) const
|
||||
{
|
||||
return gs->map->artInstances.at(aid.num);
|
||||
return gs->getMap().artInstances.at(aid.num);
|
||||
}
|
||||
|
||||
const CGObjectInstance * CGameInfoCallback::getObjInstance( ObjectInstanceID oid ) const
|
||||
{
|
||||
return gs->map->objects.at(oid.num);
|
||||
return gs->getMap().objects.at(oid.num);
|
||||
}
|
||||
|
||||
const CArtifactSet * CGameInfoCallback::getArtSet(const ArtifactLocation & loc) const
|
||||
@@ -976,12 +976,12 @@ std::vector<ObjectInstanceID> CGameInfoCallback::getVisibleTeleportObjects(std::
|
||||
|
||||
std::vector<ObjectInstanceID> CGameInfoCallback::getTeleportChannelEntrances(TeleportChannelID id, PlayerColor player) const
|
||||
{
|
||||
return getVisibleTeleportObjects(gs->map->teleportChannels[id]->entrances, player);
|
||||
return getVisibleTeleportObjects(gs->getMap().teleportChannels[id]->entrances, player);
|
||||
}
|
||||
|
||||
std::vector<ObjectInstanceID> CGameInfoCallback::getTeleportChannelExits(TeleportChannelID id, PlayerColor player) const
|
||||
{
|
||||
return getVisibleTeleportObjects(gs->map->teleportChannels[id]->exits, player);
|
||||
return getVisibleTeleportObjects(gs->getMap().teleportChannels[id]->exits, player);
|
||||
}
|
||||
|
||||
ETeleportChannelType CGameInfoCallback::getTeleportChannelType(TeleportChannelID id, PlayerColor player) const
|
||||
|
@@ -58,17 +58,17 @@ VCMI_LIB_NAMESPACE_BEGIN
|
||||
void CPrivilegedInfoCallback::getFreeTiles(std::vector<int3> & tiles) const
|
||||
{
|
||||
std::vector<int> floors;
|
||||
floors.reserve(gs->map->levels());
|
||||
for(int b = 0; b < gs->map->levels(); ++b)
|
||||
floors.reserve(gs->getMap().levels());
|
||||
for(int b = 0; b < gs->getMap().levels(); ++b)
|
||||
{
|
||||
floors.push_back(b);
|
||||
}
|
||||
const TerrainTile * tinfo = nullptr;
|
||||
for (auto zd : floors)
|
||||
{
|
||||
for (int xd = 0; xd < gs->map->width; xd++)
|
||||
for (int xd = 0; xd < gs->getMap().width; xd++)
|
||||
{
|
||||
for (int yd = 0; yd < gs->map->height; yd++)
|
||||
for (int yd = 0; yd < gs->getMap().height; yd++)
|
||||
{
|
||||
tinfo = getTile(int3 (xd,yd,zd));
|
||||
if (tinfo->isLand() && tinfo->getTerrain()->isPassable() && !tinfo->blocked()) //land and free
|
||||
@@ -95,9 +95,9 @@ void CPrivilegedInfoCallback::getTilesInRange(std::unordered_set<int3> & tiles,
|
||||
else
|
||||
{
|
||||
const TeamState * team = !player ? nullptr : gs->getPlayerTeam(*player);
|
||||
for (int xd = std::max<int>(pos.x - radious , 0); xd <= std::min<int>(pos.x + radious, gs->map->width - 1); xd++)
|
||||
for (int xd = std::max<int>(pos.x - radious , 0); xd <= std::min<int>(pos.x + radious, gs->getMap().width - 1); xd++)
|
||||
{
|
||||
for (int yd = std::max<int>(pos.y - radious, 0); yd <= std::min<int>(pos.y + radious, gs->map->height - 1); yd++)
|
||||
for (int yd = std::max<int>(pos.y - radious, 0); yd <= std::min<int>(pos.y + radious, gs->getMap().height - 1); yd++)
|
||||
{
|
||||
int3 tilePos(xd,yd,pos.z);
|
||||
int distance = pos.dist(tilePos, distanceFormula);
|
||||
@@ -126,7 +126,7 @@ void CPrivilegedInfoCallback::getAllTiles(std::unordered_set<int3> & tiles, std:
|
||||
std::vector<int> floors;
|
||||
if(level == -1)
|
||||
{
|
||||
for(int b = 0; b < gs->map->levels(); ++b)
|
||||
for(int b = 0; b < gs->getMap().levels(); ++b)
|
||||
{
|
||||
floors.push_back(b);
|
||||
}
|
||||
@@ -136,9 +136,9 @@ void CPrivilegedInfoCallback::getAllTiles(std::unordered_set<int3> & tiles, std:
|
||||
|
||||
for(auto zd: floors)
|
||||
{
|
||||
for(int xd = 0; xd < gs->map->width; xd++)
|
||||
for(int xd = 0; xd < gs->getMap().width; xd++)
|
||||
{
|
||||
for(int yd = 0; yd < gs->map->height; yd++)
|
||||
for(int yd = 0; yd < gs->getMap().height; yd++)
|
||||
{
|
||||
int3 coordinates(xd, yd, zd);
|
||||
if (filter(getTile(coordinates)))
|
||||
@@ -160,7 +160,7 @@ void CPrivilegedInfoCallback::pickAllowedArtsSet(std::vector<ArtifactID> & out,
|
||||
|
||||
void CPrivilegedInfoCallback::getAllowedSpells(std::vector<SpellID> & out, std::optional<ui16> level)
|
||||
{
|
||||
for (auto const & spellID : gs->map->allowedSpells)
|
||||
for (auto const & spellID : gs->getMap().allowedSpells)
|
||||
{
|
||||
const auto * spell = spellID.toEntity(LIBRARY);
|
||||
|
||||
@@ -208,7 +208,7 @@ void CPrivilegedInfoCallback::saveCommonState(CSaveFile & out) const
|
||||
logGlobal->info("Saving lib part of game...");
|
||||
out.putMagicBytes(SAVEGAME_MAGIC);
|
||||
logGlobal->info("\tSaving header");
|
||||
out.serializer & static_cast<CMapHeader&>(*gs->map);
|
||||
out.serializer & static_cast<CMapHeader&>(gs->getMap());
|
||||
logGlobal->info("\tSaving options");
|
||||
out.serializer & gs->getStartInfo();
|
||||
logGlobal->info("\tSaving mod list");
|
||||
@@ -219,9 +219,9 @@ void CPrivilegedInfoCallback::saveCommonState(CSaveFile & out) const
|
||||
|
||||
TerrainTile * CNonConstInfoCallback::getTile(const int3 & pos)
|
||||
{
|
||||
if(!gs->map->isInTheMap(pos))
|
||||
if(!gs->getMap().isInTheMap(pos))
|
||||
return nullptr;
|
||||
return &gs->map->getTile(pos);
|
||||
return &gs->getMap().getTile(pos);
|
||||
}
|
||||
|
||||
CGHeroInstance * CNonConstInfoCallback::getHero(const ObjectInstanceID & objid)
|
||||
@@ -251,12 +251,12 @@ PlayerState * CNonConstInfoCallback::getPlayerState(const PlayerColor & color, b
|
||||
|
||||
CArtifactInstance * CNonConstInfoCallback::getArtInstance(const ArtifactInstanceID & aid)
|
||||
{
|
||||
return gs->map->artInstances.at(aid.num);
|
||||
return gs->getMap().artInstances.at(aid.num);
|
||||
}
|
||||
|
||||
CGObjectInstance * CNonConstInfoCallback::getObjInstance(const ObjectInstanceID & oid)
|
||||
{
|
||||
return gs->map->objects.at(oid.num);
|
||||
return gs->getMap().objects.at(oid.num);
|
||||
}
|
||||
|
||||
CArmedInstance * CNonConstInfoCallback::getArmyInstance(const ObjectInstanceID & oid)
|
||||
|
@@ -150,7 +150,6 @@ CGameState::~CGameState()
|
||||
{
|
||||
// explicitly delete all ongoing battles first - BattleInfo destructor requires valid CGameState
|
||||
currentBattles.clear();
|
||||
map.dellNull();
|
||||
}
|
||||
|
||||
const IGameSettings & CGameState::getSettings() const
|
||||
@@ -334,7 +333,7 @@ void CGameState::initNewGame(const IMapService * mapService, bool allowSavingRan
|
||||
}
|
||||
}
|
||||
|
||||
map = randomMap.release();
|
||||
map = std::move(randomMap);
|
||||
|
||||
logGlobal->info("Generated random map in %i ms.", sw.getDiff());
|
||||
}
|
||||
@@ -342,14 +341,14 @@ void CGameState::initNewGame(const IMapService * mapService, bool allowSavingRan
|
||||
{
|
||||
logGlobal->info("Open map file: %s", scenarioOps->mapname);
|
||||
const ResourcePath mapURI(scenarioOps->mapname, EResType::MAP);
|
||||
map = mapService->loadMap(mapURI, callback).release();
|
||||
map = mapService->loadMap(mapURI, callback);
|
||||
}
|
||||
}
|
||||
|
||||
void CGameState::initCampaign()
|
||||
{
|
||||
campaign = std::make_unique<CGameStateCampaign>(this);
|
||||
map = campaign->getCurrentMap().release();
|
||||
map = campaign->getCurrentMap();
|
||||
}
|
||||
|
||||
void CGameState::generateOwnedObjectsAfterDeserialize()
|
||||
@@ -615,7 +614,7 @@ void CGameState::initHeroes()
|
||||
|
||||
boat->setAnchorPos(hero->anchorPos());
|
||||
boat->appearance = handler->getTemplates().front();
|
||||
boat->id = ObjectInstanceID(static_cast<si32>(gs->map->objects.size()));
|
||||
boat->id = ObjectInstanceID(static_cast<si32>(gs->getMap().objects.size()));
|
||||
|
||||
map->objects.emplace_back(boat);
|
||||
|
||||
@@ -1205,7 +1204,7 @@ std::vector<CGObjectInstance*> CGameState::guardingCreatures (int3 pos) const
|
||||
|
||||
int3 CGameState::guardingCreaturePosition (int3 pos) const
|
||||
{
|
||||
return gs->map->guardingCreaturePositions[pos.z][pos.x][pos.y];
|
||||
return gs->getMap().guardingCreaturePositions[pos.z][pos.x][pos.y];
|
||||
}
|
||||
|
||||
bool CGameState::isVisible(int3 pos, const std::optional<PlayerColor> & player) const
|
||||
|
@@ -12,7 +12,6 @@
|
||||
#include "../bonuses/CBonusSystemNode.h"
|
||||
#include "../IGameCallback.h"
|
||||
#include "../LoadProgress.h"
|
||||
#include "../ConstTransitivePtr.h"
|
||||
|
||||
#include "RumorState.h"
|
||||
#include "GameStatistics.h"
|
||||
@@ -49,6 +48,7 @@ class DLL_LINKAGE CGameState : public CNonConstInfoCallback, public Serializeabl
|
||||
|
||||
std::unique_ptr<StartInfo> initialOpts; //copy of settings received from pregame (not randomized)
|
||||
std::unique_ptr<StartInfo> scenarioOps;
|
||||
std::unique_ptr<CMap> map;
|
||||
public:
|
||||
/// Stores number of times each artifact was placed on map via randomization
|
||||
std::map<ArtifactID, int> allocatedArtifacts;
|
||||
@@ -75,7 +75,6 @@ public:
|
||||
void updateOnLoad(StartInfo * si);
|
||||
|
||||
ui32 day; //total number of days in game
|
||||
ConstTransitivePtr<CMap> map;
|
||||
std::map<PlayerColor, PlayerState> players;
|
||||
std::map<TeamID, TeamState> teams;
|
||||
CBonusSystemNode globalEffects;
|
||||
@@ -83,6 +82,7 @@ public:
|
||||
|
||||
StatisticDataSet statistic;
|
||||
|
||||
// NOTE: effectively AI mutex, only used by adventure map AI
|
||||
static std::shared_mutex mutex;
|
||||
|
||||
void updateEntity(Metatype metatype, int32_t index, const JsonNode & data) override;
|
||||
@@ -137,6 +137,15 @@ public:
|
||||
return initialOpts.get();
|
||||
}
|
||||
|
||||
CMap & getMap()
|
||||
{
|
||||
return *map;
|
||||
}
|
||||
const CMap & getMap() const
|
||||
{
|
||||
return *map;
|
||||
}
|
||||
|
||||
bool isVisible(int3 pos, const std::optional<PlayerColor> & player) const override;
|
||||
bool isVisible(const CGObjectInstance * obj, const std::optional<PlayerColor> & player) const override;
|
||||
|
||||
|
@@ -484,7 +484,7 @@ void CGameStateCampaign::generateCampaignHeroesToReplace()
|
||||
continue;
|
||||
}
|
||||
|
||||
CGHeroInstance * hero = campaignState->crossoverDeserialize(node, gameState->map);
|
||||
CGHeroInstance * hero = campaignState->crossoverDeserialize(node, gameState->map.get());
|
||||
|
||||
logGlobal->info("Hero crossover: Loading placeholder for %d (%s)", hero->getHeroType(), hero->getNameTranslated());
|
||||
|
||||
@@ -509,7 +509,7 @@ void CGameStateCampaign::generateCampaignHeroesToReplace()
|
||||
if (nodeListIter == nodeList.end())
|
||||
break;
|
||||
|
||||
CGHeroInstance * hero = campaignState->crossoverDeserialize(*nodeListIter, gameState->map);
|
||||
CGHeroInstance * hero = campaignState->crossoverDeserialize(*nodeListIter, gameState->map.get());
|
||||
nodeListIter++;
|
||||
|
||||
logGlobal->info("Hero crossover: Loading placeholder as %d (%s)", hero->getHeroType(), hero->getNameTranslated());
|
||||
@@ -520,7 +520,7 @@ void CGameStateCampaign::generateCampaignHeroesToReplace()
|
||||
// Add remaining heroes without placeholders - to transfer their artifacts to placed heroes
|
||||
for (;nodeListIter != nodeList.end(); ++nodeListIter)
|
||||
{
|
||||
CGHeroInstance * hero = campaignState->crossoverDeserialize(*nodeListIter, gameState->map);
|
||||
CGHeroInstance * hero = campaignState->crossoverDeserialize(*nodeListIter, gameState->map.get());
|
||||
campaignHeroReplacements.emplace_back(hero, ObjectInstanceID::NONE);
|
||||
}
|
||||
}
|
||||
|
@@ -40,7 +40,7 @@ StatisticDataSetEntry StatisticDataSet::createEntry(const PlayerState * ps, cons
|
||||
scenarioHighScores.parameters.push_back(param);
|
||||
scenarioHighScores.isCampaign = false;
|
||||
|
||||
data.map = gs->map->name.toString();
|
||||
data.map = gs->getMap().name.toString();
|
||||
data.timestamp = std::time(nullptr);
|
||||
data.day = gs->getDate(Date::DAY);
|
||||
data.player = ps->color;
|
||||
@@ -193,7 +193,7 @@ std::vector<const CGMine *> Statistic::getMines(const CGameState * gs, const Pla
|
||||
std::vector<const CGMine *> tmp;
|
||||
|
||||
std::vector<const CGObjectInstance *> ownedObjects;
|
||||
for(const CGObjectInstance * obj : gs->map->objects)
|
||||
for(const CGObjectInstance * obj : gs->getMap().objects)
|
||||
{
|
||||
if(obj && obj->tempOwner == ps->color)
|
||||
ownedObjects.push_back(obj);
|
||||
@@ -285,11 +285,11 @@ float Statistic::getMapExploredRatio(const CGameState * gs, PlayerColor player)
|
||||
float visible = 0.0;
|
||||
float numTiles = 0.0;
|
||||
|
||||
for(int layer = 0; layer < (gs->map->twoLevel ? 2 : 1); layer++)
|
||||
for(int y = 0; y < gs->map->height; ++y)
|
||||
for(int x = 0; x < gs->map->width; ++x)
|
||||
for(int layer = 0; layer < (gs->getMap().twoLevel ? 2 : 1); layer++)
|
||||
for(int y = 0; y < gs->getMap().height; ++y)
|
||||
for(int x = 0; x < gs->getMap().width; ++x)
|
||||
{
|
||||
TerrainTile tile = gs->map->getTile(int3(x, y, layer));
|
||||
TerrainTile tile = gs->getMap().getTile(int3(x, y, layer));
|
||||
|
||||
if(tile.blocked() && !tile.visitable())
|
||||
continue;
|
||||
@@ -346,17 +346,17 @@ std::vector<std::vector<PlayerColor>> Statistic::getRank(std::vector<std::pair<P
|
||||
|
||||
int Statistic::getObeliskVisited(const CGameState * gs, const TeamID & t)
|
||||
{
|
||||
if(gs->map->obelisksVisited.count(t))
|
||||
return gs->map->obelisksVisited.at(t);
|
||||
if(gs->getMap().obelisksVisited.count(t))
|
||||
return gs->getMap().obelisksVisited.at(t);
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
float Statistic::getObeliskVisitedRatio(const CGameState * gs, const TeamID & t)
|
||||
{
|
||||
if(!gs->map->obeliskCount)
|
||||
if(!gs->getMap().obeliskCount)
|
||||
return 0;
|
||||
return static_cast<float>(getObeliskVisited(gs, t)) / gs->map->obeliskCount;
|
||||
return static_cast<float>(getObeliskVisited(gs, t)) / gs->getMap().obeliskCount;
|
||||
}
|
||||
|
||||
std::map<EGameResID, int> Statistic::getNumMines(const CGameState * gs, const PlayerState * ps)
|
||||
|
@@ -66,16 +66,16 @@ FactionID CGDwelling::randomizeFaction(vstd::RNG & rand)
|
||||
|
||||
if (!randomizationInfo->instanceId.empty())
|
||||
{
|
||||
auto iter = cb->gameState()->map->instanceNames.find(randomizationInfo->instanceId);
|
||||
auto iter = cb->gameState()->getMap().instanceNames.find(randomizationInfo->instanceId);
|
||||
|
||||
if(iter == cb->gameState()->map->instanceNames.end())
|
||||
if(iter == cb->gameState()->getMap().instanceNames.end())
|
||||
logGlobal->error("Map object not found: %s", randomizationInfo->instanceId);
|
||||
linkedTown = dynamic_cast<CGTownInstance *>(iter->second.get());
|
||||
}
|
||||
|
||||
if (randomizationInfo->identifier != 0)
|
||||
{
|
||||
for(auto & elem : cb->gameState()->map->objects)
|
||||
for(auto & elem : cb->gameState()->getMap().objects)
|
||||
{
|
||||
auto town = dynamic_cast<CGTownInstance*>(elem.get());
|
||||
if(town && town->identifier == randomizationInfo->identifier)
|
||||
|
@@ -540,7 +540,7 @@ void CGHeroInstance::onHeroVisit(const CGHeroInstance * h) const
|
||||
|
||||
ObjectInstanceID boatId;
|
||||
const auto boatPos = visitablePos();
|
||||
if (cb->gameState()->map->getTile(boatPos).isWater())
|
||||
if (cb->gameState()->getMap().getTile(boatPos).isWater())
|
||||
{
|
||||
smp.val = movementPointsLimit(false);
|
||||
if (!boat)
|
||||
@@ -1258,7 +1258,7 @@ void CGHeroInstance::removeSpellbook()
|
||||
|
||||
if(hasSpellbook())
|
||||
{
|
||||
cb->gameState()->map->removeArtifactInstance(*this, ArtifactPosition::SPELLBOOK);
|
||||
cb->gameState()->getMap().removeArtifactInstance(*this, ArtifactPosition::SPELLBOOK);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -122,10 +122,10 @@ void CGObjectInstance::setType(MapObjectID newID, MapObjectSubID newSubID)
|
||||
{
|
||||
auto position = visitablePos();
|
||||
auto oldOffset = getVisitableOffset();
|
||||
auto &tile = cb->gameState()->map->getTile(position);
|
||||
auto &tile = cb->gameState()->getMap().getTile(position);
|
||||
|
||||
//recalculate blockvis tiles - new appearance might have different blockmap than before
|
||||
cb->gameState()->map->removeBlockVisTiles(this, true);
|
||||
cb->gameState()->getMap().removeBlockVisTiles(this, true);
|
||||
auto handler = LIBRARY->objtypeh->getHandlerFor(newID, newSubID);
|
||||
|
||||
if(!handler->getTemplates(tile.getTerrainID()).empty())
|
||||
@@ -155,7 +155,7 @@ void CGObjectInstance::setType(MapObjectID newID, MapObjectSubID newSubID)
|
||||
this->ID = Obj(newID);
|
||||
this->subID = newSubID;
|
||||
|
||||
cb->gameState()->map->addBlockVisTiles(this);
|
||||
cb->gameState()->getMap().addBlockVisTiles(this);
|
||||
}
|
||||
|
||||
void CGObjectInstance::pickRandomObject(vstd::RNG & rand)
|
||||
|
@@ -684,14 +684,14 @@ std::vector<TradeItemBuy> CGTownInstance::availableItemsIds(EMarketMode mode) co
|
||||
if(mode == EMarketMode::RESOURCE_ARTIFACT)
|
||||
{
|
||||
std::vector<TradeItemBuy> ret;
|
||||
for(const ArtifactID a : cb->gameState()->map->townMerchantArtifacts)
|
||||
for(const ArtifactID a : cb->gameState()->getMap().townMerchantArtifacts)
|
||||
ret.push_back(a);
|
||||
|
||||
return ret;
|
||||
}
|
||||
else if ( mode == EMarketMode::RESOURCE_SKILL )
|
||||
{
|
||||
return cb->gameState()->map->townUniversitySkills;
|
||||
return cb->gameState()->getMap().townUniversitySkills;
|
||||
}
|
||||
else
|
||||
return IMarket::availableItemsIds(mode);
|
||||
|
@@ -322,7 +322,7 @@ bool CGTeleport::isConnected(const CGObjectInstance * src, const CGObjectInstanc
|
||||
|
||||
bool CGTeleport::isExitPassable(CGameState * gs, const CGHeroInstance * h, const CGObjectInstance * obj)
|
||||
{
|
||||
auto * objTopVisObj = gs->map->getTile(obj->visitablePos()).topVisitableObj();
|
||||
auto * objTopVisObj = gs->getMap().getTile(obj->visitablePos()).topVisitableObj();
|
||||
if(objTopVisObj->ID == Obj::HERO)
|
||||
{
|
||||
if(h->id == objTopVisObj->id) // Just to be sure it's won't happen.
|
||||
@@ -374,7 +374,7 @@ void CGTeleport::addToChannel(std::map<TeleportChannelID, std::shared_ptr<Telepo
|
||||
|
||||
TeleportChannelID CGMonolith::findMeChannel(const std::vector<Obj> & IDs, MapObjectSubID SubID) const
|
||||
{
|
||||
for(auto obj : cb->gameState()->map->objects)
|
||||
for(auto obj : cb->gameState()->getMap().objects)
|
||||
{
|
||||
if(!obj)
|
||||
continue;
|
||||
@@ -455,9 +455,9 @@ void CGMonolith::initObj(vstd::RNG & rand)
|
||||
|
||||
channel = findMeChannel(IDs, subID);
|
||||
if(channel == TeleportChannelID())
|
||||
channel = TeleportChannelID(static_cast<si32>(cb->gameState()->map->teleportChannels.size()));
|
||||
channel = TeleportChannelID(static_cast<si32>(cb->gameState()->getMap().teleportChannels.size()));
|
||||
|
||||
addToChannel(cb->gameState()->map->teleportChannels, this);
|
||||
addToChannel(cb->gameState()->getMap().teleportChannels, this);
|
||||
}
|
||||
|
||||
void CGSubterraneanGate::onHeroVisit( const CGHeroInstance * h ) const
|
||||
@@ -487,7 +487,7 @@ void CGSubterraneanGate::postInit(IGameCallback * cb) //matches subterranean gat
|
||||
{
|
||||
//split on underground and surface gates
|
||||
std::vector<CGSubterraneanGate *> gatesSplit[2]; //surface and underground gates
|
||||
for(auto & obj : cb->gameState()->map->objects)
|
||||
for(auto & obj : cb->gameState()->getMap().objects)
|
||||
{
|
||||
if(!obj)
|
||||
continue;
|
||||
@@ -507,8 +507,8 @@ void CGSubterraneanGate::postInit(IGameCallback * cb) //matches subterranean gat
|
||||
{
|
||||
if(obj->channel == TeleportChannelID())
|
||||
{ // if object not linked to channel then create new channel
|
||||
obj->channel = TeleportChannelID(static_cast<si32>(cb->gameState()->map->teleportChannels.size()));
|
||||
addToChannel(cb->gameState()->map->teleportChannels, obj);
|
||||
obj->channel = TeleportChannelID(static_cast<si32>(cb->gameState()->getMap().teleportChannels.size()));
|
||||
addToChannel(cb->gameState()->getMap().teleportChannels, obj);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -535,7 +535,7 @@ void CGSubterraneanGate::postInit(IGameCallback * cb) //matches subterranean gat
|
||||
if(best.first >= 0) //found pair
|
||||
{
|
||||
gatesSplit[1][best.first]->channel = objCurrent->channel;
|
||||
addToChannel(cb->gameState()->map->teleportChannels, gatesSplit[1][best.first]);
|
||||
addToChannel(cb->gameState()->getMap().teleportChannels, gatesSplit[1][best.first]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -665,7 +665,7 @@ void CGArtifact::initObj(vstd::RNG & rand)
|
||||
if (!storedArtifact)
|
||||
{
|
||||
storedArtifact = ArtifactUtils::createArtifact(ArtifactID());
|
||||
cb->gameState()->map->addNewArtifactInstance(storedArtifact);
|
||||
cb->gameState()->getMap().addNewArtifactInstance(storedArtifact);
|
||||
}
|
||||
if(!storedArtifact->getType())
|
||||
storedArtifact->setType(getArtifact().toArtifact());
|
||||
@@ -959,7 +959,7 @@ void CGMagi::onHeroVisit(const CGHeroInstance * h) const
|
||||
|
||||
std::vector<const CGObjectInstance *> eyes;
|
||||
|
||||
for (auto object : cb->gameState()->map->objects)
|
||||
for (auto object : cb->gameState()->getMap().objects)
|
||||
{
|
||||
if (object && object->ID == Obj::EYE_OF_MAGI && object->subID == this->subID)
|
||||
eyes.push_back(object);
|
||||
@@ -1172,7 +1172,7 @@ void CGObelisk::onHeroVisit( const CGHeroInstance * h ) const
|
||||
|
||||
void CGObelisk::initObj(vstd::RNG & rand)
|
||||
{
|
||||
cb->gameState()->map->obeliskCount++;
|
||||
cb->gameState()->getMap().obeliskCount++;
|
||||
}
|
||||
|
||||
std::string CGObelisk::getHoverText(PlayerColor player) const
|
||||
@@ -1191,13 +1191,13 @@ void CGObelisk::setPropertyDer(ObjProperty what, ObjPropertyID identifier)
|
||||
{
|
||||
case ObjProperty::OBELISK_VISITED:
|
||||
{
|
||||
auto progress = ++cb->gameState()->map->obelisksVisited[identifier.as<TeamID>()];
|
||||
logGlobal->debug("Player %d: obelisk progress %d / %d", identifier.getNum(), static_cast<int>(progress) , static_cast<int>(cb->gameState()->map->obeliskCount));
|
||||
auto progress = ++cb->gameState()->getMap().obelisksVisited[identifier.as<TeamID>()];
|
||||
logGlobal->debug("Player %d: obelisk progress %d / %d", identifier.getNum(), static_cast<int>(progress) , static_cast<int>(cb->gameState()->getMap().obeliskCount));
|
||||
|
||||
if(progress > cb->gameState()->map->obeliskCount)
|
||||
if(progress > cb->gameState()->getMap().obeliskCount)
|
||||
{
|
||||
logGlobal->error("Visited %d of %d", static_cast<int>(progress), cb->gameState()->map->obeliskCount);
|
||||
throw std::runtime_error("Player visited " + std::to_string(progress) + " obelisks out of " + std::to_string(cb->gameState()->map->obeliskCount) + " present on map!");
|
||||
logGlobal->error("Visited %d of %d", static_cast<int>(progress), cb->gameState()->getMap().obeliskCount);
|
||||
throw std::runtime_error("Player visited " + std::to_string(progress) + " obelisks out of " + std::to_string(cb->gameState()->getMap().obeliskCount) + " present on map!");
|
||||
}
|
||||
|
||||
break;
|
||||
|
@@ -998,7 +998,7 @@ void FoWChange::applyGs(CGameState *gs)
|
||||
if (mode == ETileVisibility::HIDDEN) //do not hide too much
|
||||
{
|
||||
std::unordered_set<int3> tilesRevealed;
|
||||
for (auto & elem : gs->map->objects)
|
||||
for (auto & elem : gs->getMap().objects)
|
||||
{
|
||||
const CGObjectInstance *o = elem;
|
||||
if (o)
|
||||
@@ -1059,9 +1059,9 @@ void ChangeObjPos::applyGs(CGameState *gs)
|
||||
logNetwork->error("Wrong ChangeObjPos: object %d doesn't exist!", objid.getNum());
|
||||
return;
|
||||
}
|
||||
gs->map->removeBlockVisTiles(obj);
|
||||
gs->getMap().removeBlockVisTiles(obj);
|
||||
obj->setAnchorPos(nPos + obj->getVisitableOffset());
|
||||
gs->map->addBlockVisTiles(obj);
|
||||
gs->getMap().addBlockVisTiles(obj);
|
||||
}
|
||||
|
||||
void ChangeObjectVisitors::applyGs(CGameState *gs)
|
||||
@@ -1080,7 +1080,7 @@ void ChangeObjectVisitors::applyGs(CGameState *gs)
|
||||
break;
|
||||
case VISITOR_CLEAR:
|
||||
// remove visit info from all heroes, including those that are not present on map
|
||||
for (CGHeroInstance * hero : gs->map->allHeroes)
|
||||
for (CGHeroInstance * hero : gs->getMap().allHeroes)
|
||||
if (hero)
|
||||
hero->visitedObjects.erase(object);
|
||||
|
||||
@@ -1125,7 +1125,7 @@ void PlayerEndsGame::applyGs(CGameState *gs)
|
||||
if(p->human && gs->getStartInfo()->campState)
|
||||
{
|
||||
std::vector<CGHeroInstance *> crossoverHeroes;
|
||||
for (CGHeroInstance * hero : gs->map->heroesOnMap)
|
||||
for (CGHeroInstance * hero : gs->getMap().heroesOnMap)
|
||||
if (hero->tempOwner == player)
|
||||
crossoverHeroes.push_back(hero);
|
||||
|
||||
@@ -1189,7 +1189,7 @@ void RemoveObject::applyGs(CGameState *gs)
|
||||
CGObjectInstance *obj = gs->getObjInstance(objectID);
|
||||
logGlobal->debug("removing object id=%d; address=%x; name=%s", objectID, (intptr_t)obj, obj->getObjectName());
|
||||
//unblock tiles
|
||||
gs->map->removeBlockVisTiles(obj);
|
||||
gs->getMap().removeBlockVisTiles(obj);
|
||||
|
||||
if (initiator.isValidPlayer())
|
||||
gs->getPlayerState(initiator)->destroyedObjects.insert(objectID);
|
||||
@@ -1209,7 +1209,7 @@ void RemoveObject::applyGs(CGameState *gs)
|
||||
{
|
||||
auto * beatenHero = dynamic_cast<CGHeroInstance *>(obj);
|
||||
assert(beatenHero);
|
||||
gs->map->heroesOnMap -= beatenHero;
|
||||
gs->getMap().heroesOnMap -= beatenHero;
|
||||
|
||||
auto * siegeNode = beatenHero->whereShouldBeAttachedOnSiege(gs);
|
||||
|
||||
@@ -1238,14 +1238,14 @@ void RemoveObject::applyGs(CGameState *gs)
|
||||
//return hero to the pool, so he may reappear in tavern
|
||||
|
||||
gs->heroesPool->addHeroToPool(beatenHero);
|
||||
gs->map->objects[objectID.getNum()] = nullptr;
|
||||
gs->getMap().objects[objectID.getNum()] = nullptr;
|
||||
|
||||
//If hero on Boat is removed, the Boat disappears
|
||||
if(beatenHero->boat)
|
||||
{
|
||||
beatenHero->detachFrom(const_cast<CGBoat&>(*beatenHero->boat));
|
||||
gs->map->instanceNames.erase(beatenHero->boat->instanceName);
|
||||
gs->map->objects[beatenHero->boat->id.getNum()].dellNull();
|
||||
gs->getMap().instanceNames.erase(beatenHero->boat->instanceName);
|
||||
gs->getMap().objects[beatenHero->boat->id.getNum()].dellNull();
|
||||
beatenHero->boat = nullptr;
|
||||
}
|
||||
return;
|
||||
@@ -1254,7 +1254,7 @@ void RemoveObject::applyGs(CGameState *gs)
|
||||
const auto * quest = dynamic_cast<const IQuestObject *>(obj);
|
||||
if (quest)
|
||||
{
|
||||
gs->map->quests[quest->quest->qid] = nullptr;
|
||||
gs->getMap().quests[quest->quest->qid] = nullptr;
|
||||
for (auto &player : gs->players)
|
||||
{
|
||||
vstd::erase_if(player.second.quests, [obj](const QuestInfo & q){
|
||||
@@ -1263,9 +1263,9 @@ void RemoveObject::applyGs(CGameState *gs)
|
||||
}
|
||||
}
|
||||
|
||||
gs->map->instanceNames.erase(obj->instanceName);
|
||||
gs->map->objects[objectID.getNum()].dellNull();
|
||||
gs->map->calculateGuardingGreaturePositions();//FIXME: excessive, update only affected tiles
|
||||
gs->getMap().instanceNames.erase(obj->instanceName);
|
||||
gs->getMap().objects[objectID.getNum()].dellNull();
|
||||
gs->getMap().calculateGuardingGreaturePositions();//FIXME: excessive, update only affected tiles
|
||||
}
|
||||
|
||||
static int getDir(const int3 & src, const int3 & dst)
|
||||
@@ -1327,12 +1327,12 @@ void TryMoveHero::applyGs(CGameState *gs)
|
||||
|
||||
if(result == EMBARK) //hero enters boat at destination tile
|
||||
{
|
||||
const TerrainTile &tt = gs->map->getTile(h->convertToVisitablePos(end));
|
||||
const TerrainTile &tt = gs->getMap().getTile(h->convertToVisitablePos(end));
|
||||
assert(tt.visitableObjects.size() >= 1 && tt.visitableObjects.back()->ID == Obj::BOAT); //the only visitable object at destination is Boat
|
||||
auto * boat = dynamic_cast<CGBoat *>(tt.visitableObjects.back());
|
||||
assert(boat);
|
||||
|
||||
gs->map->removeBlockVisTiles(boat); //hero blockvis mask will be used, we don't need to duplicate it with boat
|
||||
gs->getMap().removeBlockVisTiles(boat); //hero blockvis mask will be used, we don't need to duplicate it with boat
|
||||
h->boat = boat;
|
||||
h->attachTo(*boat);
|
||||
boat->hero = h;
|
||||
@@ -1343,18 +1343,18 @@ void TryMoveHero::applyGs(CGameState *gs)
|
||||
b->direction = h->moveDir;
|
||||
b->pos = start;
|
||||
b->hero = nullptr;
|
||||
gs->map->addBlockVisTiles(b);
|
||||
gs->getMap().addBlockVisTiles(b);
|
||||
h->detachFrom(*b);
|
||||
h->boat = nullptr;
|
||||
}
|
||||
|
||||
if(start!=end && (result == SUCCESS || result == TELEPORTATION || result == EMBARK || result == DISEMBARK))
|
||||
{
|
||||
gs->map->removeBlockVisTiles(h);
|
||||
gs->getMap().removeBlockVisTiles(h);
|
||||
h->pos = end;
|
||||
if(auto * b = const_cast<CGBoat *>(h->boat))
|
||||
b->pos = end;
|
||||
gs->map->addBlockVisTiles(h);
|
||||
gs->getMap().addBlockVisTiles(h);
|
||||
}
|
||||
|
||||
auto & fogOfWarMap = gs->getPlayerTeam(h->getOwner())->fogOfWarMap;
|
||||
@@ -1417,11 +1417,11 @@ void SetHeroesInTown::applyGs(CGameState *gs)
|
||||
|
||||
if(v)
|
||||
{
|
||||
gs->map->addBlockVisTiles(v);
|
||||
gs->getMap().addBlockVisTiles(v);
|
||||
}
|
||||
if(g)
|
||||
{
|
||||
gs->map->removeBlockVisTiles(g);
|
||||
gs->getMap().removeBlockVisTiles(g);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1437,7 +1437,7 @@ void HeroRecruited::applyGs(CGameState *gs)
|
||||
auto * boat = dynamic_cast<CGBoat *>(obj);
|
||||
if (boat)
|
||||
{
|
||||
gs->map->removeBlockVisTiles(boat);
|
||||
gs->getMap().removeBlockVisTiles(boat);
|
||||
h->attachToBoat(boat);
|
||||
}
|
||||
}
|
||||
@@ -1448,16 +1448,16 @@ void HeroRecruited::applyGs(CGameState *gs)
|
||||
|
||||
if(h->id == ObjectInstanceID())
|
||||
{
|
||||
h->id = ObjectInstanceID(static_cast<si32>(gs->map->objects.size()));
|
||||
gs->map->objects.emplace_back(h);
|
||||
h->id = ObjectInstanceID(static_cast<si32>(gs->getMap().objects.size()));
|
||||
gs->getMap().objects.emplace_back(h);
|
||||
}
|
||||
else
|
||||
gs->map->objects[h->id.getNum()] = h;
|
||||
gs->getMap().objects[h->id.getNum()] = h;
|
||||
|
||||
gs->map->heroesOnMap.emplace_back(h);
|
||||
gs->getMap().heroesOnMap.emplace_back(h);
|
||||
p->addOwnedObject(h);
|
||||
h->attachTo(*p);
|
||||
gs->map->addBlockVisTiles(h);
|
||||
gs->getMap().addBlockVisTiles(h);
|
||||
|
||||
if(t)
|
||||
t->setVisitingHero(h);
|
||||
@@ -1473,7 +1473,7 @@ void GiveHero::applyGs(CGameState *gs)
|
||||
auto * boat = dynamic_cast<CGBoat *>(obj);
|
||||
if (boat)
|
||||
{
|
||||
gs->map->removeBlockVisTiles(boat);
|
||||
gs->getMap().removeBlockVisTiles(boat);
|
||||
h->attachToBoat(boat);
|
||||
}
|
||||
}
|
||||
@@ -1483,26 +1483,26 @@ void GiveHero::applyGs(CGameState *gs)
|
||||
h->attachTo(*gs->getPlayerState(player));
|
||||
|
||||
auto oldVisitablePos = h->visitablePos();
|
||||
gs->map->removeBlockVisTiles(h,true);
|
||||
gs->getMap().removeBlockVisTiles(h,true);
|
||||
h->updateAppearance();
|
||||
|
||||
h->setOwner(player);
|
||||
h->setMovementPoints(h->movementPointsLimit(true));
|
||||
h->setAnchorPos(h->convertFromVisitablePos(oldVisitablePos));
|
||||
gs->map->heroesOnMap.emplace_back(h);
|
||||
gs->getMap().heroesOnMap.emplace_back(h);
|
||||
gs->getPlayerState(h->getOwner())->addOwnedObject(h);
|
||||
|
||||
gs->map->addBlockVisTiles(h);
|
||||
gs->getMap().addBlockVisTiles(h);
|
||||
h->inTownGarrison = false;
|
||||
}
|
||||
|
||||
void NewObject::applyGs(CGameState *gs)
|
||||
{
|
||||
newObject->id = ObjectInstanceID(static_cast<si32>(gs->map->objects.size()));
|
||||
newObject->id = ObjectInstanceID(static_cast<si32>(gs->getMap().objects.size()));
|
||||
|
||||
gs->map->objects.emplace_back(newObject);
|
||||
gs->map->addBlockVisTiles(newObject);
|
||||
gs->map->calculateGuardingGreaturePositions();
|
||||
gs->getMap().objects.emplace_back(newObject);
|
||||
gs->getMap().addBlockVisTiles(newObject);
|
||||
gs->getMap().calculateGuardingGreaturePositions();
|
||||
|
||||
// attach newly spawned wandering monster to global bonus system node
|
||||
auto newArmy = dynamic_cast<CArmedInstance*>(newObject);
|
||||
@@ -1515,7 +1515,7 @@ void NewObject::applyGs(CGameState *gs)
|
||||
void NewArtifact::applyGs(CGameState *gs)
|
||||
{
|
||||
auto art = ArtifactUtils::createArtifact(artId, spellId);
|
||||
gs->map->addNewArtifactInstance(art);
|
||||
gs->getMap().addNewArtifactInstance(art);
|
||||
PutArtifact pa(art->getId(), ArtifactLocation(artHolder, pos), false);
|
||||
pa.applyGs(gs);
|
||||
}
|
||||
@@ -1632,7 +1632,7 @@ void RebalanceStacks::applyGs(CGameState *gs)
|
||||
auto dstSlot = ArtifactUtils::getArtBackpackPosition(srcHero, dstArt->getTypeId());
|
||||
if(srcHero && dstSlot != ArtifactPosition::PRE_FIRST)
|
||||
{
|
||||
gs->map->moveArtifactInstance(*dstStack, ArtifactPosition::CREATURE_SLOT, *srcHero, dstSlot);
|
||||
gs->getMap().moveArtifactInstance(*dstStack, ArtifactPosition::CREATURE_SLOT, *srcHero, dstSlot);
|
||||
}
|
||||
//else - artifact can be lost :/
|
||||
else
|
||||
@@ -1644,12 +1644,12 @@ void RebalanceStacks::applyGs(CGameState *gs)
|
||||
ea.applyGs(gs);
|
||||
logNetwork->warn("Cannot move artifact! No free slots");
|
||||
}
|
||||
gs->map->moveArtifactInstance(*srcStack, ArtifactPosition::CREATURE_SLOT, *dstStack, ArtifactPosition::CREATURE_SLOT);
|
||||
gs->getMap().moveArtifactInstance(*srcStack, ArtifactPosition::CREATURE_SLOT, *dstStack, ArtifactPosition::CREATURE_SLOT);
|
||||
//TODO: choose from dialog
|
||||
}
|
||||
else //just move to the other slot before stack gets erased
|
||||
{
|
||||
gs->map->moveArtifactInstance(*srcStack, ArtifactPosition::CREATURE_SLOT, *dstStack, ArtifactPosition::CREATURE_SLOT);
|
||||
gs->getMap().moveArtifactInstance(*srcStack, ArtifactPosition::CREATURE_SLOT, *dstStack, ArtifactPosition::CREATURE_SLOT);
|
||||
}
|
||||
}
|
||||
if (stackExp)
|
||||
@@ -1727,7 +1727,7 @@ void PutArtifact::applyGs(CGameState *gs)
|
||||
assert(hero);
|
||||
assert(art && art->canBePutAt(hero, al.slot));
|
||||
assert(ArtifactUtils::checkIfSlotValid(*hero, al.slot));
|
||||
gs->map->putArtifactInstance(*hero, art, al.slot);
|
||||
gs->getMap().putArtifactInstance(*hero, art, al.slot);
|
||||
}
|
||||
|
||||
void BulkEraseArtifacts::applyGs(CGameState *gs)
|
||||
@@ -1766,7 +1766,7 @@ void BulkEraseArtifacts::applyGs(CGameState *gs)
|
||||
{
|
||||
logGlobal->debug("Erasing artifact %s", slotInfo->artifact->getType()->getNameTranslated());
|
||||
}
|
||||
gs->map->removeArtifactInstance(*artSet, slot);
|
||||
gs->getMap().removeArtifactInstance(*artSet, slot);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1783,7 +1783,7 @@ void BulkMoveArtifacts::applyGs(CGameState *gs)
|
||||
});
|
||||
|
||||
for(const auto & slot : packToRemove)
|
||||
gs->map->removeArtifactInstance(artSet, slot);
|
||||
gs->getMap().removeArtifactInstance(artSet, slot);
|
||||
};
|
||||
|
||||
const auto bulkArtsPut = [gs](std::vector<LinkedSlots> & artsPack, CArtifactSet & initArtSet, CArtifactSet & dstArtSet)
|
||||
@@ -1792,7 +1792,7 @@ void BulkMoveArtifacts::applyGs(CGameState *gs)
|
||||
{
|
||||
auto * art = initArtSet.getArt(slotsPair.srcPos);
|
||||
assert(art);
|
||||
gs->map->putArtifactInstance(dstArtSet, art, slotsPair.dstPos);
|
||||
gs->getMap().putArtifactInstance(dstArtSet, art, slotsPair.dstPos);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1824,7 +1824,7 @@ void AssembledArtifact::applyGs(CGameState *gs)
|
||||
}));
|
||||
|
||||
auto * combinedArt = new CArtifactInstance(builtArt);
|
||||
gs->map->addNewArtifactInstance(combinedArt);
|
||||
gs->getMap().addNewArtifactInstance(combinedArt);
|
||||
|
||||
// Find slots for all involved artifacts
|
||||
std::set<ArtifactPosition, std::greater<>> slotsInvolved = { al.slot };
|
||||
@@ -1865,7 +1865,7 @@ void AssembledArtifact::applyGs(CGameState *gs)
|
||||
for(const auto & slot : slotsInvolved)
|
||||
{
|
||||
const auto constituentInstance = artSet->getArt(slot);
|
||||
gs->map->removeArtifactInstance(*artSet, slot);
|
||||
gs->getMap().removeArtifactInstance(*artSet, slot);
|
||||
|
||||
if(!combinedArt->getType()->isFused())
|
||||
{
|
||||
@@ -1877,7 +1877,7 @@ void AssembledArtifact::applyGs(CGameState *gs)
|
||||
}
|
||||
|
||||
// Put new combined artifacts
|
||||
gs->map->putArtifactInstance(*artSet, combinedArt, al.slot);
|
||||
gs->getMap().putArtifactInstance(*artSet, combinedArt, al.slot);
|
||||
}
|
||||
|
||||
void DisassembledArtifact::applyGs(CGameState *gs)
|
||||
@@ -1888,15 +1888,15 @@ void DisassembledArtifact::applyGs(CGameState *gs)
|
||||
assert(disassembledArt);
|
||||
|
||||
const auto parts = disassembledArt->getPartsInfo();
|
||||
gs->map->removeArtifactInstance(*hero, al.slot);
|
||||
gs->getMap().removeArtifactInstance(*hero, al.slot);
|
||||
for(auto & part : parts)
|
||||
{
|
||||
// ArtifactPosition::PRE_FIRST is value of main part slot -> it'll replace combined artifact in its pos
|
||||
auto slot = (ArtifactUtils::isSlotEquipment(part.slot) ? part.slot : al.slot);
|
||||
disassembledArt->detachFrom(*part.art);
|
||||
gs->map->putArtifactInstance(*hero, part.art, slot);
|
||||
gs->getMap().putArtifactInstance(*hero, part.art, slot);
|
||||
}
|
||||
gs->map->eraseArtifactInstance(disassembledArt);
|
||||
gs->getMap().eraseArtifactInstance(disassembledArt);
|
||||
}
|
||||
|
||||
void HeroVisit::applyGs(CGameState *gs)
|
||||
@@ -1918,7 +1918,7 @@ void SetAvailableArtifacts::applyGs(CGameState *gs)
|
||||
}
|
||||
else
|
||||
{
|
||||
gs->map->townMerchantArtifacts = arts;
|
||||
gs->getMap().townMerchantArtifacts = arts;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1949,7 +1949,7 @@ void NewTurn::applyGs(CGameState *gs)
|
||||
for(auto & creatureSet : availableCreatures) //set available creatures in towns
|
||||
creatureSet.applyGs(gs);
|
||||
|
||||
for(CGTownInstance* t : gs->map->towns)
|
||||
for(CGTownInstance* t : gs->getMap().towns)
|
||||
{
|
||||
t->built = 0;
|
||||
t->spellResearchCounterDay = 0;
|
||||
|
@@ -111,7 +111,7 @@ void CPathfinder::calculatePaths()
|
||||
|
||||
for(auto * initialNode : initialNodes)
|
||||
{
|
||||
if(!gamestate->isInTheMap(initialNode->coord)/* || !gs->map->isInTheMap(dest)*/) //check input
|
||||
if(!gamestate->isInTheMap(initialNode->coord)/* || !gs->getMap().isInTheMap(dest)*/) //check input
|
||||
{
|
||||
logGlobal->error("CGameState::calculatePaths: Hero outside the gs->map? How dare you...");
|
||||
throw std::runtime_error("Wrong checksum");
|
||||
@@ -251,7 +251,7 @@ TeleporterTilesVector CPathfinderHelper::getAllowedTeleportChannelExits(const Te
|
||||
auto pos = obj->getBlockedPos();
|
||||
for(const auto & p : pos)
|
||||
{
|
||||
if(gs->map->getTile(p).topVisitableId() == obj->ID)
|
||||
if(gs->getMap().getTile(p).topVisitableId() == obj->ID)
|
||||
allowedExits.push_back(p);
|
||||
}
|
||||
}
|
||||
@@ -571,7 +571,7 @@ void CPathfinderHelper::getNeighbours(
|
||||
const boost::logic::tribool & onLand,
|
||||
const bool limitCoastSailing) const
|
||||
{
|
||||
CMap * map = gs->map;
|
||||
const CMap * map = &gs->getMap();
|
||||
const TerrainType * sourceTerrain = sourceTile.getTerrain();
|
||||
|
||||
static constexpr std::array dirs = {
|
||||
|
@@ -40,7 +40,7 @@ void NodeStorage::initialize(const PathfinderOptions & options, const CGameState
|
||||
{
|
||||
for(pos.y=0; pos.y < sizes.y; ++pos.y)
|
||||
{
|
||||
const TerrainTile & tile = gs->map->getTile(pos);
|
||||
const TerrainTile & tile = gs->getMap().getTile(pos);
|
||||
if(tile.isWater())
|
||||
{
|
||||
resetTile(pos, ELayer::SAIL, PathfinderUtil::evaluateAccessibility<ELayer::SAIL>(pos, tile, fow, player, gs));
|
||||
|
@@ -23,13 +23,13 @@ CSerializer::~CSerializer() = default;
|
||||
|
||||
void CSerializer::addStdVecItems(CGameState *gs, GameLibrary *lib)
|
||||
{
|
||||
registerVectoredType<CGObjectInstance, ObjectInstanceID>(&gs->map->objects,
|
||||
registerVectoredType<CGObjectInstance, ObjectInstanceID>(&gs->getMap().objects,
|
||||
[](const CGObjectInstance &obj){ return obj.id; });
|
||||
registerVectoredType<CGHeroInstance, HeroTypeID>(&gs->map->allHeroes,
|
||||
registerVectoredType<CGHeroInstance, HeroTypeID>(&gs->getMap().allHeroes,
|
||||
[](const CGHeroInstance &h){ return h.getHeroType()->getId(); });
|
||||
registerVectoredType<CArtifactInstance, ArtifactInstanceID>(&gs->map->artInstances,
|
||||
registerVectoredType<CArtifactInstance, ArtifactInstanceID>(&gs->getMap().artInstances,
|
||||
[](const CArtifactInstance &artInst){ return artInst.getId(); });
|
||||
registerVectoredType<CQuest, si32>(&gs->map->quests,
|
||||
registerVectoredType<CQuest, si32>(&gs->getMap().quests,
|
||||
[](const CQuest &q){ return q.qid; });
|
||||
|
||||
smartVectorMembersSerialization = true;
|
||||
|
@@ -346,8 +346,8 @@ void CGameHandler::giveExperience(const CGHeroInstance * hero, TExpType amountTo
|
||||
TExpType maxExp = LIBRARY->heroh->reqExp(LIBRARY->heroh->maxSupportedLevel());
|
||||
TExpType currExp = hero->exp;
|
||||
|
||||
if (gs->map->levelLimit != 0)
|
||||
maxExp = LIBRARY->heroh->reqExp(gs->map->levelLimit);
|
||||
if (gs->getMap().levelLimit != 0)
|
||||
maxExp = LIBRARY->heroh->reqExp(gs->getMap().levelLimit);
|
||||
|
||||
TExpType canGainExp = 0;
|
||||
if (maxExp > currExp)
|
||||
@@ -553,7 +553,7 @@ void CGameHandler::init(StartInfo *si, Load::ProgressAccumulator & progressTrack
|
||||
for (auto & elem : gs->players)
|
||||
turnOrder->addPlayer(elem.first);
|
||||
|
||||
for (auto & elem : gs->map->allHeroes)
|
||||
for (auto & elem : gs->getMap().allHeroes)
|
||||
{
|
||||
if(elem)
|
||||
heroPool->getHeroSkillsRandomGenerator(elem->getHeroTypeID()); // init RMG seed
|
||||
@@ -638,7 +638,7 @@ void CGameHandler::onNewTurn()
|
||||
|
||||
if (firstTurn)
|
||||
{
|
||||
for (auto obj : gs->map->objects)
|
||||
for (auto obj : gs->getMap().objects)
|
||||
{
|
||||
if (obj && obj->ID == Obj::PRISON) //give imprisoned hero 0 exp to level him up. easiest to do at this point
|
||||
{
|
||||
@@ -655,7 +655,7 @@ void CGameHandler::onNewTurn()
|
||||
addStatistics(gameState()->statistic); // write at end of turn
|
||||
}
|
||||
|
||||
for (CGTownInstance *t : gs->map->towns)
|
||||
for (CGTownInstance *t : gs->getMap().towns)
|
||||
{
|
||||
PlayerColor player = t->tempOwner;
|
||||
|
||||
@@ -669,7 +669,7 @@ void CGameHandler::onNewTurn()
|
||||
}
|
||||
}
|
||||
|
||||
for (CGTownInstance *t : gs->map->towns)
|
||||
for (CGTownInstance *t : gs->getMap().towns)
|
||||
{
|
||||
if (t->hasBonusOfType (BonusType::DARKNESS))
|
||||
{
|
||||
@@ -696,7 +696,7 @@ void CGameHandler::onNewTurn()
|
||||
checkVictoryLossConditionsForAll(); // check for map turn limit
|
||||
|
||||
//call objects
|
||||
for (auto & elem : gs->map->objects)
|
||||
for (auto & elem : gs->getMap().objects)
|
||||
{
|
||||
if (elem)
|
||||
elem->newTurn(getRandomGenerator());
|
||||
@@ -810,7 +810,7 @@ bool CGameHandler::moveHero(ObjectInstanceID hid, int3 dst, EMovementMode moveme
|
||||
logGlobal->trace("Player %d (%s) wants to move hero %d from %s to %s", asker, asker.toString(), hid.getNum(), h->anchorPos().toString(), dst.toString());
|
||||
const int3 hmpos = h->convertToVisitablePos(dst);
|
||||
|
||||
if (!gs->map->isInTheMap(hmpos))
|
||||
if (!gs->getMap().isInTheMap(hmpos))
|
||||
{
|
||||
logGlobal->error("Destination tile is outside the map!");
|
||||
return false;
|
||||
@@ -905,7 +905,7 @@ bool CGameHandler::moveHero(ObjectInstanceID hid, int3 dst, EMovementMode moveme
|
||||
// should be called if hero changes tile but before applying TryMoveHero package
|
||||
auto leaveTile = [&]()
|
||||
{
|
||||
for (CGObjectInstance *obj : gs->map->getTile(h->visitablePos()).visitableObjects)
|
||||
for (CGObjectInstance *obj : gs->getMap().getTile(h->visitablePos()).visitableObjects)
|
||||
{
|
||||
obj->onHeroLeave(h);
|
||||
}
|
||||
@@ -3050,7 +3050,7 @@ bool CGameHandler::buyArtifact(const IMarket *m, const CGHeroInstance *h, GameRe
|
||||
if(dynamic_cast<const CGTownInstance *>(m))
|
||||
{
|
||||
saa.id = ObjectInstanceID::NONE;
|
||||
saa.arts = gs->map->townMerchantArtifacts;
|
||||
saa.arts = gs->getMap().townMerchantArtifacts;
|
||||
}
|
||||
else if(const CGBlackMarket *bm = dynamic_cast<const CGBlackMarket *>(m)) //black market
|
||||
{
|
||||
@@ -3469,7 +3469,7 @@ bool CGameHandler::buildBoat(ObjectInstanceID objid, PlayerColor playerID)
|
||||
}
|
||||
|
||||
int3 tile = obj->bestLocation();
|
||||
if (!gs->map->isInTheMap(tile))
|
||||
if (!gs->getMap().isInTheMap(tile))
|
||||
{
|
||||
complain("Cannot find appropriate tile for a boat!");
|
||||
return false;
|
||||
@@ -3559,7 +3559,7 @@ void CGameHandler::checkVictoryLossConditionsForPlayer(PlayerColor player)
|
||||
}
|
||||
|
||||
//player lost -> all his objects become unflagged (neutral)
|
||||
for (auto obj : gs->map->objects) //unflag objs
|
||||
for (auto obj : gs->getMap().objects) //unflag objs
|
||||
{
|
||||
if (obj.get() && obj->tempOwner == player)
|
||||
setOwner(obj, PlayerColor::NEUTRAL);
|
||||
@@ -3615,7 +3615,7 @@ bool CGameHandler::dig(const CGHeroInstance *h)
|
||||
InfoWindow iw;
|
||||
iw.type = EInfoWindowMode::AUTO;
|
||||
iw.player = h->tempOwner;
|
||||
if (gs->map->grailPos == h->visitablePos())
|
||||
if (gs->getMap().grailPos == h->visitablePos())
|
||||
{
|
||||
ArtifactID grail = ArtifactID::GRAIL;
|
||||
|
||||
@@ -4052,7 +4052,7 @@ void CGameHandler::synchronizeArtifactHandlerLists()
|
||||
|
||||
bool CGameHandler::isValidObject(const CGObjectInstance *obj) const
|
||||
{
|
||||
return vstd::contains(gs->map->objects, obj);
|
||||
return vstd::contains(gs->getMap().objects, obj);
|
||||
}
|
||||
|
||||
bool CGameHandler::isBlockedByQueries(const CPackForServer *pack, PlayerColor player)
|
||||
@@ -4253,7 +4253,7 @@ CGObjectInstance * CGameHandler::createNewObject(const int3 & visitablePosition,
|
||||
if (!gs->isInTheMap(visitablePosition))
|
||||
throw std::runtime_error("Attempt to create object outside map at " + visitablePosition.toString());
|
||||
|
||||
const TerrainTile & t = gs->map->getTile(visitablePosition);
|
||||
const TerrainTile & t = gs->getMap().getTile(visitablePosition);
|
||||
terrainType = t.getTerrainID();
|
||||
|
||||
auto handler = LIBRARY->objtypeh->getHandlerFor(objectID, subID);
|
||||
|
@@ -86,7 +86,7 @@ const CGameInfoCallback * ServerSpellCastEnvironment::getCb() const
|
||||
|
||||
const CMap * ServerSpellCastEnvironment::getMap() const
|
||||
{
|
||||
return gh->gameState()->map;
|
||||
return &gh->gameState()->getMap();
|
||||
}
|
||||
|
||||
bool ServerSpellCastEnvironment::moveHero(ObjectInstanceID hid, int3 dst, EMovementMode mode)
|
||||
|
@@ -160,7 +160,7 @@ BattleID BattleProcessor::setupBattle(int3 tile, BattleSideArray<const CArmedIns
|
||||
TerrainId terrain = t.getTerrainID();
|
||||
if (town)
|
||||
terrain = town->getNativeTerrain();
|
||||
else if (gameHandler->gameState()->map->isCoastalTile(tile)) //coastal tile is always ground
|
||||
else if (gameHandler->gameState()->getMap().isCoastalTile(tile)) //coastal tile is always ground
|
||||
terrain = ETerrainId::SAND;
|
||||
|
||||
BattleField battlefieldType = gameHandler->gameState()->battleGetBattlefieldType(tile, gameHandler->getRandomGenerator());
|
||||
|
@@ -41,7 +41,7 @@ NewTurnProcessor::NewTurnProcessor(CGameHandler * gameHandler)
|
||||
|
||||
void NewTurnProcessor::handleTimeEvents(PlayerColor color)
|
||||
{
|
||||
for (auto const & event : gameHandler->gameState()->map->events)
|
||||
for (auto const & event : gameHandler->gameState()->getMap().events)
|
||||
{
|
||||
if (!event.occursToday(gameHandler->gameState()->day))
|
||||
continue;
|
||||
@@ -436,7 +436,7 @@ RumorState NewTurnProcessor::pickNewRumor()
|
||||
static const std::vector<RumorState::ERumorType> rumorTypes = {RumorState::TYPE_MAP, RumorState::TYPE_SPECIAL, RumorState::TYPE_RAND, RumorState::TYPE_RAND};
|
||||
std::vector<RumorState::ERumorTypeSpecial> sRumorTypes = {
|
||||
RumorState::RUMOR_OBELISKS, RumorState::RUMOR_ARTIFACTS, RumorState::RUMOR_ARMY, RumorState::RUMOR_INCOME};
|
||||
if(gameHandler->gameState()->map->grailPos.isValid()) // Grail should always be on map, but I had related crash I didn't manage to reproduce
|
||||
if(gameHandler->gameState()->getMap().grailPos.isValid()) // Grail should always be on map, but I had related crash I didn't manage to reproduce
|
||||
sRumorTypes.push_back(RumorState::RUMOR_GRAIL);
|
||||
|
||||
int rumorId = -1;
|
||||
@@ -455,7 +455,7 @@ RumorState NewTurnProcessor::pickNewRumor()
|
||||
rumorId = *RandomGeneratorUtil::nextItem(sRumorTypes, rand);
|
||||
if(rumorId == RumorState::RUMOR_GRAIL)
|
||||
{
|
||||
rumorExtra = gameHandler->gameState()->getTile(gameHandler->gameState()->map->grailPos)->getTerrainID().getNum();
|
||||
rumorExtra = gameHandler->gameState()->getTile(gameHandler->gameState()->getMap().grailPos)->getTerrainID().getNum();
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -484,9 +484,9 @@ RumorState NewTurnProcessor::pickNewRumor()
|
||||
}
|
||||
case RumorState::TYPE_MAP:
|
||||
// Makes sure that map rumors only used if there enough rumors too choose from
|
||||
if(!gameHandler->gameState()->map->rumors.empty() && (gameHandler->gameState()->map->rumors.size() > 1 || !gameHandler->gameState()->currentRumor.last.count(RumorState::TYPE_MAP)))
|
||||
if(!gameHandler->gameState()->getMap().rumors.empty() && (gameHandler->gameState()->getMap().rumors.size() > 1 || !gameHandler->gameState()->currentRumor.last.count(RumorState::TYPE_MAP)))
|
||||
{
|
||||
rumorId = rand.nextInt(gameHandler->gameState()->map->rumors.size() - 1);
|
||||
rumorId = rand.nextInt(gameHandler->gameState()->getMap().rumors.size() - 1);
|
||||
break;
|
||||
}
|
||||
else
|
||||
@@ -507,7 +507,7 @@ RumorState NewTurnProcessor::pickNewRumor()
|
||||
|
||||
std::tuple<EWeekType, CreatureID> NewTurnProcessor::pickWeekType(bool newMonth)
|
||||
{
|
||||
for (const CGTownInstance *t : gameHandler->gameState()->map->towns)
|
||||
for (const CGTownInstance *t : gameHandler->gameState()->getMap().towns)
|
||||
{
|
||||
if (t->hasBuilt(BuildingID::GRAIL, ETownType::INFERNO))
|
||||
return { EWeekType::DEITYOFFIRE, CreatureID::IMP };
|
||||
@@ -587,7 +587,7 @@ std::vector<SetMovePoints> NewTurnProcessor::updateHeroesMovementPoints()
|
||||
{
|
||||
auto ti = h->getTurnInfo(1);
|
||||
// NOTE: this code executed when bonuses of previous day not yet updated (this happen in NewTurn::applyGs). See issue 2356
|
||||
int32_t newMovementPoints = h->movementPointsLimitCached(gameHandler->gameState()->map->getTile(h->visitablePos()).isLand(), ti.get());
|
||||
int32_t newMovementPoints = h->movementPointsLimitCached(gameHandler->gameState()->getMap().getTile(h->visitablePos()).isLand(), ti.get());
|
||||
|
||||
if (newMovementPoints != h->movementPointsRemaining())
|
||||
result.emplace_back(h->id, newMovementPoints, true);
|
||||
@@ -666,7 +666,7 @@ NewTurn NewTurnProcessor::generateNewTurnPack()
|
||||
|
||||
if (newWeek)
|
||||
{
|
||||
for (CGTownInstance *t : gameHandler->gameState()->map->towns)
|
||||
for (CGTownInstance *t : gameHandler->gameState()->getMap().towns)
|
||||
n.availableCreatures.push_back(generateTownGrowth(t, n.specialWeek, n.creatureid, firstTurn));
|
||||
}
|
||||
|
||||
@@ -695,14 +695,14 @@ void NewTurnProcessor::onNewTurn()
|
||||
|
||||
if (newWeek)
|
||||
{
|
||||
for (CGTownInstance *t : gameHandler->gameState()->map->towns)
|
||||
for (CGTownInstance *t : gameHandler->gameState()->getMap().towns)
|
||||
if (t->hasBuilt(BuildingSubID::PORTAL_OF_SUMMONING))
|
||||
gameHandler->setPortalDwelling(t, true, (n.specialWeek == EWeekType::PLAGUE ? true : false)); //set creatures for Portal of Summoning
|
||||
}
|
||||
|
||||
if (newWeek && !firstTurn)
|
||||
{
|
||||
for (CGTownInstance *t : gameHandler->gameState()->map->towns)
|
||||
for (CGTownInstance *t : gameHandler->gameState()->getMap().towns)
|
||||
{
|
||||
if (!t->getOwner().isValidPlayer())
|
||||
updateNeutralTownGarrison(t, 1 + gameHandler->getDate(Date::DAY) / 7);
|
||||
|
@@ -627,7 +627,7 @@ void PlayerMessageProcessor::cheatPuzzleReveal(PlayerColor player)
|
||||
{
|
||||
TeamState *t = gameHandler->gameState()->getPlayerTeam(player);
|
||||
|
||||
for(auto & obj : gameHandler->gameState()->map->objects)
|
||||
for(auto & obj : gameHandler->gameState()->getMap().objects)
|
||||
{
|
||||
if(obj && obj->ID == Obj::OBELISK && !obj->wasVisited(player))
|
||||
{
|
||||
|
@@ -109,7 +109,7 @@ bool TurnOrderProcessor::playersInContact(PlayerColor left, PlayerColor right) c
|
||||
const auto * leftInfo = gameHandler->getPlayerState(left, false);
|
||||
const auto * rightInfo = gameHandler->getPlayerState(right, false);
|
||||
|
||||
for (auto obj : gameHandler->gameState()->map->objects)
|
||||
for (auto obj : gameHandler->gameState()->getMap().objects)
|
||||
{
|
||||
if (obj && obj->isVisitable())
|
||||
{
|
||||
|
Reference in New Issue
Block a user