From 72c34949e5401363fc90d33f9dd60573b1977392 Mon Sep 17 00:00:00 2001
From: Misha <106913236+MishaProductions@users.noreply.github.com>
Date: Sat, 16 Dec 2023 11:01:22 -0500
Subject: [PATCH] implement Isle::Notify (#338)

* isle::notify

* Match Isle::Notify

---------

Co-authored-by: Christian Semmler <mail@csemmler.com>
---
 LEGO1/act1state.h |  1 +
 LEGO1/isle.cpp    | 77 +++++++++++++++++++++++++++++++++++++++++++++--
 LEGO1/isle.h      |  7 ++++-
 3 files changed, 82 insertions(+), 3 deletions(-)

diff --git a/LEGO1/act1state.h b/LEGO1/act1state.h
index 772d39c1..e2e8d3e1 100644
--- a/LEGO1/act1state.h
+++ b/LEGO1/act1state.h
@@ -23,6 +23,7 @@ public:
 	};
 
 	inline void SetUnknown18(MxU32 p_unk0x18) { m_unk0x18 = p_unk0x18; }
+	inline MxU32 GetUnknown18() { return m_unk0x18; }
 
 protected:
 	undefined m_unk0x8[0x10]; // 0x8
diff --git a/LEGO1/isle.cpp b/LEGO1/isle.cpp
index 3c6c23b2..cefd6009 100644
--- a/LEGO1/isle.cpp
+++ b/LEGO1/isle.cpp
@@ -1,6 +1,7 @@
 #include "isle.h"
 
 #include "act1state.h"
+#include "ambulance.h"
 #include "islepathactor.h"
 #include "legocontrolmanager.h"
 #include "legogamestate.h"
@@ -9,6 +10,8 @@
 #include "legoutil.h"
 #include "mxnotificationmanager.h"
 #include "mxtransitionmanager.h"
+#include "pizza.h"
+#include "towtrack.h"
 
 DECOMP_SIZE_ASSERT(Isle, 0x140);
 
@@ -90,10 +93,62 @@ MxResult Isle::Create(MxDSObject& p_dsObject)
 	return result;
 }
 
-// STUB: LEGO1 0x10030c10
+// FUNCTION: LEGO1 0x10030c10
 MxLong Isle::Notify(MxParam& p_param)
 {
-	// TODO
+	MxLong result = 0;
+	LegoWorld::Notify(p_param);
+
+	if (m_unk0xf6) {
+		switch (((MxNotificationParam&) p_param).GetNotification()) {
+		case c_notificationEndAction:
+			result = StopAction(p_param);
+			break;
+		case c_notificationButtonUp:
+		case c_notificationButtonDown:
+			switch (m_act1state->GetUnknown18()) {
+			case 3:
+				result = m_pizza->Notify(p_param);
+				break;
+			case 10:
+				result = m_ambulance->Notify(p_param);
+				break;
+			}
+			break;
+		case TYPE17:
+			result = HandleType17Notification(p_param);
+			break;
+		case TYPE18:
+			switch (m_act1state->GetUnknown18()) {
+			case 4:
+				result = GetCurrentVehicle()->Notify(p_param);
+				break;
+			case 8:
+				result = m_towtrack->Notify(p_param);
+				break;
+			case 10:
+				result = m_ambulance->Notify(p_param);
+				break;
+			}
+			break;
+		case TYPE19:
+			result = HandleType19Notification(p_param);
+			break;
+		case TYPE20:
+			VTable0x68(TRUE);
+			break;
+		case MXTRANSITIONMANAGER_TRANSITIONENDED:
+			result = HandleTransitionEnd();
+			break;
+		}
+	}
+
+	return result;
+}
+
+// STUB: LEGO1 0x10030d90
+MxLong Isle::StopAction(MxParam& p_param)
+{
 	return 0;
 }
 
@@ -103,12 +158,30 @@ void Isle::Stop()
 	// TODO
 }
 
+// STUB: LGEO1 0x10031030
+MxLong Isle::HandleType17Notification(MxParam& p_param)
+{
+	return 0;
+}
+
+// STUB: LEGO1 0x100315f0
+MxLong Isle::HandleType19Notification(MxParam& p_param)
+{
+	return 0;
+}
+
 // STUB: LEGO1 0x10031820
 void Isle::VTable0x68(MxBool p_add)
 {
 	// TODO
 }
 
+// STUB: LEGO1 0x10031820
+MxLong Isle::HandleTransitionEnd()
+{
+	return 0;
+}
+
 // FUNCTION: LEGO1 0x10032f10
 void Isle::VTable0x58(MxCore* p_object)
 {
diff --git a/LEGO1/isle.h b/LEGO1/isle.h
index 7b9f3987..9f44eadd 100644
--- a/LEGO1/isle.h
+++ b/LEGO1/isle.h
@@ -25,7 +25,6 @@ class Isle : public LegoWorld {
 public:
 	Isle();
 	virtual ~Isle() override;
-
 	virtual MxLong Notify(MxParam& p_param) override; // vtable+0x4
 
 	// FUNCTION: LEGO1 0x10030910
@@ -40,6 +39,7 @@ public:
 	{
 		return !strcmp(p_name, Isle::ClassName()) || LegoWorld::IsA(p_name);
 	}
+
 	virtual MxResult Create(MxDSObject& p_dsObject) override; // vtable+0x18
 	virtual void Stop() override;                             // vtable+50
 	virtual void VTable0x58(MxCore* p_object) override;       // vtable+58
@@ -53,6 +53,11 @@ public:
 
 	inline void SetUnknown13c(MxU32 p_unk0x13c) { m_unk0x13c = p_unk0x13c; }
 
+	MxLong StopAction(MxParam& p_param);
+	MxLong HandleType17Notification(MxParam& p_param);
+	MxLong HandleType19Notification(MxParam& p_param);
+	MxLong HandleTransitionEnd();
+
 protected:
 	Act1State* m_act1state;   // 0xf8
 	Pizza* m_pizza;           // 0xfc