feat(Core/Instance): Implement helpers to easily save/retrieve persist… (#15113)

This commit is contained in:
Skjalf
2023-02-18 23:11:36 -03:00
committed by GitHub
parent 84dc9e2ac8
commit a9fac92c80
4 changed files with 49 additions and 9 deletions

View File

@@ -38,6 +38,7 @@ public:
{
SetHeaders(DataHeader);
SetBossNumber(MAX_ENCOUNTER);
SetPersistentDataCount(MAX_DATA_INDEXES);
LoadDoorData(doorData);
_passageEncounter = 0;
@@ -149,7 +150,8 @@ public:
DoSummonAction(creature, player);
}
}
_passageEncounter++;
StorePersistentData(DATA_INDEX_PASSAGE_ENCOUNTER, _passageEncounter++);
SaveToDB();
}
}
@@ -186,16 +188,17 @@ public:
if (Creature* creature = instance->GetCreature(_pathaleonGUID))
creature->AI()->DoAction(1);
}
_passageEncounter++;
StorePersistentData(DATA_INDEX_PASSAGE_ENCOUNTER, _passageEncounter++);
SaveToDB();
}
}
}
}
void ReadSaveDataMore(std::istringstream& data) override
void ReadSaveDataMore(std::istringstream& /*data*/) override
{
data >> _passageEncounter;
_passageEncounter = GetPersistentData(DATA_INDEX_PASSAGE_ENCOUNTER);
if (_passageEncounter == ENCOUNTER_PASSAGE_DONE)
{
@@ -203,11 +206,6 @@ public:
}
}
void WriteSaveDataMore(std::ostringstream& data) override
{
data << _passageEncounter;
}
private:
ObjectGuid _pathaleonGUID;
uint32 _passageTimer;

View File

@@ -70,6 +70,12 @@ enum SpellIds
SPELL_TELEPORT_VISUAL = 35517
};
enum DataIndex
{
DATA_INDEX_PASSAGE_ENCOUNTER = 0,
MAX_DATA_INDEXES
};
template <class AI, class T>
inline AI* GetMechanarAI(T* obj)
{