From 0a7ccace4423a2876b803ad7dc31ded543b993f9 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sun, 5 Apr 2020 08:11:49 -0400 Subject: [PATCH] CCharacterFactory: Eliminate usages of const_cast within CreateCharacter() We can simply make this member function non-const and eliminate the need for casts like this. --- Runtime/Character/CCharacterFactory.cpp | 9 ++++----- Runtime/Character/CCharacterFactory.hpp | 2 +- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/Runtime/Character/CCharacterFactory.cpp b/Runtime/Character/CCharacterFactory.cpp index 13088c44c..c0d2e71d7 100644 --- a/Runtime/Character/CCharacterFactory.cpp +++ b/Runtime/Character/CCharacterFactory.cpp @@ -76,17 +76,16 @@ std::unique_ptr CCharacterFactory::CDummyFactory::LoadNewResourcePartSync( std::unique_ptr CCharacterFactory::CreateCharacter(int charIdx, bool loop, const TLockedToken& factory, - int defaultAnim, int drawInsts) const { + int defaultAnim, int drawInsts) { const CCharacterInfo& charInfo = x4_charInfoDB[charIdx]; const CVParamTransfer charParm(new TObjOwnerParam(&charInfo)); - TToken skinnedModel = const_cast(this)->x70_cacheResPool.GetObj( - {FourCC(drawInsts << 16), charInfo.GetModelId()}, charParm); + TToken skinnedModel = + x70_cacheResPool.GetObj({FourCC(drawInsts << 16), charInfo.GetModelId()}, charParm); std::optional> iceModel; if (charInfo.GetIceModelId().IsValid() && charInfo.GetIceSkinRulesId().IsValid()) { - iceModel.emplace(const_cast(this)->x70_cacheResPool.GetObj( - {FourCC((drawInsts << 16) | 1), charInfo.GetIceModelId()}, charParm)); + iceModel.emplace(x70_cacheResPool.GetObj({FourCC((drawInsts << 16) | 1), charInfo.GetIceModelId()}, charParm)); } return std::make_unique(x68_selfId, charInfo, defaultAnim, charIdx, loop, x14_charLayoutInfoDB[charIdx], diff --git a/Runtime/Character/CCharacterFactory.hpp b/Runtime/Character/CCharacterFactory.hpp index 7222b1be0..b1dcf44ed 100644 --- a/Runtime/Character/CCharacterFactory.hpp +++ b/Runtime/Character/CCharacterFactory.hpp @@ -68,7 +68,7 @@ public: CCharacterFactory(CSimplePool& store, const CAnimCharacterSet& ancs, CAssetId); std::unique_ptr CreateCharacter(int charIdx, bool loop, const TLockedToken& factory, - int defaultAnim, int drawInsts) const; + int defaultAnim, int drawInsts); CAssetId GetEventResourceIdForAnimResourceId(CAssetId animId) const; const CCharacterInfo& GetCharInfo(int charIdx) const { return x4_charInfoDB[charIdx]; }