Cleanup snapshot member variables in demo_extract_chat tool

Using `CSnapshotStorage::CHolder`s in the `demo_extract_chat` tool is not necessary, as only the member variable `m_pAltSnap` is being used in this tool. The regular snapshot data was copied into `m_pSnap` but never read. The other member variables were initialized but never read.
This commit is contained in:
Robert Müller 2024-07-13 22:38:17 +02:00
parent 9249b61f9f
commit a31d6a571a

View file

@ -20,23 +20,17 @@ public:
}; };
CClientData m_aClients[MAX_CLIENTS]; CClientData m_aClients[MAX_CLIENTS];
CSnapshotStorage::CHolder m_aDemoSnapshotHolders[IClient::NUM_SNAPSHOT_TYPES]; char m_aaDemoSnapshotData[IClient::NUM_SNAPSHOT_TYPES][CSnapshot::MAX_SIZE];
char m_aaaDemoSnapshotData[IClient::NUM_SNAPSHOT_TYPES][2][CSnapshot::MAX_SIZE]; CSnapshot *m_apAltSnapshots[IClient::NUM_SNAPSHOT_TYPES];
CSnapshotStorage::CHolder *m_apSnapshots[IClient::NUM_SNAPSHOT_TYPES];
CClientSnapshotHandler() : CClientSnapshotHandler() :
m_aClients(), m_aDemoSnapshotHolders() m_aClients()
{ {
mem_zero(m_aaaDemoSnapshotData, sizeof(m_aaaDemoSnapshotData)); mem_zero(m_aaDemoSnapshotData, sizeof(m_aaDemoSnapshotData));
for(int SnapshotType = 0; SnapshotType < IClient::NUM_SNAPSHOT_TYPES; SnapshotType++) for(int SnapshotType = 0; SnapshotType < IClient::NUM_SNAPSHOT_TYPES; SnapshotType++)
{ {
m_apSnapshots[SnapshotType] = &m_aDemoSnapshotHolders[SnapshotType]; m_apAltSnapshots[SnapshotType] = (CSnapshot *)&m_aaDemoSnapshotData[SnapshotType];
m_apSnapshots[SnapshotType]->m_pSnap = (CSnapshot *)&m_aaaDemoSnapshotData[SnapshotType][0];
m_apSnapshots[SnapshotType]->m_pAltSnap = (CSnapshot *)&m_aaaDemoSnapshotData[SnapshotType][1];
m_apSnapshots[SnapshotType]->m_SnapSize = 0;
m_apSnapshots[SnapshotType]->m_AltSnapSize = 0;
m_apSnapshots[SnapshotType]->m_Tick = -1;
} }
} }
@ -74,17 +68,15 @@ public:
int SnapNumItems(int SnapId) int SnapNumItems(int SnapId)
{ {
dbg_assert(SnapId >= 0 && SnapId < IClient::NUM_SNAPSHOT_TYPES, "invalid SnapId"); dbg_assert(SnapId >= 0 && SnapId < IClient::NUM_SNAPSHOT_TYPES, "invalid SnapId");
if(!m_apSnapshots[SnapId]) return m_apAltSnapshots[SnapId]->NumItems();
return 0;
return m_apSnapshots[SnapId]->m_pAltSnap->NumItems();
} }
void *SnapGetItem(int SnapId, int Index, IClient::CSnapItem *pItem) void *SnapGetItem(int SnapId, int Index, IClient::CSnapItem *pItem)
{ {
dbg_assert(SnapId >= 0 && SnapId < IClient::NUM_SNAPSHOT_TYPES, "invalid SnapId"); dbg_assert(SnapId >= 0 && SnapId < IClient::NUM_SNAPSHOT_TYPES, "invalid SnapId");
const CSnapshotItem *pSnapshotItem = m_apSnapshots[SnapId]->m_pAltSnap->GetItem(Index); const CSnapshotItem *pSnapshotItem = m_apAltSnapshots[SnapId]->GetItem(Index);
pItem->m_DataSize = m_apSnapshots[SnapId]->m_pAltSnap->GetItemSize(Index); pItem->m_DataSize = m_apAltSnapshots[SnapId]->GetItemSize(Index);
pItem->m_Type = m_apSnapshots[SnapId]->m_pAltSnap->GetItemType(Index); pItem->m_Type = m_apAltSnapshots[SnapId]->GetItemType(Index);
pItem->m_Id = pSnapshotItem->Id(); pItem->m_Id = pSnapshotItem->Id();
return (void *)pSnapshotItem->Data(); return (void *)pSnapshotItem->Data();
} }
@ -118,9 +110,8 @@ public:
if(AltSnapSize < 0) if(AltSnapSize < 0)
return; return;
std::swap(m_apSnapshots[IClient::SNAP_PREV], m_apSnapshots[IClient::SNAP_CURRENT]); std::swap(m_apAltSnapshots[IClient::SNAP_PREV], m_apAltSnapshots[IClient::SNAP_CURRENT]);
mem_copy(m_apSnapshots[IClient::SNAP_CURRENT]->m_pSnap, pData, Size); mem_copy(m_apAltSnapshots[IClient::SNAP_CURRENT], pAltSnapBuffer, AltSnapSize);
mem_copy(m_apSnapshots[IClient::SNAP_CURRENT]->m_pAltSnap, pAltSnapBuffer, AltSnapSize);
OnNewSnapshot(); OnNewSnapshot();
} }