mirror of
https://github.com/vcmi/vcmi.git
synced 2025-11-27 22:49:25 +02:00
Remove CStack::type pointer to VLC entity
This commit is contained in:
@@ -28,7 +28,7 @@ CStack::CStack(const CStackInstance * Base, const PlayerColor & O, int I, Battle
|
|||||||
CBonusSystemNode(STACK_BATTLE),
|
CBonusSystemNode(STACK_BATTLE),
|
||||||
base(Base),
|
base(Base),
|
||||||
ID(I),
|
ID(I),
|
||||||
type(Base->getCreature()),
|
typeID(Base->getId()),
|
||||||
baseAmount(Base->count),
|
baseAmount(Base->count),
|
||||||
owner(O),
|
owner(O),
|
||||||
slot(S),
|
slot(S),
|
||||||
@@ -48,7 +48,7 @@ CStack::CStack():
|
|||||||
CStack::CStack(const CStackBasicDescriptor * stack, const PlayerColor & O, int I, BattleSide Side, const SlotID & S):
|
CStack::CStack(const CStackBasicDescriptor * stack, const PlayerColor & O, int I, BattleSide Side, const SlotID & S):
|
||||||
CBonusSystemNode(STACK_BATTLE),
|
CBonusSystemNode(STACK_BATTLE),
|
||||||
ID(I),
|
ID(I),
|
||||||
type(stack->getCreature()),
|
typeID(stack->getId()),
|
||||||
baseAmount(stack->count),
|
baseAmount(stack->count),
|
||||||
owner(O),
|
owner(O),
|
||||||
slot(S),
|
slot(S),
|
||||||
@@ -60,7 +60,7 @@ CStack::CStack(const CStackBasicDescriptor * stack, const PlayerColor & O, int I
|
|||||||
void CStack::localInit(BattleInfo * battleInfo)
|
void CStack::localInit(BattleInfo * battleInfo)
|
||||||
{
|
{
|
||||||
battle = battleInfo;
|
battle = battleInfo;
|
||||||
assert(type);
|
assert(typeID.hasValue());
|
||||||
|
|
||||||
exportBonuses();
|
exportBonuses();
|
||||||
if(base) //stack originating from "real" stack in garrison -> attach to it
|
if(base) //stack originating from "real" stack in garrison -> attach to it
|
||||||
@@ -72,7 +72,7 @@ void CStack::localInit(BattleInfo * battleInfo)
|
|||||||
CArmedInstance * army = battle->battleGetArmyObject(side);
|
CArmedInstance * army = battle->battleGetArmyObject(side);
|
||||||
assert(army);
|
assert(army);
|
||||||
attachTo(*army);
|
attachTo(*army);
|
||||||
attachToSource(*type);
|
attachToSource(*typeID.toCreature());
|
||||||
}
|
}
|
||||||
nativeTerrain = getNativeTerrain(); //save nativeTerrain in the variable on the battle start to avoid dead lock
|
nativeTerrain = getNativeTerrain(); //save nativeTerrain in the variable on the battle start to avoid dead lock
|
||||||
CUnitState::localInit(this); //it causes execution of the CStack::isOnNativeTerrain where nativeTerrain will be considered
|
CUnitState::localInit(this); //it causes execution of the CStack::isOnNativeTerrain where nativeTerrain will be considered
|
||||||
@@ -164,8 +164,8 @@ std::string CStack::nodeName() const
|
|||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
oss << owner.toString();
|
oss << owner.toString();
|
||||||
oss << " battle stack [" << ID << "]: " << getCount() << " of ";
|
oss << " battle stack [" << ID << "]: " << getCount() << " of ";
|
||||||
if(type)
|
if(typeID.hasValue())
|
||||||
oss << type->getNamePluralTextID();
|
oss << typeID.toEntity(VLC)->getNamePluralTextID();
|
||||||
else
|
else
|
||||||
oss << "[UNDEFINED TYPE]";
|
oss << "[UNDEFINED TYPE]";
|
||||||
|
|
||||||
@@ -304,7 +304,7 @@ bool CStack::isMeleeAttackPossible(const battle::Unit * attacker, const battle::
|
|||||||
|
|
||||||
std::string CStack::getName() const
|
std::string CStack::getName() const
|
||||||
{
|
{
|
||||||
return (getCount() == 1) ? type->getNameSingularTranslated() : type->getNamePluralTranslated(); //War machines can't use base
|
return (getCount() == 1) ? typeID.toEntity(VLC)->getNameSingularTranslated() : typeID.toEntity(VLC)->getNamePluralTranslated(); //War machines can't use base
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CStack::canBeHealed() const
|
bool CStack::canBeHealed() const
|
||||||
@@ -326,7 +326,7 @@ bool CStack::isOnTerrain(TerrainId terrain) const
|
|||||||
|
|
||||||
const CCreature * CStack::unitType() const
|
const CCreature * CStack::unitType() const
|
||||||
{
|
{
|
||||||
return type;
|
return typeID.toCreature();
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t CStack::unitBaseAmount() const
|
int32_t CStack::unitBaseAmount() const
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ class DLL_LINKAGE CStack : public CBonusSystemNode, public battle::CUnitState, p
|
|||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
ui32 ID = -1; //unique ID of stack
|
ui32 ID = -1; //unique ID of stack
|
||||||
const CCreature * type = nullptr;
|
CreatureID typeID;
|
||||||
TerrainId nativeTerrain; //tmp variable to save native terrain value on battle init
|
TerrainId nativeTerrain; //tmp variable to save native terrain value on battle init
|
||||||
ui32 baseAmount = -1;
|
ui32 baseAmount = -1;
|
||||||
|
|
||||||
@@ -98,7 +98,7 @@ public:
|
|||||||
//stackState is not serialized here
|
//stackState is not serialized here
|
||||||
assert(isIndependentNode());
|
assert(isIndependentNode());
|
||||||
h & static_cast<CBonusSystemNode&>(*this);
|
h & static_cast<CBonusSystemNode&>(*this);
|
||||||
h & type;
|
h & typeID;
|
||||||
h & ID;
|
h & ID;
|
||||||
h & baseAmount;
|
h & baseAmount;
|
||||||
h & owner;
|
h & owner;
|
||||||
@@ -133,7 +133,7 @@ public:
|
|||||||
else if(!army || extSlot == SlotID() || !army->hasStackAtSlot(extSlot))
|
else if(!army || extSlot == SlotID() || !army->hasStackAtSlot(extSlot))
|
||||||
{
|
{
|
||||||
base = nullptr;
|
base = nullptr;
|
||||||
logGlobal->warn("%s doesn't have a base stack!", type->getNameSingularTranslated());
|
logGlobal->warn("%s doesn't have a base stack!", typeID.toEntity(VLC)->getNameSingularTranslated());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user