mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-02-14 16:03:45 +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:
@@ -84,6 +84,7 @@ public:
|
||||
|
||||
void Initialize() override
|
||||
{
|
||||
SetHeaders(DataHeader);
|
||||
memset(&m_auiEncounter, 0, sizeof(m_auiEncounter));
|
||||
CLEANED = false;
|
||||
EncounterStatus = NOT_STARTED;
|
||||
@@ -637,57 +638,26 @@ public:
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string GetSaveData() override
|
||||
{
|
||||
OUT_SAVE_INST_DATA;
|
||||
|
||||
std::ostringstream saveStream;
|
||||
saveStream << "V H " << m_auiEncounter[0] << ' ' << m_auiEncounter[1] << ' ' << m_auiEncounter[2] << ' ' << uiFirstBoss << ' ' << uiSecondBoss;
|
||||
str_data = saveStream.str();
|
||||
|
||||
OUT_SAVE_INST_DATA_COMPLETE;
|
||||
return str_data;
|
||||
}
|
||||
|
||||
void Load(const char* in) override
|
||||
void ReadSaveDataMore(std::istringstream& data) override
|
||||
{
|
||||
EncounterStatus = NOT_STARTED;
|
||||
CLEANED = false;
|
||||
events.Reset();
|
||||
events.RescheduleEvent(EVENT_CHECK_PLAYERS, 0);
|
||||
|
||||
if (!in)
|
||||
{
|
||||
OUT_LOAD_INST_DATA_FAIL;
|
||||
return;
|
||||
}
|
||||
data >> m_auiEncounter[0];
|
||||
data >> m_auiEncounter[1];
|
||||
data >> m_auiEncounter[2];
|
||||
data >> uiFirstBoss;
|
||||
}
|
||||
|
||||
OUT_LOAD_INST_DATA(in);
|
||||
|
||||
char dataHead1, dataHead2;
|
||||
uint32 data0, data1, data2, data3, data4;
|
||||
|
||||
std::istringstream loadStream(in);
|
||||
loadStream >> dataHead1 >> dataHead2 >> data0 >> data1 >> data2 >> data3 >> data4;
|
||||
|
||||
if (dataHead1 == 'V' && dataHead2 == 'H')
|
||||
{
|
||||
m_auiEncounter[0] = data0;
|
||||
m_auiEncounter[1] = data1;
|
||||
m_auiEncounter[2] = data2;
|
||||
uiFirstBoss = data3;
|
||||
uiSecondBoss = data4;
|
||||
|
||||
for (uint8 i = 0; i < MAX_ENCOUNTER; ++i)
|
||||
if (m_auiEncounter[i] == IN_PROGRESS)
|
||||
m_auiEncounter[i] = NOT_STARTED;
|
||||
|
||||
if (m_auiEncounter[MAX_ENCOUNTER - 1] == DONE)
|
||||
EncounterStatus = DONE;
|
||||
}
|
||||
else OUT_LOAD_INST_DATA_FAIL;
|
||||
|
||||
OUT_LOAD_INST_DATA_COMPLETE;
|
||||
void WriteSaveDataMore(std::ostringstream& data) override
|
||||
{
|
||||
data << m_auiEncounter[0] << ' '
|
||||
<< m_auiEncounter[1] << ' '
|
||||
<< m_auiEncounter[2] << ' '
|
||||
<< uiFirstBoss << ' '
|
||||
<< uiSecondBoss << ' ';
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
@@ -22,6 +22,8 @@
|
||||
|
||||
#include "CreatureAIImpl.h"
|
||||
|
||||
#define DataHeader "VIO"
|
||||
|
||||
#define VioletHoldScriptName "instance_violet_hold"
|
||||
|
||||
enum Creatures
|
||||
|
||||
Reference in New Issue
Block a user