diff --git a/extension.h b/extension.h index fa35dad..e0cbd25 100644 --- a/extension.h +++ b/extension.h @@ -47,7 +47,11 @@ #include "ihltv.h" #include "iserver.h" #include "iclient.h" -#include "ihltvdemorecorder.h" +#if SOURCE_ENGINE == SE_CSGO +# include "ihltvdemorecorder_csgo.h" +#else +# include "ihltvdemorecorder.h" +#endif #include "igameevents.h" #include "inetmessage.h" #include "netadr.h" diff --git a/forwards.cpp b/forwards.cpp index 8e774c0..270ec37 100644 --- a/forwards.cpp +++ b/forwards.cpp @@ -463,17 +463,15 @@ void CForwardManager::CallOnStopRecording(IDemoRecorder *recorder) if (!recorder->IsRecording()) return; - -#if SOURCE_ENGINE == SE_CSGO - char *pDemoFile = (char *)recorder->GetDemoFile() + 4; -#else - char *pDemoFile = (char *)recorder->GetDemoFile(); -#endif HLTVServerWrapper *wrapper = g_HLTVServers.GetWrapper(recorder); int instance = -1; + char *pDemoFile = ""; if (wrapper) + { instance = wrapper->GetInstanceNumber(); + pDemoFile = wrapper->GetDemoFileName(); + } m_StopRecordingFwd->PushCell(instance); m_StopRecordingFwd->PushString(pDemoFile); diff --git a/hltvserverwrapper.cpp b/hltvserverwrapper.cpp index 4c6ad2d..4447707 100644 --- a/hltvserverwrapper.cpp +++ b/hltvserverwrapper.cpp @@ -67,6 +67,18 @@ IDemoRecorder *HLTVServerWrapper::GetDemoRecorder() return m_DemoRecorder; } +char *HLTVServerWrapper::GetDemoFileName() +{ + if (!m_DemoRecorder) + return nullptr; + +#if SOURCE_ENGINE == SE_CSGO + return (char *)m_DemoRecorder + 8; +#else + return (char *)m_DemoRecorder->GetDemoFile(); +#endif +} + int HLTVServerWrapper::GetInstanceNumber() { return g_HLTVServers.GetInstanceNumber(m_HLTVServer); diff --git a/hltvserverwrapper.h b/hltvserverwrapper.h index 0b73d6d..5482fa0 100644 --- a/hltvserverwrapper.h +++ b/hltvserverwrapper.h @@ -44,6 +44,7 @@ public: IHLTVServer *GetHLTVServer(); IServer *GetBaseServer(); IDemoRecorder *GetDemoRecorder(); + char *GetDemoFileName(); HLTVClientWrapper *GetClient(int index); int GetInstanceNumber(); diff --git a/ihltvdemorecorder.h b/ihltvdemorecorder.h index e0be508..8b95a4a 100644 --- a/ihltvdemorecorder.h +++ b/ihltvdemorecorder.h @@ -5,7 +5,6 @@ class CDemoFile; class bf_read; class ServerClass; -class CGameInfo; class IDemoRecorder { @@ -19,21 +18,14 @@ public: virtual bool IsRecording(void) = 0; virtual void PauseRecording(void) = 0; virtual void ResumeRecording(void) = 0; -#if SOURCE_ENGINE == SE_CSGO - virtual void StopRecording(CGameInfo const *info) = 0; -#else virtual void StopRecording(void) = 0; -#endif virtual void RecordCommand(const char *cmdstring) = 0; virtual void RecordUserInput(int cmdnumber) = 0; virtual void RecordMessages(bf_read &data, int bits) = 0; virtual void RecordPacket(void) = 0; virtual void RecordServerClasses(ServerClass *pClasses) = 0; - virtual void RecordStringTables(void); -#if SOURCE_ENGINE == SE_CSGO - virtual void RecordCustomData(int, void const *, unsigned int); -#endif + virtual void RecordStringTables(void) = 0; virtual void ResetDemoInterpolation(void) = 0; }; diff --git a/ihltvdemorecorder_csgo.h b/ihltvdemorecorder_csgo.h new file mode 100644 index 0000000..ac028be --- /dev/null +++ b/ihltvdemorecorder_csgo.h @@ -0,0 +1,26 @@ +#ifndef _INCLUDE_DEMORECORDER_H +#define _INCLUDE_DEMORECORDER_H + + +class bf_read; +class ServerClass; +class CGameInfo; + +class IDemoRecorder +{ +public: + + virtual void SetSignonState(int state) = 0; + virtual void RecordServerClasses(ServerClass *pClasses) = 0; + virtual void RecordMessages(bf_read &data, int bits) = 0; + virtual void RecordPacket(void) = 0; + virtual void RecordCommand(const char *cmdstring) = 0; + virtual void RecordUserInput(int cmdnumber) = 0; + virtual void RecordCustomData(int, void const *, unsigned int) = 0; + virtual void ResetDemoInterpolation(void) = 0; + virtual void StartRecording(const char *filename, bool bContinuously) = 0; + virtual void StopRecording(CGameInfo const *info) = 0; + virtual bool IsRecording(void) = 0; + virtual int GetRecordingTick(void) = 0; +}; +#endif diff --git a/natives.cpp b/natives.cpp index bc943c0..231dc8f 100644 --- a/natives.cpp +++ b/natives.cpp @@ -555,11 +555,7 @@ static cell_t Native_GetDemoFileName(IPluginContext *pContext, const cell_t *par if (!hltvserver->GetDemoRecorder()->IsRecording()) return 0; -#if SOURCE_ENGINE == SE_CSGO - char *pDemoFile = (char *)hltvserver->GetDemoRecorder()->GetDemoFile() + 4; -#else - char *pDemoFile = (char *)hltvserver->GetDemoRecorder()->GetDemoFile(); -#endif + char *pDemoFile = hltvserver->GetDemoFileName(); if (!pDemoFile) return 0; diff --git a/sourcetvmanager.games.txt b/sourcetvmanager.games.txt index 21b351e..18846fe 100644 --- a/sourcetvmanager.games.txt +++ b/sourcetvmanager.games.txt @@ -114,7 +114,7 @@ { "library" "engine" "linux" "@_ZN11CHLTVServer24GetRecordingDemoFilenameEv" - "windows" "\x8B\x81\x2A\x2A\x2A\x2A\x81\xC1\x2A\x2A\x2A\x2A\xFF\x10" + "windows" "\x8B\x81\x2A\x2A\x2A\x2A\x81\xC1\x2A\x2A\x2A\x2A\x8B\x40\x2A\xFF\xE0" } // StartRecording and StopRecording are virtual, but get called directly in the linux binary..