diff --git a/DataSpec/DNACommon/Tweaks/ITweakGunRes.hpp b/DataSpec/DNACommon/Tweaks/ITweakGunRes.hpp index 549f77f18..bdc29dd7f 100644 --- a/DataSpec/DNACommon/Tweaks/ITweakGunRes.hpp +++ b/DataSpec/DNACommon/Tweaks/ITweakGunRes.hpp @@ -1,5 +1,7 @@ #pragma once +#include + #include "ITweak.hpp" #include "Runtime/IFactory.hpp" #include "Runtime/CPlayerState.hpp" @@ -27,10 +29,11 @@ struct ITweakGunRes : ITweak { ResId x30_powerBombExplode; /* Power, Ice, Wave, Plasma, Phazon / Beam, Ball */ - ResId x34_weapons[5][2]; - ResId x84_muzzle[5]; - ResId x94_charge[5]; - ResId xa4_auxMuzzle[5]; + using WeaponPair = std::array; + std::array x34_weapons; + std::array x84_muzzle; + std::array x94_charge; + std::array xa4_auxMuzzle; ResId xb4_grappleSegment; ResId xb8_grappleClaw; @@ -57,48 +60,54 @@ struct ITweakGunRes : ITweak { } } - const ResId* GetWeaponPair(EBeamId beam) const { - auto b = int(beam); - if (b < 0 || b > 4) + const WeaponPair& GetWeaponPair(EBeamId beam) const { + const auto b = int(beam); + if (b < 0 || b > 4) { return x34_weapons[0]; + } return x34_weapons[b]; } void ResolveResources(const urde::IFactory& factory) { - x4_gunMotion = factory.GetResourceIdByName(GetGunMotion().c_str())->id; - x8_grappleArm = factory.GetResourceIdByName(GetGrappleArm().c_str())->id; - xc_rightHand = factory.GetResourceIdByName(GetRightHand().c_str())->id; + x4_gunMotion = factory.GetResourceIdByName(GetGunMotion())->id; + x8_grappleArm = factory.GetResourceIdByName(GetGrappleArm())->id; + xc_rightHand = factory.GetResourceIdByName(GetRightHand())->id; - x10_powerBeam = factory.GetResourceIdByName(GetPowerBeam().c_str())->id; - x14_iceBeam = factory.GetResourceIdByName(GetIceBeam().c_str())->id; - x18_waveBeam = factory.GetResourceIdByName(GetWaveBeam().c_str())->id; - x1c_plasmaBeam = factory.GetResourceIdByName(GetPlasmaBeam().c_str())->id; - x20_phazonBeam = factory.GetResourceIdByName(GetPhazonBeam().c_str())->id; + x10_powerBeam = factory.GetResourceIdByName(GetPowerBeam())->id; + x14_iceBeam = factory.GetResourceIdByName(GetIceBeam())->id; + x18_waveBeam = factory.GetResourceIdByName(GetWaveBeam())->id; + x1c_plasmaBeam = factory.GetResourceIdByName(GetPlasmaBeam())->id; + x20_phazonBeam = factory.GetResourceIdByName(GetPhazonBeam())->id; - x24_holoTransition = factory.GetResourceIdByName(GetHoloTransition().c_str())->id; + x24_holoTransition = factory.GetResourceIdByName(GetHoloTransition())->id; - x28_bombSet = factory.GetResourceIdByName(GetBombSet().c_str())->id; - x2c_bombExplode = factory.GetResourceIdByName(GetBombExplode().c_str())->id; - x30_powerBombExplode = factory.GetResourceIdByName(GetPowerBombExplode().c_str())->id; + x28_bombSet = factory.GetResourceIdByName(GetBombSet())->id; + x2c_bombExplode = factory.GetResourceIdByName(GetBombExplode())->id; + x30_powerBombExplode = factory.GetResourceIdByName(GetPowerBombExplode())->id; - for (int i = 0; i < 5; ++i) - for (int j = 0; j < 2; ++j) - x34_weapons[i][j] = factory.GetResourceIdByName(GetWeapon(i, j).c_str())->id; + for (size_t i = 0; i < x34_weapons.size(); ++i) { + for (size_t j = 0; j < x34_weapons[i].size(); ++j) { + x34_weapons[i][j] = factory.GetResourceIdByName(GetWeapon(i, j != 0))->id; + } + } - for (int i = 0; i < 5; ++i) - x84_muzzle[i] = factory.GetResourceIdByName(GetMuzzleParticle(i).c_str())->id; + for (size_t i = 0; i < x84_muzzle.size(); ++i) { + x84_muzzle[i] = factory.GetResourceIdByName(GetMuzzleParticle(i))->id; + } - for (int i = 0; i < 5; ++i) - x94_charge[i] = factory.GetResourceIdByName(GetChargeParticle(i).c_str())->id; + for (size_t i = 0; i < x94_charge.size(); ++i) { + x94_charge[i] = factory.GetResourceIdByName(GetChargeParticle(i))->id; + } - for (int i = 0; i < 5; ++i) - xa4_auxMuzzle[i] = factory.GetResourceIdByName(GetAuxMuzzleParticle(i).c_str())->id; + for (size_t i = 0; i < xa4_auxMuzzle.size(); ++i) { + xa4_auxMuzzle[i] = factory.GetResourceIdByName(GetAuxMuzzleParticle(i))->id; + } - xb4_grappleSegment = factory.GetResourceIdByName(GetGrappleSegmentParticle().c_str())->id; - xb8_grappleClaw = factory.GetResourceIdByName(GetGrappleClawParticle().c_str())->id; - xbc_grappleHit = factory.GetResourceIdByName(GetGrappleHitParticle().c_str())->id; - xc0_grappleMuzzle = factory.GetResourceIdByName(GetGrappleMuzzleParticle().c_str())->id; - xc4_grappleSwoosh = factory.GetResourceIdByName(GetGrappleSwooshParticle().c_str())->id; + xb4_grappleSegment = factory.GetResourceIdByName(GetGrappleSegmentParticle())->id; + xb8_grappleClaw = factory.GetResourceIdByName(GetGrappleClawParticle())->id; + xbc_grappleHit = factory.GetResourceIdByName(GetGrappleHitParticle())->id; + xc0_grappleMuzzle = factory.GetResourceIdByName(GetGrappleMuzzleParticle())->id; + xc4_grappleSwoosh = factory.GetResourceIdByName(GetGrappleSwooshParticle())->id; } protected: diff --git a/Runtime/Weapon/CGunWeapon.cpp b/Runtime/Weapon/CGunWeapon.cpp index e3d4ffe62..1d144da87 100644 --- a/Runtime/Weapon/CGunWeapon.cpp +++ b/Runtime/Weapon/CGunWeapon.cpp @@ -76,7 +76,7 @@ CGunWeapon::CGunWeapon(CAssetId ancsId, EWeaponType type, TUniqueId playerId, EM } void CGunWeapon::AllocResPools(CPlayerState::EBeamId beam) { - const CAssetId* const wPair = g_tweakGunRes->GetWeaponPair(beam); + const auto& wPair = g_tweakGunRes->GetWeaponPair(beam); const char* const* muzzleNames = &skMuzzleNames[size_t(beam) * 2]; const char* const* frozenNames = &skFrozenNames[size_t(beam) * 2]; diff --git a/Runtime/Weapon/CPlayerGun.cpp b/Runtime/Weapon/CPlayerGun.cpp index 3467228d1..e5116ae27 100644 --- a/Runtime/Weapon/CPlayerGun.cpp +++ b/Runtime/Weapon/CPlayerGun.cpp @@ -107,8 +107,8 @@ void CPlayerGun::InitBombData() { } void CPlayerGun::InitMuzzleData() { - for (int i = 0; i < 5; ++i) { - x7c0_auxMuzzleEffects.push_back(g_SimplePool->GetObj(SObjectTag{FOURCC('PART'), g_tweakGunRes->xa4_auxMuzzle[i]})); + for (const auto muzzleID : g_tweakGunRes->xa4_auxMuzzle) { + x7c0_auxMuzzleEffects.push_back(g_SimplePool->GetObj(SObjectTag{FOURCC('PART'), muzzleID})); x800_auxMuzzleGenerators.emplace_back(std::make_unique(x7c0_auxMuzzleEffects.back())); x800_auxMuzzleGenerators.back()->SetParticleEmission(false); }