From 870e8c80eefa3bd8b62fa1fed1fd5ec6d530e7f7 Mon Sep 17 00:00:00 2001 From: Phillip Stephens Date: Sat, 12 Aug 2017 22:26:14 -0700 Subject: [PATCH] Refactor ResId into CAssetId --- .idea/misc.xml | 2 +- DataSpec/DNACommon/Tweaks/ITweakGunRes.hpp | 2 +- DataSpec/DNACommon/Tweaks/ITweakPlayerRes.hpp | 2 +- DataSpec/DNAMP1/MLVL.cpp | 14 +-- Editor/ProjectResourceFactoryBase.cpp | 42 ++++---- Editor/ProjectResourceFactoryBase.hpp | 2 +- Editor/ProjectResourceFactoryMP1.cpp | 20 ++-- Editor/ProjectResourceFactoryMP1.hpp | 4 +- Runtime/Audio/CAudioSys.cpp | 8 +- Runtime/Audio/CAudioSys.hpp | 6 +- Runtime/Audio/CMidiManager.hpp | 4 +- Runtime/AutoMapper/CAutoMapper.cpp | 26 ++--- Runtime/AutoMapper/CAutoMapper.hpp | 18 ++-- Runtime/AutoMapper/CMapUniverse.cpp | 2 +- Runtime/AutoMapper/CMapUniverse.hpp | 14 +-- Runtime/AutoMapper/CMapWorld.cpp | 4 +- Runtime/AutoMapper/CMapWorld.hpp | 2 +- Runtime/AutoMapper/CMapWorldInfo.cpp | 4 +- Runtime/AutoMapper/CMapWorldInfo.hpp | 4 +- Runtime/AutoMapper/CMappableObject.cpp | 2 +- Runtime/CGameHintInfo.hpp | 10 +- Runtime/CGameOptions.cpp | 16 +-- Runtime/CGameOptions.hpp | 10 +- Runtime/CGameState.cpp | 14 +-- Runtime/CGameState.hpp | 24 ++--- Runtime/CInGameTweakManagerBase.hpp | 8 +- Runtime/CMakeLists.txt | 2 +- Runtime/CMemoryCardSys.cpp | 18 ++-- Runtime/CMemoryCardSys.hpp | 46 ++++----- Runtime/CPakFile.hpp | 10 +- Runtime/CPlayerState.cpp | 26 +++-- Runtime/CPlayerState.hpp | 12 +-- Runtime/CResFactory.hpp | 2 +- Runtime/CResLoader.cpp | 12 +-- Runtime/CResLoader.hpp | 14 +-- Runtime/CSaveWorld.hpp | 2 +- Runtime/CScannableObjectInfo.cpp | 2 +- Runtime/CScannableObjectInfo.hpp | 10 +- Runtime/CStateManager.cpp | 8 +- Runtime/CStateManager.hpp | 14 +-- Runtime/Camera/CCameraFilter.cpp | 6 +- Runtime/Camera/CCameraFilter.hpp | 8 +- Runtime/Character/CAnimData.cpp | 4 +- Runtime/Character/CAnimData.hpp | 6 +- Runtime/Character/CAnimSource.cpp | 2 +- Runtime/Character/CAnimSource.hpp | 2 +- Runtime/Character/CAnimationSet.cpp | 4 +- Runtime/Character/CAnimationSet.hpp | 4 +- Runtime/Character/CAssetFactory.cpp | 2 +- Runtime/Character/CAssetFactory.hpp | 2 +- Runtime/Character/CCharacterFactory.cpp | 14 +-- Runtime/Character/CCharacterFactory.hpp | 10 +- Runtime/Character/CCharacterInfo.hpp | 28 +++--- Runtime/Character/CFBStreamedCompression.cpp | 2 +- Runtime/Character/CFBStreamedCompression.hpp | 2 +- Runtime/Character/CModelData.cpp | 12 +-- Runtime/Character/CModelData.hpp | 16 +-- Runtime/Character/CParticleDatabase.cpp | 10 +- Runtime/Character/CParticleDatabase.hpp | 6 +- Runtime/Character/CPrimitive.hpp | 4 +- Runtime/Collision/CCollisionResponseData.cpp | 6 +- Runtime/Graphics/CSkinnedModel.cpp | 8 +- Runtime/Graphics/CSkinnedModel.hpp | 8 +- Runtime/GuiSys/CAuiEnergyBarT01.cpp | 4 +- Runtime/GuiSys/CAuiEnergyBarT01.hpp | 4 +- Runtime/GuiSys/CAuiImagePane.cpp | 4 +- Runtime/GuiSys/CAuiImagePane.hpp | 8 +- Runtime/GuiSys/CGuiFrame.cpp | 4 +- Runtime/GuiSys/CGuiFrame.hpp | 6 +- Runtime/GuiSys/CGuiModel.cpp | 6 +- Runtime/GuiSys/CGuiModel.hpp | 6 +- Runtime/GuiSys/CGuiTextPane.cpp | 2 +- Runtime/GuiSys/CGuiTextPane.hpp | 4 +- Runtime/GuiSys/CGuiTextSupport.cpp | 8 +- Runtime/GuiSys/CGuiTextSupport.hpp | 10 +- Runtime/GuiSys/CScanDisplay.cpp | 2 +- Runtime/GuiSys/CTextParser.cpp | 16 +-- Runtime/GuiSys/CTextParser.hpp | 10 +- Runtime/IFactory.hpp | 6 +- Runtime/IMain.hpp | 1 + Runtime/MP1/CArtifactDoll.cpp | 12 +-- Runtime/MP1/CArtifactDoll.hpp | 4 +- Runtime/MP1/CFaceplateDecoration.cpp | 2 +- Runtime/MP1/CFaceplateDecoration.hpp | 2 +- Runtime/MP1/CInGameGuiManager.cpp | 2 +- Runtime/MP1/CInGameGuiManager.hpp | 4 +- Runtime/MP1/CLogBookScreen.cpp | 16 +-- Runtime/MP1/CLogBookScreen.hpp | 4 +- Runtime/MP1/CMFGame.cpp | 4 +- Runtime/MP1/CMemoryCardDriver.cpp | 4 +- Runtime/MP1/CMemoryCardDriver.hpp | 10 +- Runtime/MP1/CMessageScreen.cpp | 2 +- Runtime/MP1/CMessageScreen.hpp | 2 +- Runtime/MP1/CPauseScreen.cpp | 10 +- Runtime/MP1/CPauseScreen.hpp | 2 +- Runtime/MP1/CPauseScreenBase.cpp | 2 +- Runtime/MP1/CSamusHud.cpp | 2 +- Runtime/MP1/CSamusHud.hpp | 4 +- Runtime/MP1/CSaveGameScreen.cpp | 2 +- Runtime/MP1/MP1.cpp | 2 +- Runtime/MP1/MP1.hpp | 4 +- Runtime/MP1/World/CActorContraption.cpp | 2 +- Runtime/MP1/World/CActorContraption.hpp | 4 +- Runtime/MP1/World/CBabygoth.hpp | 6 +- Runtime/MP1/World/CWarWasp.cpp | 2 +- Runtime/MP1/World/CWarWasp.hpp | 2 +- Runtime/Particle/CDecalManager.cpp | 2 +- Runtime/Particle/CDecalManager.hpp | 2 +- Runtime/Particle/CParticleDataFactory.cpp | 34 +++---- Runtime/Particle/CParticleDataFactory.hpp | 12 +-- .../Particle/CParticleElectricDataFactory.cpp | 4 +- .../Particle/CProjectileWeaponDataFactory.cpp | 8 +- Runtime/RetroTypes.cpp | 39 ++++++++ Runtime/RetroTypes.hpp | 50 +++++++--- Runtime/Weapon/CBeamInfo.hpp | 8 +- Runtime/Weapon/CFlameInfo.cpp | 2 +- Runtime/Weapon/CFlameInfo.hpp | 6 +- Runtime/Weapon/CGameProjectile.hpp | 3 + Runtime/Weapon/CGunWeapon.cpp | 2 +- Runtime/Weapon/CGunWeapon.hpp | 2 +- Runtime/Weapon/CPlasmaProjectile.hpp | 2 + Runtime/Weapon/CPlayerGun.cpp | 2 +- Runtime/Weapon/CPlayerGun.hpp | 2 +- Runtime/Weapon/CWeapon.hpp | 4 +- Runtime/World/CActor.cpp | 2 +- Runtime/World/CActor.hpp | 2 +- Runtime/World/CActorParameters.hpp | 6 +- Runtime/World/CAi.cpp | 2 +- Runtime/World/CAi.hpp | 2 +- Runtime/World/CAnimationParameters.hpp | 6 +- Runtime/World/CDestroyableRock.cpp | 2 +- Runtime/World/CDestroyableRock.hpp | 2 +- Runtime/World/CFluidPlane.cpp | 2 +- Runtime/World/CFluidPlane.hpp | 8 +- Runtime/World/CFluidPlaneCPU.cpp | 4 +- Runtime/World/CFluidPlaneCPU.hpp | 12 +-- Runtime/World/CGameArea.cpp | 8 +- Runtime/World/CGameArea.hpp | 20 ++-- Runtime/World/CMorphBall.cpp | 2 +- Runtime/World/CMorphBall.hpp | 2 +- Runtime/World/CPatternedInfo.hpp | 6 +- Runtime/World/CPlayer.cpp | 32 +++--- Runtime/World/CPlayer.hpp | 24 ++--- Runtime/World/CScannableParameters.hpp | 4 +- Runtime/World/CScriptActor.cpp | 3 +- Runtime/World/CScriptActor.hpp | 4 +- Runtime/World/CScriptAreaAttributes.cpp | 2 +- Runtime/World/CScriptAreaAttributes.hpp | 4 +- Runtime/World/CScriptBeam.cpp | 4 +- Runtime/World/CScriptCameraFilterKeyframe.cpp | 2 +- Runtime/World/CScriptCameraFilterKeyframe.hpp | 4 +- Runtime/World/CScriptDamageableTrigger.cpp | 2 +- Runtime/World/CScriptDamageableTrigger.hpp | 2 +- Runtime/World/CScriptDebris.cpp | 8 +- Runtime/World/CScriptDebris.hpp | 6 +- Runtime/World/CScriptEffect.cpp | 2 +- Runtime/World/CScriptEffect.hpp | 2 +- Runtime/World/CScriptHUDMemo.cpp | 2 +- Runtime/World/CScriptHUDMemo.hpp | 2 +- Runtime/World/CScriptMidi.cpp | 2 +- Runtime/World/CScriptMidi.hpp | 2 +- Runtime/World/CScriptSpecialFunction.cpp | 2 +- Runtime/World/CScriptSpecialFunction.hpp | 8 +- Runtime/World/CScriptSteam.cpp | 2 +- Runtime/World/CScriptSteam.hpp | 2 +- Runtime/World/CScriptStreamedMusic.cpp | 2 +- Runtime/World/CScriptWater.cpp | 25 ++--- Runtime/World/CScriptWater.hpp | 24 ++--- Runtime/World/CScriptWorldTeleporter.cpp | 18 ++-- Runtime/World/CScriptWorldTeleporter.hpp | 22 ++--- Runtime/World/CWorld.cpp | 34 +++---- Runtime/World/CWorld.hpp | 54 +++++----- Runtime/World/CWorldTransManager.cpp | 8 +- Runtime/World/CWorldTransManager.hpp | 6 +- Runtime/World/IGameArea.hpp | 4 +- Runtime/World/ScriptLoader.cpp | 98 +++++++++---------- 176 files changed, 800 insertions(+), 715 deletions(-) create mode 100644 Runtime/RetroTypes.cpp diff --git a/.idea/misc.xml b/.idea/misc.xml index 674375dd3..79b3c9483 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,4 +1,4 @@ - + \ No newline at end of file diff --git a/DataSpec/DNACommon/Tweaks/ITweakGunRes.hpp b/DataSpec/DNACommon/Tweaks/ITweakGunRes.hpp index 6f8b0c4f5..def186cb7 100644 --- a/DataSpec/DNACommon/Tweaks/ITweakGunRes.hpp +++ b/DataSpec/DNACommon/Tweaks/ITweakGunRes.hpp @@ -9,7 +9,7 @@ namespace DataSpec struct ITweakGunRes : ITweak { - using ResId = int64_t; + using ResId = urde::CAssetId; enum class EBeamId { Power, diff --git a/DataSpec/DNACommon/Tweaks/ITweakPlayerRes.hpp b/DataSpec/DNACommon/Tweaks/ITweakPlayerRes.hpp index f3d30b2ea..abe22c3c9 100644 --- a/DataSpec/DNACommon/Tweaks/ITweakPlayerRes.hpp +++ b/DataSpec/DNACommon/Tweaks/ITweakPlayerRes.hpp @@ -10,7 +10,7 @@ namespace DataSpec struct ITweakPlayerRes : ITweak { - using ResId = uint64_t; + using ResId = urde::CAssetId; using EBeamId = urde::CPlayerState::EBeamId; ResId x4_saveStationIcon; diff --git a/DataSpec/DNAMP1/MLVL.cpp b/DataSpec/DNAMP1/MLVL.cpp index 10a81ee3b..ef45afdbe 100644 --- a/DataSpec/DNAMP1/MLVL.cpp +++ b/DataSpec/DNAMP1/MLVL.cpp @@ -270,8 +270,8 @@ bool MLVL::Cook(const hecl::ProjectPath& outPath, const hecl::ProjectPath& inPat { addedPaths.insert(path.hash()); urde::SObjectTag tag = g_curSpec->BuildTagFromPath(path, btok); - if (tag.id != -1) - areaOut.deps.emplace_back(tag.id, tag.type); + if (tag.id.IsValid()) + areaOut.deps.emplace_back(tag.id.Value(), tag.type); } } } @@ -309,14 +309,14 @@ bool MLVL::Cook(const hecl::ProjectPath& outPath, const hecl::ProjectPath& inPat { addedPaths.insert(path.hash()); urde::SObjectTag tag = g_curSpec->BuildTagFromPath(path, btok); - if (tag.id != -1) - areaOut.deps.emplace_back(tag.id, tag.type); + if (tag.id.IsValid()) + areaOut.deps.emplace_back(tag.id.Value(), tag.type); } } urde::SObjectTag tag = g_curSpec->BuildTagFromPath(areaPath, btok); - if (tag.id != -1) - areaOut.deps.emplace_back(tag.id, tag.type); + if (tag.id.IsValid()) + areaOut.deps.emplace_back(tag.id.Value(), tag.type); } ++areaIdx; @@ -369,7 +369,7 @@ bool MLVL::CookMAPW(const hecl::ProjectPath& outPath, fo.writeUint32Big(1); fo.writeUint32Big(mapaTags.size()); for (const urde::SObjectTag& mapa : mapaTags) - fo.writeUint32Big(mapa.id); + fo.writeUint32Big(u32(mapa.id.Value())); int64_t rem = fo.position() % 32; if (rem) for (int64_t i=0 ; i<32-rem ; ++i) diff --git a/Editor/ProjectResourceFactoryBase.cpp b/Editor/ProjectResourceFactoryBase.cpp index 0dce7d771..78bde7854 100644 --- a/Editor/ProjectResourceFactoryBase.cpp +++ b/Editor/ProjectResourceFactoryBase.cpp @@ -11,7 +11,7 @@ static void WriteTag(athena::io::YAMLDocWriter& cacheWriter, const SObjectTag& pathTag, const hecl::ProjectPath& path) { char idStr[9]; - snprintf(idStr, 9, "%08X", uint32_t(pathTag.id)); + snprintf(idStr, 9, "%08X", uint32_t(pathTag.id.Value())); if (auto v = cacheWriter.enterSubVector(idStr)) { cacheWriter.writeString(nullptr, pathTag.type.toString().c_str()); @@ -26,7 +26,7 @@ static void WriteNameTag(athena::io::YAMLDocWriter& nameWriter, const std::string& name) { char idStr[9]; - snprintf(idStr, 9, "%08X", uint32_t(pathTag.id)); + snprintf(idStr, 9, "%08X", uint32_t(pathTag.id.Value())); nameWriter.writeString(name.c_str(), idStr); } @@ -137,7 +137,7 @@ void ProjectResourceFactoryBase::BackgroundIndexRecursiveCatalogs(const hecl::Pr static void DumpCacheAdd(const SObjectTag& pathTag, const hecl::ProjectPath& path) { fprintf(stderr, "%s %08X %s\n", - pathTag.type.toString().c_str(), uint32_t(pathTag.id), + pathTag.type.toString().c_str(), uint32_t(pathTag.id.Value()), path.getRelativePathUTF8().c_str()); } #endif @@ -466,13 +466,13 @@ CFactoryFnReturn ProjectResourceFactoryBase::BuildSync(const SObjectTag& tag, CFactoryFnReturn ret = m_factoryMgr.MakeObjectFromMemory(tag, std::move(memBuf), length, false, paramXfer, selfRef); Log.report(logvisor::Info, "sync-built %.4s %08X", - tag.type.toString().c_str(), u32(tag.id)); + tag.type.toString().c_str(), u32(tag.id.Value())); return ret; } CFactoryFnReturn ret = m_factoryMgr.MakeObject(tag, *fr, paramXfer, selfRef); Log.report(logvisor::Info, "sync-built %.4s %08X", - tag.type.toString().c_str(), u32(tag.id)); + tag.type.toString().c_str(), u32(tag.id.Value())); return ret; } @@ -681,7 +681,7 @@ std::unique_ptr ProjectResourceFactoryBase::Build(const urde::SObjec const urde::CVParamTransfer& paramXfer, CObjectReference* selfRef) { - if (tag.id == kInvalidResId || !tag.id) + if (!tag.id.IsValid()) Log.report(logvisor::Fatal, "attempted to access null id on type '%s'", tag.type.toString().c_str()); const hecl::ProjectPath* resPath = nullptr; @@ -715,14 +715,14 @@ std::unique_ptr ProjectResourceFactoryBase::Build(const urde::SObjec *task.xc_targetObjPtr = newObj.get(); Log.report(logvisor::Warning, "spin-built %.4s %08X", task.x0_tag.type.toString().c_str(), - u32(task.x0_tag.id)); + u32(task.x0_tag.id.Value())); m_asyncLoadList.erase(asyncSearch); return newObj; } Log.report(logvisor::Error, "unable to spin-build %.4s %08X", task.x0_tag.type.toString().c_str(), - u32(task.x0_tag.id)); + u32(task.x0_tag.id.Value())); m_asyncLoadList.erase(asyncSearch); return {}; } @@ -748,7 +748,7 @@ void ProjectResourceFactoryBase::BuildAsync(const urde::SObjectTag& tag, urde::IObj** objOut, CObjectReference* selfRef) { - if (tag.id == kInvalidResId || !tag.id) + if (!tag.id.IsValid()) Log.report(logvisor::Fatal, "attempted to access null id on type '%s'", tag.type.toString().c_str()); BuildAsyncInternal(tag, paramXfer, objOut, selfRef); @@ -756,7 +756,7 @@ void ProjectResourceFactoryBase::BuildAsync(const urde::SObjectTag& tag, u32 ProjectResourceFactoryBase::ResourceSize(const SObjectTag& tag) { - if (tag.id == kInvalidResId || !tag.id) + if (!tag.id.IsValid()) Log.report(logvisor::Fatal, "attempted to access null id on type '%s'", tag.type.toString().c_str()); /* Ensure resource at requested path is indexed and not cooking */ @@ -776,7 +776,7 @@ std::shared_ptr ProjectResourceFactoryBase::LoadResourceAsync(const urde::SObjectTag& tag, std::unique_ptr& target) { - if ((tag.id & 0xffffffff) == 0xffffffff || !tag.id) + if (!tag.id.IsValid()) Log.report(logvisor::Fatal, "attempted to access null id"); if (m_asyncLoadList.find(tag) != m_asyncLoadList.end()) return {}; @@ -789,7 +789,7 @@ ProjectResourceFactoryBase::LoadResourcePartAsync(const urde::SObjectTag& tag, u32 size, u32 off, std::unique_ptr& target) { - if ((tag.id & 0xffffffff) == 0xffffffff || !tag.id) + if (!tag.id.IsValid()) Log.report(logvisor::Fatal, "attempted to access null id"); if (m_asyncLoadList.find(tag) != m_asyncLoadList.end()) return {}; @@ -800,7 +800,7 @@ ProjectResourceFactoryBase::LoadResourcePartAsync(const urde::SObjectTag& tag, std::shared_ptr ProjectResourceFactoryBase::LoadResourcePartAsync(const urde::SObjectTag& tag, u32 size, u32 off, u8* target) { - if ((tag.id & 0xffffffff) == 0xffffffff || !tag.id) + if (!tag.id.IsValid()) Log.report(logvisor::Fatal, "attempted to access null id"); if (m_asyncLoadList.find(tag) != m_asyncLoadList.end()) return {}; @@ -810,7 +810,7 @@ ProjectResourceFactoryBase::LoadResourcePartAsync(const urde::SObjectTag& tag, u std::unique_ptr ProjectResourceFactoryBase::LoadResourceSync(const urde::SObjectTag& tag) { - if ((tag.id & 0xffffffff) == 0xffffffff || !tag.id) + if (!tag.id.IsValid()) Log.report(logvisor::Fatal, "attempted to access null id"); /* Ensure resource at requested path is indexed and not cooking */ @@ -829,7 +829,7 @@ std::unique_ptr ProjectResourceFactoryBase::LoadResourceSync(const urde::S std::unique_ptr ProjectResourceFactoryBase::LoadResourcePartSync(const urde::SObjectTag& tag, u32 size, u32 off) { - if ((tag.id & 0xffffffff) == 0xffffffff || !tag.id) + if (!tag.id.IsValid()) Log.report(logvisor::Fatal, "attempted to access null id"); /* Ensure resource at requested path is indexed and not cooking */ @@ -854,7 +854,7 @@ void ProjectResourceFactoryBase::CancelBuild(const urde::SObjectTag& tag) bool ProjectResourceFactoryBase::CanBuild(const urde::SObjectTag& tag) { - if ((tag.id & 0xffffffff) == 0xffffffff || !tag.id) + if (!tag.id.IsValid()) Log.report(logvisor::Fatal, "attempted to access null id"); const hecl::ProjectPath* resPath = nullptr; @@ -896,9 +896,9 @@ const urde::SObjectTag* ProjectResourceFactoryBase::GetResourceIdByName(const ch return &search->second; } -FourCC ProjectResourceFactoryBase::GetResourceTypeById(ResId id) const +FourCC ProjectResourceFactoryBase::GetResourceTypeById(CAssetId id) const { - if ((id & 0xffffffff) == 0xffffffff || !id) + if (!id.IsValid()) return {}; std::unique_lock lk(const_cast(this)->m_backgroundIndexMutex); @@ -1006,7 +1006,7 @@ bool ProjectResourceFactoryBase::AsyncPumpTask( *task.xc_targetObjPtr = newObj.release(); Log.report(logvisor::Info, "async-built %.4s %08X", task.x0_tag.type.toString().c_str(), - u32(task.x0_tag.id)); + u32(task.x0_tag.id.Value())); } else if (task.xc_targetDataPtr) { @@ -1014,14 +1014,14 @@ bool ProjectResourceFactoryBase::AsyncPumpTask( *task.xc_targetDataPtr = std::move(task.x10_loadBuffer); Log.report(logvisor::Info, "async-loaded %.4s %08X", task.x0_tag.type.toString().c_str(), - u32(task.x0_tag.id)); + u32(task.x0_tag.id.Value())); } else if (task.xc_targetDataRawPtr) { /* Buffer only raw */ Log.report(logvisor::Info, "async-loaded %.4s %08X", task.x0_tag.type.toString().c_str(), - u32(task.x0_tag.id)); + u32(task.x0_tag.id.Value())); } } diff --git a/Editor/ProjectResourceFactoryBase.hpp b/Editor/ProjectResourceFactoryBase.hpp index b465cd042..de24cf8e5 100644 --- a/Editor/ProjectResourceFactoryBase.hpp +++ b/Editor/ProjectResourceFactoryBase.hpp @@ -129,7 +129,7 @@ public: void CancelBuild(const urde::SObjectTag&); bool CanBuild(const urde::SObjectTag&); const urde::SObjectTag* GetResourceIdByName(const char*) const; - FourCC GetResourceTypeById(ResId id) const; + FourCC GetResourceTypeById(CAssetId id) const; void EnumerateResources(const std::function& lambda) const; void EnumerateNamedResources(const std::function& lambda) const; diff --git a/Editor/ProjectResourceFactoryMP1.cpp b/Editor/ProjectResourceFactoryMP1.cpp index a50a6d86d..317660304 100644 --- a/Editor/ProjectResourceFactoryMP1.cpp +++ b/Editor/ProjectResourceFactoryMP1.cpp @@ -47,8 +47,8 @@ namespace urde class MP1OriginalIDs { - std::vector> m_origToNew; - std::vector> m_newToOrig; + std::vector> m_origToNew; + std::vector> m_newToOrig; public: MP1OriginalIDs(CInputStream& in) @@ -57,20 +57,20 @@ public: m_origToNew.reserve(count); for (u32 i=0 ; isecond; } - ResId TranslateNewToOriginal(ResId id) const + CAssetId TranslateNewToOriginal(CAssetId id) const { auto search = rstl::binary_find(m_newToOrig.cbegin(), m_newToOrig.cend(), id, [](const auto& id) { return id.first; }); @@ -154,12 +154,12 @@ void ProjectResourceFactoryMP1::Shutdown() ProjectResourceFactoryBase::Shutdown(); } -ResId ProjectResourceFactoryMP1::TranslateOriginalToNew(ResId id) const +CAssetId ProjectResourceFactoryMP1::TranslateOriginalToNew(CAssetId id) const { return m_origIds->TranslateOriginalToNew(id); } -ResId ProjectResourceFactoryMP1::TranslateNewToOriginal(ResId id) const +CAssetId ProjectResourceFactoryMP1::TranslateNewToOriginal(CAssetId id) const { return m_origIds->TranslateNewToOriginal(id); } diff --git a/Editor/ProjectResourceFactoryMP1.hpp b/Editor/ProjectResourceFactoryMP1.hpp index 051f36986..80e87384d 100644 --- a/Editor/ProjectResourceFactoryMP1.hpp +++ b/Editor/ProjectResourceFactoryMP1.hpp @@ -18,8 +18,8 @@ public: void GetTagListForFile(const char* pakName, std::vector& out) const; void Shutdown(); - ResId TranslateOriginalToNew(ResId id) const; - ResId TranslateNewToOriginal(ResId id) const; + CAssetId TranslateOriginalToNew(CAssetId id) const; + CAssetId TranslateNewToOriginal(CAssetId id) const; }; } diff --git a/Runtime/Audio/CAudioSys.cpp b/Runtime/Audio/CAudioSys.cpp index 03129ae2b..563284704 100644 --- a/Runtime/Audio/CAudioSys.cpp +++ b/Runtime/Audio/CAudioSys.cpp @@ -7,7 +7,7 @@ namespace urde CAudioSys* CAudioSys::g_SharedSys = nullptr; static std::unordered_map> mpGroupSetDB; -static std::unordered_map mpGroupSetResNameDB; +static std::unordered_map mpGroupSetResNameDB; static const std::string mpDefaultInvalidString = "NULL"; TLockedToken CAudioSys::FindGroupSet(const std::string& name) @@ -18,7 +18,7 @@ TLockedToken CAudioSys::FindGroupSet(const std::string& name) return search->second; } -const std::string& CAudioSys::SysGetGroupSetName(ResId id) +const std::string& CAudioSys::SysGetGroupSetName(CAssetId id) { auto search = mpGroupSetResNameDB.find(id); if (search == mpGroupSetResNameDB.cend()) @@ -26,7 +26,7 @@ const std::string& CAudioSys::SysGetGroupSetName(ResId id) return search->second; } -bool CAudioSys::SysLoadGroupSet(CSimplePool* pool, ResId id) +bool CAudioSys::SysLoadGroupSet(CSimplePool* pool, CAssetId id) { if (!FindGroupSet(SysGetGroupSetName(id))) { @@ -41,7 +41,7 @@ bool CAudioSys::SysLoadGroupSet(CSimplePool* pool, ResId id) } } -bool CAudioSys::SysLoadGroupSet(const TLockedToken& set, const std::string& name, ResId id) +bool CAudioSys::SysLoadGroupSet(const TLockedToken& set, const std::string& name, CAssetId id) { if (!FindGroupSet(name)) { diff --git a/Runtime/Audio/CAudioSys.hpp b/Runtime/Audio/CAudioSys.hpp index 2dc59e6f3..e98b69622 100644 --- a/Runtime/Audio/CAudioSys.hpp +++ b/Runtime/Audio/CAudioSys.hpp @@ -79,9 +79,9 @@ public: } static TLockedToken FindGroupSet(const std::string& name); - static const std::string& SysGetGroupSetName(ResId id); - static bool SysLoadGroupSet(CSimplePool* pool, ResId id); - static bool SysLoadGroupSet(const TLockedToken& set, const std::string& name, ResId id); + static const std::string& SysGetGroupSetName(CAssetId id); + static bool SysLoadGroupSet(CSimplePool* pool, CAssetId id); + static bool SysLoadGroupSet(const TLockedToken& set, const std::string& name, CAssetId id); static void SysUnloadAudioGroupSet(const std::string& name); static bool SysIsGroupSetLoaded(const std::string& name); static void SysAddGroupIntoAmuse(const std::string& name); diff --git a/Runtime/Audio/CMidiManager.hpp b/Runtime/Audio/CMidiManager.hpp index 81b2981f1..5b7d4961f 100644 --- a/Runtime/Audio/CMidiManager.hpp +++ b/Runtime/Audio/CMidiManager.hpp @@ -13,12 +13,12 @@ public: { u16 x0_setupId; u16 x2_groupId; - ResId x4_agscId; + CAssetId x4_agscId; std::unique_ptr x8_arrData; public: u16 GetSetupId() const { return x0_setupId; } u16 GetGroupId() const { return x2_groupId; } - ResId GetAGSCAssetId() const { return x4_agscId; } + CAssetId GetAGSCAssetId() const { return x4_agscId; } const u8* GetArrData() const { return x8_arrData.get(); } CMidiData(CInputStream& in); }; diff --git a/Runtime/AutoMapper/CAutoMapper.cpp b/Runtime/AutoMapper/CAutoMapper.cpp index 231c70833..1f287aa91 100644 --- a/Runtime/AutoMapper/CAutoMapper.cpp +++ b/Runtime/AutoMapper/CAutoMapper.cpp @@ -199,7 +199,7 @@ void CAutoMapper::SetupMiniMapWorld(const CStateManager& mgr) bool CAutoMapper::HasCurrentMapUniverseWorld() const { - ResId mlvlId = x24_world->IGetWorldAssetId(); + CAssetId mlvlId = x24_world->IGetWorldAssetId(); for (const CMapUniverse::CMapWorldData& wld : *x8_mapu) if (wld.GetWorldAssetId() == mlvlId) return true; @@ -340,7 +340,7 @@ bool CAutoMapper::CanLeaveMapScreen(const CStateManager& mgr) const return x328_ == 3 && CanLeaveMapScreenInternal(mgr); } -void CAutoMapper::SetCurWorldAssetId(ResId mlvlId) +void CAutoMapper::SetCurWorldAssetId(CAssetId mlvlId) { int numWorlds = x8_mapu->GetNumMapWorldDatas(); for (int i=0 ; iCurrentWorldAssetId(); + CAssetId curMlvl = g_GameState->CurrentWorldAssetId(); for (int i=0 ; iTextSupport().SetText(u""); std::u16string str = hecl::UTF8ToChar16( - hecl::Format("&image=SI,0.6,1.0,%8.8X;", u32(g_tweakPlayerRes->x24_lStick[x2e4_lStickPos]))); + hecl::Format("&image=SI,0.6,1.0,%8.8X;", u32(g_tweakPlayerRes->x24_lStick[x2e4_lStickPos].Value()))); str += g_MainStringTable->GetString(46); // Rotate x300_textpane_instructions->TextSupport().SetText(str); str = hecl::UTF8ToChar16( - hecl::Format("&image=SI,0.6,1.0,%8.8X;", u32(g_tweakPlayerRes->x4c_cStick[x2e8_rStickPos]))); + hecl::Format("&image=SI,0.6,1.0,%8.8X;", u32(g_tweakPlayerRes->x4c_cStick[x2e8_rStickPos].Value()))); str += g_MainStringTable->GetString(47); // Move x304_textpane_instructions1->TextSupport().SetText(str); str = hecl::UTF8ToChar16( - hecl::Format("&image=%8.8X;", u32(g_tweakPlayerRes->x74_lTrigger[x2ec_lTriggerPos]))); + hecl::Format("&image=%8.8X;", u32(g_tweakPlayerRes->x74_lTrigger[x2ec_lTriggerPos].Value()))); str += g_MainStringTable->GetString(48); // Zoom str += hecl::UTF8ToChar16( - hecl::Format("&image=%8.8X;", u32(g_tweakPlayerRes->x80_rTrigger[x2f0_rTriggerPos]))); + hecl::Format("&image=%8.8X;", u32(g_tweakPlayerRes->x80_rTrigger[x2f0_rTriggerPos].Value()))); x308_textpane_instructions2->TextSupport().SetText(str); } } @@ -1200,7 +1200,7 @@ void CAutoMapper::Update(float dt, const CStateManager& mgr) std::u16string string; if (x1bc_state == EAutoMapperState::MapScreenUniverse || (x1bc_state == EAutoMapperState::MapScreen && HasCurrentMapUniverseWorld())) - string = hecl::UTF8ToChar16(hecl::Format("image=%8.8X", u32(g_tweakPlayerRes->x98_aButton[x2f4_aButtonPos]))); + string = hecl::UTF8ToChar16(hecl::Format("image=%8.8X", u32(g_tweakPlayerRes->x98_aButton[x2f4_aButtonPos].Value()))); right1->TextSupport().SetText(string); CGuiTextPane* right = static_cast(x28_frmeMapScreen->FindWidget("textpane_right")); if (x1bc_state == EAutoMapperState::MapScreenUniverse) @@ -1323,7 +1323,7 @@ void CAutoMapper::Update(float dt, const CStateManager& mgr) CompleteMapperStateTransition(mgr); } - ResId stringId = x88_mapAreaStringId; + CAssetId stringId = x88_mapAreaStringId; if (IsInMapperState(EAutoMapperState::MapScreenUniverse)) { IWorld* wld = x14_dummyWorlds[x9c_worldIdx].get(); @@ -1366,7 +1366,7 @@ void CAutoMapper::Update(float dt, const CStateManager& mgr) if (IsInMapperState(EAutoMapperState::MapScreen)) { - ResId hintDesc = GetAreaHintDescriptionString(x24_world->IGetAreaAlways(xa0_curAreaId)->IGetAreaAssetId()); + CAssetId hintDesc = GetAreaHintDescriptionString(x24_world->IGetAreaAlways(xa0_curAreaId)->IGetAreaAssetId()); if (hintDesc != x74_areaHintDescId) { x74_areaHintDescId = hintDesc; @@ -1561,7 +1561,7 @@ void CAutoMapper::Draw(const CStateManager& mgr, const zeus::CTransform& xf, flo } if (IsInMapperState(EAutoMapperState::MapScreen)) { - ResId wldMlvl = x24_world->IGetWorldAssetId(); + CAssetId wldMlvl = x24_world->IGetWorldAssetId(); const CMapWorld* mw = x24_world->IGetMapWorld(); std::vector& hintBeaconFilters = const_cast(*this).m_hintBeaconFilters; if (hintBeaconFilters.size() < x1f8_hintLocations.size()) @@ -1688,7 +1688,7 @@ void CAutoMapper::SetupHintNavigation() navigating = true; x1e0_hintSteps.push_back({SAutoMapperHintStep::ShowBeacon{}, 0.75f}); const CGameHintInfo::CGameHint& nextHint = g_MemoryCardSys->GetHints()[hintOpts.GetNextHintIdx()]; - ResId curMlvl = x24_world->IGetWorldAssetId(); + CAssetId curMlvl = x24_world->IGetWorldAssetId(); for (const CGameHintInfo::SHintLocation& loc : nextHint.GetLocations()) { if (loc.x0_mlvlId != curMlvl) @@ -1721,7 +1721,7 @@ void CAutoMapper::SetupHintNavigation() } } -ResId CAutoMapper::GetAreaHintDescriptionString(ResId mreaId) +CAssetId CAutoMapper::GetAreaHintDescriptionString(CAssetId mreaId) { const CHintOptions& hintOpts = g_GameState->HintOptions(); for (int i=0 ; i x3c_hintBeacon; std::vector m_hintBeaconFilters; rstl::reserved_vector, 5> x48_mapIcons; - ResId x74_areaHintDescId = -1; + CAssetId x74_areaHintDescId = -1; TLockedToken x78_areaHintDesc; u32 x84_ = 0; - ResId x88_mapAreaStringId = -1; + CAssetId x88_mapAreaStringId = -1; TLockedToken x8c_mapAreaString; // Used to be optional u32 x9c_worldIdx = 0; TAreaId xa0_curAreaId; @@ -257,7 +257,7 @@ private: void TransformRenderStatesUniverseToWorld(); void TransformRenderStateWorldToUniverse(SAutoMapperRenderState&); void SetupHintNavigation(); - ResId GetAreaHintDescriptionString(ResId mreaId); + CAssetId GetAreaHintDescriptionString(CAssetId mreaId); public: CAutoMapper(CStateManager& stateMgr); @@ -266,8 +266,8 @@ public: float GetMapRotationX() const; float GetMapRotationZ() const; u32 GetFocusAreaIndex() const; - ResId GetCurrWorldAssetId() const; - void SetCurWorldAssetId(ResId mlvlId); + CAssetId GetCurrWorldAssetId() const; + void SetCurWorldAssetId(CAssetId mlvlId); void MuteAllLoopedSounds(); void UnmuteAllLoopedSounds(); void ProcessControllerInput(const CFinalInput&, CStateManager&); diff --git a/Runtime/AutoMapper/CMapUniverse.cpp b/Runtime/AutoMapper/CMapUniverse.cpp index ced32a707..e05b5f3aa 100644 --- a/Runtime/AutoMapper/CMapUniverse.cpp +++ b/Runtime/AutoMapper/CMapUniverse.cpp @@ -32,7 +32,7 @@ CMapUniverse::CMapWorldData::CMapWorldData(CInputStream& in, u32 version) if (version != 0) x54_surfColorSelected.readRGBABig(in); else - x54_surfColorSelected.fromRGBA32(255 | (x10_worldAssetId & 0xFFFFFF00)); + x54_surfColorSelected.fromRGBA32(255 | (u32(x10_worldAssetId.Value()) & 0xFFFFFF00)); x58_outlineColorSelected = zeus::CColor::lerp(zeus::CColor::skWhite, x54_surfColorSelected, 0.5f); x5c_surfColorUnselected = zeus::CColor::lerp(zeus::CColor::skBlack, x54_surfColorSelected, 0.5f); diff --git a/Runtime/AutoMapper/CMapUniverse.hpp b/Runtime/AutoMapper/CMapUniverse.hpp index a1fe8edcd..efa0e6852 100644 --- a/Runtime/AutoMapper/CMapUniverse.hpp +++ b/Runtime/AutoMapper/CMapUniverse.hpp @@ -19,14 +19,14 @@ public: { float x0_alpha; int x4_wldIdx; - ResId x8_wldRes; + CAssetId x8_wldRes; int xc_closestHex; float x10_flashPulse; const CStateManager& x14_mgr; const zeus::CTransform& x18_model; const zeus::CTransform& x1c_view; public: - CMapUniverseDrawParms(float alpha, int wldIdx, ResId wldRes, int closestHex, + CMapUniverseDrawParms(float alpha, int wldIdx, CAssetId wldRes, int closestHex, float flashPulse, const CStateManager& mgr, const zeus::CTransform& model, const zeus::CTransform& view) : x0_alpha(alpha), @@ -42,7 +42,7 @@ public: const zeus::CTransform& GetCameraTransform() const { return x1c_view; } const zeus::CTransform& GetPaneProjectionTransform() const { return x18_model; } float GetAlpha() const { return x0_alpha; } - ResId GetWorldAssetId() const { return x8_wldRes; } + CAssetId GetWorldAssetId() const { return x8_wldRes; } int GetClosestArea() const { return xc_closestHex; } float GetFlashPulse() const { return x10_flashPulse; } }; @@ -71,7 +71,7 @@ public: class CMapWorldData { std::string x0_label; - ResId x10_worldAssetId; + CAssetId x10_worldAssetId; zeus::CTransform x14_transform; std::vector x44_hexagonXfs; zeus::CColor x54_surfColorSelected; @@ -81,7 +81,7 @@ public: zeus::CVector3f x64_centerPoint = zeus::CVector3f::skZero; public: CMapWorldData(CInputStream& in, u32 version); - ResId GetWorldAssetId() const { return x10_worldAssetId; } + CAssetId GetWorldAssetId() const { return x10_worldAssetId; } const zeus::CVector3f& GetWorldCenterPoint() const { return x64_centerPoint; } const std::string& GetWorldLabel() const { return x0_label; } const zeus::CTransform& GetWorldTransform() const { return x14_transform; } @@ -94,7 +94,7 @@ public: }; private: - ResId x0_hexagonId; + CAssetId x0_hexagonId; TLockedToken x4_hexagonToken; std::vector x10_worldDatas; zeus::CVector3f x20_universeCenter = zeus::CVector3f::skZero; @@ -102,7 +102,7 @@ private: public: CMapUniverse(CInputStream&, u32); const CMapWorldData& GetMapWorldData(s32 idx) const { return x10_worldDatas[idx]; } - const CMapWorldData& GetMapWorldDataByWorldId(ResId id) const + const CMapWorldData& GetMapWorldDataByWorldId(CAssetId id) const { for (const CMapWorldData& data : x10_worldDatas) if (data.GetWorldAssetId() == id) diff --git a/Runtime/AutoMapper/CMapWorld.cpp b/Runtime/AutoMapper/CMapWorld.cpp index 6c06adbf8..b026413e0 100644 --- a/Runtime/AutoMapper/CMapWorld.cpp +++ b/Runtime/AutoMapper/CMapWorld.cpp @@ -8,7 +8,7 @@ namespace urde { -CMapWorld::CMapAreaData::CMapAreaData(ResId areaRes, EMapAreaList list, CMapAreaData* next) +CMapWorld::CMapAreaData::CMapAreaData(CAssetId areaRes, EMapAreaList list, CMapAreaData* next) : x0_area(g_SimplePool->GetObj(SObjectTag{FOURCC('MAPA'), areaRes})), x10_list(list), x14_next(next) {} @@ -22,7 +22,7 @@ CMapWorld::CMapWorld(CInputStream& in) x20_traversed.resize(areaCount); for (u32 i=0 ; iGetSaveWorldMemory(mlvlId); @@ -29,7 +29,7 @@ CMapWorldInfo::CMapWorldInfo(CBitStreamReader& reader, const CSaveWorld& savw, R x38_mapStationUsed = reader.ReadEncoded(1); } -void CMapWorldInfo::PutTo(CBitStreamWriter& writer, const CSaveWorld& savw, ResId mlvlId) const +void CMapWorldInfo::PutTo(CBitStreamWriter& writer, const CSaveWorld& savw, CAssetId mlvlId) const { const CSaveWorldMemory& worldMem = g_MemoryCardSys->GetSaveWorldMemory(mlvlId); diff --git a/Runtime/AutoMapper/CMapWorldInfo.hpp b/Runtime/AutoMapper/CMapWorldInfo.hpp index 4c246c212..2b9ed3ecb 100644 --- a/Runtime/AutoMapper/CMapWorldInfo.hpp +++ b/Runtime/AutoMapper/CMapWorldInfo.hpp @@ -17,8 +17,8 @@ class CMapWorldInfo bool x38_mapStationUsed = false; public: CMapWorldInfo()=default; - CMapWorldInfo(CBitStreamReader&, const CSaveWorld& saveWorld, ResId mlvlId); - void PutTo(CBitStreamWriter& writer, const CSaveWorld& savw, ResId mlvlId) const; + CMapWorldInfo(CBitStreamReader&, const CSaveWorld& saveWorld, CAssetId mlvlId); + void PutTo(CBitStreamWriter& writer, const CSaveWorld& savw, CAssetId mlvlId) const; bool IsMapped(TAreaId) const; void SetIsMapped(TAreaId, bool); void SetDoorVisited(TEditorId eid, bool val); diff --git a/Runtime/AutoMapper/CMappableObject.cpp b/Runtime/AutoMapper/CMappableObject.cpp index 610b4f107..cc180e9de 100644 --- a/Runtime/AutoMapper/CMappableObject.cpp +++ b/Runtime/AutoMapper/CMappableObject.cpp @@ -162,7 +162,7 @@ void CMappableObject::Draw(int curArea, const CMapWorldInfo& mwInfo, } else { - ResId iconRes; + CAssetId iconRes; zeus::CColor iconColor = zeus::CColor::skWhite; switch (x0_type) { diff --git a/Runtime/CGameHintInfo.hpp b/Runtime/CGameHintInfo.hpp index 47edad4de..8aa29ef5c 100644 --- a/Runtime/CGameHintInfo.hpp +++ b/Runtime/CGameHintInfo.hpp @@ -11,10 +11,10 @@ class CGameHintInfo public: struct SHintLocation { - ResId x0_mlvlId = -1; - ResId x4_mreaId = -1; + CAssetId x0_mlvlId = -1; + CAssetId x4_mreaId = -1; TAreaId x8_areaId = kInvalidAreaId; - ResId xc_stringId = -1; + CAssetId xc_stringId = -1; SHintLocation(CInputStream&, s32); }; @@ -23,7 +23,7 @@ public: std::string x0_name; float x10_immediateTime; float x14_normalTime; - ResId x18_stringId; + CAssetId x18_stringId; float x1c_textTime; std::vector x20_locations; public: @@ -33,7 +33,7 @@ public: float GetImmediateTime() const { return x10_immediateTime; } float GetTextTime() const { return x1c_textTime; } const std::string& GetName() const { return x0_name; } - ResId GetStringID() const { return x18_stringId; } + CAssetId GetStringID() const { return x18_stringId; } const std::vector& GetLocations() const { return x20_locations; } }; diff --git a/Runtime/CGameOptions.cpp b/Runtime/CGameOptions.cpp index 1ae94bf1f..67151de98 100644 --- a/Runtime/CGameOptions.cpp +++ b/Runtime/CGameOptions.cpp @@ -134,10 +134,10 @@ void CPersistentOptions::PutTo(CBitStreamWriter& w) const } } -bool CPersistentOptions::GetCinematicState(ResId mlvlId, TEditorId cineId) const +bool CPersistentOptions::GetCinematicState(CAssetId mlvlId, TEditorId cineId) const { auto existing = std::find_if(xac_cinematicStates.cbegin(), xac_cinematicStates.cend(), - [&](const std::pair& pair) -> bool + [&](const std::pair& pair) -> bool { return pair.first == mlvlId && pair.second == cineId; }); @@ -145,10 +145,10 @@ bool CPersistentOptions::GetCinematicState(ResId mlvlId, TEditorId cineId) const return existing != xac_cinematicStates.cend(); } -void CPersistentOptions::SetCinematicState(ResId mlvlId, TEditorId cineId, bool state) +void CPersistentOptions::SetCinematicState(CAssetId mlvlId, TEditorId cineId, bool state) { auto existing = std::find_if(xac_cinematicStates.cbegin(), xac_cinematicStates.cend(), - [&](const std::pair& pair) -> bool + [&](const std::pair& pair) -> bool { return pair.first == mlvlId && pair.second == cineId; }); @@ -361,7 +361,7 @@ void CGameOptions::SetControls(int controls) ResetControllerAssets(controls); } -static const std::pair CStickToDPadRemap[] = +static const std::pair CStickToDPadRemap[] = { {0x2A13C23E, 0xF13452F8}, {0xA91A7703, 0xC042EC91}, @@ -370,7 +370,7 @@ static const std::pair CStickToDPadRemap[] = {0xCD7B1ACA, 0x8ADA8184}, }; -static const std::pair CStickOutlineToDPadRemap[] = +static const std::pair CStickOutlineToDPadRemap[] = { {0x1A29C0E6, 0xF13452F8}, {0x5D9F9796, 0xC042EC91}, @@ -379,7 +379,7 @@ static const std::pair CStickOutlineToDPadRemap[] = {0x409AA72E, 0x8ADA8184}, }; -static std::pair TranslatePairToNew(const std::pair& p) +static std::pair TranslatePairToNew(const std::pair& p) { return {g_ResFactory->TranslateOriginalToNew(p.first), g_ResFactory->TranslateOriginalToNew(p.second)}; @@ -406,7 +406,7 @@ void CGameOptions::ResetControllerAssets(int controls) x6c_controlTxtrMap.push_back(TranslatePairToNew(CStickOutlineToDPadRemap[i])); std::sort(x6c_controlTxtrMap.begin(), x6c_controlTxtrMap.end(), - [](const std::pair& a, const std::pair& b) + [](const std::pair& a, const std::pair& b) { return a.first < b.first; }); } } diff --git a/Runtime/CGameOptions.hpp b/Runtime/CGameOptions.hpp index 18c464dcc..6adbc8662 100644 --- a/Runtime/CGameOptions.hpp +++ b/Runtime/CGameOptions.hpp @@ -57,7 +57,7 @@ class CPersistentOptions friend class CGameState; u8 x0_[98] = {}; bool x68_[64] = {}; - std::vector> xac_cinematicStates; /* (MLVL, Cinematic) */ + std::vector> xac_cinematicStates; /* (MLVL, Cinematic) */ u32 xbc_autoMapperKeyState = 0; u32 xc0_frozenFpsCount = 0; u32 xc4_frozenBallCount = 0; @@ -82,8 +82,8 @@ public: CPersistentOptions() = default; CPersistentOptions(CBitStreamReader& stream); - bool GetCinematicState(ResId mlvlId, TEditorId cineId) const; - void SetCinematicState(ResId mlvlId, TEditorId cineId, bool state); + bool GetCinematicState(CAssetId mlvlId, TEditorId cineId) const; + void SetCinematicState(CAssetId mlvlId, TEditorId cineId, bool state); u32 GetAutoMapperKeyState() const { return xbc_autoMapperKeyState; } void SetAutoMapperKeyState(u32 s) { xbc_autoMapperKeyState = s; } bool GetPlayerLinkedFusion() const { return xd0_24_fusionLinked; } @@ -136,7 +136,7 @@ class CGameOptions u16 _dummy = 0; }; - std::vector> x6c_controlTxtrMap; + std::vector> x6c_controlTxtrMap; public: CGameOptions(); @@ -177,7 +177,7 @@ public: bool GetIsHintSystemEnabled() const { return x68_28_hintSystem; } void SetControls(int controls); void ResetControllerAssets(int controls); - const std::vector>& GetControlTXTRMap() const { return x6c_controlTxtrMap; } + const std::vector>& GetControlTXTRMap() const { return x6c_controlTxtrMap; } static void TryRestoreDefaults(const CFinalInput& input, int category, int option, bool frontend, bool forceRestore); diff --git a/Runtime/CGameState.cpp b/Runtime/CGameState.cpp index e4bb45523..010d9c6f0 100644 --- a/Runtime/CGameState.cpp +++ b/Runtime/CGameState.cpp @@ -75,7 +75,7 @@ void CWorldLayerState::InitializeWorldLayers(const std::vector(); @@ -84,7 +84,7 @@ CWorldState::CWorldState(ResId id) x14_layerState = std::make_shared(); } -CWorldState::CWorldState(CBitStreamReader& reader, ResId mlvlId, const CSaveWorld& saveWorld) +CWorldState::CWorldState(CBitStreamReader& reader, CAssetId mlvlId, const CSaveWorld& saveWorld) : x0_mlvlId(mlvlId) { x4_areaId = reader.ReadEncoded(32); @@ -97,7 +97,7 @@ CWorldState::CWorldState(CBitStreamReader& reader, ResId mlvlId, const CSaveWorl void CWorldState::PutTo(CBitStreamWriter& writer, const CSaveWorld& savw) const { writer.WriteEncoded(x4_areaId, 32); - writer.WriteEncoded(x10_desiredAreaAssetId, 32); + writer.WriteEncoded(x10_desiredAreaAssetId.Value(), 32); x8_relayTracker->PutTo(writer, savw); xc_mapWorldInfo->PutTo(writer, savw, x0_mlvlId); x14_layerState->PutTo(writer); @@ -114,7 +114,7 @@ CGameState::GameFileStateInfo CGameState::LoadGameFileState(const u8* data) ret.x20_hardMode = stream.ReadEncoded(1); stream.ReadEncoded(1); - ResId origMLVL = stream.ReadEncoded(32); + CAssetId origMLVL = stream.ReadEncoded(32); ret.x8_mlvlId = g_ResFactory->TranslateOriginalToNew(origMLVL); BitsToDouble conv; @@ -236,7 +236,7 @@ void CGameState::PutTo(CBitStreamWriter& writer) const writer.WriteEncoded(CBasics::ToWiiTime(std::chrono::system_clock::now()) / CBasics::TICKS_PER_SECOND, 32); writer.WriteEncoded(x228_24_hardMode, 1); writer.WriteEncoded(x228_25_deferPowerupInit, 1); - writer.WriteEncoded(g_ResFactory->TranslateNewToOriginal(x84_mlvlId), 32); + writer.WriteEncoded(g_ResFactory->TranslateNewToOriginal(x84_mlvlId).Value(), 32); BitsToDouble conv; conv.doub = xa0_playTime; @@ -257,7 +257,7 @@ void CGameState::PutTo(CBitStreamWriter& writer) const } } -void CGameState::SetCurrentWorldId(ResId id) +void CGameState::SetCurrentWorldId(CAssetId id) { StateForWorld(id); x84_mlvlId = id; @@ -269,7 +269,7 @@ void CGameState::SetTotalPlayTime(float time) xa0_playTime = zeus::clamp(0.0, time, 359999.0); } -CWorldState& CGameState::StateForWorld(ResId mlvlId) +CWorldState& CGameState::StateForWorld(CAssetId mlvlId) { auto it = x88_worldStates.begin(); for (; it != x88_worldStates.end() ; ++it) diff --git a/Runtime/CGameState.hpp b/Runtime/CGameState.hpp index e43342efb..0acecc7be 100644 --- a/Runtime/CGameState.hpp +++ b/Runtime/CGameState.hpp @@ -44,21 +44,21 @@ public: class CWorldState { - ResId x0_mlvlId; + CAssetId x0_mlvlId; TAreaId x4_areaId = kInvalidAreaId; std::shared_ptr x8_relayTracker; std::shared_ptr xc_mapWorldInfo; - ResId x10_desiredAreaAssetId; + CAssetId x10_desiredAreaAssetId; std::shared_ptr x14_layerState; public: - explicit CWorldState(ResId id); - CWorldState(CBitStreamReader& reader, ResId mlvlId, const CSaveWorld& saveWorld); - ResId GetWorldAssetId() const { return x0_mlvlId; } + explicit CWorldState(CAssetId id); + CWorldState(CBitStreamReader& reader, CAssetId mlvlId, const CSaveWorld& saveWorld); + CAssetId GetWorldAssetId() const { return x0_mlvlId; } void SetAreaId(TAreaId aid) { x4_areaId = aid; } TAreaId GetCurrentAreaId() const { return x4_areaId; } - ResId GetDesiredAreaAssetId() const { return x10_desiredAreaAssetId; } - void SetDesiredAreaAssetId(ResId id) { x10_desiredAreaAssetId = id; } + CAssetId GetDesiredAreaAssetId() const { return x10_desiredAreaAssetId; } + void SetDesiredAreaAssetId(CAssetId id) { x10_desiredAreaAssetId = id; } const std::shared_ptr& RelayTracker() const { return x8_relayTracker; } const std::shared_ptr& MapWorldInfo() const { return xc_mapWorldInfo; } const std::shared_ptr& GetLayerState() const { return x14_layerState; } @@ -71,7 +71,7 @@ class CGameState bool x0_[128] = {}; u32 x80_; - ResId x84_mlvlId = kInvalidResId; + CAssetId x84_mlvlId; std::vector x88_worldStates; std::shared_ptr x98_playerState; std::shared_ptr x9c_transManager; @@ -96,16 +96,16 @@ class CGameState public: CGameState(); CGameState(CBitStreamReader& stream, u32 saveIdx); - void SetCurrentWorldId(ResId id); + void SetCurrentWorldId(CAssetId id); std::shared_ptr GetPlayerState() { return x98_playerState; } std::shared_ptr GetWorldTransitionManager() { return x9c_transManager; } void SetTotalPlayTime(float time); CPersistentOptions& SystemOptions() { return xa8_systemOptions; } CGameOptions& GameOptions() { return x17c_gameOptions; } CHintOptions& HintOptions() { return x1f8_hintOptions; } - CWorldState& StateForWorld(ResId mlvlId); + CWorldState& StateForWorld(CAssetId mlvlId); CWorldState& CurrentWorldState() { return StateForWorld(x84_mlvlId); } - ResId CurrentWorldAssetId() const { return x84_mlvlId; } + CAssetId CurrentWorldAssetId() const { return x84_mlvlId; } void SetHardMode(bool v) { x228_24_hardMode = v; } bool GetHardMode() const { return x228_24_hardMode; } void ReadPersistentOptions(CBitStreamReader& r); @@ -127,7 +127,7 @@ public: struct GameFileStateInfo { double x0_playTime; - u32 x8_mlvlId; + CAssetId x8_mlvlId; float xc_health; u32 x10_energyTanks; u32 x14_timestamp; diff --git a/Runtime/CInGameTweakManagerBase.hpp b/Runtime/CInGameTweakManagerBase.hpp index 042cdb1a4..261193998 100644 --- a/Runtime/CInGameTweakManagerBase.hpp +++ b/Runtime/CInGameTweakManagerBase.hpp @@ -16,14 +16,14 @@ public: { float x0_fadeIn, x4_fadeOut, x8_volume; std::string xc_fileName; - ResId x1c_res; + CAssetId x1c_res; Audio(float fadeIn, float fadeOut, float vol, const std::string& fileName, u32 handle) : x0_fadeIn(fadeIn), x4_fadeOut(fadeOut), x8_volume(vol), xc_fileName(fileName), x1c_res(handle) {} float GetFadeIn() const { return x0_fadeIn; } float GetFadeOut() const { return x4_fadeOut; } float GetVolume() const { return x8_volume; } const std::string& GetFileName() const { return xc_fileName; } - ResId GetResId() const { return x1c_res; } + CAssetId GetResId() const { return x1c_res; } static Audio None() { return Audio{0.f, 0.f, 0.f, "", 0}; } }; enum class EType @@ -77,11 +77,11 @@ public: return true; } - static std::string GetIdentifierForMidiEvent(ResId world, ResId area, + static std::string GetIdentifierForMidiEvent(CAssetId world, CAssetId area, const std::string& midiObj) { return hecl::Format("World %8.8x Area %8.8x MidiObject: %s", - u32(world), u32(area), midiObj.c_str()); + u32(world.Value()), u32(area.Value()), midiObj.c_str()); } }; diff --git a/Runtime/CMakeLists.txt b/Runtime/CMakeLists.txt index 6f06535aa..ca63735b3 100644 --- a/Runtime/CMakeLists.txt +++ b/Runtime/CMakeLists.txt @@ -49,7 +49,7 @@ if(APPLE) endif() add_library(RuntimeCommon - RetroTypes.hpp + RetroTypes.hpp RetroTypes.cpp ${CLIENT_SOURCES} ${MP1_SOURCES} ${AUDIO_SOURCES} diff --git a/Runtime/CMemoryCardSys.cpp b/Runtime/CMemoryCardSys.cpp index 6db603077..94b210f26 100644 --- a/Runtime/CMemoryCardSys.cpp +++ b/Runtime/CMemoryCardSys.cpp @@ -15,7 +15,7 @@ static kabufuda::SystemString g_CardImagePaths[2] = {}; static kabufuda::Card g_CardStates[2] = {}; static kabufuda::ECardResult g_OpResults[2] = {}; -CSaveWorldIntermediate::CSaveWorldIntermediate(ResId mlvl, ResId savw) +CSaveWorldIntermediate::CSaveWorldIntermediate(CAssetId mlvl, CAssetId savw) : x0_mlvlId(mlvl), x8_savwId(savw) { if (savw == -1) @@ -43,7 +43,7 @@ bool CSaveWorldIntermediate::InitializePump() xc_areaIds.push_back(area->IGetAreaId()); } - ResId mlvlId = wld.IGetWorldAssetId(); + CAssetId mlvlId = wld.IGetWorldAssetId(); CWorldState& mlvlState = g_GameState->StateForWorld(mlvlId); x1c_defaultLayerStates = mlvlState.GetLayerState()->x0_areaLayers; @@ -61,7 +61,7 @@ bool CSaveWorldIntermediate::InitializePump() return false; } -bool CMemoryCardSys::HasSaveWorldMemory(ResId wldId) const +bool CMemoryCardSys::HasSaveWorldMemory(CAssetId wldId) const { auto existingSearch = std::find_if(xc_memoryWorlds.cbegin(), xc_memoryWorlds.cend(), [&](const auto& wld) @@ -69,7 +69,7 @@ bool CMemoryCardSys::HasSaveWorldMemory(ResId wldId) const return existingSearch != xc_memoryWorlds.cend(); } -const CSaveWorldMemory& CMemoryCardSys::GetSaveWorldMemory(ResId wldId) const +const CSaveWorldMemory& CMemoryCardSys::GetSaveWorldMemory(CAssetId wldId) const { auto existingSearch = std::find_if(xc_memoryWorlds.cbegin(), xc_memoryWorlds.cend(), [&](const auto& wld) @@ -84,13 +84,13 @@ CMemoryCardSys::CMemoryCardSys() x1c_worldInter.emplace(); x1c_worldInter->reserve(16); - std::vector> orderedMLVLs; + std::vector> orderedMLVLs; orderedMLVLs.reserve(16); g_ResFactory->EnumerateNamedResources([&](const std::string& name, const SObjectTag& tag) -> bool { if (tag.type == FOURCC('MLVL')) { - ResId origId = g_ResFactory->TranslateNewToOriginal(tag.id); + CAssetId origId = g_ResFactory->TranslateNewToOriginal(tag.id); orderedMLVLs.emplace_back(origId, tag.id); } return true; @@ -180,17 +180,17 @@ bool CMemoryCardSys::InitializePump() return false; } -void CMemoryCardSys::CCardFileInfo::LockBannerToken(ResId bannerTxtr, CSimplePool& sp) +void CMemoryCardSys::CCardFileInfo::LockBannerToken(CAssetId bannerTxtr, CSimplePool& sp) { x3c_bannerTex = bannerTxtr; x40_bannerTok.emplace(sp.GetObj({FOURCC('TXTR'), bannerTxtr}, m_texParam)); } -CMemoryCardSys::CCardFileInfo::Icon::Icon(ResId id, kabufuda::EAnimationSpeed speed, +CMemoryCardSys::CCardFileInfo::Icon::Icon(CAssetId id, kabufuda::EAnimationSpeed speed, CSimplePool& sp, const CVParamTransfer& cv) : x0_id(id), x4_speed(speed), x8_tex(sp.GetObj({FOURCC('TXTR'), id}, cv)) {} -void CMemoryCardSys::CCardFileInfo::LockIconToken(ResId iconTxtr, kabufuda::EAnimationSpeed speed, CSimplePool& sp) +void CMemoryCardSys::CCardFileInfo::LockIconToken(CAssetId iconTxtr, kabufuda::EAnimationSpeed speed, CSimplePool& sp) { x50_iconToks.emplace_back(iconTxtr, speed, sp, m_texParam); } diff --git a/Runtime/CMemoryCardSys.hpp b/Runtime/CMemoryCardSys.hpp index a016b1bc0..9d4423166 100644 --- a/Runtime/CMemoryCardSys.hpp +++ b/Runtime/CMemoryCardSys.hpp @@ -18,17 +18,17 @@ class CSimplePool; class CSaveWorldMemory { friend class CMemoryCardSys; - ResId x0_strgId = -1; - ResId x4_savwId = -1; + CAssetId x0_strgId = -1; + CAssetId x4_savwId = -1; u32 x8_areaCount; - std::vector xc_areaIds; + std::vector xc_areaIds; std::vector x1c_defaultLayerStates; TLockedToken x2c_worldName; /* used to be optional */ TLockedToken x3c_saveWorld; /* used to be optional */ public: - ResId GetWorldNameId() const { return x0_strgId; } - ResId GetSaveWorldAssetId() const { return x4_savwId; } + CAssetId GetWorldNameId() const { return x0_strgId; } + CAssetId GetSaveWorldAssetId() const { return x4_savwId; } u32 GetAreaCount() const { return x8_areaCount; } const std::vector& GetDefaultLayerStates() const { return x1c_defaultLayerStates; } const TLockedToken& GetWorldName() const { return x2c_worldName; } @@ -44,16 +44,16 @@ public: class CSaveWorldIntermediate { friend class CMemoryCardSys; - ResId x0_mlvlId; - ResId x4_strgId; - ResId x8_savwId; - std::vector xc_areaIds; + CAssetId x0_mlvlId; + CAssetId x4_strgId; + CAssetId x8_savwId; + std::vector xc_areaIds; std::vector x1c_defaultLayerStates; std::unique_ptr x2c_dummyWorld; TLockedToken x34_saveWorld; /* Used to be auto_ptr */ public: - CSaveWorldIntermediate(ResId mlvl, ResId savw); + CSaveWorldIntermediate(CAssetId mlvl, CAssetId savw); bool InitializePump(); }; @@ -61,9 +61,9 @@ public: class CMemoryCardSys { TLockedToken x0_hints; - std::vector> xc_memoryWorlds; /* MLVL as key */ + std::vector> xc_memoryWorlds; /* MLVL as key */ std::experimental::optional> x1c_worldInter; /* used to be auto_ptr of vector */ - std::vector> x20_scanStates; + std::vector> x20_scanStates; rstl::reserved_vector x30_scanCategoryCounts; public: @@ -90,19 +90,19 @@ public: using CardStat = kabufuda::CardStat; const std::vector& GetHints() const { return x0_hints->GetHints(); } - const std::vector>& GetMemoryWorlds() const { return xc_memoryWorlds; } - const std::vector>& GetScanStates() const { return x20_scanStates; } + const std::vector>& GetMemoryWorlds() const { return xc_memoryWorlds; } + const std::vector>& GetScanStates() const { return x20_scanStates; } u32 GetScanCategoryCount(CSaveWorld::EScanCategory cat) const { return x30_scanCategoryCounts[int(cat)]; } - std::vector>::const_iterator LookupScanState(ResId id) const + std::vector>::const_iterator LookupScanState(CAssetId id) const { return rstl::binary_find(x20_scanStates.cbegin(), x20_scanStates.cend(), id, - [](const std::pair& p) { return p.first; }); + [](const std::pair& p) { return p.first; }); } - bool HasSaveWorldMemory(ResId wldId) const; - const CSaveWorldMemory& GetSaveWorldMemory(ResId wldId) const; + bool HasSaveWorldMemory(CAssetId wldId) const; + const CSaveWorldMemory& GetSaveWorldMemory(CAssetId wldId) const; CMemoryCardSys(); bool InitializePump(); @@ -111,10 +111,10 @@ public: { struct Icon { - ResId x0_id; + CAssetId x0_id; kabufuda::EAnimationSpeed x4_speed; TLockedToken x8_tex; - Icon(ResId id, kabufuda::EAnimationSpeed speed, CSimplePool& sp, const CVParamTransfer& cv); + Icon(CAssetId id, kabufuda::EAnimationSpeed speed, CSimplePool& sp, const CVParamTransfer& cv); }; enum class EStatus @@ -129,7 +129,7 @@ public: CardFileHandle m_handle; std::string x18_fileName; std::string x28_comment; - ResId x3c_bannerTex = -1; + CAssetId x3c_bannerTex = -1; std::experimental::optional> x40_bannerTok; rstl::reserved_vector x50_iconToks; std::vector xf4_saveBuffer; @@ -140,8 +140,8 @@ public: CCardFileInfo(kabufuda::ECardSlot port, const std::string& name) : m_handle(port), x18_fileName(name) {} - void LockBannerToken(ResId bannerTxtr, CSimplePool& sp); - void LockIconToken(ResId iconTxtr, kabufuda::EAnimationSpeed speed, CSimplePool& sp); + void LockBannerToken(CAssetId bannerTxtr, CSimplePool& sp); + void LockIconToken(CAssetId iconTxtr, kabufuda::EAnimationSpeed speed, CSimplePool& sp); kabufuda::ECardSlot GetCardPort() const { return m_handle.slot; } int GetFileNo() const { return m_handle.getFileNo(); } diff --git a/Runtime/CPakFile.hpp b/Runtime/CPakFile.hpp index 62777cd2f..52de5032c 100644 --- a/Runtime/CPakFile.hpp +++ b/Runtime/CPakFile.hpp @@ -46,14 +46,14 @@ private: u32 x4c_resTableCount = 0; int x50_ = -1; std::vector> x54_nameList; - std::vector x64_depList; - std::vector> x74_resList; + std::vector x64_depList; + std::vector> x74_resList; public: CPakFile(const std::string& filename, bool buildDepList, bool worldPak); - const std::vector& GetDepList() const { return x64_depList; } + const std::vector& GetDepList() const { return x64_depList; } const SObjectTag* GetResIdByName(const char* name) const; - const SResInfo* GetResInfoForLoad(u32 id) { return nullptr; } - const SResInfo* GetResInfo(u32 id) const { return nullptr; } + const SResInfo* GetResInfoForLoad(CAssetId id) { return nullptr; } + const SResInfo* GetResInfo(CAssetId id) const { return nullptr; } u32 GetFakeStaticSize() const { return 0; } void DataLoad() {} void InitialHeaderLoad() {} diff --git a/Runtime/CPlayerState.cpp b/Runtime/CPlayerState.cpp index 994a9de86..5eda73fa6 100644 --- a/Runtime/CPlayerState.cpp +++ b/Runtime/CPlayerState.cpp @@ -63,18 +63,18 @@ CPlayerState::CPlayerState() : x188_staticIntf(5) { x0_24_alive = true; - x24_powerups.resize(41); + x24_powerups.set_size(41); } CPlayerState::CPlayerState(CBitStreamReader& stream) : x188_staticIntf(5) { - x4_ = stream.ReadEncoded(0x20); + x4_enabledItems = stream.ReadEncoded(0x20); u32 tmp = stream.ReadEncoded(0x20); xc_health.SetHP(*reinterpret_cast(&tmp)); x8_currentBeam = EBeamId(stream.ReadEncoded(CBitStreamReader::GetBitCount(5))); x20_currentSuit = EPlayerSuit(stream.ReadEncoded(CBitStreamReader::GetBitCount(4))); - x24_powerups.resize(41); + x24_powerups.set_size(41); for (u32 i = 0; i < x24_powerups.size(); ++i) { if (PowerUpMaxValues[i] == 0) @@ -99,7 +99,7 @@ CPlayerState::CPlayerState(CBitStreamReader& stream) void CPlayerState::PutTo(CBitStreamWriter& stream) { - stream.WriteEncoded(x4_, 32); + stream.WriteEncoded(x4_enabledItems, 32); float hp = xc_health.GetHP(); stream.WriteEncoded(*reinterpret_cast(&hp), 32); stream.WriteEncoded(u32(x8_currentBeam), CBitStreamWriter::GetBitCount(5)); @@ -222,7 +222,7 @@ void CPlayerState::UpdateStaticInterference(CStateManager& stateMgr, const float x188_staticIntf.Update(stateMgr, dt); } -void CPlayerState::SetScanTime(ResId res, float time) +void CPlayerState::SetScanTime(CAssetId res, float time) { auto it = std::find_if(x170_scanTimes.begin(), x170_scanTimes.end(), [&](const auto& test) -> bool{ return test.first == res; @@ -232,7 +232,7 @@ void CPlayerState::SetScanTime(ResId res, float time) it->second = time; } -float CPlayerState::GetScanTime(ResId res) const +float CPlayerState::GetScanTime(CAssetId res) const { const auto it = std::find_if(x170_scanTimes.cbegin(), x170_scanTimes.cend(), [&](const auto& test) -> bool{ return test.first == res; @@ -296,10 +296,22 @@ void CPlayerState::ResetVisor() bool CPlayerState::ItemEnabled(CPlayerState::EItemType type) { if (HasPowerUp(type)) - return x24_powerups[u32(type)].x4_capacity != 0; + return (x4_enabledItems & (1 << u32(type))); return false; } +void CPlayerState::EnableItem(CPlayerState::EItemType type) +{ + if (HasPowerUp(type)) + x4_enabledItems |= (1 << u32(type)); +} + +void CPlayerState::DisableItem(CPlayerState::EItemType type) +{ + if (HasPowerUp(type)) + x4_enabledItems &= ~(1 << u32(type)); +} + bool CPlayerState::HasPowerUp(CPlayerState::EItemType type) { if (type < EItemType::Max) diff --git a/Runtime/CPlayerState.hpp b/Runtime/CPlayerState.hpp index 61b93822e..0d8ded947 100644 --- a/Runtime/CPlayerState.hpp +++ b/Runtime/CPlayerState.hpp @@ -115,15 +115,15 @@ private: u32 dummy = 0; }; - u32 x4_ = 0; + u32 x4_enabledItems = 0; EBeamId x8_currentBeam = EBeamId::Power; CHealthInfo xc_health = {99.f, 50.f}; EPlayerVisor x14_currentVisor = EPlayerVisor::Combat; EPlayerVisor x18_transitioningVisor = x14_currentVisor; float x1c_visorTransitionFactor = 0.2f; EPlayerSuit x20_currentSuit = EPlayerSuit::Power; - rstl::reserved_vector x24_powerups; - rstl::reserved_vector, 846> x170_scanTimes; + rstl::prereserved_vector x24_powerups; + rstl::reserved_vector, 846> x170_scanTimes; std::pair x180_scanCompletionRate = {}; CStaticInterference x188_staticIntf; public: @@ -147,8 +147,8 @@ public: EPlayerVisor GetActiveVisor(const CStateManager& stateMgr) const; void UpdateStaticInterference(CStateManager& stateMgr, const float& dt); void IncreaseScanTime(u32 time, float val); - void SetScanTime(ResId res, float time); - float GetScanTime(ResId time) const; + void SetScanTime(CAssetId res, float time); + float GetScanTime(CAssetId time) const; bool GetIsVisorTransitioning() const; float GetVisorTransitionFactor() const; void UpdateVisorTransition(float dt); @@ -175,7 +175,7 @@ public: void SetPlayerAlive(bool alive) { x0_24_alive = alive; } void InitializeScanTimes(); CStaticInterference& GetStaticInterference() { return x188_staticIntf; } - const rstl::reserved_vector, 846>& GetScanTimes() const { return x170_scanTimes; } + const rstl::reserved_vector, 846>& GetScanTimes() const { return x170_scanTimes; } CPlayerState(); CPlayerState(CBitStreamReader& stream); void PutTo(CBitStreamWriter& stream); diff --git a/Runtime/CResFactory.hpp b/Runtime/CResFactory.hpp index fd8163285..ba1913930 100644 --- a/Runtime/CResFactory.hpp +++ b/Runtime/CResFactory.hpp @@ -46,7 +46,7 @@ public: return x4_loader.GetResourceIdByName(name); } - FourCC GetResourceTypeById(ResId id) const + FourCC GetResourceTypeById(CAssetId id) const { return x4_loader.GetResourceTypeById(id); } diff --git a/Runtime/CResLoader.cpp b/Runtime/CResLoader.cpp index dfc9dcc8c..2ca6d4386 100644 --- a/Runtime/CResLoader.cpp +++ b/Runtime/CResLoader.cpp @@ -4,7 +4,7 @@ namespace urde { -const std::vector* CResLoader::GetTagListForFile(const std::string& name) const +const std::vector* CResLoader::GetTagListForFile(const std::string& name) const { std::string namePak = name + ".pak"; for (const std::unique_ptr& pak : x18_pakLoadedList) @@ -110,7 +110,7 @@ bool CResLoader::ResourceExists(const SObjectTag& tag) return FindResource(tag.id); } -FourCC CResLoader::GetResourceTypeById(u32 id) const +FourCC CResLoader::GetResourceTypeById(CAssetId id) const { if (FindResource(id)) return x50_cachedResInfo->x0_type; @@ -149,7 +149,7 @@ void CResLoader::AsyncIdlePakLoading() } } -bool CResLoader::FindResource(u32 id) const +bool CResLoader::FindResource(CAssetId id) const { for (const std::unique_ptr& file : x18_pakLoadedList) if (const_cast(this)->CacheFromPak(*file, id)) @@ -157,7 +157,7 @@ bool CResLoader::FindResource(u32 id) const return false; } -CPakFile* CResLoader::FindResourceForLoad(u32 id) +CPakFile* CResLoader::FindResourceForLoad(CAssetId id) { for (std::unique_ptr& file : x18_pakLoadedList) if (CacheFromPakForLoad(*file, id)) @@ -170,7 +170,7 @@ CPakFile* CResLoader::FindResourceForLoad(const SObjectTag& tag) return FindResourceForLoad(tag.id); } -bool CResLoader::CacheFromPakForLoad(CPakFile& file, u32 id) +bool CResLoader::CacheFromPakForLoad(CPakFile& file, CAssetId id) { const CPakFile::SResInfo* info = file.GetResInfoForLoad(id); if (info) @@ -182,7 +182,7 @@ bool CResLoader::CacheFromPakForLoad(CPakFile& file, u32 id) return false; } -bool CResLoader::CacheFromPak(const CPakFile& file, u32 id) +bool CResLoader::CacheFromPak(const CPakFile& file, CAssetId id) { const CPakFile::SResInfo* info = file.GetResInfo(id); if (info) diff --git a/Runtime/CResLoader.hpp b/Runtime/CResLoader.hpp index aef4596d8..d7ec499d6 100644 --- a/Runtime/CResLoader.hpp +++ b/Runtime/CResLoader.hpp @@ -19,10 +19,10 @@ class CResLoader std::list> x18_pakLoadedList; std::list> x30_pakLoadingList; u32 x44_pakLoadingCount = 0; - u32 x4c_cachedResId = -1; + CAssetId x4c_cachedResId; const CPakFile::SResInfo* x50_cachedResInfo = nullptr; public: - const std::vector* GetTagListForFile(const std::string& name) const; + const std::vector* GetTagListForFile(const std::string& name) const; void AddPakFileAsync(const std::string& name, bool samusPak, bool worldPak); void AddPakFile(const std::string& name, bool samusPak, bool worldPak); CInputStream* LoadNewResourcePartSync(const SObjectTag& tag, int offset, int length, void* extBuf); @@ -34,15 +34,15 @@ public: bool GetResourceCompression(const SObjectTag& tag); u32 ResourceSize(const SObjectTag& tag); bool ResourceExists(const SObjectTag& tag); - FourCC GetResourceTypeById(u32 id) const; + FourCC GetResourceTypeById(CAssetId id) const; const SObjectTag* GetResourceIdByName(const char* name) const; bool AreAllPaksLoaded() const; void AsyncIdlePakLoading(); - bool FindResource(u32 id) const; - CPakFile* FindResourceForLoad(u32 id); + bool FindResource(CAssetId id) const; + CPakFile* FindResourceForLoad(CAssetId id); CPakFile* FindResourceForLoad(const SObjectTag& tag); - bool CacheFromPakForLoad(CPakFile& file, u32 id); - bool CacheFromPak(const CPakFile& file, u32 id); + bool CacheFromPakForLoad(CPakFile& file, CAssetId id); + bool CacheFromPak(const CPakFile& file, CAssetId id); void MoveToCorrectLoadedList(std::unique_ptr&& file); }; diff --git a/Runtime/CSaveWorld.hpp b/Runtime/CSaveWorld.hpp index 2200c6d7a..df4043779 100644 --- a/Runtime/CSaveWorld.hpp +++ b/Runtime/CSaveWorld.hpp @@ -14,7 +14,7 @@ public: using EScanCategory = DataSpec::SAVWCommon::EScanCategory; struct SScanState { - ResId x0_id; + CAssetId x0_id; EScanCategory x4_category; }; diff --git a/Runtime/CScannableObjectInfo.cpp b/Runtime/CScannableObjectInfo.cpp index fd3364a1a..dbadf3fab 100644 --- a/Runtime/CScannableObjectInfo.cpp +++ b/Runtime/CScannableObjectInfo.cpp @@ -3,7 +3,7 @@ namespace urde { -CScannableObjectInfo::CScannableObjectInfo(CInputStream& in, ResId resId) : x0_scannableObjectId(resId) +CScannableObjectInfo::CScannableObjectInfo(CInputStream& in, CAssetId resId) : x0_scannableObjectId(resId) { u32 version = in.readUint32Big(); Load(in, version); diff --git a/Runtime/CScannableObjectInfo.hpp b/Runtime/CScannableObjectInfo.hpp index a46e45853..0756b06a0 100644 --- a/Runtime/CScannableObjectInfo.hpp +++ b/Runtime/CScannableObjectInfo.hpp @@ -17,7 +17,7 @@ public: struct SBucket { - ResId x0_texture = -1; + CAssetId x0_texture = -1; float x4_appearanceRange = 0.f; u32 x8_imagePos = 0; zeus::CVector2i xc_size; @@ -28,7 +28,7 @@ public: private: void Load(CInputStream&, u32); - ResId x0_scannableObjectId; + CAssetId x0_scannableObjectId; u32 x4_stringId = -1; float x8_totalDownloadTime = 0.f; u32 xc_category = 0; @@ -36,9 +36,9 @@ private: rstl::reserved_vector x14_buckets; public: - CScannableObjectInfo(CInputStream&, ResId); - ResId GetScannableObjectId() const { return x0_scannableObjectId; } - ResId GetStringTableId() const { return x4_stringId; } + CScannableObjectInfo(CInputStream&, CAssetId); + CAssetId GetScannableObjectId() const { return x0_scannableObjectId; } + CAssetId GetStringTableId() const { return x4_stringId; } float GetTotalDownloadTime() const { return x8_totalDownloadTime; } const SBucket& GetBucket(s32 idx) const { return x14_buckets[idx]; } u32 GetCategory() const { return xc_category; } diff --git a/Runtime/CStateManager.cpp b/Runtime/CStateManager.cpp index 3d46e70b8..95d986c39 100644 --- a/Runtime/CStateManager.cpp +++ b/Runtime/CStateManager.cpp @@ -1887,7 +1887,7 @@ void CStateManager::Update(float dt) { ShowPausedHUDMemo(xf88_, xf8c_); --xf84_; - xf88_ = -1; + xf88_.Reset(); } if (!dying && x904_gameState == EGameState::Running && !x870_cameraManager->IsInCinematicCamera()) @@ -2118,7 +2118,7 @@ void CStateManager::PostUpdatePlayer(float dt) x84c_player->PostUpdate(dt, *this); } -void CStateManager::ShowPausedHUDMemo(ResId strg, float time) +void CStateManager::ShowPausedHUDMemo(CAssetId strg, float time) { xf78_hudMessageTime = time; xf08_pauseHudMessage = strg; @@ -2142,7 +2142,7 @@ void CStateManager::FrameBegin(s32 frameCount) x8d4_inputFrameIdx = frameCount; } -void CStateManager::InitializeState(ResId mlvlId, TAreaId aid, ResId mreaId) +void CStateManager::InitializeState(CAssetId mlvlId, TAreaId aid, CAssetId mreaId) { bool hadRandom = x900_activeRandom != nullptr; SetActiveRandomToDefault(); @@ -2540,7 +2540,7 @@ std::pair CStateManager::CalculateScanCompletionRate() const u32 num = 0; u32 denom = 0; int idx = 0; - for (const std::pair& scan : x8b8_playerState->GetScanTimes()) + for (const std::pair& scan : x8b8_playerState->GetScanTimes()) { CSaveWorld::EScanCategory category = g_MemoryCardSys->GetScanStates()[idx++].second; if (category != CSaveWorld::EScanCategory::None && category != CSaveWorld::EScanCategory::Research) diff --git a/Runtime/CStateManager.hpp b/Runtime/CStateManager.hpp index 63a8ca235..e61de8ae8 100644 --- a/Runtime/CStateManager.hpp +++ b/Runtime/CStateManager.hpp @@ -62,7 +62,7 @@ struct SScriptObjectStream struct SOnScreenTex { - ResId x0_id = -1; + CAssetId x0_id = -1; zeus::CVector2i x4_origin; zeus::CVector2i xc_extent; }; @@ -207,7 +207,7 @@ private: u32 xef0_hintPeriods = 0; SOnScreenTex xef4_pendingScreenTex; - ResId xf08_pauseHudMessage = -1; + CAssetId xf08_pauseHudMessage = -1; float xf0c_escapeTimer = 0.f; float xf10_escapeTotalTime = 0.f; float xf14_curTimeMod900 = 0.f; @@ -232,8 +232,8 @@ private: float xf78_hudMessageTime = 0.f; CProjectedShadow* xf7c_projectedShadow = nullptr; u32 xf80_hudMessageFrameCount = 0; - ResId xf84_ = -1; - ResId xf88_ = -1; + s32 xf84_ = -1; + CAssetId xf88_ = -1; float xf8c_ = 0.f; EStateManagerTransition xf90_deferredTransition = EStateManagerTransition::InGame; @@ -361,10 +361,10 @@ public: void CrossTouchActors(); void ThinkEffectsAndActors(float dt); void PostUpdatePlayer(float dt); - void ShowPausedHUDMemo(ResId strg, float time); + void ShowPausedHUDMemo(CAssetId strg, float time); void ClearGraveyard(); void FrameBegin(s32 frameCount); - void InitializeState(ResId mlvlId, TAreaId aid, ResId mreaId); + void InitializeState(CAssetId mlvlId, TAreaId aid, CAssetId mreaId); void CreateStandardGameObjects(); const std::unique_ptr& GetObjectList() const { return x808_objLists[0]; } CObjectList* ObjectListById(EGameObjectList type); @@ -403,7 +403,7 @@ public: TUniqueId GetSkipCinematicSpecialFunction() const { return xf38_skipCineSpecialFunc; } void SetSkipCinematicSpecialFunction(TUniqueId id) { xf38_skipCineSpecialFunc = id; } float GetHUDMessageTime() const { return xf78_hudMessageTime; } - ResId GetPauseHUDMessage() const { return xf08_pauseHudMessage; } + CAssetId GetPauseHUDMessage() const { return xf08_pauseHudMessage; } void IncrementHUDMessageFrameCounter() { ++xf80_hudMessageFrameCount; } bool ShouldQuitGame() const { return xf94_25_quitGame; } void SetShouldQuitGame(bool should) { xf94_25_quitGame = should; } diff --git a/Runtime/Camera/CCameraFilter.cpp b/Runtime/Camera/CCameraFilter.cpp index 44c889951..305d1e33f 100644 --- a/Runtime/Camera/CCameraFilter.cpp +++ b/Runtime/Camera/CCameraFilter.cpp @@ -40,7 +40,7 @@ void CCameraFilterPass::Update(float dt) template void CCameraFilterPass::SetFilter(EFilterType type, EFilterShape shape, - float time, const zeus::CColor& color, ResId txtr) + float time, const zeus::CColor& color, CAssetId txtr) { if (time == 0.f) { @@ -65,7 +65,7 @@ void CCameraFilterPass::SetFilter(EFilterType type, EFilterShape shape, else { EFilterType origType = x0_curType; - ResId origTxtr = x20_nextTxtr; + CAssetId origTxtr = x20_nextTxtr; x1c_nextColor = color; x14_prevColor = x18_curColor; @@ -136,7 +136,7 @@ float CCameraFilterPassBase::GetT(bool invert) const } void CCameraFilterPassPoly::SetFilter(EFilterType type, EFilterShape shape, - float time, const zeus::CColor& color, ResId txtr) + float time, const zeus::CColor& color, CAssetId txtr) { if (!m_filter || m_shape != shape) { diff --git a/Runtime/Camera/CCameraFilter.hpp b/Runtime/Camera/CCameraFilter.hpp index b83dc1ced..d3b475863 100644 --- a/Runtime/Camera/CCameraFilter.hpp +++ b/Runtime/Camera/CCameraFilter.hpp @@ -46,13 +46,13 @@ protected: zeus::CColor x14_prevColor; zeus::CColor x18_curColor; zeus::CColor x1c_nextColor; - ResId x20_nextTxtr = -1; + CAssetId x20_nextTxtr = -1; TLockedToken x24_texObj; // Used to be auto_ptr float GetT(bool invert) const; public: virtual void Update(float dt)=0; virtual void SetFilter(EFilterType type, EFilterShape shape, - float time, const zeus::CColor& color, ResId txtr)=0; + float time, const zeus::CColor& color, CAssetId txtr)=0; virtual void DisableFilter(float time)=0; virtual void Draw() const=0; }; @@ -64,7 +64,7 @@ class CCameraFilterPass final : public CCameraFilterPassBase public: void Update(float dt); void SetFilter(EFilterType type, EFilterShape shape, - float time, const zeus::CColor& color, ResId txtr); + float time, const zeus::CColor& color, CAssetId txtr); void DisableFilter(float time); void Draw() const; }; @@ -76,7 +76,7 @@ class CCameraFilterPassPoly public: void Update(float dt) { if (m_filter) m_filter->Update(dt); } void SetFilter(EFilterType type, EFilterShape shape, - float time, const zeus::CColor& color, ResId txtr); + float time, const zeus::CColor& color, CAssetId txtr); void DisableFilter(float time) { if (m_filter) m_filter->DisableFilter(time); } void Draw() const { if (m_filter) m_filter->Draw(); } }; diff --git a/Runtime/Character/CAnimData.cpp b/Runtime/Character/CAnimData.cpp index 30f2c6d43..68724162c 100644 --- a/Runtime/Character/CAnimData.cpp +++ b/Runtime/Character/CAnimData.cpp @@ -40,7 +40,7 @@ void CAnimData::InitializeCache() { } -CAnimData::CAnimData(ResId id, +CAnimData::CAnimData(CAssetId id, const CCharacterInfo& character, int defaultAnim, int charIdx, bool loop, const TLockedToken& layout, @@ -97,7 +97,7 @@ CAnimData::CAnimData(ResId id, x1f8_animRoot = treeNode; } -ResId CAnimData::GetEventResourceIdForAnimResourceId(ResId id) const +CAssetId CAnimData::GetEventResourceIdForAnimResourceId(CAssetId id) const { return x0_charFactory->GetEventResourceIdForAnimResourceId(id); } diff --git a/Runtime/Character/CAnimData.hpp b/Runtime/Character/CAnimData.hpp index b672b58e0..b6109d5ad 100644 --- a/Runtime/Character/CAnimData.hpp +++ b/Runtime/Character/CAnimData.hpp @@ -98,7 +98,7 @@ class CAnimData u32 x104_ = 0; zeus::CAABox x108_aabb; CParticleDatabase x120_particleDB; - ResId x1d8_selfId; + CAssetId x1d8_selfId; zeus::CVector3f x1dc_alignPos; zeus::CQuaternion x1e8_alignRot; std::shared_ptr x1f8_animRoot; @@ -144,7 +144,7 @@ class CAnimData int m_drawInstCount; public: - CAnimData(ResId, + CAnimData(CAssetId, const CCharacterInfo& character, int defaultAnim, int charIdx, bool loop, const TLockedToken& layout, @@ -156,7 +156,7 @@ public: const TLockedToken& charFactory, int drawInstCount); - ResId GetEventResourceIdForAnimResourceId(ResId) const; + CAssetId GetEventResourceIdForAnimResourceId(CAssetId) const; void AddAdditiveSegData(const CSegIdList& list, CSegStatementSet& stSet); static SAdvancementResults AdvanceAdditiveAnim(std::shared_ptr& anim, const CCharAnimTime& time); SAdvancementDeltas AdvanceAdditiveAnims(float); diff --git a/Runtime/Character/CAnimSource.cpp b/Runtime/Character/CAnimSource.cpp index 26d6a8017..4d400d69a 100644 --- a/Runtime/Character/CAnimSource.cpp +++ b/Runtime/Character/CAnimSource.cpp @@ -133,7 +133,7 @@ CAnimSource::CAnimSource(CInputStream& in, IObjectStore& store) x40_data(RotationAndOffsetStorage::CRotationAndOffsetVectors(in), x10_frameCount), x54_evntId(in.readUint32Big()) { - if (x54_evntId) + if (x54_evntId.IsValid()) { x58_evntData = store.GetObj({SBIG('EVNT'), x54_evntId}); x58_evntData.GetObj(); diff --git a/Runtime/Character/CAnimSource.hpp b/Runtime/Character/CAnimSource.hpp index 4db67a0ec..d40062dc0 100644 --- a/Runtime/Character/CAnimSource.hpp +++ b/Runtime/Character/CAnimSource.hpp @@ -57,7 +57,7 @@ class CAnimSource std::vector x20_rotationChannels; std::vector x30_translationChannels; RotationAndOffsetStorage x40_data; - ResId x54_evntId; + CAssetId x54_evntId; TCachedToken x58_evntData; float x60_averageVelocity; diff --git a/Runtime/Character/CAnimationSet.cpp b/Runtime/Character/CAnimationSet.cpp index cf950e912..3ab071581 100644 --- a/Runtime/Character/CAnimationSet.cpp +++ b/Runtime/Character/CAnimationSet.cpp @@ -45,8 +45,8 @@ CAnimationSet::CAnimationSet(CInputStream& in) x50_animRes.reserve(animResourcesCount); for (u32 i=0 ; i> x28_additiveInfo; CAdditiveAnimationInfo x38_defaultAdditiveInfo; std::vector x40_halfTransitions; - std::vector> x50_animRes; + std::vector> x50_animRes; public: CAnimationSet(CInputStream& in); @@ -30,7 +30,7 @@ public: const std::vector& GetHalfTransitions() const { return x40_halfTransitions; } const std::vector>& GetAdditiveInfo() const { return x28_additiveInfo; } const CAdditiveAnimationInfo& GetDefaultAdditiveInfo() const { return x38_defaultAdditiveInfo; } - const std::vector>& GetAnimResIds() const { return x50_animRes; } + const std::vector>& GetAnimResIds() const { return x50_animRes; } }; } diff --git a/Runtime/Character/CAssetFactory.cpp b/Runtime/Character/CAssetFactory.cpp index d541dad6a..8f1d61dc4 100644 --- a/Runtime/Character/CAssetFactory.cpp +++ b/Runtime/Character/CAssetFactory.cpp @@ -40,7 +40,7 @@ const SObjectTag* CCharacterFactoryBuilder::CDummyFactory::GetResourceIdByName(c return nullptr; } -FourCC CCharacterFactoryBuilder::CDummyFactory::GetResourceTypeById(ResId id) const +FourCC CCharacterFactoryBuilder::CDummyFactory::GetResourceTypeById(CAssetId id) const { return {}; } diff --git a/Runtime/Character/CAssetFactory.hpp b/Runtime/Character/CAssetFactory.hpp index 5ea12e53f..33de79ad2 100644 --- a/Runtime/Character/CAssetFactory.hpp +++ b/Runtime/Character/CAssetFactory.hpp @@ -22,7 +22,7 @@ public: void CancelBuild(const SObjectTag&); bool CanBuild(const SObjectTag&); const SObjectTag* GetResourceIdByName(const char*) const; - FourCC GetResourceTypeById(ResId id) const; + FourCC GetResourceTypeById(CAssetId id) const; void EnumerateResources(const std::function& lambda) const; void EnumerateNamedResources(const std::function& lambda) const; diff --git a/Runtime/Character/CCharacterFactory.cpp b/Runtime/Character/CCharacterFactory.cpp index a75adf7cf..dbee90731 100644 --- a/Runtime/Character/CCharacterFactory.cpp +++ b/Runtime/Character/CCharacterFactory.cpp @@ -69,7 +69,7 @@ const SObjectTag* CCharacterFactory::CDummyFactory::GetResourceIdByName(const ch return nullptr; } -FourCC CCharacterFactory::CDummyFactory::GetResourceTypeById(ResId id) const +FourCC CCharacterFactory::CDummyFactory::GetResourceTypeById(CAssetId id) const { return {}; } @@ -125,8 +125,8 @@ CCharacterFactory::CreateCharacter(int charIdx, bool loop, ({FourCC(drawInsts << 16), charInfo.GetModelId()}, charParm); rstl::optional_object> iceModel; - if (charInfo.GetIceModelId() != kInvalidResId && - charInfo.GetIceSkinRulesId() != kInvalidResId) + if (charInfo.GetIceModelId().IsValid() && + charInfo.GetIceSkinRulesId().IsValid()) iceModel.emplace(const_cast(this)->x70_cacheResPool.GetObj ({FourCC((drawInsts << 16) | 1), charInfo.GetIceModelId()}, charParm)); @@ -136,15 +136,15 @@ CCharacterFactory::CreateCharacter(int charIdx, bool loop, factory, drawInsts); } -ResId CCharacterFactory::GetEventResourceIdForAnimResourceId(ResId id) const +CAssetId CCharacterFactory::GetEventResourceIdForAnimResourceId(CAssetId id) const { auto search = std::find_if(x58_animResources.cbegin(), x58_animResources.cend(), - [&](const std::pair& elem) -> bool + [&](const std::pair& elem) -> bool { return id == elem.first; }); if (search == x58_animResources.cend()) - return kInvalidResId; + return CAssetId(); return search->second; } @@ -189,7 +189,7 @@ CCharacterFactory::GetCharLayoutInfoDB(CSimplePool& store, CCharacterFactory::CCharacterFactory(CSimplePool& store, const CAnimCharacterSet& ancs, - ResId selfId) + CAssetId selfId) : x4_charInfoDB(GetCharacterInfoDB(ancs)), x14_charLayoutInfoDB(GetCharLayoutInfoDB(store, x4_charInfoDB)), x24_sysContext(std::make_shared( diff --git a/Runtime/Character/CCharacterFactory.hpp b/Runtime/Character/CCharacterFactory.hpp index 254d231cc..aa2e912a0 100644 --- a/Runtime/Character/CCharacterFactory.hpp +++ b/Runtime/Character/CCharacterFactory.hpp @@ -31,7 +31,7 @@ public: void CancelBuild(const SObjectTag&); bool CanBuild(const SObjectTag&); const SObjectTag* GetResourceIdByName(const char*) const; - FourCC GetResourceTypeById(ResId id) const; + FourCC GetResourceTypeById(CAssetId id) const; void EnumerateResources(const std::function& lambda) const; void EnumerateNamedResources(const std::function& lambda) const; @@ -52,8 +52,8 @@ private: std::vector> x30_animSourceDB; std::vector> x40_additiveInfo; CAdditiveAnimationInfo x50_defaultAdditiveInfo; - std::vector> x58_animResources; - ResId x68_selfId; + std::vector> x58_animResources; + CAssetId x68_selfId; CDummyFactory x6c_dummyFactory; CSimplePool x70_cacheResPool; @@ -63,12 +63,12 @@ private: const std::vector& chars); public: - CCharacterFactory(CSimplePool& store, const CAnimCharacterSet& ancs, ResId); + CCharacterFactory(CSimplePool& store, const CAnimCharacterSet& ancs, CAssetId); std::unique_ptr CreateCharacter(int charIdx, bool loop, const TLockedToken& factory, int defaultAnim, int drawInsts) const; - ResId GetEventResourceIdForAnimResourceId(ResId animId) const; + CAssetId GetEventResourceIdForAnimResourceId(CAssetId animId) const; const CCharacterInfo& GetCharInfo(int charIdx) const { return x4_charInfoDB[charIdx]; } const CAdditiveAnimationInfo& FindAdditiveInfo(u32 idx) const; diff --git a/Runtime/Character/CCharacterInfo.hpp b/Runtime/Character/CCharacterInfo.hpp index 6bdbf0797..a5ecc97d5 100644 --- a/Runtime/Character/CCharacterInfo.hpp +++ b/Runtime/Character/CCharacterInfo.hpp @@ -15,18 +15,18 @@ class CCharacterInfo public: struct CParticleResData { - std::vector x0_part; - std::vector x10_swhc; - std::vector x20_elsc; - std::vector x30_elsc; + std::vector x0_part; + std::vector x10_swhc; + std::vector x20_elsc; + std::vector x30_elsc; CParticleResData(CInputStream& in, u16 tableCount); }; private: u16 x0_tableCount; std::string x4_name; - ResId x14_cmdl; - ResId x18_cskr; - ResId x1c_cinf; + CAssetId x14_cmdl; + CAssetId x18_cskr; + CAssetId x1c_cinf; std::vector>> x20_animInfo; CPASDatabase x30_pasDatabase; CParticleResData x44_partRes; @@ -34,8 +34,8 @@ private: std::vector> x88_aabbs; std::vector>> x98_effects; - ResId xa8_cmdlOverlay = 0; - ResId xac_cskrOverlay = 0; + CAssetId xa8_cmdlOverlay = 0; + CAssetId xac_cskrOverlay = 0; std::vector xb0_animIdxs; @@ -43,14 +43,14 @@ public: CCharacterInfo(CInputStream& in); const std::string& GetCharacterName() const { return x4_name; } - ResId GetModelId() const {return x14_cmdl;} - ResId GetSkinRulesId() const {return x18_cskr;} - ResId GetCharLayoutInfoId() const {return x1c_cinf;} + CAssetId GetModelId() const {return x14_cmdl;} + CAssetId GetSkinRulesId() const {return x18_cskr;} + CAssetId GetCharLayoutInfoId() const {return x1c_cinf;} const std::vector>& GetAnimBBoxList() const { return x88_aabbs; } - ResId GetIceModelId() const {return xa8_cmdlOverlay;} - ResId GetIceSkinRulesId() const {return xac_cskrOverlay;} + CAssetId GetIceModelId() const {return xa8_cmdlOverlay;} + CAssetId GetIceSkinRulesId() const {return xac_cskrOverlay;} const CParticleResData& GetParticleResData() const {return x44_partRes;} u32 GetAnimationIndex(u32 idx) const { return xb0_animIdxs.at(idx); } diff --git a/Runtime/Character/CFBStreamedCompression.cpp b/Runtime/Character/CFBStreamedCompression.cpp index b8d9326a5..f7c9874ae 100644 --- a/Runtime/Character/CFBStreamedCompression.cpp +++ b/Runtime/Character/CFBStreamedCompression.cpp @@ -12,7 +12,7 @@ CFBStreamedCompression::CFBStreamedCompression(CInputStream& in, IObjectStore& o xc_rotsAndOffs = GetRotationsAndOffsets(x0_scratchSize / 4 + 1, in); - if (x4_evnt) + if (x4_evnt.IsValid()) x8_evntToken = objStore.GetObj(SObjectTag{FOURCC('EVNT'), x4_evnt}); x10_averageVelocity = CalculateAverageVelocity(GetPerChannelHeaders()); diff --git a/Runtime/Character/CFBStreamedCompression.hpp b/Runtime/Character/CFBStreamedCompression.hpp index 9d375f907..94db9474a 100644 --- a/Runtime/Character/CFBStreamedCompression.hpp +++ b/Runtime/Character/CFBStreamedCompression.hpp @@ -55,7 +55,7 @@ public: private: bool m_pc; u32 x0_scratchSize; - ResId x4_evnt; + CAssetId x4_evnt; TLockedToken x8_evntToken; std::unique_ptr xc_rotsAndOffs; float x10_averageVelocity; diff --git a/Runtime/Character/CModelData.cpp b/Runtime/Character/CModelData.cpp index 9901db65c..f56eac423 100644 --- a/Runtime/Character/CModelData.cpp +++ b/Runtime/Character/CModelData.cpp @@ -99,13 +99,13 @@ const std::unique_ptr& CModelData::PickStaticModel(EWhichModel which) return m_normalModelInst; } -void CModelData::SetXRayModel(const std::pair& modelSkin) +void CModelData::SetXRayModel(const std::pair& modelSkin) { - if (modelSkin.first) + if (modelSkin.first.IsValid()) { if (g_ResFactory->GetResourceTypeById(modelSkin.first) == SBIG('CMDL')) { - if (x10_animData && modelSkin.second && + if (x10_animData && modelSkin.second.IsValid() && g_ResFactory->GetResourceTypeById(modelSkin.second) == SBIG('CSKR')) { x10_animData->SetXRayModel(g_SimplePool->GetObj({SBIG('CMDL'), modelSkin.first}), @@ -122,13 +122,13 @@ void CModelData::SetXRayModel(const std::pair& modelSkin) } } -void CModelData::SetInfraModel(const std::pair& modelSkin) +void CModelData::SetInfraModel(const std::pair& modelSkin) { - if (modelSkin.first) + if (modelSkin.first.IsValid()) { if (g_ResFactory->GetResourceTypeById(modelSkin.first) == SBIG('CMDL')) { - if (x10_animData && modelSkin.second && + if (x10_animData && modelSkin.second.IsValid() && g_ResFactory->GetResourceTypeById(modelSkin.second) == SBIG('CSKR')) { x10_animData->SetInfraModel(g_SimplePool->GetObj({SBIG('CMDL'), modelSkin.first}), diff --git a/Runtime/Character/CModelData.hpp b/Runtime/Character/CModelData.hpp index bb645f2e4..0d9bf863b 100644 --- a/Runtime/Character/CModelData.hpp +++ b/Runtime/Character/CModelData.hpp @@ -23,22 +23,22 @@ struct SAdvancementDeltas; class CStaticRes { - ResId x0_cmdlId = 0; + CAssetId x0_cmdlId = 0; zeus::CVector3f x4_scale; public: - CStaticRes(ResId id, const zeus::CVector3f& scale) + CStaticRes(CAssetId id, const zeus::CVector3f& scale) : x0_cmdlId(id), x4_scale(scale) {} - ResId GetId() const { return x0_cmdlId; } + CAssetId GetId() const { return x0_cmdlId; } const zeus::CVector3f& GetScale() const { return x4_scale; } operator bool() const { return x0_cmdlId != 0; } }; class CAnimRes { - ResId x0_ancsId = -1; + CAssetId x0_ancsId = -1; s32 x4_charIdx = -1; zeus::CVector3f x8_scale; bool x14_canLoop = false; @@ -46,7 +46,7 @@ class CAnimRes s32 x18_defaultAnim = -1; /* NOTE: used to be x1c in demo */ public: CAnimRes() = default; - CAnimRes(ResId ancs, s32 charIdx, const zeus::CVector3f& scale, const s32 defaultAnim, bool loop) + CAnimRes(CAssetId ancs, s32 charIdx, const zeus::CVector3f& scale, const s32 defaultAnim, bool loop) : x0_ancsId(ancs), x4_charIdx(charIdx), x8_scale(scale), @@ -55,7 +55,7 @@ public: { } - ResId GetId() const { return x0_ancsId; } + CAssetId GetId() const { return x0_ancsId; } s32 GetCharacterNodeId() const { return x4_charIdx; } const zeus::CVector3f& GetScale() const { return x8_scale; } bool CanLoop() const { return x14_canLoop; } @@ -113,8 +113,8 @@ public: static EWhichModel GetRenderingModel(const CStateManager& stateMgr); CSkinnedModel& PickAnimatedModel(EWhichModel which) const; const std::unique_ptr& PickStaticModel(EWhichModel which) const; - void SetXRayModel(const std::pair& modelSkin); - void SetInfraModel(const std::pair& modelSkin); + void SetXRayModel(const std::pair& modelSkin); + void SetInfraModel(const std::pair& modelSkin); bool IsDefinitelyOpaque(EWhichModel); bool GetIsLoop() const; float GetAnimationDuration(int) const; diff --git a/Runtime/Character/CParticleDatabase.cpp b/Runtime/Character/CParticleDatabase.cpp index eee8e0f66..559a0fb2e 100644 --- a/Runtime/Character/CParticleDatabase.cpp +++ b/Runtime/Character/CParticleDatabase.cpp @@ -18,21 +18,21 @@ CParticleDatabase::CParticleDatabase() void CParticleDatabase::CacheParticleDesc(const CCharacterInfo::CParticleResData& desc) { - for (ResId id : desc.x0_part) + for (CAssetId id : desc.x0_part) { auto search = x0_particleDescs.find(id); if (search == x0_particleDescs.cend()) x0_particleDescs[id] = std::make_shared>( g_SimplePool->GetObj(SObjectTag{FOURCC('PART'), id})); } - for (ResId id : desc.x10_swhc) + for (CAssetId id : desc.x10_swhc) { auto search = x14_swooshDescs.find(id); if (search == x14_swooshDescs.cend()) x14_swooshDescs[id] = std::make_shared>( g_SimplePool->GetObj(SObjectTag{FOURCC('SWHC'), id})); } - for (ResId id : desc.x20_elsc) + for (CAssetId id : desc.x20_elsc) { auto search = x28_electricDescs.find(id); if (search == x28_electricDescs.cend()) @@ -355,10 +355,10 @@ void CParticleDatabase::SetCEXTValue(const std::string& name, int idx, float val } template -static int _getGraphicLightId(const T& system, const U& desc) +static s32 _getGraphicLightId(const T& system, const U& desc) { if (system->SystemHasLight()) - return desc.GetObjectTag()->id; + return s32(desc.GetObjectTag()->id.Value()); return -1; } diff --git a/Runtime/Character/CParticleDatabase.hpp b/Runtime/Character/CParticleDatabase.hpp index 9fe2355da..8e79b58ee 100644 --- a/Runtime/Character/CParticleDatabase.hpp +++ b/Runtime/Character/CParticleDatabase.hpp @@ -17,9 +17,9 @@ class CCharLayoutInfo; class CParticleDatabase { - std::map>> x0_particleDescs; - std::map>> x14_swooshDescs; - std::map>> x28_electricDescs; + std::map>> x0_particleDescs; + std::map>> x14_swooshDescs; + std::map>> x28_electricDescs; std::map> x3c_rendererDrawLoop; std::map> x50_firstDrawLoop; std::map> x64_lastDrawLoop; diff --git a/Runtime/Character/CPrimitive.hpp b/Runtime/Character/CPrimitive.hpp index 1adabc3c6..19ceec0c2 100644 --- a/Runtime/Character/CPrimitive.hpp +++ b/Runtime/Character/CPrimitive.hpp @@ -9,12 +9,12 @@ namespace urde class CPrimitive { - ResId x0_animId; + CAssetId x0_animId; u32 x4_animIdx; std::string x8_animName; public: CPrimitive(CInputStream& in); - ResId GetAnimResId() const { return x0_animId; } + CAssetId GetAnimResId() const { return x0_animId; } u32 GetAnimDbIdx() const { return x4_animIdx; } const std::string& GetName() const { return x8_animName; } bool operator<(const CPrimitive& other) const { return x8_animName < other.x8_animName; } diff --git a/Runtime/Collision/CCollisionResponseData.cpp b/Runtime/Collision/CCollisionResponseData.cpp index b43f6a32c..bbb66cee6 100644 --- a/Runtime/Collision/CCollisionResponseData.cpp +++ b/Runtime/Collision/CCollisionResponseData.cpp @@ -70,7 +70,7 @@ void CCollisionResponseData::AddParticleSystemToResponse(EWeaponCollisionRespons CSimplePool* resPool) { int i = int(type); - std::vector tracker; + std::vector tracker; tracker.resize(8); x0_generators[i].emplace(CPF::GetChildGeneratorDesc(in, resPool, tracker).m_token); } @@ -86,8 +86,8 @@ bool CCollisionResponseData::CheckAndAddDecalToResponse(FourCC clsId, CInputStre if (cls == SBIG('NONE')) return true; - ResId id = CPF::GetInt(in); - if (!id) + CAssetId id = u64(CPF::GetInt(in)); + if (!id.IsValid()) return true; x20_decals[i].emplace(resPool->GetObj({FOURCC('DPSC'), id})); diff --git a/Runtime/Graphics/CSkinnedModel.cpp b/Runtime/Graphics/CSkinnedModel.cpp index 2dad5aca9..05824b543 100644 --- a/Runtime/Graphics/CSkinnedModel.cpp +++ b/Runtime/Graphics/CSkinnedModel.cpp @@ -20,8 +20,8 @@ CSkinnedModel::CSkinnedModel(TLockedToken model, m_modelInst = model->MakeNewInstance(shaderIdx, drawInsts); } -CSkinnedModel::CSkinnedModel(IObjectStore& store, ResId model, - ResId skinRules, ResId layoutInfo, +CSkinnedModel::CSkinnedModel(IObjectStore& store, CAssetId model, + CAssetId skinRules, CAssetId layoutInfo, int shaderIdx, int drawInsts) : CSkinnedModel(store.GetObj(SObjectTag{FOURCC('CMDL'), model}), store.GetObj(SObjectTag{FOURCC('CSKR'), skinRules}), @@ -44,8 +44,8 @@ void CSkinnedModel::Draw(const CModelFlags& drawFlags) const m_modelInst->DrawSurfaces(drawFlags); } -CMorphableSkinnedModel::CMorphableSkinnedModel(IObjectStore& store, ResId model, - ResId skinRules, ResId layoutInfo, +CMorphableSkinnedModel::CMorphableSkinnedModel(IObjectStore& store, CAssetId model, + CAssetId skinRules, CAssetId layoutInfo, int shaderIdx, int drawInsts) : CSkinnedModel(store, model, skinRules, layoutInfo, shaderIdx, drawInsts) { diff --git a/Runtime/Graphics/CSkinnedModel.hpp b/Runtime/Graphics/CSkinnedModel.hpp index e24e1f90e..1c991820f 100644 --- a/Runtime/Graphics/CSkinnedModel.hpp +++ b/Runtime/Graphics/CSkinnedModel.hpp @@ -31,8 +31,8 @@ public: TLockedToken skinRules, TLockedToken layoutInfo, int shaderIdx, int drawInsts); - CSkinnedModel(IObjectStore& store, ResId model, ResId skinRules, - ResId layoutInfo, int shaderIdx, int drawInsts); + CSkinnedModel(IObjectStore& store, CAssetId model, CAssetId skinRules, + CAssetId layoutInfo, int shaderIdx, int drawInsts); const TLockedToken& GetModel() const {return x4_model;} const std::unique_ptr& GetModelInst() const {return m_modelInst;} @@ -58,8 +58,8 @@ public: class CMorphableSkinnedModel : public CSkinnedModel { public: - CMorphableSkinnedModel(IObjectStore& store, ResId model, ResId skinRules, - ResId layoutInfo, int shaderIdx, int drawInsts); + CMorphableSkinnedModel(IObjectStore& store, CAssetId model, CAssetId skinRules, + CAssetId layoutInfo, int shaderIdx, int drawInsts); }; } diff --git a/Runtime/GuiSys/CAuiEnergyBarT01.cpp b/Runtime/GuiSys/CAuiEnergyBarT01.cpp index 555f69ad2..45cad1e3f 100644 --- a/Runtime/GuiSys/CAuiEnergyBarT01.cpp +++ b/Runtime/GuiSys/CAuiEnergyBarT01.cpp @@ -6,7 +6,7 @@ namespace urde { -CAuiEnergyBarT01::CAuiEnergyBarT01(const CGuiWidgetParms& parms, CSimplePool* sp, ResId txtrId) +CAuiEnergyBarT01::CAuiEnergyBarT01(const CGuiWidgetParms& parms, CSimplePool* sp, CAssetId txtrId) : CGuiWidget(parms), xb8_txtrId(txtrId) { if (g_GuiSys->GetUsageMode() != CGuiSys::EUsageMode::Two) @@ -166,7 +166,7 @@ void CAuiEnergyBarT01::SetMaxEnergy(float maxEnergy) std::shared_ptr CAuiEnergyBarT01::Create(CGuiFrame* frame, CInputStream& in, CSimplePool* sp) { CGuiWidgetParms parms = ReadWidgetHeader(frame, in); - ResId tex = in.readUint32Big(); + CAssetId tex = in.readUint32Big(); std::shared_ptr ret = std::make_shared(parms, sp, tex); ret->ParseBaseInfo(frame, in, parms); return ret; diff --git a/Runtime/GuiSys/CAuiEnergyBarT01.hpp b/Runtime/GuiSys/CAuiEnergyBarT01.hpp index 2ad1ef028..4aa7a8eae 100644 --- a/Runtime/GuiSys/CAuiEnergyBarT01.hpp +++ b/Runtime/GuiSys/CAuiEnergyBarT01.hpp @@ -21,7 +21,7 @@ public: Insta }; private: - ResId xb8_txtrId; + CAssetId xb8_txtrId; TLockedToken xbc_tex; // Used to be optional zeus::CColor xcc_emptyColor; zeus::CColor xd0_filledColor; @@ -41,7 +41,7 @@ private: CEnergyBarShader m_energyBarShader; std::vector m_verts[3]; public: - CAuiEnergyBarT01(const CGuiWidgetParms& parms, CSimplePool* sp, ResId txtrId); + CAuiEnergyBarT01(const CGuiWidgetParms& parms, CSimplePool* sp, CAssetId txtrId); FourCC GetWidgetTypeID() const { return FOURCC('ENRG'); } static std::pair DownloadBarCoordFunc(float t); void Update(float dt); diff --git a/Runtime/GuiSys/CAuiImagePane.cpp b/Runtime/GuiSys/CAuiImagePane.cpp index 4215b2ed1..ef332e0e3 100644 --- a/Runtime/GuiSys/CAuiImagePane.cpp +++ b/Runtime/GuiSys/CAuiImagePane.cpp @@ -6,7 +6,7 @@ namespace urde { -CAuiImagePane::CAuiImagePane(const CGuiWidgetParms& parms, CSimplePool* sp, ResId tex0, ResId tex1, +CAuiImagePane::CAuiImagePane(const CGuiWidgetParms& parms, CSimplePool* sp, CAssetId tex0, CAssetId tex1, rstl::reserved_vector&& coords, rstl::reserved_vector&& uvs, bool initTex) : CGuiWidget(parms), xc8_tex0(tex0), xcc_tex1(tex1), xe0_coords(std::move(coords)), @@ -190,7 +190,7 @@ bool CAuiImagePane::GetIsFinishedLoadingWidgetSpecific() const return xb8_tex0Tok.IsLoaded(); } -void CAuiImagePane::SetTextureID0(ResId tex, CSimplePool* sp) +void CAuiImagePane::SetTextureID0(CAssetId tex, CSimplePool* sp) { xc8_tex0 = tex; if (!sp) diff --git a/Runtime/GuiSys/CAuiImagePane.hpp b/Runtime/GuiSys/CAuiImagePane.hpp index f0e8978fe..d4e22aa83 100644 --- a/Runtime/GuiSys/CAuiImagePane.hpp +++ b/Runtime/GuiSys/CAuiImagePane.hpp @@ -13,8 +13,8 @@ class CTexture; class CAuiImagePane : public CGuiWidget { TLockedToken xb8_tex0Tok; // Used to be optional - ResId xc8_tex0; - ResId xcc_tex1; + CAssetId xc8_tex0; + CAssetId xcc_tex1; zeus::CVector2f xd0_uvBias0; zeus::CVector2f xd8_uvBias1; rstl::reserved_vector xe0_coords; @@ -37,7 +37,7 @@ class CAuiImagePane : public CGuiWidget void DoDrawImagePane(const zeus::CColor& color, const CTexture& tex, int frame, float blurAmt, bool noBlur, CTexturedQuadFilterAlpha& quad) const; public: - CAuiImagePane(const CGuiWidgetParms& parms, CSimplePool* sp, ResId, ResId, + CAuiImagePane(const CGuiWidgetParms& parms, CSimplePool* sp, CAssetId, CAssetId, rstl::reserved_vector&& coords, rstl::reserved_vector&& uvs, bool initTex); FourCC GetWidgetTypeID() const { return FOURCC('IMGP'); } @@ -46,7 +46,7 @@ public: void Update(float dt); void Draw(const CGuiWidgetDrawParms& params) const; bool GetIsFinishedLoadingWidgetSpecific() const; - void SetTextureID0(ResId tex, CSimplePool* sp); + void SetTextureID0(CAssetId tex, CSimplePool* sp); void SetAnimationParms(const zeus::CVector2f& vec, float interval, float duration); void SetDeResFactor(float d) { x14c_deResFactor = d; } void SetFlashFactor(float t) { x150_flashFactor = t; } diff --git a/Runtime/GuiSys/CGuiFrame.cpp b/Runtime/GuiSys/CGuiFrame.cpp index 5844b9323..97b8ff1ad 100644 --- a/Runtime/GuiSys/CGuiFrame.cpp +++ b/Runtime/GuiSys/CGuiFrame.cpp @@ -13,7 +13,7 @@ namespace urde { -CGuiFrame::CGuiFrame(ResId id, CGuiSys& sys, int a, int b, int c, CSimplePool* sp) +CGuiFrame::CGuiFrame(CAssetId id, CGuiSys& sys, int a, int b, int c, CSimplePool* sp) : x0_id(id), x8_guiSys(sys), x4c_a(a), x50_b(b), x54_c(c), x58_24_loaded(false) { x3c_lights.reserve(8); @@ -208,7 +208,7 @@ void CGuiFrame::ProcessUserInput(const CFinalInput& input) const } } -std::unique_ptr CGuiFrame::CreateFrame(ResId frmeId, CGuiSys& sys, CInputStream& in, CSimplePool* sp) +std::unique_ptr CGuiFrame::CreateFrame(CAssetId frmeId, CGuiSys& sys, CInputStream& in, CSimplePool* sp) { in.readInt32Big(); int a = in.readInt32Big(); diff --git a/Runtime/GuiSys/CGuiFrame.hpp b/Runtime/GuiSys/CGuiFrame.hpp index 1239c1612..5a715ac2d 100644 --- a/Runtime/GuiSys/CGuiFrame.hpp +++ b/Runtime/GuiSys/CGuiFrame.hpp @@ -23,7 +23,7 @@ class CGuiFrame { friend class CGuiSys; private: - ResId x0_id; + CAssetId x0_id; u32 x4_ = 0; CGuiSys& x8_guiSys; std::shared_ptr xc_headWidget; @@ -42,7 +42,7 @@ private: float m_aspectConstraint = -1.f; public: - CGuiFrame(ResId id, CGuiSys& sys, int a, int b, int c, CSimplePool* sp); + CGuiFrame(CAssetId id, CGuiSys& sys, int a, int b, int c, CSimplePool* sp); ~CGuiFrame(); CGuiSys& GetGuiSys() {return x8_guiSys;} @@ -73,7 +73,7 @@ public: CGuiWidgetIdDB& GetWidgetIdDB() {return x18_idDB;} - static std::unique_ptr CreateFrame(ResId frmeId, CGuiSys& sys, CInputStream& in, CSimplePool* sp); + static std::unique_ptr CreateFrame(CAssetId frmeId, CGuiSys& sys, CInputStream& in, CSimplePool* sp); }; std::unique_ptr RGuiFrameFactoryInGame(const SObjectTag& tag, CInputStream& in, diff --git a/Runtime/GuiSys/CGuiModel.cpp b/Runtime/GuiSys/CGuiModel.cpp index b5862a47e..3da8118aa 100644 --- a/Runtime/GuiSys/CGuiModel.cpp +++ b/Runtime/GuiSys/CGuiModel.cpp @@ -8,7 +8,7 @@ namespace urde { -CGuiModel::CGuiModel(const CGuiWidgetParms& parms, CSimplePool* sp, ResId modelId, u32 lightMask, bool flag) +CGuiModel::CGuiModel(const CGuiWidgetParms& parms, CSimplePool* sp, CAssetId modelId, u32 lightMask, bool flag) : CGuiWidget(parms), x108_modelId(modelId), x10c_lightMask(lightMask) { if (!flag || modelId == 0xffffffff || @@ -18,7 +18,7 @@ CGuiModel::CGuiModel(const CGuiWidgetParms& parms, CSimplePool* sp, ResId modelI xf8_model = sp->GetObj({SBIG('CMDL'), modelId}); } -std::vector CGuiModel::GetModelAssets() const +std::vector CGuiModel::GetModelAssets() const { return {x108_modelId}; } @@ -119,7 +119,7 @@ std::shared_ptr CGuiModel::Create(CGuiFrame* frame, CInputStream& in { CGuiWidgetParms parms = ReadWidgetHeader(frame, in); - ResId model = in.readUint32Big(); + CAssetId model = in.readUint32Big(); in.readUint32Big(); u32 lightMask = in.readUint32Big(); diff --git a/Runtime/GuiSys/CGuiModel.hpp b/Runtime/GuiSys/CGuiModel.hpp index 24aa44559..aa39e4d3d 100644 --- a/Runtime/GuiSys/CGuiModel.hpp +++ b/Runtime/GuiSys/CGuiModel.hpp @@ -12,13 +12,13 @@ class CSimplePool; class CGuiModel : public CGuiWidget { TLockedToken xf8_model; - ResId x108_modelId; + CAssetId x108_modelId; u32 x10c_lightMask; public: - CGuiModel(const CGuiWidgetParms& parms, CSimplePool* sp, ResId modelId, u32 lightMask, bool flag); + CGuiModel(const CGuiWidgetParms& parms, CSimplePool* sp, CAssetId modelId, u32 lightMask, bool flag); FourCC GetWidgetTypeID() const { return FOURCC('MODL'); } - std::vector GetModelAssets() const; + std::vector GetModelAssets() const; bool GetIsFinishedLoadingWidgetSpecific() const; void Touch() const; void Draw(const CGuiWidgetDrawParms& parms) const; diff --git a/Runtime/GuiSys/CGuiTextPane.cpp b/Runtime/GuiSys/CGuiTextPane.cpp index 6a1f205f6..a1da2e14b 100644 --- a/Runtime/GuiSys/CGuiTextPane.cpp +++ b/Runtime/GuiSys/CGuiTextPane.cpp @@ -10,7 +10,7 @@ namespace urde { CGuiTextPane::CGuiTextPane(const CGuiWidgetParms& parms, CSimplePool* sp, const zeus::CVector2f& dim, - const zeus::CVector3f& vec, ResId fontId, const CGuiTextProperties& props, + const zeus::CVector3f& vec, CAssetId fontId, const CGuiTextProperties& props, const zeus::CColor& fontCol, const zeus::CColor& outlineCol, s32 extentX, s32 extentY) : CGuiPane(parms, dim, vec), xd4_textSupport(fontId, props, fontCol, outlineCol, diff --git a/Runtime/GuiSys/CGuiTextPane.hpp b/Runtime/GuiSys/CGuiTextPane.hpp index 911849faa..e1270cff6 100644 --- a/Runtime/GuiSys/CGuiTextPane.hpp +++ b/Runtime/GuiSys/CGuiTextPane.hpp @@ -12,7 +12,7 @@ class CGuiTextPane : public CGuiPane CGuiTextSupport xd4_textSupport; public: CGuiTextPane(const CGuiWidgetParms& parms, CSimplePool* sp, const zeus::CVector2f& dim, - const zeus::CVector3f& vec, ResId fontId, const CGuiTextProperties& props, + const zeus::CVector3f& vec, CAssetId fontId, const CGuiTextProperties& props, const zeus::CColor& col1, const zeus::CColor& col2, s32 padX, s32 padY); FourCC GetWidgetTypeID() const { return FOURCC('TXPN'); } @@ -20,7 +20,7 @@ public: const CGuiTextSupport& GetTextSupport() const { return xd4_textSupport; } void Update(float dt); bool GetIsFinishedLoadingWidgetSpecific() const; - std::vector GetFontAssets() const { return {xd4_textSupport.x5c_fontId}; } + std::vector GetFontAssets() const { return {xd4_textSupport.x5c_fontId}; } void SetDimensions(const zeus::CVector2f& dim, bool initVBO); void ScaleDimensions(const zeus::CVector3f& scale); void Draw(const CGuiWidgetDrawParms& parms) const; diff --git a/Runtime/GuiSys/CGuiTextSupport.cpp b/Runtime/GuiSys/CGuiTextSupport.cpp index 0c21f8ee2..d1208b378 100644 --- a/Runtime/GuiSys/CGuiTextSupport.cpp +++ b/Runtime/GuiSys/CGuiTextSupport.cpp @@ -11,7 +11,7 @@ namespace urde { -CGuiTextSupport::CGuiTextSupport(ResId fontId, const CGuiTextProperties& props, +CGuiTextSupport::CGuiTextSupport(CAssetId fontId, const CGuiTextProperties& props, const zeus::CColor& fontCol, const zeus::CColor& outlineCol, const zeus::CColor& geomCol, s32 padX, s32 padY, CSimplePool* store, CGuiWidget::EGuiModelDrawFlags drawFlags) @@ -144,8 +144,8 @@ void CGuiTextSupport::CheckAndRebuildTextBuffer() g_TextExecuteBuf->AddColor(EColorType::Outline, x28_outlineColor); std::u16string initStr; - if (x5c_fontId != kInvalidResId) - initStr = hecl::Char16Format(L"&font=%08X;", u32(x5c_fontId)); + if (x5c_fontId.IsValid()) + initStr = hecl::Char16Format(L"&font=%08X;", u32(x5c_fontId.Value())); initStr += x0_string; g_TextParser->ParseText(*g_TextExecuteBuf, initStr.c_str(), initStr.size(), x14_props.xc_txtrMap); @@ -308,7 +308,7 @@ bool CGuiTextSupport::GetIsTextSupportFinishedLoading() const return _GetIsTextSupportFinishedLoading(); } -void CGuiTextSupport::SetControlTXTRMap(const std::vector>* txtrMap) +void CGuiTextSupport::SetControlTXTRMap(const std::vector>* txtrMap) { if (x14_props.xc_txtrMap != txtrMap) { diff --git a/Runtime/GuiSys/CGuiTextSupport.hpp b/Runtime/GuiSys/CGuiTextSupport.hpp index 6545697a7..73e6bc5b4 100644 --- a/Runtime/GuiSys/CGuiTextSupport.hpp +++ b/Runtime/GuiSys/CGuiTextSupport.hpp @@ -67,11 +67,11 @@ class CGuiTextProperties bool x1_horizontal; EJustification x4_justification; EVerticalJustification x8_vertJustification; - const std::vector>* xc_txtrMap; + const std::vector>* xc_txtrMap; public: CGuiTextProperties(bool wordWrap, bool horizontal, EJustification justification, EVerticalJustification vertJustification, - const std::vector>* txtrMap=nullptr) + const std::vector>* txtrMap=nullptr) : x0_wordWrap(wordWrap), x1_horizontal(horizontal), x4_justification(justification), x8_vertJustification(vertJustification), xc_txtrMap(txtrMap) {} }; @@ -93,7 +93,7 @@ class CGuiTextSupport bool x50_typeEnable = false; float x54_chFadeTime = 0.1f; float x58_chRate = 10.0f; - ResId x5c_fontId = kInvalidResId; + CAssetId x5c_fontId; CGuiWidget::EGuiModelDrawFlags m_drawFlags; std::experimental::optional x60_renderBuf; std::vector x2bc_assets; @@ -108,7 +108,7 @@ class CGuiTextSupport bool _GetIsTextSupportFinishedLoading() const; public: - CGuiTextSupport(ResId fontId, const CGuiTextProperties& props, + CGuiTextSupport(CAssetId fontId, const CGuiTextProperties& props, const zeus::CColor& fontCol, const zeus::CColor& outlineCol, const zeus::CColor& geomCol, s32 extX, s32 extY, CSimplePool* store, CGuiWidget::EGuiModelDrawFlags drawFlags); @@ -139,7 +139,7 @@ public: float GetCurTime() const { return x3c_curTime; } void SetCurTime(float t) { x3c_curTime = t; } const std::u16string& GetString() const { return x0_string; } - void SetControlTXTRMap(const std::vector>* txtrMap); + void SetControlTXTRMap(const std::vector>* txtrMap); int GetPageCounter() const { return x304_pageCounter; } int GetTotalPageCount(); void SetPage(int page); diff --git a/Runtime/GuiSys/CScanDisplay.cpp b/Runtime/GuiSys/CScanDisplay.cpp index 3fb72d787..398cb7cc7 100644 --- a/Runtime/GuiSys/CScanDisplay.cpp +++ b/Runtime/GuiSys/CScanDisplay.cpp @@ -248,7 +248,7 @@ void CScanDisplay::StartScan(TUniqueId id, const CScannableObjectInfo& scanInfo, } } - ResId strId = x14_scannableInfo->GetStringTableId(); + CAssetId strId = x14_scannableInfo->GetStringTableId(); if (strId != -1) x194_scanStr = g_SimplePool->GetObj({FOURCC('STRG'), strId}); diff --git a/Runtime/GuiSys/CTextParser.cpp b/Runtime/GuiSys/CTextParser.cpp index 3cdb76c4d..36ccbca6c 100644 --- a/Runtime/GuiSys/CTextParser.cpp +++ b/Runtime/GuiSys/CTextParser.cpp @@ -92,7 +92,7 @@ bool CTextParser::BeginsWith(const char16_t* str, int len, const char16_t* other } void CTextParser::ParseTag(CTextExecuteBuffer& out, const char16_t* str, int len, - const std::vector>* txtrMap) + const std::vector>* txtrMap) { if (BeginsWith(str, len, u"font=")) { @@ -198,7 +198,7 @@ void CTextParser::ParseTag(CTextExecuteBuffer& out, const char16_t* str, int len } CFontImageDef CTextParser::GetImage(const char16_t* str, int len, - const std::vector>* txtrMap) + const std::vector>* txtrMap) { int commaCount = 0; for (int i=0 ; i>* txtrMap) +CAssetId CTextParser::GetAssetIdFromString(const char16_t* str, int len, + const std::vector>* txtrMap) { u8 r = GetColorValue(str); u8 g = GetColorValue(str + 2); u8 b = GetColorValue(str + 4); u8 a = GetColorValue(str + 6); - ResId id = ((r << 24) | (g << 16) | (b << 8) | a) & 0xffffffff; + CAssetId id = ((r << 24) | (g << 16) | (b << 8) | a) & 0xffffffff; if (len == 16) { @@ -312,13 +312,13 @@ ResId CTextParser::GetAssetIdFromString(const char16_t* str, int len, g = GetColorValue(str + 10); b = GetColorValue(str + 12); a = GetColorValue(str + 14); - id = (id << 32) | (((r << 24) | (g << 16) | (b << 8) | a) & 0xffffffff); + id = (id.Value() << 32) | (((r << 24) | (g << 16) | (b << 8) | a) & 0xffffffff); } if (txtrMap) { auto search = rstl::binary_find(txtrMap->begin(), txtrMap->end(), id, - [](const std::pair& a) { return a.first; }); + [](const std::pair& a) { return a.first; }); if (search != txtrMap->end()) id = search->second; } @@ -332,7 +332,7 @@ TToken CTextParser::GetFont(const char16_t* str, int len) } void CTextParser::ParseText(CTextExecuteBuffer& out, const char16_t* str, int len, - const std::vector>* txtrMap) + const std::vector>* txtrMap) { int b=0, e=0; for (b=0, e=0 ; str[e] && (len == -1 || e < len) ;) diff --git a/Runtime/GuiSys/CTextParser.hpp b/Runtime/GuiSys/CTextParser.hpp index 056fb4eab..917dc221b 100644 --- a/Runtime/GuiSys/CTextParser.hpp +++ b/Runtime/GuiSys/CTextParser.hpp @@ -16,20 +16,20 @@ class CTextParser static u8 GetColorValue(const char16_t* str); static u32 FromHex(char16_t ch); static s32 ParseInt(const char16_t* str, int len, bool signVal); - static ResId GetAssetIdFromString(const char16_t* str, int len, - const std::vector>* txtrMap); + static CAssetId GetAssetIdFromString(const char16_t* str, int len, + const std::vector>* txtrMap); static bool Equals(const char16_t* str, int len, const char16_t* other); static bool BeginsWith(const char16_t* str, int len, const char16_t* other); void ParseTag(CTextExecuteBuffer& out, const char16_t* str, int len, - const std::vector>* txtrMap); + const std::vector>* txtrMap); CFontImageDef GetImage(const char16_t* str, int len, - const std::vector>* txtrMap); + const std::vector>* txtrMap); TToken GetFont(const char16_t* str, int len); public: CTextParser(IObjectStore& store) : x0_store(store) {} void ParseText(CTextExecuteBuffer& out, const char16_t* str, int len, - const std::vector>* txtrMap); + const std::vector>* txtrMap); }; } diff --git a/Runtime/IFactory.hpp b/Runtime/IFactory.hpp index 6d4d67000..f62be291b 100644 --- a/Runtime/IFactory.hpp +++ b/Runtime/IFactory.hpp @@ -30,7 +30,7 @@ public: virtual void CancelBuild(const SObjectTag&)=0; virtual bool CanBuild(const SObjectTag&)=0; virtual const SObjectTag* GetResourceIdByName(const char*) const=0; - virtual FourCC GetResourceTypeById(ResId id) const=0; + virtual FourCC GetResourceTypeById(CAssetId id) const=0; virtual void EnumerateResources(const std::function& lambda) const=0; virtual void EnumerateNamedResources(const std::function& lambda) const=0; @@ -43,8 +43,8 @@ public: virtual void GetTagListForFile(const char* pakName, std::vector& out) const {} - virtual ResId TranslateOriginalToNew(ResId id) const { return -1; } - virtual ResId TranslateNewToOriginal(ResId id) const { return -1; } + virtual CAssetId TranslateOriginalToNew(CAssetId id) const { return -1; } + virtual CAssetId TranslateNewToOriginal(CAssetId id) const { return -1; } }; } diff --git a/Runtime/IMain.hpp b/Runtime/IMain.hpp index 98ad3e246..7fd01bb8a 100644 --- a/Runtime/IMain.hpp +++ b/Runtime/IMain.hpp @@ -42,6 +42,7 @@ public: virtual void Shutdown()=0; virtual boo::IWindow* GetMainWindow() const=0; virtual void SetFlowState(EFlowState) = 0; + virtual size_t GetExpectedIdSize() const = 0; }; } diff --git a/Runtime/MP1/CArtifactDoll.cpp b/Runtime/MP1/CArtifactDoll.cpp index 72332783a..1169a89e3 100644 --- a/Runtime/MP1/CArtifactDoll.cpp +++ b/Runtime/MP1/CArtifactDoll.cpp @@ -25,7 +25,7 @@ static const char* ArtifactPieceModels[] = "CMDL_Piece12" // Newborn }; -static const ResId ArtifactHeadScans[] = +static const CAssetId ArtifactHeadScans[] = { 0x32C9DDCE, // Truth 0xB45DAF60, // Strength @@ -55,16 +55,16 @@ CArtifactDoll::CArtifactDoll() x0_models.push_back(g_SimplePool->GetObj(ArtifactPieceModels[i])); } -int CArtifactDoll::GetArtifactHeadScanIndex(ResId scanId) +int CArtifactDoll::GetArtifactHeadScanIndex(CAssetId scanId) { - ResId orig = g_ResFactory->TranslateNewToOriginal(scanId); + CAssetId orig = g_ResFactory->TranslateNewToOriginal(scanId); for (int i=0 ; i<12 ; ++i) if (ArtifactHeadScans[i] == orig) return i; return -1; } -ResId CArtifactDoll::GetArtifactHeadScanFromItemType(CPlayerState::EItemType item) +CAssetId CArtifactDoll::GetArtifactHeadScanFromItemType(CPlayerState::EItemType item) { if (item < CPlayerState::EItemType::ArtifactOfTruth || item > CPlayerState::EItemType::ArtifactOfNewborn) return -1; @@ -78,7 +78,7 @@ void CArtifactDoll::UpdateArtifactHeadScan(const CStateManager& mgr, float delta { if (mgr.GetPlayerState()->HasPowerUp(CPlayerState::EItemType(i + 29))) { - ResId newId = g_ResFactory->TranslateOriginalToNew(ArtifactHeadScans[i]); + CAssetId newId = g_ResFactory->TranslateOriginalToNew(ArtifactHeadScans[i]); playerState.SetScanTime(newId, std::min(playerState.GetScanTime(newId) + delta, 1.f)); } } @@ -115,7 +115,7 @@ void CArtifactDoll::Draw(float alpha, const CStateManager& mgr, { if (ArtifactHeadScans[i] != -1) { - ResId newId = g_ResFactory->TranslateOriginalToNew(ArtifactHeadScans[i]); + CAssetId newId = g_ResFactory->TranslateOriginalToNew(ArtifactHeadScans[i]); float interp = (playerState.GetScanTime(newId) - 0.5f) * 2.f; if (interp < 0.5f) color = zeus::CColor::lerp(ArtifactPreColor, zeus::CColor::skWhite, 2.f * interp); diff --git a/Runtime/MP1/CArtifactDoll.hpp b/Runtime/MP1/CArtifactDoll.hpp index 59a0bbe44..474d4c654 100644 --- a/Runtime/MP1/CArtifactDoll.hpp +++ b/Runtime/MP1/CArtifactDoll.hpp @@ -22,8 +22,8 @@ class CArtifactDoll void UpdateActorLights(); public: CArtifactDoll(); - static int GetArtifactHeadScanIndex(ResId scanId); - static ResId GetArtifactHeadScanFromItemType(CPlayerState::EItemType item); + static int GetArtifactHeadScanIndex(CAssetId scanId); + static CAssetId GetArtifactHeadScanFromItemType(CPlayerState::EItemType item); static void UpdateArtifactHeadScan(const CStateManager& mgr, float delta); static void CompleteArtifactHeadScan(const CStateManager& mgr); void Draw(float alpha, const CStateManager& mgr, bool inArtifactCategory, int selectedArtifact); diff --git a/Runtime/MP1/CFaceplateDecoration.cpp b/Runtime/MP1/CFaceplateDecoration.cpp index d381db14f..d17ecfe52 100644 --- a/Runtime/MP1/CFaceplateDecoration.cpp +++ b/Runtime/MP1/CFaceplateDecoration.cpp @@ -14,7 +14,7 @@ CFaceplateDecoration::CFaceplateDecoration(CStateManager& stateMgr) {} void CFaceplateDecoration::Update(float dt, CStateManager& stateMgr) { - ResId txtrId = stateMgr.GetPlayer().GetVisorSteam().GetTextureId(); + CAssetId txtrId = stateMgr.GetPlayer().GetVisorSteam().GetTextureId(); if (txtrId == -1) { if (xc_ready) diff --git a/Runtime/MP1/CFaceplateDecoration.hpp b/Runtime/MP1/CFaceplateDecoration.hpp index 9b753b92a..fcc66a326 100644 --- a/Runtime/MP1/CFaceplateDecoration.hpp +++ b/Runtime/MP1/CFaceplateDecoration.hpp @@ -13,7 +13,7 @@ namespace MP1 class CFaceplateDecoration { - ResId x0_id; + CAssetId x0_id; TToken x4_tex; bool xc_ready = false; std::experimental::optional m_texFilter; diff --git a/Runtime/MP1/CInGameGuiManager.cpp b/Runtime/MP1/CInGameGuiManager.cpp index 891887441..aa298d5ff 100644 --- a/Runtime/MP1/CInGameGuiManager.cpp +++ b/Runtime/MP1/CInGameGuiManager.cpp @@ -722,7 +722,7 @@ void CInGameGuiManager::Draw(CStateManager& stateMgr) } } -void CInGameGuiManager::ShowPauseGameHudMessage(CStateManager& stateMgr, ResId pauseMsg, float time) +void CInGameGuiManager::ShowPauseGameHudMessage(CStateManager& stateMgr, CAssetId pauseMsg, float time) { x124_pauseGameHudMessage = pauseMsg; x128_pauseGameHudTime = time; diff --git a/Runtime/MP1/CInGameGuiManager.hpp b/Runtime/MP1/CInGameGuiManager.hpp index b28ee544c..658763f59 100644 --- a/Runtime/MP1/CInGameGuiManager.hpp +++ b/Runtime/MP1/CInGameGuiManager.hpp @@ -73,7 +73,7 @@ private: std::vector xd8_; std::vector xe8_pauseResources; CCameraFilterPass xf8_camFilter; - ResId x124_pauseGameHudMessage = -1; + CAssetId x124_pauseGameHudMessage = -1; float x128_pauseGameHudTime = 0.f; std::list x12c_; u32 x140_ = 0; @@ -138,7 +138,7 @@ public: CArchitectureQueue& archQueue); void PreDraw(CStateManager& stateMgr, bool cameraActive); void Draw(CStateManager& stateMgr); - void ShowPauseGameHudMessage(CStateManager& stateMgr, ResId pauseMsg, float time); + void ShowPauseGameHudMessage(CStateManager& stateMgr, CAssetId pauseMsg, float time); void PauseGame(CStateManager& stateMgr, EInGameGuiState state); void StartFadeIn(); bool WasInGame() const { return x1bc_prevState >= EInGameGuiState::Zero && x1bc_prevState <= EInGameGuiState::InGame; } diff --git a/Runtime/MP1/CLogBookScreen.cpp b/Runtime/MP1/CLogBookScreen.cpp index ffc41a759..8b9f69476 100644 --- a/Runtime/MP1/CLogBookScreen.cpp +++ b/Runtime/MP1/CLogBookScreen.cpp @@ -29,7 +29,7 @@ CLogBookScreen::~CLogBookScreen() CMain::EnsureWorldPakReady(g_GameState->CurrentWorldAssetId()); } -bool CLogBookScreen::IsScanComplete(CSaveWorld::EScanCategory category, ResId scan, +bool CLogBookScreen::IsScanComplete(CSaveWorld::EScanCategory category, CAssetId scan, const CPlayerState& playerState) { float time = playerState.GetScanTime(scan); @@ -45,7 +45,7 @@ void CLogBookScreen::InitializeLogBook() x19c_scanCompletes[i].reserve(g_MemoryCardSys->GetScanCategoryCount(CSaveWorld::EScanCategory(i + 1))); CPlayerState& playerState = *x4_mgr.GetPlayerState(); - for (const std::pair& scanState : g_MemoryCardSys->GetScanStates()) + for (const std::pair& scanState : g_MemoryCardSys->GetScanStates()) { if (scanState.second == CSaveWorld::EScanCategory::None) continue; @@ -54,14 +54,14 @@ void CLogBookScreen::InitializeLogBook() } std::sort(x19c_scanCompletes[4].begin(), x19c_scanCompletes[4].end(), - [](const std::pair& a, std::pair& b) + [](const std::pair& a, std::pair& b) { return CArtifactDoll::GetArtifactHeadScanIndex(a.first) < CArtifactDoll::GetArtifactHeadScanIndex(b.first); }); auto viewIt = x200_viewScans.begin(); - for (std::vector>& category : x19c_scanCompletes) + for (std::vector>& category : x19c_scanCompletes) { std::vector, TLockedToken>>& viewScans = *viewIt++; @@ -75,7 +75,7 @@ void CLogBookScreen::InitializeLogBook() void CLogBookScreen::UpdateRightTitles() { - std::vector>& category = + std::vector>& category = x19c_scanCompletes[x70_tablegroup_leftlog->GetUserSelection()]; for (int i=0 ; xd8_textpane_titles.size() ; ++i) { @@ -184,7 +184,7 @@ void CLogBookScreen::PumpArticleLoad() bool CLogBookScreen::IsScanCategoryReady(CSaveWorld::EScanCategory category) const { CPlayerState& playerState = *x4_mgr.GetPlayerState(); - for (const std::pair& scanState : g_MemoryCardSys->GetScanStates()) + for (const std::pair& scanState : g_MemoryCardSys->GetScanStates()) { if (scanState.second != category) continue; @@ -454,9 +454,9 @@ void CLogBookScreen::UpdateRightTable() { CPauseScreenBase::UpdateRightTable(); x1f0_curViewScans.clear(); - std::vector>& category = x19c_scanCompletes[x70_tablegroup_leftlog->GetUserSelection()]; + std::vector>& category = x19c_scanCompletes[x70_tablegroup_leftlog->GetUserSelection()]; x1f0_curViewScans.reserve(category.size()); - for (std::pair& scan : category) + for (std::pair& scan : category) x1f0_curViewScans.push_back(std::make_pair(g_SimplePool->GetObj({FOURCC('SCAN'), scan.first}), TLockedToken{})); diff --git a/Runtime/MP1/CLogBookScreen.hpp b/Runtime/MP1/CLogBookScreen.hpp index 7ae0bf4d5..5a854a7f7 100644 --- a/Runtime/MP1/CLogBookScreen.hpp +++ b/Runtime/MP1/CLogBookScreen.hpp @@ -12,7 +12,7 @@ namespace MP1 class CLogBookScreen : public CPauseScreenBase { - rstl::reserved_vector>, 5> x19c_scanCompletes; + rstl::reserved_vector>, 5> x19c_scanCompletes; std::vector, TCachedToken>> x1f0_curViewScans; rstl::reserved_vector, @@ -48,7 +48,7 @@ class CLogBookScreen : public CPauseScreenBase int NextSurroundingArticleIndex(int cur) const; bool IsArtifactCategorySelected() const; int GetSelectedArtifactHeadScanIndex() const; - static bool IsScanComplete(CSaveWorld::EScanCategory category, ResId scan, const CPlayerState& playerState); + static bool IsScanComplete(CSaveWorld::EScanCategory category, CAssetId scan, const CPlayerState& playerState); public: CLogBookScreen(const CStateManager& mgr, CGuiFrame& frame, const CStringTable& pauseStrg); diff --git a/Runtime/MP1/CMFGame.cpp b/Runtime/MP1/CMFGame.cpp index 1c6e369a4..e32e1521d 100644 --- a/Runtime/MP1/CMFGame.cpp +++ b/Runtime/MP1/CMFGame.cpp @@ -288,13 +288,13 @@ CMFGameLoader::CMFGameLoader() : CMFGameLoaderBase("CMFGameLoader") case EFlowState::Default: case EFlowState::StateSetter: { - ResId mlvlId = g_GameState->CurrentWorldAssetId(); + CAssetId mlvlId = g_GameState->CurrentWorldAssetId(); if (g_MemoryCardSys->HasSaveWorldMemory(mlvlId)) { const CSaveWorldMemory& savwMem = g_MemoryCardSys->GetSaveWorldMemory(mlvlId); if (savwMem.GetWorldNameId() != -1) { - ResId wtMgrFont = g_ResFactory->TranslateOriginalToNew(0xB7BBD0B4); + CAssetId wtMgrFont = g_ResFactory->TranslateOriginalToNew(0xB7BBD0B4); g_GameState->GetWorldTransitionManager()->EnableTransition(wtMgrFont, savwMem.GetWorldNameId(), 1, false, 0.1f, 16.f, 1.f); diff --git a/Runtime/MP1/CMemoryCardDriver.cpp b/Runtime/MP1/CMemoryCardDriver.cpp index edd042f36..2b38f4644 100644 --- a/Runtime/MP1/CMemoryCardDriver.cpp +++ b/Runtime/MP1/CMemoryCardDriver.cpp @@ -148,8 +148,8 @@ void CMemoryCardDriver::SGameFileSlot::LoadGameState(u32 idx) CMemoryCardDriver::SFileInfo::SFileInfo(kabufuda::ECardSlot port, const std::string& name) : x0_fileInfo(port), x14_name(name) {} -CMemoryCardDriver::CMemoryCardDriver(kabufuda::ECardSlot cardPort, ResId saveBanner, - ResId saveIcon0, ResId saveIcon1, bool importPersistent) +CMemoryCardDriver::CMemoryCardDriver(kabufuda::ECardSlot cardPort, CAssetId saveBanner, + CAssetId saveIcon0, CAssetId saveIcon1, bool importPersistent) : x0_cardPort(cardPort), x4_saveBanner(saveBanner), x8_saveIcon0(saveIcon0), xc_saveIcon1(saveIcon1), x19d_importPersistent(importPersistent) { diff --git a/Runtime/MP1/CMemoryCardDriver.hpp b/Runtime/MP1/CMemoryCardDriver.hpp index 5cac2f7b3..b58e02529 100644 --- a/Runtime/MP1/CMemoryCardDriver.hpp +++ b/Runtime/MP1/CMemoryCardDriver.hpp @@ -124,9 +124,9 @@ private: }; kabufuda::ECardSlot x0_cardPort; - ResId x4_saveBanner; - ResId x8_saveIcon0; - ResId xc_saveIcon1; + CAssetId x4_saveBanner; + CAssetId x8_saveIcon0; + CAssetId xc_saveIcon1; EState x10_state = EState::Initial; EError x14_error = EError::OK; s32 x18_cardFreeBytes = 0; @@ -142,8 +142,8 @@ private: bool x19d_importPersistent; public: - CMemoryCardDriver(kabufuda::ECardSlot cardPort, ResId saveBanner, - ResId saveIcon0, ResId saveIcon1, bool importPersistent); + CMemoryCardDriver(kabufuda::ECardSlot cardPort, CAssetId saveBanner, + CAssetId saveIcon0, CAssetId saveIcon1, bool importPersistent); void NoCardFound(); const CGameState::GameFileStateInfo* GetGameFileStateInfo(int idx); diff --git a/Runtime/MP1/CMessageScreen.cpp b/Runtime/MP1/CMessageScreen.cpp index 12aa902a5..804515c78 100644 --- a/Runtime/MP1/CMessageScreen.cpp +++ b/Runtime/MP1/CMessageScreen.cpp @@ -13,7 +13,7 @@ namespace urde namespace MP1 { -CMessageScreen::CMessageScreen(ResId msg, float delayTime) +CMessageScreen::CMessageScreen(CAssetId msg, float delayTime) : x74_delayTime(delayTime) { x78_24_exit = false; diff --git a/Runtime/MP1/CMessageScreen.hpp b/Runtime/MP1/CMessageScreen.hpp index aaa56bba9..ec96270df 100644 --- a/Runtime/MP1/CMessageScreen.hpp +++ b/Runtime/MP1/CMessageScreen.hpp @@ -40,7 +40,7 @@ class CMessageScreen float x74_delayTime; bool x78_24_exit : 1; public: - CMessageScreen(ResId msg, float time); + CMessageScreen(CAssetId msg, float time); void ProcessControllerInput(const CFinalInput& input); bool Update(float dt, float blurAmt); void Draw() const; diff --git a/Runtime/MP1/CPauseScreen.cpp b/Runtime/MP1/CPauseScreen.cpp index d7c3fa3a0..157a1a4b5 100644 --- a/Runtime/MP1/CPauseScreen.cpp +++ b/Runtime/MP1/CPauseScreen.cpp @@ -206,11 +206,11 @@ void CPauseScreen::ProcessControllerInput(const CStateManager& mgr, const CFinal } } - x38_textpane_l1->TextSupport().SetText(hecl::Format("&image=%8.8X;", u32(g_tweakPlayerRes->x74_lTrigger[input.DLTrigger()]))); - x3c_textpane_r->TextSupport().SetText(hecl::Format("&image=%8.8X;", u32(g_tweakPlayerRes->x80_rTrigger[input.DRTrigger()]))); - x48_textpane_return->TextSupport().SetText(hecl::Format("&image=%8.8X;", u32(g_tweakPlayerRes->x8c_startButton[input.DStart()]))); - x50_textpane_back->TextSupport().SetText(hecl::Format("&image=%8.8X;", u32(g_tweakPlayerRes->x98_aButton[input.DA()]))); - x4c_textpane_next->TextSupport().SetText(hecl::Format("&image=%8.8X;", u32(g_tweakPlayerRes->xa4_bButton[input.DB()]))); + x38_textpane_l1->TextSupport().SetText(hecl::Format("&image=%8.8X;", u32(g_tweakPlayerRes->x74_lTrigger[input.DLTrigger()].Value()))); + x3c_textpane_r->TextSupport().SetText(hecl::Format("&image=%8.8X;", u32(g_tweakPlayerRes->x80_rTrigger[input.DRTrigger()].Value()))); + x48_textpane_return->TextSupport().SetText(hecl::Format("&image=%8.8X;", u32(g_tweakPlayerRes->x8c_startButton[input.DStart()].Value()))); + x50_textpane_back->TextSupport().SetText(hecl::Format("&image=%8.8X;", u32(g_tweakPlayerRes->x98_aButton[input.DA()].Value()))); + x4c_textpane_next->TextSupport().SetText(hecl::Format("&image=%8.8X;", u32(g_tweakPlayerRes->xa4_bButton[input.DB()].Value()))); } void CPauseScreen::TransitionComplete() diff --git a/Runtime/MP1/CPauseScreen.hpp b/Runtime/MP1/CPauseScreen.hpp index f1156de16..ab7fc4995 100644 --- a/Runtime/MP1/CPauseScreen.hpp +++ b/Runtime/MP1/CPauseScreen.hpp @@ -42,7 +42,7 @@ private: CGuiTextPane* x48_textpane_return = nullptr; CGuiTextPane* x4c_textpane_next = nullptr; CGuiTextPane* x50_textpane_back = nullptr; - ResId x54_frmePauseScreenId; + CAssetId x54_frmePauseScreenId; u32 x58_frmePauseScreenBufSz; std::unique_ptr x5c_frmePauseScreenBuf; std::shared_ptr x60_loadTok; diff --git a/Runtime/MP1/CPauseScreenBase.cpp b/Runtime/MP1/CPauseScreenBase.cpp index bc6078980..866017153 100644 --- a/Runtime/MP1/CPauseScreenBase.cpp +++ b/Runtime/MP1/CPauseScreenBase.cpp @@ -59,7 +59,7 @@ void CPauseScreenBase::InitializeFrameGlue() x184_textpane_yicon = static_cast(x8_frame.FindWidget("textpane_yicon")); x188_textpane_ytext = static_cast(x8_frame.FindWidget("textpane_ytext")); x184_textpane_yicon->TextSupport().SetText(hecl::UTF8ToChar16(hecl::Format("&image=%8.8X;", - u32(g_tweakPlayerRes->xbc_yButton[0])))); + u32(g_tweakPlayerRes->xbc_yButton[0].Value())))); x188_textpane_ytext->TextSupport().SetText(xc_pauseStrg.GetString(99)); x188_textpane_ytext->SetColor(g_tweakGuiColors->GetPauseItemAmberColor()); x18c_slidergroup_slider = static_cast(x8_frame.FindWidget("slidergroup_slider")); diff --git a/Runtime/MP1/CSamusHud.cpp b/Runtime/MP1/CSamusHud.cpp index 50ecda6dc..3ddacfa50 100644 --- a/Runtime/MP1/CSamusHud.cpp +++ b/Runtime/MP1/CSamusHud.cpp @@ -1824,7 +1824,7 @@ void CSamusHud::SetMessage(const std::u16string& text, const CHUDMemoParms& info } } -void CSamusHud::InternalDeferHintMemo(ResId strg, u32 strgIdx, const CHUDMemoParms& info) +void CSamusHud::InternalDeferHintMemo(CAssetId strg, u32 strgIdx, const CHUDMemoParms& info) { x548_hudMemoParms = info; x550_hudMemoString = g_SimplePool->GetObj(SObjectTag{FOURCC('STRG'), strg}); diff --git a/Runtime/MP1/CSamusHud.hpp b/Runtime/MP1/CSamusHud.hpp index b8cbbae66..4b7ba2c64 100644 --- a/Runtime/MP1/CSamusHud.hpp +++ b/Runtime/MP1/CSamusHud.hpp @@ -277,12 +277,12 @@ public: SetMessage(text, info); } void SetMessage(const std::u16string& text, const CHUDMemoParms& info); - static void DeferHintMemo(ResId strg, u32 strgIdx, const CHUDMemoParms& info) + static void DeferHintMemo(CAssetId strg, u32 strgIdx, const CHUDMemoParms& info) { if (g_SamusHud) g_SamusHud->InternalDeferHintMemo(strg, strgIdx, info); } - void InternalDeferHintMemo(ResId strg, u32 strgIdx, const CHUDMemoParms& info); + void InternalDeferHintMemo(CAssetId strg, u32 strgIdx, const CHUDMemoParms& info); CGuiFrame* GetBaseHudFrame() const { return x274_loadedFrmeBaseHud; } }; diff --git a/Runtime/MP1/CSaveGameScreen.cpp b/Runtime/MP1/CSaveGameScreen.cpp index 51626e7ec..404757f2e 100644 --- a/Runtime/MP1/CSaveGameScreen.cpp +++ b/Runtime/MP1/CSaveGameScreen.cpp @@ -685,7 +685,7 @@ CSaveGameScreen::CSaveGameScreen(ESaveContext saveCtx, u64 serial) x93_inGame = bool(saveCtx); x70_saveWorlds.reserve(g_MemoryCardSys->GetMemoryWorlds().size()); - for (const std::pair& wld : g_MemoryCardSys->GetMemoryWorlds()) + for (const std::pair& wld : g_MemoryCardSys->GetMemoryWorlds()) { x70_saveWorlds.push_back( g_SimplePool->GetObj(SObjectTag{FOURCC('SAVW'), wld.second.GetSaveWorldAssetId()})); diff --git a/Runtime/MP1/MP1.cpp b/Runtime/MP1/MP1.cpp index a44dda42d..2a0c54594 100644 --- a/Runtime/MP1/MP1.cpp +++ b/Runtime/MP1/MP1.cpp @@ -277,7 +277,7 @@ void CMain::EnsureWorldPaksReady() { } -void CMain::EnsureWorldPakReady(ResId mlvl) +void CMain::EnsureWorldPakReady(CAssetId mlvl) { /* TODO: Schedule resource list load for World Pak containing mlvl */ } diff --git a/Runtime/MP1/MP1.hpp b/Runtime/MP1/MP1.hpp index ba076873d..b9ee98d07 100644 --- a/Runtime/MP1/MP1.hpp +++ b/Runtime/MP1/MP1.hpp @@ -293,7 +293,7 @@ public: void SetCardBusy(bool v) { x160_31_cardBusy = v; } void SetGameFrameDrawn() { x161_24_gameFrameDrawn = true; } static void EnsureWorldPaksReady(); - static void EnsureWorldPakReady(ResId mlvl); + static void EnsureWorldPakReady(CAssetId mlvl); EFlowState GetFlowState() const { return x12c_flowState; } void SetFlowState(EFlowState s) { x12c_flowState = s; } @@ -301,6 +301,8 @@ public: void SetX30(bool v) { x160_30_ = v; } CGameArchitectureSupport* GetArchSupport() const { return x164_archSupport.get(); } + + size_t GetExpectedIdSize() const { return sizeof(u32); } }; } diff --git a/Runtime/MP1/World/CActorContraption.cpp b/Runtime/MP1/World/CActorContraption.cpp index e1d9db561..53cfe1577 100644 --- a/Runtime/MP1/World/CActorContraption.cpp +++ b/Runtime/MP1/World/CActorContraption.cpp @@ -14,7 +14,7 @@ MP1::CActorContraption::CActorContraption(TUniqueId uid, const std::string& name const zeus::CTransform& xf, CModelData&& mData, const zeus::CAABox& aabox, const CMaterialList& matList, float mass, float zMomentum, const CHealthInfo& hInfo, const CDamageVulnerability& dVuln, const CActorParameters& aParams, - ResId part, const CDamageInfo& dInfo, bool active) + CAssetId part, const CDamageInfo& dInfo, bool active) : CScriptActor(uid, name, info, xf, std::move(mData), aabox, mass, zMomentum, matList, hInfo, dVuln, aParams, false, active, 0, 1.f, false, false, false, false) , x300_flameThrowerGen(g_SimplePool->GetObj("FlameThrower")) diff --git a/Runtime/MP1/World/CActorContraption.hpp b/Runtime/MP1/World/CActorContraption.hpp index 13193dd65..68dbeb5f8 100644 --- a/Runtime/MP1/World/CActorContraption.hpp +++ b/Runtime/MP1/World/CActorContraption.hpp @@ -14,12 +14,12 @@ class CActorContraption : public CScriptActor /* AKA Why Zoid?!?!?!? */ std::vector> x2e8_children; TToken x300_flameThrowerGen; - ResId x308_flameFxId; + CAssetId x308_flameFxId; CDamageInfo x30c_dInfo; public: CActorContraption(TUniqueId, const std::string&, const CEntityInfo&, const zeus::CTransform&, CModelData&&, const zeus::CAABox&, const CMaterialList&, float, float, const CHealthInfo&, - const CDamageVulnerability&, const CActorParameters&, ResId, const CDamageInfo&, bool); + const CDamageVulnerability&, const CActorParameters&, CAssetId, const CDamageInfo&, bool); void Accept(IVisitor &visitor); void AcceptScriptMsg(EScriptObjectMessage, TUniqueId, CStateManager &); diff --git a/Runtime/MP1/World/CBabygoth.hpp b/Runtime/MP1/World/CBabygoth.hpp index e23a27ca0..83f0caa37 100644 --- a/Runtime/MP1/World/CBabygoth.hpp +++ b/Runtime/MP1/World/CBabygoth.hpp @@ -36,15 +36,15 @@ class CBabygothData u32 x174_; public: CBabygothData(CInputStream&); - ResId GetShellModelResId() const; + CAssetId GetShellModelResId() const; void GetFireballDamage() const; - ResId GetFireballResID() const; + CAssetId GetFireballResID() const; const CDamageVulnerability& GetShellDamageVulnerability() const; void GetSHellHitPoints() const; void GetFireballAttackVariance() const; void GetFireballAttackTime() const; void GetFireBreathDamage() const; - ResId GetFireBreathResId() const; + CAssetId GetFireBreathResId() const; }; } diff --git a/Runtime/MP1/World/CWarWasp.cpp b/Runtime/MP1/World/CWarWasp.cpp index 9ff2b2e5a..ff1bfa93e 100644 --- a/Runtime/MP1/World/CWarWasp.cpp +++ b/Runtime/MP1/World/CWarWasp.cpp @@ -9,7 +9,7 @@ namespace MP1 CWarWasp::CWarWasp(TUniqueId uid, const std::string& name, const CEntityInfo& info, const zeus::CTransform& xf, CModelData&& mData, const CPatternedInfo& pInfo, CPatterned::EFlavorType flavor, CPatterned::EColliderType collider, const CDamageInfo& dInfo1, const CActorParameters& actorParms, - ResId weapon, const CDamageInfo& dInfo2, ResId particle, u32 w3) + CAssetId weapon, const CDamageInfo& dInfo2, CAssetId particle, u32 w3) : CPatterned(ECharacter::WarWasp, uid, name, flavor, info, xf, std::move(mData), pInfo, EMovementType::Flyer, collider, EBodyType::Flyer, actorParms, false) { diff --git a/Runtime/MP1/World/CWarWasp.hpp b/Runtime/MP1/World/CWarWasp.hpp index 8ed2a46be..f09fe0adf 100644 --- a/Runtime/MP1/World/CWarWasp.hpp +++ b/Runtime/MP1/World/CWarWasp.hpp @@ -14,7 +14,7 @@ public: CWarWasp(TUniqueId uid, const std::string& name, const CEntityInfo& info, const zeus::CTransform& xf, CModelData&& mData, const CPatternedInfo& pInfo, CPatterned::EFlavorType flavor, CPatterned::EColliderType, const CDamageInfo& dInfo1, const CActorParameters&, - ResId weapon, const CDamageInfo& dInfo2, ResId particle, u32 w3); + CAssetId weapon, const CDamageInfo& dInfo2, CAssetId particle, u32 w3); void Accept(IVisitor &visitor); }; diff --git a/Runtime/Particle/CDecalManager.cpp b/Runtime/Particle/CDecalManager.cpp index b75d45a52..97cab2a96 100644 --- a/Runtime/Particle/CDecalManager.cpp +++ b/Runtime/Particle/CDecalManager.cpp @@ -11,7 +11,7 @@ bool CDecalManager::m_PoolInitialized = false; s32 CDecalManager::m_FreeIndex = 63; float CDecalManager::m_DeltaTimeSinceLastDecalCreation = 0.f; s32 CDecalManager::m_LastDecalCreatedIndex = -1; -ResId CDecalManager::m_LastDecalCreatedAssetId = -1; +CAssetId CDecalManager::m_LastDecalCreatedAssetId = -1; rstl::reserved_vector CDecalManager::m_DecalPool; rstl::reserved_vector CDecalManager::m_ActiveIndexList; diff --git a/Runtime/Particle/CDecalManager.hpp b/Runtime/Particle/CDecalManager.hpp index 937988407..81112d0d2 100644 --- a/Runtime/Particle/CDecalManager.hpp +++ b/Runtime/Particle/CDecalManager.hpp @@ -26,7 +26,7 @@ class CDecalManager static s32 m_FreeIndex; static float m_DeltaTimeSinceLastDecalCreation; static s32 m_LastDecalCreatedIndex; - static ResId m_LastDecalCreatedAssetId; + static CAssetId m_LastDecalCreatedAssetId; static rstl::reserved_vector m_DecalPool; static rstl::reserved_vector m_ActiveIndexList; public: diff --git a/Runtime/Particle/CParticleDataFactory.cpp b/Runtime/Particle/CParticleDataFactory.cpp index 3f8c84566..3e97bf8c5 100644 --- a/Runtime/Particle/CParticleDataFactory.cpp +++ b/Runtime/Particle/CParticleDataFactory.cpp @@ -16,7 +16,7 @@ float CParticleDataFactory::GetReal(CInputStream& in) return in.readFloatBig(); } -int32_t CParticleDataFactory::GetInt(CInputStream& in) +s32 CParticleDataFactory::GetInt(CInputStream& in) { return in.readInt32Big(); } @@ -41,26 +41,26 @@ SParticleModel CParticleDataFactory::GetModel(CInputStream& in, CSimplePool* res FourCC clsId = GetClassID(in); if (clsId == SBIG('NONE')) return {}; - ResId id = in.readUint32Big(); - if (!id) + CAssetId id = in.readUint32Big(); + if (!id.IsValid()) return {}; return {resPool->GetObj({FOURCC('CMDL'), id}), true}; } -SChildGeneratorDesc CParticleDataFactory::GetChildGeneratorDesc(ResId res, CSimplePool* resPool, const std::vector& tracker) +SChildGeneratorDesc CParticleDataFactory::GetChildGeneratorDesc(CAssetId res, CSimplePool* resPool, const std::vector& tracker) { if (std::count(tracker.cbegin(), tracker.cend(), res) == 0) return {resPool->GetObj({FOURCC('PART'), res}), true}; return {}; } -SChildGeneratorDesc CParticleDataFactory::GetChildGeneratorDesc(CInputStream& in, CSimplePool* resPool, const std::vector& tracker) +SChildGeneratorDesc CParticleDataFactory::GetChildGeneratorDesc(CInputStream& in, CSimplePool* resPool, const std::vector& tracker) { FourCC clsId = GetClassID(in); if (clsId == SBIG('NONE')) return {}; - ResId id = in.readUint32Big(); - if (!id) + CAssetId id = in.readUint32Big(); + if (!id.IsValid()) return {}; return GetChildGeneratorDesc(id, resPool, tracker); } @@ -70,8 +70,8 @@ SSwooshGeneratorDesc CParticleDataFactory::GetSwooshGeneratorDesc(CInputStream& FourCC clsId = GetClassID(in); if (clsId == SBIG('NONE')) return {}; - ResId id = in.readUint32Big(); - if (!id) + CAssetId id = in.readUint32Big(); + if (!id.IsValid()) return {}; return {resPool->GetObj({FOURCC('SWHC'), id}), true}; } @@ -81,8 +81,8 @@ SElectricGeneratorDesc CParticleDataFactory::GetElectricGeneratorDesc(CInputStre FourCC clsId = GetClassID(in); if (clsId == SBIG('NONE')) return {}; - ResId id = in.readUint32Big(); - if (!id) + CAssetId id = in.readUint32Big(); + if (!id.IsValid()) return {}; return {resPool->GetObj({FOURCC('ELSC'), id}), true}; } @@ -97,7 +97,7 @@ CUVElement* CParticleDataFactory::GetTextureElement(CInputStream& in, CSimplePoo FourCC subId = GetClassID(in); if (subId == SBIG('NONE')) return nullptr; - ResId id = in.readUint32Big(); + CAssetId id = in.readUint32Big(); TToken txtr = resPool->GetObj({FOURCC('TXTR'), id}); return new CUVEConstant(std::move(txtr)); } @@ -106,7 +106,7 @@ CUVElement* CParticleDataFactory::GetTextureElement(CInputStream& in, CSimplePoo FourCC subId = GetClassID(in); if (subId == SBIG('NONE')) return nullptr; - ResId id = in.readUint32Big(); + CAssetId id = in.readUint32Big(); CIntElement* a = GetIntElement(in); CIntElement* b = GetIntElement(in); CIntElement* c = GetIntElement(in); @@ -827,13 +827,13 @@ CIntElement* CParticleDataFactory::GetIntElement(CInputStream& in) CGenDescription* CParticleDataFactory::GetGeneratorDesc(CInputStream& in, CSimplePool* resPool) { - std::vector tracker; + std::vector tracker; tracker.reserve(8); return CreateGeneratorDescription(in, tracker, 0, resPool); } -CGenDescription* CParticleDataFactory::CreateGeneratorDescription(CInputStream& in, std::vector& tracker, - ResId resId, CSimplePool* resPool) +CGenDescription* CParticleDataFactory::CreateGeneratorDescription(CInputStream& in, std::vector& tracker, + CAssetId resId, CSimplePool* resPool) { if (std::count(tracker.cbegin(), tracker.cend(), resId) == 0) { @@ -851,7 +851,7 @@ CGenDescription* CParticleDataFactory::CreateGeneratorDescription(CInputStream& } bool CParticleDataFactory::CreateGPSM(CGenDescription* fillDesc, CInputStream& in, - std::vector& tracker, CSimplePool* resPool) + std::vector& tracker, CSimplePool* resPool) { CRandom16 rand{99}; CGlobalRandom gr(rand); diff --git a/Runtime/Particle/CParticleDataFactory.hpp b/Runtime/Particle/CParticleDataFactory.hpp index db63677e4..294a8d28f 100644 --- a/Runtime/Particle/CParticleDataFactory.hpp +++ b/Runtime/Particle/CParticleDataFactory.hpp @@ -76,8 +76,8 @@ class CParticleDataFactory friend class CProjectileWeaponDataFactory; static SParticleModel GetModel(CInputStream& in, CSimplePool* resPool); - static SChildGeneratorDesc GetChildGeneratorDesc(ResId res, CSimplePool* resPool, const std::vector& tracker); - static SChildGeneratorDesc GetChildGeneratorDesc(CInputStream& in, CSimplePool* resPool, const std::vector& tracker); + static SChildGeneratorDesc GetChildGeneratorDesc(CAssetId res, CSimplePool* resPool, const std::vector& tracker); + static SChildGeneratorDesc GetChildGeneratorDesc(CInputStream& in, CSimplePool* resPool, const std::vector& tracker); static SSwooshGeneratorDesc GetSwooshGeneratorDesc(CInputStream& in, CSimplePool* resPool); static SElectricGeneratorDesc GetElectricGeneratorDesc(CInputStream& in, CSimplePool* resPool); static CUVElement* GetTextureElement(CInputStream& in, CSimplePool* resPool); @@ -89,13 +89,13 @@ class CParticleDataFactory static CIntElement* GetIntElement(CInputStream& in); static float GetReal(CInputStream& in); - static int32_t GetInt(CInputStream& in); + static s32 GetInt(CInputStream& in); static bool GetBool(CInputStream& in); static FourCC GetClassID(CInputStream& in); - static CGenDescription* CreateGeneratorDescription(CInputStream& in, std::vector& tracker, - ResId resId, CSimplePool* resPool); + static CGenDescription* CreateGeneratorDescription(CInputStream& in, std::vector& tracker, + CAssetId resId, CSimplePool* resPool); static bool CreateGPSM(CGenDescription* fillDesc, CInputStream& in, - std::vector& tracker, CSimplePool* resPool); + std::vector& tracker, CSimplePool* resPool); static void LoadGPSMTokens(CGenDescription* desc); public: static CGenDescription* GetGeneratorDesc(CInputStream& in, CSimplePool* resPool); diff --git a/Runtime/Particle/CParticleElectricDataFactory.cpp b/Runtime/Particle/CParticleElectricDataFactory.cpp index d83aa269a..6079eb60d 100644 --- a/Runtime/Particle/CParticleElectricDataFactory.cpp +++ b/Runtime/Particle/CParticleElectricDataFactory.cpp @@ -95,14 +95,14 @@ bool CParticleElectricDataFactory::CreateELSM(CElectricDescription* desc, CInput break; case SBIG('GPSM'): { - std::vector tracker; + std::vector tracker; tracker.reserve(8); desc->x50_GPSM = CPF::GetChildGeneratorDesc(in, resPool, tracker); break; } case SBIG('EPSM'): { - std::vector tracker; + std::vector tracker; tracker.reserve(8); desc->x60_EPSM = CPF::GetChildGeneratorDesc(in, resPool, tracker); break; diff --git a/Runtime/Particle/CProjectileWeaponDataFactory.cpp b/Runtime/Particle/CProjectileWeaponDataFactory.cpp index 283f63a18..45992fb1d 100644 --- a/Runtime/Particle/CProjectileWeaponDataFactory.cpp +++ b/Runtime/Particle/CProjectileWeaponDataFactory.cpp @@ -94,14 +94,14 @@ bool CProjectileWeaponDataFactory::CreateWPSM(CWeaponDescription* desc, CInputSt break; case SBIG('APSM'): { - std::vector tracker; + std::vector tracker; tracker.reserve(8); desc->x34_APSM = CPF::GetChildGeneratorDesc(in, resPool, tracker); break; } case SBIG('APS2'): { - std::vector tracker; + std::vector tracker; tracker.reserve(8); desc->x44_APS2 = CPF::GetChildGeneratorDesc(in, resPool, tracker); break; @@ -123,8 +123,8 @@ bool CProjectileWeaponDataFactory::CreateWPSM(CWeaponDescription* desc, CInputSt FourCC cid = CPF::GetClassID(in); if (cid == SBIG('NONE')) break; - ResId id = CPF::GetInt(in); - if (id) + CAssetId id = CPF::GetInt(in); + if (id.IsValid()) desc->x94_COLR = {resPool->GetObj({FOURCC('CRSC'), id}), true}; break; } diff --git a/Runtime/RetroTypes.cpp b/Runtime/RetroTypes.cpp new file mode 100644 index 000000000..d695c3890 --- /dev/null +++ b/Runtime/RetroTypes.cpp @@ -0,0 +1,39 @@ +#include "RetroTypes.hpp" +#include "GameGlobalObjects.hpp" +#include "IMain.hpp" + +namespace urde +{ +logvisor::Module Log("urde::RetroTypes::CAssetId"); + +CAssetId::CAssetId(CInputStream& in) +{ + if (g_Main) + { + if (g_Main->GetExpectedIdSize() == sizeof(u32)) + Assign(in.readUint32Big()); + else if (g_Main->GetExpectedIdSize() == sizeof(u64)) + Assign(in.readUint64Big()); + else + Log.report(logvisor::Fatal, "Unsupported id length %i", g_Main->GetExpectedIdSize()); + } + else + Log.report(logvisor::Fatal, "Input constructor called before runtime Main entered!"); +} + +void CAssetId::PutTo(COutputStream& out) +{ + if (g_Main) + { + if (g_Main->GetExpectedIdSize() == sizeof(u32)) + out.writeUint32Big(u32(id)); + else if (g_Main->GetExpectedIdSize() == sizeof(u64)) + out.writeUint64Big(id); + else + Log.report(logvisor::Fatal, "Unsupported id length %i", g_Main->GetExpectedIdSize()); + } + else + Log.report(logvisor::Fatal, "PutTo called before runtime Main entered!"); +} + +} \ No newline at end of file diff --git a/Runtime/RetroTypes.hpp b/Runtime/RetroTypes.hpp index 9a949b3ef..22a2262bb 100644 --- a/Runtime/RetroTypes.hpp +++ b/Runtime/RetroTypes.hpp @@ -13,27 +13,46 @@ namespace urde { using FourCC = hecl::FourCC; -using ResId = u64; -#define kInvalidResId ResId(-1) + +class CAssetId +{ +private: + u64 id = UINT64_MAX; +public: + CAssetId() = default; + CAssetId(u64 v) { Assign(v); } + explicit CAssetId(CInputStream& in); + bool IsValid() const { return id != UINT64_MAX; } + u64 Value() const { return id; } + void Assign(u64 v) { id = (v == UINT32_MAX ? UINT64_MAX : (v == 0 ? UINT64_MAX : v)); } + void Reset() { id = UINT64_MAX; } + void PutTo(COutputStream& out); + + bool operator==(const CAssetId& other) const { return id == other.id; } + bool operator!=(const CAssetId& other) const { return id != other.id; } + bool operator<(const CAssetId& other) const { return id < other.id; } +}; + +//#define kInvalidAssetId CAssetId() struct SObjectTag { FourCC type; - ResId id = kInvalidResId; - operator bool() const { return (id != kInvalidResId); } + CAssetId id; + operator bool() const { return id.IsValid(); } bool operator!=(const SObjectTag& other) const { return id != other.id; } bool operator==(const SObjectTag& other) const { return id == other.id; } bool operator<(const SObjectTag& other) const { return id < other.id; } SObjectTag() = default; - SObjectTag(FourCC tp, ResId rid) : type(tp), id(rid) {} - SObjectTag(CInputStream& in) + SObjectTag(FourCC tp, CAssetId rid) : type(tp), id(rid) {} + SObjectTag(CInputStream& in, bool _64bit = false) { in.readBytesToBuf(&type, 4); - id = in.readUint32Big(); + id = (_64bit ? in.readUint64Big() : in.readUint32Big()); } - void readMLVL(CInputStream& in) + void readMLVL(CInputStream& in, bool _64bit = false) { - id = in.readUint32Big(); + id = (_64bit ? in.readUint64Big() : in.readUint32Big()); in.readBytesToBuf(&type, 4); } }; @@ -51,6 +70,7 @@ struct TEditorId bool operator!=(const TEditorId& other) const { return (id & 0x3ffffff) != (other.id & 0x3ffffff); } bool operator==(const TEditorId& other) const { return (id & 0x3ffffff) == (other.id & 0x3ffffff); } }; +#define kInvalidEditorId TEditorId() struct TUniqueId { @@ -65,10 +85,10 @@ struct TUniqueId bool operator==(const TUniqueId& other) const { return (id == other.id); } }; +#define kInvalidUniqueId TUniqueId() + using TAreaId = s32; -#define kInvalidEditorId TEditorId() -#define kInvalidUniqueId TUniqueId() #define kInvalidAreaId TAreaId(-1) } @@ -146,7 +166,13 @@ namespace std template <> struct hash { - inline size_t operator()(const urde::SObjectTag& tag) const { return tag.id; } + inline size_t operator()(const urde::SObjectTag& tag) const { return tag.id.Value(); } +}; + +template <> +struct hash +{ + inline size_t operator()(const urde::CAssetId& id) const { return id.Value(); } }; } diff --git a/Runtime/Weapon/CBeamInfo.hpp b/Runtime/Weapon/CBeamInfo.hpp index 5c21d2f5c..3ac2e6463 100644 --- a/Runtime/Weapon/CBeamInfo.hpp +++ b/Runtime/Weapon/CBeamInfo.hpp @@ -11,10 +11,10 @@ struct CBeamInfo { u32 x0_; u32 x4_; - ResId x8_; - ResId xc_; - ResId x10_; - ResId x14_; + CAssetId x8_; + CAssetId xc_; + CAssetId x10_; + CAssetId x14_; u32 x18_; float x1c_; float x20_; diff --git a/Runtime/Weapon/CFlameInfo.cpp b/Runtime/Weapon/CFlameInfo.cpp index a7ed88b5e..2ac470f4e 100644 --- a/Runtime/Weapon/CFlameInfo.cpp +++ b/Runtime/Weapon/CFlameInfo.cpp @@ -3,7 +3,7 @@ namespace urde { -CFlameInfo::CFlameInfo(s32 w1, s32 w2, ResId flameFxId, s32 w3, float f1, float f2, float f3) +CFlameInfo::CFlameInfo(s32 w1, s32 w2, CAssetId flameFxId, s32 w3, float f1, float f2, float f3) : x0_(w1) , x4_(w2) , x8_flameFxId(flameFxId) diff --git a/Runtime/Weapon/CFlameInfo.hpp b/Runtime/Weapon/CFlameInfo.hpp index a13afb190..ec5d369ab 100644 --- a/Runtime/Weapon/CFlameInfo.hpp +++ b/Runtime/Weapon/CFlameInfo.hpp @@ -9,17 +9,17 @@ class CFlameInfo { s32 x0_; s32 x4_; - ResId x8_flameFxId; + CAssetId x8_flameFxId; s32 xc_; float x10_; float x18_; float x1c_; public: - CFlameInfo(s32, s32, ResId, s32, float, float, float); + CFlameInfo(s32, s32, CAssetId, s32, float, float, float); void GetAttributes() const; float GetLength() const; - ResId GetFlameFxId() const { return x8_flameFxId; } + CAssetId GetFlameFxId() const { return x8_flameFxId; } }; } #endif // __URDE_CFLAMEINFO_HPP__ diff --git a/Runtime/Weapon/CGameProjectile.hpp b/Runtime/Weapon/CGameProjectile.hpp index 061fb057b..0f0e2d60f 100644 --- a/Runtime/Weapon/CGameProjectile.hpp +++ b/Runtime/Weapon/CGameProjectile.hpp @@ -40,6 +40,9 @@ public: void DeleteProjectileLight(CStateManager&); void CreateProjectileLight(const std::string&, const CLight&, CStateManager&); void Chase(float, CStateManager&); + EWeaponCollisionResponseTypes GetCollisionResponseType(const zeus::CVector3f&, const zeus::CVector3f&, + const CWeaponMode&, int) const + { return EWeaponCollisionResponseTypes::Projectile; } }; } diff --git a/Runtime/Weapon/CGunWeapon.cpp b/Runtime/Weapon/CGunWeapon.cpp index 9a8d33da6..f0d0a4323 100644 --- a/Runtime/Weapon/CGunWeapon.cpp +++ b/Runtime/Weapon/CGunWeapon.cpp @@ -41,7 +41,7 @@ s32 GetWeaponIndex(EWeaponType type) return 0; } -CGunWeapon::CGunWeapon(ResId ancsId, EWeaponType type, TUniqueId uid, EMaterialTypes mType, const zeus::CVector3f& vec) +CGunWeapon::CGunWeapon(CAssetId ancsId, EWeaponType type, TUniqueId uid, EMaterialTypes mType, const zeus::CVector3f& vec) : x4_(vec), x104_gunCharacter(g_SimplePool->GetObj(SObjectTag{FOURCC('ANCS'), ancsId})), x13c_armCharacter(g_SimplePool->GetObj(skSuitArmNames[0])), diff --git a/Runtime/Weapon/CGunWeapon.hpp b/Runtime/Weapon/CGunWeapon.hpp index 203e99cce..c41614eaf 100644 --- a/Runtime/Weapon/CGunWeapon.hpp +++ b/Runtime/Weapon/CGunWeapon.hpp @@ -59,7 +59,7 @@ protected: CVelocityInfo x1d0_velInfo; CPlayerState::EBeamId x200_beamId; public: - CGunWeapon(ResId ancsId, EWeaponType type, TUniqueId uid, EMaterialTypes, const zeus::CVector3f& vec); + CGunWeapon(CAssetId ancsId, EWeaponType type, TUniqueId uid, EMaterialTypes, const zeus::CVector3f& vec); void AsyncLoadSuitArm(CStateManager& mgr); void AllocResPools(CPlayerState::EBeamId); diff --git a/Runtime/Weapon/CPlasmaProjectile.hpp b/Runtime/Weapon/CPlasmaProjectile.hpp index c2cda0a6c..c7b691e3a 100644 --- a/Runtime/Weapon/CPlasmaProjectile.hpp +++ b/Runtime/Weapon/CPlasmaProjectile.hpp @@ -15,6 +15,8 @@ public: bool, u32); void Accept(IVisitor& visitor); + + void UpdateFx(const zeus::CTransform&, float, CStateManager&) {} }; } diff --git a/Runtime/Weapon/CPlayerGun.cpp b/Runtime/Weapon/CPlayerGun.cpp index 4badeaf2c..7a54c9a9a 100644 --- a/Runtime/Weapon/CPlayerGun.cpp +++ b/Runtime/Weapon/CPlayerGun.cpp @@ -24,7 +24,7 @@ CPlayerGun::CPlayerGun(TUniqueId id) /* TODO: Finish */ } -void CPlayerGun::AcceptScriptMessage(EScriptObjectMessage, TUniqueId, CStateManager&) +void CPlayerGun::AcceptScriptMsg(EScriptObjectMessage, TUniqueId, CStateManager&) { } diff --git a/Runtime/Weapon/CPlayerGun.hpp b/Runtime/Weapon/CPlayerGun.hpp index f1527289b..0fa8e83f3 100644 --- a/Runtime/Weapon/CPlayerGun.hpp +++ b/Runtime/Weapon/CPlayerGun.hpp @@ -208,7 +208,7 @@ private: public: CPlayerGun(TUniqueId id); - void AcceptScriptMessage(EScriptObjectMessage, TUniqueId, CStateManager&); + void AcceptScriptMsg(EScriptObjectMessage, TUniqueId, CStateManager&); void AsyncLoadSuit(CStateManager& mgr); void TouchModel(const CStateManager& stateMgr); EMissleMode GetMissleMode() const { return x31c_missileMode; } diff --git a/Runtime/Weapon/CWeapon.hpp b/Runtime/Weapon/CWeapon.hpp index 6fe16ee91..f80daa2d6 100644 --- a/Runtime/Weapon/CWeapon.hpp +++ b/Runtime/Weapon/CWeapon.hpp @@ -56,8 +56,8 @@ public: void Think(float, CStateManager &) {} void Render(const CStateManager&) const {} - EWeaponCollisionResponseTypes GetCollisionResponseType(const zeus::CVector3f&, const zeus::CVector3f&, CWeaponMode&, - int) + EWeaponCollisionResponseTypes GetCollisionResponseType(const zeus::CVector3f&, const zeus::CVector3f&, + const CWeaponMode&, int) const { return EWeaponCollisionResponseTypes::Default; } diff --git a/Runtime/World/CActor.cpp b/Runtime/World/CActor.cpp index 59a895d14..acb9b68d3 100644 --- a/Runtime/World/CActor.cpp +++ b/Runtime/World/CActor.cpp @@ -150,7 +150,7 @@ const zeus::CTransform CActor::GetLocatorTransform(const std::string& segName) c } EWeaponCollisionResponseTypes CActor::GetCollisionResponseType(const zeus::CVector3f&, const zeus::CVector3f&, - CWeaponMode&, s32) + const CWeaponMode&, s32) const { return EWeaponCollisionResponseTypes::Unknown13; } diff --git a/Runtime/World/CActor.hpp b/Runtime/World/CActor.hpp index 70bba928f..df35c5673 100644 --- a/Runtime/World/CActor.hpp +++ b/Runtime/World/CActor.hpp @@ -119,7 +119,7 @@ public: virtual zeus::CVector3f GetHomingPosition(const CStateManager&, float) const; virtual zeus::CVector3f GetScanObjectIndicatorPosition(const CStateManager&) const; virtual EWeaponCollisionResponseTypes GetCollisionResponseType(const zeus::CVector3f&, const zeus::CVector3f&, - CWeaponMode&, int); + const CWeaponMode&, int) const; virtual void FluidFXThink(EFluidState, CScriptWater&, CStateManager&); virtual void OnScanStateChanged(EScanState, CStateManager&); virtual zeus::CAABox GetSortingBounds(const CStateManager&) const; diff --git a/Runtime/World/CActorParameters.hpp b/Runtime/World/CActorParameters.hpp index c5de8c8e5..ce42875be 100644 --- a/Runtime/World/CActorParameters.hpp +++ b/Runtime/World/CActorParameters.hpp @@ -13,8 +13,8 @@ class CActorParameters friend class ScriptLoader; CLightParameters x0_lightParms; CScannableParameters x40_scanParms; - std::pair x44_xrayAssets = {}; - std::pair x4c_thermalAssets = {}; + std::pair x44_xrayAssets = {}; + std::pair x4c_thermalAssets = {}; CVisorParameters x54_visorParms; union { @@ -34,7 +34,7 @@ class CActorParameters public: CActorParameters() : x58_24_(true), x58_25_thermalHeat(false), x58_26_(false), x58_27_(false) {} CActorParameters(const CLightParameters& lightParms, const CScannableParameters& scanParms, - const std::pair& xrayAssets, const std::pair& thermalAssets, + const std::pair& xrayAssets, const std::pair& thermalAssets, const CVisorParameters& visorParms, bool b1, bool thermalHeat, bool c, bool d) : x0_lightParms(lightParms) , x40_scanParms(scanParms) diff --git a/Runtime/World/CAi.cpp b/Runtime/World/CAi.cpp index 6ffe21c4b..96f6a117b 100644 --- a/Runtime/World/CAi.cpp +++ b/Runtime/World/CAi.cpp @@ -16,7 +16,7 @@ static CMaterialList MakeAiMaterialList(const CMaterialList& in) CAi::CAi(TUniqueId uid, bool active, const std::string& name, const CEntityInfo& info, const zeus::CTransform& xf, CModelData&& mData, const zeus::CAABox& box, float mass, const CHealthInfo& hInfo, - const CDamageVulnerability& dmgVuln, const CMaterialList& list, ResId fsm, const CActorParameters& actorParams, + const CDamageVulnerability& dmgVuln, const CMaterialList& list, CAssetId fsm, const CActorParameters& actorParams, float stepUp, float stepDown) : CPhysicsActor(uid, active, name, info, xf, std::move(mData), MakeAiMaterialList(list), box, SMoverData(mass), actorParams, stepUp, stepDown) diff --git a/Runtime/World/CAi.hpp b/Runtime/World/CAi.hpp index 24112e9cf..364b3c78b 100644 --- a/Runtime/World/CAi.hpp +++ b/Runtime/World/CAi.hpp @@ -37,7 +37,7 @@ public: CAi(TUniqueId uid, bool active, const std::string& name, const CEntityInfo& info, const zeus::CTransform& xf, CModelData&& mData, const zeus::CAABox& box, float mass, const CHealthInfo& hInfo, const CDamageVulnerability&, - const CMaterialList& list, ResId fsm, const CActorParameters&, float f1, float f2); + const CMaterialList& list, CAssetId fsm, const CActorParameters&, float f1, float f2); static void CreateFuncLookup(CAiFuncMap* funcMap); static CAiStateFunc GetStateFunc(const char* func); diff --git a/Runtime/World/CAnimationParameters.hpp b/Runtime/World/CAnimationParameters.hpp index 1802ba2c8..2885ff893 100644 --- a/Runtime/World/CAnimationParameters.hpp +++ b/Runtime/World/CAnimationParameters.hpp @@ -8,19 +8,19 @@ namespace urde class CAnimationParameters { - ResId x0_ancs = -1; + CAssetId x0_ancs = -1; u32 x4_charIdx = -1; u32 x8_defaultAnim = -1; public: CAnimationParameters() = default; - CAnimationParameters(ResId ancs, u32 charIdx, u32 defaultAnim) + CAnimationParameters(CAssetId ancs, u32 charIdx, u32 defaultAnim) : x0_ancs(ancs), x4_charIdx(charIdx), x8_defaultAnim(defaultAnim) {} CAnimationParameters(CInputStream& in) : x0_ancs(in.readUint32Big()), x4_charIdx(in.readUint32Big()), x8_defaultAnim(in.readUint32Big()) {} - ResId GetACSFile() const { return x0_ancs; } + CAssetId GetACSFile() const { return x0_ancs; } u32 GetCharacter() const { return x4_charIdx; } u32 GetInitialAnimation() const { return x8_defaultAnim; } void SetCharacter(u32 charIdx) { x4_charIdx = charIdx; } diff --git a/Runtime/World/CDestroyableRock.cpp b/Runtime/World/CDestroyableRock.cpp index 0a80d0fa1..20dbab798 100644 --- a/Runtime/World/CDestroyableRock.cpp +++ b/Runtime/World/CDestroyableRock.cpp @@ -5,7 +5,7 @@ namespace urde CDestroyableRock::CDestroyableRock(TUniqueId id, bool active, const std::string& name, const CEntityInfo& info, const zeus::CTransform& xf, CModelData&& modelData, float mass, const CHealthInfo& health, - const CDamageVulnerability& vulnerability, const CMaterialList& matList, ResId fsm, + const CDamageVulnerability& vulnerability, const CMaterialList& matList, CAssetId fsm, const CActorParameters& actParams, const CModelData& modelData2) : CAi(id, active, name, info, xf, std::move(modelData), modelData.GetBounds(), mass, health, vulnerability, matList, fsm, actParams, 0.3f, 0.8f) diff --git a/Runtime/World/CDestroyableRock.hpp b/Runtime/World/CDestroyableRock.hpp index 4c41dcb8a..7c95570dd 100644 --- a/Runtime/World/CDestroyableRock.hpp +++ b/Runtime/World/CDestroyableRock.hpp @@ -11,7 +11,7 @@ class CDestroyableRock : public CAi public: CDestroyableRock(TUniqueId id, bool active, const std::string& name, const CEntityInfo& info, const zeus::CTransform& xf, CModelData&& modelData, float mass, const CHealthInfo& health, - const CDamageVulnerability& vulnerability, const CMaterialList& matList, ResId fsm, + const CDamageVulnerability& vulnerability, const CMaterialList& matList, CAssetId fsm, const CActorParameters& actParams, const CModelData& modelData2); }; diff --git a/Runtime/World/CFluidPlane.cpp b/Runtime/World/CFluidPlane.cpp index 2827eacfe..9408efa03 100644 --- a/Runtime/World/CFluidPlane.cpp +++ b/Runtime/World/CFluidPlane.cpp @@ -5,7 +5,7 @@ namespace urde { -CFluidPlane::CFluidPlane(ResId texPattern1, ResId texPattern2, ResId texColor, float alpha, EFluidType fluidType, +CFluidPlane::CFluidPlane(CAssetId texPattern1, CAssetId texPattern2, CAssetId texColor, float alpha, EFluidType fluidType, float f2, const CFluidUVMotion& motion) : x4_texPattern1Id(texPattern1), x8_texPattern2Id(texPattern2), xc_texColorId(texColor), x40_alpha(alpha), x44_fluidType(fluidType), x48_f2(f2), x4c_uvMotion(motion) diff --git a/Runtime/World/CFluidPlane.hpp b/Runtime/World/CFluidPlane.hpp index 886e0a655..15f30a5b5 100644 --- a/Runtime/World/CFluidPlane.hpp +++ b/Runtime/World/CFluidPlane.hpp @@ -28,9 +28,9 @@ public: }; protected: - ResId x4_texPattern1Id; - ResId x8_texPattern2Id; - ResId xc_texColorId; + CAssetId x4_texPattern1Id; + CAssetId x8_texPattern2Id; + CAssetId xc_texColorId; std::experimental::optional> x10_texPattern1; std::experimental::optional> x20_texPattern2; std::experimental::optional> x30_texColor; @@ -39,7 +39,7 @@ protected: float x48_f2; CFluidUVMotion x4c_uvMotion; public: - CFluidPlane(ResId texPattern1, ResId texPattern2, ResId texColor, float alpha, EFluidType fluidType, + CFluidPlane(CAssetId texPattern1, CAssetId texPattern2, CAssetId texColor, float alpha, EFluidType fluidType, float f2, const CFluidUVMotion& motion); virtual void Ripple(float mag, TUniqueId rippler, const zeus::CVector3f& pos, diff --git a/Runtime/World/CFluidPlaneCPU.cpp b/Runtime/World/CFluidPlaneCPU.cpp index a1c0e3a31..7cedd9b51 100644 --- a/Runtime/World/CFluidPlaneCPU.cpp +++ b/Runtime/World/CFluidPlaneCPU.cpp @@ -43,8 +43,8 @@ CFluidPlaneCPU::CTurbulence::CTurbulence(float speed, float distance, float freq } } -CFluidPlaneCPU::CFluidPlaneCPU(ResId texPattern1, ResId texPattern2, ResId texColor, ResId bumpMap, ResId envMap, - ResId envBumpMap, ResId lightMap, float unitsPerLightmapTexel, float tileSize, +CFluidPlaneCPU::CFluidPlaneCPU(CAssetId texPattern1, CAssetId texPattern2, CAssetId texColor, CAssetId bumpMap, CAssetId envMap, + CAssetId envBumpMap, CAssetId lightMap, float unitsPerLightmapTexel, float tileSize, u32 tileSubdivisions, EFluidType fluidType, float alpha, const zeus::CVector3f& bumpLightDir, float bumpScale, const CFluidUVMotion& mot, float turbSpeed, float turbDistance, float turbFreqMax, float turbFreqMin, diff --git a/Runtime/World/CFluidPlaneCPU.hpp b/Runtime/World/CFluidPlaneCPU.hpp index f5f8839b0..b51ec2ee2 100644 --- a/Runtime/World/CFluidPlaneCPU.hpp +++ b/Runtime/World/CFluidPlaneCPU.hpp @@ -35,10 +35,10 @@ class CFluidPlaneCPU : public CFluidPlane bool HasTurbulence() const { return x34_hasTurbulence; } }; - ResId xa0_texIdBumpMap; - ResId xa4_texIdEnvMap; - ResId xa8_texIdEnvBumpMap; - ResId xac_texId4; + CAssetId xa0_texIdBumpMap; + CAssetId xa4_texIdEnvMap; + CAssetId xa8_texIdEnvBumpMap; + CAssetId xac_texId4; std::experimental::optional> xb0_bumpMap; std::experimental::optional> xc0_envMap; std::experimental::optional> xd0_envBumpMap; @@ -67,8 +67,8 @@ class CFluidPlaneCPU : public CFluidPlane std::vector lights; }; public: - CFluidPlaneCPU(ResId texPattern1, ResId texPattern2, ResId texColor, ResId bumpMap, ResId envMap, ResId envBumpMap, - ResId lightMap, float unitsPerLightmapTexel, float tileSize, u32 tileSubdivisions, + CFluidPlaneCPU(CAssetId texPattern1, CAssetId texPattern2, CAssetId texColor, CAssetId bumpMap, CAssetId envMap, CAssetId envBumpMap, + CAssetId lightMap, float unitsPerLightmapTexel, float tileSize, u32 tileSubdivisions, EFluidType fluidType, float alpha, const zeus::CVector3f& bumpLightDir, float bumpScale, const CFluidUVMotion& mot, float turbSpeed, float turbDistance, float turbFreqMax, float turbFreqMin, float turbPhaseMax, float turbPhaseMin, float turbAmplitudeMax, diff --git a/Runtime/World/CGameArea.cpp b/Runtime/World/CGameArea.cpp index 6c108be62..82f95a652 100644 --- a/Runtime/World/CGameArea.cpp +++ b/Runtime/World/CGameArea.cpp @@ -333,7 +333,7 @@ TAreaId CDummyGameArea::IGetAreaId() const return x10_areaId; } -ResId CDummyGameArea::IGetAreaAssetId() const +CAssetId CDummyGameArea::IGetAreaAssetId() const { return xc_mrea; } @@ -353,7 +353,7 @@ u32 CDummyGameArea::IGetNumAttachedAreas() const return x44_attachedAreaIndices.size(); } -ResId CDummyGameArea::IGetStringTableAssetId() const +CAssetId CDummyGameArea::IGetStringTableAssetId() const { return x8_nameSTRG; } @@ -430,7 +430,7 @@ u32 CGameArea::IGetNumAttachedAreas() const return x8c_attachedAreaIndices.size(); } -ResId CGameArea::IGetStringTableAssetId() const +CAssetId CGameArea::IGetStringTableAssetId() const { return x8_nameSTRG; } @@ -913,7 +913,7 @@ void CGameArea::PostConstructArea() if (header.version > 9) { athena::io::MemoryReader r(secIt->first, secIt->second); - ResId pathId = r.readUint32Big(); + CAssetId pathId = r.readUint32Big(); x12c_postConstructed->x10ac_path = g_SimplePool->GetObj(SObjectTag{FOURCC('PATH'), pathId}); ++secIt; } diff --git a/Runtime/World/CGameArea.hpp b/Runtime/World/CGameArea.hpp index 949b15744..2f9b21204 100644 --- a/Runtime/World/CGameArea.hpp +++ b/Runtime/World/CGameArea.hpp @@ -27,9 +27,9 @@ class CDummyGameArea : public IGameArea friend class CDummyWorld; int x4_mlvlVersion; - ResId x8_nameSTRG; - ResId xc_mrea; - ResId x10_areaId; + CAssetId x8_nameSTRG; + CAssetId xc_mrea; + TAreaId x10_areaId; zeus::CTransform x14_transform; std::vector x44_attachedAreaIndices; std::vector x54_docks; @@ -39,11 +39,11 @@ public: bool IGetScriptingMemoryAlways() const; TAreaId IGetAreaId() const; - ResId IGetAreaAssetId() const; + CAssetId IGetAreaAssetId() const; bool IIsActive() const; TAreaId IGetAttachedAreaId(int) const; u32 IGetNumAttachedAreas() const; - ResId IGetStringTableAssetId() const; + CAssetId IGetStringTableAssetId() const; const zeus::CTransform& IGetTM() const; }; @@ -84,11 +84,11 @@ class CGameArea : public IGameArea friend class CStateManager; int x4_selfIdx; - ResId x8_nameSTRG; + CAssetId x8_nameSTRG; zeus::CTransform xc_transform; zeus::CTransform x3c_invTransform; zeus::CAABox x6c_aabb; - ResId x84_mrea; + CAssetId x84_mrea; u32 x88_areaId; std::vector x8c_attachedAreaIndices; std::vector x9c_deps1; @@ -295,17 +295,17 @@ public: bool IGetScriptingMemoryAlways() const; TAreaId GetAreaId() const { return x4_selfIdx; } TAreaId IGetAreaId() const { return x4_selfIdx; } - ResId IGetAreaAssetId() const { return x84_mrea; } + CAssetId IGetAreaAssetId() const { return x84_mrea; } bool IIsActive() const; TAreaId IGetAttachedAreaId(int) const; u32 IGetNumAttachedAreas() const; - ResId IGetStringTableAssetId() const; + CAssetId IGetStringTableAssetId() const; const zeus::CTransform& IGetTM() const; void SetXRaySpeedAndTarget(float f1, float f2); void SetThermalSpeedAndTarget(float f1, float f2); - ResId GetAreaAssetId() const { return x84_mrea; } + CAssetId GetAreaAssetId() const { return x84_mrea; } const CAreaFog* GetAreaFog() const { return GetPostConstructed()->x10c4_areaFog.get(); } CAreaFog* AreaFog() { return const_cast(GetAreaFog()); } float GetXRayFogDistance() const; diff --git a/Runtime/World/CMorphBall.cpp b/Runtime/World/CMorphBall.cpp index b8923b72f..f3758fe4c 100644 --- a/Runtime/World/CMorphBall.cpp +++ b/Runtime/World/CMorphBall.cpp @@ -11,7 +11,7 @@ CMorphBall::CMorphBall(CPlayer& player, float) { } -void CMorphBall::AcceptScriptMessage(EScriptObjectMessage msg, TUniqueId sender, CStateManager& mgr) +void CMorphBall::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId sender, CStateManager& mgr) { } diff --git a/Runtime/World/CMorphBall.hpp b/Runtime/World/CMorphBall.hpp index dcd3ded15..e840c675b 100644 --- a/Runtime/World/CMorphBall.hpp +++ b/Runtime/World/CMorphBall.hpp @@ -54,7 +54,7 @@ private: public: CMorphBall(CPlayer& player, float); - void AcceptScriptMessage(EScriptObjectMessage msg, TUniqueId sender, CStateManager& mgr); + void AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId sender, CStateManager& mgr); ESpiderBallState GetSpiderBallState() const { return ESpiderBallState::Zero; } bool InSpiderBallMode() const { return false; } zeus::CVector3f GetBallContactSurfaceNormal() const { return {}; } diff --git a/Runtime/World/CPatternedInfo.hpp b/Runtime/World/CPatternedInfo.hpp index cbd351cab..654dc999a 100644 --- a/Runtime/World/CPatternedInfo.hpp +++ b/Runtime/World/CPatternedInfo.hpp @@ -41,18 +41,18 @@ class CPatternedInfo u16 xe8_deathSfx; CAnimationParameters xec_animParams; bool xf8_active; - ResId xfc_stateMachineId; + CAssetId xfc_stateMachineId; float x100_; float x104_; float x108_; u32 x10c_particle1Frames; zeus::CVector3f x110_particle1Scale; - ResId x11c_particle1; + CAssetId x11c_particle1; u32 x120_particle2Frames; zeus::CVector3f x124_particle2Scale; - ResId x130_particle2 = -1; + CAssetId x130_particle2 = -1; u16 x134_iceShatterSfx = -1; diff --git a/Runtime/World/CPlayer.cpp b/Runtime/World/CPlayer.cpp index cfbdb611e..997beb39c 100644 --- a/Runtime/World/CPlayer.cpp +++ b/Runtime/World/CPlayer.cpp @@ -41,12 +41,12 @@ static const CMaterialFilter OccluderFilter = CMaterialFilter::MakeIncludeExclude({EMaterialTypes::Solid, EMaterialTypes::Occluder}, {EMaterialTypes::ProjectilePassthrough, EMaterialTypes::ScanPassthrough, EMaterialTypes::Player}); -static CModelData MakePlayerAnimRes(ResId resId, const zeus::CVector3f& scale) +static CModelData MakePlayerAnimRes(CAssetId resId, const zeus::CVector3f& scale) { return {CAnimRes(resId, 0, scale, 0, true), 1}; } -CPlayer::CPlayer(TUniqueId uid, const zeus::CTransform& xf, const zeus::CAABox& aabb, ResId resId, +CPlayer::CPlayer(TUniqueId uid, const zeus::CTransform& xf, const zeus::CAABox& aabb, CAssetId resId, const zeus::CVector3f& playerScale, float mass, float stepUp, float stepDown, float f4, const CMaterialList& ml) : CPhysicsActor(uid, true, "CPlayer", CEntityInfo(kInvalidAreaId, CEntity::NullConnectionList), xf, @@ -64,7 +64,7 @@ CPlayer::CPlayer(TUniqueId uid, const zeus::CTransform& xf, const zeus::CAABox& x9c4_27_canEnterMorphBall = true; x9c4_28_canLeaveMorphBall = true; x9c5_31_ = true; - ResId beamId = g_tweakPlayerRes->GetBeamBallTransitionModel(x7ec_beam); + CAssetId beamId = g_tweakPlayerRes->GetBeamBallTransitionModel(x7ec_beam); x7f0_ballTransitionBeamModel = std::make_unique(CStaticRes(beamId, playerScale)); x730_transitionModels.reserve(3); x768_morphball.reset(new CMorphBall(*this, f4)); @@ -528,7 +528,7 @@ bool CPlayer::ValidateScanning(const CFinalInput& input, CStateManager& mgr) return false; } -static bool IsDataLoreResearchScan(ResId id) +static bool IsDataLoreResearchScan(CAssetId id) { auto it = g_MemoryCardSys->LookupScanState(id); if (it == g_MemoryCardSys->GetScanStates().cend()) @@ -550,7 +550,7 @@ static const char* UnlockMessageResBases[] = "STRG_SlideShow_Unlock2_" }; -static ResId UpdatePersistentScanPercent(u32 prevLogScans, u32 logScans, u32 totalLogScans) +static CAssetId UpdatePersistentScanPercent(u32 prevLogScans, u32 logScans, u32 totalLogScans) { if (prevLogScans == logScans) return -1; @@ -586,7 +586,7 @@ void CPlayer::FinishNewScan(CStateManager& mgr) if (IsDataLoreResearchScan(scanInfo->GetScannableObjectId())) { auto scanCompletion = mgr.CalculateScanCompletionRate(); - ResId message = UpdatePersistentScanPercent(mgr.GetPlayerState()->GetLogScans(), + CAssetId message = UpdatePersistentScanPercent(mgr.GetPlayerState()->GetLogScans(), scanCompletion.first, scanCompletion.second); if (message != -1) mgr.ShowPausedHUDMemo(message, 0.f); @@ -1453,7 +1453,7 @@ void CPlayer::Stop(CStateManager& stateMgr) CPhysicsActor::Stop(); ClearForcesAndTorques(); RemoveMaterial(EMaterialTypes::Immovable, stateMgr); - if (!stateMgr.GetCameraManager()->IsInCinematicCamera() && xa0c_iceTextureId != kInvalidResId) + if (!stateMgr.GetCameraManager()->IsInCinematicCamera() && xa0c_iceTextureId.IsValid()) { std::experimental::optional> gpsm; gpsm.emplace(g_SimplePool->GetObj(SObjectTag(FOURCC('PART'), xa0c_iceTextureId))); @@ -1470,7 +1470,7 @@ void CPlayer::Stop(CStateManager& stateMgr) } } -void CPlayer::Freeze(CStateManager& stateMgr, ResId steamTxtr, u16 sfx, ResId iceTxtr) +void CPlayer::Freeze(CStateManager& stateMgr, CAssetId steamTxtr, u16 sfx, CAssetId iceTxtr) { if (stateMgr.GetCameraManager()->IsInCinematicCamera() || GetFrozenState()) return; @@ -1758,12 +1758,12 @@ void CPlayer::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId sender, CState default: break; } - x490_gun->AcceptScriptMessage(msg, sender, mgr); - x768_morphball->AcceptScriptMessage(msg, sender, mgr); + x490_gun->AcceptScriptMsg(msg, sender, mgr); + x768_morphball->AcceptScriptMsg(msg, sender, mgr); CActor::AcceptScriptMsg(msg, sender, mgr); } -void CPlayer::SetVisorSteam(float f1, float f2, float f3, ResId txtr, bool affectsThermal) +void CPlayer::SetVisorSteam(float f1, float f2, float f3, CAssetId txtr, bool affectsThermal) { x7a0_visorSteam.SetSteam(f1, f2, f3, txtr, affectsThermal); } @@ -4227,9 +4227,9 @@ void CPlayer::Touch(CActor& actor, CStateManager& mgr) x768_morphball->Touch(actor, mgr); } -void CPlayer::CVisorSteam::SetSteam(float a, float b, float c, ResId txtr, bool affectsThermal) +void CPlayer::CVisorSteam::SetSteam(float a, float b, float c, CAssetId txtr, bool affectsThermal) { - if (x1c_txtr == kInvalidResId || a > x10_) + if (x1c_txtr.IsValid() || a > x10_) { x10_ = a; x14_ = b; @@ -4239,11 +4239,11 @@ void CPlayer::CVisorSteam::SetSteam(float a, float b, float c, ResId txtr, bool x28_affectsThermal = affectsThermal; } -ResId CPlayer::CVisorSteam::GetTextureId() const { return xc_tex; } +CAssetId CPlayer::CVisorSteam::GetTextureId() const { return xc_tex; } void CPlayer::CVisorSteam::Update(float dt) { - if (x1c_txtr == kInvalidResId) + if (!x1c_txtr.IsValid()) x0_ = 0.f; else { @@ -4253,7 +4253,7 @@ void CPlayer::CVisorSteam::Update(float dt) xc_tex = x1c_txtr; } - x1c_txtr = kInvalidResId; + x1c_txtr.Reset(); if ((x20_alpha - x0_) < 0.000009999f || std::fabs(x20_alpha) > 0.000009999f) return; diff --git a/Runtime/World/CPlayer.hpp b/Runtime/World/CPlayer.hpp index 74d8779db..b46220395 100644 --- a/Runtime/World/CPlayer.hpp +++ b/Runtime/World/CPlayer.hpp @@ -164,19 +164,19 @@ private: float x0_; float x4_; float x8_; - ResId xc_tex; + CAssetId xc_tex; float x10_ = 0.f; float x14_ = 0.f; float x18_ = 0.f; - ResId x1c_txtr = kInvalidResId; + CAssetId x1c_txtr; float x20_alpha = 0.f; float x24_ = 0.f; bool x28_affectsThermal = false; public: - CVisorSteam(float a, float b, float c, ResId tex) : x0_(a), x4_(b), x8_(c), xc_tex(tex) {} - ResId GetTextureId() const; - void SetSteam(float a, float b, float c, ResId txtr, bool affectsThermal); + CVisorSteam(float a, float b, float c, CAssetId tex) : x0_(a), x4_(b), x8_(c), xc_tex(tex) {} + CAssetId GetTextureId() const; + void SetSteam(float a, float b, float c, CAssetId txtr, bool affectsThermal); void Update(float dt); float GetAlpha() const { return x20_alpha; } bool AffectsThermal() const { return x28_affectsThermal; } @@ -334,8 +334,8 @@ private: float x78c_footstepSfxTimer = 0.f; EFootstepSfx x790_footstepSfxSel = EFootstepSfx::None; zeus::CVector3f x794_; - CVisorSteam x7a0_visorSteam = CVisorSteam(0.f, 0.f, 0.f, kInvalidResId); - ResId x7cc_ = kInvalidResId; + CVisorSteam x7a0_visorSteam = CVisorSteam(0.f, 0.f, 0.f, CAssetId()/*kInvalidAssetId*/); + CAssetId x7cc_; CAnimRes x7d0_animRes; CPlayerState::EBeamId x7ec_beam = CPlayerState::EBeamId::Power; std::unique_ptr x7f0_ballTransitionBeamModel; @@ -396,8 +396,8 @@ private: float x9fc_ = 0.f; TUniqueId xa00_ = kInvalidUniqueId; float xa04_ = 0.f; - ResId xa08_steamTextureId = kInvalidResId; - ResId xa0c_iceTextureId; + CAssetId xa08_steamTextureId; + CAssetId xa0c_iceTextureId; u32 xa10_phazonCounter = 0; float xa14_phazonCameraShakeTimer = 0.f; float xa18_phazonDamageLag = 0.f; @@ -416,7 +416,7 @@ private: void InitializeBallTransition(); public: - CPlayer(TUniqueId, const zeus::CTransform&, const zeus::CAABox&, ResId w1, const zeus::CVector3f&, float, float, + CPlayer(TUniqueId, const zeus::CTransform&, const zeus::CAABox&, CAssetId w1, const zeus::CVector3f&, float, float, float, float, const CMaterialList&); bool IsTransparent() const; @@ -469,13 +469,13 @@ public: void CalculatePlayerControlDirection(CStateManager& mgr); void CalculatePlayerMovementDirection(float dt); void Stop(CStateManager& stateMgr); - void Freeze(CStateManager& stateMgr, ResId steamTxtr, u16 sfx, ResId iceTxtr); + void Freeze(CStateManager& stateMgr, CAssetId steamTxtr, u16 sfx, CAssetId iceTxtr); bool GetFrozenState() const; void UpdateFrozenState(const CFinalInput& input, CStateManager& mgr); void Think(float, CStateManager&); void PreThink(float, CStateManager&); void AcceptScriptMsg(EScriptObjectMessage, TUniqueId, CStateManager&); - void SetVisorSteam(float, float, float, ResId, bool); + void SetVisorSteam(float, float, float, CAssetId, bool); void UpdateFootstepSounds(const CFinalInput& input, CStateManager&, float); u16 GetMaterialSoundUnderPlayer(CStateManager& mgr, const u16*, u32, u16); u16 SfxIdFromMaterial(const CMaterialList&, const u16*, u32, u16); diff --git a/Runtime/World/CScannableParameters.hpp b/Runtime/World/CScannableParameters.hpp index ffd5395e6..509797aa4 100644 --- a/Runtime/World/CScannableParameters.hpp +++ b/Runtime/World/CScannableParameters.hpp @@ -8,11 +8,11 @@ namespace urde class CScannableParameters { - ResId x0_scanId = -1; + CAssetId x0_scanId = -1; public: CScannableParameters() = default; - CScannableParameters(ResId id) : x0_scanId(id) {} + CScannableParameters(CAssetId id) : x0_scanId(id) {} }; } diff --git a/Runtime/World/CScriptActor.cpp b/Runtime/World/CScriptActor.cpp index 8db1ab787..7eab74e5b 100644 --- a/Runtime/World/CScriptActor.cpp +++ b/Runtime/World/CScriptActor.cpp @@ -185,7 +185,8 @@ zeus::CAABox CScriptActor::GetSortingBounds(const CStateManager& mgr) const } EWeaponCollisionResponseTypes -CScriptActor::GetCollisionResponseType(const zeus::CVector3f& v1, const zeus::CVector3f& v2, CWeaponMode& wMode, s32 w) +CScriptActor::GetCollisionResponseType(const zeus::CVector3f& v1, const zeus::CVector3f& v2, const + CWeaponMode& wMode, int w) const { const CDamageVulnerability* dVuln = GetDamageVulnerability(); if (dVuln->GetVulnerability(wMode, false) == EVulnerability::Reflect) diff --git a/Runtime/World/CScriptActor.hpp b/Runtime/World/CScriptActor.hpp index 1bbeb2f17..9e67b8c34 100644 --- a/Runtime/World/CScriptActor.hpp +++ b/Runtime/World/CScriptActor.hpp @@ -39,10 +39,10 @@ public: void PreRender(CStateManager&, const zeus::CFrustum&); zeus::CAABox GetSortingBounds(const CStateManager&) const; EWeaponCollisionResponseTypes GetCollisionResponseType(const zeus::CVector3f&, const zeus::CVector3f&, - CWeaponMode&, int); + const CWeaponMode&, int) const; rstl::optional_object GetTouchBounds() const; void Touch(CActor&, CStateManager&); - const CDamageVulnerability* GetDamageVulnerability() { return &x268_damageVulnerability; } + const CDamageVulnerability* GetDamageVulnerability() const { return &x268_damageVulnerability; } CHealthInfo* HealthInfo() { return &x260_currentHealth; } }; } diff --git a/Runtime/World/CScriptAreaAttributes.cpp b/Runtime/World/CScriptAreaAttributes.cpp index 3bbc16cad..29ac10cf9 100644 --- a/Runtime/World/CScriptAreaAttributes.cpp +++ b/Runtime/World/CScriptAreaAttributes.cpp @@ -9,7 +9,7 @@ namespace urde CScriptAreaAttributes::CScriptAreaAttributes(TUniqueId uid, const CEntityInfo& info, bool showSkybox, EEnvFxType fxType, float envFxDensity, float thermalHeat, float xrayFogDistance, - float worldLightingLevel, ResId skybox, EPhazonType phazonType) + float worldLightingLevel, CAssetId skybox, EPhazonType phazonType) : CEntity(uid, info, true, std::string()) , x34_24_showSkybox(showSkybox) , x38_envFx(fxType) diff --git a/Runtime/World/CScriptAreaAttributes.hpp b/Runtime/World/CScriptAreaAttributes.hpp index bd111a9a7..6bbd05bac 100644 --- a/Runtime/World/CScriptAreaAttributes.hpp +++ b/Runtime/World/CScriptAreaAttributes.hpp @@ -14,13 +14,13 @@ class CScriptAreaAttributes : public CEntity float x40_thermalHeat; float x44_xrayFogDistance; float x48_worldLightingLevel; - ResId x4c_skybox; + CAssetId x4c_skybox; EPhazonType x50_phazon; public: CScriptAreaAttributes(TUniqueId uid, const CEntityInfo& info, bool showSkybox, EEnvFxType fxType, float envFxDensity, float thermalHeat, float xrayFogDistance, float worldLightingLevel, - ResId skybox, EPhazonType phazonType); + CAssetId skybox, EPhazonType phazonType); void Accept(IVisitor& visitor); void AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId objId, CStateManager& stateMgr); diff --git a/Runtime/World/CScriptBeam.cpp b/Runtime/World/CScriptBeam.cpp index efaf47686..ad6e58ad1 100644 --- a/Runtime/World/CScriptBeam.cpp +++ b/Runtime/World/CScriptBeam.cpp @@ -26,8 +26,7 @@ void CScriptBeam::Accept(IVisitor& visitor) void CScriptBeam::Think(float dt, CStateManager& mgr) { -#if 0 - TCastToPtr proj{mgr.GetObjectById(x154_projectileId)}; + CPlasmaProjectile* proj = static_cast(mgr.ObjectById(x154_projectileId)); if (proj) { if (proj->GetActive()) @@ -35,7 +34,6 @@ void CScriptBeam::Think(float dt, CStateManager& mgr) } else x154_projectileId = kInvalidUniqueId; -#endif } void CScriptBeam::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId objId, CStateManager& mgr) diff --git a/Runtime/World/CScriptCameraFilterKeyframe.cpp b/Runtime/World/CScriptCameraFilterKeyframe.cpp index 66717fe53..ce2d0ebf5 100644 --- a/Runtime/World/CScriptCameraFilterKeyframe.cpp +++ b/Runtime/World/CScriptCameraFilterKeyframe.cpp @@ -7,7 +7,7 @@ namespace urde CScriptCameraFilterKeyframe::CScriptCameraFilterKeyframe(TUniqueId uid, const std::string& name, const CEntityInfo& info, EFilterType type, EFilterShape shape, u32 filterIdx, u32 unk, const zeus::CColor& color, - float timeIn, float timeOut, ResId txtr, bool active) + float timeIn, float timeOut, CAssetId txtr, bool active) : CEntity(uid, info, active, name), x34_type(type), x38_shape(shape), x3c_filterIdx(filterIdx), x40_(unk), x44_color(color), x48_timeIn(timeIn), x4c_timeOut(timeOut), x50_txtr(txtr) { diff --git a/Runtime/World/CScriptCameraFilterKeyframe.hpp b/Runtime/World/CScriptCameraFilterKeyframe.hpp index fa70329a5..9ad8b7cff 100644 --- a/Runtime/World/CScriptCameraFilterKeyframe.hpp +++ b/Runtime/World/CScriptCameraFilterKeyframe.hpp @@ -16,13 +16,13 @@ class CScriptCameraFilterKeyframe : public CEntity zeus::CColor x44_color; float x48_timeIn; float x4c_timeOut; - ResId x50_txtr; + CAssetId x50_txtr; public: CScriptCameraFilterKeyframe(TUniqueId uid, const std::string& name, const CEntityInfo& info, EFilterType type, EFilterShape shape, u32 filterIdx, u32 unk, const zeus::CColor& color, - float timeIn, float timeOut, ResId txtr, bool active); + float timeIn, float timeOut, CAssetId txtr, bool active); void AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId objId, CStateManager& stateMgr); void Accept(IVisitor& visitor); diff --git a/Runtime/World/CScriptDamageableTrigger.cpp b/Runtime/World/CScriptDamageableTrigger.cpp index d564deb89..ddf4242f5 100644 --- a/Runtime/World/CScriptDamageableTrigger.cpp +++ b/Runtime/World/CScriptDamageableTrigger.cpp @@ -23,7 +23,7 @@ CMaterialList MakeDamageableTriggerMaterial(CScriptDamageableTrigger::ECanOrbit CScriptDamageableTrigger::CScriptDamageableTrigger(TUniqueId uid, const std::string& name, const CEntityInfo& info, const zeus::CVector3f& position, const zeus::CVector3f& extent, const CHealthInfo&, - const CDamageVulnerability&, u32, ResId, ResId, ResId, + const CDamageVulnerability&, u32, CAssetId, CAssetId, CAssetId, CScriptDamageableTrigger::ECanOrbit canOrbit, bool active, const CVisorParameters& vParams) : CActor(uid, active, name, info, zeus::CTransform::Translate(position), CModelData::CModelDataNull(), MakeDamageableTriggerMaterial(canOrbit), MakeDamageableTriggerActorParms(CActorParameters::None(), vParams), diff --git a/Runtime/World/CScriptDamageableTrigger.hpp b/Runtime/World/CScriptDamageableTrigger.hpp index 25297e6ff..ed3f09304 100644 --- a/Runtime/World/CScriptDamageableTrigger.hpp +++ b/Runtime/World/CScriptDamageableTrigger.hpp @@ -18,7 +18,7 @@ public: zeus::CAABox x14c_bounds; public: CScriptDamageableTrigger(TUniqueId, const std::string&, const CEntityInfo&, const zeus::CVector3f&, const zeus::CVector3f&, - const CHealthInfo&, const CDamageVulnerability&, u32, ResId, ResId, ResId, ECanOrbit, bool, + const CHealthInfo&, const CDamageVulnerability&, u32, CAssetId, CAssetId, CAssetId, ECanOrbit, bool, const CVisorParameters&); void Accept(IVisitor& visitor); diff --git a/Runtime/World/CScriptDebris.cpp b/Runtime/World/CScriptDebris.cpp index 36b213af4..f0b1927e2 100644 --- a/Runtime/World/CScriptDebris.cpp +++ b/Runtime/World/CScriptDebris.cpp @@ -5,7 +5,7 @@ namespace urde { CScriptDebris::CScriptDebris(TUniqueId uid, const std::string& name, const CEntityInfo& info, const zeus::CTransform& xf, - CModelData&& mData, const CActorParameters& aParams, ResId, const zeus::CVector3f&, float, + CModelData&& mData, const CActorParameters& aParams, CAssetId, const zeus::CVector3f&, float, const zeus::CVector3f&, const zeus::CColor&, float f1, float f2, float f3, CScriptDebris::EScaleType, bool, bool, bool active) : CPhysicsActor(uid, active, name, info, xf, std::move(mData), @@ -19,9 +19,9 @@ CScriptDebris::CScriptDebris(TUniqueId uid, const std::string& name, const CEnti CModelData&& mData, const CActorParameters& aParams, float, float, float, float, float, float, float, float, float, const zeus::CColor&, const zeus::CColor&, float, const zeus::CVector3f&, const zeus::CVector3f&, float, float, - const zeus::CVector3f&, u32, const zeus::CVector3f&, bool, bool, - CScriptDebris::EOrientationType, u32, const zeus::CVector3f&, bool, bool, - CScriptDebris::EOrientationType, u32, const zeus::CVector3f&, CScriptDebris::EOrientationType, + const zeus::CVector3f&, CAssetId, const zeus::CVector3f&, bool, bool, + CScriptDebris::EOrientationType, CAssetId, const zeus::CVector3f&, bool, bool, + CScriptDebris::EOrientationType, CAssetId, const zeus::CVector3f&, CScriptDebris::EOrientationType, bool, bool, bool, bool active) : CPhysicsActor(uid, active, name, info, xf, std::move(mData), CMaterialList(EMaterialTypes::Solid, EMaterialTypes::Debris), diff --git a/Runtime/World/CScriptDebris.hpp b/Runtime/World/CScriptDebris.hpp index ebf5b0acd..788d4f1a9 100644 --- a/Runtime/World/CScriptDebris.hpp +++ b/Runtime/World/CScriptDebris.hpp @@ -20,14 +20,14 @@ private: TReservedAverage x2e0_; public: CScriptDebris(TUniqueId, const std::string&, const CEntityInfo&, const zeus::CTransform&, CModelData&&, - const CActorParameters&, ResId, const zeus::CVector3f&, float, const zeus::CVector3f&, + const CActorParameters&, CAssetId, const zeus::CVector3f&, float, const zeus::CVector3f&, const zeus::CColor&, float, float, float, EScaleType, bool, bool, bool); CScriptDebris(TUniqueId, const std::string&, const CEntityInfo&, const zeus::CTransform&, CModelData&&, const CActorParameters&, float, float, float, float, float, float, float, float, float, const zeus::CColor&, const zeus::CColor&, float, const zeus::CVector3f&, const zeus::CVector3f&, - float, float, const zeus::CVector3f&, u32, const zeus::CVector3f&, bool, bool, EOrientationType, u32, - const zeus::CVector3f&, bool, bool, EOrientationType, u32, const zeus::CVector3f&, EOrientationType, + float, float, const zeus::CVector3f&, CAssetId, const zeus::CVector3f&, bool, bool, EOrientationType, CAssetId, + const zeus::CVector3f&, bool, bool, EOrientationType, CAssetId, const zeus::CVector3f&, EOrientationType, bool, bool, bool, bool); void Accept(IVisitor& visitor); diff --git a/Runtime/World/CScriptEffect.cpp b/Runtime/World/CScriptEffect.cpp index 935d2f0ad..71ff45166 100644 --- a/Runtime/World/CScriptEffect.cpp +++ b/Runtime/World/CScriptEffect.cpp @@ -12,7 +12,7 @@ u32 CScriptEffect::g_NumParticlesRendered = 0; CScriptEffect::CScriptEffect(TUniqueId uid, const std::string& name, const CEntityInfo& info, const zeus::CTransform& xf, const zeus::CVector3f& scale, - ResId partId, ResId elscId, bool, bool, bool, bool active, + CAssetId partId, CAssetId elscId, bool, bool, bool, bool active, bool, float, float, float, float, bool, float, float, float, bool, bool, bool, const CLightParameters& lParms, bool) : CActor(uid, active, name, info, xf, CModelData::CModelDataNull(), CMaterialList(), diff --git a/Runtime/World/CScriptEffect.hpp b/Runtime/World/CScriptEffect.hpp index f82bf7df5..38a74efb3 100644 --- a/Runtime/World/CScriptEffect.hpp +++ b/Runtime/World/CScriptEffect.hpp @@ -13,7 +13,7 @@ class CScriptEffect : public CActor public: CScriptEffect(TUniqueId, const std::string& name, const CEntityInfo& info, const zeus::CTransform& xf, const zeus::CVector3f& scale, - ResId partId, ResId elscId, bool, bool, bool, bool active, + CAssetId partId, CAssetId elscId, bool, bool, bool, bool active, bool, float, float, float, float, bool, float, float, float, bool, bool, bool, const CLightParameters& lParms, bool); diff --git a/Runtime/World/CScriptHUDMemo.cpp b/Runtime/World/CScriptHUDMemo.cpp index 80bb36678..87a83dfd8 100644 --- a/Runtime/World/CScriptHUDMemo.cpp +++ b/Runtime/World/CScriptHUDMemo.cpp @@ -5,7 +5,7 @@ namespace urde { CScriptHUDMemo::CScriptHUDMemo(TUniqueId uid, const std::string& name, const CEntityInfo& info, const CHUDMemoParms&, - CScriptHUDMemo::EDisplayType, ResId, bool active) + CScriptHUDMemo::EDisplayType, CAssetId, bool active) : CEntity(uid, info, active, name) { } diff --git a/Runtime/World/CScriptHUDMemo.hpp b/Runtime/World/CScriptHUDMemo.hpp index b01eaf234..09f4235a3 100644 --- a/Runtime/World/CScriptHUDMemo.hpp +++ b/Runtime/World/CScriptHUDMemo.hpp @@ -18,7 +18,7 @@ public: private: public: CScriptHUDMemo(TUniqueId, const std::string&, const CEntityInfo&, const CHUDMemoParms&, - CScriptHUDMemo::EDisplayType, ResId, bool); + CScriptHUDMemo::EDisplayType, CAssetId, bool); void Accept(IVisitor& visitor); }; diff --git a/Runtime/World/CScriptMidi.cpp b/Runtime/World/CScriptMidi.cpp index 099239360..6f364572b 100644 --- a/Runtime/World/CScriptMidi.cpp +++ b/Runtime/World/CScriptMidi.cpp @@ -10,7 +10,7 @@ namespace urde { CScriptMidi::CScriptMidi(TUniqueId id, const CEntityInfo& info, const std::string& name, - bool active, ResId csng, float fadeIn, float fadeOut, s32 volume) + bool active, CAssetId csng, float fadeIn, float fadeOut, s32 volume) : CEntity(id, info, active, name), x40_fadeInTime(fadeIn), x44_fadeOutTime(fadeOut), x48_volume(volume) { diff --git a/Runtime/World/CScriptMidi.hpp b/Runtime/World/CScriptMidi.hpp index 93771f432..fed32e0e0 100644 --- a/Runtime/World/CScriptMidi.hpp +++ b/Runtime/World/CScriptMidi.hpp @@ -20,7 +20,7 @@ class CScriptMidi : public CEntity public: CScriptMidi(TUniqueId id, const CEntityInfo& info, const std::string& name, - bool active, ResId csng, float, float, s32); + bool active, CAssetId csng, float, float, s32); void Stop(CStateManager& mgr, float fadeTime); void Play(CStateManager& mgr, float fadeTime); diff --git a/Runtime/World/CScriptSpecialFunction.cpp b/Runtime/World/CScriptSpecialFunction.cpp index 54cf10a44..786cddc0d 100644 --- a/Runtime/World/CScriptSpecialFunction.cpp +++ b/Runtime/World/CScriptSpecialFunction.cpp @@ -14,7 +14,7 @@ CScriptSpecialFunction::CScriptSpecialFunction(TUniqueId uid, const std::string& const zeus::CTransform& xf, ESpecialFunction func, const std::string& lcName, float radius, float f2, float f3, float f4, const zeus::CVector3f& vec, const zeus::CColor& col, bool active, - const CDamageInfo& dInfo, ResId aId1, ResId aId2, ResId aId3, s16 sId1, + const CDamageInfo& dInfo, CAssetId aId1, CAssetId aId2, CAssetId aId3, s16 sId1, s16 sId2, s16 sId3) : CActor(uid, active, name, info, xf, CModelData::CModelDataNull(), CMaterialList(), CActorParameters::None(), kInvalidUniqueId) diff --git a/Runtime/World/CScriptSpecialFunction.hpp b/Runtime/World/CScriptSpecialFunction.hpp index 914e9ff3b..370662ebe 100644 --- a/Runtime/World/CScriptSpecialFunction.hpp +++ b/Runtime/World/CScriptSpecialFunction.hpp @@ -88,9 +88,9 @@ private: u32 x1a8_ = 2; zeus::CVector3f x1ac_ = zeus::CVector3f::skZero; bool x1b8_ = true; - ResId x1bc_; - ResId x1c0_; - ResId x1c4_; + CAssetId x1bc_; + CAssetId x1c0_; + CAssetId x1c4_; rstl::optional_object x1c8_; union { @@ -111,7 +111,7 @@ private: public: CScriptSpecialFunction(TUniqueId, const std::string&, const CEntityInfo&, const zeus::CTransform&, ESpecialFunction, const std::string&, float, float, float, float, const zeus::CVector3f&, const zeus::CColor&, - bool, const CDamageInfo&, ResId, ResId, ResId, s16, s16, s16); + bool, const CDamageInfo&, CAssetId, CAssetId, CAssetId, s16, s16, s16); void Accept(IVisitor& visitor); void Think(float, CStateManager &); diff --git a/Runtime/World/CScriptSteam.cpp b/Runtime/World/CScriptSteam.cpp index 255fcbe51..ad37cbbad 100644 --- a/Runtime/World/CScriptSteam.cpp +++ b/Runtime/World/CScriptSteam.cpp @@ -5,7 +5,7 @@ namespace urde CScriptSteam::CScriptSteam(TUniqueId uid, const std::string& name, const CEntityInfo& info, const zeus::CVector3f& pos, const zeus::CAABox& aabb, const CDamageInfo& dInfo, const zeus::CVector3f& orientedForce, - ETriggerFlags flags, bool active, ResId, float, float, float, float, bool) + ETriggerFlags flags, bool active, CAssetId, float, float, float, float, bool) : CScriptTrigger(uid, name, info, pos, aabb, dInfo, orientedForce, flags, active, false, false) { diff --git a/Runtime/World/CScriptSteam.hpp b/Runtime/World/CScriptSteam.hpp index 291f6cceb..5461008f3 100644 --- a/Runtime/World/CScriptSteam.hpp +++ b/Runtime/World/CScriptSteam.hpp @@ -11,7 +11,7 @@ class CScriptSteam : public CScriptTrigger public: CScriptSteam(TUniqueId, const std::string& name, const CEntityInfo& info, const zeus::CVector3f& pos, const zeus::CAABox&, const CDamageInfo& dInfo, const zeus::CVector3f& orientedForce, - ETriggerFlags flags, bool active, ResId, float, float, float, float, bool); + ETriggerFlags flags, bool active, CAssetId, float, float, float, float, bool); }; } diff --git a/Runtime/World/CScriptStreamedMusic.cpp b/Runtime/World/CScriptStreamedMusic.cpp index d5ca9eefa..18b945024 100644 --- a/Runtime/World/CScriptStreamedMusic.cpp +++ b/Runtime/World/CScriptStreamedMusic.cpp @@ -35,7 +35,7 @@ void CScriptStreamedMusic::TweakOverride(CStateManager& mgr) const CWorld* wld = mgr.GetWorld(); const CGameArea* area = wld->GetAreaAlways(x4_areaId); std::string twkName = hecl::Format("Area %8.8x MusicObject: %s", - unsigned(area->GetAreaAssetId()), x10_name.c_str()); + u32(area->GetAreaAssetId().Value()), x10_name.c_str()); if (g_TweakManager->HasTweakValue(twkName)) { const CTweakValue::Audio& audio = g_TweakManager->GetTweakValue(twkName)->GetAudio(); diff --git a/Runtime/World/CScriptWater.cpp b/Runtime/World/CScriptWater.cpp index f64acb291..913d3f9fa 100644 --- a/Runtime/World/CScriptWater.cpp +++ b/Runtime/World/CScriptWater.cpp @@ -16,17 +16,17 @@ const float CScriptWater::kSplashScales[6] = CScriptWater::CScriptWater(CStateManager& mgr, TUniqueId uid, const std::string& name, const CEntityInfo& info, const zeus::CVector3f& pos, const zeus::CAABox& box, const urde::CDamageInfo& dInfo, zeus::CVector3f& orientedForce, ETriggerFlags triggerFlags, bool b1, bool b2, - ResId patternMap1, ResId patternMap2, ResId colorMap, ResId bumpMap, ResId envMap, - ResId envBumpMap, ResId unusedMap, const zeus::CVector3f& bumpLightDir, float bumpScale, + CAssetId patternMap1, CAssetId patternMap2, CAssetId colorMap, CAssetId bumpMap, CAssetId envMap, + CAssetId envBumpMap, CAssetId unusedMap, const zeus::CVector3f& bumpLightDir, float bumpScale, float f2, float f3, bool active, CFluidPlane::EFluidType fluidType, bool b4, float alpha, const CFluidUVMotion& uvMot, float turbSpeed, float turbDistance, float turbFreqMax, float turbFreqMin, float turbPhaseMax, float turbPhaseMin, float turbAmplitudeMax, - float turbAmplitudeMin, const zeus::CColor& c1, const zeus::CColor& c2, ResId splashParticle1, - ResId splashParticle2, ResId splashParticle3, ResId particle4, ResId particle5, s32 i1, + float turbAmplitudeMin, const zeus::CColor& c1, const zeus::CColor& c2, CAssetId splashParticle1, + CAssetId splashParticle2, CAssetId splashParticle3, CAssetId particle4, CAssetId particle5, s32 i1, s32 visorRunoffSfx, s32 splashSfx1, s32 splashSfx2, s32 splashSfx3, float tileSize, u32 tileSubdivisions, float specularMin, float specularMax, float reflectionSize, float fluidPlaneF2, float reflectionBlend, float slF6, float slF7, float slF8, - const zeus::CColor& c3, ResId lightmapId, float unitsPerLightmapTexel, float lF2, float lF3, + const zeus::CColor& c3, CAssetId lightmapId, float unitsPerLightmapTexel, float lF2, float lF3, u32, u32, bool, s32, s32, std::unique_ptr&& u32Arr) : CScriptTrigger(uid, name, info, pos, box, dInfo, orientedForce, triggerFlags, active, false, false), x1b8_position(pos), x1c4_extent(box.max - box.min), x1d0_f2(f2), x1d4_position2(pos), x1e0_extent2(box.max - box.min), @@ -53,21 +53,21 @@ CScriptWater::CScriptWater(CStateManager& mgr, TUniqueId uid, const std::string& specularMax, reflectionBlend, reflectionSize, fluidPlaneF2); u32Arr.reset(); x264_splashEffects.resize(3); - if (x22c_splashParticle1Id != kInvalidResId) + if (x22c_splashParticle1Id.IsValid()) x264_splashEffects[0].emplace(g_SimplePool->GetObj({FOURCC('PART'), x22c_splashParticle1Id})); - if (x230_splashParticle2Id != kInvalidResId) + if (x230_splashParticle2Id.IsValid()) x264_splashEffects[1].emplace(g_SimplePool->GetObj({FOURCC('PART'), x230_splashParticle2Id})); - if (x234_splashParticle3Id != kInvalidResId) + if (x234_splashParticle3Id.IsValid()) x264_splashEffects[2].emplace(g_SimplePool->GetObj({FOURCC('PART'), x234_splashParticle3Id})); - if (x238_particle4Id != kInvalidResId) + if (x238_particle4Id.IsValid()) x23c_.emplace(g_SimplePool->GetObj({FOURCC('PART'), x238_particle4Id})); - if (x24c_particle5Id != kInvalidResId) + if (x24c_particle5Id.IsValid()) x250_visorRunoffEffect.emplace(g_SimplePool->GetObj({FOURCC('PART'), x24c_particle5Id})); x298_splashSounds.push_back(CSfxManager::TranslateSFXID(splashSfx1)); x298_splashSounds.push_back(CSfxManager::TranslateSFXID(splashSfx2)); x298_splashSounds.push_back(CSfxManager::TranslateSFXID(splashSfx3)); SetCalculateLighting(true); - if (lightmapId != kInvalidResId) + if (lightmapId.IsValid()) x90_actorLights->DisableAreaLights(); x90_actorLights->SetMaxDynamicLights(4); x90_actorLights->SetCastShadows(false); @@ -148,7 +148,8 @@ zeus::CAABox CScriptWater::GetSortingBounds(const CStateManager&) const return {}; } -EWeaponCollisionResponseTypes CScriptWater::GetCollisionResponseType(const zeus::CVector3f&, const zeus::CVector3f&, CWeaponMode&, int) +EWeaponCollisionResponseTypes CScriptWater::GetCollisionResponseType(const zeus::CVector3f&, const zeus::CVector3f&, + const CWeaponMode&, int) const { return EWeaponCollisionResponseTypes::Water; } diff --git a/Runtime/World/CScriptWater.hpp b/Runtime/World/CScriptWater.hpp index 6e2403b99..a1f39c2db 100644 --- a/Runtime/World/CScriptWater.hpp +++ b/Runtime/World/CScriptWater.hpp @@ -32,12 +32,12 @@ private: float x220_; float x224_; zeus::CColor x228_; - ResId x22c_splashParticle1Id; - ResId x230_splashParticle2Id; - ResId x234_splashParticle3Id; - ResId x238_particle4Id; + CAssetId x22c_splashParticle1Id; + CAssetId x230_splashParticle2Id; + CAssetId x234_splashParticle3Id; + CAssetId x238_particle4Id; std::experimental::optional> x23c_; - ResId x24c_particle5Id; + CAssetId x24c_particle5Id; std::experimental::optional> x250_visorRunoffEffect; u16 x260_; u16 x262_visorRunoffSfx; @@ -79,17 +79,17 @@ public: CScriptWater(CStateManager& mgr, TUniqueId uid, const std::string& name, const CEntityInfo& info, const zeus::CVector3f& pos, const zeus::CAABox& box, const urde::CDamageInfo& dInfo, zeus::CVector3f& orientedForce, ETriggerFlags triggerFlags, bool b1, bool b2, - ResId patternMap1, ResId patternMap2, ResId colorMap, ResId bumpMap, ResId envMap, - ResId envBumpMap, ResId unusedMap, const zeus::CVector3f& bumpLightDir, float bumpScale, + CAssetId patternMap1, CAssetId patternMap2, CAssetId colorMap, CAssetId bumpMap, CAssetId envMap, + CAssetId envBumpMap, CAssetId unusedMap, const zeus::CVector3f& bumpLightDir, float bumpScale, float f2, float f3, bool active, CFluidPlane::EFluidType fluidType, bool b4, float alpha, const CFluidUVMotion& uvMot, float turbSpeed, float turbDistance, float turbFreqMax, float turbFreqMin, float turbPhaseMax, float turbPhaseMin, float turbAmplitudeMax, - float turbAmplitudeMin, const zeus::CColor& c1, const zeus::CColor& c2, ResId splashParticle1, - ResId splashParticle2, ResId splashParticle3, ResId particle4, ResId particle5, s32 i1, + float turbAmplitudeMin, const zeus::CColor& c1, const zeus::CColor& c2, CAssetId splashParticle1, + CAssetId splashParticle2, CAssetId splashParticle3, CAssetId particle4, CAssetId particle5, s32 i1, s32 visorRunoffSfx, s32 splashSfx1, s32 splashSfx2, s32 splashSfx3, float tileSize, u32 tileSubdivisions, float specularMin, float specularMax, float reflectionSize, float fluidPlaneF2, float reflectionBlend, float slF6, float slF7, float slF8, - const zeus::CColor& c3, ResId lightmapId, float unitsPerLightmapTexel, float lF2, float lF3, + const zeus::CColor& c3, CAssetId lightmapId, float unitsPerLightmapTexel, float lF2, float lF3, u32, u32, bool, s32, s32, std::unique_ptr&& u32Arr); void Think(float, CStateManager&); @@ -101,8 +101,8 @@ public: void CalculateRenderBounds(); zeus::CAABox GetSortingBounds(const CStateManager&) const; void RenderSurface(); - EWeaponCollisionResponseTypes GetCollisionResponseType(const zeus::CVector3f&, const zeus::CVector3f&, CWeaponMode&, - int); + EWeaponCollisionResponseTypes GetCollisionResponseType(const zeus::CVector3f&, const zeus::CVector3f&, const CWeaponMode&, + int) const; void UpdateSplashInhabitants(CStateManager&); s16 GetSplashSound(float) const; diff --git a/Runtime/World/CScriptWorldTeleporter.cpp b/Runtime/World/CScriptWorldTeleporter.cpp index d5a505862..d01848b75 100644 --- a/Runtime/World/CScriptWorldTeleporter.cpp +++ b/Runtime/World/CScriptWorldTeleporter.cpp @@ -9,7 +9,7 @@ namespace urde { CScriptWorldTeleporter::CScriptWorldTeleporter(TUniqueId uid, const std::string& name, const CEntityInfo& info, - bool active, ResId worldId, ResId areaId) + bool active, CAssetId worldId, CAssetId areaId) : CEntity(uid, info, active, name) , x34_worldId(worldId) , x38_areaId(areaId) @@ -21,10 +21,10 @@ CScriptWorldTeleporter::CScriptWorldTeleporter(TUniqueId uid, const std::string& } CScriptWorldTeleporter::CScriptWorldTeleporter(TUniqueId uid, const std::string& name, const CEntityInfo& info, - bool active, ResId worldId, ResId areaId, - ResId playerAncs, u32 charIdx, u32 defaultAnim, - const zeus::CVector3f& playerScale, ResId platformModel, - const zeus::CVector3f& platformScale, ResId backgroundModel, + bool active, CAssetId worldId, CAssetId areaId, + CAssetId playerAncs, u32 charIdx, u32 defaultAnim, + const zeus::CVector3f& playerScale, CAssetId platformModel, + const zeus::CVector3f& platformScale, CAssetId backgroundModel, const zeus::CVector3f& backgroundScale, bool upElevator, u16 soundId, u8 volume, u8 panning) : CEntity(uid, info, active, name) @@ -47,8 +47,8 @@ CScriptWorldTeleporter::CScriptWorldTeleporter(TUniqueId uid, const std::string& } CScriptWorldTeleporter::CScriptWorldTeleporter(TUniqueId uid, const std::string& name, const CEntityInfo& info, - bool active, ResId worldId, ResId areaId, u16 soundId, u8 volume, - u8 panning, ResId fontId, ResId stringId, bool fadeWhite, + bool active, CAssetId worldId, CAssetId areaId, u16 soundId, u8 volume, + u8 panning, CAssetId fontId, CAssetId stringId, bool fadeWhite, float charFadeIn, float charsPerSecond, float showDelay) : CEntity(uid, info, active, name) , x34_worldId(worldId) @@ -94,7 +94,7 @@ void CScriptWorldTeleporter::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId { const auto& world = mgr.WorldNC(); world->SetPauseState(true); - ResId currentWorld = g_GameState->CurrentWorldAssetId(); + CAssetId currentWorld = g_GameState->CurrentWorldAssetId(); if (g_ResFactory->GetResourceTypeById(currentWorld) == SBIG('MLVL')) { @@ -130,7 +130,7 @@ void CScriptWorldTeleporter::StartTransition(CStateManager& mgr) transMgr->DisableTransition(); break; case ETeleporterType::Elevator: - if (x50_playerAnim.GetACSFile() != kInvalidResId && x50_playerAnim.GetCharacter() != -1) + if (x50_playerAnim.GetACSFile().IsValid() && x50_playerAnim.GetCharacter() != -1) { transMgr->EnableTransition(CAnimRes(x50_playerAnim.GetACSFile(), x50_playerAnim.GetCharacter(), x5c_playerScale, x50_playerAnim.GetInitialAnimation(),true), diff --git a/Runtime/World/CScriptWorldTeleporter.hpp b/Runtime/World/CScriptWorldTeleporter.hpp index d275fc61b..b40c3ddcf 100644 --- a/Runtime/World/CScriptWorldTeleporter.hpp +++ b/Runtime/World/CScriptWorldTeleporter.hpp @@ -17,8 +17,8 @@ class CScriptWorldTeleporter : public CEntity Text }; - ResId x34_worldId; - ResId x38_areaId; + CAssetId x34_worldId; + CAssetId x38_areaId; ETeleporterType x3c_type = ETeleporterType::NoTransition; union { @@ -36,21 +36,21 @@ class CScriptWorldTeleporter : public CEntity float x4c_showDelay = 0.0f; CAnimationParameters x50_playerAnim; zeus::CVector3f x5c_playerScale; - ResId x68_platformModel = kInvalidResId; + CAssetId x68_platformModel; zeus::CVector3f x6c_platformScale; - ResId x78_backgroundModel = kInvalidResId; + CAssetId x78_backgroundModel; zeus::CVector3f x7c_backgroundScale; u16 x88_soundId = -1; u8 x8a_volume = 0; u8 x8b_panning = 0; - ResId x8c_fontId; - ResId x90_stringId; + CAssetId x8c_fontId; + CAssetId x90_stringId; public: - CScriptWorldTeleporter(TUniqueId, const std::string&, const CEntityInfo&, bool, ResId, ResId); - CScriptWorldTeleporter(TUniqueId, const std::string&, const CEntityInfo&, bool, ResId, ResId, u16, u8, u8, ResId, - ResId, bool, float, float, float); - CScriptWorldTeleporter(TUniqueId, const std::string&, const CEntityInfo&, bool, ResId, ResId, ResId, u32, u32, - const zeus::CVector3f&, ResId, const zeus::CVector3f&, ResId, const zeus::CVector3f&, bool, + CScriptWorldTeleporter(TUniqueId, const std::string&, const CEntityInfo&, bool, CAssetId, CAssetId); + CScriptWorldTeleporter(TUniqueId, const std::string&, const CEntityInfo&, bool, CAssetId, CAssetId, u16, u8, u8, CAssetId, + CAssetId, bool, float, float, float); + CScriptWorldTeleporter(TUniqueId, const std::string&, const CEntityInfo&, bool, CAssetId, CAssetId, CAssetId, u32, u32, + const zeus::CVector3f&, CAssetId, const zeus::CVector3f&, CAssetId, const zeus::CVector3f&, bool, u16, u8, u8); void Accept(IVisitor&); diff --git a/Runtime/World/CWorld.cpp b/Runtime/World/CWorld.cpp index bcf12658e..2a6a8eebf 100644 --- a/Runtime/World/CWorld.cpp +++ b/Runtime/World/CWorld.cpp @@ -9,22 +9,22 @@ namespace urde { -CWorld::CSoundGroupData::CSoundGroupData(int grpId, ResId agsc) : x0_groupId(grpId), x4_agscId(agsc) +CWorld::CSoundGroupData::CSoundGroupData(int grpId, CAssetId agsc) : x0_groupId(grpId), x4_agscId(agsc) { x1c_groupData = g_SimplePool->GetObj(SObjectTag{FOURCC('AGSC'), agsc}); } -CDummyWorld::CDummyWorld(ResId mlvlId, bool loadMap) : x4_loadMap(loadMap), xc_mlvlId(mlvlId) +CDummyWorld::CDummyWorld(CAssetId mlvlId, bool loadMap) : x4_loadMap(loadMap), xc_mlvlId(mlvlId) { SObjectTag tag{FOURCC('MLVL'), mlvlId}; static_cast(g_ResFactory)->LoadResourceAsync(tag, x34_loadBuf); } -ResId CDummyWorld::IGetWorldAssetId() const { return xc_mlvlId; } +CAssetId CDummyWorld::IGetWorldAssetId() const { return xc_mlvlId; } -ResId CDummyWorld::IGetStringTableAssetId() const { return x10_strgId; } +CAssetId CDummyWorld::IGetStringTableAssetId() const { return x10_strgId; } -ResId CDummyWorld::IGetSaveWorldAssetId() const { return x14_savwId; } +CAssetId CDummyWorld::IGetSaveWorldAssetId() const { return x14_savwId; } const CMapWorld* CDummyWorld::IGetMapWorld() const { return x2c_mapWorld.GetObj(); } @@ -34,7 +34,7 @@ const IGameArea* CDummyWorld::IGetAreaAlways(TAreaId id) const { return &x18_are TAreaId CDummyWorld::IGetCurrentAreaId() const { return x3c_curAreaId; } -TAreaId CDummyWorld::IGetAreaId(ResId id) const +TAreaId CDummyWorld::IGetAreaId(CAssetId id) const { int ret = 0; if (id == -1) @@ -66,7 +66,7 @@ std::vector CWorld::CRelay::ReadMemoryRelays(athena::io::MemoryR return ret; } -void CWorldLayers::ReadWorldLayers(athena::io::MemoryReader& r, int version, ResId mlvlId) +void CWorldLayers::ReadWorldLayers(athena::io::MemoryReader& r, int version, CAssetId mlvlId) { if (version <= 14) return; @@ -180,7 +180,7 @@ std::string CDummyWorld::IGetDefaultAudioTrack() const { return {}; } int CDummyWorld::IGetAreaCount() const { return x18_areas.size(); } -CWorld::CWorld(IObjectStore& objStore, IFactory& resFactory, ResId mlvlId) +CWorld::CWorld(IObjectStore& objStore, IFactory& resFactory, CAssetId mlvlId) : x8_mlvlId(mlvlId), x60_objectStore(objStore), x64_resFactory(resFactory) { x70_24_currentAreaNeedsAllocation = true; @@ -188,11 +188,11 @@ CWorld::CWorld(IObjectStore& objStore, IFactory& resFactory, ResId mlvlId) static_cast(resFactory).LoadResourceAsync(tag, x40_loadBuf); } -ResId CWorld::IGetWorldAssetId() const { return x8_mlvlId; } +CAssetId CWorld::IGetWorldAssetId() const { return x8_mlvlId; } -ResId CWorld::IGetStringTableAssetId() const { return xc_strgId; } +CAssetId CWorld::IGetStringTableAssetId() const { return xc_strgId; } -ResId CWorld::IGetSaveWorldAssetId() const { return x10_savwId; } +CAssetId CWorld::IGetSaveWorldAssetId() const { return x10_savwId; } const CMapWorld* CWorld::IGetMapWorld() const { return const_cast(this)->GetMapWorld(); } @@ -206,7 +206,7 @@ const IGameArea* CWorld::IGetAreaAlways(TAreaId id) const { return GetAreaAlways TAreaId CWorld::IGetCurrentAreaId() const { return x68_curAreaId; } -TAreaId CWorld::IGetAreaId(ResId id) const +TAreaId CWorld::IGetAreaId(CAssetId id) const { int ret = 0; if (id == -1) @@ -238,11 +238,11 @@ void CWorld::MoveAreaToChain3(TAreaId aid) MoveToChain(x18_areas[aid].get(), EChain::Alive); } -void CWorld::LoadSoundGroup(int groupId, ResId agscId, CSoundGroupData& data) {} +void CWorld::LoadSoundGroup(int groupId, CAssetId agscId, CSoundGroupData& data) {} void CWorld::LoadSoundGroups() {} -bool CWorld::CheckWorldComplete(CStateManager* mgr, TAreaId id, ResId mreaId) +bool CWorld::CheckWorldComplete(CStateManager* mgr, TAreaId id, CAssetId mreaId) { if (mreaId != -1) { @@ -276,7 +276,7 @@ bool CWorld::CheckWorldComplete(CStateManager* mgr, TAreaId id, ResId mreaId) x10_savwId = r.readUint32Big(); if (version >= 12) { - ResId skyboxId = r.readUint32Big(); + CAssetId skyboxId = r.readUint32Big(); if (skyboxId != -1 && mgr) x94_skybox = g_SimplePool->GetObj(SObjectTag{FOURCC('CMDL'), skyboxId}); } @@ -317,7 +317,7 @@ bool CWorld::CheckWorldComplete(CStateManager* mgr, TAreaId id, ResId mreaId) for (u32 i = 0; i < audioGroupCount; ++i) { int grpId = r.readUint32Big(); - ResId agscId = r.readUint32Big(); + CAssetId agscId = r.readUint32Big(); x74_soundGroupData.emplace_back(grpId, agscId); } } @@ -325,7 +325,7 @@ bool CWorld::CheckWorldComplete(CStateManager* mgr, TAreaId id, ResId mreaId) if (version > 12) { x84_defAudioTrack = r.readString(); - std::string trackKey = hecl::Format("WorldDefault: %8.8x", u32(x8_mlvlId)); + std::string trackKey = hecl::Format("WorldDefault: %8.8x", u32(x8_mlvlId.Value())); if (g_TweakManager->HasTweakValue(trackKey)) x84_defAudioTrack = g_TweakManager->GetTweakValue(trackKey)->GetAudio().GetFileName(); } diff --git a/Runtime/World/CWorld.hpp b/Runtime/World/CWorld.hpp index c8cfe4239..c47567aa0 100644 --- a/Runtime/World/CWorld.hpp +++ b/Runtime/World/CWorld.hpp @@ -21,14 +21,14 @@ class IWorld { public: virtual ~IWorld() = default; - virtual ResId IGetWorldAssetId() const=0; - virtual ResId IGetStringTableAssetId() const=0; - virtual ResId IGetSaveWorldAssetId() const=0; + virtual CAssetId IGetWorldAssetId() const=0; + virtual CAssetId IGetStringTableAssetId() const=0; + virtual CAssetId IGetSaveWorldAssetId() const=0; virtual const CMapWorld* IGetMapWorld() const=0; virtual CMapWorld* IMapWorld()=0; virtual const IGameArea* IGetAreaAlways(TAreaId id) const=0; virtual TAreaId IGetCurrentAreaId() const=0; - virtual TAreaId IGetAreaId(ResId id) const=0; + virtual TAreaId IGetAreaId(CAssetId id) const=0; virtual bool ICheckWorldComplete()=0; virtual std::string IGetDefaultAudioTrack() const=0; virtual int IGetAreaCount() const=0; @@ -44,26 +44,26 @@ class CDummyWorld : public IWorld LoadingMapAreas, Done, } x8_phase = Phase::Loading; - ResId xc_mlvlId; - ResId x10_strgId; - ResId x14_savwId = -1; + CAssetId xc_mlvlId; + CAssetId x10_strgId; + CAssetId x14_savwId = -1; std::vector x18_areas; - ResId x28_mapWorldId = -1; + CAssetId x28_mapWorldId = -1; TLockedToken x2c_mapWorld; //AsyncTask x30_loadToken; std::unique_ptr x34_loadBuf; //u32 x38_bufSz; TAreaId x3c_curAreaId = kInvalidAreaId; public: - CDummyWorld(ResId mlvlId, bool loadMap); - ResId IGetWorldAssetId() const; - ResId IGetStringTableAssetId() const; - ResId IGetSaveWorldAssetId() const; + CDummyWorld(CAssetId mlvlId, bool loadMap); + CAssetId IGetWorldAssetId() const; + CAssetId IGetStringTableAssetId() const; + CAssetId IGetSaveWorldAssetId() const; const CMapWorld* IGetMapWorld() const; CMapWorld* IMapWorld(); const IGameArea* IGetAreaAlways(TAreaId id) const; TAreaId IGetCurrentAreaId() const; - TAreaId IGetAreaId(ResId id) const; + TAreaId IGetAreaId(CAssetId id) const; bool ICheckWorldComplete(); std::string IGetDefaultAudioTrack() const; int IGetAreaCount() const; @@ -94,11 +94,11 @@ public: struct CSoundGroupData { int x0_groupId; - ResId x4_agscId; + CAssetId x4_agscId; std::string xc_name; TCachedToken x1c_groupData; public: - CSoundGroupData(int grpId, ResId agsc); + CSoundGroupData(int grpId, CAssetId agsc); }; private: @@ -113,11 +113,11 @@ private: LoadingSoundGroups, Done, } x4_phase = Phase::Loading; - ResId x8_mlvlId = -1; - ResId xc_strgId = -1; - ResId x10_savwId = -1; + CAssetId x8_mlvlId = -1; + CAssetId xc_strgId = -1; + CAssetId x10_savwId = -1; std::vector> x18_areas; - ResId x24_mapwId = -1; + CAssetId x24_mapwId = -1; TLockedToken x28_mapWorld; std::vector x2c_relays; //AsyncTask x3c_loadToken; @@ -149,14 +149,14 @@ private: TLockedToken xb4_skyboxC; std::vector xc4_sfxHandles; - void LoadSoundGroup(int groupId, ResId agscId, CSoundGroupData& data); + void LoadSoundGroup(int groupId, CAssetId agscId, CSoundGroupData& data); void LoadSoundGroups(); public: void MoveToChain(CGameArea* area, EChain chain); void MoveAreaToChain3(TAreaId aid); - bool CheckWorldComplete(CStateManager* mgr, TAreaId id, ResId mreaId); + bool CheckWorldComplete(CStateManager* mgr, TAreaId id, CAssetId mreaId); CGameArea::CChainIterator GetChainHead(EChain chain) { return {x4c_chainHeads[int(chain)]}; } CGameArea::CConstChainIterator GetChainHead(EChain chain) const { return {x4c_chainHeads[int(chain)]}; } CGameArea::CChainIterator begin() { return GetChainHead(EChain::Alive); } @@ -167,7 +167,7 @@ public: void TravelToArea(TAreaId aid, CStateManager& mgr, bool); void SetPauseState(bool paused); - CWorld(IObjectStore& objStore, IFactory& resFactory, ResId mlvlId); + CWorld(IObjectStore& objStore, IFactory& resFactory, CAssetId mlvlId); bool DoesAreaExist(TAreaId area) const; const std::vector>& GetGameAreas() const { return x18_areas; } @@ -175,9 +175,9 @@ public: u32 GetRelayCount() const { return x2c_relays.size(); } CRelay GetRelay(u32 idx) const { return x2c_relays[idx]; } - ResId IGetWorldAssetId() const; - ResId IGetStringTableAssetId() const; - ResId IGetSaveWorldAssetId() const; + CAssetId IGetWorldAssetId() const; + CAssetId IGetStringTableAssetId() const; + CAssetId IGetSaveWorldAssetId() const; const CMapWorld* IGetMapWorld() const; CMapWorld* IMapWorld(); const CGameArea* GetAreaAlways(TAreaId) const; @@ -186,7 +186,7 @@ public: const IGameArea* IGetAreaAlways(TAreaId id) const; TAreaId IGetCurrentAreaId() const; TAreaId GetCurrentAreaId() const { return x68_curAreaId; } - TAreaId IGetAreaId(ResId id) const; + TAreaId IGetAreaId(CAssetId id) const; bool ICheckWorldComplete(); std::string IGetDefaultAudioTrack() const; int IGetAreaCount() const; @@ -212,7 +212,7 @@ struct CWorldLayers }; std::vector m_areas; std::vector m_names; - static void ReadWorldLayers(athena::io::MemoryReader& r, int version, ResId mlvlId); + static void ReadWorldLayers(athena::io::MemoryReader& r, int version, CAssetId mlvlId); }; } diff --git a/Runtime/World/CWorldTransManager.cpp b/Runtime/World/CWorldTransManager.cpp index eafb98213..7e0e2fc5e 100644 --- a/Runtime/World/CWorldTransManager.cpp +++ b/Runtime/World/CWorldTransManager.cpp @@ -383,8 +383,8 @@ void CWorldTransManager::TouchModels() } void CWorldTransManager::EnableTransition(const CAnimRes& samusRes, - ResId platRes, const zeus::CVector3f& platScale, - ResId bgRes, const zeus::CVector3f& bgScale, bool goingUp) + CAssetId platRes, const zeus::CVector3f& platScale, + CAssetId bgRes, const zeus::CVector3f& bgScale, bool goingUp) { x44_25_stopSoon = false; x44_26_goingUp = goingUp; @@ -394,7 +394,7 @@ void CWorldTransManager::EnableTransition(const CAnimRes& samusRes, x8_textData.reset(); x20_random.SetSeed(99); - ResId beamModelId = g_tweakPlayerRes->GetBeamCineModel( + CAssetId beamModelId = g_tweakPlayerRes->GetBeamCineModel( DataSpec::ITweakPlayerRes::EBeamId(g_GameState->GetPlayerState()->GetCurrentBeam())); x4_modelData->x14c_beamModel = g_SimplePool->GetObj(SObjectTag{FOURCC('CMDL'), beamModelId}); @@ -428,7 +428,7 @@ void CWorldTransManager::EnableTransition(const CAnimRes& samusRes, TouchModels(); } -void CWorldTransManager::EnableTransition(ResId fontId, ResId stringId, u32 strIdx, bool fadeWhite, +void CWorldTransManager::EnableTransition(CAssetId fontId, CAssetId stringId, u32 strIdx, bool fadeWhite, float chFadeTime, float chFadeRate, float textStartTime) { x40_strIdx = strIdx; diff --git a/Runtime/World/CWorldTransManager.hpp b/Runtime/World/CWorldTransManager.hpp index daa3b4655..3999ae94d 100644 --- a/Runtime/World/CWorldTransManager.hpp +++ b/Runtime/World/CWorldTransManager.hpp @@ -108,9 +108,9 @@ public: void Draw(); void EnableTransition(const CAnimRes& samusRes, - ResId platRes, const zeus::CVector3f& platScale, - ResId bgRes, const zeus::CVector3f& bgScale, bool goingUp); - void EnableTransition(ResId fontId, ResId stringId, u32 strIdx, bool fadeWhite, + CAssetId platRes, const zeus::CVector3f& platScale, + CAssetId bgRes, const zeus::CVector3f& bgScale, bool goingUp); + void EnableTransition(CAssetId fontId, CAssetId stringId, u32 strIdx, bool fadeWhite, float chFadeTime, float chFadeRate, float textStartTime); void StartTransition(); diff --git a/Runtime/World/IGameArea.hpp b/Runtime/World/IGameArea.hpp index 02194bfa1..952bd818f 100644 --- a/Runtime/World/IGameArea.hpp +++ b/Runtime/World/IGameArea.hpp @@ -44,11 +44,11 @@ public: virtual bool IGetScriptingMemoryAlways() const=0; virtual TAreaId IGetAreaId() const=0; - virtual ResId IGetAreaAssetId() const=0; + virtual CAssetId IGetAreaAssetId() const=0; virtual bool IIsActive() const=0; virtual TAreaId IGetAttachedAreaId(int) const=0; virtual u32 IGetNumAttachedAreas() const=0; - virtual ResId IGetStringTableAssetId() const=0; + virtual CAssetId IGetStringTableAssetId() const=0; virtual const zeus::CTransform& IGetTM() const=0; }; diff --git a/Runtime/World/ScriptLoader.cpp b/Runtime/World/ScriptLoader.cpp index 5b6828dc5..444b49b4d 100644 --- a/Runtime/World/ScriptLoader.cpp +++ b/Runtime/World/ScriptLoader.cpp @@ -198,10 +198,10 @@ CActorParameters ScriptLoader::LoadActorParameters(CInputStream& in) if (propCount > 5) sParams = LoadScannableParameters(in); - ResId xrayModel = in.readUint32Big(); - ResId xraySkin = in.readUint32Big(); - ResId infraModel = in.readUint32Big(); - ResId infraSkin = in.readUint32Big(); + CAssetId xrayModel = in.readUint32Big(); + CAssetId xraySkin = in.readUint32Big(); + CAssetId infraModel = in.readUint32Big(); + CAssetId infraSkin = in.readUint32Big(); bool b1 = true; if (propCount > 7) @@ -235,11 +235,11 @@ CActorParameters ScriptLoader::LoadActorParameters(CInputStream& in) if (propCount > 13) f3 = in.readFloatBig(); - std::pair xray = {}; + std::pair xray = {}; if (g_ResFactory->GetResourceTypeById(xrayModel)) xray = {xrayModel, xraySkin}; - std::pair infra = {}; + std::pair infra = {}; if (g_ResFactory->GetResourceTypeById(infraModel)) infra = {infraModel, infraSkin}; @@ -319,7 +319,7 @@ CLightParameters ScriptLoader::LoadLightParameters(CInputStream& in) CAnimationParameters ScriptLoader::LoadAnimationParameters(CInputStream& in) { - ResId ancs = in.readUint32Big(); + CAssetId ancs = in.readUint32Big(); s32 charIdx = in.readUint32Big(); u32 defaultAnim = in.readUint32Big(); return CAnimationParameters(ancs, charIdx, defaultAnim); @@ -395,7 +395,7 @@ CEntity* ScriptLoader::LoadActor(CStateManager& mgr, CInputStream& in, int propC CDamageVulnerability dVuln(in); - ResId staticId = in.readUint32Big(); + CAssetId staticId = in.readUint32Big(); CAnimationParameters aParms = LoadAnimationParameters(in); CActorParameters actParms = LoadActorParameters(in); @@ -574,8 +574,8 @@ CEntity* ScriptLoader::LoadEffect(CStateManager& mgr, CInputStream& in, int prop SScaledActorHead head = LoadScaledActorHead(in, mgr); - ResId partId = in.readUint32Big(); - ResId elscId = in.readUint32Big(); + CAssetId partId = in.readUint32Big(); + CAssetId elscId = in.readUint32Big(); bool b1 = in.readBool(); bool b2 = in.readBool(); bool b3 = in.readBool(); @@ -620,14 +620,14 @@ CEntity* ScriptLoader::LoadPlatform(CStateManager& mgr, CInputStream& in, int pr zeus::CVector3f centroid; centroid.readBig(in); - ResId staticId = in.readUint32Big(); + CAssetId staticId = in.readUint32Big(); CAnimationParameters aParms = LoadAnimationParameters(in); CActorParameters actParms = LoadActorParameters(in); float f1 = in.readFloatBig(); bool b1 = in.readBool(); - ResId dclnId = in.readUint32Big(); + CAssetId dclnId = in.readUint32Big(); CHealthInfo hInfo(in); @@ -904,7 +904,7 @@ CEntity* ScriptLoader::LoadPickup(CStateManager& mgr, CInputStream& in, int prop float f1 = in.readFloatBig(); float f2 = in.readFloatBig(); float f3 = in.readFloatBig(); - ResId staticModel = in.readUint32Big(); + CAssetId staticModel = in.readUint32Big(); CAnimationParameters animParms = LoadAnimationParameters(in); CActorParameters actorParms = LoadActorParameters(in); bool active = in.readBool(); @@ -992,7 +992,7 @@ CEntity* ScriptLoader::LoadBeetle(CStateManager& mgr, CInputStream& in, int prop float f1 = in.readFloatBig(); CDamageVulnerability dVuln1(in); CDamageVulnerability dVuln2(in); - ResId abdomen = in.readUint32Big(); + CAssetId abdomen = in.readUint32Big(); MP1::CBeetle::EEntranceType entrance = MP1::CBeetle::EEntranceType(in.readUint32Big()); float f2 = in.readFloatBig(); float f3 = in.readFloatBig(); @@ -1021,7 +1021,7 @@ CEntity* ScriptLoader::LoadHUDMemo(CStateManager& mgr, CInputStream& in, int pro CScriptHUDMemo::EDisplayType displayType = CScriptHUDMemo::EDisplayType::MessageBox; if (propCount == 6) displayType = CScriptHUDMemo::EDisplayType(in.readUint32Big()); - ResId message = in.readUint32Big(); + CAssetId message = in.readUint32Big(); bool active = in.readBool(); return new CScriptHUDMemo(mgr.AllocateUniqueId(), name, info, hParms, displayType, message, active); @@ -1042,7 +1042,7 @@ CEntity* ScriptLoader::LoadCameraFilterKeyframe(CStateManager& mgr, CInputStream color.readRGBABig(in); float timeIn = in.readFloatBig(); float timeOut = in.readFloatBig(); - ResId txtr = in.readUint32Big(); + CAssetId txtr = in.readUint32Big(); return new CScriptCameraFilterKeyframe(mgr.AllocateUniqueId(), name, info, type, shape, filterIdx, unk, color, timeIn, timeOut, txtr, active); @@ -1118,9 +1118,9 @@ CEntity* ScriptLoader::LoadDamageableTrigger(CStateManager& mgr, CInputStream& i CDamageVulnerability dVuln(in); u32 triggerFlags = in.readUint32Big(); triggerFlags = TransformDamagableTriggerFlags(mgr, info.GetAreaId(), triggerFlags); - ResId w1 = in.readUint32Big(); - ResId w2 = in.readUint32Big(); - ResId w3 = in.readUint32Big(); + CAssetId w1 = in.readUint32Big(); + CAssetId w2 = in.readUint32Big(); + CAssetId w3 = in.readUint32Big(); CScriptDamageableTrigger::ECanOrbit canOrbit = CScriptDamageableTrigger::ECanOrbit(in.readBool()); bool active = in.readBool(); CVisorParameters vParms = LoadVisorParameters(in); @@ -1143,9 +1143,9 @@ CEntity* ScriptLoader::LoadDebris(CStateManager& mgr, CInputStream& in, int prop float f4 = in.readFloatBig(); CScriptDebris::EScaleType scaleType = CScriptDebris::EScaleType(in.readUint32Big()); bool b1 = in.readBool(); - ResId model = in.readUint32Big(); + CAssetId model = in.readUint32Big(); CActorParameters aParams = LoadActorParameters(in); - ResId w3 = in.readUint32Big(); + CAssetId w3 = in.readUint32Big(); zeus::CVector3f v2 = zeus::CVector3f::ReadBig(in); bool b2 = in.readBool(); bool b3 = in.readBool(); @@ -1208,12 +1208,12 @@ CEntity* ScriptLoader::LoadWater(CStateManager& mgr, CInputStream& in, int propC ETriggerFlags::DetectProjectiles6 | ETriggerFlags::DetectProjectiles7; bool b1 = in.readBool(); bool displaySurface = in.readBool(); - ResId textureId1 = in.readUint32Big(); - ResId textureId2 = in.readUint32Big(); - ResId textureId3 = in.readUint32Big(); - ResId textureId4 = in.readUint32Big(); - ResId textureId5 = in.readUint32Big(); - ResId textureId6 = in.readUint32Big(); + CAssetId textureId1 = in.readUint32Big(); + CAssetId textureId2 = in.readUint32Big(); + CAssetId textureId3 = in.readUint32Big(); + CAssetId textureId4 = in.readUint32Big(); + CAssetId textureId5 = in.readUint32Big(); + CAssetId textureId6 = in.readUint32Big(); zeus::CVector3f v2; v2.readBig(in); @@ -1242,11 +1242,11 @@ CEntity* ScriptLoader::LoadWater(CStateManager& mgr, CInputStream& in, int propC c1.readRGBABig(in); zeus::CColor c2; c2.readRGBABig(in); - ResId enterParticle = in.readUint32Big(); - ResId partId2 = in.readUint32Big(); - ResId partId3 = in.readUint32Big(); - ResId partId4 = in.readUint32Big(); - ResId partId5 = in.readUint32Big(); + CAssetId enterParticle = in.readUint32Big(); + CAssetId partId2 = in.readUint32Big(); + CAssetId partId3 = in.readUint32Big(); + CAssetId partId4 = in.readUint32Big(); + CAssetId partId5 = in.readUint32Big(); u32 soundId1 = in.readUint32Big(); u32 soundId2 = in.readUint32Big(); u32 soundId3 = in.readUint32Big(); @@ -1264,7 +1264,7 @@ CEntity* ScriptLoader::LoadWater(CStateManager& mgr, CInputStream& in, int propC float heatWaveSpeed = in.readFloatBig(); zeus::CColor heatWaveColor; heatWaveColor.readRGBABig(in); - ResId lightmap = in.readUint32Big(); + CAssetId lightmap = in.readUint32Big(); float f22 = in.readFloatBig(); float f23 = in.readFloatBig(); float f24 = in.readFloatBig(); @@ -1287,11 +1287,11 @@ CEntity* ScriptLoader::LoadWater(CStateManager& mgr, CInputStream& in, int propC zeus::CAABox box(-extent * 0.5f, extent * 0.5f); - ResId realTextureId6 = -1; + CAssetId realTextureId6 = -1; if (textureId4 == -1) realTextureId6 = textureId6; - ResId realTextureId5 = -1; + CAssetId realTextureId5 = -1; if (textureId4 == -1) realTextureId5 = textureId5; @@ -1323,9 +1323,9 @@ CEntity* ScriptLoader::LoadWarWasp(CStateManager& mgr, CInputStream& in, int pro CActorParameters actorParms = LoadActorParameters(in); CPatterned::EColliderType collider = CPatterned::EColliderType(in.readBool()); CDamageInfo damageInfo1(in); - ResId weaponDesc = in.readUint32Big(); + CAssetId weaponDesc = in.readUint32Big(); CDamageInfo damageInfo2(in); - ResId particle = in.readUint32Big(); + CAssetId particle = in.readUint32Big(); u32 w1 = in.readUint32Big(); const CAnimationParameters& aParms = pInfo.GetAnimationParameters(); @@ -1653,23 +1653,23 @@ CEntity* ScriptLoader::LoadDebrisExtended(CStateManager& mgr, CInputStream& in, zeus::CVector3f v2 = zeus::CVector3f::ReadBig(in); - ResId model = in.readUint32Big(); + CAssetId model = in.readUint32Big(); CActorParameters aParam = LoadActorParameters(in); - ResId particle1 = in.readUint32Big(); + CAssetId particle1 = in.readUint32Big(); zeus::CVector3f particle1Scale = zeus::CVector3f::ReadBig(in); bool particle1B1 = in.readBool(); bool particle1B2 = in.readBool(); CScriptDebris::EOrientationType particle1W = CScriptDebris::EOrientationType(in.readUint32Big()); - ResId particle2 = in.readUint32Big(); + CAssetId particle2 = in.readUint32Big(); zeus::CVector3f particle2Scale = zeus::CVector3f::ReadBig(in); bool particle2B1 = in.readBool(); bool particle2B2 = in.readBool(); CScriptDebris::EOrientationType particle2W = CScriptDebris::EOrientationType(in.readUint32Big()); - ResId particle3 = in.readUint32Big(); + CAssetId particle3 = in.readUint32Big(); zeus::CVector3f particle3Scale = zeus::CVector3f::ReadBig(in); CScriptDebris::EOrientationType particle3W = CScriptDebris::EOrientationType(in.readUint32Big()); @@ -1806,7 +1806,7 @@ CEntity* ScriptLoader::LoadAreaAttributes(CStateManager& mgr, CInputStream& in, float thermalHeat = in.readFloatBig(); float xrayFogDistance = in.readFloatBig(); float worldLightingLevel = in.readFloatBig(); - ResId skybox = in.readUint32Big(); + CAssetId skybox = in.readUint32Big(); EPhazonType phazonType = EPhazonType(in.readUint32Big()); return new CScriptAreaAttributes(mgr.AllocateUniqueId(), info, showSkybox, fxType, envFxDensity, thermalHeat, @@ -1857,17 +1857,17 @@ CEntity* ScriptLoader::LoadWorldTeleporter(CStateManager& mgr, CInputStream& in, std::string name = mgr.HashInstanceName(in); bool active = in.readBool(); - ResId worldId = in.readUint32Big(); - ResId areaId = in.readUint32Big(); + CAssetId worldId = in.readUint32Big(); + CAssetId areaId = in.readUint32Big(); if (propCount == 4) return new CScriptWorldTeleporter(mgr.AllocateUniqueId(), name, info, active, worldId, areaId); CAnimationParameters animParms = LoadAnimationParameters(in); zeus::CVector3f playerScale = zeus::CVector3f::ReadBig(in); - ResId platformModel = in.readUint32Big(); + CAssetId platformModel = in.readUint32Big(); zeus::CVector3f platformScale = zeus::CVector3f::ReadBig(in); - ResId backgroundModel = in.readUint32Big(); + CAssetId backgroundModel = in.readUint32Big(); zeus::CVector3f backgroundScale = zeus::CVector3f::ReadBig(in); bool upElevator = in.readBool(); @@ -1875,8 +1875,8 @@ CEntity* ScriptLoader::LoadWorldTeleporter(CStateManager& mgr, CInputStream& in, u8 volume = (propCount < 13 ? u8(127) : u8(in.readUint32Big())); u8 panning = (propCount < 14 ? u8(64) : u8(in.readUint32Big())); bool showText = (propCount < 15 ? false : in.readBool()); - ResId fontId = (propCount < 16 ? kInvalidResId : in.readUint32Big()); - ResId stringId = (propCount < 17 ? kInvalidResId : in.readUint32Big()); + CAssetId fontId = (propCount < 16 ? CAssetId() : in.readUint32Big()); + CAssetId stringId = (propCount < 17 ? CAssetId() : in.readUint32Big()); bool fadeWhite = (propCount < 18 ? false : in.readBool()); float charFadeInTime = (propCount < 19 ? 0.1f : in.readFloatBig()); float charsPerSecond = (propCount < 20 ? 16.f : in.readFloatBig()); @@ -2239,7 +2239,7 @@ CEntity* ScriptLoader::LoadActorContraption(CStateManager& mgr, CInputStream& in CDamageVulnerability dVuln(in); CAnimationParameters animParams(in); CActorParameters actParams = LoadActorParameters(in); - ResId flameFxId = in.readUint32Big(); + CAssetId flameFxId = in.readUint32Big(); CDamageInfo dInfo(in); bool active = in.readBool();