1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/core/gamedll_bridge.cpp Sun Nov 23 23:22:33 2008 -0600
1.3 @@ -0,0 +1,64 @@
1.4 +#include <assert.h>
1.5 +#include "metamod.h"
1.6 +#include "metamod_plugins.h"
1.7 +#include "metamod_util.h"
1.8 +#include <loader_bridge.h>
1.9 +#include "provider/provider_ep2.h"
1.10 +
1.11 +using namespace SourceMM;
1.12 +
1.13 +class GameDllBridge : public IGameDllBridge
1.14 +{
1.15 +public:
1.16 + virtual bool DLLInit_Pre(const gamedll_bridge_info *info, char *buffer, size_t maxlength)
1.17 + {
1.18 + if (!mm_DetectGameInformation())
1.19 + {
1.20 + UTIL_Format(buffer, maxlength, "Metamod:Source failed to detect game paths; cannot load.");
1.21 + return false;
1.22 + }
1.23 +
1.24 + server = (IServerGameDLL *)info->isgd;
1.25 + g_Metamod.SetGameDLLInfo((CreateInterfaceFn)info->gsFactory,
1.26 + info->dllVersion,
1.27 + true);
1.28 + mm_InitializeGlobals((CreateInterfaceFn)info->engineFactory,
1.29 + (CreateInterfaceFn)info->physicsFactory,
1.30 + (CreateInterfaceFn)info->fsFactory,
1.31 + (CGlobalVars*)info->pGlobals);
1.32 + mm_InitializeForLoad();
1.33 + mm_StartupMetamod(false);
1.34 +
1.35 + return true;
1.36 + }
1.37 + virtual void DLLInit_Post(int *isgdUnload)
1.38 + {
1.39 + SourceHook::MemFuncInfo mfi;
1.40 +
1.41 + mfi.isVirtual = false;
1.42 + SourceHook::GetFuncInfo(&IServerGameDLL::DLLShutdown, mfi);
1.43 + assert(mfi.isVirtual);
1.44 + assert(mfi.vtbloffs == 0);
1.45 + assert(mfi.thisptroffs == 0);
1.46 + *isgdUnload = mfi.vtblindex;
1.47 +
1.48 + g_PluginMngr.SetAllLoaded();
1.49 + }
1.50 + virtual void *QueryInterface(const char *iface, int *ret)
1.51 + {
1.52 + return g_Metamod.GetServerFactory(true)(iface, ret);
1.53 + }
1.54 + virtual void Unload()
1.55 + {
1.56 + mm_UnloadMetamod();
1.57 + }
1.58 +};
1.59 +
1.60 +GameDllBridge mm16_gamedll_bridge;
1.61 +
1.62 +SMM_API IGameDllBridge *
1.63 +GetGameDllBridge()
1.64 +{
1.65 + return &mm16_gamedll_bridge;
1.66 +}
1.67 +