From b67af71f338924b12e5514eed82d292bc92781e4 Mon Sep 17 00:00:00 2001 From: Christian Semmler Date: Fri, 31 May 2024 22:46:05 -0400 Subject: [PATCH 1/9] Improve naming, use virtual key constants (#979) --- ISLE/isleapp.cpp | 2 +- .../lego/legoomni/include/legoinputmanager.h | 8 ++-- .../legoomni/src/entity/legonavcontroller.cpp | 2 +- .../legoomni/src/input/legoinputmanager.cpp | 43 ++++++++++--------- LEGO1/lego/legoomni/src/worlds/gasstation.cpp | 2 +- LEGO1/lego/legoomni/src/worlds/hospital.cpp | 2 +- LEGO1/lego/legoomni/src/worlds/infocenter.cpp | 3 +- LEGO1/lego/legoomni/src/worlds/police.cpp | 2 +- .../legoomni/src/worlds/registrationbook.cpp | 8 ++-- 9 files changed, 36 insertions(+), 36 deletions(-) diff --git a/ISLE/isleapp.cpp b/ISLE/isleapp.cpp index 6f6296aa..3f0892ed 100644 --- a/ISLE/isleapp.cpp +++ b/ISLE/isleapp.cpp @@ -153,7 +153,7 @@ void IsleApp::Close() if (Lego()) { GameState()->Save(0); if (InputManager()) { - InputManager()->QueueEvent(c_notificationKeyPress, 0, 0, 0, 0x20); + InputManager()->QueueEvent(c_notificationKeyPress, 0, 0, 0, VK_SPACE); } VideoManager()->Get3DManager()->GetLego3DView()->GetViewManager()->RemoveAll(NULL); diff --git a/LEGO1/lego/legoomni/include/legoinputmanager.h b/LEGO1/lego/legoomni/include/legoinputmanager.h index 2bd7e26b..c4a0dc1a 100644 --- a/LEGO1/lego/legoomni/include/legoinputmanager.h +++ b/LEGO1/lego/legoomni/include/legoinputmanager.h @@ -125,8 +125,8 @@ public: void ProcessEvents(); MxBool ProcessOneEvent(LegoEventNotificationParam& p_param); MxBool FUN_1005cdf0(LegoEventNotificationParam& p_param); - void FUN_1005c0f0(); - MxResult FUN_1005c160(MxU32& p_keyFlags); + void GetKeyboardState(); + MxResult GetNavigationKeyStates(MxU32& p_keyFlags); // SYNTHETIC: LEGO1 0x1005b8d0 // LegoInputManager::`scalar deleting destructor' @@ -148,8 +148,8 @@ private: MxBool m_unk0x88; // 0x88 IDirectInput* m_directInput; // 0x8c IDirectInputDevice* m_directInputDevice; // 0x90 - MxBool m_unk0x94; // 0x94 - MxU8 m_unk0x95[256]; // 0x95 + MxBool m_kbStateSuccess; // 0x94 + MxU8 m_keyboardState[256]; // 0x95 MxBool m_unk0x195; // 0x195 MxS32 m_joyid; // 0x198 MxS32 m_joystickIndex; // 0x19c diff --git a/LEGO1/lego/legoomni/src/entity/legonavcontroller.cpp b/LEGO1/lego/legoomni/src/entity/legonavcontroller.cpp index 63377d72..7f5fef34 100644 --- a/LEGO1/lego/legoomni/src/entity/legonavcontroller.cpp +++ b/LEGO1/lego/legoomni/src/entity/legonavcontroller.cpp @@ -537,7 +537,7 @@ MxResult LegoNavController::ProcessKeyboardInput() LegoInputManager* inputManager = LegoOmni::GetInstance()->GetInputManager(); MxU32 keyFlags; - if (inputManager == NULL || inputManager->FUN_1005c160(keyFlags) == FAILURE) { + if (inputManager == NULL || inputManager->GetNavigationKeyStates(keyFlags) == FAILURE) { return FAILURE; } diff --git a/LEGO1/lego/legoomni/src/input/legoinputmanager.cpp b/LEGO1/lego/legoomni/src/input/legoinputmanager.cpp index 200652b1..de3ae8b2 100644 --- a/LEGO1/lego/legoomni/src/input/legoinputmanager.cpp +++ b/LEGO1/lego/legoomni/src/input/legoinputmanager.cpp @@ -40,7 +40,7 @@ LegoInputManager::LegoInputManager() m_unk0x88 = FALSE; m_directInput = NULL; m_directInputDevice = NULL; - m_unk0x94 = FALSE; + m_kbStateSuccess = FALSE; m_unk0x195 = 0; m_joyid = -1; m_joystickIndex = -1; @@ -142,63 +142,63 @@ void LegoInputManager::ReleaseDX() } // FUNCTION: LEGO1 0x1005c0f0 -void LegoInputManager::FUN_1005c0f0() +void LegoInputManager::GetKeyboardState() { - m_unk0x94 = FALSE; + m_kbStateSuccess = FALSE; if (m_directInputDevice) { - HRESULT hr = m_directInputDevice->GetDeviceState(sizeOfArray(m_unk0x95), &m_unk0x95); + HRESULT hr = m_directInputDevice->GetDeviceState(sizeOfArray(m_keyboardState), &m_keyboardState); if (hr == DIERR_INPUTLOST || hr == DIERR_NOTACQUIRED) { if (m_directInputDevice->Acquire() == S_OK) { - hr = m_directInputDevice->GetDeviceState(sizeOfArray(m_unk0x95), &m_unk0x95); + hr = m_directInputDevice->GetDeviceState(sizeOfArray(m_keyboardState), &m_keyboardState); } } if (hr == S_OK) { - m_unk0x94 = TRUE; + m_kbStateSuccess = TRUE; } } } // FUNCTION: LEGO1 0x1005c160 -MxResult LegoInputManager::FUN_1005c160(MxU32& p_keyFlags) +MxResult LegoInputManager::GetNavigationKeyStates(MxU32& p_keyFlags) { - FUN_1005c0f0(); + GetKeyboardState(); - if (!m_unk0x94) { + if (!m_kbStateSuccess) { return FAILURE; } if (g_unk0x100f67b8) { - if (m_unk0x95[DIK_LEFT] & 0x80 && GetAsyncKeyState(VK_LEFT) == 0) { - m_unk0x95[DIK_LEFT] = 0; + if (m_keyboardState[DIK_LEFT] & 0x80 && GetAsyncKeyState(VK_LEFT) == 0) { + m_keyboardState[DIK_LEFT] = 0; } - if (m_unk0x95[DIK_RIGHT] & 0x80 && GetAsyncKeyState(VK_RIGHT) == 0) { - m_unk0x95[DIK_RIGHT] = 0; + if (m_keyboardState[DIK_RIGHT] & 0x80 && GetAsyncKeyState(VK_RIGHT) == 0) { + m_keyboardState[DIK_RIGHT] = 0; } } MxU32 keyFlags = 0; - if ((m_unk0x95[DIK_NUMPAD8] | m_unk0x95[DIK_UP]) & 0x80) { + if ((m_keyboardState[DIK_NUMPAD8] | m_keyboardState[DIK_UP]) & 0x80) { keyFlags |= c_up; } - if ((m_unk0x95[DIK_NUMPAD2] | m_unk0x95[DIK_DOWN]) & 0x80) { + if ((m_keyboardState[DIK_NUMPAD2] | m_keyboardState[DIK_DOWN]) & 0x80) { keyFlags |= c_down; } - if ((m_unk0x95[DIK_NUMPAD4] | m_unk0x95[DIK_LEFT]) & 0x80) { + if ((m_keyboardState[DIK_NUMPAD4] | m_keyboardState[DIK_LEFT]) & 0x80) { keyFlags |= c_left; } - if ((m_unk0x95[DIK_NUMPAD6] | m_unk0x95[DIK_RIGHT]) & 0x80) { + if ((m_keyboardState[DIK_NUMPAD6] | m_keyboardState[DIK_RIGHT]) & 0x80) { keyFlags |= c_right; } - if ((m_unk0x95[DIK_LCONTROL] | m_unk0x95[DIK_RCONTROL]) & 0x80) { + if ((m_keyboardState[DIK_LCONTROL] | m_keyboardState[DIK_RCONTROL]) & 0x80) { keyFlags |= c_bit5; } @@ -290,6 +290,7 @@ MxResult LegoInputManager::GetJoystickState( } } } + return FAILURE; } @@ -345,7 +346,7 @@ void LegoInputManager::QueueEvent(NotificationId p_id, MxU8 p_modifier, MxLong p LegoEventNotificationParam param = LegoEventNotificationParam(p_id, NULL, p_modifier, p_x, p_y, p_key); if (((!m_unk0x88) || ((m_unk0x335 && (param.GetType() == c_notificationButtonDown)))) || - ((m_unk0x336 && (p_key == ' ')))) { + ((m_unk0x336 && (p_key == VK_SPACE)))) { ProcessOneEvent(param); } } @@ -369,8 +370,8 @@ MxBool LegoInputManager::ProcessOneEvent(LegoEventNotificationParam& p_param) MxBool processRoi; if (p_param.GetType() == c_notificationKeyPress) { - if (!Lego()->IsTimerRunning() || p_param.GetKey() == 0x13) { - if (p_param.GetKey() == 0x10) { + if (!Lego()->IsTimerRunning() || p_param.GetKey() == VK_PAUSE) { + if (p_param.GetKey() == VK_SHIFT) { if (m_unk0x195) { m_unk0x80 = FALSE; p_param.SetType(c_notificationDrag); diff --git a/LEGO1/lego/legoomni/src/worlds/gasstation.cpp b/LEGO1/lego/legoomni/src/worlds/gasstation.cpp index 4042eb8d..5f48e5f0 100644 --- a/LEGO1/lego/legoomni/src/worlds/gasstation.cpp +++ b/LEGO1/lego/legoomni/src/worlds/gasstation.cpp @@ -297,7 +297,7 @@ MxLong GasStation::HandleEndAction(MxEndActionNotificationParam& p_param) // FUNCTION: LEGO1 0x10005920 MxLong GasStation::HandleKeyPress(MxS8 p_key) { - if (p_key == ' ' && g_unk0x100f0160 == 0 && this->m_unk0x106 != 0) { + if (p_key == VK_SPACE && g_unk0x100f0160 == 0 && m_unk0x106 != 0) { m_state->FUN_10006490(); return 1; } diff --git a/LEGO1/lego/legoomni/src/worlds/hospital.cpp b/LEGO1/lego/legoomni/src/worlds/hospital.cpp index 59d265f7..5848b4ad 100644 --- a/LEGO1/lego/legoomni/src/worlds/hospital.cpp +++ b/LEGO1/lego/legoomni/src/worlds/hospital.cpp @@ -226,7 +226,7 @@ MxLong Hospital::HandleKeyPress(MxS8 p_key) { MxLong result = 0; - if (p_key == ' ' && g_unk0x100f7918 == 0) { + if (p_key == VK_SPACE && g_unk0x100f7918 == 0) { DeleteObjects(&m_atom, HospitalScript::c_hho002cl_RunAnim, HospitalScript::c_hho006cl_RunAnim); result = 1; } diff --git a/LEGO1/lego/legoomni/src/worlds/infocenter.cpp b/LEGO1/lego/legoomni/src/worlds/infocenter.cpp index 2277300a..942551bd 100644 --- a/LEGO1/lego/legoomni/src/worlds/infocenter.cpp +++ b/LEGO1/lego/legoomni/src/worlds/infocenter.cpp @@ -612,7 +612,6 @@ MxU8 Infocenter::HandleMouseMove(MxS32 p_x, MxS32 p_y) VideoManager()->SortPresenterList(); m_unk0x11c->Enable(TRUE); m_unk0x11c->SetPosition(p_x, p_y); - m_unk0x11c->SetDisplayZ(oldDisplayZ); } else { @@ -631,7 +630,7 @@ MxLong Infocenter::HandleKeyPress(MxS8 p_key) { MxLong result = 0; - if (p_key == ' ' && m_worldStarted) { + if (p_key == VK_SPACE && m_worldStarted) { switch (m_infocenterState->GetUnknown0x74()) { case 0: StopCutscene(); diff --git a/LEGO1/lego/legoomni/src/worlds/police.cpp b/LEGO1/lego/legoomni/src/worlds/police.cpp index b80e1a33..897fa52c 100644 --- a/LEGO1/lego/legoomni/src/worlds/police.cpp +++ b/LEGO1/lego/legoomni/src/worlds/police.cpp @@ -164,7 +164,7 @@ MxLong Police::HandleKeyPress(LegoEventNotificationParam& p_param) { MxLong result = 0; - if (p_param.GetKey() == ' ' && m_policeState->GetUnknown0x0c() == 1) { + if (p_param.GetKey() == VK_SPACE && m_policeState->GetUnknown0x0c() == 1) { DeleteObjects(&m_atom, PoliceScript::c_nps001ni_RunAnim, PoliceScript::c_nps002la_RunAnim); m_policeState->SetUnknown0x0c(0); return 1; diff --git a/LEGO1/lego/legoomni/src/worlds/registrationbook.cpp b/LEGO1/lego/legoomni/src/worlds/registrationbook.cpp index 28cd8c27..803074d8 100644 --- a/LEGO1/lego/legoomni/src/worlds/registrationbook.cpp +++ b/LEGO1/lego/legoomni/src/worlds/registrationbook.cpp @@ -166,13 +166,13 @@ MxLong RegistrationBook::HandleKeyPress(MxU8 p_key) key = p_key; } - if ((key < 'A' || key > 'Z') && key != '\b') { - if (key == ' ') { + if ((key < 'A' || key > 'Z') && key != VK_BACK) { + if (key == VK_SPACE) { DeleteObjects(&m_atom, RegbookScript::c_iic006in_RunAnim, RegbookScript::c_iic008in_PlayWav); BackgroundAudioManager()->RaiseVolume(); } } - else if (key != '\b' && m_unk0x280.m_cursorPos < 7) { + else if (key != VK_BACK && m_unk0x280.m_cursorPos < 7) { m_name[0][m_unk0x280.m_cursorPos] = m_alphabet[key - 'A']->Clone(); if (m_name[0][m_unk0x280.m_cursorPos] != NULL) { @@ -190,7 +190,7 @@ MxLong RegistrationBook::HandleKeyPress(MxU8 p_key) } } else { - if (key == '\b' && m_unk0x280.m_cursorPos > 0) { + if (key == VK_BACK && m_unk0x280.m_cursorPos > 0) { m_unk0x280.m_cursorPos--; m_name[0][m_unk0x280.m_cursorPos]->Enable(FALSE); From df20b0551007de293cc8b8c54870eb7999ebbfa6 Mon Sep 17 00:00:00 2001 From: Christian Semmler Date: Sat, 1 Jun 2024 10:07:58 -0400 Subject: [PATCH 2/9] Define cursor enum and custom cursor window message (#980) * Define cursor enum and custom cursor window message * Fix param name * Remove unused header --- ISLE/isleapp.cpp | 27 ++++++++++--------- .../include/legoeventnotificationparam.h | 8 +++--- LEGO1/lego/legoomni/include/legonotify.h | 11 -------- LEGO1/lego/legoomni/include/legoutils.h | 19 ++++++++++++- LEGO1/lego/legoomni/src/common/legoutils.cpp | 4 +-- .../src/common/mxtransitionmanager.cpp | 2 +- .../src/entity/legocameracontroller.cpp | 5 ++-- LEGO1/lego/legoomni/src/entity/legoworld.cpp | 2 +- .../legoomni/src/input/legoinputmanager.cpp | 2 +- LEGO1/lego/legoomni/src/main/legomain.cpp | 6 ++--- LEGO1/lego/legoomni/src/worlds/infocenter.cpp | 8 +++--- LEGO1/lego/legoomni/src/worlds/isle.cpp | 8 +++--- 12 files changed, 54 insertions(+), 48 deletions(-) delete mode 100644 LEGO1/lego/legoomni/include/legonotify.h diff --git a/ISLE/isleapp.cpp b/ISLE/isleapp.cpp index 3f0892ed..dc087d57 100644 --- a/ISLE/isleapp.cpp +++ b/ISLE/isleapp.cpp @@ -9,6 +9,7 @@ #include "legomain.h" #include "legomodelpresenter.h" #include "legopartpresenter.h" +#include "legoutils.h" #include "legovideomanager.h" #include "legoworldpresenter.h" #include "misc.h" @@ -506,7 +507,7 @@ LRESULT WINAPI WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) g_mousedown = 0; type = c_notificationButtonUp; break; - case 0x5400: + case WM_ISLE_SETCURSOR: if (g_isle) { g_isle->SetupCursor(wParam); return 0; @@ -893,25 +894,25 @@ inline void IsleApp::Tick(BOOL sleepIfNotNextFrame) void IsleApp::SetupCursor(WPARAM wParam) { switch (wParam) { - case 0: + case e_cursorArrow: m_cursorCurrent = m_cursorArrow; break; - case 1: + case e_cursorBusy: m_cursorCurrent = m_cursorBusy; break; - case 2: + case e_cursorNo: m_cursorCurrent = m_cursorNo; break; - case 0xB: + case e_cursorNone: m_cursorCurrent = NULL; - case 3: - case 4: - case 5: - case 6: - case 7: - case 8: - case 9: - case 0xA: + case e_cursorUnused3: + case e_cursorUnused4: + case e_cursorUnused5: + case e_cursorUnused6: + case e_cursorUnused7: + case e_cursorUnused8: + case e_cursorUnused9: + case e_cursorUnused10: break; } diff --git a/LEGO1/lego/legoomni/include/legoeventnotificationparam.h b/LEGO1/lego/legoomni/include/legoeventnotificationparam.h index cdd771e3..2499454f 100644 --- a/LEGO1/lego/legoomni/include/legoeventnotificationparam.h +++ b/LEGO1/lego/legoomni/include/legoeventnotificationparam.h @@ -13,10 +13,10 @@ class LegoROI; class LegoEventNotificationParam : public MxNotificationParam { public: enum { - c_lButtonState = 0x01, - c_rButtonState = 0x02, - c_modKey1 = 0x04, - c_modKey2 = 0x08, + c_lButtonState = 1, + c_rButtonState = 2, + c_modKey1 = 4, + c_modKey2 = 8, }; // FUNCTION: LEGO1 0x10028690 diff --git a/LEGO1/lego/legoomni/include/legonotify.h b/LEGO1/lego/legoomni/include/legonotify.h deleted file mode 100644 index ed4218b2..00000000 --- a/LEGO1/lego/legoomni/include/legonotify.h +++ /dev/null @@ -1,11 +0,0 @@ -#ifndef LEGONOTIFY_H -#define LEGONOTIFY_H - -enum LegoEventNotificationParamType { - c_lButtonState = 1, - c_rButtonState = 2, - c_modKey1 = 4, - c_modKey2 = 8, -}; - -#endif // LEGONOTIFY_H diff --git a/LEGO1/lego/legoomni/include/legoutils.h b/LEGO1/lego/legoomni/include/legoutils.h index 118b6c1d..09e2d72e 100644 --- a/LEGO1/lego/legoomni/include/legoutils.h +++ b/LEGO1/lego/legoomni/include/legoutils.h @@ -7,6 +7,23 @@ #include +#define WM_ISLE_SETCURSOR 0x5400 + +enum Cursor { + e_cursorArrow = 0, + e_cursorBusy, + e_cursorNo, + e_cursorUnused3, + e_cursorUnused4, + e_cursorUnused5, + e_cursorUnused6, + e_cursorUnused7, + e_cursorUnused8, + e_cursorUnused9, + e_cursorUnused10, + e_cursorNone +}; + class MxAtomId; class LegoEntity; class LegoFile; @@ -28,7 +45,7 @@ void PlayCamAnim(LegoPathActor* p_actor, MxBool p_unused, MxU32 p_location, MxBo void FUN_1003eda0(); MxBool RemoveFromCurrentWorld(const MxAtomId& p_atomId, MxS32 p_id); void FUN_1003ef00(MxBool p_enable); -void SetAppCursor(WPARAM p_wparam); +void SetAppCursor(Cursor p_cursor); MxBool FUN_1003ef60(); MxBool RemoveFromWorld(MxAtomId& p_entityAtom, MxS32 p_entityId, MxAtomId& p_worldAtom, MxS32 p_worldEntityId); MxS32 UpdateLightPosition(MxS32 p_increase); diff --git a/LEGO1/lego/legoomni/src/common/legoutils.cpp b/LEGO1/lego/legoomni/src/common/legoutils.cpp index 60d96755..62783224 100644 --- a/LEGO1/lego/legoomni/src/common/legoutils.cpp +++ b/LEGO1/lego/legoomni/src/common/legoutils.cpp @@ -449,9 +449,9 @@ void FUN_1003ef00(MxBool p_enable) } // FUNCTION: LEGO1 0x1003ef40 -void SetAppCursor(WPARAM p_wparam) +void SetAppCursor(Cursor p_cursor) { - PostMessageA(MxOmni::GetInstance()->GetWindowHandle(), 0x5400, p_wparam, 0); + PostMessageA(MxOmni::GetInstance()->GetWindowHandle(), WM_ISLE_SETCURSOR, p_cursor, 0); } // FUNCTION: LEGO1 0x1003ef60 diff --git a/LEGO1/lego/legoomni/src/common/mxtransitionmanager.cpp b/LEGO1/lego/legoomni/src/common/mxtransitionmanager.cpp index 90a37ef2..bb252592 100644 --- a/LEGO1/lego/legoomni/src/common/mxtransitionmanager.cpp +++ b/LEGO1/lego/legoomni/src/common/mxtransitionmanager.cpp @@ -124,7 +124,7 @@ MxResult MxTransitionManager::StartTransition( LegoVideoManager* videoManager = VideoManager(); videoManager->SetRender3D(FALSE); - SetAppCursor(1); + SetAppCursor(e_cursorBusy); return SUCCESS; } return FAILURE; diff --git a/LEGO1/lego/legoomni/src/entity/legocameracontroller.cpp b/LEGO1/lego/legoomni/src/entity/legocameracontroller.cpp index da455eab..b07bb02a 100644 --- a/LEGO1/lego/legoomni/src/entity/legocameracontroller.cpp +++ b/LEGO1/lego/legoomni/src/entity/legocameracontroller.cpp @@ -2,7 +2,6 @@ #include "3dmanager/lego3dmanager.h" #include "legoinputmanager.h" -#include "legonotify.h" #include "legosoundmanager.h" #include "legovideomanager.h" #include "misc.h" @@ -109,10 +108,10 @@ void LegoCameraController::OnRButtonUp(MxPoint32 p_point) // FUNCTION: LEGO1 0x10012230 void LegoCameraController::OnMouseMove(MxU8 p_modifier, MxPoint32 p_point) { - if (p_modifier & c_lButtonState) { + if (p_modifier & LegoEventNotificationParam::c_lButtonState) { LeftDrag(p_point.GetX(), p_point.GetY()); } - else if (p_modifier & c_rButtonState) { + else if (p_modifier & LegoEventNotificationParam::c_rButtonState) { RightDrag(p_point.GetX(), p_point.GetY()); } } diff --git a/LEGO1/lego/legoomni/src/entity/legoworld.cpp b/LEGO1/lego/legoomni/src/entity/legoworld.cpp index 5d4dcd00..71ffefae 100644 --- a/LEGO1/lego/legoomni/src/entity/legoworld.cpp +++ b/LEGO1/lego/legoomni/src/entity/legoworld.cpp @@ -766,7 +766,7 @@ MxResult LegoWorld::Tickle() switch (m_startupTicks) { case e_start: m_worldStarted = TRUE; - SetAppCursor(0); + SetAppCursor(e_cursorArrow); ReadyWorld(); return TRUE; case e_two: diff --git a/LEGO1/lego/legoomni/src/input/legoinputmanager.cpp b/LEGO1/lego/legoomni/src/input/legoinputmanager.cpp index de3ae8b2..e99bdeec 100644 --- a/LEGO1/lego/legoomni/src/input/legoinputmanager.cpp +++ b/LEGO1/lego/legoomni/src/input/legoinputmanager.cpp @@ -401,7 +401,7 @@ MxBool LegoInputManager::ProcessOneEvent(LegoEventNotificationParam& p_param) if (m_unk0x335 != 0) { if (p_param.GetType() == c_notificationButtonDown) { - LegoEventNotificationParam notification(c_notificationKeyPress, NULL, 0, 0, 0, ' '); + LegoEventNotificationParam notification(c_notificationKeyPress, NULL, 0, 0, 0, VK_SPACE); LegoNotifyListCursor cursor(m_keyboardNotifyList); MxCore* target; diff --git a/LEGO1/lego/legoomni/src/main/legomain.cpp b/LEGO1/lego/legoomni/src/main/legomain.cpp index 7b559faa..ba6d7d84 100644 --- a/LEGO1/lego/legoomni/src/main/legomain.cpp +++ b/LEGO1/lego/legoomni/src/main/legomain.cpp @@ -254,7 +254,7 @@ MxResult LegoOmni::Create(MxOmniCreateParam& p_param) } m_notificationManager->Register(this); - SetAppCursor(1); + SetAppCursor(e_cursorBusy); m_gameState->SetCurrentAct(LegoGameState::e_act1); result = SUCCESS; @@ -582,12 +582,12 @@ MxLong LegoOmni::Notify(MxParam& p_param) void LegoOmni::StartTimer() { MxOmni::StartTimer(); - SetAppCursor(2); + SetAppCursor(e_cursorNo); } // FUNCTION: LEGO1 0x1005b650 void LegoOmni::StopTimer() { MxOmni::StopTimer(); - SetAppCursor(0); + SetAppCursor(e_cursorArrow); } diff --git a/LEGO1/lego/legoomni/src/worlds/infocenter.cpp b/LEGO1/lego/legoomni/src/worlds/infocenter.cpp index 942551bd..8308cf11 100644 --- a/LEGO1/lego/legoomni/src/worlds/infocenter.cpp +++ b/LEGO1/lego/legoomni/src/worlds/infocenter.cpp @@ -57,7 +57,7 @@ Infocenter::Infocenter() memset(&m_mapAreas, 0, sizeof(m_mapAreas)); m_unk0x1c8 = -1; - SetAppCursor(1); + SetAppCursor(e_cursorBusy); NotificationManager()->Register(this); m_infoManDialogueTimer = 0; @@ -1183,7 +1183,7 @@ void Infocenter::PlayCutscene(Cutscene p_entityId, MxBool p_scale) VideoManager()->EnableFullScreenMovie(TRUE, p_scale); InputManager()->SetUnknown336(TRUE); InputManager()->SetUnknown335(TRUE); - SetAppCursor(0xb); // Hide cursor + SetAppCursor(e_cursorNone); VideoManager()->GetDisplaySurface()->ClearScreen(); if (m_currentCutscene != e_noIntro) { @@ -1205,7 +1205,7 @@ void Infocenter::StopCutscene() VideoManager()->EnableFullScreenMovie(FALSE); InputManager()->SetUnknown335(FALSE); - SetAppCursor(0); // Restore cursor to arrow + SetAppCursor(e_cursorArrow); FUN_10015820(FALSE, LegoOmni::c_disableInput | LegoOmni::c_disable3d | LegoOmni::c_clearScreen); } @@ -1405,7 +1405,7 @@ void Infocenter::StartCredits() GetViewManager()->RemoveAll(NULL); InvokeAction(Extra::e_opendisk, *g_creditsScript, CreditsScript::c_LegoCredits, NULL); - SetAppCursor(0); + SetAppCursor(e_cursorArrow); } // FUNCTION: LEGO1 0x10071250 diff --git a/LEGO1/lego/legoomni/src/worlds/isle.cpp b/LEGO1/lego/legoomni/src/worlds/isle.cpp index f99cf6fc..78d05c70 100644 --- a/LEGO1/lego/legoomni/src/worlds/isle.cpp +++ b/LEGO1/lego/legoomni/src/worlds/isle.cpp @@ -816,7 +816,7 @@ void Isle::Enable(MxBool p_enable) break; } - SetAppCursor(0); + SetAppCursor(e_cursorArrow); if (m_act1state->m_unk0x018 != 8 && (m_act1state->m_unk0x018 != 0 || GameState()->m_currentArea != LegoGameState::e_elevride) && @@ -952,7 +952,7 @@ MxLong Isle::HandleTransitionEnd() VariableTable()->SetVariable("VISIBILITY", "Show Gas"); AnimationManager()->Resume(); FUN_10015820(FALSE, LegoOmni::c_disableInput | LegoOmni::c_disable3d | LegoOmni::c_clearScreen); - SetAppCursor(0); + SetAppCursor(e_cursorArrow); SetIsWorldActive(TRUE); break; case LegoGameState::e_unk33: @@ -962,7 +962,7 @@ MxLong Isle::HandleTransitionEnd() VariableTable()->SetVariable("VISIBILITY", "Show Policsta"); AnimationManager()->Resume(); FUN_10015820(FALSE, LegoOmni::c_disableInput | LegoOmni::c_disable3d | LegoOmni::c_clearScreen); - SetAppCursor(0); + SetAppCursor(e_cursorArrow); SetIsWorldActive(TRUE); break; case LegoGameState::e_polidoor: @@ -1073,7 +1073,7 @@ void Isle::FUN_10032d30( } FUN_10015820(FALSE, LegoOmni::c_disableInput | LegoOmni::c_disable3d | LegoOmni::c_clearScreen); - SetAppCursor(0); + SetAppCursor(e_cursorArrow); m_destLocation = LegoGameState::e_undefined; m_act1state->m_unk0x01f = FALSE; } From 375ac29b9b87e113feb3ca96f5da79021b7d6bb5 Mon Sep 17 00:00:00 2001 From: Christian Semmler Date: Sat, 1 Jun 2024 12:23:48 -0400 Subject: [PATCH 3/9] Implement/match Lego3DSound::Create (#981) * Implement/match Lego3DSound::Create * Add space * Naming * Changes --- LEGO1/lego/legoomni/include/lego3dsound.h | 24 +++-- LEGO1/lego/legoomni/include/legoactor.h | 15 +-- LEGO1/lego/legoomni/src/audio/lego3dsound.cpp | 91 +++++++++++++++---- LEGO1/lego/legoomni/src/entity/legoactor.cpp | 2 +- .../legoomni/src/entity/legocarraceactor.cpp | 2 +- 5 files changed, 97 insertions(+), 37 deletions(-) diff --git a/LEGO1/lego/legoomni/include/lego3dsound.h b/LEGO1/lego/legoomni/include/lego3dsound.h index a6f4bb02..14be04ee 100644 --- a/LEGO1/lego/legoomni/include/lego3dsound.h +++ b/LEGO1/lego/legoomni/include/lego3dsound.h @@ -6,6 +6,7 @@ #include +class LegoActor; class LegoROI; // VTABLE: LEGO1 0x100d5778 @@ -16,7 +17,7 @@ public: virtual ~Lego3DSound(); void Init(); - MxResult Create(LPDIRECTSOUNDBUFFER p_directSoundBuffer, const char*, MxS32 p_volume); + MxResult Create(LPDIRECTSOUNDBUFFER p_directSoundBuffer, const char* p_name, MxS32 p_volume); void Destroy(); undefined4 FUN_100118e0(LPDIRECTSOUNDBUFFER p_directSoundBuffer); void FUN_10011ca0(); @@ -26,15 +27,18 @@ public: // Lego3DSound::`scalar deleting destructor' private: - undefined m_unk0x04[4]; // 0x04 - LPDIRECTSOUNDBUFFER m_dsBuffer; // 0x08 - LegoROI* m_unk0x0c; // 0x0c - undefined4 m_unk0x10; // 0x10 - MxBool m_unk0x14; // 0x14 - MxBool m_unk0x15; // 0x15 - undefined4 m_unk0x18; // 0x18 - undefined m_unk0x1c[0x10]; // 0x1c - MxS32 m_volume; // 0x2c + LPDIRECTSOUND3DBUFFER m_ds3dBuffer; // 0x08 + LegoROI* m_roi; // 0x0c + LegoROI* m_positionROI; // 0x10 + MxBool m_enabled; // 0x14 + MxBool m_isActor; // 0x15 + LegoActor* m_actor; // 0x18 + double m_frequencyFactor; // 0x20 + DWORD m_dwFrequency; // 0x28 + MxS32 m_volume; // 0x2c }; +// GLOBAL: LEGO1 0x100db6c0 +// IID_IDirectSound3DBuffer + #endif // LEGO3DSOUND_H diff --git a/LEGO1/lego/legoomni/include/legoactor.h b/LEGO1/lego/legoomni/include/legoactor.h index ebde373c..267de5a0 100644 --- a/LEGO1/lego/legoomni/include/legoactor.h +++ b/LEGO1/lego/legoomni/include/legoactor.h @@ -30,10 +30,13 @@ public: void SetROI(LegoROI* p_roi, MxBool p_bool1, MxBool p_bool2) override; // vtable+0x24 // FUNCTION: LEGO1 0x10002cc0 - virtual MxFloat VTable0x50() { return m_unk0x68; } // vtable+0x50 + virtual MxFloat GetSoundFrequencyFactor() { return m_frequencyFactor; } // vtable+0x50 // FUNCTION: LEGO1 0x10002cd0 - virtual void VTable0x54(MxFloat p_unk0x68) { m_unk0x68 = p_unk0x68; } // vtable+0x54 + virtual void SetSoundFrequencyFactor(MxFloat p_frequencyFactor) + { + m_frequencyFactor = p_frequencyFactor; + } // vtable+0x54 // FUNCTION: LEGO1 0x10002ce0 virtual void VTable0x58(MxFloat p_unk0x70) { m_unk0x70 = p_unk0x70; } // vtable+0x58 @@ -52,10 +55,10 @@ public: protected: void FUN_1002d6e0(MxBool); - MxFloat m_unk0x68; // 0x68 - LegoCacheSound* m_sound; // 0x6c - MxFloat m_unk0x70; // 0x70 - MxU8 m_actorId; // 0x74 + MxFloat m_frequencyFactor; // 0x68 + LegoCacheSound* m_sound; // 0x6c + MxFloat m_unk0x70; // 0x70 + MxU8 m_actorId; // 0x74 }; // SYNTHETIC: LEGO1 0x1002d300 diff --git a/LEGO1/lego/legoomni/src/audio/lego3dsound.cpp b/LEGO1/lego/legoomni/src/audio/lego3dsound.cpp index 23b7a8c5..bc68915b 100644 --- a/LEGO1/lego/legoomni/src/audio/lego3dsound.cpp +++ b/LEGO1/lego/legoomni/src/audio/lego3dsound.cpp @@ -1,5 +1,6 @@ #include "lego3dsound.h" +#include "legoactor.h" #include "legocharactermanager.h" #include "misc.h" #include "mxomni.h" @@ -21,31 +22,83 @@ Lego3DSound::~Lego3DSound() // FUNCTION: LEGO1 0x10011680 void Lego3DSound::Init() { - m_dsBuffer = NULL; - m_unk0x0c = NULL; - m_unk0x10 = 0; - m_unk0x18 = 0; - m_unk0x14 = FALSE; - m_unk0x15 = FALSE; + m_ds3dBuffer = NULL; + m_roi = NULL; + m_positionROI = NULL; + m_actor = NULL; + m_enabled = FALSE; + m_isActor = FALSE; m_volume = 79; } -// STUB: LEGO1 0x100116a0 +// FUNCTION: LEGO1 0x100116a0 // FUNCTION: BETA10 0x10039647 -MxResult Lego3DSound::Create(LPDIRECTSOUNDBUFFER p_directSoundBuffer, const char*, MxS32 p_volume) +MxResult Lego3DSound::Create(LPDIRECTSOUNDBUFFER p_directSoundBuffer, const char* p_name, MxS32 p_volume) { m_volume = p_volume; if (MxOmni::IsSound3D()) { - p_directSoundBuffer->QueryInterface(IID_IDirectSoundBuffer, (LPVOID*) &m_dsBuffer); - if (m_dsBuffer == NULL) { + p_directSoundBuffer->QueryInterface(IID_IDirectSound3DBuffer, (LPVOID*) &m_ds3dBuffer); + if (m_ds3dBuffer == NULL) { return FAILURE; } - // TODO + m_ds3dBuffer->SetMinDistance(15.0f, 0); + m_ds3dBuffer->SetMaxDistance(100.0f, 0); + m_ds3dBuffer->SetPosition(0.0f, 0.0f, -40.0f, 0); + m_ds3dBuffer->SetConeOutsideVolume(-10000, 0); } - // TODO + if (m_ds3dBuffer == NULL || p_name == NULL) { + return SUCCESS; + } + + if (CharacterManager()->Exists(p_name)) { + m_roi = CharacterManager()->GetROI(p_name, TRUE); + m_enabled = m_isActor = TRUE; + } + else { + m_roi = FindROI(p_name); + } + + if (m_roi == NULL) { + m_roi = CharacterManager()->FUN_10085210(NULL, p_name, TRUE); + + if (m_roi != NULL) { + m_enabled = TRUE; + } + } + + if (m_roi == NULL) { + return SUCCESS; + } + + if (m_isActor) { + m_positionROI = m_roi->FindChildROI("head", m_roi); + } + else { + m_positionROI = m_roi; + } + + if (MxOmni::IsSound3D()) { + const float* position = m_positionROI->GetWorldPosition(); + m_ds3dBuffer->SetPosition(position[0], position[1], position[2], 0); + } + + LegoEntity* entity = m_roi->GetEntity(); + if (entity != NULL && entity->IsA("LegoActor") && ((LegoActor*) entity)->GetSoundFrequencyFactor() != 0.0f) { + m_actor = ((LegoActor*) entity); + } + + p_directSoundBuffer->GetFrequency(&m_dwFrequency); + + if (m_actor != NULL) { + m_frequencyFactor = m_actor->GetSoundFrequencyFactor(); + + if (m_frequencyFactor != 0.0) { + p_directSoundBuffer->SetFrequency(m_frequencyFactor * m_dwFrequency); + } + } return SUCCESS; } @@ -53,17 +106,17 @@ MxResult Lego3DSound::Create(LPDIRECTSOUNDBUFFER p_directSoundBuffer, const char // FUNCTION: LEGO1 0x10011880 void Lego3DSound::Destroy() { - if (m_dsBuffer) { - m_dsBuffer->Release(); - m_dsBuffer = NULL; + if (m_ds3dBuffer) { + m_ds3dBuffer->Release(); + m_ds3dBuffer = NULL; } - if (m_unk0x14 && m_unk0x0c && CharacterManager()) { - if (m_unk0x15) { - CharacterManager()->FUN_10083db0(m_unk0x0c); + if (m_enabled && m_roi && CharacterManager()) { + if (m_isActor) { + CharacterManager()->FUN_10083db0(m_roi); } else { - CharacterManager()->FUN_10083f10(m_unk0x0c); + CharacterManager()->FUN_10083f10(m_roi); } } diff --git a/LEGO1/lego/legoomni/src/entity/legoactor.cpp b/LEGO1/lego/legoomni/src/entity/legoactor.cpp index 6c455909..79c6571e 100644 --- a/LEGO1/lego/legoomni/src/entity/legoactor.cpp +++ b/LEGO1/lego/legoomni/src/entity/legoactor.cpp @@ -15,7 +15,7 @@ const char* g_actorNames[] = {"none", "pepper", "mama", "papa", "nick", "laura", // FUNCTION: LEGO1 0x1002d110 LegoActor::LegoActor() { - m_unk0x68 = 0.0f; + m_frequencyFactor = 0.0f; m_sound = NULL; m_unk0x70 = 0.0f; m_unk0x10 = 0; diff --git a/LEGO1/lego/legoomni/src/entity/legocarraceactor.cpp b/LEGO1/lego/legoomni/src/entity/legocarraceactor.cpp index 33c04798..af8c95b0 100644 --- a/LEGO1/lego/legoomni/src/entity/legocarraceactor.cpp +++ b/LEGO1/lego/legoomni/src/entity/legocarraceactor.cpp @@ -30,7 +30,7 @@ LegoCarRaceActor::LegoCarRaceActor() m_unk0x70 = 0.0f; m_unk0x0c = 0; m_unk0x13c = 0.0f; - m_unk0x68 = 1.0f; + m_frequencyFactor = 1.0f; m_unk0x1c = 0; m_unk0x10 = 0.65f; m_unk0x14 = 0.03f; From 23e5ad7d15b84377cbe429ab2abdd0837058710a Mon Sep 17 00:00:00 2001 From: Christian Semmler Date: Sat, 1 Jun 2024 12:45:34 -0400 Subject: [PATCH 4/9] Name/rename functions in LegoCharacterManager (#982) * Name/rename functions in LegoCharacterManager * Name flag --- CMakeLists.txt | 2 +- .../{legocharacters.h => legoactors.h} | 18 +- .../legoomni/include/legocharactermanager.h | 26 +-- LEGO1/lego/legoomni/include/legoentity.h | 6 +- LEGO1/lego/legoomni/src/audio/lego3dsound.cpp | 10 +- .../{legocharacters.cpp => legoactors.cpp} | 34 +-- .../src/common/legoanimationmanager.cpp | 62 +++--- .../src/common/legocharactermanager.cpp | 203 +++++++++--------- .../legoomni/src/common/legogamestate.cpp | 2 +- LEGO1/lego/legoomni/src/entity/legoactor.cpp | 2 +- LEGO1/lego/legoomni/src/entity/legoentity.cpp | 12 +- LEGO1/lego/legoomni/src/entity/legoworld.cpp | 2 +- .../legoomni/src/video/legoanimpresenter.cpp | 12 +- .../legoomni/src/video/legomodelpresenter.cpp | 11 +- .../src/video/legophonemepresenter.cpp | 8 +- LEGO1/lego/legoomni/src/worlds/infocenter.cpp | 2 +- 16 files changed, 206 insertions(+), 206 deletions(-) rename LEGO1/lego/legoomni/include/{legocharacters.h => legoactors.h} (81%) rename LEGO1/lego/legoomni/src/common/{legocharacters.cpp => legoactors.cpp} (98%) diff --git a/CMakeLists.txt b/CMakeLists.txt index cc660ede..00b4fdda 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -321,11 +321,11 @@ add_library(lego1 SHARED LEGO1/lego/legoomni/src/build/legovehiclebuildstate.cpp LEGO1/lego/legoomni/src/common/animstate.cpp LEGO1/lego/legoomni/src/common/legoactioncontrolpresenter.cpp + LEGO1/lego/legoomni/src/common/legoactors.cpp LEGO1/lego/legoomni/src/common/legoanimationmanager.cpp LEGO1/lego/legoomni/src/common/legoanimmmpresenter.cpp LEGO1/lego/legoomni/src/common/legobackgroundcolor.cpp LEGO1/lego/legoomni/src/common/legocharactermanager.cpp - LEGO1/lego/legoomni/src/common/legocharacters.cpp LEGO1/lego/legoomni/src/common/legofullscreenmovie.cpp LEGO1/lego/legoomni/src/common/legogamestate.cpp LEGO1/lego/legoomni/src/common/legoobjectfactory.cpp diff --git a/LEGO1/lego/legoomni/include/legocharacters.h b/LEGO1/lego/legoomni/include/legoactors.h similarity index 81% rename from LEGO1/lego/legoomni/include/legocharacters.h rename to LEGO1/lego/legoomni/include/legoactors.h index c21d81c7..46f288b5 100644 --- a/LEGO1/lego/legoomni/include/legocharacters.h +++ b/LEGO1/lego/legoomni/include/legoactors.h @@ -1,5 +1,5 @@ -#ifndef LEGOCHARACTERS_H -#define LEGOCHARACTERS_H +#ifndef LEGOACTORS_H +#define LEGOACTORS_H #include "decomp.h" #include "mxtypes.h" @@ -8,7 +8,7 @@ class LegoExtraActor; class LegoROI; // SIZE 0x108 -struct LegoCharacterInfo { +struct LegoActorInfo { // SIZE 0x18 struct Part { MxU8* m_unk0x00; // 0x00 @@ -29,7 +29,7 @@ struct LegoCharacterInfo { }; // SIZE 0x58 -struct LegoCharacterLOD { +struct LegoActorLOD { enum { c_flag1 = 0x01, c_flag2 = 0x02 @@ -45,7 +45,7 @@ struct LegoCharacterLOD { float m_up[3]; // 0x4c }; -enum LegoCharacterLODs { +enum LegoActorLODs { c_topLOD, c_bodyLOD, c_infohatLOD, @@ -59,7 +59,7 @@ enum LegoCharacterLODs { c_legrtLOD }; -enum LegoCharacterParts { +enum LegoActorParts { c_bodyPart, c_infohatPart, c_infogronPart, @@ -72,7 +72,7 @@ enum LegoCharacterParts { c_legrtPart }; -extern LegoCharacterInfo g_characterInfoInit[66]; -extern LegoCharacterLOD g_characterLODs[11]; +extern LegoActorInfo g_actorInfoInit[66]; +extern LegoActorLOD g_actorLODs[11]; -#endif // LEGOCHARACTERS_H +#endif // LEGOACTORS_H diff --git a/LEGO1/lego/legoomni/include/legocharactermanager.h b/LEGO1/lego/legoomni/include/legocharactermanager.h index f92bdd76..1032f8b3 100644 --- a/LEGO1/lego/legoomni/include/legocharactermanager.h +++ b/LEGO1/lego/legoomni/include/legocharactermanager.h @@ -41,7 +41,7 @@ struct LegoCharacter { MxU32 m_refCount; // 0x04 }; -struct LegoCharacterInfo; +struct LegoActorInfo; typedef map LegoCharacterMap; @@ -53,32 +53,32 @@ public: MxResult Write(LegoStorage* p_storage); MxResult Read(LegoStorage* p_storage); - LegoROI* GetROI(const char* p_key, MxBool p_createEntity); + LegoROI* GetActorROI(const char* p_name, MxBool p_createEntity); void Init(); static void SetCustomizeAnimFile(const char* p_value); - static MxBool Exists(const char* p_key); + static MxBool IsActor(const char* p_name); - void FUN_100832a0(); - MxBool FUN_10083b20(const char* p_key); + void ReleaseAllActors(); + MxBool Exists(const char* p_name); MxU32 GetRefCount(LegoROI* p_roi); - void FUN_10083c30(const char* p_name); - void FUN_10083db0(LegoROI* p_roi); - void FUN_10083f10(LegoROI* p_roi); + void ReleaseActor(const char* p_name); + void ReleaseActor(LegoROI* p_roi); + void ReleaseAutoROI(LegoROI* p_roi); MxBool FUN_100849a0(LegoROI* p_roi, LegoTextureInfo* p_textureInfo); - LegoExtraActor* GetActor(const char* p_key); - LegoCharacterInfo* GetInfo(const char* p_key); - LegoCharacterInfo* GetInfo(LegoROI* p_roi); + LegoExtraActor* GetExtraActor(const char* p_name); + LegoActorInfo* GetActorInfo(const char* p_name); + LegoActorInfo* GetActorInfo(LegoROI* p_roi); MxBool SwitchHat(LegoROI* p_roi); MxU32 FUN_10085140(LegoROI* p_roi, MxBool p_und); MxU8 GetMood(LegoROI* p_roi); - LegoROI* FUN_10085210(const char* p_name, const char* p_lodName, MxBool p_createEntity); + LegoROI* CreateAutoROI(const char* p_name, const char* p_lodName, MxBool p_createEntity); LegoROI* FUN_10085a80(const char* p_name, const char* p_lodName, MxBool p_createEntity); static const char* GetCustomizeAnimFile() { return g_customizeAnimFile; } private: - LegoROI* CreateROI(const char* p_key); + LegoROI* CreateActorROI(const char* p_key); void RemoveROI(LegoROI* p_roi); LegoROI* FindChildROI(LegoROI* p_roi, const char* p_name); MxResult FUN_10085870(LegoROI* p_roi); diff --git a/LEGO1/lego/legoomni/include/legoentity.h b/LEGO1/lego/legoomni/include/legoentity.h index 034dc700..5fcced29 100644 --- a/LEGO1/lego/legoomni/include/legoentity.h +++ b/LEGO1/lego/legoomni/include/legoentity.h @@ -14,16 +14,16 @@ class Vector3; class LegoEntity : public MxEntity { public: enum Type { - e_character = 0, + e_actor = 0, e_unk1, e_plant, e_building, - e_unk4 + e_autoROI }; enum { c_bit1 = 0x01, - c_bit2 = 0x02 + c_managerOwned = 0x02 }; enum { diff --git a/LEGO1/lego/legoomni/src/audio/lego3dsound.cpp b/LEGO1/lego/legoomni/src/audio/lego3dsound.cpp index bc68915b..eef3aa86 100644 --- a/LEGO1/lego/legoomni/src/audio/lego3dsound.cpp +++ b/LEGO1/lego/legoomni/src/audio/lego3dsound.cpp @@ -53,8 +53,8 @@ MxResult Lego3DSound::Create(LPDIRECTSOUNDBUFFER p_directSoundBuffer, const char return SUCCESS; } - if (CharacterManager()->Exists(p_name)) { - m_roi = CharacterManager()->GetROI(p_name, TRUE); + if (CharacterManager()->IsActor(p_name)) { + m_roi = CharacterManager()->GetActorROI(p_name, TRUE); m_enabled = m_isActor = TRUE; } else { @@ -62,7 +62,7 @@ MxResult Lego3DSound::Create(LPDIRECTSOUNDBUFFER p_directSoundBuffer, const char } if (m_roi == NULL) { - m_roi = CharacterManager()->FUN_10085210(NULL, p_name, TRUE); + m_roi = CharacterManager()->CreateAutoROI(NULL, p_name, TRUE); if (m_roi != NULL) { m_enabled = TRUE; @@ -113,10 +113,10 @@ void Lego3DSound::Destroy() if (m_enabled && m_roi && CharacterManager()) { if (m_isActor) { - CharacterManager()->FUN_10083db0(m_roi); + CharacterManager()->ReleaseActor(m_roi); } else { - CharacterManager()->FUN_10083f10(m_roi); + CharacterManager()->ReleaseAutoROI(m_roi); } } diff --git a/LEGO1/lego/legoomni/src/common/legocharacters.cpp b/LEGO1/lego/legoomni/src/common/legoactors.cpp similarity index 98% rename from LEGO1/lego/legoomni/src/common/legocharacters.cpp rename to LEGO1/lego/legoomni/src/common/legoactors.cpp index d80b49c8..acab09e1 100644 --- a/LEGO1/lego/legoomni/src/common/legocharacters.cpp +++ b/LEGO1/lego/legoomni/src/common/legoactors.cpp @@ -1,16 +1,16 @@ -#include "legocharacters.h" +#include "legoactors.h" -DECOMP_SIZE_ASSERT(LegoCharacterInfo, 0x108) -DECOMP_SIZE_ASSERT(LegoCharacterInfo::Part, 0x18) -DECOMP_SIZE_ASSERT(LegoCharacterLOD, 0x58) +DECOMP_SIZE_ASSERT(LegoActorInfo, 0x108) +DECOMP_SIZE_ASSERT(LegoActorInfo::Part, 0x18) +DECOMP_SIZE_ASSERT(LegoActorLOD, 0x58) -// Unclear whether g_characterLODs[0] (top) is its own global, see: LegoCharacterManager::CreateROI +// Unclear whether g_actorLODs[0] (top) is its own global, see: LegoCharacterManager::CreateActorROI // GLOBAL: LEGO1 0x100da3b0 -LegoCharacterLOD g_characterLODs[] = { +LegoActorLOD g_actorLODs[] = { {"top", "top", 0, 0.000267, 0.780808, -0.01906, 0.951612, -0.461166, -0.002794, -0.299442, 0.4617, 1.56441, 0.261321, 0, 0, 0, 0, 0, 1, 0, 1, 0}, - {"body", "body", LegoCharacterLOD::c_flag1, + {"body", "body", LegoActorLOD::c_flag1, 0.00158332, 0.401828, -0.00048697, 0.408071, -0.287507, 0.150419, -0.147452, 0.289219, 0.649774, @@ -18,7 +18,7 @@ LegoCharacterLOD g_characterLODs[] = { 0.007277, 0, 0, 1, 0, 1, 0}, - {"infohat", "infohat", LegoCharacterLOD::c_flag2, + {"infohat", "infohat", LegoActorLOD::c_flag2, 0, -0.00938, -0.01955, 0.35, -0.231822, -0.140237, -0.320954, 0.234149, 0.076968, @@ -26,7 +26,7 @@ LegoCharacterLOD g_characterLODs[] = { 0.001767, 0, 0, 1, 0, 1, 0}, - {"infogron", "infogron", LegoCharacterLOD::c_flag2, + {"infogron", "infogron", LegoActorLOD::c_flag2, 0, 0.11477, 0.00042, 0.26, -0.285558, -0.134391, -0.142231, 0.285507, 0.152986, @@ -34,7 +34,7 @@ LegoCharacterLOD g_characterLODs[] = { 0.007277, 0, 0, 1, 0, 1, 0}, - {"head", "head", LegoCharacterLOD::c_flag1, + {"head", "head", LegoActorLOD::c_flag1, 0, -0.03006, 0, 0.3, -0.189506, -0.209665, -0.189824, 0.189532, 0.228822, @@ -42,7 +42,7 @@ LegoCharacterLOD g_characterLODs[] = { 0.001781, 0, 0, 1, 0, 1, 0}, - {"arm-lft", "arm-lft", LegoCharacterLOD::c_flag2, + {"arm-lft", "arm-lft", LegoActorLOD::c_flag2, -0.06815, -0.0973747, 0.0154655, 0.237, -0.137931, -0.282775, -0.105316, 0.000989, 0.100221, @@ -50,7 +50,7 @@ LegoCharacterLOD g_characterLODs[] = { 0.023286, -0.003031, -0.017187, 0.999848, 0.173622, 0.984658, 0.017453}, - {"arm-rt", "arm-rt", LegoCharacterLOD::c_flag2, + {"arm-rt", "arm-rt", LegoActorLOD::c_flag2, 0.0680946, -0.097152, 0.0152722, 0.237, 0.00141, -0.289604, -0.100831, 0.138786, 0.09291, @@ -58,7 +58,7 @@ LegoCharacterLOD g_characterLODs[] = { 0.018302, 0, 0, 1, -0.173648, 0.984808, 0}, - {"claw-lft", "claw-lft", LegoCharacterLOD::c_flag2, + {"claw-lft", "claw-lft", LegoActorLOD::c_flag2, 0.000773381, -0.101422, -0.0237761, 0.15, -0.089838, -0.246208, -0.117735, 0.091275, 0.000263, @@ -66,7 +66,7 @@ LegoCharacterLOD g_characterLODs[] = { 0.092779, 0.000001, 0.000003, 1, 0.190812, 0.981627, -0.000003}, - {"claw-rt", "claw-lft", LegoCharacterLOD::c_flag2, + {"claw-rt", "claw-lft", LegoActorLOD::c_flag2, 0.000773381, -0.101422, -0.0237761, 0.15, -0.095016, -0.245349, -0.117979, 0.086528, 0.00067, @@ -74,7 +74,7 @@ LegoCharacterLOD g_characterLODs[] = { 0.096123, 0.00606, -0.034369, 0.999391, -0.190704, 0.981027, 0.034894}, - {"leg-lft", "leg", LegoCharacterLOD::c_flag2, + {"leg-lft", "leg", LegoActorLOD::c_flag2, 0.00433584, -0.177404, -0.0313928, 0.33, -0.129782, -0.440428, -0.184207, 0.13817, 0.118415, @@ -82,7 +82,7 @@ LegoCharacterLOD g_characterLODs[] = { 0.006822, 0, 0, 1, 0, 1, 0}, - {"leg-rt", "leg", LegoCharacterLOD::c_flag2, + {"leg-rt", "leg", LegoActorLOD::c_flag2, 0.00433584, -0.177404, -0.0313928, 0.33, -0.132864, -0.437138, -0.183944, 0.134614, 0.12043, @@ -172,7 +172,7 @@ const char* g_unk0x100f80a0[] = {"lego white", "lego black", "lego yellow", "lego red", "lego blue", "lego brown", "lego lt grey", "lego green"}; // GLOBAL: LEGO1 0x100f80c0 -LegoCharacterInfo g_characterInfoInit[] = { +LegoActorInfo g_actorInfoInit[] = { {"pepper", NULL, NULL, diff --git a/LEGO1/lego/legoomni/src/common/legoanimationmanager.cpp b/LEGO1/lego/legoomni/src/common/legoanimationmanager.cpp index 40afb7a3..3c358af4 100644 --- a/LEGO1/lego/legoomni/src/common/legoanimationmanager.cpp +++ b/LEGO1/lego/legoomni/src/common/legoanimationmanager.cpp @@ -344,14 +344,14 @@ LegoAnimationManager::~LegoAnimationManager() LegoROI* roi = m_extras[i].m_roi; if (roi != NULL) { - LegoPathActor* actor = CharacterManager()->GetActor(roi->GetName()); + LegoPathActor* actor = CharacterManager()->GetExtraActor(roi->GetName()); if (actor != NULL && actor->GetController() != NULL && CurrentWorld() != NULL) { CurrentWorld()->RemoveActor(actor); actor->SetController(NULL); } - CharacterManager()->FUN_10083db0(roi); + CharacterManager()->ReleaseActor(roi); } } @@ -430,14 +430,14 @@ void LegoAnimationManager::Suspend() LegoROI* roi = m_extras[i].m_roi; if (roi != NULL) { - LegoPathActor* actor = CharacterManager()->GetActor(roi->GetName()); + LegoPathActor* actor = CharacterManager()->GetExtraActor(roi->GetName()); if (actor != NULL && actor->GetController() != NULL) { actor->GetController()->RemoveActor(actor); actor->SetController(NULL); } - CharacterManager()->FUN_10083db0(roi); + CharacterManager()->ReleaseActor(roi); } if (m_extras[i].m_unk0x14) { @@ -1069,8 +1069,8 @@ MxResult LegoAnimationManager::StartEntityAction(MxDSAction& p_dsAction, LegoEnt MxResult result = FAILURE; LegoROI* roi = p_entity->GetROI(); - if (p_entity->GetType() == LegoEntity::e_character) { - LegoPathActor* actor = CharacterManager()->GetActor(roi->GetName()); + if (p_entity->GetType() == LegoEntity::e_actor) { + LegoPathActor* actor = CharacterManager()->GetExtraActor(roi->GetName()); if (actor) { LegoPathController* controller = actor->GetController(); @@ -1395,7 +1395,7 @@ MxLong LegoAnimationManager::Notify(MxParam& p_param) LegoROI* roi = m_extras[i].m_roi; if (roi != NULL) { - LegoExtraActor* actor = CharacterManager()->GetActor(roi->GetName()); + LegoExtraActor* actor = CharacterManager()->GetExtraActor(roi->GetName()); if (actor != NULL) { actor->Restart(); } @@ -1444,14 +1444,14 @@ MxResult LegoAnimationManager::Tickle() LegoROI* roi = m_extras[i].m_roi; if (roi != NULL && m_extras[i].m_unk0x0d) { - LegoPathActor* actor = CharacterManager()->GetActor(roi->GetName()); + LegoPathActor* actor = CharacterManager()->GetExtraActor(roi->GetName()); if (actor != NULL && actor->GetController() != NULL) { actor->GetController()->RemoveActor(actor); actor->SetController(NULL); } - CharacterManager()->FUN_10083db0(roi); + CharacterManager()->ReleaseActor(roi); if (m_extras[i].m_unk0x14) { m_extras[i].m_unk0x14 = FALSE; @@ -1701,7 +1701,7 @@ void LegoAnimationManager::FUN_10062580(AnimInfo& p_info) if (models != NULL && modelCount) { for (MxU8 i = 0; i < modelCount; i++) { - LegoPathActor* actor = CharacterManager()->GetActor(models[i].m_name); + LegoPathActor* actor = CharacterManager()->GetExtraActor(models[i].m_name); if (actor) { LegoPathController* controller = actor->GetController(); @@ -1814,13 +1814,13 @@ void LegoAnimationManager::PurgeExtra(MxBool p_und) !viewManager->FUN_100a6150(roi->GetWorldBoundingBox()))) { m_unk0x414--; - LegoPathActor* actor = CharacterManager()->GetActor(roi->GetName()); + LegoPathActor* actor = CharacterManager()->GetExtraActor(roi->GetName()); if (actor != NULL && actor->GetController() != NULL) { actor->GetController()->RemoveActor(actor); actor->SetController(NULL); } - CharacterManager()->FUN_10083db0(roi); + CharacterManager()->ReleaseActor(roi); if (m_extras[i].m_unk0x14) { m_extras[i].m_unk0x14 = FALSE; @@ -1930,15 +1930,15 @@ void LegoAnimationManager::AddExtra(MxS32 p_location, MxBool p_und) g_characters[m_lastExtraCharacterId].m_unk0x08 && !g_characters[m_lastExtraCharacterId].m_inExtras && g_characters[m_lastExtraCharacterId].m_active == active) { - if (!CharacterManager()->FUN_10083b20(g_characters[m_lastExtraCharacterId].m_name - )) { - m_extras[i].m_roi = CharacterManager()->GetROI( + if (!CharacterManager()->Exists(g_characters[m_lastExtraCharacterId].m_name)) { + m_extras[i].m_roi = CharacterManager()->GetActorROI( g_characters[m_lastExtraCharacterId].m_name, TRUE ); - LegoExtraActor* actor = - CharacterManager()->GetActor(g_characters[m_lastExtraCharacterId].m_name); + LegoExtraActor* actor = CharacterManager()->GetExtraActor( + g_characters[m_lastExtraCharacterId].m_name + ); switch (g_unk0x100f7504++ % 4) { case 0: @@ -2002,7 +2002,7 @@ void LegoAnimationManager::AddExtra(MxS32 p_location, MxBool p_und) return; } else { - CharacterManager()->FUN_10083db0(m_extras[i].m_roi); + CharacterManager()->ReleaseActor(m_extras[i].m_roi); m_extras[i].m_roi = NULL; continue; } @@ -2042,7 +2042,7 @@ MxBool LegoAnimationManager::FUN_10062e20(LegoROI* p_roi, LegoAnimPresenter* p_p MxBool inExtras = FALSE; const char* name = p_roi->GetName(); - LegoExtraActor* actor = CharacterManager()->GetActor(name); + LegoExtraActor* actor = CharacterManager()->GetExtraActor(name); if (actor != NULL) { MxS32 characterId = -1; MxS32 i; @@ -2104,7 +2104,7 @@ MxBool LegoAnimationManager::FUN_10062e20(LegoROI* p_roi, LegoAnimPresenter* p_p return FALSE; } - CharacterManager()->FUN_10083db0(p_roi); + CharacterManager()->ReleaseActor(p_roi); } else { if (inExtras) { @@ -2216,7 +2216,7 @@ void LegoAnimationManager::FUN_10063270(LegoROIList* p_list, LegoAnimPresenter* FUN_10063950(roi); } else { - LegoExtraActor* actor = CharacterManager()->GetActor(roi->GetName()); + LegoExtraActor* actor = CharacterManager()->GetExtraActor(roi->GetName()); if (actor != NULL) { for (MxS32 i = 0; i < (MxS32) sizeOfArray(m_extras); i++) { @@ -2277,7 +2277,7 @@ void LegoAnimationManager::FUN_10063780(LegoROIList* p_list) while (cursor.Next(roi)) { const char* name = roi->GetName(); - if (CharacterManager()->Exists(name)) { + if (CharacterManager()->IsActor(name)) { m_unk0x424->Append(roi); cursor.Detach(); } @@ -2292,7 +2292,7 @@ void LegoAnimationManager::FUN_10063950(LegoROI* p_roi) LegoROIListCursor cursor(m_unk0x424); if (cursor.Find(p_roi)) { - CharacterManager()->FUN_10083db0(p_roi); + CharacterManager()->ReleaseActor(p_roi); cursor.Detach(); } } @@ -2305,7 +2305,7 @@ void LegoAnimationManager::FUN_10063aa0() LegoROI* roi; while (cursor.Next(roi)) { - CharacterManager()->FUN_10083db0(roi); + CharacterManager()->ReleaseActor(roi); } } @@ -2388,7 +2388,7 @@ void LegoAnimationManager::FUN_10063d10() m_extras[i].m_unk0x0c = FALSE; - LegoExtraActor* actor = CharacterManager()->GetActor(roi->GetName()); + LegoExtraActor* actor = CharacterManager()->GetExtraActor(roi->GetName()); if (actor != NULL) { float speed = m_extras[i].m_speed; @@ -2405,7 +2405,7 @@ void LegoAnimationManager::FUN_10063d10() } } else { - LegoExtraActor* actor = CharacterManager()->GetActor(roi->GetName()); + LegoExtraActor* actor = CharacterManager()->GetExtraActor(roi->GetName()); if (actor != NULL) { actor->Restart(); } @@ -2424,7 +2424,7 @@ void LegoAnimationManager::FUN_10063e40(LegoAnimPresenter* p_presenter) while (cursor.Next(roi)) { if (!FUN_10062e20(roi, p_presenter)) { - CharacterManager()->FUN_10083db0(roi); + CharacterManager()->ReleaseActor(roi); } cursor.Detach(); @@ -2594,7 +2594,7 @@ MxResult LegoAnimationManager::FUN_10064380( } if (roi != NULL && !strcmpi(roi->GetName(), p_name)) { - actor = CharacterManager()->GetActor(p_name); + actor = CharacterManager()->GetExtraActor(p_name); if (actor != NULL && actor->GetController() != NULL) { actor->GetController()->RemoveActor(actor); @@ -2620,11 +2620,11 @@ MxResult LegoAnimationManager::FUN_10064380( return FAILURE; } - m_extras[extraIndex].m_roi = CharacterManager()->GetROI(p_name, TRUE); + m_extras[extraIndex].m_roi = CharacterManager()->GetActorROI(p_name, TRUE); m_extras[extraIndex].m_characterId = characterId; m_extras[extraIndex].m_speed = p_speed; - actor = CharacterManager()->GetActor(p_name); + actor = CharacterManager()->GetExtraActor(p_name); m_unk0x414++; } @@ -2634,7 +2634,7 @@ MxResult LegoAnimationManager::FUN_10064380( actor->SetWorldSpeed(0.0f); if (world->PlaceActor(actor, p_boundaryName, p_src, p_srcScale, p_dest, p_destScale) != SUCCESS) { - CharacterManager()->FUN_10083db0(m_extras[i].m_roi); + CharacterManager()->ReleaseActor(m_extras[i].m_roi); m_extras[i].m_roi = NULL; m_unk0x414--; return FAILURE; diff --git a/LEGO1/lego/legoomni/src/common/legocharactermanager.cpp b/LEGO1/lego/legoomni/src/common/legocharactermanager.cpp index 9f409bfb..dc48d9b5 100644 --- a/LEGO1/lego/legoomni/src/common/legocharactermanager.cpp +++ b/LEGO1/lego/legoomni/src/common/legocharactermanager.cpp @@ -1,8 +1,8 @@ #include "legocharactermanager.h" #include "3dmanager/lego3dmanager.h" +#include "legoactors.h" #include "legoanimactor.h" -#include "legocharacters.h" #include "legoextraactor.h" #include "legogamestate.h" #include "legovariables.h" @@ -40,7 +40,7 @@ MxU32 g_unk0x100fc4ec = 2; MxU32 g_unk0x100fc4f0 = 0; // GLOBAL: LEGO1 0x10104f20 -LegoCharacterInfo g_characterInfo[66]; +LegoActorInfo g_actorInfo[66]; // FUNCTION: LEGO1 0x10082a20 LegoCharacterManager::LegoCharacterManager() @@ -75,26 +75,26 @@ LegoCharacterManager::~LegoCharacterManager() // FUNCTION: LEGO1 0x10083270 void LegoCharacterManager::Init() { - for (MxS32 i = 0; i < sizeOfArray(g_characterInfo); i++) { - g_characterInfo[i] = g_characterInfoInit[i]; + for (MxS32 i = 0; i < sizeOfArray(g_actorInfo); i++) { + g_actorInfo[i] = g_actorInfoInit[i]; } } // FUNCTION: LEGO1 0x100832a0 -void LegoCharacterManager::FUN_100832a0() +void LegoCharacterManager::ReleaseAllActors() { - for (MxS32 i = 0; i < sizeOfArray(g_characterInfo); i++) { - LegoCharacterInfo* info = GetInfo(g_characterInfo[i].m_name); + for (MxS32 i = 0; i < sizeOfArray(g_actorInfo); i++) { + LegoActorInfo* info = GetActorInfo(g_actorInfo[i].m_name); if (info != NULL) { LegoExtraActor* actor = info->m_actor; if (actor != NULL && actor->IsA("LegoExtraActor")) { - LegoROI* roi = g_characterInfo[i].m_roi; + LegoROI* roi = g_actorInfo[i].m_roi; MxU32 refCount = GetRefCount(roi); while (refCount != 0) { - FUN_10083db0(roi); + ReleaseActor(roi); refCount = GetRefCount(roi); } } @@ -107,8 +107,8 @@ MxResult LegoCharacterManager::Write(LegoStorage* p_storage) { MxResult result = FAILURE; - for (MxS32 i = 0; i < sizeOfArray(g_characterInfo); i++) { - LegoCharacterInfo* info = &g_characterInfo[i]; + for (MxS32 i = 0; i < sizeOfArray(g_actorInfo); i++) { + LegoActorInfo* info = &g_actorInfo[i]; if (p_storage->Write(&info->m_unk0x0c, sizeof(info->m_unk0x0c)) != SUCCESS) { goto done; @@ -162,8 +162,8 @@ MxResult LegoCharacterManager::Read(LegoStorage* p_storage) { MxResult result = FAILURE; - for (MxS32 i = 0; i < sizeOfArray(g_characterInfo); i++) { - LegoCharacterInfo* info = &g_characterInfo[i]; + for (MxS32 i = 0; i < sizeOfArray(g_actorInfo); i++) { + LegoActorInfo* info = &g_actorInfo[i]; if (p_storage->Read(&info->m_unk0x0c, sizeof(info->m_unk0x0c)) != SUCCESS) { goto done; @@ -213,10 +213,10 @@ done: } // FUNCTION: LEGO1 0x10083500 -LegoROI* LegoCharacterManager::GetROI(const char* p_key, MxBool p_createEntity) +LegoROI* LegoCharacterManager::GetActorROI(const char* p_name, MxBool p_createEntity) { LegoCharacter* character = NULL; - LegoCharacterMap::iterator it = m_characters->find(const_cast(p_key)); + LegoCharacterMap::iterator it = m_characters->find(const_cast(p_name)); if (it != m_characters->end()) { character = (*it).second; @@ -224,7 +224,7 @@ LegoROI* LegoCharacterManager::GetROI(const char* p_key, MxBool p_createEntity) } if (character == NULL) { - LegoROI* roi = CreateROI(p_key); + LegoROI* roi = CreateActorROI(p_name); if (roi == NULL) { goto done; @@ -234,11 +234,11 @@ LegoROI* LegoCharacterManager::GetROI(const char* p_key, MxBool p_createEntity) if (roi != NULL) { character = new LegoCharacter(roi); - char* key = new char[strlen(p_key) + 1]; + char* name = new char[strlen(p_name) + 1]; - if (key != NULL) { - strcpy(key, p_key); - (*m_characters)[key] = character; + if (name != NULL) { + strcpy(name, p_name); + (*m_characters)[name] = character; VideoManager()->Get3DManager()->Add(*roi); } } @@ -254,9 +254,9 @@ done: LegoExtraActor* actor = new LegoExtraActor(); actor->SetROI(character->m_roi, FALSE, FALSE); - actor->SetType(LegoEntity::e_character); - actor->SetFlag(LegoActor::c_bit2); - GetInfo(p_key)->m_actor = actor; + actor->SetType(LegoEntity::e_actor); + actor->SetFlag(LegoEntity::c_managerOwned); + GetActorInfo(p_name)->m_actor = actor; } return character->m_roi; @@ -267,10 +267,10 @@ done: // FUNCTION: LEGO1 0x10083b20 // FUNCTION: BETA10 0x10074608 -MxBool LegoCharacterManager::FUN_10083b20(const char* p_key) +MxBool LegoCharacterManager::Exists(const char* p_name) { LegoCharacter* character = NULL; - LegoCharacterMap::iterator it = m_characters->find(const_cast(p_key)); + LegoCharacterMap::iterator it = m_characters->find(const_cast(p_name)); if (it != m_characters->end()) { return TRUE; @@ -298,7 +298,7 @@ MxU32 LegoCharacterManager::GetRefCount(LegoROI* p_roi) // FUNCTION: LEGO1 0x10083c30 // FUNCTION: BETA10 0x10074701 -void LegoCharacterManager::FUN_10083c30(const char* p_name) +void LegoCharacterManager::ReleaseActor(const char* p_name) { LegoCharacter* character = NULL; LegoCharacterMap::iterator it = m_characters->find(const_cast(p_name)); @@ -307,7 +307,7 @@ void LegoCharacterManager::FUN_10083c30(const char* p_name) character = (*it).second; if (character->RemoveRef() == 0) { - LegoCharacterInfo* info = GetInfo(p_name); + LegoActorInfo* info = GetActorInfo(p_name); LegoEntity* entity = character->m_roi->GetEntity(); if (entity != NULL) { @@ -323,11 +323,11 @@ void LegoCharacterManager::FUN_10083c30(const char* p_name) if (info != NULL) { if (info->m_actor != NULL) { - info->m_actor->ClearFlag(LegoEntity::c_bit2); + info->m_actor->ClearFlag(LegoEntity::c_managerOwned); delete info->m_actor; } - else if (entity != NULL && entity->GetFlagsIsSet(LegoEntity::c_bit2)) { - entity->ClearFlag(LegoEntity::c_bit2); + else if (entity != NULL && entity->GetFlagsIsSet(LegoEntity::c_managerOwned)) { + entity->ClearFlag(LegoEntity::c_managerOwned); delete entity; } @@ -339,7 +339,7 @@ void LegoCharacterManager::FUN_10083c30(const char* p_name) } // FUNCTION: LEGO1 0x10083db0 -void LegoCharacterManager::FUN_10083db0(LegoROI* p_roi) +void LegoCharacterManager::ReleaseActor(LegoROI* p_roi) { LegoCharacter* character = NULL; LegoCharacterMap::iterator it; @@ -349,7 +349,7 @@ void LegoCharacterManager::FUN_10083db0(LegoROI* p_roi) if (character->m_roi == p_roi) { if (character->RemoveRef() == 0) { - LegoCharacterInfo* info = GetInfo(character->m_roi->GetName()); + LegoActorInfo* info = GetActorInfo(character->m_roi->GetName()); LegoEntity* entity = character->m_roi->GetEntity(); if (entity != NULL) { @@ -365,11 +365,11 @@ void LegoCharacterManager::FUN_10083db0(LegoROI* p_roi) if (info != NULL) { if (info->m_actor != NULL) { - info->m_actor->ClearFlag(LegoEntity::c_bit2); + info->m_actor->ClearFlag(LegoEntity::c_managerOwned); delete info->m_actor; } - else if (entity != NULL && entity->GetFlagsIsSet(LegoEntity::c_bit2)) { - entity->ClearFlag(LegoEntity::c_bit2); + else if (entity != NULL && entity->GetFlagsIsSet(LegoEntity::c_managerOwned)) { + entity->ClearFlag(LegoEntity::c_managerOwned); delete entity; } @@ -384,7 +384,7 @@ void LegoCharacterManager::FUN_10083db0(LegoROI* p_roi) } // FUNCTION: LEGO1 0x10083f10 -void LegoCharacterManager::FUN_10083f10(LegoROI* p_roi) +void LegoCharacterManager::ReleaseAutoROI(LegoROI* p_roi) { LegoCharacter* character = NULL; LegoCharacterMap::iterator it; @@ -407,8 +407,8 @@ void LegoCharacterManager::FUN_10083f10(LegoROI* p_roi) m_characters->erase(it); - if (entity != NULL && entity->GetFlagsIsSet(LegoEntity::c_bit2)) { - entity->ClearFlag(LegoEntity::c_bit2); + if (entity != NULL && entity->GetFlagsIsSet(LegoEntity::c_managerOwned)) { + entity->ClearFlag(LegoEntity::c_managerOwned); delete entity; } } @@ -425,7 +425,7 @@ void LegoCharacterManager::RemoveROI(LegoROI* p_roi) } // FUNCTION: LEGO1 0x10084030 -LegoROI* LegoCharacterManager::CreateROI(const char* p_key) +LegoROI* LegoCharacterManager::CreateActorROI(const char* p_key) { MxBool success = FALSE; LegoROI* roi = NULL; @@ -438,14 +438,14 @@ LegoROI* LegoCharacterManager::CreateROI(const char* p_key) Tgl::Renderer* renderer = VideoManager()->GetRenderer(); ViewLODListManager* lodManager = GetViewLODListManager(); LegoTextureContainer* textureContainer = TextureContainer(); - LegoCharacterInfo* info = GetInfo(p_key); + LegoActorInfo* info = GetActorInfo(p_key); if (info == NULL) { goto done; } if (!strcmpi(p_key, "pep")) { - LegoCharacterInfo* pepper = GetInfo("pepper"); + LegoActorInfo* pepper = GetActorInfo("pepper"); info->m_unk0x0c = pepper->m_unk0x0c; info->m_unk0x10 = pepper->m_unk0x10; @@ -459,33 +459,33 @@ LegoROI* LegoCharacterManager::CreateROI(const char* p_key) roi = new LegoROI(renderer); roi->SetName(p_key); - boundingSphere.Center()[0] = g_characterLODs[c_topLOD].m_boundingSphere[0]; - boundingSphere.Center()[1] = g_characterLODs[c_topLOD].m_boundingSphere[1]; - boundingSphere.Center()[2] = g_characterLODs[c_topLOD].m_boundingSphere[2]; - boundingSphere.Radius() = g_characterLODs[c_topLOD].m_boundingSphere[3]; + boundingSphere.Center()[0] = g_actorLODs[c_topLOD].m_boundingSphere[0]; + boundingSphere.Center()[1] = g_actorLODs[c_topLOD].m_boundingSphere[1]; + boundingSphere.Center()[2] = g_actorLODs[c_topLOD].m_boundingSphere[2]; + boundingSphere.Radius() = g_actorLODs[c_topLOD].m_boundingSphere[3]; roi->SetBoundingSphere(boundingSphere); - boundingBox.Min()[0] = g_characterLODs[c_topLOD].m_boundingBox[0]; - boundingBox.Min()[1] = g_characterLODs[c_topLOD].m_boundingBox[1]; - boundingBox.Min()[2] = g_characterLODs[c_topLOD].m_boundingBox[2]; - boundingBox.Max()[0] = g_characterLODs[c_topLOD].m_boundingBox[3]; - boundingBox.Max()[1] = g_characterLODs[c_topLOD].m_boundingBox[4]; - boundingBox.Max()[2] = g_characterLODs[c_topLOD].m_boundingBox[5]; + boundingBox.Min()[0] = g_actorLODs[c_topLOD].m_boundingBox[0]; + boundingBox.Min()[1] = g_actorLODs[c_topLOD].m_boundingBox[1]; + boundingBox.Min()[2] = g_actorLODs[c_topLOD].m_boundingBox[2]; + boundingBox.Max()[0] = g_actorLODs[c_topLOD].m_boundingBox[3]; + boundingBox.Max()[1] = g_actorLODs[c_topLOD].m_boundingBox[4]; + boundingBox.Max()[2] = g_actorLODs[c_topLOD].m_boundingBox[5]; roi->SetUnknown0x80(boundingBox); comp = new CompoundObject(); roi->SetComp(comp); - for (i = 0; i < sizeOfArray(g_characterLODs) - 1; i++) { + for (i = 0; i < sizeOfArray(g_actorLODs) - 1; i++) { char lodName[256]; - LegoCharacterInfo::Part& part = info->m_parts[i]; + LegoActorInfo::Part& part = info->m_parts[i]; const char* parentName; if (i == 0 || i == 1) { parentName = part.m_unk0x04[part.m_unk0x00[part.m_unk0x08]]; } else { - parentName = g_characterLODs[i + 1].m_parentName; + parentName = g_actorLODs[i + 1].m_parentName; } ViewLODList* lodList = lodManager->Lookup(parentName); @@ -505,35 +505,34 @@ LegoROI* LegoCharacterManager::CreateROI(const char* p_key) LegoROI* childROI = new LegoROI(renderer, lodList); lodList->Release(); - childROI->SetName(g_characterLODs[i + 1].m_name); + childROI->SetName(g_actorLODs[i + 1].m_name); childROI->SetParentROI(roi); BoundingSphere childBoundingSphere; - childBoundingSphere.Center()[0] = g_characterLODs[i + 1].m_boundingSphere[0]; - childBoundingSphere.Center()[1] = g_characterLODs[i + 1].m_boundingSphere[1]; - childBoundingSphere.Center()[2] = g_characterLODs[i + 1].m_boundingSphere[2]; - childBoundingSphere.Radius() = g_characterLODs[i + 1].m_boundingSphere[3]; + childBoundingSphere.Center()[0] = g_actorLODs[i + 1].m_boundingSphere[0]; + childBoundingSphere.Center()[1] = g_actorLODs[i + 1].m_boundingSphere[1]; + childBoundingSphere.Center()[2] = g_actorLODs[i + 1].m_boundingSphere[2]; + childBoundingSphere.Radius() = g_actorLODs[i + 1].m_boundingSphere[3]; childROI->SetBoundingSphere(childBoundingSphere); BoundingBox childBoundingBox; - childBoundingBox.Min()[0] = g_characterLODs[i + 1].m_boundingBox[0]; - childBoundingBox.Min()[1] = g_characterLODs[i + 1].m_boundingBox[1]; - childBoundingBox.Min()[2] = g_characterLODs[i + 1].m_boundingBox[2]; - childBoundingBox.Max()[0] = g_characterLODs[i + 1].m_boundingBox[3]; - childBoundingBox.Max()[1] = g_characterLODs[i + 1].m_boundingBox[4]; - childBoundingBox.Max()[2] = g_characterLODs[i + 1].m_boundingBox[5]; + childBoundingBox.Min()[0] = g_actorLODs[i + 1].m_boundingBox[0]; + childBoundingBox.Min()[1] = g_actorLODs[i + 1].m_boundingBox[1]; + childBoundingBox.Min()[2] = g_actorLODs[i + 1].m_boundingBox[2]; + childBoundingBox.Max()[0] = g_actorLODs[i + 1].m_boundingBox[3]; + childBoundingBox.Max()[1] = g_actorLODs[i + 1].m_boundingBox[4]; + childBoundingBox.Max()[2] = g_actorLODs[i + 1].m_boundingBox[5]; childROI->SetUnknown0x80(childBoundingBox); CalcLocalTransform( - Mx3DPointFloat(g_characterLODs[i + 1].m_position), - Mx3DPointFloat(g_characterLODs[i + 1].m_direction), - Mx3DPointFloat(g_characterLODs[i + 1].m_up), + Mx3DPointFloat(g_actorLODs[i + 1].m_position), + Mx3DPointFloat(g_actorLODs[i + 1].m_direction), + Mx3DPointFloat(g_actorLODs[i + 1].m_up), mat ); childROI->WrappedSetLocalTransform(mat); - if (g_characterLODs[i + 1].m_flags & LegoCharacterLOD::c_flag1 && - (i != 0 || part.m_unk0x00[part.m_unk0x08] != 0)) { + if (g_actorLODs[i + 1].m_flags & LegoActorLOD::c_flag1 && (i != 0 || part.m_unk0x00[part.m_unk0x08] != 0)) { LegoTextureInfo* textureInfo = textureContainer->Get(part.m_unk0x10[part.m_unk0x0c[part.m_unk0x14]]); @@ -542,7 +541,7 @@ LegoROI* LegoCharacterManager::CreateROI(const char* p_key) childROI->FUN_100a9170(1.0F, 1.0F, 1.0F, 0.0F); } } - else if (g_characterLODs[i + 1].m_flags & LegoCharacterLOD::c_flag2 || (i == 0 && part.m_unk0x00[part.m_unk0x08] == 0)) { + else if (g_actorLODs[i + 1].m_flags & LegoActorLOD::c_flag2 || (i == 0 && part.m_unk0x00[part.m_unk0x08] == 0)) { LegoFloat red, green, blue, alpha; childROI->FUN_100a9bf0(part.m_unk0x10[part.m_unk0x0c[part.m_unk0x14]], red, green, blue, alpha); childROI->FUN_100a9170(red, green, blue, alpha); @@ -552,9 +551,9 @@ LegoROI* LegoCharacterManager::CreateROI(const char* p_key) } CalcLocalTransform( - Mx3DPointFloat(g_characterLODs[c_topLOD].m_position), - Mx3DPointFloat(g_characterLODs[c_topLOD].m_direction), - Mx3DPointFloat(g_characterLODs[c_topLOD].m_up), + Mx3DPointFloat(g_actorLODs[c_topLOD].m_position), + Mx3DPointFloat(g_actorLODs[c_topLOD].m_direction), + Mx3DPointFloat(g_actorLODs[c_topLOD].m_up), mat ); roi->WrappedSetLocalTransform(mat); @@ -576,12 +575,12 @@ done: MxBool LegoCharacterManager::FUN_100849a0(LegoROI* p_roi, LegoTextureInfo* p_textureInfo) { LegoResult result = SUCCESS; - LegoROI* head = FindChildROI(p_roi, g_characterLODs[c_headLOD].m_name); + LegoROI* head = FindChildROI(p_roi, g_actorLODs[c_headLOD].m_name); if (head != NULL) { char lodName[256]; - ViewLODList* lodList = GetViewLODListManager()->Lookup(g_characterLODs[c_headLOD].m_parentName); + ViewLODList* lodList = GetViewLODListManager()->Lookup(g_actorLODs[c_headLOD].m_parentName); MxS32 lodSize = lodList->Size(); sprintf(lodName, "%s%s%d", p_roi->GetName(), "head", g_unk0x100fc4e8++); ViewLODList* dupLodList = GetViewLODListManager()->Create(lodName, lodSize); @@ -589,8 +588,8 @@ MxBool LegoCharacterManager::FUN_100849a0(LegoROI* p_roi, LegoTextureInfo* p_tex Tgl::Renderer* renderer = VideoManager()->GetRenderer(); if (p_textureInfo == NULL) { - LegoCharacterInfo* info = GetInfo(p_roi->GetName()); - LegoCharacterInfo::Part& part = info->m_parts[c_headPart]; + LegoActorInfo* info = GetActorInfo(p_roi->GetName()); + LegoActorInfo::Part& part = info->m_parts[c_headPart]; p_textureInfo = TextureContainer()->Get(part.m_unk0x10[part.m_unk0x0c[part.m_unk0x14]]); } @@ -620,10 +619,10 @@ MxBool LegoCharacterManager::FUN_100849a0(LegoROI* p_roi, LegoTextureInfo* p_tex } // FUNCTION: LEGO1 0x10084c00 -MxBool LegoCharacterManager::Exists(const char* p_key) +MxBool LegoCharacterManager::IsActor(const char* p_name) { - for (MxU32 i = 0; i < sizeOfArray(g_characterInfo); i++) { - if (!strcmpi(g_characterInfo[i].m_name, p_key)) { + for (MxU32 i = 0; i < sizeOfArray(g_actorInfo); i++) { + if (!strcmpi(g_actorInfo[i].m_name, p_name)) { return TRUE; } } @@ -632,9 +631,9 @@ MxBool LegoCharacterManager::Exists(const char* p_key) } // FUNCTION: LEGO1 0x10084c40 -LegoExtraActor* LegoCharacterManager::GetActor(const char* p_key) +LegoExtraActor* LegoCharacterManager::GetExtraActor(const char* p_name) { - LegoCharacterInfo* info = GetInfo(p_key); + LegoActorInfo* info = GetActorInfo(p_name); if (info != NULL) { return info->m_actor; @@ -644,36 +643,36 @@ LegoExtraActor* LegoCharacterManager::GetActor(const char* p_key) } // FUNCTION: LEGO1 0x10084c60 -LegoCharacterInfo* LegoCharacterManager::GetInfo(const char* p_key) +LegoActorInfo* LegoCharacterManager::GetActorInfo(const char* p_name) { MxU32 i; - for (i = 0; i < sizeOfArray(g_characterInfo); i++) { - if (!strcmpi(g_characterInfo[i].m_name, p_key)) { + for (i = 0; i < sizeOfArray(g_actorInfo); i++) { + if (!strcmpi(g_actorInfo[i].m_name, p_name)) { break; } } - if (i < sizeOfArray(g_characterInfo)) { - return &g_characterInfo[i]; + if (i < sizeOfArray(g_actorInfo)) { + return &g_actorInfo[i]; } return NULL; } // FUNCTION: LEGO1 0x10084cb0 -LegoCharacterInfo* LegoCharacterManager::GetInfo(LegoROI* p_roi) +LegoActorInfo* LegoCharacterManager::GetActorInfo(LegoROI* p_roi) { MxU32 i; - for (i = 0; i < sizeOfArray(g_characterInfo); i++) { - if (g_characterInfo[i].m_roi == p_roi) { + for (i = 0; i < sizeOfArray(g_actorInfo); i++) { + if (g_actorInfo[i].m_roi == p_roi) { break; } } - if (i < sizeOfArray(g_characterInfo)) { - return &g_characterInfo[i]; + if (i < sizeOfArray(g_actorInfo)) { + return &g_actorInfo[i]; } return NULL; @@ -703,13 +702,13 @@ LegoROI* LegoCharacterManager::FindChildROI(LegoROI* p_roi, const char* p_name) // FUNCTION: LEGO1 0x10084ec0 MxBool LegoCharacterManager::SwitchHat(LegoROI* p_roi) { - LegoCharacterInfo* info = GetInfo(p_roi->GetName()); + LegoActorInfo* info = GetActorInfo(p_roi->GetName()); if (info == NULL) { return FALSE; } - LegoCharacterInfo::Part& part = info->m_parts[c_infohatPart]; + LegoActorInfo::Part& part = info->m_parts[c_infohatPart]; part.m_unk0x08++; MxU8 unk0x00 = part.m_unk0x00[part.m_unk0x08]; @@ -719,7 +718,7 @@ MxBool LegoCharacterManager::SwitchHat(LegoROI* p_roi) unk0x00 = part.m_unk0x00[part.m_unk0x08]; } - LegoROI* childROI = FindChildROI(p_roi, g_characterLODs[c_infohatLOD].m_name); + LegoROI* childROI = FindChildROI(p_roi, g_actorLODs[c_infohatLOD].m_name); if (childROI != NULL) { char lodName[256]; @@ -757,7 +756,7 @@ MxBool LegoCharacterManager::SwitchHat(LegoROI* p_roi) // FUNCTION: LEGO1 0x10085140 MxU32 LegoCharacterManager::FUN_10085140(LegoROI* p_roi, MxBool p_und) { - LegoCharacterInfo* info = GetInfo(p_roi); + LegoActorInfo* info = GetActorInfo(p_roi); if (p_und) { return info->m_mood + g_unk0x100fc4dc; @@ -774,7 +773,7 @@ MxU32 LegoCharacterManager::FUN_10085140(LegoROI* p_roi, MxBool p_und) // FUNCTION: BETA10 0x100768c5 MxU8 LegoCharacterManager::GetMood(LegoROI* p_roi) { - LegoCharacterInfo* info = GetInfo(p_roi); + LegoActorInfo* info = GetActorInfo(p_roi); if (info != NULL) { return info->m_mood; @@ -803,7 +802,7 @@ void LegoCharacterManager::SetCustomizeAnimFile(const char* p_value) } // FUNCTION: LEGO1 0x10085210 -LegoROI* LegoCharacterManager::FUN_10085210(const char* p_name, const char* p_lodName, MxBool p_createEntity) +LegoROI* LegoCharacterManager::CreateAutoROI(const char* p_name, const char* p_lodName, MxBool p_createEntity) { LegoROI* roi = NULL; @@ -853,8 +852,8 @@ LegoROI* LegoCharacterManager::FUN_10085210(const char* p_name, const char* p_lo LegoEntity* entity = new LegoEntity(); entity->SetROI(roi, FALSE, FALSE); - entity->SetType(LegoEntity::e_unk4); - entity->SetFlag(LegoActor::c_bit2); + entity->SetType(LegoEntity::e_autoROI); + entity->SetFlag(LegoEntity::c_managerOwned); } } } @@ -907,5 +906,5 @@ MxResult LegoCharacterManager::FUN_10085870(LegoROI* p_roi) // FUNCTION: LEGO1 0x10085a80 LegoROI* LegoCharacterManager::FUN_10085a80(const char* p_name, const char* p_lodName, MxBool p_createEntity) { - return FUN_10085210(p_name, p_lodName, p_createEntity); + return CreateAutoROI(p_name, p_lodName, p_createEntity); } diff --git a/LEGO1/lego/legoomni/src/common/legogamestate.cpp b/LEGO1/lego/legoomni/src/common/legogamestate.cpp index 64f4c494..be09e19b 100644 --- a/LEGO1/lego/legoomni/src/common/legogamestate.cpp +++ b/LEGO1/lego/legoomni/src/common/legogamestate.cpp @@ -177,7 +177,7 @@ void LegoGameState::SetActor(MxU8 p_actorId) IslePathActor* newActor = new IslePathActor(); const char* actorName = LegoActor::GetActorName(m_actorId); - LegoROI* roi = CharacterManager()->GetROI(actorName, FALSE); + LegoROI* roi = CharacterManager()->GetActorROI(actorName, FALSE); MxDSAction action; action.SetAtomId(*g_isleScript); diff --git a/LEGO1/lego/legoomni/src/entity/legoactor.cpp b/LEGO1/lego/legoomni/src/entity/legoactor.cpp index 79c6571e..6ab78b63 100644 --- a/LEGO1/lego/legoomni/src/entity/legoactor.cpp +++ b/LEGO1/lego/legoomni/src/entity/legoactor.cpp @@ -129,7 +129,7 @@ void LegoActor::SetROI(LegoROI* p_roi, MxBool p_bool1, MxBool p_bool2) for (MxU32 i = 1; i <= sizeOfArray(g_actorNames) - 1; i++) { if (!strcmpi(name, g_actorNames[i])) { - m_type = e_character; + m_type = e_actor; m_actorId = i; break; } diff --git a/LEGO1/lego/legoomni/src/entity/legoentity.cpp b/LEGO1/lego/legoomni/src/entity/legoentity.cpp index 4d9324ad..de931cd2 100644 --- a/LEGO1/lego/legoomni/src/entity/legoentity.cpp +++ b/LEGO1/lego/legoomni/src/entity/legoentity.cpp @@ -31,7 +31,7 @@ void LegoEntity::Init() m_flags = 0; m_actionType = Extra::ActionType::e_unknown; m_targetEntityId = -1; - m_type = e_unk4; + m_type = e_autoROI; } // FUNCTION: LEGO1 0x10010650 @@ -93,7 +93,7 @@ void LegoEntity::Destroy(MxBool p_fromDestructor) m_roi->SetEntity(NULL); } - CharacterManager()->FUN_10083db0(m_roi); + CharacterManager()->ReleaseActor(m_roi); } else { VideoManager()->Get3DManager()->GetLego3DView()->Remove(*m_roi); @@ -252,7 +252,7 @@ void LegoEntity::VTable0x34(MxBool p_und) const LegoChar* roiName = m_roi->GetName(); switch (m_type) { - case e_character: + case e_actor: objectId = CharacterManager()->FUN_10085140(m_roi, p_und); break; case e_unk1: @@ -285,7 +285,7 @@ void LegoEntity::VTable0x38() void LegoEntity::VTable0x3c() { switch (m_type) { - case e_character: + case e_actor: CharacterManager()->SwitchHat(m_roi); break; case e_unk1: @@ -366,7 +366,7 @@ MxLong LegoEntity::Notify(MxParam& p_param) break; case 6: switch (m_type) { - case e_character: + case e_actor: case e_unk1: break; case e_plant: @@ -375,7 +375,7 @@ MxLong LegoEntity::Notify(MxParam& p_param) case e_building: BuildingManager()->FUN_10030000(this); break; - case e_unk4: + case e_autoROI: break; } } diff --git a/LEGO1/lego/legoomni/src/entity/legoworld.cpp b/LEGO1/lego/legoomni/src/entity/legoworld.cpp index 71ffefae..9da873e0 100644 --- a/LEGO1/lego/legoomni/src/entity/legoworld.cpp +++ b/LEGO1/lego/legoomni/src/entity/legoworld.cpp @@ -187,7 +187,7 @@ void LegoWorld::Destroy(MxBool p_fromDestructor) while (cursor.First(entity)) { cursor.Detach(); - if (!(entity->GetFlags() & LegoEntity::c_bit2)) { + if (!(entity->GetFlags() & LegoEntity::c_managerOwned)) { delete entity; } } diff --git a/LEGO1/lego/legoomni/src/video/legoanimpresenter.cpp b/LEGO1/lego/legoomni/src/video/legoanimpresenter.cpp index 5f8662df..ffdb2b63 100644 --- a/LEGO1/lego/legoomni/src/video/legoanimpresenter.cpp +++ b/LEGO1/lego/legoomni/src/video/legoanimpresenter.cpp @@ -188,7 +188,7 @@ LegoChar* LegoAnimPresenter::FUN_10069150(const LegoChar* p_und1) { LegoChar* str; - if (LegoCharacterManager::Exists(p_und1 + 1)) { + if (LegoCharacterManager::IsActor(p_und1 + 1)) { str = new LegoChar[strlen(p_und1)]; if (str != NULL) { @@ -232,7 +232,7 @@ void LegoAnimPresenter::FUN_100692b0() src = str; } - roi = CharacterManager()->GetROI(src, TRUE); + roi = CharacterManager()->GetActorROI(src, TRUE); if (roi != NULL && str[0] == '*') { roi->SetVisibility(FALSE); @@ -268,7 +268,7 @@ void LegoAnimPresenter::FUN_100692b0() strlwr(lodName); LegoChar* und = FUN_10069150(str); - roi = CharacterManager()->FUN_10085210(und, lodName, TRUE); + roi = CharacterManager()->CreateAutoROI(und, lodName, TRUE); if (roi != NULL) { roi->SetVisibility(FALSE); @@ -313,7 +313,7 @@ void LegoAnimPresenter::FUN_100695c0() strlwr(lodName); - CharacterManager()->FUN_10085210(actorName, lodName, FALSE); + CharacterManager()->CreateAutoROI(actorName, lodName, FALSE); FUN_100698b0(rois, actorName); } } @@ -530,8 +530,8 @@ void LegoAnimPresenter::FUN_1006aa60() while (cursor.Next(roi)) { const char* name = roi->GetName(); - if (m_unk0x96 || !CharacterManager()->Exists(name)) { - CharacterManager()->FUN_10083c30(name); + if (m_unk0x96 || !CharacterManager()->IsActor(name)) { + CharacterManager()->ReleaseActor(name); } } } diff --git a/LEGO1/lego/legoomni/src/video/legomodelpresenter.cpp b/LEGO1/lego/legoomni/src/video/legomodelpresenter.cpp index ce448d71..4a2cf715 100644 --- a/LEGO1/lego/legoomni/src/video/legomodelpresenter.cpp +++ b/LEGO1/lego/legoomni/src/video/legomodelpresenter.cpp @@ -224,7 +224,7 @@ MxResult LegoModelPresenter::FUN_1007ff70( if (p_entity != NULL) { p_entity->SetROI(m_roi, TRUE, TRUE); - p_entity->ClearFlag(LegoEntity::c_bit2); + p_entity->ClearFlag(LegoEntity::c_managerOwned); } else { p_world->GetROIList().push_back(m_roi); @@ -249,9 +249,10 @@ void LegoModelPresenter::ReadyTickle() ((LegoEntityPresenter*) m_compositePresenter) ->GetInternalEntity() ->SetFlags( - ((LegoEntityPresenter*) m_compositePresenter)->GetInternalEntity()->GetFlags() & ~LegoEntity::c_bit2 + ((LegoEntityPresenter*) m_compositePresenter)->GetInternalEntity()->GetFlags() & + ~LegoEntity::c_managerOwned ); - ((LegoEntityPresenter*) m_compositePresenter)->GetInternalEntity()->SetType(LegoEntity::e_character); + ((LegoEntityPresenter*) m_compositePresenter)->GetInternalEntity()->SetType(LegoEntity::e_actor); } ParseExtra(); @@ -276,7 +277,7 @@ void LegoModelPresenter::ReadyTickle() ->GetInternalEntity() ->SetFlags( ((LegoEntityPresenter*) m_compositePresenter)->GetInternalEntity()->GetFlags() & - ~LegoEntity::c_bit2 + ~LegoEntity::c_managerOwned ); } @@ -306,7 +307,7 @@ void LegoModelPresenter::ParseExtra() char* token = strtok(output, g_parseExtraTokens); if (m_roi == NULL) { - m_roi = CharacterManager()->GetROI(token, FALSE); + m_roi = CharacterManager()->GetActorROI(token, FALSE); m_addedToView = FALSE; } } diff --git a/LEGO1/lego/legoomni/src/video/legophonemepresenter.cpp b/LEGO1/lego/legoomni/src/video/legophonemepresenter.cpp index 5fbbba21..824a4ce2 100644 --- a/LEGO1/lego/legoomni/src/video/legophonemepresenter.cpp +++ b/LEGO1/lego/legoomni/src/video/legophonemepresenter.cpp @@ -52,7 +52,7 @@ void LegoPhonemePresenter::StartingTickle() m_unk0x84 = TRUE; } else { - entityROI = CharacterManager()->GetROI(m_roiName.GetData(), TRUE); + entityROI = CharacterManager()->GetActorROI(m_roiName.GetData(), TRUE); } head = entityROI->FindChildROI("head", entityROI); @@ -143,7 +143,7 @@ void LegoPhonemePresenter::EndAction() roi = FindROI(m_roiName.GetData()); } else { - roi = CharacterManager()->GetROI(m_roiName.GetData(), TRUE); + roi = CharacterManager()->GetActorROI(m_roiName.GetData(), TRUE); } if (roi != NULL) { @@ -151,7 +151,7 @@ void LegoPhonemePresenter::EndAction() } if (!m_unk0x84) { - CharacterManager()->FUN_10083c30(m_roiName.GetData()); + CharacterManager()->ReleaseActor(m_roiName.GetData()); } TextureContainer()->EraseCached(phoneme->VTable0x10()); @@ -164,7 +164,7 @@ void LegoPhonemePresenter::EndAction() } if (!m_unk0x84) { - CharacterManager()->FUN_10083c30(m_roiName.GetData()); + CharacterManager()->ReleaseActor(m_roiName.GetData()); } } } diff --git a/LEGO1/lego/legoomni/src/worlds/infocenter.cpp b/LEGO1/lego/legoomni/src/worlds/infocenter.cpp index 8308cf11..af05132d 100644 --- a/LEGO1/lego/legoomni/src/worlds/infocenter.cpp +++ b/LEGO1/lego/legoomni/src/worlds/infocenter.cpp @@ -1308,7 +1308,7 @@ void Infocenter::Reset() PlantManager()->FUN_10027120(); BuildingManager()->FUN_10030590(); AnimationManager()->Reset(FALSE); - CharacterManager()->FUN_100832a0(); + CharacterManager()->ReleaseAllActors(); GameState()->SetCurrentAct(LegoGameState::e_act1); GameState()->SetPreviousArea(LegoGameState::e_undefined); GameState()->SetUnknown0x42c(LegoGameState::e_undefined); From 919a3f5c492390f022e4ae05b53e164e4b076619 Mon Sep 17 00:00:00 2001 From: Christian Semmler Date: Sat, 1 Jun 2024 13:38:13 -0400 Subject: [PATCH 5/9] Implement/match Lego3DSound::UpdatePosition (#983) --- LEGO1/lego/legoomni/include/lego3dsound.h | 2 +- LEGO1/lego/legoomni/src/audio/lego3dsound.cpp | 61 +++++++++++++++++-- .../src/audio/lego3dwavepresenter.cpp | 2 +- .../lego/legoomni/src/audio/legocachsound.cpp | 2 +- 4 files changed, 60 insertions(+), 7 deletions(-) diff --git a/LEGO1/lego/legoomni/include/lego3dsound.h b/LEGO1/lego/legoomni/include/lego3dsound.h index 14be04ee..315858d0 100644 --- a/LEGO1/lego/legoomni/include/lego3dsound.h +++ b/LEGO1/lego/legoomni/include/lego3dsound.h @@ -19,7 +19,7 @@ public: void Init(); MxResult Create(LPDIRECTSOUNDBUFFER p_directSoundBuffer, const char* p_name, MxS32 p_volume); void Destroy(); - undefined4 FUN_100118e0(LPDIRECTSOUNDBUFFER p_directSoundBuffer); + MxU32 UpdatePosition(LPDIRECTSOUNDBUFFER p_directSoundBuffer); void FUN_10011ca0(); MxS32 FUN_10011cf0(undefined4, undefined4); diff --git a/LEGO1/lego/legoomni/src/audio/lego3dsound.cpp b/LEGO1/lego/legoomni/src/audio/lego3dsound.cpp index eef3aa86..d93e0c6d 100644 --- a/LEGO1/lego/legoomni/src/audio/lego3dsound.cpp +++ b/LEGO1/lego/legoomni/src/audio/lego3dsound.cpp @@ -2,9 +2,13 @@ #include "legoactor.h" #include "legocharactermanager.h" +#include "legosoundmanager.h" +#include "legovideomanager.h" #include "misc.h" #include "mxomni.h" +#include + DECOMP_SIZE_ASSERT(Lego3DSound, 0x30) // FUNCTION: LEGO1 0x10011630 @@ -123,12 +127,61 @@ void Lego3DSound::Destroy() Init(); } -// STUB: LEGO1 0x100118e0 +// FUNCTION: LEGO1 0x100118e0 // FUNCTION: BETA10 0x10039a2a -undefined4 Lego3DSound::FUN_100118e0(LPDIRECTSOUNDBUFFER p_directSoundBuffer) +MxU32 Lego3DSound::UpdatePosition(LPDIRECTSOUNDBUFFER p_directSoundBuffer) { - // TODO - return 0; + MxU32 updated = FALSE; + + if (m_positionROI != NULL) { + const float* position = m_positionROI->GetWorldPosition(); + + ViewROI* pov = VideoManager()->GetViewROI(); + assert(pov); + + const float* povPosition = pov->GetWorldPosition(); + float distance = DISTSQRD3(povPosition, position); + + if (distance > 10000.0f) { + return FALSE; + } + + if (m_ds3dBuffer != NULL) { + m_ds3dBuffer->SetPosition(position[0], position[1], position[2], 0); + } + else { + MxS32 newVolume = m_volume; + + if (distance < 100.0f) { + newVolume = m_volume; + } + else if (distance < 400.0f) { + newVolume *= 0.4; + } + else if (distance < 3600.0f) { + newVolume *= 0.1; + } + else if (distance < 10000.0f) { + newVolume = 0; + } + + newVolume = newVolume * SoundManager()->GetVolume() / 100; + newVolume = SoundManager()->GetAttenuation(newVolume); + p_directSoundBuffer->SetVolume(newVolume); + } + + updated = TRUE; + } + + if (m_actor != NULL) { + if (abs(m_frequencyFactor - m_actor->GetSoundFrequencyFactor()) > 0.0001) { + m_frequencyFactor = m_actor->GetSoundFrequencyFactor(); + p_directSoundBuffer->SetFrequency(m_frequencyFactor * m_dwFrequency); + updated = TRUE; + } + } + + return updated; } // STUB: LEGO1 0x10011ca0 diff --git a/LEGO1/lego/legoomni/src/audio/lego3dwavepresenter.cpp b/LEGO1/lego/legoomni/src/audio/lego3dwavepresenter.cpp index 10b79146..8083822e 100644 --- a/LEGO1/lego/legoomni/src/audio/lego3dwavepresenter.cpp +++ b/LEGO1/lego/legoomni/src/audio/lego3dwavepresenter.cpp @@ -62,5 +62,5 @@ void Lego3DWavePresenter::StartingTickle() void Lego3DWavePresenter::StreamingTickle() { MxWavePresenter::StreamingTickle(); - m_sound.FUN_100118e0(m_dsBuffer); + m_sound.UpdatePosition(m_dsBuffer); } diff --git a/LEGO1/lego/legoomni/src/audio/legocachsound.cpp b/LEGO1/lego/legoomni/src/audio/legocachsound.cpp index 7d4f565c..3c2ab5f1 100644 --- a/LEGO1/lego/legoomni/src/audio/legocachsound.cpp +++ b/LEGO1/lego/legoomni/src/audio/legocachsound.cpp @@ -134,7 +134,7 @@ void LegoCacheSound::FUN_10006be0() } if (m_string0x74.GetLength() != 0 && !m_unk0x84) { - if (!m_unk0x10.FUN_100118e0(m_dsBuffer)) { + if (!m_unk0x10.UpdatePosition(m_dsBuffer)) { if (m_unk0x6a) { return; } From ac4e8da662039188654c986423ae8c0fee8a665c Mon Sep 17 00:00:00 2001 From: Christian Semmler Date: Sat, 1 Jun 2024 13:45:22 -0400 Subject: [PATCH 6/9] Implement/match Lego3DSound::SetDistance and Reset (#984) --- LEGO1/lego/legoomni/include/lego3dsound.h | 4 +-- LEGO1/lego/legoomni/include/legocachsound.h | 4 +-- LEGO1/lego/legoomni/include/legoworld.h | 4 +-- LEGO1/lego/legoomni/src/audio/lego3dsound.cpp | 34 +++++++++++++++---- .../lego/legoomni/src/audio/legocachsound.cpp | 10 +++--- .../src/build/legobuildingmanager.cpp | 2 +- .../src/common/legoanimationmanager.cpp | 1 + LEGO1/lego/legoomni/src/entity/legoworld.cpp | 2 ++ 8 files changed, 42 insertions(+), 19 deletions(-) diff --git a/LEGO1/lego/legoomni/include/lego3dsound.h b/LEGO1/lego/legoomni/include/lego3dsound.h index 315858d0..e52c249b 100644 --- a/LEGO1/lego/legoomni/include/lego3dsound.h +++ b/LEGO1/lego/legoomni/include/lego3dsound.h @@ -20,8 +20,8 @@ public: MxResult Create(LPDIRECTSOUNDBUFFER p_directSoundBuffer, const char* p_name, MxS32 p_volume); void Destroy(); MxU32 UpdatePosition(LPDIRECTSOUNDBUFFER p_directSoundBuffer); - void FUN_10011ca0(); - MxS32 FUN_10011cf0(undefined4, undefined4); + void Reset(); + MxS32 SetDistance(MxS32 p_min, MxS32 p_max); // SYNTHETIC: LEGO1 0x10011650 // Lego3DSound::`scalar deleting destructor' diff --git a/LEGO1/lego/legoomni/include/legocachsound.h b/LEGO1/lego/legoomni/include/legocachsound.h index f424a465..86255152 100644 --- a/LEGO1/lego/legoomni/include/legocachsound.h +++ b/LEGO1/lego/legoomni/include/legocachsound.h @@ -37,7 +37,7 @@ public: MxResult FUN_10006a30(const char* p_str, MxBool); void FUN_10006b80(); void FUN_10006be0(); - void FUN_10006cb0(undefined4 p_und1, undefined4 p_und2); + void SetDistance(MxS32 p_min, MxS32 p_max); // SYNTHETIC: LEGO1 0x10006610 // LegoCacheSound::`scalar deleting destructor' @@ -47,7 +47,7 @@ private: LPDIRECTSOUNDBUFFER m_dsBuffer; // 0x08 undefined m_unk0xc[4]; // 0x0c - Lego3DSound m_unk0x10; // 0x10 + Lego3DSound m_sound; // 0x10 undefined* m_unk0x40; // 0x40 undefined4 m_unk0x44; // 0x44 MxString m_string0x48; // 0x48 diff --git a/LEGO1/lego/legoomni/include/legoworld.h b/LEGO1/lego/legoomni/include/legoworld.h index 79088500..766d5ca5 100644 --- a/LEGO1/lego/legoomni/include/legoworld.h +++ b/LEGO1/lego/legoomni/include/legoworld.h @@ -1,14 +1,14 @@ #ifndef LEGOWORLD_H #define LEGOWORLD_H -#include "legocachesoundlist.h" #include "legoentity.h" -#include "legoentitylist.h" #include "legopathcontrollerlist.h" #include "mxpresenterlist.h" #include "roi/legoroi.h" +class LegoCacheSoundList; class LegoCameraController; +class LegoEntityList; class LegoPathBoundary; class LegoHideAnimPresenter; diff --git a/LEGO1/lego/legoomni/src/audio/lego3dsound.cpp b/LEGO1/lego/legoomni/src/audio/lego3dsound.cpp index d93e0c6d..5f6c1a95 100644 --- a/LEGO1/lego/legoomni/src/audio/lego3dsound.cpp +++ b/LEGO1/lego/legoomni/src/audio/lego3dsound.cpp @@ -184,15 +184,35 @@ MxU32 Lego3DSound::UpdatePosition(LPDIRECTSOUNDBUFFER p_directSoundBuffer) return updated; } -// STUB: LEGO1 0x10011ca0 -void Lego3DSound::FUN_10011ca0() +// FUNCTION: LEGO1 0x10011ca0 +void Lego3DSound::Reset() { - // TODO + if (m_enabled && m_roi && CharacterManager()) { + if (m_isActor) { + CharacterManager()->ReleaseActor(m_roi); + } + else { + CharacterManager()->ReleaseAutoROI(m_roi); + } + } + + m_roi = NULL; + m_positionROI = NULL; + m_actor = NULL; } -// STUB: LEGO1 0x10011cf0 -MxS32 Lego3DSound::FUN_10011cf0(undefined4, undefined4) +// FUNCTION: LEGO1 0x10011cf0 +MxS32 Lego3DSound::SetDistance(MxS32 p_min, MxS32 p_max) { - // TODO - return 0; + if (MxOmni::IsSound3D()) { + if (m_ds3dBuffer == NULL) { + return -1; + } + + m_ds3dBuffer->SetMinDistance(p_min, 0); + m_ds3dBuffer->SetMaxDistance(p_max, 0); + return 0; + } + + return 1; } diff --git a/LEGO1/lego/legoomni/src/audio/legocachsound.cpp b/LEGO1/lego/legoomni/src/audio/legocachsound.cpp index 3c2ab5f1..2a6b70ca 100644 --- a/LEGO1/lego/legoomni/src/audio/legocachsound.cpp +++ b/LEGO1/lego/legoomni/src/audio/legocachsound.cpp @@ -100,7 +100,7 @@ void LegoCacheSound::FUN_10006b80() m_unk0x58 = 0; m_unk0x6a = FALSE; - m_unk0x10.FUN_10011ca0(); + m_sound.Reset(); if (m_string0x74.GetLength() != 0) { m_string0x74 = ""; } @@ -123,7 +123,7 @@ void LegoCacheSound::FUN_10006be0() if (dwStatus == 0) { m_dsBuffer->Stop(); - m_unk0x10.FUN_10011ca0(); + m_sound.Reset(); if (m_string0x74.GetLength() != 0) { m_string0x74 = ""; } @@ -134,7 +134,7 @@ void LegoCacheSound::FUN_10006be0() } if (m_string0x74.GetLength() != 0 && !m_unk0x84) { - if (!m_unk0x10.UpdatePosition(m_dsBuffer)) { + if (!m_sound.UpdatePosition(m_dsBuffer)) { if (m_unk0x6a) { return; } @@ -150,9 +150,9 @@ void LegoCacheSound::FUN_10006be0() } // FUNCTION: LEGO1 0x10006cb0 -void LegoCacheSound::FUN_10006cb0(undefined4 p_und1, undefined4 p_und2) +void LegoCacheSound::SetDistance(MxS32 p_min, MxS32 p_max) { - m_unk0x10.FUN_10011cf0(p_und1, p_und2); + m_sound.SetDistance(p_min, p_max); } // FUNCTION: LEGO1 0x10006cd0 diff --git a/LEGO1/lego/legoomni/src/build/legobuildingmanager.cpp b/LEGO1/lego/legoomni/src/build/legobuildingmanager.cpp index 3aeef9bb..863520da 100644 --- a/LEGO1/lego/legoomni/src/build/legobuildingmanager.cpp +++ b/LEGO1/lego/legoomni/src/build/legobuildingmanager.cpp @@ -619,7 +619,7 @@ void LegoBuildingManager::ScheduleAnimation(LegoEntity* p_entity, MxU32 p_length if (p_haveSound) { m_sound = SoundManager()->GetCacheSoundManager()->FindSoundByKey("bcrash"); - m_sound->FUN_10006cb0(35, 60); + m_sound->SetDistance(35, 60); } if (m_numEntries == 0) { diff --git a/LEGO1/lego/legoomni/src/common/legoanimationmanager.cpp b/LEGO1/lego/legoomni/src/common/legoanimationmanager.cpp index 3c358af4..19ff9fa3 100644 --- a/LEGO1/lego/legoomni/src/common/legoanimationmanager.cpp +++ b/LEGO1/lego/legoomni/src/common/legoanimationmanager.cpp @@ -9,6 +9,7 @@ #include "legoanimpresenter.h" #include "legocharactermanager.h" #include "legoendanimnotificationparam.h" +#include "legoentitylist.h" #include "legoextraactor.h" #include "legogamestate.h" #include "legolocomotionanimpresenter.h" diff --git a/LEGO1/lego/legoomni/src/entity/legoworld.cpp b/LEGO1/lego/legoomni/src/entity/legoworld.cpp index 9da873e0..fcec9fdd 100644 --- a/LEGO1/lego/legoomni/src/entity/legoworld.cpp +++ b/LEGO1/lego/legoomni/src/entity/legoworld.cpp @@ -4,9 +4,11 @@ #include "legoanimationmanager.h" #include "legoanimpresenter.h" #include "legobuildingmanager.h" +#include "legocachesoundlist.h" #include "legocachesoundmanager.h" #include "legocameracontroller.h" #include "legocontrolmanager.h" +#include "legoentitylist.h" #include "legogamestate.h" #include "legoinputmanager.h" #include "legolocomotionanimpresenter.h" From 1423eb56fc2846b9883640f8b83420deac79744e Mon Sep 17 00:00:00 2001 From: Christian Semmler Date: Sat, 1 Jun 2024 17:13:57 -0400 Subject: [PATCH 7/9] Implement/match LegoSoundManager::UpdateListener (#985) --- .../lego/legoomni/include/legosoundmanager.h | 2 +- LEGO1/lego/legoomni/src/audio/lego3dsound.cpp | 16 ++++----- .../lego/legoomni/src/audio/legocachsound.cpp | 1 + .../legoomni/src/audio/legosoundmanager.cpp | 36 +++++++++++++++++-- .../src/common/legoanimationmanager.cpp | 2 +- LEGO1/lego/legoomni/src/common/legoutils.cpp | 2 +- .../src/entity/legocameracontroller.cpp | 2 +- .../legoomni/src/entity/legonavcontroller.cpp | 4 +-- .../legoomni/src/entity/legopovcontroller.cpp | 4 +-- 9 files changed, 50 insertions(+), 19 deletions(-) diff --git a/LEGO1/lego/legoomni/include/legosoundmanager.h b/LEGO1/lego/legoomni/include/legosoundmanager.h index ad46bf8f..72638c63 100644 --- a/LEGO1/lego/legoomni/include/legosoundmanager.h +++ b/LEGO1/lego/legoomni/include/legosoundmanager.h @@ -19,7 +19,7 @@ public: // SYNTHETIC: LEGO1 0x10029920 // LegoSoundManager::`scalar deleting destructor' - void FUN_1002a410(const float* p_pos, const float* p_dir, const float* p_up, const float* p_vel); + void UpdateListener(const float* p_position, const float* p_direction, const float* p_up, const float* p_velocity); inline LegoCacheSoundManager* GetCacheSoundManager() { return m_cacheSoundManager; } diff --git a/LEGO1/lego/legoomni/src/audio/lego3dsound.cpp b/LEGO1/lego/legoomni/src/audio/lego3dsound.cpp index 5f6c1a95..f2da166c 100644 --- a/LEGO1/lego/legoomni/src/audio/lego3dsound.cpp +++ b/LEGO1/lego/legoomni/src/audio/lego3dsound.cpp @@ -47,10 +47,10 @@ MxResult Lego3DSound::Create(LPDIRECTSOUNDBUFFER p_directSoundBuffer, const char return FAILURE; } - m_ds3dBuffer->SetMinDistance(15.0f, 0); - m_ds3dBuffer->SetMaxDistance(100.0f, 0); - m_ds3dBuffer->SetPosition(0.0f, 0.0f, -40.0f, 0); - m_ds3dBuffer->SetConeOutsideVolume(-10000, 0); + m_ds3dBuffer->SetMinDistance(15.0f, DS3D_IMMEDIATE); + m_ds3dBuffer->SetMaxDistance(100.0f, DS3D_IMMEDIATE); + m_ds3dBuffer->SetPosition(0.0f, 0.0f, -40.0f, DS3D_IMMEDIATE); + m_ds3dBuffer->SetConeOutsideVolume(-10000, DS3D_IMMEDIATE); } if (m_ds3dBuffer == NULL || p_name == NULL) { @@ -86,7 +86,7 @@ MxResult Lego3DSound::Create(LPDIRECTSOUNDBUFFER p_directSoundBuffer, const char if (MxOmni::IsSound3D()) { const float* position = m_positionROI->GetWorldPosition(); - m_ds3dBuffer->SetPosition(position[0], position[1], position[2], 0); + m_ds3dBuffer->SetPosition(position[0], position[1], position[2], DS3D_IMMEDIATE); } LegoEntity* entity = m_roi->GetEntity(); @@ -147,7 +147,7 @@ MxU32 Lego3DSound::UpdatePosition(LPDIRECTSOUNDBUFFER p_directSoundBuffer) } if (m_ds3dBuffer != NULL) { - m_ds3dBuffer->SetPosition(position[0], position[1], position[2], 0); + m_ds3dBuffer->SetPosition(position[0], position[1], position[2], DS3D_IMMEDIATE); } else { MxS32 newVolume = m_volume; @@ -209,8 +209,8 @@ MxS32 Lego3DSound::SetDistance(MxS32 p_min, MxS32 p_max) return -1; } - m_ds3dBuffer->SetMinDistance(p_min, 0); - m_ds3dBuffer->SetMaxDistance(p_max, 0); + m_ds3dBuffer->SetMinDistance(p_min, DS3D_IMMEDIATE); + m_ds3dBuffer->SetMaxDistance(p_max, DS3D_IMMEDIATE); return 0; } diff --git a/LEGO1/lego/legoomni/src/audio/legocachsound.cpp b/LEGO1/lego/legoomni/src/audio/legocachsound.cpp index 2a6b70ca..b426da5a 100644 --- a/LEGO1/lego/legoomni/src/audio/legocachsound.cpp +++ b/LEGO1/lego/legoomni/src/audio/legocachsound.cpp @@ -34,6 +34,7 @@ void LegoCacheSound::Init() } // STUB: LEGO1 0x10006710 +// FUNCTION: BETA10 0x10066505 MxResult LegoCacheSound::FUN_10006710() { // TODO diff --git a/LEGO1/lego/legoomni/src/audio/legosoundmanager.cpp b/LEGO1/lego/legoomni/src/audio/legosoundmanager.cpp index 942f8040..2832d825 100644 --- a/LEGO1/lego/legoomni/src/audio/legosoundmanager.cpp +++ b/LEGO1/lego/legoomni/src/audio/legosoundmanager.cpp @@ -97,8 +97,38 @@ MxResult LegoSoundManager::Tickle() return m_cacheSoundManager->Tickle(); } -// STUB: LEGO1 0x1002a410 -void LegoSoundManager::FUN_1002a410(const float* p_pos, const float* p_dir, const float* p_up, const float* p_vel) +// FUNCTION: LEGO1 0x1002a410 +// FUNCTION: BETA10 0x100d03a5 +void LegoSoundManager::UpdateListener( + const float* p_position, + const float* p_direction, + const float* p_up, + const float* p_velocity +) { - // TODO + if (m_listener != NULL) { + if (p_position != NULL) { + m_listener->SetPosition(p_position[0], p_position[1], p_position[2], DS3D_DEFERRED); + } + + if (p_direction != NULL && p_up != NULL) { + m_listener->SetOrientation( + p_direction[0], + p_direction[1], + p_direction[2], + p_up[0], + p_up[1], + p_up[2], + DS3D_DEFERRED + ); + } + + if (p_velocity != NULL) { + m_listener->SetVelocity(p_velocity[0], p_velocity[1], p_velocity[2], DS3D_DEFERRED); + } + + if (p_position != NULL || (p_direction != NULL && p_up != NULL) || p_velocity != NULL) { + m_listener->CommitDeferredSettings(); + } + } } diff --git a/LEGO1/lego/legoomni/src/common/legoanimationmanager.cpp b/LEGO1/lego/legoomni/src/common/legoanimationmanager.cpp index 19ff9fa3..fde5a979 100644 --- a/LEGO1/lego/legoomni/src/common/legoanimationmanager.cpp +++ b/LEGO1/lego/legoomni/src/common/legoanimationmanager.cpp @@ -2812,7 +2812,7 @@ void LegoAnimationManager::FUN_10064b50(MxLong p_time) viewROI->WrappedSetLocalTransform(mat); VideoManager()->Get3DManager()->Moved(*viewROI); - SoundManager()->FUN_1002a410( + SoundManager()->UpdateListener( viewROI->GetWorldPosition(), viewROI->GetWorldDirection(), viewROI->GetWorldUp(), diff --git a/LEGO1/lego/legoomni/src/common/legoutils.cpp b/LEGO1/lego/legoomni/src/common/legoutils.cpp index 62783224..7e431d03 100644 --- a/LEGO1/lego/legoomni/src/common/legoutils.cpp +++ b/LEGO1/lego/legoomni/src/common/legoutils.cpp @@ -369,7 +369,7 @@ void FUN_1003eda0() LegoROI* viewROI = VideoManager()->GetViewROI(); if (viewROI) { viewROI->FUN_100a5a30(vec); - SoundManager()->FUN_1002a410( + SoundManager()->UpdateListener( viewROI->GetWorldPosition(), viewROI->GetWorldDirection(), viewROI->GetWorldUp(), diff --git a/LEGO1/lego/legoomni/src/entity/legocameracontroller.cpp b/LEGO1/lego/legoomni/src/entity/legocameracontroller.cpp index b07bb02a..3db91002 100644 --- a/LEGO1/lego/legoomni/src/entity/legocameracontroller.cpp +++ b/LEGO1/lego/legoomni/src/entity/legocameracontroller.cpp @@ -159,7 +159,7 @@ void LegoCameraController::FUN_100123e0(const Matrix4& p_transform, MxU32 p_und) pov->WrappedSetLocalTransform(mat); m_lego3DView->Moved(*pov); - SoundManager()->FUN_1002a410( + SoundManager()->UpdateListener( pov->GetWorldPosition(), pov->GetWorldDirection(), pov->GetWorldUp(), diff --git a/LEGO1/lego/legoomni/src/entity/legonavcontroller.cpp b/LEGO1/lego/legoomni/src/entity/legonavcontroller.cpp index 7f5fef34..87274d00 100644 --- a/LEGO1/lego/legoomni/src/entity/legonavcontroller.cpp +++ b/LEGO1/lego/legoomni/src/entity/legonavcontroller.cpp @@ -421,7 +421,7 @@ MxResult LegoNavController::UpdateLocation(const char* p_location) viewROI->WrappedSetLocalTransform(mat); VideoManager()->Get3DManager()->Moved(*viewROI); - SoundManager()->FUN_1002a410( + SoundManager()->UpdateListener( viewROI->GetWorldPosition(), viewROI->GetWorldDirection(), viewROI->GetWorldUp(), @@ -458,7 +458,7 @@ MxResult LegoNavController::UpdateLocation(MxU32 p_location) viewROI->WrappedSetLocalTransform(mat); VideoManager()->Get3DManager()->Moved(*viewROI); - SoundManager()->FUN_1002a410( + SoundManager()->UpdateListener( viewROI->GetWorldPosition(), viewROI->GetWorldDirection(), viewROI->GetWorldUp(), diff --git a/LEGO1/lego/legoomni/src/entity/legopovcontroller.cpp b/LEGO1/lego/legoomni/src/entity/legopovcontroller.cpp index 0575056d..d2fedcb6 100644 --- a/LEGO1/lego/legoomni/src/entity/legopovcontroller.cpp +++ b/LEGO1/lego/legoomni/src/entity/legopovcontroller.cpp @@ -156,7 +156,7 @@ MxResult LegoPointOfViewController::Tickle() pov->WrappedSetLocalTransform(mat); m_lego3DView->Moved(*pov); - SoundManager()->FUN_1002a410( + SoundManager()->UpdateListener( pov->GetWorldPosition(), pov->GetWorldDirection(), pov->GetWorldUp(), @@ -172,7 +172,7 @@ MxResult LegoPointOfViewController::Tickle() vel.Clear(); pov->FUN_100a5a30(vel); - SoundManager()->FUN_1002a410( + SoundManager()->UpdateListener( pov->GetWorldPosition(), pov->GetWorldDirection(), pov->GetWorldUp(), From 03ffb9c5de0aefda46634d57bb8f6be5ed345917 Mon Sep 17 00:00:00 2001 From: Christian Semmler Date: Sat, 1 Jun 2024 17:29:37 -0400 Subject: [PATCH 8/9] Implement/match LegoCacheSound::Create and LegoLoadCacheSoundPresenter::StreamingTickle (#986) * Implement/match LegoCacheSound::Create * Naming * Fix naming * Fix parens --- .../legoomni/include/legocachesoundmanager.h | 2 +- LEGO1/lego/legoomni/include/legocachsound.h | 28 +++-- .../include/legoloadcachesoundpresenter.h | 8 +- .../src/audio/legocachesoundmanager.cpp | 8 +- .../lego/legoomni/src/audio/legocachsound.cpp | 112 +++++++++++++++--- .../src/audio/legoloadcachesoundpresenter.cpp | 50 +++++--- LEGO1/omni/include/mxdsmediaaction.h | 3 + LEGO1/omni/include/mxdssound.h | 4 +- LEGO1/omni/src/audio/mxwavepresenter.cpp | 4 +- 9 files changed, 165 insertions(+), 54 deletions(-) diff --git a/LEGO1/lego/legoomni/include/legocachesoundmanager.h b/LEGO1/lego/legoomni/include/legocachesoundmanager.h index e8dbc204..8297b416 100644 --- a/LEGO1/lego/legoomni/include/legocachesoundmanager.h +++ b/LEGO1/lego/legoomni/include/legocachesoundmanager.h @@ -12,7 +12,7 @@ struct LegoCacheSoundEntry { LegoCacheSoundEntry() : m_sound(NULL), m_name(NULL) {} LegoCacheSoundEntry(LegoCacheSound* p_sound, const char* p_name) : m_sound(p_sound), m_name(p_name) {} - LegoCacheSoundEntry(LegoCacheSound* p_sound) : m_sound(p_sound), m_name(p_sound->GetString0x48().GetData()) {} + LegoCacheSoundEntry(LegoCacheSound* p_sound) : m_sound(p_sound), m_name(p_sound->GetUnknown0x48().GetData()) {} // FUNCTION: LEGO1 0x1003d030 ~LegoCacheSoundEntry() diff --git a/LEGO1/lego/legoomni/include/legocachsound.h b/LEGO1/lego/legoomni/include/legocachsound.h index 86255152..10d0108b 100644 --- a/LEGO1/lego/legoomni/include/legocachsound.h +++ b/LEGO1/lego/legoomni/include/legocachsound.h @@ -26,12 +26,18 @@ public: return !strcmp(p_name, LegoCacheSound::ClassName()) || MxCore::IsA(p_name); } - virtual MxResult FUN_10006710(); // vtable+0x14 + virtual MxResult Create( + LPPCMWAVEFORMAT p_pwfx, + MxString p_mediaSrcPath, + MxS32 p_volume, + MxU8* p_data, + MxU32 p_dataSize + ); // vtable+0x14 virtual void Destroy(); // vtable+0x18 virtual void FUN_10006cd0(undefined4, undefined4); // vtable+0x1c - inline const MxString& GetString0x48() const { return m_string0x48; } - inline const undefined GetUnk0x58() const { return m_unk0x58; } + inline const MxString& GetUnknown0x48() const { return m_unk0x48; } + inline const undefined GetUnknown0x58() const { return m_unk0x58; } LegoCacheSound* FUN_10006960(); MxResult FUN_10006a30(const char* p_str, MxBool); @@ -44,20 +50,22 @@ public: private: void Init(); + void CopyData(MxU8* p_data, MxU32 p_dataSize); + MxString FUN_10006d80(const MxString& p_str); LPDIRECTSOUNDBUFFER m_dsBuffer; // 0x08 - undefined m_unk0xc[4]; // 0x0c + undefined m_unk0x0c[4]; // 0x0c Lego3DSound m_sound; // 0x10 - undefined* m_unk0x40; // 0x40 - undefined4 m_unk0x44; // 0x44 - MxString m_string0x48; // 0x48 + MxU8* m_data; // 0x40 + MxU32 m_dataSize; // 0x44 + MxString m_unk0x48; // 0x48 undefined m_unk0x58; // 0x58 - PCMWAVEFORMAT m_unk0x59; // 0x59 + PCMWAVEFORMAT m_wfx; // 0x59 MxBool m_isLooping; // 0x69 MxBool m_unk0x6a; // 0x6a - undefined4 m_unk0x6c; // 0x6c + MxS32 m_volume; // 0x6c undefined m_unk0x70; // 0x70 - MxString m_string0x74; // 0x74 + MxString m_unk0x74; // 0x74 undefined m_unk0x84; // 0x84 }; diff --git a/LEGO1/lego/legoomni/include/legoloadcachesoundpresenter.h b/LEGO1/lego/legoomni/include/legoloadcachesoundpresenter.h index 883f4b01..6def0dee 100644 --- a/LEGO1/lego/legoomni/include/legoloadcachesoundpresenter.h +++ b/LEGO1/lego/legoomni/include/legoloadcachesoundpresenter.h @@ -37,10 +37,10 @@ private: void Destroy(MxBool p_fromDestructor); LegoCacheSound* m_cacheSound; // 0x6c - undefined* m_unk0x70; // 0x70 - undefined* m_unk0x74; // 0x74 - undefined4 m_unk0x78; // 0x78 - undefined m_unk0x7c; // 0x7c + MxU8* m_data; // 0x70 + MxU8* m_pData; // 0x74 + MxU32 m_dataSize; // 0x78 + MxBool m_unk0x7c; // 0x7c PCMWAVEFORMAT m_pcmWaveFormat; // 0x7d }; diff --git a/LEGO1/lego/legoomni/src/audio/legocachesoundmanager.cpp b/LEGO1/lego/legoomni/src/audio/legocachesoundmanager.cpp index 8d645dfd..6628246b 100644 --- a/LEGO1/lego/legoomni/src/audio/legocachesoundmanager.cpp +++ b/LEGO1/lego/legoomni/src/audio/legocachesoundmanager.cpp @@ -37,7 +37,7 @@ MxResult LegoCacheSoundManager::Tickle() for (Set100d6b4c::iterator setIter = m_set.begin(); setIter != m_set.end(); setIter++) { #endif LegoCacheSound* sound = (*setIter).GetSound(); - if (sound->GetUnk0x58()) { + if (sound->GetUnknown0x58()) { sound->FUN_10006be0(); } } @@ -46,7 +46,7 @@ MxResult LegoCacheSoundManager::Tickle() while (listIter != m_list.end()) { LegoCacheSound* sound = (*listIter).GetSound(); - if (sound->GetUnk0x58()) { + if (sound->GetUnknown0x58()) { sound->FUN_10006be0(); listIter++; } @@ -84,7 +84,7 @@ LegoCacheSound* LegoCacheSoundManager::ManageSoundEntry(LegoCacheSound* p_sound) if (it != m_set.end()) { LegoCacheSound* sound = (*it).GetSound(); - if (sound->GetUnk0x58()) { + if (sound->GetUnknown0x58()) { m_list.push_back(LegoCacheSoundEntry(p_sound)); return p_sound; } @@ -117,7 +117,7 @@ LegoCacheSound* LegoCacheSoundManager::FUN_1003db10(LegoCacheSound* p_one, const return NULL; } - if (p_one->GetUnk0x58()) { + if (p_one->GetUnknown0x58()) { LegoCacheSound* result = p_one->FUN_10006960(); if (result) { diff --git a/LEGO1/lego/legoomni/src/audio/legocachsound.cpp b/LEGO1/lego/legoomni/src/audio/legocachsound.cpp index b426da5a..19ba06f3 100644 --- a/LEGO1/lego/legoomni/src/audio/legocachsound.cpp +++ b/LEGO1/lego/legoomni/src/audio/legocachsound.cpp @@ -12,10 +12,9 @@ LegoCacheSound::LegoCacheSound() Init(); } -// STUB: LEGO1 0x10006630 +// FUNCTION: LEGO1 0x10006630 LegoCacheSound::~LegoCacheSound() { - // TODO Destroy(); } @@ -23,39 +22,85 @@ LegoCacheSound::~LegoCacheSound() void LegoCacheSound::Init() { m_dsBuffer = NULL; - m_unk0x40 = NULL; + m_data = NULL; m_unk0x58 = 0; - memset(&m_unk0x59, 0, sizeof(m_unk0x59)); + memset(&m_wfx, 0, sizeof(m_wfx)); m_unk0x6a = FALSE; m_unk0x70 = 0; m_isLooping = TRUE; - m_unk0x6c = 79; + m_volume = 79; m_unk0x84 = 0; } -// STUB: LEGO1 0x10006710 +// FUNCTION: LEGO1 0x10006710 // FUNCTION: BETA10 0x10066505 -MxResult LegoCacheSound::FUN_10006710() +MxResult LegoCacheSound::Create( + LPPCMWAVEFORMAT p_pwfx, + MxString p_mediaSrcPath, + MxS32 p_volume, + MxU8* p_data, + MxU32 p_dataSize +) { - // TODO + WAVEFORMATEX wfx; + wfx.wFormatTag = p_pwfx->wf.wFormatTag; + wfx.nChannels = p_pwfx->wf.nChannels; + wfx.nSamplesPerSec = p_pwfx->wf.nSamplesPerSec; + wfx.nAvgBytesPerSec = p_pwfx->wf.nAvgBytesPerSec; + wfx.nBlockAlign = p_pwfx->wf.nBlockAlign; + wfx.wBitsPerSample = p_pwfx->wBitsPerSample; + wfx.cbSize = 0; + DSBUFFERDESC desc; memset(&desc, 0, sizeof(desc)); desc.dwSize = sizeof(desc); if (MxOmni::IsSound3D()) { - desc.dwFlags = DSBCAPS_PRIMARYBUFFER | DSBCAPS_CTRL3D; + desc.dwFlags = + DSBCAPS_STATIC | DSBCAPS_LOCSOFTWARE | DSBCAPS_CTRL3D | DSBCAPS_CTRLFREQUENCY | DSBCAPS_CTRLVOLUME; } else { - desc.dwFlags = DSBCAPS_PRIMARYBUFFER | DSBCAPS_CTRLVOLUME; + desc.dwFlags = DSBCAPS_CTRLFREQUENCY | DSBCAPS_CTRLPAN | DSBCAPS_CTRLVOLUME; } + desc.dwBufferBytes = p_dataSize; + desc.lpwfxFormat = &wfx; + if (SoundManager()->GetDirectSound()->CreateSoundBuffer(&desc, &m_dsBuffer, NULL) != DS_OK) { return FAILURE; } + m_volume = p_volume; + + MxS32 volume = m_volume * SoundManager()->GetVolume() / 100; + MxS32 attenuation = SoundManager()->GetAttenuation(volume); + m_dsBuffer->SetVolume(attenuation); + + if (m_sound.Create(m_dsBuffer, NULL, m_volume) != SUCCESS) { + m_dsBuffer->Release(); + m_dsBuffer = NULL; + return FAILURE; + } + + if (p_data != NULL && p_dataSize != 0) { + CopyData(p_data, p_dataSize); + } + + m_unk0x48 = FUN_10006d80(p_mediaSrcPath); + m_wfx = *p_pwfx; return SUCCESS; } +// FUNCTION: LEGO1 0x100068e0 +// FUNCTION: BETA10 0x100667a0 +void LegoCacheSound::CopyData(MxU8* p_data, MxU32 p_dataSize) +{ + delete[] m_data; + m_dataSize = p_dataSize; + m_data = new MxU8[m_dataSize]; + memcpy(m_data, p_data, m_dataSize); +} + // FUNCTION: LEGO1 0x10006920 void LegoCacheSound::Destroy() { @@ -65,7 +110,7 @@ void LegoCacheSound::Destroy() m_dsBuffer = NULL; } - delete m_unk0x40; + delete[] m_data; Init(); } @@ -81,7 +126,7 @@ MxResult LegoCacheSound::FUN_10006a30(const char* p_str, MxBool) { // TODO // gets param2 from FUN_1003db10 - if (!m_unk0x40 && !m_unk0x44) { + if (m_data == NULL && m_dataSize == 0) { return FAILURE; } @@ -102,8 +147,8 @@ void LegoCacheSound::FUN_10006b80() m_unk0x6a = FALSE; m_sound.Reset(); - if (m_string0x74.GetLength() != 0) { - m_string0x74 = ""; + if (m_unk0x74.GetLength() != 0) { + m_unk0x74 = ""; } } @@ -125,8 +170,8 @@ void LegoCacheSound::FUN_10006be0() if (dwStatus == 0) { m_dsBuffer->Stop(); m_sound.Reset(); - if (m_string0x74.GetLength() != 0) { - m_string0x74 = ""; + if (m_unk0x74.GetLength() != 0) { + m_unk0x74 = ""; } m_unk0x58 = 0; @@ -134,7 +179,7 @@ void LegoCacheSound::FUN_10006be0() } } - if (m_string0x74.GetLength() != 0 && !m_unk0x84) { + if (m_unk0x74.GetLength() != 0 && !m_unk0x84) { if (!m_sound.UpdatePosition(m_dsBuffer)) { if (m_unk0x6a) { return; @@ -160,3 +205,36 @@ void LegoCacheSound::SetDistance(MxS32 p_min, MxS32 p_max) void LegoCacheSound::FUN_10006cd0(undefined4, undefined4) { } + +// FUNCTION: LEGO1 0x10006d80 +// FUNCTION: BETA10 0x100670e7 +MxString LegoCacheSound::FUN_10006d80(const MxString& p_str) +{ + // TODO: Clean up code + char* str = p_str.GetData(); + MxU32 length = strlen(str); + + char* local28 = str + length; + char* local14 = local28; + char* pVar1 = local28; + + do { + local14 = pVar1; + pVar1 = local14 + -1; + + if (str == local14) { + break; + } + + if (*pVar1 == '.') { + local28 = pVar1; + } + } while (*pVar1 != '\\'); + + local14 = pVar1; + + MxString local24; + local14++; + *local28 = '\0'; + return local24 = local14; +} diff --git a/LEGO1/lego/legoomni/src/audio/legoloadcachesoundpresenter.cpp b/LEGO1/lego/legoomni/src/audio/legoloadcachesoundpresenter.cpp index 7bf31340..a0a66e89 100644 --- a/LEGO1/lego/legoomni/src/audio/legoloadcachesoundpresenter.cpp +++ b/LEGO1/lego/legoomni/src/audio/legoloadcachesoundpresenter.cpp @@ -4,6 +4,7 @@ #include "legocachsound.h" #include "legosoundmanager.h" #include "misc.h" +#include "mxdssound.h" #include "mxdssubscriber.h" #include "mxstreamchunk.h" #include "mxwavepresenter.h" @@ -25,50 +26,71 @@ LegoLoadCacheSoundPresenter::~LegoLoadCacheSoundPresenter() // FUNCTION: LEGO1 0x100184e0 void LegoLoadCacheSoundPresenter::Init() { - this->m_unk0x70 = NULL; - this->m_unk0x78 = 0; - this->m_unk0x7c = 0; + m_data = NULL; + m_dataSize = 0; + m_unk0x7c = FALSE; } // FUNCTION: LEGO1 0x100184f0 void LegoLoadCacheSoundPresenter::Destroy(MxBool p_fromDestructor) { - delete[] this->m_unk0x70; + delete[] m_data; MxWavePresenter::Destroy(p_fromDestructor); } // FUNCTION: LEGO1 0x10018510 +// FUNCTION: BETA10 0x1008c305 void LegoLoadCacheSoundPresenter::ReadyTickle() { MxStreamChunk* chunk = NextChunk(); if (chunk) { WaveFormat* header = (WaveFormat*) chunk->GetData(); - m_unk0x78 = 0; + m_dataSize = 0; MxU8* data = new MxU8[header->m_dataSize]; - m_unk0x70 = data; - m_unk0x74 = data; + m_data = data; + m_pData = data; - m_cacheSound = new LegoCacheSound; - memcpy(&m_pcmWaveFormat, &header->m_pcmWaveFormat, sizeof(m_pcmWaveFormat)); + m_cacheSound = new LegoCacheSound(); + m_pcmWaveFormat = header->m_pcmWaveFormat; m_subscriber->FreeDataChunk(chunk); ProgressTickleState(e_streaming); } } -// STUB: LEGO1 0x100185f0 +// FUNCTION: LEGO1 0x100185f0 +// FUNCTION: BETA10 0x1008c48f void LegoLoadCacheSoundPresenter::StreamingTickle() { - // TODO - EndAction(); + MxStreamChunk* chunk = NextChunk(); + + if (chunk) { + if (chunk->GetChunkFlags() & DS_CHUNK_END_OF_STREAM) { + m_cacheSound->Create( + &m_pcmWaveFormat, + ((MxDSSound*) m_action)->GetMediaSrcPath(), + ((MxDSSound*) m_action)->GetVolume(), + m_data + 2, + m_dataSize - 2 + ); + ProgressTickleState(e_done); + } + else { + memcpy(m_pData, chunk->GetData(), chunk->GetLength()); + m_dataSize += chunk->GetLength(); + m_pData += chunk->GetLength(); + } + + m_subscriber->FreeDataChunk(chunk); + } } // FUNCTION: LEGO1 0x100186f0 void LegoLoadCacheSoundPresenter::DoneTickle() { - if (m_unk0x7c != 0) { + if (m_unk0x7c) { EndAction(); } } @@ -80,7 +102,7 @@ MxResult LegoLoadCacheSoundPresenter::PutData() if (m_currentTickleState == e_done) { m_cacheSound = SoundManager()->GetCacheSoundManager()->ManageSoundEntry(m_cacheSound); - m_unk0x7c = 1; + m_unk0x7c = TRUE; } m_criticalSection.Leave(); diff --git a/LEGO1/omni/include/mxdsmediaaction.h b/LEGO1/omni/include/mxdsmediaaction.h index 9b5f8604..ec393c05 100644 --- a/LEGO1/omni/include/mxdsmediaaction.h +++ b/LEGO1/omni/include/mxdsmediaaction.h @@ -42,6 +42,9 @@ public: void CopyMediaSrcPath(const char* p_mediaSrcPath); + // FUNCTION: LEGO1 0x100186e0 + inline const char* GetMediaSrcPath() { return m_mediaSrcPath; } + // FUNCTION: BETA10 0x1013c2e0 inline MxS32 GetFramesPerSecond() const { return m_framesPerSecond; } diff --git a/LEGO1/omni/include/mxdssound.h b/LEGO1/omni/include/mxdssound.h index c406ba92..bd4f7c6b 100644 --- a/LEGO1/omni/include/mxdssound.h +++ b/LEGO1/omni/include/mxdssound.h @@ -36,8 +36,8 @@ public: // MxDSSound::`scalar deleting destructor' private: - MxU32 m_sizeOnDisk; - MxS32 m_volume; // 0xbc + MxU32 m_sizeOnDisk; // 0xb8 + MxS32 m_volume; // 0xbc }; #endif // MXDSSOUND_H diff --git a/LEGO1/omni/src/audio/mxwavepresenter.cpp b/LEGO1/omni/src/audio/mxwavepresenter.cpp index 80e52dd1..caac77cc 100644 --- a/LEGO1/omni/src/audio/mxwavepresenter.cpp +++ b/LEGO1/omni/src/audio/mxwavepresenter.cpp @@ -299,8 +299,8 @@ void MxWavePresenter::SetVolume(MxS32 p_volume) m_volume = p_volume; if (m_dsBuffer != NULL) { MxS32 volume = p_volume * MxOmni::GetInstance()->GetSoundManager()->GetVolume() / 100; - MxS32 otherVolume = MxOmni::GetInstance()->GetSoundManager()->GetAttenuation(volume); - m_dsBuffer->SetVolume(otherVolume); + MxS32 attenuation = MxOmni::GetInstance()->GetSoundManager()->GetAttenuation(volume); + m_dsBuffer->SetVolume(attenuation); } m_criticalSection.Leave(); From 828b35e9d22c7a17f7af4906049b56e0b1f4c789 Mon Sep 17 00:00:00 2001 From: Christian Semmler Date: Sun, 2 Jun 2024 11:09:09 -0400 Subject: [PATCH 9/9] Implement/match LegoCacheSound::Play and Lego3DSound::FUN_10011a60 (#987) * Implement/match LegoCacheSound::Play and Lego3DSound::FUN_10011a60 * Update names * Update --- LEGO1/lego/legoomni/include/lego3dsound.h | 1 + .../legoomni/include/legocachesoundmanager.h | 7 +- LEGO1/lego/legoomni/include/legocachsound.h | 12 +-- LEGO1/lego/legoomni/src/audio/lego3dsound.cpp | 96 ++++++++++++++++++- .../src/audio/legocachesoundmanager.cpp | 41 ++++---- .../lego/legoomni/src/audio/legocachsound.cpp | 81 ++++++++++++---- LEGO1/lego/legoomni/src/entity/legoactor.cpp | 2 +- LEGO1/lego/legoomni/src/entity/legoworld.cpp | 2 +- .../legoomni/src/paths/legoextraactor.cpp | 4 +- .../lego/legoomni/src/paths/legopathactor.cpp | 2 +- 10 files changed, 193 insertions(+), 55 deletions(-) diff --git a/LEGO1/lego/legoomni/include/lego3dsound.h b/LEGO1/lego/legoomni/include/lego3dsound.h index e52c249b..dc7840a3 100644 --- a/LEGO1/lego/legoomni/include/lego3dsound.h +++ b/LEGO1/lego/legoomni/include/lego3dsound.h @@ -20,6 +20,7 @@ public: MxResult Create(LPDIRECTSOUNDBUFFER p_directSoundBuffer, const char* p_name, MxS32 p_volume); void Destroy(); MxU32 UpdatePosition(LPDIRECTSOUNDBUFFER p_directSoundBuffer); + void FUN_10011a60(LPDIRECTSOUNDBUFFER p_directSoundBuffer, const char* p_name); void Reset(); MxS32 SetDistance(MxS32 p_min, MxS32 p_max); diff --git a/LEGO1/lego/legoomni/include/legocachesoundmanager.h b/LEGO1/lego/legoomni/include/legocachesoundmanager.h index 8297b416..0856aa70 100644 --- a/LEGO1/lego/legoomni/include/legocachesoundmanager.h +++ b/LEGO1/lego/legoomni/include/legocachesoundmanager.h @@ -56,11 +56,12 @@ public: LegoCacheSound* FindSoundByKey(const char* p_key); LegoCacheSound* ManageSoundEntry(LegoCacheSound* p_sound); - LegoCacheSound* FUN_1003dae0(const char* p_one, const char* p_two, MxBool p_three); - LegoCacheSound* FUN_1003db10(LegoCacheSound* p_one, const char* p_two, MxBool p_three); - void FUN_1003dc40(LegoCacheSound** p_und); + LegoCacheSound* Play(const char* p_key, const char* p_name, MxBool p_looping); + void Destroy(LegoCacheSound*& p_sound); private: + LegoCacheSound* Play(LegoCacheSound* p_sound, const char* p_name, MxBool p_looping); + Set100d6b4c m_set; // 0x04 List100d6b4c m_list; // 0x14 }; diff --git a/LEGO1/lego/legoomni/include/legocachsound.h b/LEGO1/lego/legoomni/include/legocachsound.h index 10d0108b..b80ded36 100644 --- a/LEGO1/lego/legoomni/include/legocachsound.h +++ b/LEGO1/lego/legoomni/include/legocachsound.h @@ -37,10 +37,10 @@ public: virtual void FUN_10006cd0(undefined4, undefined4); // vtable+0x1c inline const MxString& GetUnknown0x48() const { return m_unk0x48; } - inline const undefined GetUnknown0x58() const { return m_unk0x58; } + inline const MxBool GetUnknown0x58() const { return m_unk0x58; } - LegoCacheSound* FUN_10006960(); - MxResult FUN_10006a30(const char* p_str, MxBool); + LegoCacheSound* Clone(); + MxResult Play(const char* p_name, MxBool p_looping); void FUN_10006b80(); void FUN_10006be0(); void SetDistance(MxS32 p_min, MxS32 p_max); @@ -59,12 +59,12 @@ private: MxU8* m_data; // 0x40 MxU32 m_dataSize; // 0x44 MxString m_unk0x48; // 0x48 - undefined m_unk0x58; // 0x58 + MxBool m_unk0x58; // 0x58 PCMWAVEFORMAT m_wfx; // 0x59 - MxBool m_isLooping; // 0x69 + MxBool m_looping; // 0x69 MxBool m_unk0x6a; // 0x6a MxS32 m_volume; // 0x6c - undefined m_unk0x70; // 0x70 + MxBool m_unk0x70; // 0x70 MxString m_unk0x74; // 0x74 undefined m_unk0x84; // 0x84 }; diff --git a/LEGO1/lego/legoomni/src/audio/lego3dsound.cpp b/LEGO1/lego/legoomni/src/audio/lego3dsound.cpp index f2da166c..508cd395 100644 --- a/LEGO1/lego/legoomni/src/audio/lego3dsound.cpp +++ b/LEGO1/lego/legoomni/src/audio/lego3dsound.cpp @@ -151,7 +151,6 @@ MxU32 Lego3DSound::UpdatePosition(LPDIRECTSOUNDBUFFER p_directSoundBuffer) } else { MxS32 newVolume = m_volume; - if (distance < 100.0f) { newVolume = m_volume; } @@ -184,6 +183,101 @@ MxU32 Lego3DSound::UpdatePosition(LPDIRECTSOUNDBUFFER p_directSoundBuffer) return updated; } +// FUNCTION: LEGO1 0x10011a60 +// FUNCTION: BETA10 0x10039d04 +void Lego3DSound::FUN_10011a60(LPDIRECTSOUNDBUFFER p_directSoundBuffer, const char* p_name) +{ + assert(p_directSoundBuffer); + + if (p_name == NULL) { + if (m_ds3dBuffer != NULL) { + m_ds3dBuffer->SetMode(DS3DMODE_DISABLE, DS3D_IMMEDIATE); + } + } + else { + if (CharacterManager()->IsActor(p_name)) { + m_roi = CharacterManager()->GetActorROI(p_name, TRUE); + m_enabled = m_isActor = TRUE; + } + else { + m_roi = FindROI(p_name); + } + + if (m_roi == NULL) { + m_roi = CharacterManager()->CreateAutoROI(NULL, p_name, TRUE); + + if (m_roi != NULL) { + m_enabled = TRUE; + } + } + + if (m_roi == NULL) { + return; + } + + if (m_isActor) { + m_positionROI = m_roi->FindChildROI("head", m_roi); + } + else { + m_positionROI = m_roi; + } + + if (m_ds3dBuffer != NULL) { + DWORD dwMode; + m_ds3dBuffer->GetMode(&dwMode); + + if (dwMode & DS3DMODE_DISABLE) { + m_ds3dBuffer->SetMode(DS3DMODE_NORMAL, DS3D_IMMEDIATE); + } + + const float* position = m_positionROI->GetWorldPosition(); + m_ds3dBuffer->SetPosition(position[0], position[1], position[2], DS3D_IMMEDIATE); + } + else { + const float* position = m_positionROI->GetWorldPosition(); + ViewROI* pov = VideoManager()->GetViewROI(); + + if (pov != NULL) { + const float* povPosition = pov->GetWorldPosition(); + float distance = DISTSQRD3(povPosition, position); + + MxS32 newVolume; + if (distance < 100.0f) { + newVolume = m_volume; + } + else if (distance < 400.0f) { + newVolume = m_volume * 0.4; + } + else if (distance < 3600.0f) { + newVolume = m_volume * 0.1; + } + else { + newVolume = 0; + } + + newVolume = newVolume * SoundManager()->GetVolume() / 100; + newVolume = SoundManager()->GetAttenuation(newVolume); + p_directSoundBuffer->SetVolume(newVolume); + } + } + + LegoEntity* entity = m_roi->GetEntity(); + if (entity != NULL && entity->IsA("LegoActor") && ((LegoActor*) entity)->GetSoundFrequencyFactor() != 0.0f) { + m_actor = ((LegoActor*) entity); + } + + p_directSoundBuffer->GetFrequency(&m_dwFrequency); + + if (m_actor != NULL) { + m_frequencyFactor = m_actor->GetSoundFrequencyFactor(); + + if (m_frequencyFactor != 0.0) { + p_directSoundBuffer->SetFrequency(m_frequencyFactor * m_dwFrequency); + } + } + } +} + // FUNCTION: LEGO1 0x10011ca0 void Lego3DSound::Reset() { diff --git a/LEGO1/lego/legoomni/src/audio/legocachesoundmanager.cpp b/LEGO1/lego/legoomni/src/audio/legocachesoundmanager.cpp index 6628246b..36445ce7 100644 --- a/LEGO1/lego/legoomni/src/audio/legocachesoundmanager.cpp +++ b/LEGO1/lego/legoomni/src/audio/legocachesoundmanager.cpp @@ -104,53 +104,48 @@ LegoCacheSound* LegoCacheSoundManager::ManageSoundEntry(LegoCacheSound* p_sound) } // FUNCTION: LEGO1 0x1003dae0 -LegoCacheSound* LegoCacheSoundManager::FUN_1003dae0(const char* p_one, const char* p_two, MxBool p_three) +LegoCacheSound* LegoCacheSoundManager::Play(const char* p_key, const char* p_name, MxBool p_looping) { - // DECOMP: Second parameter is LegoRoi::m_name (0xe4) - return FUN_1003db10(FindSoundByKey(p_one), p_two, p_three); + return Play(FindSoundByKey(p_key), p_name, p_looping); } // FUNCTION: LEGO1 0x1003db10 -LegoCacheSound* LegoCacheSoundManager::FUN_1003db10(LegoCacheSound* p_one, const char* p_two, MxBool p_three) +LegoCacheSound* LegoCacheSoundManager::Play(LegoCacheSound* p_sound, const char* p_name, MxBool p_looping) { - if (!p_one) { + if (!p_sound) { return NULL; } - if (p_one->GetUnknown0x58()) { - LegoCacheSound* result = p_one->FUN_10006960(); + if (p_sound->GetUnknown0x58()) { + LegoCacheSound* clone = p_sound->Clone(); - if (result) { - LegoCacheSound* t = ManageSoundEntry(result); - t->FUN_10006a30(p_two, p_three); - return t; + if (clone) { + LegoCacheSound* sound = ManageSoundEntry(clone); + sound->Play(p_name, p_looping); + return sound; } } else { - p_one->FUN_10006a30(p_two, p_three); - return p_one; + p_sound->Play(p_name, p_looping); + return p_sound; } return NULL; } // FUNCTION: LEGO1 0x1003dc40 -void LegoCacheSoundManager::FUN_1003dc40(LegoCacheSound** p_und) +void LegoCacheSoundManager::Destroy(LegoCacheSound*& p_sound) { - // Called during LegoWorld::Destroy like this: - // SoundManager()->GetCacheSoundManager()->FUN_1003dc40(&sound); - // LegoCacheSound*& p_sound? - #ifdef COMPAT_MODE Set100d6b4c::iterator setIter; for (setIter = m_set.begin(); setIter != m_set.end(); setIter++) { #else for (Set100d6b4c::iterator setIter = m_set.begin(); setIter != m_set.end(); setIter++) { #endif - if ((*setIter).GetSound() == *p_und) { - (*p_und)->FUN_10006b80(); + if ((*setIter).GetSound() == p_sound) { + p_sound->FUN_10006b80(); - delete *p_und; + delete p_sound; m_set.erase(setIter); return; } @@ -167,8 +162,8 @@ void LegoCacheSoundManager::FUN_1003dc40(LegoCacheSound** p_und) } LegoCacheSound* sound = (*listIter).GetSound(); - if (sound == *p_und) { - (*p_und)->FUN_10006b80(); + if (sound == p_sound) { + p_sound->FUN_10006b80(); delete sound; m_list.erase(listIter); diff --git a/LEGO1/lego/legoomni/src/audio/legocachsound.cpp b/LEGO1/lego/legoomni/src/audio/legocachsound.cpp index 19ba06f3..457e51f4 100644 --- a/LEGO1/lego/legoomni/src/audio/legocachsound.cpp +++ b/LEGO1/lego/legoomni/src/audio/legocachsound.cpp @@ -23,11 +23,11 @@ void LegoCacheSound::Init() { m_dsBuffer = NULL; m_data = NULL; - m_unk0x58 = 0; + m_unk0x58 = FALSE; memset(&m_wfx, 0, sizeof(m_wfx)); m_unk0x6a = FALSE; - m_unk0x70 = 0; - m_isLooping = TRUE; + m_unk0x70 = FALSE; + m_looping = TRUE; m_volume = 79; m_unk0x84 = 0; } @@ -114,22 +114,69 @@ void LegoCacheSound::Destroy() Init(); } -// STUB: LEGO1 0x10006960 -LegoCacheSound* LegoCacheSound::FUN_10006960() +// FUNCTION: LEGO1 0x10006960 +// FUNCTION: BETA10 0x100668cf +LegoCacheSound* LegoCacheSound::Clone() { - // TODO + LegoCacheSound* pnew = new LegoCacheSound(); + + if (pnew->Create(&m_wfx, m_unk0x48, m_volume, m_data, m_dataSize) == SUCCESS) { + return pnew; + } + + delete pnew; return NULL; } -// STUB: LEGO1 0x10006a30 -MxResult LegoCacheSound::FUN_10006a30(const char* p_str, MxBool) +// FUNCTION: LEGO1 0x10006a30 +// FUNCTION: BETA10 0x10066a23 +MxResult LegoCacheSound::Play(const char* p_name, MxBool p_looping) { - // TODO - // gets param2 from FUN_1003db10 - if (m_data == NULL && m_dataSize == 0) { + if (m_data == NULL || m_dataSize == 0) { return FAILURE; } + m_unk0x6a = FALSE; + m_sound.FUN_10011a60(m_dsBuffer, p_name); + + if (p_name != NULL) { + m_unk0x74 = p_name; + } + + DWORD dwStatus; + m_dsBuffer->GetStatus(&dwStatus); + + if (dwStatus == DSBSTATUS_BUFFERLOST) { + m_dsBuffer->Restore(); + m_dsBuffer->GetStatus(&dwStatus); + } + + if (dwStatus != DSBSTATUS_BUFFERLOST) { + LPVOID pvAudioPtr1, pvAudioPtr2; + DWORD dwAudioBytes1, dwAudioBytes2; + + if (m_dsBuffer->Lock(0, m_dataSize, &pvAudioPtr1, &dwAudioBytes1, &pvAudioPtr2, &dwAudioBytes2, 0) == DS_OK) { + memcpy(pvAudioPtr1, m_data, dwAudioBytes1); + + if (dwAudioBytes2 != 0) { + memcpy(pvAudioPtr2, m_data + dwAudioBytes1, dwAudioBytes2); + } + + m_dsBuffer->Unlock(pvAudioPtr1, dwAudioBytes1, pvAudioPtr2, dwAudioBytes2); + m_dsBuffer->SetCurrentPosition(0); + m_dsBuffer->Play(0, 0, p_looping); + } + } + + if (p_looping == FALSE) { + m_looping = FALSE; + } + else { + m_looping = TRUE; + } + + m_unk0x58 = TRUE; + m_unk0x70 = TRUE; return SUCCESS; } @@ -137,13 +184,13 @@ MxResult LegoCacheSound::FUN_10006a30(const char* p_str, MxBool) void LegoCacheSound::FUN_10006b80() { DWORD dwStatus; - m_dsBuffer->GetStatus(&dwStatus); + if (dwStatus) { m_dsBuffer->Stop(); } - m_unk0x58 = 0; + m_unk0x58 = FALSE; m_unk0x6a = FALSE; m_sound.Reset(); @@ -155,7 +202,7 @@ void LegoCacheSound::FUN_10006b80() // FUNCTION: LEGO1 0x10006be0 void LegoCacheSound::FUN_10006be0() { - if (!m_isLooping) { + if (!m_looping) { DWORD dwStatus; m_dsBuffer->GetStatus(&dwStatus); @@ -164,7 +211,7 @@ void LegoCacheSound::FUN_10006be0() return; } - m_unk0x70 = 0; + m_unk0x70 = FALSE; } if (dwStatus == 0) { @@ -174,7 +221,7 @@ void LegoCacheSound::FUN_10006be0() m_unk0x74 = ""; } - m_unk0x58 = 0; + m_unk0x58 = FALSE; return; } } @@ -189,7 +236,7 @@ void LegoCacheSound::FUN_10006be0() m_unk0x6a = TRUE; } else if (m_unk0x6a) { - m_dsBuffer->Play(0, 0, m_isLooping); + m_dsBuffer->Play(0, 0, m_looping); m_unk0x6a = FALSE; } } diff --git a/LEGO1/lego/legoomni/src/entity/legoactor.cpp b/LEGO1/lego/legoomni/src/entity/legoactor.cpp index 6ab78b63..d7d79e1a 100644 --- a/LEGO1/lego/legoomni/src/entity/legoactor.cpp +++ b/LEGO1/lego/legoomni/src/entity/legoactor.cpp @@ -103,7 +103,7 @@ void LegoActor::ParseAction(char* p_extra) } if (KeyValueStringParse(value, g_strSOUND, p_extra)) { - m_sound = SoundManager()->GetCacheSoundManager()->FUN_1003dae0(value, GetROI()->GetName(), TRUE); + m_sound = SoundManager()->GetCacheSoundManager()->Play(value, GetROI()->GetName(), TRUE); } if (KeyValueStringParse(value, g_strMUTE, p_extra)) { diff --git a/LEGO1/lego/legoomni/src/entity/legoworld.cpp b/LEGO1/lego/legoomni/src/entity/legoworld.cpp index fcec9fdd..fecff1de 100644 --- a/LEGO1/lego/legoomni/src/entity/legoworld.cpp +++ b/LEGO1/lego/legoomni/src/entity/legoworld.cpp @@ -204,7 +204,7 @@ void LegoWorld::Destroy(MxBool p_fromDestructor) while (cursor.First(sound)) { cursor.Detach(); - SoundManager()->GetCacheSoundManager()->FUN_1003dc40(&sound); + SoundManager()->GetCacheSoundManager()->Destroy(sound); } delete m_cacheSoundList; diff --git a/LEGO1/lego/legoomni/src/paths/legoextraactor.cpp b/LEGO1/lego/legoomni/src/paths/legoextraactor.cpp index e1eeedbe..f0e2e69b 100644 --- a/LEGO1/lego/legoomni/src/paths/legoextraactor.cpp +++ b/LEGO1/lego/legoomni/src/paths/legoextraactor.cpp @@ -233,7 +233,7 @@ MxResult LegoExtraActor::VTable0x94(LegoPathActor* p_actor, MxBool p_bool) m_roi->FUN_100a58f0(matrix2); m_roi->VTable0x14(); FUN_1002ad8a(); - SoundManager()->GetCacheSoundManager()->FUN_1003dae0("crash5", m_roi->GetName(), FALSE); + SoundManager()->GetCacheSoundManager()->Play("crash5", m_roi->GetName(), FALSE); m_scheduledTime = Timer()->GetTime() + m_disAnim->GetDuration(); m_prevWorldSpeed = m_worldSpeed; VTable0xc4(); @@ -245,7 +245,7 @@ MxResult LegoExtraActor::VTable0x94(LegoPathActor* p_actor, MxBool p_bool) if (b) { LegoROI* roi = m_roi; - SoundManager()->GetCacheSoundManager()->FUN_1003dae0("crash5", m_roi->GetName(), FALSE); + SoundManager()->GetCacheSoundManager()->Play("crash5", m_roi->GetName(), FALSE); VTable0xc4(); m_state = 0x102; Mx3DPointFloat dir = p_actor->GetWorldDirection(); diff --git a/LEGO1/lego/legoomni/src/paths/legopathactor.cpp b/LEGO1/lego/legoomni/src/paths/legopathactor.cpp index 430914b2..454f04fb 100644 --- a/LEGO1/lego/legoomni/src/paths/legopathactor.cpp +++ b/LEGO1/lego/legoomni/src/paths/legopathactor.cpp @@ -278,7 +278,7 @@ MxS32 LegoPathActor::VTable0x8c(float p_time, Matrix4& p_transform) const char* var = VariableTable()->GetVariable(g_strHIT_WALL_SOUND); if (var && var[0] != 0) { - SoundManager()->GetCacheSoundManager()->FUN_1003dae0(var, NULL, FALSE); + SoundManager()->GetCacheSoundManager()->Play(var, NULL, FALSE); } }