summaryrefslogtreecommitdiff
path: root/src/engine/editor/Editor.cpp
diff options
context:
space:
mode:
authorMegaMech <7255464+MegaMech@users.noreply.github.com>2025-05-23 16:50:26 -0600
committerMegaMech <7255464+MegaMech@users.noreply.github.com>2025-05-23 16:50:26 -0600
commit25b68921ad4cece662b2d20885103d8cc998dac5 (patch)
treebff02190a71052cfc9897444b3e3e0fc19e20718 /src/engine/editor/Editor.cpp
parentc4721b2df546b77773e184c8c2ce3b3d83b17542 (diff)
parentc2ddd2c25626b2797b9f730d77118f0e96131108 (diff)
Merge branch 'transformsharedfromptr' of https://github.com/HarbourMasters/SpaghettiKart into transformsharedfromptr
Diffstat (limited to 'src/engine/editor/Editor.cpp')
-rw-r--r--src/engine/editor/Editor.cpp19
1 files changed, 15 insertions, 4 deletions
diff --git a/src/engine/editor/Editor.cpp b/src/engine/editor/Editor.cpp
index 446da7487..23a947a09 100644
--- a/src/engine/editor/Editor.cpp
+++ b/src/engine/editor/Editor.cpp
@@ -30,6 +30,11 @@ namespace Editor {
Editor::Editor() {
}
+ Editor::~Editor() {
+ ClearObjects();
+ ClearMatrixPool();
+ }
+
void Editor::Load() {
printf("Editor: Loading Editor...\n");
eObjectPicker.Load();
@@ -58,10 +63,16 @@ namespace Editor {
Ship::Coords mousePos = wnd->GetMousePos();
bool isMouseDown = wnd->GetMouseState(Ship::LUS_MOUSE_BTN_LEFT);
- eGameObjects.erase(
- std::remove_if(eGameObjects.begin(), eGameObjects.end(),
- [](const auto& object) { return (*object->DespawnFlag) == object->DespawnValue; }),
- eGameObjects.end());
+ auto it = std::remove_if(eGameObjects.begin(), eGameObjects.end(),
+ [](auto& object) {
+ if (*object->DespawnFlag == object->DespawnValue) {
+ delete object; // Free the pointed-to memory
+ return true; // Remove the pointer from the vector
+ }
+ return false;
+ });
+
+ eGameObjects.erase(it, eGameObjects.end());
if (isMouseDown && !wasMouseDown) {
// Mouse just pressed (Pressed state)