Skip to content

Commit

Permalink
Add MetaHookAPIVersion.
Browse files Browse the repository at this point in the history
  • Loading branch information
hzqst committed Jan 25, 2024
1 parent be1dc77 commit 5d5b2db
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 8 deletions.
6 changes: 6 additions & 0 deletions Plugins/ThreadGuard/plugins.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ void IPluginsV4::Shutdown(void)

void IPluginsV4::LoadEngine(cl_enginefunc_t *pEngfuncs)
{
if (g_pInterface->MetaHookAPIVersion < METAHOOK_API_VERSION)
{
g_pMetaHookAPI->SysError("MetaHookAPIVersion too low! expect %d, got %d !", METAHOOK_API_VERSION, g_pInterface->MetaHookAPIVersion);
return;
}

g_pFileSystem = g_pInterface->FileSystem;
g_iEngineType = g_pMetaHookAPI->GetEngineType();
g_dwEngineBuildnum = g_pMetaHookAPI->GetEngineBuildnum();
Expand Down
16 changes: 8 additions & 8 deletions include/HLSDK/common/command.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ typedef struct cmd_function_s
char *name;
xcommand_t function;
int flags;
}
cmd_function_t;
}cmd_function_t;

extern cmd_function_t *(*Cmd_GetCmdBase)(void);

cmd_function_t *Cmd_FindCmd(char *cmd_name);
xcommand_t Cmd_HookCmd(char *cmd_name, xcommand_t newfuncs);
cmd_function_t *Cmd_FindCmdPrev(char *cmd_name);
char *Cmd_CompleteCommand(char *partial, qboolean next);
#if 0
extern cmd_function_t* (*Cmd_GetCmdBase)(void);
cmd_function_t *Cmd_FindCmd(const char *cmd_name);
xcommand_t Cmd_HookCmd(const char *cmd_name, xcommand_t newfuncs);
cmd_function_t *Cmd_FindCmdPrev(const char *cmd_name);
char *Cmd_CompleteCommand(const char *partial, qboolean next);
#endif

#endif
8 changes: 8 additions & 0 deletions include/metahook.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ typedef int (*pfnUserMsgHook)(const char *pszName, int iSize, void *pbuf);

typedef void(*cvar_callback_t)(cvar_t *pcvar);

#ifndef __HLSDK_COMMAND__
#define __HLSDK_COMMAND__

typedef void(*xcommand_t)(void);

typedef struct cmd_function_s
Expand All @@ -42,6 +45,8 @@ typedef struct mh_plugininfo_s
size_t PluginModuleSize;
}mh_plugininfo_t;

#endif

#include <cdll_export.h>
#include <cdll_int.h>

Expand Down Expand Up @@ -427,12 +432,15 @@ void MH_Shutdown(void);
#include <ICommandLine.h>
#include <IRegistry.h>

#define METAHOOK_API_VERSION 100

typedef struct mh_interface_s
{
ICommandLine *CommandLine;
IFileSystem *FileSystem;
IRegistry *Registry;
IFileSystem_HL25* FileSystem_HL25;
int MetaHookAPIVersion;
}mh_interface_t;

#include <IPlugins.h>
Expand Down
1 change: 1 addition & 0 deletions src/metahook.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1035,6 +1035,7 @@ void MH_LoadEngine(HMODULE hEngineModule, BlobHandle_t hBlobEngine, const char*
gInterface.FileSystem = g_pFileSystem;
gInterface.Registry = registry;
gInterface.FileSystem_HL25 = g_pFileSystem_HL25;
gInterface.MetaHookAPIVersion = METAHOOK_API_VERSION;

if (hEngineModule)
{
Expand Down

0 comments on commit 5d5b2db

Please sign in to comment.