Implement/match IslePathActor::SpawnPlayer (#884)

* Implement/match IslePathActor::SpawnPlayer

* Fix

* Fix

* Add skip

* Rename param
This commit is contained in:
Christian Semmler 2024-05-04 10:13:05 -04:00 committed by GitHub
parent 1b1d2ecde6
commit 45f9f54f21
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
14 changed files with 278 additions and 57 deletions

View file

@ -14,6 +14,16 @@ class MxType19NotificationParam;
// SIZE 0x160
class IslePathActor : public LegoPathActor {
public:
enum {
c_LOCATIONS_NUM = 29
};
enum {
c_spawnBit1 = 0x01,
c_playMusic = 0x02,
c_spawnBit3 = 0x04
};
// SIZE 0x38
struct SpawnLocation {
SpawnLocation() {}
@ -23,11 +33,11 @@ class IslePathActor : public LegoPathActor {
LegoGameState::Area p_area,
MxAtomId* p_script,
MxS32 p_entityId,
const char* p_key,
undefined2 p_unk0x20,
float p_unk0x24,
undefined2 p_unk0x28,
float p_unk0x2c,
const char* p_path,
MxS16 p_src,
float p_srcScale,
MxS16 p_dest,
float p_destScale,
undefined4 p_unk0x30,
JukeboxScript::Script p_music
)
@ -35,40 +45,39 @@ class IslePathActor : public LegoPathActor {
m_area = p_area;
m_script = p_script;
m_entityId = p_entityId;
strcpy(m_key, p_key);
m_unk0x20 = p_unk0x20;
m_unk0x24 = p_unk0x24;
m_unk0x28 = p_unk0x28;
m_unk0x2c = p_unk0x2c;
strcpy(m_path, p_path);
m_src = p_src;
m_srcScale = p_srcScale;
m_dest = p_dest;
m_destScale = p_destScale;
m_unk0x30 = p_unk0x30;
m_music = p_music;
}
// FUNCTION: LEGO1 0x1001b230
SpawnLocation& operator=(const SpawnLocation& p_container)
SpawnLocation& operator=(const SpawnLocation& p_location)
{
m_area = p_container.m_area;
m_script = p_container.m_script;
m_entityId = p_container.m_entityId;
strcpy(m_key, p_container.m_key);
m_unk0x20 = p_container.m_unk0x20;
m_unk0x24 = p_container.m_unk0x24;
m_unk0x28 = p_container.m_unk0x28;
m_unk0x2c = p_container.m_unk0x2c;
m_unk0x30 = p_container.m_unk0x30;
m_music = p_container.m_music;
m_area = p_location.m_area;
m_script = p_location.m_script;
m_entityId = p_location.m_entityId;
strcpy(m_path, p_location.m_path);
m_src = p_location.m_src;
m_srcScale = p_location.m_srcScale;
m_dest = p_location.m_dest;
m_destScale = p_location.m_destScale;
m_unk0x30 = p_location.m_unk0x30;
m_music = p_location.m_music;
return *this;
}
private:
LegoGameState::Area m_area; // 0x00
MxAtomId* m_script; // 0x04
MxS32 m_entityId; // 0x08
char m_key[20]; // 0x0c
undefined2 m_unk0x20; // 0x20
float m_unk0x24; // 0x24
undefined2 m_unk0x28; // 0x28
float m_unk0x2c; // 0x2c
char m_path[20]; // 0x0c
MxS16 m_src; // 0x20
float m_srcScale; // 0x24
MxS16 m_dest; // 0x28
float m_destScale; // 0x2c
undefined4 m_unk0x30; // 0x30
JukeboxScript::Script m_music; // 0x34
};
@ -111,10 +120,10 @@ class IslePathActor : public LegoPathActor {
// FUNCTION: LEGO1 0x10002e00
virtual MxU32 VTable0xdc(MxType19NotificationParam&) { return 0; } // vtable+0xdc
virtual void VTable0xe0(); // vtable+0xe0
virtual void VTable0xe4(); // vtable+0xe4
virtual void VTable0xe8(LegoGameState::Area, MxBool, MxU8); // vtable+0xe8
virtual void VTable0xec(MxMatrix p_transform, LegoPathBoundary* p_boundary, MxBool p_reset);
virtual void VTable0xe0(); // vtable+0xe0
virtual void VTable0xe4(); // vtable+0xe4
virtual void SpawnPlayer(LegoGameState::Area p_area, MxBool p_und, MxU8 p_flags); // vtable+0xe8
virtual void VTable0xec(MxMatrix p_transform, LegoPathBoundary* p_boundary, MxBool p_reset); // vtable+0xec
// SYNTHETIC: LEGO1 0x10002ff0
// IslePathActor::`scalar deleting destructor'

View file

@ -44,6 +44,14 @@ class LegoPathController : public MxCore {
virtual void VTable0x14(MxU8* p_data, Vector3& p_location, MxAtomId& p_trigger); // vtable+0x14
virtual void Destroy(); // vtable+0x18
MxResult FUN_10045c20(
LegoPathActor* p_actor,
const char* p_path,
MxS32 p_src,
float p_srcScale,
MxS32 p_dest,
float p_destScale
);
undefined4 FUN_10046770(LegoPathActor* p_actor);
void FUN_100468f0(LegoAnimPresenter* p_presenter);
void FUN_10046930(LegoAnimPresenter* p_presenter);

View file

@ -1,11 +1,13 @@
#ifndef LEGOUTILS_H
#define LEGOUTILS_H
#include "decomp.h"
#include "extra.h"
#include "mxtypes.h"
#include <windows.h>
class IslePathActor;
class MxAtomId;
class LegoEntity;
class LegoFile;
@ -22,6 +24,7 @@ Extra::ActionType MatchActionString(const char*);
void InvokeAction(Extra::ActionType p_actionId, const MxAtomId& p_pAtom, MxS32 p_targetEntityId, LegoEntity* p_sender);
void SetCameraControllerFromIsle();
void ConvertHSVToRGB(float p_h, float p_s, float p_v, float* p_rOut, float* p_bOut, float* p_gOut);
void FUN_1003ecc0(IslePathActor* p_actor, undefined4, undefined4, MxBool);
void FUN_1003eda0();
MxBool RemoveFromCurrentWorld(const MxAtomId& p_atomId, MxS32 p_id);
void FUN_1003ef00(MxBool);

View file

@ -28,7 +28,7 @@ class LegoVehicleBuildState : public LegoState {
// SYNTHETIC: LEGO1 0x100260a0
// LegoVehicleBuildState::`scalar deleting destructor'
private:
// private:
Playlist m_unk0x08[4]; // 0x08
// This can be one of the following:
@ -44,8 +44,8 @@ class LegoVehicleBuildState : public LegoState {
// * 6 == exit(ing) build screen
MxU32 m_animationState; // 0x48
undefined m_unk0x4c; // 0x4c
undefined m_unk0x4d; // 0x4d
undefined m_unk0x4e; // 0x4e
MxBool m_unk0x4d; // 0x4d
MxBool m_unk0x4e; // 0x4e
MxU8 m_placedPartCount; // 0x4f
};

View file

@ -65,6 +65,14 @@ class LegoWorld : public LegoEntity {
MxBool PresentersPending();
void Remove(MxCore* p_object);
MxResult FUN_1001f720(
IslePathActor* p_actor,
const char* p_path,
MxS32 p_src,
float p_srcScale,
MxS32 p_dest,
float p_destScale
);
undefined4 FUN_1001fa70(IslePathActor* p_actor);
undefined4 FUN_1001fb70(
IslePathActor* p_actor,

View file

@ -66,17 +66,23 @@ void Helicopter::GetState()
void Helicopter::VTable0xe4()
{
if (GameState()->GetCurrentAct() == LegoGameState::e_act1) {
VTable0xe8(LegoGameState::e_unk40, TRUE, 7);
SpawnPlayer(
LegoGameState::e_unk40,
TRUE,
IslePathActor::c_spawnBit1 | IslePathActor::c_playMusic | IslePathActor::c_spawnBit3
);
}
IslePathActor::VTable0xe4();
if (GameState()->GetCurrentAct() == LegoGameState::e_act1) {
GameState()->SetCurrentArea(LegoGameState::e_copter);
if (CurrentActor()) {
if (CurrentActor()->IsA("IslePathActor")) {
((IslePathActor*) CurrentActor())->VTable0xe8(LegoGameState::e_unk55, TRUE, 7);
}
if (CurrentActor() && CurrentActor()->IsA("IslePathActor")) {
CurrentActor()->SpawnPlayer(
LegoGameState::e_unk55,
TRUE,
IslePathActor::c_spawnBit1 | IslePathActor::c_playMusic | IslePathActor::c_spawnBit3
);
}
}
@ -118,7 +124,11 @@ MxU32 Helicopter::VTable0xcc()
case LegoGameState::e_act1:
m_script = *g_isleScript;
AnimationManager()->FUN_10064670(NULL);
VTable0xe8(LegoGameState::e_unk41, TRUE, 7);
SpawnPlayer(
LegoGameState::e_unk41,
TRUE,
IslePathActor::c_spawnBit1 | IslePathActor::c_playMusic | IslePathActor::c_spawnBit3
);
((Isle*) CurrentWorld())->SetDestLocation(LegoGameState::e_copter);
FUN_10015820(TRUE, 0);
TransitionManager()->StartTransition(MxTransitionManager::e_mosaic, 50, FALSE, TRUE);
@ -258,10 +268,18 @@ MxU32 Helicopter::VTable0xd8(LegoEndAnimNotificationParam& p_param)
case 1: {
if (GameState()->GetCurrentAct() == LegoGameState::e_act1) {
((Act1State*) GameState()->GetState("Act1State"))->SetUnknown18(4);
VTable0xe8(LegoGameState::e_unk42, TRUE, 7);
SpawnPlayer(
LegoGameState::e_unk42,
TRUE,
IslePathActor::c_spawnBit1 | IslePathActor::c_playMusic | IslePathActor::c_spawnBit3
);
}
else {
VTable0xe8(LegoGameState::e_unk49, TRUE, 7);
SpawnPlayer(
LegoGameState::e_unk49,
TRUE,
IslePathActor::c_spawnBit1 | IslePathActor::c_playMusic | IslePathActor::c_spawnBit3
);
}
m_state->SetUnknown8(2);
@ -295,10 +313,18 @@ MxU32 Helicopter::VTable0xd8(LegoEndAnimNotificationParam& p_param)
if (GameState()->GetCurrentAct() == LegoGameState::e_act1) {
((Act1State*) GameState()->GetState("Act1State"))->SetUnknown18(0);
VTable0xe8(LegoGameState::e_unk41, TRUE, 7);
SpawnPlayer(
LegoGameState::e_unk41,
TRUE,
IslePathActor::c_spawnBit1 | IslePathActor::c_playMusic | IslePathActor::c_spawnBit3
);
}
else {
VTable0xe8(LegoGameState::e_unk48, TRUE, 7);
SpawnPlayer(
LegoGameState::e_unk48,
TRUE,
IslePathActor::c_spawnBit1 | IslePathActor::c_playMusic | IslePathActor::c_spawnBit3
);
}
m_state->SetUnknown8(0);

View file

@ -1,14 +1,17 @@
#include "islepathactor.h"
#include "3dmanager/lego3dmanager.h"
#include "isle_actions.h"
#include "jukebox_actions.h"
#include "legoanimationmanager.h"
#include "legonavcontroller.h"
#include "legopathboundary.h"
#include "legoutils.h"
#include "legovehiclebuildstate.h"
#include "legovideomanager.h"
#include "legoworld.h"
#include "misc.h"
#include "mxbackgroundaudiomanager.h"
#include "mxnotificationparam.h"
#include "scripts.h"
@ -16,7 +19,7 @@ DECOMP_SIZE_ASSERT(IslePathActor, 0x160)
DECOMP_SIZE_ASSERT(IslePathActor::SpawnLocation, 0x38)
// GLOBAL: LEGO1 0x10102b28
IslePathActor::SpawnLocation g_spawnLocations[29];
IslePathActor::SpawnLocation g_spawnLocations[IslePathActor::c_LOCATIONS_NUM];
// FUNCTION: LEGO1 0x1001a200
IslePathActor::IslePathActor()
@ -452,11 +455,101 @@ void IslePathActor::RegisterSpawnLocations()
);
}
// STUB: LEGO1 0x1001b2a0
// FUNCTION: LEGO1 0x1001b2a0
// FUNCTION: BETA10 0x100369c6
void IslePathActor::VTable0xe8(LegoGameState::Area, MxBool, MxU8)
void IslePathActor::SpawnPlayer(LegoGameState::Area p_area, MxBool p_und, MxU8 p_flags)
{
// TODO
MxS16 i;
for (i = 0; i < c_LOCATIONS_NUM && g_spawnLocations[i].m_area != p_area; i++) {
}
assert(i != c_LOCATIONS_NUM);
if (i != c_LOCATIONS_NUM) {
LegoWorld* world = FindWorld(*g_spawnLocations[i].m_script, g_spawnLocations[i].m_entityId);
assert(world);
if (m_world != NULL) {
m_world->FUN_1001fc80(this);
m_world->Remove(this);
VideoManager()->Get3DManager()->Remove(*m_roi);
}
m_world = world;
if (p_und) {
VTable0xe0();
}
m_world->FUN_1001f720(
this,
g_spawnLocations[i].m_path,
g_spawnLocations[i].m_src,
g_spawnLocations[i].m_srcScale,
g_spawnLocations[i].m_dest,
g_spawnLocations[i].m_destScale
);
if (GameState()->GetActorId() != m_actorId) {
m_world->Add(this);
}
LegoVehicleBuildState* state = NULL;
if (p_flags & c_spawnBit1) {
MxBool und = FALSE;
IsleScript::Script anim;
switch (g_spawnLocations[i].m_unk0x30) {
case 0x00:
case 0x44:
break;
case 0x0a:
state = (LegoVehicleBuildState*) GameState()->GetState("LegoDuneCarBuildState");
anim = IsleScript::c_igs008na_RunAnim;
break;
case 0x18:
state = (LegoVehicleBuildState*) GameState()->GetState("LegoJetskiBuildState");
anim = IsleScript::c_ijs006sn_RunAnim;
break;
case 0x23:
state = (LegoVehicleBuildState*) GameState()->GetState("LegoCopterBuildState");
anim = IsleScript::c_ips002ro_RunAnim;
break;
case 0x34:
state = (LegoVehicleBuildState*) GameState()->GetState("LegoRaceCarBuildState");
anim = IsleScript::c_irt007in_RunAnim;
break;
default:
und = TRUE;
break;
}
if (state != NULL && state->m_unk0x4d && !state->m_unk0x4e) {
if (AnimationManager()->FUN_10060dc0(anim, NULL, TRUE, FALSE, NULL, FALSE, TRUE, TRUE, TRUE) ==
SUCCESS) {
state->m_unk0x4e = TRUE;
und = FALSE;
}
}
if (und) {
FUN_1003ecc0(this, 0, g_spawnLocations[i].m_unk0x30, TRUE);
}
}
if (m_cameraFlag) {
FUN_1003eda0();
}
if (p_flags & c_playMusic && g_spawnLocations[i].m_music != JukeboxScript::c_noneJukebox) {
MxDSAction action;
action.SetAtomId(*g_jukeboxScript);
action.SetObjectId(g_spawnLocations[i].m_music);
BackgroundAudioManager()->PlayMusic(action, 5, 4);
}
}
}
// FUNCTION: LEGO1 0x1001b5b0

View file

@ -9,8 +9,8 @@ LegoVehicleBuildState::LegoVehicleBuildState(char* p_classType)
{
this->m_className = p_classType;
this->m_unk0x4c = 0;
this->m_unk0x4d = 0;
this->m_unk0x4e = 0;
this->m_unk0x4d = FALSE;
this->m_unk0x4e = FALSE;
this->m_placedPartCount = 0;
}

View file

@ -906,7 +906,11 @@ void LegoGameState::SwitchArea(Area p_area)
AnimationManager()->Resume();
}
CurrentActor()->VTable0xe8(p_area, TRUE, 7);
CurrentActor()->SpawnPlayer(
p_area,
TRUE,
IslePathActor::c_spawnBit1 | IslePathActor::c_playMusic | IslePathActor::c_spawnBit3
);
break;
}
case e_hospital:
@ -918,7 +922,11 @@ void LegoGameState::SwitchArea(Area p_area)
SetCameraControllerFromIsle();
CurrentActor()->ResetWorldTransform(TRUE);
AnimationManager()->Resume();
CurrentActor()->VTable0xe8(p_area, TRUE, 7);
CurrentActor()->SpawnPlayer(
p_area,
TRUE,
IslePathActor::c_spawnBit1 | IslePathActor::c_playMusic | IslePathActor::c_spawnBit3
);
break;
case e_police:
VideoManager()->SetUnk0x554(TRUE);

View file

@ -340,7 +340,15 @@ void ConvertHSVToRGB(float p_h, float p_s, float p_v, float* p_rOut, float* p_bO
}
}
// STUB: LEGO1 0x1003ecc0
// FUNCTION: BETA10 0x100d4b38
void FUN_1003ecc0(IslePathActor* p_actor, undefined4, undefined4, MxBool)
{
// TODO
}
// FUNCTION: LEGO1 0x1003eda0
// FUNCTION: BETA10 0x100d4bf4
void FUN_1003eda0()
{
Mx3DPointFloat vec;

View file

@ -272,6 +272,29 @@ LegoCameraController* LegoWorld::VTable0x54()
return m_cameraController;
}
// FUNCTION: LEGO1 0x1001f720
// FUNCTION: BETA10 0x100da24b
MxResult LegoWorld::FUN_1001f720(
IslePathActor* p_actor,
const char* p_path,
MxS32 p_src,
float p_srcScale,
MxS32 p_dest,
float p_destScale
)
{
LegoPathControllerListCursor cursor(&m_list0x68);
LegoPathController* controller;
while (cursor.Next(controller)) {
if (controller->FUN_10045c20(p_actor, p_path, p_src, p_srcScale, p_dest, p_destScale) == SUCCESS) {
return SUCCESS;
}
}
return FAILURE;
}
// STUB: LEGO1 0x1001fa70
undefined4 LegoWorld::FUN_1001fa70(IslePathActor* p_actor)
{

View file

@ -27,6 +27,20 @@ MxResult LegoPathController::Tickle()
return SUCCESS;
}
// STUB: LEGO1 0x10045c20
// FUNCTION: BETA10 0x100b6d80
MxResult LegoPathController::FUN_10045c20(
LegoPathActor* p_actor,
const char* p_path,
MxS32 p_src,
float p_srcScale,
MxS32 p_dest,
float p_destScale
)
{
return SUCCESS;
}
// STUB: LEGO1 0x10046770
undefined4 LegoPathController::FUN_10046770(LegoPathActor* p_actor)
{

View file

@ -504,7 +504,11 @@ void Isle::Enable(MxBool p_enable)
if (CurrentActor() != NULL && CurrentActor()->IsA("Jetski")) {
IslePathActor* actor = CurrentActor();
actor->VTable0xe8(LegoGameState::e_unk45, FALSE, 7);
actor->SpawnPlayer(
LegoGameState::e_unk45,
FALSE,
IslePathActor::c_spawnBit1 | IslePathActor::c_playMusic | IslePathActor::c_spawnBit3
);
actor->SetState(0);
}
else {
@ -653,7 +657,11 @@ void Isle::Enable(MxBool p_enable)
}
break;
case 5: {
CurrentActor()->VTable0xe8(LegoGameState::e_jetrace2, FALSE, 7);
CurrentActor()->SpawnPlayer(
LegoGameState::e_jetrace2,
FALSE,
IslePathActor::c_spawnBit1 | IslePathActor::c_playMusic | IslePathActor::c_spawnBit3
);
JetskiRaceState* raceState = (JetskiRaceState*) GameState()->GetState("JetskiRaceState");
if (raceState->GetUnknown0x28() == 2) {
@ -681,7 +689,11 @@ void Isle::Enable(MxBool p_enable)
}
case 6: {
GameState()->m_currentArea = LegoGameState::e_carraceExterior;
CurrentActor()->VTable0xe8(LegoGameState::e_unk21, FALSE, 7);
CurrentActor()->SpawnPlayer(
LegoGameState::e_unk21,
FALSE,
IslePathActor::c_spawnBit1 | IslePathActor::c_playMusic | IslePathActor::c_spawnBit3
);
CarRaceState* raceState = (CarRaceState*) GameState()->GetState("CarRaceState");
if (raceState->GetUnknown0x28() == 2) {
@ -726,7 +738,11 @@ void Isle::Enable(MxBool p_enable)
break;
case 11:
m_act1state->m_unk0x018 = 0;
CurrentActor()->VTable0xe8(LegoGameState::e_unk54, TRUE, 7);
CurrentActor()->SpawnPlayer(
LegoGameState::e_unk54,
TRUE,
IslePathActor::c_spawnBit1 | IslePathActor::c_playMusic | IslePathActor::c_spawnBit3
);
GameState()->m_currentArea = LegoGameState::e_unk66;
FUN_1003ef00(TRUE);
m_jukebox->StartAction();
@ -786,7 +802,11 @@ void Isle::FUN_10032620()
case LegoGameState::e_hospitalExterior:
case LegoGameState::e_unk31:
case LegoGameState::e_policeExterior:
CurrentActor()->VTable0xe8(GameState()->m_currentArea, TRUE, 7);
CurrentActor()->SpawnPlayer(
GameState()->m_currentArea,
TRUE,
IslePathActor::c_spawnBit1 | IslePathActor::c_playMusic | IslePathActor::c_spawnBit3
);
GameState()->m_currentArea = LegoGameState::e_unk66;
break;
}

View file

@ -29,3 +29,4 @@ m_disAnimP: "Allow original naming from beta"
i_activity: "Allow original naming from beta"
i_actor: "Allow original naming from beta"
score: "Allow original naming from beta"
c_LOCATIONS_NUM: "Allow original naming from beta"