diff --git a/CMakeLists.txt b/CMakeLists.txt index 19703c989..2771ee8c9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -199,6 +199,11 @@ find_package(Python3 COMPONENTS Interpreter) add_custom_target( ExtractAssets COMMAND ${CMAKE_COMMAND} -E rm -f oot.otr oot-mq.otr soh.otr + + # copy LUS default shaders into assets/custom + COMMAND ${CMAKE_COMMAND} -E rm -r -f ${CMAKE_CURRENT_SOURCE_DIR}/soh/assets/custom/shaders/ + COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/libultraship/src/graphic/Fast3D/shaders/ ${CMAKE_CURRENT_SOURCE_DIR}/soh/assets/custom/shaders/ + COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/OTRExporter/extract_assets.py -z "$" --non-interactive --xml-root ../soh/assets/xml --custom-otr-file soh.otr "--custom-assets-path" ${CMAKE_CURRENT_SOURCE_DIR}/soh/assets/custom --port-ver "${CMAKE_PROJECT_VERSION}" COMMAND ${CMAKE_COMMAND} -DSYSTEM_NAME=${CMAKE_SYSTEM_NAME} -DTARGET_DIR="$" -DSOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR} -DBINARY_DIR=${CMAKE_BINARY_DIR} -P ${CMAKE_CURRENT_SOURCE_DIR}/copy-existing-otrs.cmake WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/OTRExporter @@ -220,6 +225,11 @@ add_custom_target( add_custom_target( GenerateSohOtr COMMAND ${CMAKE_COMMAND} -E rm -f soh.otr + + # copy LUS default shaders into assets/custom + COMMAND ${CMAKE_COMMAND} -E rm -r -f ${CMAKE_CURRENT_SOURCE_DIR}/soh/assets/custom/shaders/ + COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/libultraship/src/graphic/Fast3D/shaders/ ${CMAKE_CURRENT_SOURCE_DIR}/soh/assets/custom/shaders/ + COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/OTRExporter/extract_assets.py -z "$" --norom --custom-otr-file soh.otr "--custom-assets-path" ${CMAKE_CURRENT_SOURCE_DIR}/soh/assets/custom --port-ver "${CMAKE_PROJECT_VERSION}" COMMAND ${CMAKE_COMMAND} -DSYSTEM_NAME=${CMAKE_SYSTEM_NAME} -DTARGET_DIR="$" -DSOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR} -DBINARY_DIR=${CMAKE_BINARY_DIR} -DONLYSOHOTR=On -P ${CMAKE_CURRENT_SOURCE_DIR}/copy-existing-otrs.cmake WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/OTRExporter diff --git a/libultraship b/libultraship index 02bb77ef2..455b6dade 160000 --- a/libultraship +++ b/libultraship @@ -1 +1 @@ -Subproject commit 02bb77ef253e2de0969fd2cb36ad2e870677d18d +Subproject commit 455b6dadef901d586332d6015fd2fd01ff07b54c diff --git a/soh/assets/.gitignore b/soh/assets/.gitignore index d75078bf1..7a844a727 100644 --- a/soh/assets/.gitignore +++ b/soh/assets/.gitignore @@ -5,3 +5,4 @@ *.vtx.inc *.dlist.inc !*.png +custom/shaders diff --git a/soh/include/macros.h b/soh/include/macros.h index 302e3755d..325fb91b6 100644 --- a/soh/include/macros.h +++ b/soh/include/macros.h @@ -8,6 +8,10 @@ // #define __attribute__(x) // #endif +// this was removed from the LUS rcp.h in https://github.com/Kenix3/libultraship/pull/833/ +// it is still used in graph.c and fault.c +#define HW_REG(reg, type) *(volatile type*)((reg) | 0xA0000000) + // SoH [Port] Always use the AVOID_UB version (we don't set AVOID_UB while building yet) /* #ifndef AVOID_UB diff --git a/soh/soh/OTRGlobals.cpp b/soh/soh/OTRGlobals.cpp index 3809a2ac6..5cdf06d9e 100644 --- a/soh/soh/OTRGlobals.cpp +++ b/soh/soh/OTRGlobals.cpp @@ -909,7 +909,7 @@ OTRVersion ReadPortVersionFromOTR(std::string otrPath) { // Use a temporary archive instance to load the otr and read the version file auto archive = std::make_shared(otrPath); if (archive->Open()) { - auto t = archive->LoadFile("portVersion", std::make_shared()); + auto t = archive->LoadFile("portVersion"); if (t != nullptr && t->IsLoaded) { auto stream = std::make_shared(t->Buffer->data(), t->Buffer->size()); auto reader = std::make_shared(stream); diff --git a/soh/soh/resource/importer/AnimationFactory.cpp b/soh/soh/resource/importer/AnimationFactory.cpp index 13aa71c86..45b582035 100644 --- a/soh/soh/resource/importer/AnimationFactory.cpp +++ b/soh/soh/resource/importer/AnimationFactory.cpp @@ -3,12 +3,12 @@ #include "spdlog/spdlog.h" namespace SOH { -std::shared_ptr ResourceFactoryBinaryAnimationV0::ReadResource(std::shared_ptr file) { - if (!FileHasValidFormatAndReader(file)) { +std::shared_ptr ResourceFactoryBinaryAnimationV0::ReadResource(std::shared_ptr file, std::shared_ptr initData) { + if (!FileHasValidFormatAndReader(file, initData)) { return nullptr; } - auto animation = std::make_shared(file->InitData); + auto animation = std::make_shared(initData); auto reader = std::get>(file->Reader); AnimationType animType = (AnimationType)reader->ReadUInt32(); diff --git a/soh/soh/resource/importer/AnimationFactory.h b/soh/soh/resource/importer/AnimationFactory.h index ae27832b6..b77374602 100644 --- a/soh/soh/resource/importer/AnimationFactory.h +++ b/soh/soh/resource/importer/AnimationFactory.h @@ -6,6 +6,6 @@ namespace SOH { class ResourceFactoryBinaryAnimationV0 : public Ship::ResourceFactoryBinary { public: - std::shared_ptr ReadResource(std::shared_ptr file) override; + std::shared_ptr ReadResource(std::shared_ptr file, std::shared_ptr initData) override; }; } // namespace SOH diff --git a/soh/soh/resource/importer/ArrayFactory.cpp b/soh/soh/resource/importer/ArrayFactory.cpp index 39be7c093..50e208a48 100644 --- a/soh/soh/resource/importer/ArrayFactory.cpp +++ b/soh/soh/resource/importer/ArrayFactory.cpp @@ -4,12 +4,12 @@ #include "graphic/Fast3D/lus_gbi.h" namespace SOH { -std::shared_ptr ResourceFactoryBinaryArrayV0::ReadResource(std::shared_ptr file) { - if (!FileHasValidFormatAndReader(file)) { +std::shared_ptr ResourceFactoryBinaryArrayV0::ReadResource(std::shared_ptr file, std::shared_ptr initData) { + if (!FileHasValidFormatAndReader(file, initData)) { return nullptr; } - auto array = std::make_shared(file->InitData); + auto array = std::make_shared(initData); auto reader = std::get>(file->Reader); array->ArrayType = (ArrayResourceType)reader->ReadUInt32(); diff --git a/soh/soh/resource/importer/ArrayFactory.h b/soh/soh/resource/importer/ArrayFactory.h index b9f5ca75b..4497591c4 100644 --- a/soh/soh/resource/importer/ArrayFactory.h +++ b/soh/soh/resource/importer/ArrayFactory.h @@ -6,6 +6,6 @@ namespace SOH { class ResourceFactoryBinaryArrayV0 : public Ship::ResourceFactoryBinary { public: - std::shared_ptr ReadResource(std::shared_ptr file) override; + std::shared_ptr ReadResource(std::shared_ptr file, std::shared_ptr initData) override; }; } // namespace LUS diff --git a/soh/soh/resource/importer/AudioSampleFactory.cpp b/soh/soh/resource/importer/AudioSampleFactory.cpp index 0ec3f5260..8ef0b9657 100644 --- a/soh/soh/resource/importer/AudioSampleFactory.cpp +++ b/soh/soh/resource/importer/AudioSampleFactory.cpp @@ -3,12 +3,12 @@ #include "spdlog/spdlog.h" namespace SOH { -std::shared_ptr ResourceFactoryBinaryAudioSampleV2::ReadResource(std::shared_ptr file) { - if (!FileHasValidFormatAndReader(file)) { +std::shared_ptr ResourceFactoryBinaryAudioSampleV2::ReadResource(std::shared_ptr file, std::shared_ptr initData) { + if (!FileHasValidFormatAndReader(file, initData)) { return nullptr; } - auto audioSample = std::make_shared(file->InitData); + auto audioSample = std::make_shared(initData); auto reader = std::get>(file->Reader); audioSample->sample.codec = reader->ReadUByte(); diff --git a/soh/soh/resource/importer/AudioSampleFactory.h b/soh/soh/resource/importer/AudioSampleFactory.h index 372e8a310..5a1a9da3a 100644 --- a/soh/soh/resource/importer/AudioSampleFactory.h +++ b/soh/soh/resource/importer/AudioSampleFactory.h @@ -6,6 +6,6 @@ namespace SOH { class ResourceFactoryBinaryAudioSampleV2 : public Ship::ResourceFactoryBinary { public: - std::shared_ptr ReadResource(std::shared_ptr file) override; + std::shared_ptr ReadResource(std::shared_ptr file, std::shared_ptr initData) override; }; } // namespace SOH diff --git a/soh/soh/resource/importer/AudioSequenceFactory.cpp b/soh/soh/resource/importer/AudioSequenceFactory.cpp index 35da7f798..a10ae7eee 100644 --- a/soh/soh/resource/importer/AudioSequenceFactory.cpp +++ b/soh/soh/resource/importer/AudioSequenceFactory.cpp @@ -3,12 +3,12 @@ #include "spdlog/spdlog.h" namespace SOH { -std::shared_ptr ResourceFactoryBinaryAudioSequenceV2::ReadResource(std::shared_ptr file) { - if (!FileHasValidFormatAndReader(file)) { +std::shared_ptr ResourceFactoryBinaryAudioSequenceV2::ReadResource(std::shared_ptr file, std::shared_ptr initData) { + if (!FileHasValidFormatAndReader(file, initData)) { return nullptr; } - auto audioSequence = std::make_shared(file->InitData); + auto audioSequence = std::make_shared(initData); auto reader = std::get>(file->Reader); audioSequence->sequence.seqDataSize = reader->ReadInt32(); diff --git a/soh/soh/resource/importer/AudioSequenceFactory.h b/soh/soh/resource/importer/AudioSequenceFactory.h index 35fd1ebef..71b1f713d 100644 --- a/soh/soh/resource/importer/AudioSequenceFactory.h +++ b/soh/soh/resource/importer/AudioSequenceFactory.h @@ -6,6 +6,6 @@ namespace SOH { class ResourceFactoryBinaryAudioSequenceV2 : public Ship::ResourceFactoryBinary { public: - std::shared_ptr ReadResource(std::shared_ptr file) override; + std::shared_ptr ReadResource(std::shared_ptr file, std::shared_ptr initData) override; }; } // namespace SOH diff --git a/soh/soh/resource/importer/AudioSoundFontFactory.cpp b/soh/soh/resource/importer/AudioSoundFontFactory.cpp index 534a7914c..e5c637574 100644 --- a/soh/soh/resource/importer/AudioSoundFontFactory.cpp +++ b/soh/soh/resource/importer/AudioSoundFontFactory.cpp @@ -4,12 +4,12 @@ #include "libultraship/libultraship.h" namespace SOH { -std::shared_ptr ResourceFactoryBinaryAudioSoundFontV2::ReadResource(std::shared_ptr file) { - if (!FileHasValidFormatAndReader(file)) { +std::shared_ptr ResourceFactoryBinaryAudioSoundFontV2::ReadResource(std::shared_ptr file, std::shared_ptr initData) { + if (!FileHasValidFormatAndReader(file, initData)) { return nullptr; } - auto audioSoundFont = std::make_shared(file->InitData); + auto audioSoundFont = std::make_shared(initData); auto reader = std::get>(file->Reader); audioSoundFont->soundFont.fntIndex = reader->ReadInt32(); diff --git a/soh/soh/resource/importer/AudioSoundFontFactory.h b/soh/soh/resource/importer/AudioSoundFontFactory.h index a80b8fe97..5db75aa66 100644 --- a/soh/soh/resource/importer/AudioSoundFontFactory.h +++ b/soh/soh/resource/importer/AudioSoundFontFactory.h @@ -6,6 +6,6 @@ namespace SOH { class ResourceFactoryBinaryAudioSoundFontV2 : public Ship::ResourceFactoryBinary { public: - std::shared_ptr ReadResource(std::shared_ptr file) override; + std::shared_ptr ReadResource(std::shared_ptr file, std::shared_ptr initData) override; }; } // namespace SOH diff --git a/soh/soh/resource/importer/BackgroundFactory.cpp b/soh/soh/resource/importer/BackgroundFactory.cpp index 6be484698..e8902827f 100644 --- a/soh/soh/resource/importer/BackgroundFactory.cpp +++ b/soh/soh/resource/importer/BackgroundFactory.cpp @@ -3,12 +3,12 @@ #include "spdlog/spdlog.h" namespace SOH { -std::shared_ptr ResourceFactoryBinaryBackgroundV0::ReadResource(std::shared_ptr file) { - if (!FileHasValidFormatAndReader(file)) { +std::shared_ptr ResourceFactoryBinaryBackgroundV0::ReadResource(std::shared_ptr file, std::shared_ptr initData) { + if (!FileHasValidFormatAndReader(file, initData)) { return nullptr; } - auto background = std::make_shared(file->InitData); + auto background = std::make_shared(initData); auto reader = std::get>(file->Reader); uint32_t dataSize = reader->ReadUInt32(); diff --git a/soh/soh/resource/importer/BackgroundFactory.h b/soh/soh/resource/importer/BackgroundFactory.h index e74e897e9..587f750a1 100644 --- a/soh/soh/resource/importer/BackgroundFactory.h +++ b/soh/soh/resource/importer/BackgroundFactory.h @@ -6,6 +6,6 @@ namespace SOH { class ResourceFactoryBinaryBackgroundV0 : public Ship::ResourceFactoryBinary { public: - std::shared_ptr ReadResource(std::shared_ptr file) override; + std::shared_ptr ReadResource(std::shared_ptr file, std::shared_ptr initData) override; }; } // namespace SOH diff --git a/soh/soh/resource/importer/CollisionHeaderFactory.cpp b/soh/soh/resource/importer/CollisionHeaderFactory.cpp index 4636d80c7..0c615fa87 100644 --- a/soh/soh/resource/importer/CollisionHeaderFactory.cpp +++ b/soh/soh/resource/importer/CollisionHeaderFactory.cpp @@ -3,12 +3,12 @@ #include "spdlog/spdlog.h" namespace SOH { -std::shared_ptr ResourceFactoryBinaryCollisionHeaderV0::ReadResource(std::shared_ptr file) { - if (!FileHasValidFormatAndReader(file)) { +std::shared_ptr ResourceFactoryBinaryCollisionHeaderV0::ReadResource(std::shared_ptr file, std::shared_ptr initData) { + if (!FileHasValidFormatAndReader(file, initData)) { return nullptr; } - auto collisionHeader = std::make_shared(file->InitData); + auto collisionHeader = std::make_shared(initData); auto reader = std::get>(file->Reader); collisionHeader->collisionHeaderData.minBounds.x = reader->ReadInt16(); @@ -123,12 +123,12 @@ std::shared_ptr ResourceFactoryBinaryCollisionHeaderV0::ReadRes return collisionHeader; } -std::shared_ptr ResourceFactoryXMLCollisionHeaderV0::ReadResource(std::shared_ptr file) { - if (!FileHasValidFormatAndReader(file)) { +std::shared_ptr ResourceFactoryXMLCollisionHeaderV0::ReadResource(std::shared_ptr file, std::shared_ptr initData) { + if (!FileHasValidFormatAndReader(file, initData)) { return nullptr; } - auto collisionHeader = std::make_shared(file->InitData); + auto collisionHeader = std::make_shared(initData); auto reader = std::get>(file->Reader)->FirstChildElement(); auto child = reader->FirstChildElement(); diff --git a/soh/soh/resource/importer/CollisionHeaderFactory.h b/soh/soh/resource/importer/CollisionHeaderFactory.h index dd438f9c3..66702f33d 100644 --- a/soh/soh/resource/importer/CollisionHeaderFactory.h +++ b/soh/soh/resource/importer/CollisionHeaderFactory.h @@ -7,11 +7,11 @@ namespace SOH { class ResourceFactoryBinaryCollisionHeaderV0 : public Ship::ResourceFactoryBinary { public: - std::shared_ptr ReadResource(std::shared_ptr file) override; + std::shared_ptr ReadResource(std::shared_ptr file, std::shared_ptr initData) override; }; class ResourceFactoryXMLCollisionHeaderV0 : public Ship::ResourceFactoryXML { public: - std::shared_ptr ReadResource(std::shared_ptr file) override; + std::shared_ptr ReadResource(std::shared_ptr file, std::shared_ptr initData) override; }; } // namespace SOH diff --git a/soh/soh/resource/importer/CutsceneFactory.cpp b/soh/soh/resource/importer/CutsceneFactory.cpp index 49e44680c..63a5695e9 100644 --- a/soh/soh/resource/importer/CutsceneFactory.cpp +++ b/soh/soh/resource/importer/CutsceneFactory.cpp @@ -58,12 +58,12 @@ static inline uint32_t read_CMD_HH(std::shared_ptr reader) { } namespace SOH { -std::shared_ptr ResourceFactoryBinaryCutsceneV0::ReadResource(std::shared_ptr file) { - if (!FileHasValidFormatAndReader(file)) { +std::shared_ptr ResourceFactoryBinaryCutsceneV0::ReadResource(std::shared_ptr file, std::shared_ptr initData) { + if (!FileHasValidFormatAndReader(file, initData)) { return nullptr; } - auto cutscene = std::make_shared(file->InitData); + auto cutscene = std::make_shared(initData); auto reader = std::get>(file->Reader); uint32_t numEntries = reader->ReadUInt32(); diff --git a/soh/soh/resource/importer/CutsceneFactory.h b/soh/soh/resource/importer/CutsceneFactory.h index 8afe98bb8..9eb5e1415 100644 --- a/soh/soh/resource/importer/CutsceneFactory.h +++ b/soh/soh/resource/importer/CutsceneFactory.h @@ -6,6 +6,6 @@ namespace SOH { class ResourceFactoryBinaryCutsceneV0 : public Ship::ResourceFactoryBinary { public: - std::shared_ptr ReadResource(std::shared_ptr file) override; + std::shared_ptr ReadResource(std::shared_ptr file, std::shared_ptr initData) override; }; } // namespace SOH diff --git a/soh/soh/resource/importer/PathFactory.cpp b/soh/soh/resource/importer/PathFactory.cpp index f0f92be02..19c374c64 100644 --- a/soh/soh/resource/importer/PathFactory.cpp +++ b/soh/soh/resource/importer/PathFactory.cpp @@ -4,12 +4,12 @@ #include "spdlog/spdlog.h" namespace SOH { -std::shared_ptr ResourceFactoryBinaryPathV0::ReadResource(std::shared_ptr file) { - if (!FileHasValidFormatAndReader(file)) { +std::shared_ptr ResourceFactoryBinaryPathV0::ReadResource(std::shared_ptr file, std::shared_ptr initData) { + if (!FileHasValidFormatAndReader(file, initData)) { return nullptr; } - auto path = std::make_shared(file->InitData); + auto path = std::make_shared(initData); auto reader = std::get>(file->Reader); path->numPaths = reader->ReadUInt32(); @@ -43,12 +43,12 @@ std::shared_ptr ResourceFactoryBinaryPathV0::ReadResource(std:: return path; } -std::shared_ptr ResourceFactoryXMLPathV0::ReadResource(std::shared_ptr file) { - if (!FileHasValidFormatAndReader(file)) { +std::shared_ptr ResourceFactoryXMLPathV0::ReadResource(std::shared_ptr file, std::shared_ptr initData) { + if (!FileHasValidFormatAndReader(file, initData)) { return nullptr; } - auto path = std::make_shared(file->InitData); + auto path = std::make_shared(initData); auto reader = std::get>(file->Reader); auto pathElement = reader->RootElement(); diff --git a/soh/soh/resource/importer/PathFactory.h b/soh/soh/resource/importer/PathFactory.h index 9dd73b110..2cba7d219 100644 --- a/soh/soh/resource/importer/PathFactory.h +++ b/soh/soh/resource/importer/PathFactory.h @@ -7,11 +7,11 @@ namespace SOH { class ResourceFactoryBinaryPathV0 : public Ship::ResourceFactoryBinary { public: - std::shared_ptr ReadResource(std::shared_ptr file) override; + std::shared_ptr ReadResource(std::shared_ptr file, std::shared_ptr initData) override; }; class ResourceFactoryXMLPathV0 : public Ship::ResourceFactoryXML { public: - std::shared_ptr ReadResource(std::shared_ptr file) override; + std::shared_ptr ReadResource(std::shared_ptr file, std::shared_ptr initData) override; }; } // namespace SOH diff --git a/soh/soh/resource/importer/PlayerAnimationFactory.cpp b/soh/soh/resource/importer/PlayerAnimationFactory.cpp index 59610da46..76857b351 100644 --- a/soh/soh/resource/importer/PlayerAnimationFactory.cpp +++ b/soh/soh/resource/importer/PlayerAnimationFactory.cpp @@ -3,12 +3,12 @@ #include "spdlog/spdlog.h" namespace SOH { -std::shared_ptr ResourceFactoryBinaryPlayerAnimationV0::ReadResource(std::shared_ptr file) { - if (!FileHasValidFormatAndReader(file)) { +std::shared_ptr ResourceFactoryBinaryPlayerAnimationV0::ReadResource(std::shared_ptr file, std::shared_ptr initData) { + if (!FileHasValidFormatAndReader(file, initData)) { return nullptr; } - auto playerAnimation = std::make_shared(file->InitData); + auto playerAnimation = std::make_shared(initData); auto reader = std::get>(file->Reader); uint32_t numEntries = reader->ReadUInt32(); diff --git a/soh/soh/resource/importer/PlayerAnimationFactory.h b/soh/soh/resource/importer/PlayerAnimationFactory.h index 3ee8b1d3a..d7efb5035 100644 --- a/soh/soh/resource/importer/PlayerAnimationFactory.h +++ b/soh/soh/resource/importer/PlayerAnimationFactory.h @@ -6,6 +6,6 @@ namespace SOH { class ResourceFactoryBinaryPlayerAnimationV0 : public Ship::ResourceFactoryBinary { public: - std::shared_ptr ReadResource(std::shared_ptr file) override; + std::shared_ptr ReadResource(std::shared_ptr file, std::shared_ptr initData) override; }; } // namespace SOH diff --git a/soh/soh/resource/importer/SceneFactory.cpp b/soh/soh/resource/importer/SceneFactory.cpp index 1bcf92e1c..b8cecf5b5 100644 --- a/soh/soh/resource/importer/SceneFactory.cpp +++ b/soh/soh/resource/importer/SceneFactory.cpp @@ -93,12 +93,12 @@ std::shared_ptr ResourceFactoryBinarySceneV0::ParseSceneCommand(s return result; } -std::shared_ptr ResourceFactoryBinarySceneV0::ReadResource(std::shared_ptr file) { - if (!FileHasValidFormatAndReader(file)) { +std::shared_ptr ResourceFactoryBinarySceneV0::ReadResource(std::shared_ptr file, std::shared_ptr initData) { + if (!FileHasValidFormatAndReader(file, initData)) { return nullptr; } - auto scene = std::make_shared(file->InitData); + auto scene = std::make_shared(initData); auto reader = std::get>(file->Reader); ParseSceneCommands(scene, reader); @@ -216,12 +216,12 @@ std::shared_ptr ResourceFactoryXMLSceneV0::ParseSceneCommand(std: return result; } -std::shared_ptr ResourceFactoryXMLSceneV0::ReadResource(std::shared_ptr file) { - if (!FileHasValidFormatAndReader(file)) { +std::shared_ptr ResourceFactoryXMLSceneV0::ReadResource(std::shared_ptr file, std::shared_ptr initData) { + if (!FileHasValidFormatAndReader(file, initData)) { return nullptr; } - auto scene = std::make_shared(file->InitData); + auto scene = std::make_shared(initData); auto reader = std::get>(file->Reader); ParseSceneCommands(scene, reader); diff --git a/soh/soh/resource/importer/SceneFactory.h b/soh/soh/resource/importer/SceneFactory.h index 115c3f3f5..52a4c42c9 100644 --- a/soh/soh/resource/importer/SceneFactory.h +++ b/soh/soh/resource/importer/SceneFactory.h @@ -12,7 +12,7 @@ class ResourceFactoryBinarySceneV0 : public Ship::ResourceFactoryBinary { public: ResourceFactoryBinarySceneV0(); - std::shared_ptr ReadResource(std::shared_ptr file) override; + std::shared_ptr ReadResource(std::shared_ptr file, std::shared_ptr initData) override; void ParseSceneCommands(std::shared_ptr scene, std::shared_ptr reader); // Doing something very similar to what we do on the ResourceLoader. @@ -28,7 +28,7 @@ class ResourceFactoryXMLSceneV0 : public Ship::ResourceFactoryXML { public: ResourceFactoryXMLSceneV0(); - std::shared_ptr ReadResource(std::shared_ptr file) override; + std::shared_ptr ReadResource(std::shared_ptr file, std::shared_ptr initData) override; void ParseSceneCommands(std::shared_ptr scene, std::shared_ptr reader); // Doing something very similar to what we do on the ResourceLoader. diff --git a/soh/soh/resource/importer/SkeletonFactory.cpp b/soh/soh/resource/importer/SkeletonFactory.cpp index d4cb965bf..e9545b978 100644 --- a/soh/soh/resource/importer/SkeletonFactory.cpp +++ b/soh/soh/resource/importer/SkeletonFactory.cpp @@ -4,12 +4,12 @@ #include namespace SOH { -std::shared_ptr ResourceFactoryBinarySkeletonV0::ReadResource(std::shared_ptr file) { - if (!FileHasValidFormatAndReader(file)) { +std::shared_ptr ResourceFactoryBinarySkeletonV0::ReadResource(std::shared_ptr file, std::shared_ptr initData) { + if (!FileHasValidFormatAndReader(file, initData)) { return nullptr; } - auto skeleton = std::make_shared(file->InitData); + auto skeleton = std::make_shared(initData); auto reader = std::get>(file->Reader); skeleton->type = (SkeletonType)reader->ReadInt8(); @@ -62,12 +62,12 @@ std::shared_ptr ResourceFactoryBinarySkeletonV0::ReadResource(s return skeleton; } -std::shared_ptr ResourceFactoryXMLSkeletonV0::ReadResource(std::shared_ptr file) { - if (!FileHasValidFormatAndReader(file)) { +std::shared_ptr ResourceFactoryXMLSkeletonV0::ReadResource(std::shared_ptr file, std::shared_ptr initData) { + if (!FileHasValidFormatAndReader(file, initData)) { return nullptr; } - auto skel = std::make_shared(file->InitData); + auto skel = std::make_shared(initData); auto reader = std::get>(file->Reader)->FirstChildElement(); auto child = reader->FirstChildElement(); diff --git a/soh/soh/resource/importer/SkeletonFactory.h b/soh/soh/resource/importer/SkeletonFactory.h index 24f92720a..33c1ea12b 100644 --- a/soh/soh/resource/importer/SkeletonFactory.h +++ b/soh/soh/resource/importer/SkeletonFactory.h @@ -7,11 +7,11 @@ namespace SOH { class ResourceFactoryBinarySkeletonV0 : public Ship::ResourceFactoryBinary { public: - std::shared_ptr ReadResource(std::shared_ptr file) override; + std::shared_ptr ReadResource(std::shared_ptr file, std::shared_ptr initData) override; }; class ResourceFactoryXMLSkeletonV0 : public Ship::ResourceFactoryXML { public: - std::shared_ptr ReadResource(std::shared_ptr file) override; + std::shared_ptr ReadResource(std::shared_ptr file, std::shared_ptr initData) override; }; } // namespace SOH diff --git a/soh/soh/resource/importer/SkeletonLimbFactory.cpp b/soh/soh/resource/importer/SkeletonLimbFactory.cpp index 3f780e6d4..4efdd66dc 100644 --- a/soh/soh/resource/importer/SkeletonLimbFactory.cpp +++ b/soh/soh/resource/importer/SkeletonLimbFactory.cpp @@ -4,12 +4,12 @@ #include "libultraship/libultraship.h" namespace SOH { -std::shared_ptr ResourceFactoryBinarySkeletonLimbV0::ReadResource(std::shared_ptr file) { - if (!FileHasValidFormatAndReader(file)) { +std::shared_ptr ResourceFactoryBinarySkeletonLimbV0::ReadResource(std::shared_ptr file, std::shared_ptr initData) { + if (!FileHasValidFormatAndReader(file, initData)) { return nullptr; } - auto skeletonLimb = std::make_shared(file->InitData); + auto skeletonLimb = std::make_shared(initData); auto reader = std::get>(file->Reader); skeletonLimb->limbType = (LimbType)reader->ReadInt8(); @@ -184,12 +184,12 @@ std::shared_ptr ResourceFactoryBinarySkeletonLimbV0::ReadResour return skeletonLimb; } -std::shared_ptr ResourceFactoryXMLSkeletonLimbV0::ReadResource(std::shared_ptr file) { - if (!FileHasValidFormatAndReader(file)) { +std::shared_ptr ResourceFactoryXMLSkeletonLimbV0::ReadResource(std::shared_ptr file, std::shared_ptr initData) { + if (!FileHasValidFormatAndReader(file, initData)) { return nullptr; } - auto skelLimb = std::make_shared(file->InitData); + auto skelLimb = std::make_shared(initData); auto reader = std::get>(file->Reader)->FirstChildElement(); std::string limbType = reader->Attribute("Type"); diff --git a/soh/soh/resource/importer/SkeletonLimbFactory.h b/soh/soh/resource/importer/SkeletonLimbFactory.h index 222cefa2c..cb5b9da22 100644 --- a/soh/soh/resource/importer/SkeletonLimbFactory.h +++ b/soh/soh/resource/importer/SkeletonLimbFactory.h @@ -7,11 +7,11 @@ namespace SOH { class ResourceFactoryBinarySkeletonLimbV0 : public Ship::ResourceFactoryBinary { public: - std::shared_ptr ReadResource(std::shared_ptr file) override; + std::shared_ptr ReadResource(std::shared_ptr file, std::shared_ptr initData) override; }; class ResourceFactoryXMLSkeletonLimbV0 : public Ship::ResourceFactoryXML { public: - std::shared_ptr ReadResource(std::shared_ptr file) override; + std::shared_ptr ReadResource(std::shared_ptr file, std::shared_ptr initData) override; }; } // namespace SOH diff --git a/soh/soh/resource/importer/TextFactory.cpp b/soh/soh/resource/importer/TextFactory.cpp index 1da1d50db..9796285c6 100644 --- a/soh/soh/resource/importer/TextFactory.cpp +++ b/soh/soh/resource/importer/TextFactory.cpp @@ -3,12 +3,12 @@ #include "spdlog/spdlog.h" namespace SOH { -std::shared_ptr ResourceFactoryBinaryTextV0::ReadResource(std::shared_ptr file) { - if (!FileHasValidFormatAndReader(file)) { +std::shared_ptr ResourceFactoryBinaryTextV0::ReadResource(std::shared_ptr file, std::shared_ptr initData) { + if (!FileHasValidFormatAndReader(file, initData)) { return nullptr; } - auto text = std::make_shared(file->InitData); + auto text = std::make_shared(initData); auto reader = std::get>(file->Reader); uint32_t msgCount = reader->ReadUInt32(); @@ -27,12 +27,12 @@ std::shared_ptr ResourceFactoryBinaryTextV0::ReadResource(std:: return text; } -std::shared_ptr ResourceFactoryXMLTextV0::ReadResource(std::shared_ptr file) { - if (!FileHasValidFormatAndReader(file)) { +std::shared_ptr ResourceFactoryXMLTextV0::ReadResource(std::shared_ptr file, std::shared_ptr initData) { + if (!FileHasValidFormatAndReader(file, initData)) { return nullptr; } - auto txt = std::make_shared(file->InitData); + auto txt = std::make_shared(initData); auto child = std::get>(file->Reader)->FirstChildElement()->FirstChildElement(); while (child != nullptr) { diff --git a/soh/soh/resource/importer/TextFactory.h b/soh/soh/resource/importer/TextFactory.h index 55a569366..2f55743b9 100644 --- a/soh/soh/resource/importer/TextFactory.h +++ b/soh/soh/resource/importer/TextFactory.h @@ -7,11 +7,11 @@ namespace SOH { class ResourceFactoryBinaryTextV0 : public Ship::ResourceFactoryBinary { public: - std::shared_ptr ReadResource(std::shared_ptr file) override; + std::shared_ptr ReadResource(std::shared_ptr file, std::shared_ptr initData) override; }; class ResourceFactoryXMLTextV0 : public Ship::ResourceFactoryXML { public: - std::shared_ptr ReadResource(std::shared_ptr file) override; + std::shared_ptr ReadResource(std::shared_ptr file, std::shared_ptr initData) override; }; } // namespace SOH