- some more fixes of 'Restart'. Still not working as intended.

This commit is contained in:
Christoph Oelckers 2015-04-28 19:03:52 +02:00
parent 91b05366d6
commit afa022605a
6 changed files with 27 additions and 17 deletions

View file

@ -45,6 +45,7 @@
#include "v_text.h" #include "v_text.h"
#include "a_pickups.h" #include "a_pickups.h"
#include "d_player.h" #include "d_player.h"
#include "fragglescript/t_fs.h"
// MACROS ------------------------------------------------------------------ // MACROS ------------------------------------------------------------------
@ -2032,6 +2033,7 @@ void PClass::StaticShutdown ()
TArray<size_t *> uniqueFPs(64); TArray<size_t *> uniqueFPs(64);
unsigned int i, j; unsigned int i, j;
FS_Close(); // this must be done before the classes get deleted.
for (i = 0; i < PClass::AllClasses.Size(); ++i) for (i = 0; i < PClass::AllClasses.Size(); ++i)
{ {
PClass *type = PClass::AllClasses[i]; PClass *type = PClass::AllClasses[i];

View file

@ -10,5 +10,6 @@ class AActor;
void T_PreprocessScripts(); void T_PreprocessScripts();
void T_LoadScripts(MapData * map); void T_LoadScripts(MapData * map);
void T_AddSpawnedThing(AActor * ); void T_AddSpawnedThing(AActor * );
void FS_Close();
#endif #endif

View file

@ -670,24 +670,28 @@ void FS_Close()
int i; int i;
DFsVariable *current, *next; DFsVariable *current, *next;
// we have to actually delete the global variables if we don't want if (global_script != NULL)
// to get them reported as memory leaks. {
for(i=0; i<VARIABLESLOTS; i++) // we have to actually delete the global variables if we don't want
{ // to get them reported as memory leaks.
current = global_script->variables[i]; for (i = 0; i < VARIABLESLOTS; i++)
while(current)
{ {
next = current->next; // save for after freeing current = global_script->variables[i];
current->ObjectFlags |= OF_YesReallyDelete; while (current)
delete current; {
current = next; // go to next in chain next = current->next; // save for after freeing
current->ObjectFlags |= OF_YesReallyDelete;
delete current;
current = next; // go to next in chain
}
} }
} GC::DelSoftRoot(global_script);
GC::DelSoftRoot(global_script); global_script->ObjectFlags |= OF_YesReallyDelete;
global_script->ObjectFlags |= OF_YesReallyDelete; delete global_script;
delete global_script; global_script = NULL;
}
} }
void T_Init() void T_Init()
@ -701,7 +705,6 @@ void T_Init()
global_script = new DFsScript; global_script = new DFsScript;
GC::AddSoftRoot(global_script); GC::AddSoftRoot(global_script);
init_functions(); init_functions();
atterm(FS_Close);
} }
} }

View file

@ -218,6 +218,7 @@ void FinishActor(const FScriptPosition &sc, PClassActor *info, Baggage &bag)
if (bag.DropItemSet) if (bag.DropItemSet)
{ {
info->DropItems = bag.DropItemList; info->DropItems = bag.DropItemList;
GC::WriteBarrier(info, info->DropItems);
} }
if (info->IsDescendantOf (RUNTIME_CLASS(AInventory))) if (info->IsDescendantOf (RUNTIME_CLASS(AInventory)))
{ {

View file

@ -594,6 +594,7 @@ void InitThingdef()
} }
// Create a sorted list of native action functions // Create a sorted list of native action functions
AFTable.Clear();
if (AFTable.Size() == 0) if (AFTable.Size() == 0)
{ {
FAutoSegIterator probe(ARegHead, ARegTail); FAutoSegIterator probe(ARegHead, ARegTail);

View file

@ -797,6 +797,7 @@ DEFINE_PROPERTY(dropitem, S_i_i, Actor)
} }
di->Next = bag.DropItemList; di->Next = bag.DropItemList;
bag.DropItemList = di; bag.DropItemList = di;
GC::WriteBarrier(di);
} }
//========================================================================== //==========================================================================
@ -2739,6 +2740,7 @@ DEFINE_CLASS_PROPERTY_PREFIX(player, startitem, S_i, PlayerPawn)
} }
di->Next = bag.DropItemList; di->Next = bag.DropItemList;
bag.DropItemList = di; bag.DropItemList = di;
GC::WriteBarrier(di);
} }
//========================================================================== //==========================================================================