- put the state pointer serializer in a virtual function so that types.cpp can operate without any knowledge of Doom states.

This commit is contained in:
Christoph Oelckers 2020-04-11 19:30:09 +02:00
commit ef8b4c7d5e
5 changed files with 78 additions and 51 deletions

View file

@ -38,7 +38,6 @@
#include "types.h"
#include "printf.h"
#include "textureid.h"
#include "version.h"
FTypeTable TypeTable;
@ -1079,6 +1078,46 @@ bool PName::ReadValue(FSerializer &ar, const char *key, void *addr) const
}
}
/* PStatePointer **********************************************************/
//==========================================================================
//
// PStatePointer Default Constructor
//
//==========================================================================
PStatePointer::PStatePointer()
{
mDescriptiveName = "Pointer<State>";
PointedType = NewStruct(NAME_State, nullptr, true);
IsConst = true;
}
//==========================================================================
//
// PStatePointer :: WriteValue
//
//==========================================================================
void PStatePointer::WriteValue(FSerializer& ar, const char* key, const void* addr) const
{
ar.StatePointer(key, const_cast<void*>(addr), nullptr);
}
//==========================================================================
//
// PStatePointer :: ReadValue
//
//==========================================================================
bool PStatePointer::ReadValue(FSerializer& ar, const char* key, void* addr) const
{
bool res = false;
ar.StatePointer(key, addr, &res);
return res;
}
/* PSpriteID ******************************************************************/
//==========================================================================
@ -2524,52 +2563,3 @@ CCMD(typetable)
DumpTypeTable();
}
// fixme: The VM depends on this but it's engine specific. Needs a better solution.
/* PStatePointer **********************************************************/
#ifdef GZDOOM
#include "info.h"
#include "serializer_doom.h"
#endif
//==========================================================================
//
// PStatePointer Default Constructor
//
//==========================================================================
PStatePointer::PStatePointer()
{
mDescriptiveName = "Pointer<State>";
PointedType = NewStruct(NAME_State, nullptr, true);
IsConst = true;
}
//==========================================================================
//
// PStatePointer :: WriteValue
//
//==========================================================================
void PStatePointer::WriteValue(FSerializer& ar, const char* key, const void* addr) const
{
#ifdef GZDOOM
ar(key, *(FState**)addr);
#endif
}
//==========================================================================
//
// PStatePointer :: ReadValue
//
//==========================================================================
bool PStatePointer::ReadValue(FSerializer& ar, const char* key, void* addr) const
{
bool res = false;
#ifdef GZDOOM
::Serialize(ar, key, *(FState**)addr, nullptr, &res);
#endif
return res;
}