Prevent assert() while saving and restoring events

The argument size of each event is checked in debug builds
and this change was missing from the x86_64 commits.

Surprisingly this didn't trigger yet with the original game,
only with the mod 'Classic Doom 3'.
This commit is contained in:
dhewg 2012-01-12 19:00:51 +01:00 committed by Daniel Gibson
parent b8f1a3e38c
commit 0fb3d2d37f
2 changed files with 12 additions and 12 deletions

View file

@ -772,17 +772,17 @@ void idEvent::Save( idSaveGame *savefile ) {
switch( format[ i ] ) { switch( format[ i ] ) {
case D_EVENT_FLOAT : case D_EVENT_FLOAT :
savefile->WriteFloat( *reinterpret_cast<float *>( dataPtr ) ); savefile->WriteFloat( *reinterpret_cast<float *>( dataPtr ) );
size += sizeof( float ); size += sizeof( intptr_t );
break; break;
case D_EVENT_INTEGER : case D_EVENT_INTEGER :
case D_EVENT_ENTITY : case D_EVENT_ENTITY :
case D_EVENT_ENTITY_NULL : case D_EVENT_ENTITY_NULL :
savefile->WriteInt( *reinterpret_cast<int *>( dataPtr ) ); savefile->WriteInt( *reinterpret_cast<int *>( dataPtr ) );
size += sizeof( int ); size += sizeof( intptr_t );
break; break;
case D_EVENT_VECTOR : case D_EVENT_VECTOR :
savefile->WriteVec3( *reinterpret_cast<idVec3 *>( dataPtr ) ); savefile->WriteVec3( *reinterpret_cast<idVec3 *>( dataPtr ) );
size += sizeof( idVec3 ); size += sizeof( E_EVENT_SIZEOF_VEC );
break; break;
case D_EVENT_STRING : case D_EVENT_STRING :
s.Clear(); s.Clear();
@ -888,17 +888,17 @@ void idEvent::Restore( idRestoreGame *savefile ) {
switch( format[ j ] ) { switch( format[ j ] ) {
case D_EVENT_FLOAT : case D_EVENT_FLOAT :
savefile->ReadFloat( *reinterpret_cast<float *>( dataPtr ) ); savefile->ReadFloat( *reinterpret_cast<float *>( dataPtr ) );
size += sizeof( float ); size += sizeof( intptr_t );
break; break;
case D_EVENT_INTEGER : case D_EVENT_INTEGER :
case D_EVENT_ENTITY : case D_EVENT_ENTITY :
case D_EVENT_ENTITY_NULL : case D_EVENT_ENTITY_NULL :
savefile->ReadInt( *reinterpret_cast<int *>( dataPtr ) ); savefile->ReadInt( *reinterpret_cast<int *>( dataPtr ) );
size += sizeof( int ); size += sizeof( intptr_t );
break; break;
case D_EVENT_VECTOR : case D_EVENT_VECTOR :
savefile->ReadVec3( *reinterpret_cast<idVec3 *>( dataPtr ) ); savefile->ReadVec3( *reinterpret_cast<idVec3 *>( dataPtr ) );
size += sizeof( idVec3 ); size += sizeof( E_EVENT_SIZEOF_VEC );
break; break;
case D_EVENT_STRING : case D_EVENT_STRING :
savefile->ReadString(s); savefile->ReadString(s);

View file

@ -638,17 +638,17 @@ void idEvent::Save( idSaveGame *savefile ) {
switch( format[ i ] ) { switch( format[ i ] ) {
case D_EVENT_FLOAT : case D_EVENT_FLOAT :
savefile->WriteFloat( *reinterpret_cast<float *>( dataPtr ) ); savefile->WriteFloat( *reinterpret_cast<float *>( dataPtr ) );
size += sizeof( float ); size += sizeof( intptr_t );
break; break;
case D_EVENT_INTEGER : case D_EVENT_INTEGER :
case D_EVENT_ENTITY : case D_EVENT_ENTITY :
case D_EVENT_ENTITY_NULL : case D_EVENT_ENTITY_NULL :
savefile->WriteInt( *reinterpret_cast<int *>( dataPtr ) ); savefile->WriteInt( *reinterpret_cast<int *>( dataPtr ) );
size += sizeof( int ); size += sizeof( intptr_t );
break; break;
case D_EVENT_VECTOR : case D_EVENT_VECTOR :
savefile->WriteVec3( *reinterpret_cast<idVec3 *>( dataPtr ) ); savefile->WriteVec3( *reinterpret_cast<idVec3 *>( dataPtr ) );
size += sizeof( idVec3 ); size += sizeof( E_EVENT_SIZEOF_VEC );
break; break;
case D_EVENT_STRING : case D_EVENT_STRING :
s.Clear(); s.Clear();
@ -737,17 +737,17 @@ void idEvent::Restore( idRestoreGame *savefile ) {
switch( format[ j ] ) { switch( format[ j ] ) {
case D_EVENT_FLOAT : case D_EVENT_FLOAT :
savefile->ReadFloat( *reinterpret_cast<float *>( dataPtr ) ); savefile->ReadFloat( *reinterpret_cast<float *>( dataPtr ) );
size += sizeof( float ); size += sizeof( intptr_t );
break; break;
case D_EVENT_INTEGER : case D_EVENT_INTEGER :
case D_EVENT_ENTITY : case D_EVENT_ENTITY :
case D_EVENT_ENTITY_NULL : case D_EVENT_ENTITY_NULL :
savefile->ReadInt( *reinterpret_cast<int *>( dataPtr ) ); savefile->ReadInt( *reinterpret_cast<int *>( dataPtr ) );
size += sizeof( int ); size += sizeof( intptr_t );
break; break;
case D_EVENT_VECTOR : case D_EVENT_VECTOR :
savefile->ReadVec3( *reinterpret_cast<idVec3 *>( dataPtr ) ); savefile->ReadVec3( *reinterpret_cast<idVec3 *>( dataPtr ) );
size += sizeof( idVec3 ); size += sizeof( E_EVENT_SIZEOF_VEC );
break; break;
case D_EVENT_STRING : case D_EVENT_STRING :
savefile->ReadString(s); savefile->ReadString(s);