- all DObjects converted.

- cleaned out some old cruft that's no longer needed.
This commit is contained in:
Christoph Oelckers 2016-09-20 10:27:53 +02:00
parent daf43f9d35
commit af6404f763
20 changed files with 137 additions and 610 deletions

View file

@ -583,7 +583,6 @@ public:
void Destroy (); void Destroy ();
~AActor (); ~AActor ();
DECLARE_OLD_SERIAL
void Serialize(FSerializer &arc); void Serialize(FSerializer &arc);
void PostSerialize(); void PostSerialize();

View file

@ -142,7 +142,6 @@ public:
DBot (); DBot ();
void Clear (); void Clear ();
DECLARE_OLD_SERIAL
void Serialize(FSerializer &arc); void Serialize(FSerializer &arc);
void Tick (); void Tick ();

View file

@ -438,8 +438,6 @@ template<class T> inline void GC::Mark(TObjPtr<T> &obj)
GC::Mark(&obj.o); GC::Mark(&obj.o);
} }
#define DECLARE_OLD_SERIAL virtual void Serialize(FArchive &arc);
class DObject class DObject
{ {
public: public:
@ -469,7 +467,6 @@ public:
inline bool IsA (const PClass *type) const; inline bool IsA (const PClass *type) const;
void SerializeUserVars(FArchive &arc); void SerializeUserVars(FArchive &arc);
DECLARE_OLD_SERIAL
void SerializeUserVars(FSerializer &arc); void SerializeUserVars(FSerializer &arc);
virtual void Serialize(FSerializer &arc); virtual void Serialize(FSerializer &arc);

View file

@ -39,6 +39,7 @@
#include "i_system.h" #include "i_system.h"
#include "doomerrors.h" #include "doomerrors.h"
#include "farchive.h" #include "farchive.h"
#include "serializer.h"
#include "d_player.h" #include "d_player.h"
@ -103,14 +104,14 @@ bool FThinkerList::IsEmpty() const
return Sentinel == NULL || Sentinel->NextThinker == NULL; return Sentinel == NULL || Sentinel->NextThinker == NULL;
} }
void DThinker::SaveList(FArchive &arc, DThinker *node) void DThinker::SaveList(FSerializer &arc, DThinker *node)
{ {
if (node != NULL) if (node != NULL)
{ {
while (!(node->ObjectFlags & OF_Sentinel)) while (!(node->ObjectFlags & OF_Sentinel))
{ {
assert(node->NextThinker != NULL && !(node->NextThinker->ObjectFlags & OF_EuthanizeMe)); assert(node->NextThinker != NULL && !(node->NextThinker->ObjectFlags & OF_EuthanizeMe));
arc << node; ::Serialize<DThinker>(arc, nullptr, node, nullptr);
node = node->NextThinker; node = node->NextThinker;
} }
} }
@ -118,6 +119,7 @@ void DThinker::SaveList(FArchive &arc, DThinker *node)
void DThinker::SerializeAll(FArchive &arc, bool hubLoad) void DThinker::SerializeAll(FArchive &arc, bool hubLoad)
{ {
#if 0
DThinker *thinker; DThinker *thinker;
BYTE stat; BYTE stat;
int statcount; int statcount;
@ -197,6 +199,7 @@ void DThinker::SerializeAll(FArchive &arc, bool hubLoad)
} }
bSerialOverride = false; bSerialOverride = false;
} }
#endif
} }
DThinker::DThinker (int statnum) throw() DThinker::DThinker (int statnum) throw()

View file

@ -1087,6 +1087,7 @@ FArchive &FArchive::SerializeObject (DObject *&object, PClass *type)
FArchive &FArchive::ReadObject (DObject* &obj, PClass *wanttype) FArchive &FArchive::ReadObject (DObject* &obj, PClass *wanttype)
{ {
#if 0
BYTE objHead; BYTE objHead;
const PClass *type; const PClass *type;
BYTE playerNum; BYTE playerNum;
@ -1203,6 +1204,7 @@ FArchive &FArchive::ReadObject (DObject* &obj, PClass *wanttype)
default: default:
I_Error ("Unknown object code (%d) in archive\n", objHead); I_Error ("Unknown object code (%d) in archive\n", objHead);
} }
#endif
return *this; return *this;
} }

View file

@ -288,19 +288,10 @@ inline FArchive &operator<< (FArchive &arc, PalEntry &p)
return arc << p.a << p.r << p.g << p.b; return arc << p.a << p.r << p.g << p.b;
} }
template<class T>
inline FArchive &operator<< (FArchive &arc, T* &object)
{
return arc.SerializeObject ((DObject*&)object, RUNTIME_TEMPLATE_CLASS(T));
}
struct FStrifeDialogueNode; struct FStrifeDialogueNode;
struct FSwitchDef; struct FSwitchDef;
struct FDoorAnimation; struct FDoorAnimation;
struct FLinePortal; struct FLinePortal;
template<> FArchive &operator<< (FArchive &arc, FStrifeDialogueNode *&node);
template<> FArchive &operator<< (FArchive &arc, FSwitchDef* &sw);
template<> FArchive &operator<< (FArchive &arc, FDoorAnimation* &da);
FArchive &operator<< (FArchive &arc, FLinePortal &da); FArchive &operator<< (FArchive &arc, FLinePortal &da);
FArchive &operator<< (FArchive &arc, FSectorPortal &da); FArchive &operator<< (FArchive &arc, FSectorPortal &da);

View file

@ -39,7 +39,7 @@
#include "v_video.h" #include "v_video.h"
#include "cmdlib.h" #include "cmdlib.h"
#include "doomstat.h" #include "doomstat.h"
#include "farchive.h" #include "serializer.h"
EXTERN_CVAR(Int, con_scaletext) EXTERN_CVAR(Int, con_scaletext)
int active_con_scaletext(); int active_con_scaletext();
@ -56,14 +56,6 @@ IMPLEMENT_CLASS (DHUDMessageTypeOnFadeOut)
* Basic HUD message. Appears and disappears without any special effects * * Basic HUD message. Appears and disappears without any special effects *
*************************************************************************/ *************************************************************************/
inline FArchive &operator<< (FArchive &arc, EColorRange &i)
{
BYTE val = (BYTE)i;
arc << val;
i = (EColorRange)val;
return arc;
}
//============================================================================ //============================================================================
// //
// DHUDMessage Constructor // DHUDMessage Constructor
@ -180,20 +172,30 @@ DHUDMessage::~DHUDMessage ()
// //
//============================================================================ //============================================================================
void DHUDMessage::Serialize(FArchive &arc) void DHUDMessage::Serialize(FSerializer &arc)
{ {
Super::Serialize(arc); Super::Serialize(arc);
arc << Left << Top << CenterX << HoldTics arc("left", Left)
<< Tics << State << TextColor ("top", Top)
//<< SBarID << SourceText << Font << Next ("centerx", CenterX)
<< HUDWidth << HUDHeight ("holdtics", HoldTics)
<< NoWrap ("tics", Tics)
<< ClipX << ClipY << ClipWidth << ClipHeight ("state", State)
<< WrapWidth .Enum("textcolor", TextColor)
<< HandleAspect ("hudwidth", HUDWidth)
<< VisibilityFlags ("hudheight", HUDHeight)
<< Style << Alpha; ("nowrap", NoWrap)
if (arc.IsLoading()) ("clipx", ClipX)
("clipy", ClipY)
("clipwidth", ClipWidth)
("clipheight", ClipHeight)
("wrapwidth", WrapWidth)
("handleaspect", HandleAspect)
("visibilityflags", VisibilityFlags)
("style", Style)
("alpha", Alpha);
if (arc.isReading())
{ {
Lines = NULL; Lines = NULL;
ResetText(SourceText); ResetText(SourceText);
@ -504,10 +506,10 @@ DHUDMessageFadeOut::DHUDMessageFadeOut (FFont *font, const char *text, float x,
// //
//============================================================================ //============================================================================
void DHUDMessageFadeOut::Serialize(FArchive &arc) void DHUDMessageFadeOut::Serialize(FSerializer &arc)
{ {
Super::Serialize (arc); Super::Serialize (arc);
arc << FadeOutTics; arc("fadeouttics", FadeOutTics);
} }
//============================================================================ //============================================================================
@ -609,10 +611,10 @@ DHUDMessageFadeInOut::DHUDMessageFadeInOut (FFont *font, const char *text, float
// //
//============================================================================ //============================================================================
void DHUDMessageFadeInOut::Serialize(FArchive &arc) void DHUDMessageFadeInOut::Serialize(FSerializer &arc)
{ {
Super::Serialize (arc); Super::Serialize (arc);
arc << FadeInTics; arc("fadeintics", FadeInTics);
} }
//============================================================================ //============================================================================
@ -718,10 +720,13 @@ DHUDMessageTypeOnFadeOut::DHUDMessageTypeOnFadeOut (FFont *font, const char *tex
// //
//============================================================================ //============================================================================
void DHUDMessageTypeOnFadeOut::Serialize(FArchive &arc) void DHUDMessageTypeOnFadeOut::Serialize(FSerializer &arc)
{ {
Super::Serialize (arc); Super::Serialize (arc);
arc << TypeOnTime << CurrLine << LineVisible << LineLen; arc("typeontime", TypeOnTime)
("currline", CurrLine)
("linevisible", LineVisible)
("linelen", LineLen);
} }
//============================================================================ //============================================================================

View file

@ -71,7 +71,7 @@ public:
EColorRange textColor, float holdTime); EColorRange textColor, float holdTime);
virtual ~DHUDMessage (); virtual ~DHUDMessage ();
virtual void Serialize(FArchive &arc); virtual void Serialize(FSerializer &arc);
void Draw (int bottom, int visibility); void Draw (int bottom, int visibility);
virtual void ResetText (const char *text); virtual void ResetText (const char *text);
@ -157,7 +157,7 @@ public:
DHUDMessageFadeOut (FFont *font, const char *text, float x, float y, int hudwidth, int hudheight, DHUDMessageFadeOut (FFont *font, const char *text, float x, float y, int hudwidth, int hudheight,
EColorRange textColor, float holdTime, float fadeOutTime); EColorRange textColor, float holdTime, float fadeOutTime);
virtual void Serialize(FArchive &arc); virtual void Serialize(FSerializer &arc);
virtual void DoDraw (int linenum, int x, int y, bool clean, int hudheight); virtual void DoDraw (int linenum, int x, int y, bool clean, int hudheight);
virtual bool Tick (); virtual bool Tick ();
@ -176,7 +176,7 @@ public:
DHUDMessageFadeInOut (FFont *font, const char *text, float x, float y, int hudwidth, int hudheight, DHUDMessageFadeInOut (FFont *font, const char *text, float x, float y, int hudwidth, int hudheight,
EColorRange textColor, float holdTime, float fadeInTime, float fadeOutTime); EColorRange textColor, float holdTime, float fadeInTime, float fadeOutTime);
virtual void Serialize(FArchive &arc); virtual void Serialize(FSerializer &arc);
virtual void DoDraw (int linenum, int x, int y, bool clean, int hudheight); virtual void DoDraw (int linenum, int x, int y, bool clean, int hudheight);
virtual bool Tick (); virtual bool Tick ();
@ -195,7 +195,7 @@ public:
DHUDMessageTypeOnFadeOut (FFont *font, const char *text, float x, float y, int hudwidth, int hudheight, DHUDMessageTypeOnFadeOut (FFont *font, const char *text, float x, float y, int hudwidth, int hudheight,
EColorRange textColor, float typeTime, float holdTime, float fadeOutTime); EColorRange textColor, float typeTime, float holdTime, float fadeOutTime);
virtual void Serialize(FArchive &arc); virtual void Serialize(FSerializer &arc);
virtual void DoDraw (int linenum, int x, int y, bool clean, int hudheight); virtual void DoDraw (int linenum, int x, int y, bool clean, int hudheight);
virtual bool Tick (); virtual bool Tick ();
virtual void ScreenSizeChanged (); virtual void ScreenSizeChanged ();
@ -355,7 +355,8 @@ public:
static void AddBlend (float r, float g, float b, float a, float v_blend[4]); static void AddBlend (float r, float g, float b, float a, float v_blend[4]);
virtual void Serialize(FArchive &arc); // do not make this a DObject Serialize function because it's not used like one!
void SerializeMessages(FSerializer &arc);
virtual void Tick (); virtual void Tick ();
virtual void Draw (EHudState state); virtual void Draw (EHudState state);

View file

@ -51,8 +51,9 @@
#include "colormatcher.h" #include "colormatcher.h"
#include "v_palette.h" #include "v_palette.h"
#include "d_player.h" #include "d_player.h"
#include "farchive.h" #include "serializer.h"
#include "gstrings.h" #include "gstrings.h"
#include "r_utility.h"
#include "../version.h" #include "../version.h"
@ -1654,12 +1655,9 @@ void DBaseStatusBar::ReceivedWeapon (AWeapon *weapon)
{ {
} }
void DBaseStatusBar::Serialize(FArchive &arc) void DBaseStatusBar::SerializeMessages(FSerializer &arc)
{ {
for (size_t i = 0; i < countof(Messages); ++i) arc.Array("hudmessages", Messages, 3, true);
{
arc << Messages[i];
}
} }
void DBaseStatusBar::ScreenSizeChanged () void DBaseStatusBar::ScreenSizeChanged ()

View file

@ -33,21 +33,6 @@ void DObject::SerializeUserVars(FSerializer &arc)
// //
//========================================================================== //==========================================================================
void DThinker::SaveList(FSerializer &arc, DThinker *node)
{
if (node != NULL)
{
while (!(node->ObjectFlags & OF_Sentinel))
{
assert(node->NextThinker != NULL && !(node->NextThinker->ObjectFlags & OF_EuthanizeMe));
//node->SerializeUserVars(arc);
::Serialize<DThinker>(arc, nullptr, node, nullptr);
node->CheckIfSerialized();
node = node->NextThinker;
}
}
}
void DThinker::SerializeThinkers(FSerializer &arc, bool hubLoad) void DThinker::SerializeThinkers(FSerializer &arc, bool hubLoad)
{ {

View file

@ -57,7 +57,6 @@
#include "doomstat.h" #include "doomstat.h"
#include "c_console.h" #include "c_console.h"
#include "sbar.h" #include "sbar.h"
#include "farchive.h"
#include "p_lnspec.h" #include "p_lnspec.h"
#include "r_utility.h" #include "r_utility.h"
#include "p_local.h" #include "p_local.h"
@ -1470,25 +1469,3 @@ static void TerminalResponse (const char *str)
} }
} }
template<> FArchive &operator<< (FArchive &arc, FStrifeDialogueNode *&node)
{
DWORD convnum;
if (arc.IsStoring())
{
arc.WriteCount (node == NULL? ~0u : node->ThisNodeNum);
}
else
{
convnum = arc.ReadCount();
if (convnum >= StrifeDialogues.Size())
{
node = NULL;
}
else
{
node = StrifeDialogues[convnum];
}
}
return arc;
}

View file

@ -29,6 +29,7 @@
#include "g_level.h" #include "g_level.h"
#include "farchive.h" #include "farchive.h"
#include "d_player.h" #include "d_player.h"
#include "serializer.h"
// MACROS ------------------------------------------------------------------ // MACROS ------------------------------------------------------------------
@ -1446,13 +1447,23 @@ void DPSprite::Tick()
// //
//------------------------------------------------------------------------ //------------------------------------------------------------------------
void DPSprite::Serialize(FArchive &arc) void DPSprite::Serialize(FSerializer &arc)
{ {
Super::Serialize(arc); Super::Serialize(arc);
arc << Next << Caller << Owner << Flags arc("next", Next)
<< State << Tics << Sprite << Frame ("caller", Caller)
<< ID << x << y << oldx << oldy; ("owner", Owner)
("flags", Flags)
("state", State)
("tics", Tics)
.Sprite("sprite", Sprite, nullptr)
("frame", Frame)
("id", ID)
("x", x)
("y", y)
("oldx", oldx)
("oldy", oldy);
} }
//------------------------------------------------------------------------ //------------------------------------------------------------------------

View file

@ -87,7 +87,7 @@ public:
private: private:
DPSprite () {} DPSprite () {}
void Serialize(FArchive &arc); void Serialize(FSerializer &arc);
void Tick(); void Tick();
void Destroy(); void Destroy();

View file

@ -863,7 +863,7 @@ void G_SerializeLevel(FSerializer &arc, bool hubload)
arc.Array("sectors", sectors, &loadsectors[0], numsectors); arc.Array("sectors", sectors, &loadsectors[0], numsectors);
arc.Array("polyobjs", polyobjs, po_NumPolyobjs); arc.Array("polyobjs", polyobjs, po_NumPolyobjs);
arc("subsectors", subsectors); arc("subsectors", subsectors);
//StatusBar->Serialize(arc); StatusBar->SerializeMessages(arc);
arc("zones", Zones); arc("zones", Zones);
arc("lineportals", linePortals); arc("lineportals", linePortals);
arc("sectorportals", sectorPortals); arc("sectorportals", sectorPortals);
@ -882,7 +882,7 @@ void G_SerializeLevel(FSerializer &arc, bool hubload)
void P_SerializeSounds (FArchive &arc) void P_SerializeSounds (FArchive &arc)
{ {
S_SerializeSounds (arc); S_SerializeSounds (arc);
DSeqNode::SerializeSequences (arc); //DSeqNode::SerializeSequences (arc);
char *name = NULL; char *name = NULL;
BYTE order; BYTE order;
@ -900,40 +900,6 @@ void P_SerializeSounds (FArchive &arc)
delete[] name; delete[] name;
} }
//==========================================================================
//
// ArchivePolyobjs
//
//==========================================================================
#define ASEG_POLYOBJS 104
void P_SerializePolyobjs (FArchive &arc)
{
int i;
FPolyObj *po;
if (arc.IsStoring ())
{
int seg = ASEG_POLYOBJS;
arc << seg << po_NumPolyobjs;
for(i = 0, po = polyobjs; i < po_NumPolyobjs; i++, po++)
{
arc << po->tag << po->Angle << po->StartSpot.pos << po->interpolation << po->bBlocked << po->bHasPortals;
arc << po->specialdata;
}
}
else
{
int data;
DAngle angle;
DVector2 delta;
for (i = 0, po = polyobjs; i < po_NumPolyobjs; i++, po++)
{
}
}
}
//========================================================================== //==========================================================================
// //
// //
@ -976,7 +942,6 @@ void G_SerializeLevel(FArchive &arc, bool hubLoad)
// This must be saved, too, of course! // This must be saved, too, of course!
FCanvasTextureInfo::Serialize(arc); FCanvasTextureInfo::Serialize(arc);
//AM_SerializeMarkers(arc);
P_SerializePlayers(arc, hubLoad); P_SerializePlayers(arc, hubLoad);
P_SerializeSounds(arc); P_SerializeSounds(arc);

View file

@ -3007,6 +3007,7 @@ void P_UnPredictPlayer ()
void player_t::Serialize(FArchive &arc) void player_t::Serialize(FArchive &arc)
{ {
#if 0
int i; int i;
FString skinname; FString skinname;
@ -3079,54 +3080,6 @@ void player_t::Serialize(FArchive &arc)
for (i = 0; i < MAXPLAYERS; i++) for (i = 0; i < MAXPLAYERS; i++)
arc << frags[i]; arc << frags[i];
if (SaveVersion < 4547)
{
int layer = PSP_WEAPON;
for (i = 0; i < 5; i++)
{
FState *state;
int tics;
double sx, sy;
int sprite;
int frame;
arc << state << tics
<< sx << sy
<< sprite << frame;
if (state != nullptr &&
((layer < PSP_TARGETCENTER && ReadyWeapon != nullptr) ||
(layer >= PSP_TARGETCENTER && mo->FindInventory(RUNTIME_CLASS(APowerTargeter), true))))
{
DPSprite *pspr;
pspr = GetPSprite(PSPLayers(layer));
pspr->State = state;
pspr->Tics = tics;
pspr->Sprite = sprite;
pspr->Frame = frame;
pspr->Owner = this;
if (layer == PSP_FLASH)
{
pspr->x = 0;
pspr->y = 0;
}
else
{
pspr->x = sx;
pspr->y = sy;
}
}
if (layer == PSP_WEAPON)
layer = PSP_FLASH;
else if (layer == PSP_FLASH)
layer = PSP_TARGETCENTER;
else
layer++;
}
}
else
arc << psprites; arc << psprites;
arc << CurrentPlayerClass; arc << CurrentPlayerClass;
@ -3154,6 +3107,7 @@ void player_t::Serialize(FArchive &arc)
userinfo.SkinChanged(skinname, CurrentPlayerClass); userinfo.SkinChanged(skinname, CurrentPlayerClass);
} }
arc << MUSINFOactor << MUSINFOtics; arc << MUSINFOactor << MUSINFOtics;
#endif
} }
bool P_IsPlayerTotallyFrozen(const player_t *player) bool P_IsPlayerTotallyFrozen(const player_t *player)

View file

@ -1043,6 +1043,7 @@ void FCanvasTextureInfo::EmptyList ()
void FCanvasTextureInfo::Serialize(FArchive &arc) void FCanvasTextureInfo::Serialize(FArchive &arc)
{ {
#if 0
if (arc.IsStoring ()) if (arc.IsStoring ())
{ {
FCanvasTextureInfo *probe; FCanvasTextureInfo *probe;
@ -1070,6 +1071,7 @@ void FCanvasTextureInfo::Serialize(FArchive &arc)
Add (viewpoint, picnum, fov); Add (viewpoint, picnum, fov);
} }
} }
#endif
} }
//========================================================================== //==========================================================================

View file

@ -27,7 +27,7 @@
#include "templates.h" #include "templates.h"
#include "c_dispatch.h" #include "c_dispatch.h"
#include "g_level.h" #include "g_level.h"
#include "farchive.h" #include "serializer.h"
#include "d_player.h" #include "d_player.h"
// MACROS ------------------------------------------------------------------ // MACROS ------------------------------------------------------------------
@ -106,7 +106,7 @@ class DSeqActorNode : public DSeqNode
public: public:
DSeqActorNode(AActor *actor, int sequence, int modenum); DSeqActorNode(AActor *actor, int sequence, int modenum);
void Destroy(); void Destroy();
void Serialize(FArchive &arc); void Serialize(FSerializer &arc);
void MakeSound(int loop, FSoundID id) void MakeSound(int loop, FSoundID id)
{ {
S_Sound(m_Actor, CHAN_BODY|loop, id, clamp(m_Volume, 0.f, 1.f), m_Atten); S_Sound(m_Actor, CHAN_BODY|loop, id, clamp(m_Volume, 0.f, 1.f), m_Atten);
@ -134,7 +134,7 @@ class DSeqPolyNode : public DSeqNode
public: public:
DSeqPolyNode(FPolyObj *poly, int sequence, int modenum); DSeqPolyNode(FPolyObj *poly, int sequence, int modenum);
void Destroy(); void Destroy();
void Serialize(FArchive &arc); void Serialize(FSerializer &arc);
void MakeSound(int loop, FSoundID id) void MakeSound(int loop, FSoundID id)
{ {
S_Sound (m_Poly, CHAN_BODY|loop, id, clamp(m_Volume, 0.f, 1.f), m_Atten); S_Sound (m_Poly, CHAN_BODY|loop, id, clamp(m_Volume, 0.f, 1.f), m_Atten);
@ -162,7 +162,7 @@ class DSeqSectorNode : public DSeqNode
public: public:
DSeqSectorNode(sector_t *sec, int chan, int sequence, int modenum); DSeqSectorNode(sector_t *sec, int chan, int sequence, int modenum);
void Destroy(); void Destroy();
void Serialize(FArchive &arc); void Serialize(FSerializer &arc);
void MakeSound(int loop, FSoundID id) void MakeSound(int loop, FSoundID id)
{ {
Channel = (Channel & 7) | CHAN_AREA | loop; Channel = (Channel & 7) | CHAN_AREA | loop;
@ -280,9 +280,9 @@ static FRandom pr_sndseq ("SndSeq");
// CODE -------------------------------------------------------------------- // CODE --------------------------------------------------------------------
void DSeqNode::SerializeSequences (FArchive &arc) void DSeqNode::SerializeSequences (FSerializer &arc)
{ {
arc << SequenceListHead; arc("sndseqlisthead", SequenceListHead);
} }
IMPLEMENT_POINTY_CLASS (DSeqNode) IMPLEMENT_POINTY_CLASS (DSeqNode)
@ -298,55 +298,58 @@ DSeqNode::DSeqNode ()
m_Next = m_Prev = m_ChildSeqNode = m_ParentSeqNode = NULL; m_Next = m_Prev = m_ChildSeqNode = m_ParentSeqNode = NULL;
} }
void DSeqNode::Serialize(FArchive &arc) void DSeqNode::Serialize(FSerializer &arc)
{ {
int seqOffset; int seqOffset;
unsigned int i; unsigned int i;
FName seqName;
int delayTics = 0;
FSoundID id;
float volume;
float atten = ATTN_NORM;
int seqnum;
unsigned int numchoices;
Super::Serialize (arc); // copy these to local variables so that the actual serialization code does not need to be duplicated for saving and loading.
if (arc.IsStoring ()) if (arc.isWriting())
{ {
seqOffset = (int)SN_GetSequenceOffset (m_Sequence, m_SequencePtr); seqOffset = (int)SN_GetSequenceOffset(m_Sequence, m_SequencePtr);
arc << seqOffset delayTics = m_DelayUntilTic;
<< m_DelayUntilTic volume = m_Volume;
<< m_Volume atten = m_Atten;
<< m_Atten id = m_CurrentSoundID;
<< m_ModeNum seqName = Sequences[m_Sequence]->SeqName;
<< m_Next numchoices = m_SequenceChoices.Size();
<< m_Prev }
<< m_ChildSeqNode Super::Serialize(arc);
<< m_ParentSeqNode
<< m_CurrentSoundID
<< Sequences[m_Sequence]->SeqName;
arc.WriteCount (m_SequenceChoices.Size()); arc("seqoffset", seqOffset)
for (i = 0; i < m_SequenceChoices.Size(); ++i) ("delaytics", delayTics)
("volume", volume)
("atten", atten)
("modelnum", m_ModeNum)
("next", m_Next)
("prev", m_Prev)
("childseqnode", m_ChildSeqNode)
("parentseqnode", m_ParentSeqNode)
("id", id)
("seqname", seqName)
("numchoices", numchoices);
// The way this is saved makes it hard to encapsulate so just do it the hard way...
if (arc.isWriting())
{
if (numchoices > 0 && arc.BeginArray("choices"))
{ {
arc << Sequences[m_SequenceChoices[i]]->SeqName; for (i = 0; i < m_SequenceChoices.Size(); ++i)
{
arc(nullptr, Sequences[m_SequenceChoices[i]]->SeqName);
}
arc.EndArray();
} }
} }
else else
{ {
FName seqName;
int delayTics = 0;
FSoundID id;
float volume;
float atten = ATTN_NORM;
int seqnum;
unsigned int numchoices;
arc << seqOffset
<< delayTics
<< volume
<< atten
<< m_ModeNum
<< m_Next
<< m_Prev
<< m_ChildSeqNode
<< m_ParentSeqNode
<< id
<< seqName;
seqnum = FindSequence (seqName); seqnum = FindSequence (seqName);
if (seqnum >= 0) if (seqnum >= 0)
{ {
@ -360,12 +363,15 @@ void DSeqNode::Serialize(FArchive &arc)
ChangeData (seqOffset, delayTics - TIME_REFERENCE, volume, id); ChangeData (seqOffset, delayTics - TIME_REFERENCE, volume, id);
numchoices = arc.ReadCount();
m_SequenceChoices.Resize(numchoices); m_SequenceChoices.Resize(numchoices);
for (i = 0; i < numchoices; ++i) if (numchoices > 0 && arc.BeginArray("choices"))
{ {
arc << seqName; for (i = 0; i < numchoices; ++i)
m_SequenceChoices[i] = FindSequence (seqName); {
arc(nullptr, seqName);
m_SequenceChoices[i] = FindSequence(seqName);
}
arc.EndArray();
} }
} }
} }
@ -425,15 +431,15 @@ IMPLEMENT_POINTY_CLASS (DSeqActorNode)
DECLARE_POINTER (m_Actor) DECLARE_POINTER (m_Actor)
END_POINTERS END_POINTERS
void DSeqActorNode::Serialize(FArchive &arc) void DSeqActorNode::Serialize(FSerializer &arc)
{ {
Super::Serialize (arc); Super::Serialize (arc);
arc << m_Actor; arc("actor", m_Actor);
} }
IMPLEMENT_CLASS (DSeqPolyNode) IMPLEMENT_CLASS (DSeqPolyNode)
void DSeqPolyNode::Serialize(FArchive &arc) void DSeqPolyNode::Serialize(FSerializer &arc)
{ {
Super::Serialize (arc); Super::Serialize (arc);
//arc << m_Poly; //arc << m_Poly;
@ -441,10 +447,11 @@ void DSeqPolyNode::Serialize(FArchive &arc)
IMPLEMENT_CLASS (DSeqSectorNode) IMPLEMENT_CLASS (DSeqSectorNode)
void DSeqSectorNode::Serialize(FArchive &arc) void DSeqSectorNode::Serialize(FSerializer &arc)
{ {
Super::Serialize (arc); Super::Serialize (arc);
arc << m_Sector << Channel; arc("sector",m_Sector)
("channel", Channel);
} }
//========================================================================== //==========================================================================

View file

@ -20,7 +20,7 @@ class DSeqNode : public DObject
DECLARE_CLASS (DSeqNode, DObject) DECLARE_CLASS (DSeqNode, DObject)
HAS_OBJECT_POINTERS HAS_OBJECT_POINTERS
public: public:
void Serialize(FArchive &arc); void Serialize(FSerializer &arc);
void StopAndDestroy (); void StopAndDestroy ();
void Destroy (); void Destroy ();
void Tick (); void Tick ();
@ -38,7 +38,7 @@ public:
inline static DSeqNode *FirstSequence() { return SequenceListHead; } inline static DSeqNode *FirstSequence() { return SequenceListHead; }
inline DSeqNode *NextSequence() const { return m_Next; } inline DSeqNode *NextSequence() const { return m_Next; }
static void SerializeSequences (FArchive &arc); static void SerializeSequences (FSerializer &arc);
protected: protected:
DSeqNode (); DSeqNode ();

View file

@ -2237,7 +2237,7 @@ static FArchive &operator<<(FArchive &arc, FSoundChan &chan)
switch (chan.SourceType) switch (chan.SourceType)
{ {
case SOURCE_None: break; case SOURCE_None: break;
case SOURCE_Actor: arc << chan.Actor; break; //case SOURCE_Actor: arc << chan.Actor; break;
case SOURCE_Sector: arc << chan.Sector; break; case SOURCE_Sector: arc << chan.Sector; break;
case SOURCE_Polyobj: /*arc << chan.Poly;*/ break; case SOURCE_Polyobj: /*arc << chan.Poly;*/ break;
case SOURCE_Unattached: arc << chan.Point[0] << chan.Point[1] << chan.Point[2]; break; case SOURCE_Unattached: arc << chan.Point[0] << chan.Point[1] << chan.Point[2]; break;
@ -2324,7 +2324,7 @@ void S_SerializeSounds(FArchive &arc)
// sounds might be heard briefly before pausing for the wipe. // sounds might be heard briefly before pausing for the wipe.
RestartEvictionsAt = level.time + 2; RestartEvictionsAt = level.time + 2;
} }
DSeqNode::SerializeSequences(arc); //DSeqNode::SerializeSequences(arc);
GSnd->Sync(false); GSnd->Sync(false);
GSnd->UpdateSounds(); GSnd->UpdateSounds();
} }

View file

@ -35,260 +35,10 @@
#define NEW_SPRITE ((BYTE)11) // A new sprite name follows #define NEW_SPRITE ((BYTE)11) // A new sprite name follows
#define OLD_SPRITE ((BYTE)12) // Reference to an old sprite name follows #define OLD_SPRITE ((BYTE)12) // Reference to an old sprite name follows
inline FArchive &operator<< (FArchive &arc, FLinkedSector &link)
{
arc << link.Sector << link.Type;
return arc;
}
//
// P_ArchiveWorld
//
void P_SerializeWorld (FArchive &arc)
{
int i, j;
sector_t *sec;
line_t *li;
zone_t *zn;
// do sectors
for (i = 0, sec = sectors; i < numsectors; i++, sec++)
{
arc << sec->floorplane
<< sec->ceilingplane;
arc << sec->lightlevel;
arc << sec->special;
arc << sec->soundtraversed
<< sec->seqType
<< sec->friction
<< sec->movefactor
<< sec->stairlock
<< sec->prevsec
<< sec->nextsec
<< sec->planes[sector_t::floor]
<< sec->planes[sector_t::ceiling]
<< sec->heightsec
<< sec->bottommap << sec->midmap << sec->topmap
<< sec->gravity;
P_SerializeTerrain(arc, sec->terrainnum[0]);
P_SerializeTerrain(arc, sec->terrainnum[1]);
arc << sec->damageamount;
arc << sec->damageinterval
<< sec->leakydamage
<< sec->damagetype
<< sec->sky
<< sec->MoreFlags
<< sec->Flags
<< sec->Portals[sector_t::floor] << sec->Portals[sector_t::ceiling]
<< sec->ZoneNumber;
arc << sec->interpolations[0]
<< sec->interpolations[1]
<< sec->interpolations[2]
<< sec->interpolations[3]
<< sec->SeqName;
sec->e->Serialize(arc);
if (arc.IsStoring ())
{
arc << sec->ColorMap->Color
<< sec->ColorMap->Fade;
BYTE sat = sec->ColorMap->Desaturate;
arc << sat;
}
else
{
PalEntry color, fade;
BYTE desaturate;
arc << color << fade
<< desaturate;
sec->ColorMap = GetSpecialLights (color, fade, desaturate);
}
}
// do lines
for (i = 0, li = lines; i < numlines; i++, li++)
{
arc << li->flags
<< li->activation
<< li->special
<< li->alpha;
if (P_IsACSSpecial(li->special))
{
P_SerializeACSScriptNumber(arc, li->args[0], false);
}
else
{
arc << li->args[0];
}
arc << li->args[1] << li->args[2] << li->args[3] << li->args[4];
arc << li->portalindex;
for (j = 0; j < 2; j++)
{
if (li->sidedef[j] == NULL)
continue;
side_t *si = li->sidedef[j];
arc << si->textures[side_t::top]
<< si->textures[side_t::mid]
<< si->textures[side_t::bottom]
<< si->Light
<< si->Flags
<< si->LeftSide
<< si->RightSide
<< si->Index;
}
}
// do zones
unsigned numzones = Zones.Size();
arc << numzones;
if (arc.IsLoading())
{
Zones.Resize(numzones);
}
for (i = 0, zn = &Zones[0]; i < (int)numzones; ++i, ++zn)
{
arc << zn->Environment;
}
arc << linePortals << sectorPortals;
P_CollectLinkedPortals();
}
void P_SerializeWorldActors(FArchive &arc)
{
int i;
sector_t *sec;
line_t *line;
for (i = 0, sec = sectors; i < numsectors; i++, sec++)
{
arc << sec->SoundTarget
<< sec->SecActTarget
<< sec->floordata
<< sec->ceilingdata
<< sec->lightingdata;
}
for (auto &s : sectorPortals)
{
arc << s.mSkybox;
}
for (i = 0, line = lines; i < numlines; i++, line++)
{
for (int s = 0; s < 2; s++)
{
if (line->sidedef[s] != NULL)
{
//DBaseDecal::SerializeChain(arc, &line->sidedef[s]->AttachedDecals);
}
}
}
}
void extsector_t::Serialize(FArchive &arc)
{
arc << FakeFloor.Sectors
<< Midtex.Floor.AttachedLines
<< Midtex.Floor.AttachedSectors
<< Midtex.Ceiling.AttachedLines
<< Midtex.Ceiling.AttachedSectors
<< Linked.Floor.Sectors
<< Linked.Ceiling.Sectors;
}
FArchive &operator<< (FArchive &arc, side_t::part &p)
{
arc << p.xOffset << p.yOffset << p.interpolation << p.texture
<< p.xScale << p.yScale;// << p.Light;
return arc;
}
FArchive &operator<< (FArchive &arc, sector_t::splane &p)
{
arc << p.xform.xOffs << p.xform.yOffs << p.xform.xScale << p.xform.yScale
<< p.xform.Angle << p.xform.baseyOffs << p.xform.baseAngle
<< p.Flags << p.Light << p.Texture << p.TexZ << p.alpha;
return arc;
}
//==========================================================================
//
// ArchiveSubsectors
//
//==========================================================================
void RecalculateDrawnSubsectors();
void P_SerializeSubsectors(FArchive &arc)
{
int num_verts, num_subs, num_nodes;
BYTE by;
if (arc.IsStoring())
{
if (hasglnodes)
{
arc << numvertexes << numsubsectors << numnodes; // These are only for verification
for(int i=0;i<numsubsectors;i+=8)
{
by = 0;
for(int j=0;j<8;j++)
{
if (i+j<numsubsectors && (subsectors[i+j].flags & SSECF_DRAWN))
{
by |= (1<<j);
}
}
arc << by;
}
}
else
{
int v = 0;
arc << v << v << v;
}
}
else
{
arc << num_verts << num_subs << num_nodes;
if (num_verts != numvertexes ||
num_subs != numsubsectors ||
num_nodes != numnodes)
{
// Nodes don't match - we can't use this info
for(int i=0;i<num_subs;i+=8)
{
// Skip the subsector info.
arc << by;
}
if (hasglnodes)
{
RecalculateDrawnSubsectors();
}
return;
}
else
{
for(int i=0;i<numsubsectors;i+=8)
{
arc << by;
for(int j=0;j<8;j++)
{
if ((by & (1<<j)) && i+j<numsubsectors)
{
subsectors[i+j].flags |= SSECF_DRAWN;
}
}
}
}
}
}
FArchive &FArchive::WriteObject (DObject *obj) FArchive &FArchive::WriteObject (DObject *obj)
{ {
#if 0
player_t *player; player_t *player;
BYTE id[2]; BYTE id[2];
@ -387,49 +137,10 @@ FArchive &FArchive::WriteObject (DObject *obj)
} }
} }
} }
#endif
return *this; return *this;
} }
void AActor::Serialize(FArchive &arc)
{
Super::Serialize(arc);
{
FString tagstr;
if (arc.IsStoring() && Tag != NULL && Tag->Len() > 0) tagstr = *Tag;
arc << tagstr;
if (arc.IsLoading())
{
if (tagstr.Len() == 0) Tag = NULL;
else Tag = mStringPropertyData.Alloc(tagstr);
}
}
if (arc.IsLoading ())
{
touching_sectorlist = NULL;
LinkToWorld(false, Sector);
AddToHash ();
SetShade (fillcolor);
if (player)
{
if (playeringame[player - players] &&
player->cls != NULL &&
!(flags4 & MF4_NOSKIN) &&
state->sprite == GetDefaultByType (player->cls)->SpawnState->sprite)
{ // Give player back the skin
sprite = skins[player->userinfo.GetSkin()].sprite;
}
if (Speed == 0)
{
Speed = GetDefault()->Speed;
}
}
ClearInterpolation();
UpdateWaterLevel(false);
}
}
FArchive &operator<< (FArchive &arc, sector_t *&sec) FArchive &operator<< (FArchive &arc, sector_t *&sec)
{ {
@ -532,12 +243,6 @@ FArchive &operator<< (FArchive &arc, FState *&state)
return arc; return arc;
} }
void DObject::Serialize(FArchive &arc)
{
ObjectFlags |= OF_SerialSuccess;
}
FArchive &operator<< (FArchive &arc, secplane_t &plane) FArchive &operator<< (FArchive &arc, secplane_t &plane)
{ {
arc << plane.normal << plane.D; arc << plane.normal << plane.D;
@ -549,37 +254,6 @@ FArchive &operator<< (FArchive &arc, secplane_t &plane)
return arc; return arc;
} }
FArchive &operator<< (FArchive &arc, botskill_t &skill)
{
return arc << skill.aiming << skill.perfection << skill.reaction << skill.isp;
}
void DBot::Serialize(FArchive &arc)
{
Super::Serialize(arc);
arc << player
<< Angle
<< dest
<< prev
<< enemy
<< missile
<< mate
<< last_mate
<< skill
<< t_active
<< t_respawn
<< t_strafe
<< t_react
<< t_fight
<< t_roam
<< t_rocket
<< first_shot
<< sleft
<< allround
<< increase
<< old;
}
void P_SerializeACSScriptNumber(FArchive &arc, int &scriptnum, bool was2byte) void P_SerializeACSScriptNumber(FArchive &arc, int &scriptnum, bool was2byte)
{ {
arc << scriptnum; arc << scriptnum;
@ -598,46 +272,3 @@ void P_SerializeACSScriptNumber(FArchive &arc, int &scriptnum, bool was2byte)
} }
} }
} }
//============================================================================
//
// Save a line portal for savegames.
//
//============================================================================
FArchive &operator<< (FArchive &arc, FLinePortal &port)
{
arc << port.mOrigin
<< port.mDestination
<< port.mDisplacement
<< port.mType
<< port.mFlags
<< port.mDefFlags
<< port.mAlign;
return arc;
}
//============================================================================
//
// Save a sector portal for savegames.
//
//============================================================================
FArchive &operator<< (FArchive &arc, FSectorPortal &port)
{
arc << port.mType
<< port.mFlags
<< port.mPartner
<< port.mPlane
<< port.mOrigin
<< port.mDestination
<< port.mDisplacement
<< port.mPlaneZ;
if (arc.IsLoading())
{
port.mSkybox = nullptr;
}
return arc;
}