mirror of https://github.com/AxioDL/metaforce.git
CPlayerState: Move arrays into an anonymous namespace where applicable
Keeps local arrays together and makes it impossible to accidentally violate the ODR.
This commit is contained in:
parent
bc285913c8
commit
f4fd182741
|
@ -11,10 +11,13 @@
|
||||||
#include <zeus/Math.hpp>
|
#include <zeus/Math.hpp>
|
||||||
|
|
||||||
namespace urde {
|
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,
|
namespace {
|
||||||
1, 1, 1, 14, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1};
|
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",
|
"Power Beam",
|
||||||
"Ice Beam",
|
"Ice Beam",
|
||||||
"Wave Beam",
|
"Wave Beam",
|
||||||
|
@ -58,6 +61,15 @@ const char* CPlayerState::PowerUpNames[41] = {
|
||||||
"Artifact of Newborn",
|
"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) {
|
CPlayerState::CPlayerState() : x188_staticIntf(5) {
|
||||||
x0_24_alive = true;
|
x0_24_alive = true;
|
||||||
x24_powerups.resize(41);
|
x24_powerups.resize(41);
|
||||||
|
@ -122,12 +134,8 @@ void CPlayerState::PutTo(CBitStreamWriter& stream) {
|
||||||
stream.WriteEncoded(x180_scanCompletionRate.second, CBitStreamWriter::GetBitCount(0x100));
|
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)]; }
|
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)]; }
|
float CPlayerState::GetComboFireAmmoPeriod() const { return ComboAmmoPeriods[u32(x8_currentBeam)]; }
|
||||||
|
|
||||||
u32 CPlayerState::CalculateItemCollectionRate() const {
|
u32 CPlayerState::CalculateItemCollectionRate() const {
|
||||||
|
@ -375,6 +383,8 @@ void CPlayerState::InitializeScanTimes() {
|
||||||
x170_scanTimes.emplace_back(state.first, 0.f);
|
x170_scanTimes.emplace_back(state.first, 0.f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
u32 CPlayerState::GetPowerUpMaxValue(EItemType type) { return PowerUpMaxValues[u32(type)]; }
|
||||||
|
|
||||||
const std::unordered_map<std::string_view, CPlayerState::EItemType> CPlayerState::g_TypeNameMap = {
|
const std::unordered_map<std::string_view, CPlayerState::EItemType> CPlayerState::g_TypeNameMap = {
|
||||||
{"powerbeam"sv, EItemType::PowerBeam},
|
{"powerbeam"sv, EItemType::PowerBeam},
|
||||||
{"icebeam"sv, EItemType::IceBeam},
|
{"icebeam"sv, EItemType::IceBeam},
|
||||||
|
|
|
@ -90,8 +90,6 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static const std::unordered_map<std::string_view, EItemType> g_TypeNameMap;
|
static const std::unordered_map<std::string_view, EItemType> g_TypeNameMap;
|
||||||
static const u32 PowerUpMaxValues[41];
|
|
||||||
static const char* PowerUpNames[41];
|
|
||||||
struct CPowerUp {
|
struct CPowerUp {
|
||||||
u32 x0_amount = 0;
|
u32 x0_amount = 0;
|
||||||
u32 x4_capacity = 0;
|
u32 x4_capacity = 0;
|
||||||
|
@ -176,7 +174,7 @@ public:
|
||||||
CPlayerState();
|
CPlayerState();
|
||||||
CPlayerState(CBitStreamReader& stream);
|
CPlayerState(CBitStreamReader& stream);
|
||||||
void PutTo(CBitStreamWriter& 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);
|
static EItemType ItemNameToType(std::string_view name);
|
||||||
bool CanTakeDamage() const { return m_canTakeDamage; }
|
bool CanTakeDamage() const { return m_canTakeDamage; }
|
||||||
void SetCanTakeDamage(bool c) { m_canTakeDamage = c; }
|
void SetCanTakeDamage(bool c) { m_canTakeDamage = c; }
|
||||||
|
|
Loading…
Reference in New Issue