diff --git a/libultraship b/libultraship index 274ec5e19..9ebed2afa 160000 --- a/libultraship +++ b/libultraship @@ -1 +1 @@ -Subproject commit 274ec5e195f40c526f489242c3c2bf66f10eb9af +Subproject commit 9ebed2afa8125c31264d510e4ce5cc35beaca8ef diff --git a/soh/soh/OTRGlobals.cpp b/soh/soh/OTRGlobals.cpp index a7d81c6dc..3093557ab 100644 --- a/soh/soh/OTRGlobals.cpp +++ b/soh/soh/OTRGlobals.cpp @@ -323,10 +323,6 @@ uint32_t OTRGlobals::GetInterpolationFPS() { return std::min(Ship::Window::GetInstance()->GetCurrentRefreshRate(), CVarGetInteger("gInterpolationFPS", 20)); } -std::shared_ptr> OTRGlobals::ListFiles(std::string path) { - return context->GetResourceManager()->ListFiles(path); -} - struct ExtensionEntry { std::string path; std::string ext; @@ -686,7 +682,7 @@ extern "C" uint32_t GetGIID(uint32_t itemID) { } extern "C" void OTRExtScanner() { - auto lst = *OTRGlobals::Instance->context->GetResourceManager()->ListFiles("*.*").get(); + auto lst = *OTRGlobals::Instance->context->GetResourceManager()->GetArchive()->ListFiles("*.*").get(); for (auto& rPath : lst) { std::vector raw = StringHelper::Split(rPath, "."); @@ -1007,7 +1003,7 @@ extern "C" void ResourceMgr_DirtyDirectory(const char* resName) { // OTRTODO: There is probably a more elegant way to go about this... extern "C" char** ResourceMgr_ListFiles(const char* searchMask, int* resultSize) { - auto lst = OTRGlobals::Instance->context->GetResourceManager()->ListFiles(searchMask); + auto lst = OTRGlobals::Instance->context->GetResourceManager()->GetArchive()->ListFiles(searchMask); char** result = (char**)malloc(lst->size() * sizeof(char*)); for (size_t i = 0; i < lst->size(); i++) { @@ -1105,9 +1101,9 @@ extern "C" uint16_t ResourceMgr_LoadTexHeightByName(char* texPath); extern "C" char* ResourceMgr_LoadTexOrDListByName(const char* filePath) { auto res = GetResourceByNameHandlingMQ(filePath); - if (res->Type == Ship::ResourceType::DisplayList) + if (res->InitData->Type == Ship::ResourceType::DisplayList) return (char*)&((std::static_pointer_cast(res))->Instructions[0]); - else if (res->Type == Ship::ResourceType::Array) + else if (res->InitData->Type == Ship::ResourceType::Array) return (char*)(std::static_pointer_cast(res))->Vertices.data(); else { return (char*)GetResourceDataByNameHandlingMQ(filePath); diff --git a/soh/soh/resource/importer/AnimationFactory.cpp b/soh/soh/resource/importer/AnimationFactory.cpp index ff4b26755..45cd5d7d1 100644 --- a/soh/soh/resource/importer/AnimationFactory.cpp +++ b/soh/soh/resource/importer/AnimationFactory.cpp @@ -3,18 +3,20 @@ #include "spdlog/spdlog.h" namespace Ship { -std::shared_ptr AnimationFactory::ReadResource(uint32_t version, std::shared_ptr reader) { - auto resource = std::make_shared(); +std::shared_ptr AnimationFactory::ReadResource(std::shared_ptr resourceMgr, + std::shared_ptr initData, + std::shared_ptr reader) { + auto resource = std::make_shared(resourceMgr, initData); std::shared_ptr factory = nullptr; - switch (version) { + switch (resource->InitData->ResourceVersion) { case 0: factory = std::make_shared(); break; } if (factory == nullptr) { - SPDLOG_ERROR("Failed to load Animation with version {}", version); + SPDLOG_ERROR("Failed to load Animation with version {}", resource->InitData->ResourceVersion); return nullptr; } diff --git a/soh/soh/resource/importer/AnimationFactory.h b/soh/soh/resource/importer/AnimationFactory.h index 319cf68c2..2ec5a23fd 100644 --- a/soh/soh/resource/importer/AnimationFactory.h +++ b/soh/soh/resource/importer/AnimationFactory.h @@ -6,7 +6,9 @@ namespace Ship { class AnimationFactory : public ResourceFactory { public: - std::shared_ptr ReadResource(uint32_t version, std::shared_ptr reader); + std::shared_ptr ReadResource(std::shared_ptr resourceMgr, + std::shared_ptr initData, + std::shared_ptr reader) override; }; class AnimationFactoryV0 : public ResourceVersionFactory { diff --git a/soh/soh/resource/importer/AudioSampleFactory.cpp b/soh/soh/resource/importer/AudioSampleFactory.cpp index 9044b7748..6e2219b01 100644 --- a/soh/soh/resource/importer/AudioSampleFactory.cpp +++ b/soh/soh/resource/importer/AudioSampleFactory.cpp @@ -3,34 +3,33 @@ #include "spdlog/spdlog.h" namespace Ship { -std::shared_ptr AudioSampleFactory::ReadResource(uint32_t version, std::shared_ptr reader) -{ - auto resource = std::make_shared(); - std::shared_ptr factory = nullptr; +std::shared_ptr AudioSampleFactory::ReadResource(std::shared_ptr resourceMgr, + std::shared_ptr initData, + std::shared_ptr reader) { + auto resource = std::make_shared(resourceMgr, initData); + std::shared_ptr factory = nullptr; - switch (version) - { - case 2: - factory = std::make_shared(); - break; - } + switch (resource->InitData->ResourceVersion) { + case 2: + factory = std::make_shared(); + break; + } - if (factory == nullptr) - { - SPDLOG_ERROR("Failed to load AudioSample with version {}", version); - return nullptr; - } + if (factory == nullptr) { + SPDLOG_ERROR("Failed to load AudioSample with version {}", resource->InitData->ResourceVersion); + return nullptr; + } - factory->ParseFileBinary(reader, resource); + factory->ParseFileBinary(reader, resource); - return resource; + return resource; } void Ship::AudioSampleFactoryV0::ParseFileBinary(std::shared_ptr reader, std::shared_ptr resource) { - std::shared_ptr audioSample = std::static_pointer_cast(resource); - ResourceVersionFactory::ParseFileBinary(reader, audioSample); + std::shared_ptr audioSample = std::static_pointer_cast(resource); + ResourceVersionFactory::ParseFileBinary(reader, audioSample); audioSample->sample.codec = reader->ReadUByte(); audioSample->sample.medium = reader->ReadUByte(); diff --git a/soh/soh/resource/importer/AudioSampleFactory.h b/soh/soh/resource/importer/AudioSampleFactory.h index a9bdc8997..1b4900292 100644 --- a/soh/soh/resource/importer/AudioSampleFactory.h +++ b/soh/soh/resource/importer/AudioSampleFactory.h @@ -7,7 +7,9 @@ namespace Ship { class AudioSampleFactory : public ResourceFactory { public: - std::shared_ptr ReadResource(uint32_t version, std::shared_ptr reader); + std::shared_ptr ReadResource(std::shared_ptr resourceMgr, + std::shared_ptr initData, + std::shared_ptr reader) override; }; class AudioSampleFactoryV0 : public ResourceVersionFactory diff --git a/soh/soh/resource/importer/AudioSequenceFactory.cpp b/soh/soh/resource/importer/AudioSequenceFactory.cpp index 3a5dbbb0c..7596e9edb 100644 --- a/soh/soh/resource/importer/AudioSequenceFactory.cpp +++ b/soh/soh/resource/importer/AudioSequenceFactory.cpp @@ -3,34 +3,33 @@ #include "spdlog/spdlog.h" namespace Ship { -std::shared_ptr AudioSequenceFactory::ReadResource(uint32_t version, std::shared_ptr reader) -{ - auto resource = std::make_shared(); - std::shared_ptr factory = nullptr; +std::shared_ptr AudioSequenceFactory::ReadResource(std::shared_ptr resourceMgr, + std::shared_ptr initData, + std::shared_ptr reader) { + auto resource = std::make_shared(resourceMgr, initData); + std::shared_ptr factory = nullptr; - switch (version) - { - case 2: - factory = std::make_shared(); - break; - } + switch (resource->InitData->ResourceVersion) { + case 2: + factory = std::make_shared(); + break; + } - if (factory == nullptr) - { - SPDLOG_ERROR("Failed to load AudioSequence with version {}", version); - return nullptr; - } + if (factory == nullptr) + { + SPDLOG_ERROR("Failed to load AudioSequence with version {}", resource->InitData->ResourceVersion); + return nullptr; + } - factory->ParseFileBinary(reader, resource); + factory->ParseFileBinary(reader, resource); - return resource; + return resource; } void Ship::AudioSequenceFactoryV0::ParseFileBinary(std::shared_ptr reader, - std::shared_ptr resource) -{ - std::shared_ptr audioSequence = std::static_pointer_cast(resource); - ResourceVersionFactory::ParseFileBinary(reader, audioSequence); + std::shared_ptr resource) { + std::shared_ptr audioSequence = std::static_pointer_cast(resource); + ResourceVersionFactory::ParseFileBinary(reader, audioSequence); audioSequence->sequence.seqDataSize = reader->ReadInt32(); audioSequence->sequenceData.reserve(audioSequence->sequence.seqDataSize); diff --git a/soh/soh/resource/importer/AudioSequenceFactory.h b/soh/soh/resource/importer/AudioSequenceFactory.h index 31ace1ff7..ab48584a0 100644 --- a/soh/soh/resource/importer/AudioSequenceFactory.h +++ b/soh/soh/resource/importer/AudioSequenceFactory.h @@ -7,7 +7,9 @@ namespace Ship { class AudioSequenceFactory : public ResourceFactory { public: - std::shared_ptr ReadResource(uint32_t version, std::shared_ptr reader); + std::shared_ptr ReadResource(std::shared_ptr resourceMgr, + std::shared_ptr initData, + std::shared_ptr reader) override; }; class AudioSequenceFactoryV0 : public ResourceVersionFactory diff --git a/soh/soh/resource/importer/AudioSoundFontFactory.cpp b/soh/soh/resource/importer/AudioSoundFontFactory.cpp index 287f680f0..05e50b219 100644 --- a/soh/soh/resource/importer/AudioSoundFontFactory.cpp +++ b/soh/soh/resource/importer/AudioSoundFontFactory.cpp @@ -4,34 +4,33 @@ #include "libultraship/bridge.h" namespace Ship { -std::shared_ptr AudioSoundFontFactory::ReadResource(uint32_t version, std::shared_ptr reader) -{ - auto resource = std::make_shared(); - std::shared_ptr factory = nullptr; +std::shared_ptr AudioSoundFontFactory::ReadResource(std::shared_ptr resourceMgr, + std::shared_ptr initData, + std::shared_ptr reader) { + auto resource = std::make_shared(resourceMgr, initData); + std::shared_ptr factory = nullptr; - switch (version) - { - case 2: - factory = std::make_shared(); - break; - } + switch (resource->InitData->ResourceVersion) { + case 2: + factory = std::make_shared(); + break; + } - if (factory == nullptr) - { - SPDLOG_ERROR("Failed to load AudioSoundFont with version {}", version); - return nullptr; - } + if (factory == nullptr) + { + SPDLOG_ERROR("Failed to load AudioSoundFont with version {}", resource->InitData->ResourceVersion); + return nullptr; + } - factory->ParseFileBinary(reader, resource); + factory->ParseFileBinary(reader, resource); - return resource; + return resource; } void Ship::AudioSoundFontFactoryV0::ParseFileBinary(std::shared_ptr reader, - std::shared_ptr resource) -{ - std::shared_ptr audioSoundFont = std::static_pointer_cast(resource); - ResourceVersionFactory::ParseFileBinary(reader, audioSoundFont); + std::shared_ptr resource) { + std::shared_ptr audioSoundFont = std::static_pointer_cast(resource); + ResourceVersionFactory::ParseFileBinary(reader, audioSoundFont); audioSoundFont->soundFont.fntIndex = reader->ReadInt32(); audioSoundFont->medium = reader->ReadInt8(); diff --git a/soh/soh/resource/importer/AudioSoundFontFactory.h b/soh/soh/resource/importer/AudioSoundFontFactory.h index 2dddee830..9abf08c0b 100644 --- a/soh/soh/resource/importer/AudioSoundFontFactory.h +++ b/soh/soh/resource/importer/AudioSoundFontFactory.h @@ -7,7 +7,9 @@ namespace Ship { class AudioSoundFontFactory : public ResourceFactory { public: - std::shared_ptr ReadResource(uint32_t version, std::shared_ptr reader); + std::shared_ptr ReadResource(std::shared_ptr resourceMgr, + std::shared_ptr initData, + std::shared_ptr reader) override; }; class AudioSoundFontFactoryV0 : public ResourceVersionFactory diff --git a/soh/soh/resource/importer/BackgroundFactory.cpp b/soh/soh/resource/importer/BackgroundFactory.cpp index 61e0ca220..ae707673a 100644 --- a/soh/soh/resource/importer/BackgroundFactory.cpp +++ b/soh/soh/resource/importer/BackgroundFactory.cpp @@ -3,18 +3,20 @@ #include "spdlog/spdlog.h" namespace Ship { -std::shared_ptr BackgroundFactory::ReadResource(uint32_t version, std::shared_ptr reader) { - auto resource = std::make_shared(); +std::shared_ptr BackgroundFactory::ReadResource(std::shared_ptr resourceMgr, + std::shared_ptr initData, + std::shared_ptr reader) { + auto resource = std::make_shared(resourceMgr, initData); std::shared_ptr factory = nullptr; - switch (version) { + switch (resource->InitData->ResourceVersion) { case 0: factory = std::make_shared(); break; } if (factory == nullptr) { - SPDLOG_ERROR("Failed to load Background with version {}", version); + SPDLOG_ERROR("Failed to load Background with version {}", resource->InitData->ResourceVersion); return nullptr; } diff --git a/soh/soh/resource/importer/BackgroundFactory.h b/soh/soh/resource/importer/BackgroundFactory.h index 00c67d4a2..3f1a1c9ba 100644 --- a/soh/soh/resource/importer/BackgroundFactory.h +++ b/soh/soh/resource/importer/BackgroundFactory.h @@ -6,7 +6,9 @@ namespace Ship { class BackgroundFactory : public ResourceFactory { public: - std::shared_ptr ReadResource(uint32_t version, std::shared_ptr reader); + std::shared_ptr ReadResource(std::shared_ptr resourceMgr, + std::shared_ptr initData, + std::shared_ptr reader) override; }; class BackgroundFactoryV0 : public ResourceVersionFactory { diff --git a/soh/soh/resource/importer/CollisionHeaderFactory.cpp b/soh/soh/resource/importer/CollisionHeaderFactory.cpp index d4a6a9a47..c18659a1e 100644 --- a/soh/soh/resource/importer/CollisionHeaderFactory.cpp +++ b/soh/soh/resource/importer/CollisionHeaderFactory.cpp @@ -3,34 +3,33 @@ #include "spdlog/spdlog.h" namespace Ship { -std::shared_ptr CollisionHeaderFactory::ReadResource(uint32_t version, std::shared_ptr reader) -{ - auto resource = std::make_shared(); - std::shared_ptr factory = nullptr; +std::shared_ptr CollisionHeaderFactory::ReadResource(std::shared_ptr resourceMgr, + std::shared_ptr initData, + std::shared_ptr reader) { + auto resource = std::make_shared(resourceMgr, initData); + std::shared_ptr factory = nullptr; - switch (version) - { - case 0: - factory = std::make_shared(); - break; - } + switch (resource->InitData->ResourceVersion) { + case 0: + factory = std::make_shared(); + break; + } - if (factory == nullptr) - { - SPDLOG_ERROR("Failed to load Collision Header with version {}", version); - return nullptr; - } + if (factory == nullptr) { + SPDLOG_ERROR("Failed to load Collision Header with version {}", resource->InitData->ResourceVersion); + return nullptr; + } - factory->ParseFileBinary(reader, resource); + factory->ParseFileBinary(reader, resource); - return resource; + return resource; } void Ship::CollisionHeaderFactoryV0::ParseFileBinary(std::shared_ptr reader, std::shared_ptr resource) { - std::shared_ptr collisionHeader = std::static_pointer_cast(resource); - ResourceVersionFactory::ParseFileBinary(reader, collisionHeader); + std::shared_ptr collisionHeader = std::static_pointer_cast(resource); + ResourceVersionFactory::ParseFileBinary(reader, collisionHeader); collisionHeader->collisionHeaderData.minBounds.x = reader->ReadInt16(); collisionHeader->collisionHeaderData.minBounds.y = reader->ReadInt16(); diff --git a/soh/soh/resource/importer/CollisionHeaderFactory.h b/soh/soh/resource/importer/CollisionHeaderFactory.h index 3247036a9..fe06e9821 100644 --- a/soh/soh/resource/importer/CollisionHeaderFactory.h +++ b/soh/soh/resource/importer/CollisionHeaderFactory.h @@ -6,7 +6,9 @@ namespace Ship { class CollisionHeaderFactory : public ResourceFactory { public: - std::shared_ptr ReadResource(uint32_t version, std::shared_ptr reader); + std::shared_ptr ReadResource(std::shared_ptr resourceMgr, + std::shared_ptr initData, + std::shared_ptr reader) override; }; class CollisionHeaderFactoryV0 : public ResourceVersionFactory { diff --git a/soh/soh/resource/importer/CutsceneFactory.cpp b/soh/soh/resource/importer/CutsceneFactory.cpp index d837259f6..ac9788cc5 100644 --- a/soh/soh/resource/importer/CutsceneFactory.cpp +++ b/soh/soh/resource/importer/CutsceneFactory.cpp @@ -3,27 +3,26 @@ #include "spdlog/spdlog.h" namespace Ship { -std::shared_ptr CutsceneFactory::ReadResource(uint32_t version, std::shared_ptr reader) -{ - auto resource = std::make_shared(); - std::shared_ptr factory = nullptr; +std::shared_ptr CutsceneFactory::ReadResource(std::shared_ptr resourceMgr, + std::shared_ptr initData, + std::shared_ptr reader) { + auto resource = std::make_shared(resourceMgr, initData); + std::shared_ptr factory = nullptr; - switch (version) - { - case 0: - factory = std::make_shared(); - break; - } + switch (resource->InitData->ResourceVersion) { + case 0: + factory = std::make_shared(); + break; + } - if (factory == nullptr) - { - SPDLOG_ERROR("Failed to load Cutscene with version {}", version); - return nullptr; - } + if (factory == nullptr) { + SPDLOG_ERROR("Failed to load Cutscene with version {}", resource->InitData->ResourceVersion); + return nullptr; + } - factory->ParseFileBinary(reader, resource); + factory->ParseFileBinary(reader, resource); - return resource; + return resource; } static inline uint32_t read_CMD_BBBB(std::shared_ptr reader) { @@ -84,10 +83,10 @@ static inline uint32_t read_CMD_HH(std::shared_ptr reader) { void Ship::CutsceneFactoryV0::ParseFileBinary(std::shared_ptr reader, std::shared_ptr resource) { - std::shared_ptr cutscene = std::static_pointer_cast(resource); - ResourceVersionFactory::ParseFileBinary(reader, cutscene); + std::shared_ptr cutscene = std::static_pointer_cast(resource); + ResourceVersionFactory::ParseFileBinary(reader, cutscene); - uint32_t numEntries = reader->ReadUInt32(); + uint32_t numEntries = reader->ReadUInt32(); cutscene->commands.reserve(numEntries); cutscene->numCommands = reader->ReadUInt32(); diff --git a/soh/soh/resource/importer/CutsceneFactory.h b/soh/soh/resource/importer/CutsceneFactory.h index e1ec1cded..bf1061ca0 100644 --- a/soh/soh/resource/importer/CutsceneFactory.h +++ b/soh/soh/resource/importer/CutsceneFactory.h @@ -7,7 +7,9 @@ namespace Ship { class CutsceneFactory : public ResourceFactory { public: - std::shared_ptr ReadResource(uint32_t version, std::shared_ptr reader); + std::shared_ptr ReadResource(std::shared_ptr resourceMgr, + std::shared_ptr initData, + std::shared_ptr reader) override; }; class CutsceneFactoryV0 : public ResourceVersionFactory diff --git a/soh/soh/resource/importer/PathFactory.cpp b/soh/soh/resource/importer/PathFactory.cpp index aac6d8b3f..8abc59694 100644 --- a/soh/soh/resource/importer/PathFactory.cpp +++ b/soh/soh/resource/importer/PathFactory.cpp @@ -3,34 +3,32 @@ #include "spdlog/spdlog.h" namespace Ship { -std::shared_ptr PathFactory::ReadResource(uint32_t version, std::shared_ptr reader) -{ - auto resource = std::make_shared(); - std::shared_ptr factory = nullptr; +std::shared_ptr PathFactory::ReadResource(std::shared_ptr resourceMgr, + std::shared_ptr initData, + std::shared_ptr reader) { + auto resource = std::make_shared(resourceMgr, initData); + std::shared_ptr factory = nullptr; - switch (version) - { - case 0: - factory = std::make_shared(); - break; - } + switch (resource->InitData->ResourceVersion) { + case 0: + factory = std::make_shared(); + break; + } - if (factory == nullptr) - { - SPDLOG_ERROR("Failed to load Path with version {}", version); - return nullptr; - } + if (factory == nullptr) { + SPDLOG_ERROR("Failed to load Path with version {}", resource->InitData->ResourceVersion); + return nullptr; + } - factory->ParseFileBinary(reader, resource); + factory->ParseFileBinary(reader, resource); - return resource; + return resource; } void Ship::PathFactoryV0::ParseFileBinary(std::shared_ptr reader, - std::shared_ptr resource) -{ - std::shared_ptr path = std::static_pointer_cast(resource); - ResourceVersionFactory::ParseFileBinary(reader, path); + std::shared_ptr resource) { + std::shared_ptr path = std::static_pointer_cast(resource); + ResourceVersionFactory::ParseFileBinary(reader, path); path->numPaths = reader->ReadUInt32(); path->paths.reserve(path->numPaths); diff --git a/soh/soh/resource/importer/PathFactory.h b/soh/soh/resource/importer/PathFactory.h index 937b6fb13..8e6918133 100644 --- a/soh/soh/resource/importer/PathFactory.h +++ b/soh/soh/resource/importer/PathFactory.h @@ -7,7 +7,9 @@ namespace Ship { class PathFactory : public ResourceFactory { public: - std::shared_ptr ReadResource(uint32_t version, std::shared_ptr reader); + std::shared_ptr ReadResource(std::shared_ptr resourceMgr, + std::shared_ptr initData, + std::shared_ptr reader) override; }; class PathFactoryV0 : public ResourceVersionFactory diff --git a/soh/soh/resource/importer/PlayerAnimationFactory.cpp b/soh/soh/resource/importer/PlayerAnimationFactory.cpp index 51adfa2ce..ea08b2bbb 100644 --- a/soh/soh/resource/importer/PlayerAnimationFactory.cpp +++ b/soh/soh/resource/importer/PlayerAnimationFactory.cpp @@ -3,36 +3,36 @@ #include "spdlog/spdlog.h" namespace Ship { -std::shared_ptr PlayerAnimationFactory::ReadResource(uint32_t version, std::shared_ptr reader) -{ - auto resource = std::make_shared(); - std::shared_ptr factory = nullptr; +std::shared_ptr PlayerAnimationFactory::ReadResource(std::shared_ptr resourceMgr, + std::shared_ptr initData, + std::shared_ptr reader) { + auto resource = std::make_shared(resourceMgr, initData); + std::shared_ptr factory = nullptr; - switch (version) - { - case 0: - factory = std::make_shared(); - break; - } + switch (resource->InitData->ResourceVersion) { + case 0: + factory = std::make_shared(); + break; + } - if (factory == nullptr) - { - SPDLOG_ERROR("Failed to load PlayerAnimation with version {}", version); - return nullptr; - } + if (factory == nullptr) + { + SPDLOG_ERROR("Failed to load PlayerAnimation with version {}", resource->InitData->ResourceVersion); + return nullptr; + } - factory->ParseFileBinary(reader, resource); + factory->ParseFileBinary(reader, resource); - return resource; + return resource; } void Ship::PlayerAnimationFactoryV0::ParseFileBinary(std::shared_ptr reader, std::shared_ptr resource) { - std::shared_ptr playerAnimation = std::static_pointer_cast(resource); - ResourceVersionFactory::ParseFileBinary(reader, playerAnimation); + std::shared_ptr playerAnimation = std::static_pointer_cast(resource); + ResourceVersionFactory::ParseFileBinary(reader, playerAnimation); - uint32_t numEntries = reader->ReadUInt32(); + uint32_t numEntries = reader->ReadUInt32(); playerAnimation->limbRotData.reserve(numEntries); for (uint32_t i = 0; i < numEntries; i++) { diff --git a/soh/soh/resource/importer/PlayerAnimationFactory.h b/soh/soh/resource/importer/PlayerAnimationFactory.h index d55cd5cef..b38b2482a 100644 --- a/soh/soh/resource/importer/PlayerAnimationFactory.h +++ b/soh/soh/resource/importer/PlayerAnimationFactory.h @@ -6,7 +6,9 @@ namespace Ship { class PlayerAnimationFactory : public ResourceFactory { public: - std::shared_ptr ReadResource(uint32_t version, std::shared_ptr reader); + std::shared_ptr ReadResource(std::shared_ptr resourceMgr, + std::shared_ptr initData, + std::shared_ptr reader) override; }; class PlayerAnimationFactoryV0 : public ResourceVersionFactory { diff --git a/soh/soh/resource/importer/SceneFactory.cpp b/soh/soh/resource/importer/SceneFactory.cpp index c4fdf8b82..9ea9f4c19 100644 --- a/soh/soh/resource/importer/SceneFactory.cpp +++ b/soh/soh/resource/importer/SceneFactory.cpp @@ -30,14 +30,15 @@ namespace Ship { -std::shared_ptr SceneFactory::ReadResource(uint32_t version, std::shared_ptr reader) -{ +std::shared_ptr SceneFactory::ReadResource(std::shared_ptr resourceMgr, + std::shared_ptr initData, + std::shared_ptr reader) { if (SceneFactory::sceneCommandFactories.empty()) { SceneFactory::sceneCommandFactories[Ship::SceneCommandID::SetLightingSettings] = std::make_shared(); SceneFactory::sceneCommandFactories[Ship::SceneCommandID::SetWind] = std::make_shared(); SceneFactory::sceneCommandFactories[Ship::SceneCommandID::SetExitList] = std::make_shared(); SceneFactory::sceneCommandFactories[Ship::SceneCommandID::SetTimeSettings] = std::make_shared(); - SceneFactory::sceneCommandFactories[Ship::SceneCommandID::SetSkyboxModifier] = std::make_shared(); + SceneFactory::sceneCommandFactories[Ship::SceneCommandID::SetSkyboxModifier] = std::make_shared(); SceneFactory::sceneCommandFactories[Ship::SceneCommandID::SetEchoSettings] = std::make_shared(); SceneFactory::sceneCommandFactories[Ship::SceneCommandID::SetSoundSettings] = std::make_shared(); SceneFactory::sceneCommandFactories[Ship::SceneCommandID::SetSkyboxSettings] = std::make_shared(); @@ -60,43 +61,45 @@ std::shared_ptr SceneFactory::ReadResource(uint32_t version, std::shar SceneFactory::sceneCommandFactories[Ship::SceneCommandID::SetMesh] = std::make_shared(); } - auto resource = std::make_shared(); - std::shared_ptr factory = nullptr; - resource->ResourceVersion = version; + auto resource = std::make_shared(resourceMgr, initData); + std::shared_ptr factory = nullptr; - switch (version) - { - case 0: - factory = std::make_shared(); - break; - } + switch (resource->InitData->ResourceVersion) { + case 0: + factory = std::make_shared(); + break; + } - if (factory == nullptr) - { - SPDLOG_ERROR("Failed to load Scene with version {}", version); - return nullptr; - } + if (factory == nullptr) { + SPDLOG_ERROR("Failed to load Scene with version {}", resource->InitData->ResourceVersion); + return nullptr; + } - factory->ParseFileBinary(reader, resource); + factory->ParseFileBinary(reader, resource); - return resource; + return resource; } void SceneFactoryV0::ParseFileBinary(std::shared_ptr reader, std::shared_ptr resource) { - std::shared_ptr scene = std::static_pointer_cast(resource); - ResourceVersionFactory::ParseFileBinary(reader, scene); + std::shared_ptr scene = std::static_pointer_cast(resource); + ResourceVersionFactory::ParseFileBinary(reader, scene); - uint32_t commandCount = reader->ReadUInt32(); - scene->commands.reserve(commandCount); - - for (uint32_t i = 0; i < commandCount; i++) { - scene->commands.push_back(ParseSceneCommand(resource->ResourceVersion, reader)); - } + ParseSceneCommands(scene, reader); } -std::shared_ptr SceneFactoryV0::ParseSceneCommand(uint32_t version, std::shared_ptr reader) { +void SceneFactoryV0::ParseSceneCommands(std::shared_ptr scene, std::shared_ptr reader) { + uint32_t commandCount = reader->ReadUInt32(); + scene->commands.reserve(commandCount); + + for (uint32_t i = 0; i < commandCount; i++) { + scene->commands.push_back(ParseSceneCommand(scene, reader, i)); + } +} + +std::shared_ptr SceneFactoryV0::ParseSceneCommand(std::shared_ptr scene, + std::shared_ptr reader, uint32_t index) { SceneCommandID cmdID = (SceneCommandID)reader->ReadInt32(); reader->Seek(-sizeof(int32_t), SeekOffsetType::Current); @@ -105,11 +108,17 @@ std::shared_ptr SceneFactoryV0::ParseSceneCommand(uint32_t version std::shared_ptr commandFactory = SceneFactory::sceneCommandFactories[cmdID]; if (commandFactory != nullptr) { - result = std::static_pointer_cast(commandFactory->ReadResource(version, reader)); + auto initData = std::make_shared(); + initData->Id = scene->InitData->Id; + initData->Type = ResourceType::SOH_SceneCommand; + initData->Path = scene->InitData->Path + "/SceneCommand" + std::to_string(index); + initData->ResourceVersion = scene->InitData->ResourceVersion; + result = std::static_pointer_cast(commandFactory->ReadResource(scene->ResourceManager, initData, reader)); + // Cache the resource? } if (result == nullptr) { - SPDLOG_ERROR("Failed to load scene command of type {}", (uint32_t)cmdID); + SPDLOG_ERROR("Failed to load scene command of type {} in scene {}", (uint32_t)cmdID, scene->InitData->Path); } return result; diff --git a/soh/soh/resource/importer/SceneFactory.h b/soh/soh/resource/importer/SceneFactory.h index ec75a20bf..5f08553f5 100644 --- a/soh/soh/resource/importer/SceneFactory.h +++ b/soh/soh/resource/importer/SceneFactory.h @@ -9,7 +9,9 @@ namespace Ship { class SceneFactory : public ResourceFactory { public: - std::shared_ptr ReadResource(uint32_t version, std::shared_ptr reader); + std::shared_ptr ReadResource(std::shared_ptr resourceMgr, + std::shared_ptr initData, + std::shared_ptr reader) override; // Doing something very similar to what we do on the ResourceLoader. // Eventually, scene commands should be moved up to the ResourceLoader as well. @@ -21,6 +23,8 @@ class SceneFactory : public ResourceFactory { class SceneFactoryV0 : public ResourceVersionFactory { public: void ParseFileBinary(std::shared_ptr reader, std::shared_ptr resource) override; - std::shared_ptr ParseSceneCommand(uint32_t version, std::shared_ptr reader); + void ParseSceneCommands(std::shared_ptr scene, std::shared_ptr reader); +protected: + std::shared_ptr ParseSceneCommand(std::shared_ptr scene, std::shared_ptr reader, uint32_t index); }; }; // namespace Ship diff --git a/soh/soh/resource/importer/SkeletonFactory.cpp b/soh/soh/resource/importer/SkeletonFactory.cpp index 315a5201d..3bca7873d 100644 --- a/soh/soh/resource/importer/SkeletonFactory.cpp +++ b/soh/soh/resource/importer/SkeletonFactory.cpp @@ -4,27 +4,26 @@ #include namespace Ship { -std::shared_ptr SkeletonFactory::ReadResource(uint32_t version, std::shared_ptr reader) -{ - auto resource = std::make_shared(); - std::shared_ptr factory = nullptr; +std::shared_ptr SkeletonFactory::ReadResource(std::shared_ptr resourceMgr, + std::shared_ptr initData, + std::shared_ptr reader) { + auto resource = std::make_shared(resourceMgr, initData); + std::shared_ptr factory = nullptr; - switch (version) - { - case 0: - factory = std::make_shared(); - break; - } + switch (resource->InitData->ResourceVersion) { + case 0: + factory = std::make_shared(); + break; + } - if (factory == nullptr) - { - SPDLOG_ERROR("Failed to load Skeleton with version {}", version); - return nullptr; - } + if (factory == nullptr) { + SPDLOG_ERROR("Failed to load Skeleton with version {}", resource->InitData->ResourceVersion); + return nullptr; + } - factory->ParseFileBinary(reader, resource); + factory->ParseFileBinary(reader, resource); - return resource; + return resource; } void SkeletonFactoryV0::ParseFileBinary(std::shared_ptr reader, @@ -33,12 +32,12 @@ void SkeletonFactoryV0::ParseFileBinary(std::shared_ptr reader, std::shared_ptr skeleton = std::static_pointer_cast(resource); ResourceVersionFactory::ParseFileBinary(reader, skeleton); - skeleton->type = (SkeletonType)reader->ReadInt8(); - skeleton->limbType = (LimbType)reader->ReadInt8(); + skeleton->type = (SkeletonType)reader->ReadInt8(); + skeleton->limbType = (LimbType)reader->ReadInt8(); skeleton->limbCount = reader->ReadUInt32(); skeleton->dListCount = reader->ReadUInt32(); - skeleton->limbTableType = (LimbType)reader->ReadInt8(); - skeleton->limbTableCount = reader->ReadUInt32(); + skeleton->limbTableType = (LimbType)reader->ReadInt8(); + skeleton->limbTableCount = reader->ReadUInt32(); skeleton->limbTable.reserve(skeleton->limbTableCount); for (uint32_t i = 0; i < skeleton->limbTableCount; i++) { @@ -48,18 +47,18 @@ void SkeletonFactoryV0::ParseFileBinary(std::shared_ptr reader, } if (skeleton->type == Ship::SkeletonType::Curve) { - skeleton->skeletonData.skelCurveLimbList.limbCount = skeleton->limbCount; - skeleton->curveLimbArray.reserve(skeleton->skeletonData.skelCurveLimbList.limbCount); + skeleton->skeletonData.skelCurveLimbList.limbCount = skeleton->limbCount; + skeleton->curveLimbArray.reserve(skeleton->skeletonData.skelCurveLimbList.limbCount); } else if (skeleton->type == Ship::SkeletonType::Flex) { - skeleton->skeletonData.flexSkeletonHeader.dListCount = skeleton->dListCount; + skeleton->skeletonData.flexSkeletonHeader.dListCount = skeleton->dListCount; } if (skeleton->type == Ship::SkeletonType::Normal) { skeleton->skeletonData.skeletonHeader.limbCount = skeleton->limbCount; - skeleton->standardLimbArray.reserve(skeleton->skeletonData.skeletonHeader.limbCount); + skeleton->standardLimbArray.reserve(skeleton->skeletonData.skeletonHeader.limbCount); } else if (skeleton->type == Ship::SkeletonType::Flex) { skeleton->skeletonData.flexSkeletonHeader.sh.limbCount = skeleton->limbCount; - skeleton->standardLimbArray.reserve(skeleton->skeletonData.flexSkeletonHeader.sh.limbCount); + skeleton->standardLimbArray.reserve(skeleton->skeletonData.flexSkeletonHeader.sh.limbCount); } for (size_t i = 0; i < skeleton->limbTable.size(); i++) { diff --git a/soh/soh/resource/importer/SkeletonFactory.h b/soh/soh/resource/importer/SkeletonFactory.h index fc80011ed..56cb80dad 100644 --- a/soh/soh/resource/importer/SkeletonFactory.h +++ b/soh/soh/resource/importer/SkeletonFactory.h @@ -7,7 +7,9 @@ namespace Ship { class SkeletonFactory : public ResourceFactory { public: - std::shared_ptr ReadResource(uint32_t version, std::shared_ptr reader); + std::shared_ptr ReadResource(std::shared_ptr resourceMgr, + std::shared_ptr initData, + std::shared_ptr reader) override; }; class SkeletonFactoryV0 : public ResourceVersionFactory diff --git a/soh/soh/resource/importer/SkeletonLimbFactory.cpp b/soh/soh/resource/importer/SkeletonLimbFactory.cpp index 9975d9bc3..652f2450f 100644 --- a/soh/soh/resource/importer/SkeletonLimbFactory.cpp +++ b/soh/soh/resource/importer/SkeletonLimbFactory.cpp @@ -4,34 +4,33 @@ #include "libultraship/bridge.h" namespace Ship { -std::shared_ptr SkeletonLimbFactory::ReadResource(uint32_t version, std::shared_ptr reader) -{ - auto resource = std::make_shared(); - std::shared_ptr factory = nullptr; +std::shared_ptr SkeletonLimbFactory::ReadResource(std::shared_ptr resourceMgr, + std::shared_ptr initData, + std::shared_ptr reader) { + auto resource = std::make_shared(resourceMgr, initData); + std::shared_ptr factory = nullptr; - switch (version) - { - case 0: - factory = std::make_shared(); - break; - } + switch (resource->InitData->ResourceVersion) { + case 0: + factory = std::make_shared(); + break; + } - if (factory == nullptr) - { - SPDLOG_ERROR("Failed to load Skeleton Limb with version {}", version); - return nullptr; - } + if (factory == nullptr) { + SPDLOG_ERROR("Failed to load Skeleton Limb with version {}", resource->InitData->ResourceVersion); + return nullptr; + } - factory->ParseFileBinary(reader, resource); + factory->ParseFileBinary(reader, resource); - return resource; + return resource; } void Ship::SkeletonLimbFactoryV0::ParseFileBinary(std::shared_ptr reader, std::shared_ptr resource) { - std::shared_ptr skeletonLimb = std::static_pointer_cast(resource); - ResourceVersionFactory::ParseFileBinary(reader, skeletonLimb); + std::shared_ptr skeletonLimb = std::static_pointer_cast(resource); + ResourceVersionFactory::ParseFileBinary(reader, skeletonLimb); skeletonLimb->limbType = (LimbType)reader->ReadInt8(); skeletonLimb->skinSegmentType = (ZLimbSkinType)reader->ReadInt8(); @@ -177,8 +176,7 @@ void Ship::SkeletonLimbFactoryV0::ParseFileBinary(std::shared_ptr skeletonLimb->skinAnimLimbData.limbModifications = skeletonLimb->skinLimbModifArray.data(); skeletonLimb->skinAnimLimbData.dlist = (Gfx*)GetResourceDataByName(skeletonLimb->skinDList2.c_str(), true); - for (size_t i = 0; i < skeletonLimb->skinLimbModifArray.size(); i++) - { + for (size_t i = 0; i < skeletonLimb->skinLimbModifArray.size(); i++) { skeletonLimb->skinAnimLimbData.limbModifications[i].vtxCount = skeletonLimb->skinLimbModifVertexArrays[i].size(); skeletonLimb->skinAnimLimbData.limbModifications[i].skinVertices = skeletonLimb->skinLimbModifVertexArrays[i].data(); diff --git a/soh/soh/resource/importer/SkeletonLimbFactory.h b/soh/soh/resource/importer/SkeletonLimbFactory.h index c10a45bbe..517ab4a85 100644 --- a/soh/soh/resource/importer/SkeletonLimbFactory.h +++ b/soh/soh/resource/importer/SkeletonLimbFactory.h @@ -7,7 +7,9 @@ namespace Ship { class SkeletonLimbFactory : public ResourceFactory { public: - std::shared_ptr ReadResource(uint32_t version, std::shared_ptr reader); + std::shared_ptr ReadResource(std::shared_ptr resourceMgr, + std::shared_ptr initData, + std::shared_ptr reader) override; }; class SkeletonLimbFactoryV0 : public ResourceVersionFactory diff --git a/soh/soh/resource/importer/TextFactory.cpp b/soh/soh/resource/importer/TextFactory.cpp index b6a465350..a73f350f9 100644 --- a/soh/soh/resource/importer/TextFactory.cpp +++ b/soh/soh/resource/importer/TextFactory.cpp @@ -3,50 +3,47 @@ #include "spdlog/spdlog.h" namespace Ship { -std::shared_ptr TextFactory::ReadResource(uint32_t version, std::shared_ptr reader) -{ - auto resource = std::make_shared(); - std::shared_ptr factory = nullptr; +std::shared_ptr TextFactory::ReadResource(std::shared_ptr resourceMgr, + std::shared_ptr initData, + std::shared_ptr reader) { + auto resource = std::make_shared(resourceMgr, initData); + std::shared_ptr factory = nullptr; - switch (version) - { - case 0: - factory = std::make_shared(); - break; - default: - // VERSION NOT SUPPORTED - break; - } + switch (resource->InitData->ResourceVersion) { + case 0: + factory = std::make_shared(); + break; + default: + // VERSION NOT SUPPORTED + break; + } - if (factory == nullptr) - { - SPDLOG_ERROR("Failed to load Text with version {}", version); - return nullptr; - } + if (factory == nullptr) { + SPDLOG_ERROR("Failed to load Text with version {}", resource->InitData->ResourceVersion); + return nullptr; + } - factory->ParseFileBinary(reader, resource); + factory->ParseFileBinary(reader, resource); - return resource; + return resource; } void Ship::TextFactoryV0::ParseFileBinary(std::shared_ptr reader, - std::shared_ptr resource) -{ - std::shared_ptr text = std::static_pointer_cast(resource); - ResourceVersionFactory::ParseFileBinary(reader, text); + std::shared_ptr resource) { + std::shared_ptr text = std::static_pointer_cast(resource); + ResourceVersionFactory::ParseFileBinary(reader, text); - uint32_t msgCount = reader->ReadUInt32(); - text->messages.reserve(msgCount); + 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(); + 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(); - text->messages.push_back(entry); - } + text->messages.push_back(entry); + } } } // namespace Ship diff --git a/soh/soh/resource/importer/TextFactory.h b/soh/soh/resource/importer/TextFactory.h index 7ba79dbeb..b1eac4a6a 100644 --- a/soh/soh/resource/importer/TextFactory.h +++ b/soh/soh/resource/importer/TextFactory.h @@ -7,7 +7,9 @@ namespace Ship { class TextFactory : public ResourceFactory { public: - std::shared_ptr ReadResource(uint32_t version, std::shared_ptr reader); + std::shared_ptr ReadResource(std::shared_ptr resourceMgr, + std::shared_ptr initData, + std::shared_ptr reader) override; }; class TextFactoryV0 : public ResourceVersionFactory diff --git a/soh/soh/resource/importer/scenecommand/EndMarkerFactory.cpp b/soh/soh/resource/importer/scenecommand/EndMarkerFactory.cpp index a9b99b101..a60390827 100644 --- a/soh/soh/resource/importer/scenecommand/EndMarkerFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/EndMarkerFactory.cpp @@ -3,36 +3,35 @@ #include "spdlog/spdlog.h" namespace Ship { -std::shared_ptr EndMarkerFactory::ReadResource(uint32_t version, std::shared_ptr reader) -{ - auto resource = std::make_shared(); - std::shared_ptr factory = nullptr; +std::shared_ptr EndMarkerFactory::ReadResource(std::shared_ptr resourceMgr, + std::shared_ptr initData, + std::shared_ptr reader) { + auto resource = std::make_shared(resourceMgr, initData); + std::shared_ptr factory = nullptr; - switch (version) - { - case 0: - factory = std::make_shared(); - break; - } + switch (resource->InitData->ResourceVersion) { + case 0: + factory = std::make_shared(); + break; + } - if (factory == nullptr) - { - SPDLOG_ERROR("Failed to load EndMarker with version {}", version); - return nullptr; - } + if (factory == nullptr) { + SPDLOG_ERROR("Failed to load EndMarker with version {}", resource->InitData->ResourceVersion); + return nullptr; + } - factory->ParseFileBinary(reader, resource); + factory->ParseFileBinary(reader, resource); - return resource; + return resource; } void Ship::EndMarkerFactoryV0::ParseFileBinary(std::shared_ptr reader, std::shared_ptr resource) { - std::shared_ptr endMarker = std::static_pointer_cast(resource); - ResourceVersionFactory::ParseFileBinary(reader, endMarker); + std::shared_ptr endMarker = std::static_pointer_cast(resource); + ResourceVersionFactory::ParseFileBinary(reader, endMarker); - ReadCommandId(endMarker, reader); + ReadCommandId(endMarker, reader); // This has no data. } diff --git a/soh/soh/resource/importer/scenecommand/EndMarkerFactory.h b/soh/soh/resource/importer/scenecommand/EndMarkerFactory.h index 0340e34ed..68ccc7919 100644 --- a/soh/soh/resource/importer/scenecommand/EndMarkerFactory.h +++ b/soh/soh/resource/importer/scenecommand/EndMarkerFactory.h @@ -5,7 +5,9 @@ namespace Ship { class EndMarkerFactory : public SceneCommandFactory { public: - std::shared_ptr ReadResource(uint32_t version, std::shared_ptr reader); + std::shared_ptr ReadResource(std::shared_ptr resourceMgr, + std::shared_ptr initData, + std::shared_ptr reader) override; }; class EndMarkerFactoryV0 : public SceneCommandVersionFactory { diff --git a/soh/soh/resource/importer/scenecommand/SetActorListFactory.cpp b/soh/soh/resource/importer/scenecommand/SetActorListFactory.cpp index b26efcc66..d2da1d126 100644 --- a/soh/soh/resource/importer/scenecommand/SetActorListFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetActorListFactory.cpp @@ -3,50 +3,49 @@ #include "spdlog/spdlog.h" namespace Ship { -std::shared_ptr SetActorListFactory::ReadResource(uint32_t version, std::shared_ptr reader) -{ - auto resource = std::make_shared(); - std::shared_ptr factory = nullptr; +std::shared_ptr SetActorListFactory::ReadResource(std::shared_ptr resourceMgr, + std::shared_ptr initData, + std::shared_ptr reader) { + auto resource = std::make_shared(resourceMgr, initData); + std::shared_ptr factory = nullptr; - switch (version) - { - case 0: - factory = std::make_shared(); - break; - } + switch (resource->InitData->ResourceVersion) { + case 0: + factory = std::make_shared(); + break; + } - if (factory == nullptr) - { - SPDLOG_ERROR("Failed to load SetActorList with version {}", version); - return nullptr; - } + if (factory == nullptr) + { + SPDLOG_ERROR("Failed to load SetActorList with version {}", resource->InitData->ResourceVersion); + return nullptr; + } - factory->ParseFileBinary(reader, resource); + factory->ParseFileBinary(reader, resource); - return resource; + return resource; } void Ship::SetActorListFactoryV0::ParseFileBinary(std::shared_ptr reader, - std::shared_ptr resource) -{ - std::shared_ptr setActorList = std::static_pointer_cast(resource); - ResourceVersionFactory::ParseFileBinary(reader, setActorList); + std::shared_ptr resource) { + std::shared_ptr setActorList = std::static_pointer_cast(resource); + ResourceVersionFactory::ParseFileBinary(reader, setActorList); - ReadCommandId(setActorList, reader); + 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); } diff --git a/soh/soh/resource/importer/scenecommand/SetActorListFactory.h b/soh/soh/resource/importer/scenecommand/SetActorListFactory.h index 4842e929f..7f5672e43 100644 --- a/soh/soh/resource/importer/scenecommand/SetActorListFactory.h +++ b/soh/soh/resource/importer/scenecommand/SetActorListFactory.h @@ -5,7 +5,9 @@ namespace Ship { class SetActorListFactory : public SceneCommandFactory { public: - std::shared_ptr ReadResource(uint32_t version, std::shared_ptr reader); + std::shared_ptr ReadResource(std::shared_ptr resourceMgr, + std::shared_ptr initData, + std::shared_ptr reader) override; }; class SetActorListFactoryV0 : public SceneCommandVersionFactory { diff --git a/soh/soh/resource/importer/scenecommand/SetAlternateHeadersFactory.cpp b/soh/soh/resource/importer/scenecommand/SetAlternateHeadersFactory.cpp index 7f28e71e0..0a19953bd 100644 --- a/soh/soh/resource/importer/scenecommand/SetAlternateHeadersFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetAlternateHeadersFactory.cpp @@ -4,46 +4,46 @@ #include "libultraship/bridge.h" namespace Ship { -std::shared_ptr SetAlternateHeadersFactory::ReadResource(uint32_t version, std::shared_ptr reader) -{ - auto resource = std::make_shared(); - std::shared_ptr factory = nullptr; +std::shared_ptr SetAlternateHeadersFactory::ReadResource(std::shared_ptr resourceMgr, + std::shared_ptr initData, + std::shared_ptr reader) { + auto resource = std::make_shared(resourceMgr, initData); + std::shared_ptr factory = nullptr; - switch (version) - { - case 0: - factory = std::make_shared(); - break; - } + switch (resource->InitData->ResourceVersion) { + case 0: + factory = std::make_shared(); + break; + } - if (factory == nullptr) - { - SPDLOG_ERROR("Failed to load SetAlternateHeaders with version {}", version); - return nullptr; - } + if (factory == nullptr) + { + SPDLOG_ERROR("Failed to load SetAlternateHeaders with version {}", resource->InitData->ResourceVersion); + return nullptr; + } - factory->ParseFileBinary(reader, resource); + factory->ParseFileBinary(reader, resource); - return resource; + return resource; } void Ship::SetAlternateHeadersFactoryV0::ParseFileBinary(std::shared_ptr reader, std::shared_ptr resource) { - std::shared_ptr setAlternateHeaders = std::static_pointer_cast(resource); - ResourceVersionFactory::ParseFileBinary(reader, setAlternateHeaders); + std::shared_ptr setAlternateHeaders = std::static_pointer_cast(resource); + ResourceVersionFactory::ParseFileBinary(reader, setAlternateHeaders); - ReadCommandId(setAlternateHeaders, reader); + 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(LoadResource(headerName.c_str(), true))); - } else { - setAlternateHeaders->headers.push_back(nullptr); - } + auto headerName = reader->ReadString(); + if (!headerName.empty()) { + setAlternateHeaders->headers.push_back(std::static_pointer_cast(LoadResource(headerName.c_str(), true))); + } else { + setAlternateHeaders->headers.push_back(nullptr); + } } } diff --git a/soh/soh/resource/importer/scenecommand/SetAlternateHeadersFactory.h b/soh/soh/resource/importer/scenecommand/SetAlternateHeadersFactory.h index 96e93fe6b..383204ba1 100644 --- a/soh/soh/resource/importer/scenecommand/SetAlternateHeadersFactory.h +++ b/soh/soh/resource/importer/scenecommand/SetAlternateHeadersFactory.h @@ -5,7 +5,9 @@ namespace Ship { class SetAlternateHeadersFactory : public SceneCommandFactory { public: - std::shared_ptr ReadResource(uint32_t version, std::shared_ptr reader); + std::shared_ptr ReadResource(std::shared_ptr resourceMgr, + std::shared_ptr initData, + std::shared_ptr reader) override; }; class SetAlternateHeadersFactoryV0 : public SceneCommandVersionFactory { diff --git a/soh/soh/resource/importer/scenecommand/SetCameraSettingsFactory.cpp b/soh/soh/resource/importer/scenecommand/SetCameraSettingsFactory.cpp index e51aed6ee..1aaf73ba4 100644 --- a/soh/soh/resource/importer/scenecommand/SetCameraSettingsFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetCameraSettingsFactory.cpp @@ -3,36 +3,35 @@ #include "spdlog/spdlog.h" namespace Ship { -std::shared_ptr SetCameraSettingsFactory::ReadResource(uint32_t version, std::shared_ptr reader) -{ - auto resource = std::make_shared(); - std::shared_ptr factory = nullptr; +std::shared_ptr SetCameraSettingsFactory::ReadResource(std::shared_ptr resourceMgr, + std::shared_ptr initData, + std::shared_ptr reader) { + auto resource = std::make_shared(resourceMgr, initData); + std::shared_ptr factory = nullptr; - switch (version) - { - case 0: - factory = std::make_shared(); - break; - } + switch (resource->InitData->ResourceVersion) { + case 0: + factory = std::make_shared(); + break; + } - if (factory == nullptr) - { - SPDLOG_ERROR("Failed to load SetCameraSettings with version {}", version); - return nullptr; - } + if (factory == nullptr) { + SPDLOG_ERROR("Failed to load SetCameraSettings with version {}", resource->InitData->ResourceVersion); + return nullptr; + } - factory->ParseFileBinary(reader, resource); + factory->ParseFileBinary(reader, resource); - return resource; + return resource; } void Ship::SetCameraSettingsFactoryV0::ParseFileBinary(std::shared_ptr reader, std::shared_ptr resource) { - std::shared_ptr setCameraSettings = std::static_pointer_cast(resource); - ResourceVersionFactory::ParseFileBinary(reader, setCameraSettings); + std::shared_ptr setCameraSettings = std::static_pointer_cast(resource); + ResourceVersionFactory::ParseFileBinary(reader, setCameraSettings); - ReadCommandId(setCameraSettings, reader); + ReadCommandId(setCameraSettings, reader); setCameraSettings->settings.cameraMovement = reader->ReadInt8(); setCameraSettings->settings.worldMapArea = reader->ReadInt32(); diff --git a/soh/soh/resource/importer/scenecommand/SetCameraSettingsFactory.h b/soh/soh/resource/importer/scenecommand/SetCameraSettingsFactory.h index e6251f3b8..5432e8d5e 100644 --- a/soh/soh/resource/importer/scenecommand/SetCameraSettingsFactory.h +++ b/soh/soh/resource/importer/scenecommand/SetCameraSettingsFactory.h @@ -5,7 +5,9 @@ namespace Ship { class SetCameraSettingsFactory : public SceneCommandFactory { public: - std::shared_ptr ReadResource(uint32_t version, std::shared_ptr reader); + std::shared_ptr ReadResource(std::shared_ptr resourceMgr, + std::shared_ptr initData, + std::shared_ptr reader) override; }; class SetCameraSettingsFactoryV0 : public SceneCommandVersionFactory { diff --git a/soh/soh/resource/importer/scenecommand/SetCollisionHeaderFactory.cpp b/soh/soh/resource/importer/scenecommand/SetCollisionHeaderFactory.cpp index ff240cf88..0e6112b3c 100644 --- a/soh/soh/resource/importer/scenecommand/SetCollisionHeaderFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetCollisionHeaderFactory.cpp @@ -4,39 +4,37 @@ #include "spdlog/spdlog.h" namespace Ship { -std::shared_ptr SetCollisionHeaderFactory::ReadResource(uint32_t version, std::shared_ptr reader) -{ - auto resource = std::make_shared(); - std::shared_ptr factory = nullptr; +std::shared_ptr SetCollisionHeaderFactory::ReadResource(std::shared_ptr resourceMgr, + std::shared_ptr initData, + std::shared_ptr reader) { + auto resource = std::make_shared(resourceMgr, initData); + std::shared_ptr factory = nullptr; - switch (version) - { - case 0: - factory = std::make_shared(); - break; - } + switch (resource->InitData->ResourceVersion) { + case 0: + factory = std::make_shared(); + break; + } - if (factory == nullptr) - { - SPDLOG_ERROR("Failed to load SetCollisionHeader with version {}", version); - return nullptr; - } + if (factory == nullptr) { + SPDLOG_ERROR("Failed to load SetCollisionHeader with version {}", resource->InitData->ResourceVersion); + return nullptr; + } - factory->ParseFileBinary(reader, resource); + factory->ParseFileBinary(reader, resource); - return resource; + return resource; } void Ship::SetCollisionHeaderFactoryV0::ParseFileBinary(std::shared_ptr reader, - std::shared_ptr resource) -{ - std::shared_ptr setCollisionHeader = std::static_pointer_cast(resource); - ResourceVersionFactory::ParseFileBinary(reader, setCollisionHeader); + std::shared_ptr resource) { + std::shared_ptr setCollisionHeader = std::static_pointer_cast(resource); + ResourceVersionFactory::ParseFileBinary(reader, setCollisionHeader); - ReadCommandId(setCollisionHeader, reader); - - setCollisionHeader->fileName = reader->ReadString(); - setCollisionHeader->collisionHeader = std::static_pointer_cast(LoadResource(setCollisionHeader->fileName.c_str(), true)); + ReadCommandId(setCollisionHeader, reader); + + setCollisionHeader->fileName = reader->ReadString(); + setCollisionHeader->collisionHeader = std::static_pointer_cast(LoadResource(setCollisionHeader->fileName.c_str(), true)); } } // namespace Ship diff --git a/soh/soh/resource/importer/scenecommand/SetCollisionHeaderFactory.h b/soh/soh/resource/importer/scenecommand/SetCollisionHeaderFactory.h index 3a3995f4f..453f3ad0d 100644 --- a/soh/soh/resource/importer/scenecommand/SetCollisionHeaderFactory.h +++ b/soh/soh/resource/importer/scenecommand/SetCollisionHeaderFactory.h @@ -5,7 +5,9 @@ namespace Ship { class SetCollisionHeaderFactory : public SceneCommandFactory { public: - std::shared_ptr ReadResource(uint32_t version, std::shared_ptr reader); + std::shared_ptr ReadResource(std::shared_ptr resourceMgr, + std::shared_ptr initData, + std::shared_ptr reader) override; }; class SetCollisionHeaderFactoryV0 : public SceneCommandVersionFactory { diff --git a/soh/soh/resource/importer/scenecommand/SetCsCameraFactory.cpp b/soh/soh/resource/importer/scenecommand/SetCsCameraFactory.cpp index eccf6bab6..959deff02 100644 --- a/soh/soh/resource/importer/scenecommand/SetCsCameraFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetCsCameraFactory.cpp @@ -3,36 +3,34 @@ #include "spdlog/spdlog.h" namespace Ship { -std::shared_ptr SetCsCameraFactory::ReadResource(uint32_t version, std::shared_ptr reader) -{ - auto resource = std::make_shared(); - std::shared_ptr factory = nullptr; +std::shared_ptr SetCsCameraFactory::ReadResource(std::shared_ptr resourceMgr, + std::shared_ptr initData, + std::shared_ptr reader) { + auto resource = std::make_shared(resourceMgr, initData); + std::shared_ptr factory = nullptr; - switch (version) - { - case 0: - factory = std::make_shared(); - break; - } + switch (resource->InitData->ResourceVersion) { + case 0: + factory = std::make_shared(); + break; + } - if (factory == nullptr) - { - SPDLOG_ERROR("Failed to load SetCsCamera with version {}", version); - return nullptr; - } + if (factory == nullptr) { + SPDLOG_ERROR("Failed to load SetCsCamera with version {}", resource->InitData->ResourceVersion); + return nullptr; + } - factory->ParseFileBinary(reader, resource); + factory->ParseFileBinary(reader, resource); - return resource; + return resource; } void Ship::SetCsCameraFactoryV0::ParseFileBinary(std::shared_ptr reader, - std::shared_ptr resource) -{ - std::shared_ptr setCsCamera = std::static_pointer_cast(resource); - ResourceVersionFactory::ParseFileBinary(reader, setCsCamera); + std::shared_ptr resource) { + std::shared_ptr setCsCamera = std::static_pointer_cast(resource); + ResourceVersionFactory::ParseFileBinary(reader, setCsCamera); - ReadCommandId(setCsCamera, reader); + ReadCommandId(setCsCamera, reader); reader->ReadInt8(); // camSize reader->ReadInt32(); // segOffset diff --git a/soh/soh/resource/importer/scenecommand/SetCsCameraFactory.h b/soh/soh/resource/importer/scenecommand/SetCsCameraFactory.h index 66a9b6ade..de74e91a1 100644 --- a/soh/soh/resource/importer/scenecommand/SetCsCameraFactory.h +++ b/soh/soh/resource/importer/scenecommand/SetCsCameraFactory.h @@ -5,7 +5,9 @@ namespace Ship { class SetCsCameraFactory : public SceneCommandFactory { public: - std::shared_ptr ReadResource(uint32_t version, std::shared_ptr reader); + std::shared_ptr ReadResource(std::shared_ptr resourceMgr, + std::shared_ptr initData, + std::shared_ptr reader) override; }; class SetCsCameraFactoryV0 : public SceneCommandVersionFactory { diff --git a/soh/soh/resource/importer/scenecommand/SetCutscenesFactory.cpp b/soh/soh/resource/importer/scenecommand/SetCutscenesFactory.cpp index b02b7c43d..e03fa78d8 100644 --- a/soh/soh/resource/importer/scenecommand/SetCutscenesFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetCutscenesFactory.cpp @@ -4,39 +4,38 @@ #include "spdlog/spdlog.h" namespace Ship { -std::shared_ptr SetCutscenesFactory::ReadResource(uint32_t version, std::shared_ptr reader) -{ - auto resource = std::make_shared(); - std::shared_ptr factory = nullptr; +std::shared_ptr SetCutscenesFactory::ReadResource(std::shared_ptr resourceMgr, + std::shared_ptr initData, + std::shared_ptr reader) { + auto resource = std::make_shared(resourceMgr, initData); + std::shared_ptr factory = nullptr; - switch (version) - { - case 0: - factory = std::make_shared(); - break; - } + switch (resource->InitData->ResourceVersion) { + case 0: + factory = std::make_shared(); + break; + } - if (factory == nullptr) - { - SPDLOG_ERROR("Failed to load SetCutscenes with version {}", version); - return nullptr; - } + if (factory == nullptr) + { + SPDLOG_ERROR("Failed to load SetCutscenes with version {}", resource->InitData->ResourceVersion); + return nullptr; + } - factory->ParseFileBinary(reader, resource); + factory->ParseFileBinary(reader, resource); - return resource; + return resource; } void Ship::SetCutscenesFactoryV0::ParseFileBinary(std::shared_ptr reader, - std::shared_ptr resource) -{ - std::shared_ptr setCutscenes = std::static_pointer_cast(resource); - ResourceVersionFactory::ParseFileBinary(reader, setCutscenes); + std::shared_ptr resource) { + std::shared_ptr setCutscenes = std::static_pointer_cast(resource); + ResourceVersionFactory::ParseFileBinary(reader, setCutscenes); - ReadCommandId(setCutscenes, reader); - - setCutscenes->fileName = reader->ReadString(); - setCutscenes->cutscene = std::static_pointer_cast(LoadResource(setCutscenes->fileName.c_str(), true)); + ReadCommandId(setCutscenes, reader); + + setCutscenes->fileName = reader->ReadString(); + setCutscenes->cutscene = std::static_pointer_cast(LoadResource(setCutscenes->fileName.c_str(), true)); } } // namespace Ship diff --git a/soh/soh/resource/importer/scenecommand/SetCutscenesFactory.h b/soh/soh/resource/importer/scenecommand/SetCutscenesFactory.h index 61725e118..c7c277fdb 100644 --- a/soh/soh/resource/importer/scenecommand/SetCutscenesFactory.h +++ b/soh/soh/resource/importer/scenecommand/SetCutscenesFactory.h @@ -5,7 +5,9 @@ namespace Ship { class SetCutscenesFactory : public SceneCommandFactory { public: - std::shared_ptr ReadResource(uint32_t version, std::shared_ptr reader); + std::shared_ptr ReadResource(std::shared_ptr resourceMgr, + std::shared_ptr initData, + std::shared_ptr reader) override; }; class SetCutscenesFactoryV0 : public SceneCommandVersionFactory { diff --git a/soh/soh/resource/importer/scenecommand/SetEchoSettingsFactory.cpp b/soh/soh/resource/importer/scenecommand/SetEchoSettingsFactory.cpp index 2a7802cbf..21e9ddac1 100644 --- a/soh/soh/resource/importer/scenecommand/SetEchoSettingsFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetEchoSettingsFactory.cpp @@ -3,36 +3,35 @@ #include "spdlog/spdlog.h" namespace Ship { -std::shared_ptr SetEchoSettingsFactory::ReadResource(uint32_t version, std::shared_ptr reader) -{ - auto resource = std::make_shared(); - std::shared_ptr factory = nullptr; +std::shared_ptr SetEchoSettingsFactory::ReadResource(std::shared_ptr resourceMgr, + std::shared_ptr initData, + std::shared_ptr reader) { + auto resource = std::make_shared(resourceMgr, initData); + std::shared_ptr factory = nullptr; - switch (version) - { - case 0: - factory = std::make_shared(); - break; - } + switch (resource->InitData->ResourceVersion) { + case 0: + factory = std::make_shared(); + break; + } - if (factory == nullptr) - { - SPDLOG_ERROR("Failed to load SetEchoSettings with version {}", version); - return nullptr; - } + if (factory == nullptr) { + SPDLOG_ERROR("Failed to load SetEchoSettings with version {}", resource->InitData->ResourceVersion); + return nullptr; + } - factory->ParseFileBinary(reader, resource); + factory->ParseFileBinary(reader, resource); - return resource; + return resource; } void Ship::SetEchoSettingsFactoryV0::ParseFileBinary(std::shared_ptr reader, std::shared_ptr resource) { - std::shared_ptr setEchoSettings = std::static_pointer_cast(resource); - ResourceVersionFactory::ParseFileBinary(reader, setEchoSettings); + std::shared_ptr setEchoSettings = std::static_pointer_cast(resource); + ResourceVersionFactory::ParseFileBinary(reader, setEchoSettings); - ReadCommandId(setEchoSettings, reader); + ReadCommandId(setEchoSettings, reader); setEchoSettings->settings.echo = reader->ReadInt8(); } diff --git a/soh/soh/resource/importer/scenecommand/SetEchoSettingsFactory.h b/soh/soh/resource/importer/scenecommand/SetEchoSettingsFactory.h index 081e07178..d15de3ef1 100644 --- a/soh/soh/resource/importer/scenecommand/SetEchoSettingsFactory.h +++ b/soh/soh/resource/importer/scenecommand/SetEchoSettingsFactory.h @@ -5,7 +5,9 @@ namespace Ship { class SetEchoSettingsFactory : public SceneCommandFactory { public: - std::shared_ptr ReadResource(uint32_t version, std::shared_ptr reader); + std::shared_ptr ReadResource(std::shared_ptr resourceMgr, + std::shared_ptr initData, + std::shared_ptr reader) override; }; class SetEchoSettingsFactoryV0 : public SceneCommandVersionFactory { diff --git a/soh/soh/resource/importer/scenecommand/SetEntranceListFactory.cpp b/soh/soh/resource/importer/scenecommand/SetEntranceListFactory.cpp index fced25a03..cb2b4ef0e 100644 --- a/soh/soh/resource/importer/scenecommand/SetEntranceListFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetEntranceListFactory.cpp @@ -3,44 +3,42 @@ #include "spdlog/spdlog.h" namespace Ship { -std::shared_ptr SetEntranceListFactory::ReadResource(uint32_t version, std::shared_ptr reader) -{ - auto resource = std::make_shared(); - std::shared_ptr factory = nullptr; +std::shared_ptr SetEntranceListFactory::ReadResource(std::shared_ptr resourceMgr, + std::shared_ptr initData, + std::shared_ptr reader) { + auto resource = std::make_shared(resourceMgr, initData); + std::shared_ptr factory = nullptr; - switch (version) - { - case 0: - factory = std::make_shared(); - break; - } + switch (resource->InitData->ResourceVersion) { + case 0: + factory = std::make_shared(); + break; + } - if (factory == nullptr) - { - SPDLOG_ERROR("Failed to load SetEntranceListList with version {}", version); - return nullptr; - } + if (factory == nullptr) { + SPDLOG_ERROR("Failed to load SetEntranceListList with version {}", resource->InitData->ResourceVersion); + return nullptr; + } - factory->ParseFileBinary(reader, resource); + factory->ParseFileBinary(reader, resource); - return resource; + return resource; } void Ship::SetEntranceListFactoryV0::ParseFileBinary(std::shared_ptr reader, - std::shared_ptr resource) -{ - std::shared_ptr setEntranceList = std::static_pointer_cast(resource); - ResourceVersionFactory::ParseFileBinary(reader, setEntranceList); + std::shared_ptr resource) { + std::shared_ptr setEntranceList = std::static_pointer_cast(resource); + ResourceVersionFactory::ParseFileBinary(reader, setEntranceList); - ReadCommandId(setEntranceList, reader); + ReadCommandId(setEntranceList, reader); setEntranceList->numEntrances = reader->ReadUInt32(); setEntranceList->entrances.reserve(setEntranceList->numEntrances); for (uint32_t i = 0; i < setEntranceList->numEntrances; i++) { - EntranceEntry entranceEntry; + EntranceEntry entranceEntry; - entranceEntry.spawn = reader->ReadInt8(); - entranceEntry.room = reader->ReadInt8(); + entranceEntry.spawn = reader->ReadInt8(); + entranceEntry.room = reader->ReadInt8(); setEntranceList->entrances.push_back(entranceEntry); } diff --git a/soh/soh/resource/importer/scenecommand/SetEntranceListFactory.h b/soh/soh/resource/importer/scenecommand/SetEntranceListFactory.h index 5dc902f3b..d6a016c97 100644 --- a/soh/soh/resource/importer/scenecommand/SetEntranceListFactory.h +++ b/soh/soh/resource/importer/scenecommand/SetEntranceListFactory.h @@ -5,7 +5,9 @@ namespace Ship { class SetEntranceListFactory : public SceneCommandFactory { public: - std::shared_ptr ReadResource(uint32_t version, std::shared_ptr reader); + std::shared_ptr ReadResource(std::shared_ptr resourceMgr, + std::shared_ptr initData, + std::shared_ptr reader) override; }; class SetEntranceListFactoryV0 : public SceneCommandVersionFactory { diff --git a/soh/soh/resource/importer/scenecommand/SetExitListFactory.cpp b/soh/soh/resource/importer/scenecommand/SetExitListFactory.cpp index a8cda9b74..ac980811c 100644 --- a/soh/soh/resource/importer/scenecommand/SetExitListFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetExitListFactory.cpp @@ -3,36 +3,34 @@ #include "spdlog/spdlog.h" namespace Ship { -std::shared_ptr SetExitListFactory::ReadResource(uint32_t version, std::shared_ptr reader) -{ - auto resource = std::make_shared(); - std::shared_ptr factory = nullptr; +std::shared_ptr SetExitListFactory::ReadResource(std::shared_ptr resourceMgr, + std::shared_ptr initData, + std::shared_ptr reader) { + auto resource = std::make_shared(resourceMgr, initData); + std::shared_ptr factory = nullptr; - switch (version) - { - case 0: - factory = std::make_shared(); - break; - } + switch (resource->InitData->ResourceVersion) { + case 0: + factory = std::make_shared(); + break; + } - if (factory == nullptr) - { - SPDLOG_ERROR("Failed to load SetExitList with version {}", version); - return nullptr; - } + if (factory == nullptr) { + SPDLOG_ERROR("Failed to load SetExitList with version {}", resource->InitData->ResourceVersion); + return nullptr; + } - factory->ParseFileBinary(reader, resource); + factory->ParseFileBinary(reader, resource); - return resource; + return resource; } void Ship::SetExitListFactoryV0::ParseFileBinary(std::shared_ptr reader, - std::shared_ptr resource) -{ - std::shared_ptr setExitList = std::static_pointer_cast(resource); - ResourceVersionFactory::ParseFileBinary(reader, setExitList); + std::shared_ptr resource) { + std::shared_ptr setExitList = std::static_pointer_cast(resource); + ResourceVersionFactory::ParseFileBinary(reader, setExitList); - ReadCommandId(setExitList, reader); + ReadCommandId(setExitList, reader); setExitList->numExits = reader->ReadUInt32(); setExitList->exits.reserve(setExitList->numExits); diff --git a/soh/soh/resource/importer/scenecommand/SetExitListFactory.h b/soh/soh/resource/importer/scenecommand/SetExitListFactory.h index 9f50f996a..b4f4d8511 100644 --- a/soh/soh/resource/importer/scenecommand/SetExitListFactory.h +++ b/soh/soh/resource/importer/scenecommand/SetExitListFactory.h @@ -5,7 +5,9 @@ namespace Ship { class SetExitListFactory : public SceneCommandFactory { public: - std::shared_ptr ReadResource(uint32_t version, std::shared_ptr reader); + std::shared_ptr ReadResource(std::shared_ptr resourceMgr, + std::shared_ptr initData, + std::shared_ptr reader) override; }; class SetExitListFactoryV0 : public SceneCommandVersionFactory { diff --git a/soh/soh/resource/importer/scenecommand/SetLightListFactory.cpp b/soh/soh/resource/importer/scenecommand/SetLightListFactory.cpp index ffe5e7dcb..ff013cbae 100644 --- a/soh/soh/resource/importer/scenecommand/SetLightListFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetLightListFactory.cpp @@ -3,45 +3,45 @@ #include "spdlog/spdlog.h" namespace Ship { -std::shared_ptr SetLightListFactory::ReadResource(uint32_t version, std::shared_ptr reader) -{ - auto resource = std::make_shared(); - std::shared_ptr factory = nullptr; +std::shared_ptr SetLightListFactory::ReadResource(std::shared_ptr resourceMgr, + std::shared_ptr initData, + std::shared_ptr reader) { + auto resource = std::make_shared(resourceMgr, initData); + std::shared_ptr factory = nullptr; - switch (version) - { - case 0: - factory = std::make_shared(); - break; - } + switch (resource->InitData->ResourceVersion) { + case 0: + factory = std::make_shared(); + break; + } - if (factory == nullptr) - { - SPDLOG_ERROR("Failed to load SetLightList with version {}", version); - return nullptr; - } + if (factory == nullptr) + { + SPDLOG_ERROR("Failed to load SetLightList with version {}", resource->InitData->ResourceVersion); + return nullptr; + } - factory->ParseFileBinary(reader, resource); + factory->ParseFileBinary(reader, resource); - return resource; + return resource; } void Ship::SetLightListFactoryV0::ParseFileBinary(std::shared_ptr reader, std::shared_ptr resource) { - std::shared_ptr setLightList = std::static_pointer_cast(resource); - ResourceVersionFactory::ParseFileBinary(reader, setLightList); + std::shared_ptr setLightList = std::static_pointer_cast(resource); + ResourceVersionFactory::ParseFileBinary(reader, setLightList); - ReadCommandId(setLightList, reader); - - setLightList->numLights = reader->ReadUInt32(); + ReadCommandId(setLightList, reader); + + setLightList->numLights = reader->ReadUInt32(); setLightList->lightList.reserve(setLightList->numLights); for (uint32_t i = 0; i < setLightList->numLights; i++) { LightInfo light; 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(); @@ -50,7 +50,7 @@ void Ship::SetLightListFactoryV0::ParseFileBinary(std::shared_ptr 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); } diff --git a/soh/soh/resource/importer/scenecommand/SetLightListFactory.h b/soh/soh/resource/importer/scenecommand/SetLightListFactory.h index 5c05a22fa..cc9849e22 100644 --- a/soh/soh/resource/importer/scenecommand/SetLightListFactory.h +++ b/soh/soh/resource/importer/scenecommand/SetLightListFactory.h @@ -5,7 +5,9 @@ namespace Ship { class SetLightListFactory : public SceneCommandFactory { public: - std::shared_ptr ReadResource(uint32_t version, std::shared_ptr reader); + std::shared_ptr ReadResource(std::shared_ptr resourceMgr, + std::shared_ptr initData, + std::shared_ptr reader) override; }; class SetLightListFactoryV0 : public SceneCommandVersionFactory { diff --git a/soh/soh/resource/importer/scenecommand/SetLightingSettingsFactory.cpp b/soh/soh/resource/importer/scenecommand/SetLightingSettingsFactory.cpp index 9a5fbb6ca..8d6c0ef97 100644 --- a/soh/soh/resource/importer/scenecommand/SetLightingSettingsFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetLightingSettingsFactory.cpp @@ -3,42 +3,41 @@ #include "spdlog/spdlog.h" namespace Ship { -std::shared_ptr SetLightingSettingsFactory::ReadResource(uint32_t version, std::shared_ptr reader) -{ - auto resource = std::make_shared(); - std::shared_ptr factory = nullptr; +std::shared_ptr SetLightingSettingsFactory::ReadResource(std::shared_ptr resourceMgr, + std::shared_ptr initData, + std::shared_ptr reader) { + auto resource = std::make_shared(resourceMgr, initData); + std::shared_ptr factory = nullptr; - switch (version) - { - case 0: - factory = std::make_shared(); - break; - } + switch (resource->InitData->ResourceVersion) { + case 0: + factory = std::make_shared(); + break; + } - if (factory == nullptr) - { - SPDLOG_ERROR("Failed to load SetLightingSettings with version {}", version); - return nullptr; - } + if (factory == nullptr) { + SPDLOG_ERROR("Failed to load SetLightingSettings with version {}", resource->InitData->ResourceVersion); + return nullptr; + } - factory->ParseFileBinary(reader, resource); + factory->ParseFileBinary(reader, resource); - return resource; + return resource; } void Ship::SetLightingSettingsFactoryV0::ParseFileBinary(std::shared_ptr reader, std::shared_ptr resource) { - std::shared_ptr setLightingSettings = std::static_pointer_cast(resource); - ResourceVersionFactory::ParseFileBinary(reader, setLightingSettings); + std::shared_ptr setLightingSettings = std::static_pointer_cast(resource); + ResourceVersionFactory::ParseFileBinary(reader, setLightingSettings); - ReadCommandId(setLightingSettings, reader); + ReadCommandId(setLightingSettings, reader); - uint32_t count = reader->ReadInt32(); + uint32_t count = reader->ReadInt32(); setLightingSettings->settings.reserve(count); - for (uint32_t i = 0; i < count; i++) { - EnvLightSettings lightSettings; + for (uint32_t i = 0; i < count; i++) { + EnvLightSettings lightSettings; lightSettings.ambientColor[0] = reader->ReadInt8(); lightSettings.ambientColor[1] = reader->ReadInt8(); lightSettings.ambientColor[2] = reader->ReadInt8(); @@ -65,8 +64,8 @@ void Ship::SetLightingSettingsFactoryV0::ParseFileBinary(std::shared_ptrReadInt16(); lightSettings.fogFar = reader->ReadUInt16(); - setLightingSettings->settings.push_back(lightSettings); - } + setLightingSettings->settings.push_back(lightSettings); + } } } // namespace Ship diff --git a/soh/soh/resource/importer/scenecommand/SetLightingSettingsFactory.h b/soh/soh/resource/importer/scenecommand/SetLightingSettingsFactory.h index 2b4600c7d..f02b65883 100644 --- a/soh/soh/resource/importer/scenecommand/SetLightingSettingsFactory.h +++ b/soh/soh/resource/importer/scenecommand/SetLightingSettingsFactory.h @@ -5,7 +5,9 @@ namespace Ship { class SetLightingSettingsFactory : public SceneCommandFactory { public: - std::shared_ptr ReadResource(uint32_t version, std::shared_ptr reader); + std::shared_ptr ReadResource(std::shared_ptr resourceMgr, + std::shared_ptr initData, + std::shared_ptr reader) override; }; class SetLightingSettingsFactoryV0 : public SceneCommandVersionFactory { diff --git a/soh/soh/resource/importer/scenecommand/SetMeshFactory.cpp b/soh/soh/resource/importer/scenecommand/SetMeshFactory.cpp index 7de2b0436..6a1e4d33c 100644 --- a/soh/soh/resource/importer/scenecommand/SetMeshFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetMeshFactory.cpp @@ -4,13 +4,13 @@ #include "libultraship/bridge.h" namespace Ship { -std::shared_ptr SetMeshFactory::ReadResource(uint32_t version, std::shared_ptr reader) -{ - auto resource = std::make_shared(); +std::shared_ptr SetMeshFactory::ReadResource(std::shared_ptr resourceMgr, + std::shared_ptr initData, + std::shared_ptr reader) { + auto resource = std::make_shared(resourceMgr, initData); std::shared_ptr factory = nullptr; - switch (version) - { + switch (resource->InitData->ResourceVersion) { case 0: factory = std::make_shared(); break; @@ -18,7 +18,7 @@ std::shared_ptr SetMeshFactory::ReadResource(uint32_t version, std::sh if (factory == nullptr) { - SPDLOG_ERROR("Failed to load SetMesh with version {}", version); + SPDLOG_ERROR("Failed to load SetMesh with version {}", resource->InitData->ResourceVersion); return nullptr; } @@ -86,9 +86,9 @@ void Ship::SetMeshFactoryV0::ParseFileBinary(std::shared_ptr reade BgImage image; image.unk_00 = reader->ReadUInt16(); image.id = reader->ReadUByte(); - std::string sourceFile = reader->ReadString(); - void* sourceData = GetResourceDataByName(sourceFile.c_str(), true); - image.source = sourceData; + std::string imagePath = "__OTR__" + reader->ReadString(); + setMesh->imagePaths.push_back(imagePath); + image.source = (void*)setMesh->imagePaths.back().c_str(); image.unk_0C = reader->ReadUInt32(); image.tlut = reader->ReadUInt32(); image.width = reader->ReadUInt16(); diff --git a/soh/soh/resource/importer/scenecommand/SetMeshFactory.h b/soh/soh/resource/importer/scenecommand/SetMeshFactory.h index be11cc0db..968002860 100644 --- a/soh/soh/resource/importer/scenecommand/SetMeshFactory.h +++ b/soh/soh/resource/importer/scenecommand/SetMeshFactory.h @@ -5,7 +5,9 @@ namespace Ship { class SetMeshFactory : public SceneCommandFactory { public: - std::shared_ptr ReadResource(uint32_t version, std::shared_ptr reader); + std::shared_ptr ReadResource(std::shared_ptr resourceMgr, + std::shared_ptr initData, + std::shared_ptr reader) override; }; class SetMeshFactoryV0 : public SceneCommandVersionFactory { diff --git a/soh/soh/resource/importer/scenecommand/SetObjectListFactory.cpp b/soh/soh/resource/importer/scenecommand/SetObjectListFactory.cpp index 2eddd6c3d..8d483631a 100644 --- a/soh/soh/resource/importer/scenecommand/SetObjectListFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetObjectListFactory.cpp @@ -3,36 +3,35 @@ #include "spdlog/spdlog.h" namespace Ship { -std::shared_ptr SetObjectListFactory::ReadResource(uint32_t version, std::shared_ptr reader) -{ - auto resource = std::make_shared(); - std::shared_ptr factory = nullptr; +std::shared_ptr SetObjectListFactory::ReadResource(std::shared_ptr resourceMgr, + std::shared_ptr initData, + std::shared_ptr reader) { + auto resource = std::make_shared(resourceMgr, initData); + std::shared_ptr factory = nullptr; - switch (version) - { - case 0: - factory = std::make_shared(); - break; - } + switch (resource->InitData->ResourceVersion) { + case 0: + factory = std::make_shared(); + break; + } - if (factory == nullptr) - { - SPDLOG_ERROR("Failed to load SetObjectList with version {}", version); - return nullptr; - } + if (factory == nullptr) { + SPDLOG_ERROR("Failed to load SetObjectList with version {}", resource->InitData->ResourceVersion); + return nullptr; + } - factory->ParseFileBinary(reader, resource); + factory->ParseFileBinary(reader, resource); - return resource; + return resource; } void Ship::SetObjectListFactoryV0::ParseFileBinary(std::shared_ptr reader, std::shared_ptr resource) { - std::shared_ptr setObjectList = std::static_pointer_cast(resource); - ResourceVersionFactory::ParseFileBinary(reader, setObjectList); + std::shared_ptr setObjectList = std::static_pointer_cast(resource); + ResourceVersionFactory::ParseFileBinary(reader, setObjectList); - ReadCommandId(setObjectList, reader); + ReadCommandId(setObjectList, reader); setObjectList->numObjects = reader->ReadUInt32(); setObjectList->objects.reserve(setObjectList->numObjects); diff --git a/soh/soh/resource/importer/scenecommand/SetObjectListFactory.h b/soh/soh/resource/importer/scenecommand/SetObjectListFactory.h index b7bb27f95..b3a9f9666 100644 --- a/soh/soh/resource/importer/scenecommand/SetObjectListFactory.h +++ b/soh/soh/resource/importer/scenecommand/SetObjectListFactory.h @@ -5,7 +5,9 @@ namespace Ship { class SetObjectListFactory : public SceneCommandFactory { public: - std::shared_ptr ReadResource(uint32_t version, std::shared_ptr reader); + std::shared_ptr ReadResource(std::shared_ptr resourceMgr, + std::shared_ptr initData, + std::shared_ptr reader) override; }; class SetObjectListFactoryV0 : public SceneCommandVersionFactory { diff --git a/soh/soh/resource/importer/scenecommand/SetPathwaysFactory.cpp b/soh/soh/resource/importer/scenecommand/SetPathwaysFactory.cpp index 420b13204..93d96ce03 100644 --- a/soh/soh/resource/importer/scenecommand/SetPathwaysFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetPathwaysFactory.cpp @@ -4,36 +4,34 @@ #include namespace Ship { -std::shared_ptr SetPathwaysFactory::ReadResource(uint32_t version, std::shared_ptr reader) -{ - auto resource = std::make_shared(); - std::shared_ptr factory = nullptr; +std::shared_ptr SetPathwaysFactory::ReadResource(std::shared_ptr resourceMgr, + std::shared_ptr initData, + std::shared_ptr reader) { + auto resource = std::make_shared(resourceMgr, initData); + std::shared_ptr factory = nullptr; - switch (version) - { - case 0: - factory = std::make_shared(); - break; - } + switch (resource->InitData->ResourceVersion) { + case 0: + factory = std::make_shared(); + break; + } - if (factory == nullptr) - { - SPDLOG_ERROR("Failed to load SetPathways with version {}", version); - return nullptr; - } + if (factory == nullptr) { + SPDLOG_ERROR("Failed to load SetPathways with version {}", resource->InitData->ResourceVersion); + return nullptr; + } - factory->ParseFileBinary(reader, resource); + factory->ParseFileBinary(reader, resource); - return resource; + return resource; } void Ship::SetPathwaysFactoryV0::ParseFileBinary(std::shared_ptr reader, - std::shared_ptr resource) -{ - std::shared_ptr setPathways = std::static_pointer_cast(resource); - ResourceVersionFactory::ParseFileBinary(reader, setPathways); + std::shared_ptr resource) { + std::shared_ptr setPathways = std::static_pointer_cast(resource); + ResourceVersionFactory::ParseFileBinary(reader, setPathways); - ReadCommandId(setPathways, reader); + ReadCommandId(setPathways, reader); setPathways->numPaths = reader->ReadUInt32(); setPathways->paths.reserve(setPathways->numPaths); diff --git a/soh/soh/resource/importer/scenecommand/SetPathwaysFactory.h b/soh/soh/resource/importer/scenecommand/SetPathwaysFactory.h index d6df48ca7..c7c69183d 100644 --- a/soh/soh/resource/importer/scenecommand/SetPathwaysFactory.h +++ b/soh/soh/resource/importer/scenecommand/SetPathwaysFactory.h @@ -5,7 +5,9 @@ namespace Ship { class SetPathwaysFactory : public SceneCommandFactory { public: - std::shared_ptr ReadResource(uint32_t version, std::shared_ptr reader); + std::shared_ptr ReadResource(std::shared_ptr resourceMgr, + std::shared_ptr initData, + std::shared_ptr reader) override; }; class SetPathwaysFactoryV0 : public SceneCommandVersionFactory { diff --git a/soh/soh/resource/importer/scenecommand/SetRoomBehaviorFactory.cpp b/soh/soh/resource/importer/scenecommand/SetRoomBehaviorFactory.cpp index effac3bd6..f387a111c 100644 --- a/soh/soh/resource/importer/scenecommand/SetRoomBehaviorFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetRoomBehaviorFactory.cpp @@ -3,36 +3,34 @@ #include "spdlog/spdlog.h" namespace Ship { -std::shared_ptr SetRoomBehaviorFactory::ReadResource(uint32_t version, std::shared_ptr reader) -{ - auto resource = std::make_shared(); - std::shared_ptr factory = nullptr; +std::shared_ptr SetRoomBehaviorFactory::ReadResource(std::shared_ptr resourceMgr, + std::shared_ptr initData, + std::shared_ptr reader) { + auto resource = std::make_shared(resourceMgr, initData); + std::shared_ptr factory = nullptr; - switch (version) - { - case 0: - factory = std::make_shared(); - break; - } + switch (resource->InitData->ResourceVersion) { + case 0: + factory = std::make_shared(); + break; + } - if (factory == nullptr) - { - SPDLOG_ERROR("Failed to load SetRoomBehavior with version {}", version); - return nullptr; - } + if (factory == nullptr) { + SPDLOG_ERROR("Failed to load SetRoomBehavior with version {}", resource->InitData->ResourceVersion); + return nullptr; + } - factory->ParseFileBinary(reader, resource); + factory->ParseFileBinary(reader, resource); - return resource; + return resource; } void Ship::SetRoomBehaviorFactoryV0::ParseFileBinary(std::shared_ptr reader, - std::shared_ptr resource) -{ - std::shared_ptr setRoomBehavior = std::static_pointer_cast(resource); - ResourceVersionFactory::ParseFileBinary(reader, setRoomBehavior); + std::shared_ptr resource) { + std::shared_ptr setRoomBehavior = std::static_pointer_cast(resource); + ResourceVersionFactory::ParseFileBinary(reader, setRoomBehavior); - ReadCommandId(setRoomBehavior, reader); + ReadCommandId(setRoomBehavior, reader); setRoomBehavior->roomBehavior.gameplayFlags = reader->ReadInt8(); setRoomBehavior->roomBehavior.gameplayFlags2 = reader->ReadInt32(); diff --git a/soh/soh/resource/importer/scenecommand/SetRoomBehaviorFactory.h b/soh/soh/resource/importer/scenecommand/SetRoomBehaviorFactory.h index 836d1bbe8..6f0d6d1bf 100644 --- a/soh/soh/resource/importer/scenecommand/SetRoomBehaviorFactory.h +++ b/soh/soh/resource/importer/scenecommand/SetRoomBehaviorFactory.h @@ -5,7 +5,9 @@ namespace Ship { class SetRoomBehaviorFactory : public SceneCommandFactory { public: - std::shared_ptr ReadResource(uint32_t version, std::shared_ptr reader); + std::shared_ptr ReadResource(std::shared_ptr resourceMgr, + std::shared_ptr initData, + std::shared_ptr reader) override; }; class SetRoomBehaviorFactoryV0 : public SceneCommandVersionFactory { diff --git a/soh/soh/resource/importer/scenecommand/SetRoomListFactory.cpp b/soh/soh/resource/importer/scenecommand/SetRoomListFactory.cpp index 87d64109f..df5dea725 100644 --- a/soh/soh/resource/importer/scenecommand/SetRoomListFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetRoomListFactory.cpp @@ -3,47 +3,46 @@ #include "spdlog/spdlog.h" namespace Ship { -std::shared_ptr SetRoomListFactory::ReadResource(uint32_t version, std::shared_ptr reader) -{ - auto resource = std::make_shared(); - std::shared_ptr factory = nullptr; +std::shared_ptr SetRoomListFactory::ReadResource(std::shared_ptr resourceMgr, + std::shared_ptr initData, + std::shared_ptr reader) { + auto resource = std::make_shared(resourceMgr, initData); + std::shared_ptr factory = nullptr; - switch (version) - { - case 0: - factory = std::make_shared(); - break; - } + switch (resource->InitData->ResourceVersion) { + case 0: + factory = std::make_shared(); + break; + } - if (factory == nullptr) - { - SPDLOG_ERROR("Failed to load SetRoomList with version {}", version); - return nullptr; - } + if (factory == nullptr) + { + SPDLOG_ERROR("Failed to load SetRoomList with version {}", resource->InitData->ResourceVersion); + return nullptr; + } - factory->ParseFileBinary(reader, resource); + factory->ParseFileBinary(reader, resource); - return resource; + return resource; } void Ship::SetRoomListFactoryV0::ParseFileBinary(std::shared_ptr reader, - std::shared_ptr resource) -{ - std::shared_ptr setRoomList = std::static_pointer_cast(resource); - ResourceVersionFactory::ParseFileBinary(reader, setRoomList); + std::shared_ptr resource) { + std::shared_ptr setRoomList = std::static_pointer_cast(resource); + ResourceVersionFactory::ParseFileBinary(reader, setRoomList); - ReadCommandId(setRoomList, reader); + 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); } diff --git a/soh/soh/resource/importer/scenecommand/SetRoomListFactory.h b/soh/soh/resource/importer/scenecommand/SetRoomListFactory.h index 3b6e0976d..f85aef356 100644 --- a/soh/soh/resource/importer/scenecommand/SetRoomListFactory.h +++ b/soh/soh/resource/importer/scenecommand/SetRoomListFactory.h @@ -5,7 +5,9 @@ namespace Ship { class SetRoomListFactory : public SceneCommandFactory { public: - std::shared_ptr ReadResource(uint32_t version, std::shared_ptr reader); + std::shared_ptr ReadResource(std::shared_ptr resourceMgr, + std::shared_ptr initData, + std::shared_ptr reader) override; }; class SetRoomListFactoryV0 : public SceneCommandVersionFactory { diff --git a/soh/soh/resource/importer/scenecommand/SetSkyboxModifierFactory.cpp b/soh/soh/resource/importer/scenecommand/SetSkyboxModifierFactory.cpp index 565e156c0..0199d2dda 100644 --- a/soh/soh/resource/importer/scenecommand/SetSkyboxModifierFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetSkyboxModifierFactory.cpp @@ -3,32 +3,30 @@ #include "spdlog/spdlog.h" namespace Ship { -std::shared_ptr SetSkyboxModifierFactory::ReadResource(uint32_t version, std::shared_ptr reader) -{ - auto resource = std::make_shared(); - std::shared_ptr factory = nullptr; +std::shared_ptr SetSkyboxModifierFactory::ReadResource(std::shared_ptr resourceMgr, + std::shared_ptr initData, + std::shared_ptr reader) { + auto resource = std::make_shared(resourceMgr, initData); + std::shared_ptr factory = nullptr; - switch (version) - { - case 0: - factory = std::make_shared(); - break; - } + switch (resource->InitData->ResourceVersion) { + case 0: + factory = std::make_shared(); + break; + } - if (factory == nullptr) - { - SPDLOG_ERROR("Failed to load SetSkyboxModifier with version {}", version); - return nullptr; - } + if (factory == nullptr) { + SPDLOG_ERROR("Failed to load SetSkyboxModifier with version {}", resource->InitData->ResourceVersion); + return nullptr; + } - factory->ParseFileBinary(reader, resource); + factory->ParseFileBinary(reader, resource); - return resource; + return resource; } void Ship::SetSkyboxModifierFactoryV0::ParseFileBinary(std::shared_ptr reader, - std::shared_ptr resource) -{ + std::shared_ptr resource) { std::shared_ptr setSkyboxModifier = std::static_pointer_cast(resource); ResourceVersionFactory::ParseFileBinary(reader, setSkyboxModifier); diff --git a/soh/soh/resource/importer/scenecommand/SetSkyboxModifierFactory.h b/soh/soh/resource/importer/scenecommand/SetSkyboxModifierFactory.h index 1d4ab43c0..fe29e5ff0 100644 --- a/soh/soh/resource/importer/scenecommand/SetSkyboxModifierFactory.h +++ b/soh/soh/resource/importer/scenecommand/SetSkyboxModifierFactory.h @@ -5,7 +5,9 @@ namespace Ship { class SetSkyboxModifierFactory : public SceneCommandFactory { public: - std::shared_ptr ReadResource(uint32_t version, std::shared_ptr reader); + std::shared_ptr ReadResource(std::shared_ptr resourceMgr, + std::shared_ptr initData, + std::shared_ptr reader) override; }; class SetSkyboxModifierFactoryV0 : public SceneCommandVersionFactory { diff --git a/soh/soh/resource/importer/scenecommand/SetSkyboxSettingsFactory.cpp b/soh/soh/resource/importer/scenecommand/SetSkyboxSettingsFactory.cpp index 803479ea1..66e80be6f 100644 --- a/soh/soh/resource/importer/scenecommand/SetSkyboxSettingsFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetSkyboxSettingsFactory.cpp @@ -3,39 +3,37 @@ #include "spdlog/spdlog.h" namespace Ship { -std::shared_ptr SetSkyboxSettingsFactory::ReadResource(uint32_t version, std::shared_ptr reader) -{ - auto resource = std::make_shared(); - std::shared_ptr factory = nullptr; +std::shared_ptr SetSkyboxSettingsFactory::ReadResource(std::shared_ptr resourceMgr, + std::shared_ptr initData, + std::shared_ptr reader) { + auto resource = std::make_shared(resourceMgr, initData); + std::shared_ptr factory = nullptr; - switch (version) - { - case 0: - factory = std::make_shared(); - break; - } + switch (resource->InitData->ResourceVersion) { + case 0: + factory = std::make_shared(); + break; + } - if (factory == nullptr) - { - SPDLOG_ERROR("Failed to load SetSkyboxSettings with version {}", version); - return nullptr; - } + if (factory == nullptr) { + SPDLOG_ERROR("Failed to load SetSkyboxSettings with version {}", resource->InitData->ResourceVersion); + return nullptr; + } - factory->ParseFileBinary(reader, resource); + factory->ParseFileBinary(reader, resource); - return 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); + std::shared_ptr resource) { + std::shared_ptr setSkyboxSettings = std::static_pointer_cast(resource); + ResourceVersionFactory::ParseFileBinary(reader, setSkyboxSettings); - ReadCommandId(setSkyboxSettings, reader); + ReadCommandId(setSkyboxSettings, reader); setSkyboxSettings->settings.unk = reader->ReadInt8(); - setSkyboxSettings->settings.skyboxId = reader->ReadInt8(); + setSkyboxSettings->settings.skyboxId = reader->ReadInt8(); setSkyboxSettings->settings.weather = reader->ReadInt8(); setSkyboxSettings->settings.indoors = reader->ReadInt8(); } diff --git a/soh/soh/resource/importer/scenecommand/SetSkyboxSettingsFactory.h b/soh/soh/resource/importer/scenecommand/SetSkyboxSettingsFactory.h index 170689159..9c84c579a 100644 --- a/soh/soh/resource/importer/scenecommand/SetSkyboxSettingsFactory.h +++ b/soh/soh/resource/importer/scenecommand/SetSkyboxSettingsFactory.h @@ -5,7 +5,9 @@ namespace Ship { class SetSkyboxSettingsFactory : public SceneCommandFactory { public: - std::shared_ptr ReadResource(uint32_t version, std::shared_ptr reader); + std::shared_ptr ReadResource(std::shared_ptr resourceMgr, + std::shared_ptr initData, + std::shared_ptr reader) override; }; class SetSkyboxSettingsFactoryV0 : public SceneCommandVersionFactory { diff --git a/soh/soh/resource/importer/scenecommand/SetSoundSettingsFactory.cpp b/soh/soh/resource/importer/scenecommand/SetSoundSettingsFactory.cpp index e6d569969..bf1815628 100644 --- a/soh/soh/resource/importer/scenecommand/SetSoundSettingsFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetSoundSettingsFactory.cpp @@ -3,36 +3,34 @@ #include "spdlog/spdlog.h" namespace Ship { -std::shared_ptr SetSoundSettingsFactory::ReadResource(uint32_t version, std::shared_ptr reader) -{ - auto resource = std::make_shared(); - std::shared_ptr factory = nullptr; +std::shared_ptr SetSoundSettingsFactory::ReadResource(std::shared_ptr resourceMgr, + std::shared_ptr initData, + std::shared_ptr reader) { + auto resource = std::make_shared(resourceMgr, initData); + std::shared_ptr factory = nullptr; - switch (version) - { - case 0: - factory = std::make_shared(); - break; - } + switch (resource->InitData->ResourceVersion) { + case 0: + factory = std::make_shared(); + break; + } - if (factory == nullptr) - { - SPDLOG_ERROR("Failed to load SetSoundSettings with version {}", version); - return nullptr; - } + if (factory == nullptr) { + SPDLOG_ERROR("Failed to load SetSoundSettings with version {}", resource->InitData->ResourceVersion); + return nullptr; + } - factory->ParseFileBinary(reader, resource); + factory->ParseFileBinary(reader, resource); - return resource; + return resource; } void Ship::SetSoundSettingsFactoryV0::ParseFileBinary(std::shared_ptr reader, - std::shared_ptr resource) -{ - std::shared_ptr setSoundSettings = std::static_pointer_cast(resource); - ResourceVersionFactory::ParseFileBinary(reader, setSoundSettings); + std::shared_ptr resource) { + std::shared_ptr setSoundSettings = std::static_pointer_cast(resource); + ResourceVersionFactory::ParseFileBinary(reader, setSoundSettings); - ReadCommandId(setSoundSettings, reader); + ReadCommandId(setSoundSettings, reader); setSoundSettings->settings.reverb = reader->ReadInt8(); setSoundSettings->settings.natureAmbienceId = reader->ReadInt8(); diff --git a/soh/soh/resource/importer/scenecommand/SetSoundSettingsFactory.h b/soh/soh/resource/importer/scenecommand/SetSoundSettingsFactory.h index 94b2702cf..f790908c9 100644 --- a/soh/soh/resource/importer/scenecommand/SetSoundSettingsFactory.h +++ b/soh/soh/resource/importer/scenecommand/SetSoundSettingsFactory.h @@ -5,7 +5,9 @@ namespace Ship { class SetSoundSettingsFactory : public SceneCommandFactory { public: - std::shared_ptr ReadResource(uint32_t version, std::shared_ptr reader); + std::shared_ptr ReadResource(std::shared_ptr resourceMgr, + std::shared_ptr initData, + std::shared_ptr reader) override; }; class SetSoundSettingsFactoryV0 : public SceneCommandVersionFactory { diff --git a/soh/soh/resource/importer/scenecommand/SetSpecialObjectsFactory.cpp b/soh/soh/resource/importer/scenecommand/SetSpecialObjectsFactory.cpp index 93807b640..d607a9ade 100644 --- a/soh/soh/resource/importer/scenecommand/SetSpecialObjectsFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetSpecialObjectsFactory.cpp @@ -3,39 +3,37 @@ #include "spdlog/spdlog.h" namespace Ship { -std::shared_ptr SetSpecialObjectsFactory::ReadResource(uint32_t version, std::shared_ptr reader) -{ - auto resource = std::make_shared(); - std::shared_ptr factory = nullptr; +std::shared_ptr SetSpecialObjectsFactory::ReadResource(std::shared_ptr resourceMgr, + std::shared_ptr initData, + std::shared_ptr reader) { + auto resource = std::make_shared(resourceMgr, initData); + std::shared_ptr factory = nullptr; - switch (version) - { - case 0: - factory = std::make_shared(); - break; - } + switch (resource->InitData->ResourceVersion) { + case 0: + factory = std::make_shared(); + break; + } - if (factory == nullptr) - { - SPDLOG_ERROR("Failed to load SetSpecialObjects with version {}", version); - return nullptr; - } + if (factory == nullptr){ + SPDLOG_ERROR("Failed to load SetSpecialObjects with version {}", resource->InitData->ResourceVersion); + return nullptr; + } - factory->ParseFileBinary(reader, resource); + factory->ParseFileBinary(reader, resource); - return resource; + return resource; } void Ship::SetSpecialObjectsFactoryV0::ParseFileBinary(std::shared_ptr reader, - std::shared_ptr resource) -{ - std::shared_ptr setSpecialObjects = std::static_pointer_cast(resource); - ResourceVersionFactory::ParseFileBinary(reader, setSpecialObjects); + std::shared_ptr resource) { + std::shared_ptr setSpecialObjects = std::static_pointer_cast(resource); + ResourceVersionFactory::ParseFileBinary(reader, setSpecialObjects); - ReadCommandId(setSpecialObjects, reader); - - setSpecialObjects->specialObjects.elfMessage = reader->ReadInt8(); - setSpecialObjects->specialObjects.globalObject = reader->ReadInt16(); + ReadCommandId(setSpecialObjects, reader); + + setSpecialObjects->specialObjects.elfMessage = reader->ReadInt8(); + setSpecialObjects->specialObjects.globalObject = reader->ReadInt16(); } } // namespace Ship diff --git a/soh/soh/resource/importer/scenecommand/SetSpecialObjectsFactory.h b/soh/soh/resource/importer/scenecommand/SetSpecialObjectsFactory.h index c0f41bd64..05190c631 100644 --- a/soh/soh/resource/importer/scenecommand/SetSpecialObjectsFactory.h +++ b/soh/soh/resource/importer/scenecommand/SetSpecialObjectsFactory.h @@ -5,7 +5,9 @@ namespace Ship { class SetSpecialObjectsFactory : public SceneCommandFactory { public: - std::shared_ptr ReadResource(uint32_t version, std::shared_ptr reader); + std::shared_ptr ReadResource(std::shared_ptr resourceMgr, + std::shared_ptr initData, + std::shared_ptr reader) override; }; class SetSpecialObjectsFactoryV0 : public SceneCommandVersionFactory { diff --git a/soh/soh/resource/importer/scenecommand/SetStartPositionListFactory.cpp b/soh/soh/resource/importer/scenecommand/SetStartPositionListFactory.cpp index 2d1c41186..c35721782 100644 --- a/soh/soh/resource/importer/scenecommand/SetStartPositionListFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetStartPositionListFactory.cpp @@ -3,50 +3,51 @@ #include "spdlog/spdlog.h" namespace Ship { -std::shared_ptr SetStartPositionListFactory::ReadResource(uint32_t version, std::shared_ptr reader) -{ - auto resource = std::make_shared(); - std::shared_ptr factory = nullptr; +std::shared_ptr SetStartPositionListFactory::ReadResource(std::shared_ptr resourceMgr, + std::shared_ptr initData, + std::shared_ptr reader) { + auto resource = std::make_shared(resourceMgr, initData); + std::shared_ptr factory = nullptr; - switch (version) - { - case 0: - factory = std::make_shared(); - break; - } + switch (resource->InitData->ResourceVersion) + { + case 0: + factory = std::make_shared(); + break; + } - if (factory == nullptr) - { - SPDLOG_ERROR("Failed to load SetStartPositionList with version {}", version); - return nullptr; - } + if (factory == nullptr) + { + SPDLOG_ERROR("Failed to load SetStartPositionList with version {}", resource->InitData->ResourceVersion); + return nullptr; + } - factory->ParseFileBinary(reader, resource); + factory->ParseFileBinary(reader, resource); - return resource; + return resource; } void Ship::SetStartPositionListFactoryV0::ParseFileBinary(std::shared_ptr reader, std::shared_ptr resource) { - std::shared_ptr setStartPositionList = std::static_pointer_cast(resource); - ResourceVersionFactory::ParseFileBinary(reader, setStartPositionList); + std::shared_ptr setStartPositionList = std::static_pointer_cast(resource); + ResourceVersionFactory::ParseFileBinary(reader, setStartPositionList); - ReadCommandId(setStartPositionList, reader); + 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); } diff --git a/soh/soh/resource/importer/scenecommand/SetStartPositionListFactory.h b/soh/soh/resource/importer/scenecommand/SetStartPositionListFactory.h index d6e6ffbe8..d218348f7 100644 --- a/soh/soh/resource/importer/scenecommand/SetStartPositionListFactory.h +++ b/soh/soh/resource/importer/scenecommand/SetStartPositionListFactory.h @@ -5,7 +5,9 @@ namespace Ship { class SetStartPositionListFactory : public SceneCommandFactory { public: - std::shared_ptr ReadResource(uint32_t version, std::shared_ptr reader); + std::shared_ptr ReadResource(std::shared_ptr resourceMgr, + std::shared_ptr initData, + std::shared_ptr reader) override; }; class SetStartPositionListFactoryV0 : public SceneCommandVersionFactory { diff --git a/soh/soh/resource/importer/scenecommand/SetTimeSettingsFactory.cpp b/soh/soh/resource/importer/scenecommand/SetTimeSettingsFactory.cpp index a0494cb22..5542e95a8 100644 --- a/soh/soh/resource/importer/scenecommand/SetTimeSettingsFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetTimeSettingsFactory.cpp @@ -3,40 +3,38 @@ #include "spdlog/spdlog.h" namespace Ship { -std::shared_ptr SetTimeSettingsFactory::ReadResource(uint32_t version, std::shared_ptr reader) -{ - auto resource = std::make_shared(); - std::shared_ptr factory = nullptr; +std::shared_ptr SetTimeSettingsFactory::ReadResource(std::shared_ptr resourceMgr, + std::shared_ptr initData, + std::shared_ptr reader) { + auto resource = std::make_shared(resourceMgr, initData); + std::shared_ptr factory = nullptr; - switch (version) - { - case 0: - factory = std::make_shared(); - break; - } + switch (resource->InitData->ResourceVersion) { + case 0: + factory = std::make_shared(); + break; + } - if (factory == nullptr) - { - SPDLOG_ERROR("Failed to load SetTimeSettings with version {}", version); - return nullptr; - } + if (factory == nullptr) { + SPDLOG_ERROR("Failed to load SetTimeSettings with version {}", resource->InitData->ResourceVersion); + return nullptr; + } - factory->ParseFileBinary(reader, resource); + factory->ParseFileBinary(reader, resource); - return resource; + return resource; } void Ship::SetTimeSettingsFactoryV0::ParseFileBinary(std::shared_ptr reader, - std::shared_ptr resource) -{ - std::shared_ptr setTimeSettings = std::static_pointer_cast(resource); - ResourceVersionFactory::ParseFileBinary(reader, setTimeSettings); + std::shared_ptr resource) { + std::shared_ptr setTimeSettings = std::static_pointer_cast(resource); + ResourceVersionFactory::ParseFileBinary(reader, setTimeSettings); - ReadCommandId(setTimeSettings, reader); - - setTimeSettings->settings.hour = reader->ReadInt8(); - setTimeSettings->settings.minute = reader->ReadInt8(); - setTimeSettings->settings.timeIncrement = reader->ReadInt8(); + ReadCommandId(setTimeSettings, reader); + + setTimeSettings->settings.hour = reader->ReadInt8(); + setTimeSettings->settings.minute = reader->ReadInt8(); + setTimeSettings->settings.timeIncrement = reader->ReadInt8(); } } // namespace Ship diff --git a/soh/soh/resource/importer/scenecommand/SetTimeSettingsFactory.h b/soh/soh/resource/importer/scenecommand/SetTimeSettingsFactory.h index e2a9fbd66..746b9b788 100644 --- a/soh/soh/resource/importer/scenecommand/SetTimeSettingsFactory.h +++ b/soh/soh/resource/importer/scenecommand/SetTimeSettingsFactory.h @@ -5,7 +5,9 @@ namespace Ship { class SetTimeSettingsFactory : public SceneCommandFactory { public: - std::shared_ptr ReadResource(uint32_t version, std::shared_ptr reader); + std::shared_ptr ReadResource(std::shared_ptr resourceMgr, + std::shared_ptr initData, + std::shared_ptr reader) override; }; class SetTimeSettingsFactoryV0 : public SceneCommandVersionFactory { diff --git a/soh/soh/resource/importer/scenecommand/SetTransitionActorListFactory.cpp b/soh/soh/resource/importer/scenecommand/SetTransitionActorListFactory.cpp index a806a3f15..af53e17af 100644 --- a/soh/soh/resource/importer/scenecommand/SetTransitionActorListFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetTransitionActorListFactory.cpp @@ -3,41 +3,39 @@ #include "spdlog/spdlog.h" namespace Ship { -std::shared_ptr SetTransitionActorListFactory::ReadResource(uint32_t version, std::shared_ptr reader) -{ - auto resource = std::make_shared(); - std::shared_ptr factory = nullptr; +std::shared_ptr SetTransitionActorListFactory::ReadResource(std::shared_ptr resourceMgr, + std::shared_ptr initData, + std::shared_ptr reader) { + auto resource = std::make_shared(resourceMgr, initData); + std::shared_ptr factory = nullptr; - switch (version) - { - case 0: - factory = std::make_shared(); - break; - } + switch (resource->InitData->ResourceVersion) { + case 0: + factory = std::make_shared(); + break; + } - if (factory == nullptr) - { - SPDLOG_ERROR("Failed to load SetTransitionActorList with version {}", version); - return nullptr; - } + if (factory == nullptr) { + SPDLOG_ERROR("Failed to load SetTransitionActorList with version {}", resource->InitData->ResourceVersion); + return nullptr; + } - factory->ParseFileBinary(reader, resource); + factory->ParseFileBinary(reader, resource); - return resource; + return resource; } void Ship::SetTransitionActorListFactoryV0::ParseFileBinary(std::shared_ptr reader, - std::shared_ptr resource) -{ - std::shared_ptr setTransitionActorList = std::static_pointer_cast(resource); - ResourceVersionFactory::ParseFileBinary(reader, setTransitionActorList); + std::shared_ptr resource) { + std::shared_ptr setTransitionActorList = std::static_pointer_cast(resource); + ResourceVersionFactory::ParseFileBinary(reader, setTransitionActorList); - ReadCommandId(setTransitionActorList, reader); + ReadCommandId(setTransitionActorList, reader); setTransitionActorList->numTransitionActors = reader->ReadUInt32(); setTransitionActorList->transitionActorList.reserve(setTransitionActorList->numTransitionActors); for (uint32_t i = 0; i < setTransitionActorList->numTransitionActors; i++) { - TransitionActorEntry entry; + TransitionActorEntry entry; entry.sides[0].room = reader->ReadUByte(); entry.sides[0].effects = reader->ReadUByte(); diff --git a/soh/soh/resource/importer/scenecommand/SetTransitionActorListFactory.h b/soh/soh/resource/importer/scenecommand/SetTransitionActorListFactory.h index 86408ed70..b6242c341 100644 --- a/soh/soh/resource/importer/scenecommand/SetTransitionActorListFactory.h +++ b/soh/soh/resource/importer/scenecommand/SetTransitionActorListFactory.h @@ -5,7 +5,9 @@ namespace Ship { class SetTransitionActorListFactory : public SceneCommandFactory { public: - std::shared_ptr ReadResource(uint32_t version, std::shared_ptr reader); + std::shared_ptr ReadResource(std::shared_ptr resourceMgr, + std::shared_ptr initData, + std::shared_ptr reader) override; }; class SetTransitionActorListFactoryV0 : public SceneCommandVersionFactory { diff --git a/soh/soh/resource/importer/scenecommand/SetWindSettingsFactory.cpp b/soh/soh/resource/importer/scenecommand/SetWindSettingsFactory.cpp index f4d3be08b..8727008b7 100644 --- a/soh/soh/resource/importer/scenecommand/SetWindSettingsFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetWindSettingsFactory.cpp @@ -3,38 +3,36 @@ #include "spdlog/spdlog.h" namespace Ship { -std::shared_ptr SetWindSettingsFactory::ReadResource(uint32_t version, std::shared_ptr reader) -{ - auto resource = std::make_shared(); - std::shared_ptr factory = nullptr; +std::shared_ptr SetWindSettingsFactory::ReadResource(std::shared_ptr resourceMgr, + std::shared_ptr initData, + std::shared_ptr reader) { + auto resource = std::make_shared(resourceMgr, initData); + std::shared_ptr factory = nullptr; - switch (version) - { - case 0: - factory = std::make_shared(); - break; - } + switch (resource->InitData->ResourceVersion) { + case 0: + factory = std::make_shared(); + break; + } - if (factory == nullptr) - { - SPDLOG_ERROR("Failed to load SetWindSettings with version {}", version); - return nullptr; - } + if (factory == nullptr) { + SPDLOG_ERROR("Failed to load SetWindSettings with version {}", resource->InitData->ResourceVersion); + return nullptr; + } - factory->ParseFileBinary(reader, resource); + factory->ParseFileBinary(reader, resource); - return resource; + return resource; } void Ship::SetWindSettingsFactoryV0::ParseFileBinary(std::shared_ptr reader, - std::shared_ptr resource) -{ - std::shared_ptr setWind = std::static_pointer_cast(resource); - ResourceVersionFactory::ParseFileBinary(reader, setWind); + std::shared_ptr resource) { + std::shared_ptr setWind = std::static_pointer_cast(resource); + ResourceVersionFactory::ParseFileBinary(reader, setWind); - ReadCommandId(setWind, reader); - - setWind->settings.windWest = reader->ReadInt8(); + ReadCommandId(setWind, reader); + + setWind->settings.windWest = reader->ReadInt8(); setWind->settings.windVertical = reader->ReadInt8(); setWind->settings.windSouth = reader->ReadInt8(); setWind->settings.windSpeed = reader->ReadUByte(); diff --git a/soh/soh/resource/importer/scenecommand/SetWindSettingsFactory.h b/soh/soh/resource/importer/scenecommand/SetWindSettingsFactory.h index 20b0b27ac..19dc1efb0 100644 --- a/soh/soh/resource/importer/scenecommand/SetWindSettingsFactory.h +++ b/soh/soh/resource/importer/scenecommand/SetWindSettingsFactory.h @@ -5,7 +5,9 @@ namespace Ship { class SetWindSettingsFactory : public SceneCommandFactory { public: - std::shared_ptr ReadResource(uint32_t version, std::shared_ptr reader); + std::shared_ptr ReadResource(std::shared_ptr resourceMgr, + std::shared_ptr initData, + std::shared_ptr reader) override; }; class SetWindSettingsFactoryV0 : public SceneCommandVersionFactory { diff --git a/soh/soh/resource/type/Animation.h b/soh/soh/resource/type/Animation.h index 6045e833b..ac78b1c25 100644 --- a/soh/soh/resource/type/Animation.h +++ b/soh/soh/resource/type/Animation.h @@ -65,6 +65,8 @@ namespace Ship { class Animation : public Resource { public: + using Resource::Resource; + void* GetPointer(); size_t GetPointerSize(); diff --git a/soh/soh/resource/type/AudioSample.h b/soh/soh/resource/type/AudioSample.h index 2407b55b5..02a9fcb39 100644 --- a/soh/soh/resource/type/AudioSample.h +++ b/soh/soh/resource/type/AudioSample.h @@ -41,6 +41,8 @@ namespace Ship { class AudioSample : public Resource { public: + using Resource::Resource; + void* GetPointer(); size_t GetPointerSize(); diff --git a/soh/soh/resource/type/AudioSequence.h b/soh/soh/resource/type/AudioSequence.h index ddfa7c004..6b473fa2e 100644 --- a/soh/soh/resource/type/AudioSequence.h +++ b/soh/soh/resource/type/AudioSequence.h @@ -19,6 +19,8 @@ typedef struct { class AudioSequence : public Resource { public: + using Resource::Resource; + void* GetPointer(); size_t GetPointerSize(); diff --git a/soh/soh/resource/type/AudioSoundFont.h b/soh/soh/resource/type/AudioSoundFont.h index 2e66b845a..c679ff912 100644 --- a/soh/soh/resource/type/AudioSoundFont.h +++ b/soh/soh/resource/type/AudioSoundFont.h @@ -54,6 +54,8 @@ typedef struct { class AudioSoundFont : public Resource { public: + using Resource::Resource; + void* GetPointer(); size_t GetPointerSize(); diff --git a/soh/soh/resource/type/Background.h b/soh/soh/resource/type/Background.h index 5f4d4c044..a00a0c1c0 100644 --- a/soh/soh/resource/type/Background.h +++ b/soh/soh/resource/type/Background.h @@ -5,6 +5,8 @@ namespace Ship { class Background : public Resource { public: + using Resource::Resource; + void* GetPointer(); size_t GetPointerSize(); diff --git a/soh/soh/resource/type/CollisionHeader.h b/soh/soh/resource/type/CollisionHeader.h index 65c84cf72..59157f737 100644 --- a/soh/soh/resource/type/CollisionHeader.h +++ b/soh/soh/resource/type/CollisionHeader.h @@ -69,6 +69,8 @@ typedef struct { class CollisionHeader : public Resource { public: + using Resource::Resource; + void* GetPointer(); size_t GetPointerSize(); diff --git a/soh/soh/resource/type/Cutscene.h b/soh/soh/resource/type/Cutscene.h index 1c747a2cc..30f4d0c61 100644 --- a/soh/soh/resource/type/Cutscene.h +++ b/soh/soh/resource/type/Cutscene.h @@ -46,6 +46,8 @@ enum class CutsceneCommands { class Cutscene : public Resource { public: + using Resource::Resource; + void* GetPointer(); size_t GetPointerSize(); diff --git a/soh/soh/resource/type/Path.h b/soh/soh/resource/type/Path.h index f64ae53a6..96afabee4 100644 --- a/soh/soh/resource/type/Path.h +++ b/soh/soh/resource/type/Path.h @@ -15,6 +15,8 @@ typedef struct { class Path : public Resource { public: + using Resource::Resource; + void* GetPointer(); size_t GetPointerSize(); diff --git a/soh/soh/resource/type/PlayerAnimation.h b/soh/soh/resource/type/PlayerAnimation.h index a4adb3464..51685360e 100644 --- a/soh/soh/resource/type/PlayerAnimation.h +++ b/soh/soh/resource/type/PlayerAnimation.h @@ -11,6 +11,8 @@ namespace Ship { class PlayerAnimation : public Resource { public: + using Resource::Resource; + void* GetPointer(); size_t GetPointerSize(); diff --git a/soh/soh/resource/type/Scene.h b/soh/soh/resource/type/Scene.h index 349f9add8..fd156b64f 100644 --- a/soh/soh/resource/type/Scene.h +++ b/soh/soh/resource/type/Scene.h @@ -11,6 +11,8 @@ namespace Ship { class Scene : public Resource { public: + using Resource::Resource; + void* GetPointer(); size_t GetPointerSize(); diff --git a/soh/soh/resource/type/Skeleton.h b/soh/soh/resource/type/Skeleton.h index e34b0b071..eef2bca58 100644 --- a/soh/soh/resource/type/Skeleton.h +++ b/soh/soh/resource/type/Skeleton.h @@ -50,6 +50,8 @@ union SkeletonData { class Skeleton : public Resource { public: + using Resource::Resource; + void* GetPointer(); size_t GetPointerSize(); diff --git a/soh/soh/resource/type/SkeletonLimb.h b/soh/soh/resource/type/SkeletonLimb.h index a039d40da..536a6a7db 100644 --- a/soh/soh/resource/type/SkeletonLimb.h +++ b/soh/soh/resource/type/SkeletonLimb.h @@ -99,6 +99,8 @@ union SkeletonLimbData { class SkeletonLimb : public Resource { public: + using Resource::Resource; + void* GetPointer(); size_t GetPointerSize(); diff --git a/soh/soh/resource/type/Text.h b/soh/soh/resource/type/Text.h index 0454af756..8b5c3530d 100644 --- a/soh/soh/resource/type/Text.h +++ b/soh/soh/resource/type/Text.h @@ -18,6 +18,8 @@ public: class Text : public Resource { public: + using Resource::Resource; + void* GetPointer(); size_t GetPointerSize(); diff --git a/soh/soh/resource/type/scenecommand/EndMarker.h b/soh/soh/resource/type/scenecommand/EndMarker.h index b836f5c05..faef8d990 100644 --- a/soh/soh/resource/type/scenecommand/EndMarker.h +++ b/soh/soh/resource/type/scenecommand/EndMarker.h @@ -14,6 +14,8 @@ typedef struct { class EndMarker : public SceneCommand { public: + using SceneCommand::SceneCommand; + void* GetPointer(); size_t GetPointerSize(); diff --git a/soh/soh/resource/type/scenecommand/SceneCommand.h b/soh/soh/resource/type/scenecommand/SceneCommand.h index 6b9674b0e..4cab5fca7 100644 --- a/soh/soh/resource/type/scenecommand/SceneCommand.h +++ b/soh/soh/resource/type/scenecommand/SceneCommand.h @@ -49,6 +49,7 @@ enum class SceneCommandID : uint8_t { class SceneCommand : public Resource { public: + using Resource::Resource; SceneCommandID cmdId; }; diff --git a/soh/soh/resource/type/scenecommand/SetActorList.h b/soh/soh/resource/type/scenecommand/SetActorList.h index a878c260e..0612490f0 100644 --- a/soh/soh/resource/type/scenecommand/SetActorList.h +++ b/soh/soh/resource/type/scenecommand/SetActorList.h @@ -19,6 +19,8 @@ typedef struct { class SetActorList : public SceneCommand { public: + using SceneCommand::SceneCommand; + void* GetPointer(); size_t GetPointerSize(); diff --git a/soh/soh/resource/type/scenecommand/SetAlternateHeaders.h b/soh/soh/resource/type/scenecommand/SetAlternateHeaders.h index bddf6486d..a88067a4f 100644 --- a/soh/soh/resource/type/scenecommand/SetAlternateHeaders.h +++ b/soh/soh/resource/type/scenecommand/SetAlternateHeaders.h @@ -15,6 +15,8 @@ namespace Ship { class SetAlternateHeaders : public SceneCommand { public: + using SceneCommand::SceneCommand; + void* GetPointer(); size_t GetPointerSize(); diff --git a/soh/soh/resource/type/scenecommand/SetCameraSettings.h b/soh/soh/resource/type/scenecommand/SetCameraSettings.h index efd6edd56..77751b51d 100644 --- a/soh/soh/resource/type/scenecommand/SetCameraSettings.h +++ b/soh/soh/resource/type/scenecommand/SetCameraSettings.h @@ -15,6 +15,8 @@ typedef struct { class SetCameraSettings : public SceneCommand { public: + using SceneCommand::SceneCommand; + void* GetPointer(); size_t GetPointerSize(); diff --git a/soh/soh/resource/type/scenecommand/SetCollisionHeader.h b/soh/soh/resource/type/scenecommand/SetCollisionHeader.h index 88cbdf7d6..4013c36f0 100644 --- a/soh/soh/resource/type/scenecommand/SetCollisionHeader.h +++ b/soh/soh/resource/type/scenecommand/SetCollisionHeader.h @@ -12,6 +12,8 @@ namespace Ship { class SetCollisionHeader : public SceneCommand { public: + using SceneCommand::SceneCommand; + void* GetPointer(); size_t GetPointerSize(); diff --git a/soh/soh/resource/type/scenecommand/SetCsCamera.h b/soh/soh/resource/type/scenecommand/SetCsCamera.h index 132b76413..ffe77cb13 100644 --- a/soh/soh/resource/type/scenecommand/SetCsCamera.h +++ b/soh/soh/resource/type/scenecommand/SetCsCamera.h @@ -14,6 +14,8 @@ typedef struct { class SetCsCamera : public SceneCommand { public: + using SceneCommand::SceneCommand; + void* GetPointer(); size_t GetPointerSize(); diff --git a/soh/soh/resource/type/scenecommand/SetCutscenes.h b/soh/soh/resource/type/scenecommand/SetCutscenes.h index 0fc91180c..c0fa53dcb 100644 --- a/soh/soh/resource/type/scenecommand/SetCutscenes.h +++ b/soh/soh/resource/type/scenecommand/SetCutscenes.h @@ -12,6 +12,8 @@ namespace Ship { class SetCutscenes : public SceneCommand { public: + using SceneCommand::SceneCommand; + void* GetPointer(); size_t GetPointerSize(); diff --git a/soh/soh/resource/type/scenecommand/SetEchoSettings.h b/soh/soh/resource/type/scenecommand/SetEchoSettings.h index 36244b5ae..0256f0043 100644 --- a/soh/soh/resource/type/scenecommand/SetEchoSettings.h +++ b/soh/soh/resource/type/scenecommand/SetEchoSettings.h @@ -14,6 +14,8 @@ typedef struct { class SetEchoSettings : public SceneCommand { public: + using SceneCommand::SceneCommand; + void* GetPointer(); size_t GetPointerSize(); diff --git a/soh/soh/resource/type/scenecommand/SetEntranceList.h b/soh/soh/resource/type/scenecommand/SetEntranceList.h index 4c1c4c93a..790ff7ce3 100644 --- a/soh/soh/resource/type/scenecommand/SetEntranceList.h +++ b/soh/soh/resource/type/scenecommand/SetEntranceList.h @@ -16,6 +16,8 @@ typedef struct { class SetEntranceList : public SceneCommand { public: + using SceneCommand::SceneCommand; + void* GetPointer(); size_t GetPointerSize(); diff --git a/soh/soh/resource/type/scenecommand/SetExitList.h b/soh/soh/resource/type/scenecommand/SetExitList.h index 652e3c8c8..50b0c1848 100644 --- a/soh/soh/resource/type/scenecommand/SetExitList.h +++ b/soh/soh/resource/type/scenecommand/SetExitList.h @@ -10,6 +10,8 @@ namespace Ship { class SetExitList : public SceneCommand { public: + using SceneCommand::SceneCommand; + void* GetPointer(); size_t GetPointerSize(); diff --git a/soh/soh/resource/type/scenecommand/SetLightList.h b/soh/soh/resource/type/scenecommand/SetLightList.h index 38448cc0e..330e0de30 100644 --- a/soh/soh/resource/type/scenecommand/SetLightList.h +++ b/soh/soh/resource/type/scenecommand/SetLightList.h @@ -37,6 +37,8 @@ typedef struct { class SetLightList : public SceneCommand { public: + using SceneCommand::SceneCommand; + void* GetPointer(); size_t GetPointerSize(); diff --git a/soh/soh/resource/type/scenecommand/SetLightingSettings.h b/soh/soh/resource/type/scenecommand/SetLightingSettings.h index 58ee02298..ab96d7287 100644 --- a/soh/soh/resource/type/scenecommand/SetLightingSettings.h +++ b/soh/soh/resource/type/scenecommand/SetLightingSettings.h @@ -21,6 +21,8 @@ typedef struct { class SetLightingSettings : public SceneCommand { public: + using SceneCommand::SceneCommand; + void* GetPointer(); size_t GetPointerSize(); diff --git a/soh/soh/resource/type/scenecommand/SetMesh.h b/soh/soh/resource/type/scenecommand/SetMesh.h index 60b62de29..ad3ddf278 100644 --- a/soh/soh/resource/type/scenecommand/SetMesh.h +++ b/soh/soh/resource/type/scenecommand/SetMesh.h @@ -85,6 +85,8 @@ typedef struct { class SetMesh : public SceneCommand { public: + using SceneCommand::SceneCommand; + void* GetPointer(); size_t GetPointerSize(); @@ -94,6 +96,7 @@ class SetMesh : public SceneCommand { std::vector dlists; std::vector dlists2; + std::vector imagePaths; std::vector images; MeshHeader meshHeader; }; diff --git a/soh/soh/resource/type/scenecommand/SetObjectList.h b/soh/soh/resource/type/scenecommand/SetObjectList.h index de2a13007..c6afffdda 100644 --- a/soh/soh/resource/type/scenecommand/SetObjectList.h +++ b/soh/soh/resource/type/scenecommand/SetObjectList.h @@ -11,6 +11,8 @@ namespace Ship { class SetObjectList : public SceneCommand { public: + using SceneCommand::SceneCommand; + void* GetPointer(); size_t GetPointerSize(); diff --git a/soh/soh/resource/type/scenecommand/SetPathways.h b/soh/soh/resource/type/scenecommand/SetPathways.h index fcf7dd569..2d8c58a70 100644 --- a/soh/soh/resource/type/scenecommand/SetPathways.h +++ b/soh/soh/resource/type/scenecommand/SetPathways.h @@ -12,6 +12,8 @@ namespace Ship { class SetPathways : public SceneCommand { public: + using SceneCommand::SceneCommand; + void* GetPointer(); size_t GetPointerSize(); diff --git a/soh/soh/resource/type/scenecommand/SetRoomBehavior.h b/soh/soh/resource/type/scenecommand/SetRoomBehavior.h index f2f95b620..9e4a1e81c 100644 --- a/soh/soh/resource/type/scenecommand/SetRoomBehavior.h +++ b/soh/soh/resource/type/scenecommand/SetRoomBehavior.h @@ -15,6 +15,8 @@ typedef struct { class SetRoomBehavior : public SceneCommand { public: + using SceneCommand::SceneCommand; + void* GetPointer(); size_t GetPointerSize(); diff --git a/soh/soh/resource/type/scenecommand/SetRoomList.h b/soh/soh/resource/type/scenecommand/SetRoomList.h index 5c998abb7..4533620ec 100644 --- a/soh/soh/resource/type/scenecommand/SetRoomList.h +++ b/soh/soh/resource/type/scenecommand/SetRoomList.h @@ -19,6 +19,8 @@ namespace Ship { class SetRoomList : public SceneCommand { public: + using SceneCommand::SceneCommand; + void* GetPointer(); size_t GetPointerSize(); diff --git a/soh/soh/resource/type/scenecommand/SetSkyboxModifier.h b/soh/soh/resource/type/scenecommand/SetSkyboxModifier.h index 7aa2ecfee..ad4a008c6 100644 --- a/soh/soh/resource/type/scenecommand/SetSkyboxModifier.h +++ b/soh/soh/resource/type/scenecommand/SetSkyboxModifier.h @@ -15,6 +15,8 @@ typedef struct { class SetSkyboxModifier : public SceneCommand { public: + using SceneCommand::SceneCommand; + void* GetPointer(); size_t GetPointerSize(); diff --git a/soh/soh/resource/type/scenecommand/SetSkyboxSettings.h b/soh/soh/resource/type/scenecommand/SetSkyboxSettings.h index 82bfc6e9e..aa110b635 100644 --- a/soh/soh/resource/type/scenecommand/SetSkyboxSettings.h +++ b/soh/soh/resource/type/scenecommand/SetSkyboxSettings.h @@ -17,6 +17,8 @@ typedef struct { class SetSkyboxSettings : public SceneCommand { public: + using SceneCommand::SceneCommand; + void* GetPointer(); size_t GetPointerSize(); diff --git a/soh/soh/resource/type/scenecommand/SetSoundSettings.h b/soh/soh/resource/type/scenecommand/SetSoundSettings.h index 27824e2ab..c2fb20366 100644 --- a/soh/soh/resource/type/scenecommand/SetSoundSettings.h +++ b/soh/soh/resource/type/scenecommand/SetSoundSettings.h @@ -16,6 +16,8 @@ typedef struct { class SetSoundSettings : public SceneCommand { public: + using SceneCommand::SceneCommand; + void* GetPointer(); size_t GetPointerSize(); diff --git a/soh/soh/resource/type/scenecommand/SetSpecialObjects.h b/soh/soh/resource/type/scenecommand/SetSpecialObjects.h index 723b7256c..a8f30b83b 100644 --- a/soh/soh/resource/type/scenecommand/SetSpecialObjects.h +++ b/soh/soh/resource/type/scenecommand/SetSpecialObjects.h @@ -15,6 +15,8 @@ typedef struct { class SetSpecialObjects : public SceneCommand { public: + using SceneCommand::SceneCommand; + void* GetPointer(); size_t GetPointerSize(); diff --git a/soh/soh/resource/type/scenecommand/SetStartPositionList.h b/soh/soh/resource/type/scenecommand/SetStartPositionList.h index d649800c9..34e7278b9 100644 --- a/soh/soh/resource/type/scenecommand/SetStartPositionList.h +++ b/soh/soh/resource/type/scenecommand/SetStartPositionList.h @@ -19,6 +19,8 @@ namespace Ship { class SetStartPositionList : public SceneCommand { public: + using SceneCommand::SceneCommand; + void* GetPointer(); size_t GetPointerSize(); diff --git a/soh/soh/resource/type/scenecommand/SetTimeSettings.h b/soh/soh/resource/type/scenecommand/SetTimeSettings.h index 0e4b25673..4eccc216a 100644 --- a/soh/soh/resource/type/scenecommand/SetTimeSettings.h +++ b/soh/soh/resource/type/scenecommand/SetTimeSettings.h @@ -16,6 +16,8 @@ typedef struct { class SetTimeSettings : public SceneCommand { public: + using SceneCommand::SceneCommand; + void* GetPointer(); size_t GetPointerSize(); diff --git a/soh/soh/resource/type/scenecommand/SetTransitionActorList.h b/soh/soh/resource/type/scenecommand/SetTransitionActorList.h index 0c08e0dcb..443499aa3 100644 --- a/soh/soh/resource/type/scenecommand/SetTransitionActorList.h +++ b/soh/soh/resource/type/scenecommand/SetTransitionActorList.h @@ -23,6 +23,8 @@ typedef struct { class SetTransitionActorList : public SceneCommand { public: + using SceneCommand::SceneCommand; + void* GetPointer(); size_t GetPointerSize(); diff --git a/soh/soh/resource/type/scenecommand/SetWindSettings.h b/soh/soh/resource/type/scenecommand/SetWindSettings.h index 2a8825fc7..a368fdf44 100644 --- a/soh/soh/resource/type/scenecommand/SetWindSettings.h +++ b/soh/soh/resource/type/scenecommand/SetWindSettings.h @@ -17,6 +17,8 @@ typedef struct { class SetWindSettings : public SceneCommand { public: + using SceneCommand::SceneCommand; + void* GetPointer(); size_t GetPointerSize();