From 7185f028f1f6eeff320f4cc84804e6348acb23a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20M=C3=BCller?= Date: Sat, 12 Nov 2022 20:31:44 +0100 Subject: [PATCH] Reduce duplicate code by using loop for snapshot types --- src/engine/client/client.cpp | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/src/engine/client/client.cpp b/src/engine/client/client.cpp index 0d3701d26..f7749f34b 100644 --- a/src/engine/client/client.cpp +++ b/src/engine/client/client.cpp @@ -3852,20 +3852,15 @@ const char *CClient::DemoPlayer_Play(const char *pFilename, int StorageType) // setup buffers mem_zero(m_aaaDemorecSnapshotData, sizeof(m_aaaDemorecSnapshotData)); - m_aapSnapshots[g_Config.m_ClDummy][SNAP_CURRENT] = &m_aDemorecSnapshotHolders[SNAP_CURRENT]; - m_aapSnapshots[g_Config.m_ClDummy][SNAP_PREV] = &m_aDemorecSnapshotHolders[SNAP_PREV]; - - m_aapSnapshots[g_Config.m_ClDummy][SNAP_CURRENT]->m_pSnap = (CSnapshot *)&m_aaaDemorecSnapshotData[SNAP_CURRENT][0]; - m_aapSnapshots[g_Config.m_ClDummy][SNAP_CURRENT]->m_pAltSnap = (CSnapshot *)&m_aaaDemorecSnapshotData[SNAP_CURRENT][1]; - m_aapSnapshots[g_Config.m_ClDummy][SNAP_CURRENT]->m_SnapSize = 0; - m_aapSnapshots[g_Config.m_ClDummy][SNAP_CURRENT]->m_AltSnapSize = 0; - m_aapSnapshots[g_Config.m_ClDummy][SNAP_CURRENT]->m_Tick = -1; - - m_aapSnapshots[g_Config.m_ClDummy][SNAP_PREV]->m_pSnap = (CSnapshot *)&m_aaaDemorecSnapshotData[SNAP_PREV][0]; - m_aapSnapshots[g_Config.m_ClDummy][SNAP_PREV]->m_pAltSnap = (CSnapshot *)&m_aaaDemorecSnapshotData[SNAP_PREV][1]; - m_aapSnapshots[g_Config.m_ClDummy][SNAP_PREV]->m_SnapSize = 0; - m_aapSnapshots[g_Config.m_ClDummy][SNAP_PREV]->m_AltSnapSize = 0; - m_aapSnapshots[g_Config.m_ClDummy][SNAP_PREV]->m_Tick = -1; + for(int SnapshotType = 0; SnapshotType < NUM_SNAPSHOT_TYPES; SnapshotType++) + { + m_aapSnapshots[g_Config.m_ClDummy][SnapshotType] = &m_aDemorecSnapshotHolders[SnapshotType]; + m_aapSnapshots[g_Config.m_ClDummy][SnapshotType]->m_pSnap = (CSnapshot *)&m_aaaDemorecSnapshotData[SnapshotType][0]; + m_aapSnapshots[g_Config.m_ClDummy][SnapshotType]->m_pAltSnap = (CSnapshot *)&m_aaaDemorecSnapshotData[SnapshotType][1]; + m_aapSnapshots[g_Config.m_ClDummy][SnapshotType]->m_SnapSize = 0; + m_aapSnapshots[g_Config.m_ClDummy][SnapshotType]->m_AltSnapSize = 0; + m_aapSnapshots[g_Config.m_ClDummy][SnapshotType]->m_Tick = -1; + } // enter demo playback state SetState(IClient::STATE_DEMOPLAYBACK);