2016-07-26 03:22:47 +03:00
|
|
|
#include "precompiled.h"
|
2016-07-04 09:07:29 +03:00
|
|
|
|
|
|
|
#ifdef _WIN32
|
2016-07-26 05:08:43 +03:00
|
|
|
// Required DLL entry point
|
2016-07-04 09:07:29 +03:00
|
|
|
// The above SDK comment indicates this routine is required, but the MSDN
|
|
|
|
// documentation indicates it's actually optional. We keep it, though, for
|
|
|
|
// completeness.
|
2016-07-26 05:08:43 +03:00
|
|
|
// Note: 'extern "C"' needed for mingw compile.
|
2016-07-04 09:07:29 +03:00
|
|
|
extern "C" BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
|
|
|
|
{
|
|
|
|
if (fdwReason == DLL_PROCESS_ATTACH) {
|
|
|
|
metamod_handle = hinstDLL;
|
|
|
|
}
|
|
|
|
else if (fdwReason == DLL_PROCESS_DETACH) {
|
|
|
|
/* nothing */
|
|
|
|
}
|
2016-07-26 03:22:47 +03:00
|
|
|
|
|
|
|
return TRUE;
|
2016-07-04 09:07:29 +03:00
|
|
|
}
|
2016-07-26 03:22:47 +03:00
|
|
|
#else
|
2016-07-04 09:07:29 +03:00
|
|
|
// Linux routines to correspond to ATTACH and DETACH cases above. These
|
|
|
|
// aren't required by linux, but are included here for completeness, and
|
|
|
|
// just in case we come across a need to do something at dll load or
|
|
|
|
// unload.
|
2016-07-26 03:22:47 +03:00
|
|
|
void _init() {
|
2016-07-04 09:07:29 +03:00
|
|
|
// called before dlopen() returns
|
|
|
|
}
|
2016-07-26 03:22:47 +03:00
|
|
|
|
|
|
|
void _fini() {
|
2016-07-04 09:07:29 +03:00
|
|
|
// called before dlclose() returns
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2016-07-26 05:08:43 +03:00
|
|
|
// Holds engine functionality callbacks
|
2016-07-04 09:07:29 +03:00
|
|
|
HL_enginefuncs_t g_engfuncs;
|
|
|
|
globalvars_t *gpGlobals;
|
|
|
|
engine_t Engine;
|
|
|
|
|
|
|
|
// Receive engine function table from engine.
|
|
|
|
//
|
|
|
|
// This appears to be the _first_ DLL routine called by the engine, so this
|
|
|
|
// is where we hook to load all the other DLLs (game, plugins, etc), which
|
|
|
|
// is actually all done in meta_startup().
|
2016-07-26 03:22:47 +03:00
|
|
|
C_DLLEXPORT void WINAPI GiveFnptrsToDll(enginefuncs_t *pengfuncsFromEngine, globalvars_t *pGlobals)
|
2016-07-04 09:07:29 +03:00
|
|
|
{
|
2016-07-26 05:08:43 +03:00
|
|
|
#ifndef _WIN32
|
2016-07-04 09:07:29 +03:00
|
|
|
metamod_handle = get_module_handle_of_memptr((void*)&g_engfuncs);
|
|
|
|
#endif
|
2016-07-26 03:22:47 +03:00
|
|
|
|
2016-07-04 09:07:29 +03:00
|
|
|
gpGlobals = pGlobals;
|
|
|
|
Engine.funcs = &g_engfuncs;
|
|
|
|
Engine.globals = pGlobals;
|
2016-07-26 03:22:47 +03:00
|
|
|
|
2016-07-04 09:07:29 +03:00
|
|
|
g_engfuncs.initialise_interface(pengfuncsFromEngine);
|
2016-07-26 03:22:47 +03:00
|
|
|
|
2016-07-26 05:08:43 +03:00
|
|
|
// NOTE: Have to call logging function _after_ initialising g_engfuncs, so
|
2016-07-04 09:07:29 +03:00
|
|
|
// that g_engfuncs.pfnAlertMessage() can be resolved properly, heh. :)
|
|
|
|
META_DEV("called: GiveFnptrsToDll");
|
|
|
|
// Load plugins, load game dll.
|
2016-07-26 03:22:47 +03:00
|
|
|
if (!metamod_startup())
|
2016-07-04 10:11:20 +03:00
|
|
|
{
|
2016-07-04 09:07:29 +03:00
|
|
|
metamod_not_loaded = 1;
|
|
|
|
}
|
2016-07-26 03:22:47 +03:00
|
|
|
|
2016-07-04 09:07:29 +03:00
|
|
|
return;
|
|
|
|
}
|