From e1ce96c473b821368fa75f8ac7b5d65ae95c1a9c Mon Sep 17 00:00:00 2001
From: Christian Semmler <mail@csemmler.com>
Date: Thu, 16 Jan 2025 19:42:38 -0700
Subject: [PATCH] Order symbols until end of `LegoGameState` (#1340)

* Order `Ambulance`

* More ordering

* Order until `LegoGameState`

* Move
---
 CMakeLists.txt                                |  12 +-
 LEGO1/lego/legoomni/include/ambulance.h       |  40 +++-
 LEGO1/lego/legoomni/include/infocenterdoor.h  |  11 +-
 LEGO1/lego/legoomni/include/islepathactor.h   |   6 -
 .../legoomni/include/legobackgroundcolor.h    |  24 ---
 .../legoomni/include/legocharactermanager.h   |  11 +-
 .../legoomni/include/legofullscreenmovie.h    |  14 --
 LEGO1/lego/legoomni/include/legogamestate.h   |  34 +++-
 LEGO1/lego/legoomni/include/legovariables.h   |   9 -
 LEGO1/lego/legoomni/src/actors/ambulance.cpp  |  39 ----
 .../legoomni/src/actors/islepathactor.cpp     |   3 +-
 .../src/common/legobackgroundcolor.cpp        | 151 --------------
 .../src/common/legocharactermanager.cpp       |  22 ++-
 .../src/common/legofullscreenmovie.cpp        |  44 -----
 .../legoomni/src/common/legogamestate.cpp     | 184 +++++++++++++++++-
 .../legoomni/src/common/legovariables.cpp     |  22 ---
 LEGO1/lego/legoomni/src/race/carrace.cpp      |   1 -
 LEGO1/lego/legoomni/src/worlds/isle.cpp       |   1 -
 18 files changed, 290 insertions(+), 338 deletions(-)
 delete mode 100644 LEGO1/lego/legoomni/include/legobackgroundcolor.h
 delete mode 100644 LEGO1/lego/legoomni/include/legofullscreenmovie.h
 delete mode 100644 LEGO1/lego/legoomni/src/common/legobackgroundcolor.cpp
 delete mode 100644 LEGO1/lego/legoomni/src/common/legofullscreenmovie.cpp

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 2fc4a4ca..0cd5ffd2 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -334,15 +334,14 @@ function(add_lego_libraries NAME)
     LEGO1/lego/legoomni/src/paths/legopathactor.cpp
     LEGO1/lego/legoomni/src/common/legobuildingmanager.cpp
     LEGO1/lego/legoomni/src/worlds/isle.cpp
-    LEGO1/lego/legoomni/src/actors/ambulance.cpp
-    LEGO1/lego/legoomni/src/actors/pizza.cpp
     LEGO1/lego/legoomni/src/actors/motorcycle.cpp
+    LEGO1/lego/legoomni/src/actors/ambulance.cpp
+    LEGO1/lego/legoomni/src/worlds/infocenterdoor.cpp
+    LEGO1/lego/legoomni/src/common/legovariables.cpp
+    LEGO1/lego/legoomni/src/actors/pizza.cpp
+    LEGO1/lego/legoomni/src/common/legogamestate.cpp
     LEGO1/lego/legoomni/src/actors/act3ammo.cpp
     LEGO1/lego/legoomni/src/audio/legocachesoundmanager.cpp
-    LEGO1/lego/legoomni/src/worlds/infocenterdoor.cpp
-    LEGO1/lego/legoomni/src/common/legogamestate.cpp
-    LEGO1/lego/legoomni/src/common/legobackgroundcolor.cpp
-    LEGO1/lego/legoomni/src/common/legofullscreenmovie.cpp
     LEGO1/lego/legoomni/src/common/legoutils.cpp
     LEGO1/lego/legoomni/src/actors/act3actors.cpp
     LEGO1/lego/legoomni/src/control/legometerpresenter.cpp
@@ -360,7 +359,6 @@ function(add_lego_libraries NAME)
     LEGO1/lego/legoomni/src/video/legophonemepresenter.cpp
     LEGO1/lego/legoomni/src/video/legotexturepresenter.cpp
     LEGO1/lego/legoomni/src/worlds/legoact2.cpp
-    LEGO1/lego/legoomni/src/common/legovariables.cpp
     LEGO1/lego/legoomni/src/main/scripts.cpp
     LEGO1/lego/legoomni/src/entity/legoentitypresenter.cpp
     LEGO1/lego/legoomni/src/entity/legonavcontroller.cpp
diff --git a/LEGO1/lego/legoomni/include/ambulance.h b/LEGO1/lego/legoomni/include/ambulance.h
index 7bb1fd3f..97e6ba38 100644
--- a/LEGO1/lego/legoomni/include/ambulance.h
+++ b/LEGO1/lego/legoomni/include/ambulance.h
@@ -13,6 +13,40 @@ class AmbulanceMissionState : public LegoState {
 public:
 	AmbulanceMissionState();
 
+	// FUNCTION: LEGO1 0x10037440
+	// FUNCTION: BETA10 0x10024480
+	MxResult Serialize(LegoStorage* p_storage) override
+	{
+		LegoState::Serialize(p_storage);
+
+		if (p_storage->IsReadMode()) {
+			p_storage->ReadS16(m_peScore);
+			p_storage->ReadS16(m_maScore);
+			p_storage->ReadS16(m_paScore);
+			p_storage->ReadS16(m_niScore);
+			p_storage->ReadS16(m_laScore);
+			p_storage->ReadS16(m_peHighScore);
+			p_storage->ReadS16(m_maHighScore);
+			p_storage->ReadS16(m_paHighScore);
+			p_storage->ReadS16(m_niHighScore);
+			p_storage->ReadS16(m_laHighScore);
+		}
+		else if (p_storage->IsWriteMode()) {
+			p_storage->WriteS16(m_peScore);
+			p_storage->WriteS16(m_maScore);
+			p_storage->WriteS16(m_paScore);
+			p_storage->WriteS16(m_niScore);
+			p_storage->WriteS16(m_laScore);
+			p_storage->WriteS16(m_peHighScore);
+			p_storage->WriteS16(m_maHighScore);
+			p_storage->WriteS16(m_paHighScore);
+			p_storage->WriteS16(m_niHighScore);
+			p_storage->WriteS16(m_laHighScore);
+		}
+
+		return SUCCESS;
+	} // vtable+0x1c
+
 	// FUNCTION: LEGO1 0x10037600
 	// FUNCTION: BETA10 0x100246c0
 	const char* ClassName() const override // vtable+0x0c
@@ -27,8 +61,6 @@ public:
 		return !strcmp(p_name, AmbulanceMissionState::ClassName()) || LegoState::IsA(p_name);
 	}
 
-	MxResult Serialize(LegoStorage* p_storage) override; // vtable+0x1c
-
 	// FUNCTION: BETA10 0x10088770
 	MxS16 GetHighScore(MxU8 p_actorId)
 	{
@@ -118,6 +150,9 @@ public:
 	MxLong Notify(MxParam& p_param) override; // vtable+0x04
 	MxResult Tickle() override;               // vtable+0x08
 
+	// FUNCTION: LEGO1 0x10035f90
+	void Destroy(MxBool p_fromDestructor) override {} // vtable+0x1c
+
 	// FUNCTION: LEGO1 0x10035fa0
 	// FUNCTION: BETA10 0x100240b0
 	const char* ClassName() const override // vtable+0x0c
@@ -133,7 +168,6 @@ public:
 	}
 
 	MxResult Create(MxDSAction& p_dsAction) override;                              // vtable+0x18
-	void Destroy(MxBool p_fromDestructor) override;                                // vtable+0x1c
 	void Animate(float p_time) override;                                           // vtable+0x70
 	MxLong HandleClick() override;                                                 // vtable+0xcc
 	MxLong HandleControl(LegoControlManagerNotificationParam& p_param) override;   // vtable+0xd4
diff --git a/LEGO1/lego/legoomni/include/infocenterdoor.h b/LEGO1/lego/legoomni/include/infocenterdoor.h
index 10caba7d..c9bb841b 100644
--- a/LEGO1/lego/legoomni/include/infocenterdoor.h
+++ b/LEGO1/lego/legoomni/include/infocenterdoor.h
@@ -16,6 +16,9 @@ public:
 
 	MxLong Notify(MxParam& p_param) override; // vtable+0x04
 
+	// FUNCTION: LEGO1 0x100377a0
+	MxBool VTable0x5c() override { return TRUE; } // vtable+0x5c
+
 	// FUNCTION: LEGO1 0x100377b0
 	// FUNCTION: BETA10 0x10032790
 	const char* ClassName() const override // vtable+0x0c
@@ -32,12 +35,8 @@ public:
 
 	MxResult Create(MxDSAction& p_dsAction) override; // vtable+0x18
 	void ReadyWorld() override;                       // vtable+0x50
-
-	// FUNCTION: LEGO1 0x100377a0
-	MxBool VTable0x5c() override { return TRUE; } // vtable+0x5c
-
-	MxBool Escape() override;              // vtable+0x64
-	void Enable(MxBool p_enable) override; // vtable+0x68
+	MxBool Escape() override;                         // vtable+0x64
+	void Enable(MxBool p_enable) override;            // vtable+0x68
 
 	// SYNTHETIC: LEGO1 0x100378d0
 	// InfocenterDoor::`scalar deleting destructor'
diff --git a/LEGO1/lego/legoomni/include/islepathactor.h b/LEGO1/lego/legoomni/include/islepathactor.h
index e3a8bd37..46630e29 100644
--- a/LEGO1/lego/legoomni/include/islepathactor.h
+++ b/LEGO1/lego/legoomni/include/islepathactor.h
@@ -131,12 +131,6 @@ public:
 
 	void FUN_1001b660();
 
-	void Reset()
-	{
-		m_roi->SetVisibility(TRUE);
-		SetActorState(c_initial);
-	}
-
 	void SetWorld(LegoWorld* p_world) { m_world = p_world; }
 
 	static void RegisterSpawnLocations();
diff --git a/LEGO1/lego/legoomni/include/legobackgroundcolor.h b/LEGO1/lego/legoomni/include/legobackgroundcolor.h
deleted file mode 100644
index 3e8b4457..00000000
--- a/LEGO1/lego/legoomni/include/legobackgroundcolor.h
+++ /dev/null
@@ -1,24 +0,0 @@
-#ifndef LEGOBACKGROUNDCOLOR_H
-#define LEGOBACKGROUNDCOLOR_H
-
-#include "mxvariable.h"
-
-// VTABLE: LEGO1 0x100d74a8
-// SIZE 0x30
-class LegoBackgroundColor : public MxVariable {
-public:
-	LegoBackgroundColor(const char* p_key, const char* p_value);
-
-	void SetValue(const char* p_colorString) override;
-	void SetLightColor(float p_r, float p_g, float p_b);
-	void SetLightColor();
-	void ToggleDayNight(MxBool);
-	void ToggleSkyColor();
-
-private:
-	float m_h;
-	float m_s;
-	float m_v;
-};
-
-#endif // LEGOBACKGROUNDCOLOR_H
diff --git a/LEGO1/lego/legoomni/include/legocharactermanager.h b/LEGO1/lego/legoomni/include/legocharactermanager.h
index cf9c7949..ae7d79c3 100644
--- a/LEGO1/lego/legoomni/include/legocharactermanager.h
+++ b/LEGO1/lego/legoomni/include/legocharactermanager.h
@@ -4,9 +4,9 @@
 #include "decomp.h"
 #include "mxstl/stlcompat.h"
 #include "mxtypes.h"
+#include "mxvariable.h"
 #include "roi/legoroi.h"
 
-class CustomizeAnimFileVariable;
 class LegoActor;
 class LegoExtraActor;
 class LegoStorage;
@@ -45,6 +45,15 @@ struct LegoActorInfo;
 
 typedef map<char*, LegoCharacter*, LegoCharacterComparator> LegoCharacterMap;
 
+// VTABLE: LEGO1 0x100da878
+// SIZE 0x24
+class CustomizeAnimFileVariable : public MxVariable {
+public:
+	CustomizeAnimFileVariable(const char* p_key);
+
+	void SetValue(const char* p_value) override; // vtable+0x04
+};
+
 // SIZE 0x08
 class LegoCharacterManager {
 public:
diff --git a/LEGO1/lego/legoomni/include/legofullscreenmovie.h b/LEGO1/lego/legoomni/include/legofullscreenmovie.h
deleted file mode 100644
index 2f2f7614..00000000
--- a/LEGO1/lego/legoomni/include/legofullscreenmovie.h
+++ /dev/null
@@ -1,14 +0,0 @@
-#ifndef LEGOFULLSCREENMOVIE_H
-#define LEGOFULLSCREENMOVIE_H
-
-#include "mxvariable.h"
-
-// VTABLE: LEGO1 0x100d74b8
-// SIZE 0x24
-class LegoFullScreenMovie : public MxVariable {
-public:
-	LegoFullScreenMovie(const char* p_key, const char* p_value);
-	void SetValue(const char* p_option) override;
-};
-
-#endif // LEGOFULLSCREENMOVIE_H
diff --git a/LEGO1/lego/legoomni/include/legogamestate.h b/LEGO1/lego/legoomni/include/legogamestate.h
index da9d9319..9f5ab042 100644
--- a/LEGO1/lego/legoomni/include/legogamestate.h
+++ b/LEGO1/lego/legoomni/include/legogamestate.h
@@ -4,15 +4,13 @@
 #include "actionsfwd.h"
 #include "decomp.h"
 #include "mxtypes.h"
+#include "mxvariable.h"
 
 #include <string.h>
 
-class LegoBackgroundColor;
 class LegoFile;
-class LegoFullScreenMovie;
 class LegoState;
 class LegoStorage;
-class MxVariable;
 class MxVariableTable;
 class MxString;
 
@@ -24,6 +22,34 @@ struct ColorStringStruct {
 	const char* m_colorName;  // 0x04
 };
 
+// VTABLE: LEGO1 0x100d74a8
+// SIZE 0x30
+class LegoBackgroundColor : public MxVariable {
+public:
+	LegoBackgroundColor(const char* p_key, const char* p_value);
+
+	void SetValue(const char* p_colorString) override; // vtable+0x04
+
+	void SetLightColor(float p_r, float p_g, float p_b);
+	void SetLightColor();
+	void ToggleDayNight(MxBool p_sun);
+	void ToggleSkyColor();
+
+private:
+	float m_h; // 0x24
+	float m_s; // 0x28
+	float m_v; // 0x2c
+};
+
+// VTABLE: LEGO1 0x100d74b8
+// SIZE 0x24
+class LegoFullScreenMovie : public MxVariable {
+public:
+	LegoFullScreenMovie(const char* p_key, const char* p_value);
+
+	void SetValue(const char* p_option) override; // vtable+0x04
+};
+
 // SIZE 0x430
 class LegoGameState {
 public:
@@ -132,7 +158,7 @@ public:
 		History();
 		void WriteScoreHistory();
 		MxResult Serialize(LegoStorage* p_storage);
-		ScoreItem* FUN_1003cc90(Username* p_player, MxU16 p_unk0x24, MxS32& p_unk0x2c);
+		ScoreItem* FUN_1003cc90(Username* p_player, MxS16 p_unk0x24, MxS32& p_unk0x2c);
 
 		// FUNCTION: BETA10 0x1002c2b0
 		MxS16 GetCount() { return m_count; }
diff --git a/LEGO1/lego/legoomni/include/legovariables.h b/LEGO1/lego/legoomni/include/legovariables.h
index 1b5cd93b..9447a5f9 100644
--- a/LEGO1/lego/legoomni/include/legovariables.h
+++ b/LEGO1/lego/legoomni/include/legovariables.h
@@ -54,13 +54,4 @@ public:
 	void SetValue(const char* p_value) override; // vtable+0x04
 };
 
-// VTABLE: LEGO1 0x100da878
-// SIZE 0x24
-class CustomizeAnimFileVariable : public MxVariable {
-public:
-	CustomizeAnimFileVariable(const char* p_key);
-
-	void SetValue(const char* p_value) override; // vtable+0x04
-};
-
 #endif // LEGOVARIABLES_H
diff --git a/LEGO1/lego/legoomni/src/actors/ambulance.cpp b/LEGO1/lego/legoomni/src/actors/ambulance.cpp
index ca2c0ddb..4eddcaa2 100644
--- a/LEGO1/lego/legoomni/src/actors/ambulance.cpp
+++ b/LEGO1/lego/legoomni/src/actors/ambulance.cpp
@@ -46,11 +46,6 @@ Ambulance::Ambulance()
 	m_fuel = 1.0;
 }
 
-// FUNCTION: LEGO1 0x10035f90
-void Ambulance::Destroy(MxBool p_fromDestructor)
-{
-}
-
 // FUNCTION: LEGO1 0x10036150
 // FUNCTION: BETA10 0x100228fe
 Ambulance::~Ambulance()
@@ -644,37 +639,3 @@ AmbulanceMissionState::AmbulanceMissionState()
 	m_niHighScore = 0;
 	m_laHighScore = 0;
 }
-
-// FUNCTION: LEGO1 0x10037440
-// FUNCTION: BETA10 0x10024480
-MxResult AmbulanceMissionState::Serialize(LegoStorage* p_storage)
-{
-	LegoState::Serialize(p_storage);
-
-	if (p_storage->IsReadMode()) {
-		p_storage->ReadS16(m_peScore);
-		p_storage->ReadS16(m_maScore);
-		p_storage->ReadS16(m_paScore);
-		p_storage->ReadS16(m_niScore);
-		p_storage->ReadS16(m_laScore);
-		p_storage->ReadS16(m_peHighScore);
-		p_storage->ReadS16(m_maHighScore);
-		p_storage->ReadS16(m_paHighScore);
-		p_storage->ReadS16(m_niHighScore);
-		p_storage->ReadS16(m_laHighScore);
-	}
-	else if (p_storage->IsWriteMode()) {
-		p_storage->WriteS16(m_peScore);
-		p_storage->WriteS16(m_maScore);
-		p_storage->WriteS16(m_paScore);
-		p_storage->WriteS16(m_niScore);
-		p_storage->WriteS16(m_laScore);
-		p_storage->WriteS16(m_peHighScore);
-		p_storage->WriteS16(m_maHighScore);
-		p_storage->WriteS16(m_paHighScore);
-		p_storage->WriteS16(m_niHighScore);
-		p_storage->WriteS16(m_laHighScore);
-	}
-
-	return SUCCESS;
-}
diff --git a/LEGO1/lego/legoomni/src/actors/islepathactor.cpp b/LEGO1/lego/legoomni/src/actors/islepathactor.cpp
index c1b5694a..75e9b03a 100644
--- a/LEGO1/lego/legoomni/src/actors/islepathactor.cpp
+++ b/LEGO1/lego/legoomni/src/actors/islepathactor.cpp
@@ -100,7 +100,8 @@ void IslePathActor::Enter()
 // FUNCTION: BETA10 0x1003669f
 void IslePathActor::Exit()
 {
-	Reset();
+	SetActorState(c_initial);
+	m_roi->SetVisibility(TRUE);
 
 	GetViewManager()->Remove(m_roi);
 	GetViewManager()->Add(m_roi);
diff --git a/LEGO1/lego/legoomni/src/common/legobackgroundcolor.cpp b/LEGO1/lego/legoomni/src/common/legobackgroundcolor.cpp
deleted file mode 100644
index bc31bb2c..00000000
--- a/LEGO1/lego/legoomni/src/common/legobackgroundcolor.cpp
+++ /dev/null
@@ -1,151 +0,0 @@
-#include "legobackgroundcolor.h"
-
-#include "3dmanager/lego3dmanager.h"
-#include "decomp.h"
-#include "legoutils.h"
-#include "legovideomanager.h"
-#include "misc.h"
-
-#include <stdio.h>
-
-DECOMP_SIZE_ASSERT(LegoBackgroundColor, 0x30)
-
-// GLOBAL: LEGO1 0x100f3fb0
-// STRING: LEGO1 0x100f3a18
-const char* g_delimiter = " \t";
-
-// GLOBAL: LEGO1 0x100f3fb4
-// STRING: LEGO1 0x100f3bf0
-const char* g_set = "set";
-
-// GLOBAL: LEGO1 0x100f3fb8
-// STRING: LEGO1 0x100f0cdc
-const char* g_reset = "reset";
-
-// FUNCTION: LEGO1 0x1003bfb0
-LegoBackgroundColor::LegoBackgroundColor(const char* p_key, const char* p_value)
-{
-	m_key = p_key;
-	m_key.ToUpperCase();
-	SetValue(p_value);
-}
-
-// FUNCTION: LEGO1 0x1003c070
-void LegoBackgroundColor::SetValue(const char* p_colorString)
-{
-	m_value = p_colorString;
-	m_value.ToLowerCase();
-
-	LegoVideoManager* videomanager = VideoManager();
-	if (!videomanager || !p_colorString) {
-		return;
-	}
-
-	float convertedR, convertedG, convertedB;
-	char* colorStringCopy = strcpy(new char[strlen(p_colorString) + 1], p_colorString);
-	char* colorStringSplit = strtok(colorStringCopy, g_delimiter);
-
-	if (!strcmp(colorStringSplit, g_set)) {
-		colorStringSplit = strtok(0, g_delimiter);
-		if (colorStringSplit) {
-			m_h = (float) (atoi(colorStringSplit) * 0.01);
-		}
-		colorStringSplit = strtok(0, g_delimiter);
-		if (colorStringSplit) {
-			m_s = (float) (atoi(colorStringSplit) * 0.01);
-		}
-		colorStringSplit = strtok(0, g_delimiter);
-		if (colorStringSplit) {
-			m_v = (float) (atoi(colorStringSplit) * 0.01);
-		}
-
-		ConvertHSVToRGB(m_h, m_s, m_v, &convertedR, &convertedG, &convertedB);
-		videomanager->SetSkyColor(convertedR, convertedG, convertedB);
-	}
-	else if (!strcmp(colorStringSplit, g_reset)) {
-		ConvertHSVToRGB(m_h, m_s, m_v, &convertedR, &convertedG, &convertedB);
-		videomanager->SetSkyColor(convertedR, convertedG, convertedB);
-	}
-
-	delete[] colorStringCopy;
-}
-
-// FUNCTION: LEGO1 0x1003c230
-void LegoBackgroundColor::ToggleDayNight(MxBool p_sun)
-{
-	char buffer[30];
-
-	if (p_sun) {
-		m_s += 0.1;
-		if (m_s > 0.9) {
-			m_s = 1.0;
-		}
-	}
-	else {
-		m_s -= 0.1;
-		if (m_s < 0.1) {
-			m_s = 0.1;
-		}
-	}
-
-	sprintf(buffer, "set %d %d %d", (MxU32) (m_h * 100.0f), (MxU32) (m_s * 100.0f), (MxU32) (m_v * 100.0f));
-	m_value = buffer;
-
-	float convertedR, convertedG, convertedB;
-	ConvertHSVToRGB(m_h, m_s, m_v, &convertedR, &convertedG, &convertedB);
-	VideoManager()->SetSkyColor(convertedR, convertedG, convertedB);
-	SetLightColor(convertedR, convertedG, convertedB);
-}
-
-// FUNCTION: LEGO1 0x1003c330
-void LegoBackgroundColor::ToggleSkyColor()
-{
-	char buffer[30];
-
-	m_h += 0.05;
-	if (m_h > 1.0) {
-		m_h -= 1.0;
-	}
-
-	sprintf(buffer, "set %d %d %d", (MxU32) (m_h * 100.0f), (MxU32) (m_s * 100.0f), (MxU32) (m_v * 100.0f));
-	m_value = buffer;
-
-	float convertedR, convertedG, convertedB;
-	ConvertHSVToRGB(m_h, m_s, m_v, &convertedR, &convertedG, &convertedB);
-	VideoManager()->SetSkyColor(convertedR, convertedG, convertedB);
-	SetLightColor(convertedR, convertedG, convertedB);
-}
-
-// FUNCTION: LEGO1 0x1003c400
-void LegoBackgroundColor::SetLightColor(float p_r, float p_g, float p_b)
-{
-	if (!VideoManager()->GetVideoParam().Flags().GetF2bit0()) {
-		// TODO: Computed constants based on what?
-		p_r *= 1. / 0.23;
-		p_g *= 1. / 0.63;
-		p_b *= 1. / 0.85;
-
-		if (p_r > 1.0) {
-			p_r = 1.0;
-		}
-
-		if (p_g > 1.0) {
-			p_g = 1.0;
-		}
-
-		if (p_b > 1.0) {
-			p_b = 1.0;
-		}
-
-		VideoManager()->Get3DManager()->GetLego3DView()->SetLightColor(FALSE, p_r, p_g, p_b);
-		VideoManager()->Get3DManager()->GetLego3DView()->SetLightColor(TRUE, p_r, p_g, p_b);
-	}
-}
-
-// FUNCTION: LEGO1 0x1003c4b0
-void LegoBackgroundColor::SetLightColor()
-{
-	float convertedR, convertedG, convertedB;
-	ConvertHSVToRGB(m_h, m_s, m_v, &convertedR, &convertedG, &convertedB);
-	SetLightColor(convertedR, convertedG, convertedB);
-}
diff --git a/LEGO1/lego/legoomni/src/common/legocharactermanager.cpp b/LEGO1/lego/legoomni/src/common/legocharactermanager.cpp
index 295b90d7..8377e30f 100644
--- a/LEGO1/lego/legoomni/src/common/legocharactermanager.cpp
+++ b/LEGO1/lego/legoomni/src/common/legocharactermanager.cpp
@@ -3,9 +3,10 @@
 #include "3dmanager/lego3dmanager.h"
 #include "legoactors.h"
 #include "legoanimactor.h"
+#include "legobuildingmanager.h"
 #include "legoextraactor.h"
 #include "legogamestate.h"
-#include "legovariables.h"
+#include "legoplantmanager.h"
 #include "legovideomanager.h"
 #include "misc.h"
 #include "misc/legocontainer.h"
@@ -21,6 +22,7 @@
 
 DECOMP_SIZE_ASSERT(LegoCharacter, 0x08)
 DECOMP_SIZE_ASSERT(LegoCharacterManager, 0x08)
+DECOMP_SIZE_ASSERT(CustomizeAnimFileVariable, 0x24)
 
 // GLOBAL: LEGO1 0x100fc4d0
 MxU32 LegoCharacterManager::g_maxMove = 4;
@@ -1086,3 +1088,21 @@ LegoROI* LegoCharacterManager::FUN_10085a80(const char* p_name, const char* p_lo
 {
 	return CreateAutoROI(p_name, p_lodName, p_createEntity);
 }
+
+// FUNCTION: LEGO1 0x10085aa0
+CustomizeAnimFileVariable::CustomizeAnimFileVariable(const char* p_key)
+{
+	m_key = p_key;
+	m_key.ToUpperCase();
+}
+
+// FUNCTION: LEGO1 0x10085b50
+void CustomizeAnimFileVariable::SetValue(const char* p_value)
+{
+	// STRING: LEGO1 0x100fc4f4
+	if (strcmp(m_key.GetData(), "CUSTOMIZE_ANIM_FILE") == 0) {
+		CharacterManager()->SetCustomizeAnimFile(p_value);
+		PlantManager()->SetCustomizeAnimFile(p_value);
+		BuildingManager()->SetCustomizeAnimFile(p_value);
+	}
+}
diff --git a/LEGO1/lego/legoomni/src/common/legofullscreenmovie.cpp b/LEGO1/lego/legoomni/src/common/legofullscreenmovie.cpp
deleted file mode 100644
index c95cb40e..00000000
--- a/LEGO1/lego/legoomni/src/common/legofullscreenmovie.cpp
+++ /dev/null
@@ -1,44 +0,0 @@
-#include "legofullscreenmovie.h"
-
-#include "decomp.h"
-#include "legovideomanager.h"
-#include "misc.h"
-#include "mxtypes.h"
-
-DECOMP_SIZE_ASSERT(LegoFullScreenMovie, 0x24)
-
-// GLOBAL: LEGO1 0x100f3fbc
-// STRING: LEGO1 0x100f3be8
-const char* g_strEnable = "enable";
-
-// GLOBAL: LEGO1 0x100f3fc0
-// STRING: LEGO1 0x100f3bf4
-const char* g_strDisable = "disable";
-
-// FUNCTION: LEGO1 0x1003c500
-LegoFullScreenMovie::LegoFullScreenMovie(const char* p_key, const char* p_value)
-{
-	m_key = p_key;
-	m_key.ToUpperCase();
-	SetValue(p_value);
-}
-
-// FUNCTION: LEGO1 0x1003c5c0
-void LegoFullScreenMovie::SetValue(const char* p_option)
-{
-	m_value = p_option;
-	m_value.ToLowerCase();
-
-	LegoVideoManager* videomanager = VideoManager();
-	if (videomanager) {
-		if (!strcmp(m_value.GetData(), g_strEnable)) {
-			videomanager->EnableFullScreenMovie(TRUE);
-			return;
-		}
-
-		if (!strcmp(m_value.GetData(), g_strDisable)) {
-			videomanager->EnableFullScreenMovie(FALSE);
-			return;
-		}
-	}
-}
diff --git a/LEGO1/lego/legoomni/src/common/legogamestate.cpp b/LEGO1/lego/legoomni/src/common/legogamestate.cpp
index 80745b95..84a05db1 100644
--- a/LEGO1/lego/legoomni/src/common/legogamestate.cpp
+++ b/LEGO1/lego/legoomni/src/common/legogamestate.cpp
@@ -31,10 +31,8 @@
 #include "jukebox_actions.h"
 #include "jukeboxw_actions.h"
 #include "legoanimationmanager.h"
-#include "legobackgroundcolor.h"
 #include "legobuildingmanager.h"
 #include "legocharactermanager.h"
-#include "legofullscreenmovie.h"
 #include "legomain.h"
 #include "legonavcontroller.h"
 #include "legoplantmanager.h"
@@ -69,6 +67,8 @@ DECOMP_SIZE_ASSERT(LegoGameState::ScoreItem, 0x2c)
 DECOMP_SIZE_ASSERT(LegoGameState::History, 0x374)
 DECOMP_SIZE_ASSERT(LegoGameState, 0x430)
 DECOMP_SIZE_ASSERT(ColorStringStruct, 0x08)
+DECOMP_SIZE_ASSERT(LegoBackgroundColor, 0x30)
+DECOMP_SIZE_ASSERT(LegoFullScreenMovie, 0x24)
 
 // GLOBAL: LEGO1 0x100f3e40
 // STRING: LEGO1 0x100f3e3c
@@ -119,6 +119,26 @@ ColorStringStruct g_colorSaveData[43] = {
 // in that table is a special entry, the string "END_OF_VARIABLES"
 extern const char* g_endOfVariables;
 
+// GLOBAL: LEGO1 0x100f3fb0
+// STRING: LEGO1 0x100f3a18
+const char* g_delimiter = " \t";
+
+// GLOBAL: LEGO1 0x100f3fb4
+// STRING: LEGO1 0x100f3bf0
+const char* g_set = "set";
+
+// GLOBAL: LEGO1 0x100f3fb8
+// STRING: LEGO1 0x100f0cdc
+const char* g_reset = "reset";
+
+// GLOBAL: LEGO1 0x100f3fbc
+// STRING: LEGO1 0x100f3be8
+const char* g_strEnable = "enable";
+
+// GLOBAL: LEGO1 0x100f3fc0
+// STRING: LEGO1 0x100f3bf4
+const char* g_strDisable = "disable";
+
 // FUNCTION: LEGO1 0x10039550
 LegoGameState::LegoGameState()
 {
@@ -1144,6 +1164,162 @@ void LegoGameState::Init()
 	m_unk0x42c = e_undefined;
 }
 
+// FUNCTION: LEGO1 0x1003bfb0
+LegoBackgroundColor::LegoBackgroundColor(const char* p_key, const char* p_value)
+{
+	m_key = p_key;
+	m_key.ToUpperCase();
+	SetValue(p_value);
+}
+
+// FUNCTION: LEGO1 0x1003c070
+void LegoBackgroundColor::SetValue(const char* p_colorString)
+{
+	m_value = p_colorString;
+	m_value.ToLowerCase();
+
+	LegoVideoManager* videomanager = VideoManager();
+	if (!videomanager || !p_colorString) {
+		return;
+	}
+
+	float convertedR, convertedG, convertedB;
+	char* colorStringCopy = strcpy(new char[strlen(p_colorString) + 1], p_colorString);
+	char* colorStringSplit = strtok(colorStringCopy, g_delimiter);
+
+	if (!strcmp(colorStringSplit, g_set)) {
+		colorStringSplit = strtok(0, g_delimiter);
+		if (colorStringSplit) {
+			m_h = (float) (atoi(colorStringSplit) * 0.01);
+		}
+		colorStringSplit = strtok(0, g_delimiter);
+		if (colorStringSplit) {
+			m_s = (float) (atoi(colorStringSplit) * 0.01);
+		}
+		colorStringSplit = strtok(0, g_delimiter);
+		if (colorStringSplit) {
+			m_v = (float) (atoi(colorStringSplit) * 0.01);
+		}
+
+		ConvertHSVToRGB(m_h, m_s, m_v, &convertedR, &convertedG, &convertedB);
+		videomanager->SetSkyColor(convertedR, convertedG, convertedB);
+	}
+	else if (!strcmp(colorStringSplit, g_reset)) {
+		ConvertHSVToRGB(m_h, m_s, m_v, &convertedR, &convertedG, &convertedB);
+		videomanager->SetSkyColor(convertedR, convertedG, convertedB);
+	}
+
+	delete[] colorStringCopy;
+}
+
+// FUNCTION: LEGO1 0x1003c230
+void LegoBackgroundColor::ToggleDayNight(MxBool p_sun)
+{
+	char buffer[30];
+
+	if (p_sun) {
+		m_s += 0.1;
+		if (m_s > 0.9) {
+			m_s = 1.0;
+		}
+	}
+	else {
+		m_s -= 0.1;
+		if (m_s < 0.1) {
+			m_s = 0.1;
+		}
+	}
+
+	sprintf(buffer, "set %d %d %d", (MxU32) (m_h * 100.0f), (MxU32) (m_s * 100.0f), (MxU32) (m_v * 100.0f));
+	m_value = buffer;
+
+	float convertedR, convertedG, convertedB;
+	ConvertHSVToRGB(m_h, m_s, m_v, &convertedR, &convertedG, &convertedB);
+	VideoManager()->SetSkyColor(convertedR, convertedG, convertedB);
+	SetLightColor(convertedR, convertedG, convertedB);
+}
+
+// FUNCTION: LEGO1 0x1003c330
+void LegoBackgroundColor::ToggleSkyColor()
+{
+	char buffer[30];
+
+	m_h += 0.05;
+	if (m_h > 1.0) {
+		m_h -= 1.0;
+	}
+
+	sprintf(buffer, "set %d %d %d", (MxU32) (m_h * 100.0f), (MxU32) (m_s * 100.0f), (MxU32) (m_v * 100.0f));
+	m_value = buffer;
+
+	float convertedR, convertedG, convertedB;
+	ConvertHSVToRGB(m_h, m_s, m_v, &convertedR, &convertedG, &convertedB);
+	VideoManager()->SetSkyColor(convertedR, convertedG, convertedB);
+	SetLightColor(convertedR, convertedG, convertedB);
+}
+
+// FUNCTION: LEGO1 0x1003c400
+void LegoBackgroundColor::SetLightColor(float p_r, float p_g, float p_b)
+{
+	if (!VideoManager()->GetVideoParam().Flags().GetF2bit0()) {
+		// TODO: Computed constants based on what?
+		p_r *= 1. / 0.23;
+		p_g *= 1. / 0.63;
+		p_b *= 1. / 0.85;
+
+		if (p_r > 1.0) {
+			p_r = 1.0;
+		}
+
+		if (p_g > 1.0) {
+			p_g = 1.0;
+		}
+
+		if (p_b > 1.0) {
+			p_b = 1.0;
+		}
+
+		VideoManager()->Get3DManager()->GetLego3DView()->SetLightColor(FALSE, p_r, p_g, p_b);
+		VideoManager()->Get3DManager()->GetLego3DView()->SetLightColor(TRUE, p_r, p_g, p_b);
+	}
+}
+
+// FUNCTION: LEGO1 0x1003c4b0
+void LegoBackgroundColor::SetLightColor()
+{
+	float convertedR, convertedG, convertedB;
+	ConvertHSVToRGB(m_h, m_s, m_v, &convertedR, &convertedG, &convertedB);
+	SetLightColor(convertedR, convertedG, convertedB);
+}
+
+// FUNCTION: LEGO1 0x1003c500
+LegoFullScreenMovie::LegoFullScreenMovie(const char* p_key, const char* p_value)
+{
+	m_key = p_key;
+	m_key.ToUpperCase();
+	SetValue(p_value);
+}
+
+// FUNCTION: LEGO1 0x1003c5c0
+void LegoFullScreenMovie::SetValue(const char* p_option)
+{
+	m_value = p_option;
+	m_value.ToLowerCase();
+
+	LegoVideoManager* videomanager = VideoManager();
+	if (videomanager) {
+		if (!strcmp(m_value.GetData(), g_strEnable)) {
+			videomanager->EnableFullScreenMovie(TRUE);
+			return;
+		}
+
+		if (!strcmp(m_value.GetData(), g_strDisable)) {
+			videomanager->EnableFullScreenMovie(FALSE);
+			return;
+		}
+	}
+}
+
 // FUNCTION: LEGO1 0x1003c670
 LegoGameState::Username::Username()
 {
@@ -1275,7 +1451,7 @@ void LegoGameState::History::WriteScoreHistory()
 
 		MxU8 tmpScores[5][5];
 		Username tmpPlayer;
-		undefined2 tmpUnk0x2a;
+		MxS16 tmpUnk0x2a;
 
 		// TODO: Match bubble sort loops
 		for (MxS32 i = m_count - 1; i > 0; i--) {
@@ -1302,7 +1478,7 @@ void LegoGameState::History::WriteScoreHistory()
 // FUNCTION: BETA10 0x1008732a
 LegoGameState::ScoreItem* LegoGameState::History::FUN_1003cc90(
 	LegoGameState::Username* p_player,
-	MxU16 p_unk0x24,
+	MxS16 p_unk0x24,
 	MxS32& p_unk0x2c
 )
 {
diff --git a/LEGO1/lego/legoomni/src/common/legovariables.cpp b/LEGO1/lego/legoomni/src/common/legovariables.cpp
index 539983bf..68768e99 100644
--- a/LEGO1/lego/legoomni/src/common/legovariables.cpp
+++ b/LEGO1/lego/legoomni/src/common/legovariables.cpp
@@ -1,11 +1,8 @@
 #include "legovariables.h"
 
 #include "3dmanager/lego3dmanager.h"
-#include "legobuildingmanager.h"
-#include "legocharactermanager.h"
 #include "legogamestate.h"
 #include "legonavcontroller.h"
-#include "legoplantmanager.h"
 #include "legovideomanager.h"
 #include "misc.h"
 #include "roi/legoroi.h"
@@ -14,7 +11,6 @@ DECOMP_SIZE_ASSERT(VisibilityVariable, 0x24)
 DECOMP_SIZE_ASSERT(CameraLocationVariable, 0x24)
 DECOMP_SIZE_ASSERT(CursorVariable, 0x24)
 DECOMP_SIZE_ASSERT(WhoAmIVariable, 0x24)
-DECOMP_SIZE_ASSERT(CustomizeAnimFileVariable, 0x24)
 
 // GLOBAL: LEGO1 0x100f7ab0
 // STRING: LEGO1 0x100f09c0
@@ -176,21 +172,3 @@ void WhoAmIVariable::SetValue(const char* p_value)
 		GameState()->SetActorId(5);
 	}
 }
-
-// FUNCTION: LEGO1 0x10085aa0
-CustomizeAnimFileVariable::CustomizeAnimFileVariable(const char* p_key)
-{
-	m_key = p_key;
-	m_key.ToUpperCase();
-}
-
-// FUNCTION: LEGO1 0x10085b50
-void CustomizeAnimFileVariable::SetValue(const char* p_value)
-{
-	// STRING: LEGO1 0x100fc4f4
-	if (strcmp(m_key.GetData(), "CUSTOMIZE_ANIM_FILE") == 0) {
-		CharacterManager()->SetCustomizeAnimFile(p_value);
-		PlantManager()->SetCustomizeAnimFile(p_value);
-		BuildingManager()->SetCustomizeAnimFile(p_value);
-	}
-}
diff --git a/LEGO1/lego/legoomni/src/race/carrace.cpp b/LEGO1/lego/legoomni/src/race/carrace.cpp
index 4b4f0acd..bd2a0a50 100644
--- a/LEGO1/lego/legoomni/src/race/carrace.cpp
+++ b/LEGO1/lego/legoomni/src/race/carrace.cpp
@@ -5,7 +5,6 @@
 #include "isle.h"
 #include "jukebox_actions.h"
 #include "legoanimationmanager.h"
-#include "legobackgroundcolor.h"
 #include "legocontrolmanager.h"
 #include "legohideanimpresenter.h"
 #include "legomain.h"
diff --git a/LEGO1/lego/legoomni/src/worlds/isle.cpp b/LEGO1/lego/legoomni/src/worlds/isle.cpp
index d3453817..aeb9be41 100644
--- a/LEGO1/lego/legoomni/src/worlds/isle.cpp
+++ b/LEGO1/lego/legoomni/src/worlds/isle.cpp
@@ -13,7 +13,6 @@
 #include "jukebox_actions.h"
 #include "jukeboxentity.h"
 #include "legoanimationmanager.h"
-#include "legobackgroundcolor.h"
 #include "legocontrolmanager.h"
 #include "legoinputmanager.h"
 #include "legomain.h"