diff --git a/OTRExporter b/OTRExporter index d8f3c4dd4..e93bd2be0 160000 --- a/OTRExporter +++ b/OTRExporter @@ -1 +1 @@ -Subproject commit d8f3c4dd4a46fb46c4f69cd387afadfa711606e9 +Subproject commit e93bd2be062b13106fdb29d98cf4ada4d7ad6827 diff --git a/libultraship b/libultraship index d5a39635a..a516b66ce 160000 --- a/libultraship +++ b/libultraship @@ -1 +1 @@ -Subproject commit d5a39635a118f814613c0fdd1601f80c809a742d +Subproject commit a516b66ce0c89fe4e33c55b1fbfbde845d0bf129 diff --git a/soh/soh/OTRGlobals.cpp b/soh/soh/OTRGlobals.cpp index 9548de28d..4d82de6bc 100644 --- a/soh/soh/OTRGlobals.cpp +++ b/soh/soh/OTRGlobals.cpp @@ -92,6 +92,7 @@ GameInteractorSail* GameInteractorSail::Instance; #include // Resource Types/Factories +#include "soh/resource/type/SohResourceType.h" #include "soh/resource/type/Animation.h" #include "soh/resource/type/AudioSample.h" #include "soh/resource/type/AudioSequence.h" @@ -319,19 +320,24 @@ OTRGlobals::OTRGlobals() { SPDLOG_INFO("Starting Ship of Harkinian version {}", (char*)gBuildVersion); - context->GetResourceManager()->GetResourceLoader()->RegisterResourceFactory(static_cast(LUS::ResourceType::SOH_Animation), std::make_shared()); - context->GetResourceManager()->GetResourceLoader()->RegisterResourceFactory(static_cast(LUS::ResourceType::SOH_PlayerAnimation), std::make_shared()); - context->GetResourceManager()->GetResourceLoader()->RegisterResourceFactory(static_cast(LUS::ResourceType::SOH_Room), std::make_shared()); // Is room scene? maybe? - context->GetResourceManager()->GetResourceLoader()->RegisterResourceFactory(static_cast(LUS::ResourceType::SOH_CollisionHeader), std::make_shared()); - context->GetResourceManager()->GetResourceLoader()->RegisterResourceFactory(static_cast(LUS::ResourceType::SOH_Skeleton), std::make_shared()); - context->GetResourceManager()->GetResourceLoader()->RegisterResourceFactory(static_cast(LUS::ResourceType::SOH_SkeletonLimb), std::make_shared()); - context->GetResourceManager()->GetResourceLoader()->RegisterResourceFactory(static_cast(LUS::ResourceType::SOH_Path), std::make_shared()); - context->GetResourceManager()->GetResourceLoader()->RegisterResourceFactory(static_cast(LUS::ResourceType::SOH_Cutscene), std::make_shared()); - context->GetResourceManager()->GetResourceLoader()->RegisterResourceFactory(static_cast(LUS::ResourceType::SOH_Text), std::make_shared()); - context->GetResourceManager()->GetResourceLoader()->RegisterResourceFactory(static_cast(LUS::ResourceType::SOH_AudioSample), std::make_shared()); - context->GetResourceManager()->GetResourceLoader()->RegisterResourceFactory(static_cast(LUS::ResourceType::SOH_AudioSoundFont), std::make_shared()); - context->GetResourceManager()->GetResourceLoader()->RegisterResourceFactory(static_cast(LUS::ResourceType::SOH_AudioSequence), std::make_shared()); - context->GetResourceManager()->GetResourceLoader()->RegisterResourceFactory(static_cast(LUS::ResourceType::SOH_Background), std::make_shared()); + auto loader = context->GetResourceManager()->GetResourceLoader(); + loader->RegisterResourceFactory(std::make_shared(), RESOURCE_FORMAT_BINARY, "Animation", static_cast(SOH::ResourceType::SOH_Animation), 0); + loader->RegisterResourceFactory(std::make_shared(), RESOURCE_FORMAT_BINARY, "PlayerAnimation", static_cast(SOH::ResourceType::SOH_PlayerAnimation), 0); + loader->RegisterResourceFactory(std::make_shared(), RESOURCE_FORMAT_BINARY, "Room", static_cast(SOH::ResourceType::SOH_Room), 0); // Is room scene? maybe? + loader->RegisterResourceFactory(std::make_shared(), RESOURCE_FORMAT_BINARY, "CollisionHeader", static_cast(SOH::ResourceType::SOH_CollisionHeader), 0); + loader->RegisterResourceFactory(std::make_shared(), RESOURCE_FORMAT_XML, "CollisionHeader", static_cast(SOH::ResourceType::SOH_CollisionHeader), 0); + loader->RegisterResourceFactory(std::make_shared(), RESOURCE_FORMAT_BINARY, "Skeleton", static_cast(SOH::ResourceType::SOH_Skeleton), 0); + loader->RegisterResourceFactory(std::make_shared(), RESOURCE_FORMAT_XML, "Skeleton", static_cast(SOH::ResourceType::SOH_Skeleton), 0); + loader->RegisterResourceFactory(std::make_shared(), RESOURCE_FORMAT_BINARY, "SkeletonLimb", static_cast(SOH::ResourceType::SOH_SkeletonLimb), 0); + loader->RegisterResourceFactory(std::make_shared(), RESOURCE_FORMAT_XML, "SkeletonLimb", static_cast(SOH::ResourceType::SOH_SkeletonLimb), 0); + loader->RegisterResourceFactory(std::make_shared(), RESOURCE_FORMAT_BINARY, "Path", static_cast(SOH::ResourceType::SOH_Path), 0); + loader->RegisterResourceFactory(std::make_shared(), RESOURCE_FORMAT_BINARY, "Cutscene", static_cast(SOH::ResourceType::SOH_Cutscene), 0); + loader->RegisterResourceFactory(std::make_shared(), RESOURCE_FORMAT_BINARY, "Text", static_cast(SOH::ResourceType::SOH_Text), 0); + loader->RegisterResourceFactory(std::make_shared(), RESOURCE_FORMAT_XML, "Text", static_cast(SOH::ResourceType::SOH_Text), 0); + loader->RegisterResourceFactory(std::make_shared(), RESOURCE_FORMAT_BINARY, "AudioSample", static_cast(SOH::ResourceType::SOH_AudioSample), 2); + loader->RegisterResourceFactory(std::make_shared(), RESOURCE_FORMAT_BINARY, "AudioSoundFont", static_cast(SOH::ResourceType::SOH_AudioSoundFont), 2); + loader->RegisterResourceFactory(std::make_shared(), RESOURCE_FORMAT_BINARY, "AudioSequence", static_cast(SOH::ResourceType::SOH_AudioSequence), 2); + loader->RegisterResourceFactory(std::make_shared(), RESOURCE_FORMAT_BINARY, "Background", static_cast(SOH::ResourceType::SOH_Background), 0); gSaveStateMgr = std::make_shared(); gRandomizer = std::make_shared(); @@ -1390,7 +1396,7 @@ extern "C" void Graph_ProcessGfxCommands(Gfx* commands) { // Actually update the CVar now before runing the alt asset update listeners CVarSetInteger("gAltAssets", !CVarGetInteger("gAltAssets", 0)); gfx_texture_cache_clear(); - LUS::SkeletonPatcher::UpdateSkeletons(); + SOH::SkeletonPatcher::UpdateSkeletons(); GameInteractor::Instance->ExecuteHooks(); } @@ -1618,7 +1624,7 @@ extern "C" uint8_t ResourceMgr_TexIsRaw(const char* texPath) { extern "C" uint8_t ResourceMgr_ResourceIsBackground(char* texPath) { auto res = GetResourceByNameHandlingMQ(texPath); - return res->GetInitData()->Type == static_cast(LUS::ResourceType::SOH_Background); + return res->GetInitData()->Type == static_cast(SOH::ResourceType::SOH_Background); } extern "C" char* ResourceMgr_LoadJPEG(char* data, size_t dataSize) @@ -1689,7 +1695,7 @@ extern "C" Sprite* GetSeedTexture(uint8_t index) { } extern "C" char* ResourceMgr_LoadPlayerAnimByName(const char* animPath) { - auto anim = std::static_pointer_cast(GetResourceByNameHandlingMQ(animPath)); + auto anim = std::static_pointer_cast(GetResourceByNameHandlingMQ(animPath)); return (char*)&anim->limbRotData[0]; } @@ -1953,7 +1959,7 @@ extern "C" SkeletonHeader* ResourceMgr_LoadSkeletonByName(const char* path, Skel // Therefore we can take this oppurtunity to take note of the Skeleton that is created... if (skelAnime != nullptr) { auto stringPath = std::string(path); - LUS::SkeletonPatcher::RegisterSkeleton(stringPath, skelAnime); + SOH::SkeletonPatcher::RegisterSkeleton(stringPath, skelAnime); } return skelHeader; @@ -1961,12 +1967,12 @@ extern "C" SkeletonHeader* ResourceMgr_LoadSkeletonByName(const char* path, Skel extern "C" void ResourceMgr_UnregisterSkeleton(SkelAnime* skelAnime) { if (skelAnime != nullptr) - LUS::SkeletonPatcher::UnregisterSkeleton(skelAnime); + SOH::SkeletonPatcher::UnregisterSkeleton(skelAnime); } extern "C" void ResourceMgr_ClearSkeletons(SkelAnime* skelAnime) { if (skelAnime != nullptr) - LUS::SkeletonPatcher::ClearSkeletons(); + SOH::SkeletonPatcher::ClearSkeletons(); } extern "C" s32* ResourceMgr_LoadCSByName(const char* path) { diff --git a/soh/soh/resource/importer/AnimationFactory.cpp b/soh/soh/resource/importer/AnimationFactory.cpp index c2aaf3067..8e1aca9b7 100644 --- a/soh/soh/resource/importer/AnimationFactory.cpp +++ b/soh/soh/resource/importer/AnimationFactory.cpp @@ -2,32 +2,14 @@ #include "soh/resource/type/Animation.h" #include "spdlog/spdlog.h" -namespace LUS { -std::shared_ptr -AnimationFactory::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; - } - - if (factory == nullptr) { - SPDLOG_ERROR("Failed to load Animation with version {}", resource->GetInitData()->ResourceVersion); +namespace SOH { +std::shared_ptr ResourceFactoryBinaryAnimationV0::ReadResource(std::shared_ptr file) { + if (!FileHasValidFormatAndReader(file)) { return nullptr; } - factory->ParseFileBinary(reader, resource); - - return resource; -} - -void LUS::AnimationFactoryV0::ParseFileBinary(std::shared_ptr reader, std::shared_ptr resource) { - std::shared_ptr animation = std::static_pointer_cast(resource); - - ResourceVersionFactory::ParseFileBinary(reader, animation); + auto animation = std::make_shared(file->InitData); + auto reader = std::get>(file->Reader); AnimationType animType = (AnimationType)reader->ReadUInt32(); animation->type = animType; @@ -100,5 +82,7 @@ void LUS::AnimationFactoryV0::ParseFileBinary(std::shared_ptr read } else if (animType == AnimationType::Legacy) { SPDLOG_DEBUG("BEYTAH ANIMATION?!"); } + + return animation; } -} // namespace LUS +} // namespace SOH \ No newline at end of file diff --git a/soh/soh/resource/importer/AnimationFactory.h b/soh/soh/resource/importer/AnimationFactory.h index dee2026f9..36dfceaae 100644 --- a/soh/soh/resource/importer/AnimationFactory.h +++ b/soh/soh/resource/importer/AnimationFactory.h @@ -1,17 +1,11 @@ #pragma once #include "Resource.h" -#include "ResourceFactory.h" +#include "ResourceFactoryBinary.h" -namespace LUS { -class AnimationFactory : public ResourceFactory { +namespace SOH { +class ResourceFactoryBinaryAnimationV0 : public LUS::ResourceFactoryBinary { public: - std::shared_ptr - ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; + std::shared_ptr ReadResource(std::shared_ptr file) override; }; - -class AnimationFactoryV0 : public ResourceVersionFactory { - public: - void ParseFileBinary(std::shared_ptr reader, std::shared_ptr resource) override; -}; -}; // namespace LUS +} // namespace SOH diff --git a/soh/soh/resource/importer/AudioSampleFactory.cpp b/soh/soh/resource/importer/AudioSampleFactory.cpp index 9d1477a51..b45e698e5 100644 --- a/soh/soh/resource/importer/AudioSampleFactory.cpp +++ b/soh/soh/resource/importer/AudioSampleFactory.cpp @@ -2,33 +2,14 @@ #include "soh/resource/type/AudioSample.h" #include "spdlog/spdlog.h" -namespace LUS { -std::shared_ptr -AudioSampleFactory::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 2: - factory = std::make_shared(); - break; +namespace SOH { +std::shared_ptr ResourceFactoryBinaryAudioSampleV2::ReadResource(std::shared_ptr file) { + if (!FileHasValidFormatAndReader(file)) { + return nullptr; } - if (factory == nullptr) { - SPDLOG_ERROR("Failed to load AudioSample with version {}", resource->GetInitData()->ResourceVersion); - return nullptr; - } - - factory->ParseFileBinary(reader, resource); - - return resource; -} - -void LUS::AudioSampleFactoryV0::ParseFileBinary(std::shared_ptr reader, - std::shared_ptr resource) -{ - std::shared_ptr audioSample = std::static_pointer_cast(resource); - ResourceVersionFactory::ParseFileBinary(reader, audioSample); + auto audioSample = std::make_shared(file->InitData); + auto reader = std::get>(file->Reader); audioSample->sample.codec = reader->ReadUByte(); audioSample->sample.medium = reader->ReadUByte(); @@ -65,9 +46,10 @@ void LUS::AudioSampleFactoryV0::ParseFileBinary(std::shared_ptr re } audioSample->book.book = audioSample->bookData.data(); audioSample->sample.book = &audioSample->book; -} -} // namespace LUS + return audioSample; +} +} // namespace SOH /* in ResourceMgr_LoadAudioSample we used to have diff --git a/soh/soh/resource/importer/AudioSampleFactory.h b/soh/soh/resource/importer/AudioSampleFactory.h index 6e9ddc17c..2680ccdc2 100644 --- a/soh/soh/resource/importer/AudioSampleFactory.h +++ b/soh/soh/resource/importer/AudioSampleFactory.h @@ -1,19 +1,11 @@ #pragma once #include "Resource.h" -#include "ResourceFactory.h" +#include "ResourceFactoryBinary.h" -namespace LUS { -class AudioSampleFactory : public ResourceFactory -{ +namespace SOH { +class ResourceFactoryBinaryAudioSampleV2 : public LUS::ResourceFactoryBinary { public: - std::shared_ptr - ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; + std::shared_ptr ReadResource(std::shared_ptr file) override; }; - -class AudioSampleFactoryV0 : public ResourceVersionFactory -{ - public: - void ParseFileBinary(std::shared_ptr reader, std::shared_ptr resource) override; -}; -}; // namespace LUS +} // namespace SOH diff --git a/soh/soh/resource/importer/AudioSequenceFactory.cpp b/soh/soh/resource/importer/AudioSequenceFactory.cpp index a4862cb19..ba2a36697 100644 --- a/soh/soh/resource/importer/AudioSequenceFactory.cpp +++ b/soh/soh/resource/importer/AudioSequenceFactory.cpp @@ -2,33 +2,14 @@ #include "soh/resource/type/AudioSequence.h" #include "spdlog/spdlog.h" -namespace LUS { -std::shared_ptr -AudioSequenceFactory::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 2: - factory = std::make_shared(); - break; - } - - if (factory == nullptr) - { - SPDLOG_ERROR("Failed to load AudioSequence with version {}", resource->GetInitData()->ResourceVersion); +namespace SOH { +std::shared_ptr ResourceFactoryBinaryAudioSequenceV2::ReadResource(std::shared_ptr file) { + if (!FileHasValidFormatAndReader(file)) { return nullptr; } - factory->ParseFileBinary(reader, resource); - - return resource; -} - -void LUS::AudioSequenceFactoryV0::ParseFileBinary(std::shared_ptr reader, - std::shared_ptr resource) { - std::shared_ptr audioSequence = std::static_pointer_cast(resource); - ResourceVersionFactory::ParseFileBinary(reader, audioSequence); + auto audioSequence = std::make_shared(file->InitData); + auto reader = std::get>(file->Reader); audioSequence->sequence.seqDataSize = reader->ReadInt32(); audioSequence->sequenceData.reserve(audioSequence->sequence.seqDataSize); @@ -48,5 +29,7 @@ void LUS::AudioSequenceFactoryV0::ParseFileBinary(std::shared_ptr for (uint32_t i = 0; i < audioSequence->sequence.numFonts; i++) { audioSequence->sequence.fonts[i] = reader->ReadUByte(); } + + return audioSequence; } -} // namespace LUS +} // namespace SOH diff --git a/soh/soh/resource/importer/AudioSequenceFactory.h b/soh/soh/resource/importer/AudioSequenceFactory.h index 12b3809aa..fb4391d61 100644 --- a/soh/soh/resource/importer/AudioSequenceFactory.h +++ b/soh/soh/resource/importer/AudioSequenceFactory.h @@ -1,19 +1,11 @@ #pragma once #include "Resource.h" -#include "ResourceFactory.h" +#include "ResourceFactoryBinary.h" -namespace LUS { -class AudioSequenceFactory : public ResourceFactory -{ +namespace SOH { +class ResourceFactoryBinaryAudioSequenceV2 : public LUS::ResourceFactoryBinary { public: - std::shared_ptr - ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; + std::shared_ptr ReadResource(std::shared_ptr file) override; }; - -class AudioSequenceFactoryV0 : public ResourceVersionFactory -{ - public: - void ParseFileBinary(std::shared_ptr reader, std::shared_ptr resource) override; -}; -}; // namespace LUS +} // namespace SOH diff --git a/soh/soh/resource/importer/AudioSoundFontFactory.cpp b/soh/soh/resource/importer/AudioSoundFontFactory.cpp index 5a94cb5f8..6d7efc58c 100644 --- a/soh/soh/resource/importer/AudioSoundFontFactory.cpp +++ b/soh/soh/resource/importer/AudioSoundFontFactory.cpp @@ -3,33 +3,14 @@ #include "spdlog/spdlog.h" #include "libultraship/libultraship.h" -namespace LUS { -std::shared_ptr -AudioSoundFontFactory::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 2: - factory = std::make_shared(); - break; - } - - if (factory == nullptr) - { - SPDLOG_ERROR("Failed to load AudioSoundFont with version {}", resource->GetInitData()->ResourceVersion); +namespace SOH { +std::shared_ptr ResourceFactoryBinaryAudioSoundFontV2::ReadResource(std::shared_ptr file) { + if (!FileHasValidFormatAndReader(file)) { return nullptr; } - factory->ParseFileBinary(reader, resource); - - return resource; -} - -void LUS::AudioSoundFontFactoryV0::ParseFileBinary(std::shared_ptr reader, - std::shared_ptr resource) { - std::shared_ptr audioSoundFont = std::static_pointer_cast(resource); - ResourceVersionFactory::ParseFileBinary(reader, audioSoundFont); + auto audioSoundFont = std::make_shared(file->InitData); + auto reader = std::get>(file->Reader); audioSoundFont->soundFont.fntIndex = reader->ReadInt32(); audioSoundFont->medium = reader->ReadInt8(); @@ -186,5 +167,7 @@ void LUS::AudioSoundFontFactoryV0::ParseFileBinary(std::shared_ptr audioSoundFont->soundEffects.push_back(soundEffect); } audioSoundFont->soundFont.soundEffects = audioSoundFont->soundEffects.data(); + + return audioSoundFont; } -} // namespace LUS +} // namespace SOH diff --git a/soh/soh/resource/importer/AudioSoundFontFactory.h b/soh/soh/resource/importer/AudioSoundFontFactory.h index 7dd5bc0d5..a63533db9 100644 --- a/soh/soh/resource/importer/AudioSoundFontFactory.h +++ b/soh/soh/resource/importer/AudioSoundFontFactory.h @@ -1,19 +1,11 @@ #pragma once #include "Resource.h" -#include "ResourceFactory.h" +#include "ResourceFactoryBinary.h" -namespace LUS { -class AudioSoundFontFactory : public ResourceFactory -{ +namespace SOH { +class ResourceFactoryBinaryAudioSoundFontV2 : public LUS::ResourceFactoryBinary { public: - std::shared_ptr - ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; + std::shared_ptr ReadResource(std::shared_ptr file) override; }; - -class AudioSoundFontFactoryV0 : public ResourceVersionFactory -{ - public: - void ParseFileBinary(std::shared_ptr reader, std::shared_ptr resource) override; -}; -}; // namespace LUS +} // namespace SOH diff --git a/soh/soh/resource/importer/BackgroundFactory.cpp b/soh/soh/resource/importer/BackgroundFactory.cpp index 5b09ce70f..07c47cbe9 100644 --- a/soh/soh/resource/importer/BackgroundFactory.cpp +++ b/soh/soh/resource/importer/BackgroundFactory.cpp @@ -2,31 +2,14 @@ #include "soh/resource/type/Background.h" #include "spdlog/spdlog.h" -namespace LUS { -std::shared_ptr -BackgroundFactory::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; - } - - if (factory == nullptr) { - SPDLOG_ERROR("Failed to load Background with version {}", resource->GetInitData()->ResourceVersion); +namespace SOH { +std::shared_ptr ResourceFactoryBinaryBackgroundV0::ReadResource(std::shared_ptr file) { + if (!FileHasValidFormatAndReader(file)) { return nullptr; } - factory->ParseFileBinary(reader, resource); - - return resource; -} - -void BackgroundFactoryV0::ParseFileBinary(std::shared_ptr reader, std::shared_ptr resource) { - std::shared_ptr background = std::static_pointer_cast(resource); - ResourceVersionFactory::ParseFileBinary(reader, background); + auto background = std::make_shared(file->InitData); + auto reader = std::get>(file->Reader); uint32_t dataSize = reader->ReadUInt32(); @@ -35,5 +18,7 @@ void BackgroundFactoryV0::ParseFileBinary(std::shared_ptr reader, for (uint32_t i = 0; i < dataSize; i++) { background->Data.push_back(reader->ReadUByte()); } + + return background; } -} // namespace LUS +} // namespace SOH diff --git a/soh/soh/resource/importer/BackgroundFactory.h b/soh/soh/resource/importer/BackgroundFactory.h index 9767fdf8b..787ee509c 100644 --- a/soh/soh/resource/importer/BackgroundFactory.h +++ b/soh/soh/resource/importer/BackgroundFactory.h @@ -1,17 +1,11 @@ #pragma once #include "resource/Resource.h" -#include "resource/ResourceFactory.h" +#include "resource/ResourceFactoryBinary.h" -namespace LUS { -class BackgroundFactory : public ResourceFactory { +namespace SOH { +class ResourceFactoryBinaryBackgroundV0 : public LUS::ResourceFactoryBinary { public: - std::shared_ptr - ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; + std::shared_ptr ReadResource(std::shared_ptr file) override; }; - -class BackgroundFactoryV0 : public ResourceVersionFactory { - public: - void ParseFileBinary(std::shared_ptr reader, std::shared_ptr resource) override; -}; -}; // namespace LUS +} // namespace SOH diff --git a/soh/soh/resource/importer/CollisionHeaderFactory.cpp b/soh/soh/resource/importer/CollisionHeaderFactory.cpp index 9300efdf0..c5372f249 100644 --- a/soh/soh/resource/importer/CollisionHeaderFactory.cpp +++ b/soh/soh/resource/importer/CollisionHeaderFactory.cpp @@ -2,54 +2,14 @@ #include "soh/resource/type/CollisionHeader.h" #include "spdlog/spdlog.h" -namespace LUS { -std::shared_ptr -CollisionHeaderFactory::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; - } - - if (factory == nullptr) { - SPDLOG_ERROR("Failed to load Collision Header with version {}", resource->GetInitData()->ResourceVersion); +namespace SOH { +std::shared_ptr ResourceFactoryBinaryCollisionHeaderV0::ReadResource(std::shared_ptr file) { + if (!FileHasValidFormatAndReader(file)) { return nullptr; } - factory->ParseFileBinary(reader, resource); - - return resource; -} - -std::shared_ptr -CollisionHeaderFactory::ReadResourceXML(std::shared_ptr initData, tinyxml2::XMLElement *reader) { - auto resource = std::make_shared(initData); - std::shared_ptr factory = nullptr; - - switch (resource->GetInitData()->ResourceVersion) { - case 0: - factory = std::make_shared(); - break; - } - - if (factory == nullptr) { - SPDLOG_ERROR("Failed to load Collision Header with version {}", resource->GetInitData()->ResourceVersion); - return nullptr; - } - - factory->ParseFileXML(reader, resource); - - return resource; -} - -void LUS::CollisionHeaderFactoryV0::ParseFileBinary(std::shared_ptr reader, - std::shared_ptr resource) -{ - std::shared_ptr collisionHeader = std::static_pointer_cast(resource); - ResourceVersionFactory::ParseFileBinary(reader, collisionHeader); + auto collisionHeader = std::make_shared(file->InitData); + auto reader = std::get>(file->Reader); collisionHeader->collisionHeaderData.minBounds.x = reader->ReadInt16(); collisionHeader->collisionHeaderData.minBounds.y = reader->ReadInt16(); @@ -159,10 +119,19 @@ void LUS::CollisionHeaderFactoryV0::ParseFileBinary(std::shared_ptrwaterBoxes.push_back(waterBox); } collisionHeader->collisionHeaderData.waterBoxes = collisionHeader->waterBoxes.data(); + + return collisionHeader; } -void LUS::CollisionHeaderFactoryV0::ParseFileXML(tinyxml2::XMLElement* reader, std::shared_ptr resource) { - std::shared_ptr collisionHeader = std::static_pointer_cast(resource); +std::shared_ptr ResourceFactoryXMLCollisionHeaderV0::ReadResource(std::shared_ptr file) { + if (!FileHasValidFormatAndReader(file)) { + return nullptr; + } + + auto collisionHeader = std::make_shared(file->InitData); + + auto reader = std::get>(file->Reader)->FirstChildElement(); + auto child = reader->FirstChildElement(); collisionHeader->collisionHeaderData.minBounds.x = reader->IntAttribute("MinBoundsX"); collisionHeader->collisionHeaderData.minBounds.y = reader->IntAttribute("MinBoundsY"); @@ -178,8 +147,6 @@ void LUS::CollisionHeaderFactoryV0::ParseFileXML(tinyxml2::XMLElement* reader, s zero.z = 0; collisionHeader->camPosDataZero = zero; - auto child = reader->FirstChildElement(); - while (child != nullptr) { std::string childName = child->Name(); if (childName == "Vertex") { @@ -274,5 +241,7 @@ void LUS::CollisionHeaderFactoryV0::ParseFileXML(tinyxml2::XMLElement* reader, s collisionHeader->collisionHeaderData.cameraDataList = collisionHeader->camData.data(); collisionHeader->collisionHeaderData.cameraDataListLen = collisionHeader->camDataCount; collisionHeader->collisionHeaderData.waterBoxes = collisionHeader->waterBoxes.data(); + + return collisionHeader; } -} \ No newline at end of file +} // namespace SOH diff --git a/soh/soh/resource/importer/CollisionHeaderFactory.h b/soh/soh/resource/importer/CollisionHeaderFactory.h index e0276b38f..abd878909 100644 --- a/soh/soh/resource/importer/CollisionHeaderFactory.h +++ b/soh/soh/resource/importer/CollisionHeaderFactory.h @@ -1,20 +1,17 @@ #pragma once #include "Resource.h" -#include "ResourceFactory.h" +#include "ResourceFactoryBinary.h" +#include "ResourceFactoryXML.h" -namespace LUS { -class CollisionHeaderFactory : public ResourceFactory { +namespace SOH { +class ResourceFactoryBinaryCollisionHeaderV0 : public LUS::ResourceFactoryBinary { public: - std::shared_ptr - ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; - std::shared_ptr - ReadResourceXML(std::shared_ptr initData, tinyxml2::XMLElement *reader) override; + std::shared_ptr ReadResource(std::shared_ptr file) override; }; -class CollisionHeaderFactoryV0 : public ResourceVersionFactory { +class ResourceFactoryXMLCollisionHeaderV0 : public LUS::ResourceFactoryXML { public: - void ParseFileBinary(std::shared_ptr reader, std::shared_ptr resource) override; - void ParseFileXML(tinyxml2::XMLElement* reader, std::shared_ptr resource) override; + std::shared_ptr ReadResource(std::shared_ptr file) override; }; -}; // namespace LUS +} // namespace SOH diff --git a/soh/soh/resource/importer/CutsceneFactory.cpp b/soh/soh/resource/importer/CutsceneFactory.cpp index 27c747a6e..28f5e642b 100644 --- a/soh/soh/resource/importer/CutsceneFactory.cpp +++ b/soh/soh/resource/importer/CutsceneFactory.cpp @@ -2,36 +2,14 @@ #include "soh/resource/type/Cutscene.h" #include "spdlog/spdlog.h" -namespace LUS { -std::shared_ptr -CutsceneFactory::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; - } - - if (factory == nullptr) { - SPDLOG_ERROR("Failed to load Cutscene with version {}", resource->GetInitData()->ResourceVersion); - return nullptr; - } - - factory->ParseFileBinary(reader, resource); - - return resource; -} - -static inline uint32_t read_CMD_BBBB(std::shared_ptr reader) { +static inline uint32_t read_CMD_BBBB(std::shared_ptr reader) { uint32_t v; reader->Read((char*)&v, sizeof(uint32_t)); return v; } -static inline uint32_t read_CMD_BBH(std::shared_ptr reader) { +static inline uint32_t read_CMD_BBH(std::shared_ptr reader) { uint32_t v; reader->Read((char*)&v, sizeof(uint32_t)); @@ -46,7 +24,7 @@ static inline uint32_t read_CMD_BBH(std::shared_ptr reader) { return v; } -static inline uint32_t read_CMD_HBB(std::shared_ptr reader) { +static inline uint32_t read_CMD_HBB(std::shared_ptr reader) { uint32_t v; reader->Read((char*)&v, sizeof(uint32_t)); @@ -61,7 +39,7 @@ static inline uint32_t read_CMD_HBB(std::shared_ptr reader) { return v; } -static inline uint32_t read_CMD_HH(std::shared_ptr reader) { +static inline uint32_t read_CMD_HH(std::shared_ptr reader) { uint32_t v; reader->Read((char*)&v, sizeof(uint32_t)); @@ -79,11 +57,14 @@ static inline uint32_t read_CMD_HH(std::shared_ptr reader) { return v; } -void LUS::CutsceneFactoryV0::ParseFileBinary(std::shared_ptr reader, - std::shared_ptr resource) -{ - std::shared_ptr cutscene = std::static_pointer_cast(resource); - ResourceVersionFactory::ParseFileBinary(reader, cutscene); +namespace SOH { +std::shared_ptr ResourceFactoryBinaryCutsceneV0::ReadResource(std::shared_ptr file) { + if (!FileHasValidFormatAndReader(file)) { + return nullptr; + } + + auto cutscene = std::make_shared(file->InitData); + auto reader = std::get>(file->Reader); uint32_t numEntries = reader->ReadUInt32(); cutscene->commands.reserve(numEntries); @@ -459,7 +440,7 @@ void LUS::CutsceneFactoryV0::ParseFileBinary(std::shared_ptr reade case 0xFFFFFFFF: // CS_END { cutscene->commands.push_back(reader->ReadUInt32()); - return; + return cutscene; } default: SPDLOG_TRACE("CutsceneV0: Unknown command {}\n", commandId); @@ -467,5 +448,7 @@ void LUS::CutsceneFactoryV0::ParseFileBinary(std::shared_ptr reade break; } } + + return cutscene; } -} // namespace LUS +} // namespace SOH diff --git a/soh/soh/resource/importer/CutsceneFactory.h b/soh/soh/resource/importer/CutsceneFactory.h index a5813f6fe..8194615af 100644 --- a/soh/soh/resource/importer/CutsceneFactory.h +++ b/soh/soh/resource/importer/CutsceneFactory.h @@ -1,19 +1,11 @@ #pragma once #include "Resource.h" -#include "ResourceFactory.h" +#include "ResourceFactoryBinary.h" -namespace LUS { -class CutsceneFactory : public ResourceFactory -{ +namespace SOH { +class ResourceFactoryBinaryCutsceneV0 : public LUS::ResourceFactoryBinary { public: - std::shared_ptr - ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; + std::shared_ptr ReadResource(std::shared_ptr file) override; }; - -class CutsceneFactoryV0 : public ResourceVersionFactory -{ - public: - void ParseFileBinary(std::shared_ptr reader, std::shared_ptr resource) override; -}; -}; // namespace LUS +} // namespace SOH diff --git a/soh/soh/resource/importer/PathFactory.cpp b/soh/soh/resource/importer/PathFactory.cpp index bb4f87eb6..07fc86f40 100644 --- a/soh/soh/resource/importer/PathFactory.cpp +++ b/soh/soh/resource/importer/PathFactory.cpp @@ -2,32 +2,14 @@ #include "soh/resource/type/Path.h" #include "spdlog/spdlog.h" -namespace LUS { -std::shared_ptr -PathFactory::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; +namespace SOH { +std::shared_ptr ResourceFactoryBinaryPathV0::ReadResource(std::shared_ptr file) { + if (!FileHasValidFormatAndReader(file)) { + return nullptr; } - if (factory == nullptr) { - SPDLOG_ERROR("Failed to load Path with version {}", resource->GetInitData()->ResourceVersion); - return nullptr; - } - - factory->ParseFileBinary(reader, resource); - - return resource; -} - -void LUS::PathFactoryV0::ParseFileBinary(std::shared_ptr reader, - std::shared_ptr resource) { - std::shared_ptr path = std::static_pointer_cast(resource); - ResourceVersionFactory::ParseFileBinary(reader, path); + auto path = std::make_shared(file->InitData); + auto reader = std::get>(file->Reader); path->numPaths = reader->ReadUInt32(); path->paths.reserve(path->numPaths); @@ -52,5 +34,7 @@ void LUS::PathFactoryV0::ParseFileBinary(std::shared_ptr reader, path->pathData.push_back(pathDataEntry); } + + return path; } -} // namespace LUS +} // namespace SOH diff --git a/soh/soh/resource/importer/PathFactory.h b/soh/soh/resource/importer/PathFactory.h index 3a8c0d595..aa8ae747c 100644 --- a/soh/soh/resource/importer/PathFactory.h +++ b/soh/soh/resource/importer/PathFactory.h @@ -1,19 +1,11 @@ #pragma once #include "Resource.h" -#include "ResourceFactory.h" +#include "ResourceFactoryBinary.h" -namespace LUS { -class PathFactory : public ResourceFactory -{ +namespace SOH { +class ResourceFactoryBinaryPathV0 : public LUS::ResourceFactoryBinary { public: - std::shared_ptr - ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; + std::shared_ptr ReadResource(std::shared_ptr file) override; }; - -class PathFactoryV0 : public ResourceVersionFactory -{ - public: - void ParseFileBinary(std::shared_ptr reader, std::shared_ptr resource) override; -}; -}; // namespace LUS +} // namespace SOH diff --git a/soh/soh/resource/importer/PlayerAnimationFactory.cpp b/soh/soh/resource/importer/PlayerAnimationFactory.cpp index ae9457669..4c25d5e80 100644 --- a/soh/soh/resource/importer/PlayerAnimationFactory.cpp +++ b/soh/soh/resource/importer/PlayerAnimationFactory.cpp @@ -2,34 +2,14 @@ #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; +namespace SOH { +std::shared_ptr ResourceFactoryBinaryPlayerAnimationV0::ReadResource(std::shared_ptr file) { + if (!FileHasValidFormatAndReader(file)) { + return nullptr; } - if (factory == nullptr) - { - SPDLOG_ERROR("Failed to load PlayerAnimation with version {}", resource->GetInitData()->ResourceVersion); - return nullptr; - } - - factory->ParseFileBinary(reader, resource); - - 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); + auto playerAnimation = std::make_shared(file->InitData); + auto reader = std::get>(file->Reader); uint32_t numEntries = reader->ReadUInt32(); playerAnimation->limbRotData.reserve(numEntries); @@ -37,5 +17,7 @@ void LUS::PlayerAnimationFactoryV0::ParseFileBinary(std::shared_ptrlimbRotData.push_back(reader->ReadInt16()); } -} -} // namespace LUS + + return playerAnimation; +}; +} // namespace SOH diff --git a/soh/soh/resource/importer/PlayerAnimationFactory.h b/soh/soh/resource/importer/PlayerAnimationFactory.h index b4981f7c6..8b459a38b 100644 --- a/soh/soh/resource/importer/PlayerAnimationFactory.h +++ b/soh/soh/resource/importer/PlayerAnimationFactory.h @@ -1,17 +1,11 @@ #pragma once #include "Resource.h" -#include "ResourceFactory.h" +#include "ResourceFactoryBinary.h" -namespace LUS { -class PlayerAnimationFactory : public ResourceFactory { +namespace SOH { +class ResourceFactoryBinaryPlayerAnimationV0 : public LUS::ResourceFactoryBinary { 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 +} // namespace SOH diff --git a/soh/soh/resource/importer/SceneFactory.cpp b/soh/soh/resource/importer/SceneFactory.cpp index b71f78a2c..679d574cb 100644 --- a/soh/soh/resource/importer/SceneFactory.cpp +++ b/soh/soh/resource/importer/SceneFactory.cpp @@ -1,4 +1,5 @@ #include "spdlog/spdlog.h" +#include "soh/resource/type/SohResourceType.h" #include "soh/resource/importer/SceneFactory.h" #include "soh/resource/type/Scene.h" #include "soh/resource/type/scenecommand/SceneCommand.h" @@ -28,67 +29,36 @@ #include "soh/resource/importer/scenecommand/SetLightListFactory.h" #include "soh/resource/importer/scenecommand/SetMeshFactory.h" -namespace LUS { - -std::shared_ptr -SceneFactory::ReadResource(std::shared_ptr initData, std::shared_ptr reader) { - if (SceneFactory::sceneCommandFactories.empty()) { - SceneFactory::sceneCommandFactories[LUS::SceneCommandID::SetLightingSettings] = std::make_shared(); - SceneFactory::sceneCommandFactories[LUS::SceneCommandID::SetWind] = std::make_shared(); - SceneFactory::sceneCommandFactories[LUS::SceneCommandID::SetExitList] = std::make_shared(); - SceneFactory::sceneCommandFactories[LUS::SceneCommandID::SetTimeSettings] = std::make_shared(); - SceneFactory::sceneCommandFactories[LUS::SceneCommandID::SetSkyboxModifier] = std::make_shared(); - SceneFactory::sceneCommandFactories[LUS::SceneCommandID::SetEchoSettings] = std::make_shared(); - SceneFactory::sceneCommandFactories[LUS::SceneCommandID::SetSoundSettings] = std::make_shared(); - SceneFactory::sceneCommandFactories[LUS::SceneCommandID::SetSkyboxSettings] = std::make_shared(); - SceneFactory::sceneCommandFactories[LUS::SceneCommandID::SetRoomBehavior] = std::make_shared(); - SceneFactory::sceneCommandFactories[LUS::SceneCommandID::SetCsCamera] = std::make_shared(); - SceneFactory::sceneCommandFactories[LUS::SceneCommandID::SetCameraSettings] = std::make_shared(); - SceneFactory::sceneCommandFactories[LUS::SceneCommandID::SetRoomList] = std::make_shared(); - SceneFactory::sceneCommandFactories[LUS::SceneCommandID::SetCollisionHeader] = std::make_shared(); - SceneFactory::sceneCommandFactories[LUS::SceneCommandID::SetEntranceList] = std::make_shared(); - SceneFactory::sceneCommandFactories[LUS::SceneCommandID::SetSpecialObjects] = std::make_shared(); - SceneFactory::sceneCommandFactories[LUS::SceneCommandID::SetObjectList] = std::make_shared(); - SceneFactory::sceneCommandFactories[LUS::SceneCommandID::SetStartPositionList] = std::make_shared(); - SceneFactory::sceneCommandFactories[LUS::SceneCommandID::SetActorList] = std::make_shared(); - SceneFactory::sceneCommandFactories[LUS::SceneCommandID::SetTransitionActorList] = std::make_shared(); - SceneFactory::sceneCommandFactories[LUS::SceneCommandID::EndMarker] = std::make_shared(); - SceneFactory::sceneCommandFactories[LUS::SceneCommandID::SetAlternateHeaders] = std::make_shared(); - SceneFactory::sceneCommandFactories[LUS::SceneCommandID::SetPathways] = std::make_shared(); - SceneFactory::sceneCommandFactories[LUS::SceneCommandID::SetCutscenes] = std::make_shared(); - SceneFactory::sceneCommandFactories[LUS::SceneCommandID::SetLightList] = std::make_shared(); - SceneFactory::sceneCommandFactories[LUS::SceneCommandID::SetMesh] = std::make_shared(); - } - - auto resource = std::make_shared(initData); - std::shared_ptr factory = nullptr; - - switch (resource->GetInitData()->ResourceVersion) { - case 0: - factory = std::make_shared(); - break; - } - - if (factory == nullptr) { - SPDLOG_ERROR("Failed to load Scene with version {}", resource->GetInitData()->ResourceVersion); - return nullptr; - } - - factory->ParseFileBinary(reader, resource); - - return resource; +namespace SOH { +ResourceFactoryBinarySceneV0::ResourceFactoryBinarySceneV0() { + sceneCommandFactories[SceneCommandID::SetLightingSettings] = std::make_shared(); + sceneCommandFactories[SceneCommandID::SetWind] = std::make_shared(); + sceneCommandFactories[SceneCommandID::SetExitList] = std::make_shared(); + sceneCommandFactories[SceneCommandID::SetTimeSettings] = std::make_shared(); + sceneCommandFactories[SceneCommandID::SetSkyboxModifier] = std::make_shared(); + sceneCommandFactories[SceneCommandID::SetEchoSettings] = std::make_shared(); + sceneCommandFactories[SceneCommandID::SetSoundSettings] = std::make_shared(); + sceneCommandFactories[SceneCommandID::SetSkyboxSettings] = std::make_shared(); + sceneCommandFactories[SceneCommandID::SetRoomBehavior] = std::make_shared(); + sceneCommandFactories[SceneCommandID::SetCsCamera] = std::make_shared(); + sceneCommandFactories[SceneCommandID::SetCameraSettings] = std::make_shared(); + sceneCommandFactories[SceneCommandID::SetRoomList] = std::make_shared(); + sceneCommandFactories[SceneCommandID::SetCollisionHeader] = std::make_shared(); + sceneCommandFactories[SceneCommandID::SetEntranceList] = std::make_shared(); + sceneCommandFactories[SceneCommandID::SetSpecialObjects] = std::make_shared(); + sceneCommandFactories[SceneCommandID::SetObjectList] = std::make_shared(); + sceneCommandFactories[SceneCommandID::SetStartPositionList] = std::make_shared(); + sceneCommandFactories[SceneCommandID::SetActorList] = std::make_shared(); + sceneCommandFactories[SceneCommandID::SetTransitionActorList] = std::make_shared(); + sceneCommandFactories[SceneCommandID::EndMarker] = std::make_shared(); + sceneCommandFactories[SceneCommandID::SetAlternateHeaders] = std::make_shared(); + sceneCommandFactories[SceneCommandID::SetPathways] = std::make_shared(); + sceneCommandFactories[SceneCommandID::SetCutscenes] = std::make_shared(); + sceneCommandFactories[SceneCommandID::SetLightList] = std::make_shared(); + sceneCommandFactories[SceneCommandID::SetMesh] = std::make_shared(); } -void SceneFactoryV0::ParseFileBinary(std::shared_ptr reader, - std::shared_ptr resource) -{ - std::shared_ptr scene = std::static_pointer_cast(resource); - ResourceVersionFactory::ParseFileBinary(reader, scene); - - ParseSceneCommands(scene, reader); -} - -void SceneFactoryV0::ParseSceneCommands(std::shared_ptr scene, std::shared_ptr reader) { +void ResourceFactoryBinarySceneV0::ParseSceneCommands(std::shared_ptr scene, std::shared_ptr reader) { uint32_t commandCount = reader->ReadUInt32(); scene->commands.reserve(commandCount); @@ -97,19 +67,19 @@ void SceneFactoryV0::ParseSceneCommands(std::shared_ptr scene, std::share } } -std::shared_ptr SceneFactoryV0::ParseSceneCommand(std::shared_ptr scene, - std::shared_ptr reader, uint32_t index) { +std::shared_ptr ResourceFactoryBinarySceneV0::ParseSceneCommand(std::shared_ptr scene, + std::shared_ptr reader, uint32_t index) { SceneCommandID cmdID = (SceneCommandID)reader->ReadInt32(); - reader->Seek(-sizeof(int32_t), SeekOffsetType::Current); + reader->Seek(-sizeof(int32_t), LUS::SeekOffsetType::Current); std::shared_ptr result = nullptr; - std::shared_ptr commandFactory = SceneFactory::sceneCommandFactories[cmdID]; + auto commandFactory = ResourceFactoryBinarySceneV0::sceneCommandFactories[cmdID]; if (commandFactory != nullptr) { - auto initData = std::make_shared(); + auto initData = std::make_shared(); initData->Id = scene->GetInitData()->Id; - initData->Type = static_cast(ResourceType::SOH_SceneCommand); + initData->Type = static_cast(SOH::ResourceType::SOH_SceneCommand); initData->Path = scene->GetInitData()->Path + "/SceneCommand" + std::to_string(index); initData->ResourceVersion = scene->GetInitData()->ResourceVersion; result = std::static_pointer_cast(commandFactory->ReadResource(initData, reader)); @@ -123,4 +93,16 @@ std::shared_ptr SceneFactoryV0::ParseSceneCommand(std::shared_ptr return result; } -} // namespace LUS +std::shared_ptr ResourceFactoryBinarySceneV0::ReadResource(std::shared_ptr file) { + if (!FileHasValidFormatAndReader(file)) { + return nullptr; + } + + auto scene = std::make_shared(file->InitData); + auto reader = std::get>(file->Reader); + + ParseSceneCommands(scene, reader); + + return scene; +}; +} // namespace SOH diff --git a/soh/soh/resource/importer/SceneFactory.h b/soh/soh/resource/importer/SceneFactory.h index 59fe08ddf..5dfed2739 100644 --- a/soh/soh/resource/importer/SceneFactory.h +++ b/soh/soh/resource/importer/SceneFactory.h @@ -4,26 +4,22 @@ #include "soh/resource/type/scenecommand/SceneCommand.h" #include "soh/resource/importer/scenecommand/SceneCommandFactory.h" #include "Resource.h" -#include "ResourceFactory.h" +#include "ResourceFactoryBinary.h" -namespace LUS { -class SceneFactory : public ResourceFactory { +namespace SOH { +class ResourceFactoryBinarySceneV0 : public LUS::ResourceFactoryBinary { public: - std::shared_ptr - ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; + ResourceFactoryBinarySceneV0(); + + std::shared_ptr ReadResource(std::shared_ptr file) override; + void ParseSceneCommands(std::shared_ptr scene, std::shared_ptr reader); // Doing something very similar to what we do on the ResourceLoader. // Eventually, scene commands should be moved up to the ResourceLoader as well. // They can not right now because the exporter does not give them a proper resource type enum value, // and the exporter does not export the commands with a proper OTR header. - static inline std::unordered_map> sceneCommandFactories; -}; - -class SceneFactoryV0 : public ResourceVersionFactory { - public: - void ParseFileBinary(std::shared_ptr reader, std::shared_ptr resource) override; - void ParseSceneCommands(std::shared_ptr scene, std::shared_ptr reader); + static inline std::unordered_map> sceneCommandFactories; protected: - std::shared_ptr ParseSceneCommand(std::shared_ptr scene, std::shared_ptr reader, uint32_t index); + std::shared_ptr ParseSceneCommand(std::shared_ptr scene, std::shared_ptr reader, uint32_t index); }; -}; // namespace LUS +} // namespace SOH diff --git a/soh/soh/resource/importer/SkeletonFactory.cpp b/soh/soh/resource/importer/SkeletonFactory.cpp index 2ce651dee..fedfda400 100644 --- a/soh/soh/resource/importer/SkeletonFactory.cpp +++ b/soh/soh/resource/importer/SkeletonFactory.cpp @@ -3,54 +3,14 @@ #include #include -namespace LUS { -std::shared_ptr -SkeletonFactory::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; - } - - if (factory == nullptr) { - SPDLOG_ERROR("Failed to load Skeleton with version {}", resource->GetInitData()->ResourceVersion); - return nullptr; - } - - factory->ParseFileBinary(reader, resource); - - return resource; -} - -std::shared_ptr -SkeletonFactory::ReadResourceXML(std::shared_ptr initData, tinyxml2::XMLElement *reader) { - auto resource = std::make_shared(initData); - std::shared_ptr factory = nullptr; - - switch (resource->GetInitData()->ResourceVersion) { - case 0: - factory = std::make_shared(); - break; - } - - if (factory == nullptr) { - SPDLOG_ERROR("Failed to load Skeleton with version {}", resource->GetInitData()->ResourceVersion); +namespace SOH { +std::shared_ptr ResourceFactoryBinarySkeletonV0::ReadResource(std::shared_ptr file) { + if (!FileHasValidFormatAndReader(file)) { return nullptr; } - factory->ParseFileXML(reader, resource); - - return resource; -} - -void SkeletonFactoryV0::ParseFileBinary(std::shared_ptr reader, - std::shared_ptr resource) -{ - std::shared_ptr skeleton = std::static_pointer_cast(resource); - ResourceVersionFactory::ParseFileBinary(reader, skeleton); + auto skeleton = std::make_shared(file->InitData); + auto reader = std::get>(file->Reader); skeleton->type = (SkeletonType)reader->ReadInt8(); skeleton->limbType = (LimbType)reader->ReadInt8(); @@ -66,17 +26,17 @@ void SkeletonFactoryV0::ParseFileBinary(std::shared_ptr reader, skeleton->limbTable.push_back(limbPath); } - if (skeleton->type == LUS::SkeletonType::Curve) { + if (skeleton->type == SkeletonType::Curve) { skeleton->skeletonData.skelCurveLimbList.limbCount = skeleton->limbCount; skeleton->curveLimbArray.reserve(skeleton->skeletonData.skelCurveLimbList.limbCount); - } else if (skeleton->type == LUS::SkeletonType::Flex) { + } else if (skeleton->type == SkeletonType::Flex) { skeleton->skeletonData.flexSkeletonHeader.dListCount = skeleton->dListCount; } - if (skeleton->type == LUS::SkeletonType::Normal) { + if (skeleton->type == SkeletonType::Normal) { skeleton->skeletonData.skeletonHeader.limbCount = skeleton->limbCount; skeleton->standardLimbArray.reserve(skeleton->skeletonData.skeletonHeader.limbCount); - } else if (skeleton->type == LUS::SkeletonType::Flex) { + } else if (skeleton->type == SkeletonType::Flex) { skeleton->skeletonData.flexSkeletonHeader.sh.limbCount = skeleton->limbCount; skeleton->standardLimbArray.reserve(skeleton->skeletonData.flexSkeletonHeader.sh.limbCount); } @@ -87,21 +47,29 @@ void SkeletonFactoryV0::ParseFileBinary(std::shared_ptr reader, skeleton->skeletonHeaderSegments.push_back(limb ? limb->GetRawPointer() : nullptr); } - if (skeleton->type == LUS::SkeletonType::Normal) { + if (skeleton->type == SkeletonType::Normal) { skeleton->skeletonData.skeletonHeader.segment = (void**)skeleton->skeletonHeaderSegments.data(); - } else if (skeleton->type == LUS::SkeletonType::Flex) { + } else if (skeleton->type == SkeletonType::Flex) { skeleton->skeletonData.flexSkeletonHeader.sh.segment = (void**)skeleton->skeletonHeaderSegments.data(); - } else if (skeleton->type == LUS::SkeletonType::Curve) { + } else if (skeleton->type == SkeletonType::Curve) { skeleton->skeletonData.skelCurveLimbList.limbs = (SkelCurveLimb**)skeleton->skeletonHeaderSegments.data(); } else { SPDLOG_ERROR("unknown skeleton type {}", (uint32_t)skeleton->type); } skeleton->skeletonData.skeletonHeader.skeletonType = (uint8_t)skeleton->type; + + return skeleton; } -void SkeletonFactoryV0::ParseFileXML(tinyxml2::XMLElement* reader, std::shared_ptr resource) -{ - std::shared_ptr skel = std::static_pointer_cast(resource); + +std::shared_ptr ResourceFactoryXMLSkeletonV0::ReadResource(std::shared_ptr file) { + if (!FileHasValidFormatAndReader(file)) { + return nullptr; + } + + auto skel = std::make_shared(file->InitData); + auto reader = std::get>(file->Reader)->FirstChildElement(); + auto child = reader->FirstChildElement(); skel->type = SkeletonType::Flex; // Default to Flex for legacy reasons if (reader->FindAttribute("Type")) { @@ -137,8 +105,6 @@ void SkeletonFactoryV0::ParseFileXML(tinyxml2::XMLElement* reader, std::shared_p skel->limbCount = reader->IntAttribute("LimbCount"); skel->dListCount = reader->IntAttribute("DisplayListCount"); - auto child = reader->FirstChildElement(); - while (child != nullptr) { std::string childName = child->Name(); @@ -157,6 +123,7 @@ void SkeletonFactoryV0::ParseFileXML(tinyxml2::XMLElement* reader, std::shared_p skel->skeletonData.flexSkeletonHeader.sh.segment = (void**)skel->skeletonHeaderSegments.data(); skel->skeletonData.flexSkeletonHeader.dListCount = skel->dListCount; skel->skeletonData.skeletonHeader.skeletonType = (uint8_t)skel->type; -} -} // namespace LUS + return skel; +} +} // namespace SOH diff --git a/soh/soh/resource/importer/SkeletonFactory.h b/soh/soh/resource/importer/SkeletonFactory.h index d64449393..5de02175f 100644 --- a/soh/soh/resource/importer/SkeletonFactory.h +++ b/soh/soh/resource/importer/SkeletonFactory.h @@ -1,23 +1,17 @@ #pragma once #include "Resource.h" -#include "ResourceFactory.h" +#include "ResourceFactoryBinary.h" +#include "ResourceFactoryXML.h" -namespace LUS { -class SkeletonFactory : public ResourceFactory -{ +namespace SOH { +class ResourceFactoryBinarySkeletonV0 : public LUS::ResourceFactoryBinary { public: - std::shared_ptr - ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; - std::shared_ptr - ReadResourceXML(std::shared_ptr initData, tinyxml2::XMLElement *reader) override; + std::shared_ptr ReadResource(std::shared_ptr file) override; }; -class SkeletonFactoryV0 : public ResourceVersionFactory -{ +class ResourceFactoryXMLSkeletonV0 : public LUS::ResourceFactoryXML { public: - void ParseFileBinary(std::shared_ptr reader, std::shared_ptr resource) override; - void ParseFileXML(tinyxml2::XMLElement* reader, std::shared_ptr resource) override; + std::shared_ptr ReadResource(std::shared_ptr file) override; }; -}; // namespace LUS - +} // namespace SOH diff --git a/soh/soh/resource/importer/SkeletonLimbFactory.cpp b/soh/soh/resource/importer/SkeletonLimbFactory.cpp index 7ca8ae1cc..15ba92281 100644 --- a/soh/soh/resource/importer/SkeletonLimbFactory.cpp +++ b/soh/soh/resource/importer/SkeletonLimbFactory.cpp @@ -3,54 +3,14 @@ #include "spdlog/spdlog.h" #include "libultraship/libultraship.h" -namespace LUS { -std::shared_ptr -SkeletonLimbFactory::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; - } - - if (factory == nullptr) { - SPDLOG_ERROR("Failed to load Skeleton Limb with version {}", resource->GetInitData()->ResourceVersion); - return nullptr; - } - - factory->ParseFileBinary(reader, resource); - - return resource; -} - -std::shared_ptr -SkeletonLimbFactory::ReadResourceXML(std::shared_ptr initData, tinyxml2::XMLElement *reader) { - auto resource = std::make_shared(initData); - std::shared_ptr factory = nullptr; - - switch (resource->GetInitData()->ResourceVersion) { - case 0: - factory = std::make_shared(); - break; - } - - if (factory == nullptr) { - SPDLOG_ERROR("Failed to load Skeleton Limb with version {}", resource->GetInitData()->ResourceVersion); +namespace SOH { +std::shared_ptr ResourceFactoryBinarySkeletonLimbV0::ReadResource(std::shared_ptr file) { + if (!FileHasValidFormatAndReader(file)) { return nullptr; } - factory->ParseFileXML(reader, resource); - - return resource; -} - -void LUS::SkeletonLimbFactoryV0::ParseFileBinary(std::shared_ptr reader, - std::shared_ptr resource) -{ - std::shared_ptr skeletonLimb = std::static_pointer_cast(resource); - ResourceVersionFactory::ParseFileBinary(reader, skeletonLimb); + auto skeletonLimb = std::make_shared(file->InitData); + auto reader = std::get>(file->Reader); skeletonLimb->limbType = (LimbType)reader->ReadInt8(); skeletonLimb->skinSegmentType = (ZLimbSkinType)reader->ReadInt8(); @@ -124,7 +84,7 @@ void LUS::SkeletonLimbFactoryV0::ParseFileBinary(std::shared_ptr r skeletonLimb->childIndex = reader->ReadUByte(); skeletonLimb->siblingIndex = reader->ReadUByte(); - if (skeletonLimb->limbType == LUS::LimbType::LOD) { + if (skeletonLimb->limbType == LimbType::LOD) { skeletonLimb->limbData.lodLimb.jointPos.x = skeletonLimb->transX; skeletonLimb->limbData.lodLimb.jointPos.y = skeletonLimb->transY; skeletonLimb->limbData.lodLimb.jointPos.z = skeletonLimb->transZ; @@ -144,7 +104,7 @@ void LUS::SkeletonLimbFactoryV0::ParseFileBinary(std::shared_ptr r } else { skeletonLimb->limbData.lodLimb.dLists[1] = nullptr; } - } else if (skeletonLimb->limbType == LUS::LimbType::Standard) { + } else if (skeletonLimb->limbType == LimbType::Standard) { skeletonLimb->limbData.standardLimb.jointPos.x = skeletonLimb->transX; skeletonLimb->limbData.standardLimb.jointPos.y = skeletonLimb->transY; skeletonLimb->limbData.standardLimb.jointPos.z = skeletonLimb->transZ; @@ -156,7 +116,7 @@ void LUS::SkeletonLimbFactoryV0::ParseFileBinary(std::shared_ptr r skeletonLimb->dListPtr = "__OTR__" + skeletonLimb->dListPtr; skeletonLimb->limbData.standardLimb.dList = (Gfx*)skeletonLimb->dListPtr.c_str(); } - } else if (skeletonLimb->limbType == LUS::LimbType::Curve) { + } else if (skeletonLimb->limbType == LimbType::Curve) { skeletonLimb->limbData.skelCurveLimb.firstChildIdx = skeletonLimb->childIndex; skeletonLimb->limbData.skelCurveLimb.nextLimbIdx = skeletonLimb->siblingIndex; skeletonLimb->limbData.skelCurveLimb.dList[0] = nullptr; @@ -171,31 +131,31 @@ void LUS::SkeletonLimbFactoryV0::ParseFileBinary(std::shared_ptr r skeletonLimb->dList2Ptr = "__OTR__" + skeletonLimb->dList2Ptr; skeletonLimb->limbData.skelCurveLimb.dList[1] = (Gfx*)skeletonLimb->dList2Ptr.c_str(); } - } else if (skeletonLimb->limbType == LUS::LimbType::Skin) { + } else if (skeletonLimb->limbType == LimbType::Skin) { skeletonLimb->limbData.skinLimb.jointPos.x = skeletonLimb->transX; skeletonLimb->limbData.skinLimb.jointPos.y = skeletonLimb->transY; skeletonLimb->limbData.skinLimb.jointPos.z = skeletonLimb->transZ; skeletonLimb->limbData.skinLimb.child = skeletonLimb->childIndex; skeletonLimb->limbData.skinLimb.sibling = skeletonLimb->siblingIndex; - if (skeletonLimb->skinSegmentType == LUS::ZLimbSkinType::SkinType_DList) { + if (skeletonLimb->skinSegmentType == ZLimbSkinType::SkinType_DList) { skeletonLimb->limbData.skinLimb.segmentType = static_cast(skeletonLimb->skinSegmentType); - } else if (skeletonLimb->skinSegmentType == LUS::ZLimbSkinType::SkinType_4) { + } else if (skeletonLimb->skinSegmentType == ZLimbSkinType::SkinType_4) { skeletonLimb->limbData.skinLimb.segmentType = 4; - } else if (skeletonLimb->skinSegmentType == LUS::ZLimbSkinType::SkinType_5) { + } else if (skeletonLimb->skinSegmentType == ZLimbSkinType::SkinType_5) { skeletonLimb->limbData.skinLimb.segmentType = 5; } else { skeletonLimb->limbData.skinLimb.segmentType = 0; } - if (skeletonLimb->skinSegmentType == LUS::ZLimbSkinType::SkinType_DList) { + if (skeletonLimb->skinSegmentType == ZLimbSkinType::SkinType_DList) { if (skeletonLimb->skinDList != "") { skeletonLimb->skinDList = "__OTR__" + skeletonLimb->skinDList; skeletonLimb->limbData.skinLimb.segment = (Gfx*)skeletonLimb->skinDList.c_str(); } else { skeletonLimb->limbData.skinLimb.segment = nullptr; } - } else if (skeletonLimb->skinSegmentType == LUS::ZLimbSkinType::SkinType_4) { + } else if (skeletonLimb->skinSegmentType == ZLimbSkinType::SkinType_4) { skeletonLimb->skinAnimLimbData.totalVtxCount = skeletonLimb->skinVtxCnt; skeletonLimb->skinAnimLimbData.limbModifCount = skeletonLimb->skinLimbModifCount; skeletonLimb->skinAnimLimbData.limbModifications = skeletonLimb->skinLimbModifArray.data(); @@ -220,10 +180,17 @@ void LUS::SkeletonLimbFactoryV0::ParseFileBinary(std::shared_ptr r skeletonLimb->limbData.skinLimb.segment = &skeletonLimb->skinAnimLimbData; } } + + return skeletonLimb; } -void SkeletonLimbFactoryV0::ParseFileXML(tinyxml2::XMLElement* reader, std::shared_ptr resource) -{ - std::shared_ptr skelLimb = std::static_pointer_cast(resource); + +std::shared_ptr ResourceFactoryXMLSkeletonLimbV0::ReadResource(std::shared_ptr file) { + if (!FileHasValidFormatAndReader(file)) { + return nullptr; + } + + auto skelLimb = std::make_shared(file->InitData); + auto reader = std::get>(file->Reader)->FirstChildElement(); std::string limbType = reader->Attribute("Type"); @@ -275,6 +242,7 @@ void SkeletonLimbFactoryV0::ParseFileXML(tinyxml2::XMLElement* reader, std::shar limbData.lodLimb.sibling = skelLimb->siblingIndex; // skelLimb->dList2Ptr = reader->Attribute("DisplayList2"); -} -} // namespace LUS + return skelLimb; +} +} // namespace SOH diff --git a/soh/soh/resource/importer/SkeletonLimbFactory.h b/soh/soh/resource/importer/SkeletonLimbFactory.h index 8480a0126..125dde2b8 100644 --- a/soh/soh/resource/importer/SkeletonLimbFactory.h +++ b/soh/soh/resource/importer/SkeletonLimbFactory.h @@ -1,23 +1,17 @@ #pragma once #include "Resource.h" -#include "ResourceFactory.h" +#include "ResourceFactoryBinary.h" +#include "ResourceFactoryXML.h" -namespace LUS { -class SkeletonLimbFactory : public ResourceFactory -{ +namespace SOH { +class ResourceFactoryBinarySkeletonLimbV0 : public LUS::ResourceFactoryBinary { public: - std::shared_ptr - ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; - std::shared_ptr - ReadResourceXML(std::shared_ptr initData, tinyxml2::XMLElement *reader) override; + std::shared_ptr ReadResource(std::shared_ptr file) override; }; -class SkeletonLimbFactoryV0 : public ResourceVersionFactory -{ +class ResourceFactoryXMLSkeletonLimbV0 : public LUS::ResourceFactoryXML { public: - void ParseFileBinary(std::shared_ptr reader, std::shared_ptr resource) override; - void ParseFileXML(tinyxml2::XMLElement* reader, std::shared_ptr resource) override; + std::shared_ptr ReadResource(std::shared_ptr file) override; }; -}; // namespace LUS - +} // namespace SOH diff --git a/soh/soh/resource/importer/TextFactory.cpp b/soh/soh/resource/importer/TextFactory.cpp index 314dd135c..89d229f80 100644 --- a/soh/soh/resource/importer/TextFactory.cpp +++ b/soh/soh/resource/importer/TextFactory.cpp @@ -2,74 +2,38 @@ #include "soh/resource/type/Text.h" #include "spdlog/spdlog.h" -namespace LUS { -std::shared_ptr -TextFactory::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; - default: - // VERSION NOT SUPPORTED - break; - } - - if (factory == nullptr) { - SPDLOG_ERROR("Failed to load Text with version {}", resource->GetInitData()->ResourceVersion); - return nullptr; - } - - factory->ParseFileBinary(reader, resource); - - return resource; -} - -std::shared_ptr -TextFactory::ReadResourceXML(std::shared_ptr initData, tinyxml2::XMLElement *reader) { - auto resource = std::make_shared(initData); - std::shared_ptr factory = nullptr; - - switch (resource->GetInitData()->ResourceVersion) { - case 0: - factory = std::make_shared(); - break; - } - - if (factory == nullptr) { - SPDLOG_ERROR("Failed to load Text with version {}", resource->GetInitData()->ResourceVersion); +namespace SOH { +std::shared_ptr ResourceFactoryBinaryTextV0::ReadResource(std::shared_ptr file) { + if (!FileHasValidFormatAndReader(file)) { return nullptr; } - factory->ParseFileXML(reader, resource); - - return resource; -} - -void LUS::TextFactoryV0::ParseFileBinary(std::shared_ptr reader, - std::shared_ptr resource) { - std::shared_ptr text = std::static_pointer_cast(resource); - ResourceVersionFactory::ParseFileBinary(reader, text); + auto text = std::make_shared(file->InitData); + auto reader = std::get>(file->Reader); uint32_t msgCount = reader->ReadUInt32(); text->messages.reserve(msgCount); for (uint32_t i = 0; i < msgCount; i++) { - MessageEntry entry; - entry.id = reader->ReadUInt16(); - entry.textboxType = reader->ReadUByte(); - entry.textboxYPos = reader->ReadUByte(); - entry.msg = reader->ReadString(); + MessageEntry entry; + entry.id = reader->ReadUInt16(); + entry.textboxType = reader->ReadUByte(); + entry.textboxYPos = reader->ReadUByte(); + entry.msg = reader->ReadString(); - text->messages.push_back(entry); + text->messages.push_back(entry); } -} -void TextFactoryV0::ParseFileXML(tinyxml2::XMLElement* reader, std::shared_ptr resource) { - std::shared_ptr txt = std::static_pointer_cast(resource); - auto child = reader->FirstChildElement(); + return text; +} + +std::shared_ptr ResourceFactoryXMLTextV0::ReadResource(std::shared_ptr file) { + if (!FileHasValidFormatAndReader(file)) { + return nullptr; + } + + auto txt = std::make_shared(file->InitData); + auto child = std::get>(file->Reader)->FirstChildElement()->FirstChildElement(); while (child != nullptr) { std::string childName = child->Name(); @@ -88,6 +52,7 @@ void TextFactoryV0::ParseFileXML(tinyxml2::XMLElement* reader, std::shared_ptrNextSiblingElement(); } -} -} // namespace LUS + return txt; +} +} // namespace SOH diff --git a/soh/soh/resource/importer/TextFactory.h b/soh/soh/resource/importer/TextFactory.h index 7a6ae2841..cb466204b 100644 --- a/soh/soh/resource/importer/TextFactory.h +++ b/soh/soh/resource/importer/TextFactory.h @@ -1,23 +1,17 @@ #pragma once #include "Resource.h" -#include "ResourceFactory.h" +#include "ResourceFactoryBinary.h" +#include "ResourceFactoryXML.h" -namespace LUS { -class TextFactory : public ResourceFactory -{ +namespace SOH { +class ResourceFactoryBinaryTextV0 : public LUS::ResourceFactoryBinary { public: - std::shared_ptr - ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; - std::shared_ptr - ReadResourceXML(std::shared_ptr initData, tinyxml2::XMLElement *reader) override; + std::shared_ptr ReadResource(std::shared_ptr file) override; }; -class TextFactoryV0 : public ResourceVersionFactory -{ +class ResourceFactoryXMLTextV0 : public LUS::ResourceFactoryXML { public: - void ParseFileBinary(std::shared_ptr reader, std::shared_ptr resource) override; - void ParseFileXML(tinyxml2::XMLElement* reader, std::shared_ptr resource) override; + std::shared_ptr ReadResource(std::shared_ptr file) override; }; -}; // namespace LUS - +} // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/EndMarkerFactory.cpp b/soh/soh/resource/importer/scenecommand/EndMarkerFactory.cpp index 4134e259a..ffcf17410 100644 --- a/soh/soh/resource/importer/scenecommand/EndMarkerFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/EndMarkerFactory.cpp @@ -2,37 +2,13 @@ #include "soh/resource/type/scenecommand/EndMarker.h" #include "spdlog/spdlog.h" -namespace LUS { -std::shared_ptr -EndMarkerFactory::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; - } - - if (factory == nullptr) { - SPDLOG_ERROR("Failed to load EndMarker with version {}", resource->GetInitData()->ResourceVersion); - return nullptr; - } - - factory->ParseFileBinary(reader, resource); - - return resource; -} - -void LUS::EndMarkerFactoryV0::ParseFileBinary(std::shared_ptr reader, - std::shared_ptr resource) -{ - std::shared_ptr endMarker = std::static_pointer_cast(resource); - ResourceVersionFactory::ParseFileBinary(reader, endMarker); +namespace SOH { +std::shared_ptr +EndMarkerFactory::ReadResource(std::shared_ptr initData, std::shared_ptr reader) { + auto endMarker = std::make_shared(initData); ReadCommandId(endMarker, reader); - - // This has no data. -} -} // namespace LUS + return endMarker; +} +} // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/EndMarkerFactory.h b/soh/soh/resource/importer/scenecommand/EndMarkerFactory.h index 8cd83b4f6..486aaa2fb 100644 --- a/soh/soh/resource/importer/scenecommand/EndMarkerFactory.h +++ b/soh/soh/resource/importer/scenecommand/EndMarkerFactory.h @@ -2,15 +2,9 @@ #include "soh/resource/importer/scenecommand/SceneCommandFactory.h" -namespace LUS { -class EndMarkerFactory : public SceneCommandFactory { +namespace SOH { +class EndMarkerFactory : public SceneCommandFactoryBinaryV0 { public: - std::shared_ptr - ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; + std::shared_ptr ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; }; - -class EndMarkerFactoryV0 : public SceneCommandVersionFactory { - public: - void ParseFileBinary(std::shared_ptr reader, std::shared_ptr resource) override; -}; -}; // namespace LUS +} // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SceneCommandFactory.cpp b/soh/soh/resource/importer/scenecommand/SceneCommandFactory.cpp index 9ad0ba2d3..9ab5d1611 100644 --- a/soh/soh/resource/importer/scenecommand/SceneCommandFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SceneCommandFactory.cpp @@ -2,9 +2,8 @@ #include "soh/resource/type/scenecommand/SceneCommand.h" #include "spdlog/spdlog.h" -namespace LUS { -void SceneCommandVersionFactory::ReadCommandId(std::shared_ptr command, std::shared_ptr reader) { +namespace SOH { +void SceneCommandFactoryBinaryV0::ReadCommandId(std::shared_ptr command, std::shared_ptr reader) { command->cmdId = (SceneCommandID)reader->ReadInt32(); } -} - \ No newline at end of file +} // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SceneCommandFactory.h b/soh/soh/resource/importer/scenecommand/SceneCommandFactory.h index d9a23818a..4cebc4a64 100644 --- a/soh/soh/resource/importer/scenecommand/SceneCommandFactory.h +++ b/soh/soh/resource/importer/scenecommand/SceneCommandFactory.h @@ -5,11 +5,12 @@ #include "ResourceFactory.h" #include "soh/resource/type/scenecommand/SceneCommand.h" -namespace LUS { -class SceneCommandFactory : public ResourceFactory {}; +namespace SOH { +class SceneCommandFactoryBinaryV0 { + public: + virtual std::shared_ptr ReadResource(std::shared_ptr initData, std::shared_ptr reader) = 0; -class SceneCommandVersionFactory : public ResourceVersionFactory { -protected: - void ReadCommandId(std::shared_ptr command, std::shared_ptr reader); + protected: + void ReadCommandId(std::shared_ptr command, std::shared_ptr reader); }; -}; // namespace LUS +} // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SetActorListFactory.cpp b/soh/soh/resource/importer/scenecommand/SetActorListFactory.cpp index 0451eb4c3..86deea193 100644 --- a/soh/soh/resource/importer/scenecommand/SetActorListFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetActorListFactory.cpp @@ -2,52 +2,30 @@ #include "soh/resource/type/scenecommand/SetActorList.h" #include "spdlog/spdlog.h" -namespace LUS { -std::shared_ptr -SetActorListFactory::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; - } - - if (factory == nullptr) - { - SPDLOG_ERROR("Failed to load SetActorList with version {}", resource->GetInitData()->ResourceVersion); - return nullptr; - } - - factory->ParseFileBinary(reader, resource); - - return resource; -} - -void LUS::SetActorListFactoryV0::ParseFileBinary(std::shared_ptr reader, - std::shared_ptr resource) { - std::shared_ptr setActorList = std::static_pointer_cast(resource); - ResourceVersionFactory::ParseFileBinary(reader, setActorList); +namespace SOH { +std::shared_ptr +SetActorListFactory::ReadResource(std::shared_ptr initData, std::shared_ptr reader) { + auto setActorList = std::make_shared(initData); ReadCommandId(setActorList, reader); setActorList->numActors = reader->ReadUInt32(); setActorList->actorList.reserve(setActorList->numActors); for (uint32_t i = 0; i < setActorList->numActors; i++) { - ActorEntry entry; + ActorEntry entry; - entry.id = reader->ReadUInt16(); - entry.pos.x = reader->ReadInt16(); - entry.pos.y = reader->ReadInt16(); - entry.pos.z = reader->ReadInt16(); - entry.rot.x = reader->ReadInt16(); - entry.rot.y = reader->ReadInt16(); - entry.rot.z = reader->ReadInt16(); - entry.params = reader->ReadUInt16(); + entry.id = reader->ReadUInt16(); + entry.pos.x = reader->ReadInt16(); + entry.pos.y = reader->ReadInt16(); + entry.pos.z = reader->ReadInt16(); + entry.rot.x = reader->ReadInt16(); + entry.rot.y = reader->ReadInt16(); + entry.rot.z = reader->ReadInt16(); + entry.params = reader->ReadUInt16(); setActorList->actorList.push_back(entry); } -} -} // namespace LUS + return setActorList; +} +} // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SetActorListFactory.h b/soh/soh/resource/importer/scenecommand/SetActorListFactory.h index 1f4c213bb..49a269cfe 100644 --- a/soh/soh/resource/importer/scenecommand/SetActorListFactory.h +++ b/soh/soh/resource/importer/scenecommand/SetActorListFactory.h @@ -2,15 +2,10 @@ #include "soh/resource/importer/scenecommand/SceneCommandFactory.h" -namespace LUS { -class SetActorListFactory : public SceneCommandFactory { +namespace SOH { +class SetActorListFactory : public SceneCommandFactoryBinaryV0 { public: - std::shared_ptr - ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; + std::shared_ptr + ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; }; - -class SetActorListFactoryV0 : public SceneCommandVersionFactory { - public: - void ParseFileBinary(std::shared_ptr reader, std::shared_ptr resource) override; -}; -}; // namespace LUS +} // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SetAlternateHeadersFactory.cpp b/soh/soh/resource/importer/scenecommand/SetAlternateHeadersFactory.cpp index 5258d970b..833d0af8c 100644 --- a/soh/soh/resource/importer/scenecommand/SetAlternateHeadersFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetAlternateHeadersFactory.cpp @@ -3,47 +3,24 @@ #include "spdlog/spdlog.h" #include "libultraship/libultraship.h" -namespace LUS { -std::shared_ptr SetAlternateHeadersFactory::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; - } - - if (factory == nullptr) - { - SPDLOG_ERROR("Failed to load SetAlternateHeaders with version {}", resource->GetInitData()->ResourceVersion); - return nullptr; - } - - factory->ParseFileBinary(reader, resource); - - return resource; -} - -void LUS::SetAlternateHeadersFactoryV0::ParseFileBinary(std::shared_ptr reader, - std::shared_ptr resource) -{ - std::shared_ptr setAlternateHeaders = std::static_pointer_cast(resource); - ResourceVersionFactory::ParseFileBinary(reader, setAlternateHeaders); +namespace SOH { +std::shared_ptr SetAlternateHeadersFactory::ReadResource(std::shared_ptr initData, + std::shared_ptr reader) { + auto setAlternateHeaders = std::make_shared(initData); ReadCommandId(setAlternateHeaders, reader); setAlternateHeaders->numHeaders = reader->ReadUInt32(); setAlternateHeaders->headers.reserve(setAlternateHeaders->numHeaders); for (uint32_t i = 0; i < setAlternateHeaders->numHeaders; i++) { - auto headerName = reader->ReadString(); - if (!headerName.empty()) { - setAlternateHeaders->headers.push_back(std::static_pointer_cast(LUS::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(headerName.c_str()))); - } else { - setAlternateHeaders->headers.push_back(nullptr); - } + auto headerName = reader->ReadString(); + if (!headerName.empty()) { + setAlternateHeaders->headers.push_back(std::static_pointer_cast(LUS::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(headerName.c_str()))); + } else { + setAlternateHeaders->headers.push_back(nullptr); + } } -} -} // namespace LUS + return setAlternateHeaders; +} +} // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SetAlternateHeadersFactory.h b/soh/soh/resource/importer/scenecommand/SetAlternateHeadersFactory.h index a534c4392..2bc430c0b 100644 --- a/soh/soh/resource/importer/scenecommand/SetAlternateHeadersFactory.h +++ b/soh/soh/resource/importer/scenecommand/SetAlternateHeadersFactory.h @@ -2,15 +2,10 @@ #include "soh/resource/importer/scenecommand/SceneCommandFactory.h" -namespace LUS { -class SetAlternateHeadersFactory : public SceneCommandFactory { +namespace SOH { +class SetAlternateHeadersFactory : public SceneCommandFactoryBinaryV0 { public: - std::shared_ptr - ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; + std::shared_ptr + ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; }; - -class SetAlternateHeadersFactoryV0 : public SceneCommandVersionFactory { - public: - void ParseFileBinary(std::shared_ptr reader, std::shared_ptr resource) override; -}; -}; // namespace LUS +} // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SetCameraSettingsFactory.cpp b/soh/soh/resource/importer/scenecommand/SetCameraSettingsFactory.cpp index 14b332d2a..7e2911a17 100644 --- a/soh/soh/resource/importer/scenecommand/SetCameraSettingsFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetCameraSettingsFactory.cpp @@ -2,38 +2,16 @@ #include "soh/resource/type/scenecommand/SetCameraSettings.h" #include "spdlog/spdlog.h" -namespace LUS { -std::shared_ptr SetCameraSettingsFactory::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; - } - - if (factory == nullptr) { - SPDLOG_ERROR("Failed to load SetCameraSettings with version {}", resource->GetInitData()->ResourceVersion); - return nullptr; - } - - factory->ParseFileBinary(reader, resource); - - return resource; -} - -void LUS::SetCameraSettingsFactoryV0::ParseFileBinary(std::shared_ptr reader, - std::shared_ptr resource) -{ - std::shared_ptr setCameraSettings = std::static_pointer_cast(resource); - ResourceVersionFactory::ParseFileBinary(reader, setCameraSettings); +namespace SOH { +std::shared_ptr SetCameraSettingsFactory::ReadResource(std::shared_ptr initData, + std::shared_ptr reader) { + auto setCameraSettings = std::make_shared(initData); ReadCommandId(setCameraSettings, reader); setCameraSettings->settings.cameraMovement = reader->ReadInt8(); setCameraSettings->settings.worldMapArea = reader->ReadInt32(); -} -} // namespace LUS + return setCameraSettings; +} +} // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SetCameraSettingsFactory.h b/soh/soh/resource/importer/scenecommand/SetCameraSettingsFactory.h index ec4dc9e42..2f1db272f 100644 --- a/soh/soh/resource/importer/scenecommand/SetCameraSettingsFactory.h +++ b/soh/soh/resource/importer/scenecommand/SetCameraSettingsFactory.h @@ -2,15 +2,10 @@ #include "soh/resource/importer/scenecommand/SceneCommandFactory.h" -namespace LUS { -class SetCameraSettingsFactory : public SceneCommandFactory { +namespace SOH { +class SetCameraSettingsFactory : public SceneCommandFactoryBinaryV0 { public: - std::shared_ptr - ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; + std::shared_ptr + ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; }; - -class SetCameraSettingsFactoryV0 : public SceneCommandVersionFactory { - public: - void ParseFileBinary(std::shared_ptr reader, std::shared_ptr resource) override; -}; -}; // namespace LUS +} // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SetCollisionHeaderFactory.cpp b/soh/soh/resource/importer/scenecommand/SetCollisionHeaderFactory.cpp index e1c113ba3..bb83dc57b 100644 --- a/soh/soh/resource/importer/scenecommand/SetCollisionHeaderFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetCollisionHeaderFactory.cpp @@ -3,37 +3,16 @@ #include "libultraship/libultraship.h" #include "spdlog/spdlog.h" -namespace LUS { -std::shared_ptr SetCollisionHeaderFactory::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; - } - - if (factory == nullptr) { - SPDLOG_ERROR("Failed to load SetCollisionHeader with version {}", resource->GetInitData()->ResourceVersion); - return nullptr; - } - - factory->ParseFileBinary(reader, resource); - - return resource; -} - -void LUS::SetCollisionHeaderFactoryV0::ParseFileBinary(std::shared_ptr reader, - std::shared_ptr resource) { - std::shared_ptr setCollisionHeader = std::static_pointer_cast(resource); - ResourceVersionFactory::ParseFileBinary(reader, setCollisionHeader); +namespace SOH { +std::shared_ptr SetCollisionHeaderFactory::ReadResource(std::shared_ptr initData, + std::shared_ptr reader) { + auto setCollisionHeader = std::make_shared(initData); ReadCommandId(setCollisionHeader, reader); setCollisionHeader->fileName = reader->ReadString(); setCollisionHeader->collisionHeader = std::static_pointer_cast(LUS::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(setCollisionHeader->fileName.c_str())); -} -} // namespace LUS + return setCollisionHeader; +} +} // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SetCollisionHeaderFactory.h b/soh/soh/resource/importer/scenecommand/SetCollisionHeaderFactory.h index 96c6ff0a1..b80ee34b4 100644 --- a/soh/soh/resource/importer/scenecommand/SetCollisionHeaderFactory.h +++ b/soh/soh/resource/importer/scenecommand/SetCollisionHeaderFactory.h @@ -2,15 +2,10 @@ #include "soh/resource/importer/scenecommand/SceneCommandFactory.h" -namespace LUS { -class SetCollisionHeaderFactory : public SceneCommandFactory { +namespace SOH { +class SetCollisionHeaderFactory : public SceneCommandFactoryBinaryV0 { public: - std::shared_ptr - ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; + std::shared_ptr + ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; }; - -class SetCollisionHeaderFactoryV0 : public SceneCommandVersionFactory { - public: - void ParseFileBinary(std::shared_ptr reader, std::shared_ptr resource) override; -}; -}; // namespace LUS +} // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SetCsCameraFactory.cpp b/soh/soh/resource/importer/scenecommand/SetCsCameraFactory.cpp index d24e3b2c3..84c277989 100644 --- a/soh/soh/resource/importer/scenecommand/SetCsCameraFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetCsCameraFactory.cpp @@ -2,32 +2,10 @@ #include "soh/resource/type/scenecommand/SetCsCamera.h" #include "spdlog/spdlog.h" -namespace LUS { -std::shared_ptr -SetCsCameraFactory::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; - } - - if (factory == nullptr) { - SPDLOG_ERROR("Failed to load SetCsCamera with version {}", resource->GetInitData()->ResourceVersion); - return nullptr; - } - - factory->ParseFileBinary(reader, resource); - - return resource; -} - -void LUS::SetCsCameraFactoryV0::ParseFileBinary(std::shared_ptr reader, - std::shared_ptr resource) { - std::shared_ptr setCsCamera = std::static_pointer_cast(resource); - ResourceVersionFactory::ParseFileBinary(reader, setCsCamera); +namespace SOH { +std::shared_ptr +SetCsCameraFactory::ReadResource(std::shared_ptr initData, std::shared_ptr reader) { + auto setCsCamera = std::make_shared(initData); ReadCommandId(setCsCamera, reader); @@ -35,6 +13,7 @@ void LUS::SetCsCameraFactoryV0::ParseFileBinary(std::shared_ptr re reader->ReadInt32(); // segOffset // OTRTODO: FINISH! -} -} // namespace LUS + return setCsCamera; +} +} // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SetCsCameraFactory.h b/soh/soh/resource/importer/scenecommand/SetCsCameraFactory.h index ec74ed58e..08dc8e3c3 100644 --- a/soh/soh/resource/importer/scenecommand/SetCsCameraFactory.h +++ b/soh/soh/resource/importer/scenecommand/SetCsCameraFactory.h @@ -2,15 +2,10 @@ #include "soh/resource/importer/scenecommand/SceneCommandFactory.h" -namespace LUS { -class SetCsCameraFactory : public SceneCommandFactory { +namespace SOH { +class SetCsCameraFactory : public SceneCommandFactoryBinaryV0 { public: - std::shared_ptr - ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; + std::shared_ptr + ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; }; - -class SetCsCameraFactoryV0 : public SceneCommandVersionFactory { - public: - void ParseFileBinary(std::shared_ptr reader, std::shared_ptr resource) override; -}; -}; // namespace LUS +} // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SetCutscenesFactory.cpp b/soh/soh/resource/importer/scenecommand/SetCutscenesFactory.cpp index db9392e7d..30f72d168 100644 --- a/soh/soh/resource/importer/scenecommand/SetCutscenesFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetCutscenesFactory.cpp @@ -3,38 +3,16 @@ #include #include "spdlog/spdlog.h" -namespace LUS { -std::shared_ptr -SetCutscenesFactory::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; - } - - if (factory == nullptr) - { - SPDLOG_ERROR("Failed to load SetCutscenes with version {}", resource->GetInitData()->ResourceVersion); - return nullptr; - } - - factory->ParseFileBinary(reader, resource); - - return resource; -} - -void LUS::SetCutscenesFactoryV0::ParseFileBinary(std::shared_ptr reader, - std::shared_ptr resource) { - std::shared_ptr setCutscenes = std::static_pointer_cast(resource); - ResourceVersionFactory::ParseFileBinary(reader, setCutscenes); +namespace SOH { +std::shared_ptr +SetCutscenesFactory::ReadResource(std::shared_ptr initData, std::shared_ptr reader) { + auto setCutscenes = std::make_shared(initData); ReadCommandId(setCutscenes, reader); setCutscenes->fileName = reader->ReadString(); setCutscenes->cutscene = std::static_pointer_cast(LUS::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(setCutscenes->fileName.c_str())); -} -} // namespace LUS + return setCutscenes; +} +} // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SetCutscenesFactory.h b/soh/soh/resource/importer/scenecommand/SetCutscenesFactory.h index 7963036ba..bbbe38c98 100644 --- a/soh/soh/resource/importer/scenecommand/SetCutscenesFactory.h +++ b/soh/soh/resource/importer/scenecommand/SetCutscenesFactory.h @@ -2,15 +2,10 @@ #include "soh/resource/importer/scenecommand/SceneCommandFactory.h" -namespace LUS { -class SetCutscenesFactory : public SceneCommandFactory { +namespace SOH { +class SetCutscenesFactory : public SceneCommandFactoryBinaryV0 { public: - std::shared_ptr - ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; + std::shared_ptr + ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; }; - -class SetCutscenesFactoryV0 : public SceneCommandVersionFactory { - public: - void ParseFileBinary(std::shared_ptr reader, std::shared_ptr resource) override; -}; -}; // namespace LUS +} // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SetEchoSettingsFactory.cpp b/soh/soh/resource/importer/scenecommand/SetEchoSettingsFactory.cpp index 530bcb8af..e9c3381cb 100644 --- a/soh/soh/resource/importer/scenecommand/SetEchoSettingsFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetEchoSettingsFactory.cpp @@ -2,37 +2,15 @@ #include "soh/resource/type/scenecommand/SetEchoSettings.h" #include "spdlog/spdlog.h" -namespace LUS { -std::shared_ptr -SetEchoSettingsFactory::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; - } - - if (factory == nullptr) { - SPDLOG_ERROR("Failed to load SetEchoSettings with version {}", resource->GetInitData()->ResourceVersion); - return nullptr; - } - - factory->ParseFileBinary(reader, resource); - - return resource; -} - -void LUS::SetEchoSettingsFactoryV0::ParseFileBinary(std::shared_ptr reader, - std::shared_ptr resource) -{ - std::shared_ptr setEchoSettings = std::static_pointer_cast(resource); - ResourceVersionFactory::ParseFileBinary(reader, setEchoSettings); +namespace SOH { +std::shared_ptr +SetEchoSettingsFactory::ReadResource(std::shared_ptr initData, std::shared_ptr reader) { + auto setEchoSettings = std::make_shared(initData); ReadCommandId(setEchoSettings, reader); setEchoSettings->settings.echo = reader->ReadInt8(); -} -} // namespace LUS + return setEchoSettings; +} +} // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SetEchoSettingsFactory.h b/soh/soh/resource/importer/scenecommand/SetEchoSettingsFactory.h index 90bf3222f..99bda6eae 100644 --- a/soh/soh/resource/importer/scenecommand/SetEchoSettingsFactory.h +++ b/soh/soh/resource/importer/scenecommand/SetEchoSettingsFactory.h @@ -2,15 +2,10 @@ #include "soh/resource/importer/scenecommand/SceneCommandFactory.h" -namespace LUS { -class SetEchoSettingsFactory : public SceneCommandFactory { +namespace SOH { +class SetEchoSettingsFactory : public SceneCommandFactoryBinaryV0 { public: - std::shared_ptr - ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; + std::shared_ptr + ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; }; - -class SetEchoSettingsFactoryV0 : public SceneCommandVersionFactory { - public: - void ParseFileBinary(std::shared_ptr reader, std::shared_ptr resource) override; -}; -}; // namespace LUS +} // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SetEntranceListFactory.cpp b/soh/soh/resource/importer/scenecommand/SetEntranceListFactory.cpp index 0fd841278..766bb82da 100644 --- a/soh/soh/resource/importer/scenecommand/SetEntranceListFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetEntranceListFactory.cpp @@ -2,32 +2,10 @@ #include "soh/resource/type/scenecommand/SetEntranceList.h" #include "spdlog/spdlog.h" -namespace LUS { -std::shared_ptr -SetEntranceListFactory::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; - } - - if (factory == nullptr) { - SPDLOG_ERROR("Failed to load SetEntranceListList with version {}", resource->GetInitData()->ResourceVersion); - return nullptr; - } - - factory->ParseFileBinary(reader, resource); - - return resource; -} - -void LUS::SetEntranceListFactoryV0::ParseFileBinary(std::shared_ptr reader, - std::shared_ptr resource) { - std::shared_ptr setEntranceList = std::static_pointer_cast(resource); - ResourceVersionFactory::ParseFileBinary(reader, setEntranceList); +namespace SOH { +std::shared_ptr +SetEntranceListFactory::ReadResource(std::shared_ptr initData, std::shared_ptr reader) { + auto setEntranceList = std::make_shared(initData); ReadCommandId(setEntranceList, reader); @@ -41,6 +19,7 @@ void LUS::SetEntranceListFactoryV0::ParseFileBinary(std::shared_ptrentrances.push_back(entranceEntry); } -} -} // namespace LUS + return setEntranceList; +} +} // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SetEntranceListFactory.h b/soh/soh/resource/importer/scenecommand/SetEntranceListFactory.h index ce20db4f7..35b7fba62 100644 --- a/soh/soh/resource/importer/scenecommand/SetEntranceListFactory.h +++ b/soh/soh/resource/importer/scenecommand/SetEntranceListFactory.h @@ -2,15 +2,10 @@ #include "soh/resource/importer/scenecommand/SceneCommandFactory.h" -namespace LUS { -class SetEntranceListFactory : public SceneCommandFactory { +namespace SOH { +class SetEntranceListFactory : public SceneCommandFactoryBinaryV0 { public: - std::shared_ptr - ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; + std::shared_ptr + ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; }; - -class SetEntranceListFactoryV0 : public SceneCommandVersionFactory { - public: - void ParseFileBinary(std::shared_ptr reader, std::shared_ptr resource) override; -}; -}; // namespace LUS +} // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SetExitListFactory.cpp b/soh/soh/resource/importer/scenecommand/SetExitListFactory.cpp index 04ed0c56b..5fef9d096 100644 --- a/soh/soh/resource/importer/scenecommand/SetExitListFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetExitListFactory.cpp @@ -2,32 +2,10 @@ #include "soh/resource/type/scenecommand/SetExitList.h" #include "spdlog/spdlog.h" -namespace LUS { -std::shared_ptr -SetExitListFactory::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; - } - - if (factory == nullptr) { - SPDLOG_ERROR("Failed to load SetExitList with version {}", resource->GetInitData()->ResourceVersion); - return nullptr; - } - - factory->ParseFileBinary(reader, resource); - - return resource; -} - -void LUS::SetExitListFactoryV0::ParseFileBinary(std::shared_ptr reader, - std::shared_ptr resource) { - std::shared_ptr setExitList = std::static_pointer_cast(resource); - ResourceVersionFactory::ParseFileBinary(reader, setExitList); +namespace SOH { +std::shared_ptr +SetExitListFactory::ReadResource(std::shared_ptr initData, std::shared_ptr reader) { + auto setExitList = std::make_shared( initData); ReadCommandId(setExitList, reader); @@ -36,6 +14,7 @@ void LUS::SetExitListFactoryV0::ParseFileBinary(std::shared_ptr re for (uint32_t i = 0; i < setExitList->numExits; i++) { setExitList->exits.push_back(reader->ReadUInt16()); } -} -} // namespace LUS + return setExitList; +} +} // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SetExitListFactory.h b/soh/soh/resource/importer/scenecommand/SetExitListFactory.h index 351ebe7ca..d82e8f04a 100644 --- a/soh/soh/resource/importer/scenecommand/SetExitListFactory.h +++ b/soh/soh/resource/importer/scenecommand/SetExitListFactory.h @@ -2,15 +2,10 @@ #include "soh/resource/importer/scenecommand/SceneCommandFactory.h" -namespace LUS { -class SetExitListFactory : public SceneCommandFactory { +namespace SOH { +class SetExitListFactory : public SceneCommandFactoryBinaryV0 { public: - std::shared_ptr - ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; + std::shared_ptr + ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; }; - -class SetExitListFactoryV0 : public SceneCommandVersionFactory { - public: - void ParseFileBinary(std::shared_ptr reader, std::shared_ptr resource) override; -}; -}; // namespace LUS +} // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SetLightListFactory.cpp b/soh/soh/resource/importer/scenecommand/SetLightListFactory.cpp index 2d2a9afe4..2d05631cd 100644 --- a/soh/soh/resource/importer/scenecommand/SetLightListFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetLightListFactory.cpp @@ -2,34 +2,10 @@ #include "soh/resource/type/scenecommand/SetLightList.h" #include "spdlog/spdlog.h" -namespace LUS { -std::shared_ptr -SetLightListFactory::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; - } - - if (factory == nullptr) - { - SPDLOG_ERROR("Failed to load SetLightList with version {}", resource->GetInitData()->ResourceVersion); - return nullptr; - } - - factory->ParseFileBinary(reader, resource); - - return resource; -} - -void LUS::SetLightListFactoryV0::ParseFileBinary(std::shared_ptr reader, - std::shared_ptr resource) -{ - std::shared_ptr setLightList = std::static_pointer_cast(resource); - ResourceVersionFactory::ParseFileBinary(reader, setLightList); +namespace SOH { +std::shared_ptr +SetLightListFactory::ReadResource(std::shared_ptr initData, std::shared_ptr reader) { + auto setLightList = std::make_shared(initData); ReadCommandId(setLightList, reader); @@ -40,7 +16,7 @@ void LUS::SetLightListFactoryV0::ParseFileBinary(std::shared_ptr r light.type = reader->ReadUByte(); - light.params.point.x = reader->ReadInt16(); + light.params.point.x = reader->ReadInt16(); light.params.point.y = reader->ReadInt16(); light.params.point.z = reader->ReadInt16(); @@ -49,10 +25,11 @@ void LUS::SetLightListFactoryV0::ParseFileBinary(std::shared_ptr r light.params.point.color[2] = reader->ReadUByte(); // b light.params.point.drawGlow = reader->ReadUByte(); - light.params.point.radius = reader->ReadInt16(); + light.params.point.radius = reader->ReadInt16(); setLightList->lightList.push_back(light); } -} -} // namespace LUS + return setLightList; +} +} // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SetLightListFactory.h b/soh/soh/resource/importer/scenecommand/SetLightListFactory.h index 24292a289..1c4a6e9dc 100644 --- a/soh/soh/resource/importer/scenecommand/SetLightListFactory.h +++ b/soh/soh/resource/importer/scenecommand/SetLightListFactory.h @@ -2,15 +2,10 @@ #include "soh/resource/importer/scenecommand/SceneCommandFactory.h" -namespace LUS { -class SetLightListFactory : public SceneCommandFactory { +namespace SOH { +class SetLightListFactory : public SceneCommandFactoryBinaryV0 { public: - std::shared_ptr - ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; + std::shared_ptr + ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; }; - -class SetLightListFactoryV0 : public SceneCommandVersionFactory { - public: - void ParseFileBinary(std::shared_ptr reader, std::shared_ptr resource) override; -}; -}; // namespace LUS +} // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SetLightingSettingsFactory.cpp b/soh/soh/resource/importer/scenecommand/SetLightingSettingsFactory.cpp index 3fdedd0e4..d0a7b89d5 100644 --- a/soh/soh/resource/importer/scenecommand/SetLightingSettingsFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetLightingSettingsFactory.cpp @@ -2,33 +2,10 @@ #include "soh/resource/type/scenecommand/SetLightingSettings.h" #include "spdlog/spdlog.h" -namespace LUS { -std::shared_ptr SetLightingSettingsFactory::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; - } - - if (factory == nullptr) { - SPDLOG_ERROR("Failed to load SetLightingSettings with version {}", resource->GetInitData()->ResourceVersion); - return nullptr; - } - - factory->ParseFileBinary(reader, resource); - - return resource; -} - -void LUS::SetLightingSettingsFactoryV0::ParseFileBinary(std::shared_ptr reader, - std::shared_ptr resource) -{ - std::shared_ptr setLightingSettings = std::static_pointer_cast(resource); - ResourceVersionFactory::ParseFileBinary(reader, setLightingSettings); +namespace SOH { +std::shared_ptr SetLightingSettingsFactory::ReadResource(std::shared_ptr initData, + std::shared_ptr reader) { + auto setLightingSettings = std::make_shared(initData); ReadCommandId(setLightingSettings, reader); @@ -65,6 +42,7 @@ void LUS::SetLightingSettingsFactoryV0::ParseFileBinary(std::shared_ptrReadUInt16(); setLightingSettings->settings.push_back(lightSettings); } -} -} // namespace LUS + return setLightingSettings; +} +} // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SetLightingSettingsFactory.h b/soh/soh/resource/importer/scenecommand/SetLightingSettingsFactory.h index 78a624ca6..df25600e2 100644 --- a/soh/soh/resource/importer/scenecommand/SetLightingSettingsFactory.h +++ b/soh/soh/resource/importer/scenecommand/SetLightingSettingsFactory.h @@ -2,15 +2,10 @@ #include "soh/resource/importer/scenecommand/SceneCommandFactory.h" -namespace LUS { -class SetLightingSettingsFactory : public SceneCommandFactory { +namespace SOH { +class SetLightingSettingsFactory : public SceneCommandFactoryBinaryV0 { public: - std::shared_ptr - ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; + std::shared_ptr + ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; }; - -class SetLightingSettingsFactoryV0 : public SceneCommandVersionFactory { - public: - void ParseFileBinary(std::shared_ptr reader, std::shared_ptr resource) override; -}; -}; // namespace LUS +} // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SetMeshFactory.cpp b/soh/soh/resource/importer/scenecommand/SetMeshFactory.cpp index 1398641a7..8c17ecc07 100644 --- a/soh/soh/resource/importer/scenecommand/SetMeshFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetMeshFactory.cpp @@ -3,34 +3,10 @@ #include "spdlog/spdlog.h" #include "libultraship/libultraship.h" -namespace LUS { -std::shared_ptr -SetMeshFactory::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; - } - - if (factory == nullptr) - { - SPDLOG_ERROR("Failed to load SetMesh with version {}", resource->GetInitData()->ResourceVersion); - return nullptr; - } - - factory->ParseFileBinary(reader, resource); - - return resource; -} - -void LUS::SetMeshFactoryV0::ParseFileBinary(std::shared_ptr reader, - std::shared_ptr resource) -{ - std::shared_ptr setMesh = std::static_pointer_cast(resource); - ResourceVersionFactory::ParseFileBinary(reader, setMesh); +namespace SOH { +std::shared_ptr +SetMeshFactory::ReadResource(std::shared_ptr initData, std::shared_ptr reader) { + auto setMesh = std::make_shared(initData); ReadCommandId(setMesh, reader); @@ -143,10 +119,10 @@ void LUS::SetMeshFactoryV0::ParseFileBinary(std::shared_ptr reader std::string meshOpa = reader->ReadString(); std::string meshXlu = reader->ReadString(); - auto opaRes = LUS::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(meshOpa.c_str()); - auto xluRes = LUS::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(meshXlu.c_str()); - dlist.opa = meshOpa != "" ? (Gfx*)(opaRes ? opaRes->GetRawPointer() : nullptr) : 0; - dlist.xlu = meshXlu != "" ? (Gfx*)(xluRes ? xluRes->GetRawPointer() : nullptr) : 0; + auto opaRes = meshOpa != "" ? LUS::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(meshOpa.c_str()) : nullptr; + auto xluRes = meshXlu != "" ? LUS::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(meshXlu.c_str()) : nullptr; + dlist.opa = (Gfx*)(opaRes ? opaRes->GetRawPointer() : nullptr); + dlist.xlu = (Gfx*)(xluRes ? xluRes->GetRawPointer() : nullptr); setMesh->dlists2.push_back(dlist); } else { @@ -164,6 +140,7 @@ void LUS::SetMeshFactoryV0::ParseFileBinary(std::shared_ptr reader } else { SPDLOG_ERROR("Tried to load mesh in SetMesh scene header with type that doesn't exist: {}", setMesh->meshHeader.base.type); } -} -} // namespace LUS + return setMesh; +} +} // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SetMeshFactory.h b/soh/soh/resource/importer/scenecommand/SetMeshFactory.h index 8ca086d43..a912bdd37 100644 --- a/soh/soh/resource/importer/scenecommand/SetMeshFactory.h +++ b/soh/soh/resource/importer/scenecommand/SetMeshFactory.h @@ -2,15 +2,10 @@ #include "soh/resource/importer/scenecommand/SceneCommandFactory.h" -namespace LUS { -class SetMeshFactory : public SceneCommandFactory { +namespace SOH { +class SetMeshFactory : public SceneCommandFactoryBinaryV0 { public: - std::shared_ptr - ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; + std::shared_ptr + ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; }; - -class SetMeshFactoryV0 : public SceneCommandVersionFactory { - public: - void ParseFileBinary(std::shared_ptr reader, std::shared_ptr resource) override; -}; -}; // namespace LUS +} // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SetObjectListFactory.cpp b/soh/soh/resource/importer/scenecommand/SetObjectListFactory.cpp index 27082f6e7..b84befb3b 100644 --- a/soh/soh/resource/importer/scenecommand/SetObjectListFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetObjectListFactory.cpp @@ -2,33 +2,10 @@ #include "soh/resource/type/scenecommand/SetObjectList.h" #include "spdlog/spdlog.h" -namespace LUS { -std::shared_ptr -SetObjectListFactory::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; - } - - if (factory == nullptr) { - SPDLOG_ERROR("Failed to load SetObjectList with version {}", resource->GetInitData()->ResourceVersion); - return nullptr; - } - - factory->ParseFileBinary(reader, resource); - - return resource; -} - -void LUS::SetObjectListFactoryV0::ParseFileBinary(std::shared_ptr reader, - std::shared_ptr resource) -{ - std::shared_ptr setObjectList = std::static_pointer_cast(resource); - ResourceVersionFactory::ParseFileBinary(reader, setObjectList); +namespace SOH { +std::shared_ptr +SetObjectListFactory::ReadResource(std::shared_ptr initData, std::shared_ptr reader) { + auto setObjectList = std::make_shared(initData); ReadCommandId(setObjectList, reader); @@ -37,6 +14,7 @@ void LUS::SetObjectListFactoryV0::ParseFileBinary(std::shared_ptr for (uint32_t i = 0; i < setObjectList->numObjects; i++) { setObjectList->objects.push_back(reader->ReadUInt16()); } -} -} // namespace LUS + return setObjectList; +} +} // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SetObjectListFactory.h b/soh/soh/resource/importer/scenecommand/SetObjectListFactory.h index 65725bfb2..4c2f002c0 100644 --- a/soh/soh/resource/importer/scenecommand/SetObjectListFactory.h +++ b/soh/soh/resource/importer/scenecommand/SetObjectListFactory.h @@ -2,15 +2,10 @@ #include "soh/resource/importer/scenecommand/SceneCommandFactory.h" -namespace LUS { -class SetObjectListFactory : public SceneCommandFactory { +namespace SOH { +class SetObjectListFactory : public SceneCommandFactoryBinaryV0 { public: - std::shared_ptr - ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; + std::shared_ptr + ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; }; - -class SetObjectListFactoryV0 : public SceneCommandVersionFactory { - public: - void ParseFileBinary(std::shared_ptr reader, std::shared_ptr resource) override; -}; -}; // namespace LUS +} // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SetPathwaysFactory.cpp b/soh/soh/resource/importer/scenecommand/SetPathwaysFactory.cpp index 1f40ab69d..61534ba48 100644 --- a/soh/soh/resource/importer/scenecommand/SetPathwaysFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetPathwaysFactory.cpp @@ -3,32 +3,10 @@ #include "spdlog/spdlog.h" #include -namespace LUS { -std::shared_ptr -SetPathwaysFactory::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; - } - - if (factory == nullptr) { - SPDLOG_ERROR("Failed to load SetPathways with version {}", resource->GetInitData()->ResourceVersion); - return nullptr; - } - - factory->ParseFileBinary(reader, resource); - - return resource; -} - -void LUS::SetPathwaysFactoryV0::ParseFileBinary(std::shared_ptr reader, - std::shared_ptr resource) { - std::shared_ptr setPathways = std::static_pointer_cast(resource); - ResourceVersionFactory::ParseFileBinary(reader, setPathways); +namespace SOH { +std::shared_ptr +SetPathwaysFactory::ReadResource(std::shared_ptr initData, std::shared_ptr reader) { + auto setPathways = std::make_shared(initData); ReadCommandId(setPathways, reader); @@ -39,6 +17,7 @@ void LUS::SetPathwaysFactoryV0::ParseFileBinary(std::shared_ptr re auto path = std::static_pointer_cast(LUS::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(pathFileName.c_str())); setPathways->paths.push_back(path->GetPointer()); } -} -} // namespace LUS + return setPathways; +} +} // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SetPathwaysFactory.h b/soh/soh/resource/importer/scenecommand/SetPathwaysFactory.h index fc9b2c62d..c622c820d 100644 --- a/soh/soh/resource/importer/scenecommand/SetPathwaysFactory.h +++ b/soh/soh/resource/importer/scenecommand/SetPathwaysFactory.h @@ -2,15 +2,10 @@ #include "soh/resource/importer/scenecommand/SceneCommandFactory.h" -namespace LUS { -class SetPathwaysFactory : public SceneCommandFactory { +namespace SOH { +class SetPathwaysFactory : public SceneCommandFactoryBinaryV0 { public: - std::shared_ptr - ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; + std::shared_ptr + ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; }; - -class SetPathwaysFactoryV0 : public SceneCommandVersionFactory { - public: - void ParseFileBinary(std::shared_ptr reader, std::shared_ptr resource) override; -}; -}; // namespace LUS +} // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SetRoomBehaviorFactory.cpp b/soh/soh/resource/importer/scenecommand/SetRoomBehaviorFactory.cpp index 409e3d410..e4601e59c 100644 --- a/soh/soh/resource/importer/scenecommand/SetRoomBehaviorFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetRoomBehaviorFactory.cpp @@ -2,37 +2,16 @@ #include "soh/resource/type/scenecommand/SetRoomBehavior.h" #include "spdlog/spdlog.h" -namespace LUS { -std::shared_ptr -SetRoomBehaviorFactory::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; - } - - if (factory == nullptr) { - SPDLOG_ERROR("Failed to load SetRoomBehavior with version {}", resource->GetInitData()->ResourceVersion); - return nullptr; - } - - factory->ParseFileBinary(reader, resource); - - return resource; -} - -void LUS::SetRoomBehaviorFactoryV0::ParseFileBinary(std::shared_ptr reader, - std::shared_ptr resource) { - std::shared_ptr setRoomBehavior = std::static_pointer_cast(resource); - ResourceVersionFactory::ParseFileBinary(reader, setRoomBehavior); +namespace SOH { +std::shared_ptr +SetRoomBehaviorFactory::ReadResource(std::shared_ptr initData, std::shared_ptr reader) { + auto setRoomBehavior = std::make_shared(initData); ReadCommandId(setRoomBehavior, reader); setRoomBehavior->roomBehavior.gameplayFlags = reader->ReadInt8(); setRoomBehavior->roomBehavior.gameplayFlags2 = reader->ReadInt32(); -} -} // namespace LUS + return setRoomBehavior; +} +} // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SetRoomBehaviorFactory.h b/soh/soh/resource/importer/scenecommand/SetRoomBehaviorFactory.h index ef5a77bd4..70a53ba1e 100644 --- a/soh/soh/resource/importer/scenecommand/SetRoomBehaviorFactory.h +++ b/soh/soh/resource/importer/scenecommand/SetRoomBehaviorFactory.h @@ -2,15 +2,10 @@ #include "soh/resource/importer/scenecommand/SceneCommandFactory.h" -namespace LUS { -class SetRoomBehaviorFactory : public SceneCommandFactory { +namespace SOH { +class SetRoomBehaviorFactory : public SceneCommandFactoryBinaryV0 { public: - std::shared_ptr - ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; + std::shared_ptr + ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; }; - -class SetRoomBehaviorFactoryV0 : public SceneCommandVersionFactory { - public: - void ParseFileBinary(std::shared_ptr reader, std::shared_ptr resource) override; -}; -}; // namespace LUS +} // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SetRoomListFactory.cpp b/soh/soh/resource/importer/scenecommand/SetRoomListFactory.cpp index 136b410a0..7726877a1 100644 --- a/soh/soh/resource/importer/scenecommand/SetRoomListFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetRoomListFactory.cpp @@ -2,49 +2,27 @@ #include "soh/resource/type/scenecommand/SetRoomList.h" #include "spdlog/spdlog.h" -namespace LUS { -std::shared_ptr -SetRoomListFactory::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; - } - - if (factory == nullptr) - { - SPDLOG_ERROR("Failed to load SetRoomList with version {}", resource->GetInitData()->ResourceVersion); - return nullptr; - } - - factory->ParseFileBinary(reader, resource); - - return resource; -} - -void LUS::SetRoomListFactoryV0::ParseFileBinary(std::shared_ptr reader, - std::shared_ptr resource) { - std::shared_ptr setRoomList = std::static_pointer_cast(resource); - ResourceVersionFactory::ParseFileBinary(reader, setRoomList); +namespace SOH { +std::shared_ptr +SetRoomListFactory::ReadResource(std::shared_ptr initData, std::shared_ptr reader) { + auto setRoomList = std::make_shared(initData); ReadCommandId(setRoomList, reader); setRoomList->numRooms = reader->ReadInt32(); setRoomList->rooms.reserve(setRoomList->numRooms); for (uint32_t i = 0; i < setRoomList->numRooms; i++) { - RomFile room; + RomFile room; - setRoomList->fileNames.push_back(reader->ReadString()); + setRoomList->fileNames.push_back(reader->ReadString()); - room.fileName = (char*)setRoomList->fileNames.back().c_str(); - room.vromStart = reader->ReadInt32(); - room.vromEnd = reader->ReadInt32(); + room.fileName = (char*)setRoomList->fileNames.back().c_str(); + room.vromStart = reader->ReadInt32(); + room.vromEnd = reader->ReadInt32(); setRoomList->rooms.push_back(room); } -} -} // namespace LUS + return setRoomList; +} +} // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SetRoomListFactory.h b/soh/soh/resource/importer/scenecommand/SetRoomListFactory.h index 1ba5e5c1f..6bf9eaa5c 100644 --- a/soh/soh/resource/importer/scenecommand/SetRoomListFactory.h +++ b/soh/soh/resource/importer/scenecommand/SetRoomListFactory.h @@ -2,15 +2,10 @@ #include "soh/resource/importer/scenecommand/SceneCommandFactory.h" -namespace LUS { -class SetRoomListFactory : public SceneCommandFactory { +namespace SOH { +class SetRoomListFactory : public SceneCommandFactoryBinaryV0 { public: - std::shared_ptr - ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; + std::shared_ptr + ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; }; - -class SetRoomListFactoryV0 : public SceneCommandVersionFactory { - public: - void ParseFileBinary(std::shared_ptr reader, std::shared_ptr resource) override; -}; -}; // namespace LUS +} // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SetSkyboxModifierFactory.cpp b/soh/soh/resource/importer/scenecommand/SetSkyboxModifierFactory.cpp index b68d2e56d..291ae578c 100644 --- a/soh/soh/resource/importer/scenecommand/SetSkyboxModifierFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetSkyboxModifierFactory.cpp @@ -2,37 +2,16 @@ #include "soh/resource/type/scenecommand/SetSkyboxModifier.h" #include "spdlog/spdlog.h" -namespace LUS { -std::shared_ptr SetSkyboxModifierFactory::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; - } - - if (factory == nullptr) { - SPDLOG_ERROR("Failed to load SetSkyboxModifier with version {}", resource->GetInitData()->ResourceVersion); - return nullptr; - } - - factory->ParseFileBinary(reader, resource); - - return resource; -} - -void LUS::SetSkyboxModifierFactoryV0::ParseFileBinary(std::shared_ptr reader, - std::shared_ptr resource) { - std::shared_ptr setSkyboxModifier = std::static_pointer_cast(resource); - ResourceVersionFactory::ParseFileBinary(reader, setSkyboxModifier); +namespace SOH { +std::shared_ptr SetSkyboxModifierFactory::ReadResource(std::shared_ptr initData, + std::shared_ptr reader) { + auto setSkyboxModifier = std::make_shared(initData); ReadCommandId(setSkyboxModifier, reader); setSkyboxModifier->modifier.skyboxDisabled = reader->ReadInt8(); setSkyboxModifier->modifier.sunMoonDisabled = reader->ReadInt8(); -} -} // namespace LUS + return setSkyboxModifier; +} +} // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SetSkyboxModifierFactory.h b/soh/soh/resource/importer/scenecommand/SetSkyboxModifierFactory.h index 9556b6699..d467cc73d 100644 --- a/soh/soh/resource/importer/scenecommand/SetSkyboxModifierFactory.h +++ b/soh/soh/resource/importer/scenecommand/SetSkyboxModifierFactory.h @@ -2,15 +2,10 @@ #include "soh/resource/importer/scenecommand/SceneCommandFactory.h" -namespace LUS { -class SetSkyboxModifierFactory : public SceneCommandFactory { +namespace SOH { +class SetSkyboxModifierFactory : public SceneCommandFactoryBinaryV0 { public: - std::shared_ptr - ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; + std::shared_ptr + ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; }; - -class SetSkyboxModifierFactoryV0 : public SceneCommandVersionFactory { - public: - void ParseFileBinary(std::shared_ptr reader, std::shared_ptr resource) override; -}; -}; // namespace LUS +} // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SetSkyboxSettingsFactory.cpp b/soh/soh/resource/importer/scenecommand/SetSkyboxSettingsFactory.cpp index 3b793c80e..f3e726b07 100644 --- a/soh/soh/resource/importer/scenecommand/SetSkyboxSettingsFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetSkyboxSettingsFactory.cpp @@ -2,32 +2,10 @@ #include "soh/resource/type/scenecommand/SetSkyboxSettings.h" #include "spdlog/spdlog.h" -namespace LUS { -std::shared_ptr SetSkyboxSettingsFactory::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; - } - - if (factory == nullptr) { - SPDLOG_ERROR("Failed to load SetSkyboxSettings with version {}", resource->GetInitData()->ResourceVersion); - return nullptr; - } - - factory->ParseFileBinary(reader, resource); - - return resource; -} - -void SetSkyboxSettingsFactoryV0::ParseFileBinary(std::shared_ptr reader, - std::shared_ptr resource) { - std::shared_ptr setSkyboxSettings = std::static_pointer_cast(resource); - ResourceVersionFactory::ParseFileBinary(reader, setSkyboxSettings); +namespace SOH { +std::shared_ptr SetSkyboxSettingsFactory::ReadResource(std::shared_ptr initData, + std::shared_ptr reader) { + auto setSkyboxSettings = std::make_shared(initData); ReadCommandId(setSkyboxSettings, reader); @@ -35,6 +13,7 @@ void SetSkyboxSettingsFactoryV0::ParseFileBinary(std::shared_ptr r setSkyboxSettings->settings.skyboxId = reader->ReadInt8(); setSkyboxSettings->settings.weather = reader->ReadInt8(); setSkyboxSettings->settings.indoors = reader->ReadInt8(); -} -} // namespace LUS + return setSkyboxSettings; +} +} // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SetSkyboxSettingsFactory.h b/soh/soh/resource/importer/scenecommand/SetSkyboxSettingsFactory.h index 7c2da4bb1..581e56122 100644 --- a/soh/soh/resource/importer/scenecommand/SetSkyboxSettingsFactory.h +++ b/soh/soh/resource/importer/scenecommand/SetSkyboxSettingsFactory.h @@ -2,15 +2,10 @@ #include "soh/resource/importer/scenecommand/SceneCommandFactory.h" -namespace LUS { -class SetSkyboxSettingsFactory : public SceneCommandFactory { +namespace SOH { +class SetSkyboxSettingsFactory : public SceneCommandFactoryBinaryV0 { public: - std::shared_ptr - ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; + std::shared_ptr + ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; }; - -class SetSkyboxSettingsFactoryV0 : public SceneCommandVersionFactory { - public: - void ParseFileBinary(std::shared_ptr reader, std::shared_ptr resource) override; -}; -}; // namespace LUS +} // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SetSoundSettingsFactory.cpp b/soh/soh/resource/importer/scenecommand/SetSoundSettingsFactory.cpp index 1817af81d..f85178e22 100644 --- a/soh/soh/resource/importer/scenecommand/SetSoundSettingsFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetSoundSettingsFactory.cpp @@ -2,38 +2,17 @@ #include "soh/resource/type/scenecommand/SetSoundSettings.h" #include "spdlog/spdlog.h" -namespace LUS { -std::shared_ptr SetSoundSettingsFactory::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; - } - - if (factory == nullptr) { - SPDLOG_ERROR("Failed to load SetSoundSettings with version {}", resource->GetInitData()->ResourceVersion); - return nullptr; - } - - factory->ParseFileBinary(reader, resource); - - return resource; -} - -void LUS::SetSoundSettingsFactoryV0::ParseFileBinary(std::shared_ptr reader, - std::shared_ptr resource) { - std::shared_ptr setSoundSettings = std::static_pointer_cast(resource); - ResourceVersionFactory::ParseFileBinary(reader, setSoundSettings); +namespace SOH { +std::shared_ptr SetSoundSettingsFactory::ReadResource(std::shared_ptr initData, + std::shared_ptr reader) { + auto setSoundSettings = std::make_shared(initData); ReadCommandId(setSoundSettings, reader); setSoundSettings->settings.reverb = reader->ReadInt8(); setSoundSettings->settings.natureAmbienceId = reader->ReadInt8(); setSoundSettings->settings.seqId = reader->ReadInt8(); -} -} // namespace LUS + return setSoundSettings; +} +} // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SetSoundSettingsFactory.h b/soh/soh/resource/importer/scenecommand/SetSoundSettingsFactory.h index 7195b0fb6..e1c4efb03 100644 --- a/soh/soh/resource/importer/scenecommand/SetSoundSettingsFactory.h +++ b/soh/soh/resource/importer/scenecommand/SetSoundSettingsFactory.h @@ -2,15 +2,10 @@ #include "soh/resource/importer/scenecommand/SceneCommandFactory.h" -namespace LUS { -class SetSoundSettingsFactory : public SceneCommandFactory { +namespace SOH { +class SetSoundSettingsFactory : public SceneCommandFactoryBinaryV0 { public: - std::shared_ptr - ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; + std::shared_ptr + ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; }; - -class SetSoundSettingsFactoryV0 : public SceneCommandVersionFactory { - public: - void ParseFileBinary(std::shared_ptr reader, std::shared_ptr resource) override; -}; -}; // namespace LUS +} // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SetSpecialObjectsFactory.cpp b/soh/soh/resource/importer/scenecommand/SetSpecialObjectsFactory.cpp index 5f818f1d4..b7fd21aa4 100644 --- a/soh/soh/resource/importer/scenecommand/SetSpecialObjectsFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetSpecialObjectsFactory.cpp @@ -2,37 +2,16 @@ #include "soh/resource/type/scenecommand/SetSpecialObjects.h" #include "spdlog/spdlog.h" -namespace LUS { -std::shared_ptr SetSpecialObjectsFactory::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; - } - - if (factory == nullptr){ - SPDLOG_ERROR("Failed to load SetSpecialObjects with version {}", resource->GetInitData()->ResourceVersion); - return nullptr; - } - - factory->ParseFileBinary(reader, resource); - - return resource; -} - -void LUS::SetSpecialObjectsFactoryV0::ParseFileBinary(std::shared_ptr reader, - std::shared_ptr resource) { - std::shared_ptr setSpecialObjects = std::static_pointer_cast(resource); - ResourceVersionFactory::ParseFileBinary(reader, setSpecialObjects); +namespace SOH { +std::shared_ptr SetSpecialObjectsFactory::ReadResource(std::shared_ptr initData, + std::shared_ptr reader) { + auto setSpecialObjects = std::make_shared(initData); ReadCommandId(setSpecialObjects, reader); setSpecialObjects->specialObjects.elfMessage = reader->ReadInt8(); setSpecialObjects->specialObjects.globalObject = reader->ReadInt16(); -} -} // namespace LUS + return setSpecialObjects; +} +} // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SetSpecialObjectsFactory.h b/soh/soh/resource/importer/scenecommand/SetSpecialObjectsFactory.h index 3e3fc77d0..503cfb61f 100644 --- a/soh/soh/resource/importer/scenecommand/SetSpecialObjectsFactory.h +++ b/soh/soh/resource/importer/scenecommand/SetSpecialObjectsFactory.h @@ -2,15 +2,10 @@ #include "soh/resource/importer/scenecommand/SceneCommandFactory.h" -namespace LUS { -class SetSpecialObjectsFactory : public SceneCommandFactory { +namespace SOH { +class SetSpecialObjectsFactory : public SceneCommandFactoryBinaryV0 { public: - std::shared_ptr - ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; + std::shared_ptr + ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; }; - -class SetSpecialObjectsFactoryV0 : public SceneCommandVersionFactory { - public: - void ParseFileBinary(std::shared_ptr reader, std::shared_ptr resource) override; -}; -}; // namespace LUS +} // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SetStartPositionListFactory.cpp b/soh/soh/resource/importer/scenecommand/SetStartPositionListFactory.cpp index bafb0b153..3165b4361 100644 --- a/soh/soh/resource/importer/scenecommand/SetStartPositionListFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetStartPositionListFactory.cpp @@ -2,54 +2,30 @@ #include "soh/resource/type/scenecommand/SetStartPositionList.h" #include "spdlog/spdlog.h" -namespace LUS { -std::shared_ptr SetStartPositionListFactory::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; - } - - if (factory == nullptr) - { - SPDLOG_ERROR("Failed to load SetStartPositionList with version {}", resource->GetInitData()->ResourceVersion); - return nullptr; - } - - factory->ParseFileBinary(reader, resource); - - return resource; -} - -void LUS::SetStartPositionListFactoryV0::ParseFileBinary(std::shared_ptr reader, - std::shared_ptr resource) -{ - std::shared_ptr setStartPositionList = std::static_pointer_cast(resource); - ResourceVersionFactory::ParseFileBinary(reader, setStartPositionList); +namespace SOH { +std::shared_ptr SetStartPositionListFactory::ReadResource(std::shared_ptr initData, + std::shared_ptr reader) { + auto setStartPositionList = std::make_shared(initData); ReadCommandId(setStartPositionList, reader); setStartPositionList->numStartPositions = reader->ReadUInt32(); setStartPositionList->startPositions.reserve(setStartPositionList->numStartPositions); for (uint32_t i = 0; i < setStartPositionList->numStartPositions; i++) { - ActorEntry entry; + ActorEntry entry; - entry.id = reader->ReadUInt16(); - entry.pos.x = reader->ReadInt16(); - entry.pos.y = reader->ReadInt16(); - entry.pos.z = reader->ReadInt16(); - entry.rot.x = reader->ReadInt16(); - entry.rot.y = reader->ReadInt16(); - entry.rot.z = reader->ReadInt16(); - entry.params = reader->ReadUInt16(); + entry.id = reader->ReadUInt16(); + entry.pos.x = reader->ReadInt16(); + entry.pos.y = reader->ReadInt16(); + entry.pos.z = reader->ReadInt16(); + entry.rot.x = reader->ReadInt16(); + entry.rot.y = reader->ReadInt16(); + entry.rot.z = reader->ReadInt16(); + entry.params = reader->ReadUInt16(); setStartPositionList->startPositions.push_back(entry); } -} -} // namespace LUS + return setStartPositionList; +} +} // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SetStartPositionListFactory.h b/soh/soh/resource/importer/scenecommand/SetStartPositionListFactory.h index d2bbcb6a6..b07901f05 100644 --- a/soh/soh/resource/importer/scenecommand/SetStartPositionListFactory.h +++ b/soh/soh/resource/importer/scenecommand/SetStartPositionListFactory.h @@ -2,15 +2,10 @@ #include "soh/resource/importer/scenecommand/SceneCommandFactory.h" -namespace LUS { -class SetStartPositionListFactory : public SceneCommandFactory { +namespace SOH { +class SetStartPositionListFactory : public SceneCommandFactoryBinaryV0 { public: - std::shared_ptr - ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; + std::shared_ptr + ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; }; - -class SetStartPositionListFactoryV0 : public SceneCommandVersionFactory { - public: - void ParseFileBinary(std::shared_ptr reader, std::shared_ptr resource) override; -}; -}; // namespace LUS +} // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SetTimeSettingsFactory.cpp b/soh/soh/resource/importer/scenecommand/SetTimeSettingsFactory.cpp index ab2ac12f0..d83b24583 100644 --- a/soh/soh/resource/importer/scenecommand/SetTimeSettingsFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetTimeSettingsFactory.cpp @@ -2,38 +2,17 @@ #include "soh/resource/type/scenecommand/SetTimeSettings.h" #include "spdlog/spdlog.h" -namespace LUS { -std::shared_ptr -SetTimeSettingsFactory::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; - } - - if (factory == nullptr) { - SPDLOG_ERROR("Failed to load SetTimeSettings with version {}", resource->GetInitData()->ResourceVersion); - return nullptr; - } - - factory->ParseFileBinary(reader, resource); - - return resource; -} - -void LUS::SetTimeSettingsFactoryV0::ParseFileBinary(std::shared_ptr reader, - std::shared_ptr resource) { - std::shared_ptr setTimeSettings = std::static_pointer_cast(resource); - ResourceVersionFactory::ParseFileBinary(reader, setTimeSettings); +namespace SOH { +std::shared_ptr +SetTimeSettingsFactory::ReadResource(std::shared_ptr initData, std::shared_ptr reader) { + auto setTimeSettings = std::make_shared(initData); ReadCommandId(setTimeSettings, reader); setTimeSettings->settings.hour = reader->ReadInt8(); setTimeSettings->settings.minute = reader->ReadInt8(); setTimeSettings->settings.timeIncrement = reader->ReadInt8(); -} -} // namespace LUS + return setTimeSettings; +} +} // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SetTimeSettingsFactory.h b/soh/soh/resource/importer/scenecommand/SetTimeSettingsFactory.h index b7ee1083c..d1336f788 100644 --- a/soh/soh/resource/importer/scenecommand/SetTimeSettingsFactory.h +++ b/soh/soh/resource/importer/scenecommand/SetTimeSettingsFactory.h @@ -2,15 +2,10 @@ #include "soh/resource/importer/scenecommand/SceneCommandFactory.h" -namespace LUS { -class SetTimeSettingsFactory : public SceneCommandFactory { +namespace SOH { +class SetTimeSettingsFactory : public SceneCommandFactoryBinaryV0 { public: - std::shared_ptr - ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; + std::shared_ptr + ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; }; - -class SetTimeSettingsFactoryV0 : public SceneCommandVersionFactory { - public: - void ParseFileBinary(std::shared_ptr reader, std::shared_ptr resource) override; -}; -}; // namespace LUS +} // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SetTransitionActorListFactory.cpp b/soh/soh/resource/importer/scenecommand/SetTransitionActorListFactory.cpp index 575151bab..c751ad611 100644 --- a/soh/soh/resource/importer/scenecommand/SetTransitionActorListFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetTransitionActorListFactory.cpp @@ -2,33 +2,11 @@ #include "soh/resource/type/scenecommand/SetTransitionActorList.h" #include "spdlog/spdlog.h" -namespace LUS { -std::shared_ptr SetTransitionActorListFactory::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; - } - - if (factory == nullptr) { - SPDLOG_ERROR("Failed to load SetTransitionActorList with version {}", resource->GetInitData()->ResourceVersion); - return nullptr; - } - - factory->ParseFileBinary(reader, resource); - - return resource; -} - -void LUS::SetTransitionActorListFactoryV0::ParseFileBinary(std::shared_ptr reader, - std::shared_ptr resource) { - std::shared_ptr setTransitionActorList = std::static_pointer_cast(resource); - ResourceVersionFactory::ParseFileBinary(reader, setTransitionActorList); - +namespace SOH { +std::shared_ptr SetTransitionActorListFactory::ReadResource(std::shared_ptr initData, + std::shared_ptr reader) { + auto setTransitionActorList = std::make_shared(initData); + ReadCommandId(setTransitionActorList, reader); setTransitionActorList->numTransitionActors = reader->ReadUInt32(); @@ -49,6 +27,7 @@ void LUS::SetTransitionActorListFactoryV0::ParseFileBinary(std::shared_ptrtransitionActorList.push_back(entry); } -} -} // namespace LUS + return setTransitionActorList; +} +} // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SetTransitionActorListFactory.h b/soh/soh/resource/importer/scenecommand/SetTransitionActorListFactory.h index 25343ced8..c8fb65f9a 100644 --- a/soh/soh/resource/importer/scenecommand/SetTransitionActorListFactory.h +++ b/soh/soh/resource/importer/scenecommand/SetTransitionActorListFactory.h @@ -2,15 +2,10 @@ #include "soh/resource/importer/scenecommand/SceneCommandFactory.h" -namespace LUS { -class SetTransitionActorListFactory : public SceneCommandFactory { +namespace SOH { +class SetTransitionActorListFactory : public SceneCommandFactoryBinaryV0 { public: - std::shared_ptr - ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; + std::shared_ptr + ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; }; - -class SetTransitionActorListFactoryV0 : public SceneCommandVersionFactory { - public: - void ParseFileBinary(std::shared_ptr reader, std::shared_ptr resource) override; -}; -}; // namespace LUS +} // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SetWindSettingsFactory.cpp b/soh/soh/resource/importer/scenecommand/SetWindSettingsFactory.cpp index 995045014..3208004ce 100644 --- a/soh/soh/resource/importer/scenecommand/SetWindSettingsFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetWindSettingsFactory.cpp @@ -2,32 +2,10 @@ #include "soh/resource/type/scenecommand/SetWindSettings.h" #include "spdlog/spdlog.h" -namespace LUS { -std::shared_ptr -SetWindSettingsFactory::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; - } - - if (factory == nullptr) { - SPDLOG_ERROR("Failed to load SetWindSettings with version {}", resource->GetInitData()->ResourceVersion); - return nullptr; - } - - factory->ParseFileBinary(reader, resource); - - return resource; -} - -void LUS::SetWindSettingsFactoryV0::ParseFileBinary(std::shared_ptr reader, - std::shared_ptr resource) { - std::shared_ptr setWind = std::static_pointer_cast(resource); - ResourceVersionFactory::ParseFileBinary(reader, setWind); +namespace SOH { +std::shared_ptr +SetWindSettingsFactory::ReadResource(std::shared_ptr initData, std::shared_ptr reader) { + auto setWind = std::make_shared(initData); ReadCommandId(setWind, reader); @@ -35,6 +13,7 @@ void LUS::SetWindSettingsFactoryV0::ParseFileBinary(std::shared_ptrsettings.windVertical = reader->ReadInt8(); setWind->settings.windSouth = reader->ReadInt8(); setWind->settings.windSpeed = reader->ReadUByte(); -} -} // namespace LUS + return setWind; +} +} // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SetWindSettingsFactory.h b/soh/soh/resource/importer/scenecommand/SetWindSettingsFactory.h index 0a783bb9f..6cc9fbc1b 100644 --- a/soh/soh/resource/importer/scenecommand/SetWindSettingsFactory.h +++ b/soh/soh/resource/importer/scenecommand/SetWindSettingsFactory.h @@ -2,15 +2,10 @@ #include "soh/resource/importer/scenecommand/SceneCommandFactory.h" -namespace LUS { -class SetWindSettingsFactory : public SceneCommandFactory { +namespace SOH { +class SetWindSettingsFactory : public SceneCommandFactoryBinaryV0 { public: - std::shared_ptr - ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; + std::shared_ptr + ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; }; - -class SetWindSettingsFactoryV0 : public SceneCommandVersionFactory { - public: - void ParseFileBinary(std::shared_ptr reader, std::shared_ptr resource) override; -}; -}; // namespace LUS +} // namespace SOH diff --git a/soh/soh/resource/type/Animation.cpp b/soh/soh/resource/type/Animation.cpp index 46327c732..d11d05394 100644 --- a/soh/soh/resource/type/Animation.cpp +++ b/soh/soh/resource/type/Animation.cpp @@ -1,6 +1,6 @@ #include "Animation.h" -namespace LUS { +namespace SOH { AnimationData* Animation::GetPointer() { return &animationData; } @@ -18,4 +18,4 @@ size_t Animation::GetPointerSize() { return 0; } } -} // namespace LUS \ No newline at end of file +} // namespace SOH \ No newline at end of file diff --git a/soh/soh/resource/type/Animation.h b/soh/soh/resource/type/Animation.h index 3d6b810bf..abd319d97 100644 --- a/soh/soh/resource/type/Animation.h +++ b/soh/soh/resource/type/Animation.h @@ -3,85 +3,85 @@ #include "Resource.h" #include -namespace LUS { - enum class AnimationType { - Normal = 0, - Link = 1, - Curve = 2, - Legacy = 3, - }; +namespace SOH { +enum class AnimationType { + Normal = 0, + Link = 1, + Curve = 2, + Legacy = 3, +}; - struct RotationIndex { - uint16_t x, y, z; +struct RotationIndex { + uint16_t x, y, z; - RotationIndex(uint16_t nX, uint16_t nY, uint16_t nZ) : x(nX), y(nY), z(nZ) { - } - }; + RotationIndex(uint16_t nX, uint16_t nY, uint16_t nZ) : x(nX), y(nY), z(nZ) { + } +}; - typedef struct { - /* 0x0000 */ u16 unk_00; // appears to be flags - /* 0x0002 */ s16 unk_02; - /* 0x0004 */ s16 unk_04; - /* 0x0006 */ s16 unk_06; - /* 0x0008 */ f32 unk_08; - } TransformData; // size = 0xC +typedef struct { + /* 0x0000 */ u16 unk_00; // appears to be flags + /* 0x0002 */ s16 unk_02; + /* 0x0004 */ s16 unk_04; + /* 0x0006 */ s16 unk_06; + /* 0x0008 */ f32 unk_08; +} TransformData; // size = 0xC - typedef struct { - /* 0x0000 */ u8* refIndex; - /* 0x0004 */ TransformData* transformData; - /* 0x0008 */ s16* copyValues; - /* 0x000C */ s16 unk_0C; - /* 0x000E */ s16 unk_0E; - } TransformUpdateIndex; // size = 0x10 +typedef struct { + /* 0x0000 */ u8* refIndex; + /* 0x0004 */ TransformData* transformData; + /* 0x0008 */ s16* copyValues; + /* 0x000C */ s16 unk_0C; + /* 0x000E */ s16 unk_0E; +} TransformUpdateIndex; // size = 0x10 - typedef struct { - /* 0x00 */ s16 frameCount; - } AnimationHeaderCommon; +typedef struct { + /* 0x00 */ s16 frameCount; +} AnimationHeaderCommon; - // Index into the frame data table. - typedef struct { - /* 0x00 */ u16 x; - /* 0x02 */ u16 y; - /* 0x04 */ u16 z; - } JointIndex; // size = 0x06 +// Index into the frame data table. +typedef struct { + /* 0x00 */ u16 x; + /* 0x02 */ u16 y; + /* 0x04 */ u16 z; +} JointIndex; // size = 0x06 - typedef struct { - /* 0x00 */ AnimationHeaderCommon common; - /* 0x04 */ s16* frameData; // "tbl" - /* 0x08 */ JointIndex* jointIndices; // "ref_tbl" - /* 0x0C */ u16 staticIndexMax; - } AnimationHeader; // size = 0x10 +typedef struct { + /* 0x00 */ AnimationHeaderCommon common; + /* 0x04 */ s16* frameData; // "tbl" + /* 0x08 */ JointIndex* jointIndices; // "ref_tbl" + /* 0x0C */ u16 staticIndexMax; +} AnimationHeader; // size = 0x10 - typedef struct { - /* 0x00 */ AnimationHeaderCommon common; - /* 0x04 */ void* segment; - } LinkAnimationHeader; // size = 0x8 +typedef struct { + /* 0x00 */ AnimationHeaderCommon common; + /* 0x04 */ void* segment; +} LinkAnimationHeader; // size = 0x8 - union AnimationData { - AnimationHeader animationHeader; - LinkAnimationHeader linkAnimationHeader; - TransformUpdateIndex transformUpdateIndex; - }; +union AnimationData { +AnimationHeader animationHeader; +LinkAnimationHeader linkAnimationHeader; +TransformUpdateIndex transformUpdateIndex; +}; - class Animation : public Resource { - public: - using Resource::Resource; +class Animation : public LUS::Resource { +public: + using Resource::Resource; - Animation() : Resource(std::shared_ptr()) {} + Animation() : Resource(std::shared_ptr()) {} - AnimationData* GetPointer(); - size_t GetPointerSize(); + AnimationData* GetPointer(); + size_t GetPointerSize(); - AnimationType type; - AnimationData animationData; + AnimationType type; + AnimationData animationData; - // NORMAL - std::vector rotationValues; - std::vector rotationIndices; + // NORMAL + std::vector rotationValues; + std::vector rotationIndices; - // CURVE - std::vector refIndexArr; - std::vector transformDataArr; - std::vector copyValuesArr; - }; -}; // namespace LUS \ No newline at end of file + // CURVE + std::vector refIndexArr; + std::vector transformDataArr; + std::vector copyValuesArr; +}; +}; // namespace LUS diff --git a/soh/soh/resource/type/AudioSample.cpp b/soh/soh/resource/type/AudioSample.cpp index 951aae6c1..288765822 100644 --- a/soh/soh/resource/type/AudioSample.cpp +++ b/soh/soh/resource/type/AudioSample.cpp @@ -1,6 +1,6 @@ #include "AudioSample.h" -namespace LUS { +namespace SOH { Sample* AudioSample::GetPointer() { return &sample; } @@ -8,4 +8,4 @@ Sample* AudioSample::GetPointer() { size_t AudioSample::GetPointerSize() { return sizeof(Sample); } -} // namespace LUS \ No newline at end of file +} // namespace SOH \ No newline at end of file diff --git a/soh/soh/resource/type/AudioSample.h b/soh/soh/resource/type/AudioSample.h index eda8aa456..4d6929c59 100644 --- a/soh/soh/resource/type/AudioSample.h +++ b/soh/soh/resource/type/AudioSample.h @@ -5,7 +5,7 @@ #include "Resource.h" #include -namespace LUS { +namespace SOH { typedef struct { /* 0x00 */ uintptr_t start; /* 0x04 */ uintptr_t end; @@ -39,11 +39,11 @@ namespace LUS { s32 sampleRate; // For wav samples only... } Sample; // size = 0x10 - class AudioSample : public Resource { + class AudioSample : public LUS::Resource { public: using Resource::Resource; - AudioSample() : Resource(std::shared_ptr()) {} + AudioSample() : Resource(std::shared_ptr()) {} Sample* GetPointer(); size_t GetPointerSize(); diff --git a/soh/soh/resource/type/AudioSequence.cpp b/soh/soh/resource/type/AudioSequence.cpp index c09514a67..41029d47d 100644 --- a/soh/soh/resource/type/AudioSequence.cpp +++ b/soh/soh/resource/type/AudioSequence.cpp @@ -1,6 +1,6 @@ #include "AudioSequence.h" -namespace LUS { +namespace SOH { Sequence* AudioSequence::GetPointer() { return &sequence; @@ -9,4 +9,4 @@ Sequence* AudioSequence::GetPointer() { size_t AudioSequence::GetPointerSize() { return sizeof(Sequence); } -} // namespace LUS +} // namespace SOH diff --git a/soh/soh/resource/type/AudioSequence.h b/soh/soh/resource/type/AudioSequence.h index 2b2bb8be9..457db6243 100644 --- a/soh/soh/resource/type/AudioSequence.h +++ b/soh/soh/resource/type/AudioSequence.h @@ -5,7 +5,7 @@ #include "Resource.h" #include -namespace LUS { +namespace SOH { typedef struct { char* seqData; @@ -17,11 +17,11 @@ typedef struct { uint8_t fonts[16]; } Sequence; -class AudioSequence : public Resource { +class AudioSequence : public LUS::Resource { public: using Resource::Resource; - AudioSequence() : Resource(std::shared_ptr()) {} + AudioSequence() : Resource(std::shared_ptr()) {} Sequence* GetPointer(); size_t GetPointerSize(); diff --git a/soh/soh/resource/type/AudioSoundFont.cpp b/soh/soh/resource/type/AudioSoundFont.cpp index 43ac40abf..12218cb64 100644 --- a/soh/soh/resource/type/AudioSoundFont.cpp +++ b/soh/soh/resource/type/AudioSoundFont.cpp @@ -1,6 +1,6 @@ #include "AudioSoundFont.h" -namespace LUS { +namespace SOH { SoundFont* AudioSoundFont::GetPointer() { return &soundFont; } @@ -8,4 +8,4 @@ SoundFont* AudioSoundFont::GetPointer() { size_t AudioSoundFont::GetPointerSize() { return sizeof(SoundFont); } -} // namespace LUS +} // namespace SOH diff --git a/soh/soh/resource/type/AudioSoundFont.h b/soh/soh/resource/type/AudioSoundFont.h index c47218090..11b899d3e 100644 --- a/soh/soh/resource/type/AudioSoundFont.h +++ b/soh/soh/resource/type/AudioSoundFont.h @@ -6,7 +6,7 @@ #include "soh/resource/type/AudioSample.h" #include -namespace LUS { +namespace SOH { typedef struct { /* 0x0 */ s16 delay; @@ -52,11 +52,11 @@ typedef struct { s32 fntIndex; } SoundFont; // size = 0x14 -class AudioSoundFont : public Resource { +class AudioSoundFont : public LUS::Resource { public: using Resource::Resource; - AudioSoundFont() : Resource(std::shared_ptr()) {} + AudioSoundFont() : Resource(std::shared_ptr()) {} SoundFont* GetPointer(); size_t GetPointerSize(); diff --git a/soh/soh/resource/type/Background.cpp b/soh/soh/resource/type/Background.cpp index bc1047b5c..5465b1ad9 100644 --- a/soh/soh/resource/type/Background.cpp +++ b/soh/soh/resource/type/Background.cpp @@ -1,6 +1,6 @@ #include "Background.h" -namespace LUS { +namespace SOH { uint8_t* Background::GetPointer() { return Data.data(); } @@ -8,4 +8,4 @@ uint8_t* Background::GetPointer() { size_t Background::GetPointerSize() { return Data.size() * sizeof(uint8_t); } -} // namespace LUS +} // namespace SOH diff --git a/soh/soh/resource/type/Background.h b/soh/soh/resource/type/Background.h index 7f22658e0..9edc4b0d6 100644 --- a/soh/soh/resource/type/Background.h +++ b/soh/soh/resource/type/Background.h @@ -2,12 +2,12 @@ #include "resource/Resource.h" -namespace LUS { -class Background : public Resource { +namespace SOH { +class Background : public LUS::Resource { public: using Resource::Resource; - Background() : Resource(std::shared_ptr()) {} + Background() : Resource(std::shared_ptr()) {} uint8_t* GetPointer(); size_t GetPointerSize(); diff --git a/soh/soh/resource/type/CollisionHeader.cpp b/soh/soh/resource/type/CollisionHeader.cpp index 5625d2b59..dbfd737ee 100644 --- a/soh/soh/resource/type/CollisionHeader.cpp +++ b/soh/soh/resource/type/CollisionHeader.cpp @@ -1,6 +1,6 @@ #include "CollisionHeader.h" -namespace LUS { +namespace SOH { CollisionHeaderData* CollisionHeader::GetPointer() { return &collisionHeaderData; } @@ -8,4 +8,4 @@ CollisionHeaderData* CollisionHeader::GetPointer() { size_t CollisionHeader::GetPointerSize() { return sizeof(collisionHeaderData); } -} // namespace LUS \ No newline at end of file +} // namespace SOH \ No newline at end of file diff --git a/soh/soh/resource/type/CollisionHeader.h b/soh/soh/resource/type/CollisionHeader.h index e401aa7f5..e2ddf3f7a 100644 --- a/soh/soh/resource/type/CollisionHeader.h +++ b/soh/soh/resource/type/CollisionHeader.h @@ -6,7 +6,7 @@ #include #include "z64math.h" -namespace LUS { +namespace SOH { typedef struct { /* 0x00 */ u16 type; @@ -67,11 +67,11 @@ typedef struct { size_t cameraDataListLen; // OTRTODO: Added to allow for bounds checking the cameraDataList. } CollisionHeaderData; // original name: BGDataInfo -class CollisionHeader : public Resource { +class CollisionHeader : public LUS::Resource { public: using Resource::Resource; - CollisionHeader() : Resource(std::shared_ptr()) {} + CollisionHeader() : Resource(std::shared_ptr()) {} CollisionHeaderData* GetPointer(); size_t GetPointerSize(); diff --git a/soh/soh/resource/type/Cutscene.cpp b/soh/soh/resource/type/Cutscene.cpp index c7e98062a..60440ceb2 100644 --- a/soh/soh/resource/type/Cutscene.cpp +++ b/soh/soh/resource/type/Cutscene.cpp @@ -1,7 +1,7 @@ #include "Cutscene.h" #include -namespace LUS { +namespace SOH { uint32_t* Cutscene::GetPointer() { return commands.data(); } @@ -9,4 +9,4 @@ uint32_t* Cutscene::GetPointer() { size_t Cutscene::GetPointerSize() { return commands.size() * sizeof(uint32_t); } -} // namespace LUS \ No newline at end of file +} // namespace SOH \ No newline at end of file diff --git a/soh/soh/resource/type/Cutscene.h b/soh/soh/resource/type/Cutscene.h index 5bd268e61..3ca8b3d50 100644 --- a/soh/soh/resource/type/Cutscene.h +++ b/soh/soh/resource/type/Cutscene.h @@ -7,7 +7,7 @@ #include "Vec3f.h" #include "Color3b.h" -namespace LUS { +namespace SOH { enum class CutsceneCommands { Cmd00 = 0x0000, @@ -44,11 +44,11 @@ enum class CutsceneCommands { Error = 0xFEAF, }; -class Cutscene : public Resource { +class Cutscene : public LUS::Resource { public: using Resource::Resource; - Cutscene() : Resource(std::shared_ptr()) {} + Cutscene() : Resource(std::shared_ptr()) {} uint32_t* GetPointer(); size_t GetPointerSize(); @@ -57,7 +57,7 @@ class Cutscene : public Resource { uint32_t endFrame; std::vector commands; }; -} // namespace LUS +} // namespace SOH ///////////// diff --git a/soh/soh/resource/type/Path.cpp b/soh/soh/resource/type/Path.cpp index 535db4e7d..072c65fd0 100644 --- a/soh/soh/resource/type/Path.cpp +++ b/soh/soh/resource/type/Path.cpp @@ -1,6 +1,6 @@ #include "Path.h" -namespace LUS { +namespace SOH { PathData* Path::GetPointer() { return pathData.data(); } @@ -8,4 +8,4 @@ PathData* Path::GetPointer() { size_t Path::GetPointerSize() { return pathData.size() * sizeof(PathData); } -} // namespace LUS +} // namespace SOH diff --git a/soh/soh/resource/type/Path.h b/soh/soh/resource/type/Path.h index 5dd16dec9..c4078bed3 100644 --- a/soh/soh/resource/type/Path.h +++ b/soh/soh/resource/type/Path.h @@ -6,18 +6,18 @@ #include #include "z64math.h" -namespace LUS { +namespace SOH { typedef struct { /* 0x00 */ u8 count; // number of points in the path /* 0x04 */ Vec3s* points; // Segment Address to the array of points } PathData; // size = 0x8 -class Path : public Resource { +class Path : public LUS::Resource { public: using Resource::Resource; - Path() : Resource(std::shared_ptr()) {} + Path() : Resource(std::shared_ptr()) {} PathData* GetPointer(); size_t GetPointerSize(); diff --git a/soh/soh/resource/type/PlayerAnimation.cpp b/soh/soh/resource/type/PlayerAnimation.cpp index 55925f49c..189460e4d 100644 --- a/soh/soh/resource/type/PlayerAnimation.cpp +++ b/soh/soh/resource/type/PlayerAnimation.cpp @@ -1,7 +1,7 @@ #include "PlayerAnimation.h" #include -namespace LUS { +namespace SOH { int16_t* PlayerAnimation::GetPointer() { return limbRotData.data(); } @@ -9,4 +9,4 @@ int16_t* PlayerAnimation::GetPointer() { size_t PlayerAnimation::GetPointerSize() { return limbRotData.size() * sizeof(int16_t); } -} // namespace LUS \ No newline at end of file +} // namespace SOH diff --git a/soh/soh/resource/type/PlayerAnimation.h b/soh/soh/resource/type/PlayerAnimation.h index 4eb51b139..d8c47a5f6 100644 --- a/soh/soh/resource/type/PlayerAnimation.h +++ b/soh/soh/resource/type/PlayerAnimation.h @@ -7,17 +7,16 @@ #include "Vec3f.h" #include "Color3b.h" -namespace LUS { - -class PlayerAnimation : public Resource { +namespace SOH { +class PlayerAnimation : public LUS::Resource { public: using Resource::Resource; - PlayerAnimation() : Resource(std::shared_ptr()) {} + PlayerAnimation() : Resource(std::shared_ptr()) {} int16_t* GetPointer(); size_t GetPointerSize(); std::vector limbRotData; }; -} // namespace LUS \ No newline at end of file +} // namespace SOH \ No newline at end of file diff --git a/soh/soh/resource/type/Scene.cpp b/soh/soh/resource/type/Scene.cpp index bfe219e54..15829c40e 100644 --- a/soh/soh/resource/type/Scene.cpp +++ b/soh/soh/resource/type/Scene.cpp @@ -1,6 +1,6 @@ #include "Scene.h" -namespace LUS { +namespace SOH { void* Scene::GetPointer() { // Scene is a special type that requries C++ processing. As such, we return nothing. return nullptr; @@ -9,4 +9,4 @@ void* Scene::GetPointer() { size_t Scene::GetPointerSize() { return 0; } -} // namespace LUS +} // namespace SOH diff --git a/soh/soh/resource/type/Scene.h b/soh/soh/resource/type/Scene.h index f726da359..79ff69392 100644 --- a/soh/soh/resource/type/Scene.h +++ b/soh/soh/resource/type/Scene.h @@ -7,13 +7,13 @@ #include "scenecommand/SceneCommand.h" #include -namespace LUS { +namespace SOH { -class Scene : public Resource { +class Scene : public LUS::Resource { public: using Resource::Resource; - Scene() : Resource(std::shared_ptr()) {} + Scene() : Resource(std::shared_ptr()) {} void* GetPointer(); size_t GetPointerSize(); diff --git a/soh/soh/resource/type/Skeleton.cpp b/soh/soh/resource/type/Skeleton.cpp index 13798d3c5..39c28f533 100644 --- a/soh/soh/resource/type/Skeleton.cpp +++ b/soh/soh/resource/type/Skeleton.cpp @@ -3,7 +3,7 @@ #include "soh/OTRGlobals.h" #include "libultraship/libultraship.h" -namespace LUS { +namespace SOH { SkeletonData* Skeleton::GetPointer() { return &skeletonData; } @@ -79,4 +79,4 @@ void SkeletonPatcher::UpdateSkeletons() { } } } -} // namespace LUS +} // namespace SOH diff --git a/soh/soh/resource/type/Skeleton.h b/soh/soh/resource/type/Skeleton.h index 490614a44..81aa90c68 100644 --- a/soh/soh/resource/type/Skeleton.h +++ b/soh/soh/resource/type/Skeleton.h @@ -5,7 +5,7 @@ #include "SkeletonLimb.h" #include -namespace LUS { +namespace SOH { enum class SkeletonType { Normal, @@ -50,11 +50,11 @@ union SkeletonData { SkelCurveLimbList skelCurveLimbList; }; -class Skeleton : public Resource { +class Skeleton : public LUS::Resource { public: using Resource::Resource; - Skeleton() : Resource(std::shared_ptr()) {} + Skeleton() : Resource(std::shared_ptr()) {} SkeletonData* GetPointer(); size_t GetPointerSize(); @@ -91,4 +91,4 @@ class SkeletonPatcher { }; -} // namespace LUS \ No newline at end of file +} // namespace SOH \ No newline at end of file diff --git a/soh/soh/resource/type/SkeletonLimb.cpp b/soh/soh/resource/type/SkeletonLimb.cpp index 8e5a8ef6d..eb599e641 100644 --- a/soh/soh/resource/type/SkeletonLimb.cpp +++ b/soh/soh/resource/type/SkeletonLimb.cpp @@ -1,6 +1,6 @@ #include "SkeletonLimb.h" -namespace LUS { +namespace SOH { SkeletonLimbData* SkeletonLimb::GetPointer() { return &limbData; } @@ -21,4 +21,4 @@ size_t SkeletonLimb::GetPointerSize() { return 0; } } -} // namespace LUS +} // namespace SOH diff --git a/soh/soh/resource/type/SkeletonLimb.h b/soh/soh/resource/type/SkeletonLimb.h index 2110b3484..bae04092c 100644 --- a/soh/soh/resource/type/SkeletonLimb.h +++ b/soh/soh/resource/type/SkeletonLimb.h @@ -4,7 +4,7 @@ #include "libultraship/libultra.h" #include "z64math.h" -namespace LUS { +namespace SOH { enum class LimbType { Invalid, Standard, @@ -97,11 +97,11 @@ union SkeletonLimbData { SkinLimb skinLimb; }; -class SkeletonLimb : public Resource { +class SkeletonLimb : public LUS::Resource { public: using Resource::Resource; - SkeletonLimb() : Resource(std::shared_ptr()) {} + SkeletonLimb() : Resource(std::shared_ptr()) {} SkeletonLimbData* GetPointer(); size_t GetPointerSize(); @@ -131,4 +131,4 @@ public: std::vector> skinLimbModifVertexArrays; std::vector> skinLimbModifTransformationArrays; }; -} // namespace LUS \ No newline at end of file +} // namespace SOH \ No newline at end of file diff --git a/soh/soh/resource/type/SohResourceType.h b/soh/soh/resource/type/SohResourceType.h new file mode 100644 index 000000000..fdf39031e --- /dev/null +++ b/soh/soh/resource/type/SohResourceType.h @@ -0,0 +1,21 @@ +#pragma once + +namespace SOH { +enum class ResourceType { + SOH_Animation = 0x4F414E4D, // OANM + SOH_PlayerAnimation = 0x4F50414D, // OPAM + SOH_Room = 0x4F524F4D, // OROM + SOH_CollisionHeader = 0x4F434F4C, // OCOL + SOH_Skeleton = 0x4F534B4C, // OSKL + SOH_SkeletonLimb = 0x4F534C42, // OSLB + SOH_Path = 0x4F505448, // OPTH + SOH_Cutscene = 0x4F435654, // OCUT + SOH_Text = 0x4F545854, // OTXT + SOH_Audio = 0x4F415544, // OAUD + SOH_AudioSample = 0x4F534D50, // OSMP + SOH_AudioSoundFont = 0x4F534654, // OSFT + SOH_AudioSequence = 0x4F534551, // OSEQ + SOH_Background = 0x4F424749, // OBGI + SOH_SceneCommand = 0x4F52434D, // ORCM +}; +} // namespace SOH diff --git a/soh/soh/resource/type/Text.cpp b/soh/soh/resource/type/Text.cpp index eee289f8a..4678dbbad 100644 --- a/soh/soh/resource/type/Text.cpp +++ b/soh/soh/resource/type/Text.cpp @@ -1,6 +1,6 @@ #include "Text.h" -namespace LUS { +namespace SOH { MessageEntry* Text::GetPointer() { return messages.data(); } @@ -8,4 +8,4 @@ MessageEntry* Text::GetPointer() { size_t Text::GetPointerSize() { return messages.size() * sizeof(MessageEntry); } -} // namespace LUS +} // namespace SOH diff --git a/soh/soh/resource/type/Text.h b/soh/soh/resource/type/Text.h index db0cb36a0..03cf7340b 100644 --- a/soh/soh/resource/type/Text.h +++ b/soh/soh/resource/type/Text.h @@ -5,7 +5,7 @@ #include "Resource.h" #include -namespace LUS { +namespace SOH { // TODO: we've moved away from using classes for this stuff class MessageEntry { @@ -16,11 +16,11 @@ public: std::string msg; }; -class Text : public Resource { +class Text : public LUS::Resource { public: using Resource::Resource; - Text() : Resource(std::shared_ptr()) {} + Text() : Resource(std::shared_ptr()) {} MessageEntry* GetPointer(); size_t GetPointerSize(); diff --git a/soh/soh/resource/type/scenecommand/EndMarker.cpp b/soh/soh/resource/type/scenecommand/EndMarker.cpp index 9d12c1518..ba8898187 100644 --- a/soh/soh/resource/type/scenecommand/EndMarker.cpp +++ b/soh/soh/resource/type/scenecommand/EndMarker.cpp @@ -1,6 +1,6 @@ #include "EndMarker.h" -namespace LUS { +namespace SOH { Marker* EndMarker::GetPointer() { return &endMarker; } @@ -8,4 +8,4 @@ Marker* EndMarker::GetPointer() { size_t EndMarker::GetPointerSize() { return sizeof(Marker); } -} // namespace LUS +} // namespace SOH diff --git a/soh/soh/resource/type/scenecommand/EndMarker.h b/soh/soh/resource/type/scenecommand/EndMarker.h index 9f981f1f9..4f45051c2 100644 --- a/soh/soh/resource/type/scenecommand/EndMarker.h +++ b/soh/soh/resource/type/scenecommand/EndMarker.h @@ -7,7 +7,7 @@ #include "SceneCommand.h" #include -namespace LUS { +namespace SOH { typedef struct { } Marker; diff --git a/soh/soh/resource/type/scenecommand/RomFile.h b/soh/soh/resource/type/scenecommand/RomFile.h index ebdc3dc3b..19a5545e7 100644 --- a/soh/soh/resource/type/scenecommand/RomFile.h +++ b/soh/soh/resource/type/scenecommand/RomFile.h @@ -2,7 +2,7 @@ #include -namespace LUS { +namespace SOH { typedef struct { /* 0x00 */ uintptr_t vromStart; /* 0x04 */ uintptr_t vromEnd; diff --git a/soh/soh/resource/type/scenecommand/SceneCommand.h b/soh/soh/resource/type/scenecommand/SceneCommand.h index 6fb845568..5eb44ae9d 100644 --- a/soh/soh/resource/type/scenecommand/SceneCommand.h +++ b/soh/soh/resource/type/scenecommand/SceneCommand.h @@ -6,7 +6,7 @@ #include "Resource.h" #include -namespace LUS { +namespace SOH { enum class SceneCommandID : uint8_t { SetStartPositionList = 0x00, @@ -47,10 +47,10 @@ enum class SceneCommandID : uint8_t { Error = 0xFF }; -class ISceneCommand : public IResource { +class ISceneCommand : public LUS::IResource { public: using IResource::IResource; - ISceneCommand() : IResource(std::shared_ptr()) {} + ISceneCommand() : IResource(std::shared_ptr()) {} SceneCommandID cmdId; }; diff --git a/soh/soh/resource/type/scenecommand/SetActorList.cpp b/soh/soh/resource/type/scenecommand/SetActorList.cpp index d37ebb148..5bb62e764 100644 --- a/soh/soh/resource/type/scenecommand/SetActorList.cpp +++ b/soh/soh/resource/type/scenecommand/SetActorList.cpp @@ -1,6 +1,6 @@ #include "SetActorList.h" -namespace LUS { +namespace SOH { ActorEntry* SetActorList::GetPointer() { return actorList.data(); } @@ -8,4 +8,4 @@ ActorEntry* SetActorList::GetPointer() { size_t SetActorList::GetPointerSize() { return actorList.size() * sizeof(ActorEntry); } -} // namespace LUS +} // namespace SOH diff --git a/soh/soh/resource/type/scenecommand/SetActorList.h b/soh/soh/resource/type/scenecommand/SetActorList.h index 117175d7d..0eb53c585 100644 --- a/soh/soh/resource/type/scenecommand/SetActorList.h +++ b/soh/soh/resource/type/scenecommand/SetActorList.h @@ -9,7 +9,7 @@ // #include #include "z64math.h" -namespace LUS { +namespace SOH { typedef struct { /* 0x00 */ s16 id; /* 0x02 */ Vec3s pos; diff --git a/soh/soh/resource/type/scenecommand/SetAlternateHeaders.cpp b/soh/soh/resource/type/scenecommand/SetAlternateHeaders.cpp index 15b3c97d4..911fef455 100644 --- a/soh/soh/resource/type/scenecommand/SetAlternateHeaders.cpp +++ b/soh/soh/resource/type/scenecommand/SetAlternateHeaders.cpp @@ -1,6 +1,6 @@ #include "SetAlternateHeaders.h" -namespace LUS { +namespace SOH { void* SetAlternateHeaders::GetPointer() { // Like Scene, SetAlternateHeader is a special type that is only acted upon in C++. return nullptr; @@ -9,4 +9,4 @@ void* SetAlternateHeaders::GetPointer() { size_t SetAlternateHeaders::GetPointerSize() { return 0; } -} // namespace LUS +} // namespace SOH diff --git a/soh/soh/resource/type/scenecommand/SetAlternateHeaders.h b/soh/soh/resource/type/scenecommand/SetAlternateHeaders.h index dc7272369..fdddee3f8 100644 --- a/soh/soh/resource/type/scenecommand/SetAlternateHeaders.h +++ b/soh/soh/resource/type/scenecommand/SetAlternateHeaders.h @@ -11,7 +11,7 @@ #include -namespace LUS { +namespace SOH { class SetAlternateHeaders : public SceneCommand { public: diff --git a/soh/soh/resource/type/scenecommand/SetCameraSettings.cpp b/soh/soh/resource/type/scenecommand/SetCameraSettings.cpp index e1d2967e7..5c41f1c8f 100644 --- a/soh/soh/resource/type/scenecommand/SetCameraSettings.cpp +++ b/soh/soh/resource/type/scenecommand/SetCameraSettings.cpp @@ -1,6 +1,6 @@ #include "SetCameraSettings.h" -namespace LUS { +namespace SOH { CameraSettings* SetCameraSettings::GetPointer() { return &settings; } @@ -8,4 +8,4 @@ CameraSettings* SetCameraSettings::GetPointer() { size_t SetCameraSettings::GetPointerSize() { return sizeof(CameraSettings); } -} // namespace LUS +} // namespace SOH diff --git a/soh/soh/resource/type/scenecommand/SetCameraSettings.h b/soh/soh/resource/type/scenecommand/SetCameraSettings.h index adbde2e02..1d8062f9a 100644 --- a/soh/soh/resource/type/scenecommand/SetCameraSettings.h +++ b/soh/soh/resource/type/scenecommand/SetCameraSettings.h @@ -7,7 +7,7 @@ #include "SceneCommand.h" #include -namespace LUS { +namespace SOH { typedef struct { int8_t cameraMovement; int32_t worldMapArea; diff --git a/soh/soh/resource/type/scenecommand/SetCollisionHeader.cpp b/soh/soh/resource/type/scenecommand/SetCollisionHeader.cpp index db8cdcb32..a1c22b9ea 100644 --- a/soh/soh/resource/type/scenecommand/SetCollisionHeader.cpp +++ b/soh/soh/resource/type/scenecommand/SetCollisionHeader.cpp @@ -1,6 +1,6 @@ #include "SetCollisionHeader.h" -namespace LUS { +namespace SOH { CollisionHeaderData* SetCollisionHeader::GetPointer() { if (collisionHeader == nullptr) { return nullptr; @@ -14,4 +14,4 @@ size_t SetCollisionHeader::GetPointerSize() { } return collisionHeader->GetPointerSize(); } -} // namespace LUS +} // namespace SOH diff --git a/soh/soh/resource/type/scenecommand/SetCollisionHeader.h b/soh/soh/resource/type/scenecommand/SetCollisionHeader.h index 79573fe74..e2f63d089 100644 --- a/soh/soh/resource/type/scenecommand/SetCollisionHeader.h +++ b/soh/soh/resource/type/scenecommand/SetCollisionHeader.h @@ -9,7 +9,7 @@ #include "soh/resource/type/CollisionHeader.h" // #include -namespace LUS { +namespace SOH { class SetCollisionHeader : public SceneCommand { public: using SceneCommand::SceneCommand; diff --git a/soh/soh/resource/type/scenecommand/SetCsCamera.cpp b/soh/soh/resource/type/scenecommand/SetCsCamera.cpp index d3eafb803..762ee1e65 100644 --- a/soh/soh/resource/type/scenecommand/SetCsCamera.cpp +++ b/soh/soh/resource/type/scenecommand/SetCsCamera.cpp @@ -1,6 +1,6 @@ #include "SetCsCamera.h" -namespace LUS { +namespace SOH { CsCamera* SetCsCamera::GetPointer() { return &csCamera; } @@ -8,4 +8,4 @@ CsCamera* SetCsCamera::GetPointer() { size_t SetCsCamera::GetPointerSize() { return sizeof(CsCamera); } -} // namespace LUS +} // namespace SOH diff --git a/soh/soh/resource/type/scenecommand/SetCsCamera.h b/soh/soh/resource/type/scenecommand/SetCsCamera.h index db0e3d682..c44d9f935 100644 --- a/soh/soh/resource/type/scenecommand/SetCsCamera.h +++ b/soh/soh/resource/type/scenecommand/SetCsCamera.h @@ -7,7 +7,7 @@ #include "SceneCommand.h" #include -namespace LUS { +namespace SOH { typedef struct { } CsCamera; diff --git a/soh/soh/resource/type/scenecommand/SetCutscenes.cpp b/soh/soh/resource/type/scenecommand/SetCutscenes.cpp index 42d1326d5..6643eda47 100644 --- a/soh/soh/resource/type/scenecommand/SetCutscenes.cpp +++ b/soh/soh/resource/type/scenecommand/SetCutscenes.cpp @@ -1,6 +1,6 @@ #include "SetCutscenes.h" -namespace LUS { +namespace SOH { uint32_t* SetCutscenes::GetPointer() { if (cutscene == nullptr) { return nullptr; @@ -14,4 +14,4 @@ size_t SetCutscenes::GetPointerSize() { } return cutscene->GetPointerSize(); } -} // namespace LUS +} // namespace SOH diff --git a/soh/soh/resource/type/scenecommand/SetCutscenes.h b/soh/soh/resource/type/scenecommand/SetCutscenes.h index 482553934..be74770c0 100644 --- a/soh/soh/resource/type/scenecommand/SetCutscenes.h +++ b/soh/soh/resource/type/scenecommand/SetCutscenes.h @@ -9,7 +9,7 @@ #include "soh/resource/type/Cutscene.h" // #include -namespace LUS { +namespace SOH { class SetCutscenes : public SceneCommand { public: using SceneCommand::SceneCommand; diff --git a/soh/soh/resource/type/scenecommand/SetEchoSettings.cpp b/soh/soh/resource/type/scenecommand/SetEchoSettings.cpp index 47cfa85ad..d4b2b1e15 100644 --- a/soh/soh/resource/type/scenecommand/SetEchoSettings.cpp +++ b/soh/soh/resource/type/scenecommand/SetEchoSettings.cpp @@ -1,6 +1,6 @@ #include "SetEchoSettings.h" -namespace LUS { +namespace SOH { EchoSettings* SetEchoSettings::GetPointer() { return &settings; } @@ -8,4 +8,4 @@ EchoSettings* SetEchoSettings::GetPointer() { size_t SetEchoSettings::GetPointerSize() { return sizeof(EchoSettings); } -} // namespace LUS +} // namespace SOH diff --git a/soh/soh/resource/type/scenecommand/SetEchoSettings.h b/soh/soh/resource/type/scenecommand/SetEchoSettings.h index ea2f664d4..30f54d1b3 100644 --- a/soh/soh/resource/type/scenecommand/SetEchoSettings.h +++ b/soh/soh/resource/type/scenecommand/SetEchoSettings.h @@ -7,7 +7,7 @@ #include "SceneCommand.h" #include -namespace LUS { +namespace SOH { typedef struct { int8_t echo; } EchoSettings; diff --git a/soh/soh/resource/type/scenecommand/SetEntranceList.cpp b/soh/soh/resource/type/scenecommand/SetEntranceList.cpp index d33ac189b..e82711da2 100644 --- a/soh/soh/resource/type/scenecommand/SetEntranceList.cpp +++ b/soh/soh/resource/type/scenecommand/SetEntranceList.cpp @@ -1,6 +1,6 @@ #include "SetEntranceList.h" -namespace LUS { +namespace SOH { EntranceEntry* SetEntranceList::GetPointer() { return entrances.data(); } @@ -8,4 +8,4 @@ EntranceEntry* SetEntranceList::GetPointer() { size_t SetEntranceList::GetPointerSize() { return entrances.size() * sizeof(EntranceEntry); } -} // namespace LUS +} // namespace SOH diff --git a/soh/soh/resource/type/scenecommand/SetEntranceList.h b/soh/soh/resource/type/scenecommand/SetEntranceList.h index d31dda78c..7c41b4b04 100644 --- a/soh/soh/resource/type/scenecommand/SetEntranceList.h +++ b/soh/soh/resource/type/scenecommand/SetEntranceList.h @@ -8,7 +8,7 @@ #include "SceneCommand.h" #include -namespace LUS { +namespace SOH { typedef struct { /* 0x00 */ u8 spawn; /* 0x01 */ u8 room; diff --git a/soh/soh/resource/type/scenecommand/SetExitList.cpp b/soh/soh/resource/type/scenecommand/SetExitList.cpp index 99966cdb4..3de483b0e 100644 --- a/soh/soh/resource/type/scenecommand/SetExitList.cpp +++ b/soh/soh/resource/type/scenecommand/SetExitList.cpp @@ -1,6 +1,6 @@ #include "SetExitList.h" -namespace LUS { +namespace SOH { uint16_t* SetExitList::GetPointer() { return exits.data(); } @@ -8,4 +8,4 @@ uint16_t* SetExitList::GetPointer() { size_t SetExitList::GetPointerSize() { return exits.size() * sizeof(int16_t); } -} // namespace LUS +} // namespace SOH diff --git a/soh/soh/resource/type/scenecommand/SetExitList.h b/soh/soh/resource/type/scenecommand/SetExitList.h index c6f0b3f42..f97f11d1e 100644 --- a/soh/soh/resource/type/scenecommand/SetExitList.h +++ b/soh/soh/resource/type/scenecommand/SetExitList.h @@ -7,7 +7,7 @@ #include "SceneCommand.h" #include -namespace LUS { +namespace SOH { class SetExitList : public SceneCommand { public: using SceneCommand::SceneCommand; diff --git a/soh/soh/resource/type/scenecommand/SetLightList.cpp b/soh/soh/resource/type/scenecommand/SetLightList.cpp index c59f75c20..459e957cb 100644 --- a/soh/soh/resource/type/scenecommand/SetLightList.cpp +++ b/soh/soh/resource/type/scenecommand/SetLightList.cpp @@ -1,6 +1,6 @@ #include "SetLightList.h" -namespace LUS { +namespace SOH { LightInfo* SetLightList::GetPointer() { return lightList.data(); } @@ -8,4 +8,4 @@ LightInfo* SetLightList::GetPointer() { size_t SetLightList::GetPointerSize() { return lightList.size() * sizeof(LightInfo); } -} // namespace LUS +} // namespace SOH diff --git a/soh/soh/resource/type/scenecommand/SetLightList.h b/soh/soh/resource/type/scenecommand/SetLightList.h index bbc5aad3d..c3ede1f16 100644 --- a/soh/soh/resource/type/scenecommand/SetLightList.h +++ b/soh/soh/resource/type/scenecommand/SetLightList.h @@ -8,7 +8,7 @@ #include "SceneCommand.h" #include -namespace LUS { +namespace SOH { typedef struct { /* 0x0 */ s16 x; /* 0x2 */ s16 y; diff --git a/soh/soh/resource/type/scenecommand/SetLightingSettings.cpp b/soh/soh/resource/type/scenecommand/SetLightingSettings.cpp index 69127f19c..042062512 100644 --- a/soh/soh/resource/type/scenecommand/SetLightingSettings.cpp +++ b/soh/soh/resource/type/scenecommand/SetLightingSettings.cpp @@ -1,6 +1,6 @@ #include "SetLightingSettings.h" -namespace LUS { +namespace SOH { EnvLightSettings* SetLightingSettings::GetPointer() { return settings.data(); } @@ -8,4 +8,4 @@ EnvLightSettings* SetLightingSettings::GetPointer() { size_t SetLightingSettings::GetPointerSize() { return settings.size() * sizeof(EnvLightSettings); } -} // namespace LUS +} // namespace SOH diff --git a/soh/soh/resource/type/scenecommand/SetLightingSettings.h b/soh/soh/resource/type/scenecommand/SetLightingSettings.h index ca894fec3..b8f08d834 100644 --- a/soh/soh/resource/type/scenecommand/SetLightingSettings.h +++ b/soh/soh/resource/type/scenecommand/SetLightingSettings.h @@ -7,7 +7,7 @@ #include "SceneCommand.h" #include -namespace LUS { +namespace SOH { typedef struct { /* 0x00 */ u8 ambientColor[3]; /* 0x03 */ s8 light1Dir[3]; diff --git a/soh/soh/resource/type/scenecommand/SetMesh.cpp b/soh/soh/resource/type/scenecommand/SetMesh.cpp index 5ecd2cbfa..1e2cd396c 100644 --- a/soh/soh/resource/type/scenecommand/SetMesh.cpp +++ b/soh/soh/resource/type/scenecommand/SetMesh.cpp @@ -1,6 +1,6 @@ #include "SetMesh.h" -namespace LUS { +namespace SOH { MeshHeader* SetMesh::GetPointer() { return &meshHeader; } @@ -8,4 +8,4 @@ MeshHeader* SetMesh::GetPointer() { size_t SetMesh::GetPointerSize() { return sizeof(MeshHeader); } -} // namespace LUS +} // namespace SOH diff --git a/soh/soh/resource/type/scenecommand/SetMesh.h b/soh/soh/resource/type/scenecommand/SetMesh.h index a3a6c9731..33ab24202 100644 --- a/soh/soh/resource/type/scenecommand/SetMesh.h +++ b/soh/soh/resource/type/scenecommand/SetMesh.h @@ -8,7 +8,7 @@ #include "libultraship/libultra.h" #include "z64math.h" -namespace LUS { +namespace SOH { typedef struct { /* 0x00 */ u8 type; } PolygonBase; diff --git a/soh/soh/resource/type/scenecommand/SetObjectList.cpp b/soh/soh/resource/type/scenecommand/SetObjectList.cpp index 921166675..04aeb27d0 100644 --- a/soh/soh/resource/type/scenecommand/SetObjectList.cpp +++ b/soh/soh/resource/type/scenecommand/SetObjectList.cpp @@ -1,6 +1,6 @@ #include "SetObjectList.h" -namespace LUS { +namespace SOH { int16_t* SetObjectList::GetPointer() { return objects.data(); } @@ -8,4 +8,4 @@ int16_t* SetObjectList::GetPointer() { size_t SetObjectList::GetPointerSize() { return objects.size() * sizeof(int16_t); } -} // namespace LUS +} // namespace SOH diff --git a/soh/soh/resource/type/scenecommand/SetObjectList.h b/soh/soh/resource/type/scenecommand/SetObjectList.h index c6f786636..e843d4db0 100644 --- a/soh/soh/resource/type/scenecommand/SetObjectList.h +++ b/soh/soh/resource/type/scenecommand/SetObjectList.h @@ -8,7 +8,7 @@ #include "SceneCommand.h" #include -namespace LUS { +namespace SOH { class SetObjectList : public SceneCommand { public: using SceneCommand::SceneCommand; diff --git a/soh/soh/resource/type/scenecommand/SetPathways.cpp b/soh/soh/resource/type/scenecommand/SetPathways.cpp index b69108ea6..fe1d7c5d8 100644 --- a/soh/soh/resource/type/scenecommand/SetPathways.cpp +++ b/soh/soh/resource/type/scenecommand/SetPathways.cpp @@ -1,6 +1,6 @@ #include "SetPathways.h" -namespace LUS { +namespace SOH { PathData** SetPathways::GetPointer() { return paths.data(); } @@ -8,4 +8,4 @@ PathData** SetPathways::GetPointer() { size_t SetPathways::GetPointerSize() { return paths.size() * sizeof(PathData*); } -} // namespace LUS +} // namespace SOH diff --git a/soh/soh/resource/type/scenecommand/SetPathways.h b/soh/soh/resource/type/scenecommand/SetPathways.h index 5846c382f..cf875cf5e 100644 --- a/soh/soh/resource/type/scenecommand/SetPathways.h +++ b/soh/soh/resource/type/scenecommand/SetPathways.h @@ -8,7 +8,7 @@ // #include #include "soh/resource/type/Path.h" -namespace LUS { +namespace SOH { class SetPathways : public SceneCommand { public: diff --git a/soh/soh/resource/type/scenecommand/SetRoomBehavior.cpp b/soh/soh/resource/type/scenecommand/SetRoomBehavior.cpp index deababc87..11bb4e95f 100644 --- a/soh/soh/resource/type/scenecommand/SetRoomBehavior.cpp +++ b/soh/soh/resource/type/scenecommand/SetRoomBehavior.cpp @@ -1,6 +1,6 @@ #include "SetRoomBehavior.h" -namespace LUS { +namespace SOH { RoomBehavior* SetRoomBehavior::GetPointer() { return &roomBehavior; } @@ -8,4 +8,4 @@ RoomBehavior* SetRoomBehavior::GetPointer() { size_t SetRoomBehavior::GetPointerSize() { return sizeof(RoomBehavior); } -} // namespace LUS +} // namespace SOH diff --git a/soh/soh/resource/type/scenecommand/SetRoomBehavior.h b/soh/soh/resource/type/scenecommand/SetRoomBehavior.h index c2a28176e..c05e96a66 100644 --- a/soh/soh/resource/type/scenecommand/SetRoomBehavior.h +++ b/soh/soh/resource/type/scenecommand/SetRoomBehavior.h @@ -7,7 +7,7 @@ #include "SceneCommand.h" #include -namespace LUS { +namespace SOH { typedef struct { int8_t gameplayFlags; int32_t gameplayFlags2; diff --git a/soh/soh/resource/type/scenecommand/SetRoomList.cpp b/soh/soh/resource/type/scenecommand/SetRoomList.cpp index cf8c1d61a..c81d3645e 100644 --- a/soh/soh/resource/type/scenecommand/SetRoomList.cpp +++ b/soh/soh/resource/type/scenecommand/SetRoomList.cpp @@ -1,6 +1,6 @@ #include "SetRoomList.h" -namespace LUS { +namespace SOH { RomFile* SetRoomList::GetPointer() { return rooms.data(); } @@ -8,4 +8,4 @@ RomFile* SetRoomList::GetPointer() { size_t SetRoomList::GetPointerSize() { return rooms.size() * sizeof(RomFile); } -} // namespace LUS +} // namespace SOH diff --git a/soh/soh/resource/type/scenecommand/SetRoomList.h b/soh/soh/resource/type/scenecommand/SetRoomList.h index 66d83dc9c..09ba46f22 100644 --- a/soh/soh/resource/type/scenecommand/SetRoomList.h +++ b/soh/soh/resource/type/scenecommand/SetRoomList.h @@ -10,7 +10,7 @@ #include -namespace LUS { +namespace SOH { // typedef struct { // /* 0x00 */ uintptr_t vromStart; // /* 0x04 */ uintptr_t vromEnd; diff --git a/soh/soh/resource/type/scenecommand/SetSkyboxModifier.cpp b/soh/soh/resource/type/scenecommand/SetSkyboxModifier.cpp index 9926ec01a..122d93d77 100644 --- a/soh/soh/resource/type/scenecommand/SetSkyboxModifier.cpp +++ b/soh/soh/resource/type/scenecommand/SetSkyboxModifier.cpp @@ -1,6 +1,6 @@ #include "SetSkyboxModifier.h" -namespace LUS { +namespace SOH { SkyboxModifier* SetSkyboxModifier::GetPointer() { return &modifier; } @@ -8,4 +8,4 @@ SkyboxModifier* SetSkyboxModifier::GetPointer() { size_t SetSkyboxModifier::GetPointerSize() { return sizeof(SkyboxModifier); } -} // namespace LUS +} // namespace SOH diff --git a/soh/soh/resource/type/scenecommand/SetSkyboxModifier.h b/soh/soh/resource/type/scenecommand/SetSkyboxModifier.h index 6a54879e6..a60adfcaf 100644 --- a/soh/soh/resource/type/scenecommand/SetSkyboxModifier.h +++ b/soh/soh/resource/type/scenecommand/SetSkyboxModifier.h @@ -7,7 +7,7 @@ #include "SceneCommand.h" #include -namespace LUS { +namespace SOH { typedef struct { uint8_t skyboxDisabled; uint8_t sunMoonDisabled; diff --git a/soh/soh/resource/type/scenecommand/SetSkyboxSettings.cpp b/soh/soh/resource/type/scenecommand/SetSkyboxSettings.cpp index 7f12d4fa3..527f0462c 100644 --- a/soh/soh/resource/type/scenecommand/SetSkyboxSettings.cpp +++ b/soh/soh/resource/type/scenecommand/SetSkyboxSettings.cpp @@ -1,6 +1,6 @@ #include "SetSkyboxSettings.h" -namespace LUS { +namespace SOH { SkyboxSettings* SetSkyboxSettings::GetPointer() { return &settings; } @@ -8,4 +8,4 @@ SkyboxSettings* SetSkyboxSettings::GetPointer() { size_t SetSkyboxSettings::GetPointerSize() { return sizeof(SetSkyboxSettings); } -} // namespace LUS +} // namespace SOH diff --git a/soh/soh/resource/type/scenecommand/SetSkyboxSettings.h b/soh/soh/resource/type/scenecommand/SetSkyboxSettings.h index a2a9593b0..f256e103e 100644 --- a/soh/soh/resource/type/scenecommand/SetSkyboxSettings.h +++ b/soh/soh/resource/type/scenecommand/SetSkyboxSettings.h @@ -7,7 +7,7 @@ #include "SceneCommand.h" #include -namespace LUS { +namespace SOH { typedef struct { uint8_t unk; uint8_t skyboxId; diff --git a/soh/soh/resource/type/scenecommand/SetSoundSettings.cpp b/soh/soh/resource/type/scenecommand/SetSoundSettings.cpp index f6f1941d1..c136d34db 100644 --- a/soh/soh/resource/type/scenecommand/SetSoundSettings.cpp +++ b/soh/soh/resource/type/scenecommand/SetSoundSettings.cpp @@ -1,6 +1,6 @@ #include "SetSoundSettings.h" -namespace LUS { +namespace SOH { SoundSettings* SetSoundSettings::GetPointer() { return &settings; } @@ -8,4 +8,4 @@ SoundSettings* SetSoundSettings::GetPointer() { size_t SetSoundSettings::GetPointerSize() { return sizeof(SoundSettings); } -} // namespace LUS +} // namespace SOH diff --git a/soh/soh/resource/type/scenecommand/SetSoundSettings.h b/soh/soh/resource/type/scenecommand/SetSoundSettings.h index c4ee4668d..b72c2b74d 100644 --- a/soh/soh/resource/type/scenecommand/SetSoundSettings.h +++ b/soh/soh/resource/type/scenecommand/SetSoundSettings.h @@ -7,7 +7,7 @@ #include "SceneCommand.h" #include -namespace LUS { +namespace SOH { typedef struct { uint8_t seqId; uint8_t natureAmbienceId; diff --git a/soh/soh/resource/type/scenecommand/SetSpecialObjects.cpp b/soh/soh/resource/type/scenecommand/SetSpecialObjects.cpp index 3887107da..304ab514c 100644 --- a/soh/soh/resource/type/scenecommand/SetSpecialObjects.cpp +++ b/soh/soh/resource/type/scenecommand/SetSpecialObjects.cpp @@ -1,6 +1,6 @@ #include "SetSpecialObjects.h" -namespace LUS { +namespace SOH { SpecialObjects* SetSpecialObjects::GetPointer() { return &specialObjects; } @@ -8,4 +8,4 @@ SpecialObjects* SetSpecialObjects::GetPointer() { size_t SetSpecialObjects::GetPointerSize() { return sizeof(SpecialObjects); } -} // namespace LUS +} // namespace SOH diff --git a/soh/soh/resource/type/scenecommand/SetSpecialObjects.h b/soh/soh/resource/type/scenecommand/SetSpecialObjects.h index 78cfcd425..2a8906461 100644 --- a/soh/soh/resource/type/scenecommand/SetSpecialObjects.h +++ b/soh/soh/resource/type/scenecommand/SetSpecialObjects.h @@ -7,7 +7,7 @@ #include "SceneCommand.h" #include -namespace LUS { +namespace SOH { typedef struct { int8_t elfMessage; int16_t globalObject; diff --git a/soh/soh/resource/type/scenecommand/SetStartPositionList.cpp b/soh/soh/resource/type/scenecommand/SetStartPositionList.cpp index 89fb40049..5fa17b2a0 100644 --- a/soh/soh/resource/type/scenecommand/SetStartPositionList.cpp +++ b/soh/soh/resource/type/scenecommand/SetStartPositionList.cpp @@ -1,6 +1,6 @@ #include "SetStartPositionList.h" -namespace LUS { +namespace SOH { ActorEntry* SetStartPositionList::GetPointer() { return startPositions.data(); } @@ -8,4 +8,4 @@ ActorEntry* SetStartPositionList::GetPointer() { size_t SetStartPositionList::GetPointerSize() { return startPositions.size() * sizeof(ActorEntry); } -} // namespace LUS +} // namespace SOH diff --git a/soh/soh/resource/type/scenecommand/SetStartPositionList.h b/soh/soh/resource/type/scenecommand/SetStartPositionList.h index 1c5d4242f..28d2d0d31 100644 --- a/soh/soh/resource/type/scenecommand/SetStartPositionList.h +++ b/soh/soh/resource/type/scenecommand/SetStartPositionList.h @@ -9,7 +9,7 @@ #include "soh/resource/type/scenecommand/SetActorList.h" // #include -namespace LUS { +namespace SOH { // typedef struct { // /* 0x00 */ s16 id; // /* 0x02 */ Vec3s pos; diff --git a/soh/soh/resource/type/scenecommand/SetTimeSettings.cpp b/soh/soh/resource/type/scenecommand/SetTimeSettings.cpp index 9a10fb022..c9380a0a0 100644 --- a/soh/soh/resource/type/scenecommand/SetTimeSettings.cpp +++ b/soh/soh/resource/type/scenecommand/SetTimeSettings.cpp @@ -1,6 +1,6 @@ #include "SetTimeSettings.h" -namespace LUS { +namespace SOH { TimeSettings* SetTimeSettings::GetPointer() { return &settings; } @@ -8,4 +8,4 @@ TimeSettings* SetTimeSettings::GetPointer() { size_t SetTimeSettings::GetPointerSize() { return sizeof(TimeSettings); } -} // namespace LUS +} // namespace SOH diff --git a/soh/soh/resource/type/scenecommand/SetTimeSettings.h b/soh/soh/resource/type/scenecommand/SetTimeSettings.h index 637398652..cd47e33dc 100644 --- a/soh/soh/resource/type/scenecommand/SetTimeSettings.h +++ b/soh/soh/resource/type/scenecommand/SetTimeSettings.h @@ -7,7 +7,7 @@ #include "SceneCommand.h" #include -namespace LUS { +namespace SOH { typedef struct { uint8_t hour; uint8_t minute; diff --git a/soh/soh/resource/type/scenecommand/SetTransitionActorList.cpp b/soh/soh/resource/type/scenecommand/SetTransitionActorList.cpp index 86387e682..c944e99f2 100644 --- a/soh/soh/resource/type/scenecommand/SetTransitionActorList.cpp +++ b/soh/soh/resource/type/scenecommand/SetTransitionActorList.cpp @@ -1,6 +1,6 @@ #include "SetTransitionActorList.h" -namespace LUS { +namespace SOH { TransitionActorEntry* SetTransitionActorList::GetPointer() { return transitionActorList.data(); } @@ -8,4 +8,4 @@ TransitionActorEntry* SetTransitionActorList::GetPointer() { size_t SetTransitionActorList::GetPointerSize() { return transitionActorList.size() * sizeof(TransitionActorEntry); } -} // namespace LUS +} // namespace SOH diff --git a/soh/soh/resource/type/scenecommand/SetTransitionActorList.h b/soh/soh/resource/type/scenecommand/SetTransitionActorList.h index bb6fc2ac6..389526b0d 100644 --- a/soh/soh/resource/type/scenecommand/SetTransitionActorList.h +++ b/soh/soh/resource/type/scenecommand/SetTransitionActorList.h @@ -9,7 +9,7 @@ // #include #include "z64math.h" -namespace LUS { +namespace SOH { typedef struct { struct { s8 room; // Room to switch to diff --git a/soh/soh/resource/type/scenecommand/SetWindSettings.cpp b/soh/soh/resource/type/scenecommand/SetWindSettings.cpp index 3aa9ce7a6..64bc8ecc8 100644 --- a/soh/soh/resource/type/scenecommand/SetWindSettings.cpp +++ b/soh/soh/resource/type/scenecommand/SetWindSettings.cpp @@ -1,6 +1,6 @@ #include "SetWindSettings.h" -namespace LUS { +namespace SOH { WindSettings* SetWindSettings::GetPointer() { return &settings; } @@ -8,4 +8,4 @@ WindSettings* SetWindSettings::GetPointer() { size_t SetWindSettings::GetPointerSize() { return sizeof(WindSettings); } -} // namespace LUS +} // namespace SOH diff --git a/soh/soh/resource/type/scenecommand/SetWindSettings.h b/soh/soh/resource/type/scenecommand/SetWindSettings.h index e79b445ae..f3f9da968 100644 --- a/soh/soh/resource/type/scenecommand/SetWindSettings.h +++ b/soh/soh/resource/type/scenecommand/SetWindSettings.h @@ -7,7 +7,7 @@ #include "SceneCommand.h" #include -namespace LUS { +namespace SOH { typedef struct { int8_t windWest; int8_t windVertical; diff --git a/soh/soh/z_message_OTR.cpp b/soh/soh/z_message_OTR.cpp index ce594879a..05432fc53 100644 --- a/soh/soh/z_message_OTR.cpp +++ b/soh/soh/z_message_OTR.cpp @@ -15,7 +15,7 @@ extern "C" MessageTableEntry* sFraMessageEntryTablePtr; extern "C" MessageTableEntry* sStaffMessageEntryTablePtr; //extern "C" MessageTableEntry* _message_0xFFFC_nes; -static void SetMessageEntry(MessageTableEntry& entry, const LUS::MessageEntry& msgEntry) { +static void SetMessageEntry(MessageTableEntry& entry, const SOH::MessageEntry& msgEntry) { entry.textId = msgEntry.id; entry.typePos = (msgEntry.textboxType << 4) | msgEntry.textboxYPos; entry.segment = msgEntry.msg.c_str(); @@ -26,7 +26,7 @@ static void OTRMessage_LoadCustom(const std::string& folderPath, MessageTableEnt auto lst = *LUS::Context::GetInstance()->GetResourceManager()->GetArchiveManager()->ListFiles(folderPath).get(); for (auto& tPath : lst) { - auto file = std::static_pointer_cast(LUS::Context::GetInstance()->GetResourceManager()->LoadResource(tPath)); + auto file = std::static_pointer_cast(LUS::Context::GetInstance()->GetResourceManager()->LoadResource(tPath)); for (size_t j = 0; j < file->messages.size(); ++j) { // Check if same text ID exists already @@ -43,7 +43,7 @@ static void OTRMessage_LoadCustom(const std::string& folderPath, MessageTableEnt } MessageTableEntry* OTRMessage_LoadTable(const std::string& filePath, bool isNES) { - auto file = std::static_pointer_cast(LUS::Context::GetInstance()->GetResourceManager()->LoadResource(filePath)); + auto file = std::static_pointer_cast(LUS::Context::GetInstance()->GetResourceManager()->LoadResource(filePath)); if (file == nullptr) return nullptr; @@ -120,7 +120,7 @@ extern "C" void OTRMessage_Init() if (sStaffMessageEntryTablePtr == NULL) { auto file2 = - std::static_pointer_cast(LUS::Context::GetInstance()->GetResourceManager()->LoadResource( + std::static_pointer_cast(LUS::Context::GetInstance()->GetResourceManager()->LoadResource( "text/staff_message_data_static/staff_message_data_static")); // OTRTODO: Should not be malloc'ing here. It's fine for now since we check that the message table is already null. sStaffMessageEntryTablePtr = (MessageTableEntry*)malloc(sizeof(MessageTableEntry) * file2->messages.size()); diff --git a/soh/soh/z_play_otr.cpp b/soh/soh/z_play_otr.cpp index 828380ea7..522a24eb8 100644 --- a/soh/soh/z_play_otr.cpp +++ b/soh/soh/z_play_otr.cpp @@ -10,7 +10,7 @@ extern "C" void Play_InitScene(PlayState * play, s32 spawn); extern "C" void Play_InitEnvironment(PlayState * play, s16 skyboxId); void OTRPlay_InitScene(PlayState* play, s32 spawn); -s32 OTRScene_ExecuteCommands(PlayState* play, LUS::Scene* scene); +s32 OTRScene_ExecuteCommands(PlayState* play, SOH::Scene* scene); //LUS::OTRResource* OTRPlay_LoadFile(PlayState* play, RomFile* file) { LUS::IResource* OTRPlay_LoadFile(PlayState* play, const char* fileName) @@ -75,7 +75,7 @@ void OTRPlay_InitScene(PlayState* play, s32 spawn) { func_80096FD4(play, &play->roomCtx.curRoom); YREG(15) = 0; gSaveContext.worldMapArea = 0; - OTRScene_ExecuteCommands(play, (LUS::Scene*)play->sceneSegment); + OTRScene_ExecuteCommands(play, (SOH::Scene*)play->sceneSegment); Play_InitEnvironment(play, play->skyboxId); // Unpause the timer for Boss Rush when the scene loaded isn't the Chamber of Sages. if (IS_BOSS_RUSH && play->sceneNum != SCENE_CHAMBER_OF_THE_SAGES) { diff --git a/soh/soh/z_scene_otr.cpp b/soh/soh/z_scene_otr.cpp index 8bfb13308..9367fa8db 100644 --- a/soh/soh/z_scene_otr.cpp +++ b/soh/soh/z_scene_otr.cpp @@ -37,7 +37,7 @@ extern LUS::IResource* OTRPlay_LoadFile(PlayState* play, const char* fileName); extern "C" s32 Object_Spawn(ObjectContext* objectCtx, s16 objectId); extern "C" RomFile sNaviMsgFiles[]; -s32 OTRScene_ExecuteCommands(PlayState* play, LUS::Scene* scene); +s32 OTRScene_ExecuteCommands(PlayState* play, SOH::Scene* scene); std::shared_ptr ResourceMgr_LoadFile(const char* path) { std::string Path = path; @@ -53,9 +53,9 @@ std::shared_ptr ResourceMgr_LoadFile(const char* path) { // Forward Declaration of function declared in OTRGlobals.cpp std::shared_ptr GetResourceByNameHandlingMQ(const char* path); -bool Scene_CommandSpawnList(PlayState* play, LUS::ISceneCommand* cmd) { - // LUS::SetStartPositionList* cmdStartPos = std::static_pointer_cast(cmd); - LUS::SetStartPositionList* cmdStartPos = (LUS::SetStartPositionList*)cmd; +bool Scene_CommandSpawnList(PlayState* play, SOH::ISceneCommand* cmd) { + // SOH::SetStartPositionList* cmdStartPos = std::static_pointer_cast(cmd); + SOH::SetStartPositionList* cmdStartPos = (SOH::SetStartPositionList*)cmd; ActorEntry* entries = (ActorEntry*)cmdStartPos->GetRawPointer(); play->linkActorEntry = &entries[play->setupEntranceList[play->curSpawn].spawn]; @@ -67,9 +67,9 @@ bool Scene_CommandSpawnList(PlayState* play, LUS::ISceneCommand* cmd) { return false; } -bool Scene_CommandActorList(PlayState* play, LUS::ISceneCommand* cmd) { - // LUS::SetActorList* cmdActor = std::static_pointer_cast(cmd); - LUS::SetActorList* cmdActor = (LUS::SetActorList*)cmd; +bool Scene_CommandActorList(PlayState* play, SOH::ISceneCommand* cmd) { + // SOH::SetActorList* cmdActor = std::static_pointer_cast(cmd); + SOH::SetActorList* cmdActor = (SOH::SetActorList*)cmd; play->numSetupActors = cmdActor->numActors; play->setupActorList = (ActorEntry*)cmdActor->GetRawPointer(); @@ -77,24 +77,24 @@ bool Scene_CommandActorList(PlayState* play, LUS::ISceneCommand* cmd) { return false; } -bool Scene_CommandUnused2(PlayState* play, LUS::ISceneCommand* cmd) { +bool Scene_CommandUnused2(PlayState* play, SOH::ISceneCommand* cmd) { // OTRTODO: Do we need to implement this? // play->unk_11DFC = SEGMENTED_TO_VIRTUAL(cmd->unused02.segment); return false; } -bool Scene_CommandCollisionHeader(PlayState* play, LUS::ISceneCommand* cmd) { - // LUS::SetCollisionHeader* cmdCol = std::static_pointer_cast(cmd); - LUS::SetCollisionHeader* cmdCol = (LUS::SetCollisionHeader*)cmd; +bool Scene_CommandCollisionHeader(PlayState* play, SOH::ISceneCommand* cmd) { + // SOH::SetCollisionHeader* cmdCol = std::static_pointer_cast(cmd); + SOH::SetCollisionHeader* cmdCol = (SOH::SetCollisionHeader*)cmd; BgCheck_Allocate(&play->colCtx, play, (CollisionHeader*)cmdCol->GetRawPointer()); return false; } -bool Scene_CommandRoomList(PlayState* play, LUS::ISceneCommand* cmd) { - // LUS::SetRoomList* cmdRoomList = std::static_pointer_cast(cmd); - LUS::SetRoomList* cmdRoomList = (LUS::SetRoomList*)cmd; +bool Scene_CommandRoomList(PlayState* play, SOH::ISceneCommand* cmd) { + // SOH::SetRoomList* cmdRoomList = std::static_pointer_cast(cmd); + SOH::SetRoomList* cmdRoomList = (SOH::SetRoomList*)cmd; play->numRooms = cmdRoomList->numRooms; play->roomList = (RomFile*)cmdRoomList->GetRawPointer(); @@ -102,17 +102,17 @@ bool Scene_CommandRoomList(PlayState* play, LUS::ISceneCommand* cmd) { return false; } -bool Scene_CommandEntranceList(PlayState* play, LUS::ISceneCommand* cmd) { - // LUS::SetEntranceList* otrEntrance = std::static_pointer_cast(cmd); - LUS::SetEntranceList* otrEntrance = (LUS::SetEntranceList*)cmd; +bool Scene_CommandEntranceList(PlayState* play, SOH::ISceneCommand* cmd) { + // SOH::SetEntranceList* otrEntrance = std::static_pointer_cast(cmd); + SOH::SetEntranceList* otrEntrance = (SOH::SetEntranceList*)cmd; play->setupEntranceList = (EntranceEntry*)otrEntrance->GetRawPointer(); return false; } -bool Scene_CommandSpecialFiles(PlayState* play, LUS::ISceneCommand* cmd) { - // LUS::SetSpecialObjects* specialCmd = std::static_pointer_cast(cmd); - LUS::SetSpecialObjects* specialCmd = (LUS::SetSpecialObjects*)cmd; +bool Scene_CommandSpecialFiles(PlayState* play, SOH::ISceneCommand* cmd) { + // SOH::SetSpecialObjects* specialCmd = std::static_pointer_cast(cmd); + SOH::SetSpecialObjects* specialCmd = (SOH::SetSpecialObjects*)cmd; if (specialCmd->specialObjects.globalObject != 0) { play->objectCtx.subKeepIndex = Object_Spawn(&play->objectCtx, specialCmd->specialObjects.globalObject); @@ -127,9 +127,9 @@ bool Scene_CommandSpecialFiles(PlayState* play, LUS::ISceneCommand* cmd) { return false; } -bool Scene_CommandRoomBehavior(PlayState* play, LUS::ISceneCommand* cmd) { - // LUS::SetRoomBehavior* cmdRoom = std::static_pointer_cast(cmd); - LUS::SetRoomBehavior* cmdRoom = (LUS::SetRoomBehavior*)cmd; +bool Scene_CommandRoomBehavior(PlayState* play, SOH::ISceneCommand* cmd) { + // SOH::SetRoomBehavior* cmdRoom = std::static_pointer_cast(cmd); + SOH::SetRoomBehavior* cmdRoom = (SOH::SetRoomBehavior*)cmd; play->roomCtx.curRoom.behaviorType1 = cmdRoom->roomBehavior.gameplayFlags; play->roomCtx.curRoom.behaviorType2 = cmdRoom->roomBehavior.gameplayFlags2 & 0xFF; @@ -139,9 +139,9 @@ bool Scene_CommandRoomBehavior(PlayState* play, LUS::ISceneCommand* cmd) { return false; } -bool Scene_CommandMeshHeader(PlayState* play, LUS::ISceneCommand* cmd) { - // LUS::SetMesh* otrMesh = static_pointer_cast(cmd); - LUS::SetMesh* otrMesh = (LUS::SetMesh*)cmd; +bool Scene_CommandMeshHeader(PlayState* play, SOH::ISceneCommand* cmd) { + // SOH::SetMesh* otrMesh = static_pointer_cast(cmd); + SOH::SetMesh* otrMesh = (SOH::SetMesh*)cmd; play->roomCtx.curRoom.meshHeader = (MeshHeader*)otrMesh->GetRawPointer(); return false; @@ -156,9 +156,9 @@ bool OTRfunc_800982FC(ObjectContext* objectCtx, s32 bankIndex, s16 objectId) { return false; } -bool Scene_CommandObjectList(PlayState* play, LUS::ISceneCommand* cmd) { - // LUS::SetObjectList* cmdObj = static_pointer_cast(cmd); - LUS::SetObjectList* cmdObj = (LUS::SetObjectList*)cmd; +bool Scene_CommandObjectList(PlayState* play, SOH::ISceneCommand* cmd) { + // SOH::SetObjectList* cmdObj = static_pointer_cast(cmd); + SOH::SetObjectList* cmdObj = (SOH::SetObjectList*)cmd; s32 i; s32 j; @@ -199,9 +199,9 @@ bool Scene_CommandObjectList(PlayState* play, LUS::ISceneCommand* cmd) { return false; } -bool Scene_CommandLightList(PlayState* play, LUS::ISceneCommand* cmd) { - // LUS::SetLightList* cmdLight = static_pointer_cast(cmd); - LUS::SetLightList* cmdLight = (LUS::SetLightList*)cmd; +bool Scene_CommandLightList(PlayState* play, SOH::ISceneCommand* cmd) { + // SOH::SetLightList* cmdLight = static_pointer_cast(cmd); + SOH::SetLightList* cmdLight = (SOH::SetLightList*)cmd; for (size_t i = 0; i < cmdLight->lightList.size(); i++) { LightContext_InsertLight(play, &play->lightCtx, (LightInfo*)&cmdLight->lightList[i]); @@ -210,17 +210,17 @@ bool Scene_CommandLightList(PlayState* play, LUS::ISceneCommand* cmd) { return false; } -bool Scene_CommandPathList(PlayState* play, LUS::ISceneCommand* cmd) { - // LUS::SetPathways* cmdPath = static_pointer_cast(cmd); - LUS::SetPathways* cmdPath = (LUS::SetPathways*)cmd; +bool Scene_CommandPathList(PlayState* play, SOH::ISceneCommand* cmd) { + // SOH::SetPathways* cmdPath = static_pointer_cast(cmd); + SOH::SetPathways* cmdPath = (SOH::SetPathways*)cmd; play->setupPathList = (Path*)(cmdPath->GetPointer()[0]); return false; } -bool Scene_CommandTransitionActorList(PlayState* play, LUS::ISceneCommand* cmd) { - // LUS::SetTransitionActorList* cmdActor = static_pointer_cast(cmd); - LUS::SetTransitionActorList* cmdActor = (LUS::SetTransitionActorList*)cmd; +bool Scene_CommandTransitionActorList(PlayState* play, SOH::ISceneCommand* cmd) { + // SOH::SetTransitionActorList* cmdActor = static_pointer_cast(cmd); + SOH::SetTransitionActorList* cmdActor = (SOH::SetTransitionActorList*)cmd; play->transiActorCtx.numActors = cmdActor->numTransitionActors; play->transiActorCtx.list = (TransitionActorEntry*)cmdActor->GetRawPointer(); @@ -232,16 +232,16 @@ bool Scene_CommandTransitionActorList(PlayState* play, LUS::ISceneCommand* cmd) // transiActorCtx->numActors = 0; //} -bool Scene_CommandLightSettingsList(PlayState* play, LUS::ISceneCommand* cmd) { +bool Scene_CommandLightSettingsList(PlayState* play, SOH::ISceneCommand* cmd) { play->envCtx.lightSettingsList = (EnvLightSettings*)cmd->GetRawPointer(); return false; } // Scene Command 0x11: Skybox Settings -bool Scene_CommandSkyboxSettings(PlayState* play, LUS::ISceneCommand* cmd) { - // LUS::SetSkyboxSettings* cmdSky = static_pointer_cast(cmd); - LUS::SetSkyboxSettings* cmdSky = (LUS::SetSkyboxSettings*)cmd; +bool Scene_CommandSkyboxSettings(PlayState* play, SOH::ISceneCommand* cmd) { + // SOH::SetSkyboxSettings* cmdSky = static_pointer_cast(cmd); + SOH::SetSkyboxSettings* cmdSky = (SOH::SetSkyboxSettings*)cmd; play->skyboxId = cmdSky->settings.skyboxId; play->envCtx.unk_17 = play->envCtx.unk_18 = cmdSky->settings.weather; @@ -250,9 +250,9 @@ bool Scene_CommandSkyboxSettings(PlayState* play, LUS::ISceneCommand* cmd) { return false; } -bool Scene_CommandSkyboxDisables(PlayState* play, LUS::ISceneCommand* cmd) { - // LUS::SetSkyboxModifier* cmdSky = static_pointer_cast(cmd); - LUS::SetSkyboxModifier* cmdSky = (LUS::SetSkyboxModifier*)cmd; +bool Scene_CommandSkyboxDisables(PlayState* play, SOH::ISceneCommand* cmd) { + // SOH::SetSkyboxModifier* cmdSky = static_pointer_cast(cmd); + SOH::SetSkyboxModifier* cmdSky = (SOH::SetSkyboxModifier*)cmd; play->envCtx.sunMoonDisabled = cmdSky->modifier.sunMoonDisabled; play->envCtx.skyboxDisabled = cmdSky->modifier.skyboxDisabled; @@ -260,9 +260,9 @@ bool Scene_CommandSkyboxDisables(PlayState* play, LUS::ISceneCommand* cmd) { return false; } -bool Scene_CommandTimeSettings(PlayState* play, LUS::ISceneCommand* cmd) { - // LUS::SetTimeSettings* cmdTime = static_pointer_cast(cmd); - LUS::SetTimeSettings* cmdTime = (LUS::SetTimeSettings*)cmd; +bool Scene_CommandTimeSettings(PlayState* play, SOH::ISceneCommand* cmd) { + // SOH::SetTimeSettings* cmdTime = static_pointer_cast(cmd); + SOH::SetTimeSettings* cmdTime = (SOH::SetTimeSettings*)cmd; if ((cmdTime->settings.hour != 0xFF) && (cmdTime->settings.minute != 0xFF)) { gSaveContext.skyboxTime = gSaveContext.dayTime = @@ -300,9 +300,9 @@ bool Scene_CommandTimeSettings(PlayState* play, LUS::ISceneCommand* cmd) { return false; } -bool Scene_CommandWindSettings(PlayState* play, LUS::ISceneCommand* cmd) { - // LUS::SetWind* cmdWind = std::static_pointer_cast(cmd); - LUS::SetWindSettings* cmdWind = (LUS::SetWindSettings*)cmd; +bool Scene_CommandWindSettings(PlayState* play, SOH::ISceneCommand* cmd) { + // SOH::SetWind* cmdWind = std::static_pointer_cast(cmd); + SOH::SetWindSettings* cmdWind = (SOH::SetWindSettings*)cmd; play->envCtx.windDirection.x = cmdWind->settings.windWest; play->envCtx.windDirection.y = cmdWind->settings.windVertical; @@ -313,19 +313,19 @@ bool Scene_CommandWindSettings(PlayState* play, LUS::ISceneCommand* cmd) { return false; } -bool Scene_CommandExitList(PlayState* play, LUS::ISceneCommand* cmd) { +bool Scene_CommandExitList(PlayState* play, SOH::ISceneCommand* cmd) { play->setupExitList = (s16*)cmd->GetRawPointer(); return false; } -bool Scene_CommandUndefined9(PlayState* play, LUS::ISceneCommand* cmd) { +bool Scene_CommandUndefined9(PlayState* play, SOH::ISceneCommand* cmd) { return false; } -bool Scene_CommandSoundSettings(PlayState* play, LUS::ISceneCommand* cmd) { - // LUS::SetSoundSettings* cmdSnd = static_pointer_cast(cmd); - LUS::SetSoundSettings* cmdSnd = (LUS::SetSoundSettings*)cmd; +bool Scene_CommandSoundSettings(PlayState* play, SOH::ISceneCommand* cmd) { + // SOH::SetSoundSettings* cmdSnd = static_pointer_cast(cmd); + SOH::SetSoundSettings* cmdSnd = (SOH::SetSoundSettings*)cmd; play->sequenceCtx.seqId = cmdSnd->settings.seqId; play->sequenceCtx.natureAmbienceId = cmdSnd->settings.natureAmbienceId; @@ -337,18 +337,18 @@ bool Scene_CommandSoundSettings(PlayState* play, LUS::ISceneCommand* cmd) { return false; } -bool Scene_CommandEchoSettings(PlayState* play, LUS::ISceneCommand* cmd) { - // LUS::SetEchoSettings* cmdEcho = static_pointer_cast(cmd); - LUS::SetEchoSettings* cmdEcho = (LUS::SetEchoSettings*)cmd; +bool Scene_CommandEchoSettings(PlayState* play, SOH::ISceneCommand* cmd) { + // SOH::SetEchoSettings* cmdEcho = static_pointer_cast(cmd); + SOH::SetEchoSettings* cmdEcho = (SOH::SetEchoSettings*)cmd; play->roomCtx.curRoom.echo = cmdEcho->settings.echo; return false; } -bool Scene_CommandAlternateHeaderList(PlayState* play, LUS::ISceneCommand* cmd) { - // LUS::SetAlternateHeaders* cmdHeaders = static_pointer_cast(cmd); - LUS::SetAlternateHeaders* cmdHeaders = (LUS::SetAlternateHeaders*)cmd; +bool Scene_CommandAlternateHeaderList(PlayState* play, SOH::ISceneCommand* cmd) { + // SOH::SetAlternateHeaders* cmdHeaders = static_pointer_cast(cmd); + SOH::SetAlternateHeaders* cmdHeaders = (SOH::SetAlternateHeaders*)cmd; // s32 pad; // SceneCmd* altHeader; @@ -358,8 +358,8 @@ bool Scene_CommandAlternateHeaderList(PlayState* play, LUS::ISceneCommand* cmd) // osSyncPrintf("\n[ZU]sceneset counter=[%X]", ((void)0, gSaveContext.sceneSetupIndex)); if (gSaveContext.sceneSetupIndex != 0) { - LUS::Scene* desiredHeader = - std::static_pointer_cast(cmdHeaders->headers[gSaveContext.sceneSetupIndex - 1]).get(); + SOH::Scene* desiredHeader = + std::static_pointer_cast(cmdHeaders->headers[gSaveContext.sceneSetupIndex - 1]).get(); if (desiredHeader != nullptr) { OTRScene_ExecuteCommands(play, desiredHeader); @@ -369,8 +369,8 @@ bool Scene_CommandAlternateHeaderList(PlayState* play, LUS::ISceneCommand* cmd) osSyncPrintf("\nげぼはっ! 指定されたデータがないでええっす!"); if (gSaveContext.sceneSetupIndex == 3) { - LUS::Scene* desiredHeader = - std::static_pointer_cast(cmdHeaders->headers[gSaveContext.sceneSetupIndex - 2]).get(); + SOH::Scene* desiredHeader = + std::static_pointer_cast(cmdHeaders->headers[gSaveContext.sceneSetupIndex - 2]).get(); // "Using adult day data there!" osSyncPrintf("\nそこで、大人の昼データを使用するでええっす!!"); @@ -385,9 +385,9 @@ bool Scene_CommandAlternateHeaderList(PlayState* play, LUS::ISceneCommand* cmd) return false; } -bool Scene_CommandCutsceneData(PlayState* play, LUS::ISceneCommand* cmd) { - // LUS::SetCutscenes* cmdCS = std::static_pointer_cast(cmd); - LUS::SetCutscenes* cmdCS = (LUS::SetCutscenes*)cmd; +bool Scene_CommandCutsceneData(PlayState* play, SOH::ISceneCommand* cmd) { + // SOH::SetCutscenes* cmdCS = std::static_pointer_cast(cmd); + SOH::SetCutscenes* cmdCS = (SOH::SetCutscenes*)cmd; play->csCtx.segment = cmdCS->cutscene->commands.data(); @@ -396,9 +396,9 @@ bool Scene_CommandCutsceneData(PlayState* play, LUS::ISceneCommand* cmd) { } // Camera & World Map Area -bool Scene_CommandMiscSettings(PlayState* play, LUS::ISceneCommand* cmd) { - // LUS::SetCameraSettings* cmdCam = std::static_pointer_cast(cmd); - LUS::SetCameraSettings* cmdCam = (LUS::SetCameraSettings*)cmd; +bool Scene_CommandMiscSettings(PlayState* play, SOH::ISceneCommand* cmd) { + // SOH::SetCameraSettings* cmdCam = std::static_pointer_cast(cmd); + SOH::SetCameraSettings* cmdCam = (SOH::SetCameraSettings*)cmd; YREG(15) = cmdCam->settings.cameraMovement; gSaveContext.worldMapArea = cmdCam->settings.worldMapArea; @@ -420,7 +420,7 @@ bool Scene_CommandMiscSettings(PlayState* play, LUS::ISceneCommand* cmd) { return false; } -bool (*sceneCommands[])(PlayState*, LUS::ISceneCommand*) = { +bool (*sceneCommands[])(PlayState*, SOH::ISceneCommand*) = { Scene_CommandSpawnList, // SCENE_CMD_ID_SPAWN_LIST Scene_CommandActorList, // SCENE_CMD_ID_ACTOR_LIST Scene_CommandUnused2, // SCENE_CMD_ID_UNUSED_2 @@ -449,8 +449,8 @@ bool (*sceneCommands[])(PlayState*, LUS::ISceneCommand*) = { Scene_CommandMiscSettings, // SCENE_CMD_ID_MISC_SETTINGS }; -s32 OTRScene_ExecuteCommands(PlayState* play, LUS::Scene* scene) { - LUS::SceneCommandID cmdCode; +s32 OTRScene_ExecuteCommands(PlayState* play, SOH::Scene* scene) { + SOH::SceneCommandID cmdCode; for (int i = 0; i < scene->commands.size(); i++) { auto sceneCmd = scene->commands[i]; @@ -487,7 +487,7 @@ extern "C" s32 OTRfunc_800973FC(PlayState* play, RoomContext* roomCtx) { roomCtx->curRoom.segment = roomCtx->unk_34; gSegments[3] = VIRTUAL_TO_PHYSICAL(roomCtx->unk_34); - OTRScene_ExecuteCommands(play, (LUS::Scene*)roomCtx->roomToLoad); + OTRScene_ExecuteCommands(play, (SOH::Scene*)roomCtx->roomToLoad); Player_SetBootData(play, GET_PLAYER(play)); Actor_SpawnTransitionActors(play, &play->actorCtx); @@ -523,7 +523,7 @@ extern "C" s32 OTRfunc_8009728C(PlayState* play, RoomContext* roomCtx, s32 roomN //&roomCtx->loadQueue, NULL, __FILE__, __LINE__); auto roomData = - std::static_pointer_cast(GetResourceByNameHandlingMQ(play->roomList[roomNum].fileName)); + std::static_pointer_cast(GetResourceByNameHandlingMQ(play->roomList[roomNum].fileName)); roomCtx->status = 1; roomCtx->roomToLoad = roomData.get();