File tree Expand file tree Collapse file tree 3 files changed +13
-0
lines changed Expand file tree Collapse file tree 3 files changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -165,6 +165,7 @@ CPlugin::CPlugin (CMUSHclientDoc * pDoc)
165
165
m_bGlobal = false ;
166
166
m_iLoadOrder = 0 ;
167
167
m_iScriptTimeTaken = 0 ;
168
+ m_bSavingStateNow = false ;
168
169
169
170
} // end of constructor
170
171
@@ -784,9 +785,15 @@ bool bError = true;
784
785
CPlugin * oldPlugin = m_pDoc->m_CurrentPlugin ;
785
786
m_pDoc->m_CurrentPlugin = this ;
786
787
788
+ // prevent infinite loops
789
+ m_bSavingStateNow = true ;
790
+
787
791
CScriptCallInfo callinfo (ON_PLUGIN_SAVE_STATE, m_PluginCallbacks [ON_PLUGIN_SAVE_STATE]);
788
792
ExecutePluginScript (callinfo);
789
793
794
+ // are not saving state now
795
+ m_bSavingStateNow = false ;
796
+
790
797
strFilename += m_pDoc->m_strWorldID ; // world ID
791
798
strFilename += " -" ;
792
799
strFilename += m_strID; // plugin ID
Original file line number Diff line number Diff line change @@ -103,6 +103,7 @@ class CPlugin :public CObject
103
103
bool m_bGlobal; // true if plugin was loaded from global prefs
104
104
long m_iLoadOrder; // sequence in which plugins are processed
105
105
LONGLONG m_iScriptTimeTaken; // time taken to execute scripts
106
+ bool m_bSavingStateNow; // to prevent infinite loops
106
107
107
108
// Lua note - for Lua the DISPID is a flag indicating whether or not
108
109
// the routine exists. It is set to DISPID_UNKNOWN if the last call caused an error
Original file line number Diff line number Diff line change @@ -500,6 +500,11 @@ long CMUSHclientDoc::SaveState()
500
500
if (!m_CurrentPlugin)
501
501
return eNotAPlugin;
502
502
503
+ // if we are already saving the state, don't do it again
504
+ if (m_CurrentPlugin->m_bSavingStateNow )
505
+ return ePluginCouldNotSaveState;
506
+
507
+ // save the state
503
508
if (m_CurrentPlugin->SaveState (true ))
504
509
return ePluginCouldNotSaveState;
505
510
You can’t perform that action at this time.
0 commit comments