Fixed warning when building stub_mm plugin.
4 // dllapi.cpp - implementation of Half-Life DLL routines
9 * This file is part of Metamod.
11 * Metamod is free software; you can redistribute it and/or modify it
12 * under the terms of the GNU General Public License as published by the
13 * Free Software Foundation; either version 2 of the License, or (at
14 * your option) any later version.
16 * Metamod is distributed in the hope that it will be useful, but
17 * WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with Metamod; if not, write to the Free Software Foundation,
23 * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 * In addition, as a special exception, the author gives permission to
26 * link the code of this program with the Half-Life Game Engine ("HL
27 * Engine") and Modified Game Libraries ("MODs") developed by Valve,
28 * L.L.C ("Valve"). You must obey the GNU General Public License in all
29 * respects for all of the code used other than the HL Engine and MODs
30 * from Valve. If you modify this file, you may extend this exception
31 * to your version of the file, but you are not obligated to do so. If
32 * you do not wish to do so, delete this exception statement from your
37 #include <extdll.h> // always
39 #include "dllapi.h" // me
40 #include "metamod.h" // SETUP_API_CALLS, etc
41 #include "api_info.h" // dllapi_info, etc
42 #include "commands_meta.h" // client_meta, etc
43 #include "log_meta.h" // META_ERROR, etc
46 // Original DLL routines, functions returning "void".
47 #define META_DLLAPI_HANDLE_void(FN_TYPE, pfnName, pfn_args) \
48 SETUP_API_CALLS_void(FN_TYPE, pfnName, dllapi_info); \
49 CALL_PLUGIN_API_void(P_PRE, pfnName, pfn_args, dllapi_table); \
50 CALL_GAME_API_void(pfnName, pfn_args, dllapi_table); \
51 CALL_PLUGIN_API_void(P_POST, pfnName, pfn_args, dllapi_post_table);
53 // Original DLL routines, functions returning an actual value.
54 #define META_DLLAPI_HANDLE(ret_t, ret_init, FN_TYPE, pfnName, pfn_args) \
55 SETUP_API_CALLS(ret_t, ret_init, FN_TYPE, pfnName, dllapi_info); \
56 CALL_PLUGIN_API(P_PRE, ret_init, pfnName, pfn_args, MRES_SUPERCEDE, dllapi_table); \
57 CALL_GAME_API(pfnName, pfn_args, dllapi_table); \
58 CALL_PLUGIN_API(P_POST, ret_init, pfnName, pfn_args, MRES_OVERRIDE, dllapi_post_table);
61 // The "new" api routines (just 3 right now), functions returning "void".
62 #define META_NEWAPI_HANDLE_void(FN_TYPE, pfnName, pfn_args) \
63 SETUP_API_CALLS_void(FN_TYPE, pfnName, newapi_info); \
64 CALL_PLUGIN_API_void(P_PRE, pfnName, pfn_args, newapi_table); \
65 CALL_GAME_API_void(pfnName, pfn_args, newapi_table); \
66 CALL_PLUGIN_API_void(P_POST, pfnName, pfn_args, newapi_post_table);
68 // The "new" api routines (just 3 right now), functions returning an actual value.
69 #define META_NEWAPI_HANDLE(ret_t, ret_init, FN_TYPE, pfnName, pfn_args) \
70 SETUP_API_CALLS(ret_t, ret_init, FN_TYPE, pfnName, newapi_info); \
71 CALL_PLUGIN_API(P_PRE, ret_init, pfnName, pfn_args, MRES_SUPERCEDE, newapi_table); \
72 CALL_GAME_API(pfnName, pfn_args, newapi_table); \
73 CALL_PLUGIN_API(P_POST, ret_init, pfnName, pfn_args, MRES_OVERRIDE, newapi_post_table);
76 // From SDK dlls/game.cpp:
77 void mm_GameDLLInit(void) {
78 META_DLLAPI_HANDLE_void(FN_GAMEINIT, pfnGameInit, ());
82 // From SDK dlls/cbase.cpp:
83 int mm_DispatchSpawn(edict_t *pent) {
84 // 0==Success, -1==Failure ?
85 META_DLLAPI_HANDLE(int, 0, FN_DISPATCHSPAWN, pfnSpawn, (pent));
88 void mm_DispatchThink(edict_t *pent) {
89 META_DLLAPI_HANDLE_void(FN_DISPATCHTHINK, pfnThink, (pent));
92 void mm_DispatchUse(edict_t *pentUsed, edict_t *pentOther) {
93 META_DLLAPI_HANDLE_void(FN_DISPATCHUSE, pfnUse, (pentUsed, pentOther));
96 void mm_DispatchTouch(edict_t *pentTouched, edict_t *pentOther) {
97 META_DLLAPI_HANDLE_void(FN_DISPATCHTOUCH, pfnTouch, (pentTouched, pentOther));
100 void mm_DispatchBlocked(edict_t *pentBlocked, edict_t *pentOther) {
101 META_DLLAPI_HANDLE_void(FN_DISPATCHBLOCKED, pfnBlocked, (pentBlocked, pentOther));
104 void mm_DispatchKeyValue(edict_t *pentKeyvalue, KeyValueData *pkvd) {
105 META_DLLAPI_HANDLE_void(FN_DISPATCHKEYVALUE, pfnKeyValue, (pentKeyvalue, pkvd));
108 void mm_DispatchSave(edict_t *pent, SAVERESTOREDATA *pSaveData) {
109 META_DLLAPI_HANDLE_void(FN_DISPATCHSAVE, pfnSave, (pent, pSaveData));
112 int mm_DispatchRestore(edict_t *pent, SAVERESTOREDATA *pSaveData, int globalEntity) {
113 // 0==Success, -1==Failure ?
114 META_DLLAPI_HANDLE(int, 0, FN_DISPATCHRESTORE, pfnRestore, (pent, pSaveData, globalEntity));
117 void mm_DispatchObjectCollsionBox(edict_t *pent) {
118 META_DLLAPI_HANDLE_void(FN_DISPATCHOBJECTCOLLISIONBOX, pfnSetAbsBox, (pent));
121 void mm_SaveWriteFields(SAVERESTOREDATA *pSaveData, const char *pname, void *pBaseData, TYPEDESCRIPTION *pFields, int fieldCount) {
122 META_DLLAPI_HANDLE_void(FN_SAVEWRITEFIELDS, pfnSaveWriteFields, (pSaveData, pname, pBaseData, pFields, fieldCount));
125 void mm_SaveReadFields(SAVERESTOREDATA *pSaveData, const char *pname, void *pBaseData, TYPEDESCRIPTION *pFields, int fieldCount) {
126 META_DLLAPI_HANDLE_void(FN_SAVEREADFIELDS, pfnSaveReadFields, (pSaveData, pname, pBaseData, pFields, fieldCount));
130 // From SDK dlls/world.cpp:
131 void mm_SaveGlobalState(SAVERESTOREDATA *pSaveData) {
132 META_DLLAPI_HANDLE_void(FN_SAVEGLOBALSTATE, pfnSaveGlobalState, (pSaveData));
135 void mm_RestoreGlobalState(SAVERESTOREDATA *pSaveData) {
136 META_DLLAPI_HANDLE_void(FN_RESTOREGLOBALSTATE, pfnRestoreGlobalState, (pSaveData));
139 void mm_ResetGlobalState(void) {
140 META_DLLAPI_HANDLE_void(FN_RESETGLOBALSTATE, pfnResetGlobalState, ());
144 // From SDK dlls/client.cpp:
145 BOOL mm_ClientConnect(edict_t *pEntity, const char *pszName, const char *pszAddress, char szRejectReason[ 128 ] ) {
146 g_Players.clear_player_cvar_query(pEntity);
147 META_DLLAPI_HANDLE(BOOL, TRUE, FN_CLIENTCONNECT, pfnClientConnect, (pEntity, pszName, pszAddress, szRejectReason));
150 void mm_ClientDisconnect(edict_t *pEntity) {
151 g_Players.clear_player_cvar_query(pEntity);
152 META_DLLAPI_HANDLE_void(FN_CLIENTDISCONNECT, pfnClientDisconnect, (pEntity));
155 void mm_ClientKill(edict_t *pEntity) {
156 META_DLLAPI_HANDLE_void(FN_CLIENTKILL, pfnClientKill, (pEntity));
159 void mm_ClientPutInServer(edict_t *pEntity) {
160 META_DLLAPI_HANDLE_void(FN_CLIENTPUTINSERVER, pfnClientPutInServer, (pEntity));
163 void mm_ClientCommand(edict_t *pEntity) {
164 if(strmatch(CMD_ARGV(0), "meta")) {
165 client_meta(pEntity);
167 META_DLLAPI_HANDLE_void(FN_CLIENTCOMMAND, pfnClientCommand, (pEntity));
170 void mm_ClientUserInfoChanged(edict_t *pEntity, char *infobuffer) {
171 META_DLLAPI_HANDLE_void(FN_CLIENTUSERINFOCHANGED, pfnClientUserInfoChanged, (pEntity, infobuffer));
174 void mm_ServerActivate(edict_t *pEdictList, int edictCount, int clientMax) {
175 META_DLLAPI_HANDLE_void(FN_SERVERACTIVATE, pfnServerActivate, (pEdictList, edictCount, clientMax));
178 void mm_ServerDeactivate(void) {
179 META_DLLAPI_HANDLE_void(FN_SERVERDEACTIVATE, pfnServerDeactivate, ());
180 // Update loaded plugins. Look for new plugins in inifile, as well as
181 // any plugins waiting for a changelevel to load.
183 // This is done in ServerDeactivate rather than Activate, as the latter
184 // isn't actually the first routine to be called on a new map. In
185 // particular DispatchKeyValue and DispatchSpawn are called before
186 // Activate, and we want any newly loaded plugins to be able to catch
189 // So, we do this from Deactivate, which is the _last_ routine called
190 // from the previous map. It's also called right before shutdown,
191 // which means whenever hlds quits, it'll reload the plugins just
192 // before it exits, which is rather silly, but oh well.
193 Plugins->refresh(PT_CHANGELEVEL);
194 Plugins->unpause_all();
195 // Plugins->retry_all(PT_CHANGELEVEL);
196 g_Players.clear_all_cvar_queries();
197 requestid_counter = 0;
200 void mm_PlayerPreThink(edict_t *pEntity) {
201 META_DLLAPI_HANDLE_void(FN_PLAYERPRETHINK, pfnPlayerPreThink, (pEntity));
204 void mm_PlayerPostThink(edict_t *pEntity) {
205 META_DLLAPI_HANDLE_void(FN_PLAYERPOSTTHINK, pfnPlayerPostThink, (pEntity));
208 void mm_StartFrame(void) {
209 META_DLLAPI_HANDLE_void(FN_STARTFRAME, pfnStartFrame, ());
212 void mm_ParmsNewLevel(void) {
213 META_DLLAPI_HANDLE_void(FN_PARMSNEWLEVEL, pfnParmsNewLevel, ());
216 void mm_ParmsChangeLevel(void) {
217 META_DLLAPI_HANDLE_void(FN_PARMSCHANGELEVEL, pfnParmsChangeLevel, ());
220 const char *mm_GetGameDescription(void) {
221 META_DLLAPI_HANDLE(const char *, NULL, FN_GETGAMEDESCRIPTION, pfnGetGameDescription, ());
224 void mm_PlayerCustomization(edict_t *pEntity, customization_t *pCust) {
225 META_DLLAPI_HANDLE_void(FN_PLAYERCUSTOMIZATION, pfnPlayerCustomization, (pEntity, pCust));
228 void mm_SpectatorConnect(edict_t *pEntity) {
229 META_DLLAPI_HANDLE_void(FN_SPECTATORCONNECT, pfnSpectatorConnect, (pEntity));
232 void mm_SpectatorDisconnect(edict_t *pEntity) {
233 META_DLLAPI_HANDLE_void(FN_SPECTATORDISCONNECT, pfnSpectatorDisconnect, (pEntity));
236 void mm_SpectatorThink(edict_t *pEntity) {
237 META_DLLAPI_HANDLE_void(FN_SPECTATORTHINK, pfnSpectatorThink, (pEntity));
240 void mm_Sys_Error(const char *error_string) {
241 META_DLLAPI_HANDLE_void(FN_SYS_ERROR, pfnSys_Error, (error_string));
245 // From SDK pm_shared/pm_shared.c:
246 void mm_PM_Move (struct playermove_s *ppmove, int server) {
247 META_DLLAPI_HANDLE_void(FN_PM_MOVE, pfnPM_Move, (ppmove, server));
250 void mm_PM_Init(struct playermove_s *ppmove) {
251 META_DLLAPI_HANDLE_void(FN_PM_INIT, pfnPM_Init, (ppmove));
254 char mm_PM_FindTextureType(const char *name) {
255 META_DLLAPI_HANDLE(char, '\0', FN_PM_FINDTEXTURETYPE, pfnPM_FindTextureType, (name));
259 // From SDK dlls/client.cpp:
260 void mm_SetupVisibility(edict_t *pViewEntity, edict_t *pClient, unsigned char **pvs, unsigned char **pas) {
261 META_DLLAPI_HANDLE_void(FN_SETUPVISIBILITY, pfnSetupVisibility, (pViewEntity, pClient, pvs, pas));
264 void mm_UpdateClientData (const struct edict_s *ent, int sendweapons, struct clientdata_s *cd) {
265 META_DLLAPI_HANDLE_void(FN_UPDATECLIENTDATA, pfnUpdateClientData, (ent, sendweapons, cd));
268 int mm_AddToFullPack(struct entity_state_s *state, int e, edict_t *ent, edict_t *host, int hostflags, int player, unsigned char *pSet) {
269 META_DLLAPI_HANDLE(int, 0, FN_ADDTOFULLPACK, pfnAddToFullPack, (state, e, ent, host, hostflags, player, pSet));
272 void mm_CreateBaseline(int player, int eindex, struct entity_state_s *baseline, struct edict_s *entity, int playermodelindex, vec3_t player_mins, vec3_t player_maxs) {
273 META_DLLAPI_HANDLE_void(FN_CREATEBASELINE, pfnCreateBaseline, (player, eindex, baseline, entity, playermodelindex, player_mins, player_maxs));
276 void mm_RegisterEncoders(void) {
277 META_DLLAPI_HANDLE_void(FN_REGISTERENCODERS, pfnRegisterEncoders, ());
280 int mm_GetWeaponData(struct edict_s *player, struct weapon_data_s *info) {
281 META_DLLAPI_HANDLE(int, 0, FN_GETWEAPONDATA, pfnGetWeaponData, (player, info));
284 void mm_CmdStart(const edict_t *player, const struct usercmd_s *cmd, unsigned int random_seed) {
285 META_DLLAPI_HANDLE_void(FN_CMDSTART, pfnCmdStart, (player, cmd, random_seed));
288 void mm_CmdEnd (const edict_t *player) {
289 META_DLLAPI_HANDLE_void(FN_CMDEND, pfnCmdEnd, (player));
292 int mm_ConnectionlessPacket(const struct netadr_s *net_from, const char *args, char *response_buffer, int *response_buffer_size) {
293 META_DLLAPI_HANDLE(int, 0, FN_CONNECTIONLESSPACKET, pfnConnectionlessPacket, (net_from, args, response_buffer, response_buffer_size));
296 int mm_GetHullBounds(int hullnumber, float *mins, float *maxs) {
297 META_DLLAPI_HANDLE(int, 0, FN_GETHULLBOUNDS, pfnGetHullBounds, (hullnumber, mins, maxs));
300 void mm_CreateInstancedBaselines (void) {
301 META_DLLAPI_HANDLE_void(FN_CREATEINSTANCEDBASELINES, pfnCreateInstancedBaselines, ());
304 int mm_InconsistentFile(const edict_t *player, const char *filename, char *disconnect_message) {
305 META_DLLAPI_HANDLE(int, 0, FN_INCONSISTENTFILE, pfnInconsistentFile, (player, filename, disconnect_message));
308 int mm_AllowLagCompensation(void) {
309 META_DLLAPI_HANDLE(int, 0, FN_ALLOWLAGCOMPENSATION, pfnAllowLagCompensation, ());
316 void mm_OnFreeEntPrivateData(edict_t *pEnt) {
317 META_NEWAPI_HANDLE_void(FN_ONFREEENTPRIVATEDATA, pfnOnFreeEntPrivateData, (pEnt));
320 void mm_GameShutdown(void) {
321 META_NEWAPI_HANDLE_void(FN_GAMESHUTDOWN, pfnGameShutdown, ());
324 int mm_ShouldCollide(edict_t *pentTouched, edict_t *pentOther) {
325 META_NEWAPI_HANDLE(int, 1, FN_SHOULDCOLLIDE, pfnShouldCollide, (pentTouched, pentOther));
328 // Added 2005-08-11 (no SDK update)
329 void mm_CvarValue(const edict_t *pEdict, const char *value) {
330 g_Players.clear_player_cvar_query(pEdict);
331 META_NEWAPI_HANDLE_void(FN_CVARVALUE, pfnCvarValue, (pEdict, value));
335 //Added 2005-11-22 (no SDK update)
336 void mm_CvarValue2(const edict_t *pEdict, int requestID, const char *cvarName, const char *value) {
337 META_NEWAPI_HANDLE_void(FN_CVARVALUE2, pfnCvarValue2, (pEdict, requestID, cvarName, value));
341 // From SDK dlls/cbase.cpp:
342 // "(wd)" indicates my comments on the functions
343 static DLL_FUNCTIONS sFunctionTable =
345 mm_GameDLLInit, //! pfnGameInit() Initialize the game (one-time call after loading of game .dll)
346 mm_DispatchSpawn, //! pfnSpawn()
347 mm_DispatchThink, //! pfnThink()
348 mm_DispatchUse, //! pfnUse()
349 mm_DispatchTouch, //! pfnTouch()
350 mm_DispatchBlocked, //! pfnBlocked()
351 mm_DispatchKeyValue, //! pfnKeyValue()
352 mm_DispatchSave, //! pfnSave()
353 mm_DispatchRestore, //! pfnRestore()
354 mm_DispatchObjectCollsionBox, //! pfnSetAbsBox()
356 mm_SaveWriteFields, //! pfnSaveWriteFields()
357 mm_SaveReadFields, //! pfnSaveReadFields()
359 mm_SaveGlobalState, //! pfnSaveGlobalState()
360 mm_RestoreGlobalState, //! pfnRestoreGlobalState()
361 mm_ResetGlobalState, //! pfnResetGlobalState()
363 mm_ClientConnect, //! pfnClientConnect() (wd) Client has connected
364 mm_ClientDisconnect, //! pfnClientDisconnect() (wd) Player has left the game
365 mm_ClientKill, //! pfnClientKill() (wd) Player has typed "kill"
366 mm_ClientPutInServer, //! pfnClientPutInServer() (wd) Client is entering the game
367 mm_ClientCommand, //! pfnClientCommand() (wd) Player has sent a command (typed, or from a bind)
368 mm_ClientUserInfoChanged, //! pfnClientUserInfoChanged() (wd) Client has updated their setinfo structure
369 mm_ServerActivate, //! pfnServerActivate() (wd) Server is starting a new map
370 mm_ServerDeactivate, //! pfnServerDeactivate() (wd) Server is leaving the map (shutdown, or changelevel); SDK2
372 mm_PlayerPreThink, //! pfnPlayerPreThink()
373 mm_PlayerPostThink, //! pfnPlayerPostThink()
375 mm_StartFrame, //! pfnStartFrame()
376 mm_ParmsNewLevel, //! pfnParmsNewLevel()
377 mm_ParmsChangeLevel, //! pfnParmsChangeLevel()
379 mm_GetGameDescription, //! pfnGetGameDescription() Returns string describing current .dll. E.g. "TeamFotrress 2", "Half-Life"
380 mm_PlayerCustomization, //! pfnPlayerCustomization() Notifies .dll of new customization for player.
382 mm_SpectatorConnect, //! pfnSpectatorConnect() Called when spectator joins server
383 mm_SpectatorDisconnect, //! pfnSpectatorDisconnect() Called when spectator leaves the server
384 mm_SpectatorThink, //! pfnSpectatorThink() Called when spectator sends a command packet (usercmd_t)
386 mm_Sys_Error, //! pfnSys_Error() Notify game .dll that engine is going to shut down. Allows mod authors to set a breakpoint. SDK2
388 mm_PM_Move, //! pfnPM_Move() (wd) SDK2
389 mm_PM_Init, //! pfnPM_Init() Server version of player movement initialization; (wd) SDK2
390 mm_PM_FindTextureType, //! pfnPM_FindTextureType() (wd) SDK2
392 mm_SetupVisibility, //! pfnSetupVisibility() Set up PVS and PAS for networking for this client; (wd) SDK2
393 mm_UpdateClientData, //! pfnUpdateClientData() Set up data sent only to specific client; (wd) SDK2
394 mm_AddToFullPack, //! pfnAddToFullPack() (wd) SDK2
395 mm_CreateBaseline, //! pfnCreateBaseline() Tweak entity baseline for network encoding, allows setup of player baselines, too.; (wd) SDK2
396 mm_RegisterEncoders, //! pfnRegisterEncoders() Callbacks for network encoding; (wd) SDK2
397 mm_GetWeaponData, //! pfnGetWeaponData() (wd) SDK2
398 mm_CmdStart, //! pfnCmdStart() (wd) SDK2
399 mm_CmdEnd, //! pfnCmdEnd() (wd) SDK2
400 mm_ConnectionlessPacket, //! pfnConnectionlessPacket() (wd) SDK2
401 mm_GetHullBounds, //! pfnGetHullBounds() (wd) SDK2
402 mm_CreateInstancedBaselines, //! pfnCreateInstancedBaselines() (wd) SDK2
403 mm_InconsistentFile, //! pfnInconsistentFile() (wd) SDK2
404 mm_AllowLagCompensation, //! pfnAllowLagCompensation() (wd) SDK2
407 DLL_FUNCTIONS *pHookedDllFunctions = &sFunctionTable;
409 // It's not clear what the difference is between GetAPI and GetAPI2; they
410 // both appear to return the exact same function table.
412 // Only one of them appears to be ever called, though. If the DLL provides
413 // GetAPI2, the engine/hlds will call that, and will not call GetAPI. If
414 // the engine couldn't find GetAPI2 in the DLL, it appears to fall back to
417 // So, GetAPI2 appears to replace GetAPI, and appears to have been added
418 // with SDK 2.0. My best guess is that, with the new SDK, interface
419 // version checking became important, and without the int ptr used in
420 // GetAPI2, the engine can't find out the version of the DLL via GetAPI.
422 // It's unclear whether a DLL coded under SDK2 needs to provide the older
425 C_DLLEXPORT int GetEntityAPI(DLL_FUNCTIONS *pFunctionTable, int interfaceVersion)
427 META_DEBUG(3, ("called: GetEntityAPI; version=%d", interfaceVersion));
428 if(!pFunctionTable) {
429 META_ERROR("GetEntityAPI called with null pFunctionTable");
432 else if(interfaceVersion != INTERFACE_VERSION) {
433 META_ERROR("GetEntityAPI version mismatch; requested=%d ours=%d", interfaceVersion, INTERFACE_VERSION);
438 memcpy(pFunctionTable, &sFunctionTable, sizeof(DLL_FUNCTIONS));
444 C_DLLEXPORT int GetEntityAPI2(DLL_FUNCTIONS *pFunctionTable, int *interfaceVersion)
446 META_DEBUG(3, ("called: GetEntityAPI2; version=%d", *interfaceVersion));
448 if(!pFunctionTable) {
449 META_ERROR("GetEntityAPI2 called with null pFunctionTable");
452 else if(*interfaceVersion != INTERFACE_VERSION) {
453 META_ERROR("GetEntityAPI2 version mismatch; requested=%d ours=%d", *interfaceVersion, INTERFACE_VERSION);
454 //! Tell engine what version we had, so it can figure out who is out of date.
455 *interfaceVersion = INTERFACE_VERSION;
460 memcpy(pFunctionTable, &sFunctionTable, sizeof(DLL_FUNCTIONS));
467 // I could find _no_ documentation or examples for the intended use of
468 // NEW_DLL_FUNCTIONS. I wouldn't have even _known_ about the
469 // GetNewDLLFunctions() function except for the reference in Adminmod.. It
470 // appears to be new with SDK 2.0.
472 // Obviously, it seems to provide additional functions to the engine, but
473 // it's unclear why a new table and interface were added, rather than
474 // appending new functions to the GetAPI table/interface.
476 // Interestingly, it appears to be called by the engine _before_ GetAPI.
478 static meta_new_dll_functions_t sNewFunctionTable (
479 &mm_OnFreeEntPrivateData, //! pfnOnFreeEntPrivateData() Called right before the object's memory is freed. Calls its destructor.
480 &mm_GameShutdown, //! pfnGameShutdown()
481 &mm_ShouldCollide, //! pfnShouldCollide()
482 // Added 2005-08-11 (no SDK update)
483 &mm_CvarValue, //! pfnCvarValue() (fz) Obsolete! Use mm_CvarValue2 instead
484 // Added 2005-11-22 (no SDK update)
485 &mm_CvarValue2 //! pfnCvarValue2() (fz) When pfnQueryClientCvarValue2() completes it will call
486 //! pfnCvarValue2() with the request ID supplied earlier, the name of
487 //! the cvar requested and the value of that cvar.
491 NEW_DLL_FUNCTIONS *pHookedNewDllFunctions = &sNewFunctionTable;
493 C_DLLEXPORT int GetNewDLLFunctions(NEW_DLL_FUNCTIONS *pNewFunctionTable, int *interfaceVersion)
495 META_DEBUG(6, ("called: GetNewDLLFunctions; version=%d", *interfaceVersion));
496 #if 0 // ~dvander - but then you can't use cvar querying on many mods...
497 // Don't provide these functions to engine if gamedll doesn't provide
498 // them. Otherwise, we're in the position of having to provide answers
499 // we can't necessarily provide (for instance, ShouldCollide())...
500 if(!GameDLL.funcs.newapi_table)
504 if(!pNewFunctionTable) {
505 META_ERROR("GetNewDLLFunctions called with null pNewFunctionTable");
508 else if(*interfaceVersion != NEW_DLL_FUNCTIONS_VERSION) {
509 META_ERROR("GetNewDLLFunctions version mismatch; requested=%d ours=%d", *interfaceVersion, NEW_DLL_FUNCTIONS_VERSION);
510 //! Tell engine what version we had, so it can figure out who is out of date.
511 *interfaceVersion = NEW_DLL_FUNCTIONS_VERSION;
515 sNewFunctionTable.copy_to(pNewFunctionTable);