From ad30f0c61cefd2716a63e303f6909dc3a42b51fb Mon Sep 17 00:00:00 2001 From: Lioncash Date: Fri, 3 Apr 2020 00:35:26 -0400 Subject: [PATCH] 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. --- Runtime/World/CActorModelParticles.cpp | 17 +++++++++-------- Runtime/World/CActorModelParticles.hpp | 4 +++- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/Runtime/World/CActorModelParticles.cpp b/Runtime/World/CActorModelParticles.cpp index fc2d17678..ceb99f7d5 100644 --- a/Runtime/World/CActorModelParticles.cpp +++ b/Runtime/World/CActorModelParticles.cpp @@ -381,23 +381,24 @@ void CActorModelParticles::IncrementDependency(EDependency d) { xe4_loadingDeps |= (1 << int(d)); } -constexpr std::array 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 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)); } } diff --git a/Runtime/World/CActorModelParticles.hpp b/Runtime/World/CActorModelParticles.hpp index 67ab400db..df191ab5d 100644 --- a/Runtime/World/CActorModelParticles.hpp +++ b/Runtime/World/CActorModelParticles.hpp @@ -2,6 +2,7 @@ #include #include +#include #include #include @@ -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 MakeOnFireGen() const; @@ -158,6 +159,7 @@ public: void AddStragglersToRenderer(const CStateManager& mgr); void Update(float dt, CStateManager& mgr); void SetupHook(TUniqueId uid); + std::list::iterator FindSystem(TUniqueId uid); std::list::const_iterator FindSystem(TUniqueId uid) const; std::list::iterator FindOrCreateSystem(CActor& act); void StartIce(CActor& actor);