- Fixed: When returning to a hub map, inventory belonging to the temporary

copies of the players stored in the archive would be destroyed and break
  apart the STAT_INVENTORY thinker list. Now they aren't destroyed while
  loading the archive but are unlinked from the inventory list instead, so
  the garbage collector will get them later.
- Changed pointer substitution to return the number of pointers changed.


SVN r803 (trunk)
This commit is contained in:
Randy Heit 2008-03-13 23:00:33 +00:00
commit 9b17dea727
8 changed files with 93 additions and 54 deletions

View file

@ -1005,10 +1005,6 @@ FArchive &FArchive::SerializeObject (DObject *&object, PClass *type)
{
if (IsStoring ())
{
if (object != (DObject*)~0)
{
GC::ReadBarrier(object);
}
return WriteObject (object);
}
else
@ -1032,6 +1028,13 @@ FArchive &FArchive::WriteObject (DObject *obj)
id[0] = M1_OBJ;
Write (id, 1);
}
else if (obj->ObjectFlags & OF_EuthanizeMe)
{
// Objects that want to die are not saved to the archive, but
// we leave the pointers to them alone.
id[0] = NULL_OBJ;
Write (id, 1);
}
else
{
const PClass *type = RUNTIME_TYPE(obj);
@ -1159,11 +1162,20 @@ FArchive &FArchive::ReadObject (DObject* &obj, PClass *wanttype)
{
// When the temporary player's inventory items were loaded,
// they became owned by the real player. Undo that now.
for (AInventory *item = tempobj->Inventory;
item != NULL; item = item->Inventory)
AInventory *item;
for (item = tempobj->Inventory; item != NULL; item = item->Inventory)
{
item->Owner = tempobj;
}
item = tempobj->Inventory;
tempobj->Inventory = NULL;
#ifdef _DEBUG
// The only references to this inventory list should be from the
// temporary player, so they will be freed when a collection occurs.
size_t a = 0;
assert(item == NULL || (a = DObject::StaticPointerSubstitution(item, NULL)) == 0);
#endif
tempobj->Destroy ();
}
else