Add destructor for restoring globals

This commit is contained in:
8dcc 2023-07-21 07:02:38 +02:00
parent e86f10ec9f
commit 790de69b5c
1 changed files with 11 additions and 0 deletions

View File

@ -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) {