Partial implementation of LegoGameState::SwitchArea (#547)

This commit is contained in:
Misha 2024-02-10 09:36:01 -05:00 committed by GitHub
parent 223b07ee3d
commit 32681935ca
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 127 additions and 12 deletions

View file

@ -66,6 +66,7 @@ class LegoWorld : public LegoEntity {
inline LegoCameraController* GetCamera() { return m_cameraController; }
inline undefined4 GetUnknown0xec() { return m_unk0xec; }
inline MxCoreSet& GetUnknown0xd0() { return m_set0xd0; }
MxBool PresentersPending();
void Remove(MxCore* p_object);

View file

@ -436,33 +436,71 @@ void LegoGameState::StopArea(MxU32 p_area)
}
}
// STUB: LEGO1 0x1003b060
// FUNCTION: LEGO1 0x1003b060
void LegoGameState::SwitchArea(MxU32 p_area)
{
m_previousArea = m_currentArea;
m_currentArea = p_area;
FUN_10015820(TRUE, LegoOmni::c_disableInput | LegoOmni::c_disable3d);
BackgroundAudioManager()->Stop();
AnimationManager()->FUN_1005ef10();
VideoManager()->SetUnk0x554(FALSE);
MxAtomId* script = g_isleScript;
LegoWorld* world;
switch (p_area) {
case 1:
InvokeAction(Extra::ActionType::e_opendisk, *g_isleScript, 0, NULL);
break;
case 2:
VideoManager()->SetUnk0x554(TRUE);
script = g_infomainScript;
InvokeAction(Extra::ActionType::e_opendisk, *g_infomainScript, 0, NULL);
break;
case 3:
VideoManager()->SetUnk0x554(TRUE);
script = g_infodoorScript;
InvokeAction(Extra::ActionType::e_opendisk, *g_infodoorScript, 0, NULL);
break;
case 4:
case 0xf:
case 0x10:
case 0x11:
case 0x13:
case 0x14:
case 0x15:
case 0x16:
case 0x19:
case 0x1d:
case 0x1f:
case 0x20:
case 0x39:
case 0x3a:
case 0x3b:
case 0x3c:
case 0x3d:
case 0x40:
case 0x42:
world = FindWorld(*g_isleScript, 0);
if (world != NULL) {
if (world->GetUnknown0xd0().empty()) {
break;
}
else {
#ifdef COMPAT_MODE
{
MxNotificationParam param(c_notificationType20, NULL);
NotificationManager()->Send(world, &param);
}
#else
NotificationManager()->Send(world, &MxNotificationParam(c_notificationType20, NULL));
#endif
break;
}
}
InvokeAction(Extra::ActionType::e_opendisk, *g_isleScript, 0, NULL);
break;
// TODO
case 5:
script = g_elevbottScript;
InvokeAction(Extra::ActionType::e_opendisk, *g_elevbottScript, 0, NULL);
break;
case 6:
case 7:
@ -471,7 +509,7 @@ void LegoGameState::SwitchArea(MxU32 p_area)
if (world == NULL) {
InvokeAction(Extra::ActionType::e_opendisk, *g_isleScript, 0, NULL);
}
else {
else if (!world->GetUnknown0xd0().empty()) {
#ifdef COMPAT_MODE
{
MxNotificationParam param(c_notificationType20, NULL);
@ -481,20 +519,96 @@ void LegoGameState::SwitchArea(MxU32 p_area)
NotificationManager()->Send(world, &MxNotificationParam(c_notificationType20, NULL));
#endif
}
InvokeAction(Extra::ActionType::e_start, *g_isleScript, 1050, NULL);
break;
case 8:
VideoManager()->SetUnk0x554(TRUE);
InvokeAction(Extra::ActionType::e_start, *g_isleScript, 1114, NULL);
break;
case 9:
InvokeAction(Extra::ActionType::e_start, *g_isleScript, 1140, NULL);
break;
case 10:
InvokeAction(Extra::ActionType::e_start, *g_isleScript, 1118, NULL);
break;
case 11:
InvokeAction(Extra::ActionType::e_start, *g_isleScript, 1145, NULL);
break;
case 12:
VideoManager()->SetUnk0x554(TRUE);
script = g_regbookScript;
InvokeAction(Extra::ActionType::e_opendisk, *g_regbookScript, 0, NULL);
break;
case 13:
VideoManager()->SetUnk0x554(TRUE);
script = g_infoscorScript;
InvokeAction(Extra::ActionType::e_opendisk, *g_infoscorScript, 0, NULL);
break;
case 14:
if (m_previousArea == 2) {
m_currentArea = 15;
world = FindWorld(*g_isleScript, 0);
if (world != NULL) {
if (world->GetUnknown0xd0().empty()) {
return;
}
else {
#ifdef COMPAT_MODE
{
MxNotificationParam param(c_notificationType20, NULL);
NotificationManager()->Send(world, &param);
}
#else
NotificationManager()->Send(world, &MxNotificationParam(c_notificationType20, NULL));
#endif
}
return;
}
else {
InvokeAction(Extra::ActionType::e_opendisk, *g_isleScript, 0, NULL);
break;
}
}
InvokeAction(Extra::ActionType::e_opendisk, *g_jetraceScript, 0, NULL);
break;
case 18:
if (m_previousArea == 2) {
m_currentArea = 19;
world = FindWorld(*g_isleScript, 0);
if (world != NULL) {
if (world->GetUnknown0xd0().empty()) {
return;
}
else {
#ifdef COMPAT_MODE
{
MxNotificationParam param(c_notificationType20, NULL);
NotificationManager()->Send(world, &param);
}
#else
NotificationManager()->Send(world, &MxNotificationParam(c_notificationType20, NULL));
#endif
}
return;
}
}
InvokeAction(Extra::ActionType::e_opendisk, *g_carraceScript, 0, NULL);
break;
case 26:
VideoManager()->SetUnk0x554(TRUE);
InvokeAction(Extra::ActionType::e_opendisk, *g_garageScript, 0, NULL);
break;
// TODO: implement other cases
// TODO: implement other cases
case 56:
VideoManager()->SetUnk0x554(TRUE);
InvokeAction(Extra::ActionType::e_opendisk, *g_histbookScript, 0, NULL);
break;
default:
break;
}
InvokeAction(Extra::ActionType::e_opendisk, *script, 0, NULL);
}
// FUNCTION: LEGO1 0x1003bac0