Add comments to gamepad patch to explain commented out code and magic flag numbers

This commit is contained in:
Jan 2021-09-11 17:49:58 +02:00
parent d96780a88e
commit c0a1a99d8b
2 changed files with 7 additions and 0 deletions

View File

@ -345,9 +345,11 @@ namespace Components
bool Gamepad::AimAssist_IsPlayerUsingOffhand(Game::AimAssistPlayerState* ps) bool Gamepad::AimAssist_IsPlayerUsingOffhand(Game::AimAssistPlayerState* ps)
{ {
// Check offhand flag
if ((ps->weapFlags & 2) == 0) if ((ps->weapFlags & 2) == 0)
return false; return false;
// If offhand weapon has no id we are not using one
if (!ps->weapIndex) if (!ps->weapIndex)
return false; return false;
@ -520,6 +522,7 @@ namespace Components
if (ps->weaponState >= Game::WEAPON_STUNNED_START && ps->weaponState <= Game::WEAPON_STUNNED_END) if (ps->weaponState >= Game::WEAPON_STUNNED_START && ps->weaponState <= Game::WEAPON_STUNNED_END)
return false; return false;
// The game checks for these flags. Their meaning is to be researched if necessary.
if (ps->eFlags & 0x100C00) if (ps->eFlags & 0x100C00)
return false; return false;
@ -809,7 +812,10 @@ namespace Components
auto yaw = -CL_GamepadAxisValue(gamePadIndex, Game::GPAD_VIRTAXIS_YAW); auto yaw = -CL_GamepadAxisValue(gamePadIndex, Game::GPAD_VIRTAXIS_YAW);
auto forward = CL_GamepadAxisValue(gamePadIndex, Game::GPAD_VIRTAXIS_FORWARD); auto forward = CL_GamepadAxisValue(gamePadIndex, Game::GPAD_VIRTAXIS_FORWARD);
auto side = CL_GamepadAxisValue(gamePadIndex, Game::GPAD_VIRTAXIS_SIDE); auto side = CL_GamepadAxisValue(gamePadIndex, Game::GPAD_VIRTAXIS_SIDE);
// The game implements an attack axis at this location. This axis is unused however so for this patch it was not implemented.
//auto attack = CL_GamepadAxisValue(gamePadIndex, Game::GPAD_VIRTAXIS_ATTACK); //auto attack = CL_GamepadAxisValue(gamePadIndex, Game::GPAD_VIRTAXIS_ATTACK);
auto moveScale = static_cast<float>(std::numeric_limits<char>::max()); auto moveScale = static_cast<float>(std::numeric_limits<char>::max());
if (std::fabs(side) > 0.0f || std::fabs(forward) > 0.0f) if (std::fabs(side) > 0.0f || std::fabs(forward) > 0.0f)

View File

@ -325,6 +325,7 @@ namespace Components
const auto width = text[1]; const auto width = text[1];
const auto materialNameLength = text[3]; const auto materialNameLength = text[3];
// This is how the game calculates width and height. Probably some 1 byte floating point number.
auto v9 = font->pixelHeight * (width - 16) + 16; auto v9 = font->pixelHeight * (width - 16) + 16;
auto w = ((((v9 >> 24) & 0x1F) + v9) >> 5); auto w = ((((v9 >> 24) & 0x1F) + v9) >> 5);