2
0
mirror of https://github.com/rehlds/metamod-r.git synced 2025-01-01 01:25:53 +03:00
metamod-r/metamod/src/h_export.cpp

61 lines
1.7 KiB
C++
Raw Normal View History

2016-07-26 03:22:47 +03:00
#include "precompiled.h"
2016-07-04 09:07:29 +03:00
#ifdef _WIN32
//! 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.
BOOL WINAPI DllMain(HINSTANCE /* hinstDLL */, DWORD fdwReason, LPVOID /* lpvReserved */)
2016-07-04 09:07:29 +03:00
{
2016-07-26 19:31:47 +03:00
if (fdwReason == DLL_PROCESS_ATTACH)
{
/* nothing */
2016-07-04 09:07:29 +03:00
}
2016-07-26 19:31:47 +03:00
else if (fdwReason == DLL_PROCESS_DETACH)
{
2016-07-04 09:07:29 +03:00
/* nothing */
}
2016-07-26 03:22:47 +03:00
return TRUE;
2016-07-04 09:07:29 +03:00
}
#elif defined(linux) || defined(__APPLE__)
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.
// NOTE: These aren't actually called. Needs investigation.
2016-07-26 19:31:47 +03:00
void _init()
{
// called before dlopen() returns
2016-07-04 09:07:29 +03:00
}
2016-07-26 19:31:47 +03:00
void _fini()
{
// called before dlclose() returns
2016-07-04 09:07:29 +03:00
}
#endif
//! Holds engine functionality callbacks
2017-05-09 18:34:55 +03:00
enginefuncs_t g_engfuncs;
globalvars_t* gpGlobals;
engine_t g_engine;
2016-07-04 09:07:29 +03:00
// 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 19:31:47 +03:00
void WINAPI GiveFnptrsToDll(enginefuncs_t *pengfuncsFromEngine, globalvars_t *pGlobals)
2016-07-04 09:07:29 +03:00
{
gpGlobals = pGlobals;
g_engine.funcs = &g_engfuncs;
g_engine.globals = pGlobals;
2016-07-26 03:22:47 +03:00
2017-05-09 18:34:55 +03:00
g_engfuncs = *pengfuncsFromEngine;
flush_ALERT_buffer();
// 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");
2016-07-04 09:07:29 +03:00
// Load plugins, load game dll.
metamod_startup();
}