diff --git a/Runtime/CPlayerState.cpp b/Runtime/CPlayerState.cpp index 21613c82a..534d8143c 100644 --- a/Runtime/CPlayerState.cpp +++ b/Runtime/CPlayerState.cpp @@ -11,10 +11,13 @@ #include namespace urde { -const u32 CPlayerState::PowerUpMaxValues[41] = {1, 1, 1, 1, 250, 1, 1, 8, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 14, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}; +namespace { +constexpr u32 PowerUpMaxValues[41] = { + 1, 1, 1, 1, 250, 1, 1, 8, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 14, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, +}; -const char* CPlayerState::PowerUpNames[41] = { +[[maybe_unused]] constexpr const char* PowerUpNames[41] = { "Power Beam", "Ice Beam", "Wave Beam", @@ -58,6 +61,15 @@ const char* CPlayerState::PowerUpNames[41] = { "Artifact of Newborn", }; +constexpr u32 costs[] = { + 5, 10, 10, 10, 1, +}; + +constexpr float ComboAmmoPeriods[] = { + 0.2f, 0.1f, 0.2f, 0.2f, 1.f, +}; +} // Anonymous namespace + CPlayerState::CPlayerState() : x188_staticIntf(5) { x0_24_alive = true; x24_powerups.resize(41); @@ -122,12 +134,8 @@ void CPlayerState::PutTo(CBitStreamWriter& stream) { stream.WriteEncoded(x180_scanCompletionRate.second, CBitStreamWriter::GetBitCount(0x100)); } -static const u32 costs[] = {5, 10, 10, 10, 1}; - u32 CPlayerState::GetMissileCostForAltAttack() const { return costs[u32(x8_currentBeam)]; } -static const float ComboAmmoPeriods[] = {0.2f, 0.1f, 0.2f, 0.2f, 1.f}; - float CPlayerState::GetComboFireAmmoPeriod() const { return ComboAmmoPeriods[u32(x8_currentBeam)]; } u32 CPlayerState::CalculateItemCollectionRate() const { @@ -375,6 +383,8 @@ void CPlayerState::InitializeScanTimes() { x170_scanTimes.emplace_back(state.first, 0.f); } +u32 CPlayerState::GetPowerUpMaxValue(EItemType type) { return PowerUpMaxValues[u32(type)]; } + const std::unordered_map CPlayerState::g_TypeNameMap = { {"powerbeam"sv, EItemType::PowerBeam}, {"icebeam"sv, EItemType::IceBeam}, diff --git a/Runtime/CPlayerState.hpp b/Runtime/CPlayerState.hpp index 380618e29..ead556565 100644 --- a/Runtime/CPlayerState.hpp +++ b/Runtime/CPlayerState.hpp @@ -90,8 +90,6 @@ public: private: static const std::unordered_map g_TypeNameMap; - static const u32 PowerUpMaxValues[41]; - static const char* PowerUpNames[41]; struct CPowerUp { u32 x0_amount = 0; u32 x4_capacity = 0; @@ -176,7 +174,7 @@ public: CPlayerState(); CPlayerState(CBitStreamReader& stream); void PutTo(CBitStreamWriter& stream); - static u32 GetPowerUpMaxValue(EItemType type) { return PowerUpMaxValues[u32(type)]; } + static u32 GetPowerUpMaxValue(EItemType type); static EItemType ItemNameToType(std::string_view name); bool CanTakeDamage() const { return m_canTakeDamage; } void SetCanTakeDamage(bool c) { m_canTakeDamage = c; }