2
0
mirror of https://github.com/rehlds/metamod-r.git synced 2025-03-03 17:15:26 +03:00

Cleanup & minor refactor

This commit is contained in:
s1lent 2017-11-18 23:14:14 +07:00
parent 0012c7779c
commit bbcee49883
No known key found for this signature in database
GPG Key ID: 0FE401DC73916B5C
9 changed files with 280 additions and 313 deletions

View File

@ -1,9 +1,9 @@
#include "precompiled.h" #include "precompiled.h"
#define CDATA_DLL_H(x, p, h) CDATA_ENTRY(DLL_FUNCTIONS, x, p, size_t(h)) #define CDATA_DLL_H(x, p, h) CDATA_ENTRY(DLL_FUNCTIONS, x, p, size_t(h))
#define CDATA_DLL(x) CDATA_ENTRY(DLL_FUNCTIONS, x, P_PRE, 0u) #define CDATA_DLL(x) CDATA_ENTRY(DLL_FUNCTIONS, x, P_PRE, 0u)
#define CDATA_NEWDLL_H(x, p, h) CDATA_ENTRY(NEW_DLL_FUNCTIONS, x, p, size_t(h)) #define CDATA_NEWDLL_H(x, p, h) CDATA_ENTRY(NEW_DLL_FUNCTIONS, x, p, size_t(h))
#define CDATA_NEWDLL(x) CDATA_ENTRY(NEW_DLL_FUNCTIONS, x, P_PRE, 0u) #define CDATA_NEWDLL(x) CDATA_ENTRY(NEW_DLL_FUNCTIONS, x, P_PRE, 0u)
DLL_FUNCTIONS sFunctionTable; DLL_FUNCTIONS sFunctionTable;
DLL_FUNCTIONS sFunctionTable_jit; DLL_FUNCTIONS sFunctionTable_jit;
@ -65,76 +65,76 @@ void EXT_FUNC mm_ServerDeactivate()
compile_data_t g_dllfunc_cdata[] = compile_data_t g_dllfunc_cdata[] =
{ {
CDATA_DLL(pfnGameInit), // pfnGameInit() Initialize the game (one-time call after loading of game .dll) CDATA_DLL(pfnGameInit), // Initialize the game (one-time call after loading of game .dll)
CDATA_DLL(pfnSpawn), // pfnSpawn() CDATA_DLL(pfnSpawn), //
CDATA_DLL(pfnThink), // pfnThink() CDATA_DLL(pfnThink), //
CDATA_DLL(pfnUse), // pfnUse() CDATA_DLL(pfnUse), //
CDATA_DLL(pfnTouch), // pfnTouch() CDATA_DLL(pfnTouch), //
CDATA_DLL(pfnBlocked), // pfnBlocked() CDATA_DLL(pfnBlocked), //
CDATA_DLL(pfnKeyValue), // pfnKeyValue() CDATA_DLL(pfnKeyValue), //
CDATA_DLL(pfnSave), // pfnSave() CDATA_DLL(pfnSave), //
CDATA_DLL(pfnRestore), // pfnRestore() CDATA_DLL(pfnRestore), //
CDATA_DLL(pfnSetAbsBox), // pfnSetAbsBox() CDATA_DLL(pfnSetAbsBox), //
CDATA_DLL(pfnSaveWriteFields), // pfnSaveWriteFields() CDATA_DLL(pfnSaveWriteFields), //
CDATA_DLL(pfnSaveReadFields), // pfnSaveReadFields() CDATA_DLL(pfnSaveReadFields), //
CDATA_DLL(pfnSaveGlobalState), // pfnSaveGlobalState() CDATA_DLL(pfnSaveGlobalState), //
CDATA_DLL(pfnRestoreGlobalState), // pfnRestoreGlobalState() CDATA_DLL(pfnRestoreGlobalState), //
CDATA_DLL(pfnResetGlobalState), // pfnResetGlobalState() CDATA_DLL(pfnResetGlobalState), //
CDATA_DLL_H(pfnClientConnect, P_PRE, mm_ClientConnect), // pfnClientConnect() (wd) Client has connected CDATA_DLL_H(pfnClientConnect, P_PRE, mm_ClientConnect), // (wd) Client has connected
CDATA_DLL_H(pfnClientDisconnect, P_PRE, mm_ClientDisconnect), // pfnClientDisconnect() (wd) Player has left the game CDATA_DLL_H(pfnClientDisconnect, P_PRE, mm_ClientDisconnect), // (wd) Player has left the game
CDATA_DLL(pfnClientKill), // pfnClientKill() (wd) Player has typed "kill" CDATA_DLL(pfnClientKill), // (wd) Player has typed "kill"
CDATA_DLL(pfnClientPutInServer), // pfnClientPutInServer() (wd) Client is entering the game CDATA_DLL(pfnClientPutInServer), // (wd) Client is entering the game
CDATA_DLL_H(pfnClientCommand, P_PRE, mm_ClientCommand), CDATA_DLL_H(pfnClientCommand, P_PRE, mm_ClientCommand),
CDATA_DLL(pfnClientUserInfoChanged), // pfnClientUserInfoChanged() (wd) Client has updated their setinfo structure CDATA_DLL(pfnClientUserInfoChanged), // (wd) Client has updated their setinfo structure
CDATA_DLL(pfnServerActivate), // pfnServerActivate() (wd) Server is starting a new map CDATA_DLL(pfnServerActivate), // (wd) Server is starting a new map
CDATA_DLL(pfnServerDeactivate), // pfnServerDeactivate() (wd) Server is leaving the map (shutdown), or changelevel); SDK2 CDATA_DLL(pfnServerDeactivate), // (wd) Server is leaving the map (shutdown), or changelevel); SDK2
CDATA_DLL(pfnPlayerPreThink), // pfnPlayerPreThink() CDATA_DLL(pfnPlayerPreThink), //
CDATA_DLL(pfnPlayerPostThink), // pfnPlayerPostThink() CDATA_DLL(pfnPlayerPostThink), //
CDATA_DLL(pfnStartFrame), // pfnStartFrame() CDATA_DLL(pfnStartFrame), //
CDATA_DLL(pfnParmsNewLevel), // pfnParmsNewLevel() CDATA_DLL(pfnParmsNewLevel), //
CDATA_DLL(pfnParmsChangeLevel), // pfnParmsChangeLevel() CDATA_DLL(pfnParmsChangeLevel), //
CDATA_DLL(pfnGetGameDescription), // pfnGetGameDescription() Returns string describing current .dll. E.g. "TeamFotrress 2"), "Half-Life" CDATA_DLL(pfnGetGameDescription), // Returns string describing current .dll. E.g. "TeamFotrress 2"), "Half-Life"
CDATA_DLL(pfnPlayerCustomization), // pfnPlayerCustomization() Notifies .dll of new customization for player. CDATA_DLL(pfnPlayerCustomization), // Notifies .dll of new customization for player.
CDATA_DLL(pfnSpectatorConnect), // pfnSpectatorConnect() Called when spectator joins server CDATA_DLL(pfnSpectatorConnect), // Called when spectator joins server
CDATA_DLL(pfnSpectatorDisconnect), // pfnSpectatorDisconnect() Called when spectator leaves the server CDATA_DLL(pfnSpectatorDisconnect), // Called when spectator leaves the server
CDATA_DLL(pfnSpectatorThink), // pfnSpectatorThink() Called when spectator sends a command packet (usercmd_t) CDATA_DLL(pfnSpectatorThink), // Called when spectator sends a command packet (usercmd_t)
CDATA_DLL(pfnSys_Error), // pfnSys_Error() Notify game .dll that engine is going to shut down. Allows mod authors to set a breakpoint. SDK2 CDATA_DLL(pfnSys_Error), // Notify game .dll that engine is going to shut down. Allows mod authors to set a breakpoint. SDK2
CDATA_DLL(pfnPM_Move), // pfnPM_Move() (wd) SDK2 CDATA_DLL(pfnPM_Move), // (wd) SDK2
CDATA_DLL(pfnPM_Init), // pfnPM_Init() Server version of player movement initialization; (wd) SDK2 CDATA_DLL(pfnPM_Init), // Server version of player movement initialization; (wd) SDK2
CDATA_DLL(pfnPM_FindTextureType), // pfnPM_FindTextureType() (wd) SDK2 CDATA_DLL(pfnPM_FindTextureType), // (wd) SDK2
CDATA_DLL(pfnSetupVisibility), // pfnSetupVisibility() Set up PVS and PAS for networking for this client; (wd) SDK2 CDATA_DLL(pfnSetupVisibility), // Set up PVS and PAS for networking for this client; (wd) SDK2
CDATA_DLL(pfnUpdateClientData), // pfnUpdateClientData() Set up data sent only to specific client; (wd) SDK2 CDATA_DLL(pfnUpdateClientData), // Set up data sent only to specific client; (wd) SDK2
CDATA_DLL(pfnAddToFullPack), // pfnAddToFullPack() (wd) SDK2 CDATA_DLL(pfnAddToFullPack), // (wd) SDK2
CDATA_DLL(pfnCreateBaseline), // pfnCreateBaseline() Tweak entity baseline for network encoding), allows setup of player baselines), too.; (wd) SDK2 CDATA_DLL(pfnCreateBaseline), // Tweak entity baseline for network encoding), allows setup of player baselines), too.; (wd) SDK2
CDATA_DLL(pfnRegisterEncoders), // pfnRegisterEncoders() Callbacks for network encoding; (wd) SDK2 CDATA_DLL(pfnRegisterEncoders), // Callbacks for network encoding; (wd) SDK2
CDATA_DLL(pfnGetWeaponData), // pfnGetWeaponData() (wd) SDK2 CDATA_DLL(pfnGetWeaponData), // (wd) SDK2
CDATA_DLL(pfnCmdStart), // pfnCmdStart() (wd) SDK2 CDATA_DLL(pfnCmdStart), // (wd) SDK2
CDATA_DLL(pfnCmdEnd), // pfnCmdEnd() (wd) SDK2 CDATA_DLL(pfnCmdEnd), // (wd) SDK2
CDATA_DLL(pfnConnectionlessPacket), // pfnConnectionlessPacket() (wd) SDK2 CDATA_DLL(pfnConnectionlessPacket), // (wd) SDK2
CDATA_DLL(pfnGetHullBounds), // pfnGetHullBounds() (wd) SDK2 CDATA_DLL(pfnGetHullBounds), // (wd) SDK2
CDATA_DLL(pfnCreateInstancedBaselines), // pfnCreateInstancedBaselines()(wd) SDK2 CDATA_DLL(pfnCreateInstancedBaselines), // (wd) SDK2
CDATA_DLL(pfnInconsistentFile), // pfnInconsistentFile() (wd) SDK2 CDATA_DLL(pfnInconsistentFile), // (wd) SDK2
CDATA_DLL(pfnAllowLagCompensation), // pfnAllowLagCompensation() (wd) SDK2 CDATA_DLL(pfnAllowLagCompensation), // (wd) SDK2
}; };
compile_data_t g_newdllfunc_cdata[] = compile_data_t g_newdllfunc_cdata[] =
{ {
CDATA_NEWDLL(pfnOnFreeEntPrivateData), // pfnOnFreeEntPrivateData() Called right before the object's memory is freed. Calls its destructor. CDATA_NEWDLL(pfnOnFreeEntPrivateData), // Called right before the object's memory is freed. Calls its destructor.
CDATA_NEWDLL_H(pfnGameShutdown, P_PRE, mm_GameShutdown), // pfnGameShutdown() CDATA_NEWDLL_H(pfnGameShutdown, P_PRE, mm_GameShutdown), //
CDATA_NEWDLL(pfnShouldCollide), // pfnShouldCollide() CDATA_NEWDLL(pfnShouldCollide), //
CDATA_NEWDLL(pfnCvarValue), // pfnCvarValue() (fz) Use mm_CvarValue2 instead CDATA_NEWDLL(pfnCvarValue), // (fz) Use mm_CvarValue2 instead
CDATA_NEWDLL(pfnCvarValue2) // pfnCvarValue2() (fz) When pfnQueryClientCvarValue2() completes it will call CDATA_NEWDLL(pfnCvarValue2) // (fz) When pfnQueryClientCvarValue2() completes it will call
// pfnCvarValue2() with the request ID supplied earlier, the name of the cvar requested and the value of that cvar. // pfnCvarValue2() with the request ID supplied earlier, the name of the cvar requested and the value of that cvar.
}; };
@ -191,7 +191,9 @@ C_DLLEXPORT int GetEntityAPI2(DLL_FUNCTIONS *pFunctionTable, int *interfaceVersi
C_DLLEXPORT int GetNewDLLFunctions(NEW_DLL_FUNCTIONS *pNewFunctionTable, int *interfaceVersion) C_DLLEXPORT int GetNewDLLFunctions(NEW_DLL_FUNCTIONS *pNewFunctionTable, int *interfaceVersion)
{ {
META_DEBUG(6, "called: GetNewDLLFunctions; version=%d", *interfaceVersion); META_DEBUG(6, "called: GetNewDLLFunctions; version=%d", *interfaceVersion);
#if 0 // ~dvander - but then you can't use cvar querying on many mods...
#if 0
// ~dvander - but then you can't use cvar querying on many mods...
// Don't provide these functions to engine if gamedll doesn't provide // Don't provide these functions to engine if gamedll doesn't provide
// them. Otherwise, we're in the position of having to provide answers // them. Otherwise, we're in the position of having to provide answers
// we can't necessarily provide (for instance, ShouldCollide())... // we can't necessarily provide (for instance, ShouldCollide())...

View File

@ -17,7 +17,7 @@ void MM_POST_HOOK mm_RegUserMsg(const char* pszName, int iSize)
// Add the msgid, name, and size to our saved list, if we haven't already. // Add the msgid, name, and size to our saved list, if we haven't already.
auto imsgid = *(int *)(g_metaGlobals.status == MRES_OVERRIDE ? g_metaGlobals.override_ret : g_metaGlobals.orig_ret); auto imsgid = *(int *)(g_metaGlobals.status == MRES_OVERRIDE ? g_metaGlobals.override_ret : g_metaGlobals.orig_ret);
auto nmsg = g_regMsgs->find(imsgid); auto nmsg = g_regMsgs->find(imsgid);
if (nmsg) { if (nmsg) {
if (!Q_strcmp(pszName, nmsg->getname())) if (!Q_strcmp(pszName, nmsg->getname()))
// This name/msgid pair was already registered. // This name/msgid pair was already registered.
@ -32,208 +32,164 @@ void MM_POST_HOOK mm_RegUserMsg(const char* pszName, int iSize)
compile_data_t g_engfuncs_cdata[] = compile_data_t g_engfuncs_cdata[] =
{ {
CDATA_ENG(pfnPrecacheModel), // pfnPrecacheModel() CDATA_ENG(pfnPrecacheModel),
CDATA_ENG(pfnPrecacheSound), // pfnPrecacheSound() CDATA_ENG(pfnPrecacheSound),
CDATA_ENG(pfnSetModel), // pfnSetModel() CDATA_ENG(pfnSetModel),
CDATA_ENG(pfnModelIndex), // pfnModelIndex() CDATA_ENG(pfnModelIndex),
CDATA_ENG(pfnModelFrames), // pfnModelFrames() CDATA_ENG(pfnModelFrames),
CDATA_ENG(pfnSetSize),
CDATA_ENG(pfnSetSize), // pfnSetSize() CDATA_ENG(pfnChangeLevel),
CDATA_ENG(pfnChangeLevel), // pfnChangeLevel() CDATA_ENG(pfnGetSpawnParms),
CDATA_ENG(pfnGetSpawnParms), // pfnGetSpawnParms() CDATA_ENG(pfnSaveSpawnParms),
CDATA_ENG(pfnSaveSpawnParms), // pfnSaveSpawnParms() CDATA_ENG(pfnVecToYaw),
CDATA_ENG(pfnVecToAngles),
CDATA_ENG(pfnVecToYaw), // pfnVecToYaw() CDATA_ENG(pfnMoveToOrigin),
CDATA_ENG(pfnVecToAngles), // pfnVecToAngles() CDATA_ENG(pfnChangeYaw),
CDATA_ENG(pfnMoveToOrigin), // pfnMoveToOrigin() CDATA_ENG(pfnChangePitch),
CDATA_ENG(pfnChangeYaw), // pfnChangeYaw() CDATA_ENG(pfnFindEntityByString),
CDATA_ENG(pfnChangePitch), // pfnChangePitch() CDATA_ENG(pfnGetEntityIllum),
CDATA_ENG(pfnFindEntityInSphere),
CDATA_ENG(pfnFindEntityByString), // pfnFindEntityByString() CDATA_ENG(pfnFindClientInPVS),
CDATA_ENG(pfnGetEntityIllum), // pfnGetEntityIllum() CDATA_ENG(pfnEntitiesInPVS),
CDATA_ENG(pfnFindEntityInSphere), // pfnFindEntityInSphere() CDATA_ENG(pfnMakeVectors),
CDATA_ENG(pfnFindClientInPVS), // pfnFindClientInPVS() CDATA_ENG(pfnAngleVectors),
CDATA_ENG(pfnEntitiesInPVS), // pfnEntitiesInPVS() CDATA_ENG(pfnCreateEntity),
CDATA_ENG(pfnRemoveEntity),
CDATA_ENG(pfnMakeVectors), // pfnMakeVectors() CDATA_ENG(pfnCreateNamedEntity),
CDATA_ENG(pfnAngleVectors), // pfnAngleVectors() CDATA_ENG(pfnMakeStatic),
CDATA_ENG(pfnEntIsOnFloor),
CDATA_ENG(pfnCreateEntity), // pfnCreateEntity() CDATA_ENG(pfnDropToFloor),
CDATA_ENG(pfnRemoveEntity), // pfnRemoveEntity() CDATA_ENG(pfnWalkMove),
CDATA_ENG(pfnCreateNamedEntity), // pfnCreateNamedEntity() CDATA_ENG(pfnSetOrigin),
CDATA_ENG(pfnEmitSound),
CDATA_ENG(pfnMakeStatic), // pfnMakeStatic() CDATA_ENG(pfnEmitAmbientSound),
CDATA_ENG(pfnEntIsOnFloor), // pfnEntIsOnFloor() CDATA_ENG(pfnTraceLine),
CDATA_ENG(pfnDropToFloor), // pfnDropToFloor() CDATA_ENG(pfnTraceToss),
CDATA_ENG(pfnTraceMonsterHull),
CDATA_ENG(pfnWalkMove), // pfnWalkMove() CDATA_ENG(pfnTraceHull),
CDATA_ENG(pfnSetOrigin), // pfnSetOrigin() CDATA_ENG(pfnTraceModel),
CDATA_ENG(pfnTraceTexture),
CDATA_ENG(pfnEmitSound), // pfnEmitSound() CDATA_ENG(pfnTraceSphere),
CDATA_ENG(pfnEmitAmbientSound), // pfnEmitAmbientSound() CDATA_ENG(pfnGetAimVector),
CDATA_ENG(pfnServerCommand),
CDATA_ENG(pfnTraceLine), // pfnTraceLine() CDATA_ENG(pfnServerExecute),
CDATA_ENG(pfnTraceToss), // pfnTraceToss() CDATA_ENG(pfnClientCommand), // D'oh, ClientCommand in dllapi too.
CDATA_ENG(pfnTraceMonsterHull), // pfnTraceMonsterHull() CDATA_ENG(pfnParticleEffect),
CDATA_ENG(pfnTraceHull), // pfnTraceHull() CDATA_ENG(pfnLightStyle),
CDATA_ENG(pfnTraceModel), // pfnTraceModel() CDATA_ENG(pfnDecalIndex),
CDATA_ENG(pfnTraceTexture), // pfnTraceTexture() CDATA_ENG(pfnPointContents),
CDATA_ENG(pfnTraceSphere), // pfnTraceSphere() CDATA_ENG(pfnMessageBegin),
CDATA_ENG(pfnGetAimVector), // pfnGetAimVector() CDATA_ENG(pfnMessageEnd),
CDATA_ENG(pfnWriteByte),
CDATA_ENG(pfnServerCommand), // pfnServerCommand() CDATA_ENG(pfnWriteChar),
CDATA_ENG(pfnServerExecute), // pfnServerExecute() CDATA_ENG(pfnWriteShort),
CDATA_ENG(pfnClientCommand), // pfnClientCommand() // D'oh, ClientCommand in dllapi too. CDATA_ENG(pfnWriteLong),
CDATA_ENG(pfnWriteAngle),
CDATA_ENG(pfnParticleEffect), // pfnParticleEffect() CDATA_ENG(pfnWriteCoord),
CDATA_ENG(pfnLightStyle), // pfnLightStyle() CDATA_ENG(pfnWriteString),
CDATA_ENG(pfnDecalIndex), // pfnDecalIndex() CDATA_ENG(pfnWriteEntity),
CDATA_ENG(pfnPointContents), // pfnPointContents() CDATA_ENG(pfnCVarRegister),
CDATA_ENG(pfnCVarGetFloat),
CDATA_ENG(pfnMessageBegin), // pfnMessageBegin() CDATA_ENG(pfnCVarGetString),
CDATA_ENG(pfnMessageEnd), // pfnMessageEnd() CDATA_ENG(pfnCVarSetFloat),
CDATA_ENG(pfnCVarSetString),
CDATA_ENG(pfnWriteByte), // pfnWriteByte() CDATA_ENG(pfnAlertMessage),
CDATA_ENG(pfnWriteChar), // pfnWriteChar() CDATA_ENG(pfnEngineFprintf),
CDATA_ENG(pfnWriteShort), // pfnWriteShort() CDATA_ENG(pfnPvAllocEntPrivateData),
CDATA_ENG(pfnWriteLong), // pfnWriteLong() CDATA_ENG(pfnPvEntPrivateData),
CDATA_ENG(pfnWriteAngle), // pfnWriteAngle() CDATA_ENG(pfnFreeEntPrivateData),
CDATA_ENG(pfnWriteCoord), // pfnWriteCoord() CDATA_ENG(pfnSzFromIndex),
CDATA_ENG(pfnWriteString), // pfnWriteString() CDATA_ENG(pfnAllocString),
CDATA_ENG(pfnWriteEntity), // pfnWriteEntity() CDATA_ENG(pfnGetVarsOfEnt),
CDATA_ENG(pfnPEntityOfEntOffset),
CDATA_ENG(pfnCVarRegister), // pfnCVarRegister() CDATA_ENG(pfnEntOffsetOfPEntity),
CDATA_ENG(pfnCVarGetFloat), // pfnCVarGetFloat() CDATA_ENG(pfnIndexOfEdict),
CDATA_ENG(pfnCVarGetString), // pfnCVarGetString() CDATA_ENG(pfnPEntityOfEntIndex),
CDATA_ENG(pfnCVarSetFloat), // pfnCVarSetFloat() CDATA_ENG(pfnFindEntityByVars),
CDATA_ENG(pfnCVarSetString), // pfnCVarSetString() CDATA_ENG(pfnGetModelPtr),
CDATA_ENG_H(pfnRegUserMsg, P_POST, mm_RegUserMsg),
CDATA_ENG(pfnAlertMessage), // pfnAlertMessage() CDATA_ENG(pfnAnimationAutomove),
CDATA_ENG(pfnEngineFprintf), // pfnEngineFprintf() CDATA_ENG(pfnGetBonePosition),
CDATA_ENG(pfnFunctionFromName),
CDATA_ENG(pfnPvAllocEntPrivateData), // pfnPvAllocEntPrivateData() CDATA_ENG(pfnNameForFunction),
CDATA_ENG(pfnPvEntPrivateData), // pfnPvEntPrivateData() CDATA_ENG(pfnClientPrintf), // JOHN: engine callbacks so game DLL can print messages to individual clients
CDATA_ENG(pfnFreeEntPrivateData), // pfnFreeEntPrivateData() CDATA_ENG(pfnServerPrint),
CDATA_ENG(pfnCmd_Args), // these 3 added
CDATA_ENG(pfnSzFromIndex), // pfnSzFromIndex() CDATA_ENG(pfnCmd_Argv), // so game DLL can easily
CDATA_ENG(pfnAllocString), // pfnAllocString() CDATA_ENG(pfnCmd_Argc), // access client 'cmd' strings
CDATA_ENG(pfnGetAttachment),
CDATA_ENG(pfnGetVarsOfEnt), // pfnGetVarsOfEnt() CDATA_ENG(pfnCRC32_Init),
CDATA_ENG(pfnPEntityOfEntOffset), // pfnPEntityOfEntOffset() CDATA_ENG(pfnCRC32_ProcessBuffer),
CDATA_ENG(pfnEntOffsetOfPEntity), // pfnEntOffsetOfPEntity() CDATA_ENG(pfnCRC32_ProcessByte),
CDATA_ENG(pfnIndexOfEdict), // pfnIndexOfEdict() CDATA_ENG(pfnCRC32_Final),
CDATA_ENG(pfnPEntityOfEntIndex), // pfnPEntityOfEntIndex() CDATA_ENG(pfnRandomLong),
CDATA_ENG(pfnFindEntityByVars), // pfnFindEntityByVars() CDATA_ENG(pfnRandomFloat),
CDATA_ENG(pfnGetModelPtr), // pfnGetModelPtr() CDATA_ENG(pfnSetView),
CDATA_ENG(pfnTime),
CDATA_ENG_H(pfnRegUserMsg, P_POST, mm_RegUserMsg), // pfnRegUserMsg() CDATA_ENG(pfnCrosshairAngle),
CDATA_ENG(pfnLoadFileForMe),
CDATA_ENG(pfnAnimationAutomove), // pfnAnimationAutomove() CDATA_ENG(pfnFreeFile),
CDATA_ENG(pfnGetBonePosition), // pfnGetBonePosition() CDATA_ENG(pfnEndSection),
CDATA_ENG(pfnCompareFileTime),
CDATA_ENG(pfnFunctionFromName), // pfnFunctionFromName() CDATA_ENG(pfnGetGameDir),
CDATA_ENG(pfnNameForFunction), // pfnNameForFunction() CDATA_ENG(pfnCvar_RegisterVariable),
CDATA_ENG(pfnFadeClientVolume),
CDATA_ENG(pfnClientPrintf), // pfnClientPrintf() // JOHN: engine callbacks so game DLL can print messages to individual clients CDATA_ENG(pfnSetClientMaxspeed),
CDATA_ENG(pfnServerPrint), // pfnServerPrint() CDATA_ENG(pfnCreateFakeClient), // returns NULL if fake client can't be created
CDATA_ENG(pfnRunPlayerMove),
CDATA_ENG(pfnCmd_Args), // pfnCmd_Args() // these 3 added CDATA_ENG(pfnNumberOfEntities),
CDATA_ENG(pfnCmd_Argv), // pfnCmd_Argv() // so game DLL can easily CDATA_ENG(pfnGetInfoKeyBuffer), // passing in NULL gets the serverinfo
CDATA_ENG(pfnCmd_Argc), // pfnCmd_Argc() // access client 'cmd' strings CDATA_ENG(pfnInfoKeyValue),
CDATA_ENG(pfnSetKeyValue),
CDATA_ENG(pfnGetAttachment), // pfnGetAttachment() CDATA_ENG(pfnSetClientKeyValue),
CDATA_ENG(pfnIsMapValid),
CDATA_ENG(pfnCRC32_Init), // pfnCRC32_Init() CDATA_ENG(pfnStaticDecal),
CDATA_ENG(pfnCRC32_ProcessBuffer), // pfnCRC32_ProcessBuffer() CDATA_ENG(pfnPrecacheGeneric),
CDATA_ENG(pfnCRC32_ProcessByte), // pfnCRC32_ProcessByte() CDATA_ENG(pfnGetPlayerUserId), // returns the server assigned userid for this player.
CDATA_ENG(pfnCRC32_Final), // pfnCRC32_Final() CDATA_ENG(pfnBuildSoundMsg),
CDATA_ENG(pfnIsDedicatedServer), // is this a dedicated server?
CDATA_ENG(pfnRandomLong), // pfnRandomLong() CDATA_ENG(pfnCVarGetPointer),
CDATA_ENG(pfnRandomFloat), // pfnRandomFloat() CDATA_ENG(pfnGetPlayerWONId), // returns the server assigned WONid for this player.
CDATA_ENG(pfnInfo_RemoveKey),
CDATA_ENG(pfnSetView), // pfnSetView() CDATA_ENG(pfnGetPhysicsKeyValue),
CDATA_ENG(pfnTime), // pfnTime() CDATA_ENG(pfnSetPhysicsKeyValue),
CDATA_ENG(pfnCrosshairAngle), // pfnCrosshairAngle() CDATA_ENG(pfnGetPhysicsInfoString),
CDATA_ENG(pfnPrecacheEvent),
CDATA_ENG(pfnLoadFileForMe), // pfnLoadFileForMe() CDATA_ENG(pfnPlaybackEvent),
CDATA_ENG(pfnFreeFile), // pfnFreeFile() CDATA_ENG(pfnSetFatPVS),
CDATA_ENG(pfnSetFatPAS),
CDATA_ENG(pfnEndSection), // pfnEndSection() // trigger_endsection CDATA_ENG(pfnCheckVisibility),
CDATA_ENG(pfnCompareFileTime), // pfnCompareFileTime() CDATA_ENG(pfnDeltaSetField),
CDATA_ENG(pfnGetGameDir), // pfnGetGameDir() CDATA_ENG(pfnDeltaUnsetField),
CDATA_ENG(pfnCvar_RegisterVariable), // pfnCvar_RegisterVariable() CDATA_ENG(pfnDeltaAddEncoder),
CDATA_ENG(pfnFadeClientVolume), // pfnFadeClientVolume() CDATA_ENG(pfnGetCurrentPlayer),
CDATA_ENG(pfnSetClientMaxspeed), // pfnSetClientMaxspeed() CDATA_ENG(pfnCanSkipPlayer),
CDATA_ENG(pfnCreateFakeClient), // pfnCreateFakeClient() // returns NULL if fake client can't be created CDATA_ENG(pfnDeltaFindField),
CDATA_ENG(pfnRunPlayerMove), // pfnRunPlayerMove() CDATA_ENG(pfnDeltaSetFieldByIndex),
CDATA_ENG(pfnNumberOfEntities), // pfnNumberOfEntities() CDATA_ENG(pfnDeltaUnsetFieldByIndex),
CDATA_ENG(pfnSetGroupMask),
CDATA_ENG(pfnGetInfoKeyBuffer), // pfnGetInfoKeyBuffer() // passing in NULL gets the serverinfo CDATA_ENG(pfnCreateInstancedBaseline), // D'oh, CreateInstancedBaseline in dllapi too.
CDATA_ENG(pfnInfoKeyValue), // pfnInfoKeyValue() CDATA_ENG(pfnCvar_DirectSet),
CDATA_ENG(pfnSetKeyValue), // pfnSetKeyValue() CDATA_ENG(pfnForceUnmodified),
CDATA_ENG(pfnSetClientKeyValue), // pfnSetClientKeyValue() CDATA_ENG(pfnGetPlayerStats),
CDATA_ENG(pfnAddServerCommand),
CDATA_ENG(pfnIsMapValid), // pfnIsMapValid() CDATA_ENG(pfnVoice_GetClientListening),
CDATA_ENG(pfnStaticDecal), // pfnStaticDecal() CDATA_ENG(pfnVoice_SetClientListening),
CDATA_ENG(pfnPrecacheGeneric), // pfnPrecacheGeneric() CDATA_ENG(pfnGetPlayerAuthId),
CDATA_ENG(pfnGetPlayerUserId), // pfnGetPlayerUserId() // returns the server assigned userid for this player. CDATA_ENG(pfnSequenceGet),
CDATA_ENG(pfnBuildSoundMsg), // pfnBuildSoundMsg() CDATA_ENG(pfnSequencePickSentence),
CDATA_ENG(pfnIsDedicatedServer), // pfnIsDedicatedServer() // is this a dedicated server? CDATA_ENG(pfnGetFileSize),
CDATA_ENG(pfnCVarGetPointer), // pfnCVarGetPointer() CDATA_ENG(pfnGetApproxWavePlayLen),
CDATA_ENG(pfnGetPlayerWONId), // pfnGetPlayerWONId() // returns the server assigned WONid for this player. CDATA_ENG(pfnIsCareerMatch),
CDATA_ENG(pfnGetLocalizedStringLength),
CDATA_ENG(pfnInfo_RemoveKey), // pfnInfo_RemoveKey() CDATA_ENG(pfnRegisterTutorMessageShown),
CDATA_ENG(pfnGetPhysicsKeyValue), // pfnGetPhysicsKeyValue() CDATA_ENG(pfnGetTimesTutorMessageShown),
CDATA_ENG(pfnSetPhysicsKeyValue), // pfnSetPhysicsKeyValue() CDATA_ENG(pfnProcessTutorMessageDecayBuffer),
CDATA_ENG(pfnGetPhysicsInfoString), // pfnGetPhysicsInfoString() CDATA_ENG(pfnConstructTutorMessageDecayBuffer),
CDATA_ENG(pfnPrecacheEvent), // pfnPrecacheEvent() CDATA_ENG(pfnResetTutorMessageDecayData),
CDATA_ENG(pfnPlaybackEvent), // pfnPlaybackEvent() CDATA_ENG_H(pfnQueryClientCvarValue, P_PRE, mm_QueryClientCvarValue),
CDATA_ENG(pfnQueryClientCvarValue2),
CDATA_ENG(pfnSetFatPVS), // pfnSetFatPVS() CDATA_ENG(pfnEngCheckParm)
CDATA_ENG(pfnSetFatPAS), // pfnSetFatPAS()
CDATA_ENG(pfnCheckVisibility), // pfnCheckVisibility()
CDATA_ENG(pfnDeltaSetField), // pfnDeltaSetField()
CDATA_ENG(pfnDeltaUnsetField), // pfnDeltaUnsetField()
CDATA_ENG(pfnDeltaAddEncoder), // pfnDeltaAddEncoder()
CDATA_ENG(pfnGetCurrentPlayer), // pfnGetCurrentPlayer()
CDATA_ENG(pfnCanSkipPlayer), // pfnCanSkipPlayer()
CDATA_ENG(pfnDeltaFindField), // pfnDeltaFindField()
CDATA_ENG(pfnDeltaSetFieldByIndex), // pfnDeltaSetFieldByIndex()
CDATA_ENG(pfnDeltaUnsetFieldByIndex), // pfnDeltaUnsetFieldByIndex()
CDATA_ENG(pfnSetGroupMask), // pfnSetGroupMask()
CDATA_ENG(pfnCreateInstancedBaseline), // pfnCreateInstancedBaseline() // D'oh, CreateInstancedBaseline in dllapi too.
CDATA_ENG(pfnCvar_DirectSet), // pfnCvar_DirectSet()
CDATA_ENG(pfnForceUnmodified), // pfnForceUnmodified()
CDATA_ENG(pfnGetPlayerStats), // pfnGetPlayerStats()
CDATA_ENG(pfnAddServerCommand), // pfnAddServerCommand()
CDATA_ENG(pfnVoice_GetClientListening), // pfnVoice_GetClientListening()
CDATA_ENG(pfnVoice_SetClientListening), // pfnVoice_SetClientListening()
CDATA_ENG(pfnGetPlayerAuthId), // pfnGetPlayerAuthId()
CDATA_ENG(pfnSequenceGet), // pfnSequenceGet()
CDATA_ENG(pfnSequencePickSentence), // pfnSequencePickSentence()
CDATA_ENG(pfnGetFileSize), // pfnGetFileSize()
CDATA_ENG(pfnGetApproxWavePlayLen), // pfnGetApproxWavePlayLen()
CDATA_ENG(pfnIsCareerMatch), // pfnIsCareerMatch()
CDATA_ENG(pfnGetLocalizedStringLength), // pfnGetLocalizedStringLength()
CDATA_ENG(pfnRegisterTutorMessageShown), // pfnRegisterTutorMessageShown()
CDATA_ENG(pfnGetTimesTutorMessageShown), // pfnGetTimesTutorMessageShown()
CDATA_ENG(pfnProcessTutorMessageDecayBuffer), // pfnProcessTutorMessageDecayBuffer()
CDATA_ENG(pfnConstructTutorMessageDecayBuffer), // pfnConstructTutorMessageDecayBuffer()
CDATA_ENG(pfnResetTutorMessageDecayData), // pfnResetTutorMessageDecayData()
CDATA_ENG_H(pfnQueryClientCvarValue, P_PRE, mm_QueryClientCvarValue), // pfnQueryClientCvarValue()
CDATA_ENG(pfnQueryClientCvarValue2), // pfnQueryClientCvarValue2()
CDATA_ENG(pfnEngCheckParm) // pfnCheckParm()*/
}; };
void compile_engfuncs_callbacks() void compile_engfuncs_callbacks()

View File

@ -5,10 +5,10 @@
// Information we have about each game/mod DLL. // Information we have about each game/mod DLL.
struct game_modinfo_t struct game_modinfo_t
{ {
const char* name; // name (the game dir) const char* name; // name (the game dir)
const char* linux_so; // filename of linux shared lib const char* linux_so; // filename of linux shared lib
const char* win_dll; // filename of win32 dll const char* win_dll; // filename of win32 dll
const char* desc; // our long-name description const char* desc; // our long-name description
}; };
bool setup_gamedll(gamedll_t* gamedll); bool setup_gamedll(gamedll_t* gamedll);

View File

@ -41,7 +41,7 @@ void metamod_startup()
Q_snprintf(configFile, sizeof configFile, "%s/%s", g_config->directory(), CONFIG_INI); Q_snprintf(configFile, sizeof configFile, "%s/%s", g_config->directory(), CONFIG_INI);
Q_snprintf(pluginFile, sizeof pluginFile, "%s/%s", g_config->directory(), PLUGINS_INI); Q_snprintf(pluginFile, sizeof pluginFile, "%s/%s", g_config->directory(), PLUGINS_INI);
Q_snprintf(execFile, sizeof execFile, "%s/%s", g_config->directory(), EXEC_CFG); Q_snprintf(execFile, sizeof execFile, "%s/%s", g_config->directory(), EXEC_CFG);
META_CONS(" "); META_CONS(" ");
META_CONS(" Metamod-r version %s Copyright (c) 2016-2017 ReHLDS Team (rebuild of original Metamod by Will Day and Jussi Kivilinna)", APP_VERSION); META_CONS(" Metamod-r version %s Copyright (c) 2016-2017 ReHLDS Team (rebuild of original Metamod by Will Day and Jussi Kivilinna)", APP_VERSION);

View File

@ -661,11 +661,11 @@ void MPluginList::show_client(edict_t* pEntity)
n++; n++;
META_CLIENT(pEntity, " [%3d] %s, v%s, %s, by %s, see %s", n, META_CLIENT(pEntity, " [%3d] %s, v%s, %s, by %s, see %s", n,
p->info()->name ? p->info()->name : "<unknown>", p->info()->name ? p->info()->name : "<unknown>",
p->info()->version ? p->info()->version : "<?>", p->info()->version ? p->info()->version : "<?>",
p->info()->date ? p->info()->date : "<../../..>", p->info()->date ? p->info()->date : "<../../..>",
p->info()->author ? p->info()->author : "<unknown>", p->info()->author ? p->info()->author : "<unknown>",
p->info()->url ? p->info()->url : "<unknown>"); p->info()->url ? p->info()->url : "<unknown>");
} }
META_CLIENT(pEntity, "%d plugins", n); META_CLIENT(pEntity, "%d plugins", n);

View File

@ -1,9 +1,8 @@
#pragma once #pragma once
#include "mplugin.h" // class MPlugin #include "mplugin.h" // class MPlugin
#include "plinfo.h" // plid_t, etc #include "plinfo.h" // plid_t, etc
// Width required to printf above MAX, for show() functions. // Width required to printf above MAX, for show() functions.
#define WIDTH_MAX_PLUGINS 2 #define WIDTH_MAX_PLUGINS 2
@ -31,7 +30,7 @@ public:
bool ini_startup(); // read inifile at startup bool ini_startup(); // read inifile at startup
bool ini_refresh(); // re-read inifile bool ini_refresh(); // re-read inifile
bool cmd_addload(const char* args); // load from console command bool cmd_addload(const char* args); // load from console command
MPlugin* plugin_addload(plid_t plid, const char* fname, PLUG_LOADTIME now); //load from plugin MPlugin* plugin_addload(plid_t plid, const char* fname, PLUG_LOADTIME now); // load from plugin
bool load(); // load the list, at startup bool load(); // load the list, at startup
bool refresh(PLUG_LOADTIME now); // update from re-read inifile bool refresh(PLUG_LOADTIME now); // update from re-read inifile
@ -44,6 +43,6 @@ public:
private: private:
size_t m_last_index; size_t m_last_index;
plugins_t m_plugins; // array of plugins plugins_t m_plugins; // array of plugins
char m_inifile[PATH_MAX]; // full pathname char m_inifile[PATH_MAX]; // full pathname
}; };

View File

@ -6,10 +6,10 @@ MPlayer::MPlayer() : m_isQueried(false)
// Mark a player as querying a client cvar and stores the cvar name // Mark a player as querying a client cvar and stores the cvar name
// meta_errno values: // meta_errno values:
// - ME_ARGUMENT cvar is NULL // - ME_ARGUMENT cvar is nullptr
void MPlayer::set_cvar_query(const char* cvar) void MPlayer::set_cvar_query(const char* cvar)
{ {
// Do not allow NULL as queried cvar since we use this as // Do not allow nullptr as queried cvar since we use this as
// return value in is_querying_cvar as indication if a // return value in is_querying_cvar as indication if a
// client cvar is queried. // client cvar is queried.
if (!cvar) { if (!cvar) {
@ -28,7 +28,7 @@ void MPlayer::clear_cvar_query(const char* cvar)
} }
// Check if a client cvar is queried for this player // Check if a client cvar is queried for this player
// Returns NULL if not // Returns nullptr if not
// or the name of the cvar. // or the name of the cvar.
const char* MPlayer::is_querying_cvar() const const char* MPlayer::is_querying_cvar() const
{ {
@ -41,20 +41,22 @@ const char* MPlayer::is_querying_cvar() const
// Mark a player as querying a client cvar and stores the cvar name // Mark a player as querying a client cvar and stores the cvar name
// meta_errno values: // meta_errno values:
// - ME_ARGUMENT cvar is NULL // - ME_ARGUMENT cvar is nullptr
void MPlayerList::set_player_cvar_query(const edict_t* pEntity, const char* cvar) void MPlayerList::set_player_cvar_query(const edict_t* pEntity, const char* cvar)
{ {
int indx = ENTINDEX(pEntity); int indx = ENTINDEX(pEntity);
if (indx >= 1 && indx <= gpGlobals->maxClients) if (indx >= 1 && indx <= gpGlobals->maxClients) {
m_players[indx].set_cvar_query(cvar); m_players[indx].set_cvar_query(cvar);
}
} }
// Unmark player as querying a client cvar // Unmark player as querying a client cvar
void MPlayerList::clear_player_cvar_query(const edict_t* pEntity, const char* cvar) void MPlayerList::clear_player_cvar_query(const edict_t* pEntity, const char* cvar)
{ {
int indx = ENTINDEX(pEntity); int indx = ENTINDEX(pEntity);
if (indx >= 1 && indx <= gpGlobals->maxClients) if (indx >= 1 && indx <= gpGlobals->maxClients) {
m_players[indx].clear_cvar_query(cvar); m_players[indx].clear_cvar_query(cvar);
}
} }
void MPlayerList::clear_all_cvar_queries() void MPlayerList::clear_all_cvar_queries()
@ -65,15 +67,16 @@ void MPlayerList::clear_all_cvar_queries()
} }
// Check if a client cvar is queried for this player // Check if a client cvar is queried for this player
// Returns NULL if not // Returns nullptr if not
// or the name of the cvar. // or the name of the cvar.
// meta_errno values: // meta_errno values:
// - ME_NOTFOUND invalid entity // - ME_NOTFOUND invalid entity
const char* MPlayerList::is_querying_cvar(const edict_t* pEntity) const const char* MPlayerList::is_querying_cvar(const edict_t* pEntity) const
{ {
int indx = ENTINDEX(pEntity); int indx = ENTINDEX(pEntity);
if (indx >= 1 && indx <= gpGlobals->maxClients) if (indx >= 1 && indx <= gpGlobals->maxClients) {
return m_players[indx].is_querying_cvar(); return m_players[indx].is_querying_cvar();
}
return NULL; return nullptr;
} }

View File

@ -9,7 +9,6 @@ const char *MPlugin::s_rPrintLoadTime[][4] = {
{ "pausable", "Pause", "at any time, and pausable", "for requested pause" }, // PT_ANYPAUSE { "pausable", "Pause", "at any time, and pausable", "for requested pause" }, // PT_ANYPAUSE
}; };
// ReSharper disable once CppPossiblyUninitializedMember
MPlugin::MPlugin() MPlugin::MPlugin()
{ {
m_status = PL_EMPTY; m_status = PL_EMPTY;
@ -176,8 +175,8 @@ bool MPlugin::plugin_parseline(const char *fname, int loader_index)
else else
m_file = m_filename; m_file = m_filename;
//grab description // grab description
//temporarily use plugin file until plugin can be queried // temporarily use plugin file until plugin can be queried
Q_snprintf(m_desc, sizeof m_desc, "<%s>", m_file); Q_snprintf(m_desc, sizeof m_desc, "<%s>", m_file);
//make full pathname //make full pathname
@ -408,7 +407,7 @@ bool MPlugin::load(PLUG_LOADTIME now, bool& delayed)
META_ERROR("dll: Couldn't close plugin file '%s': %s", m_file, "invalid handle"); META_ERROR("dll: Couldn't close plugin file '%s': %s", m_file, "invalid handle");
} }
m_status = PL_BADFILE; m_status = PL_BADFILE;
m_info = nullptr; //prevent crash m_info = nullptr; // prevent crash
return false; return false;
} }
m_status = PL_OPENED; m_status = PL_OPENED;
@ -716,10 +715,10 @@ bool MPlugin::plugin_unload(plid_t plid, PLUG_LOADTIME now, PL_UNLOAD_REASON rea
m_unloader_index = pl_unloader->index(); m_unloader_index = pl_unloader->index();
//block unloader from being unloaded by other plugin // block unloader from being unloaded by other plugin
pl_unloader->m_is_unloader = true; pl_unloader->m_is_unloader = true;
//try unload // try unload
PLUG_ACTION old_action = m_action; PLUG_ACTION old_action = m_action;
m_action = PA_UNLOAD; m_action = PA_UNLOAD;
bool delayed; bool delayed;
@ -1164,10 +1163,18 @@ const char *MPlugin::str_source(STR_SOURCE fmt) const
case PS_INI: return show ? "ini" : "ini file"; case PS_INI: return show ? "ini" : "ini file";
case PS_CMD: return show ? "cmd" : "console command"; case PS_CMD: return show ? "cmd" : "console command";
case PS_PLUGIN: case PS_PLUGIN:
if (m_source_plugin_index <= 0) {
return show ? "plUN" : "unloaded plugin"; if (m_source_plugin_index <= 0)
return show ? UTIL_VarArgs("pl%d", m_source_plugin_index) : UTIL_VarArgs("plugin [%s]", g_plugins->find(m_source_plugin_index)->description()); return show ? "plUN" : "unloaded plugin";
default: return UTIL_VarArgs(show ? "UNK%d" : "unknown (%d)", m_source);
if (show) {
return UTIL_VarArgs("pl%d", m_source_plugin_index);
}
return UTIL_VarArgs("plugin [%s]", g_plugins->find(m_source_plugin_index)->description());
}
default:
return UTIL_VarArgs(show ? "UNK%d" : "unknown (%d)", m_source);
} }
} }

View File

@ -1,12 +1,12 @@
#include "precompiled.h" #include "precompiled.h"
static hudtextparms_t g_default_csay_tparms = { static hudtextparms_t g_default_csay_tparms = {
-1, 0.25, // x, y -1, 0.25, // x, y
2, // effect 2, // effect
0, 255, 0, 0, // r, g, b, a1 0, 255, 0, 0, // r, g, b, a1
0, 0, 0, 0, // r2, g2, b2, a2 0, 0, 0, 0, // r2, g2, b2, a2
0, 0, 10, 10, // fadein, fadeout, hold, fxtime 0, 0, 10, 10, // fadein, fadeout, hold, fxtime
1 // channel 1 // channel
}; };
static const char* g_engine_msg_names[] = static const char* g_engine_msg_names[] =