Reset delegates on restart

This commit is contained in:
smallmodel 2025-02-02 19:35:01 +01:00
parent 147678b0f0
commit 58e12e0141
No known key found for this signature in database
GPG key ID: 9F2D623CEDF08512
3 changed files with 22 additions and 0 deletions

View file

@ -169,3 +169,17 @@ ScriptDelegate *ScriptDelegate::GetScriptDelegate(const char *name)
return NULL;
}
void ScriptDelegate::Reset()
{
list_script.FreeObjectList();
list_code.FreeObjectList();
list_codeMember.FreeObjectList();
}
void ScriptDelegate::ResetAllDelegates()
{
for (ScriptDelegate* delegate = root; delegate; delegate = delegate->next) {
delegate->Reset();
}
}

View file

@ -156,12 +156,18 @@ public:
*/
void Trigger(const Event& ev) const;
/**
* Reset the delegate, unregister callbacks.
*/
void Reset();
/**
* Search and return the specified script delegate by name.
*
* @param name The name to search for
*/
static ScriptDelegate *GetScriptDelegate(const char *name);
static void ResetAllDelegates();
// non-movable and non-copyable
ScriptDelegate(ScriptDelegate&& other) = delete;

View file

@ -766,6 +766,8 @@ void ScriptMaster::Reset(qboolean samemap)
StringDict.clear();
InitConstStrings();
}
ScriptDelegate::ResetAllDelegates();
}
void ScriptMaster::ExecuteRunning(void)