mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-22 13:16:23 +00:00
refactor(Core/InstanceScript): refactored load and save methods (#14977)
Co-authored-by: joschiwald <736792+joschiwald@users.noreply.github.com>
This commit is contained in:
@@ -36,6 +36,7 @@ public:
|
||||
{
|
||||
instance_mechanar_InstanceMapScript(Map* map) : InstanceScript(map)
|
||||
{
|
||||
SetHeaders(DataHeader);
|
||||
SetBossNumber(MAX_ENCOUNTER);
|
||||
LoadDoorData(doorData);
|
||||
|
||||
@@ -192,60 +193,19 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
bool SetBossState(uint32 type, EncounterState state) override
|
||||
void ReadSaveDataMore(std::istringstream& data) override
|
||||
{
|
||||
if (!InstanceScript::SetBossState(type, state))
|
||||
return false;
|
||||
data >> _passageEncounter;
|
||||
|
||||
return true;
|
||||
if (_passageEncounter == ENCOUNTER_PASSAGE_DONE)
|
||||
{
|
||||
_passageEncounter = ENCOUNTER_PASSAGE_PHASE6;
|
||||
}
|
||||
}
|
||||
|
||||
std::string GetSaveData() override
|
||||
void WriteSaveDataMore(std::ostringstream& data) override
|
||||
{
|
||||
OUT_SAVE_INST_DATA;
|
||||
|
||||
std::ostringstream saveStream;
|
||||
// Xinef: no space needed
|
||||
saveStream << "M E " << GetBossSaveData() << _passageEncounter;
|
||||
|
||||
OUT_SAVE_INST_DATA_COMPLETE;
|
||||
return saveStream.str();
|
||||
}
|
||||
|
||||
void Load(const char* str) override
|
||||
{
|
||||
if (!str)
|
||||
{
|
||||
OUT_LOAD_INST_DATA_FAIL;
|
||||
return;
|
||||
}
|
||||
|
||||
OUT_LOAD_INST_DATA(str);
|
||||
|
||||
char dataHead1, dataHead2;
|
||||
|
||||
std::istringstream loadStream(str);
|
||||
loadStream >> dataHead1 >> dataHead2;
|
||||
|
||||
if (dataHead1 == 'M' && dataHead2 == 'E')
|
||||
{
|
||||
for (uint32 i = 0; i < MAX_ENCOUNTER; ++i)
|
||||
{
|
||||
uint32 tmpState;
|
||||
loadStream >> tmpState;
|
||||
if (tmpState == IN_PROGRESS || tmpState > SPECIAL)
|
||||
tmpState = NOT_STARTED;
|
||||
SetBossState(i, EncounterState(tmpState));
|
||||
}
|
||||
|
||||
loadStream >> _passageEncounter;
|
||||
if (_passageEncounter == ENCOUNTER_PASSAGE_DONE)
|
||||
_passageEncounter = ENCOUNTER_PASSAGE_PHASE6;
|
||||
}
|
||||
else
|
||||
OUT_LOAD_INST_DATA_FAIL;
|
||||
|
||||
OUT_LOAD_INST_DATA_COMPLETE;
|
||||
data << _passageEncounter;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
@@ -24,6 +24,8 @@
|
||||
#include "SpellAuraEffects.h"
|
||||
#include "SpellScript.h"
|
||||
|
||||
#define DataHeader "MR"
|
||||
|
||||
#define MechanarScriptName "instance_mechanar"
|
||||
|
||||
enum DataTypes
|
||||
|
||||
Reference in New Issue
Block a user