Skip to content

Commit

Permalink
Update Metamod SDK
Browse files Browse the repository at this point in the history
Update Metamod SDK
  • Loading branch information
SmileYzn committed Aug 13, 2024
1 parent c6bb9e0 commit e24c0f6
Show file tree
Hide file tree
Showing 6 changed files with 179 additions and 187 deletions.
31 changes: 25 additions & 6 deletions AccuracyFix/include/metamod/dllapi.h
Original file line number Diff line number Diff line change
@@ -1,17 +1,36 @@
#pragma once

#include <eiface.h>

#ifndef DLLEXPORT
#ifdef _WIN32
#define DLLEXPORT __declspec(dllexport)
#else
#define DLLEXPORT __attribute__((visibility("default")))
#endif // _WIN32
#endif // DLLEXPORT

#ifndef C_DLLEXPORT
#define C_DLLEXPORT extern "C" DLLEXPORT
#endif

#ifndef _WIN32
#define WINAPI
#endif

typedef void (*FN_GAMEINIT)();

// Typedefs for these are provided in SDK engine/eiface.h, but I didn't
// like the names (APIFUNCTION, APIFUNCTION2, NEW_DLL_FUNCTIONS_FN).
typedef int (*GETENTITYAPI_FN)(DLL_FUNCTIONS *pFunctionTable, int interfaceVersion);
typedef int (*GETENTITYAPI2_FN)(DLL_FUNCTIONS *pFunctionTable, int *interfaceVersion);
typedef int (*GETNEWDLLFUNCTIONS_FN)(NEW_DLL_FUNCTIONS *pFunctionTable, int *interfaceVersion);
typedef int (*GETENTITYAPI_FN)(DLL_FUNCTIONS* pFunctionTable, int interfaceVersion);
typedef int (*GETENTITYAPI2_FN)(DLL_FUNCTIONS* pFunctionTable, int* interfaceVersion);
typedef int (*GETNEWDLLFUNCTIONS_FN)(NEW_DLL_FUNCTIONS* pFunctionTable, int* interfaceVersion);

C_DLLEXPORT int GetEntityAPI(DLL_FUNCTIONS *pFunctionTable, int interfaceVersion);
C_DLLEXPORT int GetEntityAPI2(DLL_FUNCTIONS *pFunctionTable, int *interfaceVersion);
C_DLLEXPORT int GetNewDLLFunctions(NEW_DLL_FUNCTIONS *pNewFunctionTable, int *interfaceVersion);
C_DLLEXPORT int GetEntityAPI(DLL_FUNCTIONS* pFunctionTable, int interfaceVersion);
C_DLLEXPORT int GetEntityAPI2(DLL_FUNCTIONS* pFunctionTable, int* interfaceVersion);
C_DLLEXPORT int GetNewDLLFunctions(NEW_DLL_FUNCTIONS* pNewFunctionTable, int* interfaceVersion);

#ifdef METAMOD_CORE
void compile_gamedll_callbacks();
void disable_clientcommand_fwd();
#endif
7 changes: 3 additions & 4 deletions AccuracyFix/include/metamod/engine_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
struct enginefuncs_s;

// Plugin's GetEngineFunctions, called by metamod.
typedef int (*GET_ENGINE_FUNCTIONS_FN)(enginefuncs_s *pengfuncsFromEngine, int *interfaceVersion);
typedef int (*GET_ENGINE_FUNCTIONS_FN)(enginefuncs_s* pengfuncsFromEngine, int* interfaceVersion);

// According to SDK engine/eiface.h:
// ONLY ADD NEW FUNCTIONS TO THE END OF THIS STRUCT. INTERFACE VERSION IS FROZEN AT 138
Expand All @@ -12,10 +12,9 @@ typedef int (*GET_ENGINE_FUNCTIONS_FN)(enginefuncs_s *pengfuncsFromEngine, int *
// Protect against other projects which use this include file but use the
// normal enginefuncs_t type for their meta_engfuncs.
#ifdef METAMOD_CORE
#include "meta_eiface.h" // meta_enginefuncs_t
extern meta_enginefuncs_t g_meta_engfuncs;
extern enginefuncs_t g_meta_engfuncs;

void compile_engine_callbacks();
void compile_engine_callbacks();
#else
extern enginefuncs_t meta_engfuncs;
#endif
30 changes: 9 additions & 21 deletions AccuracyFix/include/metamod/enginecallbacks.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,27 +10,15 @@
// "hack" our way around that by using a flag METAMOD_CORE which is set
// when compiling Metamod proper.

#ifdef METAMOD_CORE
#include "meta_eiface.h" // HL_enginefuncs_t

// Use a #define to bend the enginefuncs_t type to our HL_enginefuncs_t
// type instead as we now use that for the global object g_engfuncs.
#define enginefuncs_t HL_enginefuncs_t
#endif

#include <enginecallback.h> // ALERT, etc

#ifdef METAMOD_CORE
#undef enginefuncs_t
#endif
#include <enginecallback.h> // ALERT, etc

// Also, create some additional macros for engine callback functions, which
// weren't in SDK dlls/enginecallbacks.h but probably should have been.
#define GET_INFOKEYBUFFER (*g_engfuncs.pfnGetInfoKeyBuffer)
#define INFOKEY_VALUE (*g_engfuncs.pfnInfoKeyValue)
#define SET_CLIENT_KEYVALUE (*g_engfuncs.pfnSetClientKeyValue)
#define REG_SVR_COMMAND (*g_engfuncs.pfnAddServerCommand)
#define SERVER_PRINT (*g_engfuncs.pfnServerPrint)
#define SET_SERVER_KEYVALUE (*g_engfuncs.pfnSetKeyValue)
#define QUERY_CLIENT_CVAR_VALUE (*g_engfuncs.pfnQueryClientCvarValue)
#define QUERY_CLIENT_CVAR_VALUE2 (*g_engfuncs.pfnQueryClientCvarValue2)
#define GET_INFOKEYBUFFER (*g_engfuncs.pfnGetInfoKeyBuffer)
#define INFOKEY_VALUE (*g_engfuncs.pfnInfoKeyValue)
#define SET_CLIENT_KEYVALUE (*g_engfuncs.pfnSetClientKeyValue)
#define REG_SVR_COMMAND (*g_engfuncs.pfnAddServerCommand)
#define SERVER_PRINT (*g_engfuncs.pfnServerPrint)
#define SET_SERVER_KEYVALUE (*g_engfuncs.pfnSetKeyValue)
#define QUERY_CLIENT_CVAR_VALUE (*g_engfuncs.pfnQueryClientCvarValue)
#define QUERY_CLIENT_CVAR_VALUE2 (*g_engfuncs.pfnQueryClientCvarValue2)
150 changes: 77 additions & 73 deletions AccuracyFix/include/metamod/meta_api.h
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#pragma once

#include "dllapi.h" // GETENTITYAPI_FN, etc
#include "engine_api.h" // GET_ENGINE_FUNCTIONS_FN, etc
#include "enginecallbacks.h"
#include "dllapi.h" // GETENTITYAPI_FN, etc
#include "h_export.h"
#include "plinfo.h" // plugin_info_t, etc
#include "engine_api.h" // GET_ENGINE_FUNCTIONS_FN, etc
#include "enginecallbacks.h"
#include "plinfo.h" // plugin_info_t, etc
#include "mutil.h"

// Version consists of "major:minor", two separate integer numbers.
Expand Down Expand Up @@ -33,20 +33,24 @@
enum META_RES
{
MRES_UNSET = 0,
MRES_IGNORED, // plugin didn't take any action
MRES_HANDLED, // plugin did something, but real function should still be called
MRES_OVERRIDE, // call real function, but use my return value
MRES_SUPERCEDE, // skip real function; use my return value
MRES_IGNORED, // plugin didn't take any action
MRES_HANDLED, // plugin did something, but real function should still be called
MRES_OVERRIDE, // call real function, but use my return value
MRES_SUPERCEDE, // skip real function; use my return value
};

// Variables provided to plugins.
struct meta_globals_t
{
META_RES mres; // writable; plugin's return flag
META_RES prev_mres; // readable; return flag of the previous plugin called
META_RES status; // readable; "highest" return flag so far
void *orig_ret; // readable; return value from "real" function
void *override_ret; // readable; return value from overriding/superceding plugin
META_RES mres; // writable; plugin's return flag
META_RES prev_mres; // readable; return flag of the previous plugin called
META_RES status; // readable; "highest" return flag so far
void *orig_ret; // readable; return value from "real" function
void *override_ret; // readable; return value from overriding/superceding plugin

#ifdef METAMOD_CORE
uint32* esp_save;
#endif
};

extern meta_globals_t *gpMetaGlobals;
Expand Down Expand Up @@ -98,16 +102,16 @@ typedef void (*META_INIT_FN)();
// Get info about plugin, compare meta_interface versions, provide meta
// utility callback functions.
C_DLLEXPORT int Meta_Query(char *interfaceVersion, plugin_info_t **plinfo, mutil_funcs_t *pMetaUtilFuncs);
typedef int (*META_QUERY_FN) (char *interfaceVersion, plugin_info_t **plinfo, mutil_funcs_t *pMetaUtilFuncs);
typedef int (*META_QUERY_FN)(char *interfaceVersion, plugin_info_t **plinfo, mutil_funcs_t *pMetaUtilFuncs);

// Attach the plugin to the API; get the table of getapi functions; give
// meta_globals and gamedll_funcs.
C_DLLEXPORT int Meta_Attach(PLUG_LOADTIME now, META_FUNCTIONS *pFunctionTable, meta_globals_t *pMGlobals, gamedll_funcs_t *pGamedllFuncs);
typedef int (*META_ATTACH_FN) (PLUG_LOADTIME now, META_FUNCTIONS *pFunctionTable, meta_globals_t *pMGlobals, gamedll_funcs_t *pGamedllFuncs);
typedef int (*META_ATTACH_FN)(PLUG_LOADTIME now, META_FUNCTIONS *pFunctionTable, meta_globals_t *pMGlobals, gamedll_funcs_t *pGamedllFuncs);

// Detach the plugin; tell why and when.
C_DLLEXPORT int Meta_Detach(PLUG_LOADTIME now, PL_UNLOAD_REASON reason);
typedef int (*META_DETACH_FN) (PLUG_LOADTIME now, PL_UNLOAD_REASON reason);
typedef int (*META_DETACH_FN)(PLUG_LOADTIME now, PL_UNLOAD_REASON reason);

// Standard HL SDK interface function prototypes.
C_DLLEXPORT int GetEntityAPI_Post(DLL_FUNCTIONS *pFunctionTable, int interfaceVersion );
Expand All @@ -123,63 +127,63 @@ C_DLLEXPORT int GetEngineFunctions_Post(enginefuncs_t *pengfuncsFromEngine, int
// the other plugins.

// DLL API functions:
#define MDLL_FUNC gpGamedllFuncs->dllapi_table

#define MDLL_GameDLLInit MDLL_FUNC->pfnGameInit
#define MDLL_Spawn MDLL_FUNC->pfnSpawn
#define MDLL_Think MDLL_FUNC->pfnThink
#define MDLL_Use MDLL_FUNC->pfnUse
#define MDLL_Touch MDLL_FUNC->pfnTouch
#define MDLL_Blocked MDLL_FUNC->pfnBlocked
#define MDLL_KeyValue MDLL_FUNC->pfnKeyValue
#define MDLL_Save MDLL_FUNC->pfnSave
#define MDLL_Restore MDLL_FUNC->pfnRestore
#define MDLL_ObjectCollsionBox MDLL_FUNC->pfnAbsBox
#define MDLL_SaveWriteFields MDLL_FUNC->pfnSaveWriteFields
#define MDLL_SaveReadFields MDLL_FUNC->pfnSaveReadFields
#define MDLL_SaveGlobalState MDLL_FUNC->pfnSaveGlobalState
#define MDLL_RestoreGlobalState MDLL_FUNC->pfnRestoreGlobalState
#define MDLL_ResetGlobalState MDLL_FUNC->pfnResetGlobalState
#define MDLL_ClientConnect MDLL_FUNC->pfnClientConnect
#define MDLL_ClientDisconnect MDLL_FUNC->pfnClientDisconnect
#define MDLL_ClientKill MDLL_FUNC->pfnClientKill
#define MDLL_ClientPutInServer MDLL_FUNC->pfnClientPutInServer
#define MDLL_ClientCommand MDLL_FUNC->pfnClientCommand
#define MDLL_ClientUserInfoChanged MDLL_FUNC->pfnClientUserInfoChanged
#define MDLL_ServerActivate MDLL_FUNC->pfnServerActivate
#define MDLL_ServerDeactivate MDLL_FUNC->pfnServerDeactivate
#define MDLL_PlayerPreThink MDLL_FUNC->pfnPlayerPreThink
#define MDLL_PlayerPostThink MDLL_FUNC->pfnPlayerPostThink
#define MDLL_StartFrame MDLL_FUNC->pfnStartFrame
#define MDLL_ParmsNewLevel MDLL_FUNC->pfnParmsNewLevel
#define MDLL_ParmsChangeLevel MDLL_FUNC->pfnParmsChangeLevel
#define MDLL_GetGameDescription MDLL_FUNC->pfnGetGameDescription
#define MDLL_PlayerCustomization MDLL_FUNC->pfnPlayerCustomization
#define MDLL_SpectatorConnect MDLL_FUNC->pfnSpectatorConnect
#define MDLL_SpectatorDisconnect MDLL_FUNC->pfnSpectatorDisconnect
#define MDLL_SpectatorThink MDLL_FUNC->pfnSpectatorThink
#define MDLL_Sys_Error MDLL_FUNC->pfnSys_Error
#define MDLL_PM_Move MDLL_FUNC->pfnPM_Move
#define MDLL_PM_Init MDLL_FUNC->pfnPM_Init
#define MDLL_PM_FindTextureType MDLL_FUNC->pfnPM_FindTextureType
#define MDLL_SetupVisibility MDLL_FUNC->pfnSetupVisibility
#define MDLL_UpdateClientData MDLL_FUNC->pfnUpdateClientData
#define MDLL_AddToFullPack MDLL_FUNC->pfnAddToFullPack
#define MDLL_CreateBaseline MDLL_FUNC->pfnCreateBaseline
#define MDLL_RegisterEncoders MDLL_FUNC->pfnRegisterEncoders
#define MDLL_GetWeaponData MDLL_FUNC->pfnGetWeaponData
#define MDLL_CmdStart MDLL_FUNC->pfnCmdStart
#define MDLL_CmdEnd MDLL_FUNC->pfnCmdEnd
#define MDLL_ConnectionlessPacket MDLL_FUNC->pfnConnectionlessPacket
#define MDLL_GetHullBounds MDLL_FUNC->pfnGetHullBounds
#define MDLL_CreateInstancedBaselines MDLL_FUNC->pfnCreateInstancedBaselines
#define MDLL_InconsistentFile MDLL_FUNC->pfnInconsistentFile
#define MDLL_AllowLagCompensation MDLL_FUNC->pfnAllowLagCompensation
#define MDLL_FUNC gpGamedllFuncs->dllapi_table

#define MDLL_GameDLLInit MDLL_FUNC->pfnGameInit
#define MDLL_Spawn MDLL_FUNC->pfnSpawn
#define MDLL_Think MDLL_FUNC->pfnThink
#define MDLL_Use MDLL_FUNC->pfnUse
#define MDLL_Touch MDLL_FUNC->pfnTouch
#define MDLL_Blocked MDLL_FUNC->pfnBlocked
#define MDLL_KeyValue MDLL_FUNC->pfnKeyValue
#define MDLL_Save MDLL_FUNC->pfnSave
#define MDLL_Restore MDLL_FUNC->pfnRestore
#define MDLL_ObjectCollsionBox MDLL_FUNC->pfnAbsBox
#define MDLL_SaveWriteFields MDLL_FUNC->pfnSaveWriteFields
#define MDLL_SaveReadFields MDLL_FUNC->pfnSaveReadFields
#define MDLL_SaveGlobalState MDLL_FUNC->pfnSaveGlobalState
#define MDLL_RestoreGlobalState MDLL_FUNC->pfnRestoreGlobalState
#define MDLL_ResetGlobalState MDLL_FUNC->pfnResetGlobalState
#define MDLL_ClientConnect MDLL_FUNC->pfnClientConnect
#define MDLL_ClientDisconnect MDLL_FUNC->pfnClientDisconnect
#define MDLL_ClientKill MDLL_FUNC->pfnClientKill
#define MDLL_ClientPutInServer MDLL_FUNC->pfnClientPutInServer
#define MDLL_ClientCommand MDLL_FUNC->pfnClientCommand
#define MDLL_ClientUserInfoChanged MDLL_FUNC->pfnClientUserInfoChanged
#define MDLL_ServerActivate MDLL_FUNC->pfnServerActivate
#define MDLL_ServerDeactivate MDLL_FUNC->pfnServerDeactivate
#define MDLL_PlayerPreThink MDLL_FUNC->pfnPlayerPreThink
#define MDLL_PlayerPostThink MDLL_FUNC->pfnPlayerPostThink
#define MDLL_StartFrame MDLL_FUNC->pfnStartFrame
#define MDLL_ParmsNewLevel MDLL_FUNC->pfnParmsNewLevel
#define MDLL_ParmsChangeLevel MDLL_FUNC->pfnParmsChangeLevel
#define MDLL_GetGameDescription MDLL_FUNC->pfnGetGameDescription
#define MDLL_PlayerCustomization MDLL_FUNC->pfnPlayerCustomization
#define MDLL_SpectatorConnect MDLL_FUNC->pfnSpectatorConnect
#define MDLL_SpectatorDisconnect MDLL_FUNC->pfnSpectatorDisconnect
#define MDLL_SpectatorThink MDLL_FUNC->pfnSpectatorThink
#define MDLL_Sys_Error MDLL_FUNC->pfnSys_Error
#define MDLL_PM_Move MDLL_FUNC->pfnPM_Move
#define MDLL_PM_Init MDLL_FUNC->pfnPM_Init
#define MDLL_PM_FindTextureType MDLL_FUNC->pfnPM_FindTextureType
#define MDLL_SetupVisibility MDLL_FUNC->pfnSetupVisibility
#define MDLL_UpdateClientData MDLL_FUNC->pfnUpdateClientData
#define MDLL_AddToFullPack MDLL_FUNC->pfnAddToFullPack
#define MDLL_CreateBaseline MDLL_FUNC->pfnCreateBaseline
#define MDLL_RegisterEncoders MDLL_FUNC->pfnRegisterEncoders
#define MDLL_GetWeaponData MDLL_FUNC->pfnGetWeaponData
#define MDLL_CmdStart MDLL_FUNC->pfnCmdStart
#define MDLL_CmdEnd MDLL_FUNC->pfnCmdEnd
#define MDLL_ConnectionlessPacket MDLL_FUNC->pfnConnectionlessPacket
#define MDLL_GetHullBounds MDLL_FUNC->pfnGetHullBounds
#define MDLL_CreateInstancedBaselines MDLL_FUNC->pfnCreateInstancedBaselines
#define MDLL_InconsistentFile MDLL_FUNC->pfnInconsistentFile
#define MDLL_AllowLagCompensation MDLL_FUNC->pfnAllowLagCompensation

// NEW API functions:
#define MNEW_FUNC gpGamedllFuncs->newapi_table
#define MNEW_FUNC gpGamedllFuncs->newapi_table

#define MNEW_OnFreeEntPrivateData MNEW_FUNC->pfnOnFreeEntPrivateData
#define MNEW_GameShutdown MNEW_FUNC->pfnGameShutdown
#define MNEW_ShouldCollide MNEW_FUNC->pfnShouldCollide
#define MNEW_CvarValue MNEW_FUNC->pfnCvarValue
#define MNEW_OnFreeEntPrivateData MNEW_FUNC->pfnOnFreeEntPrivateData
#define MNEW_GameShutdown MNEW_FUNC->pfnGameShutdown
#define MNEW_ShouldCollide MNEW_FUNC->pfnShouldCollide
#define MNEW_CvarValue MNEW_FUNC->pfnCvarValue
Loading

0 comments on commit e24c0f6

Please sign in to comment.