diff --git a/src/scripts/eastern_kingdoms/tirisfal_glades/scarlet_monastery/instance_scarlet_monastery.cpp b/src/scripts/eastern_kingdoms/tirisfal_glades/scarlet_monastery/instance_scarlet_monastery.cpp index b8e313be72e..02123440c9a 100644 --- a/src/scripts/eastern_kingdoms/tirisfal_glades/scarlet_monastery/instance_scarlet_monastery.cpp +++ b/src/scripts/eastern_kingdoms/tirisfal_glades/scarlet_monastery/instance_scarlet_monastery.cpp @@ -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; @@ -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) { @@ -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; + } } } @@ -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)