From 790de69b5c3f1c451479665e468c4c0a40f8695e Mon Sep 17 00:00:00 2001 From: 8dcc <8dcc.git@gmail.com> Date: Fri, 21 Jul 2023 07:02:38 +0200 Subject: [PATCH] Add destructor for restoring globals --- src/main.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/main.c b/src/main.c index 739f2d1..2f9c9e6 100644 --- a/src/main.c +++ b/src/main.c @@ -7,6 +7,8 @@ #include "include/globals.h" #include "include/hooks.h" +static bool loaded = false; + /* * We need: * __attribute__((constructor)) @@ -30,6 +32,15 @@ __attribute__((constructor)) void load(void) { } i_engine->pfnClientCmd("echo \"hl-cheat loaded successfully!\""); + + loaded = true; +} + +__attribute__((destructor)) void unload() { + if (loaded) + globals_restore(); + + printf("hl-cheat unloaded.\n\n"); } void self_unload(void) {