Rewrote user message caching code to always use IServerGameDLL::GetUserMessageInfo (
bug 4117, r=dvander).
Games where the above function can crash are handled by detouring tier0's Error() function and jumping back to our own code. So in theory this should work on all games now.
2 * vim: set ts=4 sw=4 tw=99 noet :
3 * ======================================================
5 * Copyright (C) 2004-2009 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.
28 #include "metamod_plugins.h"
29 #include "metamod_util.h"
30 #include <loader_bridge.h>
31 #include "provider/provider_ep2.h"
33 using namespace SourceMM;
35 class GameDllBridge : public IGameDllBridge
38 virtual bool DLLInit_Pre(const gamedll_bridge_info *info, char *buffer, size_t maxlength)
40 if (!mm_DetectGameInformation())
42 UTIL_Format(buffer, maxlength, "Metamod:Source failed to detect game paths; cannot load.");
46 server = (IServerGameDLL *)info->isgd;
47 g_Metamod.SetGameDLLInfo((CreateInterfaceFn)info->gsFactory,
50 g_Metamod.SetVSPListener(info->vsp_listener_path);
51 mm_InitializeGlobals((CreateInterfaceFn)info->engineFactory,
52 (CreateInterfaceFn)info->physicsFactory,
53 (CreateInterfaceFn)info->fsFactory,
54 (CGlobalVars*)info->pGlobals);
55 mm_InitializeForLoad();
56 mm_StartupMetamod(false);
60 virtual void DLLInit_Post(int *isgdUnload)
62 SourceHook::MemFuncInfo mfi;
64 mfi.isVirtual = false;
65 SourceHook::GetFuncInfo(&IServerGameDLL::DLLShutdown, mfi);
66 assert(mfi.isVirtual);
67 assert(mfi.vtbloffs == 0);
68 assert(mfi.thisptroffs == 0);
69 *isgdUnload = mfi.vtblindex;
71 g_PluginMngr.SetAllLoaded();
73 virtual void *QueryInterface(const char *iface, int *ret)
75 return g_Metamod.GetServerFactory(true)(iface, ret);
83 GameDllBridge mm16_gamedll_bridge;
85 SMM_API IGameDllBridge *
88 return &mm16_gamedll_bridge;