Rename c_bit5 to c_ctrl in LegoInputManager, change m_unk0x6c to m_isAccelerating and clear some local unknowns (#1458)

This commit is contained in:
Florian Kaiser
2025-05-09 16:40:00 +02:00
committed by GitHub
parent 711134b3b8
commit 3811d61ea4
4 changed files with 27 additions and 19 deletions

View File

@@ -135,7 +135,7 @@ LegoNavController::LegoNavController()
m_rotationalAccel = 0.0f;
m_trackDefault = FALSE;
m_unk0x5d = FALSE;
m_unk0x6c = FALSE;
m_isAccelerating = FALSE;
m_unk0x64 = 0.0f;
m_unk0x68 = 0.0f;
m_unk0x60 = 0.0f;
@@ -564,8 +564,8 @@ MxResult LegoNavController::ProcessJoystickInput(MxBool& p_und)
// FUNCTION: LEGO1 0x100558b0
MxResult LegoNavController::ProcessKeyboardInput()
{
MxBool bool1 = FALSE;
MxBool bool2 = FALSE;
MxBool skipRotationVelAndAccelCalc = FALSE;
MxBool skipLinearVelAndAccelCalc = FALSE;
LegoInputManager* inputManager = LegoOmni::GetInstance()->GetInputManager();
MxU32 keyFlags;
@@ -574,18 +574,18 @@ MxResult LegoNavController::ProcessKeyboardInput()
}
if (keyFlags == 0) {
if (m_unk0x6c) {
if (m_isAccelerating) {
m_targetRotationalVel = 0.0;
m_targetLinearVel = 0.0;
m_rotationalAccel = m_maxRotationalDeccel;
m_linearAccel = m_maxLinearDeccel;
m_unk0x6c = FALSE;
m_isAccelerating = FALSE;
}
return FAILURE;
}
m_unk0x6c = TRUE;
m_isAccelerating = TRUE;
MxS32 hMax;
switch (keyFlags & LegoInputManager::c_leftOrRight) {
@@ -598,7 +598,7 @@ MxResult LegoNavController::ProcessKeyboardInput()
default:
m_targetRotationalVel = 0.0;
m_rotationalAccel = m_maxRotationalDeccel;
bool1 = TRUE;
skipRotationVelAndAccelCalc = TRUE;
break;
}
@@ -613,23 +613,31 @@ MxResult LegoNavController::ProcessKeyboardInput()
default:
m_targetLinearVel = 0.0;
m_linearAccel = m_maxLinearDeccel;
bool2 = TRUE;
skipLinearVelAndAccelCalc = TRUE;
break;
}
MxFloat val = keyFlags & LegoInputManager::c_bit5 ? 1.0f : 4.0f;
MxFloat val2 = keyFlags & LegoInputManager::c_bit5 ? 1.0f : 2.0f;
MxFloat maxAccelDivisor = keyFlags & LegoInputManager::c_ctrl ? 1.0f : 4.0f;
MxFloat minAccelDivisor = keyFlags & LegoInputManager::c_ctrl ? 1.0f : 2.0f;
if (!bool1) {
if (!skipRotationVelAndAccelCalc) {
m_targetRotationalVel = CalculateNewTargetVel(hMax, m_hMax / 2, m_maxRotationalVel);
m_rotationalAccel =
CalculateNewAccel(hMax, m_hMax / 2, m_maxRotationalAccel / val, (int) (m_minRotationalAccel / val2));
m_rotationalAccel = CalculateNewAccel(
hMax,
m_hMax / 2,
m_maxRotationalAccel / maxAccelDivisor,
(int) (m_minRotationalAccel / minAccelDivisor)
);
}
if (!bool2) {
if (!skipLinearVelAndAccelCalc) {
m_targetLinearVel = CalculateNewTargetVel(m_vMax - vMax, m_vMax / 2, m_maxLinearVel);
m_linearAccel =
CalculateNewAccel(m_vMax - vMax, m_vMax / 2, m_maxLinearAccel / val, (int) (m_minLinearAccel / val2));
m_linearAccel = CalculateNewAccel(
m_vMax - vMax,
m_vMax / 2,
m_maxLinearAccel / maxAccelDivisor,
(int) (m_minLinearAccel / minAccelDivisor)
);
}
return SUCCESS;