Updated changelog, added license headers.
3 * ======================================================
5 * Copyright (C) 2004-2008 AlliedModders LLC and authors.
7 * ======================================================
9 * This software is provided 'as-is', without any express or implied warranty.
10 * In no event will the authors be held liable for any damages arising from
11 * the use of this software.
13 * Permission is granted to anyone to use this software for any purpose,
14 * including commercial applications, and to alter it and redistribute it
15 * freely, subject to the following restrictions:
17 * 1. The origin of this software must not be misrepresented; you must not
18 * claim that you wrote the original software. If you use this software in a
19 * product, an acknowledgment in the product documentation would be
20 * appreciated but is not required.
21 * 2. Altered source versions must be plainly marked as such, and must not be
22 * misrepresented as being the original software.
23 * 3. This notice may not be removed or altered from any source distribution.
30 #include "metamod_plugins.h"
31 #include "metamod_util.h"
32 #include <loader_bridge.h>
33 #include "provider/provider_ep2.h"
35 using namespace SourceMM;
37 class GameDllBridge : public IGameDllBridge
40 virtual bool DLLInit_Pre(const gamedll_bridge_info *info, char *buffer, size_t maxlength)
42 if (!mm_DetectGameInformation())
44 UTIL_Format(buffer, maxlength, "Metamod:Source failed to detect game paths; cannot load.");
48 server = (IServerGameDLL *)info->isgd;
49 g_Metamod.SetGameDLLInfo((CreateInterfaceFn)info->gsFactory,
52 mm_InitializeGlobals((CreateInterfaceFn)info->engineFactory,
53 (CreateInterfaceFn)info->physicsFactory,
54 (CreateInterfaceFn)info->fsFactory,
55 (CGlobalVars*)info->pGlobals);
56 mm_InitializeForLoad();
57 mm_StartupMetamod(false);
61 virtual void DLLInit_Post(int *isgdUnload)
63 SourceHook::MemFuncInfo mfi;
65 mfi.isVirtual = false;
66 SourceHook::GetFuncInfo(&IServerGameDLL::DLLShutdown, mfi);
67 assert(mfi.isVirtual);
68 assert(mfi.vtbloffs == 0);
69 assert(mfi.thisptroffs == 0);
70 *isgdUnload = mfi.vtblindex;
72 g_PluginMngr.SetAllLoaded();
74 virtual void *QueryInterface(const char *iface, int *ret)
76 return g_Metamod.GetServerFactory(true)(iface, ret);
84 GameDllBridge mm16_gamedll_bridge;
86 SMM_API IGameDllBridge *
89 return &mm16_gamedll_bridge;