1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-27 22:49:25 +02:00

Added GameSettings to gamestate, potentially allowing to define game

settings per map (or in random map template)
This commit is contained in:
Ivan Savenko
2024-08-31 11:00:36 +00:00
parent 6179521364
commit 8225eb454e
68 changed files with 432 additions and 293 deletions

View File

@@ -23,7 +23,7 @@
#include "texts/CGeneralTextHandler.h"
#include "StartInfo.h" // for StartInfo
#include "battle/BattleInfo.h" // for BattleInfo
#include "GameSettings.h"
#include "IGameSettings.h"
#include "TerrainHandler.h"
#include "spells/CSpellHandler.h"
#include "mapping/CMap.h"
@@ -274,6 +274,11 @@ bool CGameInfoCallback::getTownInfo(const CGObjectInstance * town, InfoAboutTown
return true;
}
const IGameSettings & CGameInfoCallback::getSettings() const
{
return gs->getSettings();
}
int3 CGameInfoCallback::guardingCreaturePosition (int3 pos) const //FIXME: redundant?
{
ERROR_RET_VAL_IF(!isVisible(pos), "Tile is not visible!", int3(-1,-1,-1));
@@ -626,7 +631,7 @@ EBuildingState CGameInfoCallback::canBuildStructure( const CGTownInstance *t, Bu
if (!t->genBuildingRequirements(ID).test(buildTest))
return EBuildingState::PREREQUIRES;
if(t->built >= VLC->settings()->getInteger(EGameSettings::TOWNS_BUILDINGS_PER_TURN_CAP))
if(t->built >= getSettings().getInteger(EGameSettings::TOWNS_BUILDINGS_PER_TURN_CAP))
return EBuildingState::CANT_BUILD_TODAY; //building limit
//checking resources