mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-19 14:38:18 +00:00
Merge #6032
6032: Fix some strict-aliasing warnings and too large snapshot buffers r=heinrich5991 a=Robyt3 ## 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:
commit
3c5e2ad210
|
@ -3850,22 +3850,17 @@ const char *CClient::DemoPlayer_Play(const char *pFilename, int StorageType)
|
|||
GameClient()->OnConnected();
|
||||
|
||||
// setup buffers
|
||||
mem_zero(m_aaapDemorecSnapshotData, sizeof(m_aaapDemorecSnapshotData));
|
||||
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_aaapDemorecSnapshotData[SNAP_CURRENT][0];
|
||||
m_aapSnapshots[g_Config.m_ClDummy][SNAP_CURRENT]->m_pAltSnap = (CSnapshot *)m_aaapDemorecSnapshotData[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_aaapDemorecSnapshotData[SNAP_PREV][0];
|
||||
m_aapSnapshots[g_Config.m_ClDummy][SNAP_PREV]->m_pAltSnap = (CSnapshot *)m_aaapDemorecSnapshotData[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);
|
||||
|
|
|
@ -240,7 +240,7 @@ class CClient : public IClient, public CDemoPlayer::IListener
|
|||
int m_aSnapshotIncomingDataSize[NUM_DUMMIES];
|
||||
|
||||
CSnapshotStorage::CHolder m_aDemorecSnapshotHolders[NUM_SNAPSHOT_TYPES];
|
||||
char *m_aaapDemorecSnapshotData[NUM_SNAPSHOT_TYPES][2][CSnapshot::MAX_SIZE];
|
||||
char m_aaaDemorecSnapshotData[NUM_SNAPSHOT_TYPES][2][CSnapshot::MAX_SIZE];
|
||||
|
||||
CSnapshotDelta m_SnapshotDelta;
|
||||
|
||||
|
|
|
@ -3594,15 +3594,15 @@ void CGameContext::OnMapChange(char *pNewMapName, int MapNameSize)
|
|||
{
|
||||
int TypeID;
|
||||
int ItemID;
|
||||
int *pData = (int *)Reader.GetItem(i, &TypeID, &ItemID);
|
||||
void *pData = Reader.GetItem(i, &TypeID, &ItemID);
|
||||
int Size = Reader.GetItemSize(i);
|
||||
CMapItemInfoSettings MapInfo;
|
||||
if(TypeID == MAPITEMTYPE_INFO && ItemID == 0)
|
||||
{
|
||||
FoundInfo = true;
|
||||
CMapItemInfoSettings *pInfo = (CMapItemInfoSettings *)pData;
|
||||
if(Size >= (int)sizeof(CMapItemInfoSettings))
|
||||
{
|
||||
CMapItemInfoSettings *pInfo = (CMapItemInfoSettings *)pData;
|
||||
if(pInfo->m_Settings > -1)
|
||||
{
|
||||
SettingsIndex = pInfo->m_Settings;
|
||||
|
@ -3620,15 +3620,15 @@ void CGameContext::OnMapChange(char *pNewMapName, int MapNameSize)
|
|||
{
|
||||
MapInfo = *pInfo;
|
||||
MapInfo.m_Settings = SettingsIndex;
|
||||
pData = (int *)&MapInfo;
|
||||
pData = &MapInfo;
|
||||
Size = sizeof(MapInfo);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
*(CMapItemInfo *)&MapInfo = *(CMapItemInfo *)pInfo;
|
||||
*(CMapItemInfo *)&MapInfo = *(CMapItemInfo *)pData;
|
||||
MapInfo.m_Settings = SettingsIndex;
|
||||
pData = (int *)&MapInfo;
|
||||
pData = &MapInfo;
|
||||
Size = sizeof(MapInfo);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue