Skip to content

Commit

Permalink
Fix saving of Scarlet Monastery instance data.
Browse files Browse the repository at this point in the history
  • Loading branch information
ratkosrb committed Aug 3, 2024
1 parent ce26239 commit fddadf4
Showing 1 changed file with 44 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ struct instance_scarlet_monastery : ScriptedInstance
}

uint32 m_auiEncounter[INSTANCE_SM_MAX_ENCOUNTER];
std::string m_strInstData;

uint64 m_uiMograineGUID;
uint64 m_uiWhitemaneGUID;
Expand Down Expand Up @@ -265,8 +266,15 @@ struct instance_scarlet_monastery : ScriptedInstance
}

m_auiEncounter[0] = uiData;

if (uiData == STAGE_MOGRAINE_DONE)
{
OUT_SAVE_INST_DATA;
SaveToDB();
OUT_SAVE_INST_DATA_COMPLETE;
}
}
if (uiType == TYPE_ASHBRINGER_EVENT)
else if (uiType == TYPE_ASHBRINGER_EVENT)
{
if (uiData == IN_PROGRESS)
{
Expand All @@ -289,6 +297,13 @@ struct instance_scarlet_monastery : ScriptedInstance
scarletNpc->SetFactionTemplateId(35);
}
m_auiEncounter[1] = uiData;

if (uiData == DONE)
{
OUT_SAVE_INST_DATA;
SaveToDB();
OUT_SAVE_INST_DATA_COMPLETE;
}
}
}

Expand All @@ -301,6 +316,34 @@ struct instance_scarlet_monastery : ScriptedInstance
return 0;
}

void Load(char const* chrIn) override
{
if (!chrIn)
{
OUT_LOAD_INST_DATA_FAIL;
return;
}

OUT_LOAD_INST_DATA(chrIn);

std::istringstream loadStream(chrIn);
loadStream >> m_auiEncounter[0] >> m_auiEncounter[1];

for (uint32& i : m_auiEncounter)
if (i == IN_PROGRESS)
i = NOT_STARTED;

OUT_LOAD_INST_DATA_COMPLETE;
}

char const* Save() override
{
std::ostringstream saveStream;
saveStream << m_auiEncounter[0] << " " << m_auiEncounter[1];
m_strInstData = saveStream.str();
return m_strInstData.c_str();
}

void OnCreatureSpellHit(SpellCaster* pCaster, Creature* receiver, SpellEntry const* spell) override
{
if (m_ashbringerActive || !pCaster || !receiver || !spell)
Expand Down

0 comments on commit fddadf4

Please sign in to comment.