diff --git a/rehlds/engine/server.h b/rehlds/engine/server.h index 0c27b94..3a982a8 100644 --- a/rehlds/engine/server.h +++ b/rehlds/engine/server.h @@ -715,6 +715,7 @@ void SV_CreateResourceList(void); void SV_ClearCaches(void); void SV_PropagateCustomizations(void); void SV_WriteVoiceCodec(sizebuf_t *pBuf); +void SV_WriteVoiceCodec_internal(sizebuf_t *pBuf); void SV_CreateBaseline(void); void SV_BroadcastCommand(char *fmt, ...); void SV_BuildReconnect(sizebuf_t *msg); diff --git a/rehlds/engine/sv_main.cpp b/rehlds/engine/sv_main.cpp index ff7a094..bae6b38 100644 --- a/rehlds/engine/sv_main.cpp +++ b/rehlds/engine/sv_main.cpp @@ -5124,8 +5124,13 @@ void SV_PropagateCustomizations(void) } } -/* ../engine/sv_main.c:6850 */ void SV_WriteVoiceCodec(sizebuf_t *pBuf) +{ + g_RehldsHookchains.m_SV_WriteVoiceCodec.callChain(SV_WriteVoiceCodec_internal, pBuf); +} + +/* ../engine/sv_main.c:6850 */ +void EXT_FUNC SV_WriteVoiceCodec_internal(sizebuf_t *pBuf) { MSG_WriteByte(pBuf, svc_voiceinit); MSG_WriteString(pBuf, ""); diff --git a/rehlds/public/rehlds/rehlds_api.h b/rehlds/public/rehlds/rehlds_api.h index c9ee881..2857c5b 100644 --- a/rehlds/public/rehlds/rehlds_api.h +++ b/rehlds/public/rehlds/rehlds_api.h @@ -35,7 +35,7 @@ #include "model.h" #define REHLDS_API_VERSION_MAJOR 2 -#define REHLDS_API_VERSION_MINOR 2 +#define REHLDS_API_VERSION_MINOR 3 //Steam_NotifyClientConnect hook typedef IHookChain IRehldsHook_Steam_NotifyClientConnect; @@ -153,6 +153,10 @@ typedef IVoidHookChainRegistry IRehldsHookRegis typedef IVoidHookChain IRehldsHook_SV_ActivateServer; typedef IVoidHookChainRegistry IRehldsHookRegistry_SV_ActivateServer; +//SV_WriteVoiceCodec hook +typedef IVoidHookChain IRehldsHook_SV_WriteVoiceCodec; +typedef IVoidHookChainRegistry IRehldsHookRegistry_SV_WriteVoiceCodec; + class IRehldsHookchains { public: virtual ~IRehldsHookchains() { } @@ -186,6 +190,7 @@ public: virtual IRehldsHookRegistry_SV_CheckConsistencyResponse* SV_CheckConsistencyResponse() = 0; virtual IRehldsHookRegistry_SV_DropClient* SV_DropClient() = 0; virtual IRehldsHookRegistry_SV_ActivateServer* SV_ActivateServer() = 0; + virtual IRehldsHookRegistry_SV_WriteVoiceCodec* SV_WriteVoiceCodec() = 0; }; struct RehldsFuncs_t { @@ -222,6 +227,12 @@ struct RehldsFuncs_t { cvar_t*(*GetCvarVars)(); int (*SV_GetChallenge)(const netadr_t& adr); void (*SV_AddResource)(resourcetype_t type, const char *name, int size, unsigned char flags, int index); + int(*MSG_ReadShort)(void); + int(*MSG_ReadBuf)(int iSize, void *pbuf); + void(*MSG_WriteBuf)(sizebuf_t *sb, int iSize, void *buf); + void(*MSG_WriteByte)(sizebuf_t *sb, int c); + void(*MSG_WriteShort)(sizebuf_t *sb, int c); + void(*MSG_WriteString)(sizebuf_t *sb, const char *s); }; class IRehldsApi { diff --git a/rehlds/public/rehlds/rehlds_interfaces.h b/rehlds/public/rehlds/rehlds_interfaces.h index efcbd83..ea74dc3 100644 --- a/rehlds/public/rehlds/rehlds_interfaces.h +++ b/rehlds/public/rehlds/rehlds_interfaces.h @@ -67,6 +67,9 @@ public: virtual bool IsConnected() = 0; virtual void SetConnected(bool connected) = 0; + virtual uint32 GetVoiceStreams(int id) = 0; + virtual double GetLastVoiceTime() = 0; + virtual bool GetLoopback() = 0; // this must be the last virtual function in class #ifdef REHLDS_SELF @@ -117,4 +120,6 @@ public: virtual int GetConsistencyNum() = 0; virtual int GetResourcesNum() = 0; virtual int GetDecalNameNum() = 0; + + virtual double GetTime() = 0; }; diff --git a/rehlds/rehlds/rehlds_api_impl.cpp b/rehlds/rehlds/rehlds_api_impl.cpp index 624d8b5..8bb82e7 100644 --- a/rehlds/rehlds/rehlds_api_impl.cpp +++ b/rehlds/rehlds/rehlds_api_impl.cpp @@ -73,6 +73,30 @@ void EXT_FUNC MSG_WriteBits_api(uint32 data, int numbits) { MSG_WriteBits(data, numbits); } +int EXT_FUNC MSG_ReadShort_api() { + return MSG_ReadShort(); +} + +int EXT_FUNC MSG_ReadBuf_api(int iSize, void *pbuf) { + return MSG_ReadBuf(iSize, pbuf); +} + +void EXT_FUNC MSG_WriteBuf_api(sizebuf_t *sb, int iSize, void *buf) { + MSG_WriteBuf(sb, iSize, buf); +} + +void EXT_FUNC MSG_WriteByte_api(sizebuf_t *sb, int c) { + MSG_WriteByte(sb, c); +} + +void EXT_FUNC MSG_WriteShort_api(sizebuf_t *sb, int c) { + MSG_WriteShort(sb, c); +} + +void EXT_FUNC MSG_WriteString_api(sizebuf_t *sb, const char *s) { + MSG_WriteString(sb, s); +} + void EXT_FUNC MSG_WriteBitVec3Coord_api(const vec3_t fa) { MSG_WriteBitVec3Coord(fa); } @@ -122,7 +146,13 @@ RehldsFuncs_t g_RehldsApiFuncs = &SZ_GetSpace, &GetCvarVars_api, &SV_GetChallenge, - &SV_AddResource + &SV_AddResource, + &MSG_ReadShort_api, + &MSG_ReadBuf_api, + &MSG_WriteBuf_api, + &MSG_WriteByte_api, + &MSG_WriteShort_api, + &MSG_WriteString_api }; sizebuf_t* EXT_FUNC GetNetMessage_api() @@ -272,6 +302,10 @@ IRehldsHookRegistry_SV_ActivateServer* CRehldsHookchains::SV_ActivateServer() { return &m_SV_ActivateServer; } +IRehldsHookRegistry_SV_WriteVoiceCodec* CRehldsHookchains::SV_WriteVoiceCodec() { + return &m_SV_WriteVoiceCodec; +} + int EXT_FUNC CRehldsApi::GetMajorVersion() { return REHLDS_API_VERSION_MAJOR; diff --git a/rehlds/rehlds/rehlds_api_impl.h b/rehlds/rehlds/rehlds_api_impl.h index 298eed0..1bdc9f0 100644 --- a/rehlds/rehlds/rehlds_api_impl.h +++ b/rehlds/rehlds/rehlds_api_impl.h @@ -147,6 +147,10 @@ typedef IVoidHookChainRegistryImpl CRehldsHookR typedef IVoidHookChainImpl CRehldsHook_SV_ActivateServer; typedef IVoidHookChainRegistryImpl CRehldsHookRegistry_SV_ActivateServer; +//SV_WriteVoiceCodec hook +typedef IVoidHookChainImpl CRehldsHook_SV_WriteVoiceCodec; +typedef IVoidHookChainRegistryImpl CRehldsHookRegistry_SV_WriteVoiceCodec; + class CRehldsHookchains : public IRehldsHookchains { public: CRehldsHookRegistry_Steam_NotifyClientConnect m_Steam_NotifyClientConnect; @@ -178,6 +182,7 @@ public: CRehldsHookRegistry_SV_CheckConsistencyResponse m_SV_CheckConsistencyResponse; CRehldsHookRegistry_SV_DropClient m_SV_DropClient; CRehldsHookRegistry_SV_ActivateServer m_SV_ActivateServer; + CRehldsHookRegistry_SV_WriteVoiceCodec m_SV_WriteVoiceCodec; public: virtual IRehldsHookRegistry_Steam_NotifyClientConnect* Steam_NotifyClientConnect(); @@ -209,6 +214,7 @@ public: virtual IRehldsHookRegistry_SV_CheckConsistencyResponse* SV_CheckConsistencyResponse(); virtual IRehldsHookRegistry_SV_DropClient* SV_DropClient(); virtual IRehldsHookRegistry_SV_ActivateServer* SV_ActivateServer(); + virtual IRehldsHookRegistry_SV_WriteVoiceCodec* SV_WriteVoiceCodec(); }; extern CRehldsHookchains g_RehldsHookchains; diff --git a/rehlds/rehlds/rehlds_interfaces_impl.cpp b/rehlds/rehlds/rehlds_interfaces_impl.cpp index 9fc85cc..dc92a5d 100644 --- a/rehlds/rehlds/rehlds_interfaces_impl.cpp +++ b/rehlds/rehlds/rehlds_interfaces_impl.cpp @@ -63,13 +63,25 @@ void EXT_FUNC CGameClient::SetSpawned(bool spawned) } bool EXT_FUNC CGameClient::IsConnected() { - return m_pClient->connected != 0;; + return m_pClient->connected != 0; } void EXT_FUNC CGameClient::SetConnected(bool connected) { m_pClient->connected = connected ? 1 : 0; } +uint32 EXT_FUNC CGameClient::GetVoiceStreams(int id) { + return m_pClient->m_VoiceStreams[id >> 5]; +} + +double EXT_FUNC CGameClient::GetLastVoiceTime() { + return m_pClient->m_lastvoicetime; +} + +bool EXT_FUNC CGameClient::GetLoopback() { + return m_pClient->m_bLoopback != 0; +} + INetChan* EXT_FUNC CGameClient::GetNetChan() { return &m_NetChan; @@ -207,6 +219,10 @@ int EXT_FUNC CRehldsServerData::GetDecalNameNum() { return sv_decalnamecount; } +double EXT_FUNC CRehldsServerData::GetTime() { + return g_psv.time; +} + void Rehlds_Interfaces_FreeClients() { if (g_GameClients == NULL) diff --git a/rehlds/rehlds/rehlds_interfaces_impl.h b/rehlds/rehlds/rehlds_interfaces_impl.h index 61da653..e4543a5 100644 --- a/rehlds/rehlds/rehlds_interfaces_impl.h +++ b/rehlds/rehlds/rehlds_interfaces_impl.h @@ -76,6 +76,9 @@ public: virtual bool IsConnected(); virtual void SetConnected(bool connected); + virtual uint32 GetVoiceStreams(int id); + virtual double GetLastVoiceTime(); + virtual bool GetLoopback(); virtual client_t* GetClient(); }; @@ -103,6 +106,8 @@ public: virtual int GetConsistencyNum(); virtual int GetResourcesNum(); virtual int GetDecalNameNum(); + + virtual double GetTime(); }; extern CGameClient** g_GameClients;