From 5c7872cbc0eb8cbb80d26ab147f894434ee84935 Mon Sep 17 00:00:00 2001 From: Misha <106913236+MishaProductions@users.noreply.github.com> Date: Sun, 28 Jan 2024 15:41:58 -0500 Subject: [PATCH] fixes --- LEGO1/lego/legoomni/include/legoomni.h | 2 +- LEGO1/lego/legoomni/src/entity/legoworld.cpp | 6 -- LEGO1/lego/legoomni/src/main/legoomni.cpp | 66 ++++++++++++++------ 3 files changed, 49 insertions(+), 25 deletions(-) diff --git a/LEGO1/lego/legoomni/include/legoomni.h b/LEGO1/lego/legoomni/include/legoomni.h index 18201d9a..7a8ee7f0 100644 --- a/LEGO1/lego/legoomni/include/legoomni.h +++ b/LEGO1/lego/legoomni/include/legoomni.h @@ -105,7 +105,7 @@ class LegoOmni : public MxOmni { LegoWorld* FindWorld(const MxAtomId& p_atom, MxS32 p_entityid); void AddWorld(LegoWorld* p_world); - void DeleteEntity(LegoEntity* p_entity); + void DeleteWorld(LegoWorld* p_world); void FUN_1005b4f0(MxBool p_disable, MxU16 p_flags); LegoVideoManager* GetVideoManager() { return (LegoVideoManager*) m_videoManager; } diff --git a/LEGO1/lego/legoomni/src/entity/legoworld.cpp b/LEGO1/lego/legoomni/src/entity/legoworld.cpp index da4da276..deaf0ce7 100644 --- a/LEGO1/lego/legoomni/src/entity/legoworld.cpp +++ b/LEGO1/lego/legoomni/src/entity/legoworld.cpp @@ -485,12 +485,6 @@ MxCore* LegoWorld::Find(const MxAtomId& p_atom, MxS32 p_entityId) return NULL; } -// STUB: LEGO1 0x10021790 -MxCore* LegoWorld::FUN_10021790(const MxAtomId& p_atom, MxS32 p_objectId) -{ - return NULL; -} - // STUB: LEGO1 0x10021a70 void LegoWorld::VTable0x68(MxBool p_add) { diff --git a/LEGO1/lego/legoomni/src/main/legoomni.cpp b/LEGO1/lego/legoomni/src/main/legoomni.cpp index 433af66d..697fb44e 100644 --- a/LEGO1/lego/legoomni/src/main/legoomni.cpp +++ b/LEGO1/lego/legoomni/src/main/legoomni.cpp @@ -606,15 +606,44 @@ void LegoOmni::AddWorld(LegoWorld* p_world) m_worldList->Append(p_world); } -// STUB: LEGO1 0x1005adb0 -void LegoOmni::DeleteEntity(LegoEntity* p_entity) +// FUNCTION: LEGO1 0x1005adb0 +void LegoOmni::DeleteWorld(LegoWorld* p_world) { + if (m_worldList) { + LegoWorldListCursor cursor(m_worldList); + + while (cursor.Find(p_world)) { + cursor.Detach(); + + if (m_currentWorld == p_world) { + m_currentWorld = NULL; + } + + delete p_world; + break; + } + } } -// STUB: LEGO1 0x1005af10 -void LegoOmni::RemoveWorld(const MxAtomId&, MxLong) +// FUNCTION: LEGO1 0x1005af10 +void LegoOmni::RemoveWorld(const MxAtomId& p_atom, MxLong p_objectId) { - // TODO + if (m_worldList) { + LegoWorldListCursor cursor(m_worldList); + LegoWorldListCursor cursor2(m_worldList); // not sure why there are 2 cursors used. + LegoWorld* world; + + while (cursor.Next(world)) { + { + if ((p_objectId == -1 || world->GetEntityId() == p_objectId) && + (!p_atom.GetInternal() || world->GetAtom() == p_atom)) { + cursor.Detach(); + + delete world; + } + } + } + } } // FUNCTION: LEGO1 0x1005b0c0 @@ -638,25 +667,26 @@ LegoWorld* LegoOmni::FindWorld(const MxAtomId& p_atom, MxS32 p_entityid) void LegoOmni::DeleteObject(MxDSAction& p_dsAction) { if (p_dsAction.GetAtomId().GetInternal() != NULL) { - LegoEntity* entity = FindByEntityIdOrAtomId(p_dsAction.GetAtomId(), p_dsAction.GetObjectId()); - if (entity) { - DeleteEntity(entity); + LegoWorld* world = FindWorld(p_dsAction.GetAtomId(), p_dsAction.GetObjectId()); + if (world) { + DeleteWorld(world); return; } if (m_currentWorld != NULL) { - MxCore* entity2 = m_currentWorld->FUN_10021790(p_dsAction.GetAtomId(), p_dsAction.GetObjectId()); - m_currentWorld->EndAction(entity2); - - if (entity2->IsA("MxPresenter")) { - Streamer()->FUN_100b98f0(((MxPresenter*) entity2)->GetAction()); - ((MxPresenter*) entity2)->EndAction(); + MxCore* entity = m_currentWorld->Find(p_dsAction.GetAtomId(), p_dsAction.GetObjectId()); + if (entity) { + m_currentWorld->Remove(entity); + if (entity->IsA("MxPresenter")) { + Streamer()->FUN_100b98f0(((MxPresenter*) entity)->GetAction()); + ((MxPresenter*) entity)->EndAction(); + } + else { + delete entity; + } + return; } - else { - delete entity2; - } - return; } } MxOmni::DeleteObject(p_dsAction);