Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Con_Printf() hook #861

Merged
merged 7 commits into from
Oct 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion rehlds/engine/sys_dll.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1318,15 +1318,20 @@ void Con_DebugLog(const char *file, const char *fmt, ...)
#endif // _WIN32
}

void EXT_FUNC Con_Printf(const char *fmt, ...)
void Con_Printf(const char *fmt, ...)
{
char Dest[4096];
va_list va;

va_start(va, fmt);
Q_vsnprintf(Dest, sizeof(Dest), fmt, 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
FR_Log("REHLDS_CON", Dest);
#endif
Expand Down
1 change: 1 addition & 0 deletions rehlds/engine/sys_dll.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,5 +135,6 @@ void Con_Debug_f(void);
void Con_Init(void);
void Con_DebugLog(const char *file, const char *fmt, ...);
void Con_Printf(const char *fmt, ...);
void Con_Printf_internal(const char *Dest);
void Con_SafePrintf(const char *fmt, ...);
void Con_DPrintf(const char *fmt, ...);
5 changes: 5 additions & 0 deletions rehlds/public/rehlds/rehlds_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,10 @@ typedef IHookChainRegistry<edict_t *> IRehldsHookRegistry_ED_Alloc;
typedef IVoidHookChain<edict_t *> IRehldsHook_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 {
public:
Expand Down Expand Up @@ -274,6 +278,7 @@ class IRehldsHookchains {
virtual IRehldsHookRegistry_SV_EmitPings* SV_EmitPings() = 0;
virtual IRehldsHookRegistry_ED_Alloc* ED_Alloc() = 0;
virtual IRehldsHookRegistry_ED_Free* ED_Free() = 0;
virtual IRehldsHookRegistry_Con_Printf* Con_Printf() = 0;
};

struct RehldsFuncs_t {
Expand Down
4 changes: 4 additions & 0 deletions rehlds/rehlds/rehlds_api_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -847,6 +847,10 @@ IRehldsHookRegistry_ED_Free* CRehldsHookchains::ED_Free() {
return &m_ED_Free;
}

IRehldsHookRegistry_Con_Printf* CRehldsHookchains::Con_Printf() {
return &m_Con_Printf;
}

int EXT_FUNC CRehldsApi::GetMajorVersion()
{
return REHLDS_API_VERSION_MAJOR;
Expand Down
6 changes: 6 additions & 0 deletions rehlds/rehlds/rehlds_api_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,10 @@ typedef IHookChainRegistryImpl<edict_t *> CRehldsHookRegistry_ED_Alloc;
typedef IVoidHookChainImpl<edict_t *> CRehldsHook_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 {
public:
CRehldsHookRegistry_Steam_NotifyClientConnect m_Steam_NotifyClientConnect;
Expand Down Expand Up @@ -266,6 +270,7 @@ class CRehldsHookchains : public IRehldsHookchains {
CRehldsHookRegistry_SV_EmitPings m_SV_EmitPings;
CRehldsHookRegistry_ED_Alloc m_ED_Alloc;
CRehldsHookRegistry_ED_Free m_ED_Free;
CRehldsHookRegistry_Con_Printf m_Con_Printf;

public:
EXT_FUNC virtual IRehldsHookRegistry_Steam_NotifyClientConnect* Steam_NotifyClientConnect();
Expand Down Expand Up @@ -314,6 +319,7 @@ class CRehldsHookchains : public IRehldsHookchains {
EXT_FUNC virtual IRehldsHookRegistry_SV_EmitPings* SV_EmitPings();
EXT_FUNC virtual IRehldsHookRegistry_ED_Alloc* ED_Alloc();
EXT_FUNC virtual IRehldsHookRegistry_ED_Free* ED_Free();
EXT_FUNC virtual IRehldsHookRegistry_Con_Printf* Con_Printf();
};

extern CRehldsHookchains g_RehldsHookchains;
Expand Down
2 changes: 1 addition & 1 deletion rehlds/version/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
#pragma once

#define VERSION_MAJOR 3
#define VERSION_MINOR 10
#define VERSION_MINOR 11
#define VERSION_MAINTENANCE 0