diff --git a/soh/soh/OTRGlobals.cpp b/soh/soh/OTRGlobals.cpp index a4409ff8e..bdaef2e00 100644 --- a/soh/soh/OTRGlobals.cpp +++ b/soh/soh/OTRGlobals.cpp @@ -322,8 +322,8 @@ OTRGlobals::OTRGlobals() { auto loader = context->GetResourceManager()->GetResourceLoader(); loader->RegisterResourceFactory(std::make_shared(), RESOURCE_FORMAT_BINARY, "SOH_Animation", static_cast(SohResourceType::SOH_Animation), 0); + loader->RegisterResourceFactory(std::make_shared(), RESOURCE_FORMAT_BINARY, "SOH_PlayerAnimation", static_cast(SohResourceType::SOH_PlayerAnimation), 0); - loader->RegisterResourceFactory(static_cast(SohResourceType::SOH_PlayerAnimation), std::make_shared()); loader->RegisterResourceFactory(static_cast(SohResourceType::SOH_Room), std::make_shared()); // Is room scene? maybe? loader->RegisterResourceFactory(static_cast(SohResourceType::SOH_CollisionHeader), std::make_shared()); loader->RegisterResourceFactory(static_cast(SohResourceType::SOH_Skeleton), std::make_shared()); diff --git a/soh/soh/resource/importer/PlayerAnimationFactory.cpp b/soh/soh/resource/importer/PlayerAnimationFactory.cpp index ae9457669..19da11be4 100644 --- a/soh/soh/resource/importer/PlayerAnimationFactory.cpp +++ b/soh/soh/resource/importer/PlayerAnimationFactory.cpp @@ -2,40 +2,26 @@ #include "soh/resource/type/PlayerAnimation.h" #include "spdlog/spdlog.h" -namespace LUS { -std::shared_ptr -PlayerAnimationFactory::ReadResource(std::shared_ptr initData, std::shared_ptr reader) { - auto resource = std::make_shared(initData); - std::shared_ptr factory = nullptr; - - switch (resource->GetInitData()->ResourceVersion) { - case 0: - factory = std::make_shared(); - break; +std::shared_ptr ResourceFactoryBinaryPlayerAnimationV0::ReadResource(std::shared_ptr file) { + if (file->InitData->Format != RESOURCE_FORMAT_BINARY) { + SPDLOG_ERROR("resource file format does not match factory format."); + return nullptr; } - if (factory == nullptr) - { - SPDLOG_ERROR("Failed to load PlayerAnimation with version {}", resource->GetInitData()->ResourceVersion); - return nullptr; + if (file->Reader == nullptr) { + SPDLOG_ERROR("Failed to load resource: File has Reader ({} - {})", file->InitData->Type, + file->InitData->Path); + return nullptr; } - factory->ParseFileBinary(reader, resource); + auto playerAnimation = std::make_shared(file->InitData); - return resource; -} - -void LUS::PlayerAnimationFactoryV0::ParseFileBinary(std::shared_ptr reader, - std::shared_ptr resource) -{ - std::shared_ptr playerAnimation = std::static_pointer_cast(resource); - ResourceVersionFactory::ParseFileBinary(reader, playerAnimation); - - uint32_t numEntries = reader->ReadUInt32(); + uint32_t numEntries = file->Reader->ReadUInt32(); playerAnimation->limbRotData.reserve(numEntries); for (uint32_t i = 0; i < numEntries; i++) { - playerAnimation->limbRotData.push_back(reader->ReadInt16()); + playerAnimation->limbRotData.push_back(file->Reader->ReadInt16()); } -} -} // namespace LUS + + return playerAnimation; +}; diff --git a/soh/soh/resource/importer/PlayerAnimationFactory.h b/soh/soh/resource/importer/PlayerAnimationFactory.h index b4981f7c6..7c786c81a 100644 --- a/soh/soh/resource/importer/PlayerAnimationFactory.h +++ b/soh/soh/resource/importer/PlayerAnimationFactory.h @@ -3,15 +3,7 @@ #include "Resource.h" #include "ResourceFactory.h" -namespace LUS { -class PlayerAnimationFactory : public ResourceFactory { +class ResourceFactoryBinaryPlayerAnimationV0 : public LUS::ResourceFactory { public: - std::shared_ptr - ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; + std::shared_ptr ReadResource(std::shared_ptr file) override; }; - -class PlayerAnimationFactoryV0 : public ResourceVersionFactory { - public: - void ParseFileBinary(std::shared_ptr reader, std::shared_ptr resource) override; -}; -}; // namespace LUS diff --git a/soh/soh/resource/type/PlayerAnimation.cpp b/soh/soh/resource/type/PlayerAnimation.cpp index 55925f49c..3d50c23d1 100644 --- a/soh/soh/resource/type/PlayerAnimation.cpp +++ b/soh/soh/resource/type/PlayerAnimation.cpp @@ -1,7 +1,6 @@ #include "PlayerAnimation.h" #include -namespace LUS { int16_t* PlayerAnimation::GetPointer() { return limbRotData.data(); } @@ -9,4 +8,3 @@ int16_t* PlayerAnimation::GetPointer() { size_t PlayerAnimation::GetPointerSize() { return limbRotData.size() * sizeof(int16_t); } -} // namespace LUS \ No newline at end of file diff --git a/soh/soh/resource/type/PlayerAnimation.h b/soh/soh/resource/type/PlayerAnimation.h index 4eb51b139..0929aa88b 100644 --- a/soh/soh/resource/type/PlayerAnimation.h +++ b/soh/soh/resource/type/PlayerAnimation.h @@ -7,8 +7,6 @@ #include "Vec3f.h" #include "Color3b.h" -namespace LUS { - class PlayerAnimation : public Resource { public: using Resource::Resource; @@ -20,4 +18,3 @@ class PlayerAnimation : public Resource { std::vector limbRotData; }; -} // namespace LUS \ No newline at end of file