diff options
| author | louist103 <35883445+louist103@users.noreply.github.com> | 2023-11-25 19:28:39 -0500 |
|---|---|---|
| committer | louist103 <35883445+louist103@users.noreply.github.com> | 2023-11-25 19:28:39 -0500 |
| commit | 5c12399c80ccdff8332cede991467eda048134ed (patch) | |
| tree | 29ae143e4e0840cf6cdb274bc41d3c5cdeb6dcbe | |
| parent | 880899ce40826b89ad3289ba0ec03be2bc156e77 (diff) | |
Importer/exporter fixes.
| m--------- | OTRExporter | 0 | ||||
| -rw-r--r-- | mm/2s2h/resource/importer/SceneFactory.cpp | 2 | ||||
| -rw-r--r-- | mm/2s2h/resource/importer/scenecommand/SetCameraSettingsFactory.cpp | 6 | ||||
| -rw-r--r-- | mm/2s2h/resource/importer/scenecommand/SetCsCameraFactory.cpp | 6 | ||||
| -rw-r--r-- | mm/2s2h/resource/importer/scenecommand/SetRoomBehaviorFactory.cpp | 40 | ||||
| -rw-r--r-- | mm/2s2h/resource/importer/scenecommand/SetRoomBehaviorFactory.h | 12 | ||||
| -rw-r--r-- | mm/2s2h/resource/type/scenecommand/SetCsCamera.cpp | 2 | ||||
| -rw-r--r-- | mm/2s2h/resource/type/scenecommand/SetRoomBehavior.cpp | 6 | ||||
| -rw-r--r-- | mm/2s2h/resource/type/scenecommand/SetRoomBehavior.h | 21 | ||||
| -rw-r--r-- | mm/2s2h/z_scene_2SH.cpp | 18 |
10 files changed, 99 insertions, 14 deletions
diff --git a/OTRExporter b/OTRExporter -Subproject ff843858ce5b853fb2cd19d9cf81009859bbc5b +Subproject a2df4dda0a1f7adfa08d81242e32a9665e1d35b diff --git a/mm/2s2h/resource/importer/SceneFactory.cpp b/mm/2s2h/resource/importer/SceneFactory.cpp index 0e93da4f6..67320daa8 100644 --- a/mm/2s2h/resource/importer/SceneFactory.cpp +++ b/mm/2s2h/resource/importer/SceneFactory.cpp @@ -45,7 +45,7 @@ SceneFactory::ReadResource(std::shared_ptr<ResourceInitData> initData, std::shar SceneFactory::sceneCommandFactories[LUS::SceneCommandID::SetEchoSettings] = std::make_shared<SetEchoSettingsFactory>(); SceneFactory::sceneCommandFactories[LUS::SceneCommandID::SetSoundSettings] = std::make_shared<SetSoundSettingsFactory>(); SceneFactory::sceneCommandFactories[LUS::SceneCommandID::SetSkyboxSettings] = std::make_shared<SetSkyboxSettingsFactory>(); - SceneFactory::sceneCommandFactories[LUS::SceneCommandID::SetRoomBehavior] = std::make_shared<SetRoomBehaviorFactory>(); + SceneFactory::sceneCommandFactories[LUS::SceneCommandID::SetRoomBehavior] = std::make_shared<SetRoomBehaviorMMFactory>(); SceneFactory::sceneCommandFactories[LUS::SceneCommandID::SetCsCamera] = std::make_shared<SetCsCameraFactory>(); SceneFactory::sceneCommandFactories[LUS::SceneCommandID::SetCameraSettings] = std::make_shared<SetCameraSettingsFactory>(); SceneFactory::sceneCommandFactories[LUS::SceneCommandID::SetRoomList] = std::make_shared<SetRoomListFactory>(); diff --git a/mm/2s2h/resource/importer/scenecommand/SetCameraSettingsFactory.cpp b/mm/2s2h/resource/importer/scenecommand/SetCameraSettingsFactory.cpp index d36d412e9..caa46cefd 100644 --- a/mm/2s2h/resource/importer/scenecommand/SetCameraSettingsFactory.cpp +++ b/mm/2s2h/resource/importer/scenecommand/SetCameraSettingsFactory.cpp @@ -31,9 +31,9 @@ void LUS::SetCameraSettingsFactoryV0::ParseFileBinary(std::shared_ptr<BinaryRead ResourceVersionFactory::ParseFileBinary(reader, setCameraSettings); ReadCommandId(setCameraSettings, reader); - - setCameraSettings->settings.cameraMovement = reader->ReadInt8(); - setCameraSettings->settings.worldMapArea = reader->ReadInt32(); + // BENTODO in MM this scene command is only used as a signal to have the scene system mark an area as visted. We should make a new command factory for this but this is fine for now. + //setCameraSettings->settings.cameraMovement = reader->ReadInt8(); + //setCameraSettings->settings.worldMapArea = reader->ReadInt32(); } } // namespace LUS diff --git a/mm/2s2h/resource/importer/scenecommand/SetCsCameraFactory.cpp b/mm/2s2h/resource/importer/scenecommand/SetCsCameraFactory.cpp index 4e7c74067..445f64cb6 100644 --- a/mm/2s2h/resource/importer/scenecommand/SetCsCameraFactory.cpp +++ b/mm/2s2h/resource/importer/scenecommand/SetCsCameraFactory.cpp @@ -43,9 +43,9 @@ void LUS::SetCsCameraFactoryV0::ParseFileBinary(std::shared_ptr<BinaryReader> re } data.actorCsCamFuncData = new z64Vec3s[data.count]; for (size_t j = 0; j < data.count; j++) { - data.actorCsCamFuncData->x = reader->ReadInt16(); - data.actorCsCamFuncData->y = reader->ReadInt16(); - data.actorCsCamFuncData->z = reader->ReadInt16(); + data.actorCsCamFuncData[j].x = reader->ReadInt16(); + data.actorCsCamFuncData[j].y = reader->ReadInt16(); + data.actorCsCamFuncData[j].z = reader->ReadInt16(); } setCsCamera->csCamera.emplace_back(data); } diff --git a/mm/2s2h/resource/importer/scenecommand/SetRoomBehaviorFactory.cpp b/mm/2s2h/resource/importer/scenecommand/SetRoomBehaviorFactory.cpp index 6222eb3b6..e2c5df85f 100644 --- a/mm/2s2h/resource/importer/scenecommand/SetRoomBehaviorFactory.cpp +++ b/mm/2s2h/resource/importer/scenecommand/SetRoomBehaviorFactory.cpp @@ -3,6 +3,8 @@ #include "spdlog/spdlog.h" namespace LUS { +// OOT +#if 0 std::shared_ptr<IResource> SetRoomBehaviorFactory::ReadResource(std::shared_ptr<ResourceInitData> initData, std::shared_ptr<BinaryReader> reader) { auto resource = std::make_shared<SetRoomBehavior>(initData); @@ -34,5 +36,43 @@ void LUS::SetRoomBehaviorFactoryV0::ParseFileBinary(std::shared_ptr<BinaryReader setRoomBehavior->roomBehavior.gameplayFlags = reader->ReadInt8(); setRoomBehavior->roomBehavior.gameplayFlags2 = reader->ReadInt32(); } +#endif +// MM + +std::shared_ptr<IResource> SetRoomBehaviorMMFactory::ReadResource(std::shared_ptr<ResourceInitData> initData, + std::shared_ptr<BinaryReader> reader) { + auto resource = std::make_shared<SetRoomBehaviorMM>(initData); + std::shared_ptr<ResourceVersionFactory> factory = nullptr; + + switch (resource->GetInitData()->ResourceVersion) { + case 0: + factory = std::make_shared<SetRoomBehaviorMMFactoryV0>(); + break; + } + + if (factory == nullptr) { + SPDLOG_ERROR("Failed to load SetRoomBehavior with version {}", resource->GetInitData()->ResourceVersion); + return nullptr; + } + + factory->ParseFileBinary(reader, resource); + + return resource; +} + +void SetRoomBehaviorMMFactoryV0::ParseFileBinary(std::shared_ptr<BinaryReader> reader, + std::shared_ptr<IResource> resource) { + std::shared_ptr<SetRoomBehaviorMM> setRoomBehavior = std::static_pointer_cast<SetRoomBehaviorMM>(resource); + ResourceVersionFactory::ParseFileBinary(reader, setRoomBehavior); + + ReadCommandId(setRoomBehavior, reader); + + setRoomBehavior->roomBehavior.gameplayFlags = reader->ReadInt8(); + setRoomBehavior->roomBehavior.currRoomUnk2 = reader->ReadInt8(); + setRoomBehavior->roomBehavior.currRoomUnk5 = reader->ReadInt8(); + setRoomBehavior->roomBehavior.msgCtxUnk = reader->ReadInt8(); + setRoomBehavior->roomBehavior.enablePointLights = reader->ReadInt8(); + setRoomBehavior->roomBehavior.kankyoContextUnkE2 = reader->ReadInt8(); +} } // namespace LUS diff --git a/mm/2s2h/resource/importer/scenecommand/SetRoomBehaviorFactory.h b/mm/2s2h/resource/importer/scenecommand/SetRoomBehaviorFactory.h index de812249d..a449a1c8f 100644 --- a/mm/2s2h/resource/importer/scenecommand/SetRoomBehaviorFactory.h +++ b/mm/2s2h/resource/importer/scenecommand/SetRoomBehaviorFactory.h @@ -13,4 +13,16 @@ class SetRoomBehaviorFactoryV0 : public SceneCommandVersionFactory { public: void ParseFileBinary(std::shared_ptr<BinaryReader> reader, std::shared_ptr<IResource> resource) override; }; + +class SetRoomBehaviorMMFactory : public SceneCommandFactory { + public: + std::shared_ptr<IResource> ReadResource(std::shared_ptr<ResourceInitData> initData, + std::shared_ptr<BinaryReader> reader) override; +}; + +class SetRoomBehaviorMMFactoryV0 : public SceneCommandVersionFactory { + public: + void ParseFileBinary(std::shared_ptr<BinaryReader> reader, std::shared_ptr<IResource> resource) override; +}; + }; // namespace LUS diff --git a/mm/2s2h/resource/type/scenecommand/SetCsCamera.cpp b/mm/2s2h/resource/type/scenecommand/SetCsCamera.cpp index 186ffcae6..59af0c0fe 100644 --- a/mm/2s2h/resource/type/scenecommand/SetCsCamera.cpp +++ b/mm/2s2h/resource/type/scenecommand/SetCsCamera.cpp @@ -4,7 +4,7 @@ namespace LUS { SetCsCamera::~SetCsCamera() { for (auto c : csCamera) { if (c.actorCsCamFuncData != nullptr) { - delete c.actorCsCamFuncData; + delete[] c.actorCsCamFuncData; } } } diff --git a/mm/2s2h/resource/type/scenecommand/SetRoomBehavior.cpp b/mm/2s2h/resource/type/scenecommand/SetRoomBehavior.cpp index deababc87..a56562449 100644 --- a/mm/2s2h/resource/type/scenecommand/SetRoomBehavior.cpp +++ b/mm/2s2h/resource/type/scenecommand/SetRoomBehavior.cpp @@ -8,4 +8,10 @@ RoomBehavior* SetRoomBehavior::GetPointer() { size_t SetRoomBehavior::GetPointerSize() { return sizeof(RoomBehavior); } +RoomBehaviorMM* SetRoomBehaviorMM::GetPointer() { + return &roomBehavior; +} +size_t SetRoomBehaviorMM::GetPointerSize() { + return sizeof(RoomBehaviorMM); +} } // namespace LUS diff --git a/mm/2s2h/resource/type/scenecommand/SetRoomBehavior.h b/mm/2s2h/resource/type/scenecommand/SetRoomBehavior.h index c2a28176e..6889a2aee 100644 --- a/mm/2s2h/resource/type/scenecommand/SetRoomBehavior.h +++ b/mm/2s2h/resource/type/scenecommand/SetRoomBehavior.h @@ -13,6 +13,15 @@ typedef struct { int32_t gameplayFlags2; } RoomBehavior; +typedef struct { + int8_t gameplayFlags; + int8_t currRoomUnk2; + int8_t currRoomUnk5; + int8_t msgCtxUnk; + int8_t enablePointLights; + int8_t kankyoContextUnkE2; +} RoomBehaviorMM; + class SetRoomBehavior : public SceneCommand<RoomBehavior> { public: using SceneCommand::SceneCommand; @@ -22,4 +31,16 @@ class SetRoomBehavior : public SceneCommand<RoomBehavior> { RoomBehavior roomBehavior; }; + + +class SetRoomBehaviorMM : public SceneCommand<RoomBehaviorMM> { + public: + using SceneCommand::SceneCommand; + + RoomBehaviorMM* GetPointer(); + size_t GetPointerSize(); + + RoomBehaviorMM roomBehavior; +}; + }; // namespace LUS diff --git a/mm/2s2h/z_scene_2SH.cpp b/mm/2s2h/z_scene_2SH.cpp index 030ddcfa4..586d9d6b4 100644 --- a/mm/2s2h/z_scene_2SH.cpp +++ b/mm/2s2h/z_scene_2SH.cpp @@ -119,14 +119,20 @@ void Scene_CommandSpecialFiles(PlayState* play, LUS::ISceneCommand* cmd) { } void Scene_CommandRoomBehavior(PlayState* play, LUS::ISceneCommand* cmd) { - LUS::SetRoomBehavior* behavior = (LUS::SetRoomBehavior*)cmd; + LUS::SetRoomBehaviorMM* behavior = (LUS::SetRoomBehaviorMM*)cmd; play->roomCtx.curRoom.behaviorType1 = behavior->roomBehavior.gameplayFlags; - play->roomCtx.curRoom.behaviorType2 = behavior->roomBehavior.gameplayFlags2 & 0xFF; - play->roomCtx.curRoom.lensMode = (behavior->roomBehavior.gameplayFlags2 >> 8) & 1; - play->msgCtx.unk12044 = (behavior->roomBehavior.gameplayFlags2 >> 0xA) & 1; - play->roomCtx.curRoom.enablePosLights = (behavior->roomBehavior.gameplayFlags2 >> 0xB) & 1; - play->envCtx.stormState = (behavior->roomBehavior.gameplayFlags2 >> 0xC) & 1; + play->roomCtx.curRoom.behaviorType2 = behavior->roomBehavior.currRoomUnk2; + play->roomCtx.curRoom.lensMode = behavior->roomBehavior.currRoomUnk5; + play->msgCtx.unk12044 = behavior->roomBehavior.msgCtxUnk; + play->roomCtx.curRoom.enablePosLights = behavior->roomBehavior.enablePointLights; + play->envCtx.stormState = behavior->roomBehavior.kankyoContextUnkE2; + //play->roomCtx.curRoom.behaviorType1 = behavior->roomBehavior.gameplayFlags; + //play->roomCtx.curRoom.behaviorType2 = behavior->roomBehavior.gameplayFlags2 & 0xFF; + //play->roomCtx.curRoom.lensMode = (behavior->roomBehavior.gameplayFlags2 >> 8) & 1; + //play->msgCtx.unk12044 = (behavior->roomBehavior.gameplayFlags2 >> 0xA) & 1; + //play->roomCtx.curRoom.enablePosLights = (behavior->roomBehavior.gameplayFlags2 >> 0xB) & 1; + //play->envCtx.stormState = (behavior->roomBehavior.gameplayFlags2 >> 0xC) & 1; } void Scene_Command09(PlayState* play, LUS::ISceneCommand* cmd) { |
