diff options
| author | MegaMech <7255464+MegaMech@users.noreply.github.com> | 2024-12-30 20:39:31 -0700 |
|---|---|---|
| committer | MegaMech <7255464+MegaMech@users.noreply.github.com> | 2024-12-30 20:39:31 -0700 |
| commit | 7ee714e4e93609a5dbf1dc648df0ce504e3d7284 (patch) | |
| tree | e63c623057b555fedd3d017b5d6c34d12de31098 /src/engine/GarbageCollector.cpp | |
| parent | 41fb92b7b989290947d8f39c442219afe12d0215 (diff) | |
| parent | 57afb90c3901b4c5dc586f1be3f6604c52c423d6 (diff) | |
Merge branch 'next' of https://github.com/MegaMech/SpaghettiKart into next
Diffstat (limited to 'src/engine/GarbageCollector.cpp')
| -rw-r--r-- | src/engine/GarbageCollector.cpp | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/engine/GarbageCollector.cpp b/src/engine/GarbageCollector.cpp new file mode 100644 index 000000000..926620fe1 --- /dev/null +++ b/src/engine/GarbageCollector.cpp @@ -0,0 +1,31 @@ +#include "GarbageCollector.h" +#include "World.h" + +void RunGarbageCollector() { + //CleanActors(); + CleanObjects(); +} + +void CleanActors() { + // for (auto actor = gWorldInstance.Actors.begin(); actor != gWorldInstance.Actors.end();) { + // OObject* act = *actor; // Get a mutable copy + // if (act->PendingDestroy) { + // delete act; + // actor = gWorldInstance.Objects.erase(actor); // Remove from container + // continue; + // } + // actor++; + // } +} + +void CleanObjects() { + for (auto object = gWorldInstance.Objects.begin(); object != gWorldInstance.Objects.end();) { + OObject* obj = *object; // Get a mutable copy + if (obj->PendingDestroy) { + delete obj; + object = gWorldInstance.Objects.erase(object); // Remove from container + continue; + } + object++; + } +}
\ No newline at end of file |
