1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/trace_plugin/dllapi.cpp Tue Apr 06 07:36:14 2004 +0000
1.3 @@ -0,0 +1,432 @@
1.4 +// vi: set ts=4 sw=4 :
1.5 +// vim: set tw=75 :
1.6 +
1.7 +// dllapi.cpp - implementation of Half-Life DLL routines
1.8 +
1.9 +/*
1.10 + * Copyright (c) 2001-2003 Will Day <[email protected]>
1.11 + *
1.12 + * This file is part of Metamod.
1.13 + *
1.14 + * Metamod is free software; you can redistribute it and/or modify it
1.15 + * under the terms of the GNU General Public License as published by the
1.16 + * Free Software Foundation; either version 2 of the License, or (at
1.17 + * your option) any later version.
1.18 + *
1.19 + * Metamod is distributed in the hope that it will be useful, but
1.20 + * WITHOUT ANY WARRANTY; without even the implied warranty of
1.21 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1.22 + * General Public License for more details.
1.23 + *
1.24 + * You should have received a copy of the GNU General Public License
1.25 + * along with Metamod; if not, write to the Free Software Foundation,
1.26 + * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
1.27 + *
1.28 + * In addition, as a special exception, the author gives permission to
1.29 + * link the code of this program with the Half-Life Game Engine ("HL
1.30 + * Engine") and Modified Game Libraries ("MODs") developed by Valve,
1.31 + * L.L.C ("Valve"). You must obey the GNU General Public License in all
1.32 + * respects for all of the code used other than the HL Engine and MODs
1.33 + * from Valve. If you modify this file, you may extend this exception
1.34 + * to your version of the file, but you are not obligated to do so. If
1.35 + * you do not wish to do so, delete this exception statement from your
1.36 + * version.
1.37 + *
1.38 + */
1.39 +
1.40 +#include <extdll.h>
1.41 +#include <sdk_util.h>
1.42 +#include <cbase.h>
1.43 +#include <player.h>
1.44 +
1.45 +#include <dllapi.h>
1.46 +#include <meta_api.h>
1.47 +#include <sdk_util.h>
1.48 +
1.49 +#include "trace_api.h"
1.50 +#include "log_plugin.h"
1.51 +
1.52 +// from SDK dlls/game.cpp:
1.53 +void GameDLLInit( void ) {
1.54 + DLL_TRACE(pfnGameInit, P_PRE, (""));
1.55 + RETURN_META(MRES_IGNORED);
1.56 +}
1.57 +
1.58 +// from SDK dlls/cbase.cpp:
1.59 +int DispatchSpawn( edict_t *pent ) {
1.60 + edict_t *ed=pent;
1.61 + DLL_TRACE(pfnSpawn, P_PRE, ("classname=%s",
1.62 + ed ? STRING(ed->v.classname) : "nil"));
1.63 + // 0==Success, -1==Failure ?
1.64 + RETURN_META_VALUE(MRES_IGNORED, 0);
1.65 +}
1.66 +void DispatchThink( edict_t *pent ) {
1.67 + DLL_TRACE(pfnThink, P_PRE, (""));
1.68 + RETURN_META(MRES_IGNORED);
1.69 +}
1.70 +void DispatchUse( edict_t *pentUsed, edict_t *pentOther ) {
1.71 + DLL_TRACE(pfnUse, P_PRE, (""));
1.72 + RETURN_META(MRES_IGNORED);
1.73 +}
1.74 +void DispatchTouch( edict_t *pentTouched, edict_t *pentOther ) {
1.75 + DLL_TRACE(pfnTouch, P_PRE, (""));
1.76 + RETURN_META(MRES_IGNORED);
1.77 +}
1.78 +void DispatchBlocked( edict_t *pentBlocked, edict_t *pentOther ) {
1.79 + DLL_TRACE(pfnBlocked, P_PRE, (""));
1.80 + RETURN_META(MRES_IGNORED);
1.81 +}
1.82 +void DispatchKeyValue( edict_t *pentKeyvalue, KeyValueData *pkvd ) {
1.83 + DLL_TRACE(pfnKeyValue, P_PRE, ("classname=%s keyname=%s value=%s", P_PRE,
1.84 + pkvd->szClassName, pkvd->szKeyName, pkvd->szValue));
1.85 + RETURN_META(MRES_IGNORED);
1.86 +}
1.87 +void DispatchSave( edict_t *pent, SAVERESTOREDATA *pSaveData ) {
1.88 + DLL_TRACE(pfnSave, P_PRE, (""));
1.89 + RETURN_META(MRES_IGNORED);
1.90 +}
1.91 +int DispatchRestore( edict_t *pent, SAVERESTOREDATA *pSaveData, int globalEntity ) {
1.92 + DLL_TRACE(pfnRestore, P_PRE, (""));
1.93 + // 0==Success, -1==Failure ?
1.94 + RETURN_META_VALUE(MRES_IGNORED, 0);
1.95 +}
1.96 +void DispatchObjectCollsionBox( edict_t *pent ) {
1.97 + edict_t *ed=pent;
1.98 + DLL_TRACE(pfnSetAbsBox, P_PRE, ("classname=%s netname=%s",
1.99 + ed ? STRING(ed->v.classname) : "nil",
1.100 + ed ? STRING(ed->v.netname) : "nil"));
1.101 + RETURN_META(MRES_IGNORED);
1.102 +}
1.103 +void SaveWriteFields( SAVERESTOREDATA *pSaveData, const char *pname, void *pBaseData, TYPEDESCRIPTION *pFields, int fieldCount ) {
1.104 + DLL_TRACE(pfnSaveWriteFields, P_PRE, (""));
1.105 + RETURN_META(MRES_IGNORED);
1.106 +}
1.107 +void SaveReadFields( SAVERESTOREDATA *pSaveData, const char *pname, void *pBaseData, TYPEDESCRIPTION *pFields, int fieldCount ) {
1.108 + DLL_TRACE(pfnSaveReadFields, P_PRE, (""));
1.109 + RETURN_META(MRES_IGNORED);
1.110 +}
1.111 +
1.112 +// from SDK dlls/world.cpp:
1.113 +void SaveGlobalState( SAVERESTOREDATA *pSaveData ) {
1.114 + DLL_TRACE(pfnSaveGlobalState, P_PRE, (""));
1.115 + RETURN_META(MRES_IGNORED);
1.116 +}
1.117 +void RestoreGlobalState( SAVERESTOREDATA *pSaveData ) {
1.118 + DLL_TRACE(pfnRestoreGlobalState, P_PRE, (""));
1.119 + RETURN_META(MRES_IGNORED);
1.120 +}
1.121 +void ResetGlobalState( void ) {
1.122 + DLL_TRACE(pfnResetGlobalState, P_PRE, (""));
1.123 + RETURN_META(MRES_IGNORED);
1.124 +}
1.125 +
1.126 +//! from SDK dlls/client.cpp:
1.127 +BOOL ClientConnect( edict_t *pEntity, const char *pszName, const char *pszAddress, char szRejectReason[ 128 ] ) {
1.128 + DLL_TRACE(pfnClientConnect, P_PRE, ("name=%s, addr=%s", pszName, pszAddress));
1.129 + RETURN_META_VALUE(MRES_IGNORED, FALSE);
1.130 +}
1.131 +void ClientDisconnect( edict_t *pEntity ) {
1.132 + // DLL_TRACE(pfnClientDisconnect, P_PRE, ("name=%s", ENTITY_KEYVALUE(pEntity, "name")));
1.133 + DLL_TRACE(pfnClientDisconnect, P_PRE, ("name=%s", STRING(pEntity->v.netname)));
1.134 + RETURN_META(MRES_IGNORED);
1.135 +}
1.136 +void ClientKill( edict_t *pEntity ) {
1.137 + DLL_TRACE(pfnClientKill, P_PRE, ("name=%s", STRING(pEntity->v.netname)));
1.138 + RETURN_META(MRES_IGNORED);
1.139 +}
1.140 +void ClientPutInServer( edict_t *pEntity ) {
1.141 + CBaseEntity *pPlayer=NULL;
1.142 + pPlayer=(CBasePlayer*)GET_PRIVATE(pEntity);
1.143 + DLL_TRACE(pfnClientPutInServer, P_PRE, ("name=%s", STRING(pEntity->v.netname)));
1.144 + RETURN_META(MRES_IGNORED);
1.145 +}
1.146 +void ClientCommand( edict_t *pEntity ) {
1.147 + DLL_TRACE(pfnClientCommand, P_PRE, ("name=%s, cmd='%s %s'", STRING(pEntity->v.netname), CMD_ARGV(0),
1.148 + CMD_ARGC() >= 1 ? CMD_ARGS() : ""));
1.149 + RETURN_META(MRES_IGNORED);
1.150 +}
1.151 +void ClientUserInfoChanged( edict_t *pEntity, char *infobuffer ) {
1.152 + DLL_TRACE(pfnClientUserInfoChanged, P_PRE, ("name=%s", STRING(pEntity->v.netname)));
1.153 + RETURN_META(MRES_IGNORED);
1.154 +}
1.155 +void ServerActivate( edict_t *pEdictList, int edictCount, int clientMax ) {
1.156 + DLL_TRACE(pfnServerActivate, P_PRE, ("count=%d, max=%d", edictCount, clientMax));
1.157 + RETURN_META(MRES_IGNORED);
1.158 +}
1.159 +void ServerDeactivate( void ) {
1.160 + DLL_TRACE(pfnServerDeactivate, P_PRE, (""));
1.161 + RETURN_META(MRES_IGNORED);
1.162 +}
1.163 +void PlayerPreThink( edict_t *pEntity ) {
1.164 + DLL_TRACE(pfnPlayerPreThink, P_PRE, ("name=%s", STRING(pEntity->v.netname)));
1.165 + RETURN_META(MRES_IGNORED);
1.166 +}
1.167 +void PlayerPostThink( edict_t *pEntity ) {
1.168 + DLL_TRACE(pfnPlayerPostThink, P_PRE, ("name=%s", STRING(pEntity->v.netname)));
1.169 + RETURN_META(MRES_IGNORED);
1.170 +}
1.171 +void StartFrame( void ) {
1.172 + DLL_TRACE(pfnStartFrame, P_PRE, (""));
1.173 + RETURN_META(MRES_IGNORED);
1.174 +}
1.175 +void ParmsNewLevel( void ) {
1.176 + DLL_TRACE(pfnParmsNewLevel, P_PRE, (""));
1.177 + RETURN_META(MRES_IGNORED);
1.178 +}
1.179 +void ParmsChangeLevel( void ) {
1.180 + DLL_TRACE(pfnParmsChangeLevel, P_PRE, (""));
1.181 + RETURN_META(MRES_IGNORED);
1.182 +}
1.183 +const char *GetGameDescription( void ) {
1.184 + DLL_TRACE(pfnGetGameDescription, P_PRE, (""));
1.185 + RETURN_META_VALUE(MRES_IGNORED, "");
1.186 +}
1.187 +void PlayerCustomization( edict_t *pEntity, customization_t *pCust ) {
1.188 + DLL_TRACE(pfnPlayerCustomization, P_PRE, ("name=%s", STRING(pEntity->v.netname)));
1.189 + RETURN_META(MRES_IGNORED);
1.190 +}
1.191 +void SpectatorConnect( edict_t *pEntity ) {
1.192 + DLL_TRACE(pfnSpectatorConnect, P_PRE, (""));
1.193 + RETURN_META(MRES_IGNORED);
1.194 +}
1.195 +void SpectatorDisconnect( edict_t *pEntity ) {
1.196 + DLL_TRACE(pfnSpectatorDisconnect, P_PRE, (""));
1.197 + RETURN_META(MRES_IGNORED);
1.198 +}
1.199 +void SpectatorThink( edict_t *pEntity ) {
1.200 + DLL_TRACE(pfnSpectatorThink, P_PRE, (""));
1.201 + RETURN_META(MRES_IGNORED);
1.202 +}
1.203 +void Sys_Error( const char *error_string ) {
1.204 + DLL_TRACE(pfnSys_Error, P_PRE, ("string=%s", error_string));
1.205 + RETURN_META(MRES_IGNORED);
1.206 +}
1.207 +
1.208 +// from SDK pm_shared/pm_shared.c:
1.209 +void PM_Move ( struct playermove_s *ppmove, int server ) {
1.210 + DLL_TRACE(pfnPM_Move, P_PRE, (""));
1.211 + RETURN_META(MRES_IGNORED);
1.212 +}
1.213 +void PM_Init( struct playermove_s *ppmove ) {
1.214 + DLL_TRACE(pfnPM_Init, P_PRE, (""));
1.215 + RETURN_META(MRES_IGNORED);
1.216 +}
1.217 +char PM_FindTextureType( char *name ) {
1.218 + DLL_TRACE(pfnPM_FindTextureType, P_PRE, ("name=%s", name));
1.219 + RETURN_META_VALUE(MRES_IGNORED, '\0');
1.220 +}
1.221 +
1.222 +// from SDK dlls/client.cpp:
1.223 +void SetupVisibility( edict_t *pViewEntity, edict_t *pClient, unsigned char **pvs, unsigned char **pas ) {
1.224 + DLL_TRACE(pfnSetupVisibility, P_PRE, (""));
1.225 + RETURN_META(MRES_IGNORED);
1.226 +}
1.227 +void UpdateClientData ( const struct edict_s *ent, int sendweapons, struct clientdata_s *cd ) {
1.228 + DLL_TRACE(pfnUpdateClientData, P_PRE, (""));
1.229 + RETURN_META(MRES_IGNORED);
1.230 +}
1.231 +int AddToFullPack( struct entity_state_s *state, int e, edict_t *ent, edict_t *host, int hostflags, int player, unsigned char *pSet ) {
1.232 + DLL_TRACE(pfnAddToFullPack, P_PRE, (""));
1.233 + RETURN_META_VALUE(MRES_IGNORED, 0);
1.234 +}
1.235 +void CreateBaseline( int player, int eindex, struct entity_state_s *baseline, struct edict_s *entity, int playermodelindex, vec3_t player_mins, vec3_t player_maxs ) {
1.236 + DLL_TRACE(pfnCreateBaseline, P_PRE, (""));
1.237 + RETURN_META(MRES_IGNORED);
1.238 +}
1.239 +void RegisterEncoders( void ) {
1.240 + DLL_TRACE(pfnRegisterEncoders, P_PRE, (""));
1.241 + RETURN_META(MRES_IGNORED);
1.242 +}
1.243 +int GetWeaponData( struct edict_s *player, struct weapon_data_s *info ) {
1.244 + DLL_TRACE(pfnGetWeaponData, P_PRE, (""));
1.245 + RETURN_META_VALUE(MRES_IGNORED, 1);
1.246 +}
1.247 +void CmdStart( const edict_t *player, const struct usercmd_s *cmd, unsigned int random_seed ) {
1.248 + DLL_TRACE(pfnCmdStart, P_PRE, ("name=%s, rand=%d", STRING(player->v.netname), random_seed));
1.249 + RETURN_META(MRES_IGNORED);
1.250 +}
1.251 +void CmdEnd ( const edict_t *player ) {
1.252 + DLL_TRACE(pfnCmdEnd, P_PRE, ("name=%s", STRING(player->v.netname)));
1.253 + RETURN_META(MRES_IGNORED);
1.254 +}
1.255 +int ConnectionlessPacket( const struct netadr_s *net_from, const char *args, char *response_buffer, int *response_buffer_size ) {
1.256 + DLL_TRACE(pfnConnectionlessPacket, P_PRE, (""));
1.257 + RETURN_META_VALUE(MRES_IGNORED, 0);
1.258 +}
1.259 +int GetHullBounds( int hullnumber, float *mins, float *maxs ) {
1.260 + DLL_TRACE(pfnGetHullBounds, P_PRE, (""));
1.261 + RETURN_META_VALUE(MRES_IGNORED, 0);
1.262 +}
1.263 +void CreateInstancedBaselines ( void ) {
1.264 + DLL_TRACE(pfnCreateInstancedBaselines, P_PRE, (""));
1.265 + RETURN_META(MRES_IGNORED);
1.266 +}
1.267 +int InconsistentFile( const edict_t *player, const char *filename, char *disconnect_message ) {
1.268 + DLL_TRACE(pfnInconsistentFile, P_PRE, ("name=%s, file=%s", STRING(player->v.netname), filename));
1.269 + RETURN_META_VALUE(MRES_IGNORED, 0);
1.270 +}
1.271 +int AllowLagCompensation( void ) {
1.272 + DLL_TRACE(pfnAllowLagCompensation, P_PRE, (""));
1.273 + RETURN_META_VALUE(MRES_IGNORED, 1);
1.274 +}
1.275 +
1.276 +
1.277 +// from SDK ?
1.278 +void OnFreeEntPrivateData(edict_t *pEnt) {
1.279 + NEWDLL_TRACE(pfnOnFreeEntPrivateData, P_PRE, (""));
1.280 + RETURN_META(MRES_IGNORED);
1.281 +}
1.282 +void GameShutdown(void) {
1.283 + NEWDLL_TRACE(pfnGameShutdown, P_PRE, (""));
1.284 + RETURN_META(MRES_IGNORED);
1.285 +}
1.286 +int ShouldCollide(edict_t *pentTouched, edict_t *pentOther) {
1.287 + NEWDLL_TRACE(pfnShouldCollide, P_PRE, (""));
1.288 + RETURN_META_VALUE(MRES_IGNORED, 1);
1.289 +}
1.290 +
1.291 +
1.292 +// from SDK dlls/cbase.cpp:
1.293 +// (wd) indicates my comments on the functions
1.294 +static DLL_FUNCTIONS gFunctionTable =
1.295 +{
1.296 + GameDLLInit, //! pfnGameInit() Initialize the game (one-time call after loading of game .dll)
1.297 + DispatchSpawn, //! pfnSpawn()
1.298 + DispatchThink, //! pfnThink()
1.299 + DispatchUse, //! pfnUse()
1.300 + DispatchTouch, //! pfnTouch()
1.301 + DispatchBlocked, //! pfnBlocked()
1.302 + DispatchKeyValue, //! pfnKeyValue()
1.303 + DispatchSave, //! pfnSave()
1.304 + DispatchRestore, //! pfnRestore()
1.305 + DispatchObjectCollsionBox, //! pfnSetAbsBox()
1.306 +
1.307 + SaveWriteFields, //! pfnSaveWriteFields()
1.308 + SaveReadFields, //! pfnSaveReadFields()
1.309 +
1.310 + SaveGlobalState, //! pfnSaveGlobalState()
1.311 + RestoreGlobalState, //! pfnRestoreGlobalState()
1.312 + ResetGlobalState, //! pfnResetGlobalState()
1.313 +
1.314 + ClientConnect, //! pfnClientConnect() (wd) Client has connected
1.315 + ClientDisconnect, //! pfnClientDisconnect() (wd) Player has left the game
1.316 + ClientKill, //! pfnClientKill() (wd) Player has typed "kill"
1.317 + ClientPutInServer, //! pfnClientPutInServer() (wd) Client is entering the game
1.318 + ClientCommand, //! pfnClientCommand() (wd) Player has sent a command (typed, or from a bind)
1.319 + ClientUserInfoChanged, //! pfnClientUserInfoChanged() (wd) Client has updated their setinfo structure
1.320 + ServerActivate, //! pfnServerActivate() (wd) Server is starting a new map
1.321 + ServerDeactivate, //! pfnServerDeactivate() (wd) Server is leaving the map (shutdown, or changelevel); SDK2
1.322 +
1.323 + PlayerPreThink, //! pfnPlayerPreThink()
1.324 + PlayerPostThink, //! pfnPlayerPostThink()
1.325 +
1.326 + StartFrame, //! pfnStartFrame()
1.327 + ParmsNewLevel, //! pfnParmsNewLevel()
1.328 + ParmsChangeLevel, //! pfnParmsChangeLevel()
1.329 +
1.330 + GetGameDescription, //! pfnGetGameDescription() Returns string describing current .dll. E.g. "TeamFotrress 2", "Half-Life"
1.331 + PlayerCustomization, //! pfnPlayerCustomization() Notifies .dll of new customization for player.
1.332 +
1.333 + SpectatorConnect, //! pfnSpectatorConnect() Called when spectator joins server
1.334 + SpectatorDisconnect, //! pfnSpectatorDisconnect() Called when spectator leaves the server
1.335 + SpectatorThink, //! pfnSpectatorThink() Called when spectator sends a command packet (usercmd_t)
1.336 +
1.337 + Sys_Error, //! pfnSys_Error() Notify game .dll that engine is going to shut down. Allows mod authors to set a breakpoint. SDK2
1.338 +
1.339 + PM_Move, //! pfnPM_Move() (wd) SDK2
1.340 + PM_Init, //! pfnPM_Init() Server version of player movement initialization; (wd) SDK2
1.341 + PM_FindTextureType, //! pfnPM_FindTextureType() (wd) SDK2
1.342 +
1.343 + SetupVisibility, //! pfnSetupVisibility() Set up PVS and PAS for networking for this client; (wd) SDK2
1.344 + UpdateClientData, //! pfnUpdateClientData() Set up data sent only to specific client; (wd) SDK2
1.345 + AddToFullPack, //! pfnAddToFullPack() (wd) SDK2
1.346 + CreateBaseline, //! pfnCreateBaseline() Tweak entity baseline for network encoding, allows setup of player baselines, too.; (wd) SDK2
1.347 + RegisterEncoders, //! pfnRegisterEncoders() Callbacks for network encoding; (wd) SDK2
1.348 + GetWeaponData, //! pfnGetWeaponData() (wd) SDK2
1.349 + CmdStart, //! pfnCmdStart() (wd) SDK2
1.350 + CmdEnd, //! pfnCmdEnd() (wd) SDK2
1.351 + ConnectionlessPacket, //! pfnConnectionlessPacket() (wd) SDK2
1.352 + GetHullBounds, //! pfnGetHullBounds() (wd) SDK2
1.353 + CreateInstancedBaselines, //! pfnCreateInstancedBaselines() (wd) SDK2
1.354 + InconsistentFile, //! pfnInconsistentFile() (wd) SDK2
1.355 + AllowLagCompensation, //! pfnAllowLagCompensation() (wd) SDK2
1.356 +};
1.357 +
1.358 +// It's not clear what the difference is between GetAPI and GetAPI2; they
1.359 +// both appear to return the exact same function table.
1.360 +//
1.361 +// Only one of them appears to be ever called, though. If the DLL provides
1.362 +// GetAPI2, the engine/hlds will call that, and will not call GetAPI. If
1.363 +// the engine couldn't find GetAPI2 in the DLL, it appears to fall back to
1.364 +// GetAPI.
1.365 +//
1.366 +// So, GetAPI2 appears to replace GetAPI, and appears to have been added
1.367 +// with SDK 2.0. My best guess is that, with the new SDK, interface
1.368 +// version checking became important, and without the int ptr used in
1.369 +// GetAPI2, the engine can't find out the version of the DLL via GetAPI.
1.370 +//
1.371 +// It's unclear whether a DLL coded under SDK2 needs to provide the older
1.372 +// GetAPI or not..
1.373 +
1.374 +C_DLLEXPORT int GetEntityAPI2(DLL_FUNCTIONS *pFunctionTable,
1.375 + int *interfaceVersion )
1.376 +{
1.377 + LOG_DEVELOPER(PLID, "called: GetEntityAPI2; version=%d", *interfaceVersion);
1.378 + if(!pFunctionTable) {
1.379 + LOG_ERROR(PLID, "GetEntityAPI2 called with null pFunctionTable");
1.380 + return(FALSE);
1.381 + }
1.382 + else if(*interfaceVersion != INTERFACE_VERSION) {
1.383 + LOG_ERROR(PLID,
1.384 + "GetEntityAPI2 version mismatch; requested=%d ours=%d",
1.385 + *interfaceVersion, INTERFACE_VERSION);
1.386 + //! Tell engine what version we had, so it can figure out who is
1.387 + //! out of date.
1.388 + *interfaceVersion = INTERFACE_VERSION;
1.389 + return(FALSE);
1.390 + }
1.391 + memcpy(pFunctionTable, &gFunctionTable, sizeof(DLL_FUNCTIONS));
1.392 + return(TRUE);
1.393 +}
1.394 +
1.395 +
1.396 +// I could find _no_ documentation or examples for the intended use of
1.397 +// NEW_DLL_FUNCTIONS. I wouldn't have even _known_ about the
1.398 +// GetNewDLLFunctions() function except for the reference in Adminmod.. It
1.399 +// appears to be new with SDK 2.0.
1.400 +//
1.401 +// Obviously, it seems to provide additional functions to the engine, but
1.402 +// it's unclear why a new table and interface were added, rather than
1.403 +// appending new functions to the GetAPI table/interface.
1.404 +//
1.405 +// Interestingly, it appears to be called by the engine _before_ GetAPI.
1.406 +
1.407 +static NEW_DLL_FUNCTIONS gNewFunctionTable =
1.408 +{
1.409 + OnFreeEntPrivateData, //! pfnOnFreeEntPrivateData() Called right before the object's memory is freed. Calls its destructor.
1.410 + GameShutdown, //! pfnGameShutdown()
1.411 + ShouldCollide, //! pfnShouldCollide()
1.412 +};
1.413 +
1.414 +C_DLLEXPORT int GetNewDLLFunctions(NEW_DLL_FUNCTIONS *pNewFunctionTable,
1.415 + int *interfaceVersion)
1.416 +{
1.417 + LOG_DEVELOPER(PLID, "called: GetNewDLLFunctions; version=%d",
1.418 + *interfaceVersion);
1.419 + if(!pNewFunctionTable) {
1.420 + LOG_ERROR(PLID,
1.421 + "GetNewDLLFunctions called with null pNewFunctionTable");
1.422 + return(FALSE);
1.423 + }
1.424 + else if(*interfaceVersion != NEW_DLL_FUNCTIONS_VERSION) {
1.425 + LOG_ERROR(PLID,
1.426 + "GetNewDLLFunctions version mismatch; requested=%d ours=%d",
1.427 + *interfaceVersion, NEW_DLL_FUNCTIONS_VERSION);
1.428 + //! Tell engine what version we had, so it can figure out who is
1.429 + //! out of date.
1.430 + *interfaceVersion = NEW_DLL_FUNCTIONS_VERSION;
1.431 + return(FALSE);
1.432 + }
1.433 + memcpy(pNewFunctionTable, &gNewFunctionTable, sizeof(NEW_DLL_FUNCTIONS));
1.434 + return TRUE;
1.435 +}