1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-06 09:09:40 +02:00

Merge CPrivilegedInfoCallback into CGameInfoCallback

This commit is contained in:
Ivan Savenko
2025-05-14 13:39:37 +03:00
parent b37a3dc63c
commit 6f20235d07
96 changed files with 345 additions and 384 deletions

View File

@@ -14,7 +14,7 @@
#include "../Goals/Goals.h"
#include "../AIGateway.h"
#include "../Engine/Nullkiller.h"
#include "../../../lib/callback/CPrivilegedInfoCallback.h"
#include "../../../lib/callback/CGameInfoCallback.h"
#include "../../../lib/mapping/CMap.h"
#include "../../../lib/mapObjects/MapObjects.h"
#include "../../../lib/pathfinder/CPathfinder.h"

View File

@@ -11,7 +11,7 @@
#include "AINodeStorage.h"
#include "Actions/TownPortalAction.h"
#include "../Goals/Goals.h"
#include "../../../lib/callback/CPrivilegedInfoCallback.h"
#include "../../../lib/callback/CGameInfoCallback.h"
#include "../../../lib/mapping/CMap.h"
#include "../../../lib/mapObjects/MapObjects.h"
#include "../../../lib/pathfinder/CPathfinder.h"

View File

@@ -13,7 +13,7 @@
#include <vcmi/Environment.h>
#include "../lib/callback/IClient.h"
#include "../lib/callback/CPrivilegedInfoCallback.h"
#include "../lib/callback/CGameInfoCallback.h"
#include "../lib/ConditionalWait.h"
#include "../lib/ResourceSet.h"
@@ -122,7 +122,7 @@ public:
};
/// Class which handles client - server logic
class CClient : public CPrivilegedInfoCallback, public Environment, public IClient
class CClient : public CGameInfoCallback, public Environment, public IClient
{
std::shared_ptr<CGameState> gamestate;
public:

View File

@@ -14,7 +14,7 @@
#include "CCreatureHandler.h"
#include "GameLibrary.h"
#include "IGameSettings.h"
#include "callback/CPrivilegedInfoCallback.h"
#include "callback/CGameInfoCallback.h"
#include "entities/hero/CHeroHandler.h"
#include "mapObjects/CGHeroInstance.h"
#include "modding/ModScope.h"
@@ -707,7 +707,7 @@ void CCreatureSet::serializeJson(JsonSerializeFormat & handler, const std::strin
}
}
CStackInstance::CStackInstance(CPrivilegedInfoCallback *cb, bool isHypothetic)
CStackInstance::CStackInstance(CGameInfoCallback *cb, bool isHypothetic)
: CBonusSystemNode(isHypothetic)
, CStackBasicDescriptor(nullptr, 0)
, CArtifactSet(cb)
@@ -719,7 +719,7 @@ CStackInstance::CStackInstance(CPrivilegedInfoCallback *cb, bool isHypothetic)
setNodeType(STACK_INSTANCE);
}
CStackInstance::CStackInstance(CPrivilegedInfoCallback *cb, const CreatureID & id, TQuantity Count, bool isHypothetic)
CStackInstance::CStackInstance(CGameInfoCallback *cb, const CreatureID & id, TQuantity Count, bool isHypothetic)
: CStackInstance(cb, false)
{
setType(id);
@@ -1034,11 +1034,11 @@ const IBonusBearer* CStackInstance::getBonusBearer() const
return this;
}
CCommanderInstance::CCommanderInstance(CPrivilegedInfoCallback *cb)
CCommanderInstance::CCommanderInstance(CGameInfoCallback *cb)
:CStackInstance(cb)
{}
CCommanderInstance::CCommanderInstance(CPrivilegedInfoCallback *cb, const CreatureID & id)
CCommanderInstance::CCommanderInstance(CGameInfoCallback *cb, const CreatureID & id)
: CStackInstance(cb)
, name("Commando")
{

View File

@@ -78,7 +78,7 @@ class DLL_LINKAGE CStackInstance : public CBonusSystemNode, public CStackBasicDe
CArmedInstance * armyInstance = nullptr; //stack must be part of some army, army must be part of some object
CPrivilegedInfoCallback * getCallback() const final { return cb; }
CGameInfoCallback * getCallback() const final { return cb; }
TExpType totalExperience;//commander needs same amount of exp as hero
public:
@@ -146,8 +146,8 @@ public:
virtual int getLevel() const; //different for regular stack and commander
CreatureID getCreatureID() const; //-1 if not available
std::string getName() const; //plural or singular
CStackInstance(CPrivilegedInfoCallback *cb, bool isHypothetic = false);
CStackInstance(CPrivilegedInfoCallback *cb, const CreatureID & id, TQuantity count, bool isHypothetic = false);
CStackInstance(CGameInfoCallback *cb, bool isHypothetic = false);
CStackInstance(CGameInfoCallback *cb, const CreatureID & id, TQuantity count, bool isHypothetic = false);
virtual ~CStackInstance() = default;
void setType(const CreatureID & creID);
@@ -182,8 +182,8 @@ public:
std::vector <ui8> secondarySkills; //ID -> level
std::set <ui8> specialSkills;
//std::vector <CArtifactInstance *> arts;
CCommanderInstance(CPrivilegedInfoCallback *cb);
CCommanderInstance(CPrivilegedInfoCallback *cb, const CreatureID & id);
CCommanderInstance(CGameInfoCallback *cb);
CCommanderInstance(CGameInfoCallback *cb, const CreatureID & id);
void setAlive (bool alive);
void levelUp ();

View File

@@ -85,7 +85,6 @@ set(lib_MAIN_SRCS
callback/CGameInfoCallback.cpp
callback/CNonConstInfoCallback.cpp
callback/CPlayerSpecificInfoCallback.cpp
callback/CPrivilegedInfoCallback.cpp
campaign/CampaignHandler.cpp
campaign/CampaignState.cpp
@@ -469,13 +468,12 @@ set(lib_MAIN_HEADERS
callback/CGlobalAI.h
callback/CNonConstInfoCallback.h
callback/CPlayerSpecificInfoCallback.h
callback/CPrivilegedInfoCallback.h
callback/GameCallbackHolder.h
callback/IBattleCallback.h
callback/IBattleEventsReceiver.h
callback/IClient.h
callback/IGameActionCallback.h
callback/CPrivilegedInfoCallback.h
callback/CGameInfoCallback.h
callback/IGameEventCallback.h
callback/IGameEventsReceiver.h
callback/IGameInfoCallback.h
@@ -831,7 +829,7 @@ endif()
if(MINGW AND CMAKE_BUILD_TYPE STREQUAL "Debug")
set_source_files_properties(
serializer/SerializerReflection.cpp
CPrivilegedInfoCallback.cpp
CGameInfoCallback.cpp
PROPERTIES
COMPILE_OPTIONS "-Wa,-mbig-obj")
endif()

View File

@@ -11,7 +11,7 @@
#include "CPlayerState.h"
#include "GameLibrary.h"
#include "callback/CPrivilegedInfoCallback.h"
#include "callback/CGameInfoCallback.h"
#include "mapObjects/CGHeroInstance.h"
#include "mapObjects/CGTownInstance.h"
#include "gameState/CGameState.h"
@@ -21,7 +21,7 @@
VCMI_LIB_NAMESPACE_BEGIN
PlayerState::PlayerState(CPrivilegedInfoCallback *cb)
PlayerState::PlayerState(CGameInfoCallback *cb)
: CBonusSystemNode(PLAYER)
, GameCallbackHolder(cb)
, color(-1)

View File

@@ -75,7 +75,7 @@ public:
std::optional<ui8> daysWithoutCastle;
TurnTimerInfo turnTimer;
PlayerState(CPrivilegedInfoCallback *cb);
PlayerState(CGameInfoCallback *cb);
~PlayerState();
std::string nodeName() const override;

View File

@@ -15,7 +15,7 @@
#include "bonuses/Limiters.h"
#include "bonuses/Updaters.h"
#include "../CStack.h"
#include "../callback/CPrivilegedInfoCallback.h"
#include "../callback/CGameInfoCallback.h"
#include "../entities/artifact/CArtifact.h"
#include "../entities/building/TownFortifications.h"
#include "../filesystem/Filesystem.h"
@@ -156,7 +156,7 @@ struct RangeGenerator
std::function<int()> myRand;
};
std::unique_ptr<BattleInfo> BattleInfo::setupBattle(CPrivilegedInfoCallback *cb, const int3 & tile, TerrainId terrain, const BattleField & battlefieldType, BattleSideArray<const CArmedInstance *> armies, BattleSideArray<const CGHeroInstance *> heroes, const BattleLayout & layout, const CGTownInstance * town)
std::unique_ptr<BattleInfo> BattleInfo::setupBattle(CGameInfoCallback *cb, const int3 & tile, TerrainId terrain, const BattleField & battlefieldType, BattleSideArray<const CArmedInstance *> armies, BattleSideArray<const CGHeroInstance *> heroes, const BattleLayout & layout, const CGTownInstance * town)
{
CMP_stack cmpst;
auto currentBattle = std::make_unique<BattleInfo>(cb, layout);
@@ -458,13 +458,13 @@ CStack * BattleInfo::getStack(int stackID, bool onlyAlive)
return const_cast<CStack *>(battleGetStackByID(stackID, onlyAlive));
}
BattleInfo::BattleInfo(CPrivilegedInfoCallback *cb, const BattleLayout & layout):
BattleInfo::BattleInfo(CGameInfoCallback *cb, const BattleLayout & layout):
BattleInfo(cb)
{
*this->layout = layout;
}
BattleInfo::BattleInfo(CPrivilegedInfoCallback *cb)
BattleInfo::BattleInfo(CGameInfoCallback *cb)
:GameCallbackHolder(cb),
sides({SideInBattle(cb), SideInBattle(cb)}),
layout(std::make_unique<BattleLayout>()),

View File

@@ -74,8 +74,8 @@ public:
}
//////////////////////////////////////////////////////////////////////////
BattleInfo(CPrivilegedInfoCallback *cb, const BattleLayout & layout);
BattleInfo(CPrivilegedInfoCallback *cb);
BattleInfo(CGameInfoCallback *cb, const BattleLayout & layout);
BattleInfo(CGameInfoCallback *cb);
virtual ~BattleInfo();
const IBattleInfo * getBattle() const override;
@@ -164,7 +164,7 @@ public:
const CGHeroInstance * getHero(const PlayerColor & player) const; //returns fighting hero that belongs to given player
void localInit();
static std::unique_ptr<BattleInfo> setupBattle(CPrivilegedInfoCallback *cb, const int3 & tile, TerrainId, const BattleField & battlefieldType, BattleSideArray<const CArmedInstance *> armies, BattleSideArray<const CGHeroInstance *> heroes, const BattleLayout & layout, const CGTownInstance * town);
static std::unique_ptr<BattleInfo> setupBattle(CGameInfoCallback *cb, const int3 & tile, TerrainId, const BattleField & battlefieldType, BattleSideArray<const CArmedInstance *> armies, BattleSideArray<const CGHeroInstance *> heroes, const BattleLayout & layout, const CGTownInstance * town);
BattleSide whatSide(const PlayerColor & player) const;

View File

@@ -12,18 +12,18 @@
#include "../GameSettings.h"
#include "../GameLibrary.h"
#include "../callback/CPrivilegedInfoCallback.h"
#include "../callback/CGameInfoCallback.h"
#include "../json/JsonNode.h"
#include "../mapObjects/CArmedInstance.h"
VCMI_LIB_NAMESPACE_BEGIN
BattleLayout BattleLayout::createDefaultLayout(CPrivilegedInfoCallback * cb, const CArmedInstance * attacker, const CArmedInstance * defender)
BattleLayout BattleLayout::createDefaultLayout(CGameInfoCallback * cb, const CArmedInstance * attacker, const CArmedInstance * defender)
{
return createLayout(cb, "default", attacker, defender);
}
BattleLayout BattleLayout::createLayout(CPrivilegedInfoCallback * cb, const std::string & layoutName, const CArmedInstance * attacker, const CArmedInstance * defender)
BattleLayout BattleLayout::createLayout(CGameInfoCallback * cb, const std::string & layoutName, const CArmedInstance * attacker, const CArmedInstance * defender)
{
const auto & loadHex = [](const JsonNode & node)
{

View File

@@ -17,7 +17,7 @@
VCMI_LIB_NAMESPACE_BEGIN
class CArmedInstance;
class CPrivilegedInfoCallback;
class CGameInfoCallback;
struct DLL_EXPORT BattleLayout
{
@@ -32,8 +32,8 @@ struct DLL_EXPORT BattleLayout
bool tacticsAllowed = false;
bool obstaclesAllowed = false;
static BattleLayout createDefaultLayout(CPrivilegedInfoCallback * cb, const CArmedInstance * attacker, const CArmedInstance * defender);
static BattleLayout createLayout(CPrivilegedInfoCallback * cb, const std::string & layoutName, const CArmedInstance * attacker, const CArmedInstance * defender);
static BattleLayout createDefaultLayout(CGameInfoCallback * cb, const CArmedInstance * attacker, const CArmedInstance * defender);
static BattleLayout createLayout(CGameInfoCallback * cb, const std::string & layoutName, const CArmedInstance * attacker, const CArmedInstance * defender);
};
VCMI_LIB_NAMESPACE_END

View File

@@ -10,7 +10,7 @@
#include "StdInc.h"
#include "SideInBattle.h"
#include "../callback/CPrivilegedInfoCallback.h"
#include "../callback/CGameInfoCallback.h"
#include "../mapObjects/CGHeroInstance.h"
VCMI_LIB_NAMESPACE_BEGIN

View File

@@ -832,4 +832,130 @@ bool CGameInfoCallback::isTeleportEntrancePassable(const CGTeleport * obj, Playe
return obj && obj->isEntrance() && !isTeleportChannelImpassable(obj->channel, player);
}
void CGameInfoCallback::getFreeTiles(std::vector<int3> & tiles) const
{
std::vector<int> floors;
floors.reserve(gameState().getMap().levels());
for(int b = 0; b < gameState().getMap().levels(); ++b)
{
floors.push_back(b);
}
const TerrainTile * tinfo = nullptr;
for (auto zd : floors)
{
for (int xd = 0; xd < gameState().getMap().width; xd++)
{
for (int yd = 0; yd < gameState().getMap().height; yd++)
{
tinfo = getTile(int3 (xd,yd,zd));
if (tinfo->isLand() && tinfo->getTerrain()->isPassable() && !tinfo->blocked()) //land and free
tiles.emplace_back(xd, yd, zd);
}
}
}
}
void CGameInfoCallback::getTilesInRange(std::unordered_set<int3> & tiles,
const int3 & pos,
int radious,
ETileVisibility mode,
std::optional<PlayerColor> player,
int3::EDistanceFormula distanceFormula) const
{
if(player.has_value() && !player->isValidPlayer())
{
logGlobal->error("Illegal call to getTilesInRange!");
return;
}
if(radious == CBuilding::HEIGHT_SKYSHIP) //reveal entire map
getAllTiles (tiles, player, -1, [](auto * tile){return true;});
else
{
const TeamState * team = !player ? nullptr : gameState().getPlayerTeam(*player);
for (int xd = std::max<int>(pos.x - radious , 0); xd <= std::min<int>(pos.x + radious, gameState().getMap().width - 1); xd++)
{
for (int yd = std::max<int>(pos.y - radious, 0); yd <= std::min<int>(pos.y + radious, gameState().getMap().height - 1); yd++)
{
int3 tilePos(xd,yd,pos.z);
int distance = pos.dist(tilePos, distanceFormula);
if(distance <= radious)
{
if(!player
|| (mode == ETileVisibility::HIDDEN && team->fogOfWarMap[pos.z][xd][yd] == 0)
|| (mode == ETileVisibility::REVEALED && team->fogOfWarMap[pos.z][xd][yd] == 1)
)
tiles.insert(int3(xd,yd,pos.z));
}
}
}
}
}
void CGameInfoCallback::getAllTiles(std::unordered_set<int3> & tiles, std::optional<PlayerColor> Player, int level, std::function<bool(const TerrainTile *)> filter) const
{
if(Player.has_value() && !Player->isValidPlayer())
{
logGlobal->error("Illegal call to getAllTiles !");
return;
}
std::vector<int> floors;
if(level == -1)
{
for(int b = 0; b < gameState().getMap().levels(); ++b)
{
floors.push_back(b);
}
}
else
floors.push_back(level);
for(auto zd: floors)
{
for(int xd = 0; xd < gameState().getMap().width; xd++)
{
for(int yd = 0; yd < gameState().getMap().height; yd++)
{
int3 coordinates(xd, yd, zd);
if (filter(getTile(coordinates)))
tiles.insert(coordinates);
}
}
}
}
void CGameInfoCallback::pickAllowedArtsSet(std::vector<ArtifactID> & out, vstd::RNG & rand)
{
for (int j = 0; j < 3 ; j++)
out.push_back(gameState().pickRandomArtifact(rand, EArtifactClass::ART_TREASURE));
for (int j = 0; j < 3 ; j++)
out.push_back(gameState().pickRandomArtifact(rand, EArtifactClass::ART_MINOR));
out.push_back(gameState().pickRandomArtifact(rand, EArtifactClass::ART_MAJOR));
}
void CGameInfoCallback::getAllowedSpells(std::vector<SpellID> & out, std::optional<ui16> level)
{
for (auto const & spellID : gameState().getMap().allowedSpells)
{
const auto * spell = spellID.toEntity(LIBRARY);
if (!isAllowed(spellID))
continue;
if (level.has_value() && spell->getLevel() != level)
continue;
out.push_back(spellID);
}
}
#if SCRIPTING_ENABLED
scripting::Pool * CGameInfoCallback::getGlobalContextPool() const
{
return nullptr; // TODO
}
#endif
VCMI_LIB_NAMESPACE_END

View File

@@ -36,18 +36,30 @@ class CGTeleport;
class CGTownInstance;
class IMarket;
#if SCRIPTING_ENABLED
namespace scripting
{
class Pool;
}
#endif
namespace vstd
{
class RNG;
}
class DLL_LINKAGE CGameInfoCallback : public IGameInfoCallback
{
protected:
virtual CGameState & gameState() = 0;
virtual const CGameState & gameState() const = 0;
bool hasAccess(std::optional<PlayerColor> playerId) const;
bool canGetFullInfo(const CGObjectInstance *obj) const; //true we player owns obj or ally owns obj or privileged mode
bool isOwnedOrVisited(const CGObjectInstance *obj) const;
public:
virtual CGameState & gameState() = 0;
virtual const CGameState & gameState() const = 0;
//various
int getDate(Date mode=Date::DAY)const override; //mode=0 - total days in game, mode=1 - day of week, mode=2 - current week, mode=3 - current month
const StartInfo * getStartInfo() const override;
@@ -135,6 +147,28 @@ public:
virtual bool isTeleportChannelBidirectional(TeleportChannelID id, PlayerColor player = PlayerColor::UNFLAGGABLE) const;
virtual bool isTeleportChannelUnidirectional(TeleportChannelID id, PlayerColor player = PlayerColor::UNFLAGGABLE) const;
virtual bool isTeleportEntrancePassable(const CGTeleport * obj, PlayerColor player) const;
//used for random spawns
void getFreeTiles(std::vector<int3> &tiles) const;
//mode 1 - only unrevealed tiles; mode 0 - all, mode -1 - only revealed
void getTilesInRange(std::unordered_set<int3> & tiles,
const int3 & pos,
int radius,
ETileVisibility mode,
std::optional<PlayerColor> player = std::optional<PlayerColor>(),
int3::EDistanceFormula formula = int3::DIST_2D) const;
//returns all tiles on given level (-1 - both levels, otherwise number of level)
void getAllTiles(std::unordered_set<int3> &tiles, std::optional<PlayerColor> player, int level, std::function<bool(const TerrainTile *)> filter) const;
//gives 3 treasures, 3 minors, 1 major -> used by Black Market and Artifact Merchant
void pickAllowedArtsSet(std::vector<ArtifactID> & out, vstd::RNG & rand);
void getAllowedSpells(std::vector<SpellID> &out, std::optional<ui16> level = std::nullopt);
#if SCRIPTING_ENABLED
virtual scripting::Pool * getGlobalContextPool() const;
#endif
};
VCMI_LIB_NAMESPACE_END

View File

@@ -9,7 +9,7 @@
*/
#pragma once
#include "CPrivilegedInfoCallback.h"
#include "CGameInfoCallback.h"
#include <vcmi/Metatype.h>
@@ -17,7 +17,7 @@ VCMI_LIB_NAMESPACE_BEGIN
class JsonNode;
class DLL_LINKAGE CNonConstInfoCallback : public CPrivilegedInfoCallback
class DLL_LINKAGE CNonConstInfoCallback : public CGameInfoCallback
{
public:
//keep const version of callback accessible

View File

@@ -1,141 +0,0 @@
/*
* CPrivilegedInfoCallback.cpp, part of VCMI engine
*
* Authors: listed in file AUTHORS in main folder
*
* License: GNU General Public License v2.0 or later
* Full text of license available in license.txt file, in main folder
*
*/
#include "StdInc.h"
#include "CPrivilegedInfoCallback.h"
#include "../CPlayerState.h"
#include "../entities/artifact/EArtifactClass.h"
#include "../entities/building/CBuilding.h"
#include "../gameState/CGameState.h"
#include "../mapping/CMap.h"
#include "../spells/CSpellHandler.h"
VCMI_LIB_NAMESPACE_BEGIN
void CPrivilegedInfoCallback::getFreeTiles(std::vector<int3> & tiles) const
{
std::vector<int> floors;
floors.reserve(gameState().getMap().levels());
for(int b = 0; b < gameState().getMap().levels(); ++b)
{
floors.push_back(b);
}
const TerrainTile * tinfo = nullptr;
for (auto zd : floors)
{
for (int xd = 0; xd < gameState().getMap().width; xd++)
{
for (int yd = 0; yd < gameState().getMap().height; yd++)
{
tinfo = getTile(int3 (xd,yd,zd));
if (tinfo->isLand() && tinfo->getTerrain()->isPassable() && !tinfo->blocked()) //land and free
tiles.emplace_back(xd, yd, zd);
}
}
}
}
void CPrivilegedInfoCallback::getTilesInRange(std::unordered_set<int3> & tiles,
const int3 & pos,
int radious,
ETileVisibility mode,
std::optional<PlayerColor> player,
int3::EDistanceFormula distanceFormula) const
{
if(!!player && !player->isValidPlayer())
{
logGlobal->error("Illegal call to getTilesInRange!");
return;
}
if(radious == CBuilding::HEIGHT_SKYSHIP) //reveal entire map
getAllTiles (tiles, player, -1, [](auto * tile){return true;});
else
{
const TeamState * team = !player ? nullptr : gameState().getPlayerTeam(*player);
for (int xd = std::max<int>(pos.x - radious , 0); xd <= std::min<int>(pos.x + radious, gameState().getMap().width - 1); xd++)
{
for (int yd = std::max<int>(pos.y - radious, 0); yd <= std::min<int>(pos.y + radious, gameState().getMap().height - 1); yd++)
{
int3 tilePos(xd,yd,pos.z);
int distance = pos.dist(tilePos, distanceFormula);
if(distance <= radious)
{
if(!player
|| (mode == ETileVisibility::HIDDEN && team->fogOfWarMap[pos.z][xd][yd] == 0)
|| (mode == ETileVisibility::REVEALED && team->fogOfWarMap[pos.z][xd][yd] == 1)
)
tiles.insert(int3(xd,yd,pos.z));
}
}
}
}
}
void CPrivilegedInfoCallback::getAllTiles(std::unordered_set<int3> & tiles, std::optional<PlayerColor> Player, int level, std::function<bool(const TerrainTile *)> filter) const
{
if(!!Player && !Player->isValidPlayer())
{
logGlobal->error("Illegal call to getAllTiles !");
return;
}
std::vector<int> floors;
if(level == -1)
{
for(int b = 0; b < gameState().getMap().levels(); ++b)
{
floors.push_back(b);
}
}
else
floors.push_back(level);
for(auto zd: floors)
{
for(int xd = 0; xd < gameState().getMap().width; xd++)
{
for(int yd = 0; yd < gameState().getMap().height; yd++)
{
int3 coordinates(xd, yd, zd);
if (filter(getTile(coordinates)))
tiles.insert(coordinates);
}
}
}
}
void CPrivilegedInfoCallback::pickAllowedArtsSet(std::vector<ArtifactID> & out, vstd::RNG & rand)
{
for (int j = 0; j < 3 ; j++)
out.push_back(gameState().pickRandomArtifact(rand, EArtifactClass::ART_TREASURE));
for (int j = 0; j < 3 ; j++)
out.push_back(gameState().pickRandomArtifact(rand, EArtifactClass::ART_MINOR));
out.push_back(gameState().pickRandomArtifact(rand, EArtifactClass::ART_MAJOR));
}
void CPrivilegedInfoCallback::getAllowedSpells(std::vector<SpellID> & out, std::optional<ui16> level)
{
for (auto const & spellID : gameState().getMap().allowedSpells)
{
const auto * spell = spellID.toEntity(LIBRARY);
if (!isAllowed(spellID))
continue;
if (level.has_value() && spell->getLevel() != level)
continue;
out.push_back(spellID);
}
}
VCMI_LIB_NAMESPACE_END

View File

@@ -1,56 +0,0 @@
/*
* CPrivilegedInfoCallback.h, part of VCMI engine
*
* Authors: listed in file AUTHORS in main folder
*
* License: GNU General Public License v2.0 or later
* Full text of license available in license.txt file, in main folder
*
*/
#pragma once
#include "CGameInfoCallback.h"
VCMI_LIB_NAMESPACE_BEGIN
namespace vstd
{
class RNG;
}
#if SCRIPTING_ENABLED
namespace scripting
{
class Pool;
}
#endif
class DLL_LINKAGE CPrivilegedInfoCallback : public CGameInfoCallback
{
public:
#if SCRIPTING_ENABLED
virtual scripting::Pool * getGlobalContextPool() const = 0;
#endif
using CGameInfoCallback::gameState; // make public
//used for random spawns
void getFreeTiles(std::vector<int3> &tiles) const;
//mode 1 - only unrevealed tiles; mode 0 - all, mode -1 - only revealed
void getTilesInRange(std::unordered_set<int3> & tiles,
const int3 & pos,
int radius,
ETileVisibility mode,
std::optional<PlayerColor> player = std::optional<PlayerColor>(),
int3::EDistanceFormula formula = int3::DIST_2D) const;
//returns all tiles on given level (-1 - both levels, otherwise number of level)
void getAllTiles(std::unordered_set<int3> &tiles, std::optional<PlayerColor> player, int level, std::function<bool(const TerrainTile *)> filter) const;
//gives 3 treasures, 3 minors, 1 major -> used by Black Market and Artifact Merchant
void pickAllowedArtsSet(std::vector<ArtifactID> & out, vstd::RNG & rand);
void getAllowedSpells(std::vector<SpellID> &out, std::optional<ui16> level = std::nullopt);
};
VCMI_LIB_NAMESPACE_END

View File

@@ -11,14 +11,14 @@
VCMI_LIB_NAMESPACE_BEGIN
class CPrivilegedInfoCallback;
class CGameInfoCallback;
class DLL_LINKAGE GameCallbackHolder
{
public:
CPrivilegedInfoCallback * cb;
CGameInfoCallback * cb;
explicit GameCallbackHolder(CPrivilegedInfoCallback *cb):
explicit GameCallbackHolder(CGameInfoCallback *cb):
cb(cb)
{}
};

View File

@@ -420,7 +420,7 @@ std::optional<ui8> CampaignState::getBonusID(CampaignScenarioID which) const
return chosenCampaignBonuses.at(which);
}
std::unique_ptr<CMap> CampaignState::getMap(CampaignScenarioID scenarioId, CPrivilegedInfoCallback * cb)
std::unique_ptr<CMap> CampaignState::getMap(CampaignScenarioID scenarioId, CGameInfoCallback * cb)
{
// FIXME: there is certainly better way to handle maps inside campaigns
if(scenarioId == CampaignScenarioID::NONE)

View File

@@ -28,7 +28,7 @@ class CMap;
class CMapHeader;
class CMapInfo;
class JsonNode;
class CPrivilegedInfoCallback;
class CGameInfoCallback;
class DLL_LINKAGE CampaignRegions
{
@@ -338,7 +338,7 @@ public:
/// Returns true if all available scenarios have been completed and campaign is finished
bool isCampaignFinished() const;
std::unique_ptr<CMap> getMap(CampaignScenarioID scenarioId, CPrivilegedInfoCallback * cb);
std::unique_ptr<CMap> getMap(CampaignScenarioID scenarioId, CGameInfoCallback * cb);
std::unique_ptr<CMapHeader> getMapHeader(CampaignScenarioID scenarioId) const;
std::shared_ptr<CMapInfo> getMapInfo(CampaignScenarioID scenarioId) const;

View File

@@ -11,11 +11,11 @@
#include "StdInc.h"
#include "ArtSlotInfo.h"
#include "../../callback/CPrivilegedInfoCallback.h"
#include "../../callback/CGameInfoCallback.h"
VCMI_LIB_NAMESPACE_BEGIN
ArtSlotInfo::ArtSlotInfo(CPrivilegedInfoCallback * cb)
ArtSlotInfo::ArtSlotInfo(CGameInfoCallback * cb)
: GameCallbackHolder(cb)
{
}

View File

@@ -21,7 +21,7 @@ struct DLL_LINKAGE ArtSlotInfo : public GameCallbackHolder
ArtifactInstanceID artifactID;
bool locked = false; //if locked, then artifact points to the combined artifact
explicit ArtSlotInfo(CPrivilegedInfoCallback * cb);
explicit ArtSlotInfo(CGameInfoCallback * cb);
ArtSlotInfo(const CArtifactInstance * artifact, bool locked);
const CArtifactInstance * getArt() const;

View File

@@ -13,7 +13,7 @@
VCMI_LIB_NAMESPACE_BEGIN
CArtifactFittingSet::CArtifactFittingSet(CPrivilegedInfoCallback *cb, ArtBearer bearer)
CArtifactFittingSet::CArtifactFittingSet(CGameInfoCallback *cb, ArtBearer bearer)
: CArtifactSet(cb)
, GameCallbackHolder(cb)
, bearer(bearer)

View File

@@ -18,13 +18,13 @@ VCMI_LIB_NAMESPACE_BEGIN
// Used to try on artifacts before the claimed changes have been applied
class DLL_LINKAGE CArtifactFittingSet : public CArtifactSet, public GameCallbackHolder
{
CPrivilegedInfoCallback * getCallback() const final
CGameInfoCallback * getCallback() const final
{
return cb;
}
public:
CArtifactFittingSet(CPrivilegedInfoCallback * cb, ArtBearer Bearer);
CArtifactFittingSet(CGameInfoCallback * cb, ArtBearer Bearer);
explicit CArtifactFittingSet(const CArtifactSet & artSet);
ArtBearer bearerType() const override;

View File

@@ -14,7 +14,7 @@
#include "CArtifact.h"
#include "CArtifactSet.h"
#include "../../callback/CPrivilegedInfoCallback.h"
#include "../../callback/CGameInfoCallback.h"
#include "../../gameState/CGameState.h"
VCMI_LIB_NAMESPACE_BEGIN
@@ -125,13 +125,13 @@ void CGrowingArtifactInstance::growingUp()
}
}
CArtifactInstance::CArtifactInstance(CPrivilegedInfoCallback *cb, const CArtifact * art)
CArtifactInstance::CArtifactInstance(CGameInfoCallback *cb, const CArtifact * art)
:CArtifactInstance(cb)
{
setType(art);
}
CArtifactInstance::CArtifactInstance(CPrivilegedInfoCallback *cb)
CArtifactInstance::CArtifactInstance(CGameInfoCallback *cb)
: CBonusSystemNode(ARTIFACT_INSTANCE)
, CCombinedArtifactInstance(cb)
{

View File

@@ -82,8 +82,8 @@ class DLL_LINKAGE CArtifactInstance final
ArtifactID artTypeID;
public:
CArtifactInstance(CPrivilegedInfoCallback *cb, const CArtifact * art);
CArtifactInstance(CPrivilegedInfoCallback *cb);
CArtifactInstance(CGameInfoCallback *cb, const CArtifact * art);
CArtifactInstance(CGameInfoCallback *cb);
void setType(const CArtifact * art);
std::string nodeName() const override;
ArtifactID getTypeId() const;

View File

@@ -184,7 +184,7 @@ CArtifactSet::ArtPlacementMap CArtifactSet::putArtifact(const ArtifactPosition &
return resArtPlacement;
}
CArtifactSet::CArtifactSet(CPrivilegedInfoCallback * cb)
CArtifactSet::CArtifactSet(CGameInfoCallback * cb)
:artifactsTransitionPos(cb)
{}

View File

@@ -40,11 +40,11 @@ public:
bool hasScroll(const SpellID & aid, bool onlyWorn = false) const;
bool isPositionFree(const ArtifactPosition & pos, bool onlyLockCheck = false) const;
virtual CPrivilegedInfoCallback * getCallback() const = 0;
virtual CGameInfoCallback * getCallback() const = 0;
virtual ArtBearer bearerType() const = 0;
virtual ArtPlacementMap putArtifact(const ArtifactPosition & slot, const CArtifactInstance * art);
virtual void removeArtifact(const ArtifactPosition & slot);
CArtifactSet(CPrivilegedInfoCallback * cb);
CArtifactSet(CGameInfoCallback * cb);
virtual ~CArtifactSet() = default;
template <typename Handler> void serialize(Handler &h)

View File

@@ -31,7 +31,7 @@
#include "../bonuses/Propagators.h"
#include "../bonuses/Updaters.h"
#include "../battle/BattleInfo.h"
#include "../callback/CPrivilegedInfoCallback.h"
#include "../callback/CGameInfoCallback.h"
#include "../campaign/CampaignState.h"
#include "../constants/StringConstants.h"
#include "../entities/artifact/ArtifactUtils.h"
@@ -150,7 +150,7 @@ int CGameState::getDate(Date mode) const
return getDate(day, mode);
}
CGameState::CGameState(CPrivilegedInfoCallback * callback)
CGameState::CGameState(CGameInfoCallback * callback)
: GameCallbackHolder(callback)
{
heroesPool = std::make_unique<TavernHeroesPool>(this);

View File

@@ -68,7 +68,7 @@ public:
/// list of players currently making turn. Usually - just one, except for simturns
std::set<PlayerColor> actingPlayers;
CGameState(CPrivilegedInfoCallback * callback);
CGameState(CGameInfoCallback * callback);
virtual ~CGameState();
CGameState & gameState() final { return *this; }
@@ -240,7 +240,7 @@ private:
/// Pointer to campaign state manager. Nullptr for single scenarios
std::unique_ptr<CGameStateCampaign> campaign;
friend class CPrivilegedInfoCallback;
friend class CGameInfoCallback;
friend class CMapHandler;
friend class CGameHandler;
};

View File

@@ -18,7 +18,7 @@
#include "JsonBonus.h"
#include "../callback/CPrivilegedInfoCallback.h"
#include "../callback/CGameInfoCallback.h"
#include "../constants/StringConstants.h"
#include "../GameLibrary.h"
#include "../CCreatureHandler.h"

View File

@@ -23,7 +23,7 @@ class RNG;
class ObjectTemplate;
class CGObjectInstance;
class IObjectInfo;
class CPrivilegedInfoCallback;
class CGameInfoCallback;
/// Class responsible for creation of objects of specific type & subtype
class DLL_LINKAGE AObjectTypeHandler : public boost::noncopyable
@@ -118,7 +118,7 @@ public:
/// Creates object and set up core properties (like ID/subID). Object is NOT initialized
/// to allow creating objects before game start (e.g. map loading)
virtual std::shared_ptr<CGObjectInstance> create(CPrivilegedInfoCallback * cb, std::shared_ptr<const ObjectTemplate> tmpl) const = 0;
virtual std::shared_ptr<CGObjectInstance> create(CGameInfoCallback * cb, std::shared_ptr<const ObjectTemplate> tmpl) const = 0;
/// Configures object properties. Should be re-entrable, resetting state of the object if necessarily
/// This should set remaining properties, including randomized or depending on map

View File

@@ -27,7 +27,7 @@ class CDefaultObjectTypeHandler : public AObjectTypeHandler
randomizeObject(castedObject, rng);
}
std::shared_ptr<CGObjectInstance> create(CPrivilegedInfoCallback * cb, std::shared_ptr<const ObjectTemplate> tmpl) const final
std::shared_ptr<CGObjectInstance> create(CGameInfoCallback * cb, std::shared_ptr<const ObjectTemplate> tmpl) const final
{
auto result = createObject(cb);
@@ -44,7 +44,7 @@ class CDefaultObjectTypeHandler : public AObjectTypeHandler
protected:
virtual void initializeObject(ObjectType * object) const {}
virtual void randomizeObject(ObjectType * object, vstd::RNG & rng) const {}
virtual std::shared_ptr<ObjectType> createObject(CPrivilegedInfoCallback * cb) const
virtual std::shared_ptr<ObjectType> createObject(CGameInfoCallback * cb) const
{
return std::make_shared<ObjectType>(cb);
}

View File

@@ -37,7 +37,7 @@ bool CRewardableConstructor::hasNameTextID() const
return !objectInfo.getParameters()["name"].isNull();
}
std::shared_ptr<CGObjectInstance> CRewardableConstructor::create(CPrivilegedInfoCallback * cb, std::shared_ptr<const ObjectTemplate> tmpl) const
std::shared_ptr<CGObjectInstance> CRewardableConstructor::create(CGameInfoCallback * cb, std::shared_ptr<const ObjectTemplate> tmpl) const
{
auto ret = std::make_shared<CRewardableObject>(cb);
preInitObject(ret.get());
@@ -55,7 +55,7 @@ void CRewardableConstructor::assignBonuses(std::vector<Bonus> & bonuses, MapObje
}
}
Rewardable::Configuration CRewardableConstructor::generateConfiguration(CPrivilegedInfoCallback * cb, vstd::RNG & rand, MapObjectID objectID, const std::map<std::string, JsonNode> & presetVariables) const
Rewardable::Configuration CRewardableConstructor::generateConfiguration(CGameInfoCallback * cb, vstd::RNG & rand, MapObjectID objectID, const std::map<std::string, JsonNode> & presetVariables) const
{
Rewardable::Configuration result;
result.variables.preset = presetVariables;

View File

@@ -28,13 +28,13 @@ class DLL_LINKAGE CRewardableConstructor : public AObjectTypeHandler
public:
bool hasNameTextID() const override;
std::shared_ptr<CGObjectInstance> create(CPrivilegedInfoCallback * cb, std::shared_ptr<const ObjectTemplate> tmpl = nullptr) const override;
std::shared_ptr<CGObjectInstance> create(CGameInfoCallback * cb, std::shared_ptr<const ObjectTemplate> tmpl = nullptr) const override;
void configureObject(CGObjectInstance * object, vstd::RNG & rng) const override;
std::unique_ptr<IObjectInfo> getObjectInfo(std::shared_ptr<const ObjectTemplate> tmpl) const override;
Rewardable::Configuration generateConfiguration(CPrivilegedInfoCallback * cb, vstd::RNG & rand, MapObjectID objectID, const std::map<std::string, JsonNode> & presetVariables) const;
Rewardable::Configuration generateConfiguration(CGameInfoCallback * cb, vstd::RNG & rand, MapObjectID objectID, const std::map<std::string, JsonNode> & presetVariables) const;
};
VCMI_LIB_NAMESPACE_END

View File

@@ -17,7 +17,7 @@
#include "../GameLibrary.h"
#include "../CConfigHandler.h"
#include "../callback/CPrivilegedInfoCallback.h"
#include "../callback/CGameInfoCallback.h"
#include "../entities/faction/CTownHandler.h"
#include "../entities/hero/CHeroClass.h"
#include "../json/JsonUtils.h"
@@ -318,7 +318,7 @@ bool MarketInstanceConstructor::hasDescription() const
return !descriptionTextID.empty();
}
std::shared_ptr<CGMarket> MarketInstanceConstructor::createObject(CPrivilegedInfoCallback * cb) const
std::shared_ptr<CGMarket> MarketInstanceConstructor::createObject(CGameInfoCallback * cb) const
{
if(marketModes.size() == 1)
{

View File

@@ -137,7 +137,7 @@ class MarketInstanceConstructor : public CDefaultObjectTypeHandler<CGMarket>
void initTypeData(const JsonNode & config) override;
public:
std::shared_ptr<CGMarket> createObject(CPrivilegedInfoCallback * cb) const override;
std::shared_ptr<CGMarket> createObject(CGameInfoCallback * cb) const override;
void randomizeObject(CGMarket * object, vstd::RNG & rng) const override;
const std::set<EMarketMode> & availableModes() const;

View File

@@ -13,7 +13,7 @@
#include "../CCreatureHandler.h"
#include "../CPlayerState.h"
#include "../callback/CPrivilegedInfoCallback.h"
#include "../callback/CGameInfoCallback.h"
#include "../entities/faction/CFaction.h"
#include "../entities/faction/CTown.h"
#include "../entities/faction/CTownHandler.h"
@@ -41,12 +41,12 @@ void CArmedInstance::randomizeArmy(FactionID type)
}
}
CArmedInstance::CArmedInstance(CPrivilegedInfoCallback *cb)
CArmedInstance::CArmedInstance(CGameInfoCallback *cb)
:CArmedInstance(cb, false)
{
}
CArmedInstance::CArmedInstance(CPrivilegedInfoCallback *cb, bool isHypothetic):
CArmedInstance::CArmedInstance(CGameInfoCallback *cb, bool isHypothetic):
CGObjectInstance(cb),
CBonusSystemNode(isHypothetic),
nonEvilAlignmentMix(this, Selector::type()(BonusType::NONEVIL_ALIGNMENT_MIX)), // Take Angelic Alliance troop-mixing freedom of non-evil units into account.

View File

@@ -50,8 +50,8 @@ public:
void restoreBonusSystem(CGameState & gs) override;
//////////////////////////////////////////////////////////////////////////
CArmedInstance(CPrivilegedInfoCallback *cb);
CArmedInstance(CPrivilegedInfoCallback *cb, bool isHypothetic);
CArmedInstance(CGameInfoCallback *cb);
CArmedInstance(CGameInfoCallback *cb, bool isHypothetic);
PlayerColor getOwner() const override
{

View File

@@ -15,7 +15,7 @@
#include "../texts/CGeneralTextHandler.h"
#include "../CConfigHandler.h"
#include "../IGameSettings.h"
#include "../callback/CPrivilegedInfoCallback.h"
#include "../callback/CGameInfoCallback.h"
#include "../callback/IGameEventCallback.h"
#include "../gameState/CGameState.h"
#include "../mapObjectConstructors/CObjectClassesHandler.h"

View File

@@ -10,7 +10,7 @@
#include "StdInc.h"
#include "CGDwelling.h"
#include "../callback/CPrivilegedInfoCallback.h"
#include "../callback/CGameInfoCallback.h"
#include "../callback/IGameEventCallback.h"
#include "../serializer/JsonSerializeFormat.h"
#include "../entities/faction/CTownHandler.h"
@@ -47,7 +47,7 @@ void CGDwellingRandomizationInfo::serializeJson(JsonSerializeFormat & handler)
}
}
CGDwelling::CGDwelling(CPrivilegedInfoCallback *cb):
CGDwelling::CGDwelling(CGameInfoCallback *cb):
CArmedInstance(cb)
{}

View File

@@ -39,7 +39,7 @@ public:
std::optional<CGDwellingRandomizationInfo> randomizationInfo; //random dwelling options; not serialized
TCreaturesSet creatures; //creatures[level] -> <vector of alternative ids (base creature and upgrades, creatures amount>
CGDwelling(CPrivilegedInfoCallback *cb);
CGDwelling(CGameInfoCallback *cb);
~CGDwelling() override;
const IOwnableObject * asOwnable() const final;

View File

@@ -15,7 +15,7 @@
#include <vcmi/spells/Spell.h>
#include <vstd/RNG.h>
#include "../callback/CPrivilegedInfoCallback.h"
#include "../callback/CGameInfoCallback.h"
#include "../callback/IGameEventCallback.h"
#include "../texts/CGeneralTextHandler.h"
#include "../TerrainHandler.h"
@@ -254,7 +254,7 @@ int CGHeroInstance::movementPointsLimitCached(bool onLand, const TurnInfo * ti)
return ti->getMovePointsLimitWater();
}
CGHeroInstance::CGHeroInstance(CPrivilegedInfoCallback * cb)
CGHeroInstance::CGHeroInstance(CGameInfoCallback * cb)
: CArmedInstance(cb),
CArtifactSet(cb),
tacticFormationEnabled(false),

View File

@@ -72,7 +72,7 @@ class DLL_LINKAGE CGHeroInstance : public CArmedInstance, public IBoatGenerator,
ui32 movement; //remaining movement points
bool inTownGarrison; // if hero is in town garrison
CPrivilegedInfoCallback * getCallback() const final { return cb; }
CGameInfoCallback * getCallback() const final { return cb; }
public:
//////////////////////////////////////////////////////////////////////////
@@ -281,7 +281,7 @@ public:
/// If this hero perishes, the scenario is failed
bool isMissionCritical() const;
CGHeroInstance(CPrivilegedInfoCallback *cb);
CGHeroInstance(CGameInfoCallback *cb);
virtual ~CGHeroInstance();
PlayerColor getOwner() const override;

View File

@@ -11,7 +11,7 @@
#include "StdInc.h"
#include "CGMarket.h"
#include "../callback/CPrivilegedInfoCallback.h"
#include "../callback/CGameInfoCallback.h"
#include "../callback/IGameEventCallback.h"
#include "../texts/CGeneralTextHandler.h"
#include "../CCreatureHandler.h"
@@ -78,7 +78,7 @@ std::set<EMarketMode> CGMarket::availableModes() const
return getMarketHandler()->availableModes();
}
CGMarket::CGMarket(CPrivilegedInfoCallback *cb)
CGMarket::CGMarket(CGameInfoCallback *cb)
: CGObjectInstance(cb)
, IMarket(cb)
{}

View File

@@ -22,7 +22,7 @@ protected:
std::shared_ptr<MarketInstanceConstructor> getMarketHandler() const;
public:
CGMarket(CPrivilegedInfoCallback *cb);
CGMarket(CGameInfoCallback *cb);
///IObjectInterface
void onHeroVisit(IGameEventCallback & gameEvents, const CGHeroInstance * h) const override; //open trading window
void initObj(vstd::RNG & rand) override;//set skills for trade

View File

@@ -14,7 +14,7 @@
#include "CGHeroInstance.h"
#include "ObjectTemplate.h"
#include "../callback/CPrivilegedInfoCallback.h"
#include "../callback/CGameInfoCallback.h"
#include "../callback/IGameEventCallback.h"
#include "../gameState/CGameState.h"
#include "../texts/CGeneralTextHandler.h"
@@ -31,7 +31,7 @@
VCMI_LIB_NAMESPACE_BEGIN
//TODO: remove constructor
CGObjectInstance::CGObjectInstance(CPrivilegedInfoCallback *cb):
CGObjectInstance::CGObjectInstance(CGameInfoCallback *cb):
IObjectInterface(cb),
pos(-1,-1,-1),
ID(Obj::NO_OBJ),

View File

@@ -45,7 +45,7 @@ public:
std::string instanceName;
CGObjectInstance(CPrivilegedInfoCallback *cb);
CGObjectInstance(CGameInfoCallback *cb);
~CGObjectInstance() override;
MapObjectID getObjGroupIndex() const override;

View File

@@ -18,7 +18,7 @@
#include "../CSkillHandler.h"
#include "../StartInfo.h"
#include "../callback/CPrivilegedInfoCallback.h"
#include "../callback/CGameInfoCallback.h"
#include "../callback/IGameEventCallback.h"
#include "../constants/StringConstants.h"
#include "../networkPacks/PacksForClient.h"

View File

@@ -11,7 +11,7 @@
#include "StdInc.h"
#include "CGResource.h"
#include "../callback/CPrivilegedInfoCallback.h"
#include "../callback/CGameInfoCallback.h"
#include "../callback/IGameEventCallback.h"
#include "../mapObjectConstructors/CommonConstructors.h"
#include "../texts/CGeneralTextHandler.h"

View File

@@ -24,7 +24,7 @@
#include "../CPlayerState.h"
#include "../StartInfo.h"
#include "../TerrainHandler.h"
#include "../callback/CPrivilegedInfoCallback.h"
#include "../callback/CGameInfoCallback.h"
#include "../callback/IGameEventCallback.h"
#include "../entities/building/CBuilding.h"
#include "../entities/faction/CTownHandler.h"
@@ -264,7 +264,7 @@ TownFortifications CGTownInstance::fortificationsLevel() const
return result;
}
CGTownInstance::CGTownInstance(CPrivilegedInfoCallback *cb):
CGTownInstance::CGTownInstance(CGameInfoCallback *cb):
CGDwelling(cb),
IMarket(cb),
built(0),

View File

@@ -207,7 +207,7 @@ public:
/// Returns true if provided war machine is available in any of built buildings of this town
bool isWarMachineAvailable(ArtifactID) const;
CGTownInstance(CPrivilegedInfoCallback *cb);
CGTownInstance(CGameInfoCallback *cb);
virtual ~CGTownInstance();
///IObjectInterface overrides

View File

@@ -17,7 +17,7 @@
#include "../texts/CGeneralTextHandler.h"
#include "CGCreature.h"
#include "../IGameSettings.h"
#include "../callback/CPrivilegedInfoCallback.h"
#include "../callback/CGameInfoCallback.h"
#include "../callback/IGameEventCallback.h"
#include "../entities/artifact/CArtifact.h"
#include "../entities/hero/CHeroHandler.h"

View File

@@ -14,7 +14,7 @@
#include "../CPlayerState.h"
#include "../IGameSettings.h"
#include "../battle/BattleLayout.h"
#include "../callback/CPrivilegedInfoCallback.h"
#include "../callback/CGameInfoCallback.h"
#include "../callback/IGameEventCallback.h"
#include "../gameState/CGameState.h"
#include "../mapObjectConstructors/AObjectTypeHandler.h"
@@ -355,7 +355,7 @@ void CRewardableObject::initObj(vstd::RNG & rand)
getObjectHandler()->configureObject(this, rand);
}
CRewardableObject::CRewardableObject(CPrivilegedInfoCallback *cb)
CRewardableObject::CRewardableObject(CGameInfoCallback *cb)
:CArmedInstance(cb)
{}

View File

@@ -77,7 +77,7 @@ public:
void setPropertyDer(ObjProperty what, ObjPropertyID identifier) override;
CRewardableObject(CPrivilegedInfoCallback *cb);
CRewardableObject(CGameInfoCallback *cb);
std::string getHoverText(PlayerColor player) const override;
std::string getHoverText(const CGHeroInstance * hero) const override;

View File

@@ -14,7 +14,7 @@
#include "CGHeroInstance.h"
#include "../CPlayerState.h"
#include "../callback/CPrivilegedInfoCallback.h"
#include "../callback/CGameInfoCallback.h"
#include "../callback/IGameEventCallback.h"
#include "../gameState/CGameState.h"
#include "../mapObjectConstructors/FlaggableInstanceConstructor.h"

View File

@@ -140,7 +140,7 @@ int IMarket::availableUnits(const EMarketMode mode, const int marketItemSerial)
}
}
IMarket::IMarket(CPrivilegedInfoCallback *cb)
IMarket::IMarket(CGameInfoCallback *cb)
:altarArtifactsStorage(std::make_unique<CArtifactSetAltar>(cb))
{
}

View File

@@ -18,19 +18,19 @@ VCMI_LIB_NAMESPACE_BEGIN
class DLL_LINKAGE IMarket : public virtual Serializeable, boost::noncopyable
{
public:
explicit IMarket(CPrivilegedInfoCallback *cb);
explicit IMarket(CGameInfoCallback *cb);
~IMarket();
class CArtifactSetAltar : public CArtifactSet
{
CPrivilegedInfoCallback *cb;
CGameInfoCallback *cb;
public:
CArtifactSetAltar(CPrivilegedInfoCallback *cb)
CArtifactSetAltar(CGameInfoCallback *cb)
: CArtifactSet(cb)
, cb(cb)
{}
CPrivilegedInfoCallback * getCallback() const override {return cb;};
CGameInfoCallback * getCallback() const override {return cb;};
ArtBearer bearerType() const override {return ArtBearer::ALTAR;};
};

View File

@@ -15,7 +15,7 @@
#include "MiscObjects.h"
#include "../TerrainHandler.h"
#include "../callback/CPrivilegedInfoCallback.h"
#include "../callback/CGameInfoCallback.h"
#include "../callback/IGameEventCallback.h"
#include "../mapObjects/CGHeroInstance.h"
#include "../networkPacks/PacksForClient.h"

View File

@@ -28,7 +28,7 @@ class BoatId;
class CGObjectInstance;
class CStackInstance;
class CGHeroInstance;
class CPrivilegedInfoCallback;
class CGameInfoCallback;
class IGameEventCallback;
class ResourceSet;
class int3;

View File

@@ -12,7 +12,7 @@
#include "MiscObjects.h"
#include "../bonuses/Propagators.h"
#include "../callback/CPrivilegedInfoCallback.h"
#include "../callback/CGameInfoCallback.h"
#include "../callback/IGameEventCallback.h"
#include "../constants/StringConstants.h"
#include "../entities/artifact/ArtifactUtils.h"
@@ -483,7 +483,7 @@ void CGSubterraneanGate::initObj(vstd::RNG & rand)
type = BOTH;
}
void CGSubterraneanGate::postInit(CPrivilegedInfoCallback * cb) //matches subterranean gates into pairs
void CGSubterraneanGate::postInit(CGameInfoCallback * cb) //matches subterranean gates into pairs
{
//split on underground and surface gates
std::vector<CGSubterraneanGate *> gatesSplit[2]; //surface and underground gates
@@ -986,7 +986,7 @@ void CGMagi::onHeroVisit(IGameEventCallback & gameEvents, const CGHeroInstance *
}
}
CGBoat::CGBoat(CPrivilegedInfoCallback * cb)
CGBoat::CGBoat(CGameInfoCallback * cb)
: CGObjectInstance(cb)
{
direction = 4;

View File

@@ -257,7 +257,7 @@ class DLL_LINKAGE CGSubterraneanGate : public CGMonolith
public:
using CGMonolith::CGMonolith;
static void postInit(CPrivilegedInfoCallback * cb);
static void postInit(CGameInfoCallback * cb);
template <typename Handler> void serialize(Handler &h)
{
@@ -312,7 +312,7 @@ public:
AnimationPath overlayAnimation; //waves animations
std::array<AnimationPath, PlayerColor::PLAYER_LIMIT_I> flagAnimations;
CGBoat(CPrivilegedInfoCallback * cb);
CGBoat(CGameInfoCallback * cb);
bool isCoastVisitable() const override;
void setBoardedHero(const CGHeroInstance * hero);

View File

@@ -12,7 +12,7 @@
#include "TownBuildingInstance.h"
#include "CGTownInstance.h"
#include "../callback/CPrivilegedInfoCallback.h"
#include "../callback/CGameInfoCallback.h"
#include "../callback/IGameEventCallback.h"
#include "../mapObjects/CGHeroInstance.h"
#include "../entities/building/CBuilding.h"
@@ -21,7 +21,7 @@
VCMI_LIB_NAMESPACE_BEGIN
TownBuildingInstance::TownBuildingInstance(CPrivilegedInfoCallback * cb)
TownBuildingInstance::TownBuildingInstance(CGameInfoCallback * cb)
: IObjectInterface(cb)
, town(nullptr)
{}
@@ -62,7 +62,7 @@ int3 TownBuildingInstance::anchorPos() const
return town->anchorPos();
}
TownRewardableBuildingInstance::TownRewardableBuildingInstance(CPrivilegedInfoCallback *cb)
TownRewardableBuildingInstance::TownRewardableBuildingInstance(CGameInfoCallback *cb)
: TownBuildingInstance(cb)
{}

View File

@@ -23,7 +23,7 @@ class DLL_LINKAGE TownBuildingInstance : public IObjectInterface
///basic class for town structures handled as map objects
public:
TownBuildingInstance(CGTownInstance * town, const BuildingID & index);
TownBuildingInstance(CPrivilegedInfoCallback *cb);
TownBuildingInstance(CGameInfoCallback *cb);
CGTownInstance * town;
@@ -78,7 +78,7 @@ public:
void blockingDialogAnswered(IGameEventCallback & gameEvents, const CGHeroInstance *hero, int32_t answer) const override;
TownRewardableBuildingInstance(CGTownInstance * town, const BuildingID & index, vstd::RNG & rand);
TownRewardableBuildingInstance(CPrivilegedInfoCallback *cb);
TownRewardableBuildingInstance(CGameInfoCallback *cb);
template <typename Handler> void serialize(Handler &h)
{

View File

@@ -21,7 +21,7 @@
#include "../RoadHandler.h"
#include "../TerrainHandler.h"
#include "../callback/CPrivilegedInfoCallback.h"
#include "../callback/CGameInfoCallback.h"
#include "../entities/artifact/CArtHandler.h"
#include "../entities/hero/CHeroHandler.h"
#include "../gameState/CGameState.h"
@@ -170,7 +170,7 @@ EDiggingStatus TerrainTile::getDiggingStatus(const bool excludeTop) const
return EDiggingStatus::CAN_DIG;
}
CMap::CMap(CPrivilegedInfoCallback * cb)
CMap::CMap(CGameInfoCallback * cb)
: GameCallbackHolder(cb)
, grailPos(-1, -1, -1)
, grailRadius(0)

View File

@@ -80,7 +80,7 @@ public:
/// TODO: make private
std::vector<std::shared_ptr<CGObjectInstance>> objects;
explicit CMap(CPrivilegedInfoCallback *cb);
explicit CMap(CGameInfoCallback *cb);
~CMap();
void initTerrain();

View File

@@ -30,7 +30,7 @@
VCMI_LIB_NAMESPACE_BEGIN
std::unique_ptr<CMap> CMapService::loadMap(const ResourcePath & name, CPrivilegedInfoCallback * cb) const
std::unique_ptr<CMap> CMapService::loadMap(const ResourcePath & name, CGameInfoCallback * cb) const
{
std::string modName = LIBRARY->modh->findResourceOrigin(name);
std::string encoding = LIBRARY->modh->findResourceEncoding(name);
@@ -48,7 +48,7 @@ std::unique_ptr<CMapHeader> CMapService::loadMapHeader(const ResourcePath & name
return getMapLoader(stream, name.getName(), modName, encoding)->loadMapHeader();
}
std::unique_ptr<CMap> CMapService::loadMap(const uint8_t * buffer, int size, const std::string & name, const std::string & modName, const std::string & encoding, CPrivilegedInfoCallback * cb) const
std::unique_ptr<CMap> CMapService::loadMap(const uint8_t * buffer, int size, const std::string & name, const std::string & modName, const std::string & encoding, CGameInfoCallback * cb) const
{
auto stream = getStreamFromMem(buffer, size);
std::unique_ptr<CMap> map(getMapLoader(stream, name, modName, encoding)->loadMap(cb));

View File

@@ -22,7 +22,7 @@ class CInputStream;
class IMapLoader;
class IMapPatcher;
class CPrivilegedInfoCallback;
class CGameInfoCallback;
/**
* The map service provides loading of VCMI/H3 map files. It can
@@ -39,7 +39,7 @@ public:
* @param name the name of the map
* @return a unique ptr to the loaded map class
*/
virtual std::unique_ptr<CMap> loadMap(const ResourcePath & name, CPrivilegedInfoCallback * cb) const = 0;
virtual std::unique_ptr<CMap> loadMap(const ResourcePath & name, CGameInfoCallback * cb) const = 0;
/**
* Loads the VCMI/H3 map header specified by the name.
@@ -56,7 +56,7 @@ public:
* @param name indicates name of file that will be used during map header patching
* @return a unique ptr to the loaded map class
*/
virtual std::unique_ptr<CMap> loadMap(const uint8_t * buffer, int size, const std::string & name, const std::string & modName, const std::string & encoding, CPrivilegedInfoCallback * cb) const = 0;
virtual std::unique_ptr<CMap> loadMap(const uint8_t * buffer, int size, const std::string & name, const std::string & modName, const std::string & encoding, CGameInfoCallback * cb) const = 0;
/**
* Loads the VCMI/H3 map header from a buffer. This method is temporarily
@@ -81,9 +81,9 @@ public:
CMapService() = default;
virtual ~CMapService() = default;
std::unique_ptr<CMap> loadMap(const ResourcePath & name, CPrivilegedInfoCallback * cb) const override;
std::unique_ptr<CMap> loadMap(const ResourcePath & name, CGameInfoCallback * cb) const override;
std::unique_ptr<CMapHeader> loadMapHeader(const ResourcePath & name) const override;
std::unique_ptr<CMap> loadMap(const uint8_t * buffer, int size, const std::string & name, const std::string & modName, const std::string & encoding, CPrivilegedInfoCallback * cb) const override;
std::unique_ptr<CMap> loadMap(const uint8_t * buffer, int size, const std::string & name, const std::string & modName, const std::string & encoding, CGameInfoCallback * cb) const override;
std::unique_ptr<CMapHeader> loadMapHeader(const uint8_t * buffer, int size, const std::string & name, const std::string & modName, const std::string & encoding) const override;
void saveMap(const std::unique_ptr<CMap> & map, boost::filesystem::path fullPath) const override;
@@ -141,7 +141,7 @@ public:
*
* @return a unique ptr of the loaded map class
*/
virtual std::unique_ptr<CMap> loadMap(CPrivilegedInfoCallback * cb) = 0;
virtual std::unique_ptr<CMap> loadMap(CGameInfoCallback * cb) = 0;
/**
* Loads the VCMI/H3 map header.

View File

@@ -72,7 +72,7 @@ CMapLoaderH3M::CMapLoaderH3M(const std::string & mapName, const std::string & mo
//must be instantiated in .cpp file for access to complete types of all member fields
CMapLoaderH3M::~CMapLoaderH3M() = default;
std::unique_ptr<CMap> CMapLoaderH3M::loadMap(CPrivilegedInfoCallback * cb)
std::unique_ptr<CMap> CMapLoaderH3M::loadMap(CGameInfoCallback * cb)
{
// Init map object by parsing the input buffer
map = new CMap(cb);

View File

@@ -86,7 +86,7 @@ public:
*
* @return a unique ptr of the loaded map class
*/
std::unique_ptr<CMap> loadMap(CPrivilegedInfoCallback * cb) override;
std::unique_ptr<CMap> loadMap(CGameInfoCallback * cb) override;
/**
* Loads the VCMI/H3 map header.

View File

@@ -767,7 +767,7 @@ CMapLoaderJson::CMapLoaderJson(CInputStream * stream)
{
}
std::unique_ptr<CMap> CMapLoaderJson::loadMap(CPrivilegedInfoCallback * cb)
std::unique_ptr<CMap> CMapLoaderJson::loadMap(CGameInfoCallback * cb)
{
LOG_TRACE(logGlobal);
auto result = std::make_unique<CMap>(cb);

View File

@@ -167,7 +167,7 @@ public:
*
* @return a unique ptr of the loaded map class
*/
std::unique_ptr<CMap> loadMap(CPrivilegedInfoCallback * cb) override;
std::unique_ptr<CMap> loadMap(CGameInfoCallback * cb) override;
/**
* Loads the VCMI/Json map header.

View File

@@ -230,7 +230,7 @@ bool ObstacleProxy::isProhibited(const rmg::Area& objArea) const
return false;
};
int ObstacleProxy::getWeightedObjects(const int3 & tile, vstd::RNG & rand, CPrivilegedInfoCallback * cb, std::list<rmg::Object> & allObjects, std::vector<std::pair<rmg::Object*, int3>> & weightedObjects)
int ObstacleProxy::getWeightedObjects(const int3 & tile, vstd::RNG & rand, CGameInfoCallback * cb, std::list<rmg::Object> & allObjects, std::vector<std::pair<rmg::Object*, int3>> & weightedObjects)
{
int maxWeight = std::numeric_limits<int>::min();
for(auto & possibleObstacle : possibleObstacles)
@@ -311,7 +311,7 @@ int ObstacleProxy::getWeightedObjects(const int3 & tile, vstd::RNG & rand, CPriv
return maxWeight;
}
std::set<std::shared_ptr<CGObjectInstance>> ObstacleProxy::createObstacles(vstd::RNG & rand, CPrivilegedInfoCallback * cb)
std::set<std::shared_ptr<CGObjectInstance>> ObstacleProxy::createObstacles(vstd::RNG & rand, CGameInfoCallback * cb)
{
//reverse order, since obstacles begin in bottom-right corner, while the map coordinates begin in top-left
auto blockedTiles = blockedArea.getTilesVector();

View File

@@ -18,7 +18,7 @@ VCMI_LIB_NAMESPACE_BEGIN
class CMapEditManager;
class CGObjectInstance;
class ObjectTemplate;
class CPrivilegedInfoCallback;
class CGameInfoCallback;
class ObstacleSetFilter;
class DLL_LINKAGE ObstacleProxy
@@ -43,7 +43,7 @@ public:
virtual void placeObject(rmg::Object & object, std::set<std::shared_ptr<CGObjectInstance>> & instances);
virtual std::set<std::shared_ptr<CGObjectInstance>> createObstacles(vstd::RNG & rand, CPrivilegedInfoCallback * cb);
virtual std::set<std::shared_ptr<CGObjectInstance>> createObstacles(vstd::RNG & rand, CGameInfoCallback * cb);
virtual bool isInTheMap(const int3& tile) = 0;
@@ -52,7 +52,7 @@ public:
virtual void postProcess(const rmg::Object& object) {};
protected:
int getWeightedObjects(const int3& tile, vstd::RNG& rand, CPrivilegedInfoCallback * cb, std::list<rmg::Object>& allObjects, std::vector<std::pair<rmg::Object*, int3>>& weightedObjects);
int getWeightedObjects(const int3& tile, vstd::RNG& rand, CGameInfoCallback * cb, std::list<rmg::Object>& allObjects, std::vector<std::pair<rmg::Object*, int3>>& weightedObjects);
void sortObstacles();
rmg::Area blockedArea;

View File

@@ -20,7 +20,7 @@
#include "../CPlayerState.h"
#include "../TerrainHandler.h"
#include "../RoadHandler.h"
#include "../callback/CPrivilegedInfoCallback.h"
#include "../callback/CGameInfoCallback.h"
#include "../mapObjects/CGHeroInstance.h"
#include "../mapObjects/CGTownInstance.h"
#include "../mapObjects/MiscObjects.h"

View File

@@ -14,7 +14,7 @@
#include "../TerrainHandler.h"
#include "../GameLibrary.h"
#include "../bonuses/BonusList.h"
#include "../callback/CPrivilegedInfoCallback.h"
#include "../callback/CGameInfoCallback.h"
#include "../json/JsonNode.h"
#include "../mapObjects/CGHeroInstance.h"
#include "../mapObjects/MiscObjects.h"

View File

@@ -108,7 +108,7 @@ void Rewardable::Info::init(const JsonNode & objectConfig, const std::string & o
loadString(parameters["onGuardedMessage"], TextIdentifier(objectName, "onGuarded"));
}
Rewardable::LimitersList Rewardable::Info::configureSublimiters(Rewardable::Configuration & object, vstd::RNG & rng, CPrivilegedInfoCallback * cb, const JsonNode & source) const
Rewardable::LimitersList Rewardable::Info::configureSublimiters(Rewardable::Configuration & object, vstd::RNG & rng, CGameInfoCallback * cb, const JsonNode & source) const
{
Rewardable::LimitersList result;
for (const auto & input : source.Vector())
@@ -123,7 +123,7 @@ Rewardable::LimitersList Rewardable::Info::configureSublimiters(Rewardable::Conf
return result;
}
void Rewardable::Info::configureLimiter(Rewardable::Configuration & object, vstd::RNG & rng, CPrivilegedInfoCallback * cb, Rewardable::Limiter & limiter, const JsonNode & source) const
void Rewardable::Info::configureLimiter(Rewardable::Configuration & object, vstd::RNG & rng, CGameInfoCallback * cb, Rewardable::Limiter & limiter, const JsonNode & source) const
{
auto const & variables = object.variables.values;
JsonRandom randomizer(cb);
@@ -160,7 +160,7 @@ void Rewardable::Info::configureLimiter(Rewardable::Configuration & object, vstd
limiter.noneOf = configureSublimiters(object, rng, cb, source["noneOf"] );
}
void Rewardable::Info::configureReward(Rewardable::Configuration & object, vstd::RNG & rng, CPrivilegedInfoCallback * cb, Rewardable::Reward & reward, const JsonNode & source) const
void Rewardable::Info::configureReward(Rewardable::Configuration & object, vstd::RNG & rng, CGameInfoCallback * cb, Rewardable::Reward & reward, const JsonNode & source) const
{
auto const & variables = object.variables.values;
JsonRandom randomizer(cb);
@@ -233,7 +233,7 @@ void Rewardable::Info::configureResetInfo(Rewardable::Configuration & object, vs
resetParameters.rewards = source["rewards"].Bool();
}
void Rewardable::Info::configureVariables(Rewardable::Configuration & object, vstd::RNG & rng, CPrivilegedInfoCallback * cb, const JsonNode & source) const
void Rewardable::Info::configureVariables(Rewardable::Configuration & object, vstd::RNG & rng, CGameInfoCallback * cb, const JsonNode & source) const
{
JsonRandom randomizer(cb);
@@ -351,7 +351,7 @@ void Rewardable::Info::replaceTextPlaceholders(MetaString & target, const Variab
void Rewardable::Info::configureRewards(
Rewardable::Configuration & object,
vstd::RNG & rng,
CPrivilegedInfoCallback * cb,
CGameInfoCallback * cb,
const JsonNode & source,
Rewardable::EEventType event,
const std::string & modeName) const
@@ -408,7 +408,7 @@ void Rewardable::Info::configureRewards(
}
}
void Rewardable::Info::configureObject(Rewardable::Configuration & object, vstd::RNG & rng, CPrivilegedInfoCallback * cb) const
void Rewardable::Info::configureObject(Rewardable::Configuration & object, vstd::RNG & rng, CGameInfoCallback * cb) const
{
object.info.clear();
object.variables.values.clear();

View File

@@ -21,7 +21,7 @@ class RNG;
}
class MetaString;
class CPrivilegedInfoCallback;
class CGameInfoCallback;
namespace Rewardable
{
@@ -42,13 +42,13 @@ class DLL_LINKAGE Info : public IObjectInfo
void replaceTextPlaceholders(MetaString & target, const Variables & variables) const;
void replaceTextPlaceholders(MetaString & target, const Variables & variables, const VisitInfo & info) const;
void configureVariables(Rewardable::Configuration & object, vstd::RNG & rng, CPrivilegedInfoCallback * cb, const JsonNode & source) const;
void configureRewards(Rewardable::Configuration & object, vstd::RNG & rng, CPrivilegedInfoCallback * cb, const JsonNode & source, Rewardable::EEventType mode, const std::string & textPrefix) const;
void configureVariables(Rewardable::Configuration & object, vstd::RNG & rng, CGameInfoCallback * cb, const JsonNode & source) const;
void configureRewards(Rewardable::Configuration & object, vstd::RNG & rng, CGameInfoCallback * cb, const JsonNode & source, Rewardable::EEventType mode, const std::string & textPrefix) const;
void configureLimiter(Rewardable::Configuration & object, vstd::RNG & rng, CPrivilegedInfoCallback * cb, Rewardable::Limiter & limiter, const JsonNode & source) const;
Rewardable::LimitersList configureSublimiters(Rewardable::Configuration & object, vstd::RNG & rng, CPrivilegedInfoCallback * cb, const JsonNode & source) const;
void configureLimiter(Rewardable::Configuration & object, vstd::RNG & rng, CGameInfoCallback * cb, Rewardable::Limiter & limiter, const JsonNode & source) const;
Rewardable::LimitersList configureSublimiters(Rewardable::Configuration & object, vstd::RNG & rng, CGameInfoCallback * cb, const JsonNode & source) const;
void configureReward(Rewardable::Configuration & object, vstd::RNG & rng, CPrivilegedInfoCallback * cb, Rewardable::Reward & info, const JsonNode & source) const;
void configureReward(Rewardable::Configuration & object, vstd::RNG & rng, CGameInfoCallback * cb, Rewardable::Reward & info, const JsonNode & source) const;
void configureResetInfo(Rewardable::Configuration & object, vstd::RNG & rng, Rewardable::ResetInfo & info, const JsonNode & source) const;
public:
const JsonNode & getParameters() const;
@@ -70,7 +70,7 @@ public:
bool hasGuards() const override;
void configureObject(Rewardable::Configuration & object, vstd::RNG & rng, CPrivilegedInfoCallback * cb) const;
void configureObject(Rewardable::Configuration & object, vstd::RNG & rng, CGameInfoCallback * cb) const;
void init(const JsonNode & objectConfig, const std::string & objectTextID);

View File

@@ -14,7 +14,7 @@
#include "../TerrainHandler.h"
#include "../CPlayerState.h"
#include "../CSoundBase.h"
#include "../callback/CPrivilegedInfoCallback.h"
#include "../callback/CGameInfoCallback.h"
#include "../callback/IGameEventCallback.h"
#include "../entities/hero/CHeroHandler.h"
#include "../gameState/CGameState.h"

View File

@@ -13,7 +13,7 @@
#include "../CPlayerState.h"
#include "../CSkillHandler.h"
#include "../callback/CPrivilegedInfoCallback.h"
#include "../callback/CGameInfoCallback.h"
#include "../constants/StringConstants.h"
#include "../entities/artifact/ArtifactUtils.h"
#include "../mapObjects/CGHeroInstance.h"

View File

@@ -40,7 +40,7 @@
VCMI_LIB_NAMESPACE_BEGIN
CMapGenerator::CMapGenerator(CMapGenOptions& mapGenOptions, CPrivilegedInfoCallback * cb, int RandomSeed) :
CMapGenerator::CMapGenerator(CMapGenOptions& mapGenOptions, CGameInfoCallback * cb, int RandomSeed) :
mapGenOptions(mapGenOptions), randomSeed(RandomSeed),
monolithIndex(0),
rand(std::make_unique<CRandomGenerator>(RandomSeed))

View File

@@ -23,7 +23,7 @@ class RmgMap;
class CMap;
class Zone;
class CZonePlacer;
class CPrivilegedInfoCallback;
class CGameInfoCallback;
using JsonVector = std::vector<JsonNode>;
@@ -54,7 +54,7 @@ public:
bool singleThread;
};
explicit CMapGenerator(CMapGenOptions& mapGenOptions, CPrivilegedInfoCallback * cb, int RandomSeed);
explicit CMapGenerator(CMapGenOptions& mapGenOptions, CGameInfoCallback * cb, int RandomSeed);
~CMapGenerator(); // required due to std::unique_ptr
const Config & getConfig() const;

View File

@@ -39,7 +39,7 @@
VCMI_LIB_NAMESPACE_BEGIN
RmgMap::RmgMap(const CMapGenOptions& mapGenOptions, CPrivilegedInfoCallback * cb) :
RmgMap::RmgMap(const CMapGenOptions& mapGenOptions, CGameInfoCallback * cb) :
mapGenOptions(mapGenOptions), zonesTotal(0)
{
mapInstance = std::make_unique<CMap>(cb);

View File

@@ -38,7 +38,7 @@ public:
std::shared_ptr<MapProxy> getMapProxy() const;
CMap & getMap(const CMapGenerator *) const; //limited access
RmgMap(const CMapGenOptions& mapGenOptions, CPrivilegedInfoCallback * cb);
RmgMap(const CMapGenOptions& mapGenOptions, CGameInfoCallback * cb);
~RmgMap() = default;
CMapEditManager* getEditManager() const;

View File

@@ -23,7 +23,7 @@ public:
using Version = ESerializationVersion;
static constexpr bool saving = false;
CPrivilegedInfoCallback * cb = nullptr;
CGameInfoCallback * cb = nullptr;
Version version = Version::NONE;
bool loadingGamestate = false;
bool reverseEndianness = false; //if source has different endianness than us, we reverse bytes

View File

@@ -19,7 +19,7 @@ struct static_caster
};
CLoadFile::CLoadFile(const boost::filesystem::path & fname, CPrivilegedInfoCallback * cb)
CLoadFile::CLoadFile(const boost::filesystem::path & fname, CGameInfoCallback * cb)
: serializer(this)
, sfile(fname.c_str(), std::ios::in | std::ios::binary)
{

View File

@@ -21,7 +21,7 @@ class DLL_LINKAGE CLoadFile : public IBinaryReader
int read(std::byte * data, unsigned size) override; //throws!
public:
CLoadFile(const boost::filesystem::path & fname, CPrivilegedInfoCallback * cb); //throws!
CLoadFile(const boost::filesystem::path & fname, CGameInfoCallback * cb); //throws!
template<class T>
void load(T & data)

View File

@@ -124,7 +124,7 @@ void CConnection::enterLobbyConnectionMode()
serializer->clear();
}
void CConnection::setCallback(CPrivilegedInfoCallback * cb)
void CConnection::setCallback(CGameInfoCallback * cb)
{
deserializer->cb = cb;
}

View File

@@ -20,7 +20,7 @@ class INetworkConnection;
class ConnectionPackReader;
class ConnectionPackWriter;
class CGameState;
class CPrivilegedInfoCallback;
class CGameInfoCallback;
/// Wrapper class for game connection
/// Handles serialization and deserialization of data received from network
@@ -50,7 +50,7 @@ public:
std::unique_ptr<CPack> retrievePack(const std::vector<std::byte> & data);
void enterLobbyConnectionMode();
void setCallback(CPrivilegedInfoCallback * cb);
void setCallback(CGameInfoCallback * cb);
void enterGameplayConnectionMode(CGameState & gs);
void setSerializationVersion(ESerializationVersion version);
};

View File

@@ -30,12 +30,12 @@ template<typename Type>
class SerializerReflection final : public ISerializerReflection
{
public:
Serializeable * createPtr(BinaryDeserializer &ar, CPrivilegedInfoCallback * cb) const override
Serializeable * createPtr(BinaryDeserializer &ar, CGameInfoCallback * cb) const override
{
return ClassObjectCreator<Type>::invoke(cb);
}
void loadPtr(BinaryDeserializer &ar, CPrivilegedInfoCallback * cb, Serializeable * data) const override
void loadPtr(BinaryDeserializer &ar, CGameInfoCallback * cb, Serializeable * data) const override
{
auto * realPtr = dynamic_cast<Type *>(data);
realPtr->serialize(ar);
@@ -52,7 +52,7 @@ template<typename Type, ESerializationVersion maxVersion>
class SerializerCompatibility : public ISerializerReflection
{
public:
Serializeable * createPtr(BinaryDeserializer &ar, CPrivilegedInfoCallback * cb) const override
Serializeable * createPtr(BinaryDeserializer &ar, CGameInfoCallback * cb) const override
{
return ClassObjectCreator<Type>::invoke(cb);
}

View File

@@ -11,7 +11,7 @@
VCMI_LIB_NAMESPACE_BEGIN
class CPrivilegedInfoCallback;
class CGameInfoCallback;
class Serializeable;
class GameCallbackHolder;
class BinaryDeserializer;
@@ -21,7 +21,7 @@ class GameCallbackHolder;
template <typename T, typename Enable = void>
struct ClassObjectCreator
{
static T *invoke(CPrivilegedInfoCallback *cb)
static T *invoke(CGameInfoCallback *cb)
{
static_assert(!std::is_base_of_v<GameCallbackHolder, T>, "Cannot call new upon map objects!");
static_assert(!std::is_abstract_v<T>, "Cannot call new upon abstract classes!");
@@ -32,7 +32,7 @@ struct ClassObjectCreator
template<typename T>
struct ClassObjectCreator<T, typename std::enable_if_t<std::is_base_of_v<GameCallbackHolder, T>>>
{
static T *invoke(CPrivilegedInfoCallback *cb)
static T *invoke(CGameInfoCallback *cb)
{
static_assert(!std::is_abstract_v<T>, "Cannot call new upon abstract classes!");
return new T(cb);
@@ -42,8 +42,8 @@ struct ClassObjectCreator<T, typename std::enable_if_t<std::is_base_of_v<GameCal
class ISerializerReflection
{
public:
virtual Serializeable * createPtr(BinaryDeserializer &ar, CPrivilegedInfoCallback * cb) const =0;
virtual void loadPtr(BinaryDeserializer &ar, CPrivilegedInfoCallback * cb, Serializeable * data) const =0;
virtual Serializeable * createPtr(BinaryDeserializer &ar, CGameInfoCallback * cb) const =0;
virtual void loadPtr(BinaryDeserializer &ar, CGameInfoCallback * cb, Serializeable * data) const =0;
virtual void savePtr(BinarySerializer &ar, const Serializeable *data) const =0;
virtual ~ISerializerReflection() = default;
};

View File

@@ -11,7 +11,7 @@
#include <vcmi/Environment.h>
#include "../lib/callback/CPrivilegedInfoCallback.h"
#include "../lib/callback/CGameInfoCallback.h"
#include "../lib/callback/IGameEventCallback.h"
#include "../lib/LoadProgress.h"
#include "../lib/ScriptHandler.h"
@@ -54,7 +54,7 @@ class QueriesProcessor;
class CObjectVisitQuery;
class NewTurnProcessor;
class CGameHandler : public CPrivilegedInfoCallback, public Environment, public IGameEventCallback
class CGameHandler : public CGameInfoCallback, public Environment, public IGameEventCallback
{
CVCMIServer * lobby;
@@ -108,7 +108,7 @@ public:
~CGameHandler();
//////////////////////////////////////////////////////////////////////////
//from CPrivilegedInfoCallback
//from CGameInfoCallback
//do sth
void changeSpells(const CGHeroInstance * hero, bool give, const std::set<SpellID> &spells) override;
void setResearchedSpells(const CGTownInstance * town, int level, const std::vector<SpellID> & spells, bool accepted) override;

View File

@@ -12,12 +12,12 @@
#include <vcmi/ServerCallback.h>
#include "../../lib/callback/CPrivilegedInfoCallback.h"
#include "../../lib/callback/CGameInfoCallback.h"
#include "../../lib/callback/IGameEventCallback.h"
#include "../../lib/int3.h"
#include "../../lib/ResourceSet.h"
class GameCallbackMock : public CPrivilegedInfoCallback, public IGameEventCallback
class GameCallbackMock : public CGameInfoCallback, public IGameEventCallback
{
std::shared_ptr<CGameState> gamestate;
public:

View File

@@ -53,7 +53,7 @@ std::unique_ptr<CMap> MapServiceMock::loadMap() const
return res;
}
std::unique_ptr<CMap> MapServiceMock::loadMap(const ResourcePath & name, CPrivilegedInfoCallback * cb) const
std::unique_ptr<CMap> MapServiceMock::loadMap(const ResourcePath & name, CGameInfoCallback * cb) const
{
return loadMap();
}
@@ -65,7 +65,7 @@ std::unique_ptr<CMapHeader> MapServiceMock::loadMapHeader(const ResourcePath & n
return initialLoader.loadMapHeader();
}
std::unique_ptr<CMap> MapServiceMock::loadMap(const ui8 * buffer, int size, const std::string & name, const std::string & modName, const std::string & encoding, CPrivilegedInfoCallback * cb) const
std::unique_ptr<CMap> MapServiceMock::loadMap(const ui8 * buffer, int size, const std::string & name, const std::string & modName, const std::string & encoding, CGameInfoCallback * cb) const
{
return loadMap();
}

View File

@@ -29,9 +29,9 @@ class MapServiceMock : public IMapService
public:
MapServiceMock(const std::string & path, MapListener * mapListener_);
std::unique_ptr<CMap> loadMap(const ResourcePath & name, CPrivilegedInfoCallback * cb) const override;
std::unique_ptr<CMap> loadMap(const ResourcePath & name, CGameInfoCallback * cb) const override;
std::unique_ptr<CMapHeader> loadMapHeader(const ResourcePath & name) const override;
std::unique_ptr<CMap> loadMap(const ui8 * buffer, int size, const std::string & name, const std::string & modName, const std::string & encoding, CPrivilegedInfoCallback * cb) const override;
std::unique_ptr<CMap> loadMap(const ui8 * buffer, int size, const std::string & name, const std::string & modName, const std::string & encoding, CGameInfoCallback * cb) const override;
std::unique_ptr<CMapHeader> loadMapHeader(const ui8 * buffer, int size, const std::string & name, const std::string & modName, const std::string & encoding) const override;
void saveMap(const std::unique_ptr<CMap> & map, boost::filesystem::path fullPath) const override;