From f942ad6551762103093ed0cf580601fcfa1125df Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sun, 14 Jun 2020 18:58:03 -0400 Subject: [PATCH] CGameTemplate: Mark getter functions as const These don't modify internal class state, so we can mark them as const. --- src/Core/Resource/Script/CGameTemplate.cpp | 14 +++++++------- src/Core/Resource/Script/CGameTemplate.h | 14 +++++++------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/Core/Resource/Script/CGameTemplate.cpp b/src/Core/Resource/Script/CGameTemplate.cpp index bb2d5486..93f712ac 100644 --- a/src/Core/Resource/Script/CGameTemplate.cpp +++ b/src/Core/Resource/Script/CGameTemplate.cpp @@ -159,7 +159,7 @@ CScriptTemplate* CGameTemplate::TemplateByIndex(uint32 Index) return (std::next(it, Index))->second.pTemplate.get(); } -SState CGameTemplate::StateByID(uint32 StateID) +SState CGameTemplate::StateByID(uint32 StateID) const { const auto iter = mStates.find(StateID); @@ -169,19 +169,19 @@ SState CGameTemplate::StateByID(uint32 StateID) return SState(iter->first, iter->second); } -SState CGameTemplate::StateByID(const CFourCC& State) +SState CGameTemplate::StateByID(const CFourCC& State) const { return StateByID(State.ToLong()); } -SState CGameTemplate::StateByIndex(uint32 Index) +SState CGameTemplate::StateByIndex(uint32 Index) const { auto Iter = mStates.begin(); Iter = std::next(Iter, Index); return SState(Iter->first, Iter->second); } -SMessage CGameTemplate::MessageByID(uint32 MessageID) +SMessage CGameTemplate::MessageByID(uint32 MessageID) const { const auto iter = mMessages.find(MessageID); @@ -191,12 +191,12 @@ SMessage CGameTemplate::MessageByID(uint32 MessageID) return SMessage(iter->first, iter->second); } -SMessage CGameTemplate::MessageByID(const CFourCC& MessageID) +SMessage CGameTemplate::MessageByID(const CFourCC& MessageID) const { return MessageByID(MessageID.ToLong()); } -SMessage CGameTemplate::MessageByIndex(uint32 Index) +SMessage CGameTemplate::MessageByIndex(uint32 Index) const { auto Iter = mMessages.begin(); Iter = std::next(Iter, Index); @@ -225,7 +225,7 @@ IProperty* CGameTemplate::FindPropertyArchetype(const TString& kTypeName) return Path.pTemplate.get(); } -TString CGameTemplate::GetPropertyArchetypeFilePath(const TString& kTypeName) +TString CGameTemplate::GetPropertyArchetypeFilePath(const TString& kTypeName) const { const auto it = mPropertyTemplates.find(kTypeName); ASSERT(it != mPropertyTemplates.cend()); diff --git a/src/Core/Resource/Script/CGameTemplate.h b/src/Core/Resource/Script/CGameTemplate.h index bbb44d75..98ddaeff 100644 --- a/src/Core/Resource/Script/CGameTemplate.h +++ b/src/Core/Resource/Script/CGameTemplate.h @@ -94,14 +94,14 @@ public: CScriptTemplate* TemplateByID(uint32 ObjectID); CScriptTemplate* TemplateByID(const CFourCC& ObjectID); CScriptTemplate* TemplateByIndex(uint32 Index); - SState StateByID(uint32 StateID); - SState StateByID(const CFourCC& StateID); - SState StateByIndex(uint32 Index); - SMessage MessageByID(uint32 MessageID); - SMessage MessageByID(const CFourCC& MessageID); - SMessage MessageByIndex(uint32 Index); + SState StateByID(uint32 StateID) const; + SState StateByID(const CFourCC& StateID) const; + SState StateByIndex(uint32 Index) const; + SMessage MessageByID(uint32 MessageID) const; + SMessage MessageByID(const CFourCC& MessageID) const; + SMessage MessageByIndex(uint32 Index) const; IProperty* FindPropertyArchetype(const TString& kTypeName); - TString GetPropertyArchetypeFilePath(const TString& kTypeName); + TString GetPropertyArchetypeFilePath(const TString& kTypeName) const; bool RenamePropertyArchetype(const TString& kTypeName, const TString& kNewTypeName); CScriptTemplate* FindMiscTemplate(const TString& kTemplateName); TString GetGameDirectory() const;