1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-03-25 21:38:59 +02:00

Added move constructors for minimum required Bonus system`s classes

This commit is contained in:
AlexVinS 2016-07-29 12:27:55 +03:00
parent d188b86a50
commit 629922f43e
4 changed files with 53 additions and 1 deletions

View File

@ -2924,6 +2924,25 @@ PlayerState::PlayerState()
setNodeType(PLAYER);
}
PlayerState::PlayerState(PlayerState && other):
CBonusSystemNode(std::move(other)),
color(other.color),
human(other.human),
team(other.team),
resources(other.resources),
enteredWinningCheatCode(other.enteredWinningCheatCode),
enteredLosingCheatCode(other.enteredLosingCheatCode),
status(other.status),
daysWithoutCastle(other.daysWithoutCastle)
{
std::swap(visitedObjects, other.visitedObjects);
std::swap(heroes, other.heroes);
std::swap(towns, other.towns);
std::swap(availableHeroes, other.availableHeroes);
std::swap(dwellings, other.dwellings);
std::swap(quests, other.quests);
}
std::string PlayerState::nodeName() const
{
return "Player " + (color.getNum() < VLC->generaltexth->capColors.size() ? VLC->generaltexth->capColors[color.getNum()] : boost::lexical_cast<std::string>(color));
@ -3223,6 +3242,15 @@ TeamState::TeamState()
setNodeType(TEAM);
}
TeamState::TeamState(TeamState && other):
CBonusSystemNode(std::move(other)),
id(other.id)
{
std::swap(players, other.players);
std::swap(fogOfWarMap, other.fogOfWarMap);
}
CRandomGenerator & CGameState::getRandomGenerator()
{
//logGlobal->traceStream() << "Fetching CGameState::rand with seed " << rand.nextInt();

View File

@ -35,6 +35,8 @@ public:
boost::optional<ui8> daysWithoutCastle;
PlayerState();
PlayerState(PlayerState && other);
std::string nodeName() const override;
template <typename Handler> void serialize(Handler &h, const int version)
@ -56,6 +58,7 @@ public:
std::vector<std::vector<std::vector<ui8> > > fogOfWarMap; //true - visible, false - hidden
TeamState();
TeamState(TeamState && other);
template <typename Handler> void serialize(Handler &h, const int version)
{

View File

@ -709,6 +709,26 @@ CBonusSystemNode::CBonusSystemNode() : bonuses(true), exportedBonuses(true), nod
{
}
CBonusSystemNode::CBonusSystemNode(CBonusSystemNode && other):
bonuses(other.bonuses),
exportedBonuses(other.exportedBonuses),
nodeType(other.nodeType),
description(other.description),
cachedLast(0)
{
//todo: move constructor for bonuslist
bonuses.belongsToTree = true;
exportedBonuses.belongsToTree = true;
std::swap(parents, other.parents);
std::swap(children, other.children);
//TODO: move cache
//cachedBonuses
//cachedRequests
}
CBonusSystemNode::~CBonusSystemNode()
{
detachFromAll();

View File

@ -495,6 +495,7 @@ public:
return bonuses.end();
}
friend class CBonusSystemNode;
//friend inline std::vector<Bonus*>::iterator range_begin(BonusList & x);
//friend inline std::vector<Bonus*>::iterator range_end(BonusList & x);
};
@ -647,8 +648,8 @@ private:
const TBonusListPtr getAllBonusesWithoutCaching(const CSelector &selector, const CSelector &limit, const CBonusSystemNode *root = nullptr) const;
public:
explicit CBonusSystemNode();
CBonusSystemNode(CBonusSystemNode && other);
virtual ~CBonusSystemNode();
void limitBonuses(const BonusList &allBonuses, BonusList &out) const; //out will bo populed with bonuses that are not limited here