1.1 --- a/metamod/dllapi.cpp Wed Dec 21 18:40:50 2005 +0000
1.2 +++ b/metamod/dllapi.cpp Mon Apr 17 17:04:06 2006 +0000
1.3 @@ -194,6 +194,7 @@
1.4 Plugins->unpause_all();
1.5 // Plugins->retry_all(PT_CHANGELEVEL);
1.6 g_Players.clear_all_cvar_queries();
1.7 + requestid_counter = 0;
1.8 RETURN_API_void();
1.9 }
1.10 void mm_PlayerPreThink(edict_t *pEntity) {
1.11 @@ -339,23 +340,23 @@
1.12
1.13 // From SDK dlls/cbase.cpp:
1.14 // "(wd)" indicates my comments on the functions
1.15 -static DLL_FUNCTIONS gFunctionTable =
1.16 +static DLL_FUNCTIONS sFunctionTable =
1.17 {
1.18 - mm_GameDLLInit, //! pfnGameInit() Initialize the game (one-time call after loading of game .dll)
1.19 + mm_GameDLLInit, //! pfnGameInit() Initialize the game (one-time call after loading of game .dll)
1.20 mm_DispatchSpawn, //! pfnSpawn()
1.21 mm_DispatchThink, //! pfnThink()
1.22 - mm_DispatchUse, //! pfnUse()
1.23 + mm_DispatchUse, //! pfnUse()
1.24 mm_DispatchTouch, //! pfnTouch()
1.25 - mm_DispatchBlocked, //! pfnBlocked()
1.26 + mm_DispatchBlocked, //! pfnBlocked()
1.27 mm_DispatchKeyValue, //! pfnKeyValue()
1.28 mm_DispatchSave, //! pfnSave()
1.29 - mm_DispatchRestore, //! pfnRestore()
1.30 + mm_DispatchRestore, //! pfnRestore()
1.31 mm_DispatchObjectCollsionBox, //! pfnSetAbsBox()
1.32
1.33 - mm_SaveWriteFields, //! pfnSaveWriteFields()
1.34 + mm_SaveWriteFields, //! pfnSaveWriteFields()
1.35 mm_SaveReadFields, //! pfnSaveReadFields()
1.36
1.37 - mm_SaveGlobalState, //! pfnSaveGlobalState()
1.38 + mm_SaveGlobalState, //! pfnSaveGlobalState()
1.39 mm_RestoreGlobalState, //! pfnRestoreGlobalState()
1.40 mm_ResetGlobalState, //! pfnResetGlobalState()
1.41
1.42 @@ -369,26 +370,26 @@
1.43 mm_ServerDeactivate, //! pfnServerDeactivate() (wd) Server is leaving the map (shutdown, or changelevel); SDK2
1.44
1.45 mm_PlayerPreThink, //! pfnPlayerPreThink()
1.46 - mm_PlayerPostThink, //! pfnPlayerPostThink()
1.47 + mm_PlayerPostThink, //! pfnPlayerPostThink()
1.48
1.49 mm_StartFrame, //! pfnStartFrame()
1.50 mm_ParmsNewLevel, //! pfnParmsNewLevel()
1.51 mm_ParmsChangeLevel, //! pfnParmsChangeLevel()
1.52
1.53 mm_GetGameDescription, //! pfnGetGameDescription() Returns string describing current .dll. E.g. "TeamFotrress 2", "Half-Life"
1.54 - mm_PlayerCustomization, //! pfnPlayerCustomization() Notifies .dll of new customization for player.
1.55 + mm_PlayerCustomization, //! pfnPlayerCustomization() Notifies .dll of new customization for player.
1.56
1.57 mm_SpectatorConnect, //! pfnSpectatorConnect() Called when spectator joins server
1.58 - mm_SpectatorDisconnect, //! pfnSpectatorDisconnect() Called when spectator leaves the server
1.59 + mm_SpectatorDisconnect, //! pfnSpectatorDisconnect() Called when spectator leaves the server
1.60 mm_SpectatorThink, //! pfnSpectatorThink() Called when spectator sends a command packet (usercmd_t)
1.61
1.62 mm_Sys_Error, //! pfnSys_Error() Notify game .dll that engine is going to shut down. Allows mod authors to set a breakpoint. SDK2
1.63
1.64 - mm_PM_Move, //! pfnPM_Move() (wd) SDK2
1.65 - mm_PM_Init, //! pfnPM_Init() Server version of player movement initialization; (wd) SDK2
1.66 + mm_PM_Move, //! pfnPM_Move() (wd) SDK2
1.67 + mm_PM_Init, //! pfnPM_Init() Server version of player movement initialization; (wd) SDK2
1.68 mm_PM_FindTextureType, //! pfnPM_FindTextureType() (wd) SDK2
1.69
1.70 - mm_SetupVisibility, //! pfnSetupVisibility() Set up PVS and PAS for networking for this client; (wd) SDK2
1.71 + mm_SetupVisibility, //! pfnSetupVisibility() Set up PVS and PAS for networking for this client; (wd) SDK2
1.72 mm_UpdateClientData, //! pfnUpdateClientData() Set up data sent only to specific client; (wd) SDK2
1.73 mm_AddToFullPack, //! pfnAddToFullPack() (wd) SDK2
1.74 mm_CreateBaseline, //! pfnCreateBaseline() Tweak entity baseline for network encoding, allows setup of player baselines, too.; (wd) SDK2
1.75 @@ -403,6 +404,8 @@
1.76 mm_AllowLagCompensation, //! pfnAllowLagCompensation() (wd) SDK2
1.77 };
1.78
1.79 +DLL_FUNCTIONS *pHookedDllFunctions = &sFunctionTable;
1.80 +
1.81 // It's not clear what the difference is between GetAPI and GetAPI2; they
1.82 // both appear to return the exact same function table.
1.83 //
1.84 @@ -430,13 +433,18 @@
1.85 META_ERROR("GetEntityAPI version mismatch; requested=%d ours=%d", interfaceVersion, INTERFACE_VERSION);
1.86 return(FALSE);
1.87 }
1.88 - memcpy(pFunctionTable, &gFunctionTable, sizeof(DLL_FUNCTIONS));
1.89 +
1.90 +
1.91 + memcpy(pFunctionTable, &sFunctionTable, sizeof(DLL_FUNCTIONS));
1.92 +
1.93 +
1.94 return(TRUE);
1.95 }
1.96
1.97 C_DLLEXPORT int GetEntityAPI2(DLL_FUNCTIONS *pFunctionTable, int *interfaceVersion)
1.98 {
1.99 META_DEBUG(3, ("called: GetEntityAPI2; version=%d", *interfaceVersion));
1.100 +
1.101 if(!pFunctionTable) {
1.102 META_ERROR("GetEntityAPI2 called with null pFunctionTable");
1.103 return(FALSE);
1.104 @@ -447,7 +455,11 @@
1.105 *interfaceVersion = INTERFACE_VERSION;
1.106 return(FALSE);
1.107 }
1.108 - memcpy(pFunctionTable, &gFunctionTable, sizeof(DLL_FUNCTIONS));
1.109 +
1.110 +
1.111 + memcpy(pFunctionTable, &sFunctionTable, sizeof(DLL_FUNCTIONS));
1.112 +
1.113 +
1.114 return(TRUE);
1.115 }
1.116
1.117 @@ -463,27 +475,31 @@
1.118 //
1.119 // Interestingly, it appears to be called by the engine _before_ GetAPI.
1.120
1.121 -static NEW_DLL_FUNCTIONS gNewFunctionTable =
1.122 -{
1.123 - mm_OnFreeEntPrivateData, //! pfnOnFreeEntPrivateData() Called right before the object's memory is freed. Calls its destructor.
1.124 - mm_GameShutdown, //! pfnGameShutdown()
1.125 - mm_ShouldCollide, //! pfnShouldCollide()
1.126 +static meta_new_dll_functions_t sNewFunctionTable (
1.127 + &mm_OnFreeEntPrivateData, //! pfnOnFreeEntPrivateData() Called right before the object's memory is freed. Calls its destructor.
1.128 + &mm_GameShutdown, //! pfnGameShutdown()
1.129 + &mm_ShouldCollide, //! pfnShouldCollide()
1.130 // Added 2005-08-11 (no SDK update)
1.131 - mm_CvarValue, //! pfnCvarValue() (fz) Obsolete! Use mm_CvarValue2 instead
1.132 + &mm_CvarValue, //! pfnCvarValue() (fz) Obsolete! Use mm_CvarValue2 instead
1.133 // Added 2005-11-22 (no SDK update)
1.134 - mm_CvarValue2, //! pfnCvarValue2() (fz) When pfnQueryClientCvarValue2() completes it will call
1.135 + &mm_CvarValue2 //! pfnCvarValue2() (fz) When pfnQueryClientCvarValue2() completes it will call
1.136 //! pfnCvarValue2() with the request ID supplied earlier, the name of
1.137 //! the cvar requested and the value of that cvar.
1.138 -};
1.139 +);
1.140 +
1.141 +
1.142 +NEW_DLL_FUNCTIONS *pHookedNewDllFunctions = &sNewFunctionTable;
1.143
1.144 C_DLLEXPORT int GetNewDLLFunctions(NEW_DLL_FUNCTIONS *pNewFunctionTable, int *interfaceVersion)
1.145 {
1.146 META_DEBUG(6, ("called: GetNewDLLFunctions; version=%d", *interfaceVersion));
1.147 +#if 0 // ~dvander - but then you can't use cvar querying on many mods...
1.148 // Don't provide these functions to engine if gamedll doesn't provide
1.149 // them. Otherwise, we're in the position of having to provide answers
1.150 // we can't necessarily provide (for instance, ShouldCollide())...
1.151 if(!GameDLL.funcs.newapi_table)
1.152 return(FALSE);
1.153 +#endif
1.154
1.155 if(!pNewFunctionTable) {
1.156 META_ERROR("GetNewDLLFunctions called with null pNewFunctionTable");
1.157 @@ -495,17 +511,10 @@
1.158 *interfaceVersion = NEW_DLL_FUNCTIONS_VERSION;
1.159 return(FALSE);
1.160 }
1.161 -
1.162 - // Detect old engines
1.163 - if (!IS_VALID_PTR((void *)g_engfuncs.pfnQueryClientCvarValue2))
1.164 - {
1.165 - if (!IS_VALID_PTR((void *)g_engfuncs.pfnQueryClientCvarValue))
1.166 - memcpy(pNewFunctionTable, &gNewFunctionTable, sizeof(NEW_DLL_FUNCTIONS) - sizeof(FN_CVARVALUE) - sizeof(FN_CVARVALUE2));
1.167 - else
1.168 - memcpy(pNewFunctionTable, &gNewFunctionTable, sizeof(NEW_DLL_FUNCTIONS) - sizeof(FN_CVARVALUE2));
1.169 - } else {
1.170 - memcpy(pNewFunctionTable, &gNewFunctionTable, sizeof(NEW_DLL_FUNCTIONS));
1.171 - }
1.172 +
1.173 + sNewFunctionTable.copy_to(pNewFunctionTable);
1.174 +
1.175
1.176 return(TRUE);
1.177 }
1.178 +