mirror of
https://github.com/vcmi/vcmi.git
synced 2025-11-25 22:42:04 +02:00
Apply formatting on changed files
This commit is contained in:
@@ -24,7 +24,7 @@ VCMI_LIB_NAMESPACE_BEGIN
|
|||||||
|
|
||||||
void CArmedInstance::randomizeArmy(FactionID type)
|
void CArmedInstance::randomizeArmy(FactionID type)
|
||||||
{
|
{
|
||||||
for (auto & elem : stacks)
|
for(auto & elem : stacks)
|
||||||
{
|
{
|
||||||
if(elem.second->randomStack)
|
if(elem.second->randomStack)
|
||||||
{
|
{
|
||||||
@@ -39,16 +39,16 @@ void CArmedInstance::randomizeArmy(FactionID type)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CArmedInstance::CArmedInstance(IGameInfoCallback *cb)
|
CArmedInstance::CArmedInstance(IGameInfoCallback * cb)
|
||||||
:CArmedInstance(cb, BonusNodeType::ARMY, false)
|
: CArmedInstance(cb, BonusNodeType::ARMY, false)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
CArmedInstance::CArmedInstance(IGameInfoCallback *cb, BonusNodeType nodeType, bool isHypothetic):
|
CArmedInstance::CArmedInstance(IGameInfoCallback * cb, BonusNodeType nodeType, bool isHypothetic)
|
||||||
CGObjectInstance(cb),
|
: CGObjectInstance(cb)
|
||||||
CBonusSystemNode(nodeType, isHypothetic),
|
, CBonusSystemNode(nodeType, isHypothetic)
|
||||||
nonEvilAlignmentMix(this, Selector::type()(BonusType::NONEVIL_ALIGNMENT_MIX)), // Take Angelic Alliance troop-mixing freedom of non-evil units into account.
|
, nonEvilAlignmentMix(this, Selector::type()(BonusType::NONEVIL_ALIGNMENT_MIX)) // Take Angelic Alliance troop-mixing freedom of non-evil units into account.
|
||||||
battle(nullptr)
|
, battle(nullptr)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -58,7 +58,7 @@ void CArmedInstance::updateMoraleBonusFromArmy()
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
auto b = getExportedBonusList().getFirst(Selector::sourceType()(BonusSource::ARMY).And(Selector::type()(BonusType::MORALE)));
|
auto b = getExportedBonusList().getFirst(Selector::sourceType()(BonusSource::ARMY).And(Selector::type()(BonusType::MORALE)));
|
||||||
if(!b)
|
if(!b)
|
||||||
{
|
{
|
||||||
b = std::make_shared<Bonus>(BonusDuration::PERMANENT, BonusType::MORALE, BonusSource::ARMY, 0, BonusSourceID());
|
b = std::make_shared<Bonus>(BonusDuration::PERMANENT, BonusType::MORALE, BonusSource::ARMY, 0, BonusSourceID());
|
||||||
addNewBonus(b);
|
addNewBonus(b);
|
||||||
@@ -70,11 +70,11 @@ void CArmedInstance::updateMoraleBonusFromArmy()
|
|||||||
|
|
||||||
for(const auto & slot : Slots())
|
for(const auto & slot : Slots())
|
||||||
{
|
{
|
||||||
const auto * creature = slot.second->getCreatureID().toEntity(LIBRARY);
|
const auto * creature = slot.second->getCreatureID().toEntity(LIBRARY);
|
||||||
|
|
||||||
factions.insert(creature->getFactionID());
|
factions.insert(creature->getFactionID());
|
||||||
// Check for undead flag instead of faction (undead mummies are neutral)
|
// Check for undead flag instead of faction (undead mummies are neutral)
|
||||||
if (!hasUndead)
|
if(!hasUndead)
|
||||||
{
|
{
|
||||||
//this is costly check, let's skip it at first undead
|
//this is costly check, let's skip it at first undead
|
||||||
hasUndead |= slot.second->hasBonusOfType(BonusType::UNDEAD);
|
hasUndead |= slot.second->hasBonusOfType(BonusType::UNDEAD);
|
||||||
@@ -83,16 +83,16 @@ void CArmedInstance::updateMoraleBonusFromArmy()
|
|||||||
|
|
||||||
size_t factionsInArmy = factions.size(); //town garrison seems to take both sets into account
|
size_t factionsInArmy = factions.size(); //town garrison seems to take both sets into account
|
||||||
|
|
||||||
if (nonEvilAlignmentMix.hasBonus())
|
if(nonEvilAlignmentMix.hasBonus())
|
||||||
{
|
{
|
||||||
size_t mixableFactions = 0;
|
size_t mixableFactions = 0;
|
||||||
|
|
||||||
for(auto f : factions)
|
for(auto f : factions)
|
||||||
{
|
{
|
||||||
if (LIBRARY->factions()->getById(f)->getAlignment() != EAlignment::EVIL)
|
if(LIBRARY->factions()->getById(f)->getAlignment() != EAlignment::EVIL)
|
||||||
mixableFactions++;
|
mixableFactions++;
|
||||||
}
|
}
|
||||||
if (mixableFactions > 0)
|
if(mixableFactions > 0)
|
||||||
factionsInArmy -= mixableFactions - 1;
|
factionsInArmy -= mixableFactions - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -103,20 +103,20 @@ void CArmedInstance::updateMoraleBonusFromArmy()
|
|||||||
b->val = +1;
|
b->val = +1;
|
||||||
bonusDescription.appendTextID("core.arraytxt.115"); //All troops of one alignment +1
|
bonusDescription.appendTextID("core.arraytxt.115"); //All troops of one alignment +1
|
||||||
}
|
}
|
||||||
else if (!factions.empty()) // no bonus from empty garrison
|
else if(!factions.empty()) // no bonus from empty garrison
|
||||||
{
|
{
|
||||||
b->val = 2 - static_cast<si32>(factionsInArmy);
|
b->val = 2 - static_cast<si32>(factionsInArmy);
|
||||||
bonusDescription.appendTextID("core.arraytxt.114"); //Troops of %d alignments %d
|
bonusDescription.appendTextID("core.arraytxt.114"); //Troops of %d alignments %d
|
||||||
bonusDescription.replaceNumber(factionsInArmy);
|
bonusDescription.replaceNumber(factionsInArmy);
|
||||||
}
|
}
|
||||||
|
|
||||||
b->description = bonusDescription;
|
b->description = bonusDescription;
|
||||||
|
|
||||||
nodeHasChanged();
|
nodeHasChanged();
|
||||||
|
|
||||||
//-1 modifier for any Undead unit in army
|
//-1 modifier for any Undead unit in army
|
||||||
auto undeadModifier = getExportedBonusList().getFirst(Selector::source(BonusSource::ARMY, BonusCustomSource::undeadMoraleDebuff));
|
auto undeadModifier = getExportedBonusList().getFirst(Selector::source(BonusSource::ARMY, BonusCustomSource::undeadMoraleDebuff));
|
||||||
if(hasUndead)
|
if(hasUndead)
|
||||||
{
|
{
|
||||||
if(!undeadModifier)
|
if(!undeadModifier)
|
||||||
{
|
{
|
||||||
@@ -127,7 +127,6 @@ void CArmedInstance::updateMoraleBonusFromArmy()
|
|||||||
}
|
}
|
||||||
else if(undeadModifier)
|
else if(undeadModifier)
|
||||||
removeBonus(undeadModifier);
|
removeBonus(undeadModifier);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CArmedInstance::armyChanged()
|
void CArmedInstance::armyChanged()
|
||||||
@@ -174,7 +173,7 @@ void CArmedInstance::attachUnitsToArmy()
|
|||||||
elem.second->setArmy(getArmy());
|
elem.second->setArmy(getArmy());
|
||||||
}
|
}
|
||||||
|
|
||||||
const IBonusBearer* CArmedInstance::getBonusBearer() const
|
const IBonusBearer * CArmedInstance::getBonusBearer() const
|
||||||
{
|
{
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
@@ -187,7 +186,7 @@ void CArmedInstance::serializeJsonOptions(JsonSerializeFormat & handler)
|
|||||||
|
|
||||||
TerrainId CArmedInstance::getCurrentTerrain() const
|
TerrainId CArmedInstance::getCurrentTerrain() const
|
||||||
{
|
{
|
||||||
if (anchorPos().isValid())
|
if(anchorPos().isValid())
|
||||||
return cb->getTile(visitablePos())->getTerrainID();
|
return cb->getTile(visitablePos())->getTerrainID();
|
||||||
else
|
else
|
||||||
return TerrainId::NONE;
|
return TerrainId::NONE;
|
||||||
|
|||||||
@@ -13,8 +13,8 @@
|
|||||||
|
|
||||||
#include "../CGObjectInstance.h"
|
#include "../CGObjectInstance.h"
|
||||||
|
|
||||||
#include "../../bonuses/CBonusSystemNode.h"
|
|
||||||
#include "../../bonuses/BonusCache.h"
|
#include "../../bonuses/BonusCache.h"
|
||||||
|
#include "../../bonuses/CBonusSystemNode.h"
|
||||||
|
|
||||||
#include <vcmi/Entity.h>
|
#include <vcmi/Entity.h>
|
||||||
|
|
||||||
@@ -36,26 +36,32 @@ protected:
|
|||||||
virtual CBonusSystemNode & whatShouldBeAttached();
|
virtual CBonusSystemNode & whatShouldBeAttached();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
BattleInfo *battle; //set to the current battle, if engaged
|
BattleInfo * battle; //set to the current battle, if engaged
|
||||||
|
|
||||||
void randomizeArmy(FactionID type);
|
void randomizeArmy(FactionID type);
|
||||||
virtual void updateMoraleBonusFromArmy();
|
virtual void updateMoraleBonusFromArmy();
|
||||||
|
|
||||||
void armyChanged() override;
|
void armyChanged() override;
|
||||||
CArmedInstance * getArmy() final { return this; }
|
CArmedInstance * getArmy() final
|
||||||
const CArmedInstance * getArmy() const final { return this; }
|
{
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
const CArmedInstance * getArmy() const final
|
||||||
|
{
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
//IConstBonusProvider
|
//IConstBonusProvider
|
||||||
const IBonusBearer* getBonusBearer() const override;
|
const IBonusBearer * getBonusBearer() const override;
|
||||||
|
|
||||||
void attachToBonusSystem(CGameState & gs) override;
|
void attachToBonusSystem(CGameState & gs) override;
|
||||||
void detachFromBonusSystem(CGameState & gs) override;
|
void detachFromBonusSystem(CGameState & gs) override;
|
||||||
void restoreBonusSystem(CGameState & gs) override;
|
void restoreBonusSystem(CGameState & gs) override;
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
CArmedInstance(IGameInfoCallback *cb);
|
CArmedInstance(IGameInfoCallback * cb);
|
||||||
CArmedInstance(IGameInfoCallback *cb, BonusNodeType nodeType, bool isHypothetic);
|
CArmedInstance(IGameInfoCallback * cb, BonusNodeType nodeType, bool isHypothetic);
|
||||||
|
|
||||||
PlayerColor getOwner() const override
|
PlayerColor getOwner() const override
|
||||||
{
|
{
|
||||||
@@ -63,14 +69,15 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
TerrainId getCurrentTerrain() const;
|
TerrainId getCurrentTerrain() const;
|
||||||
|
|
||||||
void serializeJsonOptions(JsonSerializeFormat & handler) override;
|
void serializeJsonOptions(JsonSerializeFormat & handler) override;
|
||||||
|
|
||||||
template <typename Handler> void serialize(Handler &h)
|
template<typename Handler>
|
||||||
|
void serialize(Handler & h)
|
||||||
{
|
{
|
||||||
h & static_cast<CGObjectInstance&>(*this);
|
h & static_cast<CGObjectInstance &>(*this);
|
||||||
h & static_cast<CBonusSystemNode&>(*this);
|
h & static_cast<CBonusSystemNode &>(*this);
|
||||||
h & static_cast<CCreatureSet&>(*this);
|
h & static_cast<CCreatureSet &>(*this);
|
||||||
|
|
||||||
if(!h.saving && h.loadingGamestate)
|
if(!h.saving && h.loadingGamestate)
|
||||||
attachUnitsToArmy();
|
attachUnitsToArmy();
|
||||||
|
|||||||
@@ -15,11 +15,12 @@
|
|||||||
|
|
||||||
VCMI_LIB_NAMESPACE_BEGIN
|
VCMI_LIB_NAMESPACE_BEGIN
|
||||||
|
|
||||||
CCommanderInstance::CCommanderInstance(IGameInfoCallback *cb)
|
CCommanderInstance::CCommanderInstance(IGameInfoCallback * cb)
|
||||||
:CStackInstance(cb)
|
: CStackInstance(cb)
|
||||||
{}
|
{
|
||||||
|
}
|
||||||
|
|
||||||
CCommanderInstance::CCommanderInstance(IGameInfoCallback *cb, const CreatureID & id)
|
CCommanderInstance::CCommanderInstance(IGameInfoCallback * cb, const CreatureID & id)
|
||||||
: CStackInstance(cb, BonusNodeType::COMMANDER, false)
|
: CStackInstance(cb, BonusNodeType::COMMANDER, false)
|
||||||
, name("Commando")
|
, name("Commando")
|
||||||
{
|
{
|
||||||
@@ -27,16 +28,16 @@ CCommanderInstance::CCommanderInstance(IGameInfoCallback *cb, const CreatureID &
|
|||||||
level = 1;
|
level = 1;
|
||||||
setCount(1);
|
setCount(1);
|
||||||
setType(nullptr);
|
setType(nullptr);
|
||||||
secondarySkills.resize (ECommander::SPELL_POWER + 1);
|
secondarySkills.resize(ECommander::SPELL_POWER + 1);
|
||||||
setType(id);
|
setType(id);
|
||||||
//TODO - parse them
|
//TODO - parse them
|
||||||
}
|
}
|
||||||
|
|
||||||
void CCommanderInstance::setAlive (bool Alive)
|
void CCommanderInstance::setAlive(bool Alive)
|
||||||
{
|
{
|
||||||
//TODO: helm of immortality
|
//TODO: helm of immortality
|
||||||
alive = Alive;
|
alive = Alive;
|
||||||
if (!alive)
|
if(!alive)
|
||||||
{
|
{
|
||||||
removeBonusesRecursive(Bonus::UntilCommanderKilled);
|
removeBonusesRecursive(Bonus::UntilCommanderKilled);
|
||||||
}
|
}
|
||||||
@@ -49,15 +50,15 @@ bool CCommanderInstance::canGainExperience() const
|
|||||||
|
|
||||||
int CCommanderInstance::getExpRank() const
|
int CCommanderInstance::getExpRank() const
|
||||||
{
|
{
|
||||||
return LIBRARY->heroh->level (getTotalExperience());
|
return LIBRARY->heroh->level(getTotalExperience());
|
||||||
}
|
}
|
||||||
|
|
||||||
int CCommanderInstance::getLevel() const
|
int CCommanderInstance::getLevel() const
|
||||||
{
|
{
|
||||||
return std::max (1, getExpRank());
|
return std::max(1, getExpRank());
|
||||||
}
|
}
|
||||||
|
|
||||||
void CCommanderInstance::levelUp ()
|
void CCommanderInstance::levelUp()
|
||||||
{
|
{
|
||||||
level++;
|
level++;
|
||||||
for(const auto & bonus : LIBRARY->creh->commanderLevelPremy)
|
for(const auto & bonus : LIBRARY->creh->commanderLevelPremy)
|
||||||
|
|||||||
@@ -22,24 +22,28 @@ public:
|
|||||||
ui8 alive; //maybe change to bool when breaking save compatibility?
|
ui8 alive; //maybe change to bool when breaking save compatibility?
|
||||||
ui8 level; //required only to count callbacks
|
ui8 level; //required only to count callbacks
|
||||||
std::string name; // each Commander has different name
|
std::string name; // each Commander has different name
|
||||||
std::vector <ui8> secondarySkills; //ID -> level
|
std::vector<ui8> secondarySkills; //ID -> level
|
||||||
std::set <ui8> specialSkills;
|
std::set<ui8> specialSkills;
|
||||||
//std::vector <CArtifactInstance *> arts;
|
//std::vector <CArtifactInstance *> arts;
|
||||||
CCommanderInstance(IGameInfoCallback *cb);
|
CCommanderInstance(IGameInfoCallback * cb);
|
||||||
CCommanderInstance(IGameInfoCallback *cb, const CreatureID & id);
|
CCommanderInstance(IGameInfoCallback * cb, const CreatureID & id);
|
||||||
void setAlive (bool alive);
|
void setAlive(bool alive);
|
||||||
void levelUp ();
|
void levelUp();
|
||||||
|
|
||||||
bool canGainExperience() const override;
|
bool canGainExperience() const override;
|
||||||
bool gainsLevel() const; //true if commander has lower level than should upon his experience
|
bool gainsLevel() const; //true if commander has lower level than should upon his experience
|
||||||
ui64 getPower() const override {return 0;};
|
ui64 getPower() const override
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
};
|
||||||
int getExpRank() const override;
|
int getExpRank() const override;
|
||||||
int getLevel() const override;
|
int getLevel() const override;
|
||||||
ArtBearer bearerType() const override; //from CArtifactSet
|
ArtBearer bearerType() const override; //from CArtifactSet
|
||||||
|
|
||||||
template <typename Handler> void serialize(Handler &h)
|
template<typename Handler>
|
||||||
|
void serialize(Handler & h)
|
||||||
{
|
{
|
||||||
h & static_cast<CStackInstance&>(*this);
|
h & static_cast<CStackInstance &>(*this);
|
||||||
h & alive;
|
h & alive;
|
||||||
h & level;
|
h & level;
|
||||||
h & name;
|
h & name;
|
||||||
|
|||||||
@@ -18,8 +18,7 @@
|
|||||||
|
|
||||||
VCMI_LIB_NAMESPACE_BEGIN
|
VCMI_LIB_NAMESPACE_BEGIN
|
||||||
|
|
||||||
|
bool CreatureSlotComparer::operator()(const TPairCreatureSlot & lhs, const TPairCreatureSlot & rhs)
|
||||||
bool CreatureSlotComparer::operator()(const TPairCreatureSlot & lhs, const TPairCreatureSlot & rhs)
|
|
||||||
{
|
{
|
||||||
return lhs.first->getAIValue() < rhs.first->getAIValue(); // Descendant order sorting
|
return lhs.first->getAIValue() < rhs.first->getAIValue(); // Descendant order sorting
|
||||||
}
|
}
|
||||||
@@ -27,7 +26,7 @@ bool CreatureSlotComparer::operator()(const TPairCreatureSlot & lhs, const TPair
|
|||||||
const CStackInstance & CCreatureSet::operator[](const SlotID & slot) const
|
const CStackInstance & CCreatureSet::operator[](const SlotID & slot) const
|
||||||
{
|
{
|
||||||
auto i = stacks.find(slot);
|
auto i = stacks.find(slot);
|
||||||
if (i != stacks.end())
|
if(i != stacks.end())
|
||||||
return *i->second;
|
return *i->second;
|
||||||
else
|
else
|
||||||
throw std::runtime_error("That slot is empty!");
|
throw std::runtime_error("That slot is empty!");
|
||||||
@@ -36,7 +35,7 @@ const CStackInstance & CCreatureSet::operator[](const SlotID & slot) const
|
|||||||
const CCreature * CCreatureSet::getCreature(const SlotID & slot) const
|
const CCreature * CCreatureSet::getCreature(const SlotID & slot) const
|
||||||
{
|
{
|
||||||
auto i = stacks.find(slot);
|
auto i = stacks.find(slot);
|
||||||
if (i != stacks.end())
|
if(i != stacks.end())
|
||||||
return i->second->getCreature();
|
return i->second->getCreature();
|
||||||
else
|
else
|
||||||
return nullptr;
|
return nullptr;
|
||||||
@@ -71,7 +70,7 @@ SlotID CCreatureSet::getSlotFor(const CreatureID & creature, ui32 slotsAmount) c
|
|||||||
return getSlotFor(creature.toCreature(), slotsAmount);
|
return getSlotFor(creature.toCreature(), slotsAmount);
|
||||||
}
|
}
|
||||||
|
|
||||||
SlotID CCreatureSet::getSlotFor(const CCreature *c, ui32 slotsAmount) const
|
SlotID CCreatureSet::getSlotFor(const CCreature * c, ui32 slotsAmount) const
|
||||||
{
|
{
|
||||||
assert(c);
|
assert(c);
|
||||||
for(const auto & elem : stacks)
|
for(const auto & elem : stacks)
|
||||||
@@ -138,7 +137,6 @@ bool CCreatureSet::isCreatureBalanced(const CCreature * c, TQuantity ignoreAmoun
|
|||||||
if(count == ignoreAmount || count < 1)
|
if(count == ignoreAmount || count < 1)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
|
||||||
if(count > max)
|
if(count > max)
|
||||||
max = count;
|
max = count;
|
||||||
if(count < min)
|
if(count < min)
|
||||||
@@ -151,7 +149,7 @@ bool CCreatureSet::isCreatureBalanced(const CCreature * c, TQuantity ignoreAmoun
|
|||||||
|
|
||||||
SlotID CCreatureSet::getFreeSlot(ui32 slotsAmount) const
|
SlotID CCreatureSet::getFreeSlot(ui32 slotsAmount) const
|
||||||
{
|
{
|
||||||
for(ui32 i=0; i<slotsAmount; i++)
|
for(ui32 i = 0; i < slotsAmount; i++)
|
||||||
{
|
{
|
||||||
if(!vstd::contains(stacks, SlotID(i)))
|
if(!vstd::contains(stacks, SlotID(i)))
|
||||||
{
|
{
|
||||||
@@ -179,7 +177,7 @@ std::queue<SlotID> CCreatureSet::getFreeSlotsQueue(ui32 slotsAmount) const
|
|||||||
{
|
{
|
||||||
std::queue<SlotID> freeSlots;
|
std::queue<SlotID> freeSlots;
|
||||||
|
|
||||||
for (ui32 i = 0; i < slotsAmount; i++)
|
for(ui32 i = 0; i < slotsAmount; i++)
|
||||||
{
|
{
|
||||||
auto slot = SlotID(i);
|
auto slot = SlotID(i);
|
||||||
|
|
||||||
@@ -225,7 +223,7 @@ TCreatureQueue CCreatureSet::getCreatureQueue(const SlotID & exclude) const
|
|||||||
|
|
||||||
TQuantity CCreatureSet::getStackCount(const SlotID & slot) const
|
TQuantity CCreatureSet::getStackCount(const SlotID & slot) const
|
||||||
{
|
{
|
||||||
if (!hasStackAtSlot(slot))
|
if(!hasStackAtSlot(slot))
|
||||||
return 0;
|
return 0;
|
||||||
return stacks.at(slot)->getCount();
|
return stacks.at(slot)->getCount();
|
||||||
}
|
}
|
||||||
@@ -243,9 +241,9 @@ TExpType CCreatureSet::getStackAverageExperience(const SlotID & slot) const
|
|||||||
bool CCreatureSet::mergeableStacks(std::pair<SlotID, SlotID> & out, const SlotID & preferable) const /*looks for two same stacks, returns slot positions */
|
bool CCreatureSet::mergeableStacks(std::pair<SlotID, SlotID> & out, const SlotID & preferable) const /*looks for two same stacks, returns slot positions */
|
||||||
{
|
{
|
||||||
//try to match creature to our preferred stack
|
//try to match creature to our preferred stack
|
||||||
if(preferable.validSlot() && vstd::contains(stacks, preferable))
|
if(preferable.validSlot() && vstd::contains(stacks, preferable))
|
||||||
{
|
{
|
||||||
const CCreature *cr = stacks.find(preferable)->second->getCreature();
|
const CCreature * cr = stacks.find(preferable)->second->getCreature();
|
||||||
for(const auto & elem : stacks)
|
for(const auto & elem : stacks)
|
||||||
{
|
{
|
||||||
if(cr == elem.second->getType() && elem.first != preferable)
|
if(cr == elem.second->getType() && elem.first != preferable)
|
||||||
@@ -274,7 +272,7 @@ bool CCreatureSet::mergeableStacks(std::pair<SlotID, SlotID> & out, const SlotID
|
|||||||
|
|
||||||
void CCreatureSet::addToSlot(const SlotID & slot, const CreatureID & cre, TQuantity count, bool allowMerging)
|
void CCreatureSet::addToSlot(const SlotID & slot, const CreatureID & cre, TQuantity count, bool allowMerging)
|
||||||
{
|
{
|
||||||
const CCreature *c = cre.toCreature();
|
const CCreature * c = cre.toCreature();
|
||||||
|
|
||||||
if(!hasStackAtSlot(slot))
|
if(!hasStackAtSlot(slot))
|
||||||
{
|
{
|
||||||
@@ -331,18 +329,18 @@ bool CCreatureSet::needsLastStack() const
|
|||||||
ui64 CCreatureSet::getArmyStrength(int fortLevel) const
|
ui64 CCreatureSet::getArmyStrength(int fortLevel) const
|
||||||
{
|
{
|
||||||
ui64 ret = 0;
|
ui64 ret = 0;
|
||||||
for (const auto& elem : stacks)
|
for(const auto & elem : stacks)
|
||||||
{
|
{
|
||||||
ui64 powerToAdd = elem.second->getPower();
|
ui64 powerToAdd = elem.second->getPower();
|
||||||
if (fortLevel > 0)
|
if(fortLevel > 0)
|
||||||
{
|
{
|
||||||
if (!elem.second->hasBonusOfType(BonusType::FLYING))
|
if(!elem.second->hasBonusOfType(BonusType::FLYING))
|
||||||
{
|
{
|
||||||
powerToAdd /= fortLevel;
|
powerToAdd /= fortLevel;
|
||||||
if (!elem.second->hasBonusOfType(BonusType::SHOOTER))
|
if(!elem.second->hasBonusOfType(BonusType::SHOOTER))
|
||||||
powerToAdd /= fortLevel;
|
powerToAdd /= fortLevel;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ret += powerToAdd;
|
ret += powerToAdd;
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
@@ -351,7 +349,7 @@ ui64 CCreatureSet::getArmyStrength(int fortLevel) const
|
|||||||
ui64 CCreatureSet::getArmyCost() const
|
ui64 CCreatureSet::getArmyCost() const
|
||||||
{
|
{
|
||||||
ui64 ret = 0;
|
ui64 ret = 0;
|
||||||
for (const auto& elem : stacks)
|
for(const auto & elem : stacks)
|
||||||
ret += elem.second->getMarketValue();
|
ret += elem.second->getMarketValue();
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@@ -372,7 +370,7 @@ std::string CCreatureSet::getRoughAmount(const SlotID & slot, int mode) const
|
|||||||
if(settings["gameTweaks"]["numericCreaturesQuantities"].Bool())
|
if(settings["gameTweaks"]["numericCreaturesQuantities"].Bool())
|
||||||
return CCreature::getQuantityRangeStringForId(quantity);
|
return CCreature::getQuantityRangeStringForId(quantity);
|
||||||
|
|
||||||
return LIBRARY->generaltexth->arraytxt[(174 + mode) + 3*(int)quantity];
|
return LIBRARY->generaltexth->arraytxt[(174 + mode) + 3 * (int)quantity];
|
||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
@@ -450,7 +448,8 @@ CStackInstance * CCreatureSet::getStackPtr(const SlotID & slot) const
|
|||||||
{
|
{
|
||||||
if(hasStackAtSlot(slot))
|
if(hasStackAtSlot(slot))
|
||||||
return stacks.find(slot)->second.get();
|
return stacks.find(slot)->second.get();
|
||||||
else return nullptr;
|
else
|
||||||
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CCreatureSet::eraseStack(const SlotID & slot)
|
void CCreatureSet::eraseStack(const SlotID & slot)
|
||||||
@@ -459,7 +458,7 @@ void CCreatureSet::eraseStack(const SlotID & slot)
|
|||||||
detachStack(slot);
|
detachStack(slot);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CCreatureSet::contains(const CStackInstance *stack) const
|
bool CCreatureSet::contains(const CStackInstance * stack) const
|
||||||
{
|
{
|
||||||
if(!stack)
|
if(!stack)
|
||||||
return false;
|
return false;
|
||||||
@@ -471,10 +470,10 @@ bool CCreatureSet::contains(const CStackInstance *stack) const
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
SlotID CCreatureSet::findStack(const CStackInstance *stack) const
|
SlotID CCreatureSet::findStack(const CStackInstance * stack) const
|
||||||
{
|
{
|
||||||
const auto * h = dynamic_cast<const CGHeroInstance *>(this);
|
const auto * h = dynamic_cast<const CGHeroInstance *>(this);
|
||||||
if (h && h->getCommander() == stack)
|
if(h && h->getCommander() == stack)
|
||||||
return SlotID::COMMANDER_SLOT_PLACEHOLDER;
|
return SlotID::COMMANDER_SLOT_PLACEHOLDER;
|
||||||
|
|
||||||
if(!stack)
|
if(!stack)
|
||||||
@@ -499,7 +498,7 @@ void CCreatureSet::putStack(const SlotID & slot, std::unique_ptr<CStackInstance>
|
|||||||
|
|
||||||
void CCreatureSet::joinStack(const SlotID & slot, std::unique_ptr<CStackInstance> stack)
|
void CCreatureSet::joinStack(const SlotID & slot, std::unique_ptr<CStackInstance> stack)
|
||||||
{
|
{
|
||||||
[[maybe_unused]] const CCreature *c = getCreature(slot);
|
[[maybe_unused]] const CCreature * c = getCreature(slot);
|
||||||
assert(c == stack->getType());
|
assert(c == stack->getType());
|
||||||
assert(c);
|
assert(c);
|
||||||
|
|
||||||
@@ -530,7 +529,7 @@ void CCreatureSet::changeStackCount(const SlotID & slot, TQuantity toAdd)
|
|||||||
|
|
||||||
CCreatureSet::~CCreatureSet() = default;
|
CCreatureSet::~CCreatureSet() = default;
|
||||||
|
|
||||||
void CCreatureSet::setToArmy(CSimpleArmy &src)
|
void CCreatureSet::setToArmy(CSimpleArmy & src)
|
||||||
{
|
{
|
||||||
clearSlots();
|
clearSlots();
|
||||||
while(src)
|
while(src)
|
||||||
@@ -566,12 +565,12 @@ void CCreatureSet::setStackType(const SlotID & slot, const CreatureID & type)
|
|||||||
armyChanged();
|
armyChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CCreatureSet::canBeMergedWith(const CCreatureSet &cs, bool allowMergingStacks) const
|
bool CCreatureSet::canBeMergedWith(const CCreatureSet & cs, bool allowMergingStacks) const
|
||||||
{
|
{
|
||||||
if(!allowMergingStacks)
|
if(!allowMergingStacks)
|
||||||
{
|
{
|
||||||
int freeSlots = stacksCount() - GameConstants::ARMY_SIZE;
|
int freeSlots = stacksCount() - GameConstants::ARMY_SIZE;
|
||||||
std::set<const CCreature*> cresToAdd;
|
std::set<const CCreature *> cresToAdd;
|
||||||
for(const auto & elem : cs.stacks)
|
for(const auto & elem : cs.stacks)
|
||||||
{
|
{
|
||||||
SlotID dest = getSlotFor(elem.second->getCreature());
|
SlotID dest = getSlotFor(elem.second->getCreature());
|
||||||
@@ -587,13 +586,13 @@ bool CCreatureSet::canBeMergedWith(const CCreatureSet &cs, bool allowMergingStac
|
|||||||
|
|
||||||
//get types of creatures that need their own slot
|
//get types of creatures that need their own slot
|
||||||
for(const auto & elem : cs.stacks)
|
for(const auto & elem : cs.stacks)
|
||||||
if ((j = cres.getSlotFor(elem.second->getCreature())).validSlot())
|
if((j = cres.getSlotFor(elem.second->getCreature())).validSlot())
|
||||||
cres.addToSlot(j, elem.second->getId(), 1, true); //merge if possible
|
cres.addToSlot(j, elem.second->getId(), 1, true); //merge if possible
|
||||||
//cres.addToSlot(elem.first, elem.second->type->getId(), 1, true);
|
//cres.addToSlot(elem.first, elem.second->type->getId(), 1, true);
|
||||||
for(const auto & elem : stacks)
|
for(const auto & elem : stacks)
|
||||||
{
|
{
|
||||||
if ((j = cres.getSlotFor(elem.second->getCreature())).validSlot())
|
if((j = cres.getSlotFor(elem.second->getCreature())).validSlot())
|
||||||
cres.addToSlot(j, elem.second->getId(), 1, true); //merge if possible
|
cres.addToSlot(j, elem.second->getId(), 1, true); //merge if possible
|
||||||
else
|
else
|
||||||
return false; //no place found
|
return false; //no place found
|
||||||
}
|
}
|
||||||
@@ -611,22 +610,22 @@ bool CCreatureSet::hasUnits(const std::vector<CStackBasicDescriptor> & units, bo
|
|||||||
for(const auto & slot : Slots())
|
for(const auto & slot : Slots())
|
||||||
{
|
{
|
||||||
const auto & heroStack = slot.second;
|
const auto & heroStack = slot.second;
|
||||||
if (heroStack->getType() == reqStack.getType())
|
if(heroStack->getType() == reqStack.getType())
|
||||||
{
|
{
|
||||||
count += heroStack->getCount();
|
count += heroStack->getCount();
|
||||||
testedSlots += 1;
|
testedSlots += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (count > reqStack.getCount())
|
if(count > reqStack.getCount())
|
||||||
foundExtraCreatures = true;
|
foundExtraCreatures = true;
|
||||||
|
|
||||||
if (count < reqStack.getCount()) //not enough creatures of this kind
|
if(count < reqStack.getCount()) //not enough creatures of this kind
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (requireLastStack)
|
if(requireLastStack)
|
||||||
{
|
{
|
||||||
if (!foundExtraCreatures && testedSlots >= Slots().size())
|
if(!foundExtraCreatures && testedSlots >= Slots().size())
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -638,16 +637,13 @@ bool CCreatureSet::hasStackAtSlot(const SlotID & slot) const
|
|||||||
return vstd::contains(stacks, slot);
|
return vstd::contains(stacks, slot);
|
||||||
}
|
}
|
||||||
|
|
||||||
CCreatureSet & CCreatureSet::operator=(const CCreatureSet&cs)
|
CCreatureSet & CCreatureSet::operator=(const CCreatureSet & cs)
|
||||||
{
|
{
|
||||||
assert(0);
|
assert(0);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CCreatureSet::armyChanged()
|
void CCreatureSet::armyChanged() {}
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void CCreatureSet::serializeJson(JsonSerializeFormat & handler, const std::string & armyFieldName, const std::optional<int> fixedSize)
|
void CCreatureSet::serializeJson(JsonSerializeFormat & handler, const std::string & armyFieldName, const std::optional<int> fixedSize)
|
||||||
{
|
{
|
||||||
@@ -657,13 +653,12 @@ void CCreatureSet::serializeJson(JsonSerializeFormat & handler, const std::strin
|
|||||||
handler.serializeEnum("formation", formation, NArmyFormation::names);
|
handler.serializeEnum("formation", formation, NArmyFormation::names);
|
||||||
auto a = handler.enterArray(armyFieldName);
|
auto a = handler.enterArray(armyFieldName);
|
||||||
|
|
||||||
|
|
||||||
if(handler.saving)
|
if(handler.saving)
|
||||||
{
|
{
|
||||||
size_t sz = 0;
|
size_t sz = 0;
|
||||||
|
|
||||||
for(const auto & p : stacks)
|
for(const auto & p : stacks)
|
||||||
vstd::amax(sz, p.first.getNum()+1);
|
vstd::amax(sz, p.first.getNum() + 1);
|
||||||
|
|
||||||
if(fixedSize)
|
if(fixedSize)
|
||||||
vstd::amax(sz, fixedSize.value());
|
vstd::amax(sz, fixedSize.value());
|
||||||
|
|||||||
@@ -34,13 +34,13 @@ using TCreatureQueue = std::priority_queue<TPairCreatureSlot, std::vector<TPairC
|
|||||||
|
|
||||||
namespace NArmyFormation
|
namespace NArmyFormation
|
||||||
{
|
{
|
||||||
static const std::vector<std::string> names{ "wide", "tight" };
|
static const std::vector<std::string> names{"wide", "tight"};
|
||||||
}
|
}
|
||||||
|
|
||||||
class DLL_LINKAGE CCreatureSet : public IArmyDescriptor, public virtual Serializeable //seven combined creatures
|
class DLL_LINKAGE CCreatureSet : public IArmyDescriptor, public virtual Serializeable //seven combined creatures
|
||||||
{
|
{
|
||||||
CCreatureSet(const CCreatureSet &) = delete;
|
CCreatureSet(const CCreatureSet &) = delete;
|
||||||
CCreatureSet &operator=(const CCreatureSet&);
|
CCreatureSet & operator=(const CCreatureSet &);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
TSlots stacks; //slots[slot_id]->> pair(creature_id,creature_quantity)
|
TSlots stacks; //slots[slot_id]->> pair(creature_id,creature_quantity)
|
||||||
@@ -54,17 +54,23 @@ public:
|
|||||||
|
|
||||||
const TSlots &Slots() const {return stacks;}
|
const TSlots &Slots() const {return stacks;}
|
||||||
|
|
||||||
void addToSlot(const SlotID & slot, const CreatureID & cre, TQuantity count, bool allowMerging = true); //Adds stack to slot. Slot must be empty or with same type creature
|
//Adds stack to slot. Slot must be empty or with same type creature
|
||||||
void addToSlot(const SlotID & slot, std::unique_ptr<CStackInstance> stack, bool allowMerging = true); //Adds stack to slot. Slot must be empty or with same type creature
|
void addToSlot(const SlotID & slot, const CreatureID & cre, TQuantity count, bool allowMerging = true);
|
||||||
|
//Adds stack to slot. Slot must be empty or with same type creature
|
||||||
|
void addToSlot(const SlotID & slot, std::unique_ptr<CStackInstance> stack, bool allowMerging = true);
|
||||||
|
|
||||||
void clearSlots() override;
|
void clearSlots() override;
|
||||||
void setFormation(EArmyFormation tight);
|
void setFormation(EArmyFormation tight);
|
||||||
virtual CArmedInstance * getArmy() { return nullptr; }
|
virtual CArmedInstance * getArmy() { return nullptr; }
|
||||||
virtual const CArmedInstance * getArmy() const { return nullptr; }
|
virtual const CArmedInstance * getArmy() const { return nullptr; }
|
||||||
|
|
||||||
//basic operations
|
//adds new stack to the army, slot must be empty
|
||||||
void putStack(const SlotID & slot, std::unique_ptr<CStackInstance> stack); //adds new stack to the army, slot must be empty
|
void putStack(const SlotID & slot, std::unique_ptr<CStackInstance> stack);
|
||||||
void setStackCount(const SlotID & slot, TQuantity count); //stack must exist!
|
//stack must exist!
|
||||||
std::unique_ptr<CStackInstance> detachStack(const SlotID & slot); //removes stack from army but doesn't destroy it (so it can be moved somewhere else or safely deleted)
|
void setStackCount(const SlotID & slot, TQuantity count);
|
||||||
|
//removes stack from army but doesn't destroy it (so it can be moved somewhere else or safely deleted)
|
||||||
|
std::unique_ptr<CStackInstance> detachStack(const SlotID & slot);
|
||||||
|
|
||||||
void setStackType(const SlotID & slot, const CreatureID & type);
|
void setStackType(const SlotID & slot, const CreatureID & type);
|
||||||
|
|
||||||
/// Give specified amount of experience to all units in army
|
/// Give specified amount of experience to all units in army
|
||||||
@@ -86,9 +92,14 @@ public:
|
|||||||
/// Slot must be non-empty and contain more units that split quantity
|
/// Slot must be non-empty and contain more units that split quantity
|
||||||
std::unique_ptr<CStackInstance> splitStack(const SlotID & slot, TQuantity toSplit);
|
std::unique_ptr<CStackInstance> splitStack(const SlotID & slot, TQuantity toSplit);
|
||||||
|
|
||||||
void changeStackCount(const SlotID & slot, TQuantity toAdd); //stack must exist!
|
//stack must exist!
|
||||||
bool setCreature (SlotID slot, CreatureID type, TQuantity quantity) override; //replaces creature in stack; slots 0 to 6, if quantity=0 erases stack
|
void changeStackCount(const SlotID & slot, TQuantity toAdd);
|
||||||
void setToArmy(CSimpleArmy &src); //erases all our army and moves stacks from src to us; src MUST NOT be an armed object! WARNING: use it wisely. Or better do not use at all.
|
|
||||||
|
//replaces creature in stack; slots 0 to 6, if quantity=0 erases stack
|
||||||
|
bool setCreature(SlotID slot, CreatureID type, TQuantity quantity) override;
|
||||||
|
|
||||||
|
//erases all our army and moves stacks from src to us; src MUST NOT be an armed object! WARNING: use it wisely. Or better do not use at all.
|
||||||
|
void setToArmy(CSimpleArmy & src);
|
||||||
|
|
||||||
const CStackInstance & getStack(const SlotID & slot) const; //stack must exist
|
const CStackInstance & getStack(const SlotID & slot) const; //stack must exist
|
||||||
CStackInstance * getStackPtr(const SlotID & slot) const; //if stack doesn't exist, returns nullptr
|
CStackInstance * getStackPtr(const SlotID & slot) const; //if stack doesn't exist, returns nullptr
|
||||||
@@ -96,12 +107,12 @@ public:
|
|||||||
int getStackCount(const SlotID & slot) const;
|
int getStackCount(const SlotID & slot) const;
|
||||||
TExpType getStackTotalExperience(const SlotID & slot) const;
|
TExpType getStackTotalExperience(const SlotID & slot) const;
|
||||||
TExpType getStackAverageExperience(const SlotID & slot) const;
|
TExpType getStackAverageExperience(const SlotID & slot) const;
|
||||||
SlotID findStack(const CStackInstance *stack) const; //-1 if none
|
SlotID findStack(const CStackInstance * stack) const; //-1 if none
|
||||||
SlotID getSlotFor(const CreatureID & creature, ui32 slotsAmount = GameConstants::ARMY_SIZE) const; //returns -1 if no slot available
|
SlotID getSlotFor(const CreatureID & creature, ui32 slotsAmount = GameConstants::ARMY_SIZE) const; //returns -1 if no slot available
|
||||||
SlotID getSlotFor(const CCreature *c, ui32 slotsAmount = GameConstants::ARMY_SIZE) const; //returns -1 if no slot available
|
SlotID getSlotFor(const CCreature * c, ui32 slotsAmount = GameConstants::ARMY_SIZE) const; //returns -1 if no slot available
|
||||||
bool hasCreatureSlots(const CCreature * c, const SlotID & exclude) const;
|
bool hasCreatureSlots(const CCreature * c, const SlotID & exclude) const;
|
||||||
std::vector<SlotID> getCreatureSlots(const CCreature * c, const SlotID & exclude, TQuantity ignoreAmount = -1) const;
|
std::vector<SlotID> getCreatureSlots(const CCreature * c, const SlotID & exclude, TQuantity ignoreAmount = -1) const;
|
||||||
bool isCreatureBalanced(const CCreature* c, TQuantity ignoreAmount = 1) const; // Check if the creature is evenly distributed across slots
|
bool isCreatureBalanced(const CCreature * c, TQuantity ignoreAmount = 1) const; // Check if the creature is evenly distributed across slots
|
||||||
|
|
||||||
SlotID getFreeSlot(ui32 slotsAmount = GameConstants::ARMY_SIZE) const; //returns first free slot
|
SlotID getFreeSlot(ui32 slotsAmount = GameConstants::ARMY_SIZE) const; //returns first free slot
|
||||||
std::vector<SlotID> getFreeSlots(ui32 slotsAmount = GameConstants::ARMY_SIZE) const;
|
std::vector<SlotID> getFreeSlots(ui32 slotsAmount = GameConstants::ARMY_SIZE) const;
|
||||||
@@ -122,15 +133,16 @@ public:
|
|||||||
std::string getArmyDescription() const;
|
std::string getArmyDescription() const;
|
||||||
bool hasStackAtSlot(const SlotID & slot) const;
|
bool hasStackAtSlot(const SlotID & slot) const;
|
||||||
|
|
||||||
bool contains(const CStackInstance *stack) const;
|
bool contains(const CStackInstance * stack) const;
|
||||||
bool canBeMergedWith(const CCreatureSet &cs, bool allowMergingStacks = true) const;
|
bool canBeMergedWith(const CCreatureSet & cs, bool allowMergingStacks = true) const;
|
||||||
|
|
||||||
/// Returns true if this creature set contains all listed units
|
/// Returns true if this creature set contains all listed units
|
||||||
/// If requireLastStack is true, then this function will also
|
/// If requireLastStack is true, then this function will also
|
||||||
/// require presence of any unit other than requested (or more units than requested)
|
/// require presence of any unit other than requested (or more units than requested)
|
||||||
bool hasUnits(const std::vector<CStackBasicDescriptor> & units, bool requireLastStack = true) const;
|
bool hasUnits(const std::vector<CStackBasicDescriptor> & units, bool requireLastStack = true) const;
|
||||||
|
|
||||||
template <typename Handler> void serialize(Handler &h)
|
template<typename Handler>
|
||||||
|
void serialize(Handler & h)
|
||||||
{
|
{
|
||||||
h & stacks;
|
h & stacks;
|
||||||
h & formation;
|
h & formation;
|
||||||
|
|||||||
@@ -44,8 +44,8 @@ public:
|
|||||||
return !army.empty();
|
return !army.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename Handler>
|
||||||
template <typename Handler> void serialize(Handler &h)
|
void serialize(Handler & h)
|
||||||
{
|
{
|
||||||
h & army;
|
h & army;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,14 +19,15 @@ VCMI_LIB_NAMESPACE_BEGIN
|
|||||||
//This constructor should be placed here to avoid side effects
|
//This constructor should be placed here to avoid side effects
|
||||||
CStackBasicDescriptor::CStackBasicDescriptor() = default;
|
CStackBasicDescriptor::CStackBasicDescriptor() = default;
|
||||||
|
|
||||||
CStackBasicDescriptor::CStackBasicDescriptor(const CreatureID & id, TQuantity Count):
|
CStackBasicDescriptor::CStackBasicDescriptor(const CreatureID & id, TQuantity Count)
|
||||||
typeID(id),
|
: typeID(id)
|
||||||
count(Count)
|
, count(Count)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
CStackBasicDescriptor::CStackBasicDescriptor(const CCreature *c, TQuantity Count)
|
CStackBasicDescriptor::CStackBasicDescriptor(const CCreature * c, TQuantity Count)
|
||||||
: typeID(c ? c->getId() : CreatureID()), count(Count)
|
: typeID(c ? c->getId() : CreatureID())
|
||||||
|
, count(Count)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -61,7 +62,7 @@ void CStackBasicDescriptor::setCount(TQuantity newCount)
|
|||||||
count = newCount;
|
count = newCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator== (const CStackBasicDescriptor & l, const CStackBasicDescriptor & r)
|
bool operator==(const CStackBasicDescriptor & l, const CStackBasicDescriptor & r)
|
||||||
{
|
{
|
||||||
return l.typeID == r.typeID && l.count == r.count;
|
return l.typeID == r.typeID && l.count == r.count;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ class DLL_LINKAGE CStackBasicDescriptor
|
|||||||
public:
|
public:
|
||||||
CStackBasicDescriptor();
|
CStackBasicDescriptor();
|
||||||
CStackBasicDescriptor(const CreatureID & id, TQuantity Count);
|
CStackBasicDescriptor(const CreatureID & id, TQuantity Count);
|
||||||
CStackBasicDescriptor(const CCreature *c, TQuantity Count);
|
CStackBasicDescriptor(const CCreature * c, TQuantity Count);
|
||||||
virtual ~CStackBasicDescriptor() = default;
|
virtual ~CStackBasicDescriptor() = default;
|
||||||
|
|
||||||
const Creature * getType() const;
|
const Creature * getType() const;
|
||||||
@@ -39,9 +39,10 @@ public:
|
|||||||
virtual void setType(const CCreature * c);
|
virtual void setType(const CCreature * c);
|
||||||
virtual void setCount(TQuantity amount);
|
virtual void setCount(TQuantity amount);
|
||||||
|
|
||||||
friend bool operator== (const CStackBasicDescriptor & l, const CStackBasicDescriptor & r);
|
friend bool operator==(const CStackBasicDescriptor & l, const CStackBasicDescriptor & r);
|
||||||
|
|
||||||
template <typename Handler> void serialize(Handler &h)
|
template<typename Handler>
|
||||||
|
void serialize(Handler & h)
|
||||||
{
|
{
|
||||||
if(h.saving)
|
if(h.saving)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -23,11 +23,12 @@
|
|||||||
|
|
||||||
VCMI_LIB_NAMESPACE_BEGIN
|
VCMI_LIB_NAMESPACE_BEGIN
|
||||||
|
|
||||||
CStackInstance::CStackInstance(IGameInfoCallback *cb)
|
CStackInstance::CStackInstance(IGameInfoCallback * cb)
|
||||||
: CStackInstance(cb, BonusNodeType::STACK_INSTANCE, false)
|
: CStackInstance(cb, BonusNodeType::STACK_INSTANCE, false)
|
||||||
{}
|
{
|
||||||
|
}
|
||||||
|
|
||||||
CStackInstance::CStackInstance(IGameInfoCallback *cb, BonusNodeType nodeType, bool isHypothetic)
|
CStackInstance::CStackInstance(IGameInfoCallback * cb, BonusNodeType nodeType, bool isHypothetic)
|
||||||
: CBonusSystemNode(nodeType, isHypothetic)
|
: CBonusSystemNode(nodeType, isHypothetic)
|
||||||
, CStackBasicDescriptor(nullptr, 0)
|
, CStackBasicDescriptor(nullptr, 0)
|
||||||
, CArtifactSet(cb)
|
, CArtifactSet(cb)
|
||||||
@@ -35,9 +36,10 @@ CStackInstance::CStackInstance(IGameInfoCallback *cb, BonusNodeType nodeType, bo
|
|||||||
, nativeTerrain(this, Selector::type()(BonusType::TERRAIN_NATIVE))
|
, nativeTerrain(this, Selector::type()(BonusType::TERRAIN_NATIVE))
|
||||||
, initiative(this, Selector::type()(BonusType::STACKS_SPEED))
|
, initiative(this, Selector::type()(BonusType::STACKS_SPEED))
|
||||||
, totalExperience(0)
|
, totalExperience(0)
|
||||||
{}
|
{
|
||||||
|
}
|
||||||
|
|
||||||
CStackInstance::CStackInstance(IGameInfoCallback *cb, const CreatureID & id, TQuantity Count, bool isHypothetic)
|
CStackInstance::CStackInstance(IGameInfoCallback * cb, const CreatureID & id, TQuantity Count, bool isHypothetic)
|
||||||
: CStackInstance(cb, BonusNodeType::STACK_INSTANCE, false)
|
: CStackInstance(cb, BonusNodeType::STACK_INSTANCE, false)
|
||||||
{
|
{
|
||||||
setType(id);
|
setType(id);
|
||||||
@@ -51,14 +53,14 @@ CCreature::CreatureQuantityId CStackInstance::getQuantityID() const
|
|||||||
|
|
||||||
int CStackInstance::getExpRank() const
|
int CStackInstance::getExpRank() const
|
||||||
{
|
{
|
||||||
if (!LIBRARY->engineSettings()->getBoolean(EGameSettings::MODULE_STACK_EXPERIENCE))
|
if(!LIBRARY->engineSettings()->getBoolean(EGameSettings::MODULE_STACK_EXPERIENCE))
|
||||||
return 0;
|
return 0;
|
||||||
int tier = getType()->getLevel();
|
int tier = getType()->getLevel();
|
||||||
if (vstd::iswithin(tier, 1, 7))
|
if(vstd::iswithin(tier, 1, 7))
|
||||||
{
|
{
|
||||||
for(int i = static_cast<int>(LIBRARY->creh->expRanks[tier].size()) - 2; i > -1; --i) //sic!
|
for(int i = static_cast<int>(LIBRARY->creh->expRanks[tier].size()) - 2; i > -1; --i) //sic!
|
||||||
{ //exp values vary from 1st level to max exp at 11th level
|
{ //exp values vary from 1st level to max exp at 11th level
|
||||||
if (getAverageExperience() >= LIBRARY->creh->expRanks[tier][i])
|
if(getAverageExperience() >= LIBRARY->creh->expRanks[tier][i])
|
||||||
return ++i; //faster, but confusing - 0 index mean 1st level of experience
|
return ++i; //faster, but confusing - 0 index mean 1st level of experience
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
@@ -67,7 +69,7 @@ int CStackInstance::getExpRank() const
|
|||||||
{
|
{
|
||||||
for(int i = static_cast<int>(LIBRARY->creh->expRanks[0].size()) - 2; i > -1; --i)
|
for(int i = static_cast<int>(LIBRARY->creh->expRanks[0].size()) - 2; i > -1; --i)
|
||||||
{
|
{
|
||||||
if (getAverageExperience() >= LIBRARY->creh->expRanks[0][i])
|
if(getAverageExperience() >= LIBRARY->creh->expRanks[0][i])
|
||||||
return ++i;
|
return ++i;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
@@ -81,25 +83,25 @@ int CStackInstance::getLevel() const
|
|||||||
|
|
||||||
void CStackInstance::giveAverageStackExperience(TExpType desiredAmountPerUnit)
|
void CStackInstance::giveAverageStackExperience(TExpType desiredAmountPerUnit)
|
||||||
{
|
{
|
||||||
if (!canGainExperience())
|
if(!canGainExperience())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
int level = std::clamp(getLevel(), 1, 7);
|
int level = std::clamp(getLevel(), 1, 7);
|
||||||
TExpType maxAmountPerUnit = LIBRARY->creh->expRanks[level].back();
|
TExpType maxAmountPerUnit = LIBRARY->creh->expRanks[level].back();
|
||||||
TExpType actualAmountPerUnit = std::min(desiredAmountPerUnit, maxAmountPerUnit * LIBRARY->creh->maxExpPerBattle[level]/100);
|
TExpType actualAmountPerUnit = std::min(desiredAmountPerUnit, maxAmountPerUnit * LIBRARY->creh->maxExpPerBattle[level] / 100);
|
||||||
TExpType maxExperience = maxAmountPerUnit * getCount();
|
TExpType maxExperience = maxAmountPerUnit * getCount();
|
||||||
TExpType maxExperienceToGain = maxExperience - totalExperience;
|
TExpType maxExperienceToGain = maxExperience - totalExperience;
|
||||||
TExpType actualGainedExperience = std::min(maxExperienceToGain, actualAmountPerUnit * getCount());
|
TExpType actualGainedExperience = std::min(maxExperienceToGain, actualAmountPerUnit * getCount());
|
||||||
|
|
||||||
totalExperience += actualGainedExperience;
|
totalExperience += actualGainedExperience;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CStackInstance::giveTotalStackExperience(TExpType experienceToGive)
|
void CStackInstance::giveTotalStackExperience(TExpType experienceToGive)
|
||||||
{
|
{
|
||||||
if (!canGainExperience())
|
if(!canGainExperience())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
totalExperience += experienceToGive;
|
totalExperience += experienceToGive;
|
||||||
}
|
}
|
||||||
|
|
||||||
TExpType CStackInstance::getTotalExperience() const
|
TExpType CStackInstance::getTotalExperience() const
|
||||||
@@ -119,18 +121,18 @@ bool CStackInstance::canGainExperience() const
|
|||||||
|
|
||||||
void CStackInstance::setType(const CreatureID & creID)
|
void CStackInstance::setType(const CreatureID & creID)
|
||||||
{
|
{
|
||||||
if (creID == CreatureID::NONE)
|
if(creID == CreatureID::NONE)
|
||||||
setType(nullptr);//FIXME: unused branch?
|
setType(nullptr); //FIXME: unused branch?
|
||||||
else
|
else
|
||||||
setType(creID.toCreature());
|
setType(creID.toCreature());
|
||||||
}
|
}
|
||||||
|
|
||||||
void CStackInstance::setType(const CCreature *c)
|
void CStackInstance::setType(const CCreature * c)
|
||||||
{
|
{
|
||||||
if(getCreature())
|
if(getCreature())
|
||||||
{
|
{
|
||||||
detachFromSource(*getCreature());
|
detachFromSource(*getCreature());
|
||||||
if (LIBRARY->engineSettings()->getBoolean(EGameSettings::MODULE_STACK_EXPERIENCE))
|
if(LIBRARY->engineSettings()->getBoolean(EGameSettings::MODULE_STACK_EXPERIENCE))
|
||||||
totalExperience = totalExperience * LIBRARY->creh->expAfterUpgrade / 100;
|
totalExperience = totalExperience * LIBRARY->creh->expAfterUpgrade / 100;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -144,7 +146,7 @@ void CStackInstance::setCount(TQuantity newCount)
|
|||||||
{
|
{
|
||||||
assert(newCount >= 0);
|
assert(newCount >= 0);
|
||||||
|
|
||||||
if (newCount < getCount())
|
if(newCount < getCount())
|
||||||
{
|
{
|
||||||
TExpType averageExperience = totalExperience / getCount();
|
TExpType averageExperience = totalExperience / getCount();
|
||||||
totalExperience = averageExperience * newCount;
|
totalExperience = averageExperience * newCount;
|
||||||
@@ -154,9 +156,9 @@ void CStackInstance::setCount(TQuantity newCount)
|
|||||||
nodeHasChanged();
|
nodeHasChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string CStackInstance::bonusToString(const std::shared_ptr<Bonus>& bonus) const
|
std::string CStackInstance::bonusToString(const std::shared_ptr<Bonus> & bonus) const
|
||||||
{
|
{
|
||||||
if (!bonus->description.empty())
|
if(!bonus->description.empty())
|
||||||
return bonus->description.toString();
|
return bonus->description.toString();
|
||||||
else
|
else
|
||||||
return LIBRARY->getBth()->bonusToString(bonus, this);
|
return LIBRARY->getBth()->bonusToString(bonus, this);
|
||||||
@@ -164,7 +166,7 @@ std::string CStackInstance::bonusToString(const std::shared_ptr<Bonus>& bonus) c
|
|||||||
|
|
||||||
ImagePath CStackInstance::bonusToGraphics(const std::shared_ptr<Bonus> & bonus) const
|
ImagePath CStackInstance::bonusToGraphics(const std::shared_ptr<Bonus> & bonus) const
|
||||||
{
|
{
|
||||||
if (!bonus->customIconPath.empty())
|
if(!bonus->customIconPath.empty())
|
||||||
return bonus->customIconPath;
|
return bonus->customIconPath;
|
||||||
return LIBRARY->getBth()->bonusToGraphics(bonus);
|
return LIBRARY->getBth()->bonusToGraphics(bonus);
|
||||||
}
|
}
|
||||||
@@ -191,7 +193,7 @@ void CStackInstance::setArmy(CArmedInstance * ArmyObj)
|
|||||||
|
|
||||||
if(ArmyObj)
|
if(ArmyObj)
|
||||||
{
|
{
|
||||||
attachTo(const_cast<CArmedInstance&>(*ArmyObj));
|
attachTo(const_cast<CArmedInstance &>(*ArmyObj));
|
||||||
armyInstance = ArmyObj;
|
armyInstance = ArmyObj;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -200,12 +202,12 @@ std::string CStackInstance::getQuantityTXT(bool capitalized) const
|
|||||||
{
|
{
|
||||||
CCreature::CreatureQuantityId quantity = getQuantityID();
|
CCreature::CreatureQuantityId quantity = getQuantityID();
|
||||||
|
|
||||||
if ((int)quantity)
|
if((int)quantity)
|
||||||
{
|
{
|
||||||
if(settings["gameTweaks"]["numericCreaturesQuantities"].Bool())
|
if(settings["gameTweaks"]["numericCreaturesQuantities"].Bool())
|
||||||
return CCreature::getQuantityRangeStringForId(quantity);
|
return CCreature::getQuantityRangeStringForId(quantity);
|
||||||
|
|
||||||
return LIBRARY->generaltexth->arraytxt[174 + (int)quantity*3 - 1 - capitalized];
|
return LIBRARY->generaltexth->arraytxt[174 + (int)quantity * 3 - 1 - capitalized];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return "";
|
return "";
|
||||||
@@ -241,7 +243,7 @@ PlayerColor CStackInstance::getOwner() const
|
|||||||
|
|
||||||
int32_t CStackInstance::getInitiative(int turn) const
|
int32_t CStackInstance::getInitiative(int turn) const
|
||||||
{
|
{
|
||||||
if (turn == 0)
|
if(turn == 0)
|
||||||
return initiative.getValue();
|
return initiative.getValue();
|
||||||
|
|
||||||
return ACreature::getInitiative(turn);
|
return ACreature::getInitiative(turn);
|
||||||
@@ -249,7 +251,7 @@ int32_t CStackInstance::getInitiative(int turn) const
|
|||||||
|
|
||||||
TerrainId CStackInstance::getNativeTerrain() const
|
TerrainId CStackInstance::getNativeTerrain() const
|
||||||
{
|
{
|
||||||
if (nativeTerrain.hasBonus())
|
if(nativeTerrain.hasBonus())
|
||||||
return TerrainId::ANY_TERRAIN;
|
return TerrainId::ANY_TERRAIN;
|
||||||
|
|
||||||
return getFactionID().toEntity(LIBRARY)->getNativeTerrain();
|
return getFactionID().toEntity(LIBRARY)->getNativeTerrain();
|
||||||
@@ -311,7 +313,7 @@ void CStackInstance::removeArtifact(const ArtifactPosition & pos)
|
|||||||
void CStackInstance::serializeJson(JsonSerializeFormat & handler)
|
void CStackInstance::serializeJson(JsonSerializeFormat & handler)
|
||||||
{
|
{
|
||||||
//todo: artifacts
|
//todo: artifacts
|
||||||
CStackBasicDescriptor::serializeJson(handler);//must be first
|
CStackBasicDescriptor::serializeJson(handler); //must be first
|
||||||
|
|
||||||
if(handler.saving)
|
if(handler.saving)
|
||||||
{
|
{
|
||||||
@@ -335,7 +337,7 @@ void CStackInstance::serializeJson(JsonSerializeFormat & handler)
|
|||||||
handler.serializeInt("level", level, 0);
|
handler.serializeInt("level", level, 0);
|
||||||
handler.serializeInt("upgrade", upgrade, 0);
|
handler.serializeInt("upgrade", upgrade, 0);
|
||||||
|
|
||||||
randomStack = RandomStackInfo{ level, upgrade };
|
randomStack = RandomStackInfo{level, upgrade};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -348,7 +350,7 @@ FactionID CStackInstance::getFactionID() const
|
|||||||
return FactionID::NEUTRAL;
|
return FactionID::NEUTRAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
const IBonusBearer* CStackInstance::getBonusBearer() const
|
const IBonusBearer * CStackInstance::getBonusBearer() const
|
||||||
{
|
{
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,8 +15,8 @@
|
|||||||
#include "bonuses/BonusCache.h"
|
#include "bonuses/BonusCache.h"
|
||||||
#include "bonuses/CBonusSystemNode.h"
|
#include "bonuses/CBonusSystemNode.h"
|
||||||
#include "callback/GameCallbackHolder.h"
|
#include "callback/GameCallbackHolder.h"
|
||||||
#include "mapObjects/CGObjectInstance.h"
|
|
||||||
#include "entities/artifact/CArtifactSet.h"
|
#include "entities/artifact/CArtifactSet.h"
|
||||||
|
#include "mapObjects/CGObjectInstance.h"
|
||||||
|
|
||||||
VCMI_LIB_NAMESPACE_BEGIN
|
VCMI_LIB_NAMESPACE_BEGIN
|
||||||
|
|
||||||
@@ -34,9 +34,12 @@ class DLL_LINKAGE CStackInstance : public CBonusSystemNode, public CStackBasicDe
|
|||||||
|
|
||||||
CArmedInstance * armyInstance = nullptr; //stack must be part of some army, army must be part of some object
|
CArmedInstance * armyInstance = nullptr; //stack must be part of some army, army must be part of some object
|
||||||
|
|
||||||
IGameInfoCallback * getCallback() const final { return cb; }
|
IGameInfoCallback * getCallback() const final
|
||||||
|
{
|
||||||
|
return cb;
|
||||||
|
}
|
||||||
|
|
||||||
TExpType totalExperience;//commander needs same amount of exp as hero
|
TExpType totalExperience; //commander needs same amount of exp as hero
|
||||||
public:
|
public:
|
||||||
struct RandomStackInfo
|
struct RandomStackInfo
|
||||||
{
|
{
|
||||||
@@ -48,23 +51,24 @@ public:
|
|||||||
|
|
||||||
CArmedInstance * getArmy();
|
CArmedInstance * getArmy();
|
||||||
const CArmedInstance * getArmy() const; //stack must be part of some army, army must be part of some object
|
const CArmedInstance * getArmy() const; //stack must be part of some army, army must be part of some object
|
||||||
void setArmy(CArmedInstance *ArmyObj);
|
void setArmy(CArmedInstance * ArmyObj);
|
||||||
|
|
||||||
TExpType getTotalExperience() const;
|
TExpType getTotalExperience() const;
|
||||||
TExpType getAverageExperience() const;
|
TExpType getAverageExperience() const;
|
||||||
virtual bool canGainExperience() const;
|
virtual bool canGainExperience() const;
|
||||||
|
|
||||||
template <typename Handler> void serialize(Handler &h)
|
template<typename Handler>
|
||||||
|
void serialize(Handler & h)
|
||||||
{
|
{
|
||||||
h & static_cast<CBonusSystemNode&>(*this);
|
h & static_cast<CBonusSystemNode &>(*this);
|
||||||
h & static_cast<CStackBasicDescriptor&>(*this);
|
h & static_cast<CStackBasicDescriptor &>(*this);
|
||||||
h & static_cast<CArtifactSet&>(*this);
|
h & static_cast<CArtifactSet &>(*this);
|
||||||
|
|
||||||
if (h.hasFeature(Handler::Version::STACK_INSTANCE_ARMY_FIX))
|
if(h.hasFeature(Handler::Version::STACK_INSTANCE_ARMY_FIX))
|
||||||
{
|
{
|
||||||
// no-op
|
// no-op
|
||||||
}
|
}
|
||||||
if (h.hasFeature(Handler::Version::NO_RAW_POINTERS_IN_SERIALIZER))
|
if(h.hasFeature(Handler::Version::NO_RAW_POINTERS_IN_SERIALIZER))
|
||||||
{
|
{
|
||||||
ObjectInstanceID dummyID;
|
ObjectInstanceID dummyID;
|
||||||
h & dummyID;
|
h & dummyID;
|
||||||
@@ -76,7 +80,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
h & totalExperience;
|
h & totalExperience;
|
||||||
if (!h.hasFeature(Handler::Version::STACK_INSTANCE_EXPERIENCE_FIX))
|
if(!h.hasFeature(Handler::Version::STACK_INSTANCE_EXPERIENCE_FIX))
|
||||||
{
|
{
|
||||||
totalExperience *= getCount();
|
totalExperience *= getCount();
|
||||||
}
|
}
|
||||||
@@ -85,11 +89,11 @@ public:
|
|||||||
void serializeJson(JsonSerializeFormat & handler);
|
void serializeJson(JsonSerializeFormat & handler);
|
||||||
|
|
||||||
//overrides CBonusSystemNode
|
//overrides CBonusSystemNode
|
||||||
std::string bonusToString(const std::shared_ptr<Bonus>& bonus) const override; // how would bonus description look for this particular type of node
|
std::string bonusToString(const std::shared_ptr<Bonus> & bonus) const override; // how would bonus description look for this particular type of node
|
||||||
ImagePath bonusToGraphics(const std::shared_ptr<Bonus> & bonus) const; //file name of graphics from StackSkills , in future possibly others
|
ImagePath bonusToGraphics(const std::shared_ptr<Bonus> & bonus) const; //file name of graphics from StackSkills , in future possibly others
|
||||||
|
|
||||||
//IConstBonusProvider
|
//IConstBonusProvider
|
||||||
const IBonusBearer* getBonusBearer() const override;
|
const IBonusBearer * getBonusBearer() const override;
|
||||||
//INativeTerrainProvider
|
//INativeTerrainProvider
|
||||||
FactionID getFactionID() const override;
|
FactionID getFactionID() const override;
|
||||||
|
|
||||||
@@ -102,9 +106,9 @@ public:
|
|||||||
virtual int getLevel() const; //different for regular stack and commander
|
virtual int getLevel() const; //different for regular stack and commander
|
||||||
CreatureID getCreatureID() const; //-1 if not available
|
CreatureID getCreatureID() const; //-1 if not available
|
||||||
std::string getName() const; //plural or singular
|
std::string getName() const; //plural or singular
|
||||||
CStackInstance(IGameInfoCallback *cb);
|
CStackInstance(IGameInfoCallback * cb);
|
||||||
CStackInstance(IGameInfoCallback *cb, BonusNodeType nodeType, bool isHypothetic = false);
|
CStackInstance(IGameInfoCallback * cb, BonusNodeType nodeType, bool isHypothetic = false);
|
||||||
CStackInstance(IGameInfoCallback *cb, const CreatureID & id, TQuantity count, bool isHypothetic = false);
|
CStackInstance(IGameInfoCallback * cb, const CreatureID & id, TQuantity count, bool isHypothetic = false);
|
||||||
virtual ~CStackInstance() = default;
|
virtual ~CStackInstance() = default;
|
||||||
|
|
||||||
void setType(const CreatureID & creID);
|
void setType(const CreatureID & creID);
|
||||||
@@ -116,7 +120,7 @@ public:
|
|||||||
void giveTotalStackExperience(TExpType exp);
|
void giveTotalStackExperience(TExpType exp);
|
||||||
|
|
||||||
bool valid(bool allowUnrandomized) const;
|
bool valid(bool allowUnrandomized) const;
|
||||||
ArtPlacementMap putArtifact(const ArtifactPosition & pos, const CArtifactInstance * art) override;//from CArtifactSet
|
ArtPlacementMap putArtifact(const ArtifactPosition & pos, const CArtifactInstance * art) override; //from CArtifactSet
|
||||||
void removeArtifact(const ArtifactPosition & pos) override;
|
void removeArtifact(const ArtifactPosition & pos) override;
|
||||||
ArtBearer bearerType() const override; //from CArtifactSet
|
ArtBearer bearerType() const override; //from CArtifactSet
|
||||||
std::string nodeName() const override; //from CBonusSystemnode
|
std::string nodeName() const override; //from CBonusSystemnode
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
VCMI_LIB_NAMESPACE_BEGIN
|
VCMI_LIB_NAMESPACE_BEGIN
|
||||||
|
|
||||||
/// The castle event builds/adds buildings/creatures for a specific town.
|
/// The castle event builds/adds buildings/creatures for a specific town.
|
||||||
class DLL_LINKAGE CCastleEvent: public CMapEvent
|
class DLL_LINKAGE CCastleEvent : public CMapEvent
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CCastleEvent() = default;
|
CCastleEvent() = default;
|
||||||
@@ -23,7 +23,7 @@ public:
|
|||||||
std::set<BuildingID> buildings;
|
std::set<BuildingID> buildings;
|
||||||
std::vector<si32> creatures;
|
std::vector<si32> creatures;
|
||||||
|
|
||||||
template <typename Handler>
|
template<typename Handler>
|
||||||
void serialize(Handler & h)
|
void serialize(Handler & h)
|
||||||
{
|
{
|
||||||
h & static_cast<CMapEvent &>(*this);
|
h & static_cast<CMapEvent &>(*this);
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ public:
|
|||||||
|
|
||||||
std::vector<ObjectInstanceID> deletedObjectsInstances;
|
std::vector<ObjectInstanceID> deletedObjectsInstances;
|
||||||
|
|
||||||
template <typename Handler>
|
template<typename Handler>
|
||||||
void serialize(Handler & h)
|
void serialize(Handler & h)
|
||||||
{
|
{
|
||||||
h & name;
|
h & name;
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ struct DLL_LINKAGE TerrainTile
|
|||||||
std::vector<ObjectInstanceID> visitableObjects;
|
std::vector<ObjectInstanceID> visitableObjects;
|
||||||
std::vector<ObjectInstanceID> blockingObjects;
|
std::vector<ObjectInstanceID> blockingObjects;
|
||||||
|
|
||||||
template <typename Handler>
|
template<typename Handler>
|
||||||
void serialize(Handler & h)
|
void serialize(Handler & h)
|
||||||
{
|
{
|
||||||
h & terrainType;
|
h & terrainType;
|
||||||
@@ -78,7 +78,7 @@ struct DLL_LINKAGE TerrainTile
|
|||||||
h & roadDir;
|
h & roadDir;
|
||||||
h & extTileFlags;
|
h & extTileFlags;
|
||||||
|
|
||||||
if (h.hasFeature(Handler::Version::NO_RAW_POINTERS_IN_SERIALIZER))
|
if(h.hasFeature(Handler::Version::NO_RAW_POINTERS_IN_SERIALIZER))
|
||||||
{
|
{
|
||||||
h & visitableObjects;
|
h & visitableObjects;
|
||||||
h & blockingObjects;
|
h & blockingObjects;
|
||||||
@@ -87,14 +87,12 @@ struct DLL_LINKAGE TerrainTile
|
|||||||
{
|
{
|
||||||
std::vector<std::shared_ptr<CGObjectInstance>> objectPtrs;
|
std::vector<std::shared_ptr<CGObjectInstance>> objectPtrs;
|
||||||
h & objectPtrs;
|
h & objectPtrs;
|
||||||
for (const auto & ptr : objectPtrs)
|
for(const auto & ptr : objectPtrs)
|
||||||
visitableObjects.push_back(ptr->id);
|
visitableObjects.push_back(ptr->id);
|
||||||
h & objectPtrs;
|
h & objectPtrs;
|
||||||
for (const auto & ptr : objectPtrs)
|
for(const auto & ptr : objectPtrs)
|
||||||
blockingObjects.push_back(ptr->id);
|
blockingObjects.push_back(ptr->id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user