Fix demo recording support for CS:GO

The IDemoRecorder interface was heavily modified.
This commit is contained in:
Peace-Maker 2016-07-07 16:27:46 +02:00
parent 98657d2619
commit 737b2ab1d0
8 changed files with 51 additions and 22 deletions

View File

@ -47,7 +47,11 @@
#include "ihltv.h"
#include "iserver.h"
#include "iclient.h"
#if SOURCE_ENGINE == SE_CSGO
# include "ihltvdemorecorder_csgo.h"
#else
# include "ihltvdemorecorder.h"
#endif
#include "igameevents.h"
#include "inetmessage.h"
#include "netadr.h"

View File

@ -464,16 +464,14 @@ 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);

View File

@ -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);

View File

@ -44,6 +44,7 @@ public:
IHLTVServer *GetHLTVServer();
IServer *GetBaseServer();
IDemoRecorder *GetDemoRecorder();
char *GetDemoFileName();
HLTVClientWrapper *GetClient(int index);
int GetInstanceNumber();

View File

@ -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;
};

26
ihltvdemorecorder_csgo.h Normal file
View File

@ -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

View File

@ -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;

View File

@ -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..