Skip to content

Commit

Permalink
add clear for hot reload compat
Browse files Browse the repository at this point in the history
  • Loading branch information
jackhumbert committed Nov 9, 2022
1 parent e4af6c4 commit f6cc446
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 0 deletions.
Binary file modified build/red4ext/plugins/mod_settings/mod_settings.dll
Binary file not shown.
1 change: 1 addition & 0 deletions src/red4ext/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ struct ScriptData {
void __fastcall ProcessModSettings(ScriptData * scriptData) {
if (scriptData) {
ModSettings::ReadFromFile();
ModSettings::ClearVariables();
for (const auto &scriptClass : scriptData->classes) {
for (const auto &prop : scriptClass->properties) {
if (prop->runtimeProperties.size) {
Expand Down
11 changes: 11 additions & 0 deletions src/red4ext/ModSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,17 @@ ModSettings *ModSettings::GetInstance() {
return (ModSettings *)handle.instance;
}

void ModSettings::ClearVariables() {
auto self = ModSettings::GetInstance();

self->variables.Clear();
self->mods.Clear();
self->variablesByMod.Clear();
self->classes.Clear();
self->variablesByClass.Clear();
self->categoriesByMod.Clear();
}

void ModSettings::AddVariable(ModSettingsVariable *variable) {
auto self = ModSettings::GetInstance();

Expand Down
1 change: 1 addition & 0 deletions src/red4ext/ModSettings.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ struct ModSettings : RED4ext::IScriptable {

static ModSettings *GetInstance();
static bool GetSettingString(RED4ext::CName, RED4ext::CName, RED4ext::CString *);
static void ClearVariables();
static void AddVariable(ModSettingsVariable *);
static void WriteToFile();
static void ReadFromFile();
Expand Down

0 comments on commit f6cc446

Please sign in to comment.