mirror of
https://github.com/vcmi/vcmi.git
synced 2025-04-17 11:56:46 +02:00
Refactoring: always use std prefix for shared_ptr, unique_ptr and make_shared
Long time ago it's was used without prefix to make future switch from boost to std version easier. I discusses this with Ivan and decide to drop these using from Global.h now. This change wouldn't break anything because there was already code with prefix for each of three cases.
This commit is contained in:
parent
29a7934a99
commit
9fd1cff090
@ -8,7 +8,7 @@
|
||||
#include "../../lib/VCMI_Lib.h"
|
||||
|
||||
using boost::optional;
|
||||
static shared_ptr<CBattleCallback> cbc;
|
||||
static std::shared_ptr<CBattleCallback> cbc;
|
||||
|
||||
#define LOGL(text) print(text)
|
||||
#define LOGFL(text, formattingEl) print(boost::str(boost::format(text) % formattingEl))
|
||||
@ -91,7 +91,7 @@ CBattleAI::~CBattleAI(void)
|
||||
}
|
||||
}
|
||||
|
||||
void CBattleAI::init(shared_ptr<CBattleCallback> CB)
|
||||
void CBattleAI::init(std::shared_ptr<CBattleCallback> CB)
|
||||
{
|
||||
print("init called, saving ptr to IBattleCallback");
|
||||
cbc = cb = CB;
|
||||
@ -610,7 +610,7 @@ ThreatMap::ThreatMap(const CStack *Endangered) : endangered(Endangered)
|
||||
|
||||
const TBonusListPtr StackWithBonuses::getAllBonuses(const CSelector &selector, const CSelector &limit, const CBonusSystemNode *root /*= nullptr*/, const std::string &cachingStr /*= ""*/) const
|
||||
{
|
||||
TBonusListPtr ret = make_shared<BonusList>();
|
||||
TBonusListPtr ret = std::make_shared<BonusList>();
|
||||
const TBonusListPtr originalList = stack->getAllBonuses(selector, limit, root, cachingStr);
|
||||
range::copy(*originalList, std::back_inserter(*ret));
|
||||
for(auto &bonus : bonusesToAdd)
|
||||
|
@ -110,7 +110,7 @@ struct PotentialTargets
|
||||
class CBattleAI : public CBattleGameInterface
|
||||
{
|
||||
int side;
|
||||
shared_ptr<CBattleCallback> cb;
|
||||
std::shared_ptr<CBattleCallback> cb;
|
||||
|
||||
//Previous setting of cb
|
||||
bool wasWaitingForRealize, wasUnlockingGs;
|
||||
@ -120,7 +120,7 @@ public:
|
||||
CBattleAI(void);
|
||||
~CBattleAI(void);
|
||||
|
||||
void init(shared_ptr<CBattleCallback> CB) override;
|
||||
void init(std::shared_ptr<CBattleCallback> CB) override;
|
||||
void actionFinished(const BattleAction &action) override;//occurs AFTER every action taken by any stack or by the hero
|
||||
void actionStarted(const BattleAction &action) override;//occurs BEFORE every action taken by any stack or by the hero
|
||||
BattleAction activeStack(const CStack * stack) override; //called when it's turn of that stack
|
||||
|
@ -25,7 +25,7 @@ extern "C" DLL_EXPORT void GetAiName(char* name)
|
||||
strcpy_s(name, strlen(g_cszAiName) + 1, g_cszAiName);
|
||||
}
|
||||
|
||||
extern "C" DLL_EXPORT void GetNewBattleAI(shared_ptr<CBattleGameInterface> &out)
|
||||
extern "C" DLL_EXPORT void GetNewBattleAI(std::shared_ptr<CBattleGameInterface> &out)
|
||||
{
|
||||
out = make_shared<CBattleAI>();
|
||||
out = std::make_shared<CBattleAI>();
|
||||
}
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
#include "../../lib/CRandomGenerator.h"
|
||||
|
||||
void CEmptyAI::init(shared_ptr<CCallback> CB)
|
||||
void CEmptyAI::init(std::shared_ptr<CCallback> CB)
|
||||
{
|
||||
cb = CB;
|
||||
human=false;
|
||||
|
@ -7,10 +7,10 @@ struct HeroMoveDetails;
|
||||
|
||||
class CEmptyAI : public CGlobalAI
|
||||
{
|
||||
shared_ptr<CCallback> cb;
|
||||
std::shared_ptr<CCallback> cb;
|
||||
|
||||
public:
|
||||
void init(shared_ptr<CCallback> CB) override;
|
||||
void init(std::shared_ptr<CCallback> CB) override;
|
||||
void yourTurn() override;
|
||||
void heroGotLevel(const CGHeroInstance *hero, PrimarySkill::PrimarySkill pskill, std::vector<SecondarySkill> &skills, QueryID queryID) override;
|
||||
void commanderGotLevel (const CCommanderInstance * commander, std::vector<ui32> skills, QueryID queryID) override;
|
||||
|
@ -13,7 +13,7 @@ extern "C" DLL_EXPORT void GetAiName(char* name)
|
||||
strcpy(name,NAME);
|
||||
}
|
||||
|
||||
extern "C" DLL_EXPORT void GetNewAI(shared_ptr<CGlobalAI> &out)
|
||||
extern "C" DLL_EXPORT void GetNewAI(std::shared_ptr<CGlobalAI> &out)
|
||||
{
|
||||
out = make_shared<CEmptyAI>();
|
||||
out = std::make_shared<CEmptyAI>();
|
||||
}
|
@ -5,7 +5,7 @@
|
||||
#include "../../CCallback.h"
|
||||
#include "../../lib/CCreatureHandler.h"
|
||||
|
||||
static shared_ptr<CBattleCallback> cbc;
|
||||
static std::shared_ptr<CBattleCallback> cbc;
|
||||
|
||||
CStupidAI::CStupidAI(void)
|
||||
: side(-1)
|
||||
@ -19,7 +19,7 @@ CStupidAI::~CStupidAI(void)
|
||||
print("destroyed");
|
||||
}
|
||||
|
||||
void CStupidAI::init(shared_ptr<CBattleCallback> CB)
|
||||
void CStupidAI::init(std::shared_ptr<CBattleCallback> CB)
|
||||
{
|
||||
print("init called, saving ptr to IBattleCallback");
|
||||
cbc = cb = CB;
|
||||
|
@ -5,14 +5,14 @@
|
||||
class CStupidAI : public CBattleGameInterface
|
||||
{
|
||||
int side;
|
||||
shared_ptr<CBattleCallback> cb;
|
||||
std::shared_ptr<CBattleCallback> cb;
|
||||
|
||||
void print(const std::string &text) const;
|
||||
public:
|
||||
CStupidAI(void);
|
||||
~CStupidAI(void);
|
||||
|
||||
void init(shared_ptr<CBattleCallback> CB) override;
|
||||
void init(std::shared_ptr<CBattleCallback> CB) override;
|
||||
void actionFinished(const BattleAction &action) override;//occurs AFTER every action taken by any stack or by the hero
|
||||
void actionStarted(const BattleAction &action) override;//occurs BEFORE every action taken by any stack or by the hero
|
||||
BattleAction activeStack(const CStack * stack) override; //called when it's turn of that stack
|
||||
|
@ -25,7 +25,7 @@ extern "C" DLL_EXPORT void GetAiName(char* name)
|
||||
strcpy_s(name, strlen(g_cszAiName) + 1, g_cszAiName);
|
||||
}
|
||||
|
||||
extern "C" DLL_EXPORT void GetNewBattleAI(shared_ptr<CBattleGameInterface> &out)
|
||||
extern "C" DLL_EXPORT void GetNewBattleAI(std::shared_ptr<CBattleGameInterface> &out)
|
||||
{
|
||||
out = make_shared<CStupidAI>();
|
||||
out = std::make_shared<CStupidAI>();
|
||||
}
|
||||
|
@ -296,7 +296,7 @@ FuzzyHelper::TacticalAdvantage::~TacticalAdvantage()
|
||||
delete threat;
|
||||
}
|
||||
|
||||
//shared_ptr<AbstractGoal> chooseSolution (std::vector<shared_ptr<AbstractGoal>> & vec)
|
||||
//std::shared_ptr<AbstractGoal> chooseSolution (std::vector<std::shared_ptr<AbstractGoal>> & vec)
|
||||
|
||||
Goals::TSubgoal FuzzyHelper::chooseSolution (Goals::TGoalVec vec)
|
||||
{
|
||||
|
@ -83,5 +83,5 @@ public:
|
||||
float getTacticalAdvantage (const CArmedInstance *we, const CArmedInstance *enemy); //returns factor how many times enemy is stronger than us
|
||||
|
||||
Goals::TSubgoal chooseSolution (Goals::TGoalVec vec);
|
||||
//shared_ptr<AbstractGoal> chooseSolution (std::vector<shared_ptr<AbstractGoal>> & vec);
|
||||
//std::shared_ptr<AbstractGoal> chooseSolution (std::vector<std::shared_ptr<AbstractGoal>> & vec);
|
||||
};
|
||||
|
@ -23,7 +23,7 @@ using namespace Goals;
|
||||
|
||||
TSubgoal Goals::sptr(const AbstractGoal & tmp)
|
||||
{
|
||||
shared_ptr<AbstractGoal> ptr;
|
||||
std::shared_ptr<AbstractGoal> ptr;
|
||||
ptr.reset(tmp.clone());
|
||||
return ptr;
|
||||
}
|
||||
|
@ -107,7 +107,7 @@ public:
|
||||
static TSubgoal tryRecruitHero();
|
||||
|
||||
///Visitor pattern
|
||||
//TODO: make accept work for shared_ptr... somehow
|
||||
//TODO: make accept work for std::shared_ptr... somehow
|
||||
virtual void accept (VCAI * ai); //unhandled goal will report standard error
|
||||
virtual float accept (FuzzyHelper * f);
|
||||
|
||||
@ -162,7 +162,7 @@ public:
|
||||
TSubgoal iAmElementar()
|
||||
{
|
||||
setisElementar(true);
|
||||
shared_ptr<AbstractGoal> ptr;
|
||||
std::shared_ptr<AbstractGoal> ptr;
|
||||
ptr.reset(clone());
|
||||
return ptr;
|
||||
}
|
||||
|
@ -555,7 +555,7 @@ void VCAI::showWorldViewEx(const std::vector<ObjectPosInfo> & objectPositions)
|
||||
NET_EVENT_HANDLER;
|
||||
}
|
||||
|
||||
void VCAI::init(shared_ptr<CCallback> CB)
|
||||
void VCAI::init(std::shared_ptr<CCallback> CB)
|
||||
{
|
||||
LOG_TRACE(logAi);
|
||||
myCb = CB;
|
||||
|
@ -93,7 +93,7 @@ struct SectorMap
|
||||
//std::vector<std::vector<std::vector<unsigned char>>> pathfinderSector;
|
||||
|
||||
std::map<int, Sector> infoOnSectors;
|
||||
shared_ptr<boost::multi_array<TerrainTile*, 3>> visibleTiles;
|
||||
std::shared_ptr<boost::multi_array<TerrainTile*, 3>> visibleTiles;
|
||||
|
||||
SectorMap();
|
||||
SectorMap(HeroPtr h);
|
||||
@ -129,7 +129,7 @@ public:
|
||||
|
||||
friend class FuzzyHelper;
|
||||
|
||||
std::map<TeleportChannelID, shared_ptr<TeleportChannel> > knownTeleportChannels;
|
||||
std::map<TeleportChannelID, std::shared_ptr<TeleportChannel> > knownTeleportChannels;
|
||||
std::map<const CGObjectInstance *, const CGObjectInstance *> knownSubterraneanGates;
|
||||
ObjectInstanceID destinationTeleport;
|
||||
int3 destinationTeleportPos;
|
||||
@ -153,9 +153,9 @@ public:
|
||||
AIStatus status;
|
||||
std::string battlename;
|
||||
|
||||
shared_ptr<CCallback> myCb;
|
||||
std::shared_ptr<CCallback> myCb;
|
||||
|
||||
unique_ptr<boost::thread> makingTurn;
|
||||
std::unique_ptr<boost::thread> makingTurn;
|
||||
|
||||
VCAI(void);
|
||||
~VCAI(void);
|
||||
@ -180,7 +180,7 @@ public:
|
||||
|
||||
virtual std::string getBattleAIName() const override;
|
||||
|
||||
virtual void init(shared_ptr<CCallback> CB) override;
|
||||
virtual void init(std::shared_ptr<CCallback> CB) override;
|
||||
virtual void yourTurn() override;
|
||||
|
||||
virtual void heroGotLevel(const CGHeroInstance *hero, PrimarySkill::PrimarySkill pskill, std::vector<SecondarySkill> &skills, QueryID queryID) override; //pskill is gained primary skill, interface has to choose one of given skills and call callback with selection id
|
||||
|
@ -23,7 +23,7 @@ extern "C" DLL_EXPORT void GetAiName(char* name)
|
||||
strcpy_s(name, strlen(g_cszAiName) + 1, g_cszAiName);
|
||||
}
|
||||
|
||||
extern "C" DLL_EXPORT void GetNewAI(shared_ptr<CGlobalAI> &out)
|
||||
extern "C" DLL_EXPORT void GetNewAI(std::shared_ptr<CGlobalAI> &out)
|
||||
{
|
||||
out = make_shared<VCAI>();
|
||||
out = std::make_shared<VCAI>();
|
||||
}
|
||||
|
@ -333,22 +333,22 @@ int CCallback::mergeOrSwapStacks(const CArmedInstance *s1, const CArmedInstance
|
||||
return swapCreatures(s1, s2, p1, p2);
|
||||
}
|
||||
|
||||
void CCallback::registerGameInterface(shared_ptr<IGameEventsReceiver> gameEvents)
|
||||
void CCallback::registerGameInterface(std::shared_ptr<IGameEventsReceiver> gameEvents)
|
||||
{
|
||||
cl->additionalPlayerInts[*player].push_back(gameEvents);
|
||||
}
|
||||
|
||||
void CCallback::registerBattleInterface(shared_ptr<IBattleEventsReceiver> battleEvents)
|
||||
void CCallback::registerBattleInterface(std::shared_ptr<IBattleEventsReceiver> battleEvents)
|
||||
{
|
||||
cl->additionalBattleInts[*player].push_back(battleEvents);
|
||||
}
|
||||
|
||||
void CCallback::unregisterGameInterface(shared_ptr<IGameEventsReceiver> gameEvents)
|
||||
void CCallback::unregisterGameInterface(std::shared_ptr<IGameEventsReceiver> gameEvents)
|
||||
{
|
||||
cl->additionalPlayerInts[*player] -= gameEvents;
|
||||
}
|
||||
|
||||
void CCallback::unregisterBattleInterface(shared_ptr<IBattleEventsReceiver> battleEvents)
|
||||
void CCallback::unregisterBattleInterface(std::shared_ptr<IBattleEventsReceiver> battleEvents)
|
||||
{
|
||||
cl->additionalBattleInts[*player] -= battleEvents;
|
||||
}
|
||||
|
@ -110,10 +110,10 @@ public:
|
||||
virtual void calculatePaths(const CGHeroInstance *hero, CPathsInfo &out);
|
||||
|
||||
//Set of metrhods that allows adding more interfaces for this player that'll receive game event call-ins.
|
||||
void registerGameInterface(shared_ptr<IGameEventsReceiver> gameEvents);
|
||||
void registerBattleInterface(shared_ptr<IBattleEventsReceiver> battleEvents);
|
||||
void unregisterGameInterface(shared_ptr<IGameEventsReceiver> gameEvents);
|
||||
void unregisterBattleInterface(shared_ptr<IBattleEventsReceiver> battleEvents);
|
||||
void registerGameInterface(std::shared_ptr<IGameEventsReceiver> gameEvents);
|
||||
void registerBattleInterface(std::shared_ptr<IBattleEventsReceiver> battleEvents);
|
||||
void unregisterGameInterface(std::shared_ptr<IGameEventsReceiver> gameEvents);
|
||||
void unregisterBattleInterface(std::shared_ptr<IBattleEventsReceiver> battleEvents);
|
||||
|
||||
void unregisterAllInterfaces(); //stops delivering information about game events to player interfaces -> can be called ONLY after victory/loss
|
||||
|
||||
|
3
Global.h
3
Global.h
@ -180,9 +180,6 @@ static_assert(sizeof(bool) == 1, "Bool needs to be 1 byte in size.");
|
||||
/* ---------------------------------------------------------------------------- */
|
||||
/* Usings */
|
||||
/* ---------------------------------------------------------------------------- */
|
||||
using std::shared_ptr;
|
||||
using std::unique_ptr;
|
||||
using std::make_shared;
|
||||
using namespace std::placeholders;
|
||||
namespace range = boost::range;
|
||||
|
||||
|
@ -349,7 +349,7 @@ void CMusicHandler::playMusicFromSet(std::string whichSet, int entryID, bool loo
|
||||
queueNext(this, "", selectedEntry->second, loop);
|
||||
}
|
||||
|
||||
void CMusicHandler::queueNext(unique_ptr<MusicEntry> queued)
|
||||
void CMusicHandler::queueNext(std::unique_ptr<MusicEntry> queued)
|
||||
{
|
||||
if (!initialized)
|
||||
return;
|
||||
|
@ -114,11 +114,11 @@ private:
|
||||
SettingsListener listener;
|
||||
void onVolumeChange(const JsonNode &volumeNode);
|
||||
|
||||
unique_ptr<MusicEntry> current;
|
||||
unique_ptr<MusicEntry> next;
|
||||
std::unique_ptr<MusicEntry> current;
|
||||
std::unique_ptr<MusicEntry> next;
|
||||
|
||||
void queueNext(CMusicHandler *owner, std::string setName, std::string musicURI, bool looped);
|
||||
void queueNext(unique_ptr<MusicEntry> queued);
|
||||
void queueNext(std::unique_ptr<MusicEntry> queued);
|
||||
|
||||
std::map<std::string, std::map<int, std::string> > musicsSet;
|
||||
public:
|
||||
|
@ -133,7 +133,7 @@ CPlayerInterface::~CPlayerInterface()
|
||||
if(LOCPLINT == this)
|
||||
LOCPLINT = nullptr;
|
||||
}
|
||||
void CPlayerInterface::init(shared_ptr<CCallback> CB)
|
||||
void CPlayerInterface::init(std::shared_ptr<CCallback> CB)
|
||||
{
|
||||
cb = CB;
|
||||
if(observerInDuelMode)
|
||||
|
@ -105,7 +105,7 @@ public:
|
||||
static CBattleInterface * battleInt; //nullptr if no battle
|
||||
CInGameConsole * cingconsole;
|
||||
|
||||
shared_ptr<CCallback> cb; //to communicate with engine
|
||||
std::shared_ptr<CCallback> cb; //to communicate with engine
|
||||
const BattleAction *curAction; //during the battle - action currently performed by active stack (or nullptr)
|
||||
|
||||
std::list<CInfoWindow *> dialogs; //queue of dialogs awaiting to be shown (not currently shown!)
|
||||
@ -116,7 +116,7 @@ public:
|
||||
std::vector<const CGHeroInstance *> sleepingHeroes; //if hero is in here, he's sleeping
|
||||
|
||||
//During battle is quick combat mode is used
|
||||
shared_ptr<CBattleGameInterface> autofightingAI; //AI that makes decisions
|
||||
std::shared_ptr<CBattleGameInterface> autofightingAI; //AI that makes decisions
|
||||
bool isAutoFightOn; //Flag, switch it to stop quick combat. Don't touch if there is no battle interface.
|
||||
|
||||
const CArmedInstance * getSelection();
|
||||
@ -236,7 +236,7 @@ public:
|
||||
void openTownWindow(const CGTownInstance * town); //shows townscreen
|
||||
void openHeroWindow(const CGHeroInstance * hero); //shows hero window with given hero
|
||||
void updateInfo(const CGObjectInstance * specific);
|
||||
void init(shared_ptr<CCallback> CB) override;
|
||||
void init(std::shared_ptr<CCallback> CB) override;
|
||||
int3 repairScreenPos(int3 pos); //returns position closest to pos we can center screen on
|
||||
|
||||
// show dialogs
|
||||
|
@ -1918,7 +1918,7 @@ const CMapGenOptions & CRandomMapTab::getMapGenOptions() const
|
||||
return mapGenOptions;
|
||||
}
|
||||
|
||||
void CRandomMapTab::setMapGenOptions(shared_ptr<CMapGenOptions> opts)
|
||||
void CRandomMapTab::setMapGenOptions(std::shared_ptr<CMapGenOptions> opts)
|
||||
{
|
||||
mapSizeBtnGroup->setSelected(vstd::find_pos(getPossibleMapSizes(), opts->getWidth()));
|
||||
twoLevelsBtn->setSelected(opts->getHasTwoLevels());
|
||||
@ -3291,14 +3291,14 @@ void CBonusSelection::init()
|
||||
sFlags = CDefHandler::giveDef("ITGFLAGS.DEF");
|
||||
}
|
||||
|
||||
CBonusSelection::CBonusSelection(shared_ptr<CCampaignState> _ourCampaign) : ourCampaign(_ourCampaign)
|
||||
CBonusSelection::CBonusSelection(std::shared_ptr<CCampaignState> _ourCampaign) : ourCampaign(_ourCampaign)
|
||||
{
|
||||
init();
|
||||
}
|
||||
|
||||
CBonusSelection::CBonusSelection(const std::string & campaignFName)
|
||||
{
|
||||
ourCampaign = make_shared<CCampaignState>(CCampaignHandler::getCampaign(campaignFName));
|
||||
ourCampaign = std::make_shared<CCampaignState>(CCampaignHandler::getCampaign(campaignFName));
|
||||
init();
|
||||
}
|
||||
|
||||
|
@ -300,7 +300,7 @@ public:
|
||||
CFunctionList<void (const CMapInfo *)> & getMapInfoChanged();
|
||||
const CMapInfo * getMapInfo() const;
|
||||
const CMapGenOptions & getMapGenOptions() const;
|
||||
void setMapGenOptions(shared_ptr<CMapGenOptions> opts);
|
||||
void setMapGenOptions(std::shared_ptr<CMapGenOptions> opts);
|
||||
|
||||
private:
|
||||
void addButtonsToGroup(CToggleGroup * group, const std::vector<std::string> & defs, int startIndex, int endIndex, int btnWidth, int helpStartIndex) const;
|
||||
@ -316,7 +316,7 @@ private:
|
||||
* compOnlyTeamsCntGroup, * waterContentGroup, * monsterStrengthGroup;
|
||||
CButton * showRandMaps;
|
||||
CMapGenOptions mapGenOptions;
|
||||
unique_ptr<CMapInfo> mapInfo;
|
||||
std::unique_ptr<CMapInfo> mapInfo;
|
||||
CFunctionList<void(const CMapInfo *)> mapInfoChanged;
|
||||
};
|
||||
|
||||
@ -463,7 +463,7 @@ class CBonusSelection : public CIntObject
|
||||
{
|
||||
public:
|
||||
CBonusSelection(const std::string & campaignFName);
|
||||
CBonusSelection(shared_ptr<CCampaignState> _ourCampaign);
|
||||
CBonusSelection(std::shared_ptr<CCampaignState> _ourCampaign);
|
||||
~CBonusSelection();
|
||||
|
||||
void showAll(SDL_Surface * to) override;
|
||||
@ -532,7 +532,7 @@ private:
|
||||
CDefHandler * sFlags;
|
||||
|
||||
// Data
|
||||
shared_ptr<CCampaignState> ourCampaign;
|
||||
std::shared_ptr<CCampaignState> ourCampaign;
|
||||
int selectedMap;
|
||||
boost::optional<int> selectedBonus;
|
||||
StartInfo startInfo;
|
||||
|
@ -264,7 +264,7 @@ void CClient::loadGame(const std::string & fname, const bool server, const std::
|
||||
serv = sh.justConnectToServer(ipaddr, realPort);
|
||||
|
||||
CStopWatch tmh;
|
||||
unique_ptr<CLoadFile> loader;
|
||||
std::unique_ptr<CLoadFile> loader;
|
||||
try
|
||||
{
|
||||
std::string clientSaveName = *CResourceHandler::get("local")->getResourceName(ResourceID(fname, EResType::CLIENT_SAVEGAME));
|
||||
@ -461,7 +461,7 @@ void CClient::newGame( CConnection *con, StartInfo *si )
|
||||
}
|
||||
else
|
||||
{
|
||||
installNewPlayerInterface(make_shared<CPlayerInterface>(color), color);
|
||||
installNewPlayerInterface(std::make_shared<CPlayerInterface>(color), color);
|
||||
humanPlayers++;
|
||||
}
|
||||
}
|
||||
@ -477,7 +477,7 @@ void CClient::newGame( CConnection *con, StartInfo *si )
|
||||
if(!gNoGUI)
|
||||
{
|
||||
boost::unique_lock<boost::recursive_mutex> un(*LOCPLINT->pim);
|
||||
auto p = make_shared<CPlayerInterface>(PlayerColor::NEUTRAL);
|
||||
auto p = std::make_shared<CPlayerInterface>(PlayerColor::NEUTRAL);
|
||||
p->observerInDuelMode = true;
|
||||
installNewPlayerInterface(p, boost::none);
|
||||
GH.curInt = p.get();
|
||||
@ -542,7 +542,7 @@ void CClient::serialize(CISer & h, const int version)
|
||||
h & pid & dllname & isHuman;
|
||||
LOG_TRACE_PARAMS(logGlobal, "Loading player %s interface", pid);
|
||||
|
||||
shared_ptr<CGameInterface> nInt;
|
||||
std::shared_ptr<CGameInterface> nInt;
|
||||
if(dllname.length())
|
||||
{
|
||||
if(pid == PlayerColor::NEUTRAL)
|
||||
@ -560,7 +560,7 @@ void CClient::serialize(CISer & h, const int version)
|
||||
else
|
||||
{
|
||||
assert(isHuman);
|
||||
nInt = make_shared<CPlayerInterface>(pid);
|
||||
nInt = std::make_shared<CPlayerInterface>(pid);
|
||||
}
|
||||
|
||||
nInt->dllName = dllname;
|
||||
@ -611,7 +611,7 @@ void CClient::serialize(CISer & h, const int version, const std::set<PlayerColor
|
||||
h & pid & dllname & isHuman;
|
||||
LOG_TRACE_PARAMS(logGlobal, "Loading player %s interface", pid);
|
||||
|
||||
shared_ptr<CGameInterface> nInt;
|
||||
std::shared_ptr<CGameInterface> nInt;
|
||||
if(dllname.length())
|
||||
{
|
||||
if(pid == PlayerColor::NEUTRAL)
|
||||
@ -630,7 +630,7 @@ void CClient::serialize(CISer & h, const int version, const std::set<PlayerColor
|
||||
else
|
||||
{
|
||||
assert(isHuman);
|
||||
nInt = make_shared<CPlayerInterface>(pid);
|
||||
nInt = std::make_shared<CPlayerInterface>(pid);
|
||||
}
|
||||
|
||||
nInt->dllName = dllname;
|
||||
@ -668,11 +668,11 @@ void CClient::handlePack( CPack * pack )
|
||||
delete pack;
|
||||
}
|
||||
|
||||
void CClient::finishCampaign( shared_ptr<CCampaignState> camp )
|
||||
void CClient::finishCampaign( std::shared_ptr<CCampaignState> camp )
|
||||
{
|
||||
}
|
||||
|
||||
void CClient::proposeNextMission(shared_ptr<CCampaignState> camp)
|
||||
void CClient::proposeNextMission(std::shared_ptr<CCampaignState> camp)
|
||||
{
|
||||
GH.pushInt(new CBonusSelection(camp));
|
||||
}
|
||||
@ -724,7 +724,7 @@ void CClient::battleStarted(const BattleInfo * info)
|
||||
// if(battleCallbacks.count(side))
|
||||
// battleCallbacks[side]->setBattle(info);
|
||||
|
||||
shared_ptr<CPlayerInterface> att, def;
|
||||
std::shared_ptr<CPlayerInterface> att, def;
|
||||
auto &leftSide = info->sides[0], &rightSide = info->sides[1];
|
||||
|
||||
|
||||
@ -790,7 +790,7 @@ PlayerColor CClient::getLocalPlayer() const
|
||||
return getCurrentPlayer();
|
||||
}
|
||||
|
||||
void CClient::commenceTacticPhaseForInt(shared_ptr<CBattleGameInterface> battleInt)
|
||||
void CClient::commenceTacticPhaseForInt(std::shared_ptr<CBattleGameInterface> battleInt)
|
||||
{
|
||||
setThreadName("CClient::commenceTacticPhaseForInt");
|
||||
try
|
||||
@ -842,7 +842,7 @@ int CClient::sendRequest(const CPack *request, PlayerColor player)
|
||||
return requestID;
|
||||
}
|
||||
|
||||
void CClient::campaignMapFinished( shared_ptr<CCampaignState> camp )
|
||||
void CClient::campaignMapFinished( std::shared_ptr<CCampaignState> camp )
|
||||
{
|
||||
endGame(false);
|
||||
|
||||
@ -865,7 +865,7 @@ void CClient::campaignMapFinished( shared_ptr<CCampaignState> camp )
|
||||
}
|
||||
}
|
||||
|
||||
void CClient::installNewPlayerInterface(shared_ptr<CGameInterface> gameInterface, boost::optional<PlayerColor> color)
|
||||
void CClient::installNewPlayerInterface(std::shared_ptr<CGameInterface> gameInterface, boost::optional<PlayerColor> color)
|
||||
{
|
||||
boost::unique_lock<boost::recursive_mutex> un(*LOCPLINT->pim);
|
||||
PlayerColor colorUsed = color.get_value_or(PlayerColor::UNFLAGGABLE);
|
||||
@ -876,7 +876,7 @@ void CClient::installNewPlayerInterface(shared_ptr<CGameInterface> gameInterface
|
||||
playerint[colorUsed] = gameInterface;
|
||||
|
||||
logGlobal->traceStream() << boost::format("\tInitializing the interface for player %s") % colorUsed;
|
||||
auto cb = make_shared<CCallback>(gs, color, this);
|
||||
auto cb = std::make_shared<CCallback>(gs, color, this);
|
||||
callbacks[colorUsed] = cb;
|
||||
battleCallbacks[colorUsed] = cb;
|
||||
gameInterface->init(cb);
|
||||
@ -884,7 +884,7 @@ void CClient::installNewPlayerInterface(shared_ptr<CGameInterface> gameInterface
|
||||
installNewBattleInterface(gameInterface, color, false);
|
||||
}
|
||||
|
||||
void CClient::installNewBattleInterface(shared_ptr<CBattleGameInterface> battleInterface, boost::optional<PlayerColor> color, bool needCallback /*= true*/)
|
||||
void CClient::installNewBattleInterface(std::shared_ptr<CBattleGameInterface> battleInterface, boost::optional<PlayerColor> color, bool needCallback /*= true*/)
|
||||
{
|
||||
boost::unique_lock<boost::recursive_mutex> un(*LOCPLINT->pim);
|
||||
PlayerColor colorUsed = color.get_value_or(PlayerColor::UNFLAGGABLE);
|
||||
@ -897,7 +897,7 @@ void CClient::installNewBattleInterface(shared_ptr<CBattleGameInterface> battleI
|
||||
if(needCallback)
|
||||
{
|
||||
logGlobal->traceStream() << boost::format("\tInitializing the battle interface for player %s") % *color;
|
||||
auto cbc = make_shared<CBattleCallback>(gs, color, this);
|
||||
auto cbc = std::make_shared<CBattleCallback>(gs, color, this);
|
||||
battleCallbacks[colorUsed] = cbc;
|
||||
battleInterface->init(cbc);
|
||||
}
|
||||
|
@ -115,17 +115,17 @@ public:
|
||||
/// Class which handles client - server logic
|
||||
class CClient : public IGameCallback
|
||||
{
|
||||
unique_ptr<CPathsInfo> pathInfo;
|
||||
std::unique_ptr<CPathsInfo> pathInfo;
|
||||
public:
|
||||
std::map<PlayerColor,shared_ptr<CCallback> > callbacks; //callbacks given to player interfaces
|
||||
std::map<PlayerColor,shared_ptr<CBattleCallback> > battleCallbacks; //callbacks given to player interfaces
|
||||
std::vector<shared_ptr<IGameEventsReceiver>> privilagedGameEventReceivers; //scripting modules, spectator interfaces
|
||||
std::vector<shared_ptr<IBattleEventsReceiver>> privilagedBattleEventReceivers; //scripting modules, spectator interfaces
|
||||
std::map<PlayerColor, shared_ptr<CGameInterface>> playerint;
|
||||
std::map<PlayerColor, shared_ptr<CBattleGameInterface>> battleints;
|
||||
std::map<PlayerColor,std::shared_ptr<CCallback> > callbacks; //callbacks given to player interfaces
|
||||
std::map<PlayerColor,std::shared_ptr<CBattleCallback> > battleCallbacks; //callbacks given to player interfaces
|
||||
std::vector<std::shared_ptr<IGameEventsReceiver>> privilagedGameEventReceivers; //scripting modules, spectator interfaces
|
||||
std::vector<std::shared_ptr<IBattleEventsReceiver>> privilagedBattleEventReceivers; //scripting modules, spectator interfaces
|
||||
std::map<PlayerColor, std::shared_ptr<CGameInterface>> playerint;
|
||||
std::map<PlayerColor, std::shared_ptr<CBattleGameInterface>> battleints;
|
||||
|
||||
std::map<PlayerColor,std::vector<shared_ptr<IGameEventsReceiver>>> additionalPlayerInts;
|
||||
std::map<PlayerColor,std::vector<shared_ptr<IBattleEventsReceiver>>> additionalBattleInts;
|
||||
std::map<PlayerColor,std::vector<std::shared_ptr<IGameEventsReceiver>>> additionalPlayerInts;
|
||||
std::map<PlayerColor,std::vector<std::shared_ptr<IBattleEventsReceiver>>> additionalBattleInts;
|
||||
|
||||
bool hotSeat;
|
||||
CConnection *serv;
|
||||
@ -146,8 +146,8 @@ public:
|
||||
void newGame(CConnection *con, StartInfo *si); //con - connection to server
|
||||
|
||||
void loadNeutralBattleAI();
|
||||
void installNewPlayerInterface(shared_ptr<CGameInterface> gameInterface, boost::optional<PlayerColor> color);
|
||||
void installNewBattleInterface(shared_ptr<CBattleGameInterface> battleInterface, boost::optional<PlayerColor> color, bool needCallback = true);
|
||||
void installNewPlayerInterface(std::shared_ptr<CGameInterface> gameInterface, boost::optional<PlayerColor> color);
|
||||
void installNewBattleInterface(std::shared_ptr<CBattleGameInterface> battleInterface, boost::optional<PlayerColor> color, bool needCallback = true);
|
||||
std::string aiNameForPlayer(const PlayerSettings &ps, bool battleAI); //empty means no AI -> human
|
||||
|
||||
void endGame(bool closeConnection = true);
|
||||
@ -155,9 +155,9 @@ public:
|
||||
void save(const std::string & fname);
|
||||
void loadGame(const std::string & fname, const bool server = true, const std::vector<int>& humanplayerindices = std::vector<int>(), const int loadnumplayers = 1, int player_ = -1, const std::string & ipaddr = "", const std::string & port = "");
|
||||
void run();
|
||||
void campaignMapFinished( shared_ptr<CCampaignState> camp );
|
||||
void finishCampaign( shared_ptr<CCampaignState> camp );
|
||||
void proposeNextMission(shared_ptr<CCampaignState> camp);
|
||||
void campaignMapFinished( std::shared_ptr<CCampaignState> camp );
|
||||
void finishCampaign( std::shared_ptr<CCampaignState> camp );
|
||||
void proposeNextMission(std::shared_ptr<CCampaignState> camp);
|
||||
|
||||
void invalidatePaths();
|
||||
const CPathsInfo * getPathsInfo(const CGHeroInstance *h);
|
||||
@ -233,7 +233,7 @@ public:
|
||||
|
||||
void handlePack( CPack * pack ); //applies the given pack and deletes it
|
||||
void battleStarted(const BattleInfo * info);
|
||||
void commenceTacticPhaseForInt(shared_ptr<CBattleGameInterface> battleInt); //will be called as separate thread
|
||||
void commenceTacticPhaseForInt(std::shared_ptr<CBattleGameInterface> battleInt); //will be called as separate thread
|
||||
|
||||
void commitPackage(CPackForClient *pack) override;
|
||||
|
||||
|
@ -95,7 +95,7 @@ void CBattleInterface::addNewAnim(CBattleAnimation * anim)
|
||||
CBattleInterface::CBattleInterface(const CCreatureSet * army1, const CCreatureSet * army2,
|
||||
const CGHeroInstance *hero1, const CGHeroInstance *hero2,
|
||||
const SDL_Rect & myRect,
|
||||
shared_ptr<CPlayerInterface> att, shared_ptr<CPlayerInterface> defen)
|
||||
std::shared_ptr<CPlayerInterface> att, std::shared_ptr<CPlayerInterface> defen)
|
||||
: background(nullptr), queue(nullptr), attackingHeroInstance(hero1), defendingHeroInstance(hero2), animCount(0),
|
||||
activeStack(nullptr), mouseHoveredStack(nullptr), stackToActivate(nullptr), selectedStack(nullptr), previouslyHoveredHex(-1),
|
||||
currentlyHoveredHex(-1), attackingHex(-1), stackCanCastSpell(false), creatureCasting(false), spellDestSelectMode(false), spellSelMode(NO_LOCATION), spellToCast(nullptr), sp(nullptr),
|
||||
@ -3260,7 +3260,7 @@ void CBattleInterface::showStacks(SDL_Surface * to, std::vector<const CStack *>
|
||||
}
|
||||
}
|
||||
|
||||
void CBattleInterface::showObstacles(SDL_Surface *to, std::vector<shared_ptr<const CObstacleInstance> > &obstacles)
|
||||
void CBattleInterface::showObstacles(SDL_Surface *to, std::vector<std::shared_ptr<const CObstacleInstance> > &obstacles)
|
||||
{
|
||||
for (auto & obstacle : obstacles)
|
||||
{
|
||||
|
@ -79,7 +79,7 @@ struct BattleObjectsByHex
|
||||
typedef std::vector<int> TWallList;
|
||||
typedef std::vector<const CStack * > TStackList;
|
||||
typedef std::vector<const BattleEffect *> TEffectList;
|
||||
typedef std::vector<shared_ptr<const CObstacleInstance> > TObstacleList;
|
||||
typedef std::vector<std::shared_ptr<const CObstacleInstance> > TObstacleList;
|
||||
|
||||
struct HexData
|
||||
{
|
||||
@ -153,7 +153,7 @@ private:
|
||||
BattleHex currentlyHoveredHex; //number of hex that is supposed to be hovered (for a while it may be inappropriately set, but will be renewed soon)
|
||||
int attackingHex; //hex from which the stack would perform attack with current cursor
|
||||
|
||||
shared_ptr<CPlayerInterface> tacticianInterface; //used during tactics mode, points to the interface of player with higher tactics (can be either attacker or defender in hot-seat), valid onloy for human players
|
||||
std::shared_ptr<CPlayerInterface> tacticianInterface; //used during tactics mode, points to the interface of player with higher tactics (can be either attacker or defender in hot-seat), valid onloy for human players
|
||||
bool tacticsMode;
|
||||
bool stackCanCastSpell; //if true, active stack could possibly cast some target spell
|
||||
bool creatureCasting; //if true, stack currently aims to cats a spell
|
||||
@ -212,8 +212,8 @@ private:
|
||||
friend class CBattleInterface;
|
||||
} * siegeH;
|
||||
|
||||
shared_ptr<CPlayerInterface> attackerInt, defenderInt; //because LOCPLINT is not enough in hotSeat
|
||||
shared_ptr<CPlayerInterface> curInt; //current player interface
|
||||
std::shared_ptr<CPlayerInterface> attackerInt, defenderInt; //because LOCPLINT is not enough in hotSeat
|
||||
std::shared_ptr<CPlayerInterface> curInt; //current player interface
|
||||
const CGHeroInstance * getActiveHero(); //returns hero that can currently cast a spell
|
||||
|
||||
/** Methods for displaying battle screen */
|
||||
@ -229,7 +229,7 @@ private:
|
||||
|
||||
void showAliveStacks(SDL_Surface * to, std::vector<const CStack *> stacks);
|
||||
void showStacks(SDL_Surface * to, std::vector<const CStack *> stacks);
|
||||
void showObstacles(SDL_Surface *to, std::vector<shared_ptr<const CObstacleInstance> > &obstacles);
|
||||
void showObstacles(SDL_Surface *to, std::vector<std::shared_ptr<const CObstacleInstance> > &obstacles);
|
||||
void showPiecesOfWall(SDL_Surface * to, std::vector<int> pieces);
|
||||
|
||||
void showBattleEffects(SDL_Surface *to, const std::vector<const BattleEffect *> &battleEffects);
|
||||
@ -249,7 +249,7 @@ public:
|
||||
ui32 animIDhelper; //for giving IDs for animations
|
||||
static CondSh<bool> animsAreDisplayed; //for waiting with the end of battle for end of anims
|
||||
|
||||
CBattleInterface(const CCreatureSet * army1, const CCreatureSet * army2, const CGHeroInstance *hero1, const CGHeroInstance *hero2, const SDL_Rect & myRect, shared_ptr<CPlayerInterface> att, shared_ptr<CPlayerInterface> defen); //c-tor
|
||||
CBattleInterface(const CCreatureSet * army1, const CCreatureSet * army2, const CGHeroInstance *hero1, const CGHeroInstance *hero2, const SDL_Rect & myRect, std::shared_ptr<CPlayerInterface> att, std::shared_ptr<CPlayerInterface> defen); //c-tor
|
||||
~CBattleInterface(); //d-tor
|
||||
|
||||
//std::vector<TimeInterested*> timeinterested; //animation handling
|
||||
|
@ -66,7 +66,7 @@ private:
|
||||
|
||||
//animation raw data
|
||||
//TODO: use vector instead?
|
||||
unique_ptr<ui8[]> pixelData;
|
||||
std::unique_ptr<ui8[]> pixelData;
|
||||
size_t pixelDataSize;
|
||||
|
||||
// speed of animation, measure in frames per second
|
||||
|
@ -86,7 +86,7 @@ void CQuestMinimap::addQuestMarks (const QuestInfo * q)
|
||||
if (level != tile.z)
|
||||
setLevel(tile.z);
|
||||
|
||||
auto pic = make_shared<CQuestIcon>("VwSymbol.def", 3, x, y);
|
||||
auto pic = std::make_shared<CQuestIcon>("VwSymbol.def", 3, x, y);
|
||||
|
||||
pic->moveBy (Point ( -pic->pos.w/2, -pic->pos.h/2));
|
||||
pic->callback = std::bind (&CQuestMinimap::iconClicked, this);
|
||||
@ -179,7 +179,7 @@ void CQuestLog::recreateLabelList()
|
||||
else
|
||||
text.addReplacement(quests[i].obj->getObjectName()); //get name of the object
|
||||
}
|
||||
auto label = make_shared<CQuestLabel>(Rect(13, 195, 149,31), FONT_SMALL, TOPLEFT, Colors::WHITE, text.toString());
|
||||
auto label = std::make_shared<CQuestLabel>(Rect(13, 195, 149,31), FONT_SMALL, TOPLEFT, Colors::WHITE, text.toString());
|
||||
label->disable();
|
||||
|
||||
label->callback = std::bind(&CQuestLog::selectQuest, this, i, currentLabel);
|
||||
|
@ -58,7 +58,7 @@ public:
|
||||
|
||||
class CQuestMinimap : public CMinimap
|
||||
{
|
||||
std::vector <shared_ptr<CQuestIcon>> icons;
|
||||
std::vector <std::shared_ptr<CQuestIcon>> icons;
|
||||
|
||||
void clickLeft(tribool down, bool previousState) override{}; //minimap ignores clicking on its surface
|
||||
void iconClicked();
|
||||
@ -86,7 +86,7 @@ class CQuestLog : public CWindowObject
|
||||
CLabel * hideCompleteLabel;
|
||||
|
||||
const std::vector<QuestInfo> quests;
|
||||
std::vector <shared_ptr<CQuestLabel>> labels;
|
||||
std::vector <std::shared_ptr<CQuestLabel>> labels;
|
||||
CTextBox * description;
|
||||
CQuestMinimap * minimap;
|
||||
CSlider * slider; //scrolls quests
|
||||
|
@ -373,7 +373,7 @@ BattleInfo * BattleInfo::setupBattle( int3 tile, ETerrainType terrain, BFieldTyp
|
||||
|
||||
try
|
||||
{
|
||||
auto obstPtr = make_shared<CObstacleInstance>();
|
||||
auto obstPtr = std::make_shared<CObstacleInstance>();
|
||||
obstPtr->obstacleType = CObstacleInstance::ABSOLUTE_OBSTACLE;
|
||||
obstPtr->ID = obidgen.getSuchNumber(appropriateAbsoluteObstacle);
|
||||
obstPtr->uniqueID = curB->obstacles.size();
|
||||
@ -422,7 +422,7 @@ BattleInfo * BattleInfo::setupBattle( int3 tile, ETerrainType terrain, BFieldTyp
|
||||
|
||||
RangeGenerator posgenerator(18, 168, ourRand);
|
||||
|
||||
auto obstPtr = make_shared<CObstacleInstance>();
|
||||
auto obstPtr = std::make_shared<CObstacleInstance>();
|
||||
obstPtr->ID = obid;
|
||||
obstPtr->pos = posgenerator.getSuchNumber(validPosition);
|
||||
obstPtr->uniqueID = curB->obstacles.size();
|
||||
@ -539,7 +539,7 @@ BattleInfo * BattleInfo::setupBattle( int3 tile, ETerrainType terrain, BFieldTyp
|
||||
}
|
||||
|
||||
//moat
|
||||
auto moat = make_shared<MoatObstacle>();
|
||||
auto moat = std::make_shared<MoatObstacle>();
|
||||
moat->ID = curB->town->subID;
|
||||
moat->obstacleType = CObstacleInstance::MOAT;
|
||||
moat->uniqueID = curB->obstacles.size();
|
||||
@ -584,19 +584,19 @@ BattleInfo * BattleInfo::setupBattle( int3 tile, ETerrainType terrain, BFieldTyp
|
||||
|
||||
case BFieldType::HOLY_GROUND:
|
||||
{
|
||||
curB->addNewBonus(makeFeature(Bonus::MORALE, Bonus::ONE_BATTLE, 0, +1, Bonus::TERRAIN_OVERLAY)->addLimiter(make_shared<CreatureAlignmentLimiter>(EAlignment::GOOD)));
|
||||
curB->addNewBonus(makeFeature(Bonus::MORALE, Bonus::ONE_BATTLE, 0, -1, Bonus::TERRAIN_OVERLAY)->addLimiter(make_shared<CreatureAlignmentLimiter>(EAlignment::EVIL)));
|
||||
curB->addNewBonus(makeFeature(Bonus::MORALE, Bonus::ONE_BATTLE, 0, +1, Bonus::TERRAIN_OVERLAY)->addLimiter(std::make_shared<CreatureAlignmentLimiter>(EAlignment::GOOD)));
|
||||
curB->addNewBonus(makeFeature(Bonus::MORALE, Bonus::ONE_BATTLE, 0, -1, Bonus::TERRAIN_OVERLAY)->addLimiter(std::make_shared<CreatureAlignmentLimiter>(EAlignment::EVIL)));
|
||||
break;
|
||||
}
|
||||
case BFieldType::CLOVER_FIELD:
|
||||
{ //+2 luck bonus for neutral creatures
|
||||
curB->addNewBonus(makeFeature(Bonus::LUCK, Bonus::ONE_BATTLE, 0, +2, Bonus::TERRAIN_OVERLAY)->addLimiter(make_shared<CreatureAlignmentLimiter>(EAlignment::NEUTRAL)));
|
||||
curB->addNewBonus(makeFeature(Bonus::LUCK, Bonus::ONE_BATTLE, 0, +2, Bonus::TERRAIN_OVERLAY)->addLimiter(std::make_shared<CreatureAlignmentLimiter>(EAlignment::NEUTRAL)));
|
||||
break;
|
||||
}
|
||||
case BFieldType::EVIL_FOG:
|
||||
{
|
||||
curB->addNewBonus(makeFeature(Bonus::MORALE, Bonus::ONE_BATTLE, 0, -1, Bonus::TERRAIN_OVERLAY)->addLimiter(make_shared<CreatureAlignmentLimiter>(EAlignment::GOOD)));
|
||||
curB->addNewBonus(makeFeature(Bonus::MORALE, Bonus::ONE_BATTLE, 0, +1, Bonus::TERRAIN_OVERLAY)->addLimiter(make_shared<CreatureAlignmentLimiter>(EAlignment::EVIL)));
|
||||
curB->addNewBonus(makeFeature(Bonus::MORALE, Bonus::ONE_BATTLE, 0, -1, Bonus::TERRAIN_OVERLAY)->addLimiter(std::make_shared<CreatureAlignmentLimiter>(EAlignment::GOOD)));
|
||||
curB->addNewBonus(makeFeature(Bonus::MORALE, Bonus::ONE_BATTLE, 0, +1, Bonus::TERRAIN_OVERLAY)->addLimiter(std::make_shared<CreatureAlignmentLimiter>(EAlignment::EVIL)));
|
||||
break;
|
||||
}
|
||||
case BFieldType::CURSED_GROUND:
|
||||
@ -612,7 +612,7 @@ BattleInfo * BattleInfo::setupBattle( int3 tile, ETerrainType terrain, BFieldTyp
|
||||
//overlay premies given
|
||||
|
||||
//native terrain bonuses
|
||||
auto nativeTerrain = make_shared<CreatureNativeTerrainLimiter>(curB->terrainType);
|
||||
auto nativeTerrain = std::make_shared<CreatureNativeTerrainLimiter>(curB->terrainType);
|
||||
curB->addNewBonus(makeFeature(Bonus::STACKS_SPEED, Bonus::ONE_BATTLE, 0, 1, Bonus::TERRAIN_NATIVE)->addLimiter(nativeTerrain));
|
||||
curB->addNewBonus(makeFeature(Bonus::PRIMARY_SKILL, Bonus::ONE_BATTLE, PrimarySkill::ATTACK, 1, Bonus::TERRAIN_NATIVE)->addLimiter(nativeTerrain));
|
||||
curB->addNewBonus(makeFeature(Bonus::PRIMARY_SKILL, Bonus::ONE_BATTLE, PrimarySkill::DEFENSE, 1, Bonus::TERRAIN_NATIVE)->addLimiter(nativeTerrain));
|
||||
@ -701,13 +701,13 @@ int BattleInfo::getIdForNewStack() const
|
||||
return 0;
|
||||
}
|
||||
|
||||
shared_ptr<CObstacleInstance> BattleInfo::getObstacleOnTile(BattleHex tile) const
|
||||
std::shared_ptr<CObstacleInstance> BattleInfo::getObstacleOnTile(BattleHex tile) const
|
||||
{
|
||||
for(auto &obs : obstacles)
|
||||
if(vstd::contains(obs->getAffectedTiles(), tile))
|
||||
return obs;
|
||||
|
||||
return shared_ptr<CObstacleInstance>();
|
||||
return std::shared_ptr<CObstacleInstance>();
|
||||
}
|
||||
|
||||
BattlefieldBI::BattlefieldBI BattleInfo::battlefieldTypeToBI(BFieldType bfieldType)
|
||||
|
@ -83,7 +83,7 @@ struct DLL_LINKAGE BattleInfo : public CBonusSystemNode, public CBattleInfoCallb
|
||||
const CGTownInstance * town; //used during town siege, nullptr if this is not a siege (note that fortless town IS also a siege)
|
||||
int3 tile; //for background and bonuses
|
||||
std::vector<CStack*> stacks;
|
||||
std::vector<shared_ptr<CObstacleInstance> > obstacles;
|
||||
std::vector<std::shared_ptr<CObstacleInstance> > obstacles;
|
||||
SiegeInfo si;
|
||||
|
||||
BFieldType battlefieldType; //like !!BA:B
|
||||
@ -124,7 +124,7 @@ struct DLL_LINKAGE BattleInfo : public CBonusSystemNode, public CBattleInfoCallb
|
||||
//std::vector<BattleHex> getAccessibility(const CStack * stack, bool addOccupiable, std::vector<BattleHex> * attackable = nullptr, bool forPassingBy = false) const; //returns vector of accessible tiles (taking into account the creature range)
|
||||
|
||||
//bool isObstacleVisibleForSide(const CObstacleInstance &obstacle, ui8 side) const;
|
||||
shared_ptr<CObstacleInstance> getObstacleOnTile(BattleHex tile) const;
|
||||
std::shared_ptr<CObstacleInstance> getObstacleOnTile(BattleHex tile) const;
|
||||
std::set<BattleHex> getStoppers(bool whichSidePerspective) const;
|
||||
|
||||
ui32 calculateDmg(const CStack* attacker, const CStack* defender, const CGHeroInstance * attackerHero, const CGHeroInstance * defendingHero, bool shooting, ui8 charge, bool lucky, bool unlucky, bool deathBlow, bool ballistaDoubleDmg, CRandomGenerator & rand); //charge - number of hexes travelled before attack (for champion's jousting)
|
||||
|
@ -502,7 +502,7 @@ ArtifactID CArtHandler::pickRandomArtifact(CRandomGenerator & rand, int flags)
|
||||
return pickRandomArtifact(rand, flags, [](ArtifactID){ return true;});
|
||||
}
|
||||
|
||||
Bonus *createBonus(Bonus::BonusType type, int val, int subtype, Bonus::ValueType valType, shared_ptr<ILimiter> limiter = shared_ptr<ILimiter>(), int additionalInfo = 0)
|
||||
Bonus *createBonus(Bonus::BonusType type, int val, int subtype, Bonus::ValueType valType, std::shared_ptr<ILimiter> limiter = std::shared_ptr<ILimiter>(), int additionalInfo = 0)
|
||||
{
|
||||
auto added = new Bonus(Bonus::PERMANENT,type,Bonus::ARTIFACT,val,-1,subtype);
|
||||
added->additionalInfo = additionalInfo;
|
||||
@ -511,7 +511,7 @@ Bonus *createBonus(Bonus::BonusType type, int val, int subtype, Bonus::ValueType
|
||||
return added;
|
||||
}
|
||||
|
||||
Bonus *createBonus(Bonus::BonusType type, int val, int subtype, shared_ptr<IPropagator> propagator = shared_ptr<IPropagator>(), int additionalInfo = 0)
|
||||
Bonus *createBonus(Bonus::BonusType type, int val, int subtype, std::shared_ptr<IPropagator> propagator = std::shared_ptr<IPropagator>(), int additionalInfo = 0)
|
||||
{
|
||||
auto added = new Bonus(Bonus::PERMANENT,type,Bonus::ARTIFACT,val,-1,subtype);
|
||||
added->additionalInfo = additionalInfo;
|
||||
@ -520,12 +520,12 @@ Bonus *createBonus(Bonus::BonusType type, int val, int subtype, shared_ptr<IProp
|
||||
return added;
|
||||
}
|
||||
|
||||
void CArtHandler::giveArtBonus( ArtifactID aid, Bonus::BonusType type, int val, int subtype, Bonus::ValueType valType, shared_ptr<ILimiter> limiter, int additionalInfo)
|
||||
void CArtHandler::giveArtBonus( ArtifactID aid, Bonus::BonusType type, int val, int subtype, Bonus::ValueType valType, std::shared_ptr<ILimiter> limiter, int additionalInfo)
|
||||
{
|
||||
giveArtBonus(aid, createBonus(type, val, subtype, valType, limiter, additionalInfo));
|
||||
}
|
||||
|
||||
void CArtHandler::giveArtBonus(ArtifactID aid, Bonus::BonusType type, int val, int subtype, shared_ptr<IPropagator> propagator /*= nullptr*/, int additionalInfo)
|
||||
void CArtHandler::giveArtBonus(ArtifactID aid, Bonus::BonusType type, int val, int subtype, std::shared_ptr<IPropagator> propagator /*= nullptr*/, int additionalInfo)
|
||||
{
|
||||
giveArtBonus(aid, createBonus(type, val, subtype, propagator, additionalInfo));
|
||||
}
|
||||
|
@ -253,8 +253,8 @@ private:
|
||||
void loadComponents(CArtifact * art, const JsonNode & node);
|
||||
void loadGrowingArt(CGrowingArtifact * art, const JsonNode & node);
|
||||
|
||||
void giveArtBonus(ArtifactID aid, Bonus::BonusType type, int val, int subtype = -1, Bonus::ValueType valType = Bonus::BASE_NUMBER, shared_ptr<ILimiter> limiter = shared_ptr<ILimiter>(), int additionalinfo = 0);
|
||||
void giveArtBonus(ArtifactID aid, Bonus::BonusType type, int val, int subtype, shared_ptr<IPropagator> propagator, int additionalinfo = 0);
|
||||
void giveArtBonus(ArtifactID aid, Bonus::BonusType type, int val, int subtype = -1, Bonus::ValueType valType = Bonus::BASE_NUMBER, std::shared_ptr<ILimiter> limiter = std::shared_ptr<ILimiter>(), int additionalinfo = 0);
|
||||
void giveArtBonus(ArtifactID aid, Bonus::BonusType type, int val, int subtype, std::shared_ptr<IPropagator> propagator, int additionalinfo = 0);
|
||||
void giveArtBonus(ArtifactID aid, Bonus *bonus);
|
||||
|
||||
void erasePickedArt(ArtifactID id);
|
||||
|
@ -130,9 +130,9 @@ BFieldType CBattleInfoEssentials::battleGetBattlefieldType() const
|
||||
return getBattle()->battlefieldType;
|
||||
}
|
||||
|
||||
std::vector<shared_ptr<const CObstacleInstance> > CBattleInfoEssentials::battleGetAllObstacles(boost::optional<BattlePerspective::BattlePerspective> perspective /*= boost::none*/) const
|
||||
std::vector<std::shared_ptr<const CObstacleInstance> > CBattleInfoEssentials::battleGetAllObstacles(boost::optional<BattlePerspective::BattlePerspective> perspective /*= boost::none*/) const
|
||||
{
|
||||
std::vector<shared_ptr<const CObstacleInstance> > ret;
|
||||
std::vector<std::shared_ptr<const CObstacleInstance> > ret;
|
||||
RETURN_IF_NOT_BATTLE(ret);
|
||||
|
||||
if(!perspective)
|
||||
@ -1100,9 +1100,9 @@ std::pair<ui32, ui32> CBattleInfoCallback::battleEstimateDamage(const BattleAtta
|
||||
return ret;
|
||||
}
|
||||
|
||||
shared_ptr<const CObstacleInstance> CBattleInfoCallback::battleGetObstacleOnPos(BattleHex tile, bool onlyBlocking /*= true*/) const
|
||||
std::shared_ptr<const CObstacleInstance> CBattleInfoCallback::battleGetObstacleOnPos(BattleHex tile, bool onlyBlocking /*= true*/) const
|
||||
{
|
||||
RETURN_IF_NOT_BATTLE(shared_ptr<const CObstacleInstance>());
|
||||
RETURN_IF_NOT_BATTLE(std::shared_ptr<const CObstacleInstance>());
|
||||
|
||||
for(auto &obs : battleGetAllObstacles())
|
||||
{
|
||||
@ -1113,7 +1113,7 @@ shared_ptr<const CObstacleInstance> CBattleInfoCallback::battleGetObstacleOnPos(
|
||||
}
|
||||
}
|
||||
|
||||
return shared_ptr<const CObstacleInstance>();
|
||||
return std::shared_ptr<const CObstacleInstance>();
|
||||
}
|
||||
|
||||
AccessibilityInfo CBattleInfoCallback::getAccesibility() const
|
||||
|
@ -170,7 +170,7 @@ public:
|
||||
|
||||
ETerrainType battleTerrainType() const;
|
||||
BFieldType battleGetBattlefieldType() const;
|
||||
std::vector<shared_ptr<const CObstacleInstance> > battleGetAllObstacles(boost::optional<BattlePerspective::BattlePerspective> perspective = boost::none) const; //returns all obstacles on the battlefield
|
||||
std::vector<std::shared_ptr<const CObstacleInstance> > battleGetAllObstacles(boost::optional<BattlePerspective::BattlePerspective> perspective = boost::none) const; //returns all obstacles on the battlefield
|
||||
|
||||
/** @brief Main method for getting battle stacks
|
||||
*
|
||||
@ -243,7 +243,7 @@ public:
|
||||
//battle
|
||||
boost::optional<int> battleIsFinished() const; //return none if battle is ongoing; otherwise the victorious side (0/1) or 2 if it is a draw
|
||||
|
||||
shared_ptr<const CObstacleInstance> battleGetObstacleOnPos(BattleHex tile, bool onlyBlocking = true) const; //blocking obstacles makes tile inaccessible, others cause special effects (like Land Mines, Moat, Quicksands)
|
||||
std::shared_ptr<const CObstacleInstance> battleGetObstacleOnPos(BattleHex tile, bool onlyBlocking = true) const; //blocking obstacles makes tile inaccessible, others cause special effects (like Land Mines, Moat, Quicksands)
|
||||
const CStack * battleGetStackByPos(BattleHex pos, bool onlyAlive = true) const; //returns stack info by given pos
|
||||
void battleGetStackQueue(std::vector<const CStack *> &out, const int howMany, const int turn = 0, int lastMoved = -1) const;
|
||||
void battleGetStackCountOutsideHexes(bool *ac) const; // returns hexes which when in front of a stack cause us to move the amount box back
|
||||
|
@ -723,7 +723,7 @@ void CCreatureHandler::loadStackExperience(CCreature * creature, const JsonNode
|
||||
{
|
||||
if (val.Bool() == true)
|
||||
{
|
||||
bonus->limiter = make_shared<RankRangeLimiter>(RankRangeLimiter(lowerLimit));
|
||||
bonus->limiter = std::make_shared<RankRangeLimiter>(RankRangeLimiter(lowerLimit));
|
||||
creature->addNewBonus (new Bonus(*bonus)); //bonuses must be unique objects
|
||||
break; //TODO: allow bonuses to turn off?
|
||||
}
|
||||
|
@ -475,7 +475,7 @@ const TerrainTile * CGameInfoCallback::getTile( int3 tile, bool verbose) const
|
||||
}
|
||||
|
||||
//TODO: typedef?
|
||||
shared_ptr<boost::multi_array<TerrainTile*, 3>> CGameInfoCallback::getAllVisibleTiles() const
|
||||
std::shared_ptr<boost::multi_array<TerrainTile*, 3>> CGameInfoCallback::getAllVisibleTiles() const
|
||||
{
|
||||
assert(player.is_initialized());
|
||||
auto team = getPlayerTeam(player.get());
|
||||
@ -496,7 +496,7 @@ shared_ptr<boost::multi_array<TerrainTile*, 3>> CGameInfoCallback::getAllVisible
|
||||
else
|
||||
tileArray[x][y][z] = nullptr;
|
||||
}
|
||||
return make_shared<boost::multi_array<TerrainTile*, 3>>(tileArray);
|
||||
return std::make_shared<boost::multi_array<TerrainTile*, 3>>(tileArray);
|
||||
}
|
||||
|
||||
EBuildingState::EBuildingState CGameInfoCallback::canBuildStructure( const CGTownInstance *t, BuildingID ID )
|
||||
|
@ -91,7 +91,7 @@ public:
|
||||
const CMapHeader * getMapHeader()const;
|
||||
int3 getMapSize() const; //returns size of map - z is 1 for one - level map and 2 for two level map
|
||||
const TerrainTile * getTile(int3 tile, bool verbose = true) const;
|
||||
shared_ptr<boost::multi_array<TerrainTile*, 3>> getAllVisibleTiles() const;
|
||||
std::shared_ptr<boost::multi_array<TerrainTile*, 3>> getAllVisibleTiles() const;
|
||||
bool isInTheMap(const int3 &pos) const;
|
||||
|
||||
//town
|
||||
|
@ -24,19 +24,19 @@
|
||||
#ifdef VCMI_ANDROID
|
||||
// we can't use shared libraries on Android so here's a hack
|
||||
extern "C" DLL_EXPORT void VCAI_GetAiName(char* name);
|
||||
extern "C" DLL_EXPORT void VCAI_GetNewAI(shared_ptr<CGlobalAI> &out);
|
||||
extern "C" DLL_EXPORT void VCAI_GetNewAI(std::shared_ptr<CGlobalAI> &out);
|
||||
|
||||
extern "C" DLL_EXPORT void StupidAI_GetAiName(char* name);
|
||||
extern "C" DLL_EXPORT void StupidAI_GetNewBattleAI(shared_ptr<CGlobalAI> &out);
|
||||
extern "C" DLL_EXPORT void StupidAI_GetNewBattleAI(std::shared_ptr<CGlobalAI> &out);
|
||||
|
||||
extern "C" DLL_EXPORT void BattleAI_GetAiName(char* name);
|
||||
extern "C" DLL_EXPORT void BattleAI_GetNewBattleAI(shared_ptr<CBattleGameInterface> &out);
|
||||
extern "C" DLL_EXPORT void BattleAI_GetNewBattleAI(std::shared_ptr<CBattleGameInterface> &out);
|
||||
#endif
|
||||
|
||||
template<typename rett>
|
||||
shared_ptr<rett> createAny(const boost::filesystem::path& libpath, const std::string& methodName)
|
||||
std::shared_ptr<rett> createAny(const boost::filesystem::path& libpath, const std::string& methodName)
|
||||
{
|
||||
typedef void(*TGetAIFun)(shared_ptr<rett>&);
|
||||
typedef void(*TGetAIFun)(std::shared_ptr<rett>&);
|
||||
typedef void(*TGetNameFun)(char*);
|
||||
|
||||
char temp[150];
|
||||
@ -102,7 +102,7 @@ shared_ptr<rett> createAny(const boost::filesystem::path& libpath, const std::st
|
||||
getName(temp);
|
||||
logGlobal->infoStream() << "Loaded " << temp;
|
||||
|
||||
shared_ptr<rett> ret;
|
||||
std::shared_ptr<rett> ret;
|
||||
getAI(ret);
|
||||
if(!ret)
|
||||
logGlobal->errorStream() << "Cannot get AI!";
|
||||
@ -111,7 +111,7 @@ shared_ptr<rett> createAny(const boost::filesystem::path& libpath, const std::st
|
||||
}
|
||||
|
||||
template<typename rett>
|
||||
shared_ptr<rett> createAnyAI(std::string dllname, const std::string& methodName)
|
||||
std::shared_ptr<rett> createAnyAI(std::string dllname, const std::string& methodName)
|
||||
{
|
||||
logGlobal->infoStream() << "Opening " << dllname;
|
||||
const boost::filesystem::path filePath =
|
||||
@ -121,17 +121,17 @@ shared_ptr<rett> createAnyAI(std::string dllname, const std::string& methodName)
|
||||
return ret;
|
||||
}
|
||||
|
||||
shared_ptr<CGlobalAI> CDynLibHandler::getNewAI(std::string dllname)
|
||||
std::shared_ptr<CGlobalAI> CDynLibHandler::getNewAI(std::string dllname)
|
||||
{
|
||||
return createAnyAI<CGlobalAI>(dllname, "GetNewAI");
|
||||
}
|
||||
|
||||
shared_ptr<CBattleGameInterface> CDynLibHandler::getNewBattleAI(std::string dllname )
|
||||
std::shared_ptr<CBattleGameInterface> CDynLibHandler::getNewBattleAI(std::string dllname )
|
||||
{
|
||||
return createAnyAI<CBattleGameInterface>(dllname, "GetNewBattleAI");
|
||||
}
|
||||
|
||||
shared_ptr<CScriptingModule> CDynLibHandler::getNewScriptingModule(std::string dllname)
|
||||
std::shared_ptr<CScriptingModule> CDynLibHandler::getNewScriptingModule(std::string dllname)
|
||||
{
|
||||
return createAny<CScriptingModule>(dllname, "GetNewModule");
|
||||
}
|
||||
|
@ -67,7 +67,7 @@ public:
|
||||
std::string dllName;
|
||||
|
||||
virtual ~CBattleGameInterface() {};
|
||||
virtual void init(shared_ptr<CBattleCallback> CB){};
|
||||
virtual void init(std::shared_ptr<CBattleCallback> CB){};
|
||||
|
||||
//battle call-ins
|
||||
virtual BattleAction activeStack(const CStack * stack)=0; //called when it's turn of that stack
|
||||
@ -82,7 +82,7 @@ public:
|
||||
class DLL_LINKAGE CGameInterface : public CBattleGameInterface, public IGameEventsReceiver
|
||||
{
|
||||
public:
|
||||
virtual void init(shared_ptr<CCallback> CB){};
|
||||
virtual void init(std::shared_ptr<CCallback> CB){};
|
||||
virtual void yourTurn(){}; //called AFTER playerStartsTurn(player)
|
||||
|
||||
//pskill is gained primary skill, interface has to choose one of given skills and call callback with selection id
|
||||
@ -105,9 +105,9 @@ public:
|
||||
class DLL_LINKAGE CDynLibHandler
|
||||
{
|
||||
public:
|
||||
static shared_ptr<CGlobalAI> getNewAI(std::string dllname);
|
||||
static shared_ptr<CBattleGameInterface> getNewBattleAI(std::string dllname);
|
||||
static shared_ptr<CScriptingModule> getNewScriptingModule(std::string dllname);
|
||||
static std::shared_ptr<CGlobalAI> getNewAI(std::string dllname);
|
||||
static std::shared_ptr<CBattleGameInterface> getNewBattleAI(std::string dllname);
|
||||
static std::shared_ptr<CScriptingModule> getNewScriptingModule(std::string dllname);
|
||||
};
|
||||
|
||||
class DLL_LINKAGE CGlobalAI : public CGameInterface // AI class (to derivate)
|
||||
@ -123,8 +123,8 @@ class DLL_LINKAGE CAdventureAI : public CGlobalAI
|
||||
public:
|
||||
CAdventureAI() {};
|
||||
|
||||
shared_ptr<CBattleGameInterface> battleAI;
|
||||
shared_ptr<CBattleCallback> cbc;
|
||||
std::shared_ptr<CBattleGameInterface> battleAI;
|
||||
std::shared_ptr<CBattleCallback> cbc;
|
||||
|
||||
virtual std::string getBattleAIName() const = 0; //has to return name of the battle AI to be used
|
||||
|
||||
|
@ -3177,7 +3177,7 @@ DuelParameters DuelParameters::fromJSON(const std::string &fname)
|
||||
|
||||
for(const JsonNode &n : duelData["obstacles"].Vector())
|
||||
{
|
||||
auto oi = make_shared<CObstacleInstance>();
|
||||
auto oi = std::make_shared<CObstacleInstance>();
|
||||
if(n.getType() == JsonNode::DATA_VECTOR)
|
||||
{
|
||||
oi->ID = n.Vector()[0].Float();
|
||||
|
@ -149,7 +149,7 @@ struct DLL_EXPORT DuelParameters
|
||||
}
|
||||
} sides[2];
|
||||
|
||||
std::vector<shared_ptr<CObstacleInstance> > obstacles;
|
||||
std::vector<std::shared_ptr<CObstacleInstance> > obstacles;
|
||||
|
||||
static DuelParameters fromJSON(const std::string &fname);
|
||||
|
||||
|
@ -162,7 +162,7 @@ private:
|
||||
CPathsInfo & out;
|
||||
const CGHeroInstance * hero;
|
||||
const std::vector<std::vector<std::vector<ui8> > > &FoW;
|
||||
unique_ptr<CPathfinderHelper> hlp;
|
||||
std::unique_ptr<CPathfinderHelper> hlp;
|
||||
|
||||
enum EPatrolState {
|
||||
PATROL_NONE = 0,
|
||||
@ -244,7 +244,7 @@ struct DLL_LINKAGE TurnInfo
|
||||
|
||||
BonusCache(TBonusListPtr bonusList);
|
||||
};
|
||||
unique_ptr<BonusCache> bonusCache;
|
||||
std::unique_ptr<BonusCache> bonusCache;
|
||||
|
||||
const CGHeroInstance * hero;
|
||||
TBonusListPtr bonuses;
|
||||
|
@ -439,7 +439,7 @@ CTypeList::TypeInfoPtr CTypeList::registerType( const std::type_info *type )
|
||||
return typeDescr; //type found, return ptr to structure
|
||||
|
||||
//type not found - add it to the list and return given ID
|
||||
auto newType = make_shared<TypeDescriptor>();
|
||||
auto newType = std::make_shared<TypeDescriptor>();
|
||||
newType->typeID = typeInfos.size() + 1;
|
||||
newType->name = type->name();
|
||||
typeInfos[type] = newType;
|
||||
@ -604,7 +604,7 @@ int CLoadIntegrityValidator::read( void * data, unsigned size )
|
||||
return ret;
|
||||
}
|
||||
|
||||
unique_ptr<CLoadFile> CLoadIntegrityValidator::decay()
|
||||
std::unique_ptr<CLoadFile> CLoadIntegrityValidator::decay()
|
||||
{
|
||||
primaryFile->serializer.loadedPointers = this->serializer.loadedPointers;
|
||||
primaryFile->serializer.loadedPointersTypes = this->serializer.loadedPointersTypes;
|
||||
|
@ -82,12 +82,12 @@ enum SerializationLvl
|
||||
struct TypeComparer
|
||||
{
|
||||
bool operator()(const std::type_info *a, const std::type_info *b) const
|
||||
{
|
||||
#ifndef __APPLE__
|
||||
return a->before(*b);
|
||||
#else
|
||||
return strcmp(a->name(), b->name()) < 0;
|
||||
#endif
|
||||
{
|
||||
#ifndef __APPLE__
|
||||
return a->before(*b);
|
||||
#else
|
||||
return strcmp(a->name(), b->name()) < 0;
|
||||
#endif
|
||||
}
|
||||
};
|
||||
|
||||
@ -192,7 +192,7 @@ private:
|
||||
THROW_FORMAT("Cannot find caster for conversion %s -> %s which is needed to cast %s -> %s", from->name % to->name % fromArg->name() % toArg->name());
|
||||
|
||||
auto &caster = casters.at(castingPair);
|
||||
ptr = (*caster.*CastingFunction)(ptr); //Why does unique_ptr not have operator->* ..?
|
||||
ptr = (*caster.*CastingFunction)(ptr); //Why does std::unique_ptr not have operator->* ..?
|
||||
}
|
||||
|
||||
return ptr;
|
||||
@ -667,15 +667,15 @@ public:
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
class CPointerSaver : public CBasicPointerSaver
|
||||
class CPointerSaver : public CBasicPointerSaver
|
||||
{
|
||||
public:
|
||||
void savePtr(CSaverBase &ar, const void *data) const override
|
||||
{
|
||||
{
|
||||
COSer &s = static_cast<COSer&>(ar);
|
||||
const T *ptr = static_cast<const T*>(data);
|
||||
const T *ptr = static_cast<const T*>(data);
|
||||
//T is most derived known type, it's time to call actual serialize
|
||||
const_cast<T*>(ptr)->serialize(s,version);
|
||||
const_cast<T*>(ptr)->serialize(s,version);
|
||||
}
|
||||
};
|
||||
|
||||
@ -785,7 +785,7 @@ public:
|
||||
|
||||
//write type identifier
|
||||
ui16 tid = typeList.getTypeID(data);
|
||||
*this << tid;
|
||||
*this << tid;
|
||||
|
||||
this->savePointerHlp(tid, data);
|
||||
}
|
||||
@ -849,13 +849,13 @@ public:
|
||||
const_cast<T&>(data).serialize(*this,version);
|
||||
}
|
||||
template <typename T>
|
||||
void saveSerializable(const shared_ptr<T> &data)
|
||||
void saveSerializable(const std::shared_ptr<T> &data)
|
||||
{
|
||||
T *internalPtr = data.get();
|
||||
*this << internalPtr;
|
||||
}
|
||||
template <typename T>
|
||||
void saveSerializable(const unique_ptr<T> &data)
|
||||
void saveSerializable(const std::unique_ptr<T> &data)
|
||||
{
|
||||
T *internalPtr = data.get();
|
||||
*this << internalPtr;
|
||||
@ -1332,7 +1332,7 @@ public:
|
||||
|
||||
|
||||
template <typename T>
|
||||
void loadSerializable(shared_ptr<T> &data)
|
||||
void loadSerializable(std::shared_ptr<T> &data)
|
||||
{
|
||||
typedef typename boost::remove_const<T>::type NonConstT;
|
||||
NonConstT *internalPtr;
|
||||
@ -1353,7 +1353,7 @@ public:
|
||||
auto typeWeNeedToReturn = typeList.getTypeInfo<T>();
|
||||
if(*actualType == *typeWeNeedToReturn)
|
||||
{
|
||||
// No casting needed, just unpack already stored shared_ptr and return it
|
||||
// No casting needed, just unpack already stored std::shared_ptr and return it
|
||||
data = boost::any_cast<std::shared_ptr<T>>(itr->second);
|
||||
}
|
||||
else
|
||||
@ -1383,7 +1383,7 @@ public:
|
||||
data.reset();
|
||||
}
|
||||
template <typename T>
|
||||
void loadSerializable(unique_ptr<T> &data)
|
||||
void loadSerializable(std::unique_ptr<T> &data)
|
||||
{
|
||||
T *internalPtr;
|
||||
*this >> internalPtr;
|
||||
@ -1551,7 +1551,7 @@ public:
|
||||
COSer serializer;
|
||||
|
||||
std::string fName;
|
||||
unique_ptr<std::ofstream> sfile;
|
||||
std::unique_ptr<std::ofstream> sfile;
|
||||
|
||||
CSaveFile(const std::string &fname); //throws!
|
||||
~CSaveFile();
|
||||
@ -1578,7 +1578,7 @@ public:
|
||||
CISer serializer;
|
||||
|
||||
std::string fName;
|
||||
unique_ptr<boost::filesystem::ifstream> sfile;
|
||||
std::unique_ptr<boost::filesystem::ifstream> sfile;
|
||||
|
||||
CLoadFile(const boost::filesystem::path & fname, int minimalVersion = version); //throws!
|
||||
~CLoadFile();
|
||||
@ -1603,7 +1603,7 @@ class DLL_LINKAGE CLoadIntegrityValidator
|
||||
{
|
||||
public:
|
||||
CISer serializer;
|
||||
unique_ptr<CLoadFile> primaryFile, controlFile;
|
||||
std::unique_ptr<CLoadFile> primaryFile, controlFile;
|
||||
bool foundDesync;
|
||||
|
||||
CLoadIntegrityValidator(const std::string &primaryFileName, const std::string &controlFileName, int minimalVersion = version); //throws!
|
||||
@ -1611,7 +1611,7 @@ public:
|
||||
int read( void * data, unsigned size) override; //throws!
|
||||
void checkMagicBytes(const std::string &text);
|
||||
|
||||
unique_ptr<CLoadFile> decay(); //returns primary file. CLoadIntegrityValidator stops being usable anymore
|
||||
std::unique_ptr<CLoadFile> decay(); //returns primary file. CLoadIntegrityValidator stops being usable anymore
|
||||
};
|
||||
|
||||
typedef boost::asio::basic_stream_socket < boost::asio::ip::tcp , boost::asio::stream_socket_service<boost::asio::ip::tcp> > TSocket;
|
||||
@ -1702,12 +1702,12 @@ public:
|
||||
CMemorySerializer();
|
||||
|
||||
template <typename T>
|
||||
static unique_ptr<T> deepCopy(const T &data)
|
||||
static std::unique_ptr<T> deepCopy(const T &data)
|
||||
{
|
||||
CMemorySerializer mem;
|
||||
mem.oser << &data;
|
||||
|
||||
unique_ptr<T> ret;
|
||||
std::unique_ptr<T> ret;
|
||||
mem.iser >> ret;
|
||||
return ret;
|
||||
}
|
||||
|
@ -64,19 +64,19 @@ const std::map<std::string, Bonus::LimitEffect> bonusLimitEffect =
|
||||
|
||||
const std::map<std::string, TLimiterPtr> bonusLimiterMap =
|
||||
{
|
||||
{"SHOOTER_ONLY", make_shared<HasAnotherBonusLimiter>(Bonus::SHOOTER)},
|
||||
{"DRAGON_NATURE", make_shared<HasAnotherBonusLimiter>(Bonus::DRAGON_NATURE)},
|
||||
{"IS_UNDEAD", make_shared<HasAnotherBonusLimiter>(Bonus::UNDEAD)}
|
||||
{"SHOOTER_ONLY", std::make_shared<HasAnotherBonusLimiter>(Bonus::SHOOTER)},
|
||||
{"DRAGON_NATURE", std::make_shared<HasAnotherBonusLimiter>(Bonus::DRAGON_NATURE)},
|
||||
{"IS_UNDEAD", std::make_shared<HasAnotherBonusLimiter>(Bonus::UNDEAD)}
|
||||
};
|
||||
|
||||
const std::map<std::string, TPropagatorPtr> bonusPropagatorMap =
|
||||
{
|
||||
{"BATTLE_WIDE", make_shared<CPropagatorNodeType>(CBonusSystemNode::BATTLE)},
|
||||
{"VISITED_TOWN_AND_VISITOR", make_shared<CPropagatorNodeType>(CBonusSystemNode::TOWN_AND_VISITOR)},
|
||||
{"PLAYER_PROPAGATOR", make_shared<CPropagatorNodeType>(CBonusSystemNode::PLAYER)},
|
||||
{"HERO", make_shared<CPropagatorNodeType>(CBonusSystemNode::HERO)},
|
||||
{"TEAM_PROPAGATOR", make_shared<CPropagatorNodeType>(CBonusSystemNode::TEAM)}, //untested
|
||||
{"GLOBAL_EFFECT", make_shared<CPropagatorNodeType>(CBonusSystemNode::GLOBAL_EFFECTS)}
|
||||
{"BATTLE_WIDE", std::make_shared<CPropagatorNodeType>(CBonusSystemNode::BATTLE)},
|
||||
{"VISITED_TOWN_AND_VISITOR", std::make_shared<CPropagatorNodeType>(CBonusSystemNode::TOWN_AND_VISITOR)},
|
||||
{"PLAYER_PROPAGATOR", std::make_shared<CPropagatorNodeType>(CBonusSystemNode::PLAYER)},
|
||||
{"HERO", std::make_shared<CPropagatorNodeType>(CBonusSystemNode::HERO)},
|
||||
{"TEAM_PROPAGATOR", std::make_shared<CPropagatorNodeType>(CBonusSystemNode::TEAM)}, //untested
|
||||
{"GLOBAL_EFFECT", std::make_shared<CPropagatorNodeType>(CBonusSystemNode::GLOBAL_EFFECTS)}
|
||||
}; //untested
|
||||
|
||||
|
||||
@ -651,7 +651,7 @@ const TBonusListPtr CBonusSystemNode::getAllBonuses(const CSelector &selector, c
|
||||
|
||||
//We still don't have the bonuses (didn't returned them from cache)
|
||||
//Perform bonus selection
|
||||
auto ret = make_shared<BonusList>();
|
||||
auto ret = std::make_shared<BonusList>();
|
||||
cachedBonuses.getBonuses(*ret, selector, limit);
|
||||
|
||||
// Save the results in the cache
|
||||
@ -668,7 +668,7 @@ const TBonusListPtr CBonusSystemNode::getAllBonuses(const CSelector &selector, c
|
||||
|
||||
const TBonusListPtr CBonusSystemNode::getAllBonusesWithoutCaching(const CSelector &selector, const CSelector &limit, const CBonusSystemNode *root /*= nullptr*/) const
|
||||
{
|
||||
auto ret = make_shared<BonusList>();
|
||||
auto ret = std::make_shared<BonusList>();
|
||||
|
||||
// Get bonus results without caching enabled.
|
||||
BonusList beforeLimiting, afterLimiting;
|
||||
@ -1067,7 +1067,7 @@ void CBonusSystemNode::limitBonuses(const BonusList &allBonuses, BonusList &out)
|
||||
|
||||
TBonusListPtr CBonusSystemNode::limitBonuses(const BonusList &allBonuses) const
|
||||
{
|
||||
auto ret = make_shared<BonusList>();
|
||||
auto ret = std::make_shared<BonusList>();
|
||||
limitBonuses(allBonuses, *ret);
|
||||
return ret;
|
||||
}
|
||||
@ -1318,7 +1318,7 @@ Bonus * Bonus::addLimiter(TLimiterPtr Limiter)
|
||||
if(!limiterList)
|
||||
{
|
||||
//Create a new limiter list with old limiter and the new one will be pushed later
|
||||
limiterList = make_shared<LimiterList>();
|
||||
limiterList = std::make_shared<LimiterList>();
|
||||
limiterList->add(limiter);
|
||||
limiter = limiterList;
|
||||
}
|
||||
|
@ -20,9 +20,9 @@ class ILimiter;
|
||||
class IPropagator;
|
||||
class BonusList;
|
||||
|
||||
typedef shared_ptr<BonusList> TBonusListPtr;
|
||||
typedef shared_ptr<ILimiter> TLimiterPtr;
|
||||
typedef shared_ptr<IPropagator> TPropagatorPtr;
|
||||
typedef std::shared_ptr<BonusList> TBonusListPtr;
|
||||
typedef std::shared_ptr<ILimiter> TLimiterPtr;
|
||||
typedef std::shared_ptr<IPropagator> TPropagatorPtr;
|
||||
typedef std::set<CBonusSystemNode*> TNodes;
|
||||
typedef std::set<const CBonusSystemNode*> TCNodes;
|
||||
typedef std::vector<CBonusSystemNode *> TNodesVector;
|
||||
|
@ -483,10 +483,10 @@ Bonus * JsonUtils::parseBonus (const JsonNode &ability)
|
||||
break;
|
||||
case JsonNode::DATA_STRUCT: //customizable limiters
|
||||
{
|
||||
shared_ptr<ILimiter> l;
|
||||
std::shared_ptr<ILimiter> l;
|
||||
if (limiter["type"].String() == "CREATURE_TYPE_LIMITER")
|
||||
{
|
||||
shared_ptr<CCreatureTypeLimiter> l2 = make_shared<CCreatureTypeLimiter>(); //TODO: How the hell resolve pointer to creature?
|
||||
std::shared_ptr<CCreatureTypeLimiter> l2 = std::make_shared<CCreatureTypeLimiter>(); //TODO: How the hell resolve pointer to creature?
|
||||
const JsonVector vec = limiter["parameters"].Vector();
|
||||
VLC->modh->identifiers.requestIdentifier("creature", vec[0], [=](si32 creature)
|
||||
{
|
||||
@ -503,7 +503,7 @@ Bonus * JsonUtils::parseBonus (const JsonNode &ability)
|
||||
}
|
||||
if (limiter["type"].String() == "HAS_ANOTHER_BONUS_LIMITER")
|
||||
{
|
||||
shared_ptr<HasAnotherBonusLimiter> l2 = make_shared<HasAnotherBonusLimiter>();
|
||||
std::shared_ptr<HasAnotherBonusLimiter> l2 = std::make_shared<HasAnotherBonusLimiter>();
|
||||
const JsonVector vec = limiter["parameters"].Vector();
|
||||
std::string anotherBonusType = vec[0].String();
|
||||
|
||||
|
@ -443,7 +443,7 @@ struct UpdateCampaignState : public CPackForClient //119
|
||||
type = 119;
|
||||
}
|
||||
|
||||
shared_ptr<CCampaignState> camp;
|
||||
std::shared_ptr<CCampaignState> camp;
|
||||
void applyCl(CClient *cl);
|
||||
|
||||
template <typename Handler> void serialize(Handler &h, const int version)
|
||||
@ -1681,7 +1681,7 @@ struct BattleObstaclePlaced : public CPackForClient //3020
|
||||
DLL_LINKAGE void applyGs(CGameState *gs); //effect
|
||||
void applyCl(CClient *cl); //play animations & stuff
|
||||
|
||||
shared_ptr<CObstacleInstance> obstacle;
|
||||
std::shared_ptr<CObstacleInstance> obstacle;
|
||||
|
||||
template <typename Handler> void serialize(Handler &h, const int version)
|
||||
{
|
||||
|
@ -82,9 +82,9 @@ struct StartInfo
|
||||
ui8 turnTime; //in minutes, 0=unlimited
|
||||
std::string mapname; // empty for random map, otherwise name of the map or savegame
|
||||
bool createRandomMap() const { return mapGenOptions.get() != nullptr; }
|
||||
shared_ptr<CMapGenOptions> mapGenOptions;
|
||||
std::shared_ptr<CMapGenOptions> mapGenOptions;
|
||||
|
||||
shared_ptr<CCampaignState> campState;
|
||||
std::shared_ptr<CCampaignState> campState;
|
||||
|
||||
PlayerSettings & getIthPlayersSettings(PlayerColor no)
|
||||
{
|
||||
|
@ -134,7 +134,7 @@ void CLogger::setLevel(ELogLevel::ELogLevel level)
|
||||
|
||||
const CLoggerDomain & CLogger::getDomain() const { return domain; }
|
||||
|
||||
void CLogger::addTarget(unique_ptr<ILogTarget> && target)
|
||||
void CLogger::addTarget(std::unique_ptr<ILogTarget> && target)
|
||||
{
|
||||
TLockGuard _(mx);
|
||||
targets.push_back(std::move(target));
|
||||
|
@ -105,7 +105,7 @@ public:
|
||||
|
||||
inline void log(ELogLevel::ELogLevel level, const std::string & message) const;
|
||||
|
||||
void addTarget(unique_ptr<ILogTarget> && target);
|
||||
void addTarget(std::unique_ptr<ILogTarget> && target);
|
||||
void clearTargets();
|
||||
|
||||
/// Returns true if a debug/trace log message will be logged, false if not.
|
||||
@ -121,7 +121,7 @@ private:
|
||||
CLoggerDomain domain;
|
||||
CLogger * parent;
|
||||
ELogLevel::ELogLevel level;
|
||||
std::vector<unique_ptr<ILogTarget> > targets;
|
||||
std::vector<std::unique_ptr<ILogTarget> > targets;
|
||||
mutable boost::mutex mx;
|
||||
static boost::recursive_mutex smx;
|
||||
};
|
||||
@ -149,7 +149,7 @@ private:
|
||||
/// the first statement in the function. Logging traces via this macro have almost no impact when the trace is disabled.
|
||||
///
|
||||
#define RAII_TRACE(logger, onEntry, onLeave) \
|
||||
unique_ptr<CTraceLogger> ctl00; \
|
||||
std::unique_ptr<CTraceLogger> ctl00; \
|
||||
if(logger->isTraceEnabled()) \
|
||||
ctl00 = make_unique<CTraceLogger>(logger, onEntry, onLeave);
|
||||
|
||||
|
@ -874,12 +874,12 @@ std::vector<ObjectInstanceID> CGTeleport::getPassableExits(CGameState * gs, cons
|
||||
return exits;
|
||||
}
|
||||
|
||||
void CGTeleport::addToChannel(std::map<TeleportChannelID, shared_ptr<TeleportChannel> > &channelsList, const CGTeleport * obj)
|
||||
void CGTeleport::addToChannel(std::map<TeleportChannelID, std::shared_ptr<TeleportChannel> > &channelsList, const CGTeleport * obj)
|
||||
{
|
||||
shared_ptr<TeleportChannel> tc;
|
||||
std::shared_ptr<TeleportChannel> tc;
|
||||
if(channelsList.find(obj->channel) == channelsList.end())
|
||||
{
|
||||
tc = make_shared<TeleportChannel>();
|
||||
tc = std::make_shared<TeleportChannel>();
|
||||
channelsList.insert(std::make_pair(obj->channel, tc));
|
||||
}
|
||||
else
|
||||
|
@ -291,7 +291,7 @@ public:
|
||||
static bool isTeleport(const CGObjectInstance * dst);
|
||||
static bool isConnected(const CGTeleport * src, const CGTeleport * dst);
|
||||
static bool isConnected(const CGObjectInstance * src, const CGObjectInstance * dst);
|
||||
static void addToChannel(std::map<TeleportChannelID, shared_ptr<TeleportChannel> > &channelsList, const CGTeleport * obj);
|
||||
static void addToChannel(std::map<TeleportChannelID, std::shared_ptr<TeleportChannel> > &channelsList, const CGTeleport * obj);
|
||||
static std::vector<ObjectInstanceID> getPassableExits(CGameState * gs, const CGHeroInstance * h, std::vector<ObjectInstanceID> exits);
|
||||
static bool isExitPassable(CGameState * gs, const CGHeroInstance * h, const CGObjectInstance * obj);
|
||||
|
||||
|
@ -40,7 +40,7 @@ CCampaignHeader CCampaignHandler::getHeader( const std::string & name)
|
||||
return ret;
|
||||
}
|
||||
|
||||
unique_ptr<CCampaign> CCampaignHandler::getCampaign( const std::string & name )
|
||||
std::unique_ptr<CCampaign> CCampaignHandler::getCampaign( const std::string & name )
|
||||
{
|
||||
auto ret = make_unique<CCampaign>();
|
||||
|
||||
@ -411,7 +411,7 @@ CCampaignState::CCampaignState()
|
||||
|
||||
}
|
||||
|
||||
CCampaignState::CCampaignState( unique_ptr<CCampaign> _camp ) : camp(std::move(_camp))
|
||||
CCampaignState::CCampaignState( std::unique_ptr<CCampaign> _camp ) : camp(std::move(_camp))
|
||||
{
|
||||
for(int i = 0; i < camp->scenarios.size(); i++)
|
||||
{
|
||||
|
@ -144,7 +144,7 @@ public:
|
||||
class DLL_LINKAGE CCampaignState
|
||||
{
|
||||
public:
|
||||
unique_ptr<CCampaign> camp;
|
||||
std::unique_ptr<CCampaign> camp;
|
||||
std::string campaignName;
|
||||
std::vector<ui8> mapsConquered, mapsRemaining;
|
||||
boost::optional<si32> currentMap;
|
||||
@ -159,7 +159,7 @@ public:
|
||||
ui8 currentBonusID() const;
|
||||
|
||||
CCampaignState();
|
||||
CCampaignState(unique_ptr<CCampaign> _camp);
|
||||
CCampaignState(std::unique_ptr<CCampaign> _camp);
|
||||
~CCampaignState(){};
|
||||
|
||||
template <typename Handler> void serialize(Handler &h, const int version)
|
||||
@ -184,5 +184,5 @@ public:
|
||||
|
||||
static CCampaignHeader getHeader( const std::string & name); //name - name of appropriate file
|
||||
|
||||
static unique_ptr<CCampaign> getCampaign(const std::string & name); //name - name of appropriate file
|
||||
static std::unique_ptr<CCampaign> getCampaign(const std::string & name); //name - name of appropriate file
|
||||
};
|
||||
|
@ -317,12 +317,12 @@ public:
|
||||
|
||||
//Helper lists
|
||||
std::vector< ConstTransitivePtr<CGHeroInstance> > heroesOnMap;
|
||||
std::map<TeleportChannelID, shared_ptr<TeleportChannel> > teleportChannels;
|
||||
std::map<TeleportChannelID, std::shared_ptr<TeleportChannel> > teleportChannels;
|
||||
|
||||
/// associative list to identify which hero/creature id belongs to which object id(index for objects)
|
||||
std::map<si32, ObjectInstanceID> questIdentifierToId;
|
||||
|
||||
unique_ptr<CMapEditManager> editManager;
|
||||
std::unique_ptr<CMapEditManager> editManager;
|
||||
|
||||
int3 ***guardingCreaturePositions;
|
||||
|
||||
|
@ -189,7 +189,7 @@ const CMapOperation * CMapUndoManager::peekUndo() const
|
||||
return peek(undoStack);
|
||||
}
|
||||
|
||||
void CMapUndoManager::addOperation(unique_ptr<CMapOperation> && operation)
|
||||
void CMapUndoManager::addOperation(std::unique_ptr<CMapOperation> && operation)
|
||||
{
|
||||
undoStack.push_front(std::move(operation));
|
||||
if(undoStack.size() > undoRedoLimit) undoStack.pop_back();
|
||||
@ -252,7 +252,7 @@ void CMapEditManager::insertObject(CGObjectInstance * obj, const int3 & pos)
|
||||
execute(make_unique<CInsertObjectOperation>(map, obj, pos));
|
||||
}
|
||||
|
||||
void CMapEditManager::execute(unique_ptr<CMapOperation> && operation)
|
||||
void CMapEditManager::execute(std::unique_ptr<CMapOperation> && operation)
|
||||
{
|
||||
operation->execute();
|
||||
undoManager.addOperation(std::move(operation));
|
||||
@ -302,7 +302,7 @@ void CComposedOperation::redo()
|
||||
}
|
||||
}
|
||||
|
||||
void CComposedOperation::addOperation(unique_ptr<CMapOperation> && operation)
|
||||
void CComposedOperation::addOperation(std::unique_ptr<CMapOperation> && operation)
|
||||
{
|
||||
operations.push_back(std::move(operation));
|
||||
}
|
||||
|
@ -144,10 +144,10 @@ public:
|
||||
const CMapOperation * peekRedo() const;
|
||||
const CMapOperation * peekUndo() const;
|
||||
|
||||
void addOperation(unique_ptr<CMapOperation> && operation); /// Client code does not need to call this method.
|
||||
void addOperation(std::unique_ptr<CMapOperation> && operation); /// Client code does not need to call this method.
|
||||
|
||||
private:
|
||||
typedef std::list<unique_ptr<CMapOperation> > TStack;
|
||||
typedef std::list<std::unique_ptr<CMapOperation> > TStack;
|
||||
|
||||
void doOperation(TStack & fromStack, TStack & toStack, bool doUndo);
|
||||
const CMapOperation * peek(const TStack & stack) const;
|
||||
@ -182,7 +182,7 @@ public:
|
||||
CMapUndoManager & getUndoManager();
|
||||
|
||||
private:
|
||||
void execute(unique_ptr<CMapOperation> && operation);
|
||||
void execute(std::unique_ptr<CMapOperation> && operation);
|
||||
|
||||
CMap * map;
|
||||
CMapUndoManager undoManager;
|
||||
@ -205,10 +205,10 @@ public:
|
||||
void undo() override;
|
||||
void redo() override;
|
||||
|
||||
void addOperation(unique_ptr<CMapOperation> && operation);
|
||||
void addOperation(std::unique_ptr<CMapOperation> && operation);
|
||||
|
||||
private:
|
||||
std::list<unique_ptr<CMapOperation> > operations;
|
||||
std::list<std::unique_ptr<CMapOperation> > operations;
|
||||
};
|
||||
|
||||
namespace ETerrainGroup
|
||||
|
@ -1,8 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
// Forward class declarations aren't enough here. The compiler
|
||||
// generated CMapInfo d-tor, generates the unique_ptr d-tor as well here
|
||||
// as a inline method. The unique_ptr d-tor requires a complete type. Defining
|
||||
// generated CMapInfo d-tor, generates the std::unique_ptr d-tor as well here
|
||||
// as a inline method. The std::unique_ptr d-tor requires a complete type. Defining
|
||||
// the CMapInfo d-tor to let the compiler add the d-tor stuff in the .cpp file
|
||||
// would work with one exception. It prevents the generation of the move
|
||||
// constructor which is needed. (Writing such a c-tor is nasty.) With the
|
||||
@ -20,8 +20,8 @@ struct StartInfo;
|
||||
class DLL_LINKAGE CMapInfo
|
||||
{
|
||||
public:
|
||||
unique_ptr<CMapHeader> mapHeader; //may be nullptr if campaign
|
||||
unique_ptr<CCampaignHeader> campaignHeader; //may be nullptr if scenario
|
||||
std::unique_ptr<CMapHeader> mapHeader; //may be nullptr if campaign
|
||||
std::unique_ptr<CCampaignHeader> campaignHeader; //may be nullptr if scenario
|
||||
StartInfo * scenarioOpts; //options with which scenario has been started (used only with saved games)
|
||||
std::string fileURI;
|
||||
std::string date;
|
||||
|
@ -52,7 +52,7 @@ class DLL_LINKAGE CMapGenerator
|
||||
{
|
||||
public:
|
||||
explicit CMapGenerator();
|
||||
~CMapGenerator(); // required due to unique_ptr
|
||||
~CMapGenerator(); // required due to std::unique_ptr
|
||||
|
||||
std::unique_ptr<CMap> generate(CMapGenOptions * mapGenOptions, int RandomSeed = std::time(nullptr));
|
||||
|
||||
|
@ -28,7 +28,7 @@ CZoneGraphGenerator::CZoneGraphGenerator()// : gen(nullptr)
|
||||
|
||||
}
|
||||
|
||||
unique_ptr<CZoneGraph> CZoneGraphGenerator::generate(const CMapGenOptions & options, CRandomGenerator * gen)
|
||||
std::unique_ptr<CZoneGraph> CZoneGraphGenerator::generate(const CMapGenOptions & options, CRandomGenerator * gen)
|
||||
{
|
||||
return make_unique<CZoneGraph>();
|
||||
}
|
||||
|
@ -40,9 +40,9 @@ class CZoneGraphGenerator
|
||||
public:
|
||||
CZoneGraphGenerator();
|
||||
|
||||
unique_ptr<CZoneGraph> generate(const CMapGenOptions & options, CRandomGenerator * gen);
|
||||
std::unique_ptr<CZoneGraph> generate(const CMapGenOptions & options, CRandomGenerator * gen);
|
||||
|
||||
private:
|
||||
unique_ptr<CZoneGraph> graph;
|
||||
std::unique_ptr<CZoneGraph> graph;
|
||||
//CRandomGenerator * gen;
|
||||
};
|
||||
|
@ -50,6 +50,6 @@ private:
|
||||
float scaleY;
|
||||
//float a1, b1, c1, a2, b2, c2;
|
||||
//CMap * map;
|
||||
//unique_ptr<CZoneGraph> graph;
|
||||
//std::unique_ptr<CZoneGraph> graph;
|
||||
CMapGenerator * gen;
|
||||
};
|
||||
|
@ -374,7 +374,7 @@ void ObstacleMechanics::applyBattleEffects(const SpellCastEnvironment * env, con
|
||||
? (parameters.cb->obstacles.back()->uniqueID+1)
|
||||
: 0;
|
||||
|
||||
auto obstacle = make_shared<SpellCreatedObstacle>();
|
||||
auto obstacle = std::make_shared<SpellCreatedObstacle>();
|
||||
switch(owner->id) // :/
|
||||
{
|
||||
case SpellID::QUICKSAND:
|
||||
|
@ -28,7 +28,7 @@ extern "C" DLL_EXPORT void GetAiName(char* name)
|
||||
strcpy_s(name, strlen(g_cszAiName) + 1, g_cszAiName);
|
||||
}
|
||||
|
||||
extern "C" DLL_EXPORT void GetNewModule(shared_ptr<CScriptingModule> &out)
|
||||
extern "C" DLL_EXPORT void GetNewModule(std::shared_ptr<CScriptingModule> &out)
|
||||
{
|
||||
out = make_shared<ERMInterpreter>();
|
||||
out = std::make_shared<ERMInterpreter>();
|
||||
}
|
@ -225,7 +225,7 @@ void CGameHandler::levelUpHero(const CGHeroInstance * hero)
|
||||
}
|
||||
else if(hlu.skills.size() > 1)
|
||||
{
|
||||
auto levelUpQuery = make_shared<CHeroLevelUpDialogQuery>(hlu);
|
||||
auto levelUpQuery = std::make_shared<CHeroLevelUpDialogQuery>(hlu);
|
||||
hlu.queryID = levelUpQuery->queryID;
|
||||
queries.addQuery(levelUpQuery);
|
||||
sendAndApply(&hlu);
|
||||
@ -363,7 +363,7 @@ void CGameHandler::levelUpCommander(const CCommanderInstance * c)
|
||||
}
|
||||
else if(skillAmount > 1) //apply and ask for secondary skill
|
||||
{
|
||||
auto commanderLevelUp = make_shared<CCommanderLevelUpDialogQuery>(clu);
|
||||
auto commanderLevelUp = std::make_shared<CCommanderLevelUpDialogQuery>(clu);
|
||||
clu.queryID = commanderLevelUp->queryID;
|
||||
queries.addQuery(commanderLevelUp);
|
||||
sendAndApply(&clu);
|
||||
@ -471,7 +471,7 @@ void CGameHandler::endBattle(int3 tile, const CGHeroInstance *hero1, const CGHer
|
||||
const CArmedInstance *bEndArmy2 = gs->curB->sides.at(1).armyObject;
|
||||
const BattleResult::EResult result = battleResult.get()->result;
|
||||
|
||||
auto findBattleQuery = [this] () -> shared_ptr<CBattleQuery>
|
||||
auto findBattleQuery = [this] () -> std::shared_ptr<CBattleQuery>
|
||||
{
|
||||
for(auto &q : queries.allQueries())
|
||||
{
|
||||
@ -479,7 +479,7 @@ void CGameHandler::endBattle(int3 tile, const CGHeroInstance *hero1, const CGHer
|
||||
if(bq->bi == gs->curB)
|
||||
return bq;
|
||||
}
|
||||
return shared_ptr<CBattleQuery>();
|
||||
return std::shared_ptr<CBattleQuery>();
|
||||
};
|
||||
|
||||
auto battleQuery = findBattleQuery();
|
||||
@ -488,7 +488,7 @@ void CGameHandler::endBattle(int3 tile, const CGHeroInstance *hero1, const CGHer
|
||||
logGlobal->errorStream() << "Cannot find battle query!";
|
||||
if(gs->initialOpts->mode == StartInfo::DUEL)
|
||||
{
|
||||
battleQuery = make_shared<CBattleQuery>(gs->curB);
|
||||
battleQuery = std::make_shared<CBattleQuery>(gs->curB);
|
||||
}
|
||||
}
|
||||
if(battleQuery != queries.topQuery(gs->curB->sides[0].color))
|
||||
@ -1020,7 +1020,7 @@ int CGameHandler::moveStack(int stack, BattleHex dest)
|
||||
}
|
||||
else //for non-flying creatures
|
||||
{
|
||||
shared_ptr<const CObstacleInstance> obstacle, obstacle2; //obstacle that interrupted movement
|
||||
std::shared_ptr<const CObstacleInstance> obstacle, obstacle2; //obstacle that interrupted movement
|
||||
std::vector<BattleHex> tiles;
|
||||
const int tilesToMove = std::max((int)(path.first.size() - creSpeed), 0);
|
||||
int v = path.first.size()-1;
|
||||
@ -1069,7 +1069,7 @@ int CGameHandler::moveStack(int stack, BattleHex dest)
|
||||
//we don't handle obstacle at the destination tile -> it's handled separately in the if at the end
|
||||
if(curStack->position != dest)
|
||||
{
|
||||
auto processObstacle = [&](shared_ptr<const CObstacleInstance> & obs)
|
||||
auto processObstacle = [&](std::shared_ptr<const CObstacleInstance> & obs)
|
||||
{
|
||||
if(obs)
|
||||
{
|
||||
@ -1825,7 +1825,7 @@ bool CGameHandler::moveHero( ObjectInstanceID hid, int3 dst, ui8 teleporting, bo
|
||||
{
|
||||
LOG_TRACE_PARAMS(logGlobal, "Hero %s starts movement from %s to %s", h->name % tmh.start % tmh.end);
|
||||
|
||||
auto moveQuery = make_shared<CHeroMovementQuery>(tmh, h);
|
||||
auto moveQuery = std::make_shared<CHeroMovementQuery>(tmh, h);
|
||||
queries.addQuery(moveQuery);
|
||||
|
||||
if(leavingTile == LEAVING_TILE)
|
||||
@ -2000,7 +2000,7 @@ void CGameHandler::setOwner(const CGObjectInstance * obj, PlayerColor owner)
|
||||
|
||||
void CGameHandler::showBlockingDialog( BlockingDialog *iw )
|
||||
{
|
||||
auto dialogQuery = make_shared<CBlockingDialogQuery>(*iw);
|
||||
auto dialogQuery = std::make_shared<CBlockingDialogQuery>(*iw);
|
||||
queries.addQuery(dialogQuery);
|
||||
iw->queryID = dialogQuery->queryID;
|
||||
sendToAllClients(iw);
|
||||
@ -2008,7 +2008,7 @@ void CGameHandler::showBlockingDialog( BlockingDialog *iw )
|
||||
|
||||
void CGameHandler::showTeleportDialog( TeleportDialog *iw )
|
||||
{
|
||||
auto dialogQuery = make_shared<CTeleportDialogQuery>(*iw);
|
||||
auto dialogQuery = std::make_shared<CTeleportDialogQuery>(*iw);
|
||||
queries.addQuery(dialogQuery);
|
||||
iw->queryID = dialogQuery->queryID;
|
||||
sendToAllClients(iw);
|
||||
@ -2135,7 +2135,7 @@ void CGameHandler::startBattlePrimary(const CArmedInstance *army1, const CArmedI
|
||||
|
||||
setupBattle(tile, armies, heroes, creatureBank, town); //initializes stacks, places creatures on battlefield, blocks and informs player interfaces
|
||||
|
||||
auto battleQuery = make_shared<CBattleQuery>(gs->curB);
|
||||
auto battleQuery = std::make_shared<CBattleQuery>(gs->curB);
|
||||
queries.addQuery(battleQuery);
|
||||
|
||||
boost::thread(&CGameHandler::runBattle, this);
|
||||
@ -2302,7 +2302,7 @@ void CGameHandler::heroExchange(ObjectInstanceID hero1, ObjectInstanceID hero2)
|
||||
|
||||
if( gameState()->getPlayerRelations(h1->getOwner(), h2->getOwner()))
|
||||
{
|
||||
auto exchange = make_shared<CGarrisonDialogQuery>(h1, h2);
|
||||
auto exchange = std::make_shared<CGarrisonDialogQuery>(h1, h2);
|
||||
ExchangeDialog hex;
|
||||
hex.queryID = exchange->queryID;
|
||||
hex.heroes[0] = getHero(hero1);
|
||||
@ -4563,7 +4563,7 @@ void CGameHandler::showGarrisonDialog( ObjectInstanceID upobj, ObjectInstanceID
|
||||
assert(lowerArmy);
|
||||
assert(upperArmy);
|
||||
|
||||
auto garrisonQuery = make_shared<CGarrisonDialogQuery>(upperArmy, lowerArmy);
|
||||
auto garrisonQuery = std::make_shared<CGarrisonDialogQuery>(upperArmy, lowerArmy);
|
||||
queries.addQuery(garrisonQuery);
|
||||
|
||||
GarrisonDialog gd;
|
||||
@ -4634,7 +4634,7 @@ bool CGameHandler::isAllowedExchange( ObjectInstanceID id1, ObjectInstanceID id2
|
||||
void CGameHandler::objectVisited( const CGObjectInstance * obj, const CGHeroInstance * h )
|
||||
{
|
||||
logGlobal->debugStream() << h->nodeName() << " visits " << obj->getObjectName() << "(" << obj->ID << ":" << obj->subID << ")";
|
||||
auto visitQuery = make_shared<CObjectVisitQuery>(obj, h, obj->visitablePos());
|
||||
auto visitQuery = std::make_shared<CObjectVisitQuery>(obj, h, obj->visitablePos());
|
||||
queries.addQuery(visitQuery); //TODO real visit pos
|
||||
|
||||
HeroVisit hv;
|
||||
@ -5899,7 +5899,7 @@ void CasualtiesAfterBattle::takeFromArmy(CGameHandler *gh)
|
||||
}
|
||||
}
|
||||
|
||||
CGameHandler::FinishingBattleHelper::FinishingBattleHelper(shared_ptr<const CBattleQuery> Query, bool Duel, int RemainingBattleQueriesCount)
|
||||
CGameHandler::FinishingBattleHelper::FinishingBattleHelper(std::shared_ptr<const CBattleQuery> Query, bool Duel, int RemainingBattleQueriesCount)
|
||||
{
|
||||
assert(Query->result);
|
||||
assert(Query->bi);
|
||||
|
@ -258,9 +258,9 @@ public:
|
||||
struct FinishingBattleHelper
|
||||
{
|
||||
FinishingBattleHelper();
|
||||
FinishingBattleHelper(shared_ptr<const CBattleQuery> Query, bool Duel, int RemainingBattleQueriesCount);
|
||||
FinishingBattleHelper(std::shared_ptr<const CBattleQuery> Query, bool Duel, int RemainingBattleQueriesCount);
|
||||
|
||||
//shared_ptr<const CBattleQuery> query;
|
||||
//std::shared_ptr<const CBattleQuery> query;
|
||||
const CGHeroInstance *winnerHero, *loserHero;
|
||||
PlayerColor victor, loser;
|
||||
bool duel;
|
||||
@ -273,7 +273,7 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
unique_ptr<FinishingBattleHelper> finishingBattle;
|
||||
std::unique_ptr<FinishingBattleHelper> finishingBattle;
|
||||
|
||||
void battleAfterLevelUp(const BattleResult &result);
|
||||
|
||||
|
@ -200,9 +200,9 @@ void Queries::popIfTop(const CQuery &query)
|
||||
popQuery(color, topQuery(color));
|
||||
}
|
||||
|
||||
std::vector<shared_ptr<const CQuery>> Queries::allQueries() const
|
||||
std::vector<std::shared_ptr<const CQuery>> Queries::allQueries() const
|
||||
{
|
||||
std::vector<shared_ptr<const CQuery>> ret;
|
||||
std::vector<std::shared_ptr<const CQuery>> ret;
|
||||
for(auto &playerQueries : queries)
|
||||
for(auto &query : playerQueries.second)
|
||||
ret.push_back(query);
|
||||
@ -210,10 +210,10 @@ std::vector<shared_ptr<const CQuery>> Queries::allQueries() const
|
||||
return ret;
|
||||
}
|
||||
|
||||
std::vector<shared_ptr<CQuery>> Queries::allQueries()
|
||||
std::vector<std::shared_ptr<CQuery>> Queries::allQueries()
|
||||
{
|
||||
//TODO code duplication with const function :(
|
||||
std::vector<shared_ptr<CQuery>> ret;
|
||||
std::vector<std::shared_ptr<CQuery>> ret;
|
||||
for(auto &playerQueries : queries)
|
||||
for(auto &query : playerQueries.second)
|
||||
ret.push_back(query);
|
||||
|
@ -10,7 +10,7 @@ class CGameHandler;
|
||||
class CObjectVisitQuery;
|
||||
class CQuery;
|
||||
|
||||
typedef shared_ptr<CQuery> QueryPtr;
|
||||
typedef std::shared_ptr<CQuery> QueryPtr;
|
||||
|
||||
// This class represents any kind of prolonged interaction that may need to do something special after it is over.
|
||||
// It does not necessarily has to be "query" requiring player action, it can be also used internally within server.
|
||||
@ -183,8 +183,8 @@ public:
|
||||
|
||||
QueryPtr topQuery(PlayerColor player);
|
||||
|
||||
std::vector<shared_ptr<const CQuery>> allQueries() const;
|
||||
std::vector<shared_ptr<CQuery>> allQueries();
|
||||
std::vector<std::shared_ptr<const CQuery>> allQueries() const;
|
||||
std::vector<std::shared_ptr<CQuery>> allQueries();
|
||||
//void removeQuery
|
||||
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user