2
0
mirror of https://github.com/rehlds/rehlds.git synced 2025-04-24 07:13:38 +03:00

Implement Con_Printf() hook (#861)

* Implement Con_Printf hook

* update REHLDS_API_VERSION_MINOR

* Update rehlds_api.h

* Update version.h

* Apply suggestions from code review

Co-authored-by: Sergey Shorokhov <wopox1337@ya.ru>
This commit is contained in:
Franco Romaniello 2021-10-24 13:28:40 +02:00 committed by GitHub
parent c86849ef63
commit 471158b1d9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 23 additions and 2 deletions

View File

@ -1318,7 +1318,7 @@ void Con_DebugLog(const char *file, const char *fmt, ...)
#endif // _WIN32 #endif // _WIN32
} }
void EXT_FUNC Con_Printf(const char *fmt, ...) void Con_Printf(const char *fmt, ...)
{ {
char Dest[4096]; char Dest[4096];
va_list va; va_list va;
@ -1327,6 +1327,11 @@ void EXT_FUNC Con_Printf(const char *fmt, ...)
Q_vsnprintf(Dest, sizeof(Dest), fmt, va); Q_vsnprintf(Dest, sizeof(Dest), fmt, va);
va_end(va); va_end(va);
g_RehldsHookchains.m_Con_Printf.callChain(Con_Printf_internal, Dest);
}
void EXT_FUNC Con_Printf_internal(const char *Dest)
{
#ifdef REHLDS_FLIGHT_REC #ifdef REHLDS_FLIGHT_REC
FR_Log("REHLDS_CON", Dest); FR_Log("REHLDS_CON", Dest);
#endif #endif

View File

@ -135,5 +135,6 @@ void Con_Debug_f(void);
void Con_Init(void); void Con_Init(void);
void Con_DebugLog(const char *file, const char *fmt, ...); void Con_DebugLog(const char *file, const char *fmt, ...);
void Con_Printf(const char *fmt, ...); void Con_Printf(const char *fmt, ...);
void Con_Printf_internal(const char *Dest);
void Con_SafePrintf(const char *fmt, ...); void Con_SafePrintf(const char *fmt, ...);
void Con_DPrintf(const char *fmt, ...); void Con_DPrintf(const char *fmt, ...);

View File

@ -223,6 +223,10 @@ typedef IHookChainRegistry<edict_t *> IRehldsHookRegistry_ED_Alloc;
typedef IVoidHookChain<edict_t *> IRehldsHook_ED_Free; typedef IVoidHookChain<edict_t *> IRehldsHook_ED_Free;
typedef IVoidHookChainRegistry<edict_t *> IRehldsHookRegistry_ED_Free; typedef IVoidHookChainRegistry<edict_t *> IRehldsHookRegistry_ED_Free;
//Con_Printf hook
typedef IHookChain<void, const char *> IRehldsHook_Con_Printf;
typedef IHookChainRegistry<void, const char *> IRehldsHookRegistry_Con_Printf;
class IRehldsHookchains { class IRehldsHookchains {
public: public:
@ -274,6 +278,7 @@ public:
virtual IRehldsHookRegistry_SV_EmitPings* SV_EmitPings() = 0; virtual IRehldsHookRegistry_SV_EmitPings* SV_EmitPings() = 0;
virtual IRehldsHookRegistry_ED_Alloc* ED_Alloc() = 0; virtual IRehldsHookRegistry_ED_Alloc* ED_Alloc() = 0;
virtual IRehldsHookRegistry_ED_Free* ED_Free() = 0; virtual IRehldsHookRegistry_ED_Free* ED_Free() = 0;
virtual IRehldsHookRegistry_Con_Printf* Con_Printf() = 0;
}; };
struct RehldsFuncs_t { struct RehldsFuncs_t {

View File

@ -847,6 +847,10 @@ IRehldsHookRegistry_ED_Free* CRehldsHookchains::ED_Free() {
return &m_ED_Free; return &m_ED_Free;
} }
IRehldsHookRegistry_Con_Printf* CRehldsHookchains::Con_Printf() {
return &m_Con_Printf;
}
int EXT_FUNC CRehldsApi::GetMajorVersion() int EXT_FUNC CRehldsApi::GetMajorVersion()
{ {
return REHLDS_API_VERSION_MAJOR; return REHLDS_API_VERSION_MAJOR;

View File

@ -218,6 +218,10 @@ typedef IHookChainRegistryImpl<edict_t *> CRehldsHookRegistry_ED_Alloc;
typedef IVoidHookChainImpl<edict_t *> CRehldsHook_ED_Free; typedef IVoidHookChainImpl<edict_t *> CRehldsHook_ED_Free;
typedef IVoidHookChainRegistryImpl<edict_t *> CRehldsHookRegistry_ED_Free; typedef IVoidHookChainRegistryImpl<edict_t *> CRehldsHookRegistry_ED_Free;
//Con_Printf hook
typedef IHookChainImpl<void, const char *> CRehldsHook_Con_Printf;
typedef IHookChainRegistryImpl<void, const char *> CRehldsHookRegistry_Con_Printf;
class CRehldsHookchains : public IRehldsHookchains { class CRehldsHookchains : public IRehldsHookchains {
public: public:
CRehldsHookRegistry_Steam_NotifyClientConnect m_Steam_NotifyClientConnect; CRehldsHookRegistry_Steam_NotifyClientConnect m_Steam_NotifyClientConnect;
@ -266,6 +270,7 @@ public:
CRehldsHookRegistry_SV_EmitPings m_SV_EmitPings; CRehldsHookRegistry_SV_EmitPings m_SV_EmitPings;
CRehldsHookRegistry_ED_Alloc m_ED_Alloc; CRehldsHookRegistry_ED_Alloc m_ED_Alloc;
CRehldsHookRegistry_ED_Free m_ED_Free; CRehldsHookRegistry_ED_Free m_ED_Free;
CRehldsHookRegistry_Con_Printf m_Con_Printf;
public: public:
EXT_FUNC virtual IRehldsHookRegistry_Steam_NotifyClientConnect* Steam_NotifyClientConnect(); EXT_FUNC virtual IRehldsHookRegistry_Steam_NotifyClientConnect* Steam_NotifyClientConnect();
@ -314,6 +319,7 @@ public:
EXT_FUNC virtual IRehldsHookRegistry_SV_EmitPings* SV_EmitPings(); EXT_FUNC virtual IRehldsHookRegistry_SV_EmitPings* SV_EmitPings();
EXT_FUNC virtual IRehldsHookRegistry_ED_Alloc* ED_Alloc(); EXT_FUNC virtual IRehldsHookRegistry_ED_Alloc* ED_Alloc();
EXT_FUNC virtual IRehldsHookRegistry_ED_Free* ED_Free(); EXT_FUNC virtual IRehldsHookRegistry_ED_Free* ED_Free();
EXT_FUNC virtual IRehldsHookRegistry_Con_Printf* Con_Printf();
}; };
extern CRehldsHookchains g_RehldsHookchains; extern CRehldsHookchains g_RehldsHookchains;

View File

@ -6,5 +6,5 @@
#pragma once #pragma once
#define VERSION_MAJOR 3 #define VERSION_MAJOR 3
#define VERSION_MINOR 10 #define VERSION_MINOR 11
#define VERSION_MAINTENANCE 0 #define VERSION_MAINTENANCE 0