trace_plugin/dllapi.cpp
author darope
Wed Dec 21 18:40:50 2005 +0000 (2005-12-21)
changeset 249 0e54d20d8f28
parent 248 f72386298cba
child 265 9e61d0d70e9a
permissions -rw-r--r--
Merged working branch to maintrunk for release 1.18.1
darope@0
     1
// vi: set ts=4 sw=4 :
darope@0
     2
// vim: set tw=75 :
darope@0
     3
darope@0
     4
// dllapi.cpp - implementation of Half-Life DLL routines
darope@0
     5
darope@0
     6
/*
darope@0
     7
 * Copyright (c) 2001-2003 Will Day <[email protected]>
darope@0
     8
 *
darope@0
     9
 *    This file is part of Metamod.
darope@0
    10
 *
darope@0
    11
 *    Metamod is free software; you can redistribute it and/or modify it
darope@0
    12
 *    under the terms of the GNU General Public License as published by the
darope@0
    13
 *    Free Software Foundation; either version 2 of the License, or (at
darope@0
    14
 *    your option) any later version.
darope@0
    15
 *
darope@0
    16
 *    Metamod is distributed in the hope that it will be useful, but
darope@0
    17
 *    WITHOUT ANY WARRANTY; without even the implied warranty of
darope@0
    18
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
darope@0
    19
 *    General Public License for more details.
darope@0
    20
 *
darope@0
    21
 *    You should have received a copy of the GNU General Public License
darope@0
    22
 *    along with Metamod; if not, write to the Free Software Foundation,
darope@0
    23
 *    Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
darope@0
    24
 *
darope@0
    25
 *    In addition, as a special exception, the author gives permission to
darope@0
    26
 *    link the code of this program with the Half-Life Game Engine ("HL
darope@0
    27
 *    Engine") and Modified Game Libraries ("MODs") developed by Valve,
darope@0
    28
 *    L.L.C ("Valve").  You must obey the GNU General Public License in all
darope@0
    29
 *    respects for all of the code used other than the HL Engine and MODs
darope@0
    30
 *    from Valve.  If you modify this file, you may extend this exception
darope@0
    31
 *    to your version of the file, but you are not obligated to do so.  If
darope@0
    32
 *    you do not wish to do so, delete this exception statement from your
darope@0
    33
 *    version.
darope@0
    34
 *
darope@0
    35
 */
darope@0
    36
darope@0
    37
#include <extdll.h>
darope@0
    38
#include <sdk_util.h>
darope@0
    39
#include <cbase.h>
darope@0
    40
#include <player.h>
darope@0
    41
darope@0
    42
#include <dllapi.h>
darope@0
    43
#include <meta_api.h>
darope@0
    44
#include <sdk_util.h>
darope@0
    45
darope@0
    46
#include "trace_api.h"
darope@0
    47
#include "log_plugin.h"
darope@0
    48
darope@0
    49
// from SDK dlls/game.cpp:
darope@0
    50
void GameDLLInit( void ) {
darope@0
    51
	DLL_TRACE(pfnGameInit, P_PRE, (""));
darope@0
    52
	RETURN_META(MRES_IGNORED);
darope@0
    53
}
darope@0
    54
darope@0
    55
// from SDK dlls/cbase.cpp:
darope@0
    56
int DispatchSpawn( edict_t *pent ) {
darope@0
    57
	edict_t *ed=pent;
darope@0
    58
	DLL_TRACE(pfnSpawn, P_PRE, ("classname=%s",
darope@0
    59
				ed ? STRING(ed->v.classname) : "nil"));
darope@0
    60
	// 0==Success, -1==Failure ?
darope@0
    61
	RETURN_META_VALUE(MRES_IGNORED, 0);
darope@0
    62
}
darope@0
    63
void DispatchThink( edict_t *pent ) {
darope@0
    64
	DLL_TRACE(pfnThink, P_PRE, (""));
darope@0
    65
	RETURN_META(MRES_IGNORED);
darope@0
    66
}
darope@0
    67
void DispatchUse( edict_t *pentUsed, edict_t *pentOther ) {
darope@0
    68
	DLL_TRACE(pfnUse, P_PRE, (""));
darope@0
    69
	RETURN_META(MRES_IGNORED);
darope@0
    70
}
darope@0
    71
void DispatchTouch( edict_t *pentTouched, edict_t *pentOther ) {
darope@0
    72
	DLL_TRACE(pfnTouch, P_PRE, (""));
darope@0
    73
	RETURN_META(MRES_IGNORED);
darope@0
    74
}
darope@0
    75
void DispatchBlocked( edict_t *pentBlocked, edict_t *pentOther ) {
darope@0
    76
	DLL_TRACE(pfnBlocked, P_PRE, (""));
darope@0
    77
	RETURN_META(MRES_IGNORED);
darope@0
    78
}
darope@0
    79
void DispatchKeyValue( edict_t *pentKeyvalue, KeyValueData *pkvd ) {
darope@0
    80
	DLL_TRACE(pfnKeyValue, P_PRE, ("classname=%s keyname=%s value=%s", P_PRE,
darope@0
    81
			pkvd->szClassName, pkvd->szKeyName, pkvd->szValue));
darope@0
    82
	RETURN_META(MRES_IGNORED);
darope@0
    83
}
darope@0
    84
void DispatchSave( edict_t *pent, SAVERESTOREDATA *pSaveData ) {
darope@0
    85
	DLL_TRACE(pfnSave, P_PRE, (""));
darope@0
    86
	RETURN_META(MRES_IGNORED);
darope@0
    87
}
darope@0
    88
int DispatchRestore( edict_t *pent, SAVERESTOREDATA *pSaveData, int globalEntity ) {
darope@0
    89
	DLL_TRACE(pfnRestore, P_PRE, (""));
darope@0
    90
	// 0==Success, -1==Failure ?
darope@0
    91
	RETURN_META_VALUE(MRES_IGNORED, 0);
darope@0
    92
}
darope@0
    93
void DispatchObjectCollsionBox( edict_t *pent ) {
darope@0
    94
	edict_t *ed=pent;
darope@0
    95
	DLL_TRACE(pfnSetAbsBox, P_PRE, ("classname=%s netname=%s",
darope@0
    96
				ed ? STRING(ed->v.classname) : "nil",
darope@0
    97
				ed ? STRING(ed->v.netname) : "nil"));
darope@0
    98
	RETURN_META(MRES_IGNORED);
darope@0
    99
}
darope@0
   100
void SaveWriteFields( SAVERESTOREDATA *pSaveData, const char *pname, void *pBaseData, TYPEDESCRIPTION *pFields, int fieldCount ) {
darope@0
   101
	DLL_TRACE(pfnSaveWriteFields, P_PRE, (""));
darope@0
   102
	RETURN_META(MRES_IGNORED);
darope@0
   103
}
darope@0
   104
void SaveReadFields( SAVERESTOREDATA *pSaveData, const char *pname, void *pBaseData, TYPEDESCRIPTION *pFields, int fieldCount ) {
darope@0
   105
	DLL_TRACE(pfnSaveReadFields, P_PRE, (""));
darope@0
   106
	RETURN_META(MRES_IGNORED);
darope@0
   107
}
darope@0
   108
darope@0
   109
// from SDK dlls/world.cpp:
darope@0
   110
void SaveGlobalState( SAVERESTOREDATA *pSaveData ) {
darope@0
   111
	DLL_TRACE(pfnSaveGlobalState, P_PRE, (""));
darope@0
   112
	RETURN_META(MRES_IGNORED);
darope@0
   113
}
darope@0
   114
void RestoreGlobalState( SAVERESTOREDATA *pSaveData ) {
darope@0
   115
	DLL_TRACE(pfnRestoreGlobalState, P_PRE, (""));
darope@0
   116
	RETURN_META(MRES_IGNORED);
darope@0
   117
}
darope@0
   118
void ResetGlobalState( void ) {
darope@0
   119
	DLL_TRACE(pfnResetGlobalState, P_PRE, (""));
darope@0
   120
	RETURN_META(MRES_IGNORED);
darope@0
   121
}
darope@0
   122
darope@0
   123
//! from SDK dlls/client.cpp:
darope@0
   124
BOOL ClientConnect( edict_t *pEntity, const char *pszName, const char *pszAddress, char szRejectReason[ 128 ]  ) {
darope@0
   125
	DLL_TRACE(pfnClientConnect, P_PRE, ("name=%s, addr=%s", pszName, pszAddress));
darope@0
   126
	RETURN_META_VALUE(MRES_IGNORED, FALSE);
darope@0
   127
}
darope@0
   128
void ClientDisconnect( edict_t *pEntity ) {
darope@0
   129
	// DLL_TRACE(pfnClientDisconnect, P_PRE, ("name=%s", ENTITY_KEYVALUE(pEntity, "name")));
darope@0
   130
	DLL_TRACE(pfnClientDisconnect, P_PRE, ("name=%s", STRING(pEntity->v.netname)));
darope@0
   131
	RETURN_META(MRES_IGNORED);
darope@0
   132
}
darope@0
   133
void ClientKill( edict_t *pEntity ) {
darope@0
   134
	DLL_TRACE(pfnClientKill, P_PRE, ("name=%s", STRING(pEntity->v.netname)));
darope@0
   135
	RETURN_META(MRES_IGNORED);
darope@0
   136
}
darope@0
   137
void ClientPutInServer( edict_t *pEntity ) {
darope@0
   138
	CBaseEntity *pPlayer=NULL;
darope@0
   139
	pPlayer=(CBasePlayer*)GET_PRIVATE(pEntity);
darope@0
   140
	DLL_TRACE(pfnClientPutInServer, P_PRE, ("name=%s", STRING(pEntity->v.netname)));
darope@0
   141
	RETURN_META(MRES_IGNORED);
darope@0
   142
}
darope@0
   143
void ClientCommand( edict_t *pEntity ) {
darope@0
   144
	DLL_TRACE(pfnClientCommand, P_PRE, ("name=%s, cmd='%s %s'", STRING(pEntity->v.netname), CMD_ARGV(0), 
darope@0
   145
				CMD_ARGC() >= 1 ? CMD_ARGS() : ""));
darope@0
   146
	RETURN_META(MRES_IGNORED);
darope@0
   147
}
darope@0
   148
void ClientUserInfoChanged( edict_t *pEntity, char *infobuffer ) {
darope@0
   149
	DLL_TRACE(pfnClientUserInfoChanged, P_PRE, ("name=%s", STRING(pEntity->v.netname)));
darope@0
   150
	RETURN_META(MRES_IGNORED);
darope@0
   151
}
darope@0
   152
void ServerActivate( edict_t *pEdictList, int edictCount, int clientMax ) {
darope@0
   153
	DLL_TRACE(pfnServerActivate, P_PRE, ("count=%d, max=%d", edictCount, clientMax));
darope@0
   154
	RETURN_META(MRES_IGNORED);
darope@0
   155
}
darope@0
   156
void ServerDeactivate( void ) {
darope@0
   157
	DLL_TRACE(pfnServerDeactivate, P_PRE, (""));
darope@0
   158
	RETURN_META(MRES_IGNORED);
darope@0
   159
}
darope@0
   160
void PlayerPreThink( edict_t *pEntity ) {
darope@0
   161
	DLL_TRACE(pfnPlayerPreThink, P_PRE, ("name=%s", STRING(pEntity->v.netname)));
darope@0
   162
	RETURN_META(MRES_IGNORED);
darope@0
   163
}
darope@0
   164
void PlayerPostThink( edict_t *pEntity ) {
darope@0
   165
	DLL_TRACE(pfnPlayerPostThink, P_PRE, ("name=%s", STRING(pEntity->v.netname)));
darope@0
   166
	RETURN_META(MRES_IGNORED);
darope@0
   167
}
darope@0
   168
void StartFrame( void ) {
darope@0
   169
	DLL_TRACE(pfnStartFrame, P_PRE, (""));
darope@0
   170
	RETURN_META(MRES_IGNORED);
darope@0
   171
}
darope@0
   172
void ParmsNewLevel( void ) {
darope@0
   173
	DLL_TRACE(pfnParmsNewLevel, P_PRE, (""));
darope@0
   174
	RETURN_META(MRES_IGNORED);
darope@0
   175
}
darope@0
   176
void ParmsChangeLevel( void ) {
darope@0
   177
	DLL_TRACE(pfnParmsChangeLevel, P_PRE, (""));
darope@0
   178
	RETURN_META(MRES_IGNORED);
darope@0
   179
}
darope@0
   180
const char *GetGameDescription( void ) {
darope@0
   181
	DLL_TRACE(pfnGetGameDescription, P_PRE, (""));
darope@0
   182
	RETURN_META_VALUE(MRES_IGNORED, "");
darope@0
   183
}
darope@0
   184
void PlayerCustomization( edict_t *pEntity, customization_t *pCust ) {
darope@0
   185
	DLL_TRACE(pfnPlayerCustomization, P_PRE, ("name=%s", STRING(pEntity->v.netname)));
darope@0
   186
	RETURN_META(MRES_IGNORED);
darope@0
   187
}
darope@0
   188
void SpectatorConnect( edict_t *pEntity ) {
darope@0
   189
	DLL_TRACE(pfnSpectatorConnect, P_PRE, (""));
darope@0
   190
	RETURN_META(MRES_IGNORED);
darope@0
   191
}
darope@0
   192
void SpectatorDisconnect( edict_t *pEntity ) {
darope@0
   193
	DLL_TRACE(pfnSpectatorDisconnect, P_PRE, (""));
darope@0
   194
	RETURN_META(MRES_IGNORED);
darope@0
   195
}
darope@0
   196
void SpectatorThink( edict_t *pEntity ) {
darope@0
   197
	DLL_TRACE(pfnSpectatorThink, P_PRE, (""));
darope@0
   198
	RETURN_META(MRES_IGNORED);
darope@0
   199
}
darope@0
   200
void Sys_Error( const char *error_string ) {
darope@0
   201
	DLL_TRACE(pfnSys_Error, P_PRE, ("string=%s", error_string));
darope@0
   202
	RETURN_META(MRES_IGNORED);
darope@0
   203
}
darope@0
   204
darope@0
   205
// from SDK pm_shared/pm_shared.c:
darope@0
   206
void PM_Move ( struct playermove_s *ppmove, int server ) {
darope@0
   207
	DLL_TRACE(pfnPM_Move, P_PRE, (""));
darope@0
   208
	RETURN_META(MRES_IGNORED);
darope@0
   209
}
darope@0
   210
void PM_Init( struct playermove_s *ppmove ) {
darope@0
   211
	DLL_TRACE(pfnPM_Init, P_PRE, (""));
darope@0
   212
	RETURN_META(MRES_IGNORED);
darope@0
   213
}
darope@0
   214
char PM_FindTextureType( char *name ) {
darope@0
   215
	DLL_TRACE(pfnPM_FindTextureType, P_PRE, ("name=%s", name));
darope@0
   216
	RETURN_META_VALUE(MRES_IGNORED, '\0');
darope@0
   217
}
darope@0
   218
darope@0
   219
// from SDK dlls/client.cpp:
darope@0
   220
void SetupVisibility( edict_t *pViewEntity, edict_t *pClient, unsigned char **pvs, unsigned char **pas ) {
darope@0
   221
	DLL_TRACE(pfnSetupVisibility, P_PRE, (""));
darope@0
   222
	RETURN_META(MRES_IGNORED);
darope@0
   223
}
darope@0
   224
void UpdateClientData ( const struct edict_s *ent, int sendweapons, struct clientdata_s *cd ) {
darope@0
   225
	DLL_TRACE(pfnUpdateClientData, P_PRE, (""));
darope@0
   226
	RETURN_META(MRES_IGNORED);
darope@0
   227
}
darope@0
   228
int AddToFullPack( struct entity_state_s *state, int e, edict_t *ent, edict_t *host, int hostflags, int player, unsigned char *pSet ) {
darope@0
   229
	DLL_TRACE(pfnAddToFullPack, P_PRE, (""));
darope@0
   230
	RETURN_META_VALUE(MRES_IGNORED, 0);
darope@0
   231
}
darope@0
   232
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 ) {
darope@0
   233
	DLL_TRACE(pfnCreateBaseline, P_PRE, (""));
darope@0
   234
	RETURN_META(MRES_IGNORED);
darope@0
   235
}
darope@0
   236
void RegisterEncoders( void ) {
darope@0
   237
	DLL_TRACE(pfnRegisterEncoders, P_PRE, (""));
darope@0
   238
	RETURN_META(MRES_IGNORED);
darope@0
   239
}
darope@0
   240
int GetWeaponData( struct edict_s *player, struct weapon_data_s *info ) {
darope@0
   241
	DLL_TRACE(pfnGetWeaponData, P_PRE, (""));
darope@0
   242
	RETURN_META_VALUE(MRES_IGNORED, 1);
darope@0
   243
}
darope@0
   244
void CmdStart( const edict_t *player, const struct usercmd_s *cmd, unsigned int random_seed ) {
darope@0
   245
	DLL_TRACE(pfnCmdStart, P_PRE, ("name=%s, rand=%d", STRING(player->v.netname), random_seed));
darope@0
   246
	RETURN_META(MRES_IGNORED);
darope@0
   247
}
darope@0
   248
void CmdEnd ( const edict_t *player ) {
darope@0
   249
	DLL_TRACE(pfnCmdEnd, P_PRE, ("name=%s", STRING(player->v.netname)));
darope@0
   250
	RETURN_META(MRES_IGNORED);
darope@0
   251
}
darope@0
   252
int ConnectionlessPacket( const struct netadr_s *net_from, const char *args, char *response_buffer, int *response_buffer_size ) {
darope@0
   253
	DLL_TRACE(pfnConnectionlessPacket, P_PRE, (""));
darope@0
   254
	RETURN_META_VALUE(MRES_IGNORED, 0);
darope@0
   255
}
darope@0
   256
int GetHullBounds( int hullnumber, float *mins, float *maxs ) {
darope@0
   257
	DLL_TRACE(pfnGetHullBounds, P_PRE, (""));
darope@0
   258
	RETURN_META_VALUE(MRES_IGNORED, 0);
darope@0
   259
}
darope@0
   260
void CreateInstancedBaselines ( void ) {
darope@0
   261
	DLL_TRACE(pfnCreateInstancedBaselines, P_PRE, (""));
darope@0
   262
	RETURN_META(MRES_IGNORED);
darope@0
   263
}
darope@0
   264
int InconsistentFile( const edict_t *player, const char *filename, char *disconnect_message ) {
darope@0
   265
	DLL_TRACE(pfnInconsistentFile, P_PRE, ("name=%s, file=%s", STRING(player->v.netname), filename));
darope@0
   266
	RETURN_META_VALUE(MRES_IGNORED, 0);
darope@0
   267
}
darope@0
   268
int AllowLagCompensation( void ) {
darope@0
   269
	DLL_TRACE(pfnAllowLagCompensation, P_PRE, (""));
darope@0
   270
	RETURN_META_VALUE(MRES_IGNORED, 1);
darope@0
   271
}
darope@0
   272
darope@0
   273
darope@0
   274
// from SDK ?
darope@0
   275
void OnFreeEntPrivateData(edict_t *pEnt) {
darope@0
   276
	NEWDLL_TRACE(pfnOnFreeEntPrivateData, P_PRE, (""));
darope@0
   277
	RETURN_META(MRES_IGNORED);
darope@0
   278
}
darope@0
   279
void GameShutdown(void) {
darope@0
   280
	NEWDLL_TRACE(pfnGameShutdown, P_PRE, (""));
darope@0
   281
	RETURN_META(MRES_IGNORED);
darope@0
   282
}
darope@0
   283
int ShouldCollide(edict_t *pentTouched, edict_t *pentOther) {
darope@0
   284
	NEWDLL_TRACE(pfnShouldCollide, P_PRE, (""));
darope@0
   285
	RETURN_META_VALUE(MRES_IGNORED, 1);
darope@0
   286
}
darope@249
   287
darope@249
   288
// Added 2005-08-11 (no SDK update)
darope@248
   289
void CvarValue(const edict_t *pEdict, const char *szValue) {
darope@248
   290
	NEWDLL_TRACE(pfnCvarValue, P_PRE, ("player=%s, value=%s", STRING(pEdict->v.netname), szValue?szValue:"nil"));
darope@248
   291
	RETURN_META(MRES_IGNORED);
darope@248
   292
}
darope@0
   293
darope@249
   294
// Added 2005-11-22 (no SDK update)
darope@249
   295
void CvarValue2(const edict_t *pEdict, int requestID, const char *cvarName, const char *value) {
darope@249
   296
	NEWDLL_TRACE(pfnCvarValue2, P_PRE, ("player=%s, requestID=%d, cvar=%s, value=%s", 
darope@249
   297
										STRING(pEdict->v.netname), requestID, cvarName?cvarName:"nil", value?value:"nil"));
darope@249
   298
	RETURN_META(MRES_IGNORED);
darope@249
   299
}
darope@249
   300
darope@0
   301
darope@0
   302
// from SDK dlls/cbase.cpp:
darope@0
   303
// (wd) indicates my comments on the functions
darope@0
   304
static DLL_FUNCTIONS gFunctionTable = 
darope@0
   305
{
darope@0
   306
	GameDLLInit,				//! pfnGameInit()				Initialize the game (one-time call after loading of game .dll)
darope@0
   307
	DispatchSpawn,				//! pfnSpawn()
darope@0
   308
	DispatchThink,				//! pfnThink()
darope@0
   309
	DispatchUse,				//! pfnUse()
darope@0
   310
	DispatchTouch,				//! pfnTouch()
darope@0
   311
	DispatchBlocked,			//! pfnBlocked()
darope@0
   312
	DispatchKeyValue,			//! pfnKeyValue()
darope@0
   313
	DispatchSave,				//! pfnSave()
darope@0
   314
	DispatchRestore,			//! pfnRestore()
darope@0
   315
	DispatchObjectCollsionBox,	//! pfnSetAbsBox()
darope@0
   316
darope@0
   317
	SaveWriteFields,			//! pfnSaveWriteFields()
darope@0
   318
	SaveReadFields,				//! pfnSaveReadFields()
darope@0
   319
darope@0
   320
	SaveGlobalState,			//! pfnSaveGlobalState()
darope@0
   321
	RestoreGlobalState,			//! pfnRestoreGlobalState()
darope@0
   322
	ResetGlobalState,			//! pfnResetGlobalState()
darope@0
   323
darope@0
   324
	ClientConnect,				//! pfnClientConnect()			(wd) Client has connected
darope@0
   325
	ClientDisconnect,			//! pfnClientDisconnect()		(wd) Player has left the game
darope@0
   326
	ClientKill,					//! pfnClientKill()				(wd) Player has typed "kill"
darope@0
   327
	ClientPutInServer,			//! pfnClientPutInServer()		(wd) Client is entering the game
darope@0
   328
	ClientCommand,				//! pfnClientCommand()			(wd) Player has sent a command (typed, or from a bind)
darope@0
   329
	ClientUserInfoChanged,		//! pfnClientUserInfoChanged()	(wd) Client has updated their setinfo structure
darope@0
   330
	ServerActivate,				//! pfnServerActivate()			(wd) Server is starting a new map
darope@0
   331
	ServerDeactivate,			//! pfnServerDeactivate()		(wd) Server is leaving the map (shutdown, or changelevel); SDK2
darope@0
   332
darope@0
   333
	PlayerPreThink,				//! pfnPlayerPreThink()
darope@0
   334
	PlayerPostThink,			//! pfnPlayerPostThink()
darope@0
   335
darope@0
   336
	StartFrame,					//! pfnStartFrame()
darope@0
   337
	ParmsNewLevel,				//! pfnParmsNewLevel()
darope@0
   338
	ParmsChangeLevel,			//! pfnParmsChangeLevel()
darope@0
   339
darope@0
   340
	GetGameDescription,			//! pfnGetGameDescription()		Returns string describing current .dll.  E.g. "TeamFotrress 2", "Half-Life"
darope@0
   341
	PlayerCustomization,		//! pfnPlayerCustomization()	Notifies .dll of new customization for player.
darope@0
   342
darope@0
   343
	SpectatorConnect,			//! pfnSpectatorConnect()		Called when spectator joins server
darope@0
   344
	SpectatorDisconnect,		//! pfnSpectatorDisconnect()	Called when spectator leaves the server
darope@0
   345
	SpectatorThink,				//! pfnSpectatorThink()			Called when spectator sends a command packet (usercmd_t)
darope@0
   346
	
darope@0
   347
	Sys_Error,					//! pfnSys_Error()				Notify game .dll that engine is going to shut down.  Allows mod authors to set a breakpoint.  SDK2
darope@0
   348
darope@0
   349
	PM_Move,					//! pfnPM_Move()				(wd) SDK2
darope@0
   350
	PM_Init,					//! pfnPM_Init()				Server version of player movement initialization; (wd) SDK2
darope@0
   351
	PM_FindTextureType,			//! pfnPM_FindTextureType()		(wd) SDK2
darope@0
   352
	
darope@0
   353
	SetupVisibility,			//! pfnSetupVisibility()		Set up PVS and PAS for networking for this client; (wd) SDK2
darope@0
   354
	UpdateClientData,			//! pfnUpdateClientData()		Set up data sent only to specific client; (wd) SDK2
darope@0
   355
	AddToFullPack,				//! pfnAddToFullPack()			(wd) SDK2
darope@0
   356
	CreateBaseline,				//! pfnCreateBaseline()			Tweak entity baseline for network encoding, allows setup of player baselines, too.; (wd) SDK2
darope@0
   357
	RegisterEncoders,			//! pfnRegisterEncoders()		Callbacks for network encoding; (wd) SDK2
darope@0
   358
	GetWeaponData,				//! pfnGetWeaponData()			(wd) SDK2
darope@0
   359
	CmdStart,					//! pfnCmdStart()				(wd) SDK2
darope@0
   360
	CmdEnd,						//! pfnCmdEnd()					(wd) SDK2
darope@0
   361
	ConnectionlessPacket,		//! pfnConnectionlessPacket()	(wd) SDK2
darope@0
   362
	GetHullBounds,				//! pfnGetHullBounds()			(wd) SDK2
darope@0
   363
	CreateInstancedBaselines,	//! pfnCreateInstancedBaselines()	(wd) SDK2
darope@0
   364
	InconsistentFile,			//! pfnInconsistentFile()		(wd) SDK2
darope@0
   365
	AllowLagCompensation,		//! pfnAllowLagCompensation()	(wd) SDK2
darope@0
   366
};
darope@0
   367
darope@0
   368
// It's not clear what the difference is between GetAPI and GetAPI2; they
darope@0
   369
// both appear to return the exact same function table.  
darope@0
   370
//
darope@0
   371
// Only one of them appears to be ever called, though.  If the DLL provides
darope@0
   372
// GetAPI2, the engine/hlds will call that, and will not call GetAPI.  If
darope@0
   373
// the engine couldn't find GetAPI2 in the DLL, it appears to fall back to
darope@0
   374
// GetAPI.
darope@0
   375
//
darope@0
   376
// So, GetAPI2 appears to replace GetAPI, and appears to have been added
darope@0
   377
// with SDK 2.0.  My best guess is that, with the new SDK, interface
darope@0
   378
// version checking became important, and without the int ptr used in
darope@0
   379
// GetAPI2, the engine can't find out the version of the DLL via GetAPI.
darope@0
   380
//
darope@0
   381
// It's unclear whether a DLL coded under SDK2 needs to provide the older
darope@0
   382
// GetAPI or not..
darope@0
   383
darope@0
   384
C_DLLEXPORT int GetEntityAPI2(DLL_FUNCTIONS *pFunctionTable, 
darope@0
   385
		int *interfaceVersion )
darope@0
   386
{
darope@0
   387
	LOG_DEVELOPER(PLID, "called: GetEntityAPI2; version=%d", *interfaceVersion);
darope@0
   388
	if(!pFunctionTable) {
darope@0
   389
		LOG_ERROR(PLID, "GetEntityAPI2 called with null pFunctionTable");
darope@0
   390
		return(FALSE);
darope@0
   391
	}
darope@0
   392
	else if(*interfaceVersion != INTERFACE_VERSION) {
darope@0
   393
		LOG_ERROR(PLID, 
darope@0
   394
				"GetEntityAPI2 version mismatch; requested=%d ours=%d", 
darope@0
   395
				*interfaceVersion, INTERFACE_VERSION);
darope@0
   396
		//! Tell engine what version we had, so it can figure out who is 
darope@0
   397
		//! out of date.
darope@0
   398
		*interfaceVersion = INTERFACE_VERSION;
darope@0
   399
		return(FALSE);
darope@0
   400
	}
darope@0
   401
	memcpy(pFunctionTable, &gFunctionTable, sizeof(DLL_FUNCTIONS));
darope@0
   402
	return(TRUE);
darope@0
   403
}
darope@0
   404
darope@0
   405
darope@0
   406
// I could find _no_ documentation or examples for the intended use of
darope@0
   407
// NEW_DLL_FUNCTIONS.  I wouldn't have even _known_ about the
darope@0
   408
// GetNewDLLFunctions() function except for the reference in Adminmod..  It
darope@0
   409
// appears to be new with SDK 2.0.
darope@0
   410
//
darope@0
   411
// Obviously, it seems to provide additional functions to the engine, but
darope@0
   412
// it's unclear why a new table and interface were added, rather than
darope@0
   413
// appending new functions to the GetAPI table/interface.
darope@0
   414
//
darope@0
   415
// Interestingly, it appears to be called by the engine _before_ GetAPI.
darope@0
   416
darope@0
   417
static NEW_DLL_FUNCTIONS gNewFunctionTable = 
darope@0
   418
{
darope@0
   419
	OnFreeEntPrivateData,		//! pfnOnFreeEntPrivateData()	Called right before the object's memory is freed.  Calls its destructor.
darope@0
   420
	GameShutdown,				//! pfnGameShutdown()
darope@0
   421
	ShouldCollide,				//! pfnShouldCollide()
darope@249
   422
	// Added 2005-08-11 (no SDK update)
darope@248
   423
	CvarValue,					//! pfnCvarValue()
darope@249
   424
	// Added 2005-11-22 (no SDK update)
darope@249
   425
	CvarValue2,					//! pfnCvarValue2()
darope@0
   426
};
darope@0
   427
darope@0
   428
C_DLLEXPORT int GetNewDLLFunctions(NEW_DLL_FUNCTIONS *pNewFunctionTable, 
darope@0
   429
		int *interfaceVersion) 
darope@0
   430
{
darope@0
   431
	LOG_DEVELOPER(PLID, "called: GetNewDLLFunctions; version=%d", 
darope@0
   432
			*interfaceVersion);
darope@0
   433
	if(!pNewFunctionTable) {
darope@0
   434
		LOG_ERROR(PLID, 
darope@0
   435
				"GetNewDLLFunctions called with null pNewFunctionTable");
darope@0
   436
		return(FALSE);
darope@0
   437
	}
darope@0
   438
	else if(*interfaceVersion != NEW_DLL_FUNCTIONS_VERSION) {
darope@0
   439
		LOG_ERROR(PLID, 
darope@0
   440
				"GetNewDLLFunctions version mismatch; requested=%d ours=%d", 
darope@0
   441
				*interfaceVersion, NEW_DLL_FUNCTIONS_VERSION);
darope@0
   442
		//! Tell engine what version we had, so it can figure out who is 
darope@0
   443
		//! out of date.
darope@0
   444
		*interfaceVersion = NEW_DLL_FUNCTIONS_VERSION;
darope@0
   445
		return(FALSE);
darope@0
   446
	}
darope@0
   447
	memcpy(pNewFunctionTable, &gNewFunctionTable, sizeof(NEW_DLL_FUNCTIONS));
darope@0
   448
	return TRUE;
darope@0
   449
}