Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Match Jetski::HandleClick #1380

Merged
merged 4 commits into from
Feb 2, 2025
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 20 additions & 17 deletions LEGO1/lego/legoomni/src/actors/dunebuggy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,27 +157,30 @@ MxLong DuneBuggy::HandlePathStruct(LegoPathStructNotificationParam& p_param)
}

// FUNCTION: LEGO1 0x10068290
// FUNCTION: BETA10 0x1002765d
MxS32 DuneBuggy::GetColorOffset(const char* p_variable)
{
MxS32 offset = 1;
const char* colorName = VariableTable()->GetVariable(p_variable);
const char* color = VariableTable()->GetVariable(p_variable);
assert(color);

if (strcmpi(colorName, "lego green")) {
if (!strcmpi(colorName, "lego red")) {
offset = 2;
}
else if (!strcmpi(colorName, "lego yellow")) {
offset = 3;
}
else if (!strcmpi(colorName, "lego black")) {
offset = 4;
}
else if (!strcmpi(colorName, "lego blue")) {
offset = 5;
}
else if (!strcmpi(colorName, "lego white")) {
offset = 6;
}
if (!strcmpi(color, "lego green")) {
offset = 1;
}
else if (!strcmpi(color, "lego red")) {
offset = 2;
}
else if (!strcmpi(color, "lego yellow")) {
offset = 3;
}
else if (!strcmpi(color, "lego black")) {
offset = 4;
}
else if (!strcmpi(color, "lego blue")) {
offset = 5;
}
else if (!strcmpi(color, "lego white")) {
offset = 6;
}

return offset;
Expand Down
10 changes: 7 additions & 3 deletions LEGO1/lego/legoomni/src/actors/jetski.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,15 @@

DECOMP_SIZE_ASSERT(Jetski, 0x164)

// These two have been changed between BETA10 and LEGO1
// GLOBAL: LEGO1 0x100f7ab8
// STRING: LEGO1 0x100f3ce0
// GLOBAL: BETA10 0x101e0be4
const char* g_varJSFRNTY5 = "c_jsfrnty5";

// GLOBAL: LEGO1 0x100f7abc
// STRING: LEGO1 0x100f3ca4
// GLOBAL: BETA10 0x101e0be0
const char* g_varJSWNSHY5 = "c_jswnshy5";

// FUNCTION: LEGO1 0x1007e3b0
Expand Down Expand Up @@ -90,9 +93,10 @@ MxLong Jetski::HandleClick()
((IslePathActor*) UserActor())->Exit();
}

// TODO: Match
m_unk0x160 = ((DuneBuggy::GetColorOffset(g_varJSWNSHY5) * 5 + 15) * 2);
m_unk0x160 += DuneBuggy::GetColorOffset(g_varJSFRNTY5);
MxS32 local8 = DuneBuggy::GetColorOffset(g_varJSWNSHY5);
m_unk0x160 = 10 * (local8 + 3);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use the constants from the actions header here. I believe it's the base offset 40 + local8*10 iirc. The compiler will change the math to the same assembly

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You mean to use JetskiScript::c_Jetski_Actor for the 3? Not sure what you have in mind for the 10.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Try IsleScript::c_JetskiFuelMeter + (local8 - 1) * 10 (untested)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you look at the constants in that header it should become clearer

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the hint! While your suggestion matches LEGO1, it does not match BETA10, unfortunately. I have commented what the code does and also cleaned things up a little. While I was at it, I also (roughly) decompiled the BETA10 version - it still has one issue which may be entropy related.

MxS32 local1c = DuneBuggy::GetColorOffset(g_varJSFRNTY5);
m_unk0x160 += local1c;

InvokeAction(Extra::ActionType::e_start, *g_isleScript, m_unk0x160, NULL);
InvokeAction(Extra::ActionType::e_start, *g_isleScript, IsleScript::c_JetskiDashboard, NULL);
Expand Down