Skip to content

Commit 8d40e3b

Browse files
committed
fix(plugins): Exports, Reload Crash
1 parent aaf9a16 commit 8d40e3b

File tree

3 files changed

+15
-14
lines changed

3 files changed

+15
-14
lines changed

plugin_files/bin/scripting/0_events.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ const LoadEventFile = (global) => {
1010
const handlers = eventHandlers[eventName]
1111
for (let i = 0; i < handlers.length; i++) {
1212
if ((typeof handlers[i].handle) == "function") {
13-
const result = (handlers[i].handle.apply(null, eventData) || EventResult.Continue);
13+
let result = (handlers[i].handle.apply(null, eventData));
14+
if (result == null || result == undefined) result = EventResult.Continue;
1415
if (result != EventResult.Continue) return result
1516
}
1617
}
@@ -28,7 +29,8 @@ const LoadEventFile = (global) => {
2829
const handlers = eventHandlers[eventName]
2930
for (let i = 0; i < handlers.length; i++) {
3031
if ((typeof handlers[i].handle) == "function") {
31-
const result = (handlers[i].handle.apply(null, eventData) || EventResult.Continue);
32+
let result = (handlers[i].handle.apply(null, eventData));
33+
if (result == null || result == undefined) result = EventResult.Continue;
3234
if (result != EventResult.Continue) return result
3335
}
3436
}

src/plugins/object.cpp

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,6 @@ PluginObject::PluginObject(std::string m_name, ContextKinds m_kind)
1919

2020
PluginObject::~PluginObject()
2121
{
22-
if (eventFunctionPtr)
23-
{
24-
delete eventFunctionPtr;
25-
}
2622
}
2723

2824
void PluginObject::RegisterEventHandlerJSON(EValue* functionPtr)
@@ -57,9 +53,6 @@ void PluginObject::UnregisterEventHandling(std::string eventName)
5753

5854
EventResult PluginObject::TriggerEvent(std::string invokedBy, std::string eventName, std::vector<std::any> eventPayload, ClassData* eventObject)
5955
{
60-
if (GetPluginState() == PluginState_t::Stopped && eventName != "OnPluginStart" && eventName != "OnAllPluginsLoaded")
61-
return EventResult::Continue;
62-
6356
if (!eventFunctionPtr)
6457
return EventResult::Continue;
6558

@@ -101,9 +94,6 @@ EventResult PluginObject::TriggerEvent(std::string invokedBy, std::string eventN
10194

10295
EventResult PluginObject::TriggerEventJSON(std::string invokedBy, std::string eventName, std::string eventPayload, ClassData* eventObject)
10396
{
104-
if (GetPluginState() == PluginState_t::Stopped && eventName != "OnPluginStart" && eventName != "OnAllPluginsLoaded")
105-
return EventResult::Continue;
106-
10797
if (!eventFunctionPtr)
10898
return EventResult::Continue;
10999

@@ -304,6 +294,17 @@ void PluginObject::DestroyScriptingEnvironment()
304294
g_commandsManager.UnregisterCommand(command);
305295

306296
eventHandlers.clear();
297+
298+
if (eventFunctionPtr) {
299+
delete eventFunctionPtr;
300+
eventFunctionPtr = nullptr;
301+
}
302+
303+
if (eventFunctionPtrJSON) {
304+
delete eventFunctionPtrJSON;
305+
eventFunctionPtrJSON = nullptr;
306+
}
307+
307308
delete ctx;
308309
}
309310

src/scripting/entities/weapons.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,5 @@ LoadScriptingComponent(weapons, [](PluginObject plugin, EContext* ctx) -> void {
390390
}
391391
}
392392
}
393-
394-
SetStateChanged((uintptr_t)vmbodyComponent, "CBaseEntity", "m_CBodyComponent", 0);
395393
});
396394
})

0 commit comments

Comments
 (0)