Skip to content

Commit 284c2ae

Browse files
committed
xrGame: refactor DLL loading code
1 parent 4a6e56a commit 284c2ae

File tree

1 file changed

+24
-32
lines changed

1 file changed

+24
-32
lines changed

src/xrGame/xrGame.cpp

Lines changed: 24 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -33,39 +33,9 @@ DLL_API void __cdecl xrFactory_Destroy(IFactoryObject* O) { xr_delete(O); }
3333

3434
void CCC_RegisterCommands();
3535

36-
#ifdef WINDOWS
37-
BOOL APIENTRY DllMain(HANDLE hModule, u32 ul_reason_for_call, LPVOID lpReserved)
38-
{
39-
switch (ul_reason_for_call)
40-
{
41-
case DLL_PROCESS_ATTACH:
42-
{
43-
// Fill ui style token
44-
FillUIStyleToken();
45-
// register console commands
46-
CCC_RegisterCommands();
47-
// keyboard binding
48-
CCC_RegisterInput();
49-
#ifdef DEBUG
50-
// XXX nitrocaster PROFILER: temporarily disabled due to linkage issues
51-
// g_profiler = new CProfiler();
52-
#endif
53-
gStringTable = new CStringTable();
54-
StringTable().Init();
55-
break;
56-
}
57-
58-
case DLL_PROCESS_DETACH:
59-
{
60-
CleanupUIStyleToken();
61-
xr_delete(gStringTable);
62-
break;
63-
}
64-
}
65-
return (TRUE);
66-
}
67-
#else
36+
#ifdef LINUX
6837
__attribute__((constructor))
38+
#endif
6939
static void load(int argc, char** argv, char** envp)
7040
{
7141
// Fill ui style token
@@ -82,10 +52,32 @@ static void load(int argc, char** argv, char** envp)
8252
StringTable().Init();
8353
}
8454

55+
#ifdef LINUX
8556
__attribute__((destructor))
57+
#endif
8658
static void unload()
8759
{
8860
CleanupUIStyleToken();
8961
xr_delete(gStringTable);
9062
}
63+
64+
#ifdef WINDOWS
65+
BOOL APIENTRY DllMain(HANDLE hModule, u32 ul_reason_for_call, LPVOID lpReserved)
66+
{
67+
switch (ul_reason_for_call)
68+
{
69+
case DLL_PROCESS_ATTACH:
70+
{
71+
load();
72+
break;
73+
}
74+
75+
case DLL_PROCESS_DETACH:
76+
{
77+
unload()
78+
break;
79+
}
80+
}
81+
return (TRUE);
82+
}
9183
#endif

0 commit comments

Comments
 (0)