-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.cpp
More file actions
70 lines (54 loc) · 1.31 KB
/
main.cpp
File metadata and controls
70 lines (54 loc) · 1.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#include "pch.h"
#include "logging.h"
#include "sourceconsole.h"
#include "cvar.h"
#include "concommand.h"
#include "convar.h"
static bool bInitialised = false;
static void InitialiseSoup()
{
if (bInitialised)
return;
bInitialised = true;
curl_global_init_mem(CURL_GLOBAL_DEFAULT, _malloc_base, _free_base, _realloc_base, _strdup_base, _calloc_base);
InitialiseLogging();
InitialiseConsole();
InstallInitialHooks();
CallAllPendingDLLLoadCallbacks();
}
static void CleanupSoup()
{
if (!bInitialised)
return;
bInitialised = false;
// Unregister all ConCommands and ConVars from CCvar (needs g_pCVar alive),
// then delete our allocated objects.
CleanupConCommands();
CleanupConVars();
CleanupConsole();
CleanupLogging();
CleanupHooks();
curl_global_cleanup();
// Free game-heap allocations made during ON_DLL_LOAD handlers.
delete R2::g_pCVarInterface;
R2::g_pCVarInterface = nullptr;
R2::g_pCVar = nullptr;
}
// Called from DllMain thread when loaded via rpak HAS_MODULE
void Soup_OnAttach()
{
InitialiseSoup();
}
// Called from DllMain on DLL_PROCESS_DETACH (safety net for rpak unload)
void Soup_OnDetach()
{
CleanupSoup();
}
extern "C" __declspec(dllexport) void PLUGIN_INIT(void* funcs, void* data)
{
InitialiseSoup();
}
extern "C" __declspec(dllexport) void PLUGIN_UNLOAD()
{
CleanupSoup();
}