CActorModelParticles: Make GetParticleDGRPTokens take a std::string_view

Same behavior, but provides a more type-safe interface. All internal
functions called within the function operate on std::string_view
anyways.
This commit is contained in:
Lioncash 2020-04-03 00:35:26 -04:00
parent 75aa359855
commit ad30f0c61c
2 changed files with 12 additions and 9 deletions

View File

@ -381,23 +381,24 @@ void CActorModelParticles::IncrementDependency(EDependency d) {
xe4_loadingDeps |= (1 << int(d));
}
constexpr std::array<const char*, 6> ParticleDGRPs{
"Effect_OnFire_DGRP", "Effect_IceBreak_DGRP", "Effect_Ash_DGRP",
"Effect_FirePop_DGRP", "Effect_Electric_DGRP", "Effect_IcePop_DGRP",
};
CActorModelParticles::Dependency CActorModelParticles::GetParticleDGRPTokens(const char* name) {
CActorModelParticles::Dependency CActorModelParticles::GetParticleDGRPTokens(std::string_view name) const {
Dependency ret = {};
TToken<CDependencyGroup> dgrp = g_SimplePool->GetObj(name);
const auto& vector = dgrp->GetObjectTagVector();
ret.x0_tokens.reserve(vector.size());
for (const SObjectTag& tag : vector)
for (const SObjectTag& tag : vector) {
ret.x0_tokens.push_back(g_SimplePool->GetObj(tag));
}
return ret;
}
void CActorModelParticles::LoadParticleDGRPs() {
for (const char* dgrp : ParticleDGRPs) {
static constexpr std::array particleDGRPs{
"Effect_OnFire_DGRP"sv, "Effect_IceBreak_DGRP"sv, "Effect_Ash_DGRP"sv,
"Effect_FirePop_DGRP"sv, "Effect_Electric_DGRP"sv, "Effect_IcePop_DGRP"sv,
};
for (const auto& dgrp : particleDGRPs) {
x50_dgrps.push_back(GetParticleDGRPTokens(dgrp));
}
}

View File

@ -2,6 +2,7 @@
#include <list>
#include <memory>
#include <string_view>
#include <utility>
#include <vector>
@ -137,7 +138,7 @@ private:
u8 xe5_justLoadedDeps = 0;
u8 xe6_loadedDeps = 0;
Dependency GetParticleDGRPTokens(const char* name);
Dependency GetParticleDGRPTokens(std::string_view name) const;
void LoadParticleDGRPs();
std::unique_ptr<CElementGen> MakeOnFireGen() const;
@ -158,6 +159,7 @@ public:
void AddStragglersToRenderer(const CStateManager& mgr);
void Update(float dt, CStateManager& mgr);
void SetupHook(TUniqueId uid);
std::list<CItem>::iterator FindSystem(TUniqueId uid);
std::list<CItem>::const_iterator FindSystem(TUniqueId uid) const;
std::list<CItem>::iterator FindOrCreateSystem(CActor& act);
void StartIce(CActor& actor);