Skip to content

Commit

Permalink
Fix up global vector clearing
Browse files Browse the repository at this point in the history
  • Loading branch information
ZivDero committed Oct 27, 2024
1 parent bb94843 commit 4794f05
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 29 deletions.
13 changes: 0 additions & 13 deletions src/new/spawnmanager/spawnmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -941,16 +941,3 @@ int SpawnManagerClass::Preparing_Count()
}
return count;
}

/**
* Removes all SpawnManagers from the game world.
*
* @author: ZivDero
*/
void SpawnManagerClass::Clear_All()
{
for (int i = 0; i < SpawnManagers.Count(); ++i)
delete SpawnManagers[i];

SpawnManagers.Clear();
}
2 changes: 0 additions & 2 deletions src/new/spawnmanager/spawnmanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,6 @@ class DECLSPEC_UUID(UUID_SPAWN_MANAGER)
int Docked_Count();
int Preparing_Count();

static void Clear_All();

SpawnManagerClass(const SpawnManagerClass&) = delete;
SpawnManagerClass& operator= (const SpawnManagerClass&) = delete;

Expand Down
4 changes: 0 additions & 4 deletions src/vinifera/vinifera_functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -668,10 +668,6 @@ bool Vinifera_Shutdown()
* Cleanup global heaps/vectors.
*/
TheaterTypes.Clear();
ArmorTypes.Clear();
RocketTypes.Clear();
SpawnManagerClass::Clear_All();
MouseTypes.Clear();

/**
* Cleanup global extension instances.
Expand Down
24 changes: 19 additions & 5 deletions src/vinifera/vinifera_hooks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@
#include "ebolt.h"
#include "kamikazetracker.h"
#include "spawnmanager.h"
#include "armortype.h"
#include "rockettype.h"


/**
Expand Down Expand Up @@ -78,21 +80,33 @@ static void _Detach_This_From_All_Intercept(TARGET target, bool all)
*/
static void _Free_Heaps_Intercept()
{
Free_Heaps();

/**
* Cleanup global heaps/vectors.
*/
++ScenarioInit;

while (ArmorTypes.Count()) {
delete ArmorTypes[0];
}
Remove_All_Inactive();

while (RocketTypes.Count()) {
delete RocketTypes[0];
}
Remove_All_Inactive();

while (SpawnManagers.Count()) {
delete SpawnManagers[0];
}
Remove_All_Inactive();

EBoltClass::Clear_All();
ArmorTypes.Clear();
RocketTypes.Clear();
SpawnManagerClass::Clear_All();

Extension::Free_Heaps();

--ScenarioInit;

Free_Heaps();
}


Expand Down
5 changes: 0 additions & 5 deletions src/vinifera/vinifera_saveload.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -407,11 +407,6 @@ bool Vinifera_Get_All(IStream *pStm, bool load_net)
DEBUG_INFO("About to call Clear_Scenario()...\n");
Clear_Scenario();

/**
* Clear the ArmorTypes heap.
*/
ArmorTypes.Clear();

/**
* Now the scenario data has been cleaned up, we can now tell the extension
* hooks that we will be creating the extension classes via the class factories.
Expand Down

0 comments on commit 4794f05

Please sign in to comment.