mirror of https://github.com/AxioDL/metaforce.git
General: Mark a handful of deduced const variables as const explicitly
Same behavior, but makes it explicit to the reader that these are const. Prevents cases where the reader might assume that just because the variable isn't const qualified that it must be mutable, when it actually isn't.
This commit is contained in:
parent
6658be66c2
commit
5d209c8dc8
|
@ -117,7 +117,7 @@ CPersistentOptions::CPersistentOptions(CBitStreamReader& stream) {
|
|||
xd0_29_allItemsCollected = stream.ReadEncoded(1) != 0;
|
||||
xbc_autoMapperKeyState = stream.ReadEncoded(2);
|
||||
|
||||
auto& memWorlds = g_MemoryCardSys->GetMemoryWorlds();
|
||||
const auto& memWorlds = g_MemoryCardSys->GetMemoryWorlds();
|
||||
size_t cinematicCount = 0;
|
||||
for (const auto& world : memWorlds) {
|
||||
TLockedToken<CSaveWorld> saveWorld =
|
||||
|
@ -162,7 +162,7 @@ void CPersistentOptions::PutTo(CBitStreamWriter& w) const {
|
|||
w.WriteEncoded(xd0_29_allItemsCollected, 1);
|
||||
w.WriteEncoded(xbc_autoMapperKeyState, 2);
|
||||
|
||||
auto& memWorlds = g_MemoryCardSys->GetMemoryWorlds();
|
||||
const auto& memWorlds = g_MemoryCardSys->GetMemoryWorlds();
|
||||
for (const auto& world : memWorlds) {
|
||||
const TLockedToken<CSaveWorld> saveWorld =
|
||||
g_SimplePool->GetObj(SObjectTag{FOURCC('SAVW'), world.second.GetSaveWorldAssetId()});
|
||||
|
|
|
@ -132,10 +132,10 @@ void CResLoader::GetTagListForFile(const char* pakName, std::vector<SObjectTag>&
|
|||
bool CResLoader::_GetTagListForFile(std::vector<SObjectTag>& out, const std::string& path,
|
||||
const std::unique_ptr<CPakFile>& file) const {
|
||||
if (CStringExtras::CompareCaseInsensitive(file->GetPath(), path)) {
|
||||
auto& depList = file->GetDepList();
|
||||
const auto& depList = file->GetDepList();
|
||||
out.reserve(depList.size());
|
||||
for (const auto& dep : depList) {
|
||||
auto resInfo = file->GetResInfo(dep);
|
||||
const auto* const resInfo = file->GetResInfo(dep);
|
||||
out.emplace_back(resInfo->GetType(), dep);
|
||||
}
|
||||
return true;
|
||||
|
|
|
@ -187,11 +187,14 @@ void CGuiFrame::LoadWidgetsInGame(CInputStream& in, CSimplePool* sp) {
|
|||
}
|
||||
|
||||
void CGuiFrame::ProcessUserInput(const CFinalInput& input) const {
|
||||
if (input.ControllerIdx() != 0)
|
||||
if (input.ControllerIdx() != 0) {
|
||||
return;
|
||||
for (auto& widget : x2c_widgets) {
|
||||
if (widget->GetIsActive())
|
||||
}
|
||||
|
||||
for (const auto& widget : x2c_widgets) {
|
||||
if (widget->GetIsActive()) {
|
||||
widget->ProcessUserInput(input);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -33,12 +33,15 @@ void CGuiSliderGroup::StartIncreasing() {
|
|||
}
|
||||
|
||||
bool CGuiSliderGroup::TestCursorHit(const zeus::CMatrix4f& vp, const zeus::CVector2f& point) const {
|
||||
if (xcc_sliderRangeWidgets[0]->GetWidgetTypeID() != FOURCC('MODL'))
|
||||
if (xcc_sliderRangeWidgets[0]->GetWidgetTypeID() != FOURCC('MODL')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
CGuiModel* bar = static_cast<CGuiModel*>(xcc_sliderRangeWidgets[0]);
|
||||
auto& modelTok = bar->GetModel();
|
||||
if (!modelTok || !modelTok.IsLoaded())
|
||||
const auto& modelTok = bar->GetModel();
|
||||
if (!modelTok || !modelTok.IsLoaded()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const zeus::CVector3f& s0 = xcc_sliderRangeWidgets[0]->GetIdlePosition();
|
||||
const zeus::CVector3f& s1 = xcc_sliderRangeWidgets[1]->GetIdlePosition();
|
||||
|
|
|
@ -68,7 +68,7 @@ float CGuiTextSupport::GetCurrentAnimationOverAge() const {
|
|||
if (const CTextRenderBuffer* buf = GetCurrentPageRenderBuffer()) {
|
||||
if (x50_typeEnable) {
|
||||
if (x40_primStartTimes.size()) {
|
||||
auto& lastTime = x40_primStartTimes.back();
|
||||
const auto& lastTime = x40_primStartTimes.back();
|
||||
ret = std::max(ret, (buf->GetPrimitiveCount() - lastTime.second) / x58_chRate + lastTime.first);
|
||||
} else {
|
||||
ret = std::max(ret, buf->GetPrimitiveCount() / x58_chRate);
|
||||
|
|
|
@ -13,23 +13,23 @@
|
|||
namespace urde {
|
||||
|
||||
constexpr std::array BaseMenuNames{
|
||||
"BaseWidget_VisorMenu",
|
||||
"BaseWidget_BeamMenu",
|
||||
"BaseWidget_VisorMenu"sv,
|
||||
"BaseWidget_BeamMenu"sv,
|
||||
};
|
||||
|
||||
constexpr std::array TextNames{
|
||||
"TextPane_VisorMenu",
|
||||
"TextPane_BeamMenu",
|
||||
"TextPane_VisorMenu"sv,
|
||||
"TextPane_BeamMenu"sv,
|
||||
};
|
||||
|
||||
constexpr std::array BaseTitleNames{
|
||||
"basewidget_visormenutitle",
|
||||
"basewidget_beammenutitle",
|
||||
"basewidget_visormenutitle"sv,
|
||||
"basewidget_beammenutitle"sv,
|
||||
};
|
||||
|
||||
constexpr std::array ModelNames{
|
||||
"model_visor",
|
||||
"model_beam",
|
||||
"model_visor"sv,
|
||||
"model_beam"sv,
|
||||
};
|
||||
|
||||
constexpr std::array<std::array<char, 4>, 2> MenuItemOrders{{
|
||||
|
|
|
@ -326,16 +326,20 @@ void CAuxWeapon::RenderMuzzleFx() const {
|
|||
}
|
||||
|
||||
TUniqueId CAuxWeapon::HasTarget(const CStateManager& mgr) const {
|
||||
if (x74_firingBeamId == CPlayerState::EBeamId::Wave)
|
||||
if (auto* wb = static_cast<const CWaveBuster*>(mgr.GetObjectById(x70_waveBusterId)))
|
||||
if (x74_firingBeamId == CPlayerState::EBeamId::Wave) {
|
||||
if (const auto* wb = static_cast<const CWaveBuster*>(mgr.GetObjectById(x70_waveBusterId))) {
|
||||
return wb->GetHomingTargetId();
|
||||
}
|
||||
}
|
||||
return kInvalidUniqueId;
|
||||
}
|
||||
|
||||
void CAuxWeapon::SetNewTarget(TUniqueId targetId, CStateManager& mgr) {
|
||||
if (x74_firingBeamId == CPlayerState::EBeamId::Wave)
|
||||
if (auto* wb = static_cast<CWaveBuster*>(mgr.ObjectById(x70_waveBusterId)))
|
||||
if (x74_firingBeamId == CPlayerState::EBeamId::Wave) {
|
||||
if (auto* wb = static_cast<CWaveBuster*>(mgr.ObjectById(x70_waveBusterId))) {
|
||||
wb->SetNewTarget(targetId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace urde
|
||||
|
|
|
@ -1515,11 +1515,12 @@ void CPlayerGun::UpdateWeaponFire(float dt, const CPlayerState& playerState, CSt
|
|||
if (!x835_31_actorAttached) {
|
||||
x835_28_bombReady = true;
|
||||
if (x53a_powerBomb != kInvalidUniqueId && !mgr.CanCreateProjectile(x538_playerId, EWeaponType::PowerBomb, 1)) {
|
||||
auto* pb = static_cast<const CPowerBomb*>(mgr.GetObjectById(x53a_powerBomb));
|
||||
if (pb && pb->GetCurTime() <= 4.25f)
|
||||
const auto* pb = static_cast<const CPowerBomb*>(mgr.GetObjectById(x53a_powerBomb));
|
||||
if (pb && pb->GetCurTime() <= 4.25f) {
|
||||
x835_28_bombReady = false;
|
||||
else
|
||||
} else {
|
||||
x53a_powerBomb = kInvalidUniqueId;
|
||||
}
|
||||
}
|
||||
if (((pressedStates & 0x1) != 0 || x32c_chargePhase != EChargePhase::NotCharging) &&
|
||||
mgr.GetPlayerState()->HasPowerUp(CPlayerState::EItemType::MorphBallBombs)) {
|
||||
|
@ -2088,9 +2089,9 @@ void CPlayerGun::PreRender(const CStateManager& mgr, const zeus::CFrustum& frust
|
|||
}
|
||||
|
||||
void CPlayerGun::RenderEnergyDrainEffects(const CStateManager& mgr) const {
|
||||
if (TCastToConstPtr<CPlayer> player = mgr.GetObjectById(x538_playerId)) {
|
||||
if (const TCastToConstPtr<CPlayer> player = mgr.GetObjectById(x538_playerId)) {
|
||||
for (const auto& source : player->GetEnergyDrain().GetEnergyDrainSources()) {
|
||||
if (auto* metroid = CPatterned::CastTo<MP1::CMetroidBeta>(mgr.GetObjectById(source.GetEnergyDrainSourceId()))) {
|
||||
if (const auto* metroid = CPatterned::CastTo<MP1::CMetroidBeta>(mgr.GetObjectById(source.GetEnergyDrainSourceId()))) {
|
||||
metroid->RenderHitGunEffect();
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -643,7 +643,7 @@ std::optional<zeus::CAABox> CFishCloud::GetTouchBounds() const {
|
|||
|
||||
void CFishCloud::CreateBoidDeathParticle(CBoid& b) const {
|
||||
auto it = x21c_deathParticleCounts.begin();
|
||||
for (auto& p : x1f8_particleGens) {
|
||||
for (const auto& p : x1f8_particleGens) {
|
||||
p->SetParticleEmission(true);
|
||||
p->SetTranslation(b.x0_pos);
|
||||
p->ForceParticleCreation(*it);
|
||||
|
|
|
@ -1267,7 +1267,7 @@ static CAssetId UpdatePersistentScanPercent(u32 prevLogScans, u32 logScans, u32
|
|||
if (scanPercentProgStep > prevScanPercentProgStep) {
|
||||
const char* const messageResBase = UnlockMessageResBases[zeus::clamp(0, scanPercentProgStep - 1, 1)];
|
||||
const auto message = std::string(messageResBase).append(1, firstTime ? '1' : '2');
|
||||
const auto id = g_ResFactory->GetResourceIdByName(message);
|
||||
const auto* const id = g_ResFactory->GetResourceIdByName(message);
|
||||
if (id != nullptr) {
|
||||
return id->id;
|
||||
}
|
||||
|
|
|
@ -381,8 +381,8 @@ void CScriptGunTurret::SetupCollisionManager(CStateManager& mgr) {
|
|||
x49c_collisionManager->SetActive(mgr, GetActive());
|
||||
|
||||
for (int i = 0; i < x49c_collisionManager->GetNumCollisionActors(); ++i) {
|
||||
auto& desc = x49c_collisionManager->GetCollisionDescFromIndex(i);
|
||||
if (TCastToPtr<CCollisionActor> cAct = mgr.ObjectById(desc.GetCollisionActorId())) {
|
||||
const auto& desc = x49c_collisionManager->GetCollisionDescFromIndex(i);
|
||||
if (const TCastToPtr<CCollisionActor> cAct = mgr.ObjectById(desc.GetCollisionActorId())) {
|
||||
cAct->AddMaterial(EMaterialTypes::ProjectilePassthrough, mgr);
|
||||
cAct->SetMaterialFilter(CMaterialFilter::MakeIncludeExclude({EMaterialTypes::Player},
|
||||
{EMaterialTypes::Character, EMaterialTypes::NoStaticCollision, EMaterialTypes::NoPlatformCollision}));
|
||||
|
|
|
@ -53,11 +53,12 @@ void CWallWalker::AlignToFloor(CStateManager& mgr, float radius, const zeus::CVe
|
|||
zeus::CAABox aabb(newPos - margin, newPos + margin);
|
||||
CAreaCollisionCache ccache(aabb);
|
||||
CGameCollision::BuildAreaCollisionCache(mgr, ccache);
|
||||
if (x5d6_25_hasAlignSurface)
|
||||
if (x5d6_25_hasAlignSurface) {
|
||||
x5d6_25_hasAlignSurface = PointOnSurface(x568_alignNormal, newPos);
|
||||
}
|
||||
if (!x5d6_25_hasAlignSurface || !(x5d4_thinkCounter & 0x3)) {
|
||||
for (auto& leaf : ccache) {
|
||||
for (auto& node : leaf) {
|
||||
for (const auto& leaf : ccache) {
|
||||
for (const auto& node : leaf) {
|
||||
CAreaOctTree::TriListReference triArr = node.GetTriangleArray();
|
||||
for (u16 i = 0; i < triArr.GetSize(); ++i) {
|
||||
u16 triIdx = triArr.GetAt(i);
|
||||
|
|
Loading…
Reference in New Issue