6017: Minor refactoring of demo related code r=def- a=Robyt3

Extracted from #6016.

## Checklist

- [X] Tested the change ingame
- [ ] Provided screenshots if it is a visual change
- [ ] Tested in combination with possibly related configuration options
- [ ] Written a unit test (especially base/) or added coverage to integration test
- [ ] Considered possible null pointers and out of bounds array indexing
- [ ] Changed no physics that affect existing maps
- [ ] Tested the change with [ASan+UBSan or valgrind's memcheck](https://github.com/ddnet/ddnet/#using-addresssanitizer--undefinedbehavioursanitizer-or-valgrinds-memcheck) (optional)


Co-authored-by: Robert Müller <robytemueller@gmail.com>
This commit is contained in:
bors[bot] 2022-11-06 22:00:54 +00:00 committed by GitHub
commit 06e3eb5641
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 59 deletions

View file

@ -894,7 +894,7 @@ void CClient::Disconnect()
// make sure to remove replay tmp demo
if(g_Config.m_ClReplays)
{
Storage()->RemoveFile((&m_aDemoRecorder[RECORDER_REPLAYS])->GetCurrentFilename(), IStorage::TYPE_SAVE);
Storage()->RemoveFile(m_aDemoRecorder[RECORDER_REPLAYS].GetCurrentFilename(), IStorage::TYPE_SAVE);
}
}
@ -2604,37 +2604,6 @@ void CClient::OnDemoPlayerMessage(void *pData, int Size)
if(!Sys)
GameClient()->OnMessage(Msg, &Unpacker, CONN_MAIN, false);
}
/*
const IDemoPlayer::CInfo *client_demoplayer_getinfo()
{
static DEMOPLAYBACK_INFO ret;
const DEMOREC_PLAYBACKINFO *info = m_DemoPlayer.Info();
ret.first_tick = info->first_tick;
ret.last_tick = info->last_tick;
ret.current_tick = info->current_tick;
ret.paused = info->paused;
ret.speed = info->speed;
return &ret;
}*/
/*
void DemoPlayer()->SetPos(float percent)
{
demorec_playback_set(percent);
}
void DemoPlayer()->SetSpeed(float speed)
{
demorec_playback_setspeed(speed);
}
void DemoPlayer()->SetPause(int paused)
{
if(paused)
demorec_playback_pause();
else
demorec_playback_unpause();
}*/
void CClient::UpdateDemoIntraTimers()
{
@ -3083,11 +3052,6 @@ void CClient::Run()
// init the editor
m_pEditor->Init();
// load and save a map to fix it
/*if(m_pEditor->Load(arg, IStorage::TYPE_ALL))
m_pEditor->Save(arg);
return;*/
m_ServerBrowser.OnInit();
// loads the existing ddnet info file if it exists
LoadDDNetInfo();
@ -3111,13 +3075,6 @@ void CClient::Run()
m_pConsole->Print(IConsole::OUTPUT_LEVEL_STANDARD, "server", aBuf, ColorRGBA(0.7f, 0.7f, 1, 1.0f));
}
// connect to the server if wanted
/*
if(config.cl_connect[0] != 0)
Connect(config.cl_connect);
config.cl_connect[0] = 0;
*/
//
m_FpsGraph.Init(0.0f, 120.0f);
@ -3819,7 +3776,7 @@ void CClient::SaveReplay(const int Length, const char *pFilename)
else
str_format(aFilename, sizeof(aFilename), "demos/replays/%s.demo", pFilename);
char *pSrc = (&m_aDemoRecorder[RECORDER_REPLAYS])->GetCurrentFilename();
char *pSrc = m_aDemoRecorder[RECORDER_REPLAYS].GetCurrentFilename();
// Slice the demo to get only the last cl_replay_length seconds
const int EndTick = GameTick(g_Config.m_ClDummy);
@ -4021,7 +3978,7 @@ void CClient::DemoRecorder_Stop(int Recorder, bool RemoveFile)
m_aDemoRecorder[Recorder].Stop();
if(RemoveFile)
{
const char *pFilename = (&m_aDemoRecorder[Recorder])->GetCurrentFilename();
const char *pFilename = m_aDemoRecorder[Recorder].GetCurrentFilename();
if(pFilename[0] != '\0')
Storage()->RemoveFile(pFilename, IStorage::TYPE_SAVE);
}
@ -4055,10 +4012,8 @@ void CClient::Con_StopRecord(IConsole::IResult *pResult, void *pUserData)
void CClient::Con_AddDemoMarker(IConsole::IResult *pResult, void *pUserData)
{
CClient *pSelf = (CClient *)pUserData;
pSelf->DemoRecorder_AddDemoMarker(RECORDER_MANUAL);
pSelf->DemoRecorder_AddDemoMarker(RECORDER_RACE);
pSelf->DemoRecorder_AddDemoMarker(RECORDER_AUTO);
pSelf->DemoRecorder_AddDemoMarker(RECORDER_REPLAYS);
for(int Recorder = 0; Recorder < RECORDER_MAX; Recorder++)
pSelf->DemoRecorder_AddDemoMarker(Recorder);
}
void CClient::Con_BenchmarkQuit(IConsole::IResult *pResult, void *pUserData)

View file

@ -524,15 +524,6 @@ void CScoreboard::RenderScoreboard(float x, float y, float w, int Team, const ch
void CScoreboard::RenderRecordingNotification(float x)
{
if(!m_pClient->DemoRecorder(RECORDER_MANUAL)->IsRecording() &&
!m_pClient->DemoRecorder(RECORDER_AUTO)->IsRecording() &&
!m_pClient->DemoRecorder(RECORDER_RACE)->IsRecording() &&
!m_pClient->DemoRecorder(RECORDER_REPLAYS)->IsRecording())
{
return;
}
//draw the text
char aBuf[64] = "\0";
char aBuf2[64];
char aTime[32];
@ -562,6 +553,9 @@ void CScoreboard::RenderRecordingNotification(float x)
str_append(aBuf, aBuf2, sizeof(aBuf));
}
if(!aBuf[0])
return;
float w = TextRender()->TextWidth(0, 20.0f, aBuf, -1, -1.0f);
// draw the box