Skip to content

Commit

Permalink
fix init
Browse files Browse the repository at this point in the history
  • Loading branch information
jackhumbert committed Jul 23, 2022
1 parent b83ae34 commit 7c1aae4
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
Binary file modified build/red4ext/plugins/mod_settings/mod_settings.dll
Binary file not shown.
2 changes: 1 addition & 1 deletion src/red4ext/ModSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ void ModSettings::AddVariable(ModSettingsVariable *variable) {
std::shared_lock<RED4ext::SharedMutex> _(self->variables_lock);
variable->listeners = RED4ext::DynArray<RED4ext::IScriptable*>(new RED4ext::Memory::DefaultAllocator());
variable->listeners.Reserve(1000);

variable->UpdateValues();
self->variables.EmplaceBack(variable);

auto modVars = self->variablesByMod.Get(variable->mod);
Expand Down
20 changes: 10 additions & 10 deletions src/red4ext/ModSettingsVariable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@
#include "ModRuntimeSettingsVar.hpp"

void ModSettingsVariable::UpdateValues() {
auto classType = RED4ext::CRTTISystem::Get()->GetClass(className);
auto valuePtr = settingsVar->GetValuePtr();
for (auto i = 0; i < classType->propertiesWithDefaults.size; i++) {
if (classType->propertiesWithDefaults[i] == settingsVar->name) {
uint64_t addr = classType->defaultValues[i]->type;
auto propType = reinterpret_cast<RED4ext::CBaseRTTIType *>(addr & 0xFFFFFFFFFFFFFFF8);
propType->Assign(&classType->defaultValues[i]->value, valuePtr);
}
}
std::shared_lock<RED4ext::SharedMutex> _(listeners_lock);
for (auto &listener : listeners) {
if (listener && !listener->ref.Expired()) {
auto classType = RED4ext::CRTTISystem::Get()->GetClass(className);
auto valuePtr = settingsVar->GetValuePtr();
for (auto i = 0; i < classType->propertiesWithDefaults.size; i++) {
if (classType->propertiesWithDefaults[i] == settingsVar->name) {
uint64_t addr = classType->defaultValues[i]->type;
auto propType = reinterpret_cast<RED4ext::CBaseRTTIType *>(addr & 0xFFFFFFFFFFFFFFF8);
propType->Assign(&classType->defaultValues[i]->value, valuePtr);
}
}
auto prop = classType->propertiesByName.Get(settingsVar->name);
if (prop) {
if (prop && *prop) {
(*prop)->SetValue(listener, valuePtr);
}
}
Expand Down

0 comments on commit 7c1aae4

Please sign in to comment.