2
0
mirror of https://github.com/rehlds/rehlds.git synced 2025-01-04 02:55:50 +03:00

ReHLDS API: Added interceptor for string commands handled by the engine

Mark rehlds_syserror() as noreturn
Added missing includes in ReHLDS API
This commit is contained in:
dreamstalker 2015-06-23 00:15:27 +04:00
parent f5a9f2e413
commit 90f24f0413
8 changed files with 43 additions and 18 deletions

View File

@ -944,21 +944,7 @@ bool ValidateCmd_API(const char* cmd, cmd_source_t src, IGameClient* client) {
return true; return true;
} }
/* <5d4e> ../engine/cmd.c:1133 */ void Cmd_ExecuteString_internal(const char* cmdName, cmd_source_t src, IGameClient* client) {
void Cmd_ExecuteString(char *text, cmd_source_t src)
{
cmd_source = src;
Cmd_TokenizeString(text);
if (!Cmd_Argc())
{
return;
}
IGameClient* cl = (src == src_client) ? GetRehldsApiClient(host_client) : NULL;
if (!g_RehldsHookchains.m_ValidateCommand.callChain(ValidateCmd_API, cmd_argv[0], src, cl))
return;
// Search in functions // Search in functions
cmd_function_t *cmd = cmd_functions; cmd_function_t *cmd = cmd_functions;
while (cmd) while (cmd)
@ -984,7 +970,7 @@ void Cmd_ExecuteString(char *text, cmd_source_t src)
{ {
if (!Q_stricmp(cmd_argv[0], a->name)) if (!Q_stricmp(cmd_argv[0], a->name))
{ {
Cbuf_InsertText(a->value); Cbuf_InsertText(a->value);
return; return;
} }
@ -1000,6 +986,24 @@ void Cmd_ExecuteString(char *text, cmd_source_t src)
} }
} }
/* <5d4e> ../engine/cmd.c:1133 */
void Cmd_ExecuteString(char *text, cmd_source_t src)
{
cmd_source = src;
Cmd_TokenizeString(text);
if (!Cmd_Argc())
{
return;
}
IGameClient* cl = (src == src_client) ? GetRehldsApiClient(host_client) : NULL;
if (!g_RehldsHookchains.m_ValidateCommand.callChain(ValidateCmd_API, cmd_argv[0], src, cl))
return;
g_RehldsHookchains.m_ExecuteServerStringCmd.callChain(Cmd_ExecuteString_internal, cmd_argv[0], src, cl);
}
/* <5c15> ../engine/cmd.c:1181 */ /* <5c15> ../engine/cmd.c:1181 */
qboolean Cmd_ForwardToServerInternal(sizebuf_t *pBuf) qboolean Cmd_ForwardToServerInternal(sizebuf_t *pBuf)
{ {

View File

@ -175,6 +175,6 @@
static const bool __isLinux = true; static const bool __isLinux = true;
#endif #endif
extern void rehlds_syserror(const char* fmt, ...); extern void __declspec(noreturn) rehlds_syserror(const char* fmt, ...);
#endif // _OSCONFIG_H #endif // _OSCONFIG_H

View File

@ -97,6 +97,10 @@ typedef IHookChainRegistry<bool, uint8*, unsigned int, const netadr_t&> IRehldsH
typedef IHookChain<bool, const char*, cmd_source_t, IGameClient*> IRehldsHook_ValidateCommand; typedef IHookChain<bool, const char*, cmd_source_t, IGameClient*> IRehldsHook_ValidateCommand;
typedef IHookChainRegistry<bool, const char*, cmd_source_t, IGameClient*> IRehldsHookRegistry_ValidateCommand; typedef IHookChainRegistry<bool, const char*, cmd_source_t, IGameClient*> IRehldsHookRegistry_ValidateCommand;
//ExecuteServerStringCmd
typedef IVoidHookChain<const char*, cmd_source_t, IGameClient*> IRehldsHook_ExecuteServerStringCmd;
typedef IVoidHookChainRegistry<const char*, cmd_source_t, IGameClient*> IRehldsHookRegistry_ExecuteServerStringCmd;
//ClientConnected //ClientConnected
typedef IVoidHookChain<IGameClient*> IRehldsHook_ClientConnected; typedef IVoidHookChain<IGameClient*> IRehldsHook_ClientConnected;
typedef IVoidHookChainRegistry<IGameClient*> IRehldsHookRegistry_ClientConnected; typedef IVoidHookChainRegistry<IGameClient*> IRehldsHookRegistry_ClientConnected;
@ -136,6 +140,7 @@ public:
virtual IRehldsHookRegistry_HandleNetCommand* HandleNetCommand() = 0; virtual IRehldsHookRegistry_HandleNetCommand* HandleNetCommand() = 0;
virtual IRehldsHookRegistry_Mod_LoadBrushModel* Mod_LoadBrushModel() = 0; virtual IRehldsHookRegistry_Mod_LoadBrushModel* Mod_LoadBrushModel() = 0;
virtual IRehldsHookRegistry_Mod_LoadStudioModel* Mod_LoadStudioModel() = 0; virtual IRehldsHookRegistry_Mod_LoadStudioModel* Mod_LoadStudioModel() = 0;
virtual IRehldsHookRegistry_ExecuteServerStringCmd* ExecuteServerStringCmd() = 0;
}; };
struct RehldsFuncs_t { struct RehldsFuncs_t {

View File

@ -27,6 +27,10 @@
*/ */
#include "sys_shared.h" #include "sys_shared.h"
#if defined(__GNUC__)
#include <cpuid.h>
#endif
#define SSE3_FLAG (1<<0) #define SSE3_FLAG (1<<0)
#define SSSE3_FLAG (1<<9) #define SSSE3_FLAG (1<<9)
#define SSE4_1_FLAG (1<<19) #define SSE4_1_FLAG (1<<19)

View File

@ -27,6 +27,8 @@
*/ */
#pragma once #pragma once
#include <archtypes.h>
typedef struct cpuinfo_s typedef struct cpuinfo_s
{ {
uint8 sse3, ssse3, sse4_1, sse4_2, avx, avx2; uint8 sse3, ssse3, sse4_1, sse4_2, avx, avx2;

View File

@ -191,7 +191,7 @@ void CSimplePlatform::SteamAPI_UnregisterCallback(CCallbackBase *pCallback)
::SteamAPI_UnregisterCallback(pCallback); ::SteamAPI_UnregisterCallback(pCallback);
} }
void rehlds_syserror(const char* fmt, ...) { void __declspec(noreturn) rehlds_syserror(const char* fmt, ...) {
va_list argptr; va_list argptr;
static char string[8192]; static char string[8192];

View File

@ -185,6 +185,10 @@ IRehldsHookRegistry_Mod_LoadStudioModel* CRehldsHookchains::Mod_LoadStudioModel(
return &m_Mod_LoadStudioModel; return &m_Mod_LoadStudioModel;
} }
IRehldsHookRegistry_ExecuteServerStringCmd* CRehldsHookchains::ExecuteServerStringCmd() {
return &m_ExecuteServerStringCmd;
}
int CRehldsApi::GetMajorVersion() int CRehldsApi::GetMajorVersion()
{ {
return REHLDS_API_VERSION_MAJOR; return REHLDS_API_VERSION_MAJOR;

View File

@ -91,6 +91,10 @@ typedef IHookChainRegistryImpl<bool, uint8*, unsigned int, const netadr_t&> CReh
typedef IHookChainImpl<bool, const char*, cmd_source_t, IGameClient*> CRehldsHook_ValidateCommand; typedef IHookChainImpl<bool, const char*, cmd_source_t, IGameClient*> CRehldsHook_ValidateCommand;
typedef IHookChainRegistryImpl<bool, const char*, cmd_source_t, IGameClient*> CRehldsHookRegistry_ValidateCommand; typedef IHookChainRegistryImpl<bool, const char*, cmd_source_t, IGameClient*> CRehldsHookRegistry_ValidateCommand;
//ExecuteServerStringCmd
typedef IVoidHookChainImpl<const char*, cmd_source_t, IGameClient*> CRehldsHook_ExecuteServerStringCmd;
typedef IVoidHookChainRegistryImpl<const char*, cmd_source_t, IGameClient*> CRehldsHookRegistry_ExecuteServerStringCmd;
//ClientConnected //ClientConnected
typedef IVoidHookChainImpl<IGameClient*> CRehldsHook_ClientConnected; typedef IVoidHookChainImpl<IGameClient*> CRehldsHook_ClientConnected;
typedef IVoidHookChainRegistryImpl<IGameClient*> CRehldsHookRegistry_ClientConnected; typedef IVoidHookChainRegistryImpl<IGameClient*> CRehldsHookRegistry_ClientConnected;
@ -128,6 +132,7 @@ public:
CRehldsHookRegistry_HandleNetCommand m_HandleNetCommand; CRehldsHookRegistry_HandleNetCommand m_HandleNetCommand;
CRehldsHookRegistry_Mod_LoadBrushModel m_Mod_LoadBrushModel; CRehldsHookRegistry_Mod_LoadBrushModel m_Mod_LoadBrushModel;
CRehldsHookRegistry_Mod_LoadStudioModel m_Mod_LoadStudioModel; CRehldsHookRegistry_Mod_LoadStudioModel m_Mod_LoadStudioModel;
CRehldsHookRegistry_ExecuteServerStringCmd m_ExecuteServerStringCmd;
public: public:
virtual IRehldsHookRegistry_Steam_NotifyClientConnect* Steam_NotifyClientConnect(); virtual IRehldsHookRegistry_Steam_NotifyClientConnect* Steam_NotifyClientConnect();
@ -149,6 +154,7 @@ public:
virtual IRehldsHookRegistry_HandleNetCommand* HandleNetCommand(); virtual IRehldsHookRegistry_HandleNetCommand* HandleNetCommand();
virtual IRehldsHookRegistry_Mod_LoadBrushModel* Mod_LoadBrushModel(); virtual IRehldsHookRegistry_Mod_LoadBrushModel* Mod_LoadBrushModel();
virtual IRehldsHookRegistry_Mod_LoadStudioModel* Mod_LoadStudioModel(); virtual IRehldsHookRegistry_Mod_LoadStudioModel* Mod_LoadStudioModel();
virtual IRehldsHookRegistry_ExecuteServerStringCmd* ExecuteServerStringCmd();
}; };
extern CRehldsHookchains g_RehldsHookchains; extern CRehldsHookchains g_RehldsHookchains;