* bump lus

* start fixing build errors

* update resources to support lus changes

Co-authored-by: Kenix <kenixwhisperwind@gmail.com>

---------

Co-authored-by: briaguya <briaguya>
Co-authored-by: Kenix <kenixwhisperwind@gmail.com>
This commit is contained in:
briaguya 2023-04-02 14:18:45 -04:00 committed by GitHub
commit 94ad837c02
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
117 changed files with 1004 additions and 885 deletions

@ -1 +1 @@
Subproject commit 274ec5e195f40c526f489242c3c2bf66f10eb9af Subproject commit 9ebed2afa8125c31264d510e4ce5cc35beaca8ef

View file

@ -323,10 +323,6 @@ uint32_t OTRGlobals::GetInterpolationFPS() {
return std::min<uint32_t>(Ship::Window::GetInstance()->GetCurrentRefreshRate(), CVarGetInteger("gInterpolationFPS", 20)); return std::min<uint32_t>(Ship::Window::GetInstance()->GetCurrentRefreshRate(), CVarGetInteger("gInterpolationFPS", 20));
} }
std::shared_ptr<std::vector<std::string>> OTRGlobals::ListFiles(std::string path) {
return context->GetResourceManager()->ListFiles(path);
}
struct ExtensionEntry { struct ExtensionEntry {
std::string path; std::string path;
std::string ext; std::string ext;
@ -686,7 +682,7 @@ extern "C" uint32_t GetGIID(uint32_t itemID) {
} }
extern "C" void OTRExtScanner() { 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) { for (auto& rPath : lst) {
std::vector<std::string> raw = StringHelper::Split(rPath, "."); std::vector<std::string> 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... // OTRTODO: There is probably a more elegant way to go about this...
extern "C" char** ResourceMgr_ListFiles(const char* searchMask, int* resultSize) { 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*)); char** result = (char**)malloc(lst->size() * sizeof(char*));
for (size_t i = 0; i < lst->size(); i++) { 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) { extern "C" char* ResourceMgr_LoadTexOrDListByName(const char* filePath) {
auto res = GetResourceByNameHandlingMQ(filePath); auto res = GetResourceByNameHandlingMQ(filePath);
if (res->Type == Ship::ResourceType::DisplayList) if (res->InitData->Type == Ship::ResourceType::DisplayList)
return (char*)&((std::static_pointer_cast<Ship::DisplayList>(res))->Instructions[0]); return (char*)&((std::static_pointer_cast<Ship::DisplayList>(res))->Instructions[0]);
else if (res->Type == Ship::ResourceType::Array) else if (res->InitData->Type == Ship::ResourceType::Array)
return (char*)(std::static_pointer_cast<Ship::Array>(res))->Vertices.data(); return (char*)(std::static_pointer_cast<Ship::Array>(res))->Vertices.data();
else { else {
return (char*)GetResourceDataByNameHandlingMQ(filePath); return (char*)GetResourceDataByNameHandlingMQ(filePath);

View file

@ -3,18 +3,20 @@
#include "spdlog/spdlog.h" #include "spdlog/spdlog.h"
namespace Ship { namespace Ship {
std::shared_ptr<Resource> AnimationFactory::ReadResource(uint32_t version, std::shared_ptr<BinaryReader> reader) { std::shared_ptr<Resource> AnimationFactory::ReadResource(std::shared_ptr<ResourceMgr> resourceMgr,
auto resource = std::make_shared<Animation>(); std::shared_ptr<ResourceInitData> initData,
std::shared_ptr<BinaryReader> reader) {
auto resource = std::make_shared<Animation>(resourceMgr, initData);
std::shared_ptr<ResourceVersionFactory> factory = nullptr; std::shared_ptr<ResourceVersionFactory> factory = nullptr;
switch (version) { switch (resource->InitData->ResourceVersion) {
case 0: case 0:
factory = std::make_shared<AnimationFactoryV0>(); factory = std::make_shared<AnimationFactoryV0>();
break; break;
} }
if (factory == nullptr) { 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; return nullptr;
} }

View file

@ -6,7 +6,9 @@
namespace Ship { namespace Ship {
class AnimationFactory : public ResourceFactory { class AnimationFactory : public ResourceFactory {
public: public:
std::shared_ptr<Resource> ReadResource(uint32_t version, std::shared_ptr<BinaryReader> reader); std::shared_ptr<Resource> ReadResource(std::shared_ptr<ResourceMgr> resourceMgr,
std::shared_ptr<ResourceInitData> initData,
std::shared_ptr<BinaryReader> reader) override;
}; };
class AnimationFactoryV0 : public ResourceVersionFactory { class AnimationFactoryV0 : public ResourceVersionFactory {

View file

@ -3,21 +3,20 @@
#include "spdlog/spdlog.h" #include "spdlog/spdlog.h"
namespace Ship { namespace Ship {
std::shared_ptr<Resource> AudioSampleFactory::ReadResource(uint32_t version, std::shared_ptr<BinaryReader> reader) std::shared_ptr<Resource> AudioSampleFactory::ReadResource(std::shared_ptr<ResourceMgr> resourceMgr,
{ std::shared_ptr<ResourceInitData> initData,
auto resource = std::make_shared<AudioSample>(); std::shared_ptr<BinaryReader> reader) {
auto resource = std::make_shared<AudioSample>(resourceMgr, initData);
std::shared_ptr<ResourceVersionFactory> factory = nullptr; std::shared_ptr<ResourceVersionFactory> factory = nullptr;
switch (version) switch (resource->InitData->ResourceVersion) {
{
case 2: case 2:
factory = std::make_shared<AudioSampleFactoryV0>(); factory = std::make_shared<AudioSampleFactoryV0>();
break; break;
} }
if (factory == nullptr) if (factory == nullptr) {
{ SPDLOG_ERROR("Failed to load AudioSample with version {}", resource->InitData->ResourceVersion);
SPDLOG_ERROR("Failed to load AudioSample with version {}", version);
return nullptr; return nullptr;
} }

View file

@ -7,7 +7,9 @@ namespace Ship {
class AudioSampleFactory : public ResourceFactory class AudioSampleFactory : public ResourceFactory
{ {
public: public:
std::shared_ptr<Resource> ReadResource(uint32_t version, std::shared_ptr<BinaryReader> reader); std::shared_ptr<Resource> ReadResource(std::shared_ptr<ResourceMgr> resourceMgr,
std::shared_ptr<ResourceInitData> initData,
std::shared_ptr<BinaryReader> reader) override;
}; };
class AudioSampleFactoryV0 : public ResourceVersionFactory class AudioSampleFactoryV0 : public ResourceVersionFactory

View file

@ -3,13 +3,13 @@
#include "spdlog/spdlog.h" #include "spdlog/spdlog.h"
namespace Ship { namespace Ship {
std::shared_ptr<Resource> AudioSequenceFactory::ReadResource(uint32_t version, std::shared_ptr<BinaryReader> reader) std::shared_ptr<Resource> AudioSequenceFactory::ReadResource(std::shared_ptr<ResourceMgr> resourceMgr,
{ std::shared_ptr<ResourceInitData> initData,
auto resource = std::make_shared<AudioSequence>(); std::shared_ptr<BinaryReader> reader) {
auto resource = std::make_shared<AudioSequence>(resourceMgr, initData);
std::shared_ptr<ResourceVersionFactory> factory = nullptr; std::shared_ptr<ResourceVersionFactory> factory = nullptr;
switch (version) switch (resource->InitData->ResourceVersion) {
{
case 2: case 2:
factory = std::make_shared<AudioSequenceFactoryV0>(); factory = std::make_shared<AudioSequenceFactoryV0>();
break; break;
@ -17,7 +17,7 @@ std::shared_ptr<Resource> AudioSequenceFactory::ReadResource(uint32_t version, s
if (factory == nullptr) if (factory == nullptr)
{ {
SPDLOG_ERROR("Failed to load AudioSequence with version {}", version); SPDLOG_ERROR("Failed to load AudioSequence with version {}", resource->InitData->ResourceVersion);
return nullptr; return nullptr;
} }
@ -27,8 +27,7 @@ std::shared_ptr<Resource> AudioSequenceFactory::ReadResource(uint32_t version, s
} }
void Ship::AudioSequenceFactoryV0::ParseFileBinary(std::shared_ptr<BinaryReader> reader, void Ship::AudioSequenceFactoryV0::ParseFileBinary(std::shared_ptr<BinaryReader> reader,
std::shared_ptr<Resource> resource) std::shared_ptr<Resource> resource) {
{
std::shared_ptr<AudioSequence> audioSequence = std::static_pointer_cast<AudioSequence>(resource); std::shared_ptr<AudioSequence> audioSequence = std::static_pointer_cast<AudioSequence>(resource);
ResourceVersionFactory::ParseFileBinary(reader, audioSequence); ResourceVersionFactory::ParseFileBinary(reader, audioSequence);

View file

@ -7,7 +7,9 @@ namespace Ship {
class AudioSequenceFactory : public ResourceFactory class AudioSequenceFactory : public ResourceFactory
{ {
public: public:
std::shared_ptr<Resource> ReadResource(uint32_t version, std::shared_ptr<BinaryReader> reader); std::shared_ptr<Resource> ReadResource(std::shared_ptr<ResourceMgr> resourceMgr,
std::shared_ptr<ResourceInitData> initData,
std::shared_ptr<BinaryReader> reader) override;
}; };
class AudioSequenceFactoryV0 : public ResourceVersionFactory class AudioSequenceFactoryV0 : public ResourceVersionFactory

View file

@ -4,13 +4,13 @@
#include "libultraship/bridge.h" #include "libultraship/bridge.h"
namespace Ship { namespace Ship {
std::shared_ptr<Resource> AudioSoundFontFactory::ReadResource(uint32_t version, std::shared_ptr<BinaryReader> reader) std::shared_ptr<Resource> AudioSoundFontFactory::ReadResource(std::shared_ptr<ResourceMgr> resourceMgr,
{ std::shared_ptr<ResourceInitData> initData,
auto resource = std::make_shared<AudioSoundFont>(); std::shared_ptr<BinaryReader> reader) {
auto resource = std::make_shared<AudioSoundFont>(resourceMgr, initData);
std::shared_ptr<ResourceVersionFactory> factory = nullptr; std::shared_ptr<ResourceVersionFactory> factory = nullptr;
switch (version) switch (resource->InitData->ResourceVersion) {
{
case 2: case 2:
factory = std::make_shared<AudioSoundFontFactoryV0>(); factory = std::make_shared<AudioSoundFontFactoryV0>();
break; break;
@ -18,7 +18,7 @@ std::shared_ptr<Resource> AudioSoundFontFactory::ReadResource(uint32_t version,
if (factory == nullptr) if (factory == nullptr)
{ {
SPDLOG_ERROR("Failed to load AudioSoundFont with version {}", version); SPDLOG_ERROR("Failed to load AudioSoundFont with version {}", resource->InitData->ResourceVersion);
return nullptr; return nullptr;
} }
@ -28,8 +28,7 @@ std::shared_ptr<Resource> AudioSoundFontFactory::ReadResource(uint32_t version,
} }
void Ship::AudioSoundFontFactoryV0::ParseFileBinary(std::shared_ptr<BinaryReader> reader, void Ship::AudioSoundFontFactoryV0::ParseFileBinary(std::shared_ptr<BinaryReader> reader,
std::shared_ptr<Resource> resource) std::shared_ptr<Resource> resource) {
{
std::shared_ptr<AudioSoundFont> audioSoundFont = std::static_pointer_cast<AudioSoundFont>(resource); std::shared_ptr<AudioSoundFont> audioSoundFont = std::static_pointer_cast<AudioSoundFont>(resource);
ResourceVersionFactory::ParseFileBinary(reader, audioSoundFont); ResourceVersionFactory::ParseFileBinary(reader, audioSoundFont);

View file

@ -7,7 +7,9 @@ namespace Ship {
class AudioSoundFontFactory : public ResourceFactory class AudioSoundFontFactory : public ResourceFactory
{ {
public: public:
std::shared_ptr<Resource> ReadResource(uint32_t version, std::shared_ptr<BinaryReader> reader); std::shared_ptr<Resource> ReadResource(std::shared_ptr<ResourceMgr> resourceMgr,
std::shared_ptr<ResourceInitData> initData,
std::shared_ptr<BinaryReader> reader) override;
}; };
class AudioSoundFontFactoryV0 : public ResourceVersionFactory class AudioSoundFontFactoryV0 : public ResourceVersionFactory

View file

@ -3,18 +3,20 @@
#include "spdlog/spdlog.h" #include "spdlog/spdlog.h"
namespace Ship { namespace Ship {
std::shared_ptr<Resource> BackgroundFactory::ReadResource(uint32_t version, std::shared_ptr<BinaryReader> reader) { std::shared_ptr<Resource> BackgroundFactory::ReadResource(std::shared_ptr<ResourceMgr> resourceMgr,
auto resource = std::make_shared<Background>(); std::shared_ptr<ResourceInitData> initData,
std::shared_ptr<BinaryReader> reader) {
auto resource = std::make_shared<Background>(resourceMgr, initData);
std::shared_ptr<ResourceVersionFactory> factory = nullptr; std::shared_ptr<ResourceVersionFactory> factory = nullptr;
switch (version) { switch (resource->InitData->ResourceVersion) {
case 0: case 0:
factory = std::make_shared<BackgroundFactoryV0>(); factory = std::make_shared<BackgroundFactoryV0>();
break; break;
} }
if (factory == nullptr) { 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; return nullptr;
} }

View file

@ -6,7 +6,9 @@
namespace Ship { namespace Ship {
class BackgroundFactory : public ResourceFactory { class BackgroundFactory : public ResourceFactory {
public: public:
std::shared_ptr<Resource> ReadResource(uint32_t version, std::shared_ptr<BinaryReader> reader); std::shared_ptr<Resource> ReadResource(std::shared_ptr<ResourceMgr> resourceMgr,
std::shared_ptr<ResourceInitData> initData,
std::shared_ptr<BinaryReader> reader) override;
}; };
class BackgroundFactoryV0 : public ResourceVersionFactory { class BackgroundFactoryV0 : public ResourceVersionFactory {

View file

@ -3,21 +3,20 @@
#include "spdlog/spdlog.h" #include "spdlog/spdlog.h"
namespace Ship { namespace Ship {
std::shared_ptr<Resource> CollisionHeaderFactory::ReadResource(uint32_t version, std::shared_ptr<BinaryReader> reader) std::shared_ptr<Resource> CollisionHeaderFactory::ReadResource(std::shared_ptr<ResourceMgr> resourceMgr,
{ std::shared_ptr<ResourceInitData> initData,
auto resource = std::make_shared<CollisionHeader>(); std::shared_ptr<BinaryReader> reader) {
auto resource = std::make_shared<CollisionHeader>(resourceMgr, initData);
std::shared_ptr<ResourceVersionFactory> factory = nullptr; std::shared_ptr<ResourceVersionFactory> factory = nullptr;
switch (version) switch (resource->InitData->ResourceVersion) {
{
case 0: case 0:
factory = std::make_shared<CollisionHeaderFactoryV0>(); factory = std::make_shared<CollisionHeaderFactoryV0>();
break; break;
} }
if (factory == nullptr) if (factory == nullptr) {
{ SPDLOG_ERROR("Failed to load Collision Header with version {}", resource->InitData->ResourceVersion);
SPDLOG_ERROR("Failed to load Collision Header with version {}", version);
return nullptr; return nullptr;
} }

View file

@ -6,7 +6,9 @@
namespace Ship { namespace Ship {
class CollisionHeaderFactory : public ResourceFactory { class CollisionHeaderFactory : public ResourceFactory {
public: public:
std::shared_ptr<Resource> ReadResource(uint32_t version, std::shared_ptr<BinaryReader> reader); std::shared_ptr<Resource> ReadResource(std::shared_ptr<ResourceMgr> resourceMgr,
std::shared_ptr<ResourceInitData> initData,
std::shared_ptr<BinaryReader> reader) override;
}; };
class CollisionHeaderFactoryV0 : public ResourceVersionFactory { class CollisionHeaderFactoryV0 : public ResourceVersionFactory {

View file

@ -3,21 +3,20 @@
#include "spdlog/spdlog.h" #include "spdlog/spdlog.h"
namespace Ship { namespace Ship {
std::shared_ptr<Resource> CutsceneFactory::ReadResource(uint32_t version, std::shared_ptr<BinaryReader> reader) std::shared_ptr<Resource> CutsceneFactory::ReadResource(std::shared_ptr<ResourceMgr> resourceMgr,
{ std::shared_ptr<ResourceInitData> initData,
auto resource = std::make_shared<Cutscene>(); std::shared_ptr<BinaryReader> reader) {
auto resource = std::make_shared<Cutscene>(resourceMgr, initData);
std::shared_ptr<ResourceVersionFactory> factory = nullptr; std::shared_ptr<ResourceVersionFactory> factory = nullptr;
switch (version) switch (resource->InitData->ResourceVersion) {
{
case 0: case 0:
factory = std::make_shared<CutsceneFactoryV0>(); factory = std::make_shared<CutsceneFactoryV0>();
break; break;
} }
if (factory == nullptr) if (factory == nullptr) {
{ SPDLOG_ERROR("Failed to load Cutscene with version {}", resource->InitData->ResourceVersion);
SPDLOG_ERROR("Failed to load Cutscene with version {}", version);
return nullptr; return nullptr;
} }

View file

@ -7,7 +7,9 @@ namespace Ship {
class CutsceneFactory : public ResourceFactory class CutsceneFactory : public ResourceFactory
{ {
public: public:
std::shared_ptr<Resource> ReadResource(uint32_t version, std::shared_ptr<BinaryReader> reader); std::shared_ptr<Resource> ReadResource(std::shared_ptr<ResourceMgr> resourceMgr,
std::shared_ptr<ResourceInitData> initData,
std::shared_ptr<BinaryReader> reader) override;
}; };
class CutsceneFactoryV0 : public ResourceVersionFactory class CutsceneFactoryV0 : public ResourceVersionFactory

View file

@ -3,21 +3,20 @@
#include "spdlog/spdlog.h" #include "spdlog/spdlog.h"
namespace Ship { namespace Ship {
std::shared_ptr<Resource> PathFactory::ReadResource(uint32_t version, std::shared_ptr<BinaryReader> reader) std::shared_ptr<Resource> PathFactory::ReadResource(std::shared_ptr<ResourceMgr> resourceMgr,
{ std::shared_ptr<ResourceInitData> initData,
auto resource = std::make_shared<Path>(); std::shared_ptr<BinaryReader> reader) {
auto resource = std::make_shared<Path>(resourceMgr, initData);
std::shared_ptr<ResourceVersionFactory> factory = nullptr; std::shared_ptr<ResourceVersionFactory> factory = nullptr;
switch (version) switch (resource->InitData->ResourceVersion) {
{
case 0: case 0:
factory = std::make_shared<PathFactoryV0>(); factory = std::make_shared<PathFactoryV0>();
break; break;
} }
if (factory == nullptr) if (factory == nullptr) {
{ SPDLOG_ERROR("Failed to load Path with version {}", resource->InitData->ResourceVersion);
SPDLOG_ERROR("Failed to load Path with version {}", version);
return nullptr; return nullptr;
} }
@ -27,8 +26,7 @@ std::shared_ptr<Resource> PathFactory::ReadResource(uint32_t version, std::share
} }
void Ship::PathFactoryV0::ParseFileBinary(std::shared_ptr<BinaryReader> reader, void Ship::PathFactoryV0::ParseFileBinary(std::shared_ptr<BinaryReader> reader,
std::shared_ptr<Resource> resource) std::shared_ptr<Resource> resource) {
{
std::shared_ptr<Path> path = std::static_pointer_cast<Path>(resource); std::shared_ptr<Path> path = std::static_pointer_cast<Path>(resource);
ResourceVersionFactory::ParseFileBinary(reader, path); ResourceVersionFactory::ParseFileBinary(reader, path);

View file

@ -7,7 +7,9 @@ namespace Ship {
class PathFactory : public ResourceFactory class PathFactory : public ResourceFactory
{ {
public: public:
std::shared_ptr<Resource> ReadResource(uint32_t version, std::shared_ptr<BinaryReader> reader); std::shared_ptr<Resource> ReadResource(std::shared_ptr<ResourceMgr> resourceMgr,
std::shared_ptr<ResourceInitData> initData,
std::shared_ptr<BinaryReader> reader) override;
}; };
class PathFactoryV0 : public ResourceVersionFactory class PathFactoryV0 : public ResourceVersionFactory

View file

@ -3,13 +3,13 @@
#include "spdlog/spdlog.h" #include "spdlog/spdlog.h"
namespace Ship { namespace Ship {
std::shared_ptr<Resource> PlayerAnimationFactory::ReadResource(uint32_t version, std::shared_ptr<BinaryReader> reader) std::shared_ptr<Resource> PlayerAnimationFactory::ReadResource(std::shared_ptr<ResourceMgr> resourceMgr,
{ std::shared_ptr<ResourceInitData> initData,
auto resource = std::make_shared<PlayerAnimation>(); std::shared_ptr<BinaryReader> reader) {
auto resource = std::make_shared<PlayerAnimation>(resourceMgr, initData);
std::shared_ptr<ResourceVersionFactory> factory = nullptr; std::shared_ptr<ResourceVersionFactory> factory = nullptr;
switch (version) switch (resource->InitData->ResourceVersion) {
{
case 0: case 0:
factory = std::make_shared<PlayerAnimationFactoryV0>(); factory = std::make_shared<PlayerAnimationFactoryV0>();
break; break;
@ -17,7 +17,7 @@ std::shared_ptr<Resource> PlayerAnimationFactory::ReadResource(uint32_t version,
if (factory == nullptr) if (factory == nullptr)
{ {
SPDLOG_ERROR("Failed to load PlayerAnimation with version {}", version); SPDLOG_ERROR("Failed to load PlayerAnimation with version {}", resource->InitData->ResourceVersion);
return nullptr; return nullptr;
} }

View file

@ -6,7 +6,9 @@
namespace Ship { namespace Ship {
class PlayerAnimationFactory : public ResourceFactory { class PlayerAnimationFactory : public ResourceFactory {
public: public:
std::shared_ptr<Resource> ReadResource(uint32_t version, std::shared_ptr<BinaryReader> reader); std::shared_ptr<Resource> ReadResource(std::shared_ptr<ResourceMgr> resourceMgr,
std::shared_ptr<ResourceInitData> initData,
std::shared_ptr<BinaryReader> reader) override;
}; };
class PlayerAnimationFactoryV0 : public ResourceVersionFactory { class PlayerAnimationFactoryV0 : public ResourceVersionFactory {

View file

@ -30,8 +30,9 @@
namespace Ship { namespace Ship {
std::shared_ptr<Resource> SceneFactory::ReadResource(uint32_t version, std::shared_ptr<BinaryReader> reader) std::shared_ptr<Resource> SceneFactory::ReadResource(std::shared_ptr<ResourceMgr> resourceMgr,
{ std::shared_ptr<ResourceInitData> initData,
std::shared_ptr<BinaryReader> reader) {
if (SceneFactory::sceneCommandFactories.empty()) { if (SceneFactory::sceneCommandFactories.empty()) {
SceneFactory::sceneCommandFactories[Ship::SceneCommandID::SetLightingSettings] = std::make_shared<SetLightingSettingsFactory>(); SceneFactory::sceneCommandFactories[Ship::SceneCommandID::SetLightingSettings] = std::make_shared<SetLightingSettingsFactory>();
SceneFactory::sceneCommandFactories[Ship::SceneCommandID::SetWind] = std::make_shared<SetWindSettingsFactory>(); SceneFactory::sceneCommandFactories[Ship::SceneCommandID::SetWind] = std::make_shared<SetWindSettingsFactory>();
@ -60,20 +61,17 @@ std::shared_ptr<Resource> SceneFactory::ReadResource(uint32_t version, std::shar
SceneFactory::sceneCommandFactories[Ship::SceneCommandID::SetMesh] = std::make_shared<SetMeshFactory>(); SceneFactory::sceneCommandFactories[Ship::SceneCommandID::SetMesh] = std::make_shared<SetMeshFactory>();
} }
auto resource = std::make_shared<Scene>(); auto resource = std::make_shared<Scene>(resourceMgr, initData);
std::shared_ptr<ResourceVersionFactory> factory = nullptr; std::shared_ptr<ResourceVersionFactory> factory = nullptr;
resource->ResourceVersion = version;
switch (version) switch (resource->InitData->ResourceVersion) {
{
case 0: case 0:
factory = std::make_shared<SceneFactoryV0>(); factory = std::make_shared<SceneFactoryV0>();
break; break;
} }
if (factory == nullptr) if (factory == nullptr) {
{ SPDLOG_ERROR("Failed to load Scene with version {}", resource->InitData->ResourceVersion);
SPDLOG_ERROR("Failed to load Scene with version {}", version);
return nullptr; return nullptr;
} }
@ -88,15 +86,20 @@ void SceneFactoryV0::ParseFileBinary(std::shared_ptr<BinaryReader> reader,
std::shared_ptr<Scene> scene = std::static_pointer_cast<Scene>(resource); std::shared_ptr<Scene> scene = std::static_pointer_cast<Scene>(resource);
ResourceVersionFactory::ParseFileBinary(reader, scene); ResourceVersionFactory::ParseFileBinary(reader, scene);
ParseSceneCommands(scene, reader);
}
void SceneFactoryV0::ParseSceneCommands(std::shared_ptr<Scene> scene, std::shared_ptr<BinaryReader> reader) {
uint32_t commandCount = reader->ReadUInt32(); uint32_t commandCount = reader->ReadUInt32();
scene->commands.reserve(commandCount); scene->commands.reserve(commandCount);
for (uint32_t i = 0; i < commandCount; i++) { for (uint32_t i = 0; i < commandCount; i++) {
scene->commands.push_back(ParseSceneCommand(resource->ResourceVersion, reader)); scene->commands.push_back(ParseSceneCommand(scene, reader, i));
} }
} }
std::shared_ptr<SceneCommand> SceneFactoryV0::ParseSceneCommand(uint32_t version, std::shared_ptr<BinaryReader> reader) { std::shared_ptr<SceneCommand> SceneFactoryV0::ParseSceneCommand(std::shared_ptr<Scene> scene,
std::shared_ptr<BinaryReader> reader, uint32_t index) {
SceneCommandID cmdID = (SceneCommandID)reader->ReadInt32(); SceneCommandID cmdID = (SceneCommandID)reader->ReadInt32();
reader->Seek(-sizeof(int32_t), SeekOffsetType::Current); reader->Seek(-sizeof(int32_t), SeekOffsetType::Current);
@ -105,11 +108,17 @@ std::shared_ptr<SceneCommand> SceneFactoryV0::ParseSceneCommand(uint32_t version
std::shared_ptr<SceneCommandFactory> commandFactory = SceneFactory::sceneCommandFactories[cmdID]; std::shared_ptr<SceneCommandFactory> commandFactory = SceneFactory::sceneCommandFactories[cmdID];
if (commandFactory != nullptr) { if (commandFactory != nullptr) {
result = std::static_pointer_cast<SceneCommand>(commandFactory->ReadResource(version, reader)); auto initData = std::make_shared<ResourceInitData>();
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<SceneCommand>(commandFactory->ReadResource(scene->ResourceManager, initData, reader));
// Cache the resource?
} }
if (result == nullptr) { 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; return result;

View file

@ -9,7 +9,9 @@
namespace Ship { namespace Ship {
class SceneFactory : public ResourceFactory { class SceneFactory : public ResourceFactory {
public: public:
std::shared_ptr<Resource> ReadResource(uint32_t version, std::shared_ptr<BinaryReader> reader); std::shared_ptr<Resource> ReadResource(std::shared_ptr<ResourceMgr> resourceMgr,
std::shared_ptr<ResourceInitData> initData,
std::shared_ptr<BinaryReader> reader) override;
// Doing something very similar to what we do on the ResourceLoader. // Doing something very similar to what we do on the ResourceLoader.
// Eventually, scene commands should be moved up to the ResourceLoader as well. // Eventually, scene commands should be moved up to the ResourceLoader as well.
@ -21,6 +23,8 @@ class SceneFactory : public ResourceFactory {
class SceneFactoryV0 : public ResourceVersionFactory { class SceneFactoryV0 : public ResourceVersionFactory {
public: public:
void ParseFileBinary(std::shared_ptr<BinaryReader> reader, std::shared_ptr<Resource> resource) override; void ParseFileBinary(std::shared_ptr<BinaryReader> reader, std::shared_ptr<Resource> resource) override;
std::shared_ptr<SceneCommand> ParseSceneCommand(uint32_t version, std::shared_ptr<BinaryReader> reader); void ParseSceneCommands(std::shared_ptr<Scene> scene, std::shared_ptr<BinaryReader> reader);
protected:
std::shared_ptr<SceneCommand> ParseSceneCommand(std::shared_ptr<Scene> scene, std::shared_ptr<BinaryReader> reader, uint32_t index);
}; };
}; // namespace Ship }; // namespace Ship

View file

@ -4,21 +4,20 @@
#include <libultraship/bridge.h> #include <libultraship/bridge.h>
namespace Ship { namespace Ship {
std::shared_ptr<Resource> SkeletonFactory::ReadResource(uint32_t version, std::shared_ptr<BinaryReader> reader) std::shared_ptr<Resource> SkeletonFactory::ReadResource(std::shared_ptr<ResourceMgr> resourceMgr,
{ std::shared_ptr<ResourceInitData> initData,
auto resource = std::make_shared<Skeleton>(); std::shared_ptr<BinaryReader> reader) {
auto resource = std::make_shared<Skeleton>(resourceMgr, initData);
std::shared_ptr<ResourceVersionFactory> factory = nullptr; std::shared_ptr<ResourceVersionFactory> factory = nullptr;
switch (version) switch (resource->InitData->ResourceVersion) {
{
case 0: case 0:
factory = std::make_shared<SkeletonFactoryV0>(); factory = std::make_shared<SkeletonFactoryV0>();
break; break;
} }
if (factory == nullptr) if (factory == nullptr) {
{ SPDLOG_ERROR("Failed to load Skeleton with version {}", resource->InitData->ResourceVersion);
SPDLOG_ERROR("Failed to load Skeleton with version {}", version);
return nullptr; return nullptr;
} }

View file

@ -7,7 +7,9 @@ namespace Ship {
class SkeletonFactory : public ResourceFactory class SkeletonFactory : public ResourceFactory
{ {
public: public:
std::shared_ptr<Resource> ReadResource(uint32_t version, std::shared_ptr<BinaryReader> reader); std::shared_ptr<Resource> ReadResource(std::shared_ptr<ResourceMgr> resourceMgr,
std::shared_ptr<ResourceInitData> initData,
std::shared_ptr<BinaryReader> reader) override;
}; };
class SkeletonFactoryV0 : public ResourceVersionFactory class SkeletonFactoryV0 : public ResourceVersionFactory

View file

@ -4,21 +4,20 @@
#include "libultraship/bridge.h" #include "libultraship/bridge.h"
namespace Ship { namespace Ship {
std::shared_ptr<Resource> SkeletonLimbFactory::ReadResource(uint32_t version, std::shared_ptr<BinaryReader> reader) std::shared_ptr<Resource> SkeletonLimbFactory::ReadResource(std::shared_ptr<ResourceMgr> resourceMgr,
{ std::shared_ptr<ResourceInitData> initData,
auto resource = std::make_shared<SkeletonLimb>(); std::shared_ptr<BinaryReader> reader) {
auto resource = std::make_shared<SkeletonLimb>(resourceMgr, initData);
std::shared_ptr<ResourceVersionFactory> factory = nullptr; std::shared_ptr<ResourceVersionFactory> factory = nullptr;
switch (version) switch (resource->InitData->ResourceVersion) {
{
case 0: case 0:
factory = std::make_shared<SkeletonLimbFactoryV0>(); factory = std::make_shared<SkeletonLimbFactoryV0>();
break; break;
} }
if (factory == nullptr) if (factory == nullptr) {
{ SPDLOG_ERROR("Failed to load Skeleton Limb with version {}", resource->InitData->ResourceVersion);
SPDLOG_ERROR("Failed to load Skeleton Limb with version {}", version);
return nullptr; return nullptr;
} }
@ -177,8 +176,7 @@ void Ship::SkeletonLimbFactoryV0::ParseFileBinary(std::shared_ptr<BinaryReader>
skeletonLimb->skinAnimLimbData.limbModifications = skeletonLimb->skinLimbModifArray.data(); skeletonLimb->skinAnimLimbData.limbModifications = skeletonLimb->skinLimbModifArray.data();
skeletonLimb->skinAnimLimbData.dlist = (Gfx*)GetResourceDataByName(skeletonLimb->skinDList2.c_str(), true); 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].vtxCount = skeletonLimb->skinLimbModifVertexArrays[i].size();
skeletonLimb->skinAnimLimbData.limbModifications[i].skinVertices = skeletonLimb->skinLimbModifVertexArrays[i].data(); skeletonLimb->skinAnimLimbData.limbModifications[i].skinVertices = skeletonLimb->skinLimbModifVertexArrays[i].data();

View file

@ -7,7 +7,9 @@ namespace Ship {
class SkeletonLimbFactory : public ResourceFactory class SkeletonLimbFactory : public ResourceFactory
{ {
public: public:
std::shared_ptr<Resource> ReadResource(uint32_t version, std::shared_ptr<BinaryReader> reader); std::shared_ptr<Resource> ReadResource(std::shared_ptr<ResourceMgr> resourceMgr,
std::shared_ptr<ResourceInitData> initData,
std::shared_ptr<BinaryReader> reader) override;
}; };
class SkeletonLimbFactoryV0 : public ResourceVersionFactory class SkeletonLimbFactoryV0 : public ResourceVersionFactory

View file

@ -3,13 +3,13 @@
#include "spdlog/spdlog.h" #include "spdlog/spdlog.h"
namespace Ship { namespace Ship {
std::shared_ptr<Resource> TextFactory::ReadResource(uint32_t version, std::shared_ptr<BinaryReader> reader) std::shared_ptr<Resource> TextFactory::ReadResource(std::shared_ptr<ResourceMgr> resourceMgr,
{ std::shared_ptr<ResourceInitData> initData,
auto resource = std::make_shared<Text>(); std::shared_ptr<BinaryReader> reader) {
auto resource = std::make_shared<Text>(resourceMgr, initData);
std::shared_ptr<ResourceVersionFactory> factory = nullptr; std::shared_ptr<ResourceVersionFactory> factory = nullptr;
switch (version) switch (resource->InitData->ResourceVersion) {
{
case 0: case 0:
factory = std::make_shared<TextFactoryV0>(); factory = std::make_shared<TextFactoryV0>();
break; break;
@ -18,9 +18,8 @@ std::shared_ptr<Resource> TextFactory::ReadResource(uint32_t version, std::share
break; break;
} }
if (factory == nullptr) if (factory == nullptr) {
{ SPDLOG_ERROR("Failed to load Text with version {}", resource->InitData->ResourceVersion);
SPDLOG_ERROR("Failed to load Text with version {}", version);
return nullptr; return nullptr;
} }
@ -30,16 +29,14 @@ std::shared_ptr<Resource> TextFactory::ReadResource(uint32_t version, std::share
} }
void Ship::TextFactoryV0::ParseFileBinary(std::shared_ptr<BinaryReader> reader, void Ship::TextFactoryV0::ParseFileBinary(std::shared_ptr<BinaryReader> reader,
std::shared_ptr<Resource> resource) std::shared_ptr<Resource> resource) {
{
std::shared_ptr<Text> text = std::static_pointer_cast<Text>(resource); std::shared_ptr<Text> text = std::static_pointer_cast<Text>(resource);
ResourceVersionFactory::ParseFileBinary(reader, text); ResourceVersionFactory::ParseFileBinary(reader, text);
uint32_t msgCount = reader->ReadUInt32(); uint32_t msgCount = reader->ReadUInt32();
text->messages.reserve(msgCount); text->messages.reserve(msgCount);
for (uint32_t i = 0; i < msgCount; i++) for (uint32_t i = 0; i < msgCount; i++) {
{
MessageEntry entry; MessageEntry entry;
entry.id = reader->ReadUInt16(); entry.id = reader->ReadUInt16();
entry.textboxType = reader->ReadUByte(); entry.textboxType = reader->ReadUByte();

View file

@ -7,7 +7,9 @@ namespace Ship {
class TextFactory : public ResourceFactory class TextFactory : public ResourceFactory
{ {
public: public:
std::shared_ptr<Resource> ReadResource(uint32_t version, std::shared_ptr<BinaryReader> reader); std::shared_ptr<Resource> ReadResource(std::shared_ptr<ResourceMgr> resourceMgr,
std::shared_ptr<ResourceInitData> initData,
std::shared_ptr<BinaryReader> reader) override;
}; };
class TextFactoryV0 : public ResourceVersionFactory class TextFactoryV0 : public ResourceVersionFactory

View file

@ -3,21 +3,20 @@
#include "spdlog/spdlog.h" #include "spdlog/spdlog.h"
namespace Ship { namespace Ship {
std::shared_ptr<Resource> EndMarkerFactory::ReadResource(uint32_t version, std::shared_ptr<BinaryReader> reader) std::shared_ptr<Resource> EndMarkerFactory::ReadResource(std::shared_ptr<ResourceMgr> resourceMgr,
{ std::shared_ptr<ResourceInitData> initData,
auto resource = std::make_shared<EndMarker>(); std::shared_ptr<BinaryReader> reader) {
auto resource = std::make_shared<EndMarker>(resourceMgr, initData);
std::shared_ptr<ResourceVersionFactory> factory = nullptr; std::shared_ptr<ResourceVersionFactory> factory = nullptr;
switch (version) switch (resource->InitData->ResourceVersion) {
{
case 0: case 0:
factory = std::make_shared<EndMarkerFactoryV0>(); factory = std::make_shared<EndMarkerFactoryV0>();
break; break;
} }
if (factory == nullptr) if (factory == nullptr) {
{ SPDLOG_ERROR("Failed to load EndMarker with version {}", resource->InitData->ResourceVersion);
SPDLOG_ERROR("Failed to load EndMarker with version {}", version);
return nullptr; return nullptr;
} }

View file

@ -5,7 +5,9 @@
namespace Ship { namespace Ship {
class EndMarkerFactory : public SceneCommandFactory { class EndMarkerFactory : public SceneCommandFactory {
public: public:
std::shared_ptr<Resource> ReadResource(uint32_t version, std::shared_ptr<BinaryReader> reader); std::shared_ptr<Resource> ReadResource(std::shared_ptr<ResourceMgr> resourceMgr,
std::shared_ptr<ResourceInitData> initData,
std::shared_ptr<BinaryReader> reader) override;
}; };
class EndMarkerFactoryV0 : public SceneCommandVersionFactory { class EndMarkerFactoryV0 : public SceneCommandVersionFactory {

View file

@ -3,13 +3,13 @@
#include "spdlog/spdlog.h" #include "spdlog/spdlog.h"
namespace Ship { namespace Ship {
std::shared_ptr<Resource> SetActorListFactory::ReadResource(uint32_t version, std::shared_ptr<BinaryReader> reader) std::shared_ptr<Resource> SetActorListFactory::ReadResource(std::shared_ptr<ResourceMgr> resourceMgr,
{ std::shared_ptr<ResourceInitData> initData,
auto resource = std::make_shared<SetActorList>(); std::shared_ptr<BinaryReader> reader) {
auto resource = std::make_shared<SetActorList>(resourceMgr, initData);
std::shared_ptr<ResourceVersionFactory> factory = nullptr; std::shared_ptr<ResourceVersionFactory> factory = nullptr;
switch (version) switch (resource->InitData->ResourceVersion) {
{
case 0: case 0:
factory = std::make_shared<SetActorListFactoryV0>(); factory = std::make_shared<SetActorListFactoryV0>();
break; break;
@ -17,7 +17,7 @@ std::shared_ptr<Resource> SetActorListFactory::ReadResource(uint32_t version, st
if (factory == nullptr) if (factory == nullptr)
{ {
SPDLOG_ERROR("Failed to load SetActorList with version {}", version); SPDLOG_ERROR("Failed to load SetActorList with version {}", resource->InitData->ResourceVersion);
return nullptr; return nullptr;
} }
@ -27,8 +27,7 @@ std::shared_ptr<Resource> SetActorListFactory::ReadResource(uint32_t version, st
} }
void Ship::SetActorListFactoryV0::ParseFileBinary(std::shared_ptr<BinaryReader> reader, void Ship::SetActorListFactoryV0::ParseFileBinary(std::shared_ptr<BinaryReader> reader,
std::shared_ptr<Resource> resource) std::shared_ptr<Resource> resource) {
{
std::shared_ptr<SetActorList> setActorList = std::static_pointer_cast<SetActorList>(resource); std::shared_ptr<SetActorList> setActorList = std::static_pointer_cast<SetActorList>(resource);
ResourceVersionFactory::ParseFileBinary(reader, setActorList); ResourceVersionFactory::ParseFileBinary(reader, setActorList);

View file

@ -5,7 +5,9 @@
namespace Ship { namespace Ship {
class SetActorListFactory : public SceneCommandFactory { class SetActorListFactory : public SceneCommandFactory {
public: public:
std::shared_ptr<Resource> ReadResource(uint32_t version, std::shared_ptr<BinaryReader> reader); std::shared_ptr<Resource> ReadResource(std::shared_ptr<ResourceMgr> resourceMgr,
std::shared_ptr<ResourceInitData> initData,
std::shared_ptr<BinaryReader> reader) override;
}; };
class SetActorListFactoryV0 : public SceneCommandVersionFactory { class SetActorListFactoryV0 : public SceneCommandVersionFactory {

View file

@ -4,13 +4,13 @@
#include "libultraship/bridge.h" #include "libultraship/bridge.h"
namespace Ship { namespace Ship {
std::shared_ptr<Resource> SetAlternateHeadersFactory::ReadResource(uint32_t version, std::shared_ptr<BinaryReader> reader) std::shared_ptr<Resource> SetAlternateHeadersFactory::ReadResource(std::shared_ptr<ResourceMgr> resourceMgr,
{ std::shared_ptr<ResourceInitData> initData,
auto resource = std::make_shared<SetAlternateHeaders>(); std::shared_ptr<BinaryReader> reader) {
auto resource = std::make_shared<SetAlternateHeaders>(resourceMgr, initData);
std::shared_ptr<ResourceVersionFactory> factory = nullptr; std::shared_ptr<ResourceVersionFactory> factory = nullptr;
switch (version) switch (resource->InitData->ResourceVersion) {
{
case 0: case 0:
factory = std::make_shared<SetAlternateHeadersFactoryV0>(); factory = std::make_shared<SetAlternateHeadersFactoryV0>();
break; break;
@ -18,7 +18,7 @@ std::shared_ptr<Resource> SetAlternateHeadersFactory::ReadResource(uint32_t vers
if (factory == nullptr) if (factory == nullptr)
{ {
SPDLOG_ERROR("Failed to load SetAlternateHeaders with version {}", version); SPDLOG_ERROR("Failed to load SetAlternateHeaders with version {}", resource->InitData->ResourceVersion);
return nullptr; return nullptr;
} }

View file

@ -5,7 +5,9 @@
namespace Ship { namespace Ship {
class SetAlternateHeadersFactory : public SceneCommandFactory { class SetAlternateHeadersFactory : public SceneCommandFactory {
public: public:
std::shared_ptr<Resource> ReadResource(uint32_t version, std::shared_ptr<BinaryReader> reader); std::shared_ptr<Resource> ReadResource(std::shared_ptr<ResourceMgr> resourceMgr,
std::shared_ptr<ResourceInitData> initData,
std::shared_ptr<BinaryReader> reader) override;
}; };
class SetAlternateHeadersFactoryV0 : public SceneCommandVersionFactory { class SetAlternateHeadersFactoryV0 : public SceneCommandVersionFactory {

View file

@ -3,21 +3,20 @@
#include "spdlog/spdlog.h" #include "spdlog/spdlog.h"
namespace Ship { namespace Ship {
std::shared_ptr<Resource> SetCameraSettingsFactory::ReadResource(uint32_t version, std::shared_ptr<BinaryReader> reader) std::shared_ptr<Resource> SetCameraSettingsFactory::ReadResource(std::shared_ptr<ResourceMgr> resourceMgr,
{ std::shared_ptr<ResourceInitData> initData,
auto resource = std::make_shared<SetCameraSettings>(); std::shared_ptr<BinaryReader> reader) {
auto resource = std::make_shared<SetCameraSettings>(resourceMgr, initData);
std::shared_ptr<ResourceVersionFactory> factory = nullptr; std::shared_ptr<ResourceVersionFactory> factory = nullptr;
switch (version) switch (resource->InitData->ResourceVersion) {
{
case 0: case 0:
factory = std::make_shared<SetCameraSettingsFactoryV0>(); factory = std::make_shared<SetCameraSettingsFactoryV0>();
break; break;
} }
if (factory == nullptr) if (factory == nullptr) {
{ SPDLOG_ERROR("Failed to load SetCameraSettings with version {}", resource->InitData->ResourceVersion);
SPDLOG_ERROR("Failed to load SetCameraSettings with version {}", version);
return nullptr; return nullptr;
} }

View file

@ -5,7 +5,9 @@
namespace Ship { namespace Ship {
class SetCameraSettingsFactory : public SceneCommandFactory { class SetCameraSettingsFactory : public SceneCommandFactory {
public: public:
std::shared_ptr<Resource> ReadResource(uint32_t version, std::shared_ptr<BinaryReader> reader); std::shared_ptr<Resource> ReadResource(std::shared_ptr<ResourceMgr> resourceMgr,
std::shared_ptr<ResourceInitData> initData,
std::shared_ptr<BinaryReader> reader) override;
}; };
class SetCameraSettingsFactoryV0 : public SceneCommandVersionFactory { class SetCameraSettingsFactoryV0 : public SceneCommandVersionFactory {

View file

@ -4,21 +4,20 @@
#include "spdlog/spdlog.h" #include "spdlog/spdlog.h"
namespace Ship { namespace Ship {
std::shared_ptr<Resource> SetCollisionHeaderFactory::ReadResource(uint32_t version, std::shared_ptr<BinaryReader> reader) std::shared_ptr<Resource> SetCollisionHeaderFactory::ReadResource(std::shared_ptr<ResourceMgr> resourceMgr,
{ std::shared_ptr<ResourceInitData> initData,
auto resource = std::make_shared<SetCollisionHeader>(); std::shared_ptr<BinaryReader> reader) {
auto resource = std::make_shared<SetCollisionHeader>(resourceMgr, initData);
std::shared_ptr<ResourceVersionFactory> factory = nullptr; std::shared_ptr<ResourceVersionFactory> factory = nullptr;
switch (version) switch (resource->InitData->ResourceVersion) {
{
case 0: case 0:
factory = std::make_shared<SetCollisionHeaderFactoryV0>(); factory = std::make_shared<SetCollisionHeaderFactoryV0>();
break; break;
} }
if (factory == nullptr) if (factory == nullptr) {
{ SPDLOG_ERROR("Failed to load SetCollisionHeader with version {}", resource->InitData->ResourceVersion);
SPDLOG_ERROR("Failed to load SetCollisionHeader with version {}", version);
return nullptr; return nullptr;
} }
@ -28,8 +27,7 @@ std::shared_ptr<Resource> SetCollisionHeaderFactory::ReadResource(uint32_t versi
} }
void Ship::SetCollisionHeaderFactoryV0::ParseFileBinary(std::shared_ptr<BinaryReader> reader, void Ship::SetCollisionHeaderFactoryV0::ParseFileBinary(std::shared_ptr<BinaryReader> reader,
std::shared_ptr<Resource> resource) std::shared_ptr<Resource> resource) {
{
std::shared_ptr<SetCollisionHeader> setCollisionHeader = std::static_pointer_cast<SetCollisionHeader>(resource); std::shared_ptr<SetCollisionHeader> setCollisionHeader = std::static_pointer_cast<SetCollisionHeader>(resource);
ResourceVersionFactory::ParseFileBinary(reader, setCollisionHeader); ResourceVersionFactory::ParseFileBinary(reader, setCollisionHeader);

View file

@ -5,7 +5,9 @@
namespace Ship { namespace Ship {
class SetCollisionHeaderFactory : public SceneCommandFactory { class SetCollisionHeaderFactory : public SceneCommandFactory {
public: public:
std::shared_ptr<Resource> ReadResource(uint32_t version, std::shared_ptr<BinaryReader> reader); std::shared_ptr<Resource> ReadResource(std::shared_ptr<ResourceMgr> resourceMgr,
std::shared_ptr<ResourceInitData> initData,
std::shared_ptr<BinaryReader> reader) override;
}; };
class SetCollisionHeaderFactoryV0 : public SceneCommandVersionFactory { class SetCollisionHeaderFactoryV0 : public SceneCommandVersionFactory {

View file

@ -3,21 +3,20 @@
#include "spdlog/spdlog.h" #include "spdlog/spdlog.h"
namespace Ship { namespace Ship {
std::shared_ptr<Resource> SetCsCameraFactory::ReadResource(uint32_t version, std::shared_ptr<BinaryReader> reader) std::shared_ptr<Resource> SetCsCameraFactory::ReadResource(std::shared_ptr<ResourceMgr> resourceMgr,
{ std::shared_ptr<ResourceInitData> initData,
auto resource = std::make_shared<SetCsCamera>(); std::shared_ptr<BinaryReader> reader) {
auto resource = std::make_shared<SetCsCamera>(resourceMgr, initData);
std::shared_ptr<ResourceVersionFactory> factory = nullptr; std::shared_ptr<ResourceVersionFactory> factory = nullptr;
switch (version) switch (resource->InitData->ResourceVersion) {
{
case 0: case 0:
factory = std::make_shared<SetCsCameraFactoryV0>(); factory = std::make_shared<SetCsCameraFactoryV0>();
break; break;
} }
if (factory == nullptr) if (factory == nullptr) {
{ SPDLOG_ERROR("Failed to load SetCsCamera with version {}", resource->InitData->ResourceVersion);
SPDLOG_ERROR("Failed to load SetCsCamera with version {}", version);
return nullptr; return nullptr;
} }
@ -27,8 +26,7 @@ std::shared_ptr<Resource> SetCsCameraFactory::ReadResource(uint32_t version, std
} }
void Ship::SetCsCameraFactoryV0::ParseFileBinary(std::shared_ptr<BinaryReader> reader, void Ship::SetCsCameraFactoryV0::ParseFileBinary(std::shared_ptr<BinaryReader> reader,
std::shared_ptr<Resource> resource) std::shared_ptr<Resource> resource) {
{
std::shared_ptr<SetCsCamera> setCsCamera = std::static_pointer_cast<SetCsCamera>(resource); std::shared_ptr<SetCsCamera> setCsCamera = std::static_pointer_cast<SetCsCamera>(resource);
ResourceVersionFactory::ParseFileBinary(reader, setCsCamera); ResourceVersionFactory::ParseFileBinary(reader, setCsCamera);

View file

@ -5,7 +5,9 @@
namespace Ship { namespace Ship {
class SetCsCameraFactory : public SceneCommandFactory { class SetCsCameraFactory : public SceneCommandFactory {
public: public:
std::shared_ptr<Resource> ReadResource(uint32_t version, std::shared_ptr<BinaryReader> reader); std::shared_ptr<Resource> ReadResource(std::shared_ptr<ResourceMgr> resourceMgr,
std::shared_ptr<ResourceInitData> initData,
std::shared_ptr<BinaryReader> reader) override;
}; };
class SetCsCameraFactoryV0 : public SceneCommandVersionFactory { class SetCsCameraFactoryV0 : public SceneCommandVersionFactory {

View file

@ -4,13 +4,13 @@
#include "spdlog/spdlog.h" #include "spdlog/spdlog.h"
namespace Ship { namespace Ship {
std::shared_ptr<Resource> SetCutscenesFactory::ReadResource(uint32_t version, std::shared_ptr<BinaryReader> reader) std::shared_ptr<Resource> SetCutscenesFactory::ReadResource(std::shared_ptr<ResourceMgr> resourceMgr,
{ std::shared_ptr<ResourceInitData> initData,
auto resource = std::make_shared<SetCutscenes>(); std::shared_ptr<BinaryReader> reader) {
auto resource = std::make_shared<SetCutscenes>(resourceMgr, initData);
std::shared_ptr<ResourceVersionFactory> factory = nullptr; std::shared_ptr<ResourceVersionFactory> factory = nullptr;
switch (version) switch (resource->InitData->ResourceVersion) {
{
case 0: case 0:
factory = std::make_shared<SetCutscenesFactoryV0>(); factory = std::make_shared<SetCutscenesFactoryV0>();
break; break;
@ -18,7 +18,7 @@ std::shared_ptr<Resource> SetCutscenesFactory::ReadResource(uint32_t version, st
if (factory == nullptr) if (factory == nullptr)
{ {
SPDLOG_ERROR("Failed to load SetCutscenes with version {}", version); SPDLOG_ERROR("Failed to load SetCutscenes with version {}", resource->InitData->ResourceVersion);
return nullptr; return nullptr;
} }
@ -28,8 +28,7 @@ std::shared_ptr<Resource> SetCutscenesFactory::ReadResource(uint32_t version, st
} }
void Ship::SetCutscenesFactoryV0::ParseFileBinary(std::shared_ptr<BinaryReader> reader, void Ship::SetCutscenesFactoryV0::ParseFileBinary(std::shared_ptr<BinaryReader> reader,
std::shared_ptr<Resource> resource) std::shared_ptr<Resource> resource) {
{
std::shared_ptr<SetCutscenes> setCutscenes = std::static_pointer_cast<SetCutscenes>(resource); std::shared_ptr<SetCutscenes> setCutscenes = std::static_pointer_cast<SetCutscenes>(resource);
ResourceVersionFactory::ParseFileBinary(reader, setCutscenes); ResourceVersionFactory::ParseFileBinary(reader, setCutscenes);

View file

@ -5,7 +5,9 @@
namespace Ship { namespace Ship {
class SetCutscenesFactory : public SceneCommandFactory { class SetCutscenesFactory : public SceneCommandFactory {
public: public:
std::shared_ptr<Resource> ReadResource(uint32_t version, std::shared_ptr<BinaryReader> reader); std::shared_ptr<Resource> ReadResource(std::shared_ptr<ResourceMgr> resourceMgr,
std::shared_ptr<ResourceInitData> initData,
std::shared_ptr<BinaryReader> reader) override;
}; };
class SetCutscenesFactoryV0 : public SceneCommandVersionFactory { class SetCutscenesFactoryV0 : public SceneCommandVersionFactory {

View file

@ -3,21 +3,20 @@
#include "spdlog/spdlog.h" #include "spdlog/spdlog.h"
namespace Ship { namespace Ship {
std::shared_ptr<Resource> SetEchoSettingsFactory::ReadResource(uint32_t version, std::shared_ptr<BinaryReader> reader) std::shared_ptr<Resource> SetEchoSettingsFactory::ReadResource(std::shared_ptr<ResourceMgr> resourceMgr,
{ std::shared_ptr<ResourceInitData> initData,
auto resource = std::make_shared<SetEchoSettings>(); std::shared_ptr<BinaryReader> reader) {
auto resource = std::make_shared<SetEchoSettings>(resourceMgr, initData);
std::shared_ptr<ResourceVersionFactory> factory = nullptr; std::shared_ptr<ResourceVersionFactory> factory = nullptr;
switch (version) switch (resource->InitData->ResourceVersion) {
{
case 0: case 0:
factory = std::make_shared<SetEchoSettingsFactoryV0>(); factory = std::make_shared<SetEchoSettingsFactoryV0>();
break; break;
} }
if (factory == nullptr) if (factory == nullptr) {
{ SPDLOG_ERROR("Failed to load SetEchoSettings with version {}", resource->InitData->ResourceVersion);
SPDLOG_ERROR("Failed to load SetEchoSettings with version {}", version);
return nullptr; return nullptr;
} }

View file

@ -5,7 +5,9 @@
namespace Ship { namespace Ship {
class SetEchoSettingsFactory : public SceneCommandFactory { class SetEchoSettingsFactory : public SceneCommandFactory {
public: public:
std::shared_ptr<Resource> ReadResource(uint32_t version, std::shared_ptr<BinaryReader> reader); std::shared_ptr<Resource> ReadResource(std::shared_ptr<ResourceMgr> resourceMgr,
std::shared_ptr<ResourceInitData> initData,
std::shared_ptr<BinaryReader> reader) override;
}; };
class SetEchoSettingsFactoryV0 : public SceneCommandVersionFactory { class SetEchoSettingsFactoryV0 : public SceneCommandVersionFactory {

View file

@ -3,21 +3,20 @@
#include "spdlog/spdlog.h" #include "spdlog/spdlog.h"
namespace Ship { namespace Ship {
std::shared_ptr<Resource> SetEntranceListFactory::ReadResource(uint32_t version, std::shared_ptr<BinaryReader> reader) std::shared_ptr<Resource> SetEntranceListFactory::ReadResource(std::shared_ptr<ResourceMgr> resourceMgr,
{ std::shared_ptr<ResourceInitData> initData,
auto resource = std::make_shared<SetEntranceList>(); std::shared_ptr<BinaryReader> reader) {
auto resource = std::make_shared<SetEntranceList>(resourceMgr, initData);
std::shared_ptr<ResourceVersionFactory> factory = nullptr; std::shared_ptr<ResourceVersionFactory> factory = nullptr;
switch (version) switch (resource->InitData->ResourceVersion) {
{
case 0: case 0:
factory = std::make_shared<SetEntranceListFactoryV0>(); factory = std::make_shared<SetEntranceListFactoryV0>();
break; break;
} }
if (factory == nullptr) if (factory == nullptr) {
{ SPDLOG_ERROR("Failed to load SetEntranceListList with version {}", resource->InitData->ResourceVersion);
SPDLOG_ERROR("Failed to load SetEntranceListList with version {}", version);
return nullptr; return nullptr;
} }
@ -27,8 +26,7 @@ std::shared_ptr<Resource> SetEntranceListFactory::ReadResource(uint32_t version,
} }
void Ship::SetEntranceListFactoryV0::ParseFileBinary(std::shared_ptr<BinaryReader> reader, void Ship::SetEntranceListFactoryV0::ParseFileBinary(std::shared_ptr<BinaryReader> reader,
std::shared_ptr<Resource> resource) std::shared_ptr<Resource> resource) {
{
std::shared_ptr<SetEntranceList> setEntranceList = std::static_pointer_cast<SetEntranceList>(resource); std::shared_ptr<SetEntranceList> setEntranceList = std::static_pointer_cast<SetEntranceList>(resource);
ResourceVersionFactory::ParseFileBinary(reader, setEntranceList); ResourceVersionFactory::ParseFileBinary(reader, setEntranceList);

View file

@ -5,7 +5,9 @@
namespace Ship { namespace Ship {
class SetEntranceListFactory : public SceneCommandFactory { class SetEntranceListFactory : public SceneCommandFactory {
public: public:
std::shared_ptr<Resource> ReadResource(uint32_t version, std::shared_ptr<BinaryReader> reader); std::shared_ptr<Resource> ReadResource(std::shared_ptr<ResourceMgr> resourceMgr,
std::shared_ptr<ResourceInitData> initData,
std::shared_ptr<BinaryReader> reader) override;
}; };
class SetEntranceListFactoryV0 : public SceneCommandVersionFactory { class SetEntranceListFactoryV0 : public SceneCommandVersionFactory {

View file

@ -3,21 +3,20 @@
#include "spdlog/spdlog.h" #include "spdlog/spdlog.h"
namespace Ship { namespace Ship {
std::shared_ptr<Resource> SetExitListFactory::ReadResource(uint32_t version, std::shared_ptr<BinaryReader> reader) std::shared_ptr<Resource> SetExitListFactory::ReadResource(std::shared_ptr<ResourceMgr> resourceMgr,
{ std::shared_ptr<ResourceInitData> initData,
auto resource = std::make_shared<SetExitList>(); std::shared_ptr<BinaryReader> reader) {
auto resource = std::make_shared<SetExitList>(resourceMgr, initData);
std::shared_ptr<ResourceVersionFactory> factory = nullptr; std::shared_ptr<ResourceVersionFactory> factory = nullptr;
switch (version) switch (resource->InitData->ResourceVersion) {
{
case 0: case 0:
factory = std::make_shared<SetExitListFactoryV0>(); factory = std::make_shared<SetExitListFactoryV0>();
break; break;
} }
if (factory == nullptr) if (factory == nullptr) {
{ SPDLOG_ERROR("Failed to load SetExitList with version {}", resource->InitData->ResourceVersion);
SPDLOG_ERROR("Failed to load SetExitList with version {}", version);
return nullptr; return nullptr;
} }
@ -27,8 +26,7 @@ std::shared_ptr<Resource> SetExitListFactory::ReadResource(uint32_t version, std
} }
void Ship::SetExitListFactoryV0::ParseFileBinary(std::shared_ptr<BinaryReader> reader, void Ship::SetExitListFactoryV0::ParseFileBinary(std::shared_ptr<BinaryReader> reader,
std::shared_ptr<Resource> resource) std::shared_ptr<Resource> resource) {
{
std::shared_ptr<SetExitList> setExitList = std::static_pointer_cast<SetExitList>(resource); std::shared_ptr<SetExitList> setExitList = std::static_pointer_cast<SetExitList>(resource);
ResourceVersionFactory::ParseFileBinary(reader, setExitList); ResourceVersionFactory::ParseFileBinary(reader, setExitList);

View file

@ -5,7 +5,9 @@
namespace Ship { namespace Ship {
class SetExitListFactory : public SceneCommandFactory { class SetExitListFactory : public SceneCommandFactory {
public: public:
std::shared_ptr<Resource> ReadResource(uint32_t version, std::shared_ptr<BinaryReader> reader); std::shared_ptr<Resource> ReadResource(std::shared_ptr<ResourceMgr> resourceMgr,
std::shared_ptr<ResourceInitData> initData,
std::shared_ptr<BinaryReader> reader) override;
}; };
class SetExitListFactoryV0 : public SceneCommandVersionFactory { class SetExitListFactoryV0 : public SceneCommandVersionFactory {

View file

@ -3,13 +3,13 @@
#include "spdlog/spdlog.h" #include "spdlog/spdlog.h"
namespace Ship { namespace Ship {
std::shared_ptr<Resource> SetLightListFactory::ReadResource(uint32_t version, std::shared_ptr<BinaryReader> reader) std::shared_ptr<Resource> SetLightListFactory::ReadResource(std::shared_ptr<ResourceMgr> resourceMgr,
{ std::shared_ptr<ResourceInitData> initData,
auto resource = std::make_shared<SetLightList>(); std::shared_ptr<BinaryReader> reader) {
auto resource = std::make_shared<SetLightList>(resourceMgr, initData);
std::shared_ptr<ResourceVersionFactory> factory = nullptr; std::shared_ptr<ResourceVersionFactory> factory = nullptr;
switch (version) switch (resource->InitData->ResourceVersion) {
{
case 0: case 0:
factory = std::make_shared<SetLightListFactoryV0>(); factory = std::make_shared<SetLightListFactoryV0>();
break; break;
@ -17,7 +17,7 @@ std::shared_ptr<Resource> SetLightListFactory::ReadResource(uint32_t version, st
if (factory == nullptr) if (factory == nullptr)
{ {
SPDLOG_ERROR("Failed to load SetLightList with version {}", version); SPDLOG_ERROR("Failed to load SetLightList with version {}", resource->InitData->ResourceVersion);
return nullptr; return nullptr;
} }

View file

@ -5,7 +5,9 @@
namespace Ship { namespace Ship {
class SetLightListFactory : public SceneCommandFactory { class SetLightListFactory : public SceneCommandFactory {
public: public:
std::shared_ptr<Resource> ReadResource(uint32_t version, std::shared_ptr<BinaryReader> reader); std::shared_ptr<Resource> ReadResource(std::shared_ptr<ResourceMgr> resourceMgr,
std::shared_ptr<ResourceInitData> initData,
std::shared_ptr<BinaryReader> reader) override;
}; };
class SetLightListFactoryV0 : public SceneCommandVersionFactory { class SetLightListFactoryV0 : public SceneCommandVersionFactory {

View file

@ -3,21 +3,20 @@
#include "spdlog/spdlog.h" #include "spdlog/spdlog.h"
namespace Ship { namespace Ship {
std::shared_ptr<Resource> SetLightingSettingsFactory::ReadResource(uint32_t version, std::shared_ptr<BinaryReader> reader) std::shared_ptr<Resource> SetLightingSettingsFactory::ReadResource(std::shared_ptr<ResourceMgr> resourceMgr,
{ std::shared_ptr<ResourceInitData> initData,
auto resource = std::make_shared<SetLightingSettings>(); std::shared_ptr<BinaryReader> reader) {
auto resource = std::make_shared<SetLightingSettings>(resourceMgr, initData);
std::shared_ptr<ResourceVersionFactory> factory = nullptr; std::shared_ptr<ResourceVersionFactory> factory = nullptr;
switch (version) switch (resource->InitData->ResourceVersion) {
{
case 0: case 0:
factory = std::make_shared<SetLightingSettingsFactoryV0>(); factory = std::make_shared<SetLightingSettingsFactoryV0>();
break; break;
} }
if (factory == nullptr) if (factory == nullptr) {
{ SPDLOG_ERROR("Failed to load SetLightingSettings with version {}", resource->InitData->ResourceVersion);
SPDLOG_ERROR("Failed to load SetLightingSettings with version {}", version);
return nullptr; return nullptr;
} }

View file

@ -5,7 +5,9 @@
namespace Ship { namespace Ship {
class SetLightingSettingsFactory : public SceneCommandFactory { class SetLightingSettingsFactory : public SceneCommandFactory {
public: public:
std::shared_ptr<Resource> ReadResource(uint32_t version, std::shared_ptr<BinaryReader> reader); std::shared_ptr<Resource> ReadResource(std::shared_ptr<ResourceMgr> resourceMgr,
std::shared_ptr<ResourceInitData> initData,
std::shared_ptr<BinaryReader> reader) override;
}; };
class SetLightingSettingsFactoryV0 : public SceneCommandVersionFactory { class SetLightingSettingsFactoryV0 : public SceneCommandVersionFactory {

View file

@ -4,13 +4,13 @@
#include "libultraship/bridge.h" #include "libultraship/bridge.h"
namespace Ship { namespace Ship {
std::shared_ptr<Resource> SetMeshFactory::ReadResource(uint32_t version, std::shared_ptr<BinaryReader> reader) std::shared_ptr<Resource> SetMeshFactory::ReadResource(std::shared_ptr<ResourceMgr> resourceMgr,
{ std::shared_ptr<ResourceInitData> initData,
auto resource = std::make_shared<SetMesh>(); std::shared_ptr<BinaryReader> reader) {
auto resource = std::make_shared<SetMesh>(resourceMgr, initData);
std::shared_ptr<ResourceVersionFactory> factory = nullptr; std::shared_ptr<ResourceVersionFactory> factory = nullptr;
switch (version) switch (resource->InitData->ResourceVersion) {
{
case 0: case 0:
factory = std::make_shared<SetMeshFactoryV0>(); factory = std::make_shared<SetMeshFactoryV0>();
break; break;
@ -18,7 +18,7 @@ std::shared_ptr<Resource> SetMeshFactory::ReadResource(uint32_t version, std::sh
if (factory == nullptr) 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; return nullptr;
} }
@ -86,9 +86,9 @@ void Ship::SetMeshFactoryV0::ParseFileBinary(std::shared_ptr<BinaryReader> reade
BgImage image; BgImage image;
image.unk_00 = reader->ReadUInt16(); image.unk_00 = reader->ReadUInt16();
image.id = reader->ReadUByte(); image.id = reader->ReadUByte();
std::string sourceFile = reader->ReadString(); std::string imagePath = "__OTR__" + reader->ReadString();
void* sourceData = GetResourceDataByName(sourceFile.c_str(), true); setMesh->imagePaths.push_back(imagePath);
image.source = sourceData; image.source = (void*)setMesh->imagePaths.back().c_str();
image.unk_0C = reader->ReadUInt32(); image.unk_0C = reader->ReadUInt32();
image.tlut = reader->ReadUInt32(); image.tlut = reader->ReadUInt32();
image.width = reader->ReadUInt16(); image.width = reader->ReadUInt16();

View file

@ -5,7 +5,9 @@
namespace Ship { namespace Ship {
class SetMeshFactory : public SceneCommandFactory { class SetMeshFactory : public SceneCommandFactory {
public: public:
std::shared_ptr<Resource> ReadResource(uint32_t version, std::shared_ptr<BinaryReader> reader); std::shared_ptr<Resource> ReadResource(std::shared_ptr<ResourceMgr> resourceMgr,
std::shared_ptr<ResourceInitData> initData,
std::shared_ptr<BinaryReader> reader) override;
}; };
class SetMeshFactoryV0 : public SceneCommandVersionFactory { class SetMeshFactoryV0 : public SceneCommandVersionFactory {

View file

@ -3,21 +3,20 @@
#include "spdlog/spdlog.h" #include "spdlog/spdlog.h"
namespace Ship { namespace Ship {
std::shared_ptr<Resource> SetObjectListFactory::ReadResource(uint32_t version, std::shared_ptr<BinaryReader> reader) std::shared_ptr<Resource> SetObjectListFactory::ReadResource(std::shared_ptr<ResourceMgr> resourceMgr,
{ std::shared_ptr<ResourceInitData> initData,
auto resource = std::make_shared<SetObjectList>(); std::shared_ptr<BinaryReader> reader) {
auto resource = std::make_shared<SetObjectList>(resourceMgr, initData);
std::shared_ptr<ResourceVersionFactory> factory = nullptr; std::shared_ptr<ResourceVersionFactory> factory = nullptr;
switch (version) switch (resource->InitData->ResourceVersion) {
{
case 0: case 0:
factory = std::make_shared<SetObjectListFactoryV0>(); factory = std::make_shared<SetObjectListFactoryV0>();
break; break;
} }
if (factory == nullptr) if (factory == nullptr) {
{ SPDLOG_ERROR("Failed to load SetObjectList with version {}", resource->InitData->ResourceVersion);
SPDLOG_ERROR("Failed to load SetObjectList with version {}", version);
return nullptr; return nullptr;
} }

View file

@ -5,7 +5,9 @@
namespace Ship { namespace Ship {
class SetObjectListFactory : public SceneCommandFactory { class SetObjectListFactory : public SceneCommandFactory {
public: public:
std::shared_ptr<Resource> ReadResource(uint32_t version, std::shared_ptr<BinaryReader> reader); std::shared_ptr<Resource> ReadResource(std::shared_ptr<ResourceMgr> resourceMgr,
std::shared_ptr<ResourceInitData> initData,
std::shared_ptr<BinaryReader> reader) override;
}; };
class SetObjectListFactoryV0 : public SceneCommandVersionFactory { class SetObjectListFactoryV0 : public SceneCommandVersionFactory {

View file

@ -4,21 +4,20 @@
#include <libultraship/bridge.h> #include <libultraship/bridge.h>
namespace Ship { namespace Ship {
std::shared_ptr<Resource> SetPathwaysFactory::ReadResource(uint32_t version, std::shared_ptr<BinaryReader> reader) std::shared_ptr<Resource> SetPathwaysFactory::ReadResource(std::shared_ptr<ResourceMgr> resourceMgr,
{ std::shared_ptr<ResourceInitData> initData,
auto resource = std::make_shared<SetPathways>(); std::shared_ptr<BinaryReader> reader) {
auto resource = std::make_shared<SetPathways>(resourceMgr, initData);
std::shared_ptr<ResourceVersionFactory> factory = nullptr; std::shared_ptr<ResourceVersionFactory> factory = nullptr;
switch (version) switch (resource->InitData->ResourceVersion) {
{
case 0: case 0:
factory = std::make_shared<SetPathwaysFactoryV0>(); factory = std::make_shared<SetPathwaysFactoryV0>();
break; break;
} }
if (factory == nullptr) if (factory == nullptr) {
{ SPDLOG_ERROR("Failed to load SetPathways with version {}", resource->InitData->ResourceVersion);
SPDLOG_ERROR("Failed to load SetPathways with version {}", version);
return nullptr; return nullptr;
} }
@ -28,8 +27,7 @@ std::shared_ptr<Resource> SetPathwaysFactory::ReadResource(uint32_t version, std
} }
void Ship::SetPathwaysFactoryV0::ParseFileBinary(std::shared_ptr<BinaryReader> reader, void Ship::SetPathwaysFactoryV0::ParseFileBinary(std::shared_ptr<BinaryReader> reader,
std::shared_ptr<Resource> resource) std::shared_ptr<Resource> resource) {
{
std::shared_ptr<SetPathways> setPathways = std::static_pointer_cast<SetPathways>(resource); std::shared_ptr<SetPathways> setPathways = std::static_pointer_cast<SetPathways>(resource);
ResourceVersionFactory::ParseFileBinary(reader, setPathways); ResourceVersionFactory::ParseFileBinary(reader, setPathways);

View file

@ -5,7 +5,9 @@
namespace Ship { namespace Ship {
class SetPathwaysFactory : public SceneCommandFactory { class SetPathwaysFactory : public SceneCommandFactory {
public: public:
std::shared_ptr<Resource> ReadResource(uint32_t version, std::shared_ptr<BinaryReader> reader); std::shared_ptr<Resource> ReadResource(std::shared_ptr<ResourceMgr> resourceMgr,
std::shared_ptr<ResourceInitData> initData,
std::shared_ptr<BinaryReader> reader) override;
}; };
class SetPathwaysFactoryV0 : public SceneCommandVersionFactory { class SetPathwaysFactoryV0 : public SceneCommandVersionFactory {

View file

@ -3,21 +3,20 @@
#include "spdlog/spdlog.h" #include "spdlog/spdlog.h"
namespace Ship { namespace Ship {
std::shared_ptr<Resource> SetRoomBehaviorFactory::ReadResource(uint32_t version, std::shared_ptr<BinaryReader> reader) std::shared_ptr<Resource> SetRoomBehaviorFactory::ReadResource(std::shared_ptr<ResourceMgr> resourceMgr,
{ std::shared_ptr<ResourceInitData> initData,
auto resource = std::make_shared<SetRoomBehavior>(); std::shared_ptr<BinaryReader> reader) {
auto resource = std::make_shared<SetRoomBehavior>(resourceMgr, initData);
std::shared_ptr<ResourceVersionFactory> factory = nullptr; std::shared_ptr<ResourceVersionFactory> factory = nullptr;
switch (version) switch (resource->InitData->ResourceVersion) {
{
case 0: case 0:
factory = std::make_shared<SetRoomBehaviorFactoryV0>(); factory = std::make_shared<SetRoomBehaviorFactoryV0>();
break; break;
} }
if (factory == nullptr) if (factory == nullptr) {
{ SPDLOG_ERROR("Failed to load SetRoomBehavior with version {}", resource->InitData->ResourceVersion);
SPDLOG_ERROR("Failed to load SetRoomBehavior with version {}", version);
return nullptr; return nullptr;
} }
@ -27,8 +26,7 @@ std::shared_ptr<Resource> SetRoomBehaviorFactory::ReadResource(uint32_t version,
} }
void Ship::SetRoomBehaviorFactoryV0::ParseFileBinary(std::shared_ptr<BinaryReader> reader, void Ship::SetRoomBehaviorFactoryV0::ParseFileBinary(std::shared_ptr<BinaryReader> reader,
std::shared_ptr<Resource> resource) std::shared_ptr<Resource> resource) {
{
std::shared_ptr<SetRoomBehavior> setRoomBehavior = std::static_pointer_cast<SetRoomBehavior>(resource); std::shared_ptr<SetRoomBehavior> setRoomBehavior = std::static_pointer_cast<SetRoomBehavior>(resource);
ResourceVersionFactory::ParseFileBinary(reader, setRoomBehavior); ResourceVersionFactory::ParseFileBinary(reader, setRoomBehavior);

View file

@ -5,7 +5,9 @@
namespace Ship { namespace Ship {
class SetRoomBehaviorFactory : public SceneCommandFactory { class SetRoomBehaviorFactory : public SceneCommandFactory {
public: public:
std::shared_ptr<Resource> ReadResource(uint32_t version, std::shared_ptr<BinaryReader> reader); std::shared_ptr<Resource> ReadResource(std::shared_ptr<ResourceMgr> resourceMgr,
std::shared_ptr<ResourceInitData> initData,
std::shared_ptr<BinaryReader> reader) override;
}; };
class SetRoomBehaviorFactoryV0 : public SceneCommandVersionFactory { class SetRoomBehaviorFactoryV0 : public SceneCommandVersionFactory {

View file

@ -3,13 +3,13 @@
#include "spdlog/spdlog.h" #include "spdlog/spdlog.h"
namespace Ship { namespace Ship {
std::shared_ptr<Resource> SetRoomListFactory::ReadResource(uint32_t version, std::shared_ptr<BinaryReader> reader) std::shared_ptr<Resource> SetRoomListFactory::ReadResource(std::shared_ptr<ResourceMgr> resourceMgr,
{ std::shared_ptr<ResourceInitData> initData,
auto resource = std::make_shared<SetRoomList>(); std::shared_ptr<BinaryReader> reader) {
auto resource = std::make_shared<SetRoomList>(resourceMgr, initData);
std::shared_ptr<ResourceVersionFactory> factory = nullptr; std::shared_ptr<ResourceVersionFactory> factory = nullptr;
switch (version) switch (resource->InitData->ResourceVersion) {
{
case 0: case 0:
factory = std::make_shared<SetRoomListFactoryV0>(); factory = std::make_shared<SetRoomListFactoryV0>();
break; break;
@ -17,7 +17,7 @@ std::shared_ptr<Resource> SetRoomListFactory::ReadResource(uint32_t version, std
if (factory == nullptr) if (factory == nullptr)
{ {
SPDLOG_ERROR("Failed to load SetRoomList with version {}", version); SPDLOG_ERROR("Failed to load SetRoomList with version {}", resource->InitData->ResourceVersion);
return nullptr; return nullptr;
} }
@ -27,8 +27,7 @@ std::shared_ptr<Resource> SetRoomListFactory::ReadResource(uint32_t version, std
} }
void Ship::SetRoomListFactoryV0::ParseFileBinary(std::shared_ptr<BinaryReader> reader, void Ship::SetRoomListFactoryV0::ParseFileBinary(std::shared_ptr<BinaryReader> reader,
std::shared_ptr<Resource> resource) std::shared_ptr<Resource> resource) {
{
std::shared_ptr<SetRoomList> setRoomList = std::static_pointer_cast<SetRoomList>(resource); std::shared_ptr<SetRoomList> setRoomList = std::static_pointer_cast<SetRoomList>(resource);
ResourceVersionFactory::ParseFileBinary(reader, setRoomList); ResourceVersionFactory::ParseFileBinary(reader, setRoomList);

View file

@ -5,7 +5,9 @@
namespace Ship { namespace Ship {
class SetRoomListFactory : public SceneCommandFactory { class SetRoomListFactory : public SceneCommandFactory {
public: public:
std::shared_ptr<Resource> ReadResource(uint32_t version, std::shared_ptr<BinaryReader> reader); std::shared_ptr<Resource> ReadResource(std::shared_ptr<ResourceMgr> resourceMgr,
std::shared_ptr<ResourceInitData> initData,
std::shared_ptr<BinaryReader> reader) override;
}; };
class SetRoomListFactoryV0 : public SceneCommandVersionFactory { class SetRoomListFactoryV0 : public SceneCommandVersionFactory {

View file

@ -3,21 +3,20 @@
#include "spdlog/spdlog.h" #include "spdlog/spdlog.h"
namespace Ship { namespace Ship {
std::shared_ptr<Resource> SetSkyboxModifierFactory::ReadResource(uint32_t version, std::shared_ptr<BinaryReader> reader) std::shared_ptr<Resource> SetSkyboxModifierFactory::ReadResource(std::shared_ptr<ResourceMgr> resourceMgr,
{ std::shared_ptr<ResourceInitData> initData,
auto resource = std::make_shared<SetSkyboxModifier>(); std::shared_ptr<BinaryReader> reader) {
auto resource = std::make_shared<SetSkyboxModifier>(resourceMgr, initData);
std::shared_ptr<ResourceVersionFactory> factory = nullptr; std::shared_ptr<ResourceVersionFactory> factory = nullptr;
switch (version) switch (resource->InitData->ResourceVersion) {
{
case 0: case 0:
factory = std::make_shared<SetSkyboxModifierFactoryV0>(); factory = std::make_shared<SetSkyboxModifierFactoryV0>();
break; break;
} }
if (factory == nullptr) if (factory == nullptr) {
{ SPDLOG_ERROR("Failed to load SetSkyboxModifier with version {}", resource->InitData->ResourceVersion);
SPDLOG_ERROR("Failed to load SetSkyboxModifier with version {}", version);
return nullptr; return nullptr;
} }
@ -27,8 +26,7 @@ std::shared_ptr<Resource> SetSkyboxModifierFactory::ReadResource(uint32_t versio
} }
void Ship::SetSkyboxModifierFactoryV0::ParseFileBinary(std::shared_ptr<BinaryReader> reader, void Ship::SetSkyboxModifierFactoryV0::ParseFileBinary(std::shared_ptr<BinaryReader> reader,
std::shared_ptr<Resource> resource) std::shared_ptr<Resource> resource) {
{
std::shared_ptr<SetSkyboxModifier> setSkyboxModifier = std::static_pointer_cast<SetSkyboxModifier>(resource); std::shared_ptr<SetSkyboxModifier> setSkyboxModifier = std::static_pointer_cast<SetSkyboxModifier>(resource);
ResourceVersionFactory::ParseFileBinary(reader, setSkyboxModifier); ResourceVersionFactory::ParseFileBinary(reader, setSkyboxModifier);

View file

@ -5,7 +5,9 @@
namespace Ship { namespace Ship {
class SetSkyboxModifierFactory : public SceneCommandFactory { class SetSkyboxModifierFactory : public SceneCommandFactory {
public: public:
std::shared_ptr<Resource> ReadResource(uint32_t version, std::shared_ptr<BinaryReader> reader); std::shared_ptr<Resource> ReadResource(std::shared_ptr<ResourceMgr> resourceMgr,
std::shared_ptr<ResourceInitData> initData,
std::shared_ptr<BinaryReader> reader) override;
}; };
class SetSkyboxModifierFactoryV0 : public SceneCommandVersionFactory { class SetSkyboxModifierFactoryV0 : public SceneCommandVersionFactory {

View file

@ -3,21 +3,20 @@
#include "spdlog/spdlog.h" #include "spdlog/spdlog.h"
namespace Ship { namespace Ship {
std::shared_ptr<Resource> SetSkyboxSettingsFactory::ReadResource(uint32_t version, std::shared_ptr<BinaryReader> reader) std::shared_ptr<Resource> SetSkyboxSettingsFactory::ReadResource(std::shared_ptr<ResourceMgr> resourceMgr,
{ std::shared_ptr<ResourceInitData> initData,
auto resource = std::make_shared<SetSkyboxSettings>(); std::shared_ptr<BinaryReader> reader) {
auto resource = std::make_shared<SetSkyboxSettings>(resourceMgr, initData);
std::shared_ptr<ResourceVersionFactory> factory = nullptr; std::shared_ptr<ResourceVersionFactory> factory = nullptr;
switch (version) switch (resource->InitData->ResourceVersion) {
{
case 0: case 0:
factory = std::make_shared<SetSkyboxSettingsFactoryV0>(); factory = std::make_shared<SetSkyboxSettingsFactoryV0>();
break; break;
} }
if (factory == nullptr) if (factory == nullptr) {
{ SPDLOG_ERROR("Failed to load SetSkyboxSettings with version {}", resource->InitData->ResourceVersion);
SPDLOG_ERROR("Failed to load SetSkyboxSettings with version {}", version);
return nullptr; return nullptr;
} }
@ -27,8 +26,7 @@ std::shared_ptr<Resource> SetSkyboxSettingsFactory::ReadResource(uint32_t versio
} }
void SetSkyboxSettingsFactoryV0::ParseFileBinary(std::shared_ptr<BinaryReader> reader, void SetSkyboxSettingsFactoryV0::ParseFileBinary(std::shared_ptr<BinaryReader> reader,
std::shared_ptr<Resource> resource) std::shared_ptr<Resource> resource) {
{
std::shared_ptr<SetSkyboxSettings> setSkyboxSettings = std::static_pointer_cast<SetSkyboxSettings>(resource); std::shared_ptr<SetSkyboxSettings> setSkyboxSettings = std::static_pointer_cast<SetSkyboxSettings>(resource);
ResourceVersionFactory::ParseFileBinary(reader, setSkyboxSettings); ResourceVersionFactory::ParseFileBinary(reader, setSkyboxSettings);

View file

@ -5,7 +5,9 @@
namespace Ship { namespace Ship {
class SetSkyboxSettingsFactory : public SceneCommandFactory { class SetSkyboxSettingsFactory : public SceneCommandFactory {
public: public:
std::shared_ptr<Resource> ReadResource(uint32_t version, std::shared_ptr<BinaryReader> reader); std::shared_ptr<Resource> ReadResource(std::shared_ptr<ResourceMgr> resourceMgr,
std::shared_ptr<ResourceInitData> initData,
std::shared_ptr<BinaryReader> reader) override;
}; };
class SetSkyboxSettingsFactoryV0 : public SceneCommandVersionFactory { class SetSkyboxSettingsFactoryV0 : public SceneCommandVersionFactory {

View file

@ -3,21 +3,20 @@
#include "spdlog/spdlog.h" #include "spdlog/spdlog.h"
namespace Ship { namespace Ship {
std::shared_ptr<Resource> SetSoundSettingsFactory::ReadResource(uint32_t version, std::shared_ptr<BinaryReader> reader) std::shared_ptr<Resource> SetSoundSettingsFactory::ReadResource(std::shared_ptr<ResourceMgr> resourceMgr,
{ std::shared_ptr<ResourceInitData> initData,
auto resource = std::make_shared<SetSoundSettings>(); std::shared_ptr<BinaryReader> reader) {
auto resource = std::make_shared<SetSoundSettings>(resourceMgr, initData);
std::shared_ptr<ResourceVersionFactory> factory = nullptr; std::shared_ptr<ResourceVersionFactory> factory = nullptr;
switch (version) switch (resource->InitData->ResourceVersion) {
{
case 0: case 0:
factory = std::make_shared<SetSoundSettingsFactoryV0>(); factory = std::make_shared<SetSoundSettingsFactoryV0>();
break; break;
} }
if (factory == nullptr) if (factory == nullptr) {
{ SPDLOG_ERROR("Failed to load SetSoundSettings with version {}", resource->InitData->ResourceVersion);
SPDLOG_ERROR("Failed to load SetSoundSettings with version {}", version);
return nullptr; return nullptr;
} }
@ -27,8 +26,7 @@ std::shared_ptr<Resource> SetSoundSettingsFactory::ReadResource(uint32_t version
} }
void Ship::SetSoundSettingsFactoryV0::ParseFileBinary(std::shared_ptr<BinaryReader> reader, void Ship::SetSoundSettingsFactoryV0::ParseFileBinary(std::shared_ptr<BinaryReader> reader,
std::shared_ptr<Resource> resource) std::shared_ptr<Resource> resource) {
{
std::shared_ptr<SetSoundSettings> setSoundSettings = std::static_pointer_cast<SetSoundSettings>(resource); std::shared_ptr<SetSoundSettings> setSoundSettings = std::static_pointer_cast<SetSoundSettings>(resource);
ResourceVersionFactory::ParseFileBinary(reader, setSoundSettings); ResourceVersionFactory::ParseFileBinary(reader, setSoundSettings);

View file

@ -5,7 +5,9 @@
namespace Ship { namespace Ship {
class SetSoundSettingsFactory : public SceneCommandFactory { class SetSoundSettingsFactory : public SceneCommandFactory {
public: public:
std::shared_ptr<Resource> ReadResource(uint32_t version, std::shared_ptr<BinaryReader> reader); std::shared_ptr<Resource> ReadResource(std::shared_ptr<ResourceMgr> resourceMgr,
std::shared_ptr<ResourceInitData> initData,
std::shared_ptr<BinaryReader> reader) override;
}; };
class SetSoundSettingsFactoryV0 : public SceneCommandVersionFactory { class SetSoundSettingsFactoryV0 : public SceneCommandVersionFactory {

View file

@ -3,21 +3,20 @@
#include "spdlog/spdlog.h" #include "spdlog/spdlog.h"
namespace Ship { namespace Ship {
std::shared_ptr<Resource> SetSpecialObjectsFactory::ReadResource(uint32_t version, std::shared_ptr<BinaryReader> reader) std::shared_ptr<Resource> SetSpecialObjectsFactory::ReadResource(std::shared_ptr<ResourceMgr> resourceMgr,
{ std::shared_ptr<ResourceInitData> initData,
auto resource = std::make_shared<SetSpecialObjects>(); std::shared_ptr<BinaryReader> reader) {
auto resource = std::make_shared<SetSpecialObjects>(resourceMgr, initData);
std::shared_ptr<ResourceVersionFactory> factory = nullptr; std::shared_ptr<ResourceVersionFactory> factory = nullptr;
switch (version) switch (resource->InitData->ResourceVersion) {
{
case 0: case 0:
factory = std::make_shared<SetSpecialObjectsFactoryV0>(); factory = std::make_shared<SetSpecialObjectsFactoryV0>();
break; break;
} }
if (factory == nullptr) if (factory == nullptr){
{ SPDLOG_ERROR("Failed to load SetSpecialObjects with version {}", resource->InitData->ResourceVersion);
SPDLOG_ERROR("Failed to load SetSpecialObjects with version {}", version);
return nullptr; return nullptr;
} }
@ -27,8 +26,7 @@ std::shared_ptr<Resource> SetSpecialObjectsFactory::ReadResource(uint32_t versio
} }
void Ship::SetSpecialObjectsFactoryV0::ParseFileBinary(std::shared_ptr<BinaryReader> reader, void Ship::SetSpecialObjectsFactoryV0::ParseFileBinary(std::shared_ptr<BinaryReader> reader,
std::shared_ptr<Resource> resource) std::shared_ptr<Resource> resource) {
{
std::shared_ptr<SetSpecialObjects> setSpecialObjects = std::static_pointer_cast<SetSpecialObjects>(resource); std::shared_ptr<SetSpecialObjects> setSpecialObjects = std::static_pointer_cast<SetSpecialObjects>(resource);
ResourceVersionFactory::ParseFileBinary(reader, setSpecialObjects); ResourceVersionFactory::ParseFileBinary(reader, setSpecialObjects);

View file

@ -5,7 +5,9 @@
namespace Ship { namespace Ship {
class SetSpecialObjectsFactory : public SceneCommandFactory { class SetSpecialObjectsFactory : public SceneCommandFactory {
public: public:
std::shared_ptr<Resource> ReadResource(uint32_t version, std::shared_ptr<BinaryReader> reader); std::shared_ptr<Resource> ReadResource(std::shared_ptr<ResourceMgr> resourceMgr,
std::shared_ptr<ResourceInitData> initData,
std::shared_ptr<BinaryReader> reader) override;
}; };
class SetSpecialObjectsFactoryV0 : public SceneCommandVersionFactory { class SetSpecialObjectsFactoryV0 : public SceneCommandVersionFactory {

View file

@ -3,12 +3,13 @@
#include "spdlog/spdlog.h" #include "spdlog/spdlog.h"
namespace Ship { namespace Ship {
std::shared_ptr<Resource> SetStartPositionListFactory::ReadResource(uint32_t version, std::shared_ptr<BinaryReader> reader) std::shared_ptr<Resource> SetStartPositionListFactory::ReadResource(std::shared_ptr<ResourceMgr> resourceMgr,
{ std::shared_ptr<ResourceInitData> initData,
auto resource = std::make_shared<SetStartPositionList>(); std::shared_ptr<BinaryReader> reader) {
auto resource = std::make_shared<SetStartPositionList>(resourceMgr, initData);
std::shared_ptr<ResourceVersionFactory> factory = nullptr; std::shared_ptr<ResourceVersionFactory> factory = nullptr;
switch (version) switch (resource->InitData->ResourceVersion)
{ {
case 0: case 0:
factory = std::make_shared<SetStartPositionListFactoryV0>(); factory = std::make_shared<SetStartPositionListFactoryV0>();
@ -17,7 +18,7 @@ std::shared_ptr<Resource> SetStartPositionListFactory::ReadResource(uint32_t ver
if (factory == nullptr) if (factory == nullptr)
{ {
SPDLOG_ERROR("Failed to load SetStartPositionList with version {}", version); SPDLOG_ERROR("Failed to load SetStartPositionList with version {}", resource->InitData->ResourceVersion);
return nullptr; return nullptr;
} }

View file

@ -5,7 +5,9 @@
namespace Ship { namespace Ship {
class SetStartPositionListFactory : public SceneCommandFactory { class SetStartPositionListFactory : public SceneCommandFactory {
public: public:
std::shared_ptr<Resource> ReadResource(uint32_t version, std::shared_ptr<BinaryReader> reader); std::shared_ptr<Resource> ReadResource(std::shared_ptr<ResourceMgr> resourceMgr,
std::shared_ptr<ResourceInitData> initData,
std::shared_ptr<BinaryReader> reader) override;
}; };
class SetStartPositionListFactoryV0 : public SceneCommandVersionFactory { class SetStartPositionListFactoryV0 : public SceneCommandVersionFactory {

View file

@ -3,21 +3,20 @@
#include "spdlog/spdlog.h" #include "spdlog/spdlog.h"
namespace Ship { namespace Ship {
std::shared_ptr<Resource> SetTimeSettingsFactory::ReadResource(uint32_t version, std::shared_ptr<BinaryReader> reader) std::shared_ptr<Resource> SetTimeSettingsFactory::ReadResource(std::shared_ptr<ResourceMgr> resourceMgr,
{ std::shared_ptr<ResourceInitData> initData,
auto resource = std::make_shared<SetTimeSettings>(); std::shared_ptr<BinaryReader> reader) {
auto resource = std::make_shared<SetTimeSettings>(resourceMgr, initData);
std::shared_ptr<ResourceVersionFactory> factory = nullptr; std::shared_ptr<ResourceVersionFactory> factory = nullptr;
switch (version) switch (resource->InitData->ResourceVersion) {
{
case 0: case 0:
factory = std::make_shared<SetTimeSettingsFactoryV0>(); factory = std::make_shared<SetTimeSettingsFactoryV0>();
break; break;
} }
if (factory == nullptr) if (factory == nullptr) {
{ SPDLOG_ERROR("Failed to load SetTimeSettings with version {}", resource->InitData->ResourceVersion);
SPDLOG_ERROR("Failed to load SetTimeSettings with version {}", version);
return nullptr; return nullptr;
} }
@ -27,8 +26,7 @@ std::shared_ptr<Resource> SetTimeSettingsFactory::ReadResource(uint32_t version,
} }
void Ship::SetTimeSettingsFactoryV0::ParseFileBinary(std::shared_ptr<BinaryReader> reader, void Ship::SetTimeSettingsFactoryV0::ParseFileBinary(std::shared_ptr<BinaryReader> reader,
std::shared_ptr<Resource> resource) std::shared_ptr<Resource> resource) {
{
std::shared_ptr<SetTimeSettings> setTimeSettings = std::static_pointer_cast<SetTimeSettings>(resource); std::shared_ptr<SetTimeSettings> setTimeSettings = std::static_pointer_cast<SetTimeSettings>(resource);
ResourceVersionFactory::ParseFileBinary(reader, setTimeSettings); ResourceVersionFactory::ParseFileBinary(reader, setTimeSettings);

View file

@ -5,7 +5,9 @@
namespace Ship { namespace Ship {
class SetTimeSettingsFactory : public SceneCommandFactory { class SetTimeSettingsFactory : public SceneCommandFactory {
public: public:
std::shared_ptr<Resource> ReadResource(uint32_t version, std::shared_ptr<BinaryReader> reader); std::shared_ptr<Resource> ReadResource(std::shared_ptr<ResourceMgr> resourceMgr,
std::shared_ptr<ResourceInitData> initData,
std::shared_ptr<BinaryReader> reader) override;
}; };
class SetTimeSettingsFactoryV0 : public SceneCommandVersionFactory { class SetTimeSettingsFactoryV0 : public SceneCommandVersionFactory {

View file

@ -3,21 +3,20 @@
#include "spdlog/spdlog.h" #include "spdlog/spdlog.h"
namespace Ship { namespace Ship {
std::shared_ptr<Resource> SetTransitionActorListFactory::ReadResource(uint32_t version, std::shared_ptr<BinaryReader> reader) std::shared_ptr<Resource> SetTransitionActorListFactory::ReadResource(std::shared_ptr<ResourceMgr> resourceMgr,
{ std::shared_ptr<ResourceInitData> initData,
auto resource = std::make_shared<SetTransitionActorList>(); std::shared_ptr<BinaryReader> reader) {
auto resource = std::make_shared<SetTransitionActorList>(resourceMgr, initData);
std::shared_ptr<ResourceVersionFactory> factory = nullptr; std::shared_ptr<ResourceVersionFactory> factory = nullptr;
switch (version) switch (resource->InitData->ResourceVersion) {
{
case 0: case 0:
factory = std::make_shared<SetTransitionActorListFactoryV0>(); factory = std::make_shared<SetTransitionActorListFactoryV0>();
break; break;
} }
if (factory == nullptr) if (factory == nullptr) {
{ SPDLOG_ERROR("Failed to load SetTransitionActorList with version {}", resource->InitData->ResourceVersion);
SPDLOG_ERROR("Failed to load SetTransitionActorList with version {}", version);
return nullptr; return nullptr;
} }
@ -27,8 +26,7 @@ std::shared_ptr<Resource> SetTransitionActorListFactory::ReadResource(uint32_t v
} }
void Ship::SetTransitionActorListFactoryV0::ParseFileBinary(std::shared_ptr<BinaryReader> reader, void Ship::SetTransitionActorListFactoryV0::ParseFileBinary(std::shared_ptr<BinaryReader> reader,
std::shared_ptr<Resource> resource) std::shared_ptr<Resource> resource) {
{
std::shared_ptr<SetTransitionActorList> setTransitionActorList = std::static_pointer_cast<SetTransitionActorList>(resource); std::shared_ptr<SetTransitionActorList> setTransitionActorList = std::static_pointer_cast<SetTransitionActorList>(resource);
ResourceVersionFactory::ParseFileBinary(reader, setTransitionActorList); ResourceVersionFactory::ParseFileBinary(reader, setTransitionActorList);

View file

@ -5,7 +5,9 @@
namespace Ship { namespace Ship {
class SetTransitionActorListFactory : public SceneCommandFactory { class SetTransitionActorListFactory : public SceneCommandFactory {
public: public:
std::shared_ptr<Resource> ReadResource(uint32_t version, std::shared_ptr<BinaryReader> reader); std::shared_ptr<Resource> ReadResource(std::shared_ptr<ResourceMgr> resourceMgr,
std::shared_ptr<ResourceInitData> initData,
std::shared_ptr<BinaryReader> reader) override;
}; };
class SetTransitionActorListFactoryV0 : public SceneCommandVersionFactory { class SetTransitionActorListFactoryV0 : public SceneCommandVersionFactory {

View file

@ -3,21 +3,20 @@
#include "spdlog/spdlog.h" #include "spdlog/spdlog.h"
namespace Ship { namespace Ship {
std::shared_ptr<Resource> SetWindSettingsFactory::ReadResource(uint32_t version, std::shared_ptr<BinaryReader> reader) std::shared_ptr<Resource> SetWindSettingsFactory::ReadResource(std::shared_ptr<ResourceMgr> resourceMgr,
{ std::shared_ptr<ResourceInitData> initData,
auto resource = std::make_shared<SetWindSettings>(); std::shared_ptr<BinaryReader> reader) {
auto resource = std::make_shared<SetWindSettings>(resourceMgr, initData);
std::shared_ptr<ResourceVersionFactory> factory = nullptr; std::shared_ptr<ResourceVersionFactory> factory = nullptr;
switch (version) switch (resource->InitData->ResourceVersion) {
{
case 0: case 0:
factory = std::make_shared<SetWindSettingsFactoryV0>(); factory = std::make_shared<SetWindSettingsFactoryV0>();
break; break;
} }
if (factory == nullptr) if (factory == nullptr) {
{ SPDLOG_ERROR("Failed to load SetWindSettings with version {}", resource->InitData->ResourceVersion);
SPDLOG_ERROR("Failed to load SetWindSettings with version {}", version);
return nullptr; return nullptr;
} }
@ -27,8 +26,7 @@ std::shared_ptr<Resource> SetWindSettingsFactory::ReadResource(uint32_t version,
} }
void Ship::SetWindSettingsFactoryV0::ParseFileBinary(std::shared_ptr<BinaryReader> reader, void Ship::SetWindSettingsFactoryV0::ParseFileBinary(std::shared_ptr<BinaryReader> reader,
std::shared_ptr<Resource> resource) std::shared_ptr<Resource> resource) {
{
std::shared_ptr<SetWindSettings> setWind = std::static_pointer_cast<SetWindSettings>(resource); std::shared_ptr<SetWindSettings> setWind = std::static_pointer_cast<SetWindSettings>(resource);
ResourceVersionFactory::ParseFileBinary(reader, setWind); ResourceVersionFactory::ParseFileBinary(reader, setWind);

View file

@ -5,7 +5,9 @@
namespace Ship { namespace Ship {
class SetWindSettingsFactory : public SceneCommandFactory { class SetWindSettingsFactory : public SceneCommandFactory {
public: public:
std::shared_ptr<Resource> ReadResource(uint32_t version, std::shared_ptr<BinaryReader> reader); std::shared_ptr<Resource> ReadResource(std::shared_ptr<ResourceMgr> resourceMgr,
std::shared_ptr<ResourceInitData> initData,
std::shared_ptr<BinaryReader> reader) override;
}; };
class SetWindSettingsFactoryV0 : public SceneCommandVersionFactory { class SetWindSettingsFactoryV0 : public SceneCommandVersionFactory {

View file

@ -65,6 +65,8 @@ namespace Ship {
class Animation : public Resource { class Animation : public Resource {
public: public:
using Resource::Resource;
void* GetPointer(); void* GetPointer();
size_t GetPointerSize(); size_t GetPointerSize();

View file

@ -41,6 +41,8 @@ namespace Ship {
class AudioSample : public Resource { class AudioSample : public Resource {
public: public:
using Resource::Resource;
void* GetPointer(); void* GetPointer();
size_t GetPointerSize(); size_t GetPointerSize();

View file

@ -19,6 +19,8 @@ typedef struct {
class AudioSequence : public Resource { class AudioSequence : public Resource {
public: public:
using Resource::Resource;
void* GetPointer(); void* GetPointer();
size_t GetPointerSize(); size_t GetPointerSize();

View file

@ -54,6 +54,8 @@ typedef struct {
class AudioSoundFont : public Resource { class AudioSoundFont : public Resource {
public: public:
using Resource::Resource;
void* GetPointer(); void* GetPointer();
size_t GetPointerSize(); size_t GetPointerSize();

View file

@ -5,6 +5,8 @@
namespace Ship { namespace Ship {
class Background : public Resource { class Background : public Resource {
public: public:
using Resource::Resource;
void* GetPointer(); void* GetPointer();
size_t GetPointerSize(); size_t GetPointerSize();

View file

@ -69,6 +69,8 @@ typedef struct {
class CollisionHeader : public Resource { class CollisionHeader : public Resource {
public: public:
using Resource::Resource;
void* GetPointer(); void* GetPointer();
size_t GetPointerSize(); size_t GetPointerSize();

View file

@ -46,6 +46,8 @@ enum class CutsceneCommands {
class Cutscene : public Resource { class Cutscene : public Resource {
public: public:
using Resource::Resource;
void* GetPointer(); void* GetPointer();
size_t GetPointerSize(); size_t GetPointerSize();

View file

@ -15,6 +15,8 @@ typedef struct {
class Path : public Resource { class Path : public Resource {
public: public:
using Resource::Resource;
void* GetPointer(); void* GetPointer();
size_t GetPointerSize(); size_t GetPointerSize();

View file

@ -11,6 +11,8 @@ namespace Ship {
class PlayerAnimation : public Resource { class PlayerAnimation : public Resource {
public: public:
using Resource::Resource;
void* GetPointer(); void* GetPointer();
size_t GetPointerSize(); size_t GetPointerSize();

View file

@ -11,6 +11,8 @@ namespace Ship {
class Scene : public Resource { class Scene : public Resource {
public: public:
using Resource::Resource;
void* GetPointer(); void* GetPointer();
size_t GetPointerSize(); size_t GetPointerSize();

View file

@ -50,6 +50,8 @@ union SkeletonData {
class Skeleton : public Resource { class Skeleton : public Resource {
public: public:
using Resource::Resource;
void* GetPointer(); void* GetPointer();
size_t GetPointerSize(); size_t GetPointerSize();

View file

@ -99,6 +99,8 @@ union SkeletonLimbData {
class SkeletonLimb : public Resource { class SkeletonLimb : public Resource {
public: public:
using Resource::Resource;
void* GetPointer(); void* GetPointer();
size_t GetPointerSize(); size_t GetPointerSize();

View file

@ -18,6 +18,8 @@ public:
class Text : public Resource { class Text : public Resource {
public: public:
using Resource::Resource;
void* GetPointer(); void* GetPointer();
size_t GetPointerSize(); size_t GetPointerSize();

View file

@ -14,6 +14,8 @@ typedef struct {
class EndMarker : public SceneCommand { class EndMarker : public SceneCommand {
public: public:
using SceneCommand::SceneCommand;
void* GetPointer(); void* GetPointer();
size_t GetPointerSize(); size_t GetPointerSize();

View file

@ -49,6 +49,7 @@ enum class SceneCommandID : uint8_t {
class SceneCommand : public Resource { class SceneCommand : public Resource {
public: public:
using Resource::Resource;
SceneCommandID cmdId; SceneCommandID cmdId;
}; };

View file

@ -19,6 +19,8 @@ typedef struct {
class SetActorList : public SceneCommand { class SetActorList : public SceneCommand {
public: public:
using SceneCommand::SceneCommand;
void* GetPointer(); void* GetPointer();
size_t GetPointerSize(); size_t GetPointerSize();

View file

@ -15,6 +15,8 @@ namespace Ship {
class SetAlternateHeaders : public SceneCommand { class SetAlternateHeaders : public SceneCommand {
public: public:
using SceneCommand::SceneCommand;
void* GetPointer(); void* GetPointer();
size_t GetPointerSize(); size_t GetPointerSize();

View file

@ -15,6 +15,8 @@ typedef struct {
class SetCameraSettings : public SceneCommand { class SetCameraSettings : public SceneCommand {
public: public:
using SceneCommand::SceneCommand;
void* GetPointer(); void* GetPointer();
size_t GetPointerSize(); size_t GetPointerSize();

View file

@ -12,6 +12,8 @@
namespace Ship { namespace Ship {
class SetCollisionHeader : public SceneCommand { class SetCollisionHeader : public SceneCommand {
public: public:
using SceneCommand::SceneCommand;
void* GetPointer(); void* GetPointer();
size_t GetPointerSize(); size_t GetPointerSize();

View file

@ -14,6 +14,8 @@ typedef struct {
class SetCsCamera : public SceneCommand { class SetCsCamera : public SceneCommand {
public: public:
using SceneCommand::SceneCommand;
void* GetPointer(); void* GetPointer();
size_t GetPointerSize(); size_t GetPointerSize();

View file

@ -12,6 +12,8 @@
namespace Ship { namespace Ship {
class SetCutscenes : public SceneCommand { class SetCutscenes : public SceneCommand {
public: public:
using SceneCommand::SceneCommand;
void* GetPointer(); void* GetPointer();
size_t GetPointerSize(); size_t GetPointerSize();

View file

@ -14,6 +14,8 @@ typedef struct {
class SetEchoSettings : public SceneCommand { class SetEchoSettings : public SceneCommand {
public: public:
using SceneCommand::SceneCommand;
void* GetPointer(); void* GetPointer();
size_t GetPointerSize(); size_t GetPointerSize();

Some files were not shown because too many files have changed in this diff Show more