mirror of
https://github.com/dhewm/dhewm3-sdk.git
synced 2024-11-24 05:21:20 +00:00
More fixes regarding event saving and restoring
Fix silly issue from 3d692b58 (sizeof(E_EVENT_SIZEOF_VEC)). Align entity values of events to the native pointer size, which is noticeably faster on x86_64 and fixes another assert() in debug builds. Past savegames with entities in events are not compatible.
This commit is contained in:
parent
0fb3d2d37f
commit
ac090883ac
2 changed files with 24 additions and 24 deletions
|
@ -99,6 +99,8 @@ idEventDef::idEventDef( const char *command, const char *formatspec, char return
|
|||
break;
|
||||
|
||||
case D_EVENT_INTEGER :
|
||||
case D_EVENT_ENTITY :
|
||||
case D_EVENT_ENTITY_NULL :
|
||||
argsize += sizeof( intptr_t );
|
||||
break;
|
||||
|
||||
|
@ -110,14 +112,6 @@ idEventDef::idEventDef( const char *command, const char *formatspec, char return
|
|||
argsize += MAX_STRING_LEN;
|
||||
break;
|
||||
|
||||
case D_EVENT_ENTITY :
|
||||
argsize += sizeof( idEntityPtr<idEntity> );
|
||||
break;
|
||||
|
||||
case D_EVENT_ENTITY_NULL :
|
||||
argsize += sizeof( idEntityPtr<idEntity> );
|
||||
break;
|
||||
|
||||
case D_EVENT_TRACE :
|
||||
argsize += sizeof( trace_t ) + MAX_STRING_LEN + sizeof( bool );
|
||||
break;
|
||||
|
@ -775,14 +769,17 @@ void idEvent::Save( idSaveGame *savefile ) {
|
|||
size += sizeof( intptr_t );
|
||||
break;
|
||||
case D_EVENT_INTEGER :
|
||||
savefile->WriteInt( *reinterpret_cast<int *>( dataPtr ) );
|
||||
size += sizeof( intptr_t );
|
||||
break;
|
||||
case D_EVENT_ENTITY :
|
||||
case D_EVENT_ENTITY_NULL :
|
||||
savefile->WriteInt( *reinterpret_cast<int *>( dataPtr ) );
|
||||
reinterpret_cast< idEntityPtr<idEntity> * >( dataPtr )->Save(savefile);
|
||||
size += sizeof( intptr_t );
|
||||
break;
|
||||
case D_EVENT_VECTOR :
|
||||
savefile->WriteVec3( *reinterpret_cast<idVec3 *>( dataPtr ) );
|
||||
size += sizeof( E_EVENT_SIZEOF_VEC );
|
||||
size += E_EVENT_SIZEOF_VEC;
|
||||
break;
|
||||
case D_EVENT_STRING :
|
||||
s.Clear();
|
||||
|
@ -891,14 +888,17 @@ void idEvent::Restore( idRestoreGame *savefile ) {
|
|||
size += sizeof( intptr_t );
|
||||
break;
|
||||
case D_EVENT_INTEGER :
|
||||
savefile->ReadInt( *reinterpret_cast<int *>( dataPtr ) );
|
||||
size += sizeof( intptr_t );
|
||||
break;
|
||||
case D_EVENT_ENTITY :
|
||||
case D_EVENT_ENTITY_NULL :
|
||||
savefile->ReadInt( *reinterpret_cast<int *>( dataPtr ) );
|
||||
reinterpret_cast< idEntityPtr<idEntity> * >( dataPtr )->Restore(savefile);
|
||||
size += sizeof( intptr_t );
|
||||
break;
|
||||
case D_EVENT_VECTOR :
|
||||
savefile->ReadVec3( *reinterpret_cast<idVec3 *>( dataPtr ) );
|
||||
size += sizeof( E_EVENT_SIZEOF_VEC );
|
||||
size += E_EVENT_SIZEOF_VEC;
|
||||
break;
|
||||
case D_EVENT_STRING :
|
||||
savefile->ReadString(s);
|
||||
|
|
|
@ -99,6 +99,8 @@ idEventDef::idEventDef( const char *command, const char *formatspec, char return
|
|||
break;
|
||||
|
||||
case D_EVENT_INTEGER :
|
||||
case D_EVENT_ENTITY :
|
||||
case D_EVENT_ENTITY_NULL :
|
||||
argsize += sizeof( intptr_t );
|
||||
break;
|
||||
|
||||
|
@ -110,14 +112,6 @@ idEventDef::idEventDef( const char *command, const char *formatspec, char return
|
|||
argsize += MAX_STRING_LEN;
|
||||
break;
|
||||
|
||||
case D_EVENT_ENTITY :
|
||||
argsize += sizeof( idEntityPtr<idEntity> );
|
||||
break;
|
||||
|
||||
case D_EVENT_ENTITY_NULL :
|
||||
argsize += sizeof( idEntityPtr<idEntity> );
|
||||
break;
|
||||
|
||||
case D_EVENT_TRACE :
|
||||
argsize += sizeof( trace_t ) + MAX_STRING_LEN + sizeof( bool );
|
||||
break;
|
||||
|
@ -641,14 +635,17 @@ void idEvent::Save( idSaveGame *savefile ) {
|
|||
size += sizeof( intptr_t );
|
||||
break;
|
||||
case D_EVENT_INTEGER :
|
||||
savefile->WriteInt( *reinterpret_cast<int *>( dataPtr ) );
|
||||
size += sizeof( intptr_t );
|
||||
break;
|
||||
case D_EVENT_ENTITY :
|
||||
case D_EVENT_ENTITY_NULL :
|
||||
savefile->WriteInt( *reinterpret_cast<int *>( dataPtr ) );
|
||||
reinterpret_cast< idEntityPtr<idEntity> * >( dataPtr )->Save(savefile);
|
||||
size += sizeof( intptr_t );
|
||||
break;
|
||||
case D_EVENT_VECTOR :
|
||||
savefile->WriteVec3( *reinterpret_cast<idVec3 *>( dataPtr ) );
|
||||
size += sizeof( E_EVENT_SIZEOF_VEC );
|
||||
size += E_EVENT_SIZEOF_VEC;
|
||||
break;
|
||||
case D_EVENT_STRING :
|
||||
s.Clear();
|
||||
|
@ -740,14 +737,17 @@ void idEvent::Restore( idRestoreGame *savefile ) {
|
|||
size += sizeof( intptr_t );
|
||||
break;
|
||||
case D_EVENT_INTEGER :
|
||||
savefile->ReadInt( *reinterpret_cast<int *>( dataPtr ) );
|
||||
size += sizeof( intptr_t );
|
||||
break;
|
||||
case D_EVENT_ENTITY :
|
||||
case D_EVENT_ENTITY_NULL :
|
||||
savefile->ReadInt( *reinterpret_cast<int *>( dataPtr ) );
|
||||
reinterpret_cast< idEntityPtr<idEntity> * >( dataPtr )->Restore(savefile);
|
||||
size += sizeof( intptr_t );
|
||||
break;
|
||||
case D_EVENT_VECTOR :
|
||||
savefile->ReadVec3( *reinterpret_cast<idVec3 *>( dataPtr ) );
|
||||
size += sizeof( E_EVENT_SIZEOF_VEC );
|
||||
size += E_EVENT_SIZEOF_VEC;
|
||||
break;
|
||||
case D_EVENT_STRING :
|
||||
savefile->ReadString(s);
|
||||
|
|
Loading…
Reference in a new issue