Finish JetskiRace (#1158)
Some checks failed
Analyze / ${{ matrix.who }} annotations (CONFIG) (push) Has been cancelled
Analyze / ${{ matrix.who }} annotations (ISLE) (push) Has been cancelled
Analyze / ${{ matrix.who }} annotations (LEGO1) (push) Has been cancelled
Build / Download original binaries (push) Has been cancelled
Build / Current ${{ matrix.toolchain.name }} (map[clang-tidy:true msys-env:mingw-w64-clang-i686 msystem:clang32 name:msys2 clang32 no-dx5-libs:true shell:msys2 {0} werror:true]) (push) Has been cancelled
Build / Current ${{ matrix.toolchain.name }} (map[clang-tidy:true msys-env:mingw-w64-i686 msystem:mingw32 name:msys2 mingw32 shell:msys2 {0} werror:true]) (push) Has been cancelled
Build / Current ${{ matrix.toolchain.name }} (map[name:MSVC setup-cmake:true setup-msvc:true setup-ninja:true shell:sh]) (push) Has been cancelled
Build / MSVC 4.20 (push) Has been cancelled
Format / C++ (push) Has been cancelled
Naming / C++ (push) Has been cancelled
Build / Compare with master (push) Has been cancelled
Build / Upload artifacts (push) Has been cancelled

* Implement `JetskiRace::HandlePathStruct`

* Implement `JetskiRace::FUN_10016930`

* Cleanup, add BETA10

* Match HandlePathStruct

* Address review comments

* Address another review comment

---------

Co-authored-by: jonschz <jonschz@users.noreply.github.com>
Co-authored-by: Christian Semmler <mail@csemmler.com>
This commit is contained in:
jonschz 2024-11-16 20:24:03 +01:00 committed by GitHub
parent b4b28cf32e
commit fe8e56ba47
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 159 additions and 14 deletions

View File

@ -102,6 +102,7 @@ public:
}; };
// VTABLE: LEGO1 0x100d6fb8 // VTABLE: LEGO1 0x100d6fb8
// VTABLE: BETA10 0x101b9cc8
// SIZE 0x140 // SIZE 0x140
class Isle : public LegoWorld { class Isle : public LegoWorld {
public: public:
@ -116,6 +117,7 @@ public:
MxLong Notify(MxParam& p_param) override; // vtable+0x04 MxLong Notify(MxParam& p_param) override; // vtable+0x04
// FUNCTION: LEGO1 0x10030910 // FUNCTION: LEGO1 0x10030910
// FUNCTION: BETA10 0x10035d70
const char* ClassName() const override // vtable+0x0c const char* ClassName() const override // vtable+0x0c
{ {
// STRING: LEGO1 0x100f0458 // STRING: LEGO1 0x100f0458

View File

@ -61,9 +61,20 @@ public:
MxLong HandleClick(LegoEventNotificationParam&) override; // vtable+0x6c MxLong HandleClick(LegoEventNotificationParam&) override; // vtable+0x6c
MxLong HandlePathStruct(LegoPathStructNotificationParam&) override; // vtable+0x70 MxLong HandlePathStruct(LegoPathStructNotificationParam&) override; // vtable+0x70
MxLong HandleEndAction(MxEndActionNotificationParam&) override; // vtable+0x74 MxLong HandleEndAction(MxEndActionNotificationParam&) override; // vtable+0x74
void FUN_10016930(MxS32 p_param1, MxS16 p_param2);
private:
inline MxS32 PossiblyGetPlaceOfPlayer();
static MxS32 g_unk0x100f0c78;
}; };
// SYNTHETIC: LEGO1 0x1000f530 // SYNTHETIC: LEGO1 0x1000f530
// SYNTHETIC: BETA10 0x100a9b70
// JetskiRace::`scalar deleting destructor' // JetskiRace::`scalar deleting destructor'
// SYNTHETIC: BETA10 0x100aa150
// JetskiRace::~JetskiRace
#endif // JETSKIRACE_H #endif // JETSKIRACE_H

View File

@ -28,7 +28,10 @@ public:
return new LegoPathStructNotificationParam(m_type, m_sender, m_trigger, m_data); return new LegoPathStructNotificationParam(m_type, m_sender, m_trigger, m_data);
} // vtable+0x04 } // vtable+0x04
// FUNCTION: BETA10 0x10024270
MxU8 GetTrigger() { return m_trigger; } MxU8 GetTrigger() { return m_trigger; }
// FUNCTION: BETA10 0x100242a0
MxS16 GetData() { return m_data; } MxS16 GetData() { return m_data; }
protected: protected:

View File

@ -81,8 +81,6 @@ public:
Entry* GetState(MxU8 p_id); Entry* GetState(MxU8 p_id);
undefined4 GetUnknown0x28() { return m_unk0x28; }
// SYNTHETIC: LEGO1 0x1000f6f0 // SYNTHETIC: LEGO1 0x1000f6f0
// RaceState::~RaceState // RaceState::~RaceState
@ -151,12 +149,12 @@ public:
// LegoRace::`scalar deleting destructor' // LegoRace::`scalar deleting destructor'
protected: protected:
undefined4 m_unk0xf8; // 0xf8 MxS32 m_unk0xf8; // 0xf8
undefined4 m_unk0xfc; // 0xfc MxS32 m_unk0xfc; // 0xfc
undefined4 m_unk0x100; // 0x100 MxS32 m_unk0x100; // 0x100
undefined4 m_unk0x104; // 0x104 MxS32 m_unk0x104; // 0x104
undefined4 m_unk0x108; // 0x108 MxS32 m_unk0x108; // 0x108
undefined4 m_unk0x10c; // 0x10c MxS32 m_unk0x10c; // 0x10c
LegoRaceActor* m_unk0x110[3]; // 0x110 LegoRaceActor* m_unk0x110[3]; // 0x110
LegoGameState::Area m_destLocation; // 0x11c LegoGameState::Area m_destLocation; // 0x11c
LegoPathActor* m_pathActor; // 0x120 LegoPathActor* m_pathActor; // 0x120

View File

@ -38,6 +38,9 @@ extern const char* g_strHIT_WALL_SOUND;
DECOMP_SIZE_ASSERT(JetskiRace, 0x144) DECOMP_SIZE_ASSERT(JetskiRace, 0x144)
// GLOBAL: LEGO1 0x100f0c78
MxS32 JetskiRace::g_unk0x100f0c78 = 2;
// FUNCTION: LEGO1 0x100162c0 // FUNCTION: LEGO1 0x100162c0
// FUNCTION: BETA10 0x100c7e6f // FUNCTION: BETA10 0x100c7e6f
MxResult JetskiRace::Create(MxDSAction& p_dsAction) MxResult JetskiRace::Create(MxDSAction& p_dsAction)
@ -125,6 +128,7 @@ MxLong JetskiRace::HandleEndAction(MxEndActionNotificationParam& p_param)
MxLong JetskiRace::HandleClick(LegoEventNotificationParam& p_param) MxLong JetskiRace::HandleClick(LegoEventNotificationParam& p_param)
{ {
MxLong result = 0; MxLong result = 0;
if (((LegoControlManagerNotificationParam*) &p_param)->m_unk0x28 == 1) { if (((LegoControlManagerNotificationParam*) &p_param)->m_unk0x28 == 1) {
switch (((LegoControlManagerNotificationParam*) &p_param)->m_clickedObjectId) { switch (((LegoControlManagerNotificationParam*) &p_param)->m_clickedObjectId) {
case JetraceScript::c_JetskiArms_Ctl: case JetraceScript::c_JetskiArms_Ctl:
@ -148,13 +152,139 @@ MxLong JetskiRace::HandleClick(LegoEventNotificationParam& p_param)
break; break;
} }
} }
return result; return result;
} }
// STUB: LEGO1 0x100166a0 inline MxS32 JetskiRace::PossiblyGetPlaceOfPlayer()
MxLong JetskiRace::HandlePathStruct(LegoPathStructNotificationParam&)
{ {
return 0; if (m_unk0xfc < m_unk0xf8 && m_unk0x100 < m_unk0xf8) {
return 3;
}
else if (m_unk0xfc < m_unk0xf8 || m_unk0x100 < m_unk0xf8) {
return 2;
}
return 1;
}
// FUNCTION: LEGO1 0x100166a0
// FUNCTION: BETA10 0x100c8085
MxLong JetskiRace::HandlePathStruct(LegoPathStructNotificationParam& p_param)
{
MxLong result = 0;
MxEntity* sender = (MxEntity*) p_param.GetSender();
if (p_param.GetTrigger() == 68) {
MxS32 paramData = p_param.GetData();
switch (sender->GetEntityId()) {
case 10:
if (paramData <= m_unk0x104 || paramData >= m_unk0x104 + 5) {
break;
}
m_unk0x104 = paramData;
LegoChar buffer[20];
sprintf(buffer, "%g", 0.032 + 0.936 * (m_unk0xf8 * 20.0 + m_unk0x104) / (g_unk0x100f0c78 * 20.0));
VariableTable()->SetVariable("DISTANCE", buffer);
if (m_unk0x104 == 0x14) {
m_unk0x104 = 0;
m_unk0xf8++;
if (g_unk0x100f0c78 == m_unk0xf8) {
MxS16 sVar6 = PossiblyGetPlaceOfPlayer();
VariableTable()->SetVariable(g_raceState, "");
VariableTable()->SetVariable(g_strHIT_WALL_SOUND, "");
LegoRaceCar::FUN_10012de0();
m_raceState->m_unk0x28 = 2;
RaceState::Entry* raceStateEntry = m_raceState->GetState(GameState()->GetActorId());
raceStateEntry->m_unk0x02 = sVar6;
if (raceStateEntry->m_score < sVar6) {
raceStateEntry->m_score = sVar6;
}
m_destLocation = LegoGameState::e_jetrace2;
TransitionManager()->StartTransition(MxTransitionManager::e_mosaic, 50, FALSE, FALSE);
}
result = 1;
}
else if (m_unk0x104 == 0xf) {
m_hideAnim->FUN_1006db40(m_unk0xf8 * 200 + 100);
result = 1;
}
break;
case 11:
if (paramData <= m_unk0x108 || paramData >= m_unk0x108 + 5) {
break;
}
FUN_10016930(0xb, paramData);
m_unk0x108 = paramData;
if (m_unk0x108 == 0x14) {
m_unk0x108 = 0;
m_unk0xfc++;
if (g_unk0x100f0c78 == m_unk0xfc) {
((LegoPathActor*) p_param.GetSender())->SetMaxLinearVel(0.1);
}
}
break;
case 12:
if (paramData <= m_unk0x10c || paramData >= m_unk0x10c + 5) {
break;
}
FUN_10016930(0xc, paramData);
m_unk0x10c = paramData;
if (m_unk0x10c == 0x14) {
m_unk0x10c = 0;
m_unk0x100++;
if (g_unk0x100f0c78 == m_unk0x100) {
((LegoPathActor*) p_param.GetSender())->SetMaxLinearVel(0.1);
}
}
break;
}
}
return result;
}
// FUNCTION: LEGO1 0x10016930
void JetskiRace::FUN_10016930(MxS32 p_param1, MxS16 p_param2)
{
MxS32 local4;
MxStillPresenter* presenter;
MxS32 x, y;
if (p_param1 == 11) {
presenter = m_unk0x128;
local4 = m_unk0xfc;
}
else if (p_param1 == 12) {
presenter = m_unk0x12c;
local4 = m_unk0x100;
}
if (presenter) {
x = m_unk0x130.GetLeft() + 0.5 +
(m_unk0x130.GetRight() - m_unk0x130.GetLeft() + 1) * (local4 * 20.0 + p_param2) / (g_unk0x100f0c78 * 20.0);
y = m_unk0x130.GetTop() + 0.5 +
(m_unk0x130.GetBottom() - m_unk0x130.GetTop() + 1) * (local4 * 20.0 + p_param2) / (g_unk0x100f0c78 * 20.0);
presenter->SetPosition(x, y);
}
} }
// FUNCTION: LEGO1 0x10016a10 // FUNCTION: LEGO1 0x10016a10

View File

@ -529,6 +529,7 @@ MxLong Isle::HandlePathStruct(LegoPathStructNotificationParam& p_param)
} }
// FUNCTION: LEGO1 0x10031820 // FUNCTION: LEGO1 0x10031820
// FUNCTION: BETA10 0x10034158
void Isle::Enable(MxBool p_enable) void Isle::Enable(MxBool p_enable)
{ {
if (m_set0xd0.empty() == p_enable) { if (m_set0xd0.empty() == p_enable) {
@ -595,7 +596,7 @@ void Isle::Enable(MxBool p_enable)
SetIsWorldActive(FALSE); SetIsWorldActive(FALSE);
break; break;
case LegoGameState::e_jetrace2: case LegoGameState::e_jetrace2:
if (((JetskiRaceState*) GameState()->GetState("JetskiRaceState"))->GetUnknown0x28() == 2) { if (((JetskiRaceState*) GameState()->GetState("JetskiRaceState"))->m_unk0x28 == 2) {
m_act1state->m_unk0x018 = 5; m_act1state->m_unk0x018 = 5;
} }
@ -738,7 +739,7 @@ void Isle::Enable(MxBool p_enable)
); );
JetskiRaceState* raceState = (JetskiRaceState*) GameState()->GetState("JetskiRaceState"); JetskiRaceState* raceState = (JetskiRaceState*) GameState()->GetState("JetskiRaceState");
if (raceState->GetUnknown0x28() == 2) { if (raceState->m_unk0x28 == 2) {
IsleScript::Script script = IsleScript::c_noneIsle; IsleScript::Script script = IsleScript::c_noneIsle;
switch (raceState->GetState(GameState()->GetActorId())->GetUnknown0x02()) { switch (raceState->GetState(GameState()->GetActorId())->GetUnknown0x02()) {
@ -771,7 +772,7 @@ void Isle::Enable(MxBool p_enable)
); );
CarRaceState* raceState = (CarRaceState*) GameState()->GetState("CarRaceState"); CarRaceState* raceState = (CarRaceState*) GameState()->GetState("CarRaceState");
if (raceState->GetUnknown0x28() == 2) { if (raceState->m_unk0x28 == 2) {
IsleScript::Script script = IsleScript::c_noneIsle; IsleScript::Script script = IsleScript::c_noneIsle;
switch (raceState->GetState(GameState()->GetActorId())->GetUnknown0x02()) { switch (raceState->GetState(GameState()->GetActorId())->GetUnknown0x02()) {