From afa022605a3698e099c7a7db2376f8a46fd26349 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 28 Apr 2015 19:03:52 +0200 Subject: [PATCH] - some more fixes of 'Restart'. Still not working as intended. --- src/dobjtype.cpp | 2 ++ src/fragglescript/t_fs.h | 1 + src/fragglescript/t_script.cpp | 37 +++++++++++++++------------- src/thingdef/thingdef.cpp | 1 + src/thingdef/thingdef_data.cpp | 1 + src/thingdef/thingdef_properties.cpp | 2 ++ 6 files changed, 27 insertions(+), 17 deletions(-) diff --git a/src/dobjtype.cpp b/src/dobjtype.cpp index 1786eab77..18a3b47f0 100644 --- a/src/dobjtype.cpp +++ b/src/dobjtype.cpp @@ -45,6 +45,7 @@ #include "v_text.h" #include "a_pickups.h" #include "d_player.h" +#include "fragglescript/t_fs.h" // MACROS ------------------------------------------------------------------ @@ -2032,6 +2033,7 @@ void PClass::StaticShutdown () TArray uniqueFPs(64); unsigned int i, j; + FS_Close(); // this must be done before the classes get deleted. for (i = 0; i < PClass::AllClasses.Size(); ++i) { PClass *type = PClass::AllClasses[i]; diff --git a/src/fragglescript/t_fs.h b/src/fragglescript/t_fs.h index 91f90edb3..78a6f9337 100644 --- a/src/fragglescript/t_fs.h +++ b/src/fragglescript/t_fs.h @@ -10,5 +10,6 @@ class AActor; void T_PreprocessScripts(); void T_LoadScripts(MapData * map); void T_AddSpawnedThing(AActor * ); +void FS_Close(); #endif diff --git a/src/fragglescript/t_script.cpp b/src/fragglescript/t_script.cpp index 5f62fe6ac..48f0c6250 100644 --- a/src/fragglescript/t_script.cpp +++ b/src/fragglescript/t_script.cpp @@ -670,24 +670,28 @@ void FS_Close() int i; DFsVariable *current, *next; - // we have to actually delete the global variables if we don't want - // to get them reported as memory leaks. - for(i=0; ivariables[i]; - - while(current) + if (global_script != NULL) + { + // we have to actually delete the global variables if we don't want + // to get them reported as memory leaks. + for (i = 0; i < VARIABLESLOTS; i++) { - next = current->next; // save for after freeing - - current->ObjectFlags |= OF_YesReallyDelete; - delete current; - current = next; // go to next in chain + current = global_script->variables[i]; + + while (current) + { + next = current->next; // save for after freeing + + current->ObjectFlags |= OF_YesReallyDelete; + delete current; + current = next; // go to next in chain + } } - } - GC::DelSoftRoot(global_script); - global_script->ObjectFlags |= OF_YesReallyDelete; - delete global_script; + GC::DelSoftRoot(global_script); + global_script->ObjectFlags |= OF_YesReallyDelete; + delete global_script; + global_script = NULL; + } } void T_Init() @@ -701,7 +705,6 @@ void T_Init() global_script = new DFsScript; GC::AddSoftRoot(global_script); init_functions(); - atterm(FS_Close); } } diff --git a/src/thingdef/thingdef.cpp b/src/thingdef/thingdef.cpp index 60a0da8de..c0097a053 100644 --- a/src/thingdef/thingdef.cpp +++ b/src/thingdef/thingdef.cpp @@ -218,6 +218,7 @@ void FinishActor(const FScriptPosition &sc, PClassActor *info, Baggage &bag) if (bag.DropItemSet) { info->DropItems = bag.DropItemList; + GC::WriteBarrier(info, info->DropItems); } if (info->IsDescendantOf (RUNTIME_CLASS(AInventory))) { diff --git a/src/thingdef/thingdef_data.cpp b/src/thingdef/thingdef_data.cpp index d161fef6d..ca4c9b487 100644 --- a/src/thingdef/thingdef_data.cpp +++ b/src/thingdef/thingdef_data.cpp @@ -594,6 +594,7 @@ void InitThingdef() } // Create a sorted list of native action functions + AFTable.Clear(); if (AFTable.Size() == 0) { FAutoSegIterator probe(ARegHead, ARegTail); diff --git a/src/thingdef/thingdef_properties.cpp b/src/thingdef/thingdef_properties.cpp index 61098797f..17d080090 100644 --- a/src/thingdef/thingdef_properties.cpp +++ b/src/thingdef/thingdef_properties.cpp @@ -797,6 +797,7 @@ DEFINE_PROPERTY(dropitem, S_i_i, Actor) } di->Next = bag.DropItemList; bag.DropItemList = di; + GC::WriteBarrier(di); } //========================================================================== @@ -2739,6 +2740,7 @@ DEFINE_CLASS_PROPERTY_PREFIX(player, startitem, S_i, PlayerPawn) } di->Next = bag.DropItemList; bag.DropItemList = di; + GC::WriteBarrier(di); } //==========================================================================