Implement/match Isle::HandleEndAction and Isle::HandleElevatorEndAction (#691)

* WIP

* Match
This commit is contained in:
Christian Semmler 2024-03-18 15:00:58 -04:00 committed by GitHub
parent d96679ea9e
commit 52d74647be
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 149 additions and 46 deletions

View file

@ -101,7 +101,7 @@ class Act1State : public LegoState {
MxS32 m_unk0x014; // 0x014 MxS32 m_unk0x014; // 0x014
MxU32 m_unk0x018; // 0x018 MxU32 m_unk0x018; // 0x018
MxS16 m_elevFloor; // 0x01c MxS16 m_elevFloor; // 0x01c
undefined m_unk0x01e; // 0x01e MxBool m_unk0x01e; // 0x01e
MxBool m_unk0x01f; // 0x01f MxBool m_unk0x01f; // 0x01f
MxBool m_planeActive; // 0x020 MxBool m_planeActive; // 0x020
undefined m_unk0x021; // 0x021 undefined m_unk0x021; // 0x021

View file

@ -78,10 +78,11 @@ class Isle : public LegoWorld {
void Enable(MxBool p_enable) override; // vtable+68 void Enable(MxBool p_enable) override; // vtable+68
virtual void VTable0x6c(IslePathActor* p_actor); // vtable+6c virtual void VTable0x6c(IslePathActor* p_actor); // vtable+6c
MxLong StopAction(MxParam& p_param); MxLong HandleEndAction(MxEndActionNotificationParam& p_param);
MxLong HandleClick(LegoControlManagerEvent& p_param); MxLong HandleClick(LegoControlManagerEvent& p_param);
MxLong HandleType19Notification(MxParam& p_param); MxLong HandleType19Notification(MxParam& p_param);
MxLong HandleTransitionEnd(); MxLong HandleTransitionEnd();
void HandleElevatorEndAction();
void FUN_10031590(); void FUN_10031590();
void FUN_10032620(); void FUN_10032620();
void FUN_100330e0(); void FUN_100330e0();

View file

@ -3,6 +3,15 @@
#include "legoentity.h" #include "legoentity.h"
namespace JukeboxScript
{
#ifdef COMPAT_MODE
enum Script : int;
#else
enum Script;
#endif
} // namespace JukeboxScript
// VTABLE: LEGO1 0x100da8a0 // VTABLE: LEGO1 0x100da8a0
// SIZE 0x6c // SIZE 0x6c
class JukeBoxEntity : public LegoEntity { class JukeBoxEntity : public LegoEntity {
@ -26,7 +35,7 @@ class JukeBoxEntity : public LegoEntity {
} }
void StartAction(); void StartAction();
void StopAction(MxU32 p_state); void StopAction(JukeboxScript::Script p_script);
inline MxBool IsBackgroundAudioEnabled() { return m_audioEnabled; } inline MxBool IsBackgroundAudioEnabled() { return m_audioEnabled; }

View file

@ -17,6 +17,15 @@ struct ColorStringStruct {
const char* m_colorName; const char* m_colorName;
}; };
namespace JukeboxScript
{
#ifdef COMPAT_MODE
enum Script : int;
#else
enum Script;
#endif
} // namespace JukeboxScript
// SIZE 0x430 // SIZE 0x430
class LegoGameState { class LegoGameState {
public: public:
@ -159,7 +168,7 @@ class LegoGameState {
inline Act GetLoadedAct() { return m_loadedAct; } inline Act GetLoadedAct() { return m_loadedAct; }
inline Area GetCurrentArea() { return m_currentArea; } inline Area GetCurrentArea() { return m_currentArea; }
inline Area GetPreviousArea() { return m_previousArea; } inline Area GetPreviousArea() { return m_previousArea; }
inline MxU32 GetUnknown0x41c() { return m_unk0x41c; } inline JukeboxScript::Script GetUnknown0x41c() { return m_unk0x41c; }
inline Area GetUnknown0x42c() { return m_unk0x42c; } inline Area GetUnknown0x42c() { return m_unk0x42c; }
inline History* GetHistory() { return &m_history; } inline History* GetHistory() { return &m_history; }
@ -167,7 +176,7 @@ class LegoGameState {
inline void SetCurrentArea(Area p_currentArea) { m_currentArea = p_currentArea; } inline void SetCurrentArea(Area p_currentArea) { m_currentArea = p_currentArea; }
inline void SetPreviousArea(Area p_previousArea) { m_previousArea = p_previousArea; } inline void SetPreviousArea(Area p_previousArea) { m_previousArea = p_previousArea; }
inline void SetActorId(MxU8 p_actorId) { m_actorId = p_actorId; } inline void SetActorId(MxU8 p_actorId) { m_actorId = p_actorId; }
inline void SetUnknown0x41c(undefined4 p_unk0x41c) { m_unk0x41c = p_unk0x41c; } inline void SetUnknown0x41c(JukeboxScript::Script p_unk0x41c) { m_unk0x41c = p_unk0x41c; }
inline void SetUnknown0x42c(Area p_unk0x42c) { m_unk0x42c = p_unk0x42c; } inline void SetUnknown0x42c(Area p_unk0x42c) { m_unk0x42c = p_unk0x42c; }
inline Username* GetPlayersIndex(MxS32 p_index) { return &m_players[p_index]; } inline Username* GetPlayersIndex(MxS32 p_index) { return &m_players[p_index]; }
inline MxS16 GetPlayerCount() { return m_playerCount; } inline MxS16 GetPlayerCount() { return m_playerCount; }
@ -204,7 +213,7 @@ class LegoGameState {
private: private:
History m_history; // 0xa6 History m_history; // 0xa6
undefined2 m_unk0x41a; // 0x41a undefined2 m_unk0x41a; // 0x41a
undefined4 m_unk0x41c; // 0x41c JukeboxScript::Script m_unk0x41c; // 0x41c
MxBool m_isDirty; // 0x420 MxBool m_isDirty; // 0x420
public: public:

View file

@ -17,7 +17,7 @@ extern MxAtomId* g_isleScript;
// STUB: LEGO1 0x100334b0 // STUB: LEGO1 0x100334b0
Act1State::Act1State() : m_unk0x00c(0), m_unk0x00e(0), m_unk0x008(NULL), m_unk0x010(0) Act1State::Act1State() : m_unk0x00c(0), m_unk0x00e(0), m_unk0x008(NULL), m_unk0x010(0)
{ {
m_unk0x01e = 0; m_unk0x01e = FALSE;
m_unk0x018 = 1; m_unk0x018 = 1;
m_unk0x010 = 0; m_unk0x010 = 0;
m_planeActive = FALSE; m_planeActive = FALSE;

View file

@ -1,7 +1,9 @@
#include "jukeboxentity.h" #include "jukeboxentity.h"
#include "isle.h" #include "isle.h"
#include "isle_actions.h"
#include "islepathactor.h" #include "islepathactor.h"
#include "jukebox_actions.h"
#include "jukeboxstate.h" #include "jukeboxstate.h"
#include "legogamestate.h" #include "legogamestate.h"
#include "legoomni.h" #include "legoomni.h"
@ -54,28 +56,28 @@ void JukeBoxEntity::StartAction()
switch (state->GetState()) { switch (state->GetState()) {
case 0: case 0:
InvokeAction(Extra::e_start, *g_isleScript, 0x319, NULL); InvokeAction(Extra::e_start, *g_isleScript, IsleScript::c_npz001bd_RunAnim, NULL);
GameState()->SetUnknown0x41c(0x37); GameState()->SetUnknown0x41c(JukeboxScript::c_JBMusic1);
break; break;
case 1: case 1:
InvokeAction(Extra::e_start, *g_isleScript, 0x31e, NULL); InvokeAction(Extra::e_start, *g_isleScript, IsleScript::c_npz006bd_RunAnim, NULL);
GameState()->SetUnknown0x41c(0x38); GameState()->SetUnknown0x41c(JukeboxScript::c_JBMusic2);
break; break;
case 2: case 2:
InvokeAction(Extra::e_start, *g_isleScript, 0x31b, NULL); InvokeAction(Extra::e_start, *g_isleScript, IsleScript::c_npz003bd_RunAnim, NULL);
GameState()->SetUnknown0x41c(0x39); GameState()->SetUnknown0x41c(JukeboxScript::c_JBMusic3);
break; break;
case 3: case 3:
InvokeAction(Extra::e_start, *g_isleScript, 0x31a, NULL); InvokeAction(Extra::e_start, *g_isleScript, IsleScript::c_npz002bd_RunAnim, NULL);
GameState()->SetUnknown0x41c(0x3a); GameState()->SetUnknown0x41c(JukeboxScript::c_JBMusic4);
break; break;
case 4: case 4:
InvokeAction(Extra::e_start, *g_isleScript, 0x31f, NULL); InvokeAction(Extra::e_start, *g_isleScript, IsleScript::c_npz007bd_RunAnim, NULL);
GameState()->SetUnknown0x41c(0x3b); GameState()->SetUnknown0x41c(JukeboxScript::c_JBMusic5);
break; break;
case 5: case 5:
InvokeAction(Extra::e_start, *g_isleScript, 0x31c, NULL); InvokeAction(Extra::e_start, *g_isleScript, IsleScript::c_npz004bd_RunAnim, NULL);
GameState()->SetUnknown0x41c(0x3c); GameState()->SetUnknown0x41c(JukeboxScript::c_JBMusic6);
break; break;
} }
@ -91,35 +93,35 @@ void JukeBoxEntity::StartAction()
} }
// FUNCTION: LEGO1 0x100860f0 // FUNCTION: LEGO1 0x100860f0
void JukeBoxEntity::StopAction(MxU32 p_state) void JukeBoxEntity::StopAction(JukeboxScript::Script p_script)
{ {
JukeBoxState* state = (JukeBoxState*) GameState()->GetState("JukeBoxState"); JukeBoxState* state = (JukeBoxState*) GameState()->GetState("JukeBoxState");
if (state && state->IsActive()) { if (state && state->IsActive()) {
switch (p_state) { switch (p_script) {
case 0x37: case JukeboxScript::c_JBMusic1:
state->SetActive(FALSE); state->SetActive(FALSE);
InvokeAction(Extra::e_stop, *g_isleScript, 0x319, NULL); InvokeAction(Extra::e_stop, *g_isleScript, IsleScript::c_npz001bd_RunAnim, NULL);
break; break;
case 0x38: case JukeboxScript::c_JBMusic2:
state->SetActive(FALSE); state->SetActive(FALSE);
InvokeAction(Extra::e_stop, *g_isleScript, 0x31e, NULL); InvokeAction(Extra::e_stop, *g_isleScript, IsleScript::c_npz006bd_RunAnim, NULL);
break; break;
case 0x39: case JukeboxScript::c_JBMusic3:
state->SetActive(FALSE); state->SetActive(FALSE);
InvokeAction(Extra::e_stop, *g_isleScript, 0x31b, NULL); InvokeAction(Extra::e_stop, *g_isleScript, IsleScript::c_npz003bd_RunAnim, NULL);
break; break;
case 0x3a: case JukeboxScript::c_JBMusic4:
state->SetActive(FALSE); state->SetActive(FALSE);
InvokeAction(Extra::e_stop, *g_isleScript, 0x31a, NULL); InvokeAction(Extra::e_stop, *g_isleScript, IsleScript::c_npz002bd_RunAnim, NULL);
break; break;
case 0x3b: case JukeboxScript::c_JBMusic5:
state->SetActive(FALSE); state->SetActive(FALSE);
InvokeAction(Extra::e_stop, *g_isleScript, 0x31f, NULL); InvokeAction(Extra::e_stop, *g_isleScript, IsleScript::c_npz007bd_RunAnim, NULL);
break; break;
case 0x3c: case JukeboxScript::c_JBMusic6:
state->SetActive(FALSE); state->SetActive(FALSE);
InvokeAction(Extra::e_stop, *g_isleScript, 0x31c, NULL); InvokeAction(Extra::e_stop, *g_isleScript, IsleScript::c_npz004bd_RunAnim, NULL);
break; break;
} }

View file

@ -232,7 +232,7 @@ void MxBackgroundAudioManager::StopAction(MxParam& p_param)
m_action2.SetObjectId(-1); m_action2.SetObjectId(-1);
} }
Lego()->HandleActionEnd(p_param); Lego()->HandleEndAction(p_param);
} }
// FUNCTION: LEGO1 0x1007f2f0 // FUNCTION: LEGO1 0x1007f2f0

View file

@ -8,6 +8,7 @@
#include "isle.h" #include "isle.h"
#include "islepathactor.h" #include "islepathactor.h"
#include "jetski.h" #include "jetski.h"
#include "jukebox_actions.h"
#include "legoanimationmanager.h" #include "legoanimationmanager.h"
#include "legobuildingmanager.h" #include "legobuildingmanager.h"
#include "legocharactermanager.h" #include "legocharactermanager.h"
@ -93,7 +94,7 @@ LegoGameState::LegoGameState()
m_actorId = 0; m_actorId = 0;
m_savePath = NULL; m_savePath = NULL;
m_stateArray = NULL; m_stateArray = NULL;
m_unk0x41c = -1; m_unk0x41c = JukeboxScript::c_noneJukebox;
m_currentArea = e_undefined; m_currentArea = e_undefined;
m_previousArea = e_undefined; m_previousArea = e_undefined;
m_unk0x42c = e_undefined; m_unk0x42c = e_undefined;

View file

@ -21,6 +21,7 @@
#include "legovideomanager.h" #include "legovideomanager.h"
#include "misc.h" #include "misc.h"
#include "motocycle.h" #include "motocycle.h"
#include "mxbackgroundaudiomanager.h"
#include "mxmisc.h" #include "mxmisc.h"
#include "mxnotificationmanager.h" #include "mxnotificationmanager.h"
#include "mxstillpresenter.h" #include "mxstillpresenter.h"
@ -123,7 +124,7 @@ MxLong Isle::Notify(MxParam& p_param)
if (m_worldStarted) { if (m_worldStarted) {
switch (((MxNotificationParam&) p_param).GetNotification()) { switch (((MxNotificationParam&) p_param).GetNotification()) {
case c_notificationEndAction: case c_notificationEndAction:
result = StopAction(p_param); result = HandleEndAction((MxEndActionNotificationParam&) p_param);
break; break;
case c_notificationButtonUp: case c_notificationButtonUp:
case c_notificationButtonDown: case c_notificationButtonDown:
@ -167,10 +168,90 @@ MxLong Isle::Notify(MxParam& p_param)
return result; return result;
} }
// STUB: LEGO1 0x10030d90 // FUNCTION: LEGO1 0x10030d90
MxLong Isle::StopAction(MxParam& p_param) MxLong Isle::HandleEndAction(MxEndActionNotificationParam& p_param)
{ {
return 0; MxLong result;
switch (m_act1state->m_unk0x018) {
case 2:
HandleElevatorEndAction();
result = 1;
break;
case 3:
result = m_pizza->Notify(p_param);
break;
case 8:
result = m_towtrack->Notify(p_param);
break;
case 10:
result = m_ambulance->Notify(p_param);
break;
default:
result = m_radio.Notify(p_param);
if (result == 0) {
MxDSAction* action = p_param.GetAction();
// TODO: Should be signed, but worsens match
MxU32 script;
if (action->GetAtomId() == *g_jukeboxScript) {
script = action->GetObjectId();
if (script >= JukeboxScript::c_JBMusic1 && script <= JukeboxScript::c_JBMusic6) {
m_jukebox->StopAction((JukeboxScript::Script) script);
result = 1;
}
}
else if (m_act1state->m_planeActive) {
script = action->GetObjectId();
if (script >= IsleScript::c_nic002pr_RunAnim && script <= IsleScript::c_nic004pr_RunAnim) {
m_act1state->m_planeActive = FALSE;
}
}
else {
script = action->GetObjectId();
if (script == IsleScript::c_Avo917In_PlayWav ||
(script >= IsleScript::c_Avo900Ps_PlayWav && script <= IsleScript::c_Avo907Ps_PlayWav)) {
BackgroundAudioManager()->RaiseVolume();
}
}
}
}
return result;
}
// FUNCTION: LEGO1 0x10030ef0
void Isle::HandleElevatorEndAction()
{
switch (m_act1state->m_elevFloor) {
case Act1State::c_floor1:
m_destLocation = LegoGameState::e_infomain;
TransitionManager()->StartTransition(MxTransitionManager::e_mosaic, 50, FALSE, FALSE);
m_act1state->m_unk0x018 = 0;
break;
case Act1State::c_floor2:
if (m_act1state->m_unk0x01e) {
m_act1state->m_unk0x01e = FALSE;
m_act1state->m_unk0x018 = 0;
InputManager()->EnableInputProcessing();
}
else {
InvokeAction(Extra::e_start, *g_isleScript, IsleScript::c_Floor2, NULL);
InputManager()->EnableInputProcessing();
m_act1state->m_unk0x01e = TRUE;
}
break;
case Act1State::c_floor3:
m_destLocation = LegoGameState::e_elevopen;
TransitionManager()->StartTransition(MxTransitionManager::e_mosaic, 50, FALSE, FALSE);
m_act1state->m_unk0x018 = 0;
break;
}
} }
// FUNCTION: LEGO1 0x10030fc0 // FUNCTION: LEGO1 0x10030fc0
@ -228,7 +309,7 @@ MxLong Isle::HandleClick(LegoControlManagerEvent& p_param)
break; break;
case Act1State::c_floor2: case Act1State::c_floor2:
InvokeAction(Extra::e_start, *g_isleScript, IsleScript::c_Floor2, NULL); InvokeAction(Extra::e_start, *g_isleScript, IsleScript::c_Floor2, NULL);
m_act1state->m_unk0x01e = 1; m_act1state->m_unk0x01e = TRUE;
break; break;
case Act1State::c_floor3: case Act1State::c_floor3:
InvokeAction(Extra::e_start, *g_isleScript, IsleScript::c_Elev3_2_Ride, NULL); InvokeAction(Extra::e_start, *g_isleScript, IsleScript::c_Elev3_2_Ride, NULL);

View file

@ -70,7 +70,7 @@ class MxOmni : public MxCore {
MxMusicManager* GetMusicManager() const { return this->m_musicManager; } MxMusicManager* GetMusicManager() const { return this->m_musicManager; }
MxEventManager* GetEventManager() const { return this->m_eventManager; } MxEventManager* GetEventManager() const { return this->m_eventManager; }
MxAtomIdCounterSet* GetAtomIdCounterSet() const { return this->m_atomIdCounterSet; } MxAtomIdCounterSet* GetAtomIdCounterSet() const { return this->m_atomIdCounterSet; }
MxLong HandleActionEnd(MxParam& p_param); MxLong HandleEndAction(MxParam& p_param);
// SYNTHETIC: LEGO1 0x100aefd0 // SYNTHETIC: LEGO1 0x100aefd0
// MxOmni::`scalar deleting destructor' // MxOmni::`scalar deleting destructor'

View file

@ -344,11 +344,11 @@ MxLong MxOmni::Notify(MxParam& p_param)
return 0; return 0;
} }
return HandleActionEnd(p_param); return HandleEndAction(p_param);
} }
// FUNCTION: LEGO1 0x100b0880 // FUNCTION: LEGO1 0x100b0880
MxLong MxOmni::HandleActionEnd(MxParam& p_param) MxLong MxOmni::HandleEndAction(MxParam& p_param)
{ {
MxDSAction* action = ((MxEndActionNotificationParam&) p_param).GetAction(); MxDSAction* action = ((MxEndActionNotificationParam&) p_param).GetAction();
MxStreamController* controller = Streamer()->GetOpenStream(action->GetAtomId().GetInternal()); MxStreamController* controller = Streamer()->GetOpenStream(action->GetAtomId().GetInternal());