Skip to content

Commit

Permalink
Implement LegoCarBuild::FUN_10024890() and others, refactor (#1126)
Browse files Browse the repository at this point in the history
* Commit finished code changes

* Add enum data type

* Refactor away GetCurrentArea, SetCurrentArea

* Clean up and add FUN_10024890

* Add `SetPartObjectIdByName()`

* Fix naming error

* Address review comments, part 1

* Address review comments, part 2

---------

Co-authored-by: jonschz <[email protected]>
  • Loading branch information
jonschz and jonschz authored Nov 1, 2024
1 parent 115343f commit 4c0aae7
Show file tree
Hide file tree
Showing 32 changed files with 445 additions and 93 deletions.
16 changes: 13 additions & 3 deletions LEGO1/lego/legoomni/include/legocarbuild.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "legoworld.h"

class LegoCarBuildAnimPresenter;
class LegoControlManagerNotificationParam;
class LegoEventNotificationParam;
class MxControlPresenter;
class MxStillPresenter;
Expand All @@ -21,6 +22,7 @@ class LegoVehicleBuildState : public LegoState {
e_entering = 1,
e_unknown2 = 2,
e_cutscene = 3,
e_unknown4 = 4,
e_exiting = 6
};

Expand Down Expand Up @@ -71,6 +73,11 @@ typedef LegoVehicleBuildState LegoJetskiBuildState;
// SIZE 0x34c
class LegoCarBuild : public LegoWorld {
public:
enum Unknown0xf8 {
c_unknownminusone = -1,
c_unknown8 = 8
};

LegoCarBuild();
~LegoCarBuild() override;

Expand Down Expand Up @@ -117,14 +124,16 @@ class LegoCarBuild : public LegoWorld {
undefined4 FUN_100244e0(MxLong p_x, MxLong p_y);
undefined4 FUN_100246e0(MxLong p_x, MxLong p_y);
MxS32 FUN_10024850(MxLong p_x, MxLong p_y);
undefined4 FUN_10024890(LegoEventNotificationParam* p_param);
undefined4 FUN_10024890(MxParam* p_param);
undefined4 FUN_10024c20(LegoEventNotificationParam* p_param);
void FUN_10024ef0();
void FUN_10024f30();
void FUN_10024f50();
void FUN_10024f70(MxBool p_enabled);
void SetPresentersEnabled(MxBool p_enabled);
void TogglePresentersEnabled();
void FUN_100250e0(MxBool p_param);
void FUN_10025350(MxS32 p_param);
void FUN_10025450();
undefined4 FUN_10025720(undefined4 p_param1);
MxS32 FUN_10025d70();
Expand All @@ -139,7 +148,7 @@ class LegoCarBuild : public LegoWorld {
// LegoCarBuild::`scalar deleting destructor'

private:
undefined4 m_unk0xf8; // 0xf8
Unknown0xf8 m_unk0xf8; // 0xf8
MxS16 m_unk0xfc; // 0xfc
undefined m_unk0xfe[2]; // 0xfe
MxS32 m_unk0x100; // 0x100
Expand Down Expand Up @@ -197,7 +206,8 @@ class LegoCarBuild : public LegoWorld {
// variable name verified by BETA10 0x1006b219
LegoVehicleBuildState* m_buildState; // 0x32c

undefined4 m_unk0x330; // 0x330
// variable name verified by BETA10 0x1006d742
undefined4 m_carId; // 0x330

// variable name verified by BETA10 0x1006cba7
LegoGameState::Area m_destLocation; // 0x334
Expand Down
25 changes: 21 additions & 4 deletions LEGO1/lego/legoomni/include/legocarbuildpresenter.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class LegoCarBuildAnimPresenter : public LegoAnimPresenter {
{
m_name = NULL;
m_wiredName = NULL;
m_unk0x08 = 0;
m_objectId = 0;
}

// variable name verified by BETA10 0x10071b56
Expand All @@ -30,7 +30,8 @@ class LegoCarBuildAnimPresenter : public LegoAnimPresenter {
// variable name verified by BETA10 0x100719f0
LegoChar* m_wiredName; // 0x04

undefined2 m_unk0x08; // 0x08
// variable name guessed based on the setter at LEGO1 0x0x10079dc0 and its use in LEGO1 0x10024890
MxS16 m_objectId; // 0x08
};

LegoCarBuildAnimPresenter();
Expand Down Expand Up @@ -77,15 +78,33 @@ class LegoCarBuildAnimPresenter : public LegoAnimPresenter {
MxBool StringEqualsShelf(const LegoChar* p_string);
MxBool StringEndsOnY(const LegoChar* p_string);
MxBool StringEndsOnZero(const LegoChar* p_string);
const LegoChar* GetWiredNameByPartName(const LegoChar* p_name);
void SetPartObjectIdByName(const LegoChar* p_name, MxS16 p_objectId);

// FUNCTION: BETA10 0x10070180
void SetUnknown0xbc(undefined2 p_unk0xbc) { m_unk0xbc = p_unk0xbc; }

// FUNCTION: BETA10 0x100703b0
MxMatrix& GetUnknown0xe0() { return m_unk0xe0; }

MxBool StringEndsOnW(LegoChar* p_param);
MxBool StringEndsOnYOrN(const LegoChar* p_string);

const BoundingSphere& FUN_10079e20();

// FUNCTION: BETA10 0x100703e0
const LegoChar* GetWiredNameOfLastPlacedPart() { return m_parts[m_placedPartCount].m_wiredName; }

MxS16 GetNumberOfParts() { return m_numberOfParts; }
MxS16 GetPlacedPartCount() { return m_placedPartCount; }

// FUNCTION: BETA10 0x10070270
MxBool AllPartsPlaced()
{
// this function differs in BETA10
return m_placedPartCount == m_numberOfParts;
}

// SYNTHETIC: LEGO1 0x10078660
// LegoCarBuildAnimPresenter::`scalar deleting destructor'

Expand Down Expand Up @@ -118,8 +137,6 @@ class LegoCarBuildAnimPresenter : public LegoAnimPresenter {

// name verified by BETA10 0x10070d63
LegoChar* m_mainSourceId; // 0x14c

friend class LegoCarBuild;
};

#endif // LEGOCARBUILDPRESENTER_H
2 changes: 0 additions & 2 deletions LEGO1/lego/legoomni/include/legogamestate.h
Original file line number Diff line number Diff line change
Expand Up @@ -172,13 +172,11 @@ class LegoGameState {

Act GetCurrentAct() { return m_currentAct; }
Act GetLoadedAct() { return m_loadedAct; }
Area GetCurrentArea() { return m_currentArea; }
Area GetPreviousArea() { return m_previousArea; }
Area GetUnknown0x42c() { return m_unk0x42c; }
History* GetHistory() { return &m_history; }

void SetDirty(MxBool p_isDirty) { m_isDirty = p_isDirty; }
void SetCurrentArea(Area p_currentArea) { m_currentArea = p_currentArea; }
void SetPreviousArea(Area p_previousArea) { m_previousArea = p_previousArea; }
void SetActorId(MxU8 p_actorId) { m_actorId = p_actorId; }
void SetUnknown0x42c(Area p_unk0x42c) { m_unk0x42c = p_unk0x42c; }
Expand Down
2 changes: 2 additions & 0 deletions LEGO1/lego/legoomni/include/legoinputmanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,9 @@ class LegoInputManager : public MxPresenter {
// FUNCTION: BETA10 0x10031ba0
LegoControlManager* GetControlManager() { return m_controlManager; }

// FUNCTION: BETA10 0x10017870
LegoWorld* GetWorld() { return m_world; }

LegoCameraController* GetCamera() { return m_camera; }

void ProcessEvents();
Expand Down
21 changes: 12 additions & 9 deletions LEGO1/lego/legoomni/include/mxtransitionmanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class MxTransitionManager : public MxCore {
virtual MxResult GetDDrawSurfaceFromVideoManager(); // vtable+0x14

enum TransitionType {
e_notTransitioning = 0,
e_idle = 0, // name verified by BETA10 0x100ec4e6
e_noAnimation,
e_dissolve,
e_mosaic,
Expand All @@ -45,7 +45,7 @@ class MxTransitionManager : public MxCore {

MxResult StartTransition(TransitionType p_animationType, MxS32 p_speed, MxBool p_doCopy, MxBool p_playMusicInAnim);

TransitionType GetTransitionType() { return m_transitionType; }
TransitionType GetTransitionType() { return m_mode; }

// SYNTHETIC: LEGO1 0x1004b9e0
// MxTransitionManager::`scalar deleting destructor'
Expand All @@ -68,13 +68,16 @@ class MxTransitionManager : public MxCore {
FlagBitfield m_copyFlags; // 0x20
undefined4 m_unk0x24; // 0x24
FlagBitfield m_unk0x28; // 0x28
TransitionType m_transitionType; // 0x2c
LPDIRECTDRAWSURFACE m_ddSurface; // 0x30
MxU16 m_animationTimer; // 0x34
MxU16 m_columnOrder[640]; // 0x36
MxU16 m_randomShift[480]; // 0x536
MxULong m_systemTime; // 0x8f8
MxS32 m_animationSpeed; // 0x8fc

// name verified by BETA10 0x100ec4e6
TransitionType m_mode; // 0x2c

LPDIRECTDRAWSURFACE m_ddSurface; // 0x30
MxU16 m_animationTimer; // 0x34
MxU16 m_columnOrder[640]; // 0x36
MxU16 m_randomShift[480]; // 0x536
MxULong m_systemTime; // 0x8f8
MxS32 m_animationSpeed; // 0x8fc
};

#endif // MXTRANSITIONMANAGER_H
2 changes: 1 addition & 1 deletion LEGO1/lego/legoomni/src/actors/bike.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ MxResult Bike::Create(MxDSAction& p_dsAction)
void Bike::Exit()
{
IslePathActor::Exit();
GameState()->SetCurrentArea(LegoGameState::Area::e_bike);
GameState()->m_currentArea = LegoGameState::Area::e_bike;
RemoveFromCurrentWorld(*g_isleScript, IsleScript::c_BikeDashboard_Bitmap);
RemoveFromCurrentWorld(*g_isleScript, IsleScript::c_BikeArms_Ctl);
RemoveFromCurrentWorld(*g_isleScript, IsleScript::c_BikeHorn_Ctl);
Expand Down
4 changes: 2 additions & 2 deletions LEGO1/lego/legoomni/src/actors/helicopter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ void Helicopter::Exit()
IslePathActor::Exit();

if (GameState()->GetCurrentAct() == LegoGameState::e_act1) {
GameState()->SetCurrentArea(LegoGameState::e_copter);
GameState()->m_currentArea = LegoGameState::e_copter;
if (UserActor() && UserActor()->IsA("IslePathActor")) {
((IslePathActor*) UserActor())
->SpawnPlayer(
Expand Down Expand Up @@ -180,7 +180,7 @@ MxLong Helicopter::HandleControl(LegoControlManagerNotificationParam& p_param)
break;
}
Exit();
GameState()->SetCurrentArea(LegoGameState::e_unk66);
GameState()->m_currentArea = LegoGameState::e_unk66;
ret = 1;
break;
case IsleScript::c_Helicopter_TakeOff_Ctl: {
Expand Down
Loading

0 comments on commit 4c0aae7

Please sign in to comment.