From ee2bcb4d531495cf9f41dfd4c7c82e873b729d36 Mon Sep 17 00:00:00 2001
From: Christian Semmler <mail@csemmler.com>
Date: Thu, 9 Jan 2025 17:31:45 -0700
Subject: [PATCH] Order symbols in `LegoWorld` (#1321)

* Partially order `LegoWorld` symbols

* Further order `LegoWorld`
---
 LEGO1/lego/legoomni/include/legoworld.h      | 44 ++++++++++++--------
 LEGO1/lego/legoomni/src/entity/legoworld.cpp | 16 -------
 LEGO1/omni/include/mxcollection.h            |  7 ++--
 LEGO1/omni/include/mxlist.h                  |  9 +---
 4 files changed, 31 insertions(+), 45 deletions(-)

diff --git a/LEGO1/lego/legoomni/include/legoworld.h b/LEGO1/lego/legoomni/include/legoworld.h
index 9845e451..5a89c5aa 100644
--- a/LEGO1/lego/legoomni/include/legoworld.h
+++ b/LEGO1/lego/legoomni/include/legoworld.h
@@ -1,15 +1,18 @@
 #ifndef LEGOWORLD_H
 #define LEGOWORLD_H
 
+// clang-format off
+#include "mxpresenterlist.h"
+#include "legoentitylist.h"
+#include "legocachesoundlist.h"
+// clang-format on
+
 #include "legoentity.h"
 #include "legomain.h"
 #include "legopathcontrollerlist.h"
-#include "mxpresenterlist.h"
 #include "roi/legoroi.h"
 
-class LegoCacheSoundList;
 class LegoCameraController;
-class LegoEntityList;
 class LegoPathBoundary;
 class LegoHideAnimPresenter;
 
@@ -44,8 +47,26 @@ public:
 	LegoWorld();
 	~LegoWorld() override; // vtable+0x00
 
-	MxLong Notify(MxParam& p_param) override; // vtable+0x04
-	MxResult Tickle() override;               // vtable+0x08
+	MxLong Notify(MxParam& p_param) override;         // vtable+0x04
+	MxResult Tickle() override;                       // vtable+0x08
+	MxResult Create(MxDSAction& p_dsAction) override; // vtable+0x18
+	void Destroy(MxBool p_fromDestructor) override;   // vtable+0x1c
+	virtual void ReadyWorld();                        // vtable+0x50
+	virtual LegoCameraController* VTable0x54();       // vtable+0x54
+	virtual void Add(MxCore* p_object);               // vtable+0x58
+
+	// The BETA10 match could also be LegoWorld::Escape(), only the child classes might be able to tell
+	// FUNCTION: LEGO1 0x1001d670
+	// FUNCTION: BETA10 0x10017530
+	virtual MxBool VTable0x5c() { return FALSE; } // vtable+0x5c
+
+	// FUNCTION: LEGO1 0x100010a0
+	virtual void VTable0x60() {} // vtable+0x60
+
+	// FUNCTION: LEGO1 0x1001d680
+	virtual MxBool Escape() { return FALSE; } // vtable+0x64
+
+	virtual void Enable(MxBool p_enable); // vtable+0x68
 
 	// FUNCTION: LEGO1 0x1001d690
 	// FUNCTION: BETA10 0x10017660
@@ -62,19 +83,6 @@ public:
 		return !strcmp(p_name, LegoWorld::ClassName()) || LegoEntity::IsA(p_name);
 	}
 
-	MxResult Create(MxDSAction& p_dsAction) override; // vtable+0x18
-	void Destroy(MxBool p_fromDestructor) override;   // vtable+0x1c
-	virtual void ReadyWorld();                        // vtable+0x50
-	virtual LegoCameraController* VTable0x54();       // vtable+0x54
-	virtual void Add(MxCore* p_object);               // vtable+0x58
-	virtual MxBool VTable0x5c();                      // vtable+0x5c
-
-	// FUNCTION: LEGO1 0x100010a0
-	virtual void VTable0x60() {} // vtable+0x60
-
-	virtual MxBool Escape();              // vtable+0x64
-	virtual void Enable(MxBool p_enable); // vtable+0x68
-
 	MxBool PresentersPending();
 	void Remove(MxCore* p_object);
 	MxResult PlaceActor(
diff --git a/LEGO1/lego/legoomni/src/entity/legoworld.cpp b/LEGO1/lego/legoomni/src/entity/legoworld.cpp
index e00d4365..658dc5fa 100644
--- a/LEGO1/lego/legoomni/src/entity/legoworld.cpp
+++ b/LEGO1/lego/legoomni/src/entity/legoworld.cpp
@@ -4,11 +4,9 @@
 #include "legoanimationmanager.h"
 #include "legoanimpresenter.h"
 #include "legobuildingmanager.h"
-#include "legocachesoundlist.h"
 #include "legocachesoundmanager.h"
 #include "legocameracontroller.h"
 #include "legocontrolmanager.h"
-#include "legoentitylist.h"
 #include "legogamestate.h"
 #include "legoinputmanager.h"
 #include "legolocomotionanimpresenter.h"
@@ -47,20 +45,6 @@ LegoWorld::LegoWorld() : m_list0x68(TRUE)
 	NotificationManager()->Register(this);
 }
 
-// FUNCTION: LEGO1 0x1001d670
-// FUNCTION: BETA10 0x10017530
-MxBool LegoWorld::VTable0x5c()
-{
-	// The BETA10 match could also be LegoWorld::Escape(), only the child classes might be able to tell
-	return FALSE;
-}
-
-// FUNCTION: LEGO1 0x1001d680
-MxBool LegoWorld::Escape()
-{
-	return FALSE;
-}
-
 // FUNCTION: LEGO1 0x1001dfa0
 LegoWorld::~LegoWorld()
 {
diff --git a/LEGO1/omni/include/mxcollection.h b/LEGO1/omni/include/mxcollection.h
index 0c21438c..7c008e49 100644
--- a/LEGO1/omni/include/mxcollection.h
+++ b/LEGO1/omni/include/mxcollection.h
@@ -12,13 +12,14 @@ public:
 		SetDestroy(Destroy);
 	}
 
+	virtual MxS8 Compare(T, T) { return 0; } // vtable+0x14
+
+	~MxCollection() override {}
+
 	static void Destroy(T) {}
 
 	void SetDestroy(void (*p_customDestructor)(T)) { this->m_customDestructor = p_customDestructor; }
 
-	~MxCollection() override {}
-	virtual MxS8 Compare(T, T) { return 0; }
-
 protected:
 	MxU32 m_count;                 // 0x08
 	void (*m_customDestructor)(T); // 0x0c
diff --git a/LEGO1/omni/include/mxlist.h b/LEGO1/omni/include/mxlist.h
index b020eeb3..6ab165e2 100644
--- a/LEGO1/omni/include/mxlist.h
+++ b/LEGO1/omni/include/mxlist.h
@@ -46,8 +46,7 @@ template <class T>
 class MxList : protected MxCollection<T> {
 public:
 	MxList() { m_first = m_last = NULL; }
-
-	~MxList() override;
+	~MxList() override { DeleteAll(); }
 
 	void Append(T p_obj) { InsertEntry(p_obj, this->m_last, NULL); }
 	void Prepend(T p_obj) { InsertEntry(p_obj, NULL, this->m_first); }
@@ -127,12 +126,6 @@ public:
 	MxPtrListCursor(MxPtrList<T>* p_list) : MxListCursor<T*>(p_list) {}
 };
 
-template <class T>
-MxList<T>::~MxList()
-{
-	DeleteAll();
-}
-
 // Delete entries and values
 template <class T>
 inline void MxList<T>::DeleteAll()