refactor(Core/InstanceScript): refactored load and save methods (#14977)

Co-authored-by: joschiwald <736792+joschiwald@users.noreply.github.com>
This commit is contained in:
Skjalf
2023-02-12 15:53:48 -03:00
committed by GitHub
parent 5cc73e1963
commit 0dbb8c814c
126 changed files with 677 additions and 2004 deletions

View File

@@ -26,7 +26,10 @@ public:
struct instance_magisters_terrace_InstanceMapScript : public InstanceScript
{
instance_magisters_terrace_InstanceMapScript(Map* map) : InstanceScript(map) { }
instance_magisters_terrace_InstanceMapScript(Map* map) : InstanceScript(map)
{
SetHeaders(DataHeader);
}
uint32 Encounter[MAX_ENCOUNTER];
@@ -150,39 +153,17 @@ public:
}
}
std::string GetSaveData() override
// @todo: Use BossStates. This is for code compatibility
void ReadSaveDataMore(std::istringstream& data) override
{
OUT_SAVE_INST_DATA;
std::ostringstream saveStream;
saveStream << Encounter[0] << ' ' << Encounter[1] << ' ' << Encounter[2] << ' ' << Encounter[3];
OUT_SAVE_INST_DATA_COMPLETE;
return saveStream.str();
data >> Encounter[1];
data >> Encounter[2];
data >> Encounter[3];
}
void Load(const char* str) override
void WriteSaveDataMore(std::ostringstream& data) override
{
if (!str)
{
OUT_LOAD_INST_DATA_FAIL;
return;
}
OUT_LOAD_INST_DATA(str);
std::istringstream loadStream(str);
for (uint32 i = 0; i < MAX_ENCOUNTER; ++i)
{
uint32 tmpState;
loadStream >> tmpState;
if (tmpState == IN_PROGRESS || tmpState > SPECIAL)
tmpState = NOT_STARTED;
SetData(i, tmpState);
}
OUT_LOAD_INST_DATA_COMPLETE;
data << Encounter[0] << ' ' << Encounter[1] << ' ' << Encounter[2] << ' ' << Encounter[3];
}
ObjectGuid GetGuidData(uint32 identifier) const override

View File

@@ -23,6 +23,7 @@
#include "Player.h"
#include "SpellScript.h"
#define DataHeader "MT"
#define MTScriptName "instance_magisters_terrace"
enum MTData