mirror of
https://github.com/vcmi/vcmi.git
synced 2025-11-27 22:49:25 +02:00
Apply formatting on changed files
This commit is contained in:
@@ -44,11 +44,11 @@ CArmedInstance::CArmedInstance(IGameInfoCallback *cb)
|
||||
{
|
||||
}
|
||||
|
||||
CArmedInstance::CArmedInstance(IGameInfoCallback *cb, BonusNodeType nodeType, bool isHypothetic):
|
||||
CGObjectInstance(cb),
|
||||
CBonusSystemNode(nodeType, isHypothetic),
|
||||
nonEvilAlignmentMix(this, Selector::type()(BonusType::NONEVIL_ALIGNMENT_MIX)), // Take Angelic Alliance troop-mixing freedom of non-evil units into account.
|
||||
battle(nullptr)
|
||||
CArmedInstance::CArmedInstance(IGameInfoCallback * cb, BonusNodeType nodeType, bool isHypothetic)
|
||||
: CGObjectInstance(cb)
|
||||
, CBonusSystemNode(nodeType, isHypothetic)
|
||||
, nonEvilAlignmentMix(this, Selector::type()(BonusType::NONEVIL_ALIGNMENT_MIX)) // Take Angelic Alliance troop-mixing freedom of non-evil units into account.
|
||||
, battle(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -127,7 +127,6 @@ void CArmedInstance::updateMoraleBonusFromArmy()
|
||||
}
|
||||
else if(undeadModifier)
|
||||
removeBonus(undeadModifier);
|
||||
|
||||
}
|
||||
|
||||
void CArmedInstance::armyChanged()
|
||||
|
||||
@@ -13,8 +13,8 @@
|
||||
|
||||
#include "../CGObjectInstance.h"
|
||||
|
||||
#include "../../bonuses/CBonusSystemNode.h"
|
||||
#include "../../bonuses/BonusCache.h"
|
||||
#include "../../bonuses/CBonusSystemNode.h"
|
||||
|
||||
#include <vcmi/Entity.h>
|
||||
|
||||
@@ -42,8 +42,14 @@ public:
|
||||
virtual void updateMoraleBonusFromArmy();
|
||||
|
||||
void armyChanged() override;
|
||||
CArmedInstance * getArmy() final { return this; }
|
||||
const CArmedInstance * getArmy() const final { return this; }
|
||||
CArmedInstance * getArmy() final
|
||||
{
|
||||
return this;
|
||||
}
|
||||
const CArmedInstance * getArmy() const final
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//IConstBonusProvider
|
||||
@@ -66,7 +72,8 @@ public:
|
||||
|
||||
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<CBonusSystemNode &>(*this);
|
||||
|
||||
@@ -17,7 +17,8 @@ VCMI_LIB_NAMESPACE_BEGIN
|
||||
|
||||
CCommanderInstance::CCommanderInstance(IGameInfoCallback * cb)
|
||||
: CStackInstance(cb)
|
||||
{}
|
||||
{
|
||||
}
|
||||
|
||||
CCommanderInstance::CCommanderInstance(IGameInfoCallback * cb, const CreatureID & id)
|
||||
: CStackInstance(cb, BonusNodeType::COMMANDER, false)
|
||||
|
||||
@@ -32,12 +32,16 @@ public:
|
||||
|
||||
bool canGainExperience() const override;
|
||||
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 getLevel() const override;
|
||||
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 & alive;
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
VCMI_LIB_NAMESPACE_BEGIN
|
||||
|
||||
|
||||
bool CreatureSlotComparer::operator()(const TPairCreatureSlot & lhs, const TPairCreatureSlot & rhs)
|
||||
{
|
||||
return lhs.first->getAIValue() < rhs.first->getAIValue(); // Descendant order sorting
|
||||
@@ -138,7 +137,6 @@ bool CCreatureSet::isCreatureBalanced(const CCreature * c, TQuantity ignoreAmoun
|
||||
if(count == ignoreAmount || count < 1)
|
||||
continue;
|
||||
|
||||
|
||||
if(count > max)
|
||||
max = count;
|
||||
if(count < min)
|
||||
@@ -450,7 +448,8 @@ CStackInstance * CCreatureSet::getStackPtr(const SlotID & slot) const
|
||||
{
|
||||
if(hasStackAtSlot(slot))
|
||||
return stacks.find(slot)->second.get();
|
||||
else return nullptr;
|
||||
else
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void CCreatureSet::eraseStack(const SlotID & slot)
|
||||
@@ -644,10 +643,7 @@ CCreatureSet & CCreatureSet::operator=(const CCreatureSet&cs)
|
||||
return *this;
|
||||
}
|
||||
|
||||
void CCreatureSet::armyChanged()
|
||||
{
|
||||
|
||||
}
|
||||
void CCreatureSet::armyChanged() {}
|
||||
|
||||
void CCreatureSet::serializeJson(JsonSerializeFormat & handler, const std::string & armyFieldName, const std::optional<int> fixedSize)
|
||||
{
|
||||
@@ -657,7 +653,6 @@ void CCreatureSet::serializeJson(JsonSerializeFormat & handler, const std::strin
|
||||
handler.serializeEnum("formation", formation, NArmyFormation::names);
|
||||
auto a = handler.enterArray(armyFieldName);
|
||||
|
||||
|
||||
if(handler.saving)
|
||||
{
|
||||
size_t sz = 0;
|
||||
|
||||
@@ -54,17 +54,23 @@ public:
|
||||
|
||||
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
|
||||
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
|
||||
//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 setFormation(EArmyFormation tight);
|
||||
virtual CArmedInstance * getArmy() { return nullptr; }
|
||||
virtual const CArmedInstance * getArmy() const { return nullptr; }
|
||||
|
||||
//basic operations
|
||||
void putStack(const SlotID & slot, std::unique_ptr<CStackInstance> stack); //adds new stack to the army, slot must be empty
|
||||
void setStackCount(const SlotID & slot, TQuantity count); //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)
|
||||
//adds new stack to the army, slot must be empty
|
||||
void putStack(const SlotID & slot, std::unique_ptr<CStackInstance> stack);
|
||||
//stack must exist!
|
||||
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);
|
||||
|
||||
/// 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
|
||||
std::unique_ptr<CStackInstance> splitStack(const SlotID & slot, TQuantity toSplit);
|
||||
|
||||
void changeStackCount(const SlotID & slot, TQuantity toAdd); //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 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.
|
||||
//stack must exist!
|
||||
void changeStackCount(const SlotID & slot, TQuantity toAdd);
|
||||
|
||||
//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
|
||||
CStackInstance * getStackPtr(const SlotID & slot) const; //if stack doesn't exist, returns nullptr
|
||||
@@ -130,7 +141,8 @@ public:
|
||||
/// require presence of any unit other than requested (or more units than requested)
|
||||
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 & formation;
|
||||
|
||||
@@ -44,8 +44,8 @@ public:
|
||||
return !army.empty();
|
||||
}
|
||||
|
||||
|
||||
template <typename Handler> void serialize(Handler &h)
|
||||
template<typename Handler>
|
||||
void serialize(Handler & h)
|
||||
{
|
||||
h & army;
|
||||
}
|
||||
|
||||
@@ -19,14 +19,15 @@ VCMI_LIB_NAMESPACE_BEGIN
|
||||
//This constructor should be placed here to avoid side effects
|
||||
CStackBasicDescriptor::CStackBasicDescriptor() = default;
|
||||
|
||||
CStackBasicDescriptor::CStackBasicDescriptor(const CreatureID & id, TQuantity Count):
|
||||
typeID(id),
|
||||
count(Count)
|
||||
CStackBasicDescriptor::CStackBasicDescriptor(const CreatureID & id, TQuantity Count)
|
||||
: typeID(id)
|
||||
, count(Count)
|
||||
{
|
||||
}
|
||||
|
||||
CStackBasicDescriptor::CStackBasicDescriptor(const CCreature * c, TQuantity Count)
|
||||
: typeID(c ? c->getId() : CreatureID()), count(Count)
|
||||
: typeID(c ? c->getId() : CreatureID())
|
||||
, count(Count)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -41,7 +41,8 @@ public:
|
||||
|
||||
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)
|
||||
{
|
||||
|
||||
@@ -25,7 +25,8 @@ VCMI_LIB_NAMESPACE_BEGIN
|
||||
|
||||
CStackInstance::CStackInstance(IGameInfoCallback * cb)
|
||||
: CStackInstance(cb, BonusNodeType::STACK_INSTANCE, false)
|
||||
{}
|
||||
{
|
||||
}
|
||||
|
||||
CStackInstance::CStackInstance(IGameInfoCallback * cb, BonusNodeType nodeType, bool isHypothetic)
|
||||
: CBonusSystemNode(nodeType, isHypothetic)
|
||||
@@ -35,7 +36,8 @@ CStackInstance::CStackInstance(IGameInfoCallback *cb, BonusNodeType nodeType, bo
|
||||
, nativeTerrain(this, Selector::type()(BonusType::TERRAIN_NATIVE))
|
||||
, initiative(this, Selector::type()(BonusType::STACKS_SPEED))
|
||||
, totalExperience(0)
|
||||
{}
|
||||
{
|
||||
}
|
||||
|
||||
CStackInstance::CStackInstance(IGameInfoCallback * cb, const CreatureID & id, TQuantity Count, bool isHypothetic)
|
||||
: CStackInstance(cb, BonusNodeType::STACK_INSTANCE, false)
|
||||
|
||||
@@ -15,8 +15,8 @@
|
||||
#include "bonuses/BonusCache.h"
|
||||
#include "bonuses/CBonusSystemNode.h"
|
||||
#include "callback/GameCallbackHolder.h"
|
||||
#include "mapObjects/CGObjectInstance.h"
|
||||
#include "entities/artifact/CArtifactSet.h"
|
||||
#include "mapObjects/CGObjectInstance.h"
|
||||
|
||||
VCMI_LIB_NAMESPACE_BEGIN
|
||||
|
||||
@@ -34,7 +34,10 @@ 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
|
||||
|
||||
IGameInfoCallback * getCallback() const final { return cb; }
|
||||
IGameInfoCallback * getCallback() const final
|
||||
{
|
||||
return cb;
|
||||
}
|
||||
|
||||
TExpType totalExperience; //commander needs same amount of exp as hero
|
||||
public:
|
||||
@@ -54,7 +57,8 @@ public:
|
||||
TExpType getAverageExperience() 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<CStackBasicDescriptor &>(*this);
|
||||
|
||||
@@ -93,8 +93,6 @@ struct DLL_LINKAGE TerrainTile
|
||||
for(const auto & ptr : objectPtrs)
|
||||
blockingObjects.push_back(ptr->id);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user