mirror of
https://github.com/vcmi/vcmi.git
synced 2025-11-25 22:42:04 +02:00
Reduce usage of pointers to VLC entities
Final goal (of multiple PR's) is to remove all remaining pointers from serializeable game state, and replace them with either identifiers or with shared/unique pointers. CGTownInstance::town and CGHeroInstance::type members have been removed. Now this data is computed dynamically using subID member. VLC entity of a town can now be accessed via following methods: - getFactionID() returns ID of a faction - getFaction() returns pointer to a faction - getTown() returns pointer to a town VLC entity of a hero can now be accessed via following methods: - getHeroTypeID() returns ID of a hero - getHeroClassID() returns ID of a hero class - getHeroType() returns pointer to a hero - getHeroClass() returns pointer to a hero class
This commit is contained in:
@@ -72,7 +72,6 @@ public:
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
const CHero * type;
|
||||
TExpType exp; //experience points
|
||||
ui32 level; //current level of hero
|
||||
|
||||
@@ -171,7 +170,7 @@ public:
|
||||
const IOwnableObject * asOwnable() const final;
|
||||
|
||||
//INativeTerrainProvider
|
||||
FactionID getFaction() const override;
|
||||
FactionID getFactionID() const override;
|
||||
TerrainId getNativeTerrain() const override;
|
||||
int getLowestCreatureSpeed() const;
|
||||
si32 manaRegain() const; //how many points of mana can hero regain "naturally" in one day
|
||||
@@ -235,7 +234,11 @@ public:
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
HeroTypeID getHeroType() const;
|
||||
const CHeroClass * getHeroClass() const;
|
||||
HeroClassID getHeroClassID() const;
|
||||
|
||||
const CHero * getHeroType() const;
|
||||
HeroTypeID getHeroTypeID() const;
|
||||
void setHeroType(HeroTypeID type);
|
||||
|
||||
void initHero(vstd::RNG & rand);
|
||||
@@ -352,7 +355,11 @@ public:
|
||||
h & skillsInfo;
|
||||
h & visitedTown;
|
||||
h & boat;
|
||||
h & type;
|
||||
if (h.version < Handler::Version::REMOVE_TOWN_PTR)
|
||||
{
|
||||
CHero * type = nullptr;
|
||||
h & type;
|
||||
}
|
||||
h & commander;
|
||||
h & visitedObjects;
|
||||
BONUS_TREE_DESERIALIZATION_FIX
|
||||
|
||||
Reference in New Issue
Block a user