- Fixed: Because PClass is a child of DObject now, attempts to serialize them get caught by

the DObject serialization template. Therefore, FArchive::SerializeObject() needs to be
  able to handle them specially from other objects.

SVN r3924 (scripting)
This commit is contained in:
Randy Heit 2012-10-30 01:38:05 +00:00
parent e7168b3a51
commit 80782d7e5e
3 changed files with 21 additions and 21 deletions

View file

@ -1024,6 +1024,8 @@ FArchive &FArchive::SerializePointer (void *ptrbase, BYTE **ptr, DWORD elemSize)
FArchive &FArchive::SerializeObject (DObject *&object, PClass *type) FArchive &FArchive::SerializeObject (DObject *&object, PClass *type)
{ {
if (!type->IsDescendantOf(RUNTIME_CLASS(PClass)))
{ // a regular object
if (IsStoring()) if (IsStoring())
{ {
return WriteObject(object); return WriteObject(object);
@ -1033,6 +1035,19 @@ FArchive &FArchive::SerializeObject (DObject *&object, PClass *type)
return ReadObject(object, type); return ReadObject(object, type);
} }
} }
else
{ // a class object
if (IsStoring())
{
UserWriteClass((PClass *)object);
}
else
{
UserReadClass(object);
}
return *this;
}
}
FArchive &FArchive::WriteObject (DObject *obj) FArchive &FArchive::WriteObject (DObject *obj)
{ {
@ -1493,19 +1508,6 @@ void FArchive::UserReadClass (PClass *&type)
} }
} }
FArchive &operator<< (FArchive &arc, PClass *&info)
{
if (arc.IsStoring ())
{
arc.UserWriteClass (info);
}
else
{
arc.UserReadClass (info);
}
return arc;
}
FArchive &operator<< (FArchive &arc, sector_t *&sec) FArchive &operator<< (FArchive &arc, sector_t *&sec)
{ {
return arc.SerializePointer (sectors, (BYTE **)&sec, sizeof(*sectors)); return arc.SerializePointer (sectors, (BYTE **)&sec, sizeof(*sectors));

View file

@ -275,8 +275,6 @@ inline FArchive &operator<< (FArchive &arc, T* &object)
return arc.SerializeObject ((DObject*&)object, RUNTIME_TEMPLATE_CLASS(T)); return arc.SerializeObject ((DObject*&)object, RUNTIME_TEMPLATE_CLASS(T));
} }
FArchive &operator<< (FArchive &arc, PClass * &info);
class FFont; class FFont;
FArchive &SerializeFFontPtr (FArchive &arc, FFont* &font); FArchive &SerializeFFontPtr (FArchive &arc, FFont* &font);
template<> inline FArchive &operator<< <FFont> (FArchive &arc, FFont* &font) template<> inline FArchive &operator<< <FFont> (FArchive &arc, FFont* &font)

View file

@ -137,7 +137,7 @@ void SetupPlayerClasses ()
PlayerClasses.Clear(); PlayerClasses.Clear();
for (unsigned i = 0; i < gameinfo.PlayerClasses.Size(); i++) for (unsigned i = 0; i < gameinfo.PlayerClasses.Size(); i++)
{ {
PClassActor *cls = PClass::FindActor(gameinfo.PlayerClasses[i]);; PClassActor *cls = PClass::FindActor(gameinfo.PlayerClasses[i]);
if (ValidatePlayerClass(cls, gameinfo.PlayerClasses[i])) if (ValidatePlayerClass(cls, gameinfo.PlayerClasses[i]))
{ {
newclass.Flags = 0; newclass.Flags = 0;