diff --git a/CMakeLists.txt b/CMakeLists.txt index 677a5f494..7ba457735 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,8 +5,8 @@ set(CMAKE_CXX_STANDARD 20 CACHE STRING "The C++ standard to use") set(CMAKE_OSX_DEPLOYMENT_TARGET "10.15" CACHE STRING "Minimum OS X deployment version") -project(Ship VERSION 7.0.0 LANGUAGES C CXX) -set(PROJECT_BUILD_NAME "Spock Alfa" CACHE STRING "") +project(Ship VERSION 7.0.1 LANGUAGES C CXX) +set(PROJECT_BUILD_NAME "Spock Bravo" CACHE STRING "") set(PROJECT_TEAM "github.com/harbourmasters" CACHE STRING "") set_property(DIRECTORY ${CMAKE_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT soh) diff --git a/OTRExporter/OTRExporter/AnimationExporter.cpp b/OTRExporter/OTRExporter/AnimationExporter.cpp index 2d1039947..416d74725 100644 --- a/OTRExporter/OTRExporter/AnimationExporter.cpp +++ b/OTRExporter/OTRExporter/AnimationExporter.cpp @@ -5,20 +5,20 @@ void OTRExporter_Animation::Save(ZResource* res, const fs::path& outPath, Binary { ZAnimation* anim = (ZAnimation*)res; - WriteHeader(res, outPath, writer, Ship::ResourceType::SOH_Animation); + WriteHeader(res, outPath, writer, LUS::ResourceType::SOH_Animation); ZNormalAnimation* normalAnim = dynamic_cast(anim); ZCurveAnimation* curveAnim = dynamic_cast(anim); ZLinkAnimation* linkAnim = dynamic_cast(anim); if (linkAnim != nullptr) { - writer->Write((uint32_t)Ship::AnimationType::Link); + writer->Write((uint32_t)LUS::AnimationType::Link); writer->Write((uint16_t)linkAnim->frameCount); writer->Write((uint32_t)linkAnim->segmentAddress); } else if (curveAnim != nullptr) { - writer->Write((uint32_t)Ship::AnimationType::Curve); + writer->Write((uint32_t)LUS::AnimationType::Curve); writer->Write((uint16_t)curveAnim->frameCount); writer->Write((uint32_t)curveAnim->refIndexArr.size()); @@ -44,7 +44,7 @@ void OTRExporter_Animation::Save(ZResource* res, const fs::path& outPath, Binary } else if (normalAnim != nullptr) { - writer->Write((uint32_t)Ship::AnimationType::Normal); + writer->Write((uint32_t)LUS::AnimationType::Normal); writer->Write((uint16_t)normalAnim->frameCount); writer->Write((uint32_t)normalAnim->rotationValues.size()); @@ -65,6 +65,6 @@ void OTRExporter_Animation::Save(ZResource* res, const fs::path& outPath, Binary } else { - writer->Write((uint32_t)Ship::AnimationType::Legacy); + writer->Write((uint32_t)LUS::AnimationType::Legacy); } } diff --git a/OTRExporter/OTRExporter/ArrayExporter.cpp b/OTRExporter/OTRExporter/ArrayExporter.cpp index f83bfd87d..f6b602bbb 100644 --- a/OTRExporter/OTRExporter/ArrayExporter.cpp +++ b/OTRExporter/OTRExporter/ArrayExporter.cpp @@ -5,7 +5,7 @@ void OTRExporter_Array::Save(ZResource* res, const fs::path& outPath, BinaryWrit { ZArray* arr = (ZArray*)res; - WriteHeader(res, outPath, writer, Ship::ResourceType::Array); + WriteHeader(res, outPath, writer, LUS::ResourceType::Array); writer->Write((uint32_t)arr->resList[0]->GetResourceType()); writer->Write((uint32_t)arr->arrayCnt); diff --git a/OTRExporter/OTRExporter/AudioExporter.cpp b/OTRExporter/OTRExporter/AudioExporter.cpp index f2fc75928..6e1f38e79 100644 --- a/OTRExporter/OTRExporter/AudioExporter.cpp +++ b/OTRExporter/OTRExporter/AudioExporter.cpp @@ -2,7 +2,7 @@ #include "Main.h" #include #include -#include +#include #include "DisplayListExporter.h" void OTRExporter_Audio::WriteSampleEntryReference(ZAudio* audio, SampleEntry* entry, std::map samples, BinaryWriter* writer) @@ -29,7 +29,7 @@ void OTRExporter_Audio::WriteSampleEntryReference(ZAudio* audio, SampleEntry* en void OTRExporter_Audio::WriteSampleEntry(SampleEntry* entry, BinaryWriter* writer) { - WriteHeader(nullptr, "", writer, Ship::ResourceType::SOH_AudioSample, Ship::Version::Rachael); + WriteHeader(nullptr, "", writer, LUS::ResourceType::SOH_AudioSample, 2); writer->Write(entry->codec); writer->Write(entry->medium); @@ -81,7 +81,7 @@ void OTRExporter_Audio::Save(ZResource* res, const fs::path& outPath, BinaryWrit { ZAudio* audio = (ZAudio*)res; - WriteHeader(res, outPath, writer, Ship::ResourceType::SOH_Audio, Ship::Version::Rachael); + WriteHeader(res, outPath, writer, LUS::ResourceType::SOH_Audio, 2); // Write Samples as individual files for (auto pair : audio->samples) @@ -114,7 +114,7 @@ void OTRExporter_Audio::Save(ZResource* res, const fs::path& outPath, BinaryWrit MemoryStream* fntStream = new MemoryStream(); BinaryWriter fntWriter = BinaryWriter(fntStream); - WriteHeader(nullptr, "", &fntWriter, Ship::ResourceType::SOH_AudioSoundFont, Ship::Version::Rachael); + WriteHeader(nullptr, "", &fntWriter, LUS::ResourceType::SOH_AudioSoundFont, 2); fntWriter.Write((uint32_t)i); fntWriter.Write(audio->soundFontTable[i].medium); @@ -173,7 +173,7 @@ void OTRExporter_Audio::Save(ZResource* res, const fs::path& outPath, BinaryWrit MemoryStream* seqStream = new MemoryStream(); BinaryWriter seqWriter = BinaryWriter(seqStream); - WriteHeader(nullptr, "", &seqWriter, Ship::ResourceType::SOH_AudioSequence, Ship::Version::Rachael); + WriteHeader(nullptr, "", &seqWriter, LUS::ResourceType::SOH_AudioSequence, 2); seqWriter.Write((uint32_t)seq.size()); seqWriter.Write(seq.data(), seq.size()); diff --git a/OTRExporter/OTRExporter/BackgroundExporter.cpp b/OTRExporter/OTRExporter/BackgroundExporter.cpp index ced388d43..f0f1a55f4 100644 --- a/OTRExporter/OTRExporter/BackgroundExporter.cpp +++ b/OTRExporter/OTRExporter/BackgroundExporter.cpp @@ -5,7 +5,7 @@ void OTRExporter_Background::Save(ZResource* res, const fs::path& outPath, Binar { ZBackground* bg = (ZBackground*)res; - WriteHeader(bg, outPath, writer, Ship::ResourceType::SOH_Background); + WriteHeader(bg, outPath, writer, LUS::ResourceType::SOH_Background); writer->Write((uint32_t)bg->GetRawDataSize()); diff --git a/OTRExporter/OTRExporter/BlobExporter.cpp b/OTRExporter/OTRExporter/BlobExporter.cpp index 24cb9c1e0..a547718e3 100644 --- a/OTRExporter/OTRExporter/BlobExporter.cpp +++ b/OTRExporter/OTRExporter/BlobExporter.cpp @@ -5,7 +5,7 @@ void OTRExporter_Blob::Save(ZResource* res, const fs::path& outPath, BinaryWrite { ZBlob* blob = (ZBlob*)res; - WriteHeader(blob, outPath, writer, Ship::ResourceType::Blob); + WriteHeader(blob, outPath, writer, LUS::ResourceType::Blob); auto start = std::chrono::steady_clock::now(); diff --git a/OTRExporter/OTRExporter/CollisionExporter.cpp b/OTRExporter/OTRExporter/CollisionExporter.cpp index 21e4cc4c6..cbcdbb35f 100644 --- a/OTRExporter/OTRExporter/CollisionExporter.cpp +++ b/OTRExporter/OTRExporter/CollisionExporter.cpp @@ -5,7 +5,7 @@ void OTRExporter_Collision::Save(ZResource* res, const fs::path& outPath, Binary { ZCollisionHeader* col = (ZCollisionHeader*)res; - WriteHeader(res, outPath, writer, Ship::ResourceType::SOH_CollisionHeader); + WriteHeader(res, outPath, writer, LUS::ResourceType::SOH_CollisionHeader); writer->Write(col->absMinX); writer->Write(col->absMinY); @@ -32,16 +32,18 @@ void OTRExporter_Collision::Save(ZResource* res, const fs::path& outPath, Binary writer->Write(col->polygons[i].vtxA); writer->Write(col->polygons[i].vtxB); writer->Write(col->polygons[i].vtxC); - writer->Write(col->polygons[i].a); - writer->Write(col->polygons[i].b); - writer->Write(col->polygons[i].c); - writer->Write(col->polygons[i].d); + writer->Write(col->polygons[i].normX); + writer->Write(col->polygons[i].normY); + writer->Write(col->polygons[i].normZ); + writer->Write(col->polygons[i].dist); } - writer->Write((uint32_t)col->polygonTypes.size()); + writer->Write((uint32_t)col->PolygonTypes.size()); - for (uint16_t i = 0; i < col->polygonTypes.size(); i++) - writer->Write(col->polygonTypes[i]); + for (uint16_t i = 0; i < col->PolygonTypes.size(); i++) { + writer->Write(col->PolygonTypes[i].data[1]); + writer->Write(col->PolygonTypes[i].data[0]); + } writer->Write((uint32_t)col->camData->entries.size()); diff --git a/OTRExporter/OTRExporter/CutsceneExporter.cpp b/OTRExporter/OTRExporter/CutsceneExporter.cpp index d08ff6c59..2194ce65a 100644 --- a/OTRExporter/OTRExporter/CutsceneExporter.cpp +++ b/OTRExporter/OTRExporter/CutsceneExporter.cpp @@ -5,12 +5,11 @@ void OTRExporter_Cutscene::Save(ZResource* res, const fs::path& outPath, BinaryW { ZCutscene* cs = (ZCutscene*)res; - WriteHeader(cs, outPath, writer, Ship::ResourceType::SOH_Cutscene); + WriteHeader(cs, outPath, writer, LUS::ResourceType::SOH_Cutscene); - //writer->Write((uint32_t)cs->commands.size() + 2 + 2); writer->Write((uint32_t)0); - int currentStream = writer->GetBaseAddress(); + const auto currentStream = writer->GetBaseAddress(); writer->Write(CS_BEGIN_CUTSCENE(cs->numCommands, cs->endFrame)); @@ -26,12 +25,13 @@ void OTRExporter_Cutscene::Save(ZResource* res, const fs::path& outPath, BinaryW writer->Write(CMD_HH(0x0001, ((CutsceneCommandSetCameraPos*)cs->commands[i])->startFrame)); writer->Write(CMD_HH(cmdCamPos->endFrame, 0x0000)); - for (auto& e : ((CutsceneCommandSetCameraPos*)cs->commands[i])->entries) + for (const auto& e : cs->commands[i]->entries) { - writer->Write(CMD_BBH(e->continueFlag, e->cameraRoll, e->nextPointFrame)); - writer->Write(e->viewAngle); - writer->Write(CMD_HH(e->posX, e->posY)); - writer->Write(CMD_HH(e->posZ, e->unused)); + CutsceneCameraPoint* point = (CutsceneCameraPoint*)e; + writer->Write(CMD_BBH(point->continueFlag, point->cameraRoll, point->nextPointFrame)); + writer->Write(point->viewAngle); + writer->Write(CMD_HH(point->posX, point->posY)); + writer->Write(CMD_HH(point->posZ, point->unused)); } } break; @@ -43,51 +43,54 @@ void OTRExporter_Cutscene::Save(ZResource* res, const fs::path& outPath, BinaryW writer->Write(CMD_HH(0x0001, cmdCamPos->startFrame)); writer->Write(CMD_HH(cmdCamPos->endFrame, 0x0000)); - for (auto& e : ((CutsceneCommandSetCameraPos*)cs->commands[i])->entries) + for (const auto& e : cs->commands[i]->entries) { - writer->Write(CMD_BBH(e->continueFlag, e->cameraRoll, e->nextPointFrame)); - writer->Write(e->viewAngle); - writer->Write(CMD_HH(e->posX, e->posY)); - writer->Write(CMD_HH(e->posZ, e->unused)); + CutsceneCameraPoint* point = (CutsceneCameraPoint*)e; + writer->Write(CMD_BBH(point->continueFlag, point->cameraRoll, point->nextPointFrame)); + writer->Write(point->viewAngle); + writer->Write(CMD_HH(point->posX, point->posY)); + writer->Write(CMD_HH(point->posZ, point->unused)); } break; } - case (uint32_t)CutsceneCommands::SpecialAction: + case (uint32_t)CutsceneCommands::Misc: { writer->Write(CS_CMD_MISC); - writer->Write((uint32_t)CMD_W(((CutsceneCommandSpecialAction*)cs->commands[i])->entries.size())); - for (auto& e : ((CutsceneCommandSpecialAction*)cs->commands[i])->entries) //All in OOT seem to only have 1 entry + writer->Write((uint32_t)CMD_W((cs->commands[i])->entries.size())); + for (const auto& e : cs->commands[i]->entries) //All in OOT seem to only have 1 entry { - writer->Write(CMD_HH(e->base, e->startFrame)); - writer->Write(CMD_HH(e->endFrame, e->unused0)); - writer->Write(CMD_W(e->unused1)); - writer->Write(CMD_W(e->unused2)); - writer->Write(CMD_W(e->unused3)); - writer->Write(CMD_W(e->unused4)); - writer->Write(CMD_W(e->unused5)); - writer->Write(CMD_W(e->unused6)); - writer->Write(CMD_W(e->unused7)); - writer->Write(CMD_W(e->unused8)); - writer->Write(CMD_W(e->unused9)); - writer->Write(CMD_W(e->unused10)); + CutsceneSubCommandEntry_GenericCmd* cmd = (CutsceneSubCommandEntry_GenericCmd*)e; + writer->Write(CMD_HH(cmd->base, cmd->startFrame)); + writer->Write(CMD_HH(cmd->endFrame, cmd->pad)); + writer->Write(CMD_W(cmd->unused1)); + writer->Write(CMD_W(cmd->unused2)); + writer->Write(CMD_W(cmd->unused3)); + writer->Write(CMD_W(cmd->unused4)); + writer->Write(CMD_W(cmd->unused5)); + writer->Write(CMD_W(cmd->unused6)); + writer->Write(CMD_W(cmd->unused7)); + writer->Write(CMD_W(cmd->unused8)); + writer->Write(CMD_W(cmd->unused9)); + writer->Write(CMD_W(cmd->unused10)); } break; } case (uint32_t)CutsceneCommands::SetLighting: { writer->Write(CS_CMD_SET_LIGHTING); - writer->Write((uint32_t)CMD_W(((CutsceneCommandEnvLighting*)cs->commands[i])->entries.size())); - for (auto& e : ((CutsceneCommandEnvLighting*)cs->commands[i])->entries) + writer->Write((uint32_t)CMD_W((cs->commands[i])->entries.size())); + for (const auto& e : cs->commands[i]->entries) { - writer->Write(CMD_HH(e->setting, e->startFrame)); - writer->Write(CMD_HH(e->endFrame, e->unused0)); - writer->Write(CMD_W(e->unused1)); - writer->Write(CMD_W(e->unused2)); - writer->Write(CMD_W(e->unused3)); - writer->Write(CMD_W(e->unused4)); - writer->Write(CMD_W(e->unused5)); - writer->Write(CMD_W(e->unused6)); - writer->Write(CMD_W(e->unused7)); + CutsceneSubCommandEntry_GenericCmd* cmd = (CutsceneSubCommandEntry_GenericCmd*)e; + writer->Write(CMD_HH(cmd->base, cmd->startFrame)); + writer->Write(CMD_HH(cmd->endFrame, cmd->pad)); + writer->Write(CMD_W(cmd->unused1)); + writer->Write(CMD_W(cmd->unused2)); + writer->Write(CMD_W(cmd->unused3)); + writer->Write(CMD_W(cmd->unused4)); + writer->Write(CMD_W(cmd->unused5)); + writer->Write(CMD_W(cmd->unused6)); + writer->Write(CMD_W(cmd->unused7)); writer->Write((uint32_t)0x0); writer->Write((uint32_t)0x0); writer->Write((uint32_t)0x0); @@ -102,12 +105,13 @@ void OTRExporter_Cutscene::Save(ZResource* res, const fs::path& outPath, BinaryW writer->Write(CMD_HH(0x0001, ((CutsceneCommandSetCameraPos*)cs->commands[i])->startFrame)); writer->Write(CMD_HH(cmdCamPos->endFrame, 0x0000)); - for (auto& e : ((CutsceneCommandSetCameraPos*)cs->commands[i])->entries) + for (const auto& e : cs->commands[i]->entries) { - writer->Write(CMD_BBH(e->continueFlag, e->cameraRoll, e->nextPointFrame)); - writer->Write(e->viewAngle); - writer->Write(CMD_HH(e->posX, e->posY)); - writer->Write(CMD_HH(e->posZ, e->unused)); + CutsceneCameraPoint* point = (CutsceneCameraPoint*)e; + writer->Write(CMD_BBH(point->continueFlag, point->cameraRoll, point->nextPointFrame)); + writer->Write(point->viewAngle); + writer->Write(CMD_HH(point->posX, point->posY)); + writer->Write(CMD_HH(point->posZ, point->unused)); } break; } @@ -119,12 +123,13 @@ void OTRExporter_Cutscene::Save(ZResource* res, const fs::path& outPath, BinaryW writer->Write(CMD_HH(0x0001, ((CutsceneCommandSetCameraPos*)cs->commands[i])->startFrame)); writer->Write(CMD_HH(cmdCamPos->endFrame, 0x0000)); - for (auto& e : ((CutsceneCommandSetCameraPos*)cs->commands[i])->entries) + for (const auto& e : cs->commands[i]->entries) { - writer->Write(CMD_BBH(e->continueFlag, e->cameraRoll, e->nextPointFrame)); - writer->Write(e->viewAngle); - writer->Write(CMD_HH(e->posX, e->posY)); - writer->Write(CMD_HH(e->posZ, e->unused)); + CutsceneCameraPoint* point = (CutsceneCameraPoint*)e; + writer->Write(CMD_BBH(point->continueFlag, point->cameraRoll, point->nextPointFrame)); + writer->Write(point->viewAngle); + writer->Write(CMD_HH(point->posX, point->posY)); + writer->Write(CMD_HH(point->posZ, point->unused)); } break; } @@ -137,24 +142,26 @@ void OTRExporter_Cutscene::Save(ZResource* res, const fs::path& outPath, BinaryW case (uint32_t)CutsceneCommands::Cmd09: { writer->Write(CS_CMD_09); - writer->Write((uint32_t)CMD_W(((CutsceneCommandUnknown9*)cs->commands[i])->entries.size())); + writer->Write((uint32_t)CMD_W(((CutsceneCommand_Rumble*)cs->commands[i])->entries.size())); - for (auto& e : ((CutsceneCommandUnknown9*)cs->commands[i])->entries) + for (const auto& e : cs->commands[i]->entries) { - writer->Write(CMD_HH(e->base, e->startFrame)); - writer->Write(CMD_HBB(e->endFrame, e->unk2, e->unk3)); - writer->Write(CMD_BBH(e->unk4, e->unused0, e->unused1)); + CutsceneSubCommandEntry_Rumble* r = (CutsceneSubCommandEntry_Rumble*)e; + writer->Write(CMD_HH(r->base, r->startFrame)); + writer->Write(CMD_HBB(e->endFrame, r->unk_06, r->unk_07)); + writer->Write(CMD_BBH(r->unk_08, r->unk_09, r->unk_0A)); } break; } - case 0x15: - case (uint32_t)CutsceneCommands::Unknown: + case 0x15://Both unused in OoT + case 0x1A://(uint32_t)CutsceneCommands::Unknown: { +#if 0 CutsceneCommandUnknown* cmdUnk = (CutsceneCommandUnknown*)cs->commands[i]; writer->Write((uint32_t)cs->commands[i]->commandID); writer->Write((uint32_t)cmdUnk->entries.size()); - for (auto e : cmdUnk->entries) + for (const auto e : cmdUnk->entries) { writer->Write(CMD_W(e->unused0)); writer->Write(CMD_W(e->unused1)); @@ -169,31 +176,33 @@ void OTRExporter_Cutscene::Save(ZResource* res, const fs::path& outPath, BinaryW writer->Write(CMD_W(e->unused10)); writer->Write(CMD_W(e->unused11)); } +#endif } break; case (uint32_t)CutsceneCommands::Textbox: { writer->Write(CS_CMD_TEXTBOX); - writer->Write((uint32_t)CMD_W(((CutsceneCommandTextbox*)cs->commands[i])->entries.size())); + writer->Write((uint32_t)CMD_W((cs->commands[i])->entries.size())); - for (auto& e : ((CutsceneCommandTextbox*)cs->commands[i])->entries) + for (const auto& e : cs->commands[i]->entries) { - if (e->base == 0xFFFF) // CS_TEXT_NONE + CutsceneSubCommandEntry_TextBox* textBox = (CutsceneSubCommandEntry_TextBox*)e; + if (textBox->base == 0xFFFF) // CS_TEXT_NONE { - writer->Write(CMD_HH(0xFFFF, e->startFrame)); - writer->Write(CMD_HH(e->endFrame, 0xFFFF)); + writer->Write(CMD_HH(0xFFFF, textBox->startFrame)); + writer->Write(CMD_HH(textBox->endFrame, 0xFFFF)); writer->Write(CMD_HH(0xFFFF, 0xFFFF)); } else // CS_TEXT_DISPLAY_TEXTBOX { - writer->Write(CMD_HH(e->base, e->startFrame)); - writer->Write(CMD_HH(e->endFrame, e->type)); - writer->Write(CMD_HH(e->textID1, e->textID2)); + writer->Write(CMD_HH(textBox->base, textBox->startFrame)); + writer->Write(CMD_HH(textBox->endFrame, textBox->type)); + writer->Write(CMD_HH(textBox->textId1, textBox->textId2)); } } break; } - case (uint32_t)CutsceneCommands::SetActorAction0: + case 10: //ActorAction0 case (uint32_t)CutsceneCommands::SetActorAction1: case 17: case 18: @@ -292,11 +301,12 @@ void OTRExporter_Cutscene::Save(ZResource* res, const fs::path& outPath, BinaryW case (uint32_t)CutsceneCommands::SetActorAction10: { writer->Write((uint32_t)(CutsceneCommands)cs->commands[i]->commandID); - writer->Write((uint32_t)CMD_W(((CutsceneCommandActorAction*)cs->commands[i])->entries.size())); + writer->Write((uint32_t)CMD_W(cs->commands[i]->entries.size())); - for (auto& actorAct : ((CutsceneCommandActorAction*)cs->commands[i])->entries) + for (const auto& e : cs->commands[i]->entries) { - writer->Write(CMD_HH(actorAct->action, actorAct->startFrame)); + CutsceneSubCommandEntry_ActorAction* actorAct = (CutsceneSubCommandEntry_ActorAction*)e; + writer->Write(CMD_HH(actorAct->base, actorAct->startFrame)); writer->Write(CMD_HH(actorAct->endFrame, actorAct->rotX)); writer->Write(CMD_HH(actorAct->rotY, actorAct->rotZ)); writer->Write(CMD_W(actorAct->startPosX)); @@ -322,24 +332,23 @@ void OTRExporter_Cutscene::Save(ZResource* res, const fs::path& outPath, BinaryW writer->Write(CMD_HH((((CutsceneCommandSceneTransFX*)cs->commands[i])->endFrame), ((CutsceneCommandSceneTransFX*)cs->commands[i])->endFrame)); break; } - case (uint32_t)CutsceneCommands::Nop: //Not used in OOT - break; case (uint32_t)CutsceneCommands::PlayBGM: { writer->Write(CS_CMD_PLAYBGM); - writer->Write((uint32_t)CMD_W(((CutsceneCommandPlayBGM*)cs->commands[i])->entries.size())); + writer->Write((uint32_t)CMD_W(cs->commands[i]->entries.size())); - for (auto& e : ((CutsceneCommandPlayBGM*)cs->commands[i])->entries) + for (const auto& e : cs->commands[i]->entries) { - writer->Write(CMD_HH(e->sequence, e->startFrame)); - writer->Write(CMD_HH(e->endFrame, e->unknown0)); - writer->Write(CMD_W(e->unknown1)); - writer->Write(CMD_W(e->unknown2)); - writer->Write(CMD_W(e->unknown3)); - writer->Write(CMD_W(e->unknown4)); - writer->Write(CMD_W(e->unknown5)); - writer->Write(CMD_W(e->unknown6)); - writer->Write(CMD_W(e->unknown7)); + CutsceneSubCommandEntry_GenericCmd* cmd = (CutsceneSubCommandEntry_GenericCmd*)e; + writer->Write(CMD_HH(cmd->base, cmd->startFrame)); + writer->Write(CMD_HH(cmd->endFrame, cmd->pad)); + writer->Write(CMD_W(cmd->unused1)); + writer->Write(CMD_W(cmd->unused2)); + writer->Write(CMD_W(cmd->unused3)); + writer->Write(CMD_W(cmd->unused4)); + writer->Write(CMD_W(cmd->unused5)); + writer->Write(CMD_W(cmd->unused6)); + writer->Write(CMD_W(cmd->unused7)); writer->Write((uint32_t)0); writer->Write((uint32_t)0); writer->Write((uint32_t)0); @@ -349,19 +358,20 @@ void OTRExporter_Cutscene::Save(ZResource* res, const fs::path& outPath, BinaryW case (uint32_t)CutsceneCommands::StopBGM: { writer->Write(CS_CMD_STOPBGM); - writer->Write((uint32_t)CMD_W(((CutsceneCommandStopBGM*)cs->commands[i])->entries.size())); + writer->Write((uint32_t)CMD_W(cs->commands[i]->entries.size())); - for (auto& e : ((CutsceneCommandStopBGM*)cs->commands[i])->entries) + for (const auto& e : cs->commands[i]->entries) { - writer->Write(CMD_HH(e->sequence, e->startFrame)); - writer->Write(CMD_HH(e->endFrame, e->unknown0)); - writer->Write(CMD_W(e->unknown1)); - writer->Write(CMD_W(e->unknown2)); - writer->Write(CMD_W(e->unknown3)); - writer->Write(CMD_W(e->unknown4)); - writer->Write(CMD_W(e->unknown5)); - writer->Write(CMD_W(e->unknown6)); - writer->Write(CMD_W(e->unknown7)); + CutsceneSubCommandEntry_GenericCmd* cmd = (CutsceneSubCommandEntry_GenericCmd*)e; + writer->Write(CMD_HH(cmd->base, cmd->startFrame)); + writer->Write(CMD_HH(cmd->endFrame, cmd->pad)); + writer->Write(CMD_W(cmd->unused1)); + writer->Write(CMD_W(cmd->unused2)); + writer->Write(CMD_W(cmd->unused3)); + writer->Write(CMD_W(cmd->unused4)); + writer->Write(CMD_W(cmd->unused5)); + writer->Write(CMD_W(cmd->unused6)); + writer->Write(CMD_W(cmd->unused7)); writer->Write((uint32_t)0); writer->Write((uint32_t)0); writer->Write((uint32_t)0); @@ -371,19 +381,20 @@ void OTRExporter_Cutscene::Save(ZResource* res, const fs::path& outPath, BinaryW case (uint32_t)CutsceneCommands::FadeBGM: { writer->Write(CS_CMD_FADEBGM); - writer->Write((uint32_t)CMD_W(((CutsceneCommandFadeBGM*)cs->commands[i])->entries.size())); + writer->Write((uint32_t)CMD_W(cs->commands[i]->entries.size())); - for (auto& e : ((CutsceneCommandFadeBGM*)cs->commands[i])->entries) + for (const auto& e : cs->commands[i]->entries) { - writer->Write(CMD_HH(e->base, e->startFrame)); - writer->Write(CMD_HH(e->endFrame, e->unknown0)); - writer->Write(CMD_W(e->unknown1)); - writer->Write(CMD_W(e->unknown2)); - writer->Write(CMD_W(e->unknown3)); - writer->Write(CMD_W(e->unknown4)); - writer->Write(CMD_W(e->unknown5)); - writer->Write(CMD_W(e->unknown6)); - writer->Write(CMD_W(e->unknown7)); + CutsceneSubCommandEntry_GenericCmd* cmd = (CutsceneSubCommandEntry_GenericCmd*)e; + writer->Write(CMD_HH(cmd->base, cmd->startFrame)); + writer->Write(CMD_HH(cmd->endFrame, cmd->pad)); + writer->Write(CMD_W(cmd->unused1)); + writer->Write(CMD_W(cmd->unused2)); + writer->Write(CMD_W(cmd->unused3)); + writer->Write(CMD_W(cmd->unused4)); + writer->Write(CMD_W(cmd->unused5)); + writer->Write(CMD_W(cmd->unused6)); + writer->Write(CMD_W(cmd->unused7)); writer->Write((uint32_t)0); writer->Write((uint32_t)0); writer->Write((uint32_t)0); @@ -393,22 +404,24 @@ void OTRExporter_Cutscene::Save(ZResource* res, const fs::path& outPath, BinaryW case (uint32_t)CutsceneCommands::SetTime: { writer->Write(CS_CMD_SETTIME); - writer->Write((uint32_t)CMD_W(((CutsceneCommandDayTime*)cs->commands[i])->entries.size())); + writer->Write((uint32_t)CMD_W(cs->commands[i]->entries.size())); - for (auto& e : ((CutsceneCommandDayTime*)cs->commands[i])->entries) + for (const auto& e : cs->commands[i]->entries) { - writer->Write(CMD_HH(e->base, e->startFrame)); - writer->Write(CMD_HBB(e->endFrame, e->hour, e->minute)); - writer->Write((uint32_t)CMD_W(e->unused)); + CutsceneSubCommandEntry_SetTime* t = (CutsceneSubCommandEntry_SetTime*)e; + writer->Write(CMD_HH(t->base, t->startFrame)); + writer->Write(CMD_HBB(t->endFrame, t->hour, t->minute)); + writer->Write((uint32_t)CMD_W(t->unk_08)); } break; } case (uint32_t)CutsceneCommands::Terminator: { + CutsceneCommand_Terminator* t = (CutsceneCommand_Terminator*)cs->commands[i]; writer->Write(CS_CMD_TERMINATOR); writer->Write((uint32_t)1); - writer->Write(CMD_HH(((CutsceneCommandTerminator*)cs->commands[i])->base, ((CutsceneCommandTerminator*)cs->commands[i])->startFrame)); - writer->Write(CMD_HH(((CutsceneCommandTerminator*)cs->commands[i])->endFrame, ((CutsceneCommandTerminator*)cs->commands[i])->endFrame)); + writer->Write(CMD_HH(t->base, t->startFrame)); + writer->Write(CMD_HH(t->endFrame, t->endFrame)); break; } default: @@ -424,8 +437,8 @@ void OTRExporter_Cutscene::Save(ZResource* res, const fs::path& outPath, BinaryW writer->Write(0xFFFFFFFF); writer->Write((uint32_t)0); - int endStream = writer->GetBaseAddress(); - writer->Seek(currentStream - 4, SeekOffsetType::Start); + const auto endStream = writer->GetBaseAddress(); + writer->Seek((uint32_t)currentStream - 4, SeekOffsetType::Start); writer->Write((uint32_t)((endStream - currentStream) / 4)); - writer->Seek(endStream, SeekOffsetType::Start); + writer->Seek((uint32_t)endStream, SeekOffsetType::Start); } \ No newline at end of file diff --git a/OTRExporter/OTRExporter/DisplayListExporter.cpp b/OTRExporter/OTRExporter/DisplayListExporter.cpp index 3a77cba8f..81863f09d 100644 --- a/OTRExporter/OTRExporter/DisplayListExporter.cpp +++ b/OTRExporter/OTRExporter/DisplayListExporter.cpp @@ -10,7 +10,7 @@ #include #include #include "MtxExporter.h" -#include +#include #include "VersionInfo.h" #define GFX_SIZE 8 @@ -50,7 +50,7 @@ void OTRExporter_DisplayList::Save(ZResource* res, const fs::path& outPath, Bina //printf("Exporting DList %s\n", dList->GetName().c_str()); - WriteHeader(res, outPath, writer, Ship::ResourceType::DisplayList); + WriteHeader(res, outPath, writer, LUS::ResourceType::DisplayList); while (writer->GetBaseAddress() % 8 != 0) writer->Write((uint8_t)0xFF); @@ -356,7 +356,7 @@ void OTRExporter_DisplayList::Save(ZResource* res, const fs::path& outPath, Bina //std::string fName = StringHelper::Sprintf("%s\\%s", GetParentFolderName(res).c_str(), dListDecl2->varName.c_str()); std::string fName = OTRExporter_DisplayList::GetPathToRes(res, dListDecl2->varName.c_str()); - if (files.find(fName) == files.end() && !File::Exists("Extract/" + fName)) + if (files.find(fName) == files.end() && !DiskFile::Exists("Extract/" + fName)) { MemoryStream* dlStream = new MemoryStream(); BinaryWriter dlWriter = BinaryWriter(dlStream); @@ -442,7 +442,7 @@ void OTRExporter_DisplayList::Save(ZResource* res, const fs::path& outPath, Bina //std::string fName = StringHelper::Sprintf("%s\\%s", GetParentFolderName(res).c_str(), dListDecl2->varName.c_str()); std::string fName = OTRExporter_DisplayList::GetPathToRes(res, dListDecl2->varName.c_str()); - if (files.find(fName) == files.end() && !File::Exists("Extract/" + fName)) + if (files.find(fName) == files.end() && !DiskFile::Exists("Extract/" + fName)) { MemoryStream* dlStream = new MemoryStream(); BinaryWriter dlWriter = BinaryWriter(dlStream); @@ -767,7 +767,7 @@ void OTRExporter_DisplayList::Save(ZResource* res, const fs::path& outPath, Bina word0 = hash >> 32; word1 = hash & 0xFFFFFFFF; - if (files.find(fName) == files.end() && !File::Exists("Extract/" + fName)) + if (files.find(fName) == files.end() && !DiskFile::Exists("Extract/" + fName)) { // Write vertices to file MemoryStream* vtxStream = new MemoryStream(); @@ -786,7 +786,7 @@ void OTRExporter_DisplayList::Save(ZResource* res, const fs::path& outPath, Bina } // OTRTODO: Once we aren't relying on text representations, we should call ArrayExporter... - OTRExporter::WriteHeader(nullptr, "", &vtxWriter, Ship::ResourceType::Array); + OTRExporter::WriteHeader(nullptr, "", &vtxWriter, LUS::ResourceType::Array); vtxWriter.Write((uint32_t)ZResourceType::Vertex); vtxWriter.Write((uint32_t)arrCnt); diff --git a/OTRExporter/OTRExporter/Exporter.cpp b/OTRExporter/OTRExporter/Exporter.cpp index f2daa4279..a523bb16c 100644 --- a/OTRExporter/OTRExporter/Exporter.cpp +++ b/OTRExporter/OTRExporter/Exporter.cpp @@ -1,7 +1,7 @@ #include "Exporter.h" #include "VersionInfo.h" -void OTRExporter::WriteHeader(ZResource* res, const fs::path& outPath, BinaryWriter* writer, Ship::ResourceType resType, Ship::Version resVersion) +void OTRExporter::WriteHeader(ZResource* res, const fs::path& outPath, BinaryWriter* writer, LUS::ResourceType resType, int32_t resVersion) { writer->Write((uint8_t)Endianness::Little); // 0x00 writer->Write((uint8_t)0); // 0x01 diff --git a/OTRExporter/OTRExporter/Exporter.h b/OTRExporter/OTRExporter/Exporter.h index 2f6f23916..cd4ed9adb 100644 --- a/OTRExporter/OTRExporter/Exporter.h +++ b/OTRExporter/OTRExporter/Exporter.h @@ -1,6 +1,7 @@ #pragma once #include "ZResource.h" #include "ZArray.h" +#include "stdint.h" //#include "OTRExporter.h" #include #include @@ -9,5 +10,5 @@ class OTRExporter : public ZResourceExporter { protected: - static void WriteHeader(ZResource* res, const fs::path& outPath, BinaryWriter* writer, Ship::ResourceType resType, Ship::Version resVersion = MAJOR_VERSION); + static void WriteHeader(ZResource* res, const fs::path& outPath, BinaryWriter* writer, LUS::ResourceType resType, int32_t resVersion = 0); }; \ No newline at end of file diff --git a/OTRExporter/OTRExporter/Main.cpp b/OTRExporter/OTRExporter/Main.cpp index 7895fe759..b5e634ad4 100644 --- a/OTRExporter/OTRExporter/Main.cpp +++ b/OTRExporter/OTRExporter/Main.cpp @@ -18,7 +18,7 @@ #include "MtxExporter.h" #include "AudioExporter.h" #include -#include +#include #include #include #include @@ -26,7 +26,7 @@ #include std::string otrFileName = "oot.otr"; -std::shared_ptr otrArchive; +std::shared_ptr otrArchive; BinaryWriter* fileWriter; std::chrono::steady_clock::time_point fileStart, resStart; std::map> files; @@ -47,16 +47,16 @@ static void ExporterParseFileMode(const std::string& buildMode, ZFileMode& fileM printf("BOTR: Generating OTR Archive...\n"); - if (File::Exists(otrFileName)) - otrArchive = std::shared_ptr(new Ship::Archive(otrFileName, true)); + if (DiskFile::Exists(otrFileName)) + otrArchive = std::shared_ptr(new LUS::Archive(otrFileName, true)); else - otrArchive = Ship::Archive::CreateArchive(otrFileName, 40000); + otrArchive = LUS::Archive::CreateArchive(otrFileName, 40000); auto lst = Directory::ListFiles("Extract"); for (auto item : lst) { - auto fileData = File::ReadAllBytes(item); + auto fileData = DiskFile::ReadAllBytes(item); otrArchive->AddFile(StringHelper::Split(item, "Extract/")[1], (uintptr_t)fileData.data(), fileData.size()); } } @@ -70,7 +70,7 @@ static void ExporterProgramEnd() if (Globals::Instance->fileMode == ZFileMode::ExtractDirectory) { std::string romPath = Globals::Instance->baseRomPath.string(); - const std::vector& romData = File::ReadAllBytes(romPath); + const std::vector& romData = DiskFile::ReadAllBytes(romPath); crc = BitConverter::ToUInt32BE(romData, 0x10); printf("Creating version file...\n"); @@ -86,7 +86,7 @@ static void ExporterProgramEnd() printf("Created version file.\n"); printf("Generating OTR Archive...\n"); - otrArchive = Ship::Archive::CreateArchive(otrFileName, 40000); + otrArchive = LUS::Archive::CreateArchive(otrFileName, 40000); otrArchive->AddFile("version", (uintptr_t)versionStream->ToVector().data(), versionStream->GetLength()); @@ -111,11 +111,11 @@ static void ExporterProgramEnd() files.clear(); // Add any additional files that need to be manually copied... - if (File::Exists("soh.otr")) { + if (DiskFile::Exists("soh.otr")) { return; } const auto& lst = Directory::ListFiles("Extract"); - std::shared_ptr sohOtr = Ship::Archive::CreateArchive("soh.otr", 4096); + std::shared_ptr sohOtr = LUS::Archive::CreateArchive("soh.otr", 4096); //sohOtr->AddFile("version", (uintptr_t)versionStream->ToVector().data(), versionStream->GetLength()); for (const auto& item : lst) @@ -158,14 +158,14 @@ static void ExporterProgramEnd() splitPath.pop_back(); if (extension == "json") { - const auto &fileData = File::ReadAllBytes(item); + const auto &fileData = DiskFile::ReadAllBytes(item); printf("Adding accessibility texts %s\n", StringHelper::Split(item, "texts/")[1].c_str()); sohOtr->AddFile(StringHelper::Split(item, "Extract/assets/")[1], (uintptr_t)fileData.data(), fileData.size()); } continue; } - const auto& fileData = File::ReadAllBytes(item); + const auto& fileData = DiskFile::ReadAllBytes(item); printf("sohOtr->AddFile(%s)\n", StringHelper::Split(item, "Extract/")[1].c_str()); sohOtr->AddFile(StringHelper::Split(item, item.find("Extract/assets/") != std::string::npos ? "Extract/assets/" : "Extract/")[1], (uintptr_t)fileData.data(), fileData.size()); } @@ -249,7 +249,7 @@ static void ExporterResourceEnd(ZResource* res, BinaryWriter& writer) files[fName] = strem->ToVector(); } else - File::WriteAllBytes("Extract/" + fName, strem->ToVector()); + DiskFile::WriteAllBytes("Extract/" + fName, strem->ToVector()); } auto end = std::chrono::steady_clock::now(); @@ -275,7 +275,7 @@ static void ExporterXMLEnd() void AddFile(std::string fName, std::vector data) { if (Globals::Instance->fileMode != ZFileMode::ExtractDirectory) - File::WriteAllBytes("Extract/" + fName, data); + DiskFile::WriteAllBytes("Extract/" + fName, data); else { std::unique_lock Lock(fileMutex); diff --git a/OTRExporter/OTRExporter/Main.h b/OTRExporter/OTRExporter/Main.h index 09485be36..3aa68c7e1 100644 --- a/OTRExporter/OTRExporter/Main.h +++ b/OTRExporter/OTRExporter/Main.h @@ -2,7 +2,7 @@ #include -extern std::shared_ptr otrArchive; +extern std::shared_ptr otrArchive; extern std::map> files; void AddFile(std::string fName, std::vector data); \ No newline at end of file diff --git a/OTRExporter/OTRExporter/MtxExporter.cpp b/OTRExporter/OTRExporter/MtxExporter.cpp index a329c43a2..129e43aeb 100644 --- a/OTRExporter/OTRExporter/MtxExporter.cpp +++ b/OTRExporter/OTRExporter/MtxExporter.cpp @@ -4,7 +4,7 @@ void OTRExporter_MtxExporter::Save(ZResource* res, const fs::path& outPath, Bina { ZMtx* mtx = (ZMtx*)res; - WriteHeader(res, outPath, writer, Ship::ResourceType::Matrix); + WriteHeader(res, outPath, writer, LUS::ResourceType::Matrix); for (size_t i = 0; i < 4; i++) for (size_t j = 0; j < 4; j++) diff --git a/OTRExporter/OTRExporter/PathExporter.cpp b/OTRExporter/OTRExporter/PathExporter.cpp index e3f797d9c..cc507c7aa 100644 --- a/OTRExporter/OTRExporter/PathExporter.cpp +++ b/OTRExporter/OTRExporter/PathExporter.cpp @@ -5,7 +5,7 @@ void OTRExporter_Path::Save(ZResource* res, const fs::path& outPath, BinaryWrite { ZPath* path = (ZPath*)res; - WriteHeader(res, outPath, writer, Ship::ResourceType::SOH_Path); + WriteHeader(res, outPath, writer, LUS::ResourceType::SOH_Path); writer->Write((uint32_t)path->pathways.size()); diff --git a/OTRExporter/OTRExporter/PlayerAnimationExporter.cpp b/OTRExporter/OTRExporter/PlayerAnimationExporter.cpp index 22d108c82..b735c4e42 100644 --- a/OTRExporter/OTRExporter/PlayerAnimationExporter.cpp +++ b/OTRExporter/OTRExporter/PlayerAnimationExporter.cpp @@ -5,7 +5,7 @@ void OTRExporter_PlayerAnimationExporter::Save(ZResource* res, const fs::path& o { ZPlayerAnimationData* anim = (ZPlayerAnimationData*)res; - WriteHeader(res, outPath, writer, Ship::ResourceType::SOH_PlayerAnimation); + WriteHeader(res, outPath, writer, LUS::ResourceType::SOH_PlayerAnimation); auto start = std::chrono::steady_clock::now(); diff --git a/OTRExporter/OTRExporter/RoomExporter.cpp b/OTRExporter/OTRExporter/RoomExporter.cpp index 83bd3bbc6..3959d7639 100644 --- a/OTRExporter/OTRExporter/RoomExporter.cpp +++ b/OTRExporter/OTRExporter/RoomExporter.cpp @@ -1,7 +1,7 @@ #include "RoomExporter.h" #include "Utils/BinaryWriter.h" #include "Utils/MemoryStream.h" -#include "Utils/File.h" +#include #include #include #include @@ -39,7 +39,7 @@ void OTRExporter_Room::Save(ZResource* res, const fs::path& outPath, BinaryWrite { ZRoom* room = (ZRoom*)res; - WriteHeader(res, outPath, writer, Ship::ResourceType::SOH_Room); + WriteHeader(res, outPath, writer, LUS::ResourceType::SOH_Room); writer->Write((uint32_t)room->commands.size()); @@ -80,10 +80,8 @@ void OTRExporter_Room::Save(ZResource* res, const fs::path& outPath, BinaryWrite // This can cause issues if we export actors with garbage data, so let's trust the command size writer->Write((uint32_t)cmdSetActorList->numActors); - for (int i = 0; i < cmdSetActorList->numActors; i++) + for (const auto& entry : cmdSetActorList->actorList->actors) { - const ActorSpawnEntry& entry = cmdSetActorList->actors[i]; - writer->Write(entry.actorNum); writer->Write(entry.posX); writer->Write(entry.posY); @@ -91,7 +89,7 @@ void OTRExporter_Room::Save(ZResource* res, const fs::path& outPath, BinaryWrite writer->Write(entry.rotX); writer->Write(entry.rotY); writer->Write(entry.rotZ); - writer->Write(entry.initVar); + writer->Write(entry.params); } } break; @@ -393,7 +391,7 @@ void OTRExporter_Room::Save(ZResource* res, const fs::path& outPath, BinaryWrite writer->Write(entry.rotX); writer->Write(entry.rotY); writer->Write(entry.rotZ); - writer->Write(entry.initVar); + writer->Write(entry.params); } } break; @@ -441,18 +439,18 @@ void OTRExporter_Room::Save(ZResource* res, const fs::path& outPath, BinaryWrite case RoomCommand::SetCutscenes: { SetCutscenes* cmdSetCutscenes = (SetCutscenes*)cmd; - + std::string listName; Globals::Instance->GetSegmentedPtrName(cmdSetCutscenes->cmdArg2, room->parent, "CutsceneData", listName, res->parent->workerID); std::string fName = OTRExporter_DisplayList::GetPathToRes(room, listName); //std::string fName = StringHelper::Sprintf("%s\\%s", OTRExporter_DisplayList::GetParentFolderName(room).c_str(), listName.c_str()); writer->Write(fName); - + MemoryStream* csStream = new MemoryStream(); BinaryWriter csWriter = BinaryWriter(csStream); OTRExporter_Cutscene cs; cs.Save(cmdSetCutscenes->cutscenes[0], "", &csWriter); - + AddFile(fName, csStream->ToVector()); } break; diff --git a/OTRExporter/OTRExporter/SkeletonExporter.cpp b/OTRExporter/OTRExporter/SkeletonExporter.cpp index f5e3ada80..fc4bba6fa 100644 --- a/OTRExporter/OTRExporter/SkeletonExporter.cpp +++ b/OTRExporter/OTRExporter/SkeletonExporter.cpp @@ -7,7 +7,7 @@ void OTRExporter_Skeleton::Save(ZResource* res, const fs::path& outPath, BinaryW { ZSkeleton* skel = (ZSkeleton*)res; - WriteHeader(res, outPath, writer, Ship::ResourceType::SOH_Skeleton); + WriteHeader(res, outPath, writer, LUS::ResourceType::SOH_Skeleton); writer->Write((uint8_t)skel->type); writer->Write((uint8_t)skel->limbType); @@ -15,15 +15,15 @@ void OTRExporter_Skeleton::Save(ZResource* res, const fs::path& outPath, BinaryW writer->Write((uint32_t)skel->limbCount); writer->Write((uint32_t)skel->dListCount); - writer->Write((uint8_t)skel->limbsTable.limbType); - writer->Write((uint32_t)skel->limbsTable.count); + writer->Write((uint8_t)skel->limbsTable->limbType); + writer->Write((uint32_t)skel->limbsTable->count); - for (size_t i = 0; i < skel->limbsTable.count; i++) + for (size_t i = 0; i < skel->limbsTable->count; i++) { - Declaration* skelDecl = skel->parent->GetDeclarationRanged(GETSEGOFFSET(skel->limbsTable.limbsAddresses[i])); + Declaration* skelDecl = skel->parent->GetDeclarationRanged(GETSEGOFFSET(skel->limbsTable->limbsAddresses[i])); std::string name; - bool foundDecl = Globals::Instance->GetSegmentedPtrName(skel->limbsTable.limbsAddresses[i], skel->parent, "", name, res->parent->workerID); + bool foundDecl = Globals::Instance->GetSegmentedPtrName(skel->limbsTable->limbsAddresses[i], skel->parent, "", name, res->parent->workerID); if (foundDecl) { if (name.at(0) == '&') diff --git a/OTRExporter/OTRExporter/SkeletonLimbExporter.cpp b/OTRExporter/OTRExporter/SkeletonLimbExporter.cpp index 9b8742538..1ee17c444 100644 --- a/OTRExporter/OTRExporter/SkeletonLimbExporter.cpp +++ b/OTRExporter/OTRExporter/SkeletonLimbExporter.cpp @@ -7,7 +7,7 @@ void OTRExporter_SkeletonLimb::Save(ZResource* res, const fs::path& outPath, Bin { ZLimb* limb = (ZLimb*)res; - WriteHeader(res, outPath, writer, Ship::ResourceType::SOH_SkeletonLimb); + WriteHeader(res, outPath, writer, LUS::ResourceType::SOH_SkeletonLimb); writer->Write((uint8_t)limb->type); writer->Write((uint8_t)limb->skinSegmentType); diff --git a/OTRExporter/OTRExporter/TextExporter.cpp b/OTRExporter/OTRExporter/TextExporter.cpp index 1e8c8da9d..2fcfe8251 100644 --- a/OTRExporter/OTRExporter/TextExporter.cpp +++ b/OTRExporter/OTRExporter/TextExporter.cpp @@ -5,7 +5,7 @@ void OTRExporter_Text::Save(ZResource* res, const fs::path& outPath, BinaryWrite { ZText* txt = (ZText*)res; - WriteHeader(txt, outPath, writer, Ship::ResourceType::SOH_Text); + WriteHeader(txt, outPath, writer, LUS::ResourceType::SOH_Text); writer->Write((uint32_t)txt->messages.size()); diff --git a/OTRExporter/OTRExporter/TextureExporter.cpp b/OTRExporter/OTRExporter/TextureExporter.cpp index fae445cf8..77cc20955 100644 --- a/OTRExporter/OTRExporter/TextureExporter.cpp +++ b/OTRExporter/OTRExporter/TextureExporter.cpp @@ -5,7 +5,7 @@ void OTRExporter_Texture::Save(ZResource* res, const fs::path& outPath, BinaryWr { ZTexture* tex = (ZTexture*)res; - WriteHeader(tex, outPath, writer, Ship::ResourceType::Texture); + WriteHeader(tex, outPath, writer, LUS::ResourceType::Texture); auto start = std::chrono::steady_clock::now(); diff --git a/OTRExporter/OTRExporter/VersionInfo.cpp b/OTRExporter/OTRExporter/VersionInfo.cpp index 145aa86b9..50910bc31 100644 --- a/OTRExporter/OTRExporter/VersionInfo.cpp +++ b/OTRExporter/OTRExporter/VersionInfo.cpp @@ -1,25 +1,25 @@ #include "VersionInfo.h" #include -std::map resourceVersions; +std::map resourceVersions; void InitVersionInfo() { - resourceVersions = std::map { - { Ship::ResourceType::SOH_Animation, 0 }, - { Ship::ResourceType::Texture, 0 }, - { Ship::ResourceType::SOH_PlayerAnimation, 0 }, - { Ship::ResourceType::DisplayList, 0 }, - { Ship::ResourceType::SOH_Room, 0 }, - { Ship::ResourceType::SOH_CollisionHeader, 0 }, - { Ship::ResourceType::SOH_Skeleton, 0 }, - { Ship::ResourceType::SOH_SkeletonLimb, 0 }, - { Ship::ResourceType::Matrix, 0 }, - { Ship::ResourceType::SOH_Path, 0 }, - { Ship::ResourceType::Vertex, 0 }, - { Ship::ResourceType::SOH_Cutscene, 0 }, - { Ship::ResourceType::Array, 0 }, - { Ship::ResourceType::SOH_Text, 0 }, - { Ship::ResourceType::Blob, 0 }, + resourceVersions = std::map { + { LUS::ResourceType::SOH_Animation, 0 }, + { LUS::ResourceType::Texture, 0 }, + { LUS::ResourceType::SOH_PlayerAnimation, 0 }, + { LUS::ResourceType::DisplayList, 0 }, + { LUS::ResourceType::SOH_Room, 0 }, + { LUS::ResourceType::SOH_CollisionHeader, 0 }, + { LUS::ResourceType::SOH_Skeleton, 0 }, + { LUS::ResourceType::SOH_SkeletonLimb, 0 }, + { LUS::ResourceType::Matrix, 0 }, + { LUS::ResourceType::SOH_Path, 0 }, + { LUS::ResourceType::Vertex, 0 }, + { LUS::ResourceType::SOH_Cutscene, 0 }, + { LUS::ResourceType::Array, 0 }, + { LUS::ResourceType::SOH_Text, 0 }, + { LUS::ResourceType::Blob, 0 }, }; } diff --git a/OTRExporter/OTRExporter/VersionInfo.h b/OTRExporter/OTRExporter/VersionInfo.h index 240fc032a..03f8417f2 100644 --- a/OTRExporter/OTRExporter/VersionInfo.h +++ b/OTRExporter/OTRExporter/VersionInfo.h @@ -4,6 +4,4 @@ #include #include "src/resource/Resource.h" -#define MAJOR_VERSION Ship::Version::Deckard - -extern std::map resourceVersions; \ No newline at end of file +extern std::map resourceVersions; \ No newline at end of file diff --git a/OTRExporter/OTRExporter/VtxExporter.cpp b/OTRExporter/OTRExporter/VtxExporter.cpp index 5d8001d24..009545d77 100644 --- a/OTRExporter/OTRExporter/VtxExporter.cpp +++ b/OTRExporter/OTRExporter/VtxExporter.cpp @@ -5,7 +5,7 @@ void OTRExporter_Vtx::SaveArr(ZResource* res, const fs::path& outPath, const std::vector& vec, BinaryWriter* writer) { - WriteHeader(res, outPath, writer, Ship::ResourceType::Vertex); + WriteHeader(res, outPath, writer, LUS::ResourceType::Vertex); for (auto& res: vec) { ZVtx* vtx = (ZVtx*)res; @@ -27,7 +27,7 @@ void OTRExporter_Vtx::Save(ZResource* res, const fs::path& outPath, BinaryWriter { ZVtx* vtx = (ZVtx*)res; - WriteHeader(res, outPath, writer, Ship::ResourceType::Vertex); + WriteHeader(res, outPath, writer, LUS::ResourceType::Vertex); writer->Write((uint32_t)1); //Yes I'm hard coding it to one, it *should* be fine. diff --git a/ZAPDTR/.gitrepo b/ZAPDTR/.gitrepo index 8b17360d1..bf9a6491f 100644 --- a/ZAPDTR/.gitrepo +++ b/ZAPDTR/.gitrepo @@ -4,9 +4,9 @@ ; git-subrepo command. See https://github.com/git-commands/git-subrepo#readme ; [subrepo] - remote = https://github.com/HarbourMasters/ZAPDTR.git + remote = https://github.com/harbourmasters/ZAPDTR branch = master - commit = e23b125d89bd973998d2eb00896bcbaf1b53a329 - parent = 17b1a8e7fd5517f9232e531da0fed6ef80a87f04 + commit = d4c35b90aed66eeed61066b4b76e488bfab52b4d + parent = 9d17e19a1dcf2b5c6cef0d3c93816f98a280eb58 method = rebase cmdver = 0.4.3 diff --git a/ZAPDTR/ExporterTest/CollisionExporter.cpp b/ZAPDTR/ExporterTest/CollisionExporter.cpp index 4ab8a62cd..c2167180d 100644 --- a/ZAPDTR/ExporterTest/CollisionExporter.cpp +++ b/ZAPDTR/ExporterTest/CollisionExporter.cpp @@ -50,17 +50,19 @@ void ExporterExample_Collision::Save(ZResource* res, [[maybe_unused]] const fs:: writer->Write(col->polygons[i].vtxA); writer->Write(col->polygons[i].vtxB); writer->Write(col->polygons[i].vtxC); - writer->Write(col->polygons[i].a); - writer->Write(col->polygons[i].b); - writer->Write(col->polygons[i].c); - writer->Write(col->polygons[i].d); + writer->Write(col->polygons[i].normX); + writer->Write(col->polygons[i].normY); + writer->Write(col->polygons[i].normZ); + writer->Write(col->polygons[i].dist); } writer->Seek(col->polyTypeDefSegmentOffset, SeekOffsetType::Start); - for (uint16_t i = 0; i < col->polygonTypes.size(); i++) - writer->Write(col->polygonTypes[i]); - + for (const auto& poly : col->polygonTypes) + { + writer->Write(poly.data[0]); + writer->Write(poly.data[1]); + } writer->Seek(col->camDataSegmentOffset, SeekOffsetType::Start); for (auto entry : col->camData->entries) diff --git a/ZAPDTR/ExporterTest/ExporterTest.vcxproj b/ZAPDTR/ExporterTest/ExporterTest.vcxproj index 839d45102..341f72ceb 100644 --- a/ZAPDTR/ExporterTest/ExporterTest.vcxproj +++ b/ZAPDTR/ExporterTest/ExporterTest.vcxproj @@ -1,160 +1,160 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - - 16.0 - Win32Proj - {65608eb0-1a47-45ad-ab66-192fb64c762c} - ExporterTest - 10.0 - ExporterExample - - - - Application - true - v142 - Unicode - - - Application - false - v142 - true - Unicode - - - StaticLibrary - true - v142 - Unicode - - - Application - false - v142 - true - Unicode - - - - - - - - - - - - - - - - - - - - - true - - - false - - - true - $(ProjectDir)..\ZAPD\;$(ProjectDir)..\ZAPDUtils;$(ProjectDir)..\lib\tinyxml2;$(ProjectDir)..\lib\libgfxd;$(ProjectDir)..\lib\elfio;$(ProjectDir)..\lib\stb;$(ProjectDir);$(IncludePath) - - - false - - - - Level3 - true - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - - - - - Level3 - true - true - true - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - true - true - - - - - Level3 - true - _DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) - true - stdcpp17 - stdc11 - MultiThreadedDebug - - - Console - true - - - - - Level3 - true - true - true - NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - true - true - - - - - - - - - - - - - - - - + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 16.0 + Win32Proj + {65608eb0-1a47-45ad-ab66-192fb64c762c} + ExporterTest + 10.0 + ExporterExample + + + + Application + true + v142 + Unicode + + + Application + false + v143 + true + Unicode + + + StaticLibrary + true + v142 + Unicode + + + Application + false + v143 + true + Unicode + + + + + + + + + + + + + + + + + + + + + true + + + false + + + true + $(ProjectDir)..\ZAPD\;$(ProjectDir)..\ZAPDUtils;$(ProjectDir)..\lib\tinyxml2;$(ProjectDir)..\lib\libgfxd;$(ProjectDir)..\lib\elfio;$(ProjectDir)..\lib\stb;$(ProjectDir);$(IncludePath) + + + false + + + + Level3 + true + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + + + + + Level3 + true + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + Level3 + true + _DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + true + stdcpp17 + stdc11 + MultiThreadedDebug + + + Console + true + + + + + Level3 + true + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ZAPDTR/ExporterTest/RoomExporter.cpp b/ZAPDTR/ExporterTest/RoomExporter.cpp index bc7ef3727..e77f26485 100644 --- a/ZAPDTR/ExporterTest/RoomExporter.cpp +++ b/ZAPDTR/ExporterTest/RoomExporter.cpp @@ -1,7 +1,7 @@ #include "RoomExporter.h" #include "CollisionExporter.h" #include "Utils/BinaryWriter.h" -#include "Utils/File.h" +#include #include "Utils/MemoryStream.h" #include "ZRoom/Commands/SetCameraSettings.h" #include "ZRoom/Commands/SetCollisionHeader.h" @@ -334,7 +334,7 @@ void ExporterExample_Room::Save(ZResource* res, const fs::path& outPath, BinaryW writer->Write(entry.rotX); writer->Write(entry.rotY); writer->Write(entry.rotZ); - writer->Write(entry.initVar); + writer->Write(entry.params); } writer->Seek(oldOffset, SeekOffsetType::Start); @@ -367,6 +367,6 @@ void ExporterExample_Room::Save(ZResource* res, const fs::path& outPath, BinaryW } // writer->Close(); - // File::WriteAllBytes(StringHelper::Sprintf("%s", res->GetName().c_str()), + // DiskFile::WriteAllBytes(StringHelper::Sprintf("%s", res->GetName().c_str()), // memStream->ToVector()); } diff --git a/ZAPDTR/Jenkinsfile b/ZAPDTR/Jenkinsfile deleted file mode 100644 index ec9b56ac5..000000000 --- a/ZAPDTR/Jenkinsfile +++ /dev/null @@ -1,97 +0,0 @@ -pipeline { - agent { - label 'ZAPD' - } - - stages { - // Non-parallel ZAPD stage - stage('Build ZAPD') { - steps { - sh 'make -j WERROR=1' - } - } - - // CHECKOUT THE REPOS - stage('Checkout Repos') { - parallel { - stage('Checkout oot') { - steps { - dir('oot') { - git url: 'https://github.com/zeldaret/oot.git' - } - } - } - - stage('Checkout mm') { - steps{ - dir('mm') { - git url: 'https://github.com/zeldaret/mm.git' - } - } - } - } - } - - // SETUP THE REPOS - stage('Set up repos') { - parallel { - stage('Setup OOT') { - steps { - dir('oot') { - sh 'cp /usr/local/etc/roms/baserom_oot.z64 baserom_original.z64' - - // Identical to `make setup` except for copying our newer ZAPD.out into oot - sh 'git submodule update --init --recursive' - sh 'make -C tools' - sh 'cp ../ZAPD.out tools/ZAPD/' - sh 'python3 fixbaserom.py' - sh 'python3 extract_baserom.py' - sh 'python3 extract_assets.py' - } - } - } - - stage('Setup MM') { - steps { - dir('mm') { - sh 'cp /usr/local/etc/roms/mm.us.rev1.z64 baserom.mm.us.rev1.z64' - - // Identical to `make setup` except for copying our newer ZAPD.out into mm - sh 'make -C tools' - sh 'cp ../ZAPD.out tools/ZAPD/' - sh 'python3 tools/fixbaserom.py' - sh 'python3 tools/extract_baserom.py' - sh 'python3 extract_assets.py -t$(nproc)' - } - } - } - } - } - - // BUILD THE REPOS - stage('Build repos') { - parallel { - stage('Build oot') { - steps { - dir('oot') { - sh 'make -j' - } - } - } - stage('Build mm') { - steps { - dir('mm') { - sh 'make -j disasm' - sh 'make -j all' - } - } - } - } - } - } - post { - always { - cleanWs() - } - } -} diff --git a/ZAPDTR/Makefile b/ZAPDTR/Makefile new file mode 100644 index 000000000..e725f94f8 --- /dev/null +++ b/ZAPDTR/Makefile @@ -0,0 +1,134 @@ +# use variables in submakes +export +OPTIMIZATION_ON ?= 1 +ASAN ?= 0 +DEPRECATION_ON ?= 1 +DEBUG ?= 0 +COPYCHECK_ARGS ?= +LLD ?= 0 +WERROR ?= 0 + +# Use clang++ if available, else use g++ +ifeq ($(shell command -v clang++ >/dev/null 2>&1; echo $$?),0) + CXX := clang++ +else + CXX := g++ +endif + +INC := -I ZAPD -I lib/libgfxd -I lib/tinyxml2 -I ZAPDUtils +CXXFLAGS := -fpic -std=c++17 -Wall -Wextra -fno-omit-frame-pointer +OPTFLAGS := + +ifneq ($(DEBUG),0) + OPTIMIZATION_ON = 0 + CXXFLAGS += -g3 -DDEVELOPMENT -D_DEBUG + COPYCHECK_ARGS += --devel + DEPRECATION_ON = 0 +endif + +ifneq ($(WERROR),0) + CXXFLAGS += -Werror +endif + +ifeq ($(OPTIMIZATION_ON),0) + OPTFLAGS := -O0 +else + OPTFLAGS := -O2 +endif + +ifneq ($(ASAN),0) + CXXFLAGS += -fsanitize=address -fsanitize=pointer-compare -fsanitize=pointer-subtract -fsanitize=undefined +endif +ifneq ($(DEPRECATION_ON),0) + CXXFLAGS += -DDEPRECATION_ON +endif +# CXXFLAGS += -DTEXTURE_DEBUG + +LDFLAGS := -lm -ldl -lpng + +# Use LLD if available. Set LLD=0 to not use it +ifeq ($(shell command -v ld.lld >/dev/null 2>&1; echo $$?),0) + LLD := 1 +endif + +ifneq ($(LLD),0) + LDFLAGS += -fuse-ld=lld +endif + +UNAME := $(shell uname) +UNAMEM := $(shell uname -m) +ifneq ($(UNAME), Darwin) + LDFLAGS += -Wl,-export-dynamic -lstdc++fs + EXPORTERS := -Wl,--whole-archive ExporterTest/ExporterTest.a -Wl,--no-whole-archive +else + EXPORTERS := -Wl,-force_load ExporterTest/ExporterTest.a + ifeq ($(UNAMEM),arm64) + ifeq ($(shell brew list libpng > /dev/null 2>&1; echo $$?),0) + LDFLAGS += -L $(shell brew --prefix)/lib + INC += -I $(shell brew --prefix)/include + else + $(error Please install libpng via Homebrew) + endif + endif +endif + + +ZAPD_SRC_DIRS := $(shell find ZAPD -type d) +SRC_DIRS = $(ZAPD_SRC_DIRS) lib/tinyxml2 + +ZAPD_CPP_FILES := $(foreach dir,$(ZAPD_SRC_DIRS),$(wildcard $(dir)/*.cpp)) +ZAPD_H_FILES := $(foreach dir,$(ZAPD_SRC_DIRS),$(wildcard $(dir)/*.h)) + +CPP_FILES += $(ZAPD_CPP_FILES) lib/tinyxml2/tinyxml2.cpp +O_FILES := $(foreach f,$(CPP_FILES:.cpp=.o),build/$f) +O_FILES += build/ZAPD/BuildInfo.o + +# create build directories +$(shell mkdir -p $(foreach dir,$(SRC_DIRS),build/$(dir))) + + +# Main targets +all: ZAPD.out copycheck + +build/ZAPD/BuildInfo.o: + python3 ZAPD/genbuildinfo.py $(COPYCHECK_ARGS) + $(CXX) $(CXXFLAGS) $(OPTFLAGS) $(INC) -c $(OUTPUT_OPTION) build/ZAPD/BuildInfo.cpp + +copycheck: ZAPD.out + python3 copycheck.py + +clean: + rm -rf build ZAPD.out + $(MAKE) -C lib/libgfxd clean + $(MAKE) -C ZAPDUtils clean + $(MAKE) -C ExporterTest clean + +rebuild: clean all + +format: + clang-format-11 -i $(ZAPD_CPP_FILES) $(ZAPD_H_FILES) + $(MAKE) -C ZAPDUtils format + $(MAKE) -C ExporterTest format + +.PHONY: all build/ZAPD/BuildInfo.o copycheck clean rebuild format + +build/%.o: %.cpp + $(CXX) $(CXXFLAGS) $(OPTFLAGS) $(INC) -c $(OUTPUT_OPTION) $< + + +# Submakes +lib/libgfxd/libgfxd.a: + $(MAKE) -C lib/libgfxd + +.PHONY: ExporterTest +ExporterTest: + $(MAKE) -C ExporterTest + +.PHONY: ZAPDUtils +ZAPDUtils: + $(MAKE) -C ZAPDUtils + + +# Linking +ZAPD.out: $(O_FILES) lib/libgfxd/libgfxd.a ExporterTest ZAPDUtils + $(CXX) $(CXXFLAGS) $(O_FILES) lib/libgfxd/libgfxd.a ZAPDUtils/ZAPDUtils.a $(EXPORTERS) $(LDFLAGS) $(OUTPUT_OPTION) diff --git a/ZAPDTR/README.md b/ZAPDTR/README.md index 448aea033..bb96bab1b 100644 --- a/ZAPDTR/README.md +++ b/ZAPDTR/README.md @@ -71,9 +71,6 @@ ZAPD needs a _File parsing mode_ to be passed as first parameter. The options ar - `blb`: "Build blob" mode. - In this mode, ZAPD expects a BIN file as input and a filename as ouput. - ZAPD will try to convert the given BIN into the contents of a `uint8_t` C array. -- `bovl`: "Build overlay" mode. - - In this mode, ZAPD expects an overlay C file as input, a filename as ouput and an overlay configuration path (`-cfg`). - - ZAPD will generate a reloc `.s` file. ZAPD also accepts the following list of extra parameters: @@ -102,8 +99,6 @@ ZAPD also accepts the following list of extra parameters: - `ia16` - `ci4` - `ci8` -- `-cfg PATH`: Set cfg path (for overlays). - - Can be used only in `bovl` mode. - `-rconf PATH` Read Config File. - `-eh`: Enable error handler. - Only available in non-Windows environments. diff --git a/ZAPDTR/ZAPD/CMakeLists.txt b/ZAPDTR/ZAPD/CMakeLists.txt index 0b0412c40..96c42d00c 100644 --- a/ZAPDTR/ZAPD/CMakeLists.txt +++ b/ZAPDTR/ZAPD/CMakeLists.txt @@ -17,6 +17,7 @@ set(Header_Files "ImageBackend.h" "OutputFormatter.h" "WarningHandler.h" + "CrashHandler.h" ) source_group("Header Files" FILES ${Header_Files}) @@ -27,22 +28,6 @@ set(Header_Files__Libraries ) source_group("Header Files\\Libraries" FILES ${Header_Files__Libraries}) -set(Header_Files__Libraries__elfio - "../lib/elfio/elfio/elf_types.hpp" - "../lib/elfio/elfio/elfio.hpp" - "../lib/elfio/elfio/elfio_dump.hpp" - "../lib/elfio/elfio/elfio_dynamic.hpp" - "../lib/elfio/elfio/elfio_header.hpp" - "../lib/elfio/elfio/elfio_note.hpp" - "../lib/elfio/elfio/elfio_relocation.hpp" - "../lib/elfio/elfio/elfio_section.hpp" - "../lib/elfio/elfio/elfio_segment.hpp" - "../lib/elfio/elfio/elfio_strings.hpp" - "../lib/elfio/elfio/elfio_symbols.hpp" - "../lib/elfio/elfio/elfio_utils.hpp" -) -source_group("Header Files\\Libraries\\elfio" FILES ${Header_Files__Libraries__elfio}) - set(Header_Files__Libraries__libgfxd "../lib/libgfxd/gbi.h" "../lib/libgfxd/gfxd.h" @@ -58,15 +43,17 @@ source_group("Header Files\\Yaz0" FILES ${Header_Files__Yaz0}) set(Header_Files__Z64 "OtherStructs/SkinLimbStructs.h" - "Overlays/ZOverlay.h" + "OtherStructs/CutsceneMM_Commands.h" + "OtherStructs/Cutscene_Commands.h" "ZAnimation.h" + "ZActorList.h" "ZArray.h" "ZAudio.h" "ZBackground.h" "ZBlob.h" "ZCollision.h" + "ZCollisionPoly.h" "ZCutscene.h" - "ZCutsceneMM.h" "ZDisplayList.h" "ZFile.h" "ZLimb.h" @@ -77,6 +64,7 @@ set(Header_Files__Z64 "ZRom.h" "ZScalar.h" "ZSkeleton.h" + "ZSurfaceType.h" "ZString.h" "ZSymbol.h" "ZText.h" @@ -136,6 +124,7 @@ set(Resource_Files source_group("Resource Files" FILES ${Resource_Files}) set(Source_Files + "CrashHandler.cpp" "Declaration.cpp" "FileWorker.cpp" "GameConfig.cpp" @@ -165,16 +154,18 @@ source_group("Source Files\\Yaz0" FILES ${Source_Files__Yaz0}) set(Source_Files__Z64 "OtherStructs/SkinLimbStructs.cpp" - "Overlays/ZOverlay.cpp" + "OtherStructs/CutsceneMM_Commands.cpp" + "OtherStructs/Cutscene_Commands.cpp" "ZAnimation.cpp" + "ZActorList.cpp" "ZArray.cpp" "ZAudio.cpp" "ZAudioDecode.cpp" "ZBackground.cpp" "ZBlob.cpp" "ZCollision.cpp" + "ZCollisionPoly.cpp" "ZCutscene.cpp" - "ZCutsceneMM.cpp" "ZDisplayList.cpp" "ZFile.cpp" "ZLimb.cpp" @@ -185,6 +176,7 @@ set(Source_Files__Z64 "ZRom.cpp" "ZScalar.cpp" "ZSkeleton.cpp" + "ZSurfaceType.cpp" "ZString.cpp" "ZSymbol.cpp" "ZText.cpp" @@ -241,7 +233,6 @@ source_group("Source Files\\Z64\\ZRoom\\Commands" FILES ${Source_Files__Z64__ZRo set(ALL_FILES ${Header_Files} ${Header_Files__Libraries} - ${Header_Files__Libraries__elfio} ${Header_Files__Libraries__libgfxd} ${Header_Files__Yaz0} ${Header_Files__Z64} diff --git a/ZAPDTR/ZAPD/CrashHandler.cpp b/ZAPDTR/ZAPD/CrashHandler.cpp new file mode 100644 index 000000000..356866536 --- /dev/null +++ b/ZAPDTR/ZAPD/CrashHandler.cpp @@ -0,0 +1,205 @@ +#include "CrashHandler.h" +#include "Utils/StringHelper.h" + +#if __has_include() +#define HAS_POSIX 1 +#else +#define HAS_POSIX 0 +#endif + +#include +#include +#include +#include + +#if HAS_POSIX == 1 +#include +#include // for __cxa_demangle +#include // for dladdr +#include +#include +#elif defined(_MSC_VER) +#include +#include + +#include + +#pragma comment(lib, "Dbghelp.lib") +#endif + +// Feel free to add more crash messages. +static std::array crashEasterEgg = { + "\tYou've met with a terrible fate, haven't you?", + "\tSEA BEARS FOAM. SLEEP BEARS DREAMS. \n\tBOTH END IN THE SAME WAY: CRASSSH!", + "\tZAPD has fallen and cannot get up.", + "\tIT'S A SECRET TO EVERYBODY. \n\tBut it shouldn't be, you'd better ask about it!", + "\tI AM ERROR.", + "\tGRUMBLE,GRUMBLE...", + "\tDODONGO DISLIKES SMOKE \n\tAnd ZAPD dislikes whatever you fed it.", + "\tMay the way of the Hero lead \n\tto the debugger.", + "\tTHE WIND FISH SLUMBERS LONG... \n\tTHE HERO'S LIFE GONE... ", + "\tSEA BEARS FOAM, SLEEP BEARS DREAMS. \n\tBOTH END IN THE SAME WAY CRASSSH!", + "\tYou've met with a terrible fate, haven't you?", + "\tMaster, I calculate a 100% probability that ZAPD has crashed. \n\tAdditionally, the " + "batteries in your Wii Remote are nearly depleted.", + "\t CONGRATURATIONS! \n" + "\tAll Pages are displayed.\n" + "\t THANK YOU! \n" + "\t You are great debugger!", + "\tRCP is HUNG UP!!\n" + "\tOh! MY GOD!!", +}; + +#if HAS_POSIX == 1 +void ErrorHandler(int sig) +{ + std::array arr; + constexpr size_t nMaxFrames = arr.size(); + size_t size = backtrace(arr.data(), nMaxFrames); + char** symbols = backtrace_symbols(arr.data(), nMaxFrames); + + fprintf(stderr, "\nZAPD crashed. (Signal: %i)\n", sig); + + srand(time(nullptr)); + auto easterIndex = rand() % crashEasterEgg.size(); + + fprintf(stderr, "\n%s\n\n", crashEasterEgg[easterIndex]); + + fprintf(stderr, "Traceback:\n"); + for (size_t i = 1; i < size; i++) + { + Dl_info info; + uint32_t gotAddress = dladdr(arr[i], &info); + std::string functionName(symbols[i]); + + if (gotAddress != 0 && info.dli_sname != nullptr) + { + int32_t status; + char* demangled = abi::__cxa_demangle(info.dli_sname, nullptr, nullptr, &status); + const char* nameFound = info.dli_sname; + + if (status == 0) + { + nameFound = demangled; + } + + functionName = StringHelper::Sprintf("%s (+0x%X)", nameFound, + (char*)arr[i] - (char*)info.dli_saddr); + free(demangled); + } + + fprintf(stderr, "%-3zd %s\n", i, functionName.c_str()); + } + + fprintf(stderr, "\n"); + + free(symbols); + exit(1); +} +#elif defined(_MSC_VER) + +void printStack(CONTEXT* ctx) +{ + BOOL result; + HANDLE process; + HANDLE thread; + HMODULE hModule; + ULONG frame; + DWORD64 displacement; + DWORD disp; + + srand(time(nullptr)); + auto easterIndex = rand() % crashEasterEgg.size(); + + fprintf(stderr, "\n%s\n\n", crashEasterEgg[easterIndex]); + +#if defined(_M_AMD64) + STACKFRAME64 stack; + memset(&stack, 0, sizeof(STACKFRAME64)); +#else + STACKFRAME stack; + memset(&stack, 0, sizeof(STACKFRAME)); +#endif + + char buffer[sizeof(SYMBOL_INFO) + MAX_SYM_NAME + sizeof(TCHAR)]; + char module[512]; + + PSYMBOL_INFO symbol = (PSYMBOL_INFO)buffer; + + CONTEXT ctx2; + memcpy(&ctx2, ctx, sizeof(CONTEXT)); + + process = GetCurrentProcess(); + thread = GetCurrentThread(); + SymInitialize(process, nullptr, TRUE); + + constexpr DWORD machineType = +#if defined(_M_AMD64) + IMAGE_FILE_MACHINE_AMD64; +#else + IMAGE_FILE_MACHINE_I386; +#endif + + displacement = 0; + + for (frame = 0;; frame++) + { + result = StackWalk(machineType, process, thread, &stack, &ctx2, nullptr, + SymFunctionTableAccess, SymGetModuleBase, nullptr); + if (!result) + { + break; + } + symbol->SizeOfStruct = sizeof(SYMBOL_INFO); + symbol->MaxNameLen = MAX_SYM_NAME; + SymFromAddr(process, (ULONG64)stack.AddrPC.Offset, &displacement, symbol); +#if defined(_M_AMD64) + IMAGEHLP_LINE64 line; + line.SizeOfStruct = sizeof(IMAGEHLP_LINE64); +#else + IMAGEHLP_LINE line; + line.SizeOfStruct = sizeof(IMAGEHLP_LINE); +#endif + if (SymGetLineFromAddr(process, stack.AddrPC.Offset, &disp, &line)) + { + fprintf(stderr, "%u\t %s in %s: line: %lu: \n", frame, symbol->Name, line.FileName, + line.LineNumber); + } + + else + { + fprintf(stderr, "%u\tat % s\n", frame, symbol->Name); + hModule = nullptr; + GetModuleHandleEx(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | + GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, + (LPCTSTR)(stack.AddrPC.Offset), &hModule); + + if (hModule != nullptr) + { + GetModuleFileNameA(hModule, module, 512 - 1); + } + fprintf(stderr, "%u\tIn %s\n", frame, module); + } + } +} + +LONG seh_filter(_EXCEPTION_POINTERS* ex) +{ + fprintf(stderr, "EXCEPTION 0x%x occured\n", ex->ExceptionRecord->ExceptionCode); + printStack(ex->ContextRecord); + return EXCEPTION_EXECUTE_HANDLER; +} +#endif + +void CrashHandler_Init() +{ +#if HAS_POSIX == 1 + signal(SIGSEGV, ErrorHandler); + signal(SIGABRT, ErrorHandler); +#elif defined(_MSC_VER) + SetUnhandledExceptionFilter(seh_filter); +#else + HANDLE_WARNING(WarningType::Always, + "tried to set error handler, but this ZAPD build lacks support for one", ""); +#endif +} diff --git a/ZAPDTR/ZAPD/CrashHandler.h b/ZAPDTR/ZAPD/CrashHandler.h new file mode 100644 index 000000000..102778bec --- /dev/null +++ b/ZAPDTR/ZAPD/CrashHandler.h @@ -0,0 +1,6 @@ +#ifndef CRASH_HANDLER_H +#define CRASH_HANDLER_H + +void CrashHandler_Init(); + +#endif diff --git a/ZAPDTR/ZAPD/Declaration.cpp b/ZAPDTR/ZAPD/Declaration.cpp index 27494b866..3f0c0ad93 100644 --- a/ZAPDTR/ZAPD/Declaration.cpp +++ b/ZAPDTR/ZAPD/Declaration.cpp @@ -178,7 +178,7 @@ std::string Declaration::GetExternalDeclarationStr() const std::string Declaration::GetExternStr() const { - if (IsStatic() || varType == "") + if (IsStatic() || varType == "" || isUnaccounted) { return ""; } diff --git a/ZAPDTR/ZAPD/Declaration.h b/ZAPDTR/ZAPD/Declaration.h index 45d36f49e..64712d8c3 100644 --- a/ZAPDTR/ZAPD/Declaration.h +++ b/ZAPDTR/ZAPD/Declaration.h @@ -2,6 +2,7 @@ #include #include +#include // TODO: should we drop the `_t` suffix because of UNIX compliance? typedef uint32_t segptr_t; diff --git a/ZAPDTR/ZAPD/GameConfig.cpp b/ZAPDTR/ZAPD/GameConfig.cpp index ae29ba28f..9a2e8898c 100644 --- a/ZAPDTR/ZAPD/GameConfig.cpp +++ b/ZAPDTR/ZAPD/GameConfig.cpp @@ -2,9 +2,10 @@ #include #include +#include #include "Utils/Directory.h" -#include "Utils/File.h" +#include #include "Utils/Path.h" #include "ZFile.h" #include "tinyxml2.h" @@ -56,7 +57,7 @@ void GameConfig::ReadTexturePool(const fs::path& texturePoolXmlPath) void GameConfig::GenSymbolMap(const fs::path& symbolMapPath) { - auto symbolLines = File::ReadAllLines(symbolMapPath); + auto symbolLines = DiskFile::ReadAllLines(symbolMapPath); for (std::string& symbolLine : symbolLines) { @@ -78,7 +79,7 @@ void GameConfig::ConfigFunc_ActorList(const tinyxml2::XMLElement& element) { std::string fileName = element.Attribute("File"); std::vector lines = - File::ReadAllLines(Path::GetDirectoryName(configFilePath) / fileName); + DiskFile::ReadAllLines(Path::GetDirectoryName(configFilePath) / fileName); for (auto& line : lines) actorList.emplace_back(std::move(line)); @@ -88,12 +89,32 @@ void GameConfig::ConfigFunc_ObjectList(const tinyxml2::XMLElement& element) { std::string fileName = element.Attribute("File"); std::vector lines = - File::ReadAllLines(Path::GetDirectoryName(configFilePath) / fileName); + DiskFile::ReadAllLines(Path::GetDirectoryName(configFilePath) / fileName); for (auto& line : lines) objectList.emplace_back(std::move(line)); } +void GameConfig::ConfigFunc_EntranceList(const tinyxml2::XMLElement& element) +{ + std::string fileName = element.Attribute("File"); + std::vector lines = + DiskFile::ReadAllLines(Path::GetDirectoryName(configFilePath) / fileName); + + for (auto& line : lines) + entranceList.emplace_back(std::move(line)); +} + +void GameConfig::ConfigFunc_specialEntranceList(const tinyxml2::XMLElement& element) +{ + std::string fileName = element.Attribute("File"); + std::vector lines = + DiskFile::ReadAllLines(Path::GetDirectoryName(configFilePath) / fileName); + + for (auto& line : lines) + specialEntranceList.emplace_back(std::move(line)); +} + void GameConfig::ConfigFunc_TexturePool(const tinyxml2::XMLElement& element) { std::string fileName = element.Attribute("File"); @@ -145,10 +166,12 @@ void GameConfig::ConfigFunc_ExternalFile(const tinyxml2::XMLElement& element) void GameConfig::ReadConfigFile(const fs::path& argConfigFilePath) { - static const std::map ConfigFuncDictionary = { + static const std::unordered_map ConfigFuncDictionary = { {"SymbolMap", &GameConfig::ConfigFunc_SymbolMap}, {"ActorList", &GameConfig::ConfigFunc_ActorList}, {"ObjectList", &GameConfig::ConfigFunc_ObjectList}, + {"EntranceList", &GameConfig::ConfigFunc_EntranceList}, + {"SpecialEntranceList", &GameConfig::ConfigFunc_specialEntranceList}, {"TexturePool", &GameConfig::ConfigFunc_TexturePool}, {"BGConfig", &GameConfig::ConfigFunc_BGConfig}, {"ExternalXMLFolder", &GameConfig::ConfigFunc_ExternalXMLFolder}, diff --git a/ZAPDTR/ZAPD/GameConfig.h b/ZAPDTR/ZAPD/GameConfig.h index c478d16ce..2a783d10a 100644 --- a/ZAPDTR/ZAPD/GameConfig.h +++ b/ZAPDTR/ZAPD/GameConfig.h @@ -31,6 +31,8 @@ public: std::map symbolMap; std::vector actorList; std::vector objectList; + std::vector entranceList; + std::vector specialEntranceList; std::map texturePool; // Key = CRC // ZBackground @@ -49,6 +51,8 @@ public: void ConfigFunc_SymbolMap(const tinyxml2::XMLElement& element); void ConfigFunc_ActorList(const tinyxml2::XMLElement& element); void ConfigFunc_ObjectList(const tinyxml2::XMLElement& element); + void ConfigFunc_EntranceList(const tinyxml2::XMLElement& element); + void ConfigFunc_specialEntranceList(const tinyxml2::XMLElement& element); void ConfigFunc_TexturePool(const tinyxml2::XMLElement& element); void ConfigFunc_BGConfig(const tinyxml2::XMLElement& element); void ConfigFunc_ExternalXMLFolder(const tinyxml2::XMLElement& element); diff --git a/ZAPDTR/ZAPD/Globals.cpp b/ZAPDTR/ZAPD/Globals.cpp index 8443e4d07..a6b22cfa2 100644 --- a/ZAPDTR/ZAPD/Globals.cpp +++ b/ZAPDTR/ZAPD/Globals.cpp @@ -3,7 +3,7 @@ #include #include -#include "Utils/File.h" +#include #include "Utils/Path.h" #include "WarningHandler.h" #include "tinyxml2.h" @@ -134,12 +134,12 @@ void Globals::BuildAssetTexture(const fs::path& pngFilePath, TextureType texType tex.FromPNG(pngFilePath.string(), texType); std::string cfgPath = StringHelper::Split(pngFilePath.string(), ".")[0] + ".cfg"; - if (File::Exists(cfgPath)) - name = File::ReadAllText(cfgPath); + if (DiskFile::Exists(cfgPath)) + name = DiskFile::ReadAllText(cfgPath); std::string src = tex.GetBodySourceCode(); - File::WriteAllBytes(outPath.string(), src.c_str(), src.size()); + DiskFile::WriteAllBytes(outPath.string(), src.c_str(), src.size()); } std::map& Globals::GetExporterMap() @@ -186,7 +186,7 @@ std::vector Globals::GetBaseromFile(std::string fileName) } else - return File::ReadAllBytes(fileName); + return DiskFile::ReadAllBytes(fileName); } bool Globals::GetSegmentedPtrName(segptr_t segAddress, ZFile* currentFile, diff --git a/ZAPDTR/ZAPD/ImageBackend.cpp b/ZAPDTR/ZAPD/ImageBackend.cpp index 2e6beca5d..7ebb29121 100644 --- a/ZAPDTR/ZAPD/ImageBackend.cpp +++ b/ZAPDTR/ZAPD/ImageBackend.cpp @@ -398,7 +398,7 @@ void ImageBackend::SetPaletteIndex(size_t index, uint8_t nR, uint8_t nG, uint8_t alphaPalette[index] = nA; } -void ImageBackend::SetPalette(const ImageBackend& pal) +void ImageBackend::SetPalette(const ImageBackend& pal, uint32_t offset) { assert(isColorIndexed); size_t bytePerPixel = pal.GetBytesPerPixel(); @@ -422,7 +422,7 @@ void ImageBackend::SetPalette(const ImageBackend& pal) uint8_t g = pal.pixelMatrix[y][x * bytePerPixel + 1]; uint8_t b = pal.pixelMatrix[y][x * bytePerPixel + 2]; uint8_t a = pal.pixelMatrix[y][x * bytePerPixel + 3]; - SetPaletteIndex(index, r, g, b, a); + SetPaletteIndex(index + offset, r, g, b, a); } } } diff --git a/ZAPDTR/ZAPD/ImageBackend.h b/ZAPDTR/ZAPD/ImageBackend.h index 9e05a2eed..0b1f4806c 100644 --- a/ZAPDTR/ZAPD/ImageBackend.h +++ b/ZAPDTR/ZAPD/ImageBackend.h @@ -42,8 +42,9 @@ public: void SetGrayscalePixel(size_t y, size_t x, uint8_t grayscale, uint8_t alpha = 0); void SetIndexedPixel(size_t y, size_t x, uint8_t index, uint8_t grayscale); + void SetIndexedPixel(size_t y, size_t x, uint8_t index, RGBAPixel pixel); void SetPaletteIndex(size_t index, uint8_t nR, uint8_t nG, uint8_t nB, uint8_t nA); - void SetPalette(const ImageBackend& pal); + void SetPalette(const ImageBackend& pal, uint32_t offset = 0); uint32_t GetWidth() const; uint32_t GetHeight() const; diff --git a/ZAPDTR/ZAPD/Main.cpp b/ZAPDTR/ZAPD/Main.cpp index 486813f1e..a2030aaa4 100644 --- a/ZAPDTR/ZAPD/Main.cpp +++ b/ZAPDTR/ZAPD/Main.cpp @@ -1,7 +1,6 @@ #include "Globals.h" -#include "Overlays/ZOverlay.h" #include "Utils/Directory.h" -#include "Utils/File.h" +#include #include "Utils/Path.h" #include "WarningHandler.h" @@ -72,15 +71,7 @@ ZRoom room(nullptr); #include "ZFile.h" #include "ZTexture.h" -#ifdef __linux__ -#include -#include -#include -#include // for __cxa_demangle -#include // for dladdr -#include -#include -#endif +#include "CrashHandler.h" #include #include @@ -90,8 +81,6 @@ ZRoom room(nullptr); //extern const char gBuildHash[]; const char gBuildHash[] = ""; -// LINUX_TODO: remove, those are because of soh <-> lus dependency problems - bool Parse(const fs::path& xmlFilePath, const fs::path& basePath, const fs::path& outPath, ZFileMode fileMode, int workerID); @@ -102,62 +91,6 @@ int ExtractFunc(int workerID, int fileListSize, std::string fileListItem, ZFileM volatile int numWorkersLeft = 0; -#ifdef __linux__ -#define ARRAY_COUNT(arr) (sizeof(arr) / sizeof(arr[0])) -void ErrorHandler(int sig) -{ - void* array[4096]; - const size_t nMaxFrames = sizeof(array) / sizeof(array[0]); - size_t size = backtrace(array, nMaxFrames); - char** symbols = backtrace_symbols(array, nMaxFrames); - - fprintf(stderr, "\nZAPD crashed. (Signal: %i)\n", sig); - - // Feel free to add more crash messages. - const char* crashEasterEgg[] = { - "\tYou've met with a terrible fate, haven't you?", - "\tSEA BEARS FOAM. SLEEP BEARS DREAMS. \n\tBOTH END IN THE SAME WAY: CRASSSH!", - "\tZAPD has fallen and cannot get up.", - }; - - srand(time(nullptr)); - auto easterIndex = rand() % ARRAY_COUNT(crashEasterEgg); - - fprintf(stderr, "\n%s\n\n", crashEasterEgg[easterIndex]); - - fprintf(stderr, "Traceback:\n"); - for (size_t i = 1; i < size; i++) - { - Dl_info info; - uint32_t gotAddress = dladdr(array[i], &info); - std::string functionName(symbols[i]); - - if (gotAddress != 0 && info.dli_sname != nullptr) - { - int32_t status; - char* demangled = abi::__cxa_demangle(info.dli_sname, nullptr, nullptr, &status); - const char* nameFound = info.dli_sname; - - if (status == 0) - { - nameFound = demangled; - } - - functionName = StringHelper::Sprintf("%s (+0x%X)", nameFound, - (char*)array[i] - (char*)info.dli_saddr); - free(demangled); - } - - fprintf(stderr, "%-3zd %s\n", i, functionName.c_str()); - } - - fprintf(stderr, "\n"); - - free(symbols); - exit(1); -} -#endif - extern void ImportExporters(); extern "C" int zapd_main(int argc, char* argv[]) @@ -246,12 +179,6 @@ extern "C" int zapd_main(int argc, char* argv[]) { Globals::Instance->texType = ZTexture::GetTextureTypeFromString(argv[++i]); } - else if (arg == "-cfg") // Set cfg path (for overlays) - // TODO: Change the name of this to something else so it doesn't - // get confused with XML config files. - { - Globals::Instance->cfgPath = argv[++i]; - } else if (arg == "-fl") // Set baserom filelist path { Globals::Instance->fileListPath = argv[++i]; @@ -262,16 +189,7 @@ extern "C" int zapd_main(int argc, char* argv[]) } else if (arg == "-eh") // Enable Error Handler { -#ifdef __linux__ - signal(SIGSEGV, ErrorHandler); - signal(SIGABRT, ErrorHandler); -#else - // HANDLE_WARNING(WarningType::Always, - // "tried to set error handler, but this ZAPD build lacks support for one", - // ""); -#endif - - + CrashHandler_Init(); } else if (arg == "-v") // Verbose { @@ -326,8 +244,6 @@ extern "C" int zapd_main(int argc, char* argv[]) fileMode = ZFileMode::BuildTexture; else if (buildMode == "bren") fileMode = ZFileMode::BuildBackground; - else if (buildMode == "bovl") - fileMode = ZFileMode::BuildOverlay; else if (buildMode == "bsf") fileMode = ZFileMode::BuildSourceFile; else if (buildMode == "bblb") @@ -662,7 +578,7 @@ void BuildAssetBackground(const fs::path& imageFilePath, const fs::path& outPath ZBackground background(nullptr); background.ParseBinaryFile(imageFilePath.string(), false); - File::WriteAllText(outPath.string(), background.GetBodySourceCode()); + DiskFile::WriteAllText(outPath.string(), background.GetBodySourceCode()); } void BuildAssetBlob(const fs::path& blobFilePath, const fs::path& outPath) @@ -672,7 +588,7 @@ void BuildAssetBlob(const fs::path& blobFilePath, const fs::path& outPath) std::string src = blob->GetBodySourceCode(); - File::WriteAllText(outPath.string(), src); + DiskFile::WriteAllText(outPath.string(), src); delete blob; } diff --git a/ZAPDTR/ZAPD/OtherStructs/CutsceneMM_Commands.cpp b/ZAPDTR/ZAPD/OtherStructs/CutsceneMM_Commands.cpp new file mode 100644 index 000000000..edefbc051 --- /dev/null +++ b/ZAPDTR/ZAPD/OtherStructs/CutsceneMM_Commands.cpp @@ -0,0 +1,213 @@ +#include "CutsceneMM_Commands.h" + +#include +#include + +#include "Utils/BitConverter.h" +#include "Utils/StringHelper.h" + +// Specific for command lists where each entry has size 8 bytes +const std::unordered_map csCommandsDescMM = { + {CutsceneMMCommands::CS_CMD_MISC, {"CS_MISC", "(0x%02X, %i, %i, %i)"}}, + {CutsceneMMCommands::CS_CMD_SET_LIGHTING, {"CS_LIGHTING", "(0x%02X, %i, %i)"}}, + {CutsceneMMCommands::CS_CMD_SCENE_TRANS_FX, {"CS_SCENE_TRANS_FX", "(%i, %i, %i)"}}, + {CutsceneMMCommands::CS_CMD_MOTIONBLUR, {"CS_MOTIONBLUR", "(%i, %i, %i)"}}, + {CutsceneMMCommands::CS_CMD_GIVETATL, {"CS_GIVETATL", "(%i, %i, %i)"}}, + {CutsceneMMCommands::CS_CMD_PLAYSEQ, {"CS_PLAYSEQ", "(0x%04X, %i, %i)"}}, + {CutsceneMMCommands::CS_CMD_130, {"CS_SCENE_UNK_130", "(0x%04X, %i, %i, %i)"}}, + {CutsceneMMCommands::CS_CMD_131, {"CS_SCENE_UNK_131", "(0x%04X, %i, %i, %i)"}}, + {CutsceneMMCommands::CS_CMD_132, {"CS_SCENE_UNK_132", "(%i, %i, %i)"}}, + {CutsceneMMCommands::CS_CMD_STOPSEQ, {"CS_STOPSEQ", "(0x%04X, %i, %i, %i)"}}, + {CutsceneMMCommands::CS_CMD_PLAYAMBIENCE, {"CS_PLAYAMBIENCE", "(0x%04X, %i, %i, %i)"}}, + {CutsceneMMCommands::CS_CMD_FADEAMBIENCE, {"CS_FADEAMBIENCE", "(0x%04X, %i, %i, %i)"}}, + {CutsceneMMCommands::CS_CMD_TERMINATOR, {"CS_TERMINATOR", "(%i, %i, %i)"}}, + {CutsceneMMCommands::CS_CMD_CHOOSE_CREDITS_SCENES, + {"CS_CHOOSE_CREDITS_SCENES", "(%i, %i, %i)"}}, +}; + +CutsceneSubCommandEntry_GenericMMCmd::CutsceneSubCommandEntry_GenericMMCmd( + const std::vector& rawData, offset_t rawDataIndex, CutsceneMMCommands cmdId) + : CutsceneSubCommandEntry(rawData, rawDataIndex), commandId(cmdId) +{ +} + +std::string CutsceneSubCommandEntry_GenericMMCmd::GetBodySourceCode() const +{ + const auto& element = csCommandsDescMM.find(commandId); + std::string entryFmt = "CS_UNK_DATA(0x%02X, %i, %i, %i)"; + + if (element != csCommandsDescMM.end()) + { + entryFmt = element->second.cmdMacro; + entryFmt += element->second.args; + } + + return StringHelper::Sprintf(entryFmt.c_str(), base, startFrame, endFrame, pad); +} + +CutsceneMMCommand_GenericCmd::CutsceneMMCommand_GenericCmd(const std::vector& rawData, + offset_t rawDataIndex, + CutsceneMMCommands cmdId) + : CutsceneCommand(rawData, rawDataIndex) +{ + rawDataIndex += 4; + + commandID = static_cast(cmdId); + + entries.reserve(numEntries); + for (size_t i = 0; i < numEntries; i++) + { + auto* entry = new CutsceneSubCommandEntry_GenericMMCmd(rawData, rawDataIndex, cmdId); + entries.push_back(entry); + rawDataIndex += entry->GetRawSize(); + } +} + +std::string CutsceneMMCommand_GenericCmd::GetCommandMacro() const +{ + const auto& element = csCommandsDescMM.find(static_cast(commandID)); + + if (element != csCommandsDescMM.end()) + { + return StringHelper::Sprintf("%s_LIST(%i)", element->second.cmdMacro, numEntries); + } + + return StringHelper::Sprintf("CS_UNK_DATA_LIST(0x%X, %i)", commandID, numEntries); +} + +CutsceneSubCommandEntry_Camera::CutsceneSubCommandEntry_Camera(const std::vector& rawData, + offset_t rawDataIndex) + : CutsceneSubCommandEntry(rawData, rawDataIndex) +{ +} + +std::string CutsceneSubCommandEntry_Camera::GetBodySourceCode() const +{ + return StringHelper::Sprintf("CMD_HH(0x%04X, 0x%04X)", base, startFrame); +} + +size_t CutsceneSubCommandEntry_Camera::GetRawSize() const +{ + return 0x04; +} + +CutsceneMMCommand_Camera::CutsceneMMCommand_Camera(const std::vector& rawData, + offset_t rawDataIndex) + : CutsceneCommand(rawData, rawDataIndex) +{ + rawDataIndex += 4; + + entries.reserve(numEntries); + for (size_t i = 0; i < numEntries / 4; i++) + { + auto* entry = new CutsceneSubCommandEntry_Camera(rawData, rawDataIndex); + entries.push_back(entry); + rawDataIndex += entry->GetRawSize(); + } +} + +std::string CutsceneMMCommand_Camera::GetCommandMacro() const +{ + return StringHelper::Sprintf("CS_CAMERA_LIST(%i)", numEntries); +} + +CutsceneSubCommandEntry_FadeScreen::CutsceneSubCommandEntry_FadeScreen( + const std::vector& rawData, offset_t rawDataIndex) + : CutsceneSubCommandEntry(rawData, rawDataIndex) +{ + unk_06 = BitConverter::ToUInt8BE(rawData, rawDataIndex + 0x06); + unk_07 = BitConverter::ToUInt8BE(rawData, rawDataIndex + 0x07); + unk_08 = BitConverter::ToUInt8BE(rawData, rawDataIndex + 0x08); + unk_09 = BitConverter::ToUInt8BE(rawData, rawDataIndex + 0x09); + unk_0A = BitConverter::ToUInt8BE(rawData, rawDataIndex + 0x0A); + unk_0B = BitConverter::ToUInt8BE(rawData, rawDataIndex + 0x0B); +} + +std::string CutsceneSubCommandEntry_FadeScreen::GetBodySourceCode() const +{ + return StringHelper::Sprintf("CS_FADESCREEN(0x%02X, %i, %i, %i, %i, %i)", base, startFrame, + endFrame, unk_06, unk_07, unk_08); +} + +size_t CutsceneSubCommandEntry_FadeScreen::GetRawSize() const +{ + return 0x0C; +} + +CutsceneMMCommand_FadeScreen::CutsceneMMCommand_FadeScreen(const std::vector& rawData, + offset_t rawDataIndex) + : CutsceneCommand(rawData, rawDataIndex) +{ + rawDataIndex += 4; + + entries.reserve(numEntries); + for (size_t i = 0; i < numEntries; i++) + { + auto* entry = new CutsceneSubCommandEntry_FadeScreen(rawData, rawDataIndex); + entries.push_back(entry); + rawDataIndex += entry->GetRawSize(); + } +} + +std::string CutsceneMMCommand_FadeScreen::GetCommandMacro() const +{ + return StringHelper::Sprintf("CS_FADESCREEN_LIST(%i)", numEntries); +} + +CutsceneSubCommandEntry_FadeSeq::CutsceneSubCommandEntry_FadeSeq( + const std::vector& rawData, offset_t rawDataIndex) + : CutsceneSubCommandEntry(rawData, rawDataIndex) +{ + unk_08 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 8); +} + +std::string CutsceneSubCommandEntry_FadeSeq::GetBodySourceCode() const +{ + return StringHelper::Sprintf("CS_FADESEQ(%i, %i, %i)", base, startFrame, endFrame); +} + +size_t CutsceneSubCommandEntry_FadeSeq::GetRawSize() const +{ + return 0x0C; +} + +CutsceneMMCommand_FadeSeq::CutsceneMMCommand_FadeSeq(const std::vector& rawData, + offset_t rawDataIndex) + : CutsceneCommand(rawData, rawDataIndex) +{ + rawDataIndex += 4; + + entries.reserve(numEntries); + for (size_t i = 0; i < numEntries; i++) + { + auto* entry = new CutsceneSubCommandEntry_FadeSeq(rawData, rawDataIndex); + entries.push_back(entry); + rawDataIndex += entry->GetRawSize(); + } +} + +std::string CutsceneMMCommand_FadeSeq::GetCommandMacro() const +{ + return StringHelper::Sprintf("CS_FADESEQ_LIST(%i)", numEntries); +} + +CutsceneSubCommandEntry_NonImplemented::CutsceneSubCommandEntry_NonImplemented( + const std::vector& rawData, offset_t rawDataIndex) + : CutsceneSubCommandEntry(rawData, rawDataIndex) +{ +} + +CutsceneMMCommand_NonImplemented::CutsceneMMCommand_NonImplemented( + const std::vector& rawData, offset_t rawDataIndex) + : CutsceneCommand(rawData, rawDataIndex) +{ + rawDataIndex += 4; + + entries.reserve(numEntries); + for (size_t i = 0; i < numEntries; i++) + { + auto* entry = new CutsceneSubCommandEntry_NonImplemented(rawData, rawDataIndex); + entries.push_back(entry); + rawDataIndex += entry->GetRawSize(); + } +} diff --git a/ZAPDTR/ZAPD/OtherStructs/CutsceneMM_Commands.h b/ZAPDTR/ZAPD/OtherStructs/CutsceneMM_Commands.h new file mode 100644 index 000000000..c8ae4eb60 --- /dev/null +++ b/ZAPDTR/ZAPD/OtherStructs/CutsceneMM_Commands.h @@ -0,0 +1,140 @@ +#pragma once + +#include "Cutscene_Commands.h" + +enum class CutsceneMMCommands +{ + /* 0x00A */ CS_CMD_TEXTBOX = 0xA, + /* 0x05A */ CS_CMD_CAMERA = 0x5A, + /* 0x096 */ CS_CMD_MISC = 0x96, + /* 0x097 */ CS_CMD_SET_LIGHTING, + /* 0x098 */ CS_CMD_SCENE_TRANS_FX, + /* 0x099 */ CS_CMD_MOTIONBLUR, + /* 0x09A */ CS_CMD_GIVETATL, + /* 0x09B */ CS_CMD_FADESCREEN, + /* 0x09C */ CS_CMD_FADESEQ, + /* 0x09D */ CS_CMD_SETTIME, + /* 0x0C8 */ CS_CMD_SET_PLAYER_ACTION = 0xC8, + /* 0x0FA */ CS_CMD_UNK_FA = 0xFA, + /* 0x0FE */ CS_CMD_UNK_FE = 0xFE, + /* 0x0FF */ CS_CMD_UNK_FF, + /* 0x100 */ CS_CMD_UNK_100, + /* 0x101 */ CS_CMD_UNK_101, + /* 0x102 */ CS_CMD_UNK_102, + /* 0x103 */ CS_CMD_UNK_103, + /* 0x104 */ CS_CMD_UNK_104, + /* 0x105 */ CS_CMD_UNK_105, + /* 0x108 */ CS_CMD_UNK_108 = 0x108, + /* 0x109 */ CS_CMD_UNK_109, + /* 0x12C */ CS_CMD_PLAYSEQ = 0x12C, + /* 0x12D */ CS_CMD_UNK_12D, + /* 0x130 */ CS_CMD_130 = 0x130, + /* 0x131 */ CS_CMD_131 = 0x131, + /* 0x132 */ CS_CMD_132 = 0x132, + /* 0x133 */ CS_CMD_STOPSEQ, + /* 0x134 */ CS_CMD_PLAYAMBIENCE, + /* 0x135 */ CS_CMD_FADEAMBIENCE, + /* 0x15E */ CS_CMD_TERMINATOR = 0x15E, + /* 0x15F */ CS_CMD_CHOOSE_CREDITS_SCENES, + /* 0x190 */ CS_CMD_RUMBLE = 0x190, +}; + +class CutsceneSubCommandEntry_GenericMMCmd : public CutsceneSubCommandEntry +{ +public: + CutsceneMMCommands commandId; + + CutsceneSubCommandEntry_GenericMMCmd(const std::vector& rawData, offset_t rawDataIndex, + CutsceneMMCommands cmdId); + + std::string GetBodySourceCode() const override; +}; + +class CutsceneMMCommand_GenericCmd : public CutsceneCommand +{ +public: + CutsceneMMCommand_GenericCmd(const std::vector& rawData, offset_t rawDataIndex, + CutsceneMMCommands cmdId); + + std::string GetCommandMacro() const override; +}; + +// TODO: MM cutscene camera command is implemented as a placeholder until we better understand how +// it works +class CutsceneSubCommandEntry_Camera : public CutsceneSubCommandEntry +{ +public: + uint32_t unk_08; + + CutsceneSubCommandEntry_Camera(const std::vector& rawData, offset_t rawDataIndex); + + std::string GetBodySourceCode() const override; + + size_t GetRawSize() const override; +}; + +class CutsceneMMCommand_Camera : public CutsceneCommand +{ +public: + CutsceneMMCommand_Camera(const std::vector& rawData, offset_t rawDataIndex); + + std::string GetCommandMacro() const override; +}; + +class CutsceneSubCommandEntry_FadeScreen : public CutsceneSubCommandEntry +{ +public: + uint8_t unk_06; + uint8_t unk_07; + uint8_t unk_08; + uint8_t unk_09; + uint8_t unk_0A; + uint8_t unk_0B; + + CutsceneSubCommandEntry_FadeScreen(const std::vector& rawData, offset_t rawDataIndex); + + std::string GetBodySourceCode() const override; + + size_t GetRawSize() const override; +}; + +class CutsceneMMCommand_FadeScreen : public CutsceneCommand +{ +public: + CutsceneMMCommand_FadeScreen(const std::vector& rawData, offset_t rawDataIndex); + + std::string GetCommandMacro() const override; +}; + +class CutsceneSubCommandEntry_FadeSeq : public CutsceneSubCommandEntry +{ +public: + uint32_t unk_08; + + CutsceneSubCommandEntry_FadeSeq(const std::vector& rawData, offset_t rawDataIndex); + + std::string GetBodySourceCode() const override; + + size_t GetRawSize() const override; +}; + +class CutsceneMMCommand_FadeSeq : public CutsceneCommand +{ +public: + CutsceneMMCommand_FadeSeq(const std::vector& rawData, offset_t rawDataIndex); + + std::string GetCommandMacro() const override; +}; + +class CutsceneSubCommandEntry_NonImplemented : public CutsceneSubCommandEntry +{ +public: + CutsceneSubCommandEntry_NonImplemented(const std::vector& rawData, + offset_t rawDataIndex); +}; + +class CutsceneMMCommand_NonImplemented : public CutsceneCommand +{ +public: + CutsceneMMCommand_NonImplemented(const std::vector& rawData, offset_t rawDataIndex); +}; diff --git a/ZAPDTR/ZAPD/OtherStructs/Cutscene_Commands.cpp b/ZAPDTR/ZAPD/OtherStructs/Cutscene_Commands.cpp new file mode 100644 index 000000000..8ae4c69d7 --- /dev/null +++ b/ZAPDTR/ZAPD/OtherStructs/Cutscene_Commands.cpp @@ -0,0 +1,596 @@ +#include "Cutscene_Commands.h" + +#include +#include + +#include "CutsceneMM_Commands.h" +#include "Globals.h" +#include "Utils/BitConverter.h" +#include "Utils/StringHelper.h" + +/* CutsceneSubCommandEntry */ + +CutsceneSubCommandEntry::CutsceneSubCommandEntry(const std::vector& rawData, + offset_t rawDataIndex) +{ + base = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0); + startFrame = BitConverter::ToUInt16BE(rawData, rawDataIndex + 2); + endFrame = BitConverter::ToUInt16BE(rawData, rawDataIndex + 4); + pad = BitConverter::ToUInt16BE(rawData, rawDataIndex + 6); +} + +std::string CutsceneSubCommandEntry::GetBodySourceCode() const +{ + return StringHelper::Sprintf("CMD_HH(0x%04X, 0x%04X), CMD_HH(0x%04X, 0x%04X)", base, startFrame, + endFrame, pad); +} + +size_t CutsceneSubCommandEntry::GetRawSize() const +{ + return 0x08; +} + +/* CutsceneCommand */ + +CutsceneCommand::CutsceneCommand(const std::vector& rawData, offset_t rawDataIndex) +{ + numEntries = BitConverter::ToUInt32BE(rawData, rawDataIndex + 0); +} + +CutsceneCommand::~CutsceneCommand() +{ + for (auto& entry : entries) + { + delete entry; + } +} + +std::string CutsceneCommand::GetCommandMacro() const +{ + return StringHelper::Sprintf("CMD_W(0x%08X), CMD_W(0x%08X)", commandID, numEntries); +} + +std::string CutsceneCommand::GenerateSourceCode() const +{ + std::string result; + + result += GetCommandMacro(); + result += ",\n"; + + for (auto& entry : entries) + { + result += " "; + result += entry->GetBodySourceCode(); + result += ",\n"; + } + + return result; +} + +size_t CutsceneCommand::GetCommandSize() const +{ + size_t size = 0; + if (entries.size() > 0) + { + size = entries.at(0)->GetRawSize() * entries.size(); + } + else + { + size = 0x08 * numEntries; + } + return 0x08 + size; +} + +void CutsceneCommand::SetCommandID(uint32_t nCommandID) +{ + commandID = nCommandID; + + for (auto& entry : entries) + { + entry->commandID = commandID; + } +} + +// Specific for command lists where each entry has size 0x30 bytes +const std::unordered_map csCommandsDesc = { + {CutsceneCommands::Misc, + {"CS_MISC", "(0x%04X, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i)"}}, + {CutsceneCommands::SetLighting, + {"CS_LIGHTING", "(0x%02X, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i)"}}, + {CutsceneCommands::PlayBGM, {"CS_PLAY_BGM", "(%i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i)"}}, + {CutsceneCommands::StopBGM, {"CS_STOP_BGM", "(%i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i)"}}, + {CutsceneCommands::FadeBGM, {"CS_FADE_BGM", "(%i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i)"}}, +}; + +CutsceneSubCommandEntry_GenericCmd::CutsceneSubCommandEntry_GenericCmd( + const std::vector& rawData, offset_t rawDataIndex, CutsceneCommands cmdId) + : CutsceneSubCommandEntry(rawData, rawDataIndex), commandId(cmdId) +{ + word0 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 0x0); + word1 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 0x4); + + unused1 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 0x8); + unused2 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 0xC); + unused3 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 0x10); + unused4 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 0x14); + unused5 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 0x18); + unused6 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 0x1C); + unused7 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 0x20); + unused8 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 0x24); + unused9 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 0x28); + unused10 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 0x2C); +} + +std::string CutsceneSubCommandEntry_GenericCmd::GetBodySourceCode() const +{ + const auto& element = csCommandsDesc.find(commandId); + + if (element != csCommandsDesc.end()) + { + std::string entryFmt = element->second.cmdMacro; + entryFmt += element->second.args; + + return StringHelper::Sprintf(entryFmt.c_str(), base, startFrame, endFrame, pad, unused1, + unused2, unused3, unused4, unused5, unused6, unused7, unused8, + unused9, unused10); + } + + return StringHelper::Sprintf("CS_UNK_DATA(0x%08X, 0x%08X, 0x%08X, 0x%08X, 0x%08X, 0x%08X, " + "0x%08X, 0x%08X, 0x%08X, 0x%08X, 0x%08X, 0x%08X)", + word0, word1, unused1, unused2, unused3, unused4, unused5, unused6, + unused7, unused8, unused9, unused10); +} + +size_t CutsceneSubCommandEntry_GenericCmd::GetRawSize() const +{ + return 0x30; +} + +CutsceneCommand_GenericCmd::CutsceneCommand_GenericCmd(const std::vector& rawData, + offset_t rawDataIndex, + CutsceneCommands cmdId) + : CutsceneCommand(rawData, rawDataIndex) +{ + rawDataIndex += 4; + + commandID = static_cast(cmdId); + entries.reserve(numEntries); + + for (size_t i = 0; i < numEntries; i++) + { + auto* entry = new CutsceneSubCommandEntry_GenericCmd(rawData, rawDataIndex, cmdId); + entries.push_back(entry); + rawDataIndex += entry->GetRawSize(); + } +} + +std::string CutsceneCommand_GenericCmd::GetCommandMacro() const +{ + const auto& element = csCommandsDesc.find(static_cast(commandID)); + + if (element != csCommandsDesc.end()) + { + return StringHelper::Sprintf("%s_LIST(%i)", element->second.cmdMacro, numEntries); + } + + return StringHelper::Sprintf("CS_UNK_DATA_LIST(0x%X, %i)", commandID, numEntries); +} + +CutsceneCameraPoint::CutsceneCameraPoint(const std::vector& rawData, offset_t rawDataIndex) + : CutsceneSubCommandEntry(rawData, rawDataIndex) +{ + continueFlag = BitConverter::ToInt8BE(rawData, rawDataIndex + 0); + cameraRoll = BitConverter::ToInt8BE(rawData, rawDataIndex + 1); + nextPointFrame = BitConverter::ToInt16BE(rawData, rawDataIndex + 2); + viewAngle = BitConverter::ToFloatBE(rawData, rawDataIndex + 4); + + posX = BitConverter::ToInt16BE(rawData, rawDataIndex + 8); + posY = BitConverter::ToInt16BE(rawData, rawDataIndex + 10); + posZ = BitConverter::ToInt16BE(rawData, rawDataIndex + 12); + + unused = BitConverter::ToInt16BE(rawData, rawDataIndex + 14); +} + +std::string CutsceneCameraPoint::GetBodySourceCode() const +{ + std::string result = ""; + + if (commandID == (int32_t)CutsceneCommands::SetCameraFocus) + { + result += "CS_CAM_FOCUS_POINT"; + } + else if (commandID == (int32_t)CutsceneCommands::SetCameraFocusLink) + { + result += "CS_CAM_FOCUS_POINT_PLAYER"; + } + else if (commandID == (int32_t)CutsceneCommands::SetCameraPosLink) + { + result += "CS_CAM_POS_PLAYER"; + } + else + { + result += "CS_CAM_POS"; + } + + std::string continueMacro = "CS_CMD_CONTINUE"; + if (continueFlag != 0) + continueMacro = "CS_CMD_STOP"; + + result += + StringHelper::Sprintf("(%s, 0x%02X, %i, %ff, %i, %i, %i, 0x%04X)", continueMacro.c_str(), + cameraRoll, nextPointFrame, viewAngle, posX, posY, posZ, unused); + return result; +} + +size_t CutsceneCameraPoint::GetRawSize() const +{ + return 0x10; +} + +CutsceneCommandSetCameraPos::CutsceneCommandSetCameraPos(const std::vector& rawData, + offset_t rawDataIndex) + : CutsceneCommand(rawData, rawDataIndex) +{ + base = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0); + startFrame = BitConverter::ToUInt16BE(rawData, rawDataIndex + 2); + endFrame = BitConverter::ToUInt16BE(rawData, rawDataIndex + 4); + unused = BitConverter::ToUInt16BE(rawData, rawDataIndex + 6); + + bool shouldContinue = true; + + uint32_t currentPtr = rawDataIndex + 8; + + while (shouldContinue) + { + CutsceneCameraPoint* camPoint = new CutsceneCameraPoint(rawData, currentPtr); + entries.push_back(camPoint); + + if (camPoint->continueFlag == -1) + shouldContinue = false; + + currentPtr += camPoint->GetRawSize(); + } +} + +std::string CutsceneCommandSetCameraPos::GetCommandMacro() const +{ + std::string result; + + std::string listStr; + + if (commandID == (int32_t)CutsceneCommands::SetCameraFocus) + { + listStr = "CS_CAM_FOCUS_POINT_LIST"; + } + else if (commandID == (int32_t)CutsceneCommands::SetCameraFocusLink) + { + listStr = "CS_CAM_FOCUS_POINT_PLAYER_LIST"; + } + else if (commandID == (int32_t)CutsceneCommands::SetCameraPosLink) + { + listStr = "CS_CAM_POS_PLAYER_LIST"; + } + else + { + listStr = "CS_CAM_POS_LIST"; + } + + result += StringHelper::Sprintf("%s(%i, %i)", listStr.c_str(), startFrame, endFrame); + + return result; +} + +size_t CutsceneCommandSetCameraPos::GetCommandSize() const +{ + return 0x0C + entries.at(0)->GetRawSize() * entries.size(); +} + +CutsceneSubCommandEntry_Rumble::CutsceneSubCommandEntry_Rumble(const std::vector& rawData, + offset_t rawDataIndex) + : CutsceneSubCommandEntry(rawData, rawDataIndex) +{ + unk_06 = BitConverter::ToUInt8BE(rawData, rawDataIndex + 0x06); + unk_07 = BitConverter::ToUInt8BE(rawData, rawDataIndex + 0x07); + unk_08 = BitConverter::ToUInt8BE(rawData, rawDataIndex + 0x08); + unk_09 = BitConverter::ToUInt8BE(rawData, rawDataIndex + 0x09); + unk_0A = BitConverter::ToUInt8BE(rawData, rawDataIndex + 0x0A); + unk_0B = BitConverter::ToUInt8BE(rawData, rawDataIndex + 0x0B); +} + +std::string CutsceneSubCommandEntry_Rumble::GetBodySourceCode() const +{ + if (Globals::Instance->game == ZGame::MM_RETAIL) + { + return StringHelper::Sprintf("CS_RUMBLE(%i, %i, %i, 0x%02X, 0x%02X, 0x%02X)", base, + startFrame, endFrame, unk_06, unk_07, unk_08); + } + + return StringHelper::Sprintf("CS_CMD_09(%i, %i, %i, 0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x%02X)", + base, startFrame, endFrame, unk_06, unk_07, unk_08, unk_09, unk_0A, + unk_0B); +} + +size_t CutsceneSubCommandEntry_Rumble::GetRawSize() const +{ + return 0x0C; +} + +CutsceneCommand_Rumble::CutsceneCommand_Rumble(const std::vector& rawData, + offset_t rawDataIndex) + : CutsceneCommand(rawData, rawDataIndex) +{ + rawDataIndex += 4; + + entries.reserve(numEntries); + for (size_t i = 0; i < numEntries; i++) + { + auto* entry = new CutsceneSubCommandEntry_Rumble(rawData, rawDataIndex); + entries.push_back(entry); + rawDataIndex += entry->GetRawSize(); + } +} + +std::string CutsceneCommand_Rumble::GetCommandMacro() const +{ + if (Globals::Instance->game == ZGame::MM_RETAIL) + { + return StringHelper::Sprintf("CS_RUMBLE_LIST(%i)", numEntries); + } + return StringHelper::Sprintf("CS_CMD_09_LIST(%i)", numEntries); +} + +CutsceneSubCommandEntry_SetTime::CutsceneSubCommandEntry_SetTime( + const std::vector& rawData, offset_t rawDataIndex) + : CutsceneSubCommandEntry(rawData, rawDataIndex) +{ + hour = BitConverter::ToUInt8BE(rawData, rawDataIndex + 6); + minute = BitConverter::ToUInt8BE(rawData, rawDataIndex + 7); + unk_08 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 8); +} + +std::string CutsceneSubCommandEntry_SetTime::GetBodySourceCode() const +{ + return StringHelper::Sprintf("CS_TIME(%i, %i, %i, %i, %i, %i)", base, startFrame, endFrame, + hour, minute, unk_08); +} + +size_t CutsceneSubCommandEntry_SetTime::GetRawSize() const +{ + return 0x0C; +} + +CutsceneCommand_SetTime::CutsceneCommand_SetTime(const std::vector& rawData, + offset_t rawDataIndex) + : CutsceneCommand(rawData, rawDataIndex) +{ + rawDataIndex += 4; + + entries.reserve(numEntries); + for (size_t i = 0; i < numEntries; i++) + { + auto* entry = new CutsceneSubCommandEntry_SetTime(rawData, rawDataIndex); + entries.push_back(entry); + rawDataIndex += entry->GetRawSize(); + } +} + +std::string CutsceneCommand_SetTime::GetCommandMacro() const +{ + return StringHelper::Sprintf("CS_TIME_LIST(%i)", numEntries); +} + +CutsceneSubCommandEntry_TextBox::CutsceneSubCommandEntry_TextBox( + const std::vector& rawData, offset_t rawDataIndex) + : CutsceneSubCommandEntry(rawData, rawDataIndex) +{ + type = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0x6); + textId1 = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0x8); + textId2 = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0xA); +} + +std::string CutsceneSubCommandEntry_TextBox::GetBodySourceCode() const +{ + if (type == 0xFFFF) + { + return StringHelper::Sprintf("CS_TEXT_NONE(%i, %i)", startFrame, endFrame); + } + if (type == 2) + { + return StringHelper::Sprintf("CS_TEXT_LEARN_SONG(%i, %i, %i, 0x%X)", base, startFrame, + endFrame, textId1); + } + + if (Globals::Instance->game == ZGame::MM_RETAIL) + { + switch (type) + { + case 0: + return StringHelper::Sprintf("CS_TEXT_DEFAULT(0x%X, %i, %i, 0x%X, 0x%X)", base, + startFrame, endFrame, textId1, textId2); + + case 1: + return StringHelper::Sprintf("CS_TEXT_TYPE_1(0x%X, %i, %i, 0x%X, 0x%X)", base, + startFrame, endFrame, textId1, textId2); + + case 3: + return StringHelper::Sprintf("CS_TEXT_TYPE_3(0x%X, %i, %i, 0x%X, 0x%X)", base, + startFrame, endFrame, textId1, textId2); + + case 4: + return StringHelper::Sprintf("CS_TEXT_BOSSES_REMAINS(0x%X, %i, %i, 0x%X)", base, + startFrame, endFrame, textId1); + + case 5: + return StringHelper::Sprintf("CS_TEXT_ALL_NORMAL_MASKS(0x%X, %i, %i, 0x%X)", base, + startFrame, endFrame, textId1); + } + } + + return StringHelper::Sprintf("CS_TEXT_DISPLAY_TEXTBOX(0x%X, %i, %i, %i, 0x%X, 0x%X)", base, + startFrame, endFrame, type, textId1, textId2); +} + +size_t CutsceneSubCommandEntry_TextBox::GetRawSize() const +{ + return 0x0C; +} + +CutsceneCommand_TextBox::CutsceneCommand_TextBox(const std::vector& rawData, + offset_t rawDataIndex) + : CutsceneCommand(rawData, rawDataIndex) +{ + rawDataIndex += 4; + + entries.reserve(numEntries); + for (size_t i = 0; i < numEntries; i++) + { + auto* entry = new CutsceneSubCommandEntry_TextBox(rawData, rawDataIndex); + entries.push_back(entry); + rawDataIndex += entry->GetRawSize(); + } +} + +std::string CutsceneCommand_TextBox::GetCommandMacro() const +{ + return StringHelper::Sprintf("CS_TEXT_LIST(%i)", numEntries); +} + +CutsceneSubCommandEntry_ActorAction::CutsceneSubCommandEntry_ActorAction( + const std::vector& rawData, offset_t rawDataIndex) + : CutsceneSubCommandEntry(rawData, rawDataIndex) +{ + rotX = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0x6); + rotY = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0x8); + rotZ = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0xA); + startPosX = BitConverter::ToInt32BE(rawData, rawDataIndex + 0xC); + startPosY = BitConverter::ToInt32BE(rawData, rawDataIndex + 0x10); + startPosZ = BitConverter::ToInt32BE(rawData, rawDataIndex + 0x14); + endPosX = BitConverter::ToInt32BE(rawData, rawDataIndex + 0x18); + endPosY = BitConverter::ToInt32BE(rawData, rawDataIndex + 0x1C); + endPosZ = BitConverter::ToInt32BE(rawData, rawDataIndex + 0x20); + normalX = BitConverter::ToFloatBE(rawData, rawDataIndex + 0x24); + normalY = BitConverter::ToFloatBE(rawData, rawDataIndex + 0x28); + normalZ = BitConverter::ToFloatBE(rawData, rawDataIndex + 0x2C); +} + +std::string CutsceneSubCommandEntry_ActorAction::GetBodySourceCode() const +{ + std::string result; + + if (Globals::Instance->game == ZGame::MM_RETAIL) + { + if (static_cast(commandID) == + CutsceneMMCommands::CS_CMD_SET_PLAYER_ACTION) + { + result = "CS_PLAYER_ACTION"; + } + else + { + result = "CS_ACTOR_ACTION"; + } + } + else + { + if (static_cast(commandID) == CutsceneCommands::SetPlayerAction) + { + result = "CS_PLAYER_ACTION"; + } + else + { + result = "CS_NPC_ACTION"; + } + } + + result += + StringHelper::Sprintf("(%i, %i, %i, 0x%04X, 0x%04X, 0x%04X, %i, %i, " + "%i, %i, %i, %i, %.11ef, %.11ef, %.11ef)", + base, startFrame, endFrame, rotX, rotY, rotZ, startPosX, startPosY, + startPosZ, endPosX, endPosY, endPosZ, normalX, normalY, normalZ); + return result; +} + +size_t CutsceneSubCommandEntry_ActorAction::GetRawSize() const +{ + return 0x30; +} + +CutsceneCommand_ActorAction::CutsceneCommand_ActorAction(const std::vector& rawData, + offset_t rawDataIndex) + : CutsceneCommand(rawData, rawDataIndex) +{ + rawDataIndex += 4; + + entries.reserve(numEntries); + for (size_t i = 0; i < numEntries; i++) + { + auto* entry = new CutsceneSubCommandEntry_ActorAction(rawData, rawDataIndex); + entries.push_back(entry); + rawDataIndex += entry->GetRawSize(); + } +} + +std::string CutsceneCommand_ActorAction::GetCommandMacro() const +{ + if (Globals::Instance->game == ZGame::MM_RETAIL) + { + if (static_cast(commandID) == + CutsceneMMCommands::CS_CMD_SET_PLAYER_ACTION) + { + return StringHelper::Sprintf("CS_PLAYER_ACTION_LIST(%i)", numEntries); + } + return StringHelper::Sprintf("CS_ACTOR_ACTION_LIST(0x%03X, %i)", commandID, numEntries); + } + + if (static_cast(commandID) == CutsceneCommands::SetPlayerAction) + { + return StringHelper::Sprintf("CS_PLAYER_ACTION_LIST(%i)", entries.size()); + } + return StringHelper::Sprintf("CS_NPC_ACTION_LIST(0x%03X, %i)", commandID, entries.size()); +} + +CutsceneCommand_Terminator::CutsceneCommand_Terminator(const std::vector& rawData, + offset_t rawDataIndex) + : CutsceneCommand(rawData, rawDataIndex) +{ + rawDataIndex += 4; + + base = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0); + startFrame = BitConverter::ToUInt16BE(rawData, rawDataIndex + 2); + endFrame = BitConverter::ToUInt16BE(rawData, rawDataIndex + 4); + unknown = BitConverter::ToUInt16BE(rawData, rawDataIndex + 6); // endFrame duplicate +} + +std::string CutsceneCommand_Terminator::GenerateSourceCode() const +{ + std::string result; + + result += StringHelper::Sprintf("CS_TERMINATOR(%i, %i, %i),\n", base, startFrame, endFrame); + + return result; +} + +size_t CutsceneCommand_Terminator::GetCommandSize() const +{ + return 0x10; +} + +CutsceneCommandSceneTransFX::CutsceneCommandSceneTransFX(const std::vector& rawData, + offset_t rawDataIndex) + : CutsceneCommand(rawData, rawDataIndex) +{ + rawDataIndex += 4; + + base = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0); + startFrame = BitConverter::ToUInt16BE(rawData, rawDataIndex + 2); + endFrame = BitConverter::ToUInt16BE(rawData, rawDataIndex + 4); +} + +std::string CutsceneCommandSceneTransFX::GenerateSourceCode() const +{ + return StringHelper::Sprintf("CS_SCENE_TRANS_FX(%i, %i, %i),\n", base, startFrame, endFrame); +} + +size_t CutsceneCommandSceneTransFX::GetCommandSize() const +{ + return 0x10; +} diff --git a/ZAPDTR/ZAPD/OtherStructs/Cutscene_Commands.h b/ZAPDTR/ZAPD/OtherStructs/Cutscene_Commands.h new file mode 100644 index 000000000..c46273587 --- /dev/null +++ b/ZAPDTR/ZAPD/OtherStructs/Cutscene_Commands.h @@ -0,0 +1,267 @@ +#pragma once + +#include +#include +#include + +#include "Declaration.h" + +enum class CutsceneCommands +{ + SetCameraPos = 0x0001, + SetCameraFocus = 0x0002, + Misc = 0x0003, + SetLighting = 0x0004, + SetCameraPosLink = 0x0005, + SetCameraFocusLink = 0x0006, + Cmd07 = 0x0007, + Cmd08 = 0x0008, + Cmd09 = 0x0009, // Rumble + Textbox = 0x0013, + SetPlayerAction = 0x000A, + SetActorAction1 = 0x000F, + SetActorAction2 = 0x000E, + SetActorAction3 = 0x0019, + SetActorAction4 = 0x001D, + SetActorAction5 = 0x001E, + SetActorAction6 = 0x002C, + SetActorAction7 = 0x001F, + SetActorAction8 = 0x0031, + SetActorAction9 = 0x003E, + SetActorAction10 = 0x008F, + SetSceneTransFX = 0x002D, + PlayBGM = 0x0056, + StopBGM = 0x0057, + FadeBGM = 0x007C, + SetTime = 0x008C, + Terminator = 0x03E8, +}; + +typedef struct CsCommandListDescriptor +{ + const char* cmdMacro; + const char* args; +} CsCommandListDescriptor; + +class CutsceneSubCommandEntry +{ +public: + uint16_t base; + uint16_t startFrame; + uint16_t endFrame; + uint16_t pad; + + uint32_t commandID; + + CutsceneSubCommandEntry(const std::vector& rawData, offset_t rawDataIndex); + virtual ~CutsceneSubCommandEntry() = default; + + virtual std::string GetBodySourceCode() const; + + virtual size_t GetRawSize() const; +}; + +class CutsceneCommand +{ +public: + uint32_t commandID; + uint32_t commandIndex; + + uint32_t numEntries; + std::vector entries; + + CutsceneCommand(const std::vector& rawData, offset_t rawDataIndex); + virtual ~CutsceneCommand(); + + virtual std::string GetCommandMacro() const; + virtual std::string GenerateSourceCode() const; + virtual size_t GetCommandSize() const; + + virtual void SetCommandID(uint32_t nCommandID); +}; + +class CutsceneSubCommandEntry_GenericCmd : public CutsceneSubCommandEntry +{ +public: + CutsceneCommands commandId; + + uint32_t word0 = 0; + uint32_t word1 = 0; + + uint32_t unused1 = 0; + uint32_t unused2 = 0; + uint32_t unused3 = 0; + uint32_t unused4 = 0; + uint32_t unused5 = 0; + uint32_t unused6 = 0; + uint32_t unused7 = 0; + uint32_t unused8 = 0; + uint32_t unused9 = 0; + uint32_t unused10 = 0; + + CutsceneSubCommandEntry_GenericCmd(const std::vector& rawData, offset_t rawDataIndex, + CutsceneCommands cmdId); + + std::string GetBodySourceCode() const override; + + size_t GetRawSize() const override; +}; + +class CutsceneCommand_GenericCmd : public CutsceneCommand +{ +public: + CutsceneCommand_GenericCmd(const std::vector& rawData, offset_t rawDataIndex, + CutsceneCommands cmdId); + + std::string GetCommandMacro() const override; +}; + +class CutsceneCameraPoint : public CutsceneSubCommandEntry +{ +public: + int8_t continueFlag; + int8_t cameraRoll; + int16_t nextPointFrame; + float viewAngle; + int16_t posX, posY, posZ; + int16_t unused; + + CutsceneCameraPoint(const std::vector& rawData, offset_t rawDataIndex); + + std::string GetBodySourceCode() const override; + + size_t GetRawSize() const override; +}; + +class CutsceneCommandSetCameraPos : public CutsceneCommand +{ +public: + uint16_t base; + uint16_t startFrame; + uint16_t endFrame; + uint16_t unused; + + CutsceneCommandSetCameraPos(const std::vector& rawData, offset_t rawDataIndex); + + std::string GetCommandMacro() const override; + + size_t GetCommandSize() const override; +}; + +class CutsceneCommandSceneTransFX : public CutsceneCommand +{ +public: + uint16_t base; + uint16_t startFrame; + uint16_t endFrame; + + CutsceneCommandSceneTransFX(const std::vector& rawData, offset_t rawDataIndex); + + std::string GenerateSourceCode() const override; + size_t GetCommandSize() const override; +}; + +class CutsceneSubCommandEntry_Rumble : public CutsceneSubCommandEntry +{ +public: + uint8_t unk_06; + uint8_t unk_07; + uint8_t unk_08; + uint8_t unk_09; + uint8_t unk_0A; + uint8_t unk_0B; + + CutsceneSubCommandEntry_Rumble(const std::vector& rawData, offset_t rawDataIndex); + + std::string GetBodySourceCode() const override; + + size_t GetRawSize() const override; +}; + +class CutsceneCommand_Rumble : public CutsceneCommand +{ +public: + CutsceneCommand_Rumble(const std::vector& rawData, offset_t rawDataIndex); + + std::string GetCommandMacro() const override; +}; + +class CutsceneSubCommandEntry_SetTime : public CutsceneSubCommandEntry +{ +public: + uint8_t hour; + uint8_t minute; + uint32_t unk_08; + + CutsceneSubCommandEntry_SetTime(const std::vector& rawData, offset_t rawDataIndex); + + std::string GetBodySourceCode() const override; + + size_t GetRawSize() const override; +}; + +class CutsceneCommand_SetTime : public CutsceneCommand +{ +public: + CutsceneCommand_SetTime(const std::vector& rawData, offset_t rawDataIndex); + + std::string GetCommandMacro() const override; +}; + +class CutsceneSubCommandEntry_TextBox : public CutsceneSubCommandEntry +{ +public: + uint16_t type; + uint16_t textId1; + uint16_t textId2; + + CutsceneSubCommandEntry_TextBox(const std::vector& rawData, offset_t rawDataIndex); + + std::string GetBodySourceCode() const override; + + size_t GetRawSize() const override; +}; + +class CutsceneCommand_TextBox : public CutsceneCommand +{ +public: + CutsceneCommand_TextBox(const std::vector& rawData, offset_t rawDataIndex); + + std::string GetCommandMacro() const override; +}; + +class CutsceneSubCommandEntry_ActorAction : public CutsceneSubCommandEntry +{ +public: + uint16_t rotX, rotY, rotZ; + int32_t startPosX, startPosY, startPosZ; + int32_t endPosX, endPosY, endPosZ; + float normalX, normalY, normalZ; + + CutsceneSubCommandEntry_ActorAction(const std::vector& rawData, offset_t rawDataIndex); + std::string GetBodySourceCode() const override; + + size_t GetRawSize() const override; +}; + +class CutsceneCommand_ActorAction : public CutsceneCommand +{ +public: + CutsceneCommand_ActorAction(const std::vector& rawData, offset_t rawDataIndex); + + std::string GetCommandMacro() const override; +}; + +class CutsceneCommand_Terminator : public CutsceneCommand +{ +public: + uint16_t base; + uint16_t startFrame; + uint16_t endFrame; + uint16_t unknown; + + CutsceneCommand_Terminator(const std::vector& rawData, offset_t rawDataIndex); + + std::string GenerateSourceCode() const override; + size_t GetCommandSize() const override; +}; diff --git a/ZAPDTR/ZAPD/OtherStructs/SkinLimbStructs.cpp b/ZAPDTR/ZAPD/OtherStructs/SkinLimbStructs.cpp index c9a537ced..8a0e49cf3 100644 --- a/ZAPDTR/ZAPD/OtherStructs/SkinLimbStructs.cpp +++ b/ZAPDTR/ZAPD/OtherStructs/SkinLimbStructs.cpp @@ -104,6 +104,8 @@ void Struct_800A598C::ParseRawData() if (unk_8 != 0 && GETSEGNUM(unk_8) == parent->segment) { uint32_t unk_8_Offset = Seg2Filespace(unk_8, parent->baseAddress); + + unk_8_arr.reserve(unk_0); for (size_t i = 0; i < unk_0; i++) { Struct_800A57C0 unk8_data(parent); @@ -117,6 +119,8 @@ void Struct_800A598C::ParseRawData() if (unk_C != 0 && GETSEGNUM(unk_8) == parent->segment) { uint32_t unk_C_Offset = Seg2Filespace(unk_C, parent->baseAddress); + + unk_C_arr.reserve(unk_2); for (size_t i = 0; i < unk_2; i++) { Struct_800A598C_2 unkC_data(parent); @@ -246,6 +250,8 @@ void Struct_800A5E28::ParseRawData() if (unk_4 != 0 && GETSEGNUM(unk_4) == parent->segment) { uint32_t unk_4_Offset = Seg2Filespace(unk_4, parent->baseAddress); + + unk_4_arr.reserve(unk_2); for (size_t i = 0; i < unk_2; i++) { Struct_800A598C unk_4_data(parent); diff --git a/ZAPDTR/ZAPD/OutputFormatter.h b/ZAPDTR/ZAPD/OutputFormatter.h index 03abfdb96..391f41027 100644 --- a/ZAPDTR/ZAPD/OutputFormatter.h +++ b/ZAPDTR/ZAPD/OutputFormatter.h @@ -3,6 +3,7 @@ #include #include #include +#include class OutputFormatter { diff --git a/ZAPDTR/ZAPD/Overlays/ZOverlay.cpp b/ZAPDTR/ZAPD/Overlays/ZOverlay.cpp index c3e7c68c7..168ed2374 100644 --- a/ZAPDTR/ZAPD/Overlays/ZOverlay.cpp +++ b/ZAPDTR/ZAPD/Overlays/ZOverlay.cpp @@ -5,7 +5,7 @@ #include #include "Globals.h" #include "Utils/Directory.h" -#include "Utils/File.h" +#include #include "Utils/Path.h" #include "Utils/StringHelper.h" #include "WarningHandler.h" @@ -76,7 +76,7 @@ static const std::unordered_set sSections = { ZOverlay* ZOverlay::FromBuild(fs::path buildPath, fs::path cfgFolderPath) { - std::string cfgText = File::ReadAllText(cfgFolderPath / "overlay.cfg"); + std::string cfgText = DiskFile::ReadAllText(cfgFolderPath / "overlay.cfg"); std::vector cfgLines = StringHelper::Split(cfgText, "\n"); ZOverlay* ovl = new ZOverlay(StringHelper::Strip(cfgLines[0], "\r")); diff --git a/ZAPDTR/ZAPD/WarningHandler.cpp b/ZAPDTR/ZAPD/WarningHandler.cpp index 29f8352a7..163b028b5 100644 --- a/ZAPDTR/ZAPD/WarningHandler.cpp +++ b/ZAPDTR/ZAPD/WarningHandler.cpp @@ -199,8 +199,16 @@ bool WarningHandler::WasElevatedToError(WarningType warnType) { * Print file/line/function info for debugging */ void WarningHandler::FunctionPreamble(const char* filename, int32_t line, const char* function) { - if (Globals::Instance->verbosity >= VerbosityLevel::VERBOSITY_DEBUG) { - fprintf(stderr, "%s:%i: in function %s:\n", filename, line, function); + bool forcePrint = false; + +#ifdef DEVELOPMENT + forcePrint = true; +#endif + + fprintf(stderr, "\n"); + + if (forcePrint || Globals::Instance->verbosity >= VerbosityLevel::VERBOSITY_DEBUG) { + fprintf(stderr, "%s:%i: in function <%s>:\n", filename, line, function); } } diff --git a/ZAPDTR/ZAPD/ZAPD.vcxproj b/ZAPDTR/ZAPD/ZAPD.vcxproj new file mode 100644 index 000000000..505e41100 --- /dev/null +++ b/ZAPDTR/ZAPD/ZAPD.vcxproj @@ -0,0 +1,372 @@ + + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 15.0 + {B53F9E5B-0A58-4BAE-9AFE-856C8CBB8D36} + ZAPD + 10.0 + ZAPD + + + + Application + true + v142 + MultiByte + + + Application + false + v142 + true + MultiByte + + + Application + true + v142 + MultiByte + + + Application + false + v142 + true + MultiByte + + + + + + + + + + + + + + + + + + + + + $(OutDir);$(ProjectDir)..\lib\libgfxd;$(ProjectDir)..\packages\libpng-v142.1.6.37.2\build\native\lib\x64\v142\Debug\;$(LibraryPath) + $(ProjectDir)..\ZAPDUtils;$(ProjectDir)..\lib\tinyxml2;$(ProjectDir)..\lib\libgfxd;$(ProjectDir)..\lib\elfio;$(ProjectDir)..\lib\stb;$(ProjectDir);$(IncludePath) + + + $(IncludePath) + + + $(SolutionDir)ZAPD\lib\tinyxml2;$(SolutionDir)ZAPD\lib\libgfxd;$(SolutionDir)ZAPD\lib\elfio;$(SolutionDir)ZAPD\lib\stb;$(ProjectDir);$(IncludePath) + $(SolutionDir)ZAPD\lib\libgfxd;$(SolutionDir)x64\Debug;$(SolutionDir)packages\libpng.1.6.28.1\build\native\lib\x64\v140\dynamic\Debug;$(LibraryPath) + + + + Level3 + Disabled + true + true + stdcpp17 + stdc11 + _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + true + + + true + Console + + + cd .. +mkdir build\ZAPD + python ZAPD/genbuildinfo.py + + + + + Level3 + Disabled + true + true + stdcpp17 + _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + EnableFastChecks + stdc11 + MultiThreadedDebug + true + + + true + ZAPDUtils.lib;/WHOLEARCHIVE:ExporterExample.lib;%(AdditionalDependencies) + false + Console + + + cd .. +mkdir build\ZAPD + python ZAPD/genbuildinfo.py + + + + + Level3 + MaxSpeed + true + true + true + true + true + + + true + true + + + cd .. +mkdir build\ZAPD + python ZAPD/genbuildinfo.py + + + + + Level3 + MaxSpeed + true + true + true + true + stdcpplatest + _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + true + + + true + true + + + cd .. +mkdir build\ZAPD + python ZAPD/genbuildinfo.py + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + true + + + + + + + + + + + + + + + + + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + + + + + + \ No newline at end of file diff --git a/ZAPDTR/ZAPD/ZAPD.vcxproj.filters b/ZAPDTR/ZAPD/ZAPD.vcxproj.filters new file mode 100644 index 000000000..ce89882fe --- /dev/null +++ b/ZAPDTR/ZAPD/ZAPD.vcxproj.filters @@ -0,0 +1,572 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;hm;inl;inc;ipp;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + {02148456-5068-4613-8478-f10addc58e70} + + + {bcab3136-95ba-4839-833c-43d78ad6e335} + + + {dc06ed84-f6fe-4277-80f3-d62bd5cdbb98} + + + {6049c045-bc38-4221-b29e-ca6d4d8af4aa} + + + {490e3a08-047b-48d3-ab53-3a860a3b92aa} + + + {26c06845-8e8e-4b79-ad18-07c4f9c0f801} + + + {d45c420d-2378-47ac-92c5-80db9475c195} + + + {03cc56a2-e0e8-4167-80a0-98fb900a959a} + + + {73db0879-6df8-4f6a-8cc2-a1f836e9e796} + + + {be9a5be0-ec6a-4200-8e39-bb58c7da7aa8} + + + {7ee79d97-c6a8-4e82-93ef-37981f4d7838} + + + {85600275-99fe-491d-8189-bcc3dc1a8903} + + + {ba9990b0-1082-48bb-874c-6108534b5455} + + + {ce9d91b0-ba20-4296-bc2d-8630965bb392} + + + {730beb67-6d59-4849-9d9b-702c4a565fc0} + + + + + Source Files + + + Source Files\Z64\ZRoom + + + Source Files\Z64\ZRoom\Commands + + + Source Files\Z64\ZRoom + + + Source Files\Z64\ZRoom\Commands + + + Source Files\Z64\ZRoom\Commands + + + Source Files\Z64\ZRoom\Commands + + + Source Files\Z64\ZRoom\Commands + + + Source Files\Z64\ZRoom\Commands + + + Source Files\Z64\ZRoom\Commands + + + Source Files\Z64\ZRoom\Commands + + + Source Files\Z64\ZRoom\Commands + + + Source Files\Z64\ZRoom\Commands + + + Source Files\Z64\ZRoom\Commands + + + Source Files\Z64\ZRoom\Commands + + + Source Files + + + Source Files\Z64\ZRoom\Commands + + + Source Files\Z64\ZRoom\Commands + + + Source Files\Z64\ZRoom\Commands + + + Source Files\Z64\ZRoom\Commands + + + Source Files\Z64\ZRoom\Commands + + + Source Files\Z64\ZRoom\Commands + + + Source Files\Z64\ZRoom\Commands + + + Source Files\Z64\ZRoom\Commands + + + Source Files\Z64\ZRoom\Commands + + + Source Files\Z64\ZRoom\Commands + + + Source Files\Z64\ZRoom\Commands + + + Source Files\Z64\ZRoom\Commands + + + Source Files\Z64 + + + Source Files\Z64 + + + Source Files\Z64 + + + Source Files\Z64 + + + Source Files\Z64 + + + Source Files\Z64 + + + Source Files\Z64 + + + Source Files\Z64 + + + Source Files\Z64\ZRoom\Commands + + + Source Files\Z64\ZRoom\Commands + + + Source Files\Z64 + + + Source Files\Z64 + + + Source Files\Z64 + + + Source Files\Z64 + + + Source Files\Z64 + + + Source Files\Z64 + + + Source Files + + + Source Files\Z64 + + + Source Files\Libraries\libgfxd + + + Source Files\Libraries\libgfxd + + + Source Files\Libraries\libgfxd + + + Source Files\Libraries\libgfxd + + + Source Files\Libraries\libgfxd + + + Source Files\Libraries\libgfxd + + + Source Files\Libraries\libgfxd + + + Source Files\Z64 + + + Source Files\Z64\ZRoom\Commands + + + Source Files\Z64\ZRoom\Commands + + + Source Files\Z64\ZRoom\Commands + + + Source Files\Z64\ZRoom\Commands + + + Source Files\Z64\ZRoom\Commands + + + Source Files\Z64\ZRoom\Commands + + + Source Files\Z64 + + + Source Files\Z64\ZRoom\Commands + + + Source Files\Z64 + + + Source Files + + + Source Files + + + Source Files\Z64 + + + Source Files + + + Source Files\Z64 + + + Source Files\Z64 + + + Source Files + + + Source Files\Z64 + + + Source Files + + + Source Files\Z64 + + + Source Files\Z64 + + + Source Files\Z64 + + + Source Files + + + Source Files\Z64 + + + + + Header Files\Z64\ZRoom + + + Header Files\Z64\ZRoom + + + Header Files\Z64\ZRoom\Commands + + + Header Files\Z64\ZRoom\Commands + + + Header Files\Z64\ZRoom\Commands + + + Header Files\Z64\ZRoom\Commands + + + Header Files\Z64\ZRoom\Commands + + + Header Files\Z64\ZRoom\Commands + + + Header Files\Z64\ZRoom\Commands + + + Header Files\Z64\ZRoom\Commands + + + Header Files\Z64\ZRoom\Commands + + + Header Files\Z64\ZRoom\Commands + + + Header Files\Z64\ZRoom\Commands + + + Header Files\Z64\ZRoom\Commands + + + Header Files\Libraries\elfio + + + Header Files\Libraries\elfio + + + Header Files\Libraries\elfio + + + Header Files\Libraries\elfio + + + Header Files\Libraries\elfio + + + Header Files\Libraries\elfio + + + Header Files\Libraries\elfio + + + Header Files\Libraries\elfio + + + Header Files\Libraries\elfio + + + Header Files\Libraries\elfio + + + Header Files\Libraries\elfio + + + Header Files\Libraries\elfio + + + Header Files + + + Header Files\Z64\ZRoom\Commands + + + Header Files\Z64\ZRoom\Commands + + + Header Files\Z64\ZRoom\Commands + + + Header Files\Z64\ZRoom\Commands + + + Header Files\Z64\ZRoom\Commands + + + Header Files\Z64\ZRoom\Commands + + + Header Files\Z64\ZRoom\Commands + + + Header Files\Z64\ZRoom\Commands + + + Header Files\Z64\ZRoom\Commands + + + Header Files\Z64\ZRoom\Commands + + + Header Files\Z64\ZRoom\Commands + + + Header Files\Z64\ZRoom\Commands + + + Header Files\Libraries + + + Header Files\Libraries + + + Header Files\Z64 + + + Header Files\Z64 + + + Header Files\Z64 + + + Header Files\Z64 + + + Header Files\Z64 + + + Header Files\Z64 + + + Header Files\Z64 + + + Header Files\Z64 + + + Header Files\Z64\ZRoom\Commands + + + Header Files\Z64\ZRoom\Commands + + + Header Files\Z64 + + + Header Files\Z64 + + + Header Files\Z64 + + + Header Files + + + Header Files\Z64 + + + Header Files\Z64 + + + Header Files + + + Header Files\Z64 + + + Header Files + + + Header Files\Z64 + + + Header Files\Libraries\libgfxd + + + Header Files\Libraries\libgfxd + + + Header Files\Libraries\libgfxd + + + Header Files\Z64 + + + Header Files\Z64\ZRoom\Commands + + + Header Files\Z64\ZRoom\Commands + + + Header Files\Z64\ZRoom\Commands + + + Header Files\Z64\ZRoom\Commands + + + Header Files\Z64\ZRoom\Commands + + + Header Files\Z64\ZRoom\Commands + + + Header Files\Z64 + + + Header Files\Z64\ZRoom\Commands + + + Header Files + + + Header Files\Z64 + + + Header Files + + + Header Files\Z64 + + + Header Files + + + Header Files\Z64 + + + Header Files\Z64 + + + Header Files\Z64 + + + Header Files + + + Header Files\Z64 + + + Header Files\Z64 + + + Header Files\Z64 + + + Header Files + + + Header Files\Z64 + + + + + Resource Files + + + any\any + + + NuGet + + + + + + \ No newline at end of file diff --git a/ZAPDTR/ZAPD/ZActorList.cpp b/ZAPDTR/ZAPD/ZActorList.cpp new file mode 100644 index 000000000..ee5cb4d44 --- /dev/null +++ b/ZAPDTR/ZAPD/ZActorList.cpp @@ -0,0 +1,194 @@ +#include "ZActorList.h" + +#include "Globals.h" +#include "Utils/BitConverter.h" +#include "WarningHandler.h" +#include "ZFile.h" +#include "ZRoom/ZNames.h" + +REGISTER_ZFILENODE(ActorList, ZActorList); + +ZActorList::ZActorList(ZFile* nParent) : ZResource(nParent) +{ + RegisterRequiredAttribute("Count"); +} + +void ZActorList::ExtractFromBinary(uint32_t nRawDataIndex, uint8_t nNumActors) +{ + rawDataIndex = nRawDataIndex; + numActors = nNumActors; + + // Don't parse raw data of external files + if (parent->GetMode() == ZFileMode::ExternalFile) + return; + + ParseRawData(); +} + +void ZActorList::ParseXML(tinyxml2::XMLElement* reader) +{ + ZResource::ParseXML(reader); + + numActors = StringHelper::StrToL(registeredAttributes.at("Count").value); + + if (numActors < 1) + { + HANDLE_ERROR_RESOURCE( + WarningType::InvalidAttributeValue, parent, this, rawDataIndex, + StringHelper::Sprintf("invalid value '%d' found for 'NumPaths' attribute", numActors), + "Should be at least '1'"); + } +} + +void ZActorList::ParseRawData() +{ + ZResource::ParseRawData(); + + offset_t currentPtr = rawDataIndex; + size_t largestlength = 0; + + for (size_t i = 0; i < numActors; i++) + { + ActorSpawnEntry entry(parent->GetRawData(), currentPtr); + + currentPtr += entry.GetRawDataSize(); + actors.push_back(entry); + + size_t actorNameLength = ZNames::GetActorName(entry.GetActorId()).size(); + if (actorNameLength > largestlength) + largestlength = actorNameLength; + } + + for (auto& entry : actors) + { + entry.SetLargestActorName(largestlength); + } +} + +Declaration* ZActorList::DeclareVar(const std::string& prefix, const std::string& bodyStr) +{ + std::string auxName = name; + + if (name == "") + auxName = GetDefaultName(prefix); + + Declaration* decl = + parent->AddDeclarationArray(rawDataIndex, GetDeclarationAlignment(), GetRawDataSize(), + GetSourceTypeName(), name, GetActorListArraySize(), bodyStr); + decl->staticConf = staticConf; + + return decl; +} + +std::string ZActorList::GetBodySourceCode() const +{ + std::string declaration; + + size_t index = 0; + for (auto& entry : actors) + { + declaration += StringHelper::Sprintf("\t{ %s },", entry.GetBodySourceCode().c_str()); + + if (index < actors.size() - 1) + declaration += "\n"; + + index++; + } + + return declaration; +} + +std::string ZActorList::GetSourceTypeName() const +{ + return actors.front().GetSourceTypeName(); +} + +ZResourceType ZActorList::GetResourceType() const +{ + return ZResourceType::ActorList; +} + +size_t ZActorList::GetRawDataSize() const +{ + return actors.size() * actors.front().GetRawDataSize(); +} + +size_t ZActorList::GetActorListArraySize() const +{ + size_t actorCount = 0; + + // Doing an else-if here so we only do the loop when the game is SW97. + // Actor 0x22 is removed from SW97, so we need to ensure that we don't increment the actor count + // for it. + if (Globals::Instance->game == ZGame::OOT_SW97) + { + actorCount = 0; + + for (const auto& entry : actors) + if (entry.GetActorId() != 0x22) + actorCount++; + } + else + { + actorCount = actors.size(); + } + + return actorCount; +} + +/* ActorSpawnEntry */ + +ActorSpawnEntry::ActorSpawnEntry(const std::vector& rawData, uint32_t rawDataIndex) +{ + actorNum = BitConverter::ToInt16BE(rawData, rawDataIndex + 0); + posX = BitConverter::ToInt16BE(rawData, rawDataIndex + 2); + posY = BitConverter::ToInt16BE(rawData, rawDataIndex + 4); + posZ = BitConverter::ToInt16BE(rawData, rawDataIndex + 6); + rotX = BitConverter::ToUInt16BE(rawData, rawDataIndex + 8); + rotY = BitConverter::ToUInt16BE(rawData, rawDataIndex + 10); + rotZ = BitConverter::ToUInt16BE(rawData, rawDataIndex + 12); + params = BitConverter::ToInt16BE(rawData, rawDataIndex + 14); +} + +std::string ActorSpawnEntry::GetBodySourceCode() const +{ + std::string body; + + std::string actorNameFmt = StringHelper::Sprintf("%%-%zus ", largestActorName + 1); + body = + StringHelper::Sprintf(actorNameFmt.c_str(), (ZNames::GetActorName(actorNum) + ",").c_str()); + + body += StringHelper::Sprintf("{ %6i, %6i, %6i }, ", posX, posY, posZ); + if (Globals::Instance->game == ZGame::MM_RETAIL) + body += StringHelper::Sprintf("{ SPAWN_ROT_FLAGS(%#5hX, 0x%04X)" + ", SPAWN_ROT_FLAGS(%#5hX, 0x%04X)" + ", SPAWN_ROT_FLAGS(%#5hX, 0x%04X) }, ", + (rotX >> 7) & 0b111111111, rotX & 0b1111111, + (rotY >> 7) & 0b111111111, rotY & 0b1111111, + (rotZ >> 7) & 0b111111111, rotZ & 0b1111111); + else + body += StringHelper::Sprintf("{ %#6hX, %#6hX, %#6hX }, ", rotX, rotY, rotZ); + body += StringHelper::Sprintf("0x%04X", params); + + return body; +} + +std::string ActorSpawnEntry::GetSourceTypeName() const +{ + return "ActorEntry"; +} + +size_t ActorSpawnEntry::GetRawDataSize() const +{ + return 16; +} + +uint16_t ActorSpawnEntry::GetActorId() const +{ + return actorNum; +} + +void ActorSpawnEntry::SetLargestActorName(size_t nameSize) +{ + largestActorName = nameSize; +} diff --git a/ZAPDTR/ZAPD/ZActorList.h b/ZAPDTR/ZAPD/ZActorList.h new file mode 100644 index 000000000..7cc63da2f --- /dev/null +++ b/ZAPDTR/ZAPD/ZActorList.h @@ -0,0 +1,52 @@ +#pragma once + +#include "ZResource.h" + +class ActorSpawnEntry +{ +public: + uint16_t actorNum; + int16_t posX; + int16_t posY; + int16_t posZ; + uint16_t rotX; + uint16_t rotY; + uint16_t rotZ; + uint16_t params; + size_t largestActorName = 16; + + ActorSpawnEntry(const std::vector& rawData, uint32_t rawDataIndex); + + std::string GetBodySourceCode() const; + + std::string GetSourceTypeName() const; + size_t GetRawDataSize() const; + + uint16_t GetActorId() const; + void SetLargestActorName(size_t nameSize); +}; + +class ZActorList : public ZResource +{ +public: + std::vector actors; + uint32_t numActors = 0; + + ZActorList(ZFile* nParent); + + void ExtractFromBinary(offset_t nRawDataIndex, uint8_t nNumActors); + + void ParseXML(tinyxml2::XMLElement* reader) override; + void ParseRawData() override; + + Declaration* DeclareVar(const std::string& prefix, const std::string& bodyStr) override; + std::string GetBodySourceCode() const override; + + std::string GetSourceTypeName() const override; + ZResourceType GetResourceType() const override; + + size_t GetRawDataSize() const override; + +protected: + size_t GetActorListArraySize() const; +}; diff --git a/ZAPDTR/ZAPD/ZAnimation.cpp b/ZAPDTR/ZAPD/ZAnimation.cpp index ef4735e09..199851415 100644 --- a/ZAPDTR/ZAPD/ZAnimation.cpp +++ b/ZAPDTR/ZAPD/ZAnimation.cpp @@ -4,7 +4,7 @@ #include "Globals.h" #include "Utils/BitConverter.h" -#include "Utils/File.h" +#include #include "Utils/StringHelper.h" #include "WarningHandler.h" #include "ZFile.h" @@ -67,7 +67,7 @@ void ZNormalAnimation::ParseRawData() { ZAnimation::ParseRawData(); - const uint8_t* data = parent->GetRawData().data(); + auto& data = parent->GetRawData(); rotationValuesSeg = BitConverter::ToInt32BE(data, rawDataIndex + 4); rotationIndicesSeg = BitConverter::ToInt32BE(data, rawDataIndex + 8); diff --git a/ZAPDTR/ZAPD/ZArray.cpp b/ZAPDTR/ZAPD/ZArray.cpp index 86d73e1e6..8725e28cc 100644 --- a/ZAPDTR/ZAPD/ZArray.cpp +++ b/ZAPDTR/ZAPD/ZArray.cpp @@ -44,6 +44,7 @@ void ZArray::ParseXML(tinyxml2::XMLElement* reader) auto nodeMap = ZFile::GetNodeMap(); size_t childIndex = rawDataIndex; + resList.reserve(arrayCnt); for (size_t i = 0; i < arrayCnt; i++) { ZResource* res = nodeMap->at(childName)(parent); @@ -95,17 +96,27 @@ Declaration* ZArray::DeclareVar(const std::string& prefix, const std::string& bo std::string ZArray::GetBodySourceCode() const { - std::string output = ""; + std::string output; for (size_t i = 0; i < arrayCnt; i++) { const auto& res = resList[i]; output += "\t"; - if (res->GetResourceType() == ZResourceType::Scalar || res->GetResourceType() == ZResourceType::Vertex) + switch (res->GetResourceType()) + { + case ZResourceType::Pointer: + case ZResourceType::Scalar: + case ZResourceType::Vertex: + case ZResourceType::CollisionPoly: + case ZResourceType::SurfaceType: output += resList.at(i)->GetBodySourceCode(); - else + break; + + default: output += StringHelper::Sprintf("{ %s }", resList.at(i)->GetBodySourceCode().c_str()); + break; + } if (i < arrayCnt - 1 || res->IsExternalResource()) output += ",\n"; @@ -117,7 +128,7 @@ std::string ZArray::GetBodySourceCode() const size_t ZArray::GetRawDataSize() const { size_t size = 0; - for (auto res : resList) + for (const auto res : resList) size += res->GetRawDataSize(); return size; } diff --git a/ZAPDTR/ZAPD/ZAudio.cpp b/ZAPDTR/ZAPD/ZAudio.cpp index 50bb181f2..9f2059271 100644 --- a/ZAPDTR/ZAPD/ZAudio.cpp +++ b/ZAPDTR/ZAPD/ZAudio.cpp @@ -2,7 +2,7 @@ #include "Globals.h" #include "Utils/BitConverter.h" -#include "Utils/File.h" +#include #include "Utils/Path.h" #include "Utils/StringHelper.h" #include "ZFile.h" diff --git a/ZAPDTR/ZAPD/ZBackground.cpp b/ZAPDTR/ZAPD/ZBackground.cpp index 94efe06e9..026002da1 100644 --- a/ZAPDTR/ZAPD/ZBackground.cpp +++ b/ZAPDTR/ZAPD/ZBackground.cpp @@ -2,7 +2,7 @@ #include "Globals.h" #include "Utils/BitConverter.h" -#include "Utils/File.h" +#include #include "Utils/Path.h" #include "Utils/StringHelper.h" #include "WarningHandler.h" @@ -46,7 +46,7 @@ void ZBackground::ParseBinaryFile(const std::string& inFolder, bool appendOutNam if (appendOutName) filepath = filepath / (outName + "." + GetExternalExtension()); - data = File::ReadAllBytes(filepath.string()); + data = DiskFile::ReadAllBytes(filepath.string()); // Add padding. data.insert(data.end(), GetRawDataSize() - data.size(), 0x00); @@ -153,7 +153,7 @@ void ZBackground::Save(const fs::path& outFolder) if (!Globals::Instance->otrMode) { fs::path filepath = outFolder / (outName + "." + GetExternalExtension()); - File::WriteAllBytes(filepath.string(), data); + DiskFile::WriteAllBytes(filepath.string(), data); } } diff --git a/ZAPDTR/ZAPD/ZBlob.cpp b/ZAPDTR/ZAPD/ZBlob.cpp index 759dbbc62..0965d7e4e 100644 --- a/ZAPDTR/ZAPD/ZBlob.cpp +++ b/ZAPDTR/ZAPD/ZBlob.cpp @@ -2,7 +2,7 @@ #include "Globals.h" #include "Utils/BitConverter.h" -#include "Utils/File.h" +#include #include "Utils/Path.h" #include "Utils/StringHelper.h" #include "ZFile.h" @@ -19,7 +19,7 @@ ZBlob* ZBlob::FromFile(const std::string& filePath) { ZBlob* blob = new ZBlob(nullptr); blob->name = StringHelper::Split(Path::GetFileNameWithoutExtension(filePath), ".")[0]; - blob->blobData = File::ReadAllBytes(filePath); + blob->blobData = DiskFile::ReadAllBytes(filePath); return blob; } @@ -87,7 +87,7 @@ std::string ZBlob::GetBodySourceCode() const void ZBlob::Save(const fs::path& outFolder) { if (!Globals::Instance->otrMode) - File::WriteAllBytes((outFolder / (name + ".bin")).string(), blobData); + DiskFile::WriteAllBytes((outFolder / (name + ".bin")).string(), blobData); } bool ZBlob::IsExternalResource() const diff --git a/ZAPDTR/ZAPD/ZCollision.cpp b/ZAPDTR/ZAPD/ZCollision.cpp index 2a282cf2f..e75cfe2aa 100644 --- a/ZAPDTR/ZAPD/ZCollision.cpp +++ b/ZAPDTR/ZAPD/ZCollision.cpp @@ -1,5 +1,6 @@ #include "ZCollision.h" +#include #include #include @@ -51,7 +52,7 @@ void ZCollisionHeader::ParseRawData() vertices.reserve(numVerts); polygons.reserve(numPolygons); - uint32_t currentPtr = vtxSegmentOffset; + offset_t currentPtr = vtxSegmentOffset; for (uint16_t i = 0; i < numVerts; i++) { @@ -63,23 +64,67 @@ void ZCollisionHeader::ParseRawData() } for (uint16_t i = 0; i < numPolygons; i++) - polygons.push_back(PolygonEntry(rawData, polySegmentOffset + (i * 16))); + { + ZCollisionPoly poly(parent); + poly.SetRawDataIndex(polySegmentOffset + (i * 16)); + poly.ParseRawData(); + polygons.push_back(poly); + } uint16_t highestPolyType = 0; - for (PolygonEntry poly : polygons) + for (const ZCollisionPoly& poly : polygons) { if (poly.type > highestPolyType) highestPolyType = poly.type; } for (uint16_t i = 0; i < highestPolyType + 1; i++) - polygonTypes.push_back( - BitConverter::ToUInt64BE(rawData, polyTypeDefSegmentOffset + (i * 8))); + { + ZSurfaceType surfaceType(parent); + surfaceType.SetRawDataIndex(polyTypeDefSegmentOffset + (i * 8)); + surfaceType.ParseRawData(); + PolygonTypes.push_back(surfaceType); + } + // polygonTypes.push_back( + // BitConverter::ToUInt64BE(rawData, polyTypeDefSegmentOffset + (i * 8))); - if (camDataAddress != 0) - camData = new CameraDataList(parent, name, rawData, camDataSegmentOffset, - polyTypeDefSegmentOffset, polygonTypes.size()); + if (camDataAddress != SEGMENTED_NULL) + { + // Try to guess how many elements the CamDataList array has. + // The "guessing algorithm" is basically a "best effort" one and it + // is error-prone. + // This is based mostly on observation of how CollisionHeader data is + // usually ordered. If for some reason the data was in some other funny + // order, this would probably break. + // The most common ordering is: + // - *CamData* + // - SurfaceType + // - CollisionPoly + // - Vertices + // - WaterBoxes + // - CollisionHeader + offset_t upperCameraBoundary = polyTypeDefSegmentOffset; + if (upperCameraBoundary == 0) + { + upperCameraBoundary = polySegmentOffset; + } + if (upperCameraBoundary == 0) + { + upperCameraBoundary = vtxSegmentOffset; + } + if (upperCameraBoundary == 0) + { + upperCameraBoundary = waterBoxSegmentOffset; + } + if (upperCameraBoundary == 0) + { + upperCameraBoundary = rawDataIndex; + } + + camData = + new CameraDataList(parent, name, rawData, camDataSegmentOffset, upperCameraBoundary); + } for (uint16_t i = 0; i < numWaterBoxes; i++) waterBoxes.push_back(WaterBoxHeader( @@ -110,8 +155,7 @@ void ZCollisionHeader::DeclareReferences(const std::string& prefix) parent->AddDeclarationArray( waterBoxSegmentOffset, DeclarationAlignment::Align4, 16 * waterBoxes.size(), "WaterBox", - StringHelper::Sprintf("%s_waterBoxes_%06X", auxName.c_str(), waterBoxSegmentOffset), - waterBoxes.size(), declaration); + StringHelper::Sprintf("%sWaterBoxes", auxName.c_str()), waterBoxes.size(), declaration); } if (polygons.size() > 0) @@ -122,40 +166,31 @@ void ZCollisionHeader::DeclareReferences(const std::string& prefix) { for (size_t i = 0; i < polygons.size(); i++) { - declaration += StringHelper::Sprintf( - "\t{ 0x%04X, 0x%04X, 0x%04X, 0x%04X, 0x%04X, 0x%04X, 0x%04X, 0x%04X },", - polygons[i].type, polygons[i].vtxA, polygons[i].vtxB, polygons[i].vtxC, - polygons[i].a, polygons[i].b, polygons[i].c, polygons[i].d); + declaration += + StringHelper::Sprintf("\t%s,", polygons[i].GetBodySourceCode().c_str()); if (i + 1 < polygons.size()) declaration += "\n"; } } - parent->AddDeclarationArray( - polySegmentOffset, DeclarationAlignment::Align4, polygons.size() * 16, "CollisionPoly", - StringHelper::Sprintf("%s_polygons_%08X", auxName.c_str(), polySegmentOffset), - polygons.size(), declaration); + parent->AddDeclarationArray(polySegmentOffset, DeclarationAlignment::Align4, + polygons.size() * 16, polygons[0].GetSourceTypeName().c_str(), + StringHelper::Sprintf("%sPolygons", auxName.c_str()), + polygons.size(), declaration); } declaration.clear(); - if (!Globals::Instance->otrMode) + for (const auto& polyType : PolygonTypes) { - for (size_t i = 0; i < polygonTypes.size(); i++) - { - declaration += StringHelper::Sprintf("\t{ 0x%08lX, 0x%08lX },", polygonTypes[i] >> 32, - polygonTypes[i] & 0xFFFFFFFF); - - if (i < polygonTypes.size() - 1) - declaration += "\n"; - } + declaration += StringHelper::Sprintf("\t%s,", polyType.GetBodySourceCode().c_str()); } - if (polyTypeDefAddress != 0) - parent->AddDeclarationArray( - polyTypeDefSegmentOffset, DeclarationAlignment::Align4, polygonTypes.size() * 8, - "SurfaceType", - StringHelper::Sprintf("%s_surfaceType_%08X", auxName.c_str(), polyTypeDefSegmentOffset), - polygonTypes.size(), declaration); + if (polyTypeDefAddress != SEGMENTED_NULL) + parent->AddDeclarationArray(polyTypeDefSegmentOffset, DeclarationAlignment::Align4, + PolygonTypes.size() * 8, + PolygonTypes[0].GetSourceTypeName().c_str(), + StringHelper::Sprintf("%sSurfaceType", auxName.c_str()), + PolygonTypes.size(), declaration); declaration.clear(); @@ -180,8 +215,7 @@ void ZCollisionHeader::DeclareReferences(const std::string& prefix) parent->AddDeclarationArray( vtxSegmentOffset, first.GetDeclarationAlignment(), vertices.size() * first.GetRawDataSize(), first.GetSourceTypeName(), - StringHelper::Sprintf("%s_vtx_%08X", auxName.c_str(), vtxSegmentOffset), - vertices.size(), declaration); + StringHelper::Sprintf("%sVertices", auxName.c_str()), vertices.size(), declaration); } } @@ -244,34 +278,18 @@ size_t ZCollisionHeader::GetRawDataSize() const return 44; } -PolygonEntry::PolygonEntry(const std::vector& rawData, uint32_t rawDataIndex) -{ - const uint8_t* data = rawData.data(); - - type = BitConverter::ToUInt16BE(data, rawDataIndex + 0); - vtxA = BitConverter::ToUInt16BE(data, rawDataIndex + 2); - vtxB = BitConverter::ToUInt16BE(data, rawDataIndex + 4); - vtxC = BitConverter::ToUInt16BE(data, rawDataIndex + 6); - a = BitConverter::ToUInt16BE(data, rawDataIndex + 8); - b = BitConverter::ToUInt16BE(data, rawDataIndex + 10); - c = BitConverter::ToUInt16BE(data, rawDataIndex + 12); - d = BitConverter::ToUInt16BE(data, rawDataIndex + 14); -} - WaterBoxHeader::WaterBoxHeader(const std::vector& rawData, uint32_t rawDataIndex) { - const uint8_t* data = rawData.data(); - - xMin = BitConverter::ToInt16BE(data, rawDataIndex + 0); - ySurface = BitConverter::ToInt16BE(data, rawDataIndex + 2); - zMin = BitConverter::ToInt16BE(data, rawDataIndex + 4); - xLength = BitConverter::ToInt16BE(data, rawDataIndex + 6); - zLength = BitConverter::ToInt16BE(data, rawDataIndex + 8); + xMin = BitConverter::ToInt16BE(rawData, rawDataIndex + 0); + ySurface = BitConverter::ToInt16BE(rawData, rawDataIndex + 2); + zMin = BitConverter::ToInt16BE(rawData, rawDataIndex + 4); + xLength = BitConverter::ToInt16BE(rawData, rawDataIndex + 6); + zLength = BitConverter::ToInt16BE(rawData, rawDataIndex + 8); if (Globals::Instance->game == ZGame::OOT_SW97) - properties = BitConverter::ToInt16BE(data, rawDataIndex + 10); + properties = BitConverter::ToInt16BE(rawData, rawDataIndex + 10); else - properties = BitConverter::ToInt32BE(data, rawDataIndex + 12); + properties = BitConverter::ToInt32BE(rawData, rawDataIndex + 12); } std::string WaterBoxHeader::GetBodySourceCode() const @@ -281,16 +299,17 @@ std::string WaterBoxHeader::GetBodySourceCode() const } CameraDataList::CameraDataList(ZFile* parent, const std::string& prefix, - const std::vector& rawData, uint32_t rawDataIndex, - uint32_t polyTypeDefSegmentOffset, - [[maybe_unused]] uint32_t polygonTypesCnt) + const std::vector& rawData, offset_t rawDataIndex, + offset_t upperCameraBoundary) { std::string declaration; // Parse CameraDataEntries - int32_t numElements = (polyTypeDefSegmentOffset - rawDataIndex) / 8; - uint32_t cameraPosDataSeg = rawDataIndex; - for (int32_t i = 0; i < numElements; i++) + size_t numElements = (upperCameraBoundary - rawDataIndex) / 8; + assert(numElements < 10000); + + offset_t cameraPosDataSeg = rawDataIndex; + for (size_t i = 0; i < numElements; i++) { CameraDataEntry* entry = new CameraDataEntry(); @@ -322,8 +341,7 @@ CameraDataList::CameraDataList(ZFile* parent, const std::string& prefix, { int32_t index = ((entries[i]->cameraPosDataSeg & 0x00FFFFFF) - cameraPosDataOffset) / 0x6; - sprintf(camSegLine, "&%s_camPosData_%08X[%i]", prefix.c_str(), cameraPosDataOffset, - index); + sprintf(camSegLine, "&%sCamPosData[%i]", prefix.c_str(), index); } else sprintf(camSegLine, "NULL"); @@ -338,7 +356,7 @@ CameraDataList::CameraDataList(ZFile* parent, const std::string& prefix, parent->AddDeclarationArray( rawDataIndex, DeclarationAlignment::Align4, entries.size() * 8, "CamData", - StringHelper::Sprintf("%s_camDataList_%08X", prefix.c_str(), rawDataIndex), entries.size(), + StringHelper::Sprintf("%sCamDataList", prefix.c_str(), rawDataIndex), entries.size(), declaration); uint32_t numDataTotal = (rawDataIndex - cameraPosDataOffset) / 0x6; @@ -359,10 +377,9 @@ CameraDataList::CameraDataList(ZFile* parent, const std::string& prefix, int32_t cameraPosDataIndex = GETSEGOFFSET(cameraPosDataSeg); uint32_t entrySize = numDataTotal * 0x6; - parent->AddDeclarationArray( - cameraPosDataIndex, DeclarationAlignment::Align4, entrySize, "Vec3s", - StringHelper::Sprintf("%s_camPosData_%08X", prefix.c_str(), cameraPosDataIndex), - numDataTotal, declaration); + parent->AddDeclarationArray(cameraPosDataIndex, DeclarationAlignment::Align4, entrySize, + "Vec3s", StringHelper::Sprintf("%sCamPosData", prefix.c_str()), + numDataTotal, declaration); } } diff --git a/ZAPDTR/ZAPD/ZCollision.h b/ZAPDTR/ZAPD/ZCollision.h index 4bce7c944..7db03bf16 100644 --- a/ZAPDTR/ZAPD/ZCollision.h +++ b/ZAPDTR/ZAPD/ZCollision.h @@ -1,20 +1,12 @@ #pragma once +#include "ZCollisionPoly.h" #include "ZFile.h" #include "ZResource.h" #include "ZRoom/ZRoom.h" +#include "ZSurfaceType.h" #include "ZVector.h" -class PolygonEntry -{ -public: - uint16_t type; - uint16_t vtxA, vtxB, vtxC; - uint16_t a, b, c, d; - - PolygonEntry(const std::vector& rawData, uint32_t rawDataIndex); -}; - class WaterBoxHeader { public: @@ -54,8 +46,7 @@ public: std::vector cameraPositionData; CameraDataList(ZFile* parent, const std::string& prefix, const std::vector& rawData, - uint32_t rawDataIndex, uint32_t polyTypeDefSegmentOffset, - uint32_t polygonTypesCnt); + offset_t rawDataIndex, offset_t upperCameraBoundary); ~CameraDataList(); }; @@ -78,8 +69,8 @@ public: waterBoxSegmentOffset; std::vector vertices; - std::vector polygons; - std::vector polygonTypes; + std::vector polygons; + std::vector PolygonTypes; std::vector waterBoxes; CameraDataList* camData = nullptr; diff --git a/ZAPDTR/ZAPD/ZCollisionPoly.cpp b/ZAPDTR/ZAPD/ZCollisionPoly.cpp new file mode 100644 index 000000000..c4eb2d461 --- /dev/null +++ b/ZAPDTR/ZAPD/ZCollisionPoly.cpp @@ -0,0 +1,78 @@ +#include "ZCollisionPoly.h" + +#include "Globals.h" +#include "Utils/BitConverter.h" +#include "Utils/StringHelper.h" + +REGISTER_ZFILENODE(CollisionPoly, ZCollisionPoly); + +ZCollisionPoly::ZCollisionPoly(ZFile* nParent) : ZResource(nParent) +{ +} + +ZCollisionPoly::~ZCollisionPoly() +{ +} + +void ZCollisionPoly::ParseRawData() +{ + const auto& rawData = parent->GetRawData(); + type = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0); + + vtxA = BitConverter::ToUInt16BE(rawData, rawDataIndex + 2); + vtxB = BitConverter::ToUInt16BE(rawData, rawDataIndex + 4); + vtxC = BitConverter::ToUInt16BE(rawData, rawDataIndex + 6); + + normX = BitConverter::ToUInt16BE(rawData, rawDataIndex + 8); + normY = BitConverter::ToUInt16BE(rawData, rawDataIndex + 10); + normZ = BitConverter::ToUInt16BE(rawData, rawDataIndex + 12); + + dist = BitConverter::ToUInt16BE(rawData, rawDataIndex + 14); +} + +void ZCollisionPoly::DeclareReferences(const std::string& prefix) +{ + std::string declaration; + std::string auxName = name; + + if (name == "") + auxName = GetDefaultName(prefix); + + parent->AddDeclaration(rawDataIndex, DeclarationAlignment::Align4, GetRawDataSize(), + GetSourceTypeName(), name.c_str(), GetBodySourceCode()); +} + +std::string ZCollisionPoly::GetBodySourceCode() const +{ + std::string declaration; + + declaration += + StringHelper::Sprintf("{0x%04X, 0x%04X, 0x%04X, 0x%04X, 0x%04X, 0x%04X, 0x%04X, 0x%04X}", + type, vtxA, vtxB, vtxC, normX, normY, normZ, dist); + return declaration; +} + +std::string ZCollisionPoly::GetDefaultName(const std::string& prefix) const +{ + return StringHelper::Sprintf("%sCollisionPoly_%06X", prefix.c_str(), rawDataIndex); +} + +ZResourceType ZCollisionPoly::GetResourceType() const +{ + return ZResourceType::CollisionPoly; +} + +size_t ZCollisionPoly::GetRawDataSize() const +{ + return 16; +} + +std::string ZCollisionPoly::GetSourceTypeName() const +{ + return "CollisionPoly"; +} + +bool ZCollisionPoly::DoesSupportArray() const +{ + return true; +} \ No newline at end of file diff --git a/ZAPDTR/ZAPD/ZCollisionPoly.h b/ZAPDTR/ZAPD/ZCollisionPoly.h new file mode 100644 index 000000000..64b98ba1d --- /dev/null +++ b/ZAPDTR/ZAPD/ZCollisionPoly.h @@ -0,0 +1,29 @@ +#pragma once + +#include "ZFile.h" +#include "ZResource.h" + +class ZCollisionPoly : public ZResource +{ +public: + uint16_t type; + uint16_t vtxA, vtxB, vtxC; + uint16_t normX, normY, normZ; + uint16_t dist; + + ZCollisionPoly(ZFile* nParent); + ~ZCollisionPoly(); + + void ParseRawData() override; + void DeclareReferences(const std::string& prefix) override; + + std::string GetBodySourceCode() const override; + std::string GetDefaultName(const std::string& prefix) const override; + + std::string GetSourceTypeName() const override; + ZResourceType GetResourceType() const override; + + bool DoesSupportArray() const override; + + size_t GetRawDataSize() const override; +}; \ No newline at end of file diff --git a/ZAPDTR/ZAPD/ZCutscene.cpp b/ZAPDTR/ZAPD/ZCutscene.cpp index 69fbd9e48..605894979 100644 --- a/ZAPDTR/ZAPD/ZCutscene.cpp +++ b/ZAPDTR/ZAPD/ZCutscene.cpp @@ -1,5 +1,9 @@ #include "ZCutscene.h" +#include + +#include "Globals.h" +#include "OtherStructs/CutsceneMM_Commands.h" #include "Utils/BitConverter.h" #include "Utils/StringHelper.h" #include "WarningHandler.h" @@ -7,7 +11,7 @@ REGISTER_ZFILENODE(Cutscene, ZCutscene); -ZCutscene::ZCutscene(ZFile* nParent) : ZCutsceneBase(nParent) +ZCutscene::ZCutscene(ZFile* nParent) : ZResource(nParent) { genOTRDef = true; } @@ -17,91 +21,20 @@ ZCutscene::~ZCutscene() for (CutsceneCommand* cmd : commands) delete cmd; } -CutsceneCommandSetCameraPos::~CutsceneCommandSetCameraPos() -{ - for (auto e : entries) - delete e; -} - -CutsceneCommandSpecialAction::~CutsceneCommandSpecialAction() -{ - for (auto e : entries) - delete e; -} - -CutsceneCommandFadeBGM::~CutsceneCommandFadeBGM() -{ - for (auto e : entries) - delete e; -} - -CutsceneCommandPlayBGM::~CutsceneCommandPlayBGM() -{ - for (auto e : entries) - delete e; -} - -CutsceneCommandStopBGM::~CutsceneCommandStopBGM() -{ - for (auto e : entries) - delete e; -} - -CutsceneCommandEnvLighting::~CutsceneCommandEnvLighting() -{ - for (auto e : entries) - delete e; -} - -CutsceneCommandUnknown9::~CutsceneCommandUnknown9() -{ - for (auto e : entries) - delete e; -} - -CutsceneCommandUnknown::~CutsceneCommandUnknown() -{ - for (auto e : entries) - delete e; -} - -CutsceneCommandDayTime::~CutsceneCommandDayTime() -{ - for (auto e : entries) - delete e; -} - -CutsceneCommandTextbox::~CutsceneCommandTextbox() -{ - for (auto e : entries) - delete e; -} - -CutsceneCommandActorAction::~CutsceneCommandActorAction() -{ - for (auto e : entries) - delete e; -} - -CutsceneCommandSceneTransFX::~CutsceneCommandSceneTransFX() -{ -} std::string ZCutscene::GetBodySourceCode() const { std::string output = ""; - uint32_t curPtr = 0; output += StringHelper::Sprintf(" CS_BEGIN_CUTSCENE(%i, %i),\n", commands.size(), endFrame); for (size_t i = 0; i < commands.size(); i++) { CutsceneCommand* cmd = commands[i]; - output += " " + cmd->GenerateSourceCode(curPtr); - curPtr += cmd->GetCommandSize(); + output += " " + cmd->GenerateSourceCode(); } - output += StringHelper::Sprintf(" CS_END(),\n", commands.size(), endFrame); + output += StringHelper::Sprintf(" CS_END(),", commands.size(), endFrame); return output; } @@ -116,12 +49,19 @@ size_t ZCutscene::GetRawDataSize() const for (size_t i = 0; i < commands.size(); i++) { CutsceneCommand* cmd = commands[i]; + size += cmd->GetCommandSize(); - size += 4; } // End - size += 8; + if (Globals::Instance->game == ZGame::MM_RETAIL) + { + size += 4; + } + else + { + size += 8; + } return size; } @@ -136,153 +76,68 @@ void ZCutscene::ParseRawData() commands = std::vector(); endFrame = BitConverter::ToInt32BE(rawData, rawDataIndex + 4); - uint32_t currentPtr = rawDataIndex + 8; - + offset_t currentPtr = rawDataIndex + 8; + commands.reserve(numCommands); for (int32_t i = 0; i < numCommands; i++) { - int32_t id = BitConverter::ToInt32BE(rawData, currentPtr); + uint32_t id = BitConverter::ToUInt32BE(rawData, currentPtr); - if (id == -1) + if (id == 0xFFFFFFFF) break; - CutsceneCommands cmdID = (CutsceneCommands)GetCommandFromID(id); + if (Globals::Instance->verbosity >= VerbosityLevel::VERBOSITY_DEBUG) + { + printf("Cutscene Command: 0x%X (%i)\n", id, id); + } + currentPtr += 4; - int32_t numEntries = 1; + CutsceneCommand* cmd = nullptr; - for (int32_t j = 0; j < numEntries; j++) + if (Globals::Instance->game == ZGame::MM_RETAIL) { - CutsceneCommand* cmd = nullptr; - - switch (cmdID) - { - case CutsceneCommands::Cmd00: - break; - case CutsceneCommands::SetCameraPos: - cmd = new CutsceneCommandSetCameraPos(rawData, currentPtr); - break; - case CutsceneCommands::SetCameraFocus: - cmd = new CutsceneCommandSetCameraPos(rawData, currentPtr); - break; - case CutsceneCommands::SpecialAction: - cmd = new CutsceneCommandSpecialAction(rawData, currentPtr); - break; - case CutsceneCommands::SetLighting: - cmd = new CutsceneCommandEnvLighting(rawData, currentPtr); - break; - case CutsceneCommands::SetCameraPosLink: - cmd = new CutsceneCommandSetCameraPos(rawData, currentPtr); - break; - case CutsceneCommands::SetCameraFocusLink: - cmd = new CutsceneCommandSetCameraPos(rawData, currentPtr); - break; - case CutsceneCommands::Cmd07: - break; - case CutsceneCommands::Cmd08: - break; - case CutsceneCommands::Cmd09: - cmd = new CutsceneCommandUnknown9(rawData, currentPtr); - break; - case CutsceneCommands::Textbox: - cmd = new CutsceneCommandTextbox(rawData, currentPtr); - break; - case CutsceneCommands::Unknown: - cmd = new CutsceneCommandUnknown(rawData, currentPtr); - break; - case CutsceneCommands::SetActorAction0: - case CutsceneCommands::SetActorAction1: - case CutsceneCommands::SetActorAction2: - case CutsceneCommands::SetActorAction3: - case CutsceneCommands::SetActorAction4: - case CutsceneCommands::SetActorAction5: - case CutsceneCommands::SetActorAction6: - case CutsceneCommands::SetActorAction7: - case CutsceneCommands::SetActorAction8: - case CutsceneCommands::SetActorAction9: - case CutsceneCommands::SetActorAction10: - cmd = new CutsceneCommandActorAction(rawData, currentPtr); - break; - case CutsceneCommands::SetSceneTransFX: - cmd = new CutsceneCommandSceneTransFX(rawData, currentPtr); - break; - case CutsceneCommands::Nop: - cmd = new CutsceneCommandNop(rawData, currentPtr); - break; - case CutsceneCommands::PlayBGM: - cmd = new CutsceneCommandPlayBGM(rawData, currentPtr); - break; - case CutsceneCommands::StopBGM: - cmd = new CutsceneCommandStopBGM(rawData, currentPtr); - break; - case CutsceneCommands::FadeBGM: - cmd = new CutsceneCommandFadeBGM(rawData, currentPtr); - break; - case CutsceneCommands::SetTime: - cmd = new CutsceneCommandDayTime(rawData, currentPtr); - break; - case CutsceneCommands::Terminator: - cmd = new CutsceneCommandTerminator(rawData, currentPtr); - break; - case CutsceneCommands::End: - cmd = new CutsceneCommandEnd(rawData, currentPtr); - break; - case CutsceneCommands::Error: - HANDLE_WARNING_RESOURCE(WarningType::NotImplemented, parent, this, rawDataIndex, - StringHelper::Sprintf("cutscene command error %d", cmdID), - ""); - break; - } - - cmd->commandIndex = i; - cmd->commandID = (uint32_t)id; - currentPtr += (uint32_t)cmd->GetCommandSize(); - - commands.push_back(cmd); + cmd = GetCommandMM(id, currentPtr); } + else + { + cmd = GetCommandOoT(id, currentPtr); + } + + if (cmd == nullptr) + { + HANDLE_WARNING_RESOURCE( + WarningType::NotImplemented, parent, this, rawDataIndex, + StringHelper::Sprintf("Cutscene command not implemented"), + StringHelper::Sprintf("Command ID: 0x%X\nIndex: %d\ncurrentPtr-rawDataIndex: 0x%X", + id, i, currentPtr - rawDataIndex)); + cmd = new CutsceneMMCommand_NonImplemented(rawData, currentPtr); + } + + assert(cmd != nullptr); + + cmd->commandIndex = i; + cmd->SetCommandID(id); + size_t commmandSize = cmd->GetCommandSize(); + if (Globals::Instance->verbosity >= VerbosityLevel::VERBOSITY_DEBUG) + { + printf("\t Command size: 0x%zX (%zu)\n", commmandSize, commmandSize); + } + currentPtr += commmandSize - 4; + + commands.push_back(cmd); } } -CutsceneCommands ZCutscene::GetCommandFromID(int32_t id) +CutsceneCommand* ZCutscene::GetCommandOoT(uint32_t id, offset_t currentPtr) const { + CutsceneCommands cmdID = static_cast(id); + + const auto& rawData = parent->GetRawData(); + switch (id) { - case 0x0003: - return CutsceneCommands::SpecialAction; - case 0x0004: - return CutsceneCommands::SetLighting; - case 0x0056: - return CutsceneCommands::PlayBGM; - case 0x0057: - return CutsceneCommands::StopBGM; - case 0x007C: - return CutsceneCommands::FadeBGM; - case 0x0009: - return CutsceneCommands::Cmd09; - case 0x0013: - return CutsceneCommands::Textbox; - case 0x008C: - return CutsceneCommands::SetTime; - case 0x0001: - return CutsceneCommands::SetCameraPos; - case 0x0002: - return CutsceneCommands::SetCameraFocus; - case 0x0005: - return CutsceneCommands::SetCameraPosLink; - case 0x0006: - return CutsceneCommands::SetCameraFocusLink; - case 0x0007: - return CutsceneCommands::Cmd07; - case 0x0008: - return CutsceneCommands::Cmd08; - case 0x03E8: - return CutsceneCommands::Terminator; - case 0xFFFF: - return CutsceneCommands::End; - case 0x002D: - return CutsceneCommands::SetSceneTransFX; - case 10: - return CutsceneCommands::SetActorAction0; - case 15: + case 10: // CutsceneCommands::SetPlayerAction + case 15: // CutsceneCommands::SetActorAction1 case 17: case 18: case 23: @@ -300,8 +155,7 @@ CutsceneCommands ZCutscene::GetCommandFromID(int32_t id) case 138: case 139: case 144: - return CutsceneCommands::SetActorAction1; - case 14: + case 14: // CutsceneCommands::SetActorAction2 case 16: case 24: case 35: @@ -319,8 +173,7 @@ CutsceneCommands ZCutscene::GetCommandFromID(int32_t id) case 125: case 131: case 141: - return CutsceneCommands::SetActorAction2; - case 25: + case 25: // CutsceneCommands::SetActorAction3 case 36: case 41: case 50: @@ -333,8 +186,7 @@ CutsceneCommands ZCutscene::GetCommandFromID(int32_t id) case 121: case 126: case 132: - return CutsceneCommands::SetActorAction3; - case 29: + case 29: // CutsceneCommands::SetActorAction4 case 37: case 42: case 51: @@ -347,8 +199,7 @@ CutsceneCommands ZCutscene::GetCommandFromID(int32_t id) case 108: case 127: case 133: - return CutsceneCommands::SetActorAction4; - case 30: + case 30: // CutsceneCommands::SetActorAction5 case 38: case 43: case 47: @@ -357,16 +208,14 @@ CutsceneCommands ZCutscene::GetCommandFromID(int32_t id) case 83: case 128: case 135: - return CutsceneCommands::SetActorAction5; - case 44: + case 44: // CutsceneCommands::SetActorAction6 case 55: case 77: case 84: case 90: case 129: case 136: - return CutsceneCommands::SetActorAction6; - case 31: + case 31: // CutsceneCommands::SetActorAction7 case 52: case 57: case 58: @@ -374,19 +223,17 @@ CutsceneCommands ZCutscene::GetCommandFromID(int32_t id) case 115: case 130: case 137: - return CutsceneCommands::SetActorAction7; - case 49: + case 49: // CutsceneCommands::SetActorAction8 case 60: case 89: case 111: case 114: case 134: case 142: - return CutsceneCommands::SetActorAction8; - case 62: - return CutsceneCommands::SetActorAction9; - case 143: - return CutsceneCommands::SetActorAction10; + case 62: // CutsceneCommands::SetActorAction9 + case 143: // CutsceneCommands::SetActorAction10 + return new CutsceneCommand_ActorAction(rawData, currentPtr); + case 0x0B: case 0x0D: case 0x1A: @@ -404,843 +251,120 @@ CutsceneCommands ZCutscene::GetCommandFromID(int32_t id) case 0x70: case 0x71: case 0x4A: - return CutsceneCommands::Unknown; + return new CutsceneCommand_GenericCmd(rawData, currentPtr, cmdID); } - HANDLE_WARNING_RESOURCE( - WarningType::NotImplemented, parent, this, rawDataIndex, - StringHelper::Sprintf("could not identify cutscene command. ID 0x%04X", id), ""); - - return CutsceneCommands::Error; -} - -ZResourceType ZCutscene::GetResourceType() const -{ - return ZResourceType::Cutscene; -} - -CutsceneCommand::CutsceneCommand([[maybe_unused]] const std::vector& rawData, - [[maybe_unused]] uint32_t rawDataIndex) -{ -} - -CutsceneCommand::~CutsceneCommand() -{ -} - -std::string CutsceneCommand::GetCName() -{ - return "SCmdCutsceneData"; -} - -std::string CutsceneCommand::GenerateSourceCode(uint32_t baseAddress) -{ - return StringHelper::Sprintf("%s CutsceneData%04XCmd%02X = { 0x%02X,", GetCName().c_str(), - baseAddress, commandIndex, commandID); -} - -size_t CutsceneCommand::GetCommandSize() -{ - return 4; -} - -CutsceneCameraPoint::CutsceneCameraPoint(const std::vector& rawData, uint32_t rawDataIndex) -{ - const uint8_t* data = rawData.data(); - - continueFlag = data[rawDataIndex + 0]; - cameraRoll = data[rawDataIndex + 1]; - nextPointFrame = BitConverter::ToInt16BE(data, rawDataIndex + 2); - viewAngle = BitConverter::ToFloatBE(data, rawDataIndex + 4); - - posX = BitConverter::ToInt16BE(data, rawDataIndex + 8); - posY = BitConverter::ToInt16BE(data, rawDataIndex + 10); - posZ = BitConverter::ToInt16BE(data, rawDataIndex + 12); - - unused = BitConverter::ToInt16BE(data, rawDataIndex + 14); -} - -CutsceneCommandSetCameraPos::CutsceneCommandSetCameraPos(const std::vector& rawData, - uint32_t rawDataIndex) - : CutsceneCommand(rawData, rawDataIndex) -{ - const uint8_t* data = rawData.data(); - - base = BitConverter::ToUInt16BE(data, rawDataIndex + 0); - startFrame = BitConverter::ToUInt16BE(data, rawDataIndex + 2); - endFrame = BitConverter::ToUInt16BE(data, rawDataIndex + 4); - unused = BitConverter::ToUInt16BE(data, rawDataIndex + 6); - - entries = std::vector(); - - bool shouldContinue = true; - - uint32_t currentPtr = rawDataIndex + 8; - - while (shouldContinue) + switch (cmdID) { - CutsceneCameraPoint* camPoint = new CutsceneCameraPoint(rawData, currentPtr); - entries.push_back(camPoint); + case CutsceneCommands::Misc: + case CutsceneCommands::SetLighting: + case CutsceneCommands::PlayBGM: + case CutsceneCommands::StopBGM: + case CutsceneCommands::FadeBGM: + return new CutsceneCommand_GenericCmd(rawData, currentPtr, cmdID); - if (camPoint->continueFlag == -1) - shouldContinue = false; + case CutsceneCommands::SetCameraPos: + case CutsceneCommands::SetCameraFocus: + case CutsceneCommands::SetCameraPosLink: + case CutsceneCommands::SetCameraFocusLink: + return new CutsceneCommandSetCameraPos(rawData, currentPtr); - currentPtr += 16; + case CutsceneCommands::Cmd07: + break; + case CutsceneCommands::Cmd08: + break; + case CutsceneCommands::Cmd09: + return new CutsceneCommand_Rumble(rawData, currentPtr); + case CutsceneCommands::Textbox: + return new CutsceneCommand_TextBox(rawData, currentPtr); + + case CutsceneCommands::SetPlayerAction: + case CutsceneCommands::SetActorAction1: + case CutsceneCommands::SetActorAction2: + case CutsceneCommands::SetActorAction3: + case CutsceneCommands::SetActorAction4: + case CutsceneCommands::SetActorAction5: + case CutsceneCommands::SetActorAction6: + case CutsceneCommands::SetActorAction7: + case CutsceneCommands::SetActorAction8: + case CutsceneCommands::SetActorAction9: + case CutsceneCommands::SetActorAction10: + break; + + case CutsceneCommands::SetSceneTransFX: + return new CutsceneCommandSceneTransFX(rawData, currentPtr); + + case CutsceneCommands::SetTime: + return new CutsceneCommand_SetTime(rawData, currentPtr); + case CutsceneCommands::Terminator: + return new CutsceneCommand_Terminator(rawData, currentPtr); } + + return nullptr; } -// TODO -std::string CutsceneCommandSetCameraPos::GetCName() +CutsceneCommand* ZCutscene::GetCommandMM(uint32_t id, offset_t currentPtr) const { - return ""; -} + CutsceneMMCommands cmdID = static_cast(id); -std::string CutsceneCommandSetCameraPos::GenerateSourceCode([[maybe_unused]] uint32_t baseAddress) -{ - std::string result; + const auto& rawData = parent->GetRawData(); - std::string listStr; - std::string posStr; - - if (commandID == (int32_t)CutsceneCommands::SetCameraFocus) + if (((id >= 100) && (id < 150)) || (id == 201) || ((id >= 450) && (id < 600))) { - listStr = "CS_CAM_FOCUS_POINT_LIST"; - posStr = "CS_CAM_FOCUS_POINT"; + return new CutsceneCommand_ActorAction(rawData, currentPtr); } - else if (commandID == (int32_t)CutsceneCommands::SetCameraFocusLink) + + switch (cmdID) { - listStr = "CS_CAM_FOCUS_POINT_PLAYER_LIST"; - posStr = "CS_CAM_FOCUS_POINT_PLAYER"; - } - else if (commandID == (int32_t)CutsceneCommands::SetCameraPosLink) - { - listStr = "CS_CAM_POS_PLAYER_LIST"; - posStr = "CS_CAM_POS_PLAYER"; - } - else - { - listStr = "CS_CAM_POS_LIST"; - posStr = "CS_CAM_POS"; + case CutsceneMMCommands::CS_CMD_MISC: + case CutsceneMMCommands::CS_CMD_SET_LIGHTING: + case CutsceneMMCommands::CS_CMD_SCENE_TRANS_FX: + case CutsceneMMCommands::CS_CMD_MOTIONBLUR: + case CutsceneMMCommands::CS_CMD_GIVETATL: + case CutsceneMMCommands::CS_CMD_PLAYSEQ: + case CutsceneMMCommands::CS_CMD_130: + case CutsceneMMCommands::CS_CMD_131: + case CutsceneMMCommands::CS_CMD_132: + case CutsceneMMCommands::CS_CMD_STOPSEQ: + case CutsceneMMCommands::CS_CMD_PLAYAMBIENCE: + case CutsceneMMCommands::CS_CMD_FADEAMBIENCE: + case CutsceneMMCommands::CS_CMD_TERMINATOR: + case CutsceneMMCommands::CS_CMD_CHOOSE_CREDITS_SCENES: + + case CutsceneMMCommands::CS_CMD_UNK_FA: + case CutsceneMMCommands::CS_CMD_UNK_FE: + case CutsceneMMCommands::CS_CMD_UNK_FF: + case CutsceneMMCommands::CS_CMD_UNK_100: + case CutsceneMMCommands::CS_CMD_UNK_101: + case CutsceneMMCommands::CS_CMD_UNK_102: + case CutsceneMMCommands::CS_CMD_UNK_103: + case CutsceneMMCommands::CS_CMD_UNK_104: + case CutsceneMMCommands::CS_CMD_UNK_105: + case CutsceneMMCommands::CS_CMD_UNK_108: + case CutsceneMMCommands::CS_CMD_UNK_109: + case CutsceneMMCommands::CS_CMD_UNK_12D: + return new CutsceneMMCommand_GenericCmd(rawData, currentPtr, cmdID); + + case CutsceneMMCommands::CS_CMD_TEXTBOX: + return new CutsceneCommand_TextBox(rawData, currentPtr); + case CutsceneMMCommands::CS_CMD_CAMERA: + return new CutsceneMMCommand_Camera(rawData, currentPtr); + case CutsceneMMCommands::CS_CMD_FADESCREEN: + return new CutsceneMMCommand_FadeScreen(rawData, currentPtr); + case CutsceneMMCommands::CS_CMD_FADESEQ: + return new CutsceneMMCommand_FadeSeq(rawData, currentPtr); + case CutsceneMMCommands::CS_CMD_SETTIME: + return new CutsceneCommand_SetTime(rawData, currentPtr); + case CutsceneMMCommands::CS_CMD_SET_PLAYER_ACTION: + return new CutsceneCommand_ActorAction(rawData, currentPtr); + case CutsceneMMCommands::CS_CMD_RUMBLE: + return new CutsceneCommand_Rumble(rawData, currentPtr); } - result += StringHelper::Sprintf("%s(%i, %i),\n", listStr.c_str(), startFrame, endFrame); - - for (size_t i = 0; i < entries.size(); i++) - { - std::string continueMacro = "CS_CMD_CONTINUE"; - if (entries[i]->continueFlag != 0) - continueMacro = "CS_CMD_STOP"; - result += StringHelper::Sprintf(" %s(%s, 0x%02X, %i, %ff, %i, %i, %i, 0x%04X),\n", - posStr.c_str(), continueMacro.c_str(), - entries[i]->cameraRoll, entries[i]->nextPointFrame, - entries[i]->viewAngle, entries[i]->posX, entries[i]->posY, - entries[i]->posZ, entries[i]->unused); - } - - return result; -} - -size_t CutsceneCommandSetCameraPos::GetCommandSize() -{ - return 8 + (entries.size() * 16); -} - -MusicFadeEntry::MusicFadeEntry(const std::vector& rawData, uint32_t rawDataIndex) -{ - base = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0); - startFrame = BitConverter::ToUInt16BE(rawData, rawDataIndex + 2); - endFrame = BitConverter::ToUInt16BE(rawData, rawDataIndex + 4); - unknown0 = BitConverter::ToUInt16BE(rawData, rawDataIndex + 6); - unknown1 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 8); - unknown2 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 12); - unknown3 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 16); - unknown4 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 20); - unknown5 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 24); - unknown6 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 28); - unknown7 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 32); - unknown8 = BitConverter::ToUInt32BE(rawData, - rawDataIndex + 36); // Macro hardcodes it as zero - unknown9 = BitConverter::ToUInt32BE(rawData, - rawDataIndex + 40); // Macro hardcodes it as zero - unknown10 = BitConverter::ToUInt32BE(rawData, - rawDataIndex + 44); // Macro hardcodes it as zero -} - -CutsceneCommandFadeBGM::CutsceneCommandFadeBGM(const std::vector& rawData, - uint32_t rawDataIndex) - : CutsceneCommand(rawData, rawDataIndex) -{ - uint32_t numEntries = BitConverter::ToUInt32BE(rawData, rawDataIndex + 0); - - rawDataIndex += 4; - - for (uint32_t i = 0; i < numEntries; i++) - { - entries.push_back(new MusicFadeEntry(rawData, rawDataIndex)); - rawDataIndex += 0x30; - } -} - -std::string CutsceneCommandFadeBGM::GetCName() -{ - return "CsCmdMusicFade"; -} - -std::string CutsceneCommandFadeBGM::GenerateSourceCode([[maybe_unused]] uint32_t baseAddress) -{ - std::string result; - - result += StringHelper::Sprintf("CS_FADE_BGM_LIST(%i),\n", entries.size()); - - for (size_t i = 0; i < entries.size(); i++) - { - result += StringHelper::Sprintf( - " CS_FADE_BGM(%i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i),\n", entries[i]->base, - entries[i]->startFrame, entries[i]->endFrame, entries[i]->unknown0, - entries[i]->unknown1, entries[i]->unknown2, entries[i]->unknown3, entries[i]->unknown4, - entries[i]->unknown5, entries[i]->unknown6, entries[i]->unknown7); - } - - return result; -} - -size_t CutsceneCommandFadeBGM::GetCommandSize() -{ - return CutsceneCommand::GetCommandSize() + 0x30 * entries.size(); -} - -MusicChangeEntry::MusicChangeEntry(const std::vector& rawData, uint32_t rawDataIndex) -{ - sequence = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0); - startFrame = BitConverter::ToUInt16BE(rawData, rawDataIndex + 2); - endFrame = BitConverter::ToUInt16BE(rawData, rawDataIndex + 4); - unknown0 = BitConverter::ToUInt16BE(rawData, rawDataIndex + 6); - unknown1 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 8); - unknown2 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 12); - unknown3 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 16); - unknown4 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 20); - unknown5 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 24); - unknown6 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 28); - unknown7 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 32); -} - -CutsceneCommandPlayBGM::CutsceneCommandPlayBGM(const std::vector& rawData, - uint32_t rawDataIndex) - : CutsceneCommand(rawData, rawDataIndex) -{ - uint32_t numEntries = BitConverter::ToUInt32BE(rawData, rawDataIndex + 0); - - rawDataIndex += 4; - - for (uint32_t i = 0; i < numEntries; i++) - { - entries.push_back(new MusicChangeEntry(rawData, rawDataIndex)); - rawDataIndex += 0x30; - } -} - -std::string CutsceneCommandPlayBGM::GenerateSourceCode([[maybe_unused]] uint32_t baseAddress) -{ - std::string result; - - result += StringHelper::Sprintf("CS_PLAY_BGM_LIST(%i),\n", entries.size()); - - for (size_t i = 0; i < entries.size(); i++) - { - result += StringHelper::Sprintf( - " CS_PLAY_BGM(%i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i),\n", - entries[i]->sequence, entries[i]->startFrame, entries[i]->endFrame, - entries[i]->unknown0, entries[i]->unknown1, entries[i]->unknown2, entries[i]->unknown3, - entries[i]->unknown4, entries[i]->unknown5, entries[i]->unknown6, entries[i]->unknown7); - } - - return result; -} - -std::string CutsceneCommandPlayBGM::GetCName() -{ - return "CsCmdMusicChange"; -} - -size_t CutsceneCommandPlayBGM::GetCommandSize() -{ - return CutsceneCommand::GetCommandSize() + 0x30; -} - -CutsceneCommandStopBGM::CutsceneCommandStopBGM(const std::vector& rawData, - uint32_t rawDataIndex) - : CutsceneCommand(rawData, rawDataIndex) -{ - uint32_t numEntries = BitConverter::ToUInt32BE(rawData, rawDataIndex + 0); - - rawDataIndex += 4; - - for (uint32_t i = 0; i < numEntries; i++) - { - entries.push_back(new MusicChangeEntry(rawData, rawDataIndex)); - rawDataIndex += 0x30; - } -} - -std::string CutsceneCommandStopBGM::GenerateSourceCode([[maybe_unused]] uint32_t baseAddress) -{ - std::string result; - - result += StringHelper::Sprintf("CS_STOP_BGM_LIST(%i),\n", entries.size()); - - for (size_t i = 0; i < entries.size(); i++) - { - result += StringHelper::Sprintf( - "\t\tCS_STOP_BGM(%i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i),\n", entries[i]->sequence, - entries[i]->startFrame, entries[i]->endFrame, entries[i]->unknown0, - entries[i]->unknown1, entries[i]->unknown2, entries[i]->unknown3, entries[i]->unknown4, - entries[i]->unknown5, entries[i]->unknown6, entries[i]->unknown7); - } - - return result; -} - -std::string CutsceneCommandStopBGM::GetCName() -{ - return "CsCmdMusicChange"; -} - -size_t CutsceneCommandStopBGM::GetCommandSize() -{ - return CutsceneCommand::GetCommandSize() + 0x30; -} - -EnvLightingEntry::EnvLightingEntry(const std::vector& rawData, uint32_t rawDataIndex) -{ - setting = (uint16_t)BitConverter::ToInt16BE(rawData, rawDataIndex + 0); - startFrame = (uint16_t)BitConverter::ToInt16BE(rawData, rawDataIndex + 2); - endFrame = (uint16_t)BitConverter::ToInt16BE(rawData, rawDataIndex + 4); - unused0 = (uint16_t)BitConverter::ToInt16BE(rawData, rawDataIndex + 6); - unused1 = (uint32_t)BitConverter::ToInt32BE(rawData, rawDataIndex + 8); - unused2 = (uint32_t)BitConverter::ToInt32BE(rawData, rawDataIndex + 12); - unused3 = (uint32_t)BitConverter::ToInt32BE(rawData, rawDataIndex + 16); - unused4 = (uint32_t)BitConverter::ToInt32BE(rawData, rawDataIndex + 20); - unused5 = (uint32_t)BitConverter::ToInt32BE(rawData, rawDataIndex + 24); - unused6 = (uint32_t)BitConverter::ToInt32BE(rawData, rawDataIndex + 28); - unused7 = (uint32_t)BitConverter::ToInt32BE(rawData, rawDataIndex + 32); -} - -CutsceneCommandEnvLighting::CutsceneCommandEnvLighting(const std::vector& rawData, - uint32_t rawDataIndex) - : CutsceneCommand(rawData, rawDataIndex) -{ - int32_t numEntries = BitConverter::ToInt32BE(rawData, rawDataIndex + 0); - - rawDataIndex += 4; - - for (int32_t i = 0; i < numEntries; i++) - { - entries.push_back(new EnvLightingEntry(rawData, rawDataIndex)); - rawDataIndex += 0x30; - } -} - -std::string CutsceneCommandEnvLighting::GenerateSourceCode([[maybe_unused]] uint32_t baseAddress) -{ - std::string result; - - result += StringHelper::Sprintf("CS_LIGHTING_LIST(%i),\n", entries.size()); - - for (size_t i = 0; i < entries.size(); i++) - { - result += StringHelper::Sprintf( - "\t\tCS_LIGHTING(%i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i),\n", entries[i]->setting, - entries[i]->startFrame, entries[i]->endFrame, entries[i]->unused0, entries[i]->unused1, - entries[i]->unused2, entries[i]->unused3, entries[i]->unused4, entries[i]->unused5, - entries[i]->unused6, entries[i]->unused7); - } - - return result; -} - -std::string CutsceneCommandEnvLighting::GetCName() -{ - return "CsCmdEnvLighting"; -} - -size_t CutsceneCommandEnvLighting::GetCommandSize() -{ - return CutsceneCommand::GetCommandSize() + (0x30 * entries.size()); -} - -Unknown9Entry::Unknown9Entry(const std::vector& rawData, uint32_t rawDataIndex) -{ - base = (uint16_t)BitConverter::ToInt16BE(rawData, rawDataIndex + 0); - startFrame = (uint16_t)BitConverter::ToInt16BE(rawData, rawDataIndex + 2); - endFrame = (uint16_t)BitConverter::ToInt16BE(rawData, rawDataIndex + 4); - unk2 = rawData[rawDataIndex + 6]; - unk3 = rawData[rawDataIndex + 7]; - unk4 = rawData[rawDataIndex + 8]; - unused0 = rawData[rawDataIndex + 10]; - unused1 = rawData[rawDataIndex + 11]; - ; -} - -CutsceneCommandUnknown9::CutsceneCommandUnknown9(const std::vector& rawData, - uint32_t rawDataIndex) - : CutsceneCommand(rawData, rawDataIndex) -{ - int32_t numEntries = BitConverter::ToInt32BE(rawData, rawDataIndex); - - rawDataIndex += 4; - - for (int32_t i = 0; i < numEntries; i++) - { - entries.push_back(new Unknown9Entry(rawData, rawDataIndex)); - rawDataIndex += 0x0C; - } -} - -std::string CutsceneCommandUnknown9::GenerateSourceCode([[maybe_unused]] uint32_t baseAddress) -{ - std::string result; - - result += StringHelper::Sprintf("CS_CMD_09_LIST(%i),\n", entries.size()); - - for (size_t i = 0; i < entries.size(); i++) - { - result += StringHelper::Sprintf("\t\tCS_CMD_09(%i, %i, %i, %i, %i, %i, %i, %i),\n", - entries[i]->base, entries[i]->startFrame, - entries[i]->endFrame, entries[i]->unk2, entries[i]->unk3, - entries[i]->unk4, entries[i]->unused0, entries[i]->unused1); - } - - return result; -} - -std::string CutsceneCommandUnknown9::GetCName() -{ - return "CsCmdUnknown9"; -} - -size_t CutsceneCommandUnknown9::GetCommandSize() -{ - return CutsceneCommand::GetCommandSize() + (entries.size() * 12); -} - -UnkEntry::UnkEntry(const std::vector& rawData, uint32_t rawDataIndex) -{ - unused0 = (uint32_t)BitConverter::ToInt32BE(rawData, rawDataIndex + 0); - unused1 = (uint32_t)BitConverter::ToInt32BE(rawData, rawDataIndex + 4); - unused2 = (uint32_t)BitConverter::ToInt32BE(rawData, rawDataIndex + 8); - unused3 = (uint32_t)BitConverter::ToInt32BE(rawData, rawDataIndex + 12); - unused4 = (uint32_t)BitConverter::ToInt32BE(rawData, rawDataIndex + 16); - unused5 = (uint32_t)BitConverter::ToInt32BE(rawData, rawDataIndex + 20); - unused6 = (uint32_t)BitConverter::ToInt32BE(rawData, rawDataIndex + 24); - unused7 = (uint32_t)BitConverter::ToInt32BE(rawData, rawDataIndex + 28); - unused8 = (uint32_t)BitConverter::ToInt32BE(rawData, rawDataIndex + 32); - unused9 = (uint32_t)BitConverter::ToInt32BE(rawData, rawDataIndex + 36); - unused10 = (uint32_t)BitConverter::ToInt32BE(rawData, rawDataIndex + 40); - unused11 = (uint32_t)BitConverter::ToInt32BE(rawData, rawDataIndex + 44); -} - -CutsceneCommandUnknown::CutsceneCommandUnknown(const std::vector& rawData, - uint32_t rawDataIndex) - : CutsceneCommand(rawData, rawDataIndex) -{ - int32_t numEntries = BitConverter::ToInt32BE(rawData, rawDataIndex); - - rawDataIndex += 4; - - for (int32_t i = 0; i < numEntries; i++) - { - entries.push_back(new UnkEntry(rawData, rawDataIndex)); - rawDataIndex += 0x30; - } -} - -std::string CutsceneCommandUnknown::GenerateSourceCode([[maybe_unused]] uint32_t baseAddress) -{ - std::string result; - - result += StringHelper::Sprintf("CS_UNK_DATA_LIST(0x%02X, %i),\n", commandID, entries.size()); - - for (size_t i = 0; i < entries.size(); i++) - { - result += StringHelper::Sprintf( - " CS_UNK_DATA(%i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i),\n", - entries[i]->unused0, entries[i]->unused1, entries[i]->unused2, entries[i]->unused3, - entries[i]->unused4, entries[i]->unused5, entries[i]->unused6, entries[i]->unused7, - entries[i]->unused8, entries[i]->unused9, entries[i]->unused10, entries[i]->unused11); - } - - return result; -} - -std::string CutsceneCommandUnknown::GetCName() -{ - return "CsCmdUnknown1A"; -} - -size_t CutsceneCommandUnknown::GetCommandSize() -{ - return CutsceneCommand::GetCommandSize() + (entries.size() * 0x30); -} - -DayTimeEntry::DayTimeEntry(const std::vector& rawData, uint32_t rawDataIndex) -{ - base = (uint16_t)BitConverter::ToInt16BE(rawData, rawDataIndex + 0); - startFrame = (uint16_t)BitConverter::ToInt16BE(rawData, rawDataIndex + 2); - endFrame = (uint16_t)BitConverter::ToInt16BE(rawData, rawDataIndex + 4); - hour = rawData[rawDataIndex + 6]; - minute = rawData[rawDataIndex + 7]; - unused = rawData[rawDataIndex + 8]; -} - -CutsceneCommandDayTime::CutsceneCommandDayTime(const std::vector& rawData, - uint32_t rawDataIndex) - : CutsceneCommand(rawData, rawDataIndex) -{ - int32_t numEntries = BitConverter::ToInt32BE(rawData, rawDataIndex); - - rawDataIndex += 4; - - for (int32_t i = 0; i < numEntries; i++) - { - entries.push_back(new DayTimeEntry(rawData, rawDataIndex)); - rawDataIndex += 12; - } -} - -std::string CutsceneCommandDayTime::GetCName() -{ - return "CsCmdDayTime"; -} - -std::string CutsceneCommandDayTime::GenerateSourceCode([[maybe_unused]] uint32_t baseAddress) -{ - std::string result; - - result += StringHelper::Sprintf("CS_TIME_LIST(%i),\n", entries.size()); - - for (size_t i = 0; i < entries.size(); i++) - { - result += StringHelper::Sprintf( - " CS_TIME(%i, %i, %i, %i, %i, %i),\n", entries[i]->base, entries[i]->startFrame, - entries[i]->endFrame, entries[i]->hour, entries[i]->minute, entries[i]->unused); - } - - return result; -} - -size_t CutsceneCommandDayTime::GetCommandSize() -{ - return CutsceneCommand::GetCommandSize() + (entries.size() * 12); -} - -TextboxEntry::TextboxEntry(const std::vector& rawData, uint32_t rawDataIndex) -{ - base = (uint16_t)BitConverter::ToInt16BE(rawData, rawDataIndex + 0); - startFrame = (uint16_t)BitConverter::ToInt16BE(rawData, rawDataIndex + 2); - endFrame = (uint16_t)BitConverter::ToInt16BE(rawData, rawDataIndex + 4); - type = (uint16_t)BitConverter::ToInt16BE(rawData, rawDataIndex + 6); - textID1 = (uint16_t)BitConverter::ToInt16BE(rawData, rawDataIndex + 8); - textID2 = (uint16_t)BitConverter::ToInt16BE(rawData, rawDataIndex + 10); -} - -CutsceneCommandTextbox::CutsceneCommandTextbox(const std::vector& rawData, - uint32_t rawDataIndex) - : CutsceneCommand(rawData, rawDataIndex) -{ - int32_t numEntries = BitConverter::ToInt32BE(rawData, rawDataIndex); - - rawDataIndex += 4; - - for (int32_t i = 0; i < numEntries; i++) - { - entries.push_back(new TextboxEntry(rawData, rawDataIndex)); - rawDataIndex += 12; - } -} - -std::string CutsceneCommandTextbox::GetCName() -{ - return "CsCmdTextbox"; -} - -std::string CutsceneCommandTextbox::GenerateSourceCode([[maybe_unused]] uint32_t baseAddress) -{ - std::string result; - - result += StringHelper::Sprintf("CS_TEXT_LIST(%i),\n", entries.size()); - - for (size_t i = 0; i < entries.size(); i++) - { - if (entries[i]->base == 0xFFFF) - { - result += StringHelper::Sprintf(" CS_TEXT_NONE(%i, %i),\n", - entries[i]->startFrame, entries[i]->endFrame); - } - else - { - result += StringHelper::Sprintf( - " CS_TEXT_DISPLAY_TEXTBOX(%i, %i, %i, %i, %i, %i),\n", entries[i]->base, - entries[i]->startFrame, entries[i]->endFrame, entries[i]->type, entries[i]->textID1, - entries[i]->textID2); - } - } - - return result; -} - -size_t CutsceneCommandTextbox::GetCommandSize() -{ - return CutsceneCommand::GetCommandSize() + (entries.size() * 12); -} - -ActorAction::ActorAction(const std::vector& rawData, uint32_t rawDataIndex) -{ - const uint8_t* data = rawData.data(); - - action = (uint16_t)BitConverter::ToInt16BE(data, rawDataIndex + 0); - startFrame = (uint16_t)BitConverter::ToInt16BE(data, rawDataIndex + 2); - endFrame = (uint16_t)BitConverter::ToInt16BE(data, rawDataIndex + 4); - rotX = (uint16_t)BitConverter::ToInt16BE(data, rawDataIndex + 6); - rotY = (uint16_t)BitConverter::ToInt16BE(data, rawDataIndex + 8); - rotZ = (uint16_t)BitConverter::ToInt16BE(data, rawDataIndex + 10); - startPosX = BitConverter::ToInt32BE(data, rawDataIndex + 12); - startPosY = BitConverter::ToInt32BE(data, rawDataIndex + 16); - startPosZ = BitConverter::ToInt32BE(data, rawDataIndex + 20); - endPosX = BitConverter::ToInt32BE(data, rawDataIndex + 24); - endPosY = BitConverter::ToInt32BE(data, rawDataIndex + 28); - endPosZ = BitConverter::ToInt32BE(data, rawDataIndex + 32); - normalX = BitConverter::ToFloatBE(data, rawDataIndex + 36); - normalY = BitConverter::ToFloatBE(data, rawDataIndex + 40); - normalZ = BitConverter::ToFloatBE(data, rawDataIndex + 44); -} - -CutsceneCommandActorAction::CutsceneCommandActorAction(const std::vector& rawData, - uint32_t rawDataIndex) - : CutsceneCommand(rawData, rawDataIndex) -{ - int32_t numEntries = BitConverter::ToInt32BE(rawData, rawDataIndex); - - rawDataIndex += 4; - - for (int32_t i = 0; i < numEntries; i++) - { - entries.push_back(new ActorAction(rawData, rawDataIndex)); - rawDataIndex += 0x30; - } -} - -std::string CutsceneCommandActorAction::GenerateSourceCode([[maybe_unused]] uint32_t baseAddress) -{ - std::string result; - std::string subCommand; - - if (commandID == 10) - { - result += StringHelper::Sprintf("CS_PLAYER_ACTION_LIST(%i),\n", entries.size()); - subCommand = "CS_PLAYER_ACTION"; - } - else - { - result += StringHelper::Sprintf("CS_NPC_ACTION_LIST(%i, %i),\n", commandID, entries.size()); - subCommand = "CS_NPC_ACTION"; - } - - for (size_t i = 0; i < entries.size(); i++) - { - result += StringHelper::Sprintf( - "\t\t%s(0x%04X, %i, %i, 0x%04X, 0x%04X, 0x%04X, %i, %i, %i, %i, %i, %i, %.11ef, " - "%.11ef, %.11ef),\n", - subCommand.c_str(), entries[i]->action, entries[i]->startFrame, entries[i]->endFrame, - entries[i]->rotX, entries[i]->rotY, entries[i]->rotZ, entries[i]->startPosX, - entries[i]->startPosY, entries[i]->startPosZ, entries[i]->endPosX, entries[i]->endPosY, - entries[i]->endPosZ, entries[i]->normalX, entries[i]->normalY, entries[i]->normalZ); - } - - return result; -} - -std::string CutsceneCommandActorAction::GetCName() -{ - return "CsCmdBase"; -} - -size_t CutsceneCommandActorAction::GetCommandSize() -{ - return CutsceneCommand::GetCommandSize() + (entries.size() * 0x30); -} - -CutsceneCommandTerminator::CutsceneCommandTerminator(const std::vector& rawData, - uint32_t rawDataIndex) - : CutsceneCommand(rawData, rawDataIndex) -{ - rawDataIndex += 4; - - base = (uint16_t)BitConverter::ToInt16BE(rawData, rawDataIndex + 0); - startFrame = (uint16_t)BitConverter::ToInt16BE(rawData, rawDataIndex + 2); - endFrame = (uint16_t)BitConverter::ToInt16BE(rawData, rawDataIndex + 4); - unknown = (uint16_t)BitConverter::ToInt16BE(rawData, rawDataIndex + 6); // endFrame duplicate -} - -std::string CutsceneCommandTerminator::GetCName() -{ - return "CsCmdBase"; -} - -std::string CutsceneCommandTerminator::GenerateSourceCode([[maybe_unused]] uint32_t baseAddress) -{ - std::string result; - - result += StringHelper::Sprintf("CS_TERMINATOR(0x%04X, %i, %i),\n", base, startFrame, endFrame); - - return result; -} - -size_t CutsceneCommandTerminator::GetCommandSize() -{ - return CutsceneCommand::GetCommandSize() + 8; -} - -CutsceneCommandEnd::CutsceneCommandEnd(const std::vector& rawData, uint32_t rawDataIndex) - : CutsceneCommand(rawData, rawDataIndex) -{ - base = (uint16_t)BitConverter::ToInt16BE(rawData, rawDataIndex + 0); - startFrame = (uint16_t)BitConverter::ToInt16BE(rawData, rawDataIndex + 2); - endFrame = (uint16_t)BitConverter::ToInt16BE(rawData, rawDataIndex + 4); -} - -std::string CutsceneCommandEnd::GenerateSourceCode([[maybe_unused]] uint32_t baseAddress) -{ - std::string result; - - result += StringHelper::Sprintf("CS_END(),\n"); - - return result; -} - -std::string CutsceneCommandEnd::GetCName() -{ - return "CsCmdBase"; -} - -size_t CutsceneCommandEnd::GetCommandSize() -{ - return CutsceneCommand::GetCommandSize() + 6; -} - -SpecialActionEntry::SpecialActionEntry(const std::vector& rawData, uint32_t rawDataIndex) -{ - const uint8_t* data = rawData.data(); - - base = BitConverter::ToUInt16BE(data, rawDataIndex + 0); - startFrame = BitConverter::ToUInt16BE(data, rawDataIndex + 2); - endFrame = BitConverter::ToUInt16BE(data, rawDataIndex + 4); - unused0 = BitConverter::ToUInt16BE(data, rawDataIndex + 6); - unused1 = BitConverter::ToUInt32BE(data, rawDataIndex + 8); - unused2 = BitConverter::ToUInt32BE(data, rawDataIndex + 12); - unused3 = BitConverter::ToUInt32BE(data, rawDataIndex + 16); - unused4 = BitConverter::ToUInt32BE(data, rawDataIndex + 20); - unused5 = BitConverter::ToUInt32BE(data, rawDataIndex + 24); - unused6 = BitConverter::ToUInt32BE(data, rawDataIndex + 28); - unused7 = BitConverter::ToUInt32BE(data, rawDataIndex + 32); - unused8 = BitConverter::ToUInt32BE(data, rawDataIndex + 36); - unused9 = BitConverter::ToUInt32BE(data, rawDataIndex + 40); - unused10 = BitConverter::ToUInt32BE(data, rawDataIndex + 44); -} - -CutsceneCommandSpecialAction::CutsceneCommandSpecialAction(const std::vector& rawData, - uint32_t rawDataIndex) - : CutsceneCommand(rawData, rawDataIndex) -{ - int32_t numEntries = BitConverter::ToInt32BE(rawData, rawDataIndex + 0); - - rawDataIndex += 4; - - for (int32_t i = 0; i < numEntries; i++) - { - entries.push_back(new SpecialActionEntry(rawData, rawDataIndex)); - rawDataIndex += 0x30; - } -} - -std::string CutsceneCommandSpecialAction::GenerateSourceCode([[maybe_unused]] uint32_t baseAddress) -{ - std::string result; - - result += StringHelper::Sprintf("CS_MISC_LIST(%i),\n", entries.size()); - - for (size_t i = 0; i < entries.size(); i++) - { - result += StringHelper::Sprintf( - "\t\tCS_MISC(0x%04X, %i, %i, 0x%04X, 0x%04X, 0x%04X, %i, %i, %i, %i, %i, %i, %i, " - "%i),\n", - entries[i]->base, entries[i]->startFrame, entries[i]->endFrame, entries[i]->unused0, - entries[i]->unused1, entries[i]->unused2, entries[i]->unused3, entries[i]->unused4, - entries[i]->unused5, entries[i]->unused6, entries[i]->unused7, entries[i]->unused8, - entries[i]->unused9, entries[i]->unused10); - } - - return result; -} - -std::string CutsceneCommandSpecialAction::GetCName() -{ - return "CsCmdBase"; -} - -size_t CutsceneCommandSpecialAction::GetCommandSize() -{ - return CutsceneCommand::GetCommandSize() + (0x30 * entries.size()); -} - -CutsceneCommandNop::CutsceneCommandNop(const std::vector& rawData, uint32_t rawDataIndex) - : CutsceneCommand(rawData, rawDataIndex) -{ - base = (uint16_t)BitConverter::ToInt16BE(rawData, rawDataIndex + 0); - startFrame = (uint16_t)BitConverter::ToInt16BE(rawData, rawDataIndex + 2); - endFrame = (uint16_t)BitConverter::ToInt16BE(rawData, rawDataIndex + 4); -} - -std::string CutsceneCommandNop::GetCName() -{ - return "CsCmdBase"; -} - -size_t CutsceneCommandNop::GetCommandSize() -{ - return CutsceneCommand::GetCommandSize() + 6; -} - -CutsceneCommandSceneTransFX::CutsceneCommandSceneTransFX(const std::vector& rawData, - uint32_t rawDataIndex) - : CutsceneCommand(rawData, rawDataIndex) -{ - rawDataIndex += 4; - - base = (uint16_t)BitConverter::ToInt16BE(rawData, rawDataIndex + 0); - startFrame = (uint16_t)BitConverter::ToInt16BE(rawData, rawDataIndex + 2); - endFrame = (uint16_t)BitConverter::ToInt16BE(rawData, rawDataIndex + 4); -} - -std::string CutsceneCommandSceneTransFX::GenerateSourceCode([[maybe_unused]] uint32_t baseAddress) -{ - return StringHelper::Sprintf("CS_SCENE_TRANS_FX(%i, %i, %i),\n", base, startFrame, endFrame); -} - -std::string CutsceneCommandSceneTransFX::GetCName() -{ - return "CsCmdBase"; -} - -size_t CutsceneCommandSceneTransFX::GetCommandSize() -{ - return CutsceneCommand::GetCommandSize() + 8; -} - -ZCutsceneBase::ZCutsceneBase(ZFile* nParent) : ZResource(nParent) -{ + return nullptr; } -Declaration* ZCutsceneBase::DeclareVar(const std::string& prefix, const std::string& bodyStr) +Declaration* ZCutscene::DeclareVar(const std::string& prefix, const std::string& bodyStr) { std::string auxName = name; @@ -1254,7 +378,12 @@ Declaration* ZCutsceneBase::DeclareVar(const std::string& prefix, const std::str return decl; } -std::string ZCutsceneBase::GetSourceTypeName() const +std::string ZCutscene::GetSourceTypeName() const { return "CutsceneData"; } + +ZResourceType ZCutscene::GetResourceType() const +{ + return ZResourceType::Cutscene; +} diff --git a/ZAPDTR/ZAPD/ZCutscene.h b/ZAPDTR/ZAPD/ZCutscene.h index 8e901e307..098f3ad86 100644 --- a/ZAPDTR/ZAPD/ZCutscene.h +++ b/ZAPDTR/ZAPD/ZCutscene.h @@ -3,422 +3,13 @@ #include #include #include -#include "ZFile.h" -#include "ZResource.h" #include "tinyxml2.h" -enum class CutsceneCommands -{ - Cmd00 = 0x0000, - SetCameraPos = 0x0001, - SetCameraFocus = 0x0002, - SpecialAction = 0x0003, - SetLighting = 0x0004, - SetCameraPosLink = 0x0005, - SetCameraFocusLink = 0x0006, - Cmd07 = 0x0007, - Cmd08 = 0x0008, - Cmd09 = 0x0009, - Unknown = 0x001A, - Textbox = 0x0013, - SetActorAction0 = 0x000A, - SetActorAction1 = 0x000F, - SetActorAction2 = 0x000E, - SetActorAction3 = 0x0019, - SetActorAction4 = 0x001D, - SetActorAction5 = 0x001E, - SetActorAction6 = 0x002C, - SetActorAction7 = 0x001F, - SetActorAction8 = 0x0031, - SetActorAction9 = 0x003E, - SetActorAction10 = 0x008F, - SetSceneTransFX = 0x002D, - Nop = 0x000B, - PlayBGM = 0x0056, - StopBGM = 0x0057, - FadeBGM = 0x007C, - SetTime = 0x008C, - Terminator = 0x03E8, - End = 0xFFFF, - Error = 0xFEAF, -}; +#include "OtherStructs/Cutscene_Commands.h" +#include "ZFile.h" +#include "ZResource.h" -class CutsceneCameraPoint -{ -public: - int8_t continueFlag; - int8_t cameraRoll; - int16_t nextPointFrame; - float viewAngle; - int16_t posX, posY, posZ; - int16_t unused; - - CutsceneCameraPoint(const std::vector& rawData, uint32_t rawDataIndex); -}; - -class CutsceneCommand -{ -public: - uint32_t commandID; - uint32_t commandIndex; - virtual ~CutsceneCommand(); - CutsceneCommand(const std::vector& rawData, uint32_t rawDataIndex); - virtual std::string GetCName(); - virtual std::string GenerateSourceCode(uint32_t baseAddress); - virtual size_t GetCommandSize(); -}; - -class CutsceneCommandSetCameraPos : public CutsceneCommand -{ -public: - uint16_t base; - uint16_t startFrame; - uint16_t endFrame; - uint16_t unused; - - std::vector entries; - ~CutsceneCommandSetCameraPos(); - CutsceneCommandSetCameraPos(const std::vector& rawData, uint32_t rawDataIndex); - std::string GetCName(); - std::string GenerateSourceCode(uint32_t baseAddress); - size_t GetCommandSize(); -}; - -class SpecialActionEntry -{ -public: - uint16_t base; - uint16_t startFrame; - uint16_t endFrame; - uint16_t unused0; - uint32_t unused1; - uint32_t unused2; - uint32_t unused3; - uint32_t unused4; - uint32_t unused5; - uint32_t unused6; - uint32_t unused7; - uint32_t unused8; - uint32_t unused9; - uint32_t unused10; - - SpecialActionEntry(const std::vector& rawData, uint32_t rawDataIndex); -}; - -class CutsceneCommandSpecialAction : public CutsceneCommand -{ -public: - std::vector entries; - - CutsceneCommandSpecialAction(const std::vector& rawData, uint32_t rawDataIndex); - ~CutsceneCommandSpecialAction(); - std::string GetCName(); - std::string GenerateSourceCode(uint32_t baseAddress); - size_t GetCommandSize(); -}; - -class MusicFadeEntry -{ -public: - uint16_t base; - uint16_t startFrame; - uint16_t endFrame; - uint16_t unknown0; - uint32_t unknown1; - uint32_t unknown2; - uint32_t unknown3; - uint32_t unknown4; - uint32_t unknown5; - uint32_t unknown6; - uint32_t unknown7; - uint32_t unknown8; - uint32_t unknown9; - uint32_t unknown10; - - MusicFadeEntry(const std::vector& rawData, uint32_t rawDataIndex); -}; - -class CutsceneCommandFadeBGM : public CutsceneCommand -{ -public: - std::vector entries; - - CutsceneCommandFadeBGM(const std::vector& rawData, uint32_t rawDataIndex); - ~CutsceneCommandFadeBGM(); - std::string GetCName(); - std::string GenerateSourceCode(uint32_t baseAddress); - size_t GetCommandSize(); -}; - -class MusicChangeEntry -{ -public: - uint16_t sequence; - uint16_t startFrame; - uint16_t endFrame; - uint16_t unknown0; - uint32_t unknown1; - uint32_t unknown2; - uint32_t unknown3; - uint32_t unknown4; - uint32_t unknown5; - uint32_t unknown6; - uint32_t unknown7; - - MusicChangeEntry(const std::vector& rawData, uint32_t rawDataIndex); -}; - -class CutsceneCommandPlayBGM : public CutsceneCommand -{ -public: - std::vector entries; - - CutsceneCommandPlayBGM(const std::vector& rawData, uint32_t rawDataIndex); - ~CutsceneCommandPlayBGM(); - std::string GetCName(); - std::string GenerateSourceCode(uint32_t baseAddress); - size_t GetCommandSize(); -}; - -class CutsceneCommandStopBGM : public CutsceneCommand -{ -public: - std::vector entries; - - CutsceneCommandStopBGM(const std::vector& rawData, uint32_t rawDataIndex); - ~CutsceneCommandStopBGM(); - std::string GetCName(); - std::string GenerateSourceCode(uint32_t baseAddress); - size_t GetCommandSize(); -}; - -class EnvLightingEntry -{ -public: - uint16_t setting; - uint16_t startFrame; - uint16_t endFrame; - uint16_t unused0; - uint32_t unused1; - uint32_t unused2; - uint32_t unused3; - uint32_t unused4; - uint32_t unused5; - uint32_t unused6; - uint32_t unused7; - - EnvLightingEntry(const std::vector& rawData, uint32_t rawDataIndex); -}; - -class CutsceneCommandEnvLighting : public CutsceneCommand -{ -public: - std::vector entries; - - CutsceneCommandEnvLighting(const std::vector& rawData, uint32_t rawDataIndex); - ~CutsceneCommandEnvLighting(); - std::string GetCName(); - std::string GenerateSourceCode(uint32_t baseAddress); - size_t GetCommandSize(); -}; - -class CutsceneCommandSceneTransFX : public CutsceneCommand -{ -public: - uint16_t base; - uint16_t startFrame; - uint16_t endFrame; - ~CutsceneCommandSceneTransFX(); - CutsceneCommandSceneTransFX(const std::vector& rawData, uint32_t rawDataIndex); - std::string GetCName(); - std::string GenerateSourceCode(uint32_t baseAddress); - size_t GetCommandSize(); -}; - -class Unknown9Entry -{ -public: - uint16_t base; - uint16_t startFrame; - uint16_t endFrame; - uint16_t unk2; - uint16_t unk3; - uint16_t unk4; - uint8_t unused0; - uint8_t unused1; - - Unknown9Entry(const std::vector& rawData, uint32_t rawDataIndex); -}; - -class CutsceneCommandUnknown9 : public CutsceneCommand -{ -public: - std::vector entries; - - CutsceneCommandUnknown9(const std::vector& rawData, uint32_t rawDataIndex); - ~CutsceneCommandUnknown9(); - std::string GetCName(); - std::string GenerateSourceCode(uint32_t baseAddress); - size_t GetCommandSize(); -}; - -class UnkEntry -{ -public: - uint32_t unused0; - uint32_t unused1; - uint32_t unused2; - uint32_t unused3; - uint32_t unused4; - uint32_t unused5; - uint32_t unused6; - uint32_t unused7; - uint32_t unused8; - uint32_t unused9; - uint32_t unused10; - uint32_t unused11; - - UnkEntry(const std::vector& rawData, uint32_t rawDataIndex); -}; - -class CutsceneCommandUnknown : public CutsceneCommand -{ -public: - std::vector entries; - - CutsceneCommandUnknown(const std::vector& rawData, uint32_t rawDataIndex); - ~CutsceneCommandUnknown(); - std::string GetCName(); - std::string GenerateSourceCode(uint32_t baseAddress); - size_t GetCommandSize(); -}; - -class DayTimeEntry -{ -public: - uint16_t base; - uint16_t startFrame; - uint16_t endFrame; - uint8_t hour; - uint8_t minute; - uint8_t unused; - - DayTimeEntry(const std::vector& rawData, uint32_t rawDataIndex); -}; - -class CutsceneCommandDayTime : public CutsceneCommand -{ -public: - std::vector entries; - - CutsceneCommandDayTime(const std::vector& rawData, uint32_t rawDataIndex); - ~CutsceneCommandDayTime(); - std::string GetCName(); - std::string GenerateSourceCode(uint32_t baseAddress); - size_t GetCommandSize(); -}; - -class TextboxEntry -{ -public: - uint16_t base; - uint16_t startFrame; - uint16_t endFrame; - uint16_t type; - uint16_t textID1; - uint16_t textID2; - - TextboxEntry(const std::vector& rawData, uint32_t rawDataIndex); -}; - -class CutsceneCommandTextbox : public CutsceneCommand -{ -public: - std::vector entries; - - CutsceneCommandTextbox(const std::vector& rawData, uint32_t rawDataIndex); - ~CutsceneCommandTextbox(); - std::string GetCName(); - std::string GenerateSourceCode(uint32_t baseAddress); - size_t GetCommandSize(); -}; - -class ActorAction -{ -public: - uint16_t action; - uint16_t startFrame; - uint16_t endFrame; - int16_t rotX, rotY, rotZ; - int32_t startPosX, startPosY, startPosZ; - int32_t endPosX, endPosY, endPosZ; - float normalX, normalY, normalZ; - - ActorAction(const std::vector& rawData, uint32_t rawDataIndex); -}; - -class CutsceneCommandActorAction : public CutsceneCommand -{ -public: - std::vector entries; - - CutsceneCommandActorAction(const std::vector& rawData, uint32_t rawDataIndex); - ~CutsceneCommandActorAction(); - std::string GetCName(); - std::string GenerateSourceCode(uint32_t baseAddress); - size_t GetCommandSize(); -}; - -class CutsceneCommandTerminator : public CutsceneCommand -{ -public: - uint16_t base; - uint16_t startFrame; - uint16_t endFrame; - uint16_t unknown; - - CutsceneCommandTerminator(const std::vector& rawData, uint32_t rawDataIndex); - std::string GetCName(); - std::string GenerateSourceCode(uint32_t baseAddress); - size_t GetCommandSize(); -}; - -class CutsceneCommandEnd : public CutsceneCommand -{ -public: - uint16_t base; - uint16_t startFrame; - uint16_t endFrame; - - CutsceneCommandEnd(const std::vector& rawData, uint32_t rawDataIndex); - std::string GetCName(); - std::string GenerateSourceCode(uint32_t baseAddress); - size_t GetCommandSize(); -}; - -class CutsceneCommandNop : public CutsceneCommand -{ -public: - uint16_t base; - uint16_t startFrame; - uint16_t endFrame; - - CutsceneCommandNop(const std::vector& rawData, uint32_t rawDataIndex); - std::string GetCName(); - size_t GetCommandSize(); -}; - -class ZCutsceneBase : public ZResource -{ -public: - ZCutsceneBase(ZFile* nParent); - - Declaration* DeclareVar(const std::string& prefix, const std::string& bodyStr) override; - - std::string GetSourceTypeName() const override; -}; - -class ZCutscene : public ZCutsceneBase +class ZCutscene : public ZResource { public: ZCutscene(ZFile* nParent); @@ -426,15 +17,20 @@ public: void ParseRawData() override; + Declaration* DeclareVar(const std::string& prefix, const std::string& bodyStr) override; + std::string GetBodySourceCode() const override; size_t GetRawDataSize() const override; + std::string GetSourceTypeName() const override; ZResourceType GetResourceType() const override; - CutsceneCommands GetCommandFromID(int32_t id); - int32_t numCommands; int32_t endFrame; std::vector commands; + +protected: + CutsceneCommand* GetCommandOoT(uint32_t id, offset_t currentPtr) const; + CutsceneCommand* GetCommandMM(uint32_t id, offset_t currentPtr) const; }; diff --git a/ZAPDTR/ZAPD/ZCutsceneMM.cpp b/ZAPDTR/ZAPD/ZCutsceneMM.cpp deleted file mode 100644 index d0208bc07..000000000 --- a/ZAPDTR/ZAPD/ZCutsceneMM.cpp +++ /dev/null @@ -1,61 +0,0 @@ -#include "ZCutsceneMM.h" - -#include "Utils/BitConverter.h" -#include "Utils/StringHelper.h" - -ZCutsceneMM::ZCutsceneMM(ZFile* nParent) : ZCutsceneBase(nParent) -{ -} - -ZCutsceneMM::~ZCutsceneMM() -{ - for (CutsceneCommand* cmd : commands) - delete cmd; -} - -std::string ZCutsceneMM::GetBodySourceCode() const -{ - std::string output; - - output += StringHelper::Sprintf(" CS_BEGIN_CUTSCENE(%i, %i),", numCommands, endFrame); - - for (size_t i = 0; i < data.size(); i++) - { - if ((i % 4) == 0) - output += "\n "; - output += StringHelper::Sprintf("0x%08X, ", data[i]); - } - - return output; -} - -size_t ZCutsceneMM::GetRawDataSize() const -{ - return 8 + data.size() * 4; -} - -void ZCutsceneMM::ParseRawData() -{ - const auto& rawData = parent->GetRawData(); - - numCommands = BitConverter::ToInt32BE(rawData, rawDataIndex + 0); - commands = std::vector(); - - endFrame = BitConverter::ToInt32BE(rawData, rawDataIndex + 4); - uint32_t currentPtr = rawDataIndex + 8; - uint32_t lastData = 0; - - // TODO currently cutscenes aren't being parsed, so just consume words until we see an end - // marker. - do - { - lastData = BitConverter::ToInt32BE(rawData, currentPtr); - data.push_back(lastData); - currentPtr += 4; - } while (lastData != 0xFFFFFFFF); -} - -ZResourceType ZCutsceneMM::GetResourceType() const -{ - return ZResourceType::Cutscene; -} diff --git a/ZAPDTR/ZAPD/ZCutsceneMM.h b/ZAPDTR/ZAPD/ZCutsceneMM.h deleted file mode 100644 index 44b108d6c..000000000 --- a/ZAPDTR/ZAPD/ZCutsceneMM.h +++ /dev/null @@ -1,29 +0,0 @@ -#pragma once - -#include -#include -#include -#include "ZCutscene.h" -#include "ZFile.h" -#include "tinyxml2.h" - -class ZCutsceneMM : public ZCutsceneBase -{ -public: - ZCutsceneMM(ZFile* nParent); - virtual ~ZCutsceneMM(); - - std::string GetBodySourceCode() const override; - - size_t GetRawDataSize() const override; - - void ParseRawData() override; - ZResourceType GetResourceType() const override; - -protected: - int32_t numCommands; - int32_t endFrame; - std::vector commands; - - std::vector data; -}; diff --git a/ZAPDTR/ZAPD/ZDisplayList.cpp b/ZAPDTR/ZAPD/ZDisplayList.cpp index 406245b33..9a43a2a22 100644 --- a/ZAPDTR/ZAPD/ZDisplayList.cpp +++ b/ZAPDTR/ZAPD/ZDisplayList.cpp @@ -9,7 +9,7 @@ #include "Globals.h" #include "OutputFormatter.h" #include "Utils/BitConverter.h" -#include "Utils/File.h" +#include #include "Utils/Path.h" #include "Utils/StringHelper.h" #include "WarningHandler.h" @@ -213,6 +213,7 @@ void ZDisplayList::ParseRawData() instructions.reserve(numInstructions); uint32_t ptr = rawDataIndex; + instructions.reserve(numInstructions); for (size_t i = 0; i < numInstructions; i++) { instructions.push_back(BitConverter::ToUInt64BE(rawData, ptr)); @@ -1981,7 +1982,7 @@ void ZDisplayList::DeclareReferences(const std::string& prefix) // Generate Vertex Declarations std::vector vtxKeys; - + vtxKeys.reserve(vertices.size()); for (auto& item : vertices) vtxKeys.push_back(item.first); diff --git a/ZAPDTR/ZAPD/ZFile.cpp b/ZAPDTR/ZAPD/ZFile.cpp index 1f4b92bcf..d04f3b7e3 100644 --- a/ZAPDTR/ZAPD/ZFile.cpp +++ b/ZAPDTR/ZAPD/ZFile.cpp @@ -10,7 +10,7 @@ #include "Utils/BinaryWriter.h" #include "Utils/BitConverter.h" #include "Utils/Directory.h" -#include "Utils/File.h" +#include #include "Utils/MemoryStream.h" #include "Utils/Path.h" #include "Utils/StringHelper.h" @@ -190,7 +190,7 @@ void ZFile::ParseXML(tinyxml2::XMLElement* reader, const std::string& filename) { if (Globals::Instance->fileMode != ZFileMode::ExtractDirectory) { - if (!File::Exists((basePath / name).string())) + if (!DiskFile::Exists((basePath / name).string())) { std::string errorHeader = StringHelper::Sprintf("binary file '%s' does not exist.", (basePath / name).c_str()); @@ -224,7 +224,12 @@ void ZFile::ParseXML(tinyxml2::XMLElement* reader, const std::string& filename) // Check for repeated attributes. if (offsetXml != nullptr) { - rawDataIndex = strtol(StringHelper::Split(std::string(offsetXml), "0x")[1].c_str(), NULL, 16); + if (!StringHelper::IsValidOffset(std::string_view(offsetXml))) + { + HANDLE_ERROR(WarningType::InvalidXML, + StringHelper::Sprintf("Invalid offset %s entered", offsetXml), ""); + } + rawDataIndex = strtol(offsetXml, NULL, 16); if (offsetSet.find(offsetXml) != offsetSet.end()) { @@ -416,7 +421,7 @@ void ZFile::ExtractResources() if (memStreamFile->GetLength() > 0) { - File::WriteAllBytes(StringHelper::Sprintf("%s%s.bin", + DiskFile::WriteAllBytes(StringHelper::Sprintf("%s%s.bin", Globals::Instance->outputPath.string().c_str(), GetName().c_str()), memStreamFile->ToVector()); @@ -433,7 +438,7 @@ void ZFile::AddResource(ZResource* res) resources.push_back(res); } -ZResource* ZFile::FindResource(uint32_t rawDataIndex) +ZResource* ZFile::FindResource(offset_t rawDataIndex) { for (ZResource* res : resources) { @@ -447,6 +452,7 @@ ZResource* ZFile::FindResource(uint32_t rawDataIndex) std::vector ZFile::GetResourcesOfType(ZResourceType resType) { std::vector resList; + resList.reserve(resources.size()); for (ZResource* res : resources) { @@ -722,7 +728,7 @@ bool ZFile::GetDeclarationArrayIndexedName(segptr_t segAddress, size_t elementSi return true; } -Declaration* ZFile::GetDeclaration(uint32_t address) const +Declaration* ZFile::GetDeclaration(offset_t address) const { if (declarations.find(address) != declarations.end()) return declarations.at(address); @@ -730,7 +736,7 @@ Declaration* ZFile::GetDeclaration(uint32_t address) const return nullptr; } -Declaration* ZFile::GetDeclarationRanged(uint32_t address) const +Declaration* ZFile::GetDeclarationRanged(offset_t address) const { for (const auto decl : declarations) { @@ -741,7 +747,7 @@ Declaration* ZFile::GetDeclarationRanged(uint32_t address) const return nullptr; } -bool ZFile::HasDeclaration(uint32_t address) +bool ZFile::HasDeclaration(offset_t address) { assert(GETSEGNUM(address) == 0); return declarations.find(address) != declarations.end(); @@ -796,7 +802,7 @@ void ZFile::GenerateSourceFiles() OutputFormatter formatter; formatter.Write(sourceOutput); - File::WriteAllText(outPath, formatter.GetOutput()); + DiskFile::WriteAllText(outPath, formatter.GetOutput()); } GenerateSourceHeaderFiles(); @@ -805,9 +811,14 @@ void ZFile::GenerateSourceFiles() void ZFile::GenerateSourceHeaderFiles() { OutputFormatter formatter; + std::string guard = outName.stem().string(); + std::transform(guard.begin(), guard.end(), guard.begin(), ::toupper); formatter.Write("#pragma once\n\n"); + formatter.Write( + StringHelper::Sprintf("#ifndef %s_H\n#define %s_H 1\n\n", guard.c_str(), guard.c_str())); formatter.Write("#include \"align_asset_macro.h\"\n"); + std::set nameSet; for (ZResource* res : resources) { @@ -827,6 +838,8 @@ void ZFile::GenerateSourceHeaderFiles() formatter.Write(ProcessExterns()); + formatter.Write("#endif\n"); + fs::path headerFilename = GetSourceOutputFolderPath() / outName.stem().concat(".h"); if (Globals::Instance->verbosity >= VerbosityLevel::VERBOSITY_INFO) @@ -837,7 +850,7 @@ void ZFile::GenerateSourceHeaderFiles() output.pop_back(); if (Globals::Instance->fileMode != ZFileMode::ExtractDirectory) - File::WriteAllText(headerFilename, output); + DiskFile::WriteAllText(headerFilename, output); else if (Globals::Instance->sourceOutputPath != "") { std::string xmlPath = xmlFilePath.string(); @@ -862,7 +875,7 @@ void ZFile::GenerateSourceHeaderFiles() outPath += "/"; } - File::WriteAllText(outPath, output); + DiskFile::WriteAllText(outPath, output); } } @@ -1108,7 +1121,7 @@ std::string ZFile::ProcessDeclarations() extType = "vtx"; auto filepath = outputPath / item.second->varName; - File::WriteAllText( + DiskFile::WriteAllText( StringHelper::Sprintf("%s.%s.inc", filepath.string().c_str(), extType.c_str()), item.second->text); } @@ -1244,6 +1257,10 @@ void ZFile::HandleUnaccountedData() uint32_t lastSize = 0; std::vector declsAddresses; + if (Globals::Instance->otrMode) + return; + + declsAddresses.reserve(declarations.size()); if (Globals::Instance->otrMode) return; diff --git a/ZAPDTR/ZAPD/ZFile.h b/ZAPDTR/ZAPD/ZFile.h index ae7409061..04334547c 100644 --- a/ZAPDTR/ZAPD/ZFile.h +++ b/ZAPDTR/ZAPD/ZFile.h @@ -32,8 +32,8 @@ class ZFile { public: std::map declarations; - std::string defines; std::vector resources; + std::string defines; int workerID; bool isCompilable = false; @@ -56,7 +56,7 @@ public: void ExtractResources(); void BuildSourceFile(); void AddResource(ZResource* res); - ZResource* FindResource(uint32_t rawDataIndex); + ZResource* FindResource(offset_t rawDataIndex); std::vector GetResourcesOfType(ZResourceType resType); Declaration* AddDeclaration(offset_t address, DeclarationAlignment alignment, size_t size, @@ -85,9 +85,9 @@ public: const std::string& expectedType, std::string& declName) const; - Declaration* GetDeclaration(uint32_t address) const; - Declaration* GetDeclarationRanged(uint32_t address) const; - bool HasDeclaration(uint32_t address); + Declaration* GetDeclaration(offset_t address) const; + Declaration* GetDeclarationRanged(offset_t address) const; + bool HasDeclaration(offset_t address); std::string GetHeaderInclude() const; std::string GetZRoomHeaderInclude() const; diff --git a/ZAPDTR/ZAPD/ZLimb.cpp b/ZAPDTR/ZAPD/ZLimb.cpp index 9eb7eac8d..d0c3ffe3e 100644 --- a/ZAPDTR/ZAPD/ZLimb.cpp +++ b/ZAPDTR/ZAPD/ZLimb.cpp @@ -4,12 +4,15 @@ #include "Globals.h" #include "Utils/BitConverter.h" +#include "Utils/StringHelper.h" #include "WarningHandler.h" +#include "ZSkeleton.h" REGISTER_ZFILENODE(Limb, ZLimb); ZLimb::ZLimb(ZFile* nParent) : ZResource(nParent), segmentStruct(nParent) { + RegisterOptionalAttribute("EnumName"); RegisterOptionalAttribute("LimbType"); RegisterOptionalAttribute("Type"); } @@ -30,6 +33,12 @@ void ZLimb::ParseXML(tinyxml2::XMLElement* reader) { ZResource::ParseXML(reader); + auto& enumNameXml = registeredAttributes.at("EnumName").value; + if (enumNameXml != "") + { + enumName = enumNameXml; + } + // Reading from a std::string limbType = registeredAttributes.at("LimbType").value; if (limbType == "") // Reading from a @@ -247,11 +256,24 @@ std::string ZLimb::GetBodySourceCode() const } else { + std::string childStr; + std::string siblingStr; + if (limbsTable != nullptr) + { + childStr = limbsTable->GetLimbEnumName(childIndex); + siblingStr = limbsTable->GetLimbEnumName(siblingIndex); + } + else + { + childStr = StringHelper::Sprintf("0x%02X", childIndex); + siblingStr = StringHelper::Sprintf("0x%02X", siblingIndex); + } + if (type != ZLimbType::Curve) { entryStr += StringHelper::Sprintf("{ %i, %i, %i }, ", transX, transY, transZ); } - entryStr += StringHelper::Sprintf("0x%02X, 0x%02X,\n", childIndex, siblingIndex); + entryStr += StringHelper::Sprintf("%s, %s,\n", childStr.c_str(), siblingStr.c_str()); switch (type) { @@ -360,6 +382,11 @@ ZLimbType ZLimb::GetTypeByAttributeName(const std::string& attrName) return ZLimbType::Invalid; } +void ZLimb::SetLimbIndex(uint8_t nLimbIndex) +{ + limbIndex = nLimbIndex; +} + void ZLimb::DeclareDList(segptr_t dListSegmentedPtr, const std::string& prefix, const std::string& limbSuffix) { diff --git a/ZAPDTR/ZAPD/ZLimb.h b/ZAPDTR/ZAPD/ZLimb.h index 5de5276e9..b75236f5e 100644 --- a/ZAPDTR/ZAPD/ZLimb.h +++ b/ZAPDTR/ZAPD/ZLimb.h @@ -18,9 +18,14 @@ enum class ZLimbType Legacy, }; +class ZLimbTable; + class ZLimb : public ZResource { public: + std::string enumName; + ZLimbTable* limbsTable = nullptr; // borrowed pointer, do not delete! + ZLimbType type = ZLimbType::Standard; ZLimbSkinType skinSegmentType = ZLimbSkinType::SkinType_0; // Skin only @@ -39,6 +44,8 @@ public: int16_t transX = 0, transY = 0, transZ = 0; uint8_t childIndex = 0, siblingIndex = 0; + uint8_t limbIndex = 0; + ZLimb(ZFile* nParent); void ExtractFromBinary(uint32_t nRawDataIndex, ZLimbType nType); @@ -59,6 +66,8 @@ public: static const char* GetSourceTypeName(ZLimbType limbType); static ZLimbType GetTypeByAttributeName(const std::string& attrName); + void SetLimbIndex(uint8_t nLimbIndex); + protected: void DeclareDList(segptr_t dListSegmentedPtr, const std::string& prefix, const std::string& limbSuffix); diff --git a/ZAPDTR/ZAPD/ZPath.cpp b/ZAPDTR/ZAPD/ZPath.cpp index 660821ce8..849b4edfc 100644 --- a/ZAPDTR/ZAPD/ZPath.cpp +++ b/ZAPDTR/ZAPD/ZPath.cpp @@ -35,6 +35,7 @@ void ZPath::ParseRawData() uint32_t currentPtr = rawDataIndex; + pathways.reserve(numPaths); for (size_t pathIndex = 0; pathIndex < numPaths; pathIndex++) { PathwayEntry path(parent); @@ -125,6 +126,7 @@ void PathwayEntry::ParseRawData() uint32_t currentPtr = GETSEGOFFSET(listSegmentAddress); + points.reserve(numPoints); for (int32_t i = 0; i < numPoints; i++) { ZVector vec(parent); diff --git a/ZAPDTR/ZAPD/ZPointer.cpp b/ZAPDTR/ZAPD/ZPointer.cpp new file mode 100644 index 000000000..6e6945cad --- /dev/null +++ b/ZAPDTR/ZAPD/ZPointer.cpp @@ -0,0 +1,57 @@ +#include "ZPointer.h" + +#include "Globals.h" +#include "Utils/BitConverter.h" +#include "Utils/StringHelper.h" +#include "WarningHandler.h" +#include "ZFile.h" + +REGISTER_ZFILENODE(Pointer, ZPointer); + +ZPointer::ZPointer(ZFile* nParent) : ZResource(nParent) +{ + RegisterRequiredAttribute("Type"); +} + +void ZPointer::ParseXML(tinyxml2::XMLElement* reader) +{ + ZResource::ParseXML(reader); + + type = registeredAttributes.at("Type").value; +} + +void ZPointer::ParseRawData() +{ + auto& rawData = parent->GetRawData(); + + ptr = BitConverter::ToUInt32BE(rawData, rawDataIndex); +} + +std::string ZPointer::GetBodySourceCode() const +{ + std::string ptrName; + + Globals::Instance->GetSegmentedPtrName(ptr, parent, "", ptrName); + + return ptrName; +} + +bool ZPointer::DoesSupportArray() const +{ + return true; +} + +std::string ZPointer::GetSourceTypeName() const +{ + return type + "*"; +} + +ZResourceType ZPointer::GetResourceType() const +{ + return ZResourceType::Pointer; +} + +size_t ZPointer::GetRawDataSize() const +{ + return 0x04; +} diff --git a/ZAPDTR/ZAPD/ZPointer.h b/ZAPDTR/ZAPD/ZPointer.h new file mode 100644 index 000000000..8fb588933 --- /dev/null +++ b/ZAPDTR/ZAPD/ZPointer.h @@ -0,0 +1,22 @@ +#pragma once + +#include "ZResource.h" + +class ZPointer : public ZResource +{ +public: + segptr_t ptr = SEGMENTED_NULL; + std::string type; + + ZPointer(ZFile* nParent); + + void ParseXML(tinyxml2::XMLElement* reader) override; + void ParseRawData() override; + std::string GetBodySourceCode() const override; + + bool DoesSupportArray() const override; + std::string GetSourceTypeName() const override; + ZResourceType GetResourceType() const override; + + size_t GetRawDataSize() const override; +}; diff --git a/ZAPDTR/ZAPD/ZResource.cpp b/ZAPDTR/ZAPD/ZResource.cpp index dd7a45810..aacc7afdc 100644 --- a/ZAPDTR/ZAPD/ZResource.cpp +++ b/ZAPDTR/ZAPD/ZResource.cpp @@ -261,6 +261,11 @@ offset_t ZResource::GetRawDataIndex() const return rawDataIndex; } +void ZResource::SetRawDataIndex(offset_t nRawDataIndex) +{ + rawDataIndex = nRawDataIndex; +} + std::string ZResource::GetBodySourceCode() const { return "ERROR"; diff --git a/ZAPDTR/ZAPD/ZResource.h b/ZAPDTR/ZAPD/ZResource.h index 59b074daf..05c35a26b 100644 --- a/ZAPDTR/ZAPD/ZResource.h +++ b/ZAPDTR/ZAPD/ZResource.h @@ -52,7 +52,11 @@ enum class ZResourceType Vector, Vertex, Text, - Audio + Audio, + ActorList, + CollisionPoly, + Pointer, + SurfaceType, }; class ResourceAttribute @@ -153,6 +157,8 @@ public: [[nodiscard]] const std::string& GetOutName() const; void SetOutName(const std::string& nName); [[nodiscard]] offset_t GetRawDataIndex() const; + void SetRawDataIndex(offset_t nRawDataIndex); + /** * The size of the current struct being extracted, not counting data referenced by it */ diff --git a/ZAPDTR/ZAPD/ZRom.cpp b/ZAPDTR/ZAPD/ZRom.cpp index 5dfad57ae..abce2bf0a 100644 --- a/ZAPDTR/ZAPD/ZRom.cpp +++ b/ZAPDTR/ZAPD/ZRom.cpp @@ -1,6 +1,6 @@ #include "ZRom.h" #include "Utils/BitConverter.h" -#include "Utils/File.h" +#include #include "Utils/Directory.h" #include "yaz0/yaz0.h" @@ -95,7 +95,7 @@ bool ZRom::IsMQ() { ZRom::ZRom(std::string romPath) { RomVersion version; - romData = File::ReadAllBytes(romPath); + romData = DiskFile::ReadAllBytes(romPath); version.crc = BitConverter::ToInt32BE(romData, 0x10); @@ -189,7 +189,7 @@ ZRom::ZRom(std::string romPath) } auto path = StringHelper::Sprintf("%s/%s", Globals::Instance->fileListPath.string().c_str(), version.listPath.c_str()); - auto txt = File::ReadAllText(path); + auto txt = DiskFile::ReadAllText(path); std::vector lines = StringHelper::Split(txt, "\n"); std::vector decompressedData(1); @@ -222,7 +222,7 @@ ZRom::ZRom(std::string romPath) else files[lines[i]] = outData; - //File::WriteAllBytes(StringHelper::Sprintf("baserom/%s", lines[i].c_str()), files[lines[i]]); + //DiskFile::WriteAllBytes(StringHelper::Sprintf("baserom/%s", lines[i].c_str()), files[lines[i]]); } } diff --git a/ZAPDTR/ZAPD/ZRoom/Commands/SetActorCutsceneList.cpp b/ZAPDTR/ZAPD/ZRoom/Commands/SetActorCutsceneList.cpp index 4c9e8fb5f..ee0183706 100644 --- a/ZAPDTR/ZAPD/ZRoom/Commands/SetActorCutsceneList.cpp +++ b/ZAPDTR/ZAPD/ZRoom/Commands/SetActorCutsceneList.cpp @@ -14,8 +14,9 @@ void SetActorCutsceneList::ParseRawData() { ZRoomCommand::ParseRawData(); int numCutscenes = cmdArg1; - int32_t currentPtr = segmentOffset; + offset_t currentPtr = segmentOffset; + cutscenes.reserve(numCutscenes); for (int32_t i = 0; i < numCutscenes; i++) { ActorCutsceneEntry entry(parent->GetRawData(), currentPtr); diff --git a/ZAPDTR/ZAPD/ZRoom/Commands/SetActorList.cpp b/ZAPDTR/ZAPD/ZRoom/Commands/SetActorList.cpp index 1cda3c2c6..0e667c058 100644 --- a/ZAPDTR/ZAPD/ZRoom/Commands/SetActorList.cpp +++ b/ZAPDTR/ZAPD/ZRoom/Commands/SetActorList.cpp @@ -1,10 +1,10 @@ #include "SetActorList.h" +#include + #include "Globals.h" #include "Utils/BitConverter.h" #include "Utils/StringHelper.h" -#include "ZFile.h" -#include "ZRoom/ZNames.h" #include "ZRoom/ZRoom.h" SetActorList::SetActorList(ZFile* nParent) : ZRoomCommand(nParent) @@ -15,67 +15,28 @@ void SetActorList::ParseRawData() { ZRoomCommand::ParseRawData(); numActors = cmdArg1; + + actorList = new ZActorList(parent); + actorList->ExtractFromBinary(segmentOffset, numActors); } void SetActorList::DeclareReferences(const std::string& prefix) { - if (numActors != 0 && cmdArg2 != 0) + if (parent->HasDeclaration(segmentOffset)) { - std::string varName = - StringHelper::Sprintf("%sActorList_%06X", prefix.c_str(), segmentOffset); - parent->AddDeclarationPlaceholder(segmentOffset, varName); - } -} - -void SetActorList::ParseRawDataLate() -{ - ZRoomCommand::ParseRawDataLate(); - size_t actorsAmount = zRoom->GetDeclarationSizeFromNeighbor(segmentOffset) / 0x10; - - uint32_t currentPtr = segmentOffset; - - for (size_t i = 0; i < actorsAmount; i++) - { - ActorSpawnEntry entry(parent->GetRawData(), currentPtr); - - currentPtr += entry.GetRawDataSize(); - actors.push_back(entry); - } -} - -void SetActorList::DeclareReferencesLate(const std::string& prefix) -{ - if (actors.empty()) + delete actorList; + actorList = static_cast(parent->FindResource(segmentOffset)); + assert(actorList != nullptr); + assert(actorList->GetResourceType() == ZResourceType::ActorList); return; - - std::string declaration; - - size_t largestlength = 0; - for (const auto& entry : actors) - { - size_t actorNameLength = ZNames::GetActorName(entry.GetActorId()).size(); - if (actorNameLength > largestlength) - largestlength = actorNameLength; } - size_t index = 0; - for (auto& entry : actors) + if (actorList->GetName() == "") { - entry.SetLargestActorName(largestlength); - declaration += StringHelper::Sprintf("\t{ %s },", entry.GetBodySourceCode().c_str()); - - if (index < actors.size() - 1) - declaration += "\n"; - - index++; + actorList->SetName(actorList->GetDefaultName(prefix)); } - - const auto& entry = actors.front(); - - std::string varName = StringHelper::Sprintf("%sActorList_%06X", prefix.c_str(), segmentOffset); - parent->AddDeclarationArray(segmentOffset, DeclarationAlignment::Align4, - actors.size() * entry.GetRawDataSize(), entry.GetSourceTypeName(), - varName, GetActorListArraySize(), declaration); + actorList->DeclareVar(prefix, ""); + parent->AddResource(actorList); } std::string SetActorList::GetBodySourceCode() const @@ -83,37 +44,10 @@ std::string SetActorList::GetBodySourceCode() const std::string listName; Globals::Instance->GetSegmentedPtrName(cmdArg2, parent, "ActorEntry", listName, parent->workerID); - if (numActors != actors.size()) - { - printf("%s: numActors(%i) ~ actors(%li)\n", parent->GetName().c_str(), numActors, - actors.size()); - } + return StringHelper::Sprintf("SCENE_CMD_ACTOR_LIST(%i, %s)", numActors, listName.c_str()); } -size_t SetActorList::GetActorListArraySize() const -{ - size_t actorCount = 0; - - // Doing an else-if here so we only do the loop when the game is SW97. - // Actor 0x22 is removed from SW97, so we need to ensure that we don't increment the actor count - // for it. - if (Globals::Instance->game == ZGame::OOT_SW97) - { - actorCount = 0; - - for (const auto& entry : actors) - if (entry.GetActorId() != 0x22) - actorCount++; - } - else - { - actorCount = actors.size(); - } - - return actorCount; -} - std::string SetActorList::GetCommandCName() const { return "SCmdActorList"; @@ -123,58 +57,3 @@ RoomCommand SetActorList::GetRoomCommand() const { return RoomCommand::SetActorList; } - -ActorSpawnEntry::ActorSpawnEntry(const std::vector& rawData, uint32_t rawDataIndex) -{ - actorNum = BitConverter::ToInt16BE(rawData, rawDataIndex + 0); - posX = BitConverter::ToInt16BE(rawData, rawDataIndex + 2); - posY = BitConverter::ToInt16BE(rawData, rawDataIndex + 4); - posZ = BitConverter::ToInt16BE(rawData, rawDataIndex + 6); - rotX = BitConverter::ToUInt16BE(rawData, rawDataIndex + 8); - rotY = BitConverter::ToUInt16BE(rawData, rawDataIndex + 10); - rotZ = BitConverter::ToUInt16BE(rawData, rawDataIndex + 12); - initVar = BitConverter::ToInt16BE(rawData, rawDataIndex + 14); -} - -std::string ActorSpawnEntry::GetBodySourceCode() const -{ - std::string body; - - std::string actorNameFmt = StringHelper::Sprintf("%%-%zus ", largestActorName + 1); - body = - StringHelper::Sprintf(actorNameFmt.c_str(), (ZNames::GetActorName(actorNum) + ",").c_str()); - - body += StringHelper::Sprintf("{ %6i, %6i, %6i }, ", posX, posY, posZ); - if (Globals::Instance->game == ZGame::MM_RETAIL) - body += StringHelper::Sprintf("{ SPAWN_ROT_FLAGS(%#5hX, 0x%04X)" - ", SPAWN_ROT_FLAGS(%#5hX, 0x%04X)" - ", SPAWN_ROT_FLAGS(%#5hX, 0x%04X) }, ", - (rotX >> 7) & 0b111111111, rotX & 0b1111111, - (rotY >> 7) & 0b111111111, rotY & 0b1111111, - (rotZ >> 7) & 0b111111111, rotZ & 0b1111111); - else - body += StringHelper::Sprintf("{ %#6hX, %#6hX, %#6hX }, ", rotX, rotY, rotZ); - body += StringHelper::Sprintf("0x%04X", initVar); - - return body; -} - -std::string ActorSpawnEntry::GetSourceTypeName() const -{ - return "ActorEntry"; -} - -int32_t ActorSpawnEntry::GetRawDataSize() const -{ - return 16; -} - -uint16_t ActorSpawnEntry::GetActorId() const -{ - return actorNum; -} - -void ActorSpawnEntry::SetLargestActorName(size_t nameSize) -{ - largestActorName = nameSize; -} diff --git a/ZAPDTR/ZAPD/ZRoom/Commands/SetActorList.h b/ZAPDTR/ZAPD/ZRoom/Commands/SetActorList.h index 7b341256c..9122c15bb 100644 --- a/ZAPDTR/ZAPD/ZRoom/Commands/SetActorList.h +++ b/ZAPDTR/ZAPD/ZRoom/Commands/SetActorList.h @@ -1,45 +1,19 @@ #pragma once +#include "ZActorList.h" #include "ZRoom/ZRoomCommand.h" -class ActorSpawnEntry -{ -public: - uint16_t actorNum; - int16_t posX; - int16_t posY; - int16_t posZ; - uint16_t rotX; - uint16_t rotY; - uint16_t rotZ; - uint16_t initVar; - size_t largestActorName = 16; - - ActorSpawnEntry(const std::vector& rawData, uint32_t rawDataIndex); - - std::string GetBodySourceCode() const; - - std::string GetSourceTypeName() const; - int32_t GetRawDataSize() const; - - uint16_t GetActorId() const; - void SetLargestActorName(size_t nameSize); -}; - class SetActorList : public ZRoomCommand { public: - uint8_t numActors; - std::vector actors; + uint32_t numActors; + ZActorList* actorList = nullptr; SetActorList(ZFile* nParent); void ParseRawData() override; void DeclareReferences(const std::string& prefix) override; - void ParseRawDataLate() override; - void DeclareReferencesLate(const std::string& prefix) override; - std::string GetBodySourceCode() const override; RoomCommand GetRoomCommand() const override; diff --git a/ZAPDTR/ZAPD/ZRoom/Commands/SetAlternateHeaders.cpp b/ZAPDTR/ZAPD/ZRoom/Commands/SetAlternateHeaders.cpp index a89c2b74d..9e61c6a76 100644 --- a/ZAPDTR/ZAPD/ZRoom/Commands/SetAlternateHeaders.cpp +++ b/ZAPDTR/ZAPD/ZRoom/Commands/SetAlternateHeaders.cpp @@ -21,9 +21,10 @@ void SetAlternateHeaders::DeclareReferences([[maybe_unused]] const std::string& void SetAlternateHeaders::ParseRawDataLate() { - int numHeaders = zRoom->GetDeclarationSizeFromNeighbor(segmentOffset) / 4; + size_t numHeaders = zRoom->GetDeclarationSizeFromNeighbor(segmentOffset) / 4; - for (int32_t i = 0; i < numHeaders; i++) + headers.reserve(numHeaders); + for (uint32_t i = 0; i < numHeaders; i++) { int32_t address = BitConverter::ToInt32BE(parent->GetRawData(), segmentOffset + (i * 4)); headers.push_back(address); diff --git a/ZAPDTR/ZAPD/ZRoom/Commands/SetCsCamera.cpp b/ZAPDTR/ZAPD/ZRoom/Commands/SetCsCamera.cpp index 577a89cd1..5a9ae128e 100644 --- a/ZAPDTR/ZAPD/ZRoom/Commands/SetCsCamera.cpp +++ b/ZAPDTR/ZAPD/ZRoom/Commands/SetCsCamera.cpp @@ -18,6 +18,7 @@ void SetCsCamera::ParseRawData() uint32_t currentPtr = segmentOffset; int32_t numPoints = 0; + cameras.reserve(numCameras); for (int32_t i = 0; i < numCameras; i++) { CsCameraEntry entry(parent->GetRawData(), currentPtr); @@ -31,6 +32,7 @@ void SetCsCamera::ParseRawData() { uint32_t currentPtr = cameras.at(0).GetSegmentOffset(); + points.reserve(numPoints); for (int32_t i = 0; i < numPoints; i++) { ZVector vec(parent); diff --git a/ZAPDTR/ZAPD/ZRoom/Commands/SetCutscenes.cpp b/ZAPDTR/ZAPD/ZRoom/Commands/SetCutscenes.cpp index 106f6f680..68ff58c19 100644 --- a/ZAPDTR/ZAPD/ZRoom/Commands/SetCutscenes.cpp +++ b/ZAPDTR/ZAPD/ZRoom/Commands/SetCutscenes.cpp @@ -10,19 +10,25 @@ SetCutscenes::SetCutscenes(ZFile* nParent) : ZRoomCommand(nParent) { } -SetCutscenes::~SetCutscenes() -{ - for (ZCutsceneBase* cutscene : cutscenes) - delete cutscene; -} - void SetCutscenes::ParseRawData() { ZRoomCommand::ParseRawData(); - std::string output; numCutscenes = cmdArg1; - if (Globals::Instance->game == ZGame::OOT_RETAIL || Globals::Instance->game == ZGame::OOT_SW97) + + if (Globals::Instance->game == ZGame::MM_RETAIL) + { + int32_t currentPtr = segmentOffset; + + cutsceneEntries.reserve(numCutscenes); + for (uint8_t i = 0; i < numCutscenes; i++) + { + CutsceneEntry entry(parent->GetRawData(), currentPtr); + cutsceneEntries.push_back(entry); + currentPtr += 8; + } + } + else if (Globals::Instance->game == ZGame::OOT_RETAIL || Globals::Instance->game == ZGame::OOT_SW97) { ZCutscene* cutscene = new ZCutscene(parent); cutscene->ExtractFromFile(segmentOffset); @@ -35,28 +41,48 @@ void SetCutscenes::ParseRawData() cutscenes.push_back(cutscene); } - else +} + +void SetCutscenes::DeclareReferences(const std::string& prefix) +{ + std::string varPrefix = name; + if (varPrefix == "") + varPrefix = prefix; + + if (Globals::Instance->game == ZGame::MM_RETAIL) { - int32_t currentPtr = segmentOffset; std::string declaration; + size_t i = 0; - for (uint8_t i = 0; i < numCutscenes; i++) + for (const auto& entry : cutsceneEntries) { - CutsceneEntry entry(parent->GetRawData(), currentPtr); - cutsceneEntries.push_back(entry); - currentPtr += 8; + if (entry.segmentPtr != SEGMENTED_NULL && + GETSEGNUM(entry.segmentPtr) == parent->segment) + { + offset_t csOffset = Seg2Filespace(entry.segmentPtr, parent->baseAddress); + if (!parent->HasDeclaration(csOffset)) + { + auto* cutscene = new ZCutscene(parent); + cutscene->ExtractFromFile(csOffset); + cutscene->SetName(cutscene->GetDefaultName(varPrefix)); + cutscene->DeclareVar(varPrefix, ""); + cutscene->DeclareReferences(varPrefix); + parent->AddResource(cutscene); + } + } - // TODO: don't hardcode %sCutsceneData_%06X, look up for the declared name instead - declaration += StringHelper::Sprintf( - " { %sCutsceneData_%06X, 0x%04X, 0x%02X, 0x%02X },", zRoom->GetName().c_str(), - entry.segmentOffset, entry.exit, entry.entrance, entry.flag); + std::string csName; + Globals::Instance->GetSegmentedPtrName(entry.segmentPtr, parent, "CutsceneData", + csName, parent->workerID); - if (i < numCutscenes - 1) + declaration += + StringHelper::Sprintf(" { %s, 0x%04X, 0x%02X, 0x%02X },", csName.c_str(), + entry.exit, entry.entrance, entry.flag); + + if (i + 1 < numCutscenes) declaration += "\n"; - ZCutsceneMM* cutscene = new ZCutsceneMM(parent); - cutscene->ExtractFromFile(entry.segmentOffset); - cutscenes.push_back(cutscene); + i++; } parent->AddDeclarationArray(segmentOffset, DeclarationAlignment::Align4, @@ -65,19 +91,19 @@ void SetCutscenes::ParseRawData() zRoom->GetName().c_str(), segmentOffset), cutsceneEntries.size(), declaration); } - - for (ZCutsceneBase* cutscene : cutscenes) + else { - if (cutscene->GetRawDataIndex() != 0) + if (cmdArg2 != SEGMENTED_NULL && GETSEGNUM(cmdArg2) == parent->segment) { - Declaration* decl = parent->GetDeclaration(cutscene->GetRawDataIndex()); - if (decl == nullptr) + offset_t csOffset = Seg2Filespace(cmdArg2, parent->baseAddress); + if (!parent->HasDeclaration(csOffset)) { - cutscene->GetSourceOutputCode(zRoom->GetName()); - } - else if (decl->text == "") - { - decl->text = cutscene->GetBodySourceCode(); + auto* cutscene = new ZCutscene(parent); + cutscene->ExtractFromFile(csOffset); + cutscene->SetName(cutscene->GetDefaultName(varPrefix)); + cutscene->DeclareVar(varPrefix, ""); + cutscene->DeclareReferences(varPrefix); + parent->AddResource(cutscene); } } } @@ -90,8 +116,15 @@ std::string SetCutscenes::GetBodySourceCode() const parent->workerID); if (Globals::Instance->game == ZGame::MM_RETAIL) + { + Globals::Instance->GetSegmentedPtrName(cmdArg2, parent, "CutsceneEntry", listName, + parent->workerID); return StringHelper::Sprintf("SCENE_CMD_CUTSCENE_LIST(%i, %s)", numCutscenes, listName.c_str()); + } + + Globals::Instance->GetSegmentedPtrName(cmdArg2, parent, "CutsceneData", listName, + parent->workerID); return StringHelper::Sprintf("SCENE_CMD_CUTSCENE_DATA(%s)", listName.c_str()); } @@ -106,7 +139,7 @@ RoomCommand SetCutscenes::GetRoomCommand() const } CutsceneEntry::CutsceneEntry(const std::vector& rawData, uint32_t rawDataIndex) - : segmentOffset(GETSEGOFFSET(BitConverter::ToInt32BE(rawData, rawDataIndex + 0))), + : segmentPtr(BitConverter::ToInt32BE(rawData, rawDataIndex + 0)), exit(BitConverter::ToInt16BE(rawData, rawDataIndex + 4)), entrance(rawData[rawDataIndex + 6]), flag(rawData[rawDataIndex + 7]) { diff --git a/ZAPDTR/ZAPD/ZRoom/Commands/SetCutscenes.h b/ZAPDTR/ZAPD/ZRoom/Commands/SetCutscenes.h index ad032bbe6..b1d175fec 100644 --- a/ZAPDTR/ZAPD/ZRoom/Commands/SetCutscenes.h +++ b/ZAPDTR/ZAPD/ZRoom/Commands/SetCutscenes.h @@ -1,7 +1,6 @@ #pragma once #include "ZCutscene.h" -#include "ZCutsceneMM.h" #include "ZRoom/ZRoomCommand.h" class CutsceneEntry @@ -9,7 +8,7 @@ class CutsceneEntry public: CutsceneEntry(const std::vector& rawData, uint32_t rawDataIndex); - uint32_t segmentOffset; + segptr_t segmentPtr; uint16_t exit; uint8_t entrance; uint8_t flag; @@ -18,14 +17,14 @@ public: class SetCutscenes : public ZRoomCommand { public: - std::vector cutscenes; + std::vector cutscenes; std::vector cutsceneEntries; // (MM Only) uint8_t numCutscenes; // (MM Only) SetCutscenes(ZFile* nParent); - ~SetCutscenes(); void ParseRawData() override; + void DeclareReferences(const std::string& prefix) override; std::string GetBodySourceCode() const override; diff --git a/ZAPDTR/ZAPD/ZRoom/Commands/SetEntranceList.cpp b/ZAPDTR/ZAPD/ZRoom/Commands/SetEntranceList.cpp index aa20102ff..6749e1770 100644 --- a/ZAPDTR/ZAPD/ZRoom/Commands/SetEntranceList.cpp +++ b/ZAPDTR/ZAPD/ZRoom/Commands/SetEntranceList.cpp @@ -24,10 +24,11 @@ void SetEntranceList::DeclareReferences([[maybe_unused]] const std::string& pref void SetEntranceList::ParseRawDataLate() { // Parse Entrances and Generate Declaration - int numEntrances = zRoom->GetDeclarationSizeFromNeighbor(segmentOffset) / 2; + uint32_t numEntrances = zRoom->GetDeclarationSizeFromNeighbor(segmentOffset) / 2; uint32_t currentPtr = segmentOffset; - for (int32_t i = 0; i < numEntrances; i++) + entrances.reserve(numEntrances); + for (uint32_t i = 0; i < numEntrances; i++) { EntranceEntry entry(parent->GetRawData(), currentPtr); entrances.push_back(entry); diff --git a/ZAPDTR/ZAPD/ZRoom/Commands/SetExitList.cpp b/ZAPDTR/ZAPD/ZRoom/Commands/SetExitList.cpp index 34d2a6e56..3b9ce2dfa 100644 --- a/ZAPDTR/ZAPD/ZRoom/Commands/SetExitList.cpp +++ b/ZAPDTR/ZAPD/ZRoom/Commands/SetExitList.cpp @@ -4,6 +4,7 @@ #include "Utils/BitConverter.h" #include "Utils/StringHelper.h" #include "ZFile.h" +#include "ZRoom/ZNames.h" #include "ZRoom/ZRoom.h" SetExitList::SetExitList(ZFile* nParent) : ZRoomCommand(nParent) @@ -23,10 +24,11 @@ void SetExitList::DeclareReferences([[maybe_unused]] const std::string& prefix) void SetExitList::ParseRawDataLate() { // Parse Entrances and Generate Declaration - int numEntrances = zRoom->GetDeclarationSizeFromNeighbor(segmentOffset) / 2; + uint32_t numEntrances = zRoom->GetDeclarationSizeFromNeighbor(segmentOffset) / 2; uint32_t currentPtr = segmentOffset; - for (int32_t i = 0; i < numEntrances; i++) + exits.reserve(numEntrances); + for (uint32_t i = 0; i < numEntrances; i++) { uint16_t exit = BitConverter::ToUInt16BE(parent->GetRawData(), currentPtr); exits.push_back(exit); @@ -43,7 +45,8 @@ void SetExitList::DeclareReferencesLate([[maybe_unused]] const std::string& pref for (size_t i = 0; i < exits.size(); i++) { - declaration += StringHelper::Sprintf(" 0x%04X,", exits.at(i)); + declaration += + StringHelper::Sprintf(" %s,", ZNames::GetEntranceName(exits[i]).c_str()); if (i + 1 < exits.size()) declaration += "\n"; } diff --git a/ZAPDTR/ZAPD/ZRoom/Commands/SetLightList.cpp b/ZAPDTR/ZAPD/ZRoom/Commands/SetLightList.cpp index 060fce0a2..4c551be13 100644 --- a/ZAPDTR/ZAPD/ZRoom/Commands/SetLightList.cpp +++ b/ZAPDTR/ZAPD/ZRoom/Commands/SetLightList.cpp @@ -15,6 +15,8 @@ void SetLightList::ParseRawData() numLights = cmdArg1; int32_t currentPtr = segmentOffset; + + lights.reserve(this->numLights); for (int i = 0; i < this->numLights; i++) { LightInfo light(parent->GetRawData(), currentPtr); diff --git a/ZAPDTR/ZAPD/ZRoom/Commands/SetLightingSettings.cpp b/ZAPDTR/ZAPD/ZRoom/Commands/SetLightingSettings.cpp index 4824f3f61..547862a52 100644 --- a/ZAPDTR/ZAPD/ZRoom/Commands/SetLightingSettings.cpp +++ b/ZAPDTR/ZAPD/ZRoom/Commands/SetLightingSettings.cpp @@ -15,6 +15,7 @@ void SetLightingSettings::ParseRawData() ZRoomCommand::ParseRawData(); uint8_t numLights = cmdArg1; + settings.reserve(numLights); for (int i = 0; i < numLights; i++) settings.push_back(LightingSettings(parent->GetRawData(), segmentOffset + (i * 22))); } diff --git a/ZAPDTR/ZAPD/ZRoom/Commands/SetMesh.cpp b/ZAPDTR/ZAPD/ZRoom/Commands/SetMesh.cpp index 0723fcf14..c6f2d7dca 100644 --- a/ZAPDTR/ZAPD/ZRoom/Commands/SetMesh.cpp +++ b/ZAPDTR/ZAPD/ZRoom/Commands/SetMesh.cpp @@ -442,6 +442,8 @@ void PolygonType1::DeclareReferences(const std::string& prefix) { listAddress = Seg2Filespace(list, parent->baseAddress); uint32_t auxPtr = listAddress; + + multiList.reserve(count); for (size_t i = 0; i < count; ++i) { BgImage bg(false, prefix, auxPtr, parent); @@ -545,6 +547,8 @@ void PolygonType2::ParseRawData() end = BitConverter::ToUInt32BE(rawData, rawDataIndex + 0x08); uint32_t currentPtr = GETSEGOFFSET(start); + + polyDLists.reserve(num); for (size_t i = 0; i < num; i++) { PolygonDlist entry(parent); diff --git a/ZAPDTR/ZAPD/ZRoom/Commands/SetMinimapChests.cpp b/ZAPDTR/ZAPD/ZRoom/Commands/SetMinimapChests.cpp index 3e6c72a11..25bfae703 100644 --- a/ZAPDTR/ZAPD/ZRoom/Commands/SetMinimapChests.cpp +++ b/ZAPDTR/ZAPD/ZRoom/Commands/SetMinimapChests.cpp @@ -15,8 +15,9 @@ void SetMinimapChests::ParseRawData() ZRoomCommand::ParseRawData(); int numChests = cmdArg1; - int32_t currentPtr = segmentOffset; + offset_t currentPtr = segmentOffset; + chests.reserve(numChests); for (int32_t i = 0; i < numChests; i++) { MinimapChest chest(parent->GetRawData(), currentPtr); diff --git a/ZAPDTR/ZAPD/ZRoom/Commands/SetMinimapList.cpp b/ZAPDTR/ZAPD/ZRoom/Commands/SetMinimapList.cpp index 255bd4e3a..e02e1a92b 100644 --- a/ZAPDTR/ZAPD/ZRoom/Commands/SetMinimapList.cpp +++ b/ZAPDTR/ZAPD/ZRoom/Commands/SetMinimapList.cpp @@ -17,8 +17,9 @@ void SetMinimapList::ParseRawData() listSegmentOffset = GETSEGOFFSET(listSegmentAddr); unk4 = BitConverter::ToInt32BE(parent->GetRawData(), segmentOffset + 4); - int32_t currentPtr = listSegmentOffset; + uint32_t currentPtr = listSegmentOffset; + minimaps.reserve(zRoom->roomCount); for (int32_t i = 0; i < zRoom->roomCount; i++) { MinimapEntry entry(parent->GetRawData(), currentPtr); diff --git a/ZAPDTR/ZAPD/ZRoom/Commands/SetObjectList.cpp b/ZAPDTR/ZAPD/ZRoom/Commands/SetObjectList.cpp index 29519d3ce..a8bb76a08 100644 --- a/ZAPDTR/ZAPD/ZRoom/Commands/SetObjectList.cpp +++ b/ZAPDTR/ZAPD/ZRoom/Commands/SetObjectList.cpp @@ -17,6 +17,7 @@ void SetObjectList::ParseRawData() uint8_t objectCnt = parent->GetRawData().at(rawDataIndex + 1); uint32_t currentPtr = segmentOffset; + objects.reserve(objectCnt); for (uint8_t i = 0; i < objectCnt; i++) { uint16_t objectIndex = BitConverter::ToInt16BE(parent->GetRawData(), currentPtr); diff --git a/ZAPDTR/ZAPD/ZRoom/Commands/SetRoomList.cpp b/ZAPDTR/ZAPD/ZRoom/Commands/SetRoomList.cpp index a63dd8772..abb2b003c 100644 --- a/ZAPDTR/ZAPD/ZRoom/Commands/SetRoomList.cpp +++ b/ZAPDTR/ZAPD/ZRoom/Commands/SetRoomList.cpp @@ -69,6 +69,7 @@ void RomFile::ParseRawData() uint32_t currentPtr = rawDataIndex; + rooms.reserve(numRooms); for (int32_t i = 0; i < numRooms; i++) { RoomEntry entry(parent->GetRawData(), currentPtr); @@ -104,9 +105,9 @@ std::string RomFile::GetBodySourceCode() const if (!isFirst) declaration += "\n"; - declaration += - StringHelper::Sprintf("\t{ (u32)_%sSegmentRomStart, (u32)_%sSegmentRomEnd },", - roomName.c_str(), roomName.c_str()); + declaration += StringHelper::Sprintf( + "\t{ (uintptr_t)_%sSegmentRomStart, (uintptr_t)_%sSegmentRomEnd },", + roomName.c_str(), roomName.c_str()); isFirst = false; } } diff --git a/ZAPDTR/ZAPD/ZRoom/Commands/SetStartPositionList.cpp b/ZAPDTR/ZAPD/ZRoom/Commands/SetStartPositionList.cpp index 32a2b7000..03856d23b 100644 --- a/ZAPDTR/ZAPD/ZRoom/Commands/SetStartPositionList.cpp +++ b/ZAPDTR/ZAPD/ZRoom/Commands/SetStartPositionList.cpp @@ -16,9 +16,10 @@ void SetStartPositionList::ParseRawData() ZRoomCommand::ParseRawData(); uint8_t numActors = cmdArg1; - uint32_t currentPtr = segmentOffset; + offset_t currentPtr = segmentOffset; - for (int32_t i = 0; i < numActors; i++) + actors.reserve(numActors); + for (uint32_t i = 0; i < numActors; i++) { actors.push_back(ActorSpawnEntry(parent->GetRawData(), currentPtr)); currentPtr += 16; diff --git a/ZAPDTR/ZAPD/ZRoom/Commands/SetTransitionActorList.cpp b/ZAPDTR/ZAPD/ZRoom/Commands/SetTransitionActorList.cpp index 2414f0d2f..051ddd875 100644 --- a/ZAPDTR/ZAPD/ZRoom/Commands/SetTransitionActorList.cpp +++ b/ZAPDTR/ZAPD/ZRoom/Commands/SetTransitionActorList.cpp @@ -17,6 +17,7 @@ void SetTransitionActorList::ParseRawData() int numActors = cmdArg1; uint32_t currentPtr = segmentOffset; + transitionActors.reserve(numActors); for (int32_t i = 0; i < numActors; i++) { TransitionActorEntry entry(parent->GetRawData(), currentPtr); diff --git a/ZAPDTR/ZAPD/ZRoom/ZNames.h b/ZAPDTR/ZAPD/ZRoom/ZNames.h index 94e08de0d..667407c36 100644 --- a/ZAPDTR/ZAPD/ZRoom/ZNames.h +++ b/ZAPDTR/ZAPD/ZRoom/ZNames.h @@ -12,17 +12,17 @@ public: { if (id >= Globals::Instance->cfg.objectList.size()) return StringHelper::Sprintf("0x%04X", id); - return Globals::Instance->cfg.objectList.at(id); + return Globals::Instance->cfg.objectList[id]; } - static std::string GetActorName(int32_t id) + static std::string GetActorName(uint16_t id) { switch (Globals::Instance->game) { case ZGame::OOT_RETAIL: case ZGame::OOT_SW97: if (id < ZNames::GetNumActors()) - return Globals::Instance->cfg.actorList.at(id); + return Globals::Instance->cfg.actorList[id]; else return StringHelper::Sprintf("0x%04X", id); case ZGame::MM_RETAIL: @@ -31,7 +31,7 @@ public: id &= 0xFFF; std::string name; if (id < ZNames::GetNumActors()) - name = Globals::Instance->cfg.actorList.at(id); + name = Globals::Instance->cfg.actorList[id]; else name = StringHelper::Sprintf("0x%04X", id); @@ -45,5 +45,20 @@ public: return ""; } - static int32_t GetNumActors() { return Globals::Instance->cfg.actorList.size(); } + static std::string GetEntranceName(uint16_t id) + { + if (ZNames::GetNumEntrances() == 0 || ZNames::GetNumSpecialEntrances() == 0) + return StringHelper::Sprintf("0x%04X", id); + + if (id < ZNames::GetNumEntrances()) + return Globals::Instance->cfg.entranceList[id]; + else if ((id >= 0x7FF9 && id <= 0x7FFF) && !((id - 0x7FF9U) > GetNumSpecialEntrances())) // Special entrances + return Globals::Instance->cfg.specialEntranceList[id - 0x7FF9]; + else + return StringHelper::Sprintf("0x%04X", id); + } + + static size_t GetNumActors() { return Globals::Instance->cfg.actorList.size(); } + static size_t GetNumEntrances() { return Globals::Instance->cfg.entranceList.size(); } + static size_t GetNumSpecialEntrances() { return Globals::Instance->cfg.specialEntranceList.size(); } }; diff --git a/ZAPDTR/ZAPD/ZRoom/ZRoom.cpp b/ZAPDTR/ZAPD/ZRoom/ZRoom.cpp index 5831eaa56..11dd70687 100644 --- a/ZAPDTR/ZAPD/ZRoom/ZRoom.cpp +++ b/ZAPDTR/ZAPD/ZRoom/ZRoom.cpp @@ -39,7 +39,7 @@ #include "Commands/Unused1D.h" #include "Commands/ZRoomCommandUnk.h" #include "Globals.h" -#include "Utils/File.h" +#include #include "Utils/Path.h" #include "Utils/StringHelper.h" #include "WarningHandler.h" diff --git a/ZAPDTR/ZAPD/ZScalar.cpp b/ZAPDTR/ZAPD/ZScalar.cpp index 7e4be4d57..6c4cf121a 100644 --- a/ZAPDTR/ZAPD/ZScalar.cpp +++ b/ZAPDTR/ZAPD/ZScalar.cpp @@ -2,7 +2,7 @@ #include "Globals.h" #include "Utils/BitConverter.h" -#include "Utils/File.h" +#include #include "Utils/StringHelper.h" #include "WarningHandler.h" #include "ZFile.h" diff --git a/ZAPDTR/ZAPD/ZSkeleton.cpp b/ZAPDTR/ZAPD/ZSkeleton.cpp index bff4b8263..a071209bc 100644 --- a/ZAPDTR/ZAPD/ZSkeleton.cpp +++ b/ZAPDTR/ZAPD/ZSkeleton.cpp @@ -10,10 +10,15 @@ REGISTER_ZFILENODE(Skeleton, ZSkeleton); REGISTER_ZFILENODE(LimbTable, ZLimbTable); -ZSkeleton::ZSkeleton(ZFile* nParent) : ZResource(nParent), limbsTable(nParent) +ZSkeleton::ZSkeleton(ZFile* nParent) : ZResource(nParent) { RegisterRequiredAttribute("Type"); RegisterRequiredAttribute("LimbType"); + genOTRDef = true; + + RegisterOptionalAttribute("EnumName"); + RegisterOptionalAttribute("LimbNone"); + RegisterOptionalAttribute("LimbMax"); genOTRDef = true; } @@ -44,6 +49,41 @@ void ZSkeleton::ParseXML(tinyxml2::XMLElement* reader) limbTypeXml.c_str()), "Defaulting to 'Standard'."); } + + enumName = registeredAttributes.at("EnumName").value; + limbNoneName = registeredAttributes.at("LimbNone").value; + limbMaxName = registeredAttributes.at("LimbMax").value; + + if (enumName != "") + { + if (limbNoneName == "" || limbMaxName == "") + { + HANDLE_ERROR_RESOURCE(WarningType::MissingAttribute, parent, this, rawDataIndex, + "'EnumName' attribute was used but either 'LimbNone' or " + "'LimbMax' attribute is missing", + ""); + } + } + + if (limbNoneName != "") + { + if (limbMaxName == "") + { + HANDLE_ERROR_RESOURCE( + WarningType::MissingAttribute, parent, this, rawDataIndex, + "'LimbNone' attribute was used but 'LimbMax' attribute is missing", ""); + } + } + + if (limbMaxName != "") + { + if (limbNoneName == "") + { + HANDLE_ERROR_RESOURCE( + WarningType::MissingAttribute, parent, this, rawDataIndex, + "'LimbMax' attribute was used but 'LimbNone' attribute is missing", ""); + } + } } void ZSkeleton::ParseRawData() @@ -58,12 +98,6 @@ void ZSkeleton::ParseRawData() { dListCount = BitConverter::ToUInt8BE(rawData, rawDataIndex + 8); } - - if (limbsArrayAddress != 0 && GETSEGNUM(limbsArrayAddress) == parent->segment) - { - uint32_t ptr = Seg2Filespace(limbsArrayAddress, parent->baseAddress); - limbsTable.ExtractFromBinary(ptr, limbType, limbCount); - } } void ZSkeleton::DeclareReferences(const std::string& prefix) @@ -74,14 +108,33 @@ void ZSkeleton::DeclareReferences(const std::string& prefix) ZResource::DeclareReferences(defaultPrefix); - if (limbsArrayAddress != 0 && GETSEGNUM(limbsArrayAddress) == parent->segment) + if (limbsArrayAddress != SEGMENTED_NULL && GETSEGNUM(limbsArrayAddress) == parent->segment) { - uint32_t ptr = Seg2Filespace(limbsArrayAddress, parent->baseAddress); + offset_t ptr = Seg2Filespace(limbsArrayAddress, parent->baseAddress); + if (!parent->HasDeclaration(ptr)) { - limbsTable.SetName(StringHelper::Sprintf("%sLimbs", defaultPrefix.c_str())); - limbsTable.DeclareReferences(prefix); - limbsTable.GetSourceOutputCode(prefix); + limbsTable = new ZLimbTable(parent); + limbsTable->ExtractFromBinary(ptr, limbType, limbCount); + limbsTable->SetName(StringHelper::Sprintf("%sLimbs", defaultPrefix.c_str())); + parent->AddResource(limbsTable); + } + else + { + limbsTable = static_cast(parent->FindResource(ptr)); + } + + if (limbsTable->enumName == "") + { + limbsTable->enumName = enumName; + } + if (limbsTable->limbNoneName == "") + { + limbsTable->limbNoneName = limbNoneName; + } + if (limbsTable->limbMaxName == "") + { + limbsTable->limbMaxName = limbMaxName; } } } @@ -92,15 +145,27 @@ std::string ZSkeleton::GetBodySourceCode() const Globals::Instance->GetSegmentedPtrName(limbsArrayAddress, parent, "", limbArrayName, parent->workerID); + std::string countStr; + assert(limbsTable != nullptr); + // There are some Skeletons with the wrong limb count on them, so this check is necessary. + if (limbsTable->count == limbCount) + { + countStr = StringHelper::Sprintf("ARRAY_COUNT(%s)", limbArrayName.c_str()); + } + else + { + countStr = StringHelper::Sprintf("%i", limbCount); + } + switch (type) { case ZSkeletonType::Normal: case ZSkeletonType::Curve: - return StringHelper::Sprintf("\n\t%s, %i\n", limbArrayName.c_str(), limbCount); + return StringHelper::Sprintf("\n\t%s, %s\n", limbArrayName.c_str(), countStr.c_str()); case ZSkeletonType::Flex: - return StringHelper::Sprintf("\n\t{ %s, %i }, %i\n", limbArrayName.c_str(), limbCount, - dListCount); + return StringHelper::Sprintf("\n\t{ %s, %s }, %i\n", limbArrayName.c_str(), + countStr.c_str(), dListCount); } // TODO: Throw exception? @@ -156,6 +221,9 @@ ZLimbTable::ZLimbTable(ZFile* nParent) : ZResource(nParent) { RegisterRequiredAttribute("LimbType"); RegisterRequiredAttribute("Count"); + RegisterOptionalAttribute("EnumName"); + RegisterOptionalAttribute("LimbNone"); + RegisterOptionalAttribute("LimbMax"); } void ZLimbTable::ExtractFromBinary(uint32_t nRawDataIndex, ZLimbType nLimbType, size_t nCount) @@ -182,6 +250,40 @@ void ZLimbTable::ParseXML(tinyxml2::XMLElement* reader) } count = StringHelper::StrToL(registeredAttributes.at("Count").value); + + enumName = registeredAttributes.at("EnumName").value; + limbNoneName = registeredAttributes.at("LimbNone").value; + limbMaxName = registeredAttributes.at("LimbMax").value; + + if (enumName != "") + { + if (limbNoneName == "" || limbMaxName == "") + { + HANDLE_ERROR_RESOURCE( + WarningType::MissingAttribute, parent, this, rawDataIndex, + "'EnumName' attribute was used but 'LimbNone'/'LimbMax' attributes is missing", ""); + } + } + + if (limbNoneName != "") + { + if (limbMaxName == "") + { + HANDLE_ERROR_RESOURCE( + WarningType::MissingAttribute, parent, this, rawDataIndex, + "'LimbNone' attribute was used but 'LimbMax' attribute is missing", ""); + } + } + + if (limbMaxName != "") + { + if (limbNoneName == "") + { + HANDLE_ERROR_RESOURCE( + WarningType::MissingAttribute, parent, this, rawDataIndex, + "'LimbMax' attribute was used but 'LimbNone' attribute is missing", ""); + } + } } void ZLimbTable::ParseRawData() @@ -190,6 +292,8 @@ void ZLimbTable::ParseRawData() const auto& rawData = parent->GetRawData(); uint32_t ptr = rawDataIndex; + + limbsAddresses.reserve(count); for (size_t i = 0; i < count; i++) { limbsAddresses.push_back(BitConverter::ToUInt32BE(rawData, ptr)); @@ -204,7 +308,7 @@ void ZLimbTable::DeclareReferences(const std::string& prefix) varPrefix = prefix; ZResource::DeclareReferences(varPrefix); - + limbsReferences.reserve(count); for (size_t i = 0; i < count; i++) { segptr_t limbAddress = limbsAddresses[i]; @@ -212,15 +316,28 @@ void ZLimbTable::DeclareReferences(const std::string& prefix) if (limbAddress != 0 && GETSEGNUM(limbAddress) == parent->segment) { uint32_t limbOffset = Seg2Filespace(limbAddress, parent->baseAddress); + ZLimb* limb; + if (!parent->HasDeclaration(limbOffset)) { - ZLimb* limb = new ZLimb(parent); + limb = new ZLimb(parent); limb->ExtractFromBinary(limbOffset, limbType); limb->SetName(limb->GetDefaultName(varPrefix)); limb->DeclareVar(varPrefix, ""); limb->DeclareReferences(varPrefix); parent->AddResource(limb); } + else + { + limb = static_cast(parent->FindResource(limbOffset)); + assert(limb != nullptr); + assert(limb->GetResourceType() == ZResourceType::Limb); + } + + limb->limbsTable = this; + limb->SetLimbIndex(i + 1); + + limbsReferences.push_back(limb); } } } @@ -250,6 +367,13 @@ std::string ZLimbTable::GetBodySourceCode() const parent->workerID); body += StringHelper::Sprintf("\t%s,", limbName.c_str()); + auto& limb = limbsReferences.at(i); + std::string limbEnumName = limb->enumName; + if (limbEnumName != "") + { + body += StringHelper::Sprintf(" /* %s */", limbEnumName.c_str()); + } + if (i + 1 < count) body += "\n"; } @@ -257,6 +381,46 @@ std::string ZLimbTable::GetBodySourceCode() const return body; } +std::string ZLimbTable::GetSourceOutputHeader([[maybe_unused]] const std::string& prefix) +{ + if (limbNoneName == "" || limbMaxName == "" || enumName == "") + { + // Don't produce a enum of any of those attributes is missing + return ""; + } + + std::string limbEnum = StringHelper::Sprintf("typedef enum %s {\n", enumName.c_str()); + + // This assumes there isn't any skeleton with more than 0x100 limbs + + limbEnum += StringHelper::Sprintf(" /* 0x00 */ %s,\n", limbNoneName.c_str()); + + size_t i = 0; + for (; i < count; i++) + { + auto& limb = limbsReferences.at(i); + std::string limbEnumName = limb->enumName; + + if (limbEnumName == "") + { + HANDLE_ERROR_RESOURCE( + WarningType::MissingAttribute, parent, this, rawDataIndex, + "Skeleton's enum attributes were used but at least one limb is missing its " + "'LimbName' attribute", + StringHelper::Sprintf("When processing limb %02i, named '%s' at offset '0x%X'", + i + 1, limb->GetName().c_str(), limb->GetRawDataIndex())); + } + + limbEnum += StringHelper::Sprintf(" /* 0x%02X */ %s,\n", i + 1, limbEnumName.c_str()); + } + + limbEnum += StringHelper::Sprintf(" /* 0x%02X */ %s\n", i + 1, limbMaxName.c_str()); + + limbEnum += StringHelper::Sprintf("} %s;\n", enumName.c_str()); + + return limbEnum; +} + std::string ZLimbTable::GetSourceTypeName() const { switch (limbType) @@ -287,3 +451,28 @@ size_t ZLimbTable::GetRawDataSize() const { return 4 * limbsAddresses.size(); } + +std::string ZLimbTable::GetLimbEnumName(uint8_t limbIndex) const +{ + if (limbIndex == 0xFF) + { + return "LIMB_DONE"; + } + + if (limbIndex < count) + { + std::string limbEnumName = limbsReferences.at(limbIndex)->enumName; + if (limbEnumName != "") + { + return StringHelper::Sprintf("%s - 1", limbEnumName.c_str()); + } + } + else + { + HANDLE_WARNING_RESOURCE(WarningType::InvalidExtractedData, parent, this, rawDataIndex, + StringHelper::Sprintf("Limb index '%02i' out of range", limbIndex), + ""); + } + + return StringHelper::Sprintf("0x%02X", limbIndex); +} diff --git a/ZAPDTR/ZAPD/ZSkeleton.h b/ZAPDTR/ZAPD/ZSkeleton.h index b1598c6d2..892d5de35 100644 --- a/ZAPDTR/ZAPD/ZSkeleton.h +++ b/ZAPDTR/ZAPD/ZSkeleton.h @@ -20,7 +20,14 @@ class ZLimbTable : public ZResource public: ZLimbType limbType = ZLimbType::Standard; size_t count = 0; + std::vector limbsAddresses; + std::vector limbsReferences; // borrowed pointers, do not delete! + + // XML attributes + std::string enumName; + std::string limbNoneName; + std::string limbMaxName; ZLimbTable(ZFile* nParent); @@ -34,10 +41,14 @@ public: std::string GetBodySourceCode() const override; + std::string GetSourceOutputHeader([[maybe_unused]] const std::string& prefix); + std::string GetSourceTypeName() const override; ZResourceType GetResourceType() const override; size_t GetRawDataSize() const override; + + std::string GetLimbEnumName(uint8_t limbIndex) const; }; class ZSkeleton : public ZResource @@ -45,10 +56,13 @@ class ZSkeleton : public ZResource public: ZSkeletonType type = ZSkeletonType::Normal; ZLimbType limbType = ZLimbType::Standard; + std::string enumName; + std::string limbNoneName; + std::string limbMaxName; + segptr_t limbsArrayAddress; uint8_t limbCount = 0; uint8_t dListCount = 0; // FLEX SKELETON ONLY - ZLimbTable limbsTable; ZSkeleton(ZFile* nParent); @@ -65,4 +79,7 @@ public: DeclarationAlignment GetDeclarationAlignment() const override; uint8_t GetLimbCount(); + + ZLimbTable* limbsTable = nullptr; // borrowed pointer, do not delete! + }; diff --git a/ZAPDTR/ZAPD/ZString.cpp b/ZAPDTR/ZAPD/ZString.cpp index 2a0c1eaf8..4a9069496 100644 --- a/ZAPDTR/ZAPD/ZString.cpp +++ b/ZAPDTR/ZAPD/ZString.cpp @@ -1,6 +1,6 @@ #include "ZString.h" -#include "Utils/File.h" +#include #include "Utils/StringHelper.h" #include "ZFile.h" diff --git a/ZAPDTR/ZAPD/ZSurfaceType.cpp b/ZAPDTR/ZAPD/ZSurfaceType.cpp new file mode 100644 index 000000000..27e73accc --- /dev/null +++ b/ZAPDTR/ZAPD/ZSurfaceType.cpp @@ -0,0 +1,65 @@ +#include "ZSurfaceType.h" + +#include "Globals.h" +#include "Utils/BitConverter.h" +#include "Utils/StringHelper.h" + +REGISTER_ZFILENODE(SurfaceType, ZSurfaceType); + +ZSurfaceType::ZSurfaceType(ZFile* nParent) : ZResource(nParent) +{ +} + +ZSurfaceType::~ZSurfaceType() +{ +} + +void ZSurfaceType::ParseRawData() +{ + const auto& rawData = parent->GetRawData(); + + data[0] = BitConverter::ToUInt32BE(rawData, rawDataIndex + 0); + data[1] = BitConverter::ToUInt32BE(rawData, rawDataIndex + 4); +} + +void ZSurfaceType::DeclareReferences(const std::string& prefix) +{ + std::string declaration; + std::string auxName = name; + + if (name == "") + auxName = GetDefaultName(prefix); + + parent->AddDeclaration(rawDataIndex, DeclarationAlignment::Align4, GetRawDataSize(), + GetSourceTypeName(), name.c_str(), GetBodySourceCode()); +} + +std::string ZSurfaceType::GetBodySourceCode() const +{ + return StringHelper::Sprintf("{0x%08X, 0x%08X}", data[0], data[1]); +} + +std::string ZSurfaceType::GetDefaultName(const std::string& prefix) const +{ + return StringHelper::Sprintf("%sSurfaceType_%06X", prefix.c_str(), rawDataIndex); +} + +ZResourceType ZSurfaceType::GetResourceType() const +{ + return ZResourceType::SurfaceType; +} + +size_t ZSurfaceType::GetRawDataSize() const +{ + return 8; +} + +std::string ZSurfaceType::GetSourceTypeName() const +{ + return "SurfaceType"; +} + +bool ZSurfaceType::DoesSupportArray() const +{ + return true; +} diff --git a/ZAPDTR/ZAPD/ZSurfaceType.h b/ZAPDTR/ZAPD/ZSurfaceType.h new file mode 100644 index 000000000..3bbddee8c --- /dev/null +++ b/ZAPDTR/ZAPD/ZSurfaceType.h @@ -0,0 +1,27 @@ +#pragma once + +#include +#include "ZFile.h" +#include "ZResource.h" + +class ZSurfaceType : public ZResource +{ +public: + std::array data; + + ZSurfaceType(ZFile* nParent); + ~ZSurfaceType(); + + void ParseRawData() override; + void DeclareReferences(const std::string& prefix) override; + + std::string GetBodySourceCode() const override; + std::string GetDefaultName(const std::string& prefix) const override; + + std::string GetSourceTypeName() const override; + ZResourceType GetResourceType() const override; + + bool DoesSupportArray() const override; + + size_t GetRawDataSize() const override; +}; diff --git a/ZAPDTR/ZAPD/ZText.cpp b/ZAPDTR/ZAPD/ZText.cpp index b024920ba..95e4b5236 100644 --- a/ZAPDTR/ZAPD/ZText.cpp +++ b/ZAPDTR/ZAPD/ZText.cpp @@ -2,7 +2,7 @@ #include "Globals.h" #include "Utils/BitConverter.h" -#include "Utils/File.h" +#include #include "Utils/Path.h" #include "Utils/StringHelper.h" #include "ZFile.h" diff --git a/ZAPDTR/ZAPD/ZTexture.cpp b/ZAPDTR/ZAPD/ZTexture.cpp index 4b58b7195..e0a91f082 100644 --- a/ZAPDTR/ZAPD/ZTexture.cpp +++ b/ZAPDTR/ZAPD/ZTexture.cpp @@ -6,7 +6,7 @@ #include "Globals.h" #include "Utils/BitConverter.h" #include "Utils/Directory.h" -#include "Utils/File.h" +#include #include "Utils/Path.h" #include "WarningHandler.h" @@ -18,11 +18,15 @@ ZTexture::ZTexture(ZFile* nParent) : ZResource(nParent) height = 0; dWordAligned = true; genOTRDef = true; + splitTlut = false; RegisterRequiredAttribute("Width"); RegisterRequiredAttribute("Height"); RegisterRequiredAttribute("Format"); RegisterOptionalAttribute("TlutOffset"); + RegisterOptionalAttribute("ExternalTlut"); + RegisterOptionalAttribute("ExternalTlutOffset"); + RegisterOptionalAttribute("SplitTlut"); } void ZTexture::ExtractFromBinary(uint32_t nRawDataIndex, int32_t nWidth, int32_t nHeight, @@ -57,6 +61,7 @@ void ZTexture::ParseXML(tinyxml2::XMLElement* reader) std::string widthXml = registeredAttributes.at("Width").value; std::string heightXml = registeredAttributes.at("Height").value; + std::string SplitTlutXml = registeredAttributes.at("SplitTlut").value; if (!StringHelper::HasOnlyDigits(widthXml)) { @@ -73,6 +78,27 @@ void ZTexture::ParseXML(tinyxml2::XMLElement* reader) errorHeader, ""); } + if (!registeredAttributes.at("ExternalTlut").wasSet && + registeredAttributes.at("SplitTlut").wasSet) + { + std::string errorHeader = + StringHelper::Sprintf("SplitTlut set without using an external tlut"); + HANDLE_WARNING_RESOURCE(WarningType::InvalidAttributeValue, parent, this, rawDataIndex, + errorHeader, ""); + } + + if (!SplitTlutXml.empty()) + { + if (!tinyxml2::XMLUtil::ToBool(SplitTlutXml.c_str(), &splitTlut)) + { + std::string errorHeader = StringHelper::Sprintf( + "Invalid value passed to SplitTlut: '%s'. Valid values are true, false, 1, 0", + SplitTlutXml.c_str()); + HANDLE_ERROR_RESOURCE(WarningType::InvalidAttributeValue, parent, this, rawDataIndex, + errorHeader, ""); + } + } + width = StringHelper::StrToL(widthXml); height = StringHelper::StrToL(heightXml); @@ -146,6 +172,47 @@ void ZTexture::ParseRawData() } } +void ZTexture::ParseRawDataLate() +{ + if (registeredAttributes["ExternalTlut"].wasSet) + { + const std::string externPalette = registeredAttributes["ExternalTlut"].value; + for (const auto& file : Globals::Instance->files) + { + if (file->GetName() == externPalette) + { + offset_t palOffset = 0; + if (registeredAttributes["ExternalTlutOffset"].wasSet) + { + palOffset = + StringHelper::StrToL(registeredAttributes["ExternalTlutOffset"].value, 16); + } + else + { + HANDLE_WARNING_RESOURCE( + WarningType::MissingOffsets, parent, this, rawDataIndex, + StringHelper::Sprintf( + "No ExternalTlutOffset Given. Assuming offset of 0x0"), + ""); + } + for (const auto& res : file->resources) + { + if (res->GetRawDataIndex() == palOffset) + { + ZTexture* palette = (ZTexture*)res; + ZTexture tlutTemp(file); + + tlut = &tlutTemp; + tlut->ExtractFromBinary(palOffset, palette->width, palette->height, + TextureType::RGBA16bpp, true); + SetTlut(tlut); + } + } + } + } + } +} + void ZTexture::PrepareBitmapRGBA16() { textureData.InitEmptyRGBImage(width, height, true); @@ -351,34 +418,42 @@ void ZTexture::DeclareReferences([[maybe_unused]] const std::string& prefix) void ZTexture::PrepareRawDataFromFile(const fs::path& pngFilePath) { + textureData.ReadPng(pngFilePath); + + width = textureData.GetWidth(); + height = textureData.GetHeight(); + + textureDataRaw.clear(); + textureDataRaw.resize(GetRawDataSize()); + switch (format) { case TextureType::RGBA16bpp: - PrepareRawDataRGBA16(pngFilePath); + PrepareRawDataRGBA16(); break; case TextureType::RGBA32bpp: - PrepareRawDataRGBA32(pngFilePath); + PrepareRawDataRGBA32(); break; case TextureType::Grayscale4bpp: - PrepareRawDataGrayscale4(pngFilePath); + PrepareRawDataGrayscale4(); break; case TextureType::Grayscale8bpp: - PrepareRawDataGrayscale8(pngFilePath); + PrepareRawDataGrayscale8(); break; case TextureType::GrayscaleAlpha4bpp: - PrepareRawDataGrayscaleAlpha4(pngFilePath); + PrepareRawDataGrayscaleAlpha4(); break; case TextureType::GrayscaleAlpha8bpp: - PrepareRawDataGrayscaleAlpha8(pngFilePath); + PrepareRawDataGrayscaleAlpha8(); break; case TextureType::GrayscaleAlpha16bpp: - PrepareRawDataGrayscaleAlpha16(pngFilePath); + PrepareRawDataGrayscaleAlpha16(); break; case TextureType::Palette4bpp: - PrepareRawDataPalette4(pngFilePath); + PrepareRawDataPalette4(); break; case TextureType::Palette8bpp: - PrepareRawDataPalette8(pngFilePath); + PrepareRawDataPalette8(); break; case TextureType::Error: HANDLE_ERROR_PROCESS(WarningType::InvalidPNG, "Input PNG file has invalid format type", ""); @@ -386,15 +461,8 @@ void ZTexture::PrepareRawDataFromFile(const fs::path& pngFilePath) } } -void ZTexture::PrepareRawDataRGBA16(const fs::path& rgbaPath) +void ZTexture::PrepareRawDataRGBA16() { - textureData.ReadPng(rgbaPath); - - width = textureData.GetWidth(); - height = textureData.GetHeight(); - - textureDataRaw.clear(); - textureDataRaw.resize(GetRawDataSize()); for (uint16_t y = 0; y < height; y++) { for (uint16_t x = 0; x < width; x++) @@ -416,15 +484,8 @@ void ZTexture::PrepareRawDataRGBA16(const fs::path& rgbaPath) } } -void ZTexture::PrepareRawDataRGBA32(const fs::path& rgbaPath) +void ZTexture::PrepareRawDataRGBA32() { - textureData.ReadPng(rgbaPath); - - width = textureData.GetWidth(); - height = textureData.GetHeight(); - - textureDataRaw.clear(); - textureDataRaw.resize(GetRawDataSize()); for (uint16_t y = 0; y < height; y++) { for (uint16_t x = 0; x < width; x++) @@ -440,15 +501,8 @@ void ZTexture::PrepareRawDataRGBA32(const fs::path& rgbaPath) } } -void ZTexture::PrepareRawDataGrayscale4(const fs::path& grayPath) +void ZTexture::PrepareRawDataGrayscale4() { - textureData.ReadPng(grayPath); - - width = textureData.GetWidth(); - height = textureData.GetHeight(); - - textureDataRaw.clear(); - textureDataRaw.resize(GetRawDataSize()); for (uint16_t y = 0; y < height; y++) { for (uint16_t x = 0; x < width; x += 2) @@ -462,15 +516,8 @@ void ZTexture::PrepareRawDataGrayscale4(const fs::path& grayPath) } } -void ZTexture::PrepareRawDataGrayscale8(const fs::path& grayPath) +void ZTexture::PrepareRawDataGrayscale8() { - textureData.ReadPng(grayPath); - - width = textureData.GetWidth(); - height = textureData.GetHeight(); - - textureDataRaw.clear(); - textureDataRaw.resize(GetRawDataSize()); for (uint16_t y = 0; y < height; y++) { for (uint16_t x = 0; x < width; x++) @@ -482,15 +529,8 @@ void ZTexture::PrepareRawDataGrayscale8(const fs::path& grayPath) } } -void ZTexture::PrepareRawDataGrayscaleAlpha4(const fs::path& grayAlphaPath) +void ZTexture::PrepareRawDataGrayscaleAlpha4() { - textureData.ReadPng(grayAlphaPath); - - width = textureData.GetWidth(); - height = textureData.GetHeight(); - - textureDataRaw.clear(); - textureDataRaw.resize(GetRawDataSize()); for (uint16_t y = 0; y < height; y++) { for (uint16_t x = 0; x < width; x += 2) @@ -515,15 +555,8 @@ void ZTexture::PrepareRawDataGrayscaleAlpha4(const fs::path& grayAlphaPath) } } -void ZTexture::PrepareRawDataGrayscaleAlpha8(const fs::path& grayAlphaPath) +void ZTexture::PrepareRawDataGrayscaleAlpha8() { - textureData.ReadPng(grayAlphaPath); - - width = textureData.GetWidth(); - height = textureData.GetHeight(); - - textureDataRaw.clear(); - textureDataRaw.resize(GetRawDataSize()); for (uint16_t y = 0; y < height; y++) { for (uint16_t x = 0; x < width; x++) @@ -539,15 +572,8 @@ void ZTexture::PrepareRawDataGrayscaleAlpha8(const fs::path& grayAlphaPath) } } -void ZTexture::PrepareRawDataGrayscaleAlpha16(const fs::path& grayAlphaPath) +void ZTexture::PrepareRawDataGrayscaleAlpha16() { - textureData.ReadPng(grayAlphaPath); - - width = textureData.GetWidth(); - height = textureData.GetHeight(); - - textureDataRaw.clear(); - textureDataRaw.resize(GetRawDataSize()); for (uint16_t y = 0; y < height; y++) { for (uint16_t x = 0; x < width; x++) @@ -564,15 +590,8 @@ void ZTexture::PrepareRawDataGrayscaleAlpha16(const fs::path& grayAlphaPath) } } -void ZTexture::PrepareRawDataPalette4(const fs::path& palPath) +void ZTexture::PrepareRawDataPalette4() { - textureData.ReadPng(palPath); - - width = textureData.GetWidth(); - height = textureData.GetHeight(); - - textureDataRaw.clear(); - textureDataRaw.resize(GetRawDataSize()); for (uint16_t y = 0; y < height; y++) { for (uint16_t x = 0; x < width; x += 2) @@ -587,15 +606,8 @@ void ZTexture::PrepareRawDataPalette4(const fs::path& palPath) } } -void ZTexture::PrepareRawDataPalette8(const fs::path& palPath) +void ZTexture::PrepareRawDataPalette8() { - textureData.ReadPng(palPath); - - width = textureData.GetWidth(); - height = textureData.GetHeight(); - - textureDataRaw.clear(); - textureDataRaw.resize(GetRawDataSize()); for (uint16_t y = 0; y < height; y++) { for (uint16_t x = 0; x < width; x++) @@ -715,7 +727,7 @@ void ZTexture::Save(const fs::path& outFolder) // process for generating the Texture Pool XML. if (Globals::Instance->outputCrc) { - File::WriteAllText((Globals::Instance->outputPath / (outName + ".txt")).string(), + DiskFile::WriteAllText((Globals::Instance->outputPath / (outName + ".txt")).string(), StringHelper::Sprintf("%08lX", hash)); } @@ -728,11 +740,7 @@ void ZTexture::Save(const fs::path& outFolder) if (!Directory::Exists(outPath.string())) Directory::CreateDirectory(outPath.string()); -//#ifdef _MSC_VER fs::path outFileName; -//#else - //std::filesystem::__cxx11::path outFileName; -//#endif if (!dWordAligned) outFileName = outPath / (outName + ".u32" + "." + GetExternalExtension() + ".png"); @@ -790,9 +798,8 @@ Declaration* ZTexture::DeclareVar(const std::string& prefix, incStr = StringHelper::Sprintf("%s.%s.inc.c", poolEntry->second.path.c_str(), GetExternalExtension().c_str()); else - incStr = - StringHelper::Sprintf("%s.u32.%s.inc.c", poolEntry->second.path.c_str(), - GetExternalExtension().c_str()); + incStr = StringHelper::Sprintf("%s.u32.%s.inc.c", poolEntry->second.path.c_str(), + GetExternalExtension().c_str()); } } size_t texSizeDivisor = (dWordAligned) ? 8 : 4; @@ -951,7 +958,7 @@ void ZTexture::SetTlut(ZTexture* nTlut) assert(nTlut->isPalette); tlut = nTlut; - textureData.SetPalette(tlut->textureData); + textureData.SetPalette(tlut->textureData, splitTlut ? 128 : 0); } bool ZTexture::HasTlut() const diff --git a/ZAPDTR/ZAPD/ZTexture.h b/ZAPDTR/ZAPD/ZTexture.h index 29c3fbc0a..8cece3ff2 100644 --- a/ZAPDTR/ZAPD/ZTexture.h +++ b/ZAPDTR/ZAPD/ZTexture.h @@ -28,6 +28,7 @@ protected: std::vector textureDataRaw; // When reading from a PNG file. uint32_t tlutOffset = static_cast(-1); ZTexture* tlut = nullptr; + bool splitTlut; void PrepareBitmapRGBA16(); void PrepareBitmapRGBA32(); @@ -40,15 +41,15 @@ protected: void PrepareBitmapPalette8(); void PrepareRawDataFromFile(const fs::path& inFolder); - void PrepareRawDataRGBA16(const fs::path& rgbaPath); - void PrepareRawDataRGBA32(const fs::path& rgbaPath); - void PrepareRawDataGrayscale4(const fs::path& grayPath); - void PrepareRawDataGrayscale8(const fs::path& grayPath); - void PrepareRawDataGrayscaleAlpha4(const fs::path& grayAlphaPath); - void PrepareRawDataGrayscaleAlpha8(const fs::path& grayAlphaPath); - void PrepareRawDataGrayscaleAlpha16(const fs::path& grayAlphaPath); - void PrepareRawDataPalette4(const fs::path& palPath); - void PrepareRawDataPalette8(const fs::path& palPath); + void PrepareRawDataRGBA16(); + void PrepareRawDataRGBA32(); + void PrepareRawDataGrayscale4(); + void PrepareRawDataGrayscale8(); + void PrepareRawDataGrayscaleAlpha4(); + void PrepareRawDataGrayscaleAlpha8(); + void PrepareRawDataGrayscaleAlpha16(); + void PrepareRawDataPalette4(); + void PrepareRawDataPalette8(); public: ZTexture(ZFile* nParent); @@ -88,4 +89,5 @@ public: bool IsColorIndexed() const; void SetTlut(ZTexture* nTlut); bool HasTlut() const; + void ParseRawDataLate() override; }; diff --git a/ZAPDTR/ZAPD/ZVector.cpp b/ZAPDTR/ZAPD/ZVector.cpp index a5a059e35..092b876d2 100644 --- a/ZAPDTR/ZAPD/ZVector.cpp +++ b/ZAPDTR/ZAPD/ZVector.cpp @@ -4,7 +4,7 @@ #include "Globals.h" #include "Utils/BitConverter.h" -#include "Utils/File.h" +#include #include "Utils/StringHelper.h" #include "WarningHandler.h" #include "ZFile.h" @@ -48,7 +48,7 @@ void ZVector::ParseRawData() int32_t currentRawDataIndex = rawDataIndex; // TODO: this shouldn't be necessary. scalars.clear(); - + scalars.reserve(dimensions); for (uint32_t i = 0; i < dimensions; i++) { ZScalar scalar(parent); diff --git a/ZAPDTR/docs/zapd_extraction_xml_reference.md b/ZAPDTR/docs/zapd_extraction_xml_reference.md index 36d040c29..78817dc6e 100644 --- a/ZAPDTR/docs/zapd_extraction_xml_reference.md +++ b/ZAPDTR/docs/zapd_extraction_xml_reference.md @@ -9,6 +9,7 @@ This document aims to be a small reference of how to create a compatible xml fil - [Basic XML](#basic-xml) - [Resources types](#resources-types) - [File](#file) + - [ExternalFile](#externalfile) - [Texture](#texture) - [Background](#background) - [Blob](#blob) @@ -33,6 +34,7 @@ This document aims to be a small reference of how to create a compatible xml fil - [Array](#array) - [Path](#path) - [PlayerAnimationData](#playeranimationdata) + - [Pointer](#pointer) ## Basic XML @@ -147,12 +149,15 @@ u64 gCraterSmokeConeTex[] = { - Attributes: - - `Name`: Required. Suxffixed by `Tex`, unless it is a palette, in that case it is suffixed by `TLUT`. + - `Name`: Required. Suffixed by `Tex`, unless it is a palette, in that case it is suffixed by `TLUT`. - `OutName`: Required. The filename of the extracted `.png` file. - `Format`: Required. The format of the image. Valid values: `rgba32`, `rgba16`, `i4`, `i8`, `ia4`, `ia8`, `ia16`, `ci4` and `ci8`. - `Width`: Required. Width in pixels of the image. - `Height`: Required. Height in pixels of the image. - `TlutOffset`: Optional. Specifies the tlut's offset used by this texture. This attribute is only valid if `Format` is either `ci4` or `ci8`, otherwise an exception would be thrown. + - `ExternalTlut`: Optional. Specifies that the texture's tlut is in a different file. Takes the filename of the file that contains the tlut. + - `ExternalTlutOffset`: Optional. Specifies the offset in the `ExternalTlut` of the tlut for the given texture. + - `SplitTlut`: Optional. Specifies that the given texture should take from the upper half of the tlut. Takes a bool, i.e. one of `true`, `false`, `1`, `0`. The following is a list of the texture formats the Nintendo 64 supports, with their gfxdis names and ZAPD format names. @@ -183,7 +188,7 @@ If you want to know more about this formats, you can check [`gsDPLoadTextureBloc - Attributes: - - `Name`: Required. Suxffixed by `Background`. + - `Name`: Required. Suffixed by `Background`. - `OutName`: Required. The filename of the extracted `.jpg` file. ※ Explicit use of this tag isn't often necesary because it would probably be extracted automatically by another extracted element. You can use this to name them if you don't like the autogenerated name. @@ -211,7 +216,7 @@ u8 gFireTempleBlob_00CCC0[] = { - Attributes: - - `Name`: Required. Suxffixed by `Blob`. + - `Name`: Required. Suffixed by `Blob`. - `Size`: Required. Amount of bytes to extract. Hex. ※ We usually use blobs when we can't figure out the content's type of chunk of data. @@ -230,7 +235,7 @@ A.k.a. Display list, or Gfx. - Attributes: - - `Name`: Required. Suxffixed by `DL`. + - `Name`: Required. Suffixed by `DL`. ------------------------- @@ -244,7 +249,7 @@ A data type exclusive to Majora's Mask, that has scrolling, color changing, and - Attributes: - - `Name`: Required. Suxffixed by `TexAnim`. + - `Name`: Required. Suffixed by `TexAnim`. ------------------------- @@ -304,7 +309,7 @@ Like `Scene`s and `Room`s, `AltHeader`s is special too. It should always be decl - Attributes: - - `Name`: Required. Suxffixed by `AltHeader`. + - `Name`: Required. Suffixed by `AltHeader`. ------------------------- @@ -318,7 +323,7 @@ Like `Scene`s and `Room`s, `AltHeader`s is special too. It should always be decl - Attributes: - - `Name`: Required. Suxffixed by `Anim`. + - `Name`: Required. Suffixed by `Anim`. ------------------------- @@ -332,7 +337,7 @@ Like `Scene`s and `Room`s, `AltHeader`s is special too. It should always be decl - Attributes: - - `Name`: Required. Suxffixed by `Anim`. + - `Name`: Required. Suffixed by `Anim`. ------------------------- @@ -346,7 +351,7 @@ Like `Scene`s and `Room`s, `AltHeader`s is special too. It should always be decl - Attributes: - - `Name`: Required. Suxffixed by `Anim`. + - `Name`: Required. Suffixed by `Anim`. - `SkelOffset`: Required. Offset of the `CurveSkeleton` (I.e. a [`Skeleton`](#skeleton) resource with `Type="Curve"`) related to this animation. ------------------------- @@ -363,7 +368,7 @@ Useful only for the unused `object_human`'s animation data. - Attributes: - - `Name`: Required. Suxffixed by `Anim`. + - `Name`: Required. Suffixed by `Anim`. ------------------------- @@ -377,9 +382,16 @@ Useful only for the unused `object_human`'s animation data. - Attributes: - - `Name`: Required. Suxffixed by `Skel`. + - `Name`: Required. Suffixed by `Skel`. - `Type`: Required. Valid values: `Normal`, `Flex` and `Curve`. - `LimbType`: Required. Valid values: `Standard`, `LOD`, `Skin`, `Curve` and `Legacy`. + - `EnumName`: Optional. The name of `typedef`'d limb enum. + - `LimbNone`: Optional. The name of the limb with index zero in the limb enum. + - `LimbMax`: Optional. The name of the max limb index in the limb enum. + +ZAPD is able to generate a limb enum by itself only if all the required data is provided. Providing some but not all the required data would trigger an error and the execution will halt. + +The required data is providing the `EnumName`, `LimbNone` and `LimbMax` attributes in the `Skeleton` or `LimbTable` node and the `EnumName` attribute in every `Limb` of this skeleton. ※ There are no restrictions in the `Type` and `LimbType` attributes besides the valid values, so any skeleton type can be combined with any limb type. @@ -395,9 +407,14 @@ Useful only for the unused `object_human`'s animation data. - Attributes: - - `Name`: Required. Suxffixed by `Skel`. + - `Name`: Required. Suffixed by `Skel`. - `LimbType`: Required. Valid values: `Standard`, `LOD`, `Skin`, `Curve` and `Legacy`. - `Count`: Required. Amount of limbs. Integer. + - `EnumName`: Optional. The name of `typedef`'d limb enum. + - `LimbNone`: Optional. The name of the limb with index zero in the limb enum. + - `LimbMax`: Optional. The name of the max limb index in the limb enum. + +See [Skeleton](#skeleton) for info on the limb enum generation. ------------------------- @@ -411,8 +428,11 @@ Useful only for the unused `object_human`'s animation data. - Attributes: - - `Name`: Required. Suxffixed by `Limb`. + - `Name`: Required. Suffixed by `Limb`. - `LimbType`: Required. Valid values: `Standard`, `LOD`, `Skin`, `Curve` and `Legacy`. + - `EnumName`: Optional. The name used for this limb in the limbs enum. It must be either present in every limb or in none. + +See [Skeleton](#skeleton) for info on the limb enum generation. ------------------------- @@ -451,7 +471,7 @@ extern u8 gJsjutanShadowTex[2048]; - Attributes: - - `Name`: Required. Suxffixed by `Col`. + - `Name`: Required. Suffixed by `Col`. ------------------------- @@ -473,7 +493,7 @@ u64 pad34F8 = { 0 }; - Attributes: - - `Name`: Required. Suxffixed by ~~`TBD`~~. + - `Name`: Required. Suffixed by ~~`TBD`~~. - `Type`: Required. Valid values: `s8`, `u8`, `x8`, `s16`, `u16`, `x16`, `s32`, `u32`, `x32`, `s64`, `u64`, `x64`, `f32` and `f64`. ※ Can be wrapped in an [`Array`](#array) tag. @@ -527,7 +547,7 @@ Vec3s gLinkPauseChildDekuShieldJointTable[24] = { - Attributes: - - `Name`: Required. Suxffixed by ~~`TBD`~~. + - `Name`: Required. Suffixed by ~~`TBD`~~. - `Type`: Required. Specifies the vector's type (`Vec3s`, `Vec3i` and `Vec3f`). Valid values: `s16`, `s32` and `f32`. - `Dimensions`: Required. The amount of dimensions of the vector. Valid values: `3`. @@ -547,7 +567,7 @@ Vec3s gLinkPauseChildDekuShieldJointTable[24] = { - Attributes: - - `Name`: Required. Suxffixed by `Vtx`. + - `Name`: Required. Suffixed by `Vtx`. ※ Can be wrapped in an [`Array`](#array) tag. @@ -563,7 +583,7 @@ Vec3s gLinkPauseChildDekuShieldJointTable[24] = { - Attributes: - - `Name`: Required. Suxffixed by `Mtx`. + - `Name`: Required. Suffixed by `Mtx`. ※ Explicit use of this tag isn't often necesary because it would probably be extracted automatically by another extracted element. @@ -579,7 +599,7 @@ Vec3s gLinkPauseChildDekuShieldJointTable[24] = { - Attributes: - - `Name`: Required. Suxffixed by `Cs`. + - `Name`: Required. Suffixed by `Cs`. ※ Explicit use of this tag isn't often necesary because it would probably be extracted automatically by another extracted element. @@ -589,7 +609,7 @@ Vec3s gLinkPauseChildDekuShieldJointTable[24] = { The `Array` element is special, because it needs an inner element to work. It will declare an array of its inner element. -Currently, only [`Scalar`](#scalar), [`Vector`](#vector) and [`Vtx`](#vtx) support being wrapped in an array. +Currently, only [`Pointer`](#pointer), [`Scalar`](#scalar), [`Vector`](#vector) and [`Vtx`](#vtx) support being wrapped in an array. - Example: @@ -616,7 +636,7 @@ Currently, only [`Scalar`](#scalar), [`Vector`](#vector) and [`Vtx`](#vtx) suppo - Attributes: - - `Name`: Required. Suxffixed by `Path`. + - `Name`: Required. Suffixed by `Path`. - `NumPaths`: Optional. The amount of paths contained in the array. It must be a positive integer. ------------------------- @@ -633,7 +653,28 @@ Allows the extraction of the specific data of the player animations which are fo - Attributes: - - `Name`: Required. Suxffixed by `AnimData`. + - `Name`: Required. Suffixed by `AnimData`. - `FrameCount`: Required. The length of the animation in frames. It must be a positive integer. ------------------------- + +### Pointer + +Allows the extraction of a variable that contains a pointer + +- Example: + +```xml + + + +``` + +- Attributes: + + - `Name`: Required. + - `Type`: Required. The type of the extracted pointer. + +※ Can be wrapped in an [`Array`](#array) tag. + +------------------------- diff --git a/ZAPDTR/lib/elfio/elfio/elf_types.hpp b/ZAPDTR/lib/elfio/elfio/elf_types.hpp deleted file mode 100644 index 63d025a58..000000000 --- a/ZAPDTR/lib/elfio/elfio/elf_types.hpp +++ /dev/null @@ -1,851 +0,0 @@ -/* -Copyright (C) 2001-2015 by Serge Lamikhov-Center - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -*/ - -#ifndef ELFTYPES_H -#define ELFTYPES_H - -#ifndef ELFIO_NO_OWN_TYPES - #if !defined(ELFIO_NO_CSTDINT) && !defined(ELFIO_NO_INTTYPES) - #include - #else - typedef unsigned char uint8_t; - typedef signed char int8_t; - typedef unsigned short uint16_t; - typedef signed short int16_t; - #ifdef _MSC_VER - typedef unsigned __int32 uint32_t; - typedef signed __int32 int32_t; - typedef unsigned __int64 uint64_t; - typedef signed __int64 int64_t; - #else - typedef unsigned int uint32_t; - typedef signed int int32_t; - typedef unsigned long long uint64_t; - typedef signed long long int64_t; - #endif // _MSC_VER - #endif // ELFIO_NO_CSTDINT -#endif // ELFIO_NO_OWN_TYPES - -namespace ELFIO { - -// Attention! Platform depended definitions. -typedef uint16_t Elf_Half; -typedef uint32_t Elf_Word; -typedef int32_t Elf_Sword; -typedef uint64_t Elf_Xword; -typedef int64_t Elf_Sxword; - -typedef uint32_t Elf32_Addr; -typedef uint32_t Elf32_Off; -typedef uint64_t Elf64_Addr; -typedef uint64_t Elf64_Off; - -#define Elf32_Half Elf_Half -#define Elf64_Half Elf_Half -#define Elf32_Word Elf_Word -#define Elf64_Word Elf_Word -#define Elf32_Sword Elf_Sword -#define Elf64_Sword Elf_Sword - -/////////////////////// -// ELF Header Constants - -// File type -#define ET_NONE 0 -#define ET_REL 1 -#define ET_EXEC 2 -#define ET_DYN 3 -#define ET_CORE 4 -#define ET_LOOS 0xFE00 -#define ET_HIOS 0xFEFF -#define ET_LOPROC 0xFF00 -#define ET_HIPROC 0xFFFF - - -#define EM_NONE 0 // No machine -#define EM_M32 1 // AT&T WE 32100 -#define EM_SPARC 2 // SUN SPARC -#define EM_386 3 // Intel 80386 -#define EM_68K 4 // Motorola m68k family -#define EM_88K 5 // Motorola m88k family -#define EM_486 6 // Intel 80486// Reserved for future use -#define EM_860 7 // Intel 80860 -#define EM_MIPS 8 // MIPS R3000 (officially, big-endian only) -#define EM_S370 9 // IBM System/370 -#define EM_MIPS_RS3_LE 10 // MIPS R3000 little-endian (Oct 4 1999 Draft) Deprecated -#define EM_res011 11 // Reserved -#define EM_res012 12 // Reserved -#define EM_res013 13 // Reserved -#define EM_res014 14 // Reserved -#define EM_PARISC 15 // HPPA -#define EM_res016 16 // Reserved -#define EM_VPP550 17 // Fujitsu VPP500 -#define EM_SPARC32PLUS 18 // Sun's "v8plus" -#define EM_960 19 // Intel 80960 -#define EM_PPC 20 // PowerPC -#define EM_PPC64 21 // 64-bit PowerPC -#define EM_S390 22 // IBM S/390 -#define EM_SPU 23 // Sony/Toshiba/IBM SPU -#define EM_res024 24 // Reserved -#define EM_res025 25 // Reserved -#define EM_res026 26 // Reserved -#define EM_res027 27 // Reserved -#define EM_res028 28 // Reserved -#define EM_res029 29 // Reserved -#define EM_res030 30 // Reserved -#define EM_res031 31 // Reserved -#define EM_res032 32 // Reserved -#define EM_res033 33 // Reserved -#define EM_res034 34 // Reserved -#define EM_res035 35 // Reserved -#define EM_V800 36 // NEC V800 series -#define EM_FR20 37 // Fujitsu FR20 -#define EM_RH32 38 // TRW RH32 -#define EM_MCORE 39 // Motorola M*Core // May also be taken by Fujitsu MMA -#define EM_RCE 39 // Old name for MCore -#define EM_ARM 40 // ARM -#define EM_OLD_ALPHA 41 // Digital Alpha -#define EM_SH 42 // Renesas (formerly Hitachi) / SuperH SH -#define EM_SPARCV9 43 // SPARC v9 64-bit -#define EM_TRICORE 44 // Siemens Tricore embedded processor -#define EM_ARC 45 // ARC Cores -#define EM_H8_300 46 // Renesas (formerly Hitachi) H8/300 -#define EM_H8_300H 47 // Renesas (formerly Hitachi) H8/300H -#define EM_H8S 48 // Renesas (formerly Hitachi) H8S -#define EM_H8_500 49 // Renesas (formerly Hitachi) H8/500 -#define EM_IA_64 50 // Intel IA-64 Processor -#define EM_MIPS_X 51 // Stanford MIPS-X -#define EM_COLDFIRE 52 // Motorola Coldfire -#define EM_68HC12 53 // Motorola M68HC12 -#define EM_MMA 54 // Fujitsu Multimedia Accelerator -#define EM_PCP 55 // Siemens PCP -#define EM_NCPU 56 // Sony nCPU embedded RISC processor -#define EM_NDR1 57 // Denso NDR1 microprocesspr -#define EM_STARCORE 58 // Motorola Star*Core processor -#define EM_ME16 59 // Toyota ME16 processor -#define EM_ST100 60 // STMicroelectronics ST100 processor -#define EM_TINYJ 61 // Advanced Logic Corp. TinyJ embedded processor -#define EM_X86_64 62 // Advanced Micro Devices X86-64 processor -#define EM_PDSP 63 // Sony DSP Processor -#define EM_PDP10 64 // Digital Equipment Corp. PDP-10 -#define EM_PDP11 65 // Digital Equipment Corp. PDP-11 -#define EM_FX66 66 // Siemens FX66 microcontroller -#define EM_ST9PLUS 67 // STMicroelectronics ST9+ 8/16 bit microcontroller -#define EM_ST7 68 // STMicroelectronics ST7 8-bit microcontroller -#define EM_68HC16 69 // Motorola MC68HC16 Microcontroller -#define EM_68HC11 70 // Motorola MC68HC11 Microcontroller -#define EM_68HC08 71 // Motorola MC68HC08 Microcontroller -#define EM_68HC05 72 // Motorola MC68HC05 Microcontroller -#define EM_SVX 73 // Silicon Graphics SVx -#define EM_ST19 74 // STMicroelectronics ST19 8-bit cpu -#define EM_VAX 75 // Digital VAX -#define EM_CRIS 76 // Axis Communications 32-bit embedded processor -#define EM_JAVELIN 77 // Infineon Technologies 32-bit embedded cpu -#define EM_FIREPATH 78 // Element 14 64-bit DSP processor -#define EM_ZSP 79 // LSI Logic's 16-bit DSP processor -#define EM_MMIX 80 // Donald Knuth's educational 64-bit processor -#define EM_HUANY 81 // Harvard's machine-independent format -#define EM_PRISM 82 // SiTera Prism -#define EM_AVR 83 // Atmel AVR 8-bit microcontroller -#define EM_FR30 84 // Fujitsu FR30 -#define EM_D10V 85 // Mitsubishi D10V -#define EM_D30V 86 // Mitsubishi D30V -#define EM_V850 87 // NEC v850 -#define EM_M32R 88 // Renesas M32R (formerly Mitsubishi M32R) -#define EM_MN10300 89 // Matsushita MN10300 -#define EM_MN10200 90 // Matsushita MN10200 -#define EM_PJ 91 // picoJava -#define EM_OPENRISC 92 // OpenRISC 32-bit embedded processor -#define EM_ARC_A5 93 // ARC Cores Tangent-A5 -#define EM_XTENSA 94 // Tensilica Xtensa Architecture -#define EM_VIDEOCORE 95 // Alphamosaic VideoCore processor -#define EM_TMM_GPP 96 // Thompson Multimedia General Purpose Processor -#define EM_NS32K 97 // National Semiconductor 32000 series -#define EM_TPC 98 // Tenor Network TPC processor -#define EM_SNP1K 99 // Trebia SNP 1000 processor -#define EM_ST200 100 // STMicroelectronics ST200 microcontroller -#define EM_IP2K 101 // Ubicom IP2022 micro controller -#define EM_MAX 102 // MAX Processor -#define EM_CR 103 // National Semiconductor CompactRISC -#define EM_F2MC16 104 // Fujitsu F2MC16 -#define EM_MSP430 105 // TI msp430 micro controller -#define EM_BLACKFIN 106 // ADI Blackfin -#define EM_SE_C33 107 // S1C33 Family of Seiko Epson processors -#define EM_SEP 108 // Sharp embedded microprocessor -#define EM_ARCA 109 // Arca RISC Microprocessor -#define EM_UNICORE 110 // Microprocessor series from PKU-Unity Ltd. and MPRC of Peking University -#define EM_EXCESS 111 // eXcess: 16/32/64-bit configurable embedded CPU -#define EM_DXP 112 // Icera Semiconductor Inc. Deep Execution Processor -#define EM_ALTERA_NIOS2 113 // Altera Nios II soft-core processor -#define EM_CRX 114 // National Semiconductor CRX -#define EM_XGATE 115 // Motorola XGATE embedded processor -#define EM_C166 116 // Infineon C16x/XC16x processor -#define EM_M16C 117 // Renesas M16C series microprocessors -#define EM_DSPIC30F 118 // Microchip Technology dsPIC30F Digital Signal Controller -#define EM_CE 119 // Freescale Communication Engine RISC core -#define EM_M32C 120 // Renesas M32C series microprocessors -#define EM_res121 121 // Reserved -#define EM_res122 122 // Reserved -#define EM_res123 123 // Reserved -#define EM_res124 124 // Reserved -#define EM_res125 125 // Reserved -#define EM_res126 126 // Reserved -#define EM_res127 127 // Reserved -#define EM_res128 128 // Reserved -#define EM_res129 129 // Reserved -#define EM_res130 130 // Reserved -#define EM_TSK3000 131 // Altium TSK3000 core -#define EM_RS08 132 // Freescale RS08 embedded processor -#define EM_res133 133 // Reserved -#define EM_ECOG2 134 // Cyan Technology eCOG2 microprocessor -#define EM_SCORE 135 // Sunplus Score -#define EM_SCORE7 135 // Sunplus S+core7 RISC processor -#define EM_DSP24 136 // New Japan Radio (NJR) 24-bit DSP Processor -#define EM_VIDEOCORE3 137 // Broadcom VideoCore III processor -#define EM_LATTICEMICO32 138 // RISC processor for Lattice FPGA architecture -#define EM_SE_C17 139 // Seiko Epson C17 family -#define EM_TI_C6000 140 // Texas Instruments TMS320C6000 DSP family -#define EM_TI_C2000 141 // Texas Instruments TMS320C2000 DSP family -#define EM_TI_C5500 142 // Texas Instruments TMS320C55x DSP family -#define EM_res143 143 // Reserved -#define EM_res144 144 // Reserved -#define EM_res145 145 // Reserved -#define EM_res146 146 // Reserved -#define EM_res147 147 // Reserved -#define EM_res148 148 // Reserved -#define EM_res149 149 // Reserved -#define EM_res150 150 // Reserved -#define EM_res151 151 // Reserved -#define EM_res152 152 // Reserved -#define EM_res153 153 // Reserved -#define EM_res154 154 // Reserved -#define EM_res155 155 // Reserved -#define EM_res156 156 // Reserved -#define EM_res157 157 // Reserved -#define EM_res158 158 // Reserved -#define EM_res159 159 // Reserved -#define EM_MMDSP_PLUS 160 // STMicroelectronics 64bit VLIW Data Signal Processor -#define EM_CYPRESS_M8C 161 // Cypress M8C microprocessor -#define EM_R32C 162 // Renesas R32C series microprocessors -#define EM_TRIMEDIA 163 // NXP Semiconductors TriMedia architecture family -#define EM_QDSP6 164 // QUALCOMM DSP6 Processor -#define EM_8051 165 // Intel 8051 and variants -#define EM_STXP7X 166 // STMicroelectronics STxP7x family -#define EM_NDS32 167 // Andes Technology compact code size embedded RISC processor family -#define EM_ECOG1 168 // Cyan Technology eCOG1X family -#define EM_ECOG1X 168 // Cyan Technology eCOG1X family -#define EM_MAXQ30 169 // Dallas Semiconductor MAXQ30 Core Micro-controllers -#define EM_XIMO16 170 // New Japan Radio (NJR) 16-bit DSP Processor -#define EM_MANIK 171 // M2000 Reconfigurable RISC Microprocessor -#define EM_CRAYNV2 172 // Cray Inc. NV2 vector architecture -#define EM_RX 173 // Renesas RX family -#define EM_METAG 174 // Imagination Technologies META processor architecture -#define EM_MCST_ELBRUS 175 // MCST Elbrus general purpose hardware architecture -#define EM_ECOG16 176 // Cyan Technology eCOG16 family -#define EM_CR16 177 // National Semiconductor CompactRISC 16-bit processor -#define EM_ETPU 178 // Freescale Extended Time Processing Unit -#define EM_SLE9X 179 // Infineon Technologies SLE9X core -#define EM_L1OM 180 // Intel L1OM -#define EM_INTEL181 181 // Reserved by Intel -#define EM_INTEL182 182 // Reserved by Intel -#define EM_res183 183 // Reserved by ARM -#define EM_res184 184 // Reserved by ARM -#define EM_AVR32 185 // Atmel Corporation 32-bit microprocessor family -#define EM_STM8 186 // STMicroeletronics STM8 8-bit microcontroller -#define EM_TILE64 187 // Tilera TILE64 multicore architecture family -#define EM_TILEPRO 188 // Tilera TILEPro multicore architecture family -#define EM_MICROBLAZE 189 // Xilinx MicroBlaze 32-bit RISC soft processor core -#define EM_CUDA 190 // NVIDIA CUDA architecture -#define EM_TILEGX 191 // Tilera TILE-Gx multicore architecture family -#define EM_CLOUDSHIELD 192 // CloudShield architecture family -#define EM_COREA_1ST 193 // KIPO-KAIST Core-A 1st generation processor family -#define EM_COREA_2ND 194 // KIPO-KAIST Core-A 2nd generation processor family -#define EM_ARC_COMPACT2 195 // Synopsys ARCompact V2 -#define EM_OPEN8 196 // Open8 8-bit RISC soft processor core -#define EM_RL78 197 // Renesas RL78 family -#define EM_VIDEOCORE5 198 // Broadcom VideoCore V processor -#define EM_78KOR 199 // Renesas 78KOR family -#define EM_56800EX 200 // Freescale 56800EX Digital Signal Controller (DSC) -#define EM_BA1 201 // Beyond BA1 CPU architecture -#define EM_BA2 202 // Beyond BA2 CPU architecture -#define EM_XCORE 203 // XMOS xCORE processor family -#define EM_MCHP_PIC 204 // Microchip 8-bit PIC(r) family -#define EM_INTEL205 205 // Reserved by Intel -#define EM_INTEL206 206 // Reserved by Intel -#define EM_INTEL207 207 // Reserved by Intel -#define EM_INTEL208 208 // Reserved by Intel -#define EM_INTEL209 209 // Reserved by Intel -#define EM_KM32 210 // KM211 KM32 32-bit processor -#define EM_KMX32 211 // KM211 KMX32 32-bit processor -#define EM_KMX16 212 // KM211 KMX16 16-bit processor -#define EM_KMX8 213 // KM211 KMX8 8-bit processor -#define EM_KVARC 214 // KM211 KVARC processor -#define EM_CDP 215 // Paneve CDP architecture family -#define EM_COGE 216 // Cognitive Smart Memory Processor -#define EM_COOL 217 // iCelero CoolEngine -#define EM_NORC 218 // Nanoradio Optimized RISC -#define EM_CSR_KALIMBA 219 // CSR Kalimba architecture family -#define EM_Z80 220 // Zilog Z80 -#define EM_VISIUM 221 // Controls and Data Services VISIUMcore processor -#define EM_FT32 222 // FTDI Chip FT32 high performance 32-bit RISC architecture -#define EM_MOXIE 223 // Moxie processor family -#define EM_AMDGPU 224 // AMD GPU architecture -#define EM_RISCV 243 // RISC-V -#define EM_LANAI 244 // Lanai processor -#define EM_CEVA 245 // CEVA Processor Architecture Family -#define EM_CEVA_X2 246 // CEVA X2 Processor Family -#define EM_BPF 247 // Linux BPF – in-kernel virtual machine - -// File version -#define EV_NONE 0 -#define EV_CURRENT 1 - -// Identification index -#define EI_MAG0 0 -#define EI_MAG1 1 -#define EI_MAG2 2 -#define EI_MAG3 3 -#define EI_CLASS 4 -#define EI_DATA 5 -#define EI_VERSION 6 -#define EI_OSABI 7 -#define EI_ABIVERSION 8 -#define EI_PAD 9 -#define EI_NIDENT 16 - -// Magic number -#define ELFMAG0 0x7F -#define ELFMAG1 'E' -#define ELFMAG2 'L' -#define ELFMAG3 'F' - -// File class -#define ELFCLASSNONE 0 -#define ELFCLASS32 1 -#define ELFCLASS64 2 - -// Encoding -#define ELFDATANONE 0 -#define ELFDATA2LSB 1 -#define ELFDATA2MSB 2 - -// OS extensions -#define ELFOSABI_NONE 0 // No extensions or unspecified -#define ELFOSABI_HPUX 1 // Hewlett-Packard HP-UX -#define ELFOSABI_NETBSD 2 // NetBSD -#define ELFOSABI_LINUX 3 // Linux -#define ELFOSABI_SOLARIS 6 // Sun Solaris -#define ELFOSABI_AIX 7 // AIX -#define ELFOSABI_IRIX 8 // IRIX -#define ELFOSABI_FREEBSD 9 // FreeBSD -#define ELFOSABI_TRU64 10 // Compaq TRU64 UNIX -#define ELFOSABI_MODESTO 11 // Novell Modesto -#define ELFOSABI_OPENBSD 12 // Open BSD -#define ELFOSABI_OPENVMS 13 // Open VMS -#define ELFOSABI_NSK 14 // Hewlett-Packard Non-Stop Kernel -#define ELFOSABI_AROS 15 // Amiga Research OS -#define ELFOSABI_FENIXOS 16 // The FenixOS highly scalable multi-core OS -// 64-255 Architecture-specific value range -#define ELFOSABI_AMDGPU_HSA 64 // AMDGPU OS for HSA compatible compute - // kernels. -#define ELFOSABI_AMDGPU_PAL 65 // AMDGPU OS for AMD PAL compatible graphics - // shaders and compute kernels. -#define ELFOSABI_AMDGPU_MESA3D 66 // AMDGPU OS for Mesa3D compatible graphics - // shaders and compute kernels. - - -// AMDGPU specific e_flags -#define EF_AMDGPU_MACH 0x0ff // AMDGPU processor selection mask. -#define EF_AMDGPU_XNACK 0x100 // Indicates if the XNACK target feature is - // enabled for all code contained in the ELF. -// AMDGPU processors -#define EF_AMDGPU_MACH_NONE 0x000 // Unspecified processor. -#define EF_AMDGPU_MACH_R600_R600 0x001 -#define EF_AMDGPU_MACH_R600_R630 0x002 -#define EF_AMDGPU_MACH_R600_RS880 0x003 -#define EF_AMDGPU_MACH_R600_RV670 0x004 -#define EF_AMDGPU_MACH_R600_RV710 0x005 -#define EF_AMDGPU_MACH_R600_RV730 0x006 -#define EF_AMDGPU_MACH_R600_RV770 0x007 -#define EF_AMDGPU_MACH_R600_CEDAR 0x008 -#define EF_AMDGPU_MACH_R600_CYPRESS 0x009 -#define EF_AMDGPU_MACH_R600_JUNIPER 0x00a -#define EF_AMDGPU_MACH_R600_REDWOOD 0x00b -#define EF_AMDGPU_MACH_R600_SUMO 0x00c -#define EF_AMDGPU_MACH_R600_BARTS 0x00d -#define EF_AMDGPU_MACH_R600_CAICOS 0x00e -#define EF_AMDGPU_MACH_R600_CAYMAN 0x00f -#define EF_AMDGPU_MACH_R600_TURKS 0x010 -#define EF_AMDGPU_MACH_R600_RESERVED_FIRST 0x011 -#define EF_AMDGPU_MACH_R600_RESERVED_LAST 0x01f -#define EF_AMDGPU_MACH_R600_FIRST EF_AMDGPU_MACH_R600_R600 -#define EF_AMDGPU_MACH_R600_LAST EF_AMDGPU_MACH_R600_TURKS -#define EF_AMDGPU_MACH_AMDGCN_GFX600 0x020 -#define EF_AMDGPU_MACH_AMDGCN_GFX601 0x021 -#define EF_AMDGPU_MACH_AMDGCN_GFX700 0x022 -#define EF_AMDGPU_MACH_AMDGCN_GFX701 0x023 -#define EF_AMDGPU_MACH_AMDGCN_GFX702 0x024 -#define EF_AMDGPU_MACH_AMDGCN_GFX703 0x025 -#define EF_AMDGPU_MACH_AMDGCN_GFX704 0x026 -#define EF_AMDGPU_MACH_AMDGCN_GFX801 0x028 -#define EF_AMDGPU_MACH_AMDGCN_GFX802 0x029 -#define EF_AMDGPU_MACH_AMDGCN_GFX803 0x02a -#define EF_AMDGPU_MACH_AMDGCN_GFX810 0x02b -#define EF_AMDGPU_MACH_AMDGCN_GFX900 0x02c -#define EF_AMDGPU_MACH_AMDGCN_GFX902 0x02d -#define EF_AMDGPU_MACH_AMDGCN_GFX904 0x02e -#define EF_AMDGPU_MACH_AMDGCN_GFX906 0x02f -#define EF_AMDGPU_MACH_AMDGCN_RESERVED0 0x027 -#define EF_AMDGPU_MACH_AMDGCN_RESERVED1 0x030 -#define EF_AMDGPU_MACH_AMDGCN_FIRST EF_AMDGPU_MACH_AMDGCN_GFX600 -#define EF_AMDGPU_MACH_AMDGCN_LAST EF_AMDGPU_MACH_AMDGCN_GFX906 - -///////////////////// -// Sections constants - -// Section indexes -#define SHN_UNDEF 0 -#define SHN_LORESERVE 0xFF00 -#define SHN_LOPROC 0xFF00 -#define SHN_HIPROC 0xFF1F -#define SHN_LOOS 0xFF20 -#define SHN_HIOS 0xFF3F -#define SHN_ABS 0xFFF1 -#define SHN_COMMON 0xFFF2 -#define SHN_XINDEX 0xFFFF -#define SHN_HIRESERVE 0xFFFF - -// Section types -#define SHT_NULL 0 -#define SHT_PROGBITS 1 -#define SHT_SYMTAB 2 -#define SHT_STRTAB 3 -#define SHT_RELA 4 -#define SHT_HASH 5 -#define SHT_DYNAMIC 6 -#define SHT_NOTE 7 -#define SHT_NOBITS 8 -#define SHT_REL 9 -#define SHT_SHLIB 10 -#define SHT_DYNSYM 11 -#define SHT_INIT_ARRAY 14 -#define SHT_FINI_ARRAY 15 -#define SHT_PREINIT_ARRAY 16 -#define SHT_GROUP 17 -#define SHT_SYMTAB_SHNDX 18 -#define SHT_LOOS 0x60000000 -#define SHT_HIOS 0x6fffffff -#define SHT_LOPROC 0x70000000 -#define SHT_HIPROC 0x7FFFFFFF -#define SHT_LOUSER 0x80000000 -#define SHT_HIUSER 0xFFFFFFFF - -// Section attribute flags -#define SHF_WRITE 0x1 -#define SHF_ALLOC 0x2 -#define SHF_EXECINSTR 0x4 -#define SHF_MERGE 0x10 -#define SHF_STRINGS 0x20 -#define SHF_INFO_LINK 0x40 -#define SHF_LINK_ORDER 0x80 -#define SHF_OS_NONCONFORMING 0x100 -#define SHF_GROUP 0x200 -#define SHF_TLS 0x400 -#define SHF_MASKOS 0x0ff00000 -#define SHF_MASKPROC 0xF0000000 - -// Section group flags -#define GRP_COMDAT 0x1 -#define GRP_MASKOS 0x0ff00000 -#define GRP_MASKPROC 0xf0000000 - -// Symbol binding -#define STB_LOCAL 0 -#define STB_GLOBAL 1 -#define STB_WEAK 2 -#define STB_LOOS 10 -#define STB_HIOS 12 -#define STB_MULTIDEF 13 -#define STB_LOPROC 13 -#define STB_HIPROC 15 - -// Note types -#define NT_AMDGPU_METADATA 1 -#define NT_AMD_AMDGPU_HSA_METADATA 10 -#define NT_AMD_AMDGPU_ISA 11 -#define NT_AMD_AMDGPU_PAL_METADATA 12 - -// Symbol types -#define STT_NOTYPE 0 -#define STT_OBJECT 1 -#define STT_FUNC 2 -#define STT_SECTION 3 -#define STT_FILE 4 -#define STT_COMMON 5 -#define STT_TLS 6 -#define STT_LOOS 10 -#define STT_AMDGPU_HSA_KERNEL 10 -#define STT_HIOS 12 -#define STT_LOPROC 13 -#define STT_HIPROC 15 - -// Symbol visibility -#define STV_DEFAULT 0 -#define STV_INTERNAL 1 -#define STV_HIDDEN 2 -#define STV_PROTECTED 3 - -// Undefined name -#define STN_UNDEF 0 - -// Relocation types -#define R_386_NONE 0 -#define R_X86_64_NONE 0 -#define R_AMDGPU_NONE 0 -#define R_386_32 1 -#define R_X86_64_64 1 -#define R_AMDGPU_ABS32_LO 1 -#define R_386_PC32 2 -#define R_X86_64_PC32 2 -#define R_AMDGPU_ABS32_HI 2 -#define R_386_GOT32 3 -#define R_X86_64_GOT32 3 -#define R_AMDGPU_ABS64 3 -#define R_386_PLT32 4 -#define R_X86_64_PLT32 4 -#define R_AMDGPU_REL32 4 -#define R_386_COPY 5 -#define R_X86_64_COPY 5 -#define R_AMDGPU_REL64 5 -#define R_386_GLOB_DAT 6 -#define R_X86_64_GLOB_DAT 6 -#define R_AMDGPU_ABS32 6 -#define R_386_JMP_SLOT 7 -#define R_X86_64_JUMP_SLOT 7 -#define R_AMDGPU_GOTPCREL 7 -#define R_386_RELATIVE 8 -#define R_X86_64_RELATIVE 8 -#define R_AMDGPU_GOTPCREL32_LO 8 -#define R_386_GOTOFF 9 -#define R_X86_64_GOTPCREL 9 -#define R_AMDGPU_GOTPCREL32_HI 9 -#define R_386_GOTPC 10 -#define R_X86_64_32 10 -#define R_AMDGPU_REL32_LO 10 -#define R_386_32PLT 11 -#define R_X86_64_32S 11 -#define R_AMDGPU_REL32_HI 11 -#define R_X86_64_16 12 -#define R_X86_64_PC16 13 -#define R_AMDGPU_RELATIVE64 13 -#define R_386_TLS_TPOFF 14 -#define R_X86_64_8 14 -#define R_386_TLS_IE 15 -#define R_X86_64_PC8 15 -#define R_386_TLS_GOTIE 16 -#define R_X86_64_DTPMOD64 16 -#define R_386_TLS_LE 17 -#define R_X86_64_DTPOFF64 17 -#define R_386_TLS_GD 18 -#define R_X86_64_TPOFF64 18 -#define R_386_TLS_LDM 19 -#define R_X86_64_TLSGD 19 -#define R_386_16 20 -#define R_X86_64_TLSLD 20 -#define R_386_PC16 21 -#define R_X86_64_DTPOFF32 21 -#define R_386_8 22 -#define R_X86_64_GOTTPOFF 22 -#define R_386_PC8 23 -#define R_X86_64_TPOFF32 23 -#define R_386_TLS_GD_32 24 -#define R_X86_64_PC64 24 -#define R_386_TLS_GD_PUSH 25 -#define R_X86_64_GOTOFF64 25 -#define R_386_TLS_GD_CALL 26 -#define R_X86_64_GOTPC32 26 -#define R_386_TLS_GD_POP 27 -#define R_X86_64_GOT64 27 -#define R_386_TLS_LDM_32 28 -#define R_X86_64_GOTPCREL64 28 -#define R_386_TLS_LDM_PUSH 29 -#define R_X86_64_GOTPC64 29 -#define R_386_TLS_LDM_CALL 30 -#define R_X86_64_GOTPLT64 30 -#define R_386_TLS_LDM_POP 31 -#define R_X86_64_PLTOFF64 31 -#define R_386_TLS_LDO_32 32 -#define R_386_TLS_IE_32 33 -#define R_386_TLS_LE_32 34 -#define R_X86_64_GOTPC32_TLSDESC 34 -#define R_386_TLS_DTPMOD32 35 -#define R_X86_64_TLSDESC_CALL 35 -#define R_386_TLS_DTPOFF32 36 -#define R_X86_64_TLSDESC 36 -#define R_386_TLS_TPOFF32 37 -#define R_X86_64_IRELATIVE 37 -#define R_386_SIZE32 38 -#define R_386_TLS_GOTDESC 39 -#define R_386_TLS_DESC_CALL 40 -#define R_386_TLS_DESC 41 -#define R_386_IRELATIVE 42 -#define R_386_GOT32X 43 -#define R_X86_64_GNU_VTINHERIT 250 -#define R_X86_64_GNU_VTENTRY 251 - -// Segment types -#define PT_NULL 0 -#define PT_LOAD 1 -#define PT_DYNAMIC 2 -#define PT_INTERP 3 -#define PT_NOTE 4 -#define PT_SHLIB 5 -#define PT_PHDR 6 -#define PT_TLS 7 -#define PT_LOOS 0x60000000 -#define PT_HIOS 0x6fffffff -#define PT_LOPROC 0x70000000 -#define PT_HIPROC 0x7FFFFFFF - -// Segment flags -#define PF_X 1 // Execute -#define PF_W 2 // Write -#define PF_R 4 // Read -#define PF_MASKOS 0x0ff00000 // Unspecified -#define PF_MASKPROC 0xf0000000 // Unspecified - -// Dynamic Array Tags -#define DT_NULL 0 -#define DT_NEEDED 1 -#define DT_PLTRELSZ 2 -#define DT_PLTGOT 3 -#define DT_HASH 4 -#define DT_STRTAB 5 -#define DT_SYMTAB 6 -#define DT_RELA 7 -#define DT_RELASZ 8 -#define DT_RELAENT 9 -#define DT_STRSZ 10 -#define DT_SYMENT 11 -#define DT_INIT 12 -#define DT_FINI 13 -#define DT_SONAME 14 -#define DT_RPATH 15 -#define DT_SYMBOLIC 16 -#define DT_REL 17 -#define DT_RELSZ 18 -#define DT_RELENT 19 -#define DT_PLTREL 20 -#define DT_DEBUG 21 -#define DT_TEXTREL 22 -#define DT_JMPREL 23 -#define DT_BIND_NOW 24 -#define DT_INIT_ARRAY 25 -#define DT_FINI_ARRAY 26 -#define DT_INIT_ARRAYSZ 27 -#define DT_FINI_ARRAYSZ 28 -#define DT_RUNPATH 29 -#define DT_FLAGS 30 -#define DT_ENCODING 32 -#define DT_PREINIT_ARRAY 32 -#define DT_PREINIT_ARRAYSZ 33 -#define DT_MAXPOSTAGS 34 -#define DT_LOOS 0x6000000D -#define DT_HIOS 0x6ffff000 -#define DT_LOPROC 0x70000000 -#define DT_HIPROC 0x7FFFFFFF - -// DT_FLAGS values -#define DF_ORIGIN 0x1 -#define DF_SYMBOLIC 0x2 -#define DF_TEXTREL 0x4 -#define DF_BIND_NOW 0x8 -#define DF_STATIC_TLS 0x10 - - -// ELF file header -struct Elf32_Ehdr { - unsigned char e_ident[EI_NIDENT]; - Elf_Half e_type; - Elf_Half e_machine; - Elf_Word e_version; - Elf32_Addr e_entry; - Elf32_Off e_phoff; - Elf32_Off e_shoff; - Elf_Word e_flags; - Elf_Half e_ehsize; - Elf_Half e_phentsize; - Elf_Half e_phnum; - Elf_Half e_shentsize; - Elf_Half e_shnum; - Elf_Half e_shstrndx; -}; - -struct Elf64_Ehdr { - unsigned char e_ident[EI_NIDENT]; - Elf_Half e_type; - Elf_Half e_machine; - Elf_Word e_version; - Elf64_Addr e_entry; - Elf64_Off e_phoff; - Elf64_Off e_shoff; - Elf_Word e_flags; - Elf_Half e_ehsize; - Elf_Half e_phentsize; - Elf_Half e_phnum; - Elf_Half e_shentsize; - Elf_Half e_shnum; - Elf_Half e_shstrndx; -}; - - -// Section header -struct Elf32_Shdr { - Elf_Word sh_name; - Elf_Word sh_type; - Elf_Word sh_flags; - Elf32_Addr sh_addr; - Elf32_Off sh_offset; - Elf_Word sh_size; - Elf_Word sh_link; - Elf_Word sh_info; - Elf_Word sh_addralign; - Elf_Word sh_entsize; -}; - -struct Elf64_Shdr { - Elf_Word sh_name; - Elf_Word sh_type; - Elf_Xword sh_flags; - Elf64_Addr sh_addr; - Elf64_Off sh_offset; - Elf_Xword sh_size; - Elf_Word sh_link; - Elf_Word sh_info; - Elf_Xword sh_addralign; - Elf_Xword sh_entsize; -}; - - -// Segment header -struct Elf32_Phdr { - Elf_Word p_type; - Elf32_Off p_offset; - Elf32_Addr p_vaddr; - Elf32_Addr p_paddr; - Elf_Word p_filesz; - Elf_Word p_memsz; - Elf_Word p_flags; - Elf_Word p_align; -}; - -struct Elf64_Phdr { - Elf_Word p_type; - Elf_Word p_flags; - Elf64_Off p_offset; - Elf64_Addr p_vaddr; - Elf64_Addr p_paddr; - Elf_Xword p_filesz; - Elf_Xword p_memsz; - Elf_Xword p_align; -}; - - -// Symbol table entry -struct Elf32_Sym { - Elf_Word st_name; - Elf32_Addr st_value; - Elf_Word st_size; - unsigned char st_info; - unsigned char st_other; - Elf_Half st_shndx; -}; - -struct Elf64_Sym { - Elf_Word st_name; - unsigned char st_info; - unsigned char st_other; - Elf_Half st_shndx; - Elf64_Addr st_value; - Elf_Xword st_size; -}; - - -#define ELF_ST_BIND(i) ((i)>>4) -#define ELF_ST_TYPE(i) ((i)&0xf) -#define ELF_ST_INFO(b,t) (((b)<<4)+((t)&0xf)) - -#define ELF_ST_VISIBILITY(o) ((o)&0x3) - - -// Relocation entries -struct Elf32_Rel { - Elf32_Addr r_offset; - Elf_Word r_info; -}; - -struct Elf32_Rela { - Elf32_Addr r_offset; - Elf_Word r_info; - Elf_Sword r_addend; -}; - -struct Elf64_Rel { - Elf64_Addr r_offset; - Elf_Xword r_info; -}; - -struct Elf64_Rela { - Elf64_Addr r_offset; - Elf_Xword r_info; - Elf_Sxword r_addend; -}; - - -#define ELF32_R_SYM(i) ((i)>>8) -#define ELF32_R_TYPE(i) ((unsigned char)(i)) -#define ELF32_R_INFO(s,t) (((s)<<8 )+(unsigned char)(t)) - -#define ELF64_R_SYM(i) ((i)>>32) -#define ELF64_R_TYPE(i) ((i)&0xffffffffL) -#define ELF64_R_INFO(s,t) ((((int64_t)(s))<<32)+((t)&0xffffffffL)) - -// Dynamic structure -struct Elf32_Dyn { - Elf_Sword d_tag; - union { - Elf_Word d_val; - Elf32_Addr d_ptr; - } d_un; -}; - -struct Elf64_Dyn { - Elf_Sxword d_tag; - union { - Elf_Xword d_val; - Elf64_Addr d_ptr; - } d_un; -}; - -} // namespace ELFIO - -#endif // ELFTYPES_H diff --git a/ZAPDTR/lib/elfio/elfio/elfio.hpp b/ZAPDTR/lib/elfio/elfio/elfio.hpp deleted file mode 100644 index f997b5dfc..000000000 --- a/ZAPDTR/lib/elfio/elfio/elfio.hpp +++ /dev/null @@ -1,955 +0,0 @@ -/* -Copyright (C) 2001-2015 by Serge Lamikhov-Center - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -*/ - -#ifndef ELFIO_HPP -#define ELFIO_HPP - -#ifdef _MSC_VER -#pragma warning ( push ) -#pragma warning(disable:4996) -#pragma warning(disable:4355) -#pragma warning(disable:4244) -#endif - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#define ELFIO_HEADER_ACCESS_GET( TYPE, FNAME ) \ -TYPE \ -get_##FNAME() const \ -{ \ - return header? header->get_##FNAME() : 0; \ -} - -#define ELFIO_HEADER_ACCESS_GET_SET( TYPE, FNAME ) \ -TYPE \ -get_##FNAME() const \ -{ \ - return header? header->get_##FNAME() : 0; \ -} \ -void \ -set_##FNAME( TYPE val ) \ -{ \ - if (header) { \ - header->set_##FNAME( val ); \ - } \ -} \ - -namespace ELFIO { - -//------------------------------------------------------------------------------ -class elfio -{ - public: -//------------------------------------------------------------------------------ - elfio() : sections( this ), segments( this ) - { - header = 0; - current_file_pos = 0; - create( ELFCLASS32, ELFDATA2LSB ); - } - -//------------------------------------------------------------------------------ - ~elfio() - { - clean(); - } - -//------------------------------------------------------------------------------ - void create( unsigned char file_class, unsigned char encoding ) - { - clean(); - convertor.setup( encoding ); - header = create_header( file_class, encoding ); - create_mandatory_sections(); - } - -//------------------------------------------------------------------------------ - bool load( const std::string& file_name ) - { - std::ifstream stream; - stream.open( file_name.c_str(), std::ios::in | std::ios::binary ); - if ( !stream ) { - return false; - } - - return load(stream); - } - -//------------------------------------------------------------------------------ - bool load( std::istream &stream ) - { - clean(); - - unsigned char e_ident[EI_NIDENT]; - // Read ELF file signature - stream.read( reinterpret_cast( &e_ident ), sizeof( e_ident ) ); - - // Is it ELF file? - if ( stream.gcount() != sizeof( e_ident ) || - e_ident[EI_MAG0] != ELFMAG0 || - e_ident[EI_MAG1] != ELFMAG1 || - e_ident[EI_MAG2] != ELFMAG2 || - e_ident[EI_MAG3] != ELFMAG3 ) { - return false; - } - - if ( ( e_ident[EI_CLASS] != ELFCLASS64 ) && - ( e_ident[EI_CLASS] != ELFCLASS32 )) { - return false; - } - - convertor.setup( e_ident[EI_DATA] ); - header = create_header( e_ident[EI_CLASS], e_ident[EI_DATA] ); - if ( 0 == header ) { - return false; - } - if ( !header->load( stream ) ) { - return false; - } - - load_sections( stream ); - bool is_still_good = load_segments( stream ); - return is_still_good; - } - -//------------------------------------------------------------------------------ - bool save( const std::string& file_name ) - { - std::ofstream stream; - stream.open( file_name.c_str(), std::ios::out | std::ios::binary ); - if ( !stream ) { - return false; - } - - return save(stream); - } - -//------------------------------------------------------------------------------ - bool save( std::ostream &stream ) - { - if ( !stream || !header) { - return false; - } - - bool is_still_good = true; - // Define layout specific header fields - // The position of the segment table is fixed after the header. - // The position of the section table is variable and needs to be fixed - // before saving. - header->set_segments_num( segments.size() ); - header->set_segments_offset( segments.size() ? header->get_header_size() : 0 ); - header->set_sections_num( sections.size() ); - header->set_sections_offset( 0 ); - - // Layout the first section right after the segment table - current_file_pos = header->get_header_size() + - header->get_segment_entry_size() * header->get_segments_num(); - - calc_segment_alignment(); - - is_still_good = layout_segments_and_their_sections(); - is_still_good = is_still_good && layout_sections_without_segments(); - is_still_good = is_still_good && layout_section_table(); - - is_still_good = is_still_good && save_header( stream ); - is_still_good = is_still_good && save_sections( stream ); - is_still_good = is_still_good && save_segments( stream ); - - return is_still_good; - } - -//------------------------------------------------------------------------------ - // ELF header access functions - ELFIO_HEADER_ACCESS_GET( unsigned char, class ); - ELFIO_HEADER_ACCESS_GET( unsigned char, elf_version ); - ELFIO_HEADER_ACCESS_GET( unsigned char, encoding ); - ELFIO_HEADER_ACCESS_GET( Elf_Word, version ); - ELFIO_HEADER_ACCESS_GET( Elf_Half, header_size ); - ELFIO_HEADER_ACCESS_GET( Elf_Half, section_entry_size ); - ELFIO_HEADER_ACCESS_GET( Elf_Half, segment_entry_size ); - - ELFIO_HEADER_ACCESS_GET_SET( unsigned char, os_abi ); - ELFIO_HEADER_ACCESS_GET_SET( unsigned char, abi_version ); - ELFIO_HEADER_ACCESS_GET_SET( Elf_Half, type ); - ELFIO_HEADER_ACCESS_GET_SET( Elf_Half, machine ); - ELFIO_HEADER_ACCESS_GET_SET( Elf_Word, flags ); - ELFIO_HEADER_ACCESS_GET_SET( Elf64_Addr, entry ); - ELFIO_HEADER_ACCESS_GET_SET( Elf64_Off, sections_offset ); - ELFIO_HEADER_ACCESS_GET_SET( Elf64_Off, segments_offset ); - ELFIO_HEADER_ACCESS_GET_SET( Elf_Half, section_name_str_index ); - -//------------------------------------------------------------------------------ - const endianess_convertor& get_convertor() const - { - return convertor; - } - -//------------------------------------------------------------------------------ - Elf_Xword get_default_entry_size( Elf_Word section_type ) const - { - switch( section_type ) { - case SHT_RELA: - if ( header->get_class() == ELFCLASS64 ) { - return sizeof( Elf64_Rela ); - } - else { - return sizeof( Elf32_Rela ); - } - case SHT_REL: - if ( header->get_class() == ELFCLASS64 ) { - return sizeof( Elf64_Rel ); - } - else { - return sizeof( Elf32_Rel ); - } - case SHT_SYMTAB: - if ( header->get_class() == ELFCLASS64 ) { - return sizeof( Elf64_Sym ); - } - else { - return sizeof( Elf32_Sym ); - } - case SHT_DYNAMIC: - if ( header->get_class() == ELFCLASS64 ) { - return sizeof( Elf64_Dyn ); - } - else { - return sizeof( Elf32_Dyn ); - } - default: - return 0; - } - } - -//------------------------------------------------------------------------------ - private: - bool is_offset_in_section( Elf64_Off offset, const section* sec ) const { - return offset >= sec->get_offset() && offset < sec->get_offset()+sec->get_size(); - } - -//------------------------------------------------------------------------------ - public: - - //! returns an empty string if no problems are detected, - //! or a string containing an error message if problems are found - std::string validate() const { - - // check for overlapping sections in the file - for ( int i = 0; i < sections.size(); ++i) { - for ( int j = i+1; j < sections.size(); ++j ) { - const section* a = sections[i]; - const section* b = sections[j]; - if ( !(a->get_type() & SHT_NOBITS) - && !(b->get_type() & SHT_NOBITS) - && (a->get_size() > 0) - && (b->get_size() > 0) - && (a->get_offset() > 0) - && (b->get_offset() > 0)) { - if ( is_offset_in_section( a->get_offset(), b ) - || is_offset_in_section( a->get_offset()+a->get_size()-1, b ) - || is_offset_in_section( b->get_offset(), a ) - || is_offset_in_section( b->get_offset()+b->get_size()-1, a )) { - return "Sections " + a->get_name() + " and " + b->get_name() + " overlap in file"; - } - } - } - } - - // more checks to be added here... - - return ""; - } - -//------------------------------------------------------------------------------ - private: -//------------------------------------------------------------------------------ - void clean() - { - delete header; - header = 0; - - std::vector::const_iterator it; - for ( it = sections_.begin(); it != sections_.end(); ++it ) { - delete *it; - } - sections_.clear(); - - std::vector::const_iterator it1; - for ( it1 = segments_.begin(); it1 != segments_.end(); ++it1 ) { - delete *it1; - } - segments_.clear(); - } - -//------------------------------------------------------------------------------ - elf_header* create_header( unsigned char file_class, unsigned char encoding ) - { - elf_header* new_header = 0; - - if ( file_class == ELFCLASS64 ) { - new_header = new elf_header_impl< Elf64_Ehdr >( &convertor, - encoding ); - } - else if ( file_class == ELFCLASS32 ) { - new_header = new elf_header_impl< Elf32_Ehdr >( &convertor, - encoding ); - } - else { - return 0; - } - - return new_header; - } - -//------------------------------------------------------------------------------ - section* create_section() - { - section* new_section; - unsigned char file_class = get_class(); - - if ( file_class == ELFCLASS64 ) { - new_section = new section_impl( &convertor ); - } - else if ( file_class == ELFCLASS32 ) { - new_section = new section_impl( &convertor ); - } - else { - return 0; - } - - new_section->set_index( (Elf_Half)sections_.size() ); - sections_.push_back( new_section ); - - return new_section; - } - - -//------------------------------------------------------------------------------ - segment* create_segment() - { - segment* new_segment; - unsigned char file_class = header->get_class(); - - if ( file_class == ELFCLASS64 ) { - new_segment = new segment_impl( &convertor ); - } - else if ( file_class == ELFCLASS32 ) { - new_segment = new segment_impl( &convertor ); - } - else { - return 0; - } - - new_segment->set_index( (Elf_Half)segments_.size() ); - segments_.push_back( new_segment ); - - return new_segment; - } - -//------------------------------------------------------------------------------ - void create_mandatory_sections() - { - // Create null section without calling to 'add_section' as no string - // section containing section names exists yet - section* sec0 = create_section(); - sec0->set_index( 0 ); - sec0->set_name( "" ); - sec0->set_name_string_offset( 0 ); - - set_section_name_str_index( 1 ); - section* shstrtab = sections.add( ".shstrtab" ); - shstrtab->set_type( SHT_STRTAB ); - shstrtab->set_addr_align( 1 ); - } - -//------------------------------------------------------------------------------ - Elf_Half load_sections( std::istream& stream ) - { - Elf_Half entry_size = header->get_section_entry_size(); - Elf_Half num = header->get_sections_num(); - Elf64_Off offset = header->get_sections_offset(); - - for ( Elf_Half i = 0; i < num; ++i ) { - section* sec = create_section(); - sec->load( stream, (std::streamoff)offset + i * entry_size ); - sec->set_index( i ); - // To mark that the section is not permitted to reassign address - // during layout calculation - sec->set_address( sec->get_address() ); - } - - Elf_Half shstrndx = get_section_name_str_index(); - - if ( SHN_UNDEF != shstrndx ) { - string_section_accessor str_reader( sections[shstrndx] ); - for ( Elf_Half i = 0; i < num; ++i ) { - Elf_Word section_offset = sections[i]->get_name_string_offset(); - const char* p = str_reader.get_string( section_offset ); - if ( p != 0 ) { - sections[i]->set_name( p ); - } - } - } - - return num; - } - -//------------------------------------------------------------------------------ - //! Checks whether the addresses of the section entirely fall within the given segment. - //! It doesn't matter if the addresses are memory addresses, or file offsets, - //! they just need to be in the same address space - bool is_sect_in_seg ( Elf64_Off sect_begin, Elf_Xword sect_size, Elf64_Off seg_begin, Elf64_Off seg_end ) { - return seg_begin <= sect_begin - && sect_begin + sect_size <= seg_end - && sect_begin < seg_end; // this is important criteria when sect_size == 0 - // Example: seg_begin=10, seg_end=12 (-> covering the bytes 10 and 11) - // sect_begin=12, sect_size=0 -> shall return false! - } - -//------------------------------------------------------------------------------ - bool load_segments( std::istream& stream ) - { - Elf_Half entry_size = header->get_segment_entry_size(); - Elf_Half num = header->get_segments_num(); - Elf64_Off offset = header->get_segments_offset(); - - for ( Elf_Half i = 0; i < num; ++i ) { - segment* seg; - unsigned char file_class = header->get_class(); - - if ( file_class == ELFCLASS64 ) { - seg = new segment_impl( &convertor ); - } - else if ( file_class == ELFCLASS32 ) { - seg = new segment_impl( &convertor ); - } - else { - return false; - } - - seg->load( stream, (std::streamoff)offset + i * entry_size ); - seg->set_index( i ); - - // Add sections to the segments (similar to readelfs algorithm) - Elf64_Off segBaseOffset = seg->get_offset(); - Elf64_Off segEndOffset = segBaseOffset + seg->get_file_size(); - Elf64_Off segVBaseAddr = seg->get_virtual_address(); - Elf64_Off segVEndAddr = segVBaseAddr + seg->get_memory_size(); - for( Elf_Half j = 0; j < sections.size(); ++j ) { - const section* psec = sections[j]; - - // SHF_ALLOC sections are matched based on the virtual address - // otherwise the file offset is matched - if( psec->get_flags() & SHF_ALLOC - ? is_sect_in_seg( psec->get_address(), psec->get_size(), segVBaseAddr, segVEndAddr ) - : is_sect_in_seg( psec->get_offset(), psec->get_size(), segBaseOffset, segEndOffset )) { - // Alignment of segment shall not be updated, to preserve original value - // It will be re-calculated on saving. - seg->add_section_index( psec->get_index(), 0 ); - } - } - - // Add section into the segments' container - segments_.push_back( seg ); - } - - return true; - } - -//------------------------------------------------------------------------------ - bool save_header( std::ostream& stream ) - { - return header->save( stream ); - } - -//------------------------------------------------------------------------------ - bool save_sections( std::ostream& stream ) - { - for ( unsigned int i = 0; i < sections_.size(); ++i ) { - section *sec = sections_.at(i); - - std::streampos headerPosition = - (std::streamoff)header->get_sections_offset() + - header->get_section_entry_size() * sec->get_index(); - - sec->save(stream,headerPosition,sec->get_offset()); - } - return true; - } - -//------------------------------------------------------------------------------ - bool save_segments( std::ostream& stream ) - { - for ( unsigned int i = 0; i < segments_.size(); ++i ) { - segment *seg = segments_.at(i); - - std::streampos headerPosition = header->get_segments_offset() + - header->get_segment_entry_size()*seg->get_index(); - - seg->save( stream, headerPosition, seg->get_offset() ); - } - return true; - } - -//------------------------------------------------------------------------------ - bool is_section_without_segment( unsigned int section_index ) - { - bool found = false; - - for ( unsigned int j = 0; !found && ( j < segments.size() ); ++j ) { - for ( unsigned int k = 0; - !found && ( k < segments[j]->get_sections_num() ); - ++k ) { - found = segments[j]->get_section_index_at( k ) == section_index; - } - } - - return !found; - } - -//------------------------------------------------------------------------------ - bool is_subsequence_of( segment* seg1, segment* seg2 ) - { - // Return 'true' if sections of seg1 are a subset of sections in seg2 - const std::vector& sections1 = seg1->get_sections(); - const std::vector& sections2 = seg2->get_sections(); - - bool found = false; - if ( sections1.size() < sections2.size() ) { - found = std::includes( sections2.begin(), sections2.end(), - sections1.begin(), sections1.end() ); - } - - return found; - } - -//------------------------------------------------------------------------------ - std::vector get_ordered_segments( ) - { - std::vector res; - std::deque worklist; - - res.reserve(segments.size()); - std::copy( segments_.begin(), segments_.end(), - std::back_inserter( worklist )) ; - - // Bring the segments which start at address 0 to the front - size_t nextSlot = 0; - for( size_t i = 0; i < worklist.size(); ++i ) { - if( i != nextSlot && worklist[i]->is_offset_initialized() - && worklist[i]->get_offset() == 0 ) { - if (worklist[nextSlot]->get_offset() == 0) { - ++nextSlot; - } - std::swap(worklist[i],worklist[nextSlot]); - ++nextSlot; - } - } - - while ( !worklist.empty() ) { - segment *seg = worklist.front(); - worklist.pop_front(); - - size_t i = 0; - for ( ; i < worklist.size(); ++i ) { - if ( is_subsequence_of( seg, worklist[i] ) ) { - break; - } - } - - if ( i < worklist.size() ) - worklist.push_back(seg); - else - res.push_back(seg); - } - - return res; - } - - -//------------------------------------------------------------------------------ - bool layout_sections_without_segments( ) - { - for ( unsigned int i = 0; i < sections_.size(); ++i ) { - if ( is_section_without_segment( i ) ) { - section *sec = sections_[i]; - - Elf_Xword section_align = sec->get_addr_align(); - if ( section_align > 1 && current_file_pos % section_align != 0 ) { - current_file_pos += section_align - - current_file_pos % section_align; - } - - if ( 0 != sec->get_index() ) - sec->set_offset(current_file_pos); - - if ( SHT_NOBITS != sec->get_type() && - SHT_NULL != sec->get_type() ) { - current_file_pos += sec->get_size(); - } - } - } - - return true; - } - - -//------------------------------------------------------------------------------ - void calc_segment_alignment( ) - { - for( std::vector::iterator s = segments_.begin(); s != segments_.end(); ++s ) { - segment* seg = *s; - for ( int i = 0; i < seg->get_sections_num(); ++i ) { - section* sect = sections_[ seg->get_section_index_at(i) ]; - if ( sect->get_addr_align() > seg->get_align() ) { - seg->set_align( sect->get_addr_align() ); - } - } - } - } - -//------------------------------------------------------------------------------ - bool layout_segments_and_their_sections( ) - { - std::vector worklist; - std::vector section_generated(sections.size(),false); - - // Get segments in a order in where segments which contain a - // sub sequence of other segments are located at the end - worklist = get_ordered_segments(); - - for ( unsigned int i = 0; i < worklist.size(); ++i ) { - Elf_Xword segment_memory = 0; - Elf_Xword segment_filesize = 0; - Elf_Xword seg_start_pos = current_file_pos; - segment* seg = worklist[i]; - - // Special case: PHDR segment - // This segment contains the program headers but no sections - if ( seg->get_type() == PT_PHDR && seg->get_sections_num() == 0 ) { - seg_start_pos = header->get_segments_offset(); - segment_memory = segment_filesize = - header->get_segment_entry_size() * header->get_segments_num(); - } - // Special case: - // Segments which start with the NULL section and have further sections - else if ( seg->get_sections_num() > 1 - && sections[seg->get_section_index_at( 0 )]->get_type() == SHT_NULL ) { - seg_start_pos = 0; - if ( seg->get_sections_num() ) { - segment_memory = segment_filesize = current_file_pos; - } - } - // New segments with not generated sections - // have to be aligned - else if ( seg->get_sections_num() - && !section_generated[seg->get_section_index_at( 0 )] ) { - Elf_Xword align = seg->get_align() > 0 ? seg->get_align() : 1; - Elf64_Off cur_page_alignment = current_file_pos % align; - Elf64_Off req_page_alignment = seg->get_virtual_address() % align; - Elf64_Off error = req_page_alignment - cur_page_alignment; - - current_file_pos += ( seg->get_align() + error ) % align; - seg_start_pos = current_file_pos; - } - else if ( seg->get_sections_num() ) { - seg_start_pos = sections[seg->get_section_index_at( 0 )]->get_offset(); - } - - // Write segment's data - for ( unsigned int j = 0; j < seg->get_sections_num(); ++j ) { - Elf_Half index = seg->get_section_index_at( j ); - - section* sec = sections[ index ]; - - // The NULL section is always generated - if ( SHT_NULL == sec->get_type()) { - section_generated[index] = true; - continue; - } - - Elf_Xword secAlign = 0; - // Fix up the alignment - if ( !section_generated[index] && sec->is_address_initialized() - && SHT_NOBITS != sec->get_type() - && SHT_NULL != sec->get_type() - && 0 != sec->get_size() ) { - // Align the sections based on the virtual addresses - // when possible (this is what matters for execution) - Elf64_Off req_offset = sec->get_address() - seg->get_virtual_address(); - Elf64_Off cur_offset = current_file_pos - seg_start_pos; - if ( req_offset < cur_offset) { - // something has gone awfully wrong, abort! - // secAlign would turn out negative, seeking backwards and overwriting previous data - return false; - } - secAlign = req_offset - cur_offset; - } - else if (!section_generated[index] && !sec->is_address_initialized() ) { - // If no address has been specified then only the section - // alignment constraint has to be matched - Elf_Xword align = sec->get_addr_align(); - if (align == 0) { - align = 1; - } - Elf64_Off error = current_file_pos % align; - secAlign = ( align - error ) % align; - } - else if (section_generated[index] ) { - // Alignment for already generated sections - secAlign = sec->get_offset() - seg_start_pos - segment_filesize; - } - - // Determine the segment file and memory sizes - // Special case .tbss section (NOBITS) in non TLS segment - if ( (sec->get_flags() & SHF_ALLOC) - && !( (sec->get_flags() & SHF_TLS) && (seg->get_type() != PT_TLS) - && ( SHT_NOBITS == sec->get_type())) ) - segment_memory += sec->get_size() + secAlign; - if ( SHT_NOBITS != sec->get_type() && SHT_NULL != sec->get_type() ) - segment_filesize += sec->get_size() + secAlign; - - // Nothing to be done when generating nested segments - if(section_generated[index]) { - continue; - } - - current_file_pos += secAlign; - - // Set the section addresses when missing - if ( !sec->is_address_initialized() ) - sec->set_address( seg->get_virtual_address() - + current_file_pos - seg_start_pos); - - if ( 0 != sec->get_index() ) - sec->set_offset(current_file_pos); - - if ( SHT_NOBITS != sec->get_type() && SHT_NULL != sec->get_type() ) - current_file_pos += sec->get_size(); - section_generated[index] = true; - } - - seg->set_file_size( segment_filesize ); - - // If we already have a memory size from loading an elf file (value > 0), - // it must not shrink! - // Memory size may be bigger than file size and it is the loader's job to do something - // with the surplus bytes in memory, like initializing them with a defined value. - if ( seg->get_memory_size() < segment_memory ) { - seg->set_memory_size( segment_memory ); - } - - seg->set_offset(seg_start_pos); - } - - return true; - } - -//------------------------------------------------------------------------------ - bool layout_section_table() - { - // Simply place the section table at the end for now - Elf64_Off alignmentError = current_file_pos % 4; - current_file_pos += ( 4 - alignmentError ) % 4; - header->set_sections_offset(current_file_pos); - return true; - } - - -//------------------------------------------------------------------------------ - public: - friend class Sections; - class Sections { - public: -//------------------------------------------------------------------------------ - Sections( elfio* parent_ ) : - parent( parent_ ) - { - } - -//------------------------------------------------------------------------------ - Elf_Half size() const - { - return (Elf_Half)parent->sections_.size(); - } - -//------------------------------------------------------------------------------ - section* operator[]( unsigned int index ) const - { - section* sec = 0; - - if ( index < parent->sections_.size() ) { - sec = parent->sections_[index]; - } - - return sec; - } - -//------------------------------------------------------------------------------ - section* operator[]( const std::string& name ) const - { - section* sec = 0; - - std::vector::const_iterator it; - for ( it = parent->sections_.begin(); - it != parent->sections_.end(); - ++it ) { - if ( (*it)->get_name() == name ) { - sec = *it; - break; - } - } - - return sec; - } - -//------------------------------------------------------------------------------ - section* add( const std::string& name ) - { - section* new_section = parent->create_section(); - new_section->set_name( name ); - - Elf_Half str_index = parent->get_section_name_str_index(); - section* string_table( parent->sections_[str_index] ); - string_section_accessor str_writer( string_table ); - Elf_Word pos = str_writer.add_string( name ); - new_section->set_name_string_offset( pos ); - - return new_section; - } - -//------------------------------------------------------------------------------ - std::vector::iterator begin() { - return parent->sections_.begin(); - } - -//------------------------------------------------------------------------------ - std::vector::iterator end() { - return parent->sections_.end(); - } - -//------------------------------------------------------------------------------ - std::vector::const_iterator begin() const { - return parent->sections_.cbegin(); - } - -//------------------------------------------------------------------------------ - std::vector::const_iterator end() const { - return parent->sections_.cend(); - } - -//------------------------------------------------------------------------------ - private: - elfio* parent; - } sections; - -//------------------------------------------------------------------------------ - public: - friend class Segments; - class Segments { - public: -//------------------------------------------------------------------------------ - Segments( elfio* parent_ ) : - parent( parent_ ) - { - } - -//------------------------------------------------------------------------------ - Elf_Half size() const - { - return (Elf_Half)parent->segments_.size(); - } - -//------------------------------------------------------------------------------ - segment* operator[]( unsigned int index ) const - { - return parent->segments_[index]; - } - - -//------------------------------------------------------------------------------ - segment* add() - { - return parent->create_segment(); - } - -//------------------------------------------------------------------------------ - std::vector::iterator begin() { - return parent->segments_.begin(); - } - -//------------------------------------------------------------------------------ - std::vector::iterator end() { - return parent->segments_.end(); - } - -//------------------------------------------------------------------------------ - std::vector::const_iterator begin() const { - return parent->segments_.cbegin(); - } - -//------------------------------------------------------------------------------ - std::vector::const_iterator end() const { - return parent->segments_.cend(); - } - -//------------------------------------------------------------------------------ - private: - elfio* parent; - } segments; - -//------------------------------------------------------------------------------ - private: - elf_header* header; - std::vector sections_; - std::vector segments_; - endianess_convertor convertor; - - Elf_Xword current_file_pos; -}; - -} // namespace ELFIO - -#include -#include -#include -#include - -#ifdef _MSC_VER -#pragma warning ( pop ) -#endif - -#endif // ELFIO_HPP diff --git a/ZAPDTR/lib/elfio/elfio/elfio_dump.hpp b/ZAPDTR/lib/elfio/elfio/elfio_dump.hpp deleted file mode 100644 index 4ace66514..000000000 --- a/ZAPDTR/lib/elfio/elfio/elfio_dump.hpp +++ /dev/null @@ -1,976 +0,0 @@ -/* -Copyright (C) 2001-2015 by Serge Lamikhov-Center - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -*/ - -#ifndef ELFIO_DUMP_HPP -#define ELFIO_DUMP_HPP - -#include -#include -#include -#include -#include -#include - -namespace ELFIO { - - -static struct class_table_t { - const char key; - const char* str; -} class_table [] = -{ - { ELFCLASS32, "ELF32" }, - { ELFCLASS64, "ELF64" }, -}; - - -static struct endian_table_t { - const char key; - const char* str; -} endian_table [] = -{ - { ELFDATANONE, "None" }, - { ELFDATA2LSB, "Little endian" }, - { ELFDATA2MSB, "Big endian" }, -}; - - -static struct version_table_t { - const Elf64_Word key; - const char* str; -} version_table [] = -{ - { EV_NONE , "None" }, - { EV_CURRENT, "Current" }, -}; - - -static struct type_table_t { - const Elf32_Half key; - const char* str; -} type_table [] = -{ - { ET_NONE, "No file type" }, - { ET_REL , "Relocatable file" }, - { ET_EXEC, "Executable file" }, - { ET_DYN , "Shared object file" }, - { ET_CORE, "Core file" }, -}; - - -static struct machine_table_t { - const Elf64_Half key; - const char* str; -} machine_table [] = -{ - { EM_NONE , "No machine" }, - { EM_M32 , "AT&T WE 32100" }, - { EM_SPARC , "SUN SPARC" }, - { EM_386 , "Intel 80386" }, - { EM_68K , "Motorola m68k family" }, - { EM_88K , "Motorola m88k family" }, - { EM_486 , "Intel 80486// Reserved for future use" }, - { EM_860 , "Intel 80860" }, - { EM_MIPS , "MIPS R3000 (officially, big-endian only)" }, - { EM_S370 , "IBM System/370" }, - { EM_MIPS_RS3_LE , "MIPS R3000 little-endian (Oct 4 1999 Draft) Deprecated" }, - { EM_res011 , "Reserved" }, - { EM_res012 , "Reserved" }, - { EM_res013 , "Reserved" }, - { EM_res014 , "Reserved" }, - { EM_PARISC , "HPPA" }, - { EM_res016 , "Reserved" }, - { EM_VPP550 , "Fujitsu VPP500" }, - { EM_SPARC32PLUS , "Sun's v8plus" }, - { EM_960 , "Intel 80960" }, - { EM_PPC , "PowerPC" }, - { EM_PPC64 , "64-bit PowerPC" }, - { EM_S390 , "IBM S/390" }, - { EM_SPU , "Sony/Toshiba/IBM SPU" }, - { EM_res024 , "Reserved" }, - { EM_res025 , "Reserved" }, - { EM_res026 , "Reserved" }, - { EM_res027 , "Reserved" }, - { EM_res028 , "Reserved" }, - { EM_res029 , "Reserved" }, - { EM_res030 , "Reserved" }, - { EM_res031 , "Reserved" }, - { EM_res032 , "Reserved" }, - { EM_res033 , "Reserved" }, - { EM_res034 , "Reserved" }, - { EM_res035 , "Reserved" }, - { EM_V800 , "NEC V800 series" }, - { EM_FR20 , "Fujitsu FR20" }, - { EM_RH32 , "TRW RH32" }, - { EM_MCORE , "Motorola M*Core // May also be taken by Fujitsu MMA" }, - { EM_RCE , "Old name for MCore" }, - { EM_ARM , "ARM" }, - { EM_OLD_ALPHA , "Digital Alpha" }, - { EM_SH , "Renesas (formerly Hitachi) / SuperH SH" }, - { EM_SPARCV9 , "SPARC v9 64-bit" }, - { EM_TRICORE , "Siemens Tricore embedded processor" }, - { EM_ARC , "ARC Cores" }, - { EM_H8_300 , "Renesas (formerly Hitachi) H8/300" }, - { EM_H8_300H , "Renesas (formerly Hitachi) H8/300H" }, - { EM_H8S , "Renesas (formerly Hitachi) H8S" }, - { EM_H8_500 , "Renesas (formerly Hitachi) H8/500" }, - { EM_IA_64 , "Intel IA-64 Processor" }, - { EM_MIPS_X , "Stanford MIPS-X" }, - { EM_COLDFIRE , "Motorola Coldfire" }, - { EM_68HC12 , "Motorola M68HC12" }, - { EM_MMA , "Fujitsu Multimedia Accelerator" }, - { EM_PCP , "Siemens PCP" }, - { EM_NCPU , "Sony nCPU embedded RISC processor" }, - { EM_NDR1 , "Denso NDR1 microprocesspr" }, - { EM_STARCORE , "Motorola Star*Core processor" }, - { EM_ME16 , "Toyota ME16 processor" }, - { EM_ST100 , "STMicroelectronics ST100 processor" }, - { EM_TINYJ , "Advanced Logic Corp. TinyJ embedded processor" }, - { EM_X86_64 , "Advanced Micro Devices X86-64 processor" }, - { EM_PDSP , "Sony DSP Processor" }, - { EM_PDP10 , "Digital Equipment Corp. PDP-10" }, - { EM_PDP11 , "Digital Equipment Corp. PDP-11" }, - { EM_FX66 , "Siemens FX66 microcontroller" }, - { EM_ST9PLUS , "STMicroelectronics ST9+ 8/16 bit microcontroller" }, - { EM_ST7 , "STMicroelectronics ST7 8-bit microcontroller" }, - { EM_68HC16 , "Motorola MC68HC16 Microcontroller" }, - { EM_68HC11 , "Motorola MC68HC11 Microcontroller" }, - { EM_68HC08 , "Motorola MC68HC08 Microcontroller" }, - { EM_68HC05 , "Motorola MC68HC05 Microcontroller" }, - { EM_SVX , "Silicon Graphics SVx" }, - { EM_ST19 , "STMicroelectronics ST19 8-bit cpu" }, - { EM_VAX , "Digital VAX" }, - { EM_CRIS , "Axis Communications 32-bit embedded processor" }, - { EM_JAVELIN , "Infineon Technologies 32-bit embedded cpu" }, - { EM_FIREPATH , "Element 14 64-bit DSP processor" }, - { EM_ZSP , "LSI Logic's 16-bit DSP processor" }, - { EM_MMIX , "Donald Knuth's educational 64-bit processor" }, - { EM_HUANY , "Harvard's machine-independent format" }, - { EM_PRISM , "SiTera Prism" }, - { EM_AVR , "Atmel AVR 8-bit microcontroller" }, - { EM_FR30 , "Fujitsu FR30" }, - { EM_D10V , "Mitsubishi D10V" }, - { EM_D30V , "Mitsubishi D30V" }, - { EM_V850 , "NEC v850" }, - { EM_M32R , "Renesas M32R (formerly Mitsubishi M32R)" }, - { EM_MN10300 , "Matsushita MN10300" }, - { EM_MN10200 , "Matsushita MN10200" }, - { EM_PJ , "picoJava" }, - { EM_OPENRISC , "OpenRISC 32-bit embedded processor" }, - { EM_ARC_A5 , "ARC Cores Tangent-A5" }, - { EM_XTENSA , "Tensilica Xtensa Architecture" }, - { EM_VIDEOCORE , "Alphamosaic VideoCore processor" }, - { EM_TMM_GPP , "Thompson Multimedia General Purpose Processor" }, - { EM_NS32K , "National Semiconductor 32000 series" }, - { EM_TPC , "Tenor Network TPC processor" }, - { EM_SNP1K , "Trebia SNP 1000 processor" }, - { EM_ST200 , "STMicroelectronics ST200 microcontroller" }, - { EM_IP2K , "Ubicom IP2022 micro controller" }, - { EM_MAX , "MAX Processor" }, - { EM_CR , "National Semiconductor CompactRISC" }, - { EM_F2MC16 , "Fujitsu F2MC16" }, - { EM_MSP430 , "TI msp430 micro controller" }, - { EM_BLACKFIN , "ADI Blackfin" }, - { EM_SE_C33 , "S1C33 Family of Seiko Epson processors" }, - { EM_SEP , "Sharp embedded microprocessor" }, - { EM_ARCA , "Arca RISC Microprocessor" }, - { EM_UNICORE , "Microprocessor series from PKU-Unity Ltd. and MPRC of Peking University" }, - { EM_EXCESS , "eXcess: 16/32/64-bit configurable embedded CPU" }, - { EM_DXP , "Icera Semiconductor Inc. Deep Execution Processor" }, - { EM_ALTERA_NIOS2 , "Altera Nios II soft-core processor" }, - { EM_CRX , "National Semiconductor CRX" }, - { EM_XGATE , "Motorola XGATE embedded processor" }, - { EM_C166 , "Infineon C16x/XC16x processor" }, - { EM_M16C , "Renesas M16C series microprocessors" }, - { EM_DSPIC30F , "Microchip Technology dsPIC30F Digital Signal Controller" }, - { EM_CE , "Freescale Communication Engine RISC core" }, - { EM_M32C , "Renesas M32C series microprocessors" }, - { EM_res121 , "Reserved" }, - { EM_res122 , "Reserved" }, - { EM_res123 , "Reserved" }, - { EM_res124 , "Reserved" }, - { EM_res125 , "Reserved" }, - { EM_res126 , "Reserved" }, - { EM_res127 , "Reserved" }, - { EM_res128 , "Reserved" }, - { EM_res129 , "Reserved" }, - { EM_res130 , "Reserved" }, - { EM_TSK3000 , "Altium TSK3000 core" }, - { EM_RS08 , "Freescale RS08 embedded processor" }, - { EM_res133 , "Reserved" }, - { EM_ECOG2 , "Cyan Technology eCOG2 microprocessor" }, - { EM_SCORE , "Sunplus Score" }, - { EM_SCORE7 , "Sunplus S+core7 RISC processor" }, - { EM_DSP24 , "New Japan Radio (NJR) 24-bit DSP Processor" }, - { EM_VIDEOCORE3 , "Broadcom VideoCore III processor" }, - { EM_LATTICEMICO32, "RISC processor for Lattice FPGA architecture" }, - { EM_SE_C17 , "Seiko Epson C17 family" }, - { EM_TI_C6000 , "Texas Instruments TMS320C6000 DSP family" }, - { EM_TI_C2000 , "Texas Instruments TMS320C2000 DSP family" }, - { EM_TI_C5500 , "Texas Instruments TMS320C55x DSP family" }, - { EM_res143 , "Reserved" }, - { EM_res144 , "Reserved" }, - { EM_res145 , "Reserved" }, - { EM_res146 , "Reserved" }, - { EM_res147 , "Reserved" }, - { EM_res148 , "Reserved" }, - { EM_res149 , "Reserved" }, - { EM_res150 , "Reserved" }, - { EM_res151 , "Reserved" }, - { EM_res152 , "Reserved" }, - { EM_res153 , "Reserved" }, - { EM_res154 , "Reserved" }, - { EM_res155 , "Reserved" }, - { EM_res156 , "Reserved" }, - { EM_res157 , "Reserved" }, - { EM_res158 , "Reserved" }, - { EM_res159 , "Reserved" }, - { EM_MMDSP_PLUS , "STMicroelectronics 64bit VLIW Data Signal Processor" }, - { EM_CYPRESS_M8C , "Cypress M8C microprocessor" }, - { EM_R32C , "Renesas R32C series microprocessors" }, - { EM_TRIMEDIA , "NXP Semiconductors TriMedia architecture family" }, - { EM_QDSP6 , "QUALCOMM DSP6 Processor" }, - { EM_8051 , "Intel 8051 and variants" }, - { EM_STXP7X , "STMicroelectronics STxP7x family" }, - { EM_NDS32 , "Andes Technology compact code size embedded RISC processor family" }, - { EM_ECOG1 , "Cyan Technology eCOG1X family" }, - { EM_ECOG1X , "Cyan Technology eCOG1X family" }, - { EM_MAXQ30 , "Dallas Semiconductor MAXQ30 Core Micro-controllers" }, - { EM_XIMO16 , "New Japan Radio (NJR) 16-bit DSP Processor" }, - { EM_MANIK , "M2000 Reconfigurable RISC Microprocessor" }, - { EM_CRAYNV2 , "Cray Inc. NV2 vector architecture" }, - { EM_RX , "Renesas RX family" }, - { EM_METAG , "Imagination Technologies META processor architecture" }, - { EM_MCST_ELBRUS , "MCST Elbrus general purpose hardware architecture" }, - { EM_ECOG16 , "Cyan Technology eCOG16 family" }, - { EM_CR16 , "National Semiconductor CompactRISC 16-bit processor" }, - { EM_ETPU , "Freescale Extended Time Processing Unit" }, - { EM_SLE9X , "Infineon Technologies SLE9X core" }, - { EM_L1OM , "Intel L1OM" }, - { EM_INTEL181 , "Reserved by Intel" }, - { EM_INTEL182 , "Reserved by Intel" }, - { EM_res183 , "Reserved by ARM" }, - { EM_res184 , "Reserved by ARM" }, - { EM_AVR32 , "Atmel Corporation 32-bit microprocessor family" }, - { EM_STM8 , "STMicroeletronics STM8 8-bit microcontroller" }, - { EM_TILE64 , "Tilera TILE64 multicore architecture family" }, - { EM_TILEPRO , "Tilera TILEPro multicore architecture family" }, - { EM_MICROBLAZE , "Xilinx MicroBlaze 32-bit RISC soft processor core" }, - { EM_CUDA , "NVIDIA CUDA architecture " }, -}; - - -static struct section_type_table_t { - const Elf64_Half key; - const char* str; -} section_type_table [] = -{ - { SHT_NULL , "NULL" }, - { SHT_PROGBITS , "PROGBITS" }, - { SHT_SYMTAB , "SYMTAB" }, - { SHT_STRTAB , "STRTAB" }, - { SHT_RELA , "RELA" }, - { SHT_HASH , "HASH" }, - { SHT_DYNAMIC , "DYNAMIC" }, - { SHT_NOTE , "NOTE" }, - { SHT_NOBITS , "NOBITS" }, - { SHT_REL , "REL" }, - { SHT_SHLIB , "SHLIB" }, - { SHT_DYNSYM , "DYNSYM" }, - { SHT_INIT_ARRAY , "INIT_ARRAY" }, - { SHT_FINI_ARRAY , "FINI_ARRAY" }, - { SHT_PREINIT_ARRAY, "PREINIT_ARRAY" }, - { SHT_GROUP , "GROUP" }, - { SHT_SYMTAB_SHNDX , "SYMTAB_SHNDX " }, -}; - - -static struct segment_type_table_t { - const Elf_Word key; - const char* str; -} segment_type_table [] = -{ - { PT_NULL , "NULL" }, - { PT_LOAD , "LOAD" }, - { PT_DYNAMIC, "DYNAMIC" }, - { PT_INTERP , "INTERP" }, - { PT_NOTE , "NOTE" }, - { PT_SHLIB , "SHLIB" }, - { PT_PHDR , "PHDR" }, - { PT_TLS , "TLS" }, -}; - - -static struct segment_flag_table_t { - const Elf_Word key; - const char* str; -} segment_flag_table [] = -{ - { 0, "" }, - { 1, "X" }, - { 2, "W" }, - { 3, "WX" }, - { 4, "R" }, - { 5, "RX" }, - { 6, "RW" }, - { 7, "RWX" }, -}; - - -static struct symbol_bind_t { - const Elf_Word key; - const char* str; -} symbol_bind_table [] = -{ - { STB_LOCAL , "LOCAL" }, - { STB_GLOBAL , "GLOBAL" }, - { STB_WEAK , "WEAK" }, - { STB_LOOS , "LOOS" }, - { STB_HIOS , "HIOS" }, - { STB_MULTIDEF, "MULTIDEF" }, - { STB_LOPROC , "LOPROC" }, - { STB_HIPROC , "HIPROC" }, -}; - - -static struct symbol_type_t { - const Elf_Word key; - const char* str; -} symbol_type_table [] = -{ - { STT_NOTYPE , "NOTYPE" }, - { STT_OBJECT , "OBJECT" }, - { STT_FUNC , "FUNC" }, - { STT_SECTION, "SECTION" }, - { STT_FILE , "FILE" }, - { STT_COMMON , "COMMON" }, - { STT_TLS , "TLS" }, - { STT_LOOS , "LOOS" }, - { STT_HIOS , "HIOS" }, - { STT_LOPROC , "LOPROC" }, - { STT_HIPROC , "HIPROC" }, -}; - - -static struct dynamic_tag_t { - const Elf_Word key; - const char* str; -} dynamic_tag_table [] = -{ - { DT_NULL , "NULL" }, - { DT_NEEDED , "NEEDED" }, - { DT_PLTRELSZ , "PLTRELSZ" }, - { DT_PLTGOT , "PLTGOT" }, - { DT_HASH , "HASH" }, - { DT_STRTAB , "STRTAB" }, - { DT_SYMTAB , "SYMTAB" }, - { DT_RELA , "RELA" }, - { DT_RELASZ , "RELASZ" }, - { DT_RELAENT , "RELAENT" }, - { DT_STRSZ , "STRSZ" }, - { DT_SYMENT , "SYMENT" }, - { DT_INIT , "INIT" }, - { DT_FINI , "FINI" }, - { DT_SONAME , "SONAME" }, - { DT_RPATH , "RPATH" }, - { DT_SYMBOLIC , "SYMBOLIC" }, - { DT_REL , "REL" }, - { DT_RELSZ , "RELSZ" }, - { DT_RELENT , "RELENT" }, - { DT_PLTREL , "PLTREL" }, - { DT_DEBUG , "DEBUG" }, - { DT_TEXTREL , "TEXTREL" }, - { DT_JMPREL , "JMPREL" }, - { DT_BIND_NOW , "BIND_NOW" }, - { DT_INIT_ARRAY , "INIT_ARRAY" }, - { DT_FINI_ARRAY , "FINI_ARRAY" }, - { DT_INIT_ARRAYSZ , "INIT_ARRAYSZ" }, - { DT_FINI_ARRAYSZ , "FINI_ARRAYSZ" }, - { DT_RUNPATH , "RUNPATH" }, - { DT_FLAGS , "FLAGS" }, - { DT_ENCODING , "ENCODING" }, - { DT_PREINIT_ARRAY , "PREINIT_ARRAY" }, - { DT_PREINIT_ARRAYSZ, "PREINIT_ARRAYSZ" }, - { DT_MAXPOSTAGS , "MAXPOSTAGS" }, -}; - -static const ELFIO::Elf_Xword MAX_DATA_ENTRIES = 64; - -//------------------------------------------------------------------------------ -class dump -{ -#define DUMP_DEC_FORMAT( width ) std::setw(width) << std::setfill( ' ' ) << \ - std::dec << std::right -#define DUMP_HEX_FORMAT( width ) std::setw(width) << std::setfill( '0' ) << \ - std::hex << std::right -#define DUMP_STR_FORMAT( width ) std::setw(width) << std::setfill( ' ' ) << \ - std::hex << std::left - - public: -//------------------------------------------------------------------------------ - static void - header( std::ostream& out, const elfio& reader ) - { - if (!reader.get_header_size()) - { - return; - } - out << "ELF Header" << std::endl << std::endl - << " Class: " << str_class( reader.get_class() ) << std::endl - << " Encoding: " << str_endian( reader.get_encoding() ) << std::endl - << " ELFVersion: " << str_version( reader.get_elf_version() ) << std::endl - << " Type: " << str_type( reader.get_type() ) << std::endl - << " Machine: " << str_machine( reader.get_machine() ) << std::endl - << " Version: " << str_version( reader.get_version() ) << std::endl - << " Entry: " << "0x" << std::hex << reader.get_entry() << std::endl - << " Flags: " << "0x" << std::hex << reader.get_flags() << std::endl - << std::endl; - } - -//------------------------------------------------------------------------------ - static void - section_headers( std::ostream& out, const elfio& reader ) - { - Elf_Half n = reader.sections.size(); - - if ( n == 0 ) { - return; - } - - out << "Section Headers:" << std::endl; - if ( reader.get_class() == ELFCLASS32 ) { // Output for 32-bit - out << "[ Nr ] Type Addr Size ES Flg Lk Inf Al Name" << std::endl; - } - else { // Output for 64-bit - out << "[ Nr ] Type Addr Size ES Flg" << std::endl - << " Lk Inf Al Name" << std::endl; - } - - for ( Elf_Half i = 0; i < n; ++i ) { // For all sections - section* sec = reader.sections[i]; - section_header( out, i, sec, reader.get_class() ); - } - - out << "Key to Flags: W (write), A (alloc), X (execute)\n\n" - << std::endl; - } - -//------------------------------------------------------------------------------ - static void - section_header( std::ostream& out, Elf_Half no, const section* sec, - unsigned char elf_class ) - { - std::ios_base::fmtflags original_flags = out.flags(); - - if ( elf_class == ELFCLASS32 ) { // Output for 32-bit - out << "[" - << DUMP_DEC_FORMAT( 5 ) << no - << "] " - << DUMP_STR_FORMAT( 17 ) << str_section_type( sec->get_type() ) << " " - << DUMP_HEX_FORMAT( 8 ) << sec->get_address() << " " - << DUMP_HEX_FORMAT( 8 ) << sec->get_size() << " " - << DUMP_HEX_FORMAT( 2 ) << sec->get_entry_size() << " " - << DUMP_STR_FORMAT( 3 ) << section_flags( sec->get_flags() ) << " " - << DUMP_HEX_FORMAT( 2 ) << sec->get_link() << " " - << DUMP_HEX_FORMAT( 3 ) << sec->get_info() << " " - << DUMP_HEX_FORMAT( 2 ) << sec->get_addr_align() << " " - << DUMP_STR_FORMAT( 17 ) << sec->get_name() << " " - << std::endl; - } - else { // Output for 64-bit - out << "[" - << DUMP_DEC_FORMAT( 5 ) << no - << "] " - << DUMP_STR_FORMAT( 17 ) << str_section_type( sec->get_type() ) << " " - << DUMP_HEX_FORMAT( 16 ) << sec->get_address() << " " - << DUMP_HEX_FORMAT( 16 ) << sec->get_size() << " " - << DUMP_HEX_FORMAT( 4 ) << sec->get_entry_size() << " " - << DUMP_STR_FORMAT( 3 ) << section_flags( sec->get_flags() ) << " " - << std::endl - << " " - << DUMP_HEX_FORMAT( 4 ) << sec->get_link() << " " - << DUMP_HEX_FORMAT( 4 ) << sec->get_info() << " " - << DUMP_HEX_FORMAT( 4 ) << sec->get_addr_align() << " " - << DUMP_STR_FORMAT( 17 ) << sec->get_name() << " " - << std::endl; - } - - out.flags(original_flags); - - return; - } - -//------------------------------------------------------------------------------ - static void - segment_headers( std::ostream& out, const elfio& reader ) - { - Elf_Half n = reader.segments.size(); - if ( n == 0 ) { - return; - } - - out << "Segment headers:" << std::endl; - if ( reader.get_class() == ELFCLASS32 ) { // Output for 32-bit - out << "[ Nr ] Type VirtAddr PhysAddr FileSize Mem.Size Flags Align" - << std::endl; - } - else { // Output for 64-bit - out << "[ Nr ] Type VirtAddr PhysAddr Flags" << std::endl - << " FileSize Mem.Size Align" - << std::endl; - } - - for ( Elf_Half i = 0; i < n; ++i ) { - segment* seg = reader.segments[i]; - segment_header( out, i, seg, reader.get_class() ); - } - - out << std::endl; - } - -//------------------------------------------------------------------------------ - static void - segment_header( std::ostream& out, Elf_Half no, const segment* seg, - unsigned int elf_class ) - { - std::ios_base::fmtflags original_flags = out.flags(); - - if ( elf_class == ELFCLASS32 ) { // Output for 32-bit - out << "[" - << DUMP_DEC_FORMAT( 5 ) << no - << "] " - << DUMP_STR_FORMAT( 14 ) << str_segment_type( seg->get_type() ) << " " - << DUMP_HEX_FORMAT( 8 ) << seg->get_virtual_address() << " " - << DUMP_HEX_FORMAT( 8 ) << seg->get_physical_address() << " " - << DUMP_HEX_FORMAT( 8 ) << seg->get_file_size() << " " - << DUMP_HEX_FORMAT( 8 ) << seg->get_memory_size() << " " - << DUMP_STR_FORMAT( 8 ) << str_segment_flag( seg->get_flags() ) << " " - << DUMP_HEX_FORMAT( 8 ) << seg->get_align() << " " - << std::endl; - } - else { // Output for 64-bit - out << "[" - << DUMP_DEC_FORMAT( 5 ) << no - << "] " - << DUMP_STR_FORMAT( 14 ) << str_segment_type( seg->get_type() ) << " " - << DUMP_HEX_FORMAT( 16 ) << seg->get_virtual_address() << " " - << DUMP_HEX_FORMAT( 16 ) << seg->get_physical_address() << " " - << DUMP_STR_FORMAT( 16 ) << str_segment_flag( seg->get_flags() ) << " " - << std::endl - << " " - << DUMP_HEX_FORMAT( 16 ) << seg->get_file_size() << " " - << DUMP_HEX_FORMAT( 16 ) << seg->get_memory_size() << " " - << DUMP_HEX_FORMAT( 16 ) << seg->get_align() << " " - << std::endl; - } - - out.flags(original_flags); - } - -//------------------------------------------------------------------------------ - static void - symbol_tables( std::ostream& out, const elfio& reader ) - { - Elf_Half n = reader.sections.size(); - for ( Elf_Half i = 0; i < n; ++i ) { // For all sections - section* sec = reader.sections[i]; - if ( SHT_SYMTAB == sec->get_type() || SHT_DYNSYM == sec->get_type() ) { - symbol_section_accessor symbols( reader, sec ); - - Elf_Xword sym_no = symbols.get_symbols_num(); - if ( sym_no > 0 ) { - out << "Symbol table (" << sec->get_name() << ")" << std::endl; - if ( reader.get_class() == ELFCLASS32 ) { // Output for 32-bit - out << "[ Nr ] Value Size Type Bind Sect Name" - << std::endl; - } - else { // Output for 64-bit - out << "[ Nr ] Value Size Type Bind Sect" << std::endl - << " Name" - << std::endl; - } - for ( Elf_Half i = 0; i < sym_no; ++i ) { - std::string name; - Elf64_Addr value = 0; - Elf_Xword size = 0; - unsigned char bind = 0; - unsigned char type = 0; - Elf_Half section = 0; - unsigned char other = 0; - symbols.get_symbol( i, name, value, size, bind, type, section, other ); - symbol_table( out, i, name, value, size, bind, type, section, reader.get_class() ); - } - - out << std::endl; - } - } - } - } - -//------------------------------------------------------------------------------ - static void - symbol_table( std::ostream& out, - Elf_Half no, - std::string& name, - Elf64_Addr value, - Elf_Xword size, - unsigned char bind, - unsigned char type, - Elf_Half section, - unsigned int elf_class ) - { - std::ios_base::fmtflags original_flags = out.flags(); - - if ( elf_class == ELFCLASS32 ) { // Output for 32-bit - out << "[" - << DUMP_DEC_FORMAT( 5 ) << no - << "] " - << DUMP_HEX_FORMAT( 8 ) << value << " " - << DUMP_HEX_FORMAT( 8 ) << size << " " - << DUMP_STR_FORMAT( 7 ) << str_symbol_type( type ) << " " - << DUMP_STR_FORMAT( 8 ) << str_symbol_bind( bind ) << " " - << DUMP_DEC_FORMAT( 5 ) << section << " " - << DUMP_STR_FORMAT( 1 ) << name << " " - << std::endl; - } - else { // Output for 64-bit - out << "[" - << DUMP_DEC_FORMAT( 5 ) << no - << "] " - << DUMP_HEX_FORMAT( 16 ) << value << " " - << DUMP_HEX_FORMAT( 16 ) << size << " " - << DUMP_STR_FORMAT( 7 ) << str_symbol_type( type ) << " " - << DUMP_STR_FORMAT( 8 ) << str_symbol_bind( bind ) << " " - << DUMP_DEC_FORMAT( 5 ) << section << " " - << std::endl - << " " - << DUMP_STR_FORMAT( 1 ) << name << " " - << std::endl; - } - - out.flags(original_flags); - } - -//------------------------------------------------------------------------------ - static void - notes( std::ostream& out, const elfio& reader ) - { - Elf_Half no = reader.sections.size(); - for ( Elf_Half i = 0; i < no; ++i ) { // For all sections - section* sec = reader.sections[i]; - if ( SHT_NOTE == sec->get_type() ) { // Look at notes - note_section_accessor notes( reader, sec ); - int no_notes = notes.get_notes_num(); - if ( no > 0 ) { - out << "Note section (" << sec->get_name() << ")" << std::endl - << " No Type Name" - << std::endl; - for ( int j = 0; j < no_notes; ++j ) { // For all notes - Elf_Word type; - std::string name; - void* desc; - Elf_Word descsz; - - if ( notes.get_note(j, type, name, desc, descsz) ) { - // 'name' usually contains \0 at the end. Try to fix it - name = name.c_str(); - note( out, j, type, name ); - } - } - - out << std::endl; - } - } - } - } - -//------------------------------------------------------------------------------ - static void - note( std::ostream& out, - int no, - Elf_Word type, - const std::string& name ) - { - out << " [" - << DUMP_DEC_FORMAT( 2 ) << no - << "] " - << DUMP_HEX_FORMAT( 8 ) << type << " " - << DUMP_STR_FORMAT( 1 ) << name - << std::endl; - } - -//------------------------------------------------------------------------------ - static void - dynamic_tags( std::ostream& out, const elfio& reader ) - { - Elf_Half n = reader.sections.size(); - for ( Elf_Half i = 0; i < n; ++i ) { // For all sections - section* sec = reader.sections[i]; - if ( SHT_DYNAMIC == sec->get_type() ) { - dynamic_section_accessor dynamic( reader, sec ); - - Elf_Xword dyn_no = dynamic.get_entries_num(); - if ( dyn_no > 0 ) { - out << "Dynamic section (" << sec->get_name() << ")" << std::endl; - out << "[ Nr ] Tag Name/Value" << std::endl; - for ( Elf_Xword i = 0; i < dyn_no; ++i ) { - Elf_Xword tag = 0; - Elf_Xword value = 0; - std::string str; - dynamic.get_entry( i, tag, value, str ); - dynamic_tag( out, i, tag, value, str, reader.get_class() ); - if ( DT_NULL == tag ) { - break; - } - } - - out << std::endl; - } - } - } - } - -//------------------------------------------------------------------------------ - static void - dynamic_tag( std::ostream& out, - Elf_Xword no, - Elf_Xword tag, - Elf_Xword value, - std::string str, - unsigned int /*elf_class*/ ) - { - out << "[" - << DUMP_DEC_FORMAT( 5 ) << no - << "] " - << DUMP_STR_FORMAT( 16 ) << str_dynamic_tag( tag ) << " "; - if ( str.empty() ) { - out << DUMP_HEX_FORMAT( 16 ) << value << " "; - } - else { - out << DUMP_STR_FORMAT( 32 ) << str << " "; - } - out << std::endl; - } - -//------------------------------------------------------------------------------ - static void - section_data( std::ostream& out, const section* sec ) - { - std::ios_base::fmtflags original_flags = out.flags(); - - out << sec->get_name() << std::endl; - const char* pdata = sec->get_data(); - if ( pdata ){ - ELFIO::Elf_Xword i; - for ( i = 0; i < std::min( sec->get_size(), MAX_DATA_ENTRIES ); ++i ) { - if ( i % 16 == 0 ) { - out << "[" << DUMP_HEX_FORMAT( 8 ) << i << "]"; - } - - out << " " << DUMP_HEX_FORMAT( 2 ) << ( pdata[i] & 0x000000FF ); - - if ( i % 16 == 15 ) { - out << std::endl; - } - } - if ( i % 16 != 0 ) { - out << std::endl; - } - - out.flags(original_flags); - } - - return; - } - -//------------------------------------------------------------------------------ - static void - section_datas( std::ostream& out, const elfio& reader ) - { - Elf_Half n = reader.sections.size(); - - if ( n == 0 ) { - return; - } - - out << "Section Data:" << std::endl; - - for ( Elf_Half i = 1; i < n; ++i ) { // For all sections - section* sec = reader.sections[i]; - if ( sec->get_type() == SHT_NOBITS ) { - continue; - } - section_data( out, sec ); - } - - out << std::endl; - } - -//------------------------------------------------------------------------------ - static void - segment_data( std::ostream& out, Elf_Half no, const segment* seg ) - { - std::ios_base::fmtflags original_flags = out.flags(); - - out << "Segment # " << no << std::endl; - const char* pdata = seg->get_data(); - if ( pdata ) { - ELFIO::Elf_Xword i; - for ( i = 0; i < std::min( seg->get_file_size(), MAX_DATA_ENTRIES ); ++i ) { - if ( i % 16 == 0 ) { - out << "[" << DUMP_HEX_FORMAT( 8 ) << i << "]"; - } - - out << " " << DUMP_HEX_FORMAT( 2 ) << ( pdata[i] & 0x000000FF ); - - if ( i % 16 == 15 ) { - out << std::endl; - } - } - if ( i % 16 != 0 ) { - out << std::endl; - } - - out.flags(original_flags); - } - - return; - } - -//------------------------------------------------------------------------------ - static void - segment_datas( std::ostream& out, const elfio& reader ) - { - Elf_Half n = reader.segments.size(); - - if ( n == 0 ) { - return; - } - - out << "Segment Data:" << std::endl; - - for ( Elf_Half i = 0; i < n; ++i ) { // For all sections - segment* seg = reader.segments[i]; - segment_data( out, i, seg ); - } - - out << std::endl; - } - - private: -//------------------------------------------------------------------------------ - template< typename T, typename K > - std::string - static - find_value_in_table( const T& table, const K& key ) - { - std::string res = "?"; - for ( unsigned int i = 0; i < sizeof( table )/sizeof( table[0] ); ++i ) { - if ( table[i].key == key ) { - res = table[i].str; - break; - } - } - - return res; - } - - -//------------------------------------------------------------------------------ - template< typename T, typename K > - static - std::string - format_assoc( const T& table, const K& key ) - { - std::string str = find_value_in_table( table, key ); - if ( str == "?" ) { - std::ostringstream oss; - oss << str << " (0x" << std::hex << key << ")"; - str = oss.str(); - } - - return str; - } - - -//------------------------------------------------------------------------------ - template< typename T > - static - std::string - format_assoc( const T& table, const char key ) - { - return format_assoc( table, (const int)key ); - } - - -//------------------------------------------------------------------------------ - static - std::string - section_flags( Elf_Xword flags ) - { - std::string ret = ""; - if ( flags & SHF_WRITE ) { - ret += "W"; - } - if ( flags & SHF_ALLOC ) { - ret += "A"; - } - if ( flags & SHF_EXECINSTR ) { - ret += "X"; - } - - return ret; - } - - -//------------------------------------------------------------------------------ -#define STR_FUNC_TABLE( name ) \ - template< typename T > \ - static \ - std::string \ - str_##name( const T key ) \ - { \ - return format_assoc( name##_table, key ); \ - } - - STR_FUNC_TABLE( class ) - STR_FUNC_TABLE( endian ) - STR_FUNC_TABLE( version ) - STR_FUNC_TABLE( type ) - STR_FUNC_TABLE( machine ) - STR_FUNC_TABLE( section_type ) - STR_FUNC_TABLE( segment_type ) - STR_FUNC_TABLE( segment_flag ) - STR_FUNC_TABLE( symbol_bind ) - STR_FUNC_TABLE( symbol_type ) - STR_FUNC_TABLE( dynamic_tag ) - -#undef STR_FUNC_TABLE -#undef DUMP_DEC_FORMAT -#undef DUMP_HEX_FORMAT -#undef DUMP_STR_FORMAT -}; // class dump - - -}; // namespace ELFIO - -#endif // ELFIO_DUMP_HPP diff --git a/ZAPDTR/lib/elfio/elfio/elfio_dynamic.hpp b/ZAPDTR/lib/elfio/elfio/elfio_dynamic.hpp deleted file mode 100644 index 42f26805b..000000000 --- a/ZAPDTR/lib/elfio/elfio/elfio_dynamic.hpp +++ /dev/null @@ -1,257 +0,0 @@ -/* -Copyright (C) 2001-2015 by Serge Lamikhov-Center - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -*/ - -#ifndef ELFIO_DYNAMIC_HPP -#define ELFIO_DYNAMIC_HPP - -namespace ELFIO { - -//------------------------------------------------------------------------------ -template< class S > -class dynamic_section_accessor_template -{ - public: -//------------------------------------------------------------------------------ - dynamic_section_accessor_template( const elfio& elf_file_, S* section_ ) : - elf_file( elf_file_ ), - dynamic_section( section_ ) - { - } - -//------------------------------------------------------------------------------ - Elf_Xword - get_entries_num() const - { - Elf_Xword nRet = 0; - - if ( 0 != dynamic_section->get_entry_size() ) { - nRet = dynamic_section->get_size() / dynamic_section->get_entry_size(); - } - - return nRet; - } - -//------------------------------------------------------------------------------ - bool - get_entry( Elf_Xword index, - Elf_Xword& tag, - Elf_Xword& value, - std::string& str ) const - { - if ( index >= get_entries_num() ) { // Is index valid - return false; - } - - if ( elf_file.get_class() == ELFCLASS32 ) { - generic_get_entry_dyn< Elf32_Dyn >( index, tag, value ); - } - else { - generic_get_entry_dyn< Elf64_Dyn >( index, tag, value ); - } - - // If the tag may have a string table reference, prepare the string - if ( tag == DT_NEEDED || - tag == DT_SONAME || - tag == DT_RPATH || - tag == DT_RUNPATH ) { - string_section_accessor strsec = - elf_file.sections[ get_string_table_index() ]; - const char* result = strsec.get_string( value ); - if ( 0 == result ) { - str.clear(); - return false; - } - str = result; - } - else { - str.clear(); - } - - return true; - } - -//------------------------------------------------------------------------------ - void - add_entry( Elf_Xword tag, - Elf_Xword value ) - { - if ( elf_file.get_class() == ELFCLASS32 ) { - generic_add_entry< Elf32_Dyn >( tag, value ); - } - else { - generic_add_entry< Elf64_Dyn >( tag, value ); - } - } - -//------------------------------------------------------------------------------ - void - add_entry( Elf_Xword tag, - const std::string& str ) - { - string_section_accessor strsec = - elf_file.sections[ get_string_table_index() ]; - Elf_Xword value = strsec.add_string( str ); - add_entry( tag, value ); - } - -//------------------------------------------------------------------------------ - private: -//------------------------------------------------------------------------------ - Elf_Half - get_string_table_index() const - { - return (Elf_Half)dynamic_section->get_link(); - } - -//------------------------------------------------------------------------------ - template< class T > - void - generic_get_entry_dyn( Elf_Xword index, - Elf_Xword& tag, - Elf_Xword& value ) const - { - const endianess_convertor& convertor = elf_file.get_convertor(); - - // Check unusual case when dynamic section has no data - if( dynamic_section->get_data() == 0 || - ( index + 1 ) * dynamic_section->get_entry_size() > dynamic_section->get_size() ) { - tag = DT_NULL; - value = 0; - return; - } - - const T* pEntry = reinterpret_cast( - dynamic_section->get_data() + - index * dynamic_section->get_entry_size() ); - tag = convertor( pEntry->d_tag ); - switch ( tag ) { - case DT_NULL: - case DT_SYMBOLIC: - case DT_TEXTREL: - case DT_BIND_NOW: - value = 0; - break; - case DT_NEEDED: - case DT_PLTRELSZ: - case DT_RELASZ: - case DT_RELAENT: - case DT_STRSZ: - case DT_SYMENT: - case DT_SONAME: - case DT_RPATH: - case DT_RELSZ: - case DT_RELENT: - case DT_PLTREL: - case DT_INIT_ARRAYSZ: - case DT_FINI_ARRAYSZ: - case DT_RUNPATH: - case DT_FLAGS: - case DT_PREINIT_ARRAYSZ: - value = convertor( pEntry->d_un.d_val ); - break; - case DT_PLTGOT: - case DT_HASH: - case DT_STRTAB: - case DT_SYMTAB: - case DT_RELA: - case DT_INIT: - case DT_FINI: - case DT_REL: - case DT_DEBUG: - case DT_JMPREL: - case DT_INIT_ARRAY: - case DT_FINI_ARRAY: - case DT_PREINIT_ARRAY: - default: - value = convertor( pEntry->d_un.d_ptr ); - break; - } - } - -//------------------------------------------------------------------------------ - template< class T > - void - generic_add_entry( Elf_Xword tag, Elf_Xword value ) - { - const endianess_convertor& convertor = elf_file.get_convertor(); - - T entry; - - switch ( tag ) { - case DT_NULL: - case DT_SYMBOLIC: - case DT_TEXTREL: - case DT_BIND_NOW: - value = 0; - case DT_NEEDED: - case DT_PLTRELSZ: - case DT_RELASZ: - case DT_RELAENT: - case DT_STRSZ: - case DT_SYMENT: - case DT_SONAME: - case DT_RPATH: - case DT_RELSZ: - case DT_RELENT: - case DT_PLTREL: - case DT_INIT_ARRAYSZ: - case DT_FINI_ARRAYSZ: - case DT_RUNPATH: - case DT_FLAGS: - case DT_PREINIT_ARRAYSZ: - entry.d_un.d_val = convertor( value ); - break; - case DT_PLTGOT: - case DT_HASH: - case DT_STRTAB: - case DT_SYMTAB: - case DT_RELA: - case DT_INIT: - case DT_FINI: - case DT_REL: - case DT_DEBUG: - case DT_JMPREL: - case DT_INIT_ARRAY: - case DT_FINI_ARRAY: - case DT_PREINIT_ARRAY: - default: - entry.d_un.d_ptr = convertor( value ); - break; - } - - entry.d_tag = convertor( tag ); - - dynamic_section->append_data( reinterpret_cast( &entry ), sizeof( entry ) ); - } - -//------------------------------------------------------------------------------ - private: - const elfio& elf_file; - S* dynamic_section; -}; - -using dynamic_section_accessor = dynamic_section_accessor_template
; -using const_dynamic_section_accessor = dynamic_section_accessor_template; - -} // namespace ELFIO - -#endif // ELFIO_DYNAMIC_HPP diff --git a/ZAPDTR/lib/elfio/elfio/elfio_header.hpp b/ZAPDTR/lib/elfio/elfio/elfio_header.hpp deleted file mode 100644 index 6f8da0285..000000000 --- a/ZAPDTR/lib/elfio/elfio/elfio_header.hpp +++ /dev/null @@ -1,145 +0,0 @@ -/* -Copyright (C) 2001-2015 by Serge Lamikhov-Center - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -*/ - -#ifndef ELF_HEADER_HPP -#define ELF_HEADER_HPP - -#include - -namespace ELFIO { - -class elf_header -{ - public: - virtual ~elf_header() {}; - virtual bool load( std::istream& stream ) = 0; - virtual bool save( std::ostream& stream ) const = 0; - - // ELF header functions - ELFIO_GET_ACCESS_DECL( unsigned char, class ); - ELFIO_GET_ACCESS_DECL( unsigned char, elf_version ); - ELFIO_GET_ACCESS_DECL( unsigned char, encoding ); - ELFIO_GET_ACCESS_DECL( Elf_Half, header_size ); - ELFIO_GET_ACCESS_DECL( Elf_Half, section_entry_size ); - ELFIO_GET_ACCESS_DECL( Elf_Half, segment_entry_size ); - - ELFIO_GET_SET_ACCESS_DECL( Elf_Word, version ); - ELFIO_GET_SET_ACCESS_DECL( unsigned char, os_abi ); - ELFIO_GET_SET_ACCESS_DECL( unsigned char, abi_version ); - ELFIO_GET_SET_ACCESS_DECL( Elf_Half, type ); - ELFIO_GET_SET_ACCESS_DECL( Elf_Half, machine ); - ELFIO_GET_SET_ACCESS_DECL( Elf_Word, flags ); - ELFIO_GET_SET_ACCESS_DECL( Elf64_Addr, entry ); - ELFIO_GET_SET_ACCESS_DECL( Elf_Half, sections_num ); - ELFIO_GET_SET_ACCESS_DECL( Elf64_Off, sections_offset ); - ELFIO_GET_SET_ACCESS_DECL( Elf_Half, segments_num ); - ELFIO_GET_SET_ACCESS_DECL( Elf64_Off, segments_offset ); - ELFIO_GET_SET_ACCESS_DECL( Elf_Half, section_name_str_index ); -}; - - -template< class T > struct elf_header_impl_types; -template<> struct elf_header_impl_types { - typedef Elf32_Phdr Phdr_type; - typedef Elf32_Shdr Shdr_type; - static const unsigned char file_class = ELFCLASS32; -}; -template<> struct elf_header_impl_types { - typedef Elf64_Phdr Phdr_type; - typedef Elf64_Shdr Shdr_type; - static const unsigned char file_class = ELFCLASS64; -}; - -template< class T > class elf_header_impl : public elf_header -{ - public: - elf_header_impl( endianess_convertor* convertor_, - unsigned char encoding ) - { - convertor = convertor_; - - std::fill_n( reinterpret_cast( &header ), sizeof( header ), '\0' ); - - header.e_ident[EI_MAG0] = ELFMAG0; - header.e_ident[EI_MAG1] = ELFMAG1; - header.e_ident[EI_MAG2] = ELFMAG2; - header.e_ident[EI_MAG3] = ELFMAG3; - header.e_ident[EI_CLASS] = elf_header_impl_types::file_class; - header.e_ident[EI_DATA] = encoding; - header.e_ident[EI_VERSION] = EV_CURRENT; - header.e_version = (*convertor)( (Elf_Word)EV_CURRENT ); - header.e_ehsize = ( sizeof( header ) ); - header.e_ehsize = (*convertor)( header.e_ehsize ); - header.e_shstrndx = (*convertor)( (Elf_Half)1 ); - header.e_phentsize = sizeof( typename elf_header_impl_types::Phdr_type ); - header.e_shentsize = sizeof( typename elf_header_impl_types::Shdr_type ); - header.e_phentsize = (*convertor)( header.e_phentsize ); - header.e_shentsize = (*convertor)( header.e_shentsize ); - } - - bool - load( std::istream& stream ) - { - stream.seekg( 0 ); - stream.read( reinterpret_cast( &header ), sizeof( header ) ); - - return (stream.gcount() == sizeof( header ) ); - } - - bool - save( std::ostream& stream ) const - { - stream.seekp( 0 ); - stream.write( reinterpret_cast( &header ), sizeof( header ) ); - - return stream.good(); - } - - // ELF header functions - ELFIO_GET_ACCESS( unsigned char, class, header.e_ident[EI_CLASS] ); - ELFIO_GET_ACCESS( unsigned char, elf_version, header.e_ident[EI_VERSION] ); - ELFIO_GET_ACCESS( unsigned char, encoding, header.e_ident[EI_DATA] ); - ELFIO_GET_ACCESS( Elf_Half, header_size, header.e_ehsize ); - ELFIO_GET_ACCESS( Elf_Half, section_entry_size, header.e_shentsize ); - ELFIO_GET_ACCESS( Elf_Half, segment_entry_size, header.e_phentsize ); - - ELFIO_GET_SET_ACCESS( Elf_Word, version, header.e_version); - ELFIO_GET_SET_ACCESS( unsigned char, os_abi, header.e_ident[EI_OSABI] ); - ELFIO_GET_SET_ACCESS( unsigned char, abi_version, header.e_ident[EI_ABIVERSION] ); - ELFIO_GET_SET_ACCESS( Elf_Half, type, header.e_type ); - ELFIO_GET_SET_ACCESS( Elf_Half, machine, header.e_machine ); - ELFIO_GET_SET_ACCESS( Elf_Word, flags, header.e_flags ); - ELFIO_GET_SET_ACCESS( Elf_Half, section_name_str_index, header.e_shstrndx ); - ELFIO_GET_SET_ACCESS( Elf64_Addr, entry, header.e_entry ); - ELFIO_GET_SET_ACCESS( Elf_Half, sections_num, header.e_shnum ); - ELFIO_GET_SET_ACCESS( Elf64_Off, sections_offset, header.e_shoff ); - ELFIO_GET_SET_ACCESS( Elf_Half, segments_num, header.e_phnum ); - ELFIO_GET_SET_ACCESS( Elf64_Off, segments_offset, header.e_phoff ); - - private: - T header; - endianess_convertor* convertor; -}; - -} // namespace ELFIO - -#endif // ELF_HEADER_HPP diff --git a/ZAPDTR/lib/elfio/elfio/elfio_note.hpp b/ZAPDTR/lib/elfio/elfio/elfio_note.hpp deleted file mode 100644 index 8619c7385..000000000 --- a/ZAPDTR/lib/elfio/elfio/elfio_note.hpp +++ /dev/null @@ -1,170 +0,0 @@ -/* -Copyright (C) 2001-2015 by Serge Lamikhov-Center - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -*/ - -#ifndef ELFIO_NOTE_HPP -#define ELFIO_NOTE_HPP - -namespace ELFIO { - -//------------------------------------------------------------------------------ -// There are discrepancies in documentations. SCO documentation -// (http://www.sco.com/developers/gabi/latest/ch5.pheader.html#note_section) -// requires 8 byte entries alignment for 64-bit ELF file, -// but Oracle's definition uses the same structure -// for 32-bit and 64-bit formats. -// (https://docs.oracle.com/cd/E23824_01/html/819-0690/chapter6-18048.html) -// -// It looks like EM_X86_64 Linux implementation is similar to Oracle's -// definition. Therefore, the same alignment works for both formats -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -template< class S > -class note_section_accessor_template -{ - public: -//------------------------------------------------------------------------------ - note_section_accessor_template( const elfio& elf_file_, S* section_ ) : - elf_file( elf_file_ ), note_section( section_ ) - { - process_section(); - } - -//------------------------------------------------------------------------------ - Elf_Word - get_notes_num() const - { - return (Elf_Word)note_start_positions.size(); - } - -//------------------------------------------------------------------------------ - bool - get_note( Elf_Word index, - Elf_Word& type, - std::string& name, - void*& desc, - Elf_Word& descSize ) const - { - if ( index >= note_section->get_size() ) { - return false; - } - - const char* pData = note_section->get_data() + note_start_positions[index]; - int align = sizeof( Elf_Word ); - - const endianess_convertor& convertor = elf_file.get_convertor(); - type = convertor( *(const Elf_Word*)( pData + 2*align ) ); - Elf_Word namesz = convertor( *(const Elf_Word*)( pData ) ); - descSize = convertor( *(const Elf_Word*)( pData + sizeof( namesz ) ) ); - Elf_Xword max_name_size = note_section->get_size() - note_start_positions[index]; - if ( namesz > max_name_size || - namesz + descSize > max_name_size ) { - return false; - } - name.assign( pData + 3*align, namesz - 1); - if ( 0 == descSize ) { - desc = 0; - } - else { - desc = const_cast ( pData + 3*align + - ( ( namesz + align - 1 )/align )*align ); - } - - return true; - } - -//------------------------------------------------------------------------------ - void add_note( Elf_Word type, - const std::string& name, - const void* desc, - Elf_Word descSize ) - { - const endianess_convertor& convertor = elf_file.get_convertor(); - - int align = sizeof( Elf_Word ); - Elf_Word nameLen = (Elf_Word)name.size() + 1; - Elf_Word nameLenConv = convertor( nameLen ); - std::string buffer( reinterpret_cast( &nameLenConv ), align ); - Elf_Word descSizeConv = convertor( descSize ); - buffer.append( reinterpret_cast( &descSizeConv ), align ); - type = convertor( type ); - buffer.append( reinterpret_cast( &type ), align ); - buffer.append( name ); - buffer.append( 1, '\x00' ); - const char pad[] = { '\0', '\0', '\0', '\0' }; - if ( nameLen % align != 0 ) { - buffer.append( pad, align - nameLen % align ); - } - if ( desc != 0 && descSize != 0 ) { - buffer.append( reinterpret_cast( desc ), descSize ); - if ( descSize % align != 0 ) { - buffer.append( pad, align - descSize % align ); - } - } - - note_start_positions.push_back( note_section->get_size() ); - note_section->append_data( buffer ); - } - - private: -//------------------------------------------------------------------------------ - void process_section() - { - const endianess_convertor& convertor = elf_file.get_convertor(); - const char* data = note_section->get_data(); - Elf_Xword size = note_section->get_size(); - Elf_Xword current = 0; - - note_start_positions.clear(); - - // Is it empty? - if ( 0 == data || 0 == size ) { - return; - } - - int align = sizeof( Elf_Word ); - while ( current + 3*align <= size ) { - note_start_positions.push_back( current ); - Elf_Word namesz = convertor( - *(const Elf_Word*)( data + current ) ); - Elf_Word descsz = convertor( - *(const Elf_Word*)( data + current + sizeof( namesz ) ) ); - - current += 3*sizeof( Elf_Word ) + - ( ( namesz + align - 1 ) / align ) * align + - ( ( descsz + align - 1 ) / align ) * align; - } - } - -//------------------------------------------------------------------------------ - private: - const elfio& elf_file; - S* note_section; - std::vector note_start_positions; -}; - -using note_section_accessor = note_section_accessor_template
; -using const_note_section_accessor = note_section_accessor_template; - -} // namespace ELFIO - -#endif // ELFIO_NOTE_HPP diff --git a/ZAPDTR/lib/elfio/elfio/elfio_relocation.hpp b/ZAPDTR/lib/elfio/elfio/elfio_relocation.hpp deleted file mode 100644 index 238598e97..000000000 --- a/ZAPDTR/lib/elfio/elfio/elfio_relocation.hpp +++ /dev/null @@ -1,373 +0,0 @@ -/* -Copyright (C) 2001-2015 by Serge Lamikhov-Center - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -*/ - -#ifndef ELFIO_RELOCATION_HPP -#define ELFIO_RELOCATION_HPP - -namespace ELFIO { - -template struct get_sym_and_type; -template<> struct get_sym_and_type< Elf32_Rel > -{ - static int get_r_sym( Elf_Xword info ) - { - return ELF32_R_SYM( (Elf_Word)info ); - } - static int get_r_type( Elf_Xword info ) - { - return ELF32_R_TYPE( (Elf_Word)info ); - } -}; -template<> struct get_sym_and_type< Elf32_Rela > -{ - static int get_r_sym( Elf_Xword info ) - { - return ELF32_R_SYM( (Elf_Word)info ); - } - static int get_r_type( Elf_Xword info ) - { - return ELF32_R_TYPE( (Elf_Word)info ); - } -}; -template<> struct get_sym_and_type< Elf64_Rel > -{ - static int get_r_sym( Elf_Xword info ) - { - return ELF64_R_SYM( info ); - } - static int get_r_type( Elf_Xword info ) - { - return ELF64_R_TYPE( info ); - } -}; -template<> struct get_sym_and_type< Elf64_Rela > -{ - static int get_r_sym( Elf_Xword info ) - { - return ELF64_R_SYM( info ); - } - static int get_r_type( Elf_Xword info ) - { - return ELF64_R_TYPE( info ); - } -}; - - -//------------------------------------------------------------------------------ -template< class S > -class relocation_section_accessor_template -{ - public: -//------------------------------------------------------------------------------ - relocation_section_accessor_template( const elfio& elf_file_, S* section_ ) : - elf_file( elf_file_ ), - relocation_section( section_ ) - { - } - -//------------------------------------------------------------------------------ - Elf_Xword - get_entries_num() const - { - Elf_Xword nRet = 0; - - if ( 0 != relocation_section->get_entry_size() ) { - nRet = relocation_section->get_size() / relocation_section->get_entry_size(); - } - - return nRet; - } - -//------------------------------------------------------------------------------ - bool - get_entry( Elf_Xword index, - Elf64_Addr& offset, - Elf_Word& symbol, - Elf_Word& type, - Elf_Sxword& addend ) const - { - if ( index >= get_entries_num() ) { // Is index valid - return false; - } - - if ( elf_file.get_class() == ELFCLASS32 ) { - if ( SHT_REL == relocation_section->get_type() ) { - generic_get_entry_rel< Elf32_Rel >( index, offset, symbol, - type, addend ); - } - else if ( SHT_RELA == relocation_section->get_type() ) { - generic_get_entry_rela< Elf32_Rela >( index, offset, symbol, - type, addend ); - } - } - else { - if ( SHT_REL == relocation_section->get_type() ) { - generic_get_entry_rel< Elf64_Rel >( index, offset, symbol, - type, addend ); - } - else if ( SHT_RELA == relocation_section->get_type() ) { - generic_get_entry_rela< Elf64_Rela >( index, offset, symbol, - type, addend ); - } - } - - return true; - } - -//------------------------------------------------------------------------------ - bool - get_entry( Elf_Xword index, - Elf64_Addr& offset, - Elf64_Addr& symbolValue, - std::string& symbolName, - Elf_Word& type, - Elf_Sxword& addend, - Elf_Sxword& calcValue ) const - { - // Do regular job - Elf_Word symbol; - bool ret = get_entry( index, offset, symbol, type, addend ); - - // Find the symbol - Elf_Xword size; - unsigned char bind; - unsigned char symbolType; - Elf_Half section; - unsigned char other; - - symbol_section_accessor symbols( elf_file, elf_file.sections[get_symbol_table_index()] ); - ret = ret && symbols.get_symbol( symbol, symbolName, symbolValue, - size, bind, symbolType, section, other ); - - if ( ret ) { // Was it successful? - switch ( type ) { - case R_386_NONE: // none - calcValue = 0; - break; - case R_386_32: // S + A - calcValue = symbolValue + addend; - break; - case R_386_PC32: // S + A - P - calcValue = symbolValue + addend - offset; - break; - case R_386_GOT32: // G + A - P - calcValue = 0; - break; - case R_386_PLT32: // L + A - P - calcValue = 0; - break; - case R_386_COPY: // none - calcValue = 0; - break; - case R_386_GLOB_DAT: // S - case R_386_JMP_SLOT: // S - calcValue = symbolValue; - break; - case R_386_RELATIVE: // B + A - calcValue = addend; - break; - case R_386_GOTOFF: // S + A - GOT - calcValue = 0; - break; - case R_386_GOTPC: // GOT + A - P - calcValue = 0; - break; - default: // Not recognized symbol! - calcValue = 0; - break; - } - } - - return ret; - } - -//------------------------------------------------------------------------------ - void - add_entry( Elf64_Addr offset, Elf_Xword info ) - { - if ( elf_file.get_class() == ELFCLASS32 ) { - generic_add_entry< Elf32_Rel >( offset, info ); - } - else { - generic_add_entry< Elf64_Rel >( offset, info ); - } - } - -//------------------------------------------------------------------------------ - void - add_entry( Elf64_Addr offset, Elf_Word symbol, unsigned char type ) - { - Elf_Xword info; - if ( elf_file.get_class() == ELFCLASS32 ) { - info = ELF32_R_INFO( (Elf_Xword)symbol, type ); - } - else { - info = ELF64_R_INFO((Elf_Xword)symbol, type ); - } - - add_entry( offset, info ); - } - -//------------------------------------------------------------------------------ - void - add_entry( Elf64_Addr offset, Elf_Xword info, Elf_Sxword addend ) - { - if ( elf_file.get_class() == ELFCLASS32 ) { - generic_add_entry< Elf32_Rela >( offset, info, addend ); - } - else { - generic_add_entry< Elf64_Rela >( offset, info, addend ); - } - } - -//------------------------------------------------------------------------------ - void - add_entry( Elf64_Addr offset, Elf_Word symbol, unsigned char type, - Elf_Sxword addend ) - { - Elf_Xword info; - if ( elf_file.get_class() == ELFCLASS32 ) { - info = ELF32_R_INFO( (Elf_Xword)symbol, type ); - } - else { - info = ELF64_R_INFO( (Elf_Xword)symbol, type ); - } - - add_entry( offset, info, addend ); - } - -//------------------------------------------------------------------------------ - void - add_entry( string_section_accessor str_writer, - const char* str, - symbol_section_accessor sym_writer, - Elf64_Addr value, - Elf_Word size, - unsigned char sym_info, - unsigned char other, - Elf_Half shndx, - Elf64_Addr offset, - unsigned char type ) - { - Elf_Word str_index = str_writer.add_string( str ); - Elf_Word sym_index = sym_writer.add_symbol( str_index, value, size, - sym_info, other, shndx ); - add_entry( offset, sym_index, type ); - } - -//------------------------------------------------------------------------------ - private: -//------------------------------------------------------------------------------ - Elf_Half - get_symbol_table_index() const - { - return (Elf_Half)relocation_section->get_link(); - } - -//------------------------------------------------------------------------------ - template< class T > - void - generic_get_entry_rel( Elf_Xword index, - Elf64_Addr& offset, - Elf_Word& symbol, - Elf_Word& type, - Elf_Sxword& addend ) const - { - const endianess_convertor& convertor = elf_file.get_convertor(); - - const T* pEntry = reinterpret_cast( - relocation_section->get_data() + - index * relocation_section->get_entry_size() ); - offset = convertor( pEntry->r_offset ); - Elf_Xword tmp = convertor( pEntry->r_info ); - symbol = get_sym_and_type::get_r_sym( tmp ); - type = get_sym_and_type::get_r_type( tmp ); - addend = 0; - } - -//------------------------------------------------------------------------------ - template< class T > - void - generic_get_entry_rela( Elf_Xword index, - Elf64_Addr& offset, - Elf_Word& symbol, - Elf_Word& type, - Elf_Sxword& addend ) const - { - const endianess_convertor& convertor = elf_file.get_convertor(); - - const T* pEntry = reinterpret_cast( - relocation_section->get_data() + - index * relocation_section->get_entry_size() ); - offset = convertor( pEntry->r_offset ); - Elf_Xword tmp = convertor( pEntry->r_info ); - symbol = get_sym_and_type::get_r_sym( tmp ); - type = get_sym_and_type::get_r_type( tmp ); - addend = convertor( pEntry->r_addend ); - } - -//------------------------------------------------------------------------------ - template< class T > - void - generic_add_entry( Elf64_Addr offset, Elf_Xword info ) - { - const endianess_convertor& convertor = elf_file.get_convertor(); - - T entry; - entry.r_offset = offset; - entry.r_info = info; - entry.r_offset = convertor( entry.r_offset ); - entry.r_info = convertor( entry.r_info ); - - relocation_section->append_data( reinterpret_cast( &entry ), sizeof( entry ) ); - } - -//------------------------------------------------------------------------------ - template< class T > - void - generic_add_entry( Elf64_Addr offset, Elf_Xword info, Elf_Sxword addend ) - { - const endianess_convertor& convertor = elf_file.get_convertor(); - - T entry; - entry.r_offset = offset; - entry.r_info = info; - entry.r_addend = addend; - entry.r_offset = convertor( entry.r_offset ); - entry.r_info = convertor( entry.r_info ); - entry.r_addend = convertor( entry.r_addend ); - - relocation_section->append_data( reinterpret_cast( &entry ), sizeof( entry ) ); - } - -//------------------------------------------------------------------------------ - private: - const elfio& elf_file; - S* relocation_section; -}; - -using relocation_section_accessor = relocation_section_accessor_template
; -using const_relocation_section_accessor = relocation_section_accessor_template; - -} // namespace ELFIO - -#endif // ELFIO_RELOCATION_HPP diff --git a/ZAPDTR/lib/elfio/elfio/elfio_section.hpp b/ZAPDTR/lib/elfio/elfio/elfio_section.hpp deleted file mode 100644 index 3bfc2333c..000000000 --- a/ZAPDTR/lib/elfio/elfio/elfio_section.hpp +++ /dev/null @@ -1,314 +0,0 @@ -/* -Copyright (C) 2001-2015 by Serge Lamikhov-Center - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -*/ - -#ifndef ELFIO_SECTION_HPP -#define ELFIO_SECTION_HPP - -#include -#include - -namespace ELFIO { - -class section -{ - friend class elfio; - public: - virtual ~section() {}; - - ELFIO_GET_ACCESS_DECL ( Elf_Half, index ); - ELFIO_GET_SET_ACCESS_DECL( std::string, name ); - ELFIO_GET_SET_ACCESS_DECL( Elf_Word, type ); - ELFIO_GET_SET_ACCESS_DECL( Elf_Xword, flags ); - ELFIO_GET_SET_ACCESS_DECL( Elf_Word, info ); - ELFIO_GET_SET_ACCESS_DECL( Elf_Word, link ); - ELFIO_GET_SET_ACCESS_DECL( Elf_Xword, addr_align ); - ELFIO_GET_SET_ACCESS_DECL( Elf_Xword, entry_size ); - ELFIO_GET_SET_ACCESS_DECL( Elf64_Addr, address ); - ELFIO_GET_SET_ACCESS_DECL( Elf_Xword, size ); - ELFIO_GET_SET_ACCESS_DECL( Elf_Word, name_string_offset ); - ELFIO_GET_ACCESS_DECL ( Elf64_Off, offset ); - size_t stream_size; - size_t get_stream_size() const - { - return stream_size; - } - - void set_stream_size(size_t value) - { - stream_size = value; - } - - virtual const char* get_data() const = 0; - virtual void set_data( const char* pData, Elf_Word size ) = 0; - virtual void set_data( const std::string& data ) = 0; - virtual void append_data( const char* pData, Elf_Word size ) = 0; - virtual void append_data( const std::string& data ) = 0; - - protected: - ELFIO_SET_ACCESS_DECL( Elf64_Off, offset ); - ELFIO_SET_ACCESS_DECL( Elf_Half, index ); - - virtual void load( std::istream& stream, - std::streampos header_offset ) = 0; - virtual void save( std::ostream& stream, - std::streampos header_offset, - std::streampos data_offset ) = 0; - virtual bool is_address_initialized() const = 0; -}; - - -template< class T > -class section_impl : public section -{ - public: -//------------------------------------------------------------------------------ - section_impl( const endianess_convertor* convertor_ ) : convertor( convertor_ ) - { - std::fill_n( reinterpret_cast( &header ), sizeof( header ), '\0' ); - is_address_set = false; - data = 0; - data_size = 0; - } - -//------------------------------------------------------------------------------ - ~section_impl() - { - delete [] data; - } - -//------------------------------------------------------------------------------ - // Section info functions - ELFIO_GET_SET_ACCESS( Elf_Word, type, header.sh_type ); - ELFIO_GET_SET_ACCESS( Elf_Xword, flags, header.sh_flags ); - ELFIO_GET_SET_ACCESS( Elf_Xword, size, header.sh_size ); - ELFIO_GET_SET_ACCESS( Elf_Word, link, header.sh_link ); - ELFIO_GET_SET_ACCESS( Elf_Word, info, header.sh_info ); - ELFIO_GET_SET_ACCESS( Elf_Xword, addr_align, header.sh_addralign ); - ELFIO_GET_SET_ACCESS( Elf_Xword, entry_size, header.sh_entsize ); - ELFIO_GET_SET_ACCESS( Elf_Word, name_string_offset, header.sh_name ); - ELFIO_GET_ACCESS ( Elf64_Addr, address, header.sh_addr ); - -//------------------------------------------------------------------------------ - Elf_Half - get_index() const - { - return index; - } - - -//------------------------------------------------------------------------------ - std::string - get_name() const - { - return name; - } - -//------------------------------------------------------------------------------ - void - set_name( std::string name_ ) - { - name = name_; - } - -//------------------------------------------------------------------------------ - void - set_address( Elf64_Addr value ) - { - header.sh_addr = value; - header.sh_addr = (*convertor)( header.sh_addr ); - is_address_set = true; - } - -//------------------------------------------------------------------------------ - bool - is_address_initialized() const - { - return is_address_set; - } - -//------------------------------------------------------------------------------ - const char* - get_data() const - { - return data; - } - -//------------------------------------------------------------------------------ - void - set_data( const char* raw_data, Elf_Word size ) - { - if ( get_type() != SHT_NOBITS ) { - delete [] data; - try { - data = new char[size]; - } catch (const std::bad_alloc&) { - data = 0; - data_size = 0; - size = 0; - } - if ( 0 != data && 0 != raw_data ) { - data_size = size; - std::copy( raw_data, raw_data + size, data ); - } - } - - set_size( size ); - } - -//------------------------------------------------------------------------------ - void - set_data( const std::string& str_data ) - { - return set_data( str_data.c_str(), (Elf_Word)str_data.size() ); - } - -//------------------------------------------------------------------------------ - void - append_data( const char* raw_data, Elf_Word size ) - { - if ( get_type() != SHT_NOBITS ) { - if ( get_size() + size < data_size ) { - std::copy( raw_data, raw_data + size, data + get_size() ); - } - else { - data_size = 2*( data_size + size); - char* new_data; - try { - new_data = new char[data_size]; - } catch (const std::bad_alloc&) { - new_data = 0; - size = 0; - } - if ( 0 != new_data ) { - std::copy( data, data + get_size(), new_data ); - std::copy( raw_data, raw_data + size, new_data + get_size() ); - delete [] data; - data = new_data; - } - } - set_size( get_size() + size ); - } - } - -//------------------------------------------------------------------------------ - void - append_data( const std::string& str_data ) - { - return append_data( str_data.c_str(), (Elf_Word)str_data.size() ); - } - -//------------------------------------------------------------------------------ - protected: -//------------------------------------------------------------------------------ - ELFIO_GET_SET_ACCESS( Elf64_Off, offset, header.sh_offset ); - -//------------------------------------------------------------------------------ - void - set_index( Elf_Half value ) - { - index = value; - } - -//------------------------------------------------------------------------------ - void - load( std::istream& stream, - std::streampos header_offset ) - { - std::fill_n( reinterpret_cast( &header ), sizeof( header ), '\0' ); - - stream.seekg ( 0, stream.end ); - set_stream_size ( stream.tellg() ); - - stream.seekg( header_offset ); - stream.read( reinterpret_cast( &header ), sizeof( header ) ); - - - Elf_Xword size = get_size(); - if ( 0 == data && SHT_NULL != get_type() && SHT_NOBITS != get_type() && size < get_stream_size()) { - try { - data = new char[size + 1]; - } catch (const std::bad_alloc&) { - data = 0; - data_size = 0; - } - - if ( ( 0 != size ) && ( 0 != data ) ) { - stream.seekg( (*convertor)( header.sh_offset ) ); - stream.read( data, size ); - data[size] = 0; // Ensure data is ended with 0 to avoid oob read - data_size = size; - } - } - } - -//------------------------------------------------------------------------------ - void - save( std::ostream& stream, - std::streampos header_offset, - std::streampos data_offset ) - { - if ( 0 != get_index() ) { - header.sh_offset = data_offset; - header.sh_offset = (*convertor)( header.sh_offset ); - } - - save_header( stream, header_offset ); - if ( get_type() != SHT_NOBITS && get_type() != SHT_NULL && - get_size() != 0 && data != 0 ) { - save_data( stream, data_offset ); - } - } - -//------------------------------------------------------------------------------ - private: -//------------------------------------------------------------------------------ - void - save_header( std::ostream& stream, - std::streampos header_offset ) const - { - stream.seekp( header_offset ); - stream.write( reinterpret_cast( &header ), sizeof( header ) ); - } - -//------------------------------------------------------------------------------ - void - save_data( std::ostream& stream, - std::streampos data_offset ) const - { - stream.seekp( data_offset ); - stream.write( get_data(), get_size() ); - } - -//------------------------------------------------------------------------------ - private: - T header; - Elf_Half index; - std::string name; - char* data; - Elf_Word data_size; - const endianess_convertor* convertor; - bool is_address_set; -}; - -} // namespace ELFIO - -#endif // ELFIO_SECTION_HPP diff --git a/ZAPDTR/lib/elfio/elfio/elfio_segment.hpp b/ZAPDTR/lib/elfio/elfio/elfio_segment.hpp deleted file mode 100644 index 642fd2907..000000000 --- a/ZAPDTR/lib/elfio/elfio/elfio_segment.hpp +++ /dev/null @@ -1,246 +0,0 @@ -/* -Copyright (C) 2001-2015 by Serge Lamikhov-Center - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -*/ - -#ifndef ELFIO_SEGMENT_HPP -#define ELFIO_SEGMENT_HPP - -#include -#include - -namespace ELFIO { - -class segment -{ - friend class elfio; - public: - virtual ~segment() {}; - - ELFIO_GET_ACCESS_DECL ( Elf_Half, index ); - ELFIO_GET_SET_ACCESS_DECL( Elf_Word, type ); - ELFIO_GET_SET_ACCESS_DECL( Elf_Word, flags ); - ELFIO_GET_SET_ACCESS_DECL( Elf_Xword, align ); - ELFIO_GET_SET_ACCESS_DECL( Elf64_Addr, virtual_address ); - ELFIO_GET_SET_ACCESS_DECL( Elf64_Addr, physical_address ); - ELFIO_GET_SET_ACCESS_DECL( Elf_Xword, file_size ); - ELFIO_GET_SET_ACCESS_DECL( Elf_Xword, memory_size ); - ELFIO_GET_ACCESS_DECL( Elf64_Off, offset ); - - virtual const char* get_data() const = 0; - - virtual Elf_Half add_section_index( Elf_Half index, Elf_Xword addr_align ) = 0; - virtual Elf_Half get_sections_num() const = 0; - virtual Elf_Half get_section_index_at( Elf_Half num ) const = 0; - virtual bool is_offset_initialized() const = 0; - - protected: - ELFIO_SET_ACCESS_DECL( Elf64_Off, offset ); - ELFIO_SET_ACCESS_DECL( Elf_Half, index ); - - virtual const std::vector& get_sections() const = 0; - virtual void load( std::istream& stream, std::streampos header_offset ) = 0; - virtual void save( std::ostream& stream, std::streampos header_offset, - std::streampos data_offset ) = 0; -}; - - -//------------------------------------------------------------------------------ -template< class T > -class segment_impl : public segment -{ - public: -//------------------------------------------------------------------------------ - segment_impl( endianess_convertor* convertor_ ) : - stream_size( 0 ), index( 0 ), data( 0 ), convertor( convertor_ ) - { - is_offset_set = false; - std::fill_n( reinterpret_cast( &ph ), sizeof( ph ), '\0' ); - } - -//------------------------------------------------------------------------------ - virtual ~segment_impl() - { - delete [] data; - } - -//------------------------------------------------------------------------------ - // Section info functions - ELFIO_GET_SET_ACCESS( Elf_Word, type, ph.p_type ); - ELFIO_GET_SET_ACCESS( Elf_Word, flags, ph.p_flags ); - ELFIO_GET_SET_ACCESS( Elf_Xword, align, ph.p_align ); - ELFIO_GET_SET_ACCESS( Elf64_Addr, virtual_address, ph.p_vaddr ); - ELFIO_GET_SET_ACCESS( Elf64_Addr, physical_address, ph.p_paddr ); - ELFIO_GET_SET_ACCESS( Elf_Xword, file_size, ph.p_filesz ); - ELFIO_GET_SET_ACCESS( Elf_Xword, memory_size, ph.p_memsz ); - ELFIO_GET_ACCESS( Elf64_Off, offset, ph.p_offset ); - size_t stream_size; - -//------------------------------------------------------------------------------ - size_t - get_stream_size() const - { - return stream_size; - } - -//------------------------------------------------------------------------------ - void - set_stream_size(size_t value) - { - stream_size = value; - } - -//------------------------------------------------------------------------------ - Elf_Half - get_index() const - { - return index; - } - -//------------------------------------------------------------------------------ - const char* - get_data() const - { - return data; - } - -//------------------------------------------------------------------------------ - Elf_Half - add_section_index( Elf_Half sec_index, Elf_Xword addr_align ) - { - sections.push_back( sec_index ); - if ( addr_align > get_align() ) { - set_align( addr_align ); - } - - return (Elf_Half)sections.size(); - } - -//------------------------------------------------------------------------------ - Elf_Half - get_sections_num() const - { - return (Elf_Half)sections.size(); - } - -//------------------------------------------------------------------------------ - Elf_Half - get_section_index_at( Elf_Half num ) const - { - if ( num < sections.size() ) { - return sections[num]; - } - - return Elf_Half(-1); - } - -//------------------------------------------------------------------------------ - protected: -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ - void - set_offset( Elf64_Off value ) - { - ph.p_offset = value; - ph.p_offset = (*convertor)( ph.p_offset ); - is_offset_set = true; - } - -//------------------------------------------------------------------------------ - bool - is_offset_initialized() const - { - return is_offset_set; - } - -//------------------------------------------------------------------------------ - const std::vector& - get_sections() const - { - return sections; - } - -//------------------------------------------------------------------------------ - void - set_index( Elf_Half value ) - { - index = value; - } - -//------------------------------------------------------------------------------ - void - load( std::istream& stream, - std::streampos header_offset ) - { - - stream.seekg ( 0, stream.end ); - set_stream_size ( stream.tellg() ); - - stream.seekg( header_offset ); - stream.read( reinterpret_cast( &ph ), sizeof( ph ) ); - is_offset_set = true; - - if ( PT_NULL != get_type() && 0 != get_file_size() ) { - stream.seekg( (*convertor)( ph.p_offset ) ); - Elf_Xword size = get_file_size(); - - if ( size > get_stream_size() ) { - data = 0; - } - else { - try { - data = new char[size + 1]; - } catch (const std::bad_alloc&) { - data = 0; - } - - if ( 0 != data ) { - stream.read( data, size ); - data[size] = 0; - } - } - } - } - -//------------------------------------------------------------------------------ - void save( std::ostream& stream, - std::streampos header_offset, - std::streampos data_offset ) - { - ph.p_offset = data_offset; - ph.p_offset = (*convertor)(ph.p_offset); - stream.seekp( header_offset ); - stream.write( reinterpret_cast( &ph ), sizeof( ph ) ); - } - -//------------------------------------------------------------------------------ - private: - T ph; - Elf_Half index; - char* data; - std::vector sections; - endianess_convertor* convertor; - bool is_offset_set; -}; - -} // namespace ELFIO - -#endif // ELFIO_SEGMENT_HPP diff --git a/ZAPDTR/lib/elfio/elfio/elfio_strings.hpp b/ZAPDTR/lib/elfio/elfio/elfio_strings.hpp deleted file mode 100644 index 552f00029..000000000 --- a/ZAPDTR/lib/elfio/elfio/elfio_strings.hpp +++ /dev/null @@ -1,100 +0,0 @@ -/* -Copyright (C) 2001-2015 by Serge Lamikhov-Center - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -*/ - -#ifndef ELFIO_STRINGS_HPP -#define ELFIO_STRINGS_HPP - -#include -#include -#include - -namespace ELFIO { - -//------------------------------------------------------------------------------ -template< class S > -class string_section_accessor_template -{ - public: -//------------------------------------------------------------------------------ - string_section_accessor_template( S* section_ ) : - string_section( section_ ) - { - } - - -//------------------------------------------------------------------------------ - const char* - get_string( Elf_Word index ) const - { - if ( string_section ) { - if ( index < string_section->get_size() ) { - const char* data = string_section->get_data(); - if ( 0 != data ) { - return data + index; - } - } - } - - return 0; - } - - -//------------------------------------------------------------------------------ - Elf_Word - add_string( const char* str ) - { - Elf_Word current_position = 0; - - if (string_section) { - // Strings are addeded to the end of the current section data - current_position = (Elf_Word)string_section->get_size(); - - if ( current_position == 0 ) { - char empty_string = '\0'; - string_section->append_data( &empty_string, 1 ); - current_position++; - } - string_section->append_data( str, (Elf_Word)std::strlen( str ) + 1 ); - } - - return current_position; - } - - -//------------------------------------------------------------------------------ - Elf_Word - add_string( const std::string& str ) - { - return add_string( str.c_str() ); - } - -//------------------------------------------------------------------------------ - private: - S* string_section; -}; - -using string_section_accessor = string_section_accessor_template
; -using const_string_section_accessor = string_section_accessor_template; - -} // namespace ELFIO - -#endif // ELFIO_STRINGS_HPP diff --git a/ZAPDTR/lib/elfio/elfio/elfio_symbols.hpp b/ZAPDTR/lib/elfio/elfio/elfio_symbols.hpp deleted file mode 100644 index d18756a9a..000000000 --- a/ZAPDTR/lib/elfio/elfio/elfio_symbols.hpp +++ /dev/null @@ -1,282 +0,0 @@ -/* -Copyright (C) 2001-2015 by Serge Lamikhov-Center - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -*/ - -#ifndef ELFIO_SYMBOLS_HPP -#define ELFIO_SYMBOLS_HPP - -namespace ELFIO { - -//------------------------------------------------------------------------------ -template< class S > -class symbol_section_accessor_template -{ - public: -//------------------------------------------------------------------------------ - symbol_section_accessor_template( const elfio& elf_file_, S* symbol_section_ ) : - elf_file( elf_file_ ), - symbol_section( symbol_section_ ) - { - find_hash_section(); - } - -//------------------------------------------------------------------------------ - Elf_Xword - get_symbols_num() const - { - Elf_Xword nRet = 0; - if ( 0 != symbol_section->get_entry_size() ) { - nRet = symbol_section->get_size() / symbol_section->get_entry_size(); - } - - return nRet; - } - -//------------------------------------------------------------------------------ - bool - get_symbol( Elf_Xword index, - std::string& name, - Elf64_Addr& value, - Elf_Xword& size, - unsigned char& bind, - unsigned char& type, - Elf_Half& section_index, - unsigned char& other ) const - { - bool ret = false; - - if ( elf_file.get_class() == ELFCLASS32 ) { - ret = generic_get_symbol( index, name, value, size, bind, - type, section_index, other ); - } - else { - ret = generic_get_symbol( index, name, value, size, bind, - type, section_index, other ); - } - - return ret; - } - -//------------------------------------------------------------------------------ - bool - get_symbol( const std::string& name, - Elf64_Addr& value, - Elf_Xword& size, - unsigned char& bind, - unsigned char& type, - Elf_Half& section_index, - unsigned char& other ) const - { - bool ret = false; - - if ( 0 != get_hash_table_index() ) { - Elf_Word nbucket = *(const Elf_Word*)hash_section->get_data(); - Elf_Word nchain = *(const Elf_Word*)( hash_section->get_data() + - sizeof( Elf_Word ) ); - Elf_Word val = elf_hash( (const unsigned char*)name.c_str() ); - - Elf_Word y = *(const Elf_Word*)( hash_section->get_data() + - ( 2 + val % nbucket ) * sizeof( Elf_Word ) ); - std::string str; - get_symbol( y, str, value, size, bind, type, section_index, other ); - while ( str != name && STN_UNDEF != y && y < nchain ) { - y = *(const Elf_Word*)( hash_section->get_data() + - ( 2 + nbucket + y ) * sizeof( Elf_Word ) ); - get_symbol( y, str, value, size, bind, type, section_index, other ); - } - if ( str == name ) { - ret = true; - } - } - - return ret; - } - -//------------------------------------------------------------------------------ - Elf_Word - add_symbol( Elf_Word name, Elf64_Addr value, Elf_Xword size, - unsigned char info, unsigned char other, - Elf_Half shndx ) - { - Elf_Word nRet; - - if ( symbol_section->get_size() == 0 ) { - if ( elf_file.get_class() == ELFCLASS32 ) { - nRet = generic_add_symbol( 0, 0, 0, 0, 0, 0 ); - } - else { - nRet = generic_add_symbol( 0, 0, 0, 0, 0, 0 ); - } - } - - if ( elf_file.get_class() == ELFCLASS32 ) { - nRet = generic_add_symbol( name, value, size, info, other, - shndx ); - } - else { - nRet = generic_add_symbol( name, value, size, info, other, - shndx ); - } - - return nRet; - } - -//------------------------------------------------------------------------------ - Elf_Word - add_symbol( Elf_Word name, Elf64_Addr value, Elf_Xword size, - unsigned char bind, unsigned char type, unsigned char other, - Elf_Half shndx ) - { - return add_symbol( name, value, size, ELF_ST_INFO( bind, type ), other, shndx ); - } - -//------------------------------------------------------------------------------ - Elf_Word - add_symbol( string_section_accessor& pStrWriter, const char* str, - Elf64_Addr value, Elf_Xword size, - unsigned char info, unsigned char other, - Elf_Half shndx ) - { - Elf_Word index = pStrWriter.add_string( str ); - return add_symbol( index, value, size, info, other, shndx ); - } - -//------------------------------------------------------------------------------ - Elf_Word - add_symbol( string_section_accessor& pStrWriter, const char* str, - Elf64_Addr value, Elf_Xword size, - unsigned char bind, unsigned char type, unsigned char other, - Elf_Half shndx ) - { - return add_symbol( pStrWriter, str, value, size, ELF_ST_INFO( bind, type ), other, shndx ); - } - -//------------------------------------------------------------------------------ - private: -//------------------------------------------------------------------------------ - void - find_hash_section() - { - hash_section = 0; - hash_section_index = 0; - Elf_Half nSecNo = elf_file.sections.size(); - for ( Elf_Half i = 0; i < nSecNo && 0 == hash_section_index; ++i ) { - const section* sec = elf_file.sections[i]; - if ( sec->get_link() == symbol_section->get_index() ) { - hash_section = sec; - hash_section_index = i; - } - } - } - -//------------------------------------------------------------------------------ - Elf_Half - get_string_table_index() const - { - return (Elf_Half)symbol_section->get_link(); - } - -//------------------------------------------------------------------------------ - Elf_Half - get_hash_table_index() const - { - return hash_section_index; - } - -//------------------------------------------------------------------------------ - template< class T > - bool - generic_get_symbol( Elf_Xword index, - std::string& name, Elf64_Addr& value, - Elf_Xword& size, - unsigned char& bind, unsigned char& type, - Elf_Half& section_index, - unsigned char& other ) const - { - bool ret = false; - - if ( index < get_symbols_num() ) { - const T* pSym = reinterpret_cast( - symbol_section->get_data() + - index * symbol_section->get_entry_size() ); - - const endianess_convertor& convertor = elf_file.get_convertor(); - - section* string_section = elf_file.sections[get_string_table_index()]; - string_section_accessor str_reader( string_section ); - const char* pStr = str_reader.get_string( convertor( pSym->st_name ) ); - if ( 0 != pStr ) { - name = pStr; - } - value = convertor( pSym->st_value ); - size = convertor( pSym->st_size ); - bind = ELF_ST_BIND( pSym->st_info ); - type = ELF_ST_TYPE( pSym->st_info ); - section_index = convertor( pSym->st_shndx ); - other = pSym->st_other; - - ret = true; - } - - return ret; - } - -//------------------------------------------------------------------------------ - template< class T > - Elf_Word - generic_add_symbol( Elf_Word name, Elf64_Addr value, Elf_Xword size, - unsigned char info, unsigned char other, - Elf_Half shndx ) - { - const endianess_convertor& convertor = elf_file.get_convertor(); - - T entry; - entry.st_name = convertor( name ); - entry.st_value = value; - entry.st_value = convertor( entry.st_value ); - entry.st_size = size; - entry.st_size = convertor( entry.st_size ); - entry.st_info = convertor( info ); - entry.st_other = convertor( other ); - entry.st_shndx = convertor( shndx ); - - symbol_section->append_data( reinterpret_cast( &entry ), - sizeof( entry ) ); - - Elf_Word nRet = symbol_section->get_size() / sizeof( entry ) - 1; - - return nRet; - } - -//------------------------------------------------------------------------------ - private: - const elfio& elf_file; - S* symbol_section; - Elf_Half hash_section_index; - const section* hash_section; -}; - -using symbol_section_accessor = symbol_section_accessor_template
; -using const_symbol_section_accessor = symbol_section_accessor_template; - -} // namespace ELFIO - -#endif // ELFIO_SYMBOLS_HPP diff --git a/ZAPDTR/lib/elfio/elfio/elfio_utils.hpp b/ZAPDTR/lib/elfio/elfio/elfio_utils.hpp deleted file mode 100644 index 2baf5a77c..000000000 --- a/ZAPDTR/lib/elfio/elfio/elfio_utils.hpp +++ /dev/null @@ -1,209 +0,0 @@ -/* -Copyright (C) 2001-2015 by Serge Lamikhov-Center - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -*/ - -#ifndef ELFIO_UTILS_HPP -#define ELFIO_UTILS_HPP - -#define ELFIO_GET_ACCESS( TYPE, NAME, FIELD ) \ - TYPE get_##NAME() const \ - { \ - return (*convertor)( FIELD ); \ - } -#define ELFIO_SET_ACCESS( TYPE, NAME, FIELD ) \ - void set_##NAME( TYPE value ) \ - { \ - FIELD = value; \ - FIELD = (*convertor)( FIELD ); \ - } -#define ELFIO_GET_SET_ACCESS( TYPE, NAME, FIELD ) \ - TYPE get_##NAME() const \ - { \ - return (*convertor)( FIELD ); \ - } \ - void set_##NAME( TYPE value ) \ - { \ - FIELD = value; \ - FIELD = (*convertor)( FIELD ); \ - } - -#define ELFIO_GET_ACCESS_DECL( TYPE, NAME ) \ - virtual TYPE get_##NAME() const = 0 - -#define ELFIO_SET_ACCESS_DECL( TYPE, NAME ) \ - virtual void set_##NAME( TYPE value ) = 0 - -#define ELFIO_GET_SET_ACCESS_DECL( TYPE, NAME ) \ - virtual TYPE get_##NAME() const = 0; \ - virtual void set_##NAME( TYPE value ) = 0 - -namespace ELFIO { - -//------------------------------------------------------------------------------ -class endianess_convertor { - public: -//------------------------------------------------------------------------------ - endianess_convertor() - { - need_conversion = false; - } - -//------------------------------------------------------------------------------ - void - setup( unsigned char elf_file_encoding ) - { - need_conversion = ( elf_file_encoding != get_host_encoding() ); - } - -//------------------------------------------------------------------------------ - uint64_t - operator()( uint64_t value ) const - { - if ( !need_conversion ) { - return value; - } - value = - ( ( value & 0x00000000000000FFull ) << 56 ) | - ( ( value & 0x000000000000FF00ull ) << 40 ) | - ( ( value & 0x0000000000FF0000ull ) << 24 ) | - ( ( value & 0x00000000FF000000ull ) << 8 ) | - ( ( value & 0x000000FF00000000ull ) >> 8 ) | - ( ( value & 0x0000FF0000000000ull ) >> 24 ) | - ( ( value & 0x00FF000000000000ull ) >> 40 ) | - ( ( value & 0xFF00000000000000ull ) >> 56 ); - - return value; - } - -//------------------------------------------------------------------------------ - int64_t - operator()( int64_t value ) const - { - if ( !need_conversion ) { - return value; - } - return (int64_t)(*this)( (uint64_t)value ); - } - -//------------------------------------------------------------------------------ - uint32_t - operator()( uint32_t value ) const - { - if ( !need_conversion ) { - return value; - } - value = - ( ( value & 0x000000FF ) << 24 ) | - ( ( value & 0x0000FF00 ) << 8 ) | - ( ( value & 0x00FF0000 ) >> 8 ) | - ( ( value & 0xFF000000 ) >> 24 ); - - return value; - } - -//------------------------------------------------------------------------------ - int32_t - operator()( int32_t value ) const - { - if ( !need_conversion ) { - return value; - } - return (int32_t)(*this)( (uint32_t)value ); - } - -//------------------------------------------------------------------------------ - uint16_t - operator()( uint16_t value ) const - { - if ( !need_conversion ) { - return value; - } - value = - ( ( value & 0x00FF ) << 8 ) | - ( ( value & 0xFF00 ) >> 8 ); - - return value; - } - -//------------------------------------------------------------------------------ - int16_t - operator()( int16_t value ) const - { - if ( !need_conversion ) { - return value; - } - return (int16_t)(*this)( (uint16_t)value ); - } - -//------------------------------------------------------------------------------ - int8_t - operator()( int8_t value ) const - { - return value; - } - -//------------------------------------------------------------------------------ - uint8_t - operator()( uint8_t value ) const - { - return value; - } - -//------------------------------------------------------------------------------ - private: -//------------------------------------------------------------------------------ - unsigned char - get_host_encoding() const - { - static const int tmp = 1; - if ( 1 == *(const char*)&tmp ) { - return ELFDATA2LSB; - } - else { - return ELFDATA2MSB; - } - } - -//------------------------------------------------------------------------------ - private: - bool need_conversion; -}; - - -//------------------------------------------------------------------------------ -inline -uint32_t -elf_hash( const unsigned char *name ) -{ - uint32_t h = 0, g; - while ( *name ) { - h = (h << 4) + *name++; - g = h & 0xf0000000; - if ( g != 0 ) - h ^= g >> 24; - h &= ~g; - } - return h; -} - -} // namespace ELFIO - -#endif // ELFIO_UTILS_HPP diff --git a/libultraship b/libultraship index f9e554dc2..57660fbb1 160000 --- a/libultraship +++ b/libultraship @@ -1 +1 @@ -Subproject commit f9e554dc214c2f23cfc74a26348ef9fd3055451b +Subproject commit 57660fbb186d85923a1f771bfaafe241c209e579 diff --git a/soh/include/z64.h b/soh/include/z64.h index 09332cd94..7fa24a1b6 100644 --- a/soh/include/z64.h +++ b/soh/include/z64.h @@ -39,7 +39,7 @@ #define SYSTEM_HEAP_SIZE (1024 * 1024 * 4) #ifdef __cplusplus -namespace Ship +namespace LUS { class Resource; class Scene; diff --git a/soh/soh/Enhancements/audio/AudioCollection.cpp b/soh/soh/Enhancements/audio/AudioCollection.cpp index b59385f8a..289abc256 100644 --- a/soh/soh/Enhancements/audio/AudioCollection.cpp +++ b/soh/soh/Enhancements/audio/AudioCollection.cpp @@ -229,7 +229,7 @@ void AudioCollection::RemoveFromShufflePool(SequenceInfo* seqInfo) { excludedSequences.insert(seqInfo); includedSequences.erase(seqInfo); CVarSetInteger(cvarKey.c_str(), 1); - Ship::RequestCvarSaveOnNextTick(); + LUS::RequestCvarSaveOnNextTick(); } void AudioCollection::AddToShufflePool(SequenceInfo* seqInfo) { @@ -237,7 +237,7 @@ void AudioCollection::AddToShufflePool(SequenceInfo* seqInfo) { includedSequences.insert(seqInfo); excludedSequences.erase(seqInfo); CVarClear(cvarKey.c_str()); - Ship::RequestCvarSaveOnNextTick(); + LUS::RequestCvarSaveOnNextTick(); } void AudioCollection::InitializeShufflePool() { diff --git a/soh/soh/Enhancements/audio/AudioEditor.cpp b/soh/soh/Enhancements/audio/AudioEditor.cpp index d6bf71d19..40f680ab9 100644 --- a/soh/soh/Enhancements/audio/AudioEditor.cpp +++ b/soh/soh/Enhancements/audio/AudioEditor.cpp @@ -158,7 +158,7 @@ void Draw_SfxTab(const std::string& tabId, SeqType type) { const std::string randomizeAllButton = "Randomize All" + hiddenTabId; if (ImGui::Button(resetAllButton.c_str())) { ResetGroup(map, type); - Ship::RequestCvarSaveOnNextTick(); + LUS::RequestCvarSaveOnNextTick(); if (type == SEQ_BGM_WORLD) { ReplayCurrentBGM(); } @@ -166,7 +166,7 @@ void Draw_SfxTab(const std::string& tabId, SeqType type) { ImGui::SameLine(); if (ImGui::Button(randomizeAllButton.c_str())) { RandomizeGroup(type); - Ship::RequestCvarSaveOnNextTick(); + LUS::RequestCvarSaveOnNextTick(); if (type == SEQ_BGM_WORLD) { ReplayCurrentBGM(); } @@ -205,7 +205,7 @@ void Draw_SfxTab(const std::string& tabId, SeqType type) { if (ImGui::Selectable(seqData.label.c_str())) { CVarSetInteger(cvarKey.c_str(), value); - Ship::RequestCvarSaveOnNextTick(); + LUS::RequestCvarSaveOnNextTick(); UpdateCurrentBGM(defaultValue, type); } } @@ -219,7 +219,7 @@ void Draw_SfxTab(const std::string& tabId, SeqType type) { ImGui::PushItemWidth(-FLT_MIN); if (ImGui::Button(resetButton.c_str())) { CVarSetInteger(cvarKey.c_str(), defaultValue); - Ship::RequestCvarSaveOnNextTick(); + LUS::RequestCvarSaveOnNextTick(); UpdateCurrentBGM(defaultValue, seqData.category); } ImGui::SameLine(); @@ -236,7 +236,7 @@ void Draw_SfxTab(const std::string& tabId, SeqType type) { auto it = validSequences.begin(); const auto& seqData = *std::next(it, rand() % validSequences.size()); CVarSetInteger(cvarKey.c_str(), seqData->sequenceId); - Ship::RequestCvarSaveOnNextTick(); + LUS::RequestCvarSaveOnNextTick(); UpdateCurrentBGM(seqData->sequenceId, type); } } @@ -308,7 +308,10 @@ void DrawTypeChip(SeqType type) { void DrawSfxEditor(bool& open) { if (!open) { - CVarSetInteger("gAudioEditor.WindowOpen", 0); + if (CVarGetInteger("gAudioEditor.WindowOpen", 0)) { + CVarClear("gAudioEditor.WindowOpen"); + LUS::RequestCvarSaveOnNextTick(); + } return; } @@ -378,7 +381,7 @@ void DrawSfxEditor(bool& open) { const std::string resetButton = "Reset##linkVoiceFreqMultiplier"; if (ImGui::Button(resetButton.c_str())) { CVarSetFloat("gLinkVoiceFreqMultiplier", 1.0f); - Ship::RequestCvarSaveOnNextTick(); + LUS::RequestCvarSaveOnNextTick(); } ImGui::NewLine(); @@ -552,7 +555,7 @@ void DrawSfxEditor(bool& open) { void InitAudioEditor() { //Draw the bar in the menu. - Ship::AddWindow("Enhancements", "Audio Editor", DrawSfxEditor); + LUS::AddWindow("Enhancements", "Audio Editor", DrawSfxEditor, CVarGetInteger("gAudioEditor.WindowOpen", 0)); } std::vector allTypes = { SEQ_BGM_WORLD, SEQ_BGM_EVENT, SEQ_BGM_BATTLE, SEQ_OCARINA, SEQ_FANFARE, SEQ_INSTRUMENT, SEQ_SFX }; @@ -562,7 +565,7 @@ void AudioEditor_RandomizeAll() { RandomizeGroup(type); } - Ship::RequestCvarSaveOnNextTick(); + LUS::RequestCvarSaveOnNextTick(); ReplayCurrentBGM(); } @@ -571,6 +574,6 @@ void AudioEditor_ResetAll() { ResetGroup(AudioCollection::Instance->GetAllSequences(), type); } - Ship::RequestCvarSaveOnNextTick(); + LUS::RequestCvarSaveOnNextTick(); ReplayCurrentBGM(); } diff --git a/soh/soh/Enhancements/bootcommands.c b/soh/soh/Enhancements/bootcommands.c index 679e61488..99dc4b492 100644 --- a/soh/soh/Enhancements/bootcommands.c +++ b/soh/soh/Enhancements/bootcommands.c @@ -20,13 +20,10 @@ static BootCommand sCommands[] = { { "--skiplogo", BootCommands_Command_SkipLogo void BootCommands_Init() { - CVarRegisterInteger("gDebugEnabled", 0); - CVarRegisterInteger("gLanguages", LANGUAGE_ENG); - CVarRegisterInteger("gDebugWarpScreenTranslation", 1); - CVarRegisterInteger("gInvertYAxis", 1); // Clears vars to prevent randomizer menu from being disabled - CVarSetInteger("gRandoGenerating", 0); // Clear when a crash happened during rando seed generation - CVarSetInteger("gOnFileSelectNameEntry", 0); // Clear when soh is killed on the file name entry page + CVarClear("gRandoGenerating"); // Clear when a crash happened during rando seed generation + CVarClear("gNewSeedGenerated"); + CVarClear("gOnFileSelectNameEntry"); // Clear when soh is killed on the file name entry page #if defined(__SWITCH__) || defined(__WIIU__) CVarRegisterInteger("gControlNav", 1); // always enable controller nav on switch/wii u #endif diff --git a/soh/soh/Enhancements/controls/GameControlEditor.cpp b/soh/soh/Enhancements/controls/GameControlEditor.cpp index d8780353e..719edaf0e 100644 --- a/soh/soh/Enhancements/controls/GameControlEditor.cpp +++ b/soh/soh/Enhancements/controls/GameControlEditor.cpp @@ -88,7 +88,7 @@ namespace GameControlEditor { void DrawUI(bool&); void Init() { - Ship::AddWindow("Enhancements", "Game Control Editor", DrawUI); + LUS::AddWindow("Enhancements", "Game Control Editor", DrawUI, CVarGetInteger("gGameControlEditorEnabled", 0)); addButtonName(BTN_A, "A"); addButtonName(BTN_B, "B"); @@ -136,7 +136,7 @@ namespace GameControlEditor { } if (ImGui::Selectable(i->second, i->first == currentButton)) { CVarSetInteger(mapping.cVarName, i->first); - Ship::RequestCvarSaveOnNextTick(); + LUS::RequestCvarSaveOnNextTick(); } } ImGui::EndCombo(); @@ -172,7 +172,7 @@ namespace GameControlEditor { ImGui::TableSetupColumn("Modifiers##CustomOcaranaModifiers", PANEL_TABLE_COLUMN_FLAGS); TableHelper::InitHeader(false); - Ship::BeginGroupPanel("Notes", ImGui::GetContentRegionAvail()); + LUS::BeginGroupPanel("Notes", ImGui::GetContentRegionAvail()); labelWidth = ImGui::CalcTextSize("D5").x + 10; DrawMapping(ocarinaD5, labelWidth, disableMask); DrawMapping(ocarinaB4, labelWidth, disableMask); @@ -181,16 +181,16 @@ namespace GameControlEditor { DrawMapping(ocarinaD4, labelWidth, disableMask); ImGui::Dummy(ImVec2(0, 5)); float cursorY = ImGui::GetCursorPosY(); - Ship::EndGroupPanel(); + LUS::EndGroupPanel(); TableHelper::NextCol(); - Ship::BeginGroupPanel("Modifiers", ImGui::GetContentRegionAvail()); + LUS::BeginGroupPanel("Modifiers", ImGui::GetContentRegionAvail()); labelWidth = ImGui::CalcTextSize(ocarinaSongDisable.label).x + 10; DrawMapping(ocarinaSongDisable, labelWidth, disableMask); DrawMapping(ocarinaSharp, labelWidth, disableMask); DrawMapping(ocarinaFlat, labelWidth, disableMask); - Ship::EndGroupPanel(cursorY - ImGui::GetCursorPosY() + 2); + LUS::EndGroupPanel(cursorY - ImGui::GetCursorPosY() + 2); ImGui::EndTable(); } @@ -201,7 +201,7 @@ namespace GameControlEditor { UIWidgets::Spacer(0); } - Ship::BeginGroupPanel("Alternate controls", ImGui::GetContentRegionAvail()); + LUS::BeginGroupPanel("Alternate controls", ImGui::GetContentRegionAvail()); if (ImGui::BeginTable("tableOcarinaAlternateControls", 2, ImGuiTableFlags_SizingFixedSame)) { ImGui::TableSetupColumn("D-pad", PANEL_TABLE_COLUMN_FLAGS); ImGui::TableSetupColumn("Right stick", PANEL_TABLE_COLUMN_FLAGS); @@ -213,7 +213,7 @@ namespace GameControlEditor { UIWidgets::Spacer(0); ImGui::EndTable(); } - Ship::EndGroupPanel(); + LUS::EndGroupPanel(); ImGui::EndTable(); } @@ -221,10 +221,10 @@ namespace GameControlEditor { // CurrentPort is indexed started at 1 here due to the Generic tab, instead of 0 like in InputEditor // Therefore CurrentPort - 1 must always be used inside this function instead of CurrentPort void DrawCustomButtons() { - Ship::GetInputEditor()->DrawControllerSelect(CurrentPort - 1); + LUS::GetInputEditor()->DrawControllerSelect(CurrentPort - 1); - Ship::GetInputEditor()->DrawButton("Modifier 1", BTN_MODIFIER1, CurrentPort - 1, &BtnReading); - Ship::GetInputEditor()->DrawButton("Modifier 2", BTN_MODIFIER2, CurrentPort - 1, &BtnReading); + LUS::GetInputEditor()->DrawButton("Modifier 1", BTN_MODIFIER1, CurrentPort - 1, &BtnReading); + LUS::GetInputEditor()->DrawButton("Modifier 2", BTN_MODIFIER2, CurrentPort - 1, &BtnReading); } void DrawCameraControlPanel() { @@ -233,7 +233,7 @@ namespace GameControlEditor { } UIWidgets::Spacer(0); - Ship::BeginGroupPanel("Aiming/First-Person Camera", ImGui::GetContentRegionAvail()); + LUS::BeginGroupPanel("Aiming/First-Person Camera", ImGui::GetContentRegionAvail()); UIWidgets::PaddedEnhancementCheckbox("Right Stick Aiming", "gRightStickAiming"); DrawHelpIcon("Allows for aiming with the right stick in:\n-First-Person/C-Up view\n-Weapon Aiming"); UIWidgets::PaddedEnhancementCheckbox("Invert Aiming X Axis", "gInvertAimingXAxis"); @@ -242,27 +242,29 @@ namespace GameControlEditor { DrawHelpIcon("Inverts the Camera Y Axis in:\n-First-Person/C-Up view\n-Weapon Aiming"); UIWidgets::PaddedEnhancementCheckbox("Disable Auto-Centering in First-Person View", "gDisableAutoCenterViewFirstPerson"); DrawHelpIcon("Prevents the C-Up view from auto-centering, allowing for Gyro Aiming"); - UIWidgets::PaddedEnhancementCheckbox("Enable Custom Aiming/First-Person sensitivity", "gEnableFirstPersonSensitivity", true, false); + if (UIWidgets::PaddedEnhancementCheckbox("Enable Custom Aiming/First-Person sensitivity", "gEnableFirstPersonSensitivity", true, false)) { + if (!CVarGetInteger("gEnableFirstPersonSensitivity", 0)) { + CVarClear("gFirstPersonCameraSensitivity"); + } + } if (CVarGetInteger("gEnableFirstPersonSensitivity", 0)) { UIWidgets::EnhancementSliderFloat("Aiming/First-Person Horizontal Sensitivity: %d %%", "##FirstPersonSensitivity Horizontal", "gFirstPersonCameraSensitivityX", 0.01f, 5.0f, "", 1.0f, true); UIWidgets::EnhancementSliderFloat("Aiming/First-Person Vertical Sensitivity: %d %%", "##FirstPersonSensitivity Vertical", "gFirstPersonCameraSensitivityY", 0.01f, 5.0f, "", 1.0f, true); - } else { - CVarSetFloat("gFirstPersonCameraSensitivity", 1.0f); } UIWidgets::Spacer(0); - Ship::EndGroupPanel(); + LUS::EndGroupPanel(); UIWidgets::Spacer(0); - Ship::BeginGroupPanel("Third-Person Camera", ImGui::GetContentRegionAvail()); + LUS::BeginGroupPanel("Third-Person Camera", ImGui::GetContentRegionAvail()); UIWidgets::PaddedEnhancementCheckbox("Free Camera", "gFreeCamera"); DrawHelpIcon("Enables free camera control\nNote: You must remap C buttons off of the right stick in the " "controller config menu, and map the camera stick to the right stick."); UIWidgets::PaddedEnhancementCheckbox("Invert Camera X Axis", "gInvertXAxis"); DrawHelpIcon("Inverts the Camera X Axis in:\n-Free camera"); - UIWidgets::PaddedEnhancementCheckbox("Invert Camera Y Axis", "gInvertYAxis"); + UIWidgets::PaddedEnhancementCheckbox("Invert Camera Y Axis", "gInvertYAxis", true, true, false, "", UIWidgets::CheckboxGraphics::Cross, true); DrawHelpIcon("Inverts the Camera Y Axis in:\n-Free camera"); UIWidgets::Spacer(0); + UIWidgets::PaddedEnhancementSliderFloat("Third-Person Horizontal Sensitivity: %d %%", "##ThirdPersonSensitivity Horizontal", @@ -273,7 +275,7 @@ namespace GameControlEditor { "gFreeCameraDistMax", 100, 900, "", 185, true, false, true); UIWidgets::PaddedEnhancementSliderInt("Camera Transition Speed: %d", "##CamTranSpeed", "gFreeCameraTransitionSpeed", 0, 900, "", 25, true, false, true); - Ship::EndGroupPanel(); + LUS::EndGroupPanel(); } void DrawDpadControlPanel() { @@ -283,7 +285,7 @@ namespace GameControlEditor { ImVec2 cursor = ImGui::GetCursorPos(); ImGui::SetCursorPos(ImVec2(cursor.x + 5, cursor.y + 5)); - Ship::BeginGroupPanel("D-Pad Options", ImGui::GetContentRegionAvail()); + LUS::BeginGroupPanel("D-Pad Options", ImGui::GetContentRegionAvail()); UIWidgets::PaddedEnhancementCheckbox("D-pad Support on Pause Screen", "gDpadPause"); DrawHelpIcon("Navigate Pause with the D-pad\nIf used with D-pad as Equip Items, you must hold C-Up to equip instead of navigate\n" "To make the cursor only move a single space no matter how long a direction is held, manually set gDpadHoldChange to 0"); @@ -292,7 +294,7 @@ namespace GameControlEditor { "To make the cursor only move a single space during name entry no matter how long a direction is held, manually set gDpadHoldChange to 0"); UIWidgets::PaddedEnhancementCheckbox("D-pad as Equip Items", "gDpadEquips"); DrawHelpIcon("Equip items and equipment on the D-pad\nIf used with D-pad on Pause Screen, you must hold C-Up to equip instead of navigate"); - Ship::EndGroupPanel(); + LUS::EndGroupPanel(); } void DrawMiscControlPanel() { @@ -302,7 +304,7 @@ namespace GameControlEditor { ImVec2 cursor = ImGui::GetCursorPos(); ImGui::SetCursorPos(ImVec2(cursor.x + 5, cursor.y + 5)); - Ship::BeginGroupPanel("Misc Controls", ImGui::GetContentRegionAvail()); + LUS::BeginGroupPanel("Misc Controls", ImGui::GetContentRegionAvail()); UIWidgets::PaddedText("Allow the cursor to be on any slot"); static const char* cursorOnAnySlot[3] = { "Only in Rando", "Always", "Never" }; UIWidgets::EnhancementCombobox("gPauseAnyCursor", cursorOnAnySlot, PAUSE_ANY_CURSOR_RANDO_ONLY); @@ -313,22 +315,25 @@ namespace GameControlEditor { DrawHelpIcon("Hold the assigned button to change the maximum walking speed\nTo change the assigned button, go into the Ports tabs above"); if (CVarGetInteger("gEnableWalkModify", 0)) { UIWidgets::Spacer(5); - Ship::BeginGroupPanel("Walk Modifier", ImGui::GetContentRegionAvail()); + LUS::BeginGroupPanel("Walk Modifier", ImGui::GetContentRegionAvail()); UIWidgets::PaddedEnhancementCheckbox("Toggle modifier instead of holding", "gWalkSpeedToggle", true, false); UIWidgets::PaddedEnhancementSliderFloat("Modifier 1: %d %%", "##WalkMod1", "gWalkModifierOne", 0.0f, 5.0f, "", 1.0f, true, true, false, true); UIWidgets::PaddedEnhancementSliderFloat("Modifier 2: %d %%", "##WalkMod2", "gWalkModifierTwo", 0.0f, 5.0f, "", 1.0f, true, true, false, true); - Ship::EndGroupPanel(); + LUS::EndGroupPanel(); } UIWidgets::Spacer(0); UIWidgets::PaddedEnhancementCheckbox("Answer Navi Prompt with L Button", "gNaviOnL"); DrawHelpIcon("Speak to Navi with L but enter first-person camera with C-Up"); - Ship::EndGroupPanel(); + LUS::EndGroupPanel(); } void DrawUI(bool& open) { if (!open) { - CVarSetInteger("gGameControlEditorEnabled", false); + if (CVarGetInteger("gGameControlEditorEnabled", 0)) { + CVarClear("gGameControlEditorEnabled"); + LUS::RequestCvarSaveOnNextTick(); + } return; } diff --git a/soh/soh/Enhancements/cosmetics/CosmeticsEditor.cpp b/soh/soh/Enhancements/cosmetics/CosmeticsEditor.cpp index 2bc1353e9..0cda15d01 100644 --- a/soh/soh/Enhancements/cosmetics/CosmeticsEditor.cpp +++ b/soh/soh/Enhancements/cosmetics/CosmeticsEditor.cpp @@ -385,7 +385,7 @@ void ResetPositionAll() { int hue = 0; // Runs every frame to update rainbow hue, a potential future optimization is to only run this a once or twice a second and increase the speed of the rainbow hue rotation. -void CosmeticsUpdateTick(bool& open) { +void CosmeticsUpdateTick() { int index = 0; float rainbowSpeed = CVarGetFloat("gCosmetics.RainbowSpeed", 0.6f); for (auto& [id, cosmeticOption] : cosmeticOptions) { @@ -1411,7 +1411,7 @@ void Draw_Placements(){ void DrawSillyTab() { if (CVarGetInteger("gLetItSnow", 0)) { if (UIWidgets::EnhancementCheckbox("Let It Snow", "gLetItSnow")) { - Ship::RequestCvarSaveOnNextTick(); + LUS::RequestCvarSaveOnNextTick(); } } if (UIWidgets::EnhancementSliderFloat("Link Body Scale: %f", "##Link_BodyScale", "gCosmetics.Link_BodyScale.Value", 0.001f, 0.025f, "", 0.01f, false)) { @@ -1421,7 +1421,7 @@ void DrawSillyTab() { if (ImGui::Button("Reset##Link_BodyScale")) { CVarClear("gCosmetics.Link_BodyScale.Value"); CVarClear("gCosmetics.Link_BodyScale.Changed"); - Ship::RequestCvarSaveOnNextTick(); + LUS::RequestCvarSaveOnNextTick(); static Player* player = GET_PLAYER(gPlayState); player->actor.scale.x = 0.01f; player->actor.scale.y = 0.01f; @@ -1434,7 +1434,7 @@ void DrawSillyTab() { if (ImGui::Button("Reset##Link_HeadScale")) { CVarClear("gCosmetics.Link_HeadScale.Value"); CVarClear("gCosmetics.Link_HeadScale.Changed"); - Ship::RequestCvarSaveOnNextTick(); + LUS::RequestCvarSaveOnNextTick(); } if (UIWidgets::EnhancementSliderFloat("Link Sword Scale: %f", "##Link_SwordScale", "gCosmetics.Link_SwordScale.Value", 1.0f, 2.5f, "", 1.0f, false)) { CVarSetInteger("gCosmetics.Link_SwordScale.Changed", 1); @@ -1443,44 +1443,44 @@ void DrawSillyTab() { if (ImGui::Button("Reset##Link_SwordScale")) { CVarClear("gCosmetics.Link_SwordScale.Value"); CVarClear("gCosmetics.Link_SwordScale.Changed"); - Ship::RequestCvarSaveOnNextTick(); + LUS::RequestCvarSaveOnNextTick(); } UIWidgets::EnhancementSliderFloat("Bunny Hood Length: %f", "##BunnyHood_EarLength", "gCosmetics.BunnyHood_EarLength", -300.0f, 1000.0f, "", 0.0f, false); ImGui::SameLine(); if (ImGui::Button("Reset##BunnyHood_EarLength")) { CVarClear("gCosmetics.BunnyHood_EarLength"); - Ship::RequestCvarSaveOnNextTick(); + LUS::RequestCvarSaveOnNextTick(); } UIWidgets::EnhancementSliderFloat("Bunny Hood Spread: %f", "##BunnyHood_EarSpread", "gCosmetics.BunnyHood_EarSpread", -300.0f, 500.0f, "", 0.0f, false); ImGui::SameLine(); if (ImGui::Button("Reset##BunnyHood_EarSpread")) { CVarClear("gCosmetics.BunnyHood_EarSpread"); - Ship::RequestCvarSaveOnNextTick(); + LUS::RequestCvarSaveOnNextTick(); } UIWidgets::EnhancementSliderFloat("Goron Neck Length: %f", "##Goron_NeckLength", "gCosmetics.Goron_NeckLength", 0.0f, 1000.0f, "", 0.0f, false); ImGui::SameLine(); if (ImGui::Button("Reset##Goron_NeckLength")) { CVarClear("gCosmetics.Goron_NeckLength"); - Ship::RequestCvarSaveOnNextTick(); + LUS::RequestCvarSaveOnNextTick(); } UIWidgets::EnhancementCheckbox("Unfix Goron Spin", "gUnfixGoronSpin"); UIWidgets::EnhancementSliderFloat("Fairies Size: %f", "##Fairies_Size", "gCosmetics.Fairies_Size", 0.25f, 5.0f, "", 1.0f, false); ImGui::SameLine(); if (ImGui::Button("Reset##Fairies_Size")) { CVarClear("gCosmetics.Fairies_Size"); - Ship::RequestCvarSaveOnNextTick(); + LUS::RequestCvarSaveOnNextTick(); } UIWidgets::EnhancementSliderFloat("N64 Logo Spin Speed: %f", "##N64Logo_SpinSpeed", "gCosmetics.N64Logo_SpinSpeed", 0.25f, 5.0f, "", 1.0f, false); ImGui::SameLine(); if (ImGui::Button("Reset##N64Logo_SpinSpeed")) { CVarClear("gCosmetics.N64Logo_SpinSpeed"); - Ship::RequestCvarSaveOnNextTick(); + LUS::RequestCvarSaveOnNextTick(); } UIWidgets::EnhancementSliderFloat("Moon Size: %f", "##Moon_Size", "gCosmetics.Moon_Size", 0.5f, 2.0f, "", 1.0f, false); ImGui::SameLine(); if (ImGui::Button("Reset##Moon_Size")) { CVarClear("gCosmetics.Moon_Size"); - Ship::RequestCvarSaveOnNextTick(); + LUS::RequestCvarSaveOnNextTick(); } if (UIWidgets::EnhancementSliderFloat("Kak Windmill Speed: %f", "##Kak_Windmill_Speed", "gCosmetics.Kak_Windmill_Speed.Value", 100.0f, 6000.0f, "", 100.0f, false)) { CVarSetInteger("gCosmetics.Kak_Windmill_Speed.Changed", 1); @@ -1489,7 +1489,7 @@ void DrawSillyTab() { if (ImGui::Button("Reset##Kak_Windmill_Speed")) { CVarClear("gCosmetics.Kak_Windmill_Speed.Value"); CVarClear("gCosmetics.Kak_Windmill_Speed.Changed"); - Ship::RequestCvarSaveOnNextTick(); + LUS::RequestCvarSaveOnNextTick(); } } @@ -1597,7 +1597,7 @@ void DrawCosmeticRow(CosmeticOption& cosmeticOption) { CVarSetInteger((cosmeticOption.rainbowCvar), 0); CVarSetInteger((cosmeticOption.changedCvar), 1); ApplyOrResetCustomGfxPatches(); - Ship::RequestCvarSaveOnNextTick(); + LUS::RequestCvarSaveOnNextTick(); } ImGui::SameLine(); ImGui::Text(cosmeticOption.label.c_str()); @@ -1605,7 +1605,7 @@ void DrawCosmeticRow(CosmeticOption& cosmeticOption) { if (ImGui::Button(("Random##" + cosmeticOption.label).c_str())) { RandomizeColor(cosmeticOption); ApplyOrResetCustomGfxPatches(); - Ship::RequestCvarSaveOnNextTick(); + LUS::RequestCvarSaveOnNextTick(); } ImGui::SameLine(); bool isRainbow = (bool)CVarGetInteger((cosmeticOption.rainbowCvar), 0); @@ -1613,20 +1613,20 @@ void DrawCosmeticRow(CosmeticOption& cosmeticOption) { CVarSetInteger((cosmeticOption.rainbowCvar), isRainbow); CVarSetInteger((cosmeticOption.changedCvar), 1); ApplyOrResetCustomGfxPatches(); - Ship::RequestCvarSaveOnNextTick(); + LUS::RequestCvarSaveOnNextTick(); } ImGui::SameLine(); bool isLocked = (bool)CVarGetInteger((cosmeticOption.lockedCvar), 0); if (ImGui::Checkbox(("Locked##" + cosmeticOption.label).c_str(), &isLocked)) { CVarSetInteger((cosmeticOption.lockedCvar), isLocked); - Ship::RequestCvarSaveOnNextTick(); + LUS::RequestCvarSaveOnNextTick(); } if (CVarGetInteger((cosmeticOption.changedCvar), 0)) { ImGui::SameLine(); if (ImGui::Button(("Reset##" + cosmeticOption.label).c_str())) { ResetColor(cosmeticOption); ApplyOrResetCustomGfxPatches(); - Ship::RequestCvarSaveOnNextTick(); + LUS::RequestCvarSaveOnNextTick(); } } } @@ -1642,7 +1642,7 @@ void DrawCosmeticGroup(CosmeticGroup cosmeticGroup) { } } ApplyOrResetCustomGfxPatches(); - Ship::RequestCvarSaveOnNextTick(); + LUS::RequestCvarSaveOnNextTick(); } ImGui::SameLine(); if (ImGui::Button(("Reset##" + label).c_str())) { @@ -1652,7 +1652,7 @@ void DrawCosmeticGroup(CosmeticGroup cosmeticGroup) { } } ApplyOrResetCustomGfxPatches(); - Ship::RequestCvarSaveOnNextTick(); + LUS::RequestCvarSaveOnNextTick(); } for (auto& [id, cosmeticOption] : cosmeticOptions) { if (cosmeticOption.group == cosmeticGroup && (!cosmeticOption.advancedOption || CVarGetInteger("gCosmetics.AdvancedMode", 0))) { @@ -1668,7 +1668,10 @@ static const char* colorSchemes[2] = { void DrawCosmeticsEditor(bool& open) { if (!open) { - CVarSetInteger("gCosmeticsEditorEnabled", 0); + if (CVarGetInteger("gCosmeticsEditorEnabled", 0)) { + CVarClear("gCosmeticsEditorEnabled"); + LUS::RequestCvarSaveOnNextTick(); + } return; } @@ -1689,7 +1692,7 @@ void DrawCosmeticsEditor(bool& open) { CVarSetInteger(cosmeticOption.lockedCvar, 1); } } - Ship::RequestCvarSaveOnNextTick(); + LUS::RequestCvarSaveOnNextTick(); } ImGui::SameLine(); if (ImGui::Button("Unlock All Advanced", ImVec2(ImGui::GetContentRegionAvail().x, 30.0f))) { @@ -1698,7 +1701,7 @@ void DrawCosmeticsEditor(bool& open) { CVarSetInteger(cosmeticOption.lockedCvar, 0); } } - Ship::RequestCvarSaveOnNextTick(); + LUS::RequestCvarSaveOnNextTick(); } } UIWidgets::EnhancementCheckbox("Sync Rainbow colors", "gCosmetics.RainbowSync"); @@ -1710,7 +1713,7 @@ void DrawCosmeticsEditor(bool& open) { } } ApplyOrResetCustomGfxPatches(); - Ship::RequestCvarSaveOnNextTick(); + LUS::RequestCvarSaveOnNextTick(); } ImGui::SameLine(); if (ImGui::Button("Reset All", ImVec2(ImGui::GetContentRegionAvail().x, 30.0f))) { @@ -1720,7 +1723,7 @@ void DrawCosmeticsEditor(bool& open) { } } ApplyOrResetCustomGfxPatches(); - Ship::RequestCvarSaveOnNextTick(); + LUS::RequestCvarSaveOnNextTick(); } if (ImGui::Button("Lock All", ImVec2(ImGui::GetContentRegionAvail().x / 2, 30.0f))) { @@ -1729,7 +1732,7 @@ void DrawCosmeticsEditor(bool& open) { CVarSetInteger(cosmeticOption.lockedCvar, 1); } } - Ship::RequestCvarSaveOnNextTick(); + LUS::RequestCvarSaveOnNextTick(); } ImGui::SameLine(); if (ImGui::Button("Unlock All", ImVec2(ImGui::GetContentRegionAvail().x, 30.0f))) { @@ -1738,7 +1741,7 @@ void DrawCosmeticsEditor(bool& open) { CVarSetInteger(cosmeticOption.lockedCvar, 0); } } - Ship::RequestCvarSaveOnNextTick(); + LUS::RequestCvarSaveOnNextTick(); } if (ImGui::BeginTabBar("CosmeticsContextTabBar", ImGuiTabBarFlags_NoCloseWithMiddleMouseButton)) { @@ -1763,7 +1766,7 @@ void DrawCosmeticsEditor(bool& open) { if (ImGui::Button("Reset##Trails_Duration")) { CVarClear("gCosmetics.Trails_Duration.Value"); CVarClear("gCosmetics.Trails_Duration.Changed"); - Ship::RequestCvarSaveOnNextTick(); + LUS::RequestCvarSaveOnNextTick(); } ImGui::EndTabItem(); } @@ -1797,13 +1800,15 @@ void RegisterOnLoadGameHook() { }); } -void InitCosmeticsEditor() { - // There's probably a better way to do this, but leaving as is for historical reasons. Even though there is no - // real window being rendered here, it calls this every frame allowing us to rotate through the rainbow hue for cosmetics - Ship::AddWindow("Enhancements", "Cosmetics Update Tick", CosmeticsUpdateTick, true, true); +void RegisterOnGameFrameUpdateHook() { + GameInteractor::Instance->RegisterGameHook([]() { + CosmeticsUpdateTick(); + }); +} +void InitCosmeticsEditor() { // Draw the bar in the menu. - Ship::AddWindow("Enhancements", "Cosmetics Editor", DrawCosmeticsEditor); + LUS::AddWindow("Enhancements", "Cosmetics Editor", DrawCosmeticsEditor, CVarGetInteger("gCosmeticsEditorEnabled", 0)); // Convert the `current color` into the format that the ImGui color picker expects for (auto& [id, cosmeticOption] : cosmeticOptions) { Color_RGBA8 defaultColor = {cosmeticOption.defaultColor.x, cosmeticOption.defaultColor.y, cosmeticOption.defaultColor.z, cosmeticOption.defaultColor.w}; @@ -1814,11 +1819,12 @@ void InitCosmeticsEditor() { cosmeticOption.currentColor.z = cvarColor.b / 255.0; cosmeticOption.currentColor.w = cvarColor.a / 255.0; } - Ship::RequestCvarSaveOnNextTick(); + LUS::RequestCvarSaveOnNextTick(); ApplyOrResetCustomGfxPatches(); ApplyAuthenticGfxPatches(); RegisterOnLoadGameHook(); + RegisterOnGameFrameUpdateHook(); } void CosmeticsEditor_RandomizeAll() { @@ -1829,7 +1835,7 @@ void CosmeticsEditor_RandomizeAll() { } } - Ship::RequestCvarSaveOnNextTick(); + LUS::RequestCvarSaveOnNextTick(); ApplyOrResetCustomGfxPatches(); } @@ -1840,6 +1846,6 @@ void CosmeticsEditor_ResetAll() { } } - Ship::RequestCvarSaveOnNextTick(); + LUS::RequestCvarSaveOnNextTick(); ApplyOrResetCustomGfxPatches(); } diff --git a/soh/soh/Enhancements/crowd-control/CrowdControl.cpp b/soh/soh/Enhancements/crowd-control/CrowdControl.cpp index a3af11682..a7265a23a 100644 --- a/soh/soh/Enhancements/crowd-control/CrowdControl.cpp +++ b/soh/soh/Enhancements/crowd-control/CrowdControl.cpp @@ -417,6 +417,7 @@ CrowdControl::Effect* CrowdControl::ParseMessage(char payload[512]) { break; case kEffectFillHeart: effect->giEffect = new GameInteractionEffect::ModifyHealth(); + effect->giEffect->parameters[0] = receivedParameter; break; case kEffectKnockbackLinkWeak: effect->giEffect = new GameInteractionEffect::KnockbackPlayer(); @@ -454,6 +455,7 @@ CrowdControl::Effect* CrowdControl::ParseMessage(char payload[512]) { break; case kEffectAddRupees: effect->giEffect = new GameInteractionEffect::ModifyRupees(); + effect->giEffect->parameters[0] = receivedParameter; break; case kEffectGiveDekuShield: effect->giEffect = new GameInteractionEffect::GiveOrTakeShield(); @@ -465,26 +467,32 @@ CrowdControl::Effect* CrowdControl::ParseMessage(char payload[512]) { break; case kEffectRefillSticks: effect->giEffect = new GameInteractionEffect::AddOrTakeAmmo(); + effect->giEffect->parameters[0] = receivedParameter; effect->giEffect->parameters[1] = ITEM_STICK; break; case kEffectRefillNuts: effect->giEffect = new GameInteractionEffect::AddOrTakeAmmo(); + effect->giEffect->parameters[0] = receivedParameter; effect->giEffect->parameters[1] = ITEM_NUT; break; case kEffectRefillBombs: effect->giEffect = new GameInteractionEffect::AddOrTakeAmmo(); + effect->giEffect->parameters[0] = receivedParameter; effect->giEffect->parameters[1] = ITEM_BOMB; break; case kEffectRefillSeeds: effect->giEffect = new GameInteractionEffect::AddOrTakeAmmo(); + effect->giEffect->parameters[0] = receivedParameter; effect->giEffect->parameters[1] = ITEM_SLINGSHOT; break; case kEffectRefillArrows: effect->giEffect = new GameInteractionEffect::AddOrTakeAmmo(); + effect->giEffect->parameters[0] = receivedParameter; effect->giEffect->parameters[1] = ITEM_BOW; break; case kEffectRefillBombchus: effect->giEffect = new GameInteractionEffect::AddOrTakeAmmo(); + effect->giEffect->parameters[0] = receivedParameter; effect->giEffect->parameters[1] = ITEM_BOMBCHU; break; @@ -811,16 +819,6 @@ CrowdControl::Effect* CrowdControl::ParseMessage(char payload[512]) { break; } - // If no value is specifically set, default to using whatever CC sends us. - // Values are used for various things depending on the effect, but they - // usually represent the "amount" of an effect. Amount of hearts healed, - // strength of knockback, etc. - if (effect->giEffect != NULL) { - if (!effect->giEffect->parameters[0]) { - effect->giEffect->parameters[0] = receivedParameter; - } - } - return effect; } diff --git a/soh/soh/Enhancements/crowd-control/ShipOfHarkinian.cs b/soh/soh/Enhancements/crowd-control/ShipOfHarkinian.cs index 730386f3e..e4cb6a6ca 100644 --- a/soh/soh/Enhancements/crowd-control/ShipOfHarkinian.cs +++ b/soh/soh/Enhancements/crowd-control/ShipOfHarkinian.cs @@ -113,7 +113,7 @@ public class ShipOfHarkinian : SimpleTCPPack new("No UI", "no_ui") { Category = "Visual Effects", Duration = 60, Price = 20, Description = "No need to see ammo counts. The cinematic experience." }, new("Rainstorm", "rainstorm") { Category = "Visual Effects", Duration = 30, Price = 5, Description = "Summon a rainstorm for a sad moment." }, new("Debug Mode", "debug_mode") { Category = "Visual Effects", Duration = 30, Price = 20, Description = "if (debug_mode) { ShowCollision(); }" }, - new("Randomize Cosmetics", "random_cosmetics") { Category = "Visual Effects", Duration = 30, Price = 30, Description = "Randomize most cosmetics options. Cosmetics changed by bidding wars are unaffected." }, + new("Randomize Cosmetics", "random_cosmetics") { Category = "Visual Effects", Price = 30, Description = "Randomize most cosmetics options. Cosmetics changed by bidding wars are unaffected." }, // Controls diff --git a/soh/soh/Enhancements/debugconsole.cpp b/soh/soh/Enhancements/debugconsole.cpp index cf11dde1d..29047a216 100644 --- a/soh/soh/Enhancements/debugconsole.cpp +++ b/soh/soh/Enhancements/debugconsole.cpp @@ -17,6 +17,7 @@ #include #include +#include #include #undef PATH_HACK #undef Path @@ -31,16 +32,16 @@ extern PlayState* gPlayState; #include -#define CMD_REGISTER Ship::GetConsole()->AddCommand +#define CMD_REGISTER LUS::GetConsole()->AddCommand -static bool ActorSpawnHandler(std::shared_ptr Console, const std::vector& args) { +static bool ActorSpawnHandler(std::shared_ptr Console, const std::vector& args) { if ((args.size() != 9) && (args.size() != 3) && (args.size() != 6)) { - Ship::GetConsole()->SendErrorMessage("Not enough arguments passed to actorspawn"); + LUS::GetConsole()->SendErrorMessage("Not enough arguments passed to actorspawn"); return CMD_FAILED; } if (gPlayState == nullptr) { - Ship::GetConsole()->SendErrorMessage("PlayState == nullptr"); + LUS::GetConsole()->SendErrorMessage("PlayState == nullptr"); return CMD_FAILED; } @@ -76,28 +77,28 @@ static bool ActorSpawnHandler(std::shared_ptr Console, const std: if (Actor_Spawn(&gPlayState->actorCtx, gPlayState, actorId, spawnPoint.pos.x, spawnPoint.pos.y, spawnPoint.pos.z, spawnPoint.rot.x, spawnPoint.rot.y, spawnPoint.rot.z, params, 0) == NULL) { - Ship::GetConsole()->SendErrorMessage("Failed to spawn actor. Actor_Spawn returned NULL"); + LUS::GetConsole()->SendErrorMessage("Failed to spawn actor. Actor_Spawn returned NULL"); return CMD_FAILED; } return CMD_SUCCESS; } -static bool KillPlayerHandler(std::shared_ptr Console, const std::vector&) { +static bool KillPlayerHandler(std::shared_ptr Console, const std::vector&) { GameInteractionEffectBase* effect = new GameInteractionEffect::SetPlayerHealth(); effect->parameters[0] = 0; GameInteractionEffectQueryResult result = GameInteractor::ApplyEffect(effect); if (result == GameInteractionEffectQueryResult::Possible) { - Ship::GetConsole()->SendInfoMessage("[SOH] You've met with a terrible fate, haven't you?"); + LUS::GetConsole()->SendInfoMessage("[SOH] You've met with a terrible fate, haven't you?"); return CMD_SUCCESS; } else { - Ship::GetConsole()->SendInfoMessage("[SOH] Command failed: Could not kill player."); + LUS::GetConsole()->SendInfoMessage("[SOH] Command failed: Could not kill player."); return CMD_FAILED; } } -static bool SetPlayerHealthHandler(std::shared_ptr Console, const std::vector& args) { +static bool SetPlayerHealthHandler(std::shared_ptr Console, const std::vector& args) { if (args.size() < 2) { - Ship::GetConsole()->SendErrorMessage("[SOH] Unexpected arguments passed"); + LUS::GetConsole()->SendErrorMessage("[SOH] Unexpected arguments passed"); return CMD_FAILED; } int health; @@ -105,12 +106,12 @@ static bool SetPlayerHealthHandler(std::shared_ptr Console, const try { health = std::stoi(args[1]); } catch (std::invalid_argument const& ex) { - Ship::GetConsole()->SendErrorMessage("[SOH] Health value must be an integer."); + LUS::GetConsole()->SendErrorMessage("[SOH] Health value must be an integer."); return CMD_FAILED; } if (health < 0) { - Ship::GetConsole()->SendErrorMessage("[SOH] Health value must be a positive integer"); + LUS::GetConsole()->SendErrorMessage("[SOH] Health value must be a positive integer"); return CMD_FAILED; } @@ -118,15 +119,15 @@ static bool SetPlayerHealthHandler(std::shared_ptr Console, const effect->parameters[0] = health; GameInteractionEffectQueryResult result = GameInteractor::ApplyEffect(effect); if (result == GameInteractionEffectQueryResult::Possible) { - Ship::GetConsole()->SendInfoMessage("[SOH] Player health updated to %d", health); + LUS::GetConsole()->SendInfoMessage("[SOH] Player health updated to %d", health); return CMD_SUCCESS; } else { - Ship::GetConsole()->SendInfoMessage("[SOH] Command failed: Could not set player health."); + LUS::GetConsole()->SendInfoMessage("[SOH] Command failed: Could not set player health."); return CMD_FAILED; } } -static bool LoadSceneHandler(std::shared_ptr Console, const std::vector&) { +static bool LoadSceneHandler(std::shared_ptr Console, const std::vector&) { gSaveContext.respawnFlag = 0; gSaveContext.seqId = 0xFF; gSaveContext.gameMode = 0; @@ -134,7 +135,7 @@ static bool LoadSceneHandler(std::shared_ptr Console, const std:: return CMD_SUCCESS; } -static bool RupeeHandler(std::shared_ptr Console, const std::vector& args) { +static bool RupeeHandler(std::shared_ptr Console, const std::vector& args) { if (args.size() < 2) { return CMD_FAILED; } @@ -144,31 +145,31 @@ static bool RupeeHandler(std::shared_ptr Console, const std::vect rupeeAmount = std::stoi(args[1]); } catch (std::invalid_argument const& ex) { - Ship::GetConsole()->SendErrorMessage("[SOH] Rupee count must be an integer."); + LUS::GetConsole()->SendErrorMessage("[SOH] Rupee count must be an integer."); return CMD_FAILED; } if (rupeeAmount < 0) { - Ship::GetConsole()->SendErrorMessage("[SOH] Rupee count must be positive"); + LUS::GetConsole()->SendErrorMessage("[SOH] Rupee count must be positive"); return CMD_FAILED; } gSaveContext.rupees = rupeeAmount; - Ship::GetConsole()->SendInfoMessage("Set rupee count to %u", rupeeAmount); + LUS::GetConsole()->SendInfoMessage("Set rupee count to %u", rupeeAmount); return CMD_SUCCESS; } -static bool SetPosHandler(std::shared_ptr Console, const std::vector args) { +static bool SetPosHandler(std::shared_ptr Console, const std::vector args) { if (gPlayState == nullptr) { - Ship::GetConsole()->SendErrorMessage("PlayState == nullptr"); + LUS::GetConsole()->SendErrorMessage("PlayState == nullptr"); return CMD_FAILED; } Player* player = GET_PLAYER(gPlayState); if (args.size() == 1) { - Ship::GetConsole()->SendInfoMessage("Player position is [ %.2f, %.2f, %.2f ]", player->actor.world.pos.x, + LUS::GetConsole()->SendInfoMessage("Player position is [ %.2f, %.2f, %.2f ]", player->actor.world.pos.x, player->actor.world.pos.y, player->actor.world.pos.z); return CMD_SUCCESS; @@ -180,15 +181,15 @@ static bool SetPosHandler(std::shared_ptr Console, const std::vec player->actor.world.pos.y = std::stof(args[2]); player->actor.world.pos.z = std::stof(args[3]); - Ship::GetConsole()->SendInfoMessage("Set player position to [ %.2f, %.2f, %.2f ]", player->actor.world.pos.x, + LUS::GetConsole()->SendInfoMessage("Set player position to [ %.2f, %.2f, %.2f ]", player->actor.world.pos.x, player->actor.world.pos.y, player->actor.world.pos.z); return CMD_SUCCESS; } -static bool ResetHandler(std::shared_ptr Console, std::vector args) { +static bool ResetHandler(std::shared_ptr Console, std::vector args) { if (gPlayState == nullptr) { - Ship::GetConsole()->SendErrorMessage("PlayState == nullptr"); + LUS::GetConsole()->SendErrorMessage("PlayState == nullptr"); return CMD_FAILED; } @@ -205,9 +206,9 @@ const static std::map ammoItems{ { "beans", ITEM_BEAN } }; -static bool AddAmmoHandler(std::shared_ptr Console, const std::vector& args) { +static bool AddAmmoHandler(std::shared_ptr Console, const std::vector& args) { if (args.size() < 3) { - Ship::GetConsole()->SendErrorMessage("[SOH] Unexpected arguments passed"); + LUS::GetConsole()->SendErrorMessage("[SOH] Unexpected arguments passed"); return CMD_FAILED; } int amount; @@ -215,18 +216,18 @@ static bool AddAmmoHandler(std::shared_ptr Console, const std::ve try { amount = std::stoi(args[2]); } catch (std::invalid_argument const& ex) { - Ship::GetConsole()->SendErrorMessage("Ammo count must be an integer"); + LUS::GetConsole()->SendErrorMessage("Ammo count must be an integer"); return CMD_FAILED; } if (amount < 0) { - Ship::GetConsole()->SendErrorMessage("Ammo count must be positive"); + LUS::GetConsole()->SendErrorMessage("Ammo count must be positive"); return CMD_FAILED; } const auto& it = ammoItems.find(args[1]); if (it == ammoItems.end()) { - Ship::GetConsole()->SendErrorMessage("Invalid ammo type. Options are 'sticks', 'nuts', 'bombs', 'seeds', 'arrows', 'bombchus' and 'beans'"); + LUS::GetConsole()->SendErrorMessage("Invalid ammo type. Options are 'sticks', 'nuts', 'bombs', 'seeds', 'arrows', 'bombchus' and 'beans'"); return CMD_FAILED; } @@ -236,17 +237,17 @@ static bool AddAmmoHandler(std::shared_ptr Console, const std::ve GameInteractionEffectQueryResult result = GameInteractor::ApplyEffect(effect); if (result == GameInteractionEffectQueryResult::Possible) { - Ship::GetConsole()->SendInfoMessage("[SOH] Added ammo."); + LUS::GetConsole()->SendInfoMessage("[SOH] Added ammo."); return CMD_SUCCESS; } else { - Ship::GetConsole()->SendInfoMessage("[SOH] Command failed: Could not add ammo."); + LUS::GetConsole()->SendInfoMessage("[SOH] Command failed: Could not add ammo."); return CMD_FAILED; } } -static bool TakeAmmoHandler(std::shared_ptr Console, const std::vector& args) { +static bool TakeAmmoHandler(std::shared_ptr Console, const std::vector& args) { if (args.size() < 3) { - Ship::GetConsole()->SendErrorMessage("[SOH] Unexpected arguments passed"); + LUS::GetConsole()->SendErrorMessage("[SOH] Unexpected arguments passed"); return CMD_FAILED; } int amount; @@ -254,18 +255,18 @@ static bool TakeAmmoHandler(std::shared_ptr Console, const std::v try { amount = std::stoi(args[2]); } catch (std::invalid_argument const& ex) { - Ship::GetConsole()->SendErrorMessage("Ammo count must be an integer"); + LUS::GetConsole()->SendErrorMessage("Ammo count must be an integer"); return CMD_FAILED; } if (amount < 0) { - Ship::GetConsole()->SendErrorMessage("Ammo count must be positive"); + LUS::GetConsole()->SendErrorMessage("Ammo count must be positive"); return CMD_FAILED; } const auto& it = ammoItems.find(args[1]); if (it == ammoItems.end()) { - Ship::GetConsole()->SendErrorMessage( + LUS::GetConsole()->SendErrorMessage( "Invalid ammo type. Options are 'sticks', 'nuts', 'bombs', 'seeds', 'arrows', 'bombchus' and 'beans'"); return CMD_FAILED; } @@ -276,10 +277,10 @@ static bool TakeAmmoHandler(std::shared_ptr Console, const std::v GameInteractionEffectQueryResult result = GameInteractor::ApplyEffect(effect); if (result == GameInteractionEffectQueryResult::Possible) { - Ship::GetConsole()->SendInfoMessage("[SOH] Took ammo."); + LUS::GetConsole()->SendInfoMessage("[SOH] Took ammo."); return CMD_SUCCESS; } else { - Ship::GetConsole()->SendInfoMessage("[SOH] Command failed: Could not take ammo."); + LUS::GetConsole()->SendInfoMessage("[SOH] Command failed: Could not take ammo."); return CMD_FAILED; } } @@ -291,9 +292,9 @@ const static std::map bottleItems{ { "big_poe", ITEM_BIG_POE }, { "blue_fire", ITEM_BLUE_FIRE }, { "rutos_letter", ITEM_LETTER_RUTO }, }; -static bool BottleHandler(std::shared_ptr Console, const std::vector& args) { +static bool BottleHandler(std::shared_ptr Console, const std::vector& args) { if (args.size() < 3) { - Ship::GetConsole()->SendErrorMessage("[SOH] Unexpected arguments passed"); + LUS::GetConsole()->SendErrorMessage("[SOH] Unexpected arguments passed"); return CMD_FAILED; } @@ -301,19 +302,19 @@ static bool BottleHandler(std::shared_ptr Console, const std::vec try { slot = std::stoi(args[2]); } catch (std::invalid_argument const& ex) { - Ship::GetConsole()->SendErrorMessage("[SOH] Bottle slot must be an integer."); + LUS::GetConsole()->SendErrorMessage("[SOH] Bottle slot must be an integer."); return CMD_FAILED; } if ((slot < 1) || (slot > 4)) { - Ship::GetConsole()->SendErrorMessage("Invalid slot passed"); + LUS::GetConsole()->SendErrorMessage("Invalid slot passed"); return CMD_FAILED; } const auto& it = bottleItems.find(args[1]); if (it == bottleItems.end()) { - Ship::GetConsole()->SendErrorMessage("Invalid item passed"); + LUS::GetConsole()->SendErrorMessage("Invalid item passed"); return CMD_FAILED; } @@ -323,9 +324,9 @@ static bool BottleHandler(std::shared_ptr Console, const std::vec return CMD_SUCCESS; } -static bool BHandler(std::shared_ptr Console, const std::vector& args) { +static bool BHandler(std::shared_ptr Console, const std::vector& args) { if (args.size() < 2) { - Ship::GetConsole()->SendErrorMessage("[SOH] Unexpected arguments passed"); + LUS::GetConsole()->SendErrorMessage("[SOH] Unexpected arguments passed"); return CMD_FAILED; } @@ -333,9 +334,9 @@ static bool BHandler(std::shared_ptr Console, const std::vector Console, const std::vector& args) { +static bool ItemHandler(std::shared_ptr Console, const std::vector& args) { if (args.size() < 3) { - Ship::GetConsole()->SendErrorMessage("[SOH] Unexpected arguments passed"); + LUS::GetConsole()->SendErrorMessage("[SOH] Unexpected arguments passed"); return CMD_FAILED; } @@ -344,9 +345,9 @@ static bool ItemHandler(std::shared_ptr Console, const std::vecto return CMD_SUCCESS; } -static bool GiveItemHandler(std::shared_ptr Console, const std::vector args) { +static bool GiveItemHandler(std::shared_ptr Console, const std::vector args) { if (args.size() < 3) { - Ship::GetConsole()->SendErrorMessage("[SOH] Unexpected arguments passed"); + LUS::GetConsole()->SendErrorMessage("[SOH] Unexpected arguments passed"); return CMD_FAILED; } GetItemEntry getItemEntry = GET_ITEM_NONE; @@ -356,7 +357,7 @@ static bool GiveItemHandler(std::shared_ptr Console, const std::v } else if (args[1].compare("randomizer") == 0) { getItemEntry = ItemTableManager::Instance->RetrieveItemEntry(MOD_RANDOMIZER, std::stoi(args[2])); } else { - Ship::GetConsole()->SendErrorMessage("[SOH] Invalid argument passed, must be 'vanilla' or 'randomizer'"); + LUS::GetConsole()->SendErrorMessage("[SOH] Invalid argument passed, must be 'vanilla' or 'randomizer'"); return CMD_FAILED; } @@ -365,9 +366,9 @@ static bool GiveItemHandler(std::shared_ptr Console, const std::v return CMD_SUCCESS; } -static bool EntranceHandler(std::shared_ptr Console, const std::vector& args) { +static bool EntranceHandler(std::shared_ptr Console, const std::vector& args) { if (args.size() < 2) { - Ship::GetConsole()->SendErrorMessage("[SOH] Unexpected arguments passed"); + LUS::GetConsole()->SendErrorMessage("[SOH] Unexpected arguments passed"); return CMD_FAILED; } @@ -376,7 +377,7 @@ static bool EntranceHandler(std::shared_ptr Console, const std::v try { entrance = std::stoi(args[1], nullptr, 16); } catch (std::invalid_argument const& ex) { - Ship::GetConsole()->SendErrorMessage("[SOH] Entrance value must be a Hex number."); + LUS::GetConsole()->SendErrorMessage("[SOH] Entrance value must be a Hex number."); return CMD_FAILED; } @@ -386,7 +387,7 @@ static bool EntranceHandler(std::shared_ptr Console, const std::v gSaveContext.nextTransitionType = 11; } -static bool VoidHandler(std::shared_ptr Console, const std::vector& args) { +static bool VoidHandler(std::shared_ptr Console, const std::vector& args) { if (gPlayState != nullptr) { gSaveContext.respawn[RESPAWN_MODE_DOWN].tempSwchFlags = gPlayState->actorCtx.flags.tempSwch; gSaveContext.respawn[RESPAWN_MODE_DOWN].tempCollectFlags = gPlayState->actorCtx.flags.tempCollect; @@ -396,20 +397,20 @@ static bool VoidHandler(std::shared_ptr Console, const std::vecto gPlayState->fadeTransition = 2; gSaveContext.nextTransitionType = 2; } else { - Ship::GetConsole()->SendErrorMessage("gPlayState == nullptr"); + LUS::GetConsole()->SendErrorMessage("gPlayState == nullptr"); return CMD_FAILED; } return CMD_SUCCESS; } -static bool ReloadHandler(std::shared_ptr Console, const std::vector& args) { +static bool ReloadHandler(std::shared_ptr Console, const std::vector& args) { if (gPlayState != nullptr) { gPlayState->nextEntranceIndex = gSaveContext.entranceIndex; gPlayState->sceneLoadFlag = 0x14; gPlayState->fadeTransition = 11; gSaveContext.nextTransitionType = 11; } else { - Ship::GetConsole()->SendErrorMessage("gPlayState == nullptr"); + LUS::GetConsole()->SendErrorMessage("gPlayState == nullptr"); return CMD_FAILED; } return CMD_SUCCESS; @@ -419,15 +420,15 @@ const static std::map fw_options { { "clear", 0}, {"warp", 1}, {"backup", 2} }; -static bool FWHandler(std::shared_ptr Console, const std::vector& args) { +static bool FWHandler(std::shared_ptr Console, const std::vector& args) { if (args.size() < 2) { - Ship::GetConsole()->SendErrorMessage("[SOH] Unexpected arguments passed"); + LUS::GetConsole()->SendErrorMessage("[SOH] Unexpected arguments passed"); return CMD_FAILED; } const auto& it = fw_options.find(args[1]); if (it == fw_options.end()) { - Ship::GetConsole()->SendErrorMessage("[SOH] Invalid option. Options are 'clear', 'warp', 'backup'"); + LUS::GetConsole()->SendErrorMessage("[SOH] Invalid option. Options are 'clear', 'warp', 'backup'"); return CMD_FAILED; } @@ -436,7 +437,7 @@ static bool FWHandler(std::shared_ptr Console, const std::vector< switch(it->second) { case 0: //clear gSaveContext.fw = clear; - Ship::GetConsole()->SendInfoMessage("[SOH] Farore's wind point cleared! Reload scene to take effect."); + LUS::GetConsole()->SendInfoMessage("[SOH] Farore's wind point cleared! Reload scene to take effect."); return CMD_SUCCESS; break; case 1: //warp @@ -445,7 +446,7 @@ static bool FWHandler(std::shared_ptr Console, const std::vector< gPlayState->nextEntranceIndex = gSaveContext.respawn[RESPAWN_MODE_TOP].entranceIndex; gPlayState->fadeTransition = 5; } else { - Ship::GetConsole()->SendErrorMessage("Farore's wind not set!"); + LUS::GetConsole()->SendErrorMessage("Farore's wind not set!"); return CMD_FAILED; } return CMD_SUCCESS; @@ -454,77 +455,77 @@ static bool FWHandler(std::shared_ptr Console, const std::vector< if (CVarGetInteger("gBetterFW", 0)) { gSaveContext.fw = gSaveContext.backupFW; gSaveContext.fw.set = 1; - Ship::GetConsole()->SendInfoMessage("[SOH] Backup FW data copied! Reload scene to take effect."); + LUS::GetConsole()->SendInfoMessage("[SOH] Backup FW data copied! Reload scene to take effect."); return CMD_SUCCESS; } else { - Ship::GetConsole()->SendErrorMessage("Better Farore's Wind isn't turned on!"); + LUS::GetConsole()->SendErrorMessage("Better Farore's Wind isn't turned on!"); return CMD_FAILED; } break; } } else { - Ship::GetConsole()->SendErrorMessage("gPlayState == nullptr"); + LUS::GetConsole()->SendErrorMessage("gPlayState == nullptr"); return CMD_FAILED; } return CMD_SUCCESS; } -static bool FileSelectHandler(std::shared_ptr Console, const std::vector& args) { +static bool FileSelectHandler(std::shared_ptr Console, const std::vector& args) { if (gPlayState != nullptr) { SET_NEXT_GAMESTATE(&gPlayState->state, FileChoose_Init, FileChooseContext); gPlayState->state.running = 0; } else { - Ship::GetConsole()->SendErrorMessage("gPlayState == nullptr"); + LUS::GetConsole()->SendErrorMessage("gPlayState == nullptr"); return CMD_FAILED; } return CMD_SUCCESS; } -static bool QuitHandler(std::shared_ptr Console, const std::vector& args) { - Ship::Window::GetInstance()->Close(); +static bool QuitHandler(std::shared_ptr Console, const std::vector& args) { + LUS::Context::GetInstance()->GetWindow()->Close(); return CMD_SUCCESS; } -static bool SaveStateHandler(std::shared_ptr Console, const std::vector& args) { +static bool SaveStateHandler(std::shared_ptr Console, const std::vector& args) { unsigned int slot = OTRGlobals::Instance->gSaveStateMgr->GetCurrentSlot(); const SaveStateReturn rtn = OTRGlobals::Instance->gSaveStateMgr->AddRequest({ slot, RequestType::SAVE }); switch (rtn) { case SaveStateReturn::SUCCESS: - Ship::GetConsole()->SendInfoMessage("[SOH] Saved state to slot %u", slot); + LUS::GetConsole()->SendInfoMessage("[SOH] Saved state to slot %u", slot); return CMD_SUCCESS; case SaveStateReturn::FAIL_WRONG_GAMESTATE: - Ship::GetConsole()->SendErrorMessage("[SOH] Can not save a state outside of \"GamePlay\""); + LUS::GetConsole()->SendErrorMessage("[SOH] Can not save a state outside of \"GamePlay\""); return CMD_FAILED; } } -static bool LoadStateHandler(std::shared_ptr Console, const std::vector& args) { +static bool LoadStateHandler(std::shared_ptr Console, const std::vector& args) { unsigned int slot = OTRGlobals::Instance->gSaveStateMgr->GetCurrentSlot(); const SaveStateReturn rtn = OTRGlobals::Instance->gSaveStateMgr->AddRequest({ slot, RequestType::LOAD }); switch (rtn) { case SaveStateReturn::SUCCESS: - Ship::GetConsole()->SendInfoMessage("[SOH] Loaded state from slot (%u)", slot); + LUS::GetConsole()->SendInfoMessage("[SOH] Loaded state from slot (%u)", slot); return CMD_SUCCESS; case SaveStateReturn::FAIL_INVALID_SLOT: - Ship::GetConsole()->SendErrorMessage("[SOH] Invalid State Slot Number (%u)", slot); + LUS::GetConsole()->SendErrorMessage("[SOH] Invalid State Slot Number (%u)", slot); return CMD_FAILED; case SaveStateReturn::FAIL_STATE_EMPTY: - Ship::GetConsole()->SendErrorMessage("[SOH] State Slot (%u) is empty", slot); + LUS::GetConsole()->SendErrorMessage("[SOH] State Slot (%u) is empty", slot); return CMD_FAILED; case SaveStateReturn::FAIL_WRONG_GAMESTATE: - Ship::GetConsole()->SendErrorMessage("[SOH] Can not load a state outside of \"GamePlay\""); + LUS::GetConsole()->SendErrorMessage("[SOH] Can not load a state outside of \"GamePlay\""); return CMD_FAILED; } } -static bool StateSlotSelectHandler(std::shared_ptr Console, const std::vector& args) { +static bool StateSlotSelectHandler(std::shared_ptr Console, const std::vector& args) { if (args.size() < 2) { - Ship::GetConsole()->SendErrorMessage("[SOH] Unexpected arguments passed"); + LUS::GetConsole()->SendErrorMessage("[SOH] Unexpected arguments passed"); return CMD_FAILED; } uint8_t slot; @@ -532,24 +533,24 @@ static bool StateSlotSelectHandler(std::shared_ptr Console, const try { slot = std::stoi(args[1], nullptr, 10); } catch (std::invalid_argument const& ex) { - Ship::GetConsole()->SendErrorMessage("[SOH] SaveState slot value must be a number."); + LUS::GetConsole()->SendErrorMessage("[SOH] SaveState slot value must be a number."); return CMD_FAILED; } if (slot < 0) { - Ship::GetConsole()->SendErrorMessage("[SOH] Invalid slot passed. Slot must be between 0 and 2"); + LUS::GetConsole()->SendErrorMessage("[SOH] Invalid slot passed. Slot must be between 0 and 2"); return CMD_FAILED; } OTRGlobals::Instance->gSaveStateMgr->SetCurrentSlot(slot); - Ship::GetConsole()->SendInfoMessage("[SOH] Slot %u selected", + LUS::GetConsole()->SendInfoMessage("[SOH] Slot %u selected", OTRGlobals::Instance->gSaveStateMgr->GetCurrentSlot()); return CMD_SUCCESS; } -static bool InvisibleHandler(std::shared_ptr Console, const std::vector& args) { +static bool InvisibleHandler(std::shared_ptr Console, const std::vector& args) { if (args.size() < 2) { - Ship::GetConsole()->SendErrorMessage("[SOH] Unexpected arguments passed"); + LUS::GetConsole()->SendErrorMessage("[SOH] Unexpected arguments passed"); return CMD_FAILED; } uint8_t state; @@ -557,7 +558,7 @@ static bool InvisibleHandler(std::shared_ptr Console, const std:: try { state = std::stoi(args[1], nullptr, 10) == 0 ? 0 : 1; } catch (std::invalid_argument const& ex) { - Ship::GetConsole()->SendErrorMessage("[SOH] Invisible value must be a number."); + LUS::GetConsole()->SendErrorMessage("[SOH] Invisible value must be a number."); return CMD_FAILED; } @@ -565,18 +566,18 @@ static bool InvisibleHandler(std::shared_ptr Console, const std:: GameInteractionEffectQueryResult result = state ? GameInteractor::ApplyEffect(effect) : GameInteractor::RemoveEffect(effect); if (result == GameInteractionEffectQueryResult::Possible) { - Ship::GetConsole()->SendInfoMessage("[SOH] Invisible Link %s", state ? "enabled" : "disabled"); + LUS::GetConsole()->SendInfoMessage("[SOH] Invisible Link %s", state ? "enabled" : "disabled"); return CMD_SUCCESS; } else { - Ship::GetConsole()->SendInfoMessage("[SOH] Command failed: Could not %s Invisible Link.", + LUS::GetConsole()->SendInfoMessage("[SOH] Command failed: Could not %s Invisible Link.", state ? "enable" : "disable"); return CMD_FAILED; } } -static bool GiantLinkHandler(std::shared_ptr Console, const std::vector& args) { +static bool GiantLinkHandler(std::shared_ptr Console, const std::vector& args) { if (args.size() < 2) { - Ship::GetConsole()->SendErrorMessage("[SOH] Unexpected arguments passed"); + LUS::GetConsole()->SendErrorMessage("[SOH] Unexpected arguments passed"); return CMD_FAILED; } uint8_t state; @@ -584,7 +585,7 @@ static bool GiantLinkHandler(std::shared_ptr Console, const std:: try { state = std::stoi(args[1], nullptr, 10) == 0 ? 0 : 1; } catch (std::invalid_argument const& ex) { - Ship::GetConsole()->SendErrorMessage("[SOH] Giant value must be a number."); + LUS::GetConsole()->SendErrorMessage("[SOH] Giant value must be a number."); return CMD_FAILED; } @@ -593,18 +594,18 @@ static bool GiantLinkHandler(std::shared_ptr Console, const std:: GameInteractionEffectQueryResult result = state ? GameInteractor::ApplyEffect(effect) : GameInteractor::RemoveEffect(effect); if (result == GameInteractionEffectQueryResult::Possible) { - Ship::GetConsole()->SendInfoMessage("[SOH] Giant Link %s", state ? "enabled" : "disabled"); + LUS::GetConsole()->SendInfoMessage("[SOH] Giant Link %s", state ? "enabled" : "disabled"); return CMD_SUCCESS; } else { - Ship::GetConsole()->SendInfoMessage("[SOH] Command failed: Could not %s Giant Link.", + LUS::GetConsole()->SendInfoMessage("[SOH] Command failed: Could not %s Giant Link.", state ? "enable" : "disable"); return CMD_FAILED; } } -static bool MinishLinkHandler(std::shared_ptr Console, const std::vector& args) { +static bool MinishLinkHandler(std::shared_ptr Console, const std::vector& args) { if (args.size() < 2) { - Ship::GetConsole()->SendErrorMessage("[SOH] Unexpected arguments passed"); + LUS::GetConsole()->SendErrorMessage("[SOH] Unexpected arguments passed"); return CMD_FAILED; } uint8_t state; @@ -612,7 +613,7 @@ static bool MinishLinkHandler(std::shared_ptr Console, const std: try { state = std::stoi(args[1], nullptr, 10) == 0 ? 0 : 1; } catch (std::invalid_argument const& ex) { - Ship::GetConsole()->SendErrorMessage("[SOH] Minish value must be a number."); + LUS::GetConsole()->SendErrorMessage("[SOH] Minish value must be a number."); return CMD_FAILED; } @@ -621,18 +622,18 @@ static bool MinishLinkHandler(std::shared_ptr Console, const std: GameInteractionEffectQueryResult result = state ? GameInteractor::ApplyEffect(effect) : GameInteractor::RemoveEffect(effect); if (result == GameInteractionEffectQueryResult::Possible) { - Ship::GetConsole()->SendInfoMessage("[SOH] Minish Link %s", state ? "enabled" : "disabled"); + LUS::GetConsole()->SendInfoMessage("[SOH] Minish Link %s", state ? "enabled" : "disabled"); return CMD_SUCCESS; } else { - Ship::GetConsole()->SendInfoMessage("[SOH] Command failed: Could not %s Minish Link.", + LUS::GetConsole()->SendInfoMessage("[SOH] Command failed: Could not %s Minish Link.", state ? "enable" : "disable"); return CMD_FAILED; } } -static bool AddHeartContainerHandler(std::shared_ptr Console, const std::vector& args) { +static bool AddHeartContainerHandler(std::shared_ptr Console, const std::vector& args) { if (args.size() < 2) { - Ship::GetConsole()->SendErrorMessage("[SOH] Unexpected arguments passed"); + LUS::GetConsole()->SendErrorMessage("[SOH] Unexpected arguments passed"); return CMD_FAILED; } int hearts; @@ -640,12 +641,12 @@ static bool AddHeartContainerHandler(std::shared_ptr Console, con try { hearts = std::stoi(args[1]); } catch (std::invalid_argument const& ex) { - Ship::GetConsole()->SendErrorMessage("[SOH] Hearts value must be an integer."); + LUS::GetConsole()->SendErrorMessage("[SOH] Hearts value must be an integer."); return CMD_FAILED; } if (hearts < 0) { - Ship::GetConsole()->SendErrorMessage("[SOH] Hearts value must be a positive integer"); + LUS::GetConsole()->SendErrorMessage("[SOH] Hearts value must be a positive integer"); return CMD_FAILED; } @@ -653,17 +654,17 @@ static bool AddHeartContainerHandler(std::shared_ptr Console, con effect->parameters[0] = hearts; GameInteractionEffectQueryResult result = GameInteractor::ApplyEffect(effect); if (result == GameInteractionEffectQueryResult::Possible) { - Ship::GetConsole()->SendInfoMessage("[SOH] Added %d heart containers", hearts); + LUS::GetConsole()->SendInfoMessage("[SOH] Added %d heart containers", hearts); return CMD_SUCCESS; } else { - Ship::GetConsole()->SendInfoMessage("[SOH] Command failed: Could not add heart containers."); + LUS::GetConsole()->SendInfoMessage("[SOH] Command failed: Could not add heart containers."); return CMD_FAILED; } } -static bool RemoveHeartContainerHandler(std::shared_ptr Console, const std::vector& args) { +static bool RemoveHeartContainerHandler(std::shared_ptr Console, const std::vector& args) { if (args.size() < 2) { - Ship::GetConsole()->SendErrorMessage("[SOH] Unexpected arguments passed"); + LUS::GetConsole()->SendErrorMessage("[SOH] Unexpected arguments passed"); return CMD_FAILED; } int hearts; @@ -671,12 +672,12 @@ static bool RemoveHeartContainerHandler(std::shared_ptr Console, try { hearts = std::stoi(args[1]); } catch (std::invalid_argument const& ex) { - Ship::GetConsole()->SendErrorMessage("[SOH] Hearts value must be an integer."); + LUS::GetConsole()->SendErrorMessage("[SOH] Hearts value must be an integer."); return CMD_FAILED; } if (hearts < 0) { - Ship::GetConsole()->SendErrorMessage("[SOH] Hearts value must be a positive integer"); + LUS::GetConsole()->SendErrorMessage("[SOH] Hearts value must be a positive integer"); return CMD_FAILED; } @@ -684,42 +685,42 @@ static bool RemoveHeartContainerHandler(std::shared_ptr Console, effect->parameters[0] = -hearts; GameInteractionEffectQueryResult result = GameInteractor::ApplyEffect(effect); if (result == GameInteractionEffectQueryResult::Possible) { - Ship::GetConsole()->SendInfoMessage("[SOH] Removed %d heart containers", hearts); + LUS::GetConsole()->SendInfoMessage("[SOH] Removed %d heart containers", hearts); return CMD_SUCCESS; } else { - Ship::GetConsole()->SendInfoMessage("[SOH] Command failed: Could not remove heart containers."); + LUS::GetConsole()->SendInfoMessage("[SOH] Command failed: Could not remove heart containers."); return CMD_FAILED; } } -static bool GravityHandler(std::shared_ptr Console, const std::vector& args) { +static bool GravityHandler(std::shared_ptr Console, const std::vector& args) { if (args.size() < 2) { - Ship::GetConsole()->SendErrorMessage("[SOH] Unexpected arguments passed"); + LUS::GetConsole()->SendErrorMessage("[SOH] Unexpected arguments passed"); return CMD_FAILED; } GameInteractionEffectBase* effect = new GameInteractionEffect::ModifyGravity(); try { - effect->parameters[0] = Ship::Math::clamp(std::stoi(args[1], nullptr, 10), GI_GRAVITY_LEVEL_LIGHT, GI_GRAVITY_LEVEL_HEAVY); + effect->parameters[0] = LUS::Math::clamp(std::stoi(args[1], nullptr, 10), GI_GRAVITY_LEVEL_LIGHT, GI_GRAVITY_LEVEL_HEAVY); } catch (std::invalid_argument const& ex) { - Ship::GetConsole()->SendErrorMessage("[SOH] Gravity value must be a number."); + LUS::GetConsole()->SendErrorMessage("[SOH] Gravity value must be a number."); return CMD_FAILED; } GameInteractionEffectQueryResult result = GameInteractor::ApplyEffect(effect); if (result == GameInteractionEffectQueryResult::Possible) { - Ship::GetConsole()->SendInfoMessage("[SOH] Updated gravity."); + LUS::GetConsole()->SendInfoMessage("[SOH] Updated gravity."); return CMD_SUCCESS; } else { - Ship::GetConsole()->SendInfoMessage("[SOH] Command failed: Could not update gravity."); + LUS::GetConsole()->SendInfoMessage("[SOH] Command failed: Could not update gravity."); return CMD_FAILED; } } -static bool NoUIHandler(std::shared_ptr Console, const std::vector& args) { +static bool NoUIHandler(std::shared_ptr Console, const std::vector& args) { if (args.size() < 2) { - Ship::GetConsole()->SendErrorMessage("[SOH] Unexpected arguments passed"); + LUS::GetConsole()->SendErrorMessage("[SOH] Unexpected arguments passed"); return CMD_FAILED; } uint8_t state; @@ -727,7 +728,7 @@ static bool NoUIHandler(std::shared_ptr Console, const std::vecto try { state = std::stoi(args[1], nullptr, 10) == 0 ? 0 : 1; } catch (std::invalid_argument const& ex) { - Ship::GetConsole()->SendErrorMessage("[SOH] No UI value must be a number."); + LUS::GetConsole()->SendErrorMessage("[SOH] No UI value must be a number."); return CMD_FAILED; } @@ -736,31 +737,31 @@ static bool NoUIHandler(std::shared_ptr Console, const std::vecto state ? GameInteractor::ApplyEffect(effect) : GameInteractor::RemoveEffect(effect); if (result == GameInteractionEffectQueryResult::Possible) { - Ship::GetConsole()->SendInfoMessage("[SOH] No UI %s", state ? "enabled" : "disabled"); + LUS::GetConsole()->SendInfoMessage("[SOH] No UI %s", state ? "enabled" : "disabled"); return CMD_SUCCESS; } else { - Ship::GetConsole()->SendInfoMessage("[SOH] Command failed: Could not %s No UI.", + LUS::GetConsole()->SendInfoMessage("[SOH] Command failed: Could not %s No UI.", state ? "enable" : "disable"); return CMD_FAILED; } } -static bool FreezeHandler(std::shared_ptr Console, const std::vector& args) { +static bool FreezeHandler(std::shared_ptr Console, const std::vector& args) { GameInteractionEffectBase* effect = new GameInteractionEffect::FreezePlayer(); GameInteractionEffectQueryResult result = GameInteractor::ApplyEffect(effect); if (result == GameInteractionEffectQueryResult::Possible) { - Ship::GetConsole()->SendInfoMessage("[SOH] Player frozen"); + LUS::GetConsole()->SendInfoMessage("[SOH] Player frozen"); return CMD_SUCCESS; } else { - Ship::GetConsole()->SendInfoMessage("[SOH] Command failed: Could not freeze player."); + LUS::GetConsole()->SendInfoMessage("[SOH] Command failed: Could not freeze player."); return CMD_FAILED; } } -static bool DefenseModifierHandler(std::shared_ptr Console, const std::vector& args) { +static bool DefenseModifierHandler(std::shared_ptr Console, const std::vector& args) { if (args.size() < 2) { - Ship::GetConsole()->SendErrorMessage("[SOH] Unexpected arguments passed"); + LUS::GetConsole()->SendErrorMessage("[SOH] Unexpected arguments passed"); return CMD_FAILED; } GameInteractionEffectBase* effect = new GameInteractionEffect::ModifyDefenseModifier(); @@ -768,23 +769,23 @@ static bool DefenseModifierHandler(std::shared_ptr Console, const try { effect->parameters[0] = std::stoi(args[1], nullptr, 10); } catch (std::invalid_argument const& ex) { - Ship::GetConsole()->SendErrorMessage("[SOH] Defense modifier value must be a number."); + LUS::GetConsole()->SendErrorMessage("[SOH] Defense modifier value must be a number."); return CMD_FAILED; } GameInteractionEffectQueryResult result = GameInteractor::ApplyEffect(effect); if (result == GameInteractionEffectQueryResult::Possible) { - Ship::GetConsole()->SendInfoMessage("[SOH] Defense modifier set to %d", effect->parameters[0]); + LUS::GetConsole()->SendInfoMessage("[SOH] Defense modifier set to %d", effect->parameters[0]); return CMD_SUCCESS; } else { - Ship::GetConsole()->SendInfoMessage("[SOH] Command failed: Could not set defense modifier."); + LUS::GetConsole()->SendInfoMessage("[SOH] Command failed: Could not set defense modifier."); return CMD_FAILED; } } -static bool DamageHandler(std::shared_ptr Console, const std::vector& args) { +static bool DamageHandler(std::shared_ptr Console, const std::vector& args) { if (args.size() < 2) { - Ship::GetConsole()->SendErrorMessage("[SOH] Unexpected arguments passed"); + LUS::GetConsole()->SendErrorMessage("[SOH] Unexpected arguments passed"); return CMD_FAILED; } GameInteractionEffectBase* effect = new GameInteractionEffect::ModifyHealth(); @@ -792,29 +793,29 @@ static bool DamageHandler(std::shared_ptr Console, const std::vec try { int value = std::stoi(args[1], nullptr, 10); if (value < 0) { - Ship::GetConsole()->SendErrorMessage("[SOH] Invalid value passed. Value must be greater than 0"); + LUS::GetConsole()->SendErrorMessage("[SOH] Invalid value passed. Value must be greater than 0"); return CMD_FAILED; } effect->parameters[0] = -value; } catch (std::invalid_argument const& ex) { - Ship::GetConsole()->SendErrorMessage("[SOH] Damage value must be a number."); + LUS::GetConsole()->SendErrorMessage("[SOH] Damage value must be a number."); return CMD_FAILED; } GameInteractionEffectQueryResult result = GameInteractor::ApplyEffect(effect); if (result == GameInteractionEffectQueryResult::Possible) { - Ship::GetConsole()->SendInfoMessage("[SOH] Player damaged"); + LUS::GetConsole()->SendInfoMessage("[SOH] Player damaged"); return CMD_SUCCESS; } else { - Ship::GetConsole()->SendInfoMessage("[SOH] Command failed: Could not damage player."); + LUS::GetConsole()->SendInfoMessage("[SOH] Command failed: Could not damage player."); return CMD_FAILED; } } -static bool HealHandler(std::shared_ptr Console, const std::vector& args) { +static bool HealHandler(std::shared_ptr Console, const std::vector& args) { if (args.size() < 2) { - Ship::GetConsole()->SendErrorMessage("[SOH] Unexpected arguments passed"); + LUS::GetConsole()->SendErrorMessage("[SOH] Unexpected arguments passed"); return CMD_FAILED; } GameInteractionEffectBase* effect = new GameInteractionEffect::ModifyHealth(); @@ -822,55 +823,55 @@ static bool HealHandler(std::shared_ptr Console, const std::vecto try { int value = std::stoi(args[1], nullptr, 10); if (value < 0) { - Ship::GetConsole()->SendErrorMessage("[SOH] Invalid value passed. Value must be greater than 0"); + LUS::GetConsole()->SendErrorMessage("[SOH] Invalid value passed. Value must be greater than 0"); return CMD_FAILED; } effect->parameters[0] = value; } catch (std::invalid_argument const& ex) { - Ship::GetConsole()->SendErrorMessage("[SOH] Damage value must be a number."); + LUS::GetConsole()->SendErrorMessage("[SOH] Damage value must be a number."); return CMD_FAILED; } GameInteractionEffectQueryResult result = GameInteractor::ApplyEffect(effect); if (result == GameInteractionEffectQueryResult::Possible) { - Ship::GetConsole()->SendInfoMessage("[SOH] Player healed"); + LUS::GetConsole()->SendInfoMessage("[SOH] Player healed"); return CMD_SUCCESS; } else { - Ship::GetConsole()->SendInfoMessage("[SOH] Command failed: Could not heal player."); + LUS::GetConsole()->SendInfoMessage("[SOH] Command failed: Could not heal player."); return CMD_FAILED; } } -static bool FillMagicHandler(std::shared_ptr Console, const std::vector& args) { +static bool FillMagicHandler(std::shared_ptr Console, const std::vector& args) { GameInteractionEffectBase* effect = new GameInteractionEffect::FillMagic(); GameInteractionEffectQueryResult result = GameInteractor::ApplyEffect(effect); if (result == GameInteractionEffectQueryResult::Possible) { - Ship::GetConsole()->SendInfoMessage("[SOH] Magic filled"); + LUS::GetConsole()->SendInfoMessage("[SOH] Magic filled"); return CMD_SUCCESS; } else { - Ship::GetConsole()->SendInfoMessage("[SOH] Command failed: Could not fill magic."); + LUS::GetConsole()->SendInfoMessage("[SOH] Command failed: Could not fill magic."); return CMD_FAILED; } } -static bool EmptyMagicHandler(std::shared_ptr Console, const std::vector& args) { +static bool EmptyMagicHandler(std::shared_ptr Console, const std::vector& args) { GameInteractionEffectBase* effect = new GameInteractionEffect::EmptyMagic(); GameInteractionEffectQueryResult result = GameInteractor::ApplyEffect(effect); if (result == GameInteractionEffectQueryResult::Possible) { - Ship::GetConsole()->SendInfoMessage("[SOH] Magic emptied"); + LUS::GetConsole()->SendInfoMessage("[SOH] Magic emptied"); return CMD_SUCCESS; } else { - Ship::GetConsole()->SendInfoMessage("[SOH] Command failed: Could not empty magic."); + LUS::GetConsole()->SendInfoMessage("[SOH] Command failed: Could not empty magic."); return CMD_FAILED; } } -static bool NoZHandler(std::shared_ptr Console, const std::vector& args) { +static bool NoZHandler(std::shared_ptr Console, const std::vector& args) { if (args.size() < 2) { - Ship::GetConsole()->SendErrorMessage("[SOH] Unexpected arguments passed"); + LUS::GetConsole()->SendErrorMessage("[SOH] Unexpected arguments passed"); return CMD_FAILED; } uint8_t state; @@ -878,7 +879,7 @@ static bool NoZHandler(std::shared_ptr Console, const std::vector try { state = std::stoi(args[1], nullptr, 10) == 0 ? 0 : 1; } catch (std::invalid_argument const& ex) { - Ship::GetConsole()->SendErrorMessage("[SOH] NoZ value must be a number."); + LUS::GetConsole()->SendErrorMessage("[SOH] NoZ value must be a number."); return CMD_FAILED; } @@ -887,18 +888,18 @@ static bool NoZHandler(std::shared_ptr Console, const std::vector state ? GameInteractor::ApplyEffect(effect) : GameInteractor::RemoveEffect(effect); if (result == GameInteractionEffectQueryResult::Possible) { - Ship::GetConsole()->SendInfoMessage("[SOH] NoZ " + std::string(state ? "enabled" : "disabled")); + LUS::GetConsole()->SendInfoMessage("[SOH] NoZ " + std::string(state ? "enabled" : "disabled")); return CMD_SUCCESS; } else { - Ship::GetConsole()->SendInfoMessage("[SOH] Command failed: Could not " + + LUS::GetConsole()->SendInfoMessage("[SOH] Command failed: Could not " + std::string(state ? "enable" : "disable") + " NoZ."); return CMD_FAILED; } } -static bool OneHitKOHandler(std::shared_ptr Console, const std::vector& args) { +static bool OneHitKOHandler(std::shared_ptr Console, const std::vector& args) { if (args.size() < 2) { - Ship::GetConsole()->SendErrorMessage("[SOH] Unexpected arguments passed"); + LUS::GetConsole()->SendErrorMessage("[SOH] Unexpected arguments passed"); return CMD_FAILED; } uint8_t state; @@ -906,7 +907,7 @@ static bool OneHitKOHandler(std::shared_ptr Console, const std::v try { state = std::stoi(args[1], nullptr, 10) == 0 ? 0 : 1; } catch (std::invalid_argument const& ex) { - Ship::GetConsole()->SendErrorMessage("[SOH] One-hit KO value must be a number."); + LUS::GetConsole()->SendErrorMessage("[SOH] One-hit KO value must be a number."); return CMD_FAILED; } @@ -915,18 +916,18 @@ static bool OneHitKOHandler(std::shared_ptr Console, const std::v state ? GameInteractor::ApplyEffect(effect) : GameInteractor::RemoveEffect(effect); if (result == GameInteractionEffectQueryResult::Possible) { - Ship::GetConsole()->SendInfoMessage("[SOH] One-hit KO " + std::string(state ? "enabled" : "disabled")); + LUS::GetConsole()->SendInfoMessage("[SOH] One-hit KO " + std::string(state ? "enabled" : "disabled")); return CMD_SUCCESS; } else { - Ship::GetConsole()->SendInfoMessage("[SOH] Command failed: Could not " + + LUS::GetConsole()->SendInfoMessage("[SOH] Command failed: Could not " + std::string(state ? "enable" : "disable") + " One-hit KO."); return CMD_FAILED; } } -static bool PacifistHandler(std::shared_ptr Console, const std::vector& args) { +static bool PacifistHandler(std::shared_ptr Console, const std::vector& args) { if (args.size() < 2) { - Ship::GetConsole()->SendErrorMessage("[SOH] Unexpected arguments passed"); + LUS::GetConsole()->SendErrorMessage("[SOH] Unexpected arguments passed"); return CMD_FAILED; } uint8_t state; @@ -934,7 +935,7 @@ static bool PacifistHandler(std::shared_ptr Console, const std::v try { state = std::stoi(args[1], nullptr, 10) == 0 ? 0 : 1; } catch (std::invalid_argument const& ex) { - Ship::GetConsole()->SendErrorMessage("[SOH] Pacifist value must be a number."); + LUS::GetConsole()->SendErrorMessage("[SOH] Pacifist value must be a number."); return CMD_FAILED; } @@ -943,18 +944,18 @@ static bool PacifistHandler(std::shared_ptr Console, const std::v state ? GameInteractor::ApplyEffect(effect) : GameInteractor::RemoveEffect(effect); if (result == GameInteractionEffectQueryResult::Possible) { - Ship::GetConsole()->SendInfoMessage("[SOH] Pacifist " + std::string(state ? "enabled" : "disabled")); + LUS::GetConsole()->SendInfoMessage("[SOH] Pacifist " + std::string(state ? "enabled" : "disabled")); return CMD_SUCCESS; } else { - Ship::GetConsole()->SendInfoMessage("[SOH] Command failed: Could not " + + LUS::GetConsole()->SendInfoMessage("[SOH] Command failed: Could not " + std::string(state ? "enable" : "disable") + " Pacifist."); return CMD_FAILED; } } -static bool PaperLinkHandler(std::shared_ptr Console, const std::vector& args) { +static bool PaperLinkHandler(std::shared_ptr Console, const std::vector& args) { if (args.size() < 2) { - Ship::GetConsole()->SendErrorMessage("[SOH] Unexpected arguments passed"); + LUS::GetConsole()->SendErrorMessage("[SOH] Unexpected arguments passed"); return CMD_FAILED; } uint8_t state; @@ -962,7 +963,7 @@ static bool PaperLinkHandler(std::shared_ptr Console, const std:: try { state = std::stoi(args[1], nullptr, 10) == 0 ? 0 : 1; } catch (std::invalid_argument const& ex) { - Ship::GetConsole()->SendErrorMessage("[SOH] Paper Link value must be a number."); + LUS::GetConsole()->SendErrorMessage("[SOH] Paper Link value must be a number."); return CMD_FAILED; } @@ -972,18 +973,18 @@ static bool PaperLinkHandler(std::shared_ptr Console, const std:: state ? GameInteractor::ApplyEffect(effect) : GameInteractor::RemoveEffect(effect); if (result == GameInteractionEffectQueryResult::Possible) { - Ship::GetConsole()->SendInfoMessage("[SOH] Paper Link " + std::string(state ? "enabled" : "disabled")); + LUS::GetConsole()->SendInfoMessage("[SOH] Paper Link " + std::string(state ? "enabled" : "disabled")); return CMD_SUCCESS; } else { - Ship::GetConsole()->SendInfoMessage("[SOH] Command failed: Could not " + + LUS::GetConsole()->SendInfoMessage("[SOH] Command failed: Could not " + std::string(state ? "enable" : "disable") + " Paper Link."); return CMD_FAILED; } } -static bool RainstormHandler(std::shared_ptr Console, const std::vector& args) { +static bool RainstormHandler(std::shared_ptr Console, const std::vector& args) { if (args.size() < 2) { - Ship::GetConsole()->SendErrorMessage("[SOH] Unexpected arguments passed"); + LUS::GetConsole()->SendErrorMessage("[SOH] Unexpected arguments passed"); return CMD_FAILED; } uint8_t state; @@ -991,7 +992,7 @@ static bool RainstormHandler(std::shared_ptr Console, const std:: try { state = std::stoi(args[1], nullptr, 10) == 0 ? 0 : 1; } catch (std::invalid_argument const& ex) { - Ship::GetConsole()->SendErrorMessage("[SOH] Rainstorm value must be a number."); + LUS::GetConsole()->SendErrorMessage("[SOH] Rainstorm value must be a number."); return CMD_FAILED; } @@ -1000,18 +1001,18 @@ static bool RainstormHandler(std::shared_ptr Console, const std:: state ? GameInteractor::ApplyEffect(effect) : GameInteractor::RemoveEffect(effect); if (result == GameInteractionEffectQueryResult::Possible) { - Ship::GetConsole()->SendInfoMessage("[SOH] Rainstorm " + std::string(state ? "enabled" : "disabled")); + LUS::GetConsole()->SendInfoMessage("[SOH] Rainstorm " + std::string(state ? "enabled" : "disabled")); return CMD_SUCCESS; } else { - Ship::GetConsole()->SendInfoMessage("[SOH] Command failed: Could not " + + LUS::GetConsole()->SendInfoMessage("[SOH] Command failed: Could not " + std::string(state ? "enable" : "disable") + " Rainstorm."); return CMD_FAILED; } } -static bool ReverseControlsHandler(std::shared_ptr Console, const std::vector& args) { +static bool ReverseControlsHandler(std::shared_ptr Console, const std::vector& args) { if (args.size() < 2) { - Ship::GetConsole()->SendErrorMessage("[SOH] Unexpected arguments passed"); + LUS::GetConsole()->SendErrorMessage("[SOH] Unexpected arguments passed"); return CMD_FAILED; } uint8_t state; @@ -1019,7 +1020,7 @@ static bool ReverseControlsHandler(std::shared_ptr Console, const try { state = std::stoi(args[1], nullptr, 10) == 0 ? 0 : 1; } catch (std::invalid_argument const& ex) { - Ship::GetConsole()->SendErrorMessage("[SOH] Reverse controls value must be a number."); + LUS::GetConsole()->SendErrorMessage("[SOH] Reverse controls value must be a number."); return CMD_FAILED; } @@ -1028,19 +1029,19 @@ static bool ReverseControlsHandler(std::shared_ptr Console, const state ? GameInteractor::ApplyEffect(effect) : GameInteractor::RemoveEffect(effect); if (result == GameInteractionEffectQueryResult::Possible) { - Ship::GetConsole()->SendInfoMessage("[SOH] Reverse controls " + + LUS::GetConsole()->SendInfoMessage("[SOH] Reverse controls " + std::string(state ? "enabled" : "disabled")); return CMD_SUCCESS; } else { - Ship::GetConsole()->SendInfoMessage("[SOH] Command failed: Could not " + + LUS::GetConsole()->SendInfoMessage("[SOH] Command failed: Could not " + std::string(state ? "enable" : "disable") + " Reverse controls."); return CMD_FAILED; } } -static bool UpdateRupeesHandler(std::shared_ptr Console, const std::vector& args) { +static bool UpdateRupeesHandler(std::shared_ptr Console, const std::vector& args) { if (args.size() < 2) { - Ship::GetConsole()->SendErrorMessage("[SOH] Unexpected arguments passed"); + LUS::GetConsole()->SendErrorMessage("[SOH] Unexpected arguments passed"); return CMD_FAILED; } GameInteractionEffectBase* effect = new GameInteractionEffect::ModifyRupees(); @@ -1048,23 +1049,23 @@ static bool UpdateRupeesHandler(std::shared_ptr Console, const st try { effect->parameters[0] = std::stoi(args[1], nullptr, 10); } catch (std::invalid_argument const& ex) { - Ship::GetConsole()->SendErrorMessage("[SOH] Rupee value must be a number."); + LUS::GetConsole()->SendErrorMessage("[SOH] Rupee value must be a number."); return CMD_FAILED; } GameInteractionEffectQueryResult result = GameInteractor::ApplyEffect(effect); if (result == GameInteractionEffectQueryResult::Possible) { - Ship::GetConsole()->SendInfoMessage("[SOH] Rupees updated"); + LUS::GetConsole()->SendInfoMessage("[SOH] Rupees updated"); return CMD_SUCCESS; } else { - Ship::GetConsole()->SendInfoMessage("[SOH] Command failed: Could not update rupees."); + LUS::GetConsole()->SendInfoMessage("[SOH] Command failed: Could not update rupees."); return CMD_FAILED; } } -static bool SpeedModifierHandler(std::shared_ptr Console, const std::vector& args) { +static bool SpeedModifierHandler(std::shared_ptr Console, const std::vector& args) { if (args.size() < 2) { - Ship::GetConsole()->SendErrorMessage("[SOH] Unexpected arguments passed"); + LUS::GetConsole()->SendErrorMessage("[SOH] Unexpected arguments passed"); return CMD_FAILED; } GameInteractionEffectBase* effect = new GameInteractionEffect::ModifyRunSpeedModifier(); @@ -1072,16 +1073,16 @@ static bool SpeedModifierHandler(std::shared_ptr Console, const s try { effect->parameters[0] = std::stoi(args[1], nullptr, 10); } catch (std::invalid_argument const& ex) { - Ship::GetConsole()->SendErrorMessage("[SOH] Speed modifier value must be a number."); + LUS::GetConsole()->SendErrorMessage("[SOH] Speed modifier value must be a number."); return CMD_FAILED; } GameInteractionEffectQueryResult result = GameInteractor::ApplyEffect(effect); if (result == GameInteractionEffectQueryResult::Possible) { - Ship::GetConsole()->SendInfoMessage("[SOH] Speed modifier updated"); + LUS::GetConsole()->SendInfoMessage("[SOH] Speed modifier updated"); return CMD_SUCCESS; } else { - Ship::GetConsole()->SendInfoMessage("[SOH] Command failed: Could not update speed modifier."); + LUS::GetConsole()->SendInfoMessage("[SOH] Command failed: Could not update speed modifier."); return CMD_FAILED; } } @@ -1092,15 +1093,15 @@ const static std::map boots { { "hover", PLAYER_BOOTS_HOVER }, }; -static bool BootsHandler(std::shared_ptr Console, const std::vector& args) { +static bool BootsHandler(std::shared_ptr Console, const std::vector& args) { if (args.size() < 2) { - Ship::GetConsole()->SendErrorMessage("[SOH] Unexpected arguments passed"); + LUS::GetConsole()->SendErrorMessage("[SOH] Unexpected arguments passed"); return CMD_FAILED; } const auto& it = boots.find(args[1]); if (it == boots.end()) { - Ship::GetConsole()->SendErrorMessage("Invalid boot type. Options are 'kokiri', 'iron' and 'hover'"); + LUS::GetConsole()->SendErrorMessage("Invalid boot type. Options are 'kokiri', 'iron' and 'hover'"); return CMD_FAILED; } @@ -1109,10 +1110,10 @@ static bool BootsHandler(std::shared_ptr Console, const std::vect GameInteractionEffectQueryResult result = GameInteractor::ApplyEffect(effect); if (result == GameInteractionEffectQueryResult::Possible) { - Ship::GetConsole()->SendInfoMessage("[SOH] Boots updated."); + LUS::GetConsole()->SendInfoMessage("[SOH] Boots updated."); return CMD_SUCCESS; } else { - Ship::GetConsole()->SendInfoMessage("[SOH] Command failed: Could not update boots."); + LUS::GetConsole()->SendInfoMessage("[SOH] Command failed: Could not update boots."); return CMD_FAILED; } } @@ -1123,15 +1124,15 @@ const static std::map shields { { "mirror", ITEM_SHIELD_MIRROR }, }; -static bool GiveShieldHandler(std::shared_ptr Console, const std::vector& args) { +static bool GiveShieldHandler(std::shared_ptr Console, const std::vector& args) { if (args.size() < 2) { - Ship::GetConsole()->SendErrorMessage("[SOH] Unexpected arguments passed"); + LUS::GetConsole()->SendErrorMessage("[SOH] Unexpected arguments passed"); return CMD_FAILED; } const auto& it = shields.find(args[1]); if (it == shields.end()) { - Ship::GetConsole()->SendErrorMessage("Invalid shield type. Options are 'deku', 'hylian' and 'mirror'"); + LUS::GetConsole()->SendErrorMessage("Invalid shield type. Options are 'deku', 'hylian' and 'mirror'"); return CMD_FAILED; } @@ -1140,23 +1141,23 @@ static bool GiveShieldHandler(std::shared_ptr Console, const std: GameInteractionEffectQueryResult result = GameInteractor::ApplyEffect(effect); if (result == GameInteractionEffectQueryResult::Possible) { - Ship::GetConsole()->SendInfoMessage("[SOH] Gave shield."); + LUS::GetConsole()->SendInfoMessage("[SOH] Gave shield."); return CMD_SUCCESS; } else { - Ship::GetConsole()->SendInfoMessage("[SOH] Command failed: Could not give shield."); + LUS::GetConsole()->SendInfoMessage("[SOH] Command failed: Could not give shield."); return CMD_FAILED; } } -static bool TakeShieldHandler(std::shared_ptr Console, const std::vector& args) { +static bool TakeShieldHandler(std::shared_ptr Console, const std::vector& args) { if (args.size() < 2) { - Ship::GetConsole()->SendErrorMessage("[SOH] Unexpected arguments passed"); + LUS::GetConsole()->SendErrorMessage("[SOH] Unexpected arguments passed"); return CMD_FAILED; } const auto& it = shields.find(args[1]); if (it == shields.end()) { - Ship::GetConsole()->SendErrorMessage("Invalid shield type. Options are 'deku', 'hylian' and 'mirror'"); + LUS::GetConsole()->SendErrorMessage("Invalid shield type. Options are 'deku', 'hylian' and 'mirror'"); return CMD_FAILED; } @@ -1165,17 +1166,17 @@ static bool TakeShieldHandler(std::shared_ptr Console, const std: GameInteractionEffectQueryResult result = GameInteractor::ApplyEffect(effect); if (result == GameInteractionEffectQueryResult::Possible) { - Ship::GetConsole()->SendInfoMessage("[SOH] Took shield."); + LUS::GetConsole()->SendInfoMessage("[SOH] Took shield."); return CMD_SUCCESS; } else { - Ship::GetConsole()->SendInfoMessage("[SOH] Command failed: Could not take shield."); + LUS::GetConsole()->SendInfoMessage("[SOH] Command failed: Could not take shield."); return CMD_FAILED; } } -static bool KnockbackHandler(std::shared_ptr Console, const std::vector& args) { +static bool KnockbackHandler(std::shared_ptr Console, const std::vector& args) { if (args.size() < 2) { - Ship::GetConsole()->SendErrorMessage("[SOH] Unexpected arguments passed"); + LUS::GetConsole()->SendErrorMessage("[SOH] Unexpected arguments passed"); return CMD_FAILED; } GameInteractionEffectBase* effect = new GameInteractionEffect::KnockbackPlayer(); @@ -1183,65 +1184,65 @@ static bool KnockbackHandler(std::shared_ptr Console, const std:: try { int value = std::stoi(args[1], nullptr, 10); if (value < 0) { - Ship::GetConsole()->SendErrorMessage("[SOH] Invalid value passed. Value must be greater than 0"); + LUS::GetConsole()->SendErrorMessage("[SOH] Invalid value passed. Value must be greater than 0"); return CMD_FAILED; } effect->parameters[0] = value; } catch (std::invalid_argument const& ex) { - Ship::GetConsole()->SendErrorMessage("[SOH] Knockback value must be a number."); + LUS::GetConsole()->SendErrorMessage("[SOH] Knockback value must be a number."); return CMD_FAILED; } GameInteractionEffectQueryResult result = GameInteractor::ApplyEffect(effect); if (result == GameInteractionEffectQueryResult::Possible) { - Ship::GetConsole()->SendInfoMessage("[SOH] Knockback applied"); + LUS::GetConsole()->SendInfoMessage("[SOH] Knockback applied"); return CMD_SUCCESS; } else { - Ship::GetConsole()->SendInfoMessage("[SOH] Command failed: Could not apply knockback."); + LUS::GetConsole()->SendInfoMessage("[SOH] Command failed: Could not apply knockback."); return CMD_FAILED; } } -static bool ElectrocuteHandler(std::shared_ptr Console, const std::vector& args) { +static bool ElectrocuteHandler(std::shared_ptr Console, const std::vector& args) { GameInteractionEffectBase* effect = new GameInteractionEffect::ElectrocutePlayer(); GameInteractionEffectQueryResult result = GameInteractor::ApplyEffect(effect); if (result == GameInteractionEffectQueryResult::Possible) { - Ship::GetConsole()->SendInfoMessage("[SOH] Electrocuted player"); + LUS::GetConsole()->SendInfoMessage("[SOH] Electrocuted player"); return CMD_SUCCESS; } else { - Ship::GetConsole()->SendInfoMessage("[SOH] Command failed: Could not electrocute player."); + LUS::GetConsole()->SendInfoMessage("[SOH] Command failed: Could not electrocute player."); return CMD_FAILED; } } -static bool BurnHandler(std::shared_ptr Console, const std::vector& args) { +static bool BurnHandler(std::shared_ptr Console, const std::vector& args) { GameInteractionEffectBase* effect = new GameInteractionEffect::BurnPlayer(); GameInteractionEffectQueryResult result = GameInteractor::ApplyEffect(effect); if (result == GameInteractionEffectQueryResult::Possible) { - Ship::GetConsole()->SendInfoMessage("[SOH] Burned player"); + LUS::GetConsole()->SendInfoMessage("[SOH] Burned player"); return CMD_SUCCESS; } else { - Ship::GetConsole()->SendInfoMessage("[SOH] Command failed: Could not burn player."); + LUS::GetConsole()->SendInfoMessage("[SOH] Command failed: Could not burn player."); return CMD_FAILED; } } -static bool CuccoStormHandler(std::shared_ptr Console, const std::vector& args) { +static bool CuccoStormHandler(std::shared_ptr Console, const std::vector& args) { GameInteractionEffectQueryResult result = GameInteractor::RawAction::SpawnActor(ACTOR_EN_NIW, 0); if (result == GameInteractionEffectQueryResult::Possible) { - Ship::GetConsole()->SendInfoMessage("[SOH] Spawned cucco storm"); + LUS::GetConsole()->SendInfoMessage("[SOH] Spawned cucco storm"); return CMD_SUCCESS; } else { - Ship::GetConsole()->SendInfoMessage("[SOH] Command failed: Could not spawn cucco storm."); + LUS::GetConsole()->SendInfoMessage("[SOH] Command failed: Could not spawn cucco storm."); return CMD_FAILED; } } -static bool GenerateRandoHandler(std::shared_ptr Console, const std::vector& args) { +static bool GenerateRandoHandler(std::shared_ptr Console, const std::vector& args) { if (args.size() == 1) { if (GenerateRandomizer()) { return CMD_SUCCESS; @@ -1260,18 +1261,18 @@ static bool GenerateRandoHandler(std::shared_ptr Console, const s return CMD_SUCCESS; } } catch (std::invalid_argument const& ex) { - Ship::GetConsole()->SendErrorMessage("[SOH] seed|count value must be a number."); + LUS::GetConsole()->SendErrorMessage("[SOH] seed|count value must be a number."); return CMD_FAILED; } - Ship::GetConsole()->SendErrorMessage("[SOH] Rando generation already in progress"); + LUS::GetConsole()->SendErrorMessage("[SOH] Rando generation already in progress"); return CMD_FAILED; } -static bool CosmeticsHandler(std::shared_ptr Console, const std::vector& args) { +static bool CosmeticsHandler(std::shared_ptr Console, const std::vector& args) { if (args.size() < 2) { - Ship::GetConsole()->SendErrorMessage("[SOH] Unexpected arguments passed"); + LUS::GetConsole()->SendErrorMessage("[SOH] Unexpected arguments passed"); return CMD_FAILED; } @@ -1280,16 +1281,16 @@ static bool CosmeticsHandler(std::shared_ptr Console, const std:: } else if (args[1].compare("randomize") == 0) { CosmeticsEditor_RandomizeAll(); } else { - Ship::GetConsole()->SendErrorMessage("[SOH] Invalid argument passed, must be 'reset' or 'randomize'"); + LUS::GetConsole()->SendErrorMessage("[SOH] Invalid argument passed, must be 'reset' or 'randomize'"); return CMD_FAILED; } return CMD_SUCCESS; } -static bool SfxHandler(std::shared_ptr Console, const std::vector& args) { +static bool SfxHandler(std::shared_ptr Console, const std::vector& args) { if (args.size() < 2) { - Ship::GetConsole()->SendErrorMessage("[SOH] Unexpected arguments passed"); + LUS::GetConsole()->SendErrorMessage("[SOH] Unexpected arguments passed"); return CMD_FAILED; } @@ -1298,7 +1299,7 @@ static bool SfxHandler(std::shared_ptr Console, const std::vector } else if (args[1].compare("randomize") == 0) { AudioEditor_RandomizeAll(); } else { - Ship::GetConsole()->SendErrorMessage("[SOH] Invalid argument passed, must be 'reset' or 'randomize'"); + LUS::GetConsole()->SendErrorMessage("[SOH] Invalid argument passed, must be 'reset' or 'randomize'"); return CMD_FAILED; } @@ -1336,7 +1337,7 @@ static int CheckVarType(const std::string& input) return result; } -static bool SetCVarHandler(std::shared_ptr Console, const std::vector& args) { +static bool SetCVarHandler(std::shared_ptr Console, const std::vector& args) { if (args.size() < 3) return CMD_FAILED; @@ -1361,11 +1362,11 @@ static bool SetCVarHandler(std::shared_ptr Console, const std::ve CVarSave(); - //Ship::GetConsole()->SendInfoMessage("[SOH] Updated player position to [ %.2f, %.2f, %.2f ]", pos.x, pos.y, pos.z); + //LUS::GetConsole()->SendInfoMessage("[SOH] Updated player position to [ %.2f, %.2f, %.2f ]", pos.x, pos.y, pos.z); return CMD_SUCCESS; } -static bool GetCVarHandler(std::shared_ptr Console, const std::vector& args) { +static bool GetCVarHandler(std::shared_ptr Console, const std::vector& args) { if (args.size() < 2) return CMD_FAILED; @@ -1373,18 +1374,18 @@ static bool GetCVarHandler(std::shared_ptr Console, const std::ve if (cvar != nullptr) { - if (cvar->Type == Ship::ConsoleVariableType::Integer) - Ship::GetConsole()->SendInfoMessage("[SOH] Variable %s is %i", args[1].c_str(), cvar->Integer); - else if (cvar->Type == Ship::ConsoleVariableType::Float) - Ship::GetConsole()->SendInfoMessage("[SOH] Variable %s is %f", args[1].c_str(), cvar->Float); - else if (cvar->Type == Ship::ConsoleVariableType::String) - Ship::GetConsole()->SendInfoMessage("[SOH] Variable %s is %s", args[1].c_str(), cvar->String.c_str()); - else if (cvar->Type == Ship::ConsoleVariableType::Color) - Ship::GetConsole()->SendInfoMessage("[SOH] Variable %s is %08X", args[1].c_str(), cvar->Color); + if (cvar->Type == LUS::ConsoleVariableType::Integer) + LUS::GetConsole()->SendInfoMessage("[SOH] Variable %s is %i", args[1].c_str(), cvar->Integer); + else if (cvar->Type == LUS::ConsoleVariableType::Float) + LUS::GetConsole()->SendInfoMessage("[SOH] Variable %s is %f", args[1].c_str(), cvar->Float); + else if (cvar->Type == LUS::ConsoleVariableType::String) + LUS::GetConsole()->SendInfoMessage("[SOH] Variable %s is %s", args[1].c_str(), cvar->String.c_str()); + else if (cvar->Type == LUS::ConsoleVariableType::Color) + LUS::GetConsole()->SendInfoMessage("[SOH] Variable %s is %08X", args[1].c_str(), cvar->Color); } else { - Ship::GetConsole()->SendInfoMessage("[SOH] Could not find variable %s", args[1].c_str()); + LUS::GetConsole()->SendInfoMessage("[SOH] Could not find variable %s", args[1].c_str()); } @@ -1401,17 +1402,17 @@ void DebugConsole_Init(void) { CMD_REGISTER("save_state", { SaveStateHandler, "Save a state." }); CMD_REGISTER("load_state", { LoadStateHandler, "Load a state." }); CMD_REGISTER("set_slot", { StateSlotSelectHandler, "Selects a SaveState slot", { - { "Slot number", Ship::ArgumentType::NUMBER, } + { "Slot number", LUS::ArgumentType::NUMBER, } }}); // Map & Location CMD_REGISTER("void", { VoidHandler, "Voids out of the current map." }); CMD_REGISTER("reload", { ReloadHandler, "Reloads the current map." }); CMD_REGISTER("fw", { FWHandler,"Spawns the player where Farore's Wind is set." , { - { "clear|warp|backup", Ship::ArgumentType::TEXT } + { "clear|warp|backup", LUS::ArgumentType::TEXT } }}); CMD_REGISTER("entrance", { EntranceHandler, "Sends player to the entered entrance (hex)", { - { "entrance", Ship::ArgumentType::NUMBER } + { "entrance", LUS::ArgumentType::NUMBER } }}); // Gameplay @@ -1420,73 +1421,73 @@ void DebugConsole_Init(void) { CMD_REGISTER("map", { LoadSceneHandler, "Load up kak?" }); CMD_REGISTER("rupee", { RupeeHandler, "Set your rupee counter.", { - {"amount", Ship::ArgumentType::NUMBER } + {"amount", LUS::ArgumentType::NUMBER } }}); CMD_REGISTER("bItem", { BHandler, "Set an item to the B button.", { - { "Item ID", Ship::ArgumentType::NUMBER } + { "Item ID", LUS::ArgumentType::NUMBER } }}); - CMD_REGISTER("spawn", { ActorSpawnHandler, "Spawn an actor.", { { "actor_id", Ship::ArgumentType::NUMBER }, - { "data", Ship::ArgumentType::NUMBER }, - { "x", Ship::ArgumentType::PLAYER_POS, true }, - { "y", Ship::ArgumentType::PLAYER_POS, true }, - { "z", Ship::ArgumentType::PLAYER_POS, true }, - { "rx", Ship::ArgumentType::PLAYER_ROT, true }, - { "ry", Ship::ArgumentType::PLAYER_ROT, true }, - { "rz", Ship::ArgumentType::PLAYER_ROT, true } + CMD_REGISTER("spawn", { ActorSpawnHandler, "Spawn an actor.", { { "actor_id", LUS::ArgumentType::NUMBER }, + { "data", LUS::ArgumentType::NUMBER }, + { "x", LUS::ArgumentType::PLAYER_POS, true }, + { "y", LUS::ArgumentType::PLAYER_POS, true }, + { "z", LUS::ArgumentType::PLAYER_POS, true }, + { "rx", LUS::ArgumentType::PLAYER_ROT, true }, + { "ry", LUS::ArgumentType::PLAYER_ROT, true }, + { "rz", LUS::ArgumentType::PLAYER_ROT, true } }}); CMD_REGISTER("pos", { SetPosHandler, "Sets the position of the player.", { - { "x", Ship::ArgumentType::PLAYER_POS, true }, - { "y", Ship::ArgumentType::PLAYER_POS, true }, - { "z", Ship::ArgumentType::PLAYER_POS, true } + { "x", LUS::ArgumentType::PLAYER_POS, true }, + { "y", LUS::ArgumentType::PLAYER_POS, true }, + { "z", LUS::ArgumentType::PLAYER_POS, true } }}); CMD_REGISTER("set", { SetCVarHandler, "Sets a console variable.", { - { "varName", Ship::ArgumentType::TEXT }, - { "varValue", Ship::ArgumentType::TEXT } + { "varName", LUS::ArgumentType::TEXT }, + { "varValue", LUS::ArgumentType::TEXT } }}); CMD_REGISTER("get", { GetCVarHandler, "Gets a console variable.", { - { "varName", Ship::ArgumentType::TEXT } + { "varName", LUS::ArgumentType::TEXT } }}); CMD_REGISTER("addammo", { AddAmmoHandler, "Adds ammo of an item.", { - { "sticks|nuts|bombs|seeds|arrows|bombchus|beans", Ship::ArgumentType::TEXT }, - { "count", Ship::ArgumentType::NUMBER } + { "sticks|nuts|bombs|seeds|arrows|bombchus|beans", LUS::ArgumentType::TEXT }, + { "count", LUS::ArgumentType::NUMBER } }}); CMD_REGISTER("takeammo", { TakeAmmoHandler, "Removes ammo of an item.", { - { "sticks|nuts|bombs|seeds|arrows|bombchus|beans", Ship::ArgumentType::TEXT }, - { "count", Ship::ArgumentType::NUMBER } + { "sticks|nuts|bombs|seeds|arrows|bombchus|beans", LUS::ArgumentType::TEXT }, + { "count", LUS::ArgumentType::NUMBER } }}); CMD_REGISTER("bottle", { BottleHandler, "Changes item in a bottle slot.", { - { "item", Ship::ArgumentType::TEXT }, - { "slot", Ship::ArgumentType::NUMBER } + { "item", LUS::ArgumentType::TEXT }, + { "slot", LUS::ArgumentType::NUMBER } }}); CMD_REGISTER("give_item", { GiveItemHandler, "Gives an item to the player as if it was given from an actor", { - { "vanilla|randomizer", Ship::ArgumentType::TEXT }, - { "giveItemID", Ship::ArgumentType::NUMBER } + { "vanilla|randomizer", LUS::ArgumentType::TEXT }, + { "giveItemID", LUS::ArgumentType::NUMBER } }}); CMD_REGISTER("item", { ItemHandler, "Sets item ID in arg 1 into slot arg 2. No boundary checks. Use with caution.", { - { "slot", Ship::ArgumentType::NUMBER }, - { "item id", Ship::ArgumentType::NUMBER } + { "slot", LUS::ArgumentType::NUMBER }, + { "item id", LUS::ArgumentType::NUMBER } }}); CMD_REGISTER("invisible", { InvisibleHandler, "Activate Link's Elvish cloak, making him appear invisible.", { - { "value", Ship::ArgumentType::NUMBER } + { "value", LUS::ArgumentType::NUMBER } }}); CMD_REGISTER("giant_link", { GiantLinkHandler, "Turn Link into a giant Lonky boi.", { - { "value", Ship::ArgumentType::NUMBER } + { "value", LUS::ArgumentType::NUMBER } }}); CMD_REGISTER("minish_link", { MinishLinkHandler, "Turn Link into a minish boi.", { - { "value", Ship::ArgumentType::NUMBER } + { "value", LUS::ArgumentType::NUMBER } }}); CMD_REGISTER("add_heart_container", { AddHeartContainerHandler, "Give Link a heart! The maximum amount of hearts is 20!" }); @@ -1494,25 +1495,25 @@ void DebugConsole_Init(void) { CMD_REGISTER("remove_heart_container", { RemoveHeartContainerHandler, "Remove a heart from Link. The minimal amount of hearts is 3." }); CMD_REGISTER("gravity", { GravityHandler, "Set gravity level.", { - { "value", Ship::ArgumentType::NUMBER } + { "value", LUS::ArgumentType::NUMBER } }}); CMD_REGISTER("no_ui", { NoUIHandler, "Disables the UI.", { - { "value", Ship::ArgumentType::NUMBER } + { "value", LUS::ArgumentType::NUMBER } }}); CMD_REGISTER("freeze", { FreezeHandler, "Freezes Link in place" }); CMD_REGISTER("defense_modifier", { DefenseModifierHandler, "Sets the defense modifier.", { - { "value", Ship::ArgumentType::NUMBER } + { "value", LUS::ArgumentType::NUMBER } }}); CMD_REGISTER("damage", { DamageHandler, "Deal damage to Link.", { - { "value", Ship::ArgumentType::NUMBER } + { "value", LUS::ArgumentType::NUMBER } }}); CMD_REGISTER("heal", { HealHandler, "Heals Link.", { - { "value", Ship::ArgumentType::NUMBER } + { "value", LUS::ArgumentType::NUMBER } }}); CMD_REGISTER("fill_magic", { FillMagicHandler, "Fills magic." }); @@ -1520,49 +1521,49 @@ void DebugConsole_Init(void) { CMD_REGISTER("empty_magic", { EmptyMagicHandler, "Empties magic." }); CMD_REGISTER("no_z", { NoZHandler, "Disables Z-button presses.", { - { "value", Ship::ArgumentType::NUMBER } + { "value", LUS::ArgumentType::NUMBER } }}); CMD_REGISTER("ohko", { OneHitKOHandler, "Activates one hit KO. Any damage kills Link and he cannot gain health in this mode.", { - { "value", Ship::ArgumentType::NUMBER } + { "value", LUS::ArgumentType::NUMBER } }}); CMD_REGISTER("pacifist", { PacifistHandler, "Activates pacifist mode. Prevents Link from using his weapon.", { - { "value", Ship::ArgumentType::NUMBER } + { "value", LUS::ArgumentType::NUMBER } }}); CMD_REGISTER("paper_link", { PaperLinkHandler, "Link but made out of paper.", { - { "value", Ship::ArgumentType::NUMBER } + { "value", LUS::ArgumentType::NUMBER } }}); CMD_REGISTER("rainstorm", { RainstormHandler, "Activates rainstorm." }); CMD_REGISTER("reverse_controls", { ReverseControlsHandler, "Reverses the controls.", { - { "value", Ship::ArgumentType::NUMBER } + { "value", LUS::ArgumentType::NUMBER } }}); CMD_REGISTER("update_rupees", { UpdateRupeesHandler, "Adds rupees.", { - { "value", Ship::ArgumentType::NUMBER } + { "value", LUS::ArgumentType::NUMBER } }}); CMD_REGISTER("speed_modifier", { SpeedModifierHandler, "Sets the speed modifier.", { - { "value", Ship::ArgumentType::NUMBER } + { "value", LUS::ArgumentType::NUMBER } }}); CMD_REGISTER("boots", { BootsHandler, "Activates boots.", { - { "kokiri|iron|hover", Ship::ArgumentType::TEXT }, + { "kokiri|iron|hover", LUS::ArgumentType::TEXT }, }}); CMD_REGISTER("giveshield", { GiveShieldHandler, "Gives a shield and equips it when Link is the right age for it.", { - { "deku|hylian|mirror", Ship::ArgumentType::TEXT }, + { "deku|hylian|mirror", LUS::ArgumentType::TEXT }, }}); CMD_REGISTER("takeshield", { TakeShieldHandler, "Takes a shield and unequips it if Link is wearing it.", { - { "deku|hylian|mirror", Ship::ArgumentType::TEXT }, + { "deku|hylian|mirror", LUS::ArgumentType::TEXT }, }}); CMD_REGISTER("knockback", { KnockbackHandler, "Knocks Link back.", { - { "value", Ship::ArgumentType::NUMBER } + { "value", LUS::ArgumentType::NUMBER } }}); CMD_REGISTER("electrocute", { ElectrocuteHandler, "Electrocutes Link." }); @@ -1572,16 +1573,16 @@ void DebugConsole_Init(void) { CMD_REGISTER("cucco_storm", { CuccoStormHandler, "Cucco Storm" }); CMD_REGISTER("gen_rando", { GenerateRandoHandler, "Generate a randomizer seed", { - { "seed|count", Ship::ArgumentType::NUMBER, true }, - { "testing", Ship::ArgumentType::NUMBER, true }, + { "seed|count", LUS::ArgumentType::NUMBER, true }, + { "testing", LUS::ArgumentType::NUMBER, true }, }}); CMD_REGISTER("cosmetics", { CosmeticsHandler, "Change cosmetics.", { - { "reset|randomize", Ship::ArgumentType::TEXT }, + { "reset|randomize", LUS::ArgumentType::TEXT }, }}); CMD_REGISTER("sfx", { SfxHandler, "Change SFX.", { - { "reset|randomize", Ship::ArgumentType::TEXT }, + { "reset|randomize", LUS::ArgumentType::TEXT }, }}); CVarSave(); diff --git a/soh/soh/Enhancements/debugger/actorViewer.cpp b/soh/soh/Enhancements/debugger/actorViewer.cpp index 6bf29c12b..0e92806b3 100644 --- a/soh/soh/Enhancements/debugger/actorViewer.cpp +++ b/soh/soh/Enhancements/debugger/actorViewer.cpp @@ -531,7 +531,10 @@ void PopulateActorDropdown(int i, std::vector& data) { void DrawActorViewer(bool& open) { if (!open) { - CVarSetInteger("gActorViewerEnabled", 0); + if (CVarGetInteger("gActorViewerEnabled", 0)) { + CVarClear("gActorViewerEnabled"); + LUS::RequestCvarSaveOnNextTick(); + } return; } @@ -787,5 +790,5 @@ void DrawActorViewer(bool& open) { } void InitActorViewer() { - Ship::AddWindow("Developer Tools", "Actor Viewer", DrawActorViewer); + LUS::AddWindow("Developer Tools", "Actor Viewer", DrawActorViewer, CVarGetInteger("gActorViewerEnabled", 0)); } diff --git a/soh/soh/Enhancements/debugger/colViewer.cpp b/soh/soh/Enhancements/debugger/colViewer.cpp index 17244706a..1d5e4b04c 100644 --- a/soh/soh/Enhancements/debugger/colViewer.cpp +++ b/soh/soh/Enhancements/debugger/colViewer.cpp @@ -53,7 +53,10 @@ static std::vector sphereVtx; // Draws the ImGui window for the collision viewer void DrawColViewerWindow(bool& open) { if (!open) { - CVarSetInteger("gCollisionViewerEnabled", 0); + if (CVarGetInteger("gCollisionViewerEnabled", 0)) { + CVarClear("gCollisionViewerEnabled"); + LUS::RequestCvarSaveOnNextTick(); + } return; } @@ -288,7 +291,7 @@ void CreateSphereData() { } void InitColViewer() { - Ship::AddWindow("Developer Tools", "Collision Viewer", DrawColViewerWindow); + LUS::AddWindow("Developer Tools", "Collision Viewer", DrawColViewerWindow, CVarGetInteger("gCollisionViewerEnabled", 0)); CreateCylinderData(); CreateSphereData(); diff --git a/soh/soh/Enhancements/debugger/debugSaveEditor.cpp b/soh/soh/Enhancements/debugger/debugSaveEditor.cpp index 0f423dcce..b2290e740 100644 --- a/soh/soh/Enhancements/debugger/debugSaveEditor.cpp +++ b/soh/soh/Enhancements/debugger/debugSaveEditor.cpp @@ -605,7 +605,7 @@ void DrawInfoTab() { void DrawBGSItemFlag(uint8_t itemID) { const ItemMapEntry& slotEntry = itemMapping[itemID]; - ImGui::Image(Ship::GetTextureByName(slotEntry.name), ImVec2(32.0f, 32.0f), ImVec2(0, 0), ImVec2(1, 1)); + ImGui::Image(LUS::GetTextureByName(slotEntry.name), ImVec2(32.0f, 32.0f), ImVec2(0, 0), ImVec2(1, 1)); ImGui::SameLine(); int tradeIndex = itemID - ITEM_POCKET_EGG; bool hasItem = (gSaveContext.adultTradeItems & (1 << tradeIndex)) != 0; @@ -647,7 +647,7 @@ void DrawInventoryTab() { uint8_t item = gSaveContext.inventory.items[index]; if (item != ITEM_NONE) { const ItemMapEntry& slotEntry = itemMapping.find(item)->second; - if (ImGui::ImageButton(Ship::GetTextureByName(slotEntry.name), ImVec2(32.0f, 32.0f), ImVec2(0, 0), + if (ImGui::ImageButton(LUS::GetTextureByName(slotEntry.name), ImVec2(32.0f, 32.0f), ImVec2(0, 0), ImVec2(1, 1), 0)) { selectedIndex = index; ImGui::OpenPopup(itemPopupPicker); @@ -695,7 +695,7 @@ void DrawInventoryTab() { ImGui::SameLine(); } const ItemMapEntry& slotEntry = possibleItems[pickerIndex]; - if (ImGui::ImageButton(Ship::GetTextureByName(slotEntry.name), ImVec2(32.0f, 32.0f), + if (ImGui::ImageButton(LUS::GetTextureByName(slotEntry.name), ImVec2(32.0f, 32.0f), ImVec2(0, 0), ImVec2(1, 1), 0)) { gSaveContext.inventory.items[selectedIndex] = slotEntry.id; // Set adult trade item flag if you're playing adult trade shuffle in rando @@ -733,7 +733,7 @@ void DrawInventoryTab() { ImGui::PushItemWidth(32.0f); ImGui::BeginGroup(); - ImGui::Image(Ship::GetTextureByName(itemMapping[item].name), ImVec2(32.0f, 32.0f)); + ImGui::Image(LUS::GetTextureByName(itemMapping[item].name), ImVec2(32.0f, 32.0f)); ImGui::InputScalar("##ammoInput", ImGuiDataType_S8, &AMMO(item)); ImGui::EndGroup(); @@ -1148,7 +1148,7 @@ void DrawUpgradeIcon(const std::string& categoryName, int32_t categoryId, const uint8_t item = items[CUR_UPG_VALUE(categoryId)]; if (item != ITEM_NONE) { const ItemMapEntry& slotEntry = itemMapping[item]; - if (ImGui::ImageButton(Ship::GetTextureByName(slotEntry.name), ImVec2(32.0f, 32.0f), ImVec2(0, 0), + if (ImGui::ImageButton(LUS::GetTextureByName(slotEntry.name), ImVec2(32.0f, 32.0f), ImVec2(0, 0), ImVec2(1, 1), 0)) { ImGui::OpenPopup(upgradePopupPicker); } @@ -1176,7 +1176,7 @@ void DrawUpgradeIcon(const std::string& categoryName, int32_t categoryId, const UIWidgets::SetLastItemHoverText("None"); } else { const ItemMapEntry& slotEntry = itemMapping[items[pickerIndex]]; - if (ImGui::ImageButton(Ship::GetTextureByName(slotEntry.name), ImVec2(32.0f, 32.0f), ImVec2(0, 0), + if (ImGui::ImageButton(LUS::GetTextureByName(slotEntry.name), ImVec2(32.0f, 32.0f), ImVec2(0, 0), ImVec2(1, 1), 0)) { Inventory_ChangeUpgrade(categoryId, pickerIndex); ImGui::CloseCurrentPopup(); @@ -1213,7 +1213,7 @@ void DrawEquipmentTab() { bool hasEquip = (bitMask & gSaveContext.inventory.equipment) != 0; const ItemMapEntry& entry = itemMapping[equipmentValues[i]]; ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(0, 0, 0, 0)); - if (ImGui::ImageButton(Ship::GetTextureByName(hasEquip ? entry.name : entry.nameFaded), + if (ImGui::ImageButton(LUS::GetTextureByName(hasEquip ? entry.name : entry.nameFaded), ImVec2(32.0f, 32.0f), ImVec2(0, 0), ImVec2(1, 1), 0)) { if (hasEquip) { gSaveContext.inventory.equipment &= ~bitMask; @@ -1312,7 +1312,7 @@ void DrawQuestItemButton(uint32_t item) { uint32_t bitMask = 1 << entry.id; bool hasQuestItem = (bitMask & gSaveContext.inventory.questItems) != 0; ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(0, 0, 0, 0)); - if (ImGui::ImageButton(Ship::GetTextureByName(hasQuestItem ? entry.name : entry.nameFaded), + if (ImGui::ImageButton(LUS::GetTextureByName(hasQuestItem ? entry.name : entry.nameFaded), ImVec2(32.0f, 32.0f), ImVec2(0, 0), ImVec2(1, 1), 0)) { if (hasQuestItem) { gSaveContext.inventory.questItems &= ~bitMask; @@ -1330,7 +1330,7 @@ void DrawDungeonItemButton(uint32_t item, uint32_t scene) { uint32_t bitMask = 1 << (entry.id - ITEM_KEY_BOSS); // Bitset starts at ITEM_KEY_BOSS == 0. the rest are sequential bool hasItem = (bitMask & gSaveContext.inventory.dungeonItems[scene]) != 0; ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(0, 0, 0, 0)); - if (ImGui::ImageButton(Ship::GetTextureByName(hasItem ? entry.name : entry.nameFaded), + if (ImGui::ImageButton(LUS::GetTextureByName(hasItem ? entry.name : entry.nameFaded), ImVec2(32.0f, 32.0f), ImVec2(0, 0), ImVec2(1, 1), 0)) { if (hasItem) { gSaveContext.inventory.dungeonItems[scene] &= ~bitMask; @@ -1377,7 +1377,7 @@ void DrawQuestStatusTab() { uint32_t bitMask = 1 << entry.id; bool hasQuestItem = (bitMask & gSaveContext.inventory.questItems) != 0; ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(0, 0, 0, 0)); - if (ImGui::ImageButton(Ship::GetTextureByName(hasQuestItem ? entry.name : entry.nameFaded), + if (ImGui::ImageButton(LUS::GetTextureByName(hasQuestItem ? entry.name : entry.nameFaded), ImVec2(16.0f, 24.0f), ImVec2(0, 0), ImVec2(1, 1), 0)) { if (hasQuestItem) { gSaveContext.inventory.questItems &= ~bitMask; @@ -1440,7 +1440,7 @@ void DrawQuestStatusTab() { if (dungeonItemsScene != SCENE_BDAN_BOSS) { float lineHeight = ImGui::GetTextLineHeightWithSpacing(); - ImGui::Image(Ship::GetTextureByName(itemMapping[ITEM_KEY_SMALL].name), ImVec2(lineHeight, lineHeight)); + ImGui::Image(LUS::GetTextureByName(itemMapping[ITEM_KEY_SMALL].name), ImVec2(lineHeight, lineHeight)); ImGui::SameLine(); if (ImGui::InputScalar("##Keys", ImGuiDataType_S8, gSaveContext.inventory.dungeonKeys + dungeonItemsScene)) { gSaveContext.sohStats.dungeonKeys[dungeonItemsScene] = gSaveContext.inventory.dungeonKeys[dungeonItemsScene]; @@ -1733,7 +1733,10 @@ void DrawPlayerTab() { void DrawSaveEditor(bool& open) { if (!open) { - CVarSetInteger("gSaveEditorEnabled", 0); + if (CVarGetInteger("gSaveEditorEnabled", 0)) { + CVarClear("gSaveEditorEnabled"); + LUS::RequestCvarSaveOnNextTick(); + } return; } @@ -1781,34 +1784,34 @@ void DrawSaveEditor(bool& open) { } void InitSaveEditor() { - Ship::AddWindow("Developer Tools", "Save Editor", DrawSaveEditor); + LUS::AddWindow("Developer Tools", "Save Editor", DrawSaveEditor, CVarGetInteger("gSaveEditorEnabled", 0)); // Load item icons into ImGui for (const auto& entry : itemMapping) { - Ship::LoadResource(entry.second.name, entry.second.texturePath); - Ship::LoadResource(entry.second.nameFaded, entry.second.texturePath, ImVec4(1, 1, 1, 0.3f)); + LUS::LoadResource(entry.second.name, entry.second.texturePath); + LUS::LoadResource(entry.second.nameFaded, entry.second.texturePath, ImVec4(1, 1, 1, 0.3f)); } for (const auto& entry : gregMapping) { ImVec4 gregGreen = ImVec4(42.0f / 255.0f, 169.0f / 255.0f, 40.0f / 255.0f, 1.0f); ImVec4 gregFadedGreen = gregGreen; gregFadedGreen.w = 0.3f; - Ship::LoadResource(entry.second.name, entry.second.texturePath, gregGreen); - Ship::LoadResource(entry.second.nameFaded, entry.second.texturePath, gregFadedGreen); + LUS::LoadResource(entry.second.name, entry.second.texturePath, gregGreen); + LUS::LoadResource(entry.second.nameFaded, entry.second.texturePath, gregFadedGreen); } for (const auto& entry : questMapping) { - Ship::LoadResource(entry.second.name, entry.second.texturePath); - Ship::LoadResource(entry.second.nameFaded, entry.second.texturePath, ImVec4(1, 1, 1, 0.3f)); + LUS::LoadResource(entry.second.name, entry.second.texturePath); + LUS::LoadResource(entry.second.nameFaded, entry.second.texturePath, ImVec4(1, 1, 1, 0.3f)); } for (const auto& entry : songMapping) { - Ship::LoadResource(entry.name, gSongNoteTex, entry.color); + LUS::LoadResource(entry.name, gSongNoteTex, entry.color); ImVec4 fadedCol = entry.color; fadedCol.w = 0.3f; - Ship::LoadResource(entry.nameFaded, gSongNoteTex, fadedCol); + LUS::LoadResource(entry.nameFaded, gSongNoteTex, fadedCol); } for (const auto& entry : vanillaSongMapping) { - Ship::LoadResource(entry.name, gSongNoteTex, entry.color); + LUS::LoadResource(entry.name, gSongNoteTex, entry.color); ImVec4 fadedCol = entry.color; fadedCol.w = 0.3f; - Ship::LoadResource(entry.nameFaded, gSongNoteTex, fadedCol); + LUS::LoadResource(entry.nameFaded, gSongNoteTex, fadedCol); } } diff --git a/soh/soh/Enhancements/debugger/dlViewer.cpp b/soh/soh/Enhancements/debugger/dlViewer.cpp index e19e395e0..a5865d84f 100644 --- a/soh/soh/Enhancements/debugger/dlViewer.cpp +++ b/soh/soh/Enhancements/debugger/dlViewer.cpp @@ -10,7 +10,7 @@ #include #include #include -#include +#include extern "C" { #include @@ -40,7 +40,10 @@ std::map cmdMap = { void DrawDLViewer(bool& open) { if (!open) { - CVarSetInteger("gDLViewerEnabled", 0); + if (CVarGetInteger("gDLViewerEnabled", 0)) { + CVarClear("gDLViewerEnabled"); + LUS::RequestCvarSaveOnNextTick(); + } return; } @@ -64,7 +67,7 @@ void DrawDLViewer(bool& open) { ImGui::EndCombo(); } if (activeDisplayList != nullptr) { - auto res = std::static_pointer_cast(OTRGlobals::Instance->context->GetResourceManager()->LoadResource(activeDisplayList)); + auto res = std::static_pointer_cast(LUS::Context::GetInstance()->GetResourceManager()->LoadResource(activeDisplayList)); for (int i = 0; i < res->Instructions.size(); i++) { std::string id = "##CMD" + std::to_string(i); Gfx* gfx = (Gfx*)&res->Instructions[i]; @@ -138,7 +141,7 @@ void DrawDLViewer(bool& open) { } void InitDLViewer() { - Ship::AddWindow("Developer Tools", "Display List Viewer", DrawDLViewer); + LUS::AddWindow("Developer Tools", "Display List Viewer", DrawDLViewer, CVarGetInteger("gDLViewerEnabled", 0)); displayListsSearchResults = ResourceMgr_ListFiles("*DL", &displayListsSearchResultsCount); } diff --git a/soh/soh/Enhancements/game-interactor/GameInteractor_RawAction.cpp b/soh/soh/Enhancements/game-interactor/GameInteractor_RawAction.cpp index 11881893a..4b0f43a5a 100644 --- a/soh/soh/Enhancements/game-interactor/GameInteractor_RawAction.cpp +++ b/soh/soh/Enhancements/game-interactor/GameInteractor_RawAction.cpp @@ -335,7 +335,7 @@ void GameInteractor::RawAction::SetCosmeticsColor(uint8_t cosmeticCategory, uint break; } - Ship::RequestCvarSaveOnNextTick(); + LUS::RequestCvarSaveOnNextTick(); ApplyOrResetCustomGfxPatches(); } diff --git a/soh/soh/Enhancements/gameplaystats.cpp b/soh/soh/Enhancements/gameplaystats.cpp index 1fccc7250..5d60964bd 100644 --- a/soh/soh/Enhancements/gameplaystats.cpp +++ b/soh/soh/Enhancements/gameplaystats.cpp @@ -263,7 +263,10 @@ std::string ResolveSceneID(int sceneID, int roomID){ void DrawStatsTracker(bool& open) { if (!open) { - CVarSetInteger("gGameplayStatsEnabled", 0); + if (CVarGetInteger("gGameplayStatsEnabled", 0)) { + CVarClear("gGameplayStatsEnabled"); + LUS::RequestCvarSaveOnNextTick(); + } return; } @@ -667,8 +670,7 @@ void SetupDisplayColors() { } extern "C" void InitStatTracker() { - Ship::AddWindow("Enhancements", "Gameplay Stats", DrawStatsTracker, - CVarGetInteger("gGameplayStatsEnabled", 0) == 1); + LUS::AddWindow("Enhancements", "Gameplay Stats", DrawStatsTracker, CVarGetInteger("gGameplayStatsEnabled", 0)); SetupDisplayNames(); SetupDisplayColors(); } \ No newline at end of file diff --git a/soh/soh/Enhancements/mods.cpp b/soh/soh/Enhancements/mods.cpp index 15232c1da..94d8853db 100644 --- a/soh/soh/Enhancements/mods.cpp +++ b/soh/soh/Enhancements/mods.cpp @@ -152,7 +152,7 @@ void RegisterFreezeTime() { int32_t prevTime = CVarGetInteger("gPrevTime", gSaveContext.dayTime); gSaveContext.dayTime = prevTime; } else { - CVarSetInteger("gPrevTime", -1); + CVarClear("gPrevTime"); } }); } @@ -408,11 +408,13 @@ void RegisterHyperBosses() { uint8_t isBossActor = actor->id == ACTOR_BOSS_GOMA || // Gohma actor->id == ACTOR_BOSS_DODONGO || // King Dodongo + actor->id == ACTOR_EN_BDFIRE || // King Dodongo Fire Breath actor->id == ACTOR_BOSS_VA || // Barinade actor->id == ACTOR_BOSS_GANONDROF || // Phantom Ganon - (actor->id == 0 && actor->category == ACTORCAT_BOSS) || // Phantom Ganon/Ganondorf Energy Ball/Thunder + actor->id == ACTOR_EN_FHG_FIRE || // Phantom Ganon/Ganondorf Energy Ball/Thunder actor->id == ACTOR_EN_FHG || // Phantom Ganon's Horse actor->id == ACTOR_BOSS_FD || actor->id == ACTOR_BOSS_FD2 || // Volvagia (grounded/flying) + actor->id == ACTOR_EN_VB_BALL || // Volvagia Rocks actor->id == ACTOR_BOSS_MO || // Morpha actor->id == ACTOR_BOSS_SST || // Bongo Bongo actor->id == ACTOR_BOSS_TW || // Twinrova diff --git a/soh/soh/Enhancements/presets.cpp b/soh/soh/Enhancements/presets.cpp index 9977e49be..8871abaf5 100644 --- a/soh/soh/Enhancements/presets.cpp +++ b/soh/soh/Enhancements/presets.cpp @@ -59,7 +59,7 @@ void DrawPresetSelector(PresetType presetTypeId) { if (selectedPresetId != 0) { applyPreset(selectedPresetDef.entries); } - Ship::RequestCvarSaveOnNextTick(); + LUS::RequestCvarSaveOnNextTick(); } ImGui::PopStyleVar(1); } diff --git a/soh/soh/Enhancements/randomizer/3drando/entrance.cpp b/soh/soh/Enhancements/randomizer/3drando/entrance.cpp index e1eeb69d9..71cba408b 100644 --- a/soh/soh/Enhancements/randomizer/3drando/entrance.cpp +++ b/soh/soh/Enhancements/randomizer/3drando/entrance.cpp @@ -333,7 +333,7 @@ static bool ValidateWorld(Entrance* entrancePlaced) { // This means we need to hard check that none of the relevant entrances are ever reachable as that age // This is mostly relevant when mixing entrance pools or shuffling special interiors (such as windmill or kak potion shop) // Warp Songs and Overworld Spawns can also end up inside certain indoors so those need to be handled as well - std::array childForbidden = {"OGC Great Fairy Fountain -> Castle Grounds", "GV Carpenter Tent -> GV Fortress Side"}; + std::array childForbidden = {"OGC Great Fairy Fountain -> Castle Grounds", "GV Carpenter Tent -> GV Fortress Side", "Ganon's Castle Entryway -> Castle Grounds From Ganon's Castle"}; std::array adultForbidden = {"HC Great Fairy Fountain -> Castle Grounds", "HC Storms Grotto -> Castle Grounds"}; auto allShuffleableEntrances = GetShuffleableEntrances(EntranceType::All, false); @@ -711,8 +711,8 @@ int ShuffleAllEntrances() { {EntranceType::Dungeon, ICE_CAVERN_ENTRYWAY, ZORAS_FOUNTAIN, 0x03D4}}, {{EntranceType::Dungeon, GERUDO_FORTRESS, GERUDO_TRAINING_GROUNDS_ENTRYWAY, 0x0008}, {EntranceType::Dungeon, GERUDO_TRAINING_GROUNDS_ENTRYWAY, GERUDO_FORTRESS, 0x03A8}}, - {{EntranceType::GanonDungeon, GANONS_CASTLE_GROUNDS, GANONS_CASTLE_ENTRYWAY, 0x0467}, - {EntranceType::GanonDungeon, GANONS_CASTLE_ENTRYWAY, GANONS_CASTLE_GROUNDS, 0x023D}}, + {{EntranceType::GanonDungeon, GANONS_CASTLE_LEDGE, GANONS_CASTLE_ENTRYWAY, 0x0467}, + {EntranceType::GanonDungeon, GANONS_CASTLE_ENTRYWAY, CASTLE_GROUNDS_FROM_GANONS_CASTLE, 0x023D}}, {{EntranceType::Interior, KOKIRI_FOREST, KF_MIDOS_HOUSE, 0x0433}, {EntranceType::Interior, KF_MIDOS_HOUSE, KOKIRI_FOREST, 0x0443}}, diff --git a/soh/soh/Enhancements/randomizer/3drando/keys.hpp b/soh/soh/Enhancements/randomizer/3drando/keys.hpp index cc72e6235..29f5f32fa 100644 --- a/soh/soh/Enhancements/randomizer/3drando/keys.hpp +++ b/soh/soh/Enhancements/randomizer/3drando/keys.hpp @@ -1171,12 +1171,14 @@ typedef enum { TEMPLE_OF_TIME, TOT_BEYOND_DOOR_OF_TIME, CASTLE_GROUNDS, + CASTLE_GROUNDS_FROM_GANONS_CASTLE, HYRULE_CASTLE_GROUNDS, HC_GARDEN, HC_GREAT_FAIRY_FOUNTAIN, HC_STORMS_GROTTO, GANONS_CASTLE_GROUNDS, OGC_GREAT_FAIRY_FOUNTAIN, + GANONS_CASTLE_LEDGE, KAKARIKO_VILLAGE, KAK_CARPENTER_BOSS_HOUSE, KAK_HOUSE_OF_SKULLTULA, diff --git a/soh/soh/Enhancements/randomizer/3drando/location_access/locacc_castle_town.cpp b/soh/soh/Enhancements/randomizer/3drando/location_access/locacc_castle_town.cpp index aeb2ddbbf..918c74021 100644 --- a/soh/soh/Enhancements/randomizer/3drando/location_access/locacc_castle_town.cpp +++ b/soh/soh/Enhancements/randomizer/3drando/location_access/locacc_castle_town.cpp @@ -135,14 +135,17 @@ void AreaTable_Init_CastleTown() { Entrance(CASTLE_GROUNDS, {[]{return true;}}), }); - areaTable[GANONS_CASTLE_GROUNDS] = Area("Ganon's Castle Grounds", "Castle Grounds", OUTSIDE_GANONS_CASTLE, NO_DAY_NIGHT_CYCLE, {}, { + areaTable[GANONS_CASTLE_GROUNDS] = Area("Ganon's Castle Grounds", "Castle Grounds", OUTSIDE_GANONS_CASTLE, NO_DAY_NIGHT_CYCLE, { + EventAccess(&BuiltRainbowBridge, {[]{return CanBuildRainbowBridge;}}), + }, { //Locations //the terrain was lowered such that you can't get this GS with a simple sword slash - LocationAccess(OGC_GS, {[]{return HasExplosives || (IsAdult && (LogicOutsideGanonsGS || Bow || HookshotOrBoomerang || CanUse(DINS_FIRE)));}}), + LocationAccess(OGC_GS, {[]{return CanJumpslash || CanUseProjectile + || (CanShield && CanUse(MEGATON_HAMMER)) || CanUse(DINS_FIRE);}}), }, { //Exits Entrance(CASTLE_GROUNDS, {[]{return AtNight;}}), Entrance(OGC_GREAT_FAIRY_FOUNTAIN, {[]{return CanUse(GOLDEN_GAUNTLETS) && AtNight;}}), - Entrance(GANONS_CASTLE_ENTRYWAY, {[]{return CanBuildRainbowBridge;}, + Entrance(GANONS_CASTLE_LEDGE, {[]{return BuiltRainbowBridge;}, /*Glitched*/[]{return (HasBombchus && CanDoGlitch(GlitchType::BombHover, GlitchDifficulty::NOVICE)) || CanDoGlitch(GlitchType::HoverBoost, GlitchDifficulty::ADVANCED) || (HoverBoots && CanShield && Bombs && CanDoGlitch(GlitchType::SuperSlide, GlitchDifficulty::EXPERT)) || (HoverBoots && CanDoGlitch(GlitchType::Megaflip, GlitchDifficulty::ADVANCED));}}), }); @@ -155,6 +158,20 @@ void AreaTable_Init_CastleTown() { Entrance(CASTLE_GROUNDS, {[]{return true;}}), }); + areaTable[CASTLE_GROUNDS_FROM_GANONS_CASTLE] = Area("Castle Grounds From Ganon's Castle", "Castle Grounds From Ganon's Castle", NONE, NO_DAY_NIGHT_CYCLE, {}, {}, { + // Exits + Entrance(HYRULE_CASTLE_GROUNDS, { [] { return IsChild; }}), + Entrance(GANONS_CASTLE_LEDGE, { [] { return IsAdult; }}), + }); + + areaTable[GANONS_CASTLE_LEDGE] = Area("Ganon's Castle Ledge", "OGC Ganon's Castle Ledge", NONE, NO_DAY_NIGHT_CYCLE, + {}, {}, { + // Exits + Entrance(GANONS_CASTLE_GROUNDS, {[]{return BuiltRainbowBridge;}, + /*Glitched*/[]{return (HasBombchus && CanDoGlitch(GlitchType::BombHover, GlitchDifficulty::NOVICE)) || CanDoGlitch(GlitchType::HoverBoost, GlitchDifficulty::ADVANCED) || (HoverBoots && CanShield && Bombs && CanDoGlitch(GlitchType::SuperSlide, GlitchDifficulty::EXPERT)) || (HoverBoots && CanDoGlitch(GlitchType::Megaflip, GlitchDifficulty::ADVANCED));}}), + Entrance(GANONS_CASTLE_ENTRYWAY, {[]{return IsAdult;}}), + }); + areaTable[MARKET_GUARD_HOUSE] = Area("Market Guard House", "Market Guard House", NONE, NO_DAY_NIGHT_CYCLE, {}, { //Locations LocationAccess(MARKET_10_BIG_POES, {[]{return IsAdult && BigPoeKill;}}), diff --git a/soh/soh/Enhancements/randomizer/3drando/location_access/locacc_ganons_castle.cpp b/soh/soh/Enhancements/randomizer/3drando/location_access/locacc_ganons_castle.cpp index 7b3bb11fa..890a50b74 100644 --- a/soh/soh/Enhancements/randomizer/3drando/location_access/locacc_ganons_castle.cpp +++ b/soh/soh/Enhancements/randomizer/3drando/location_access/locacc_ganons_castle.cpp @@ -15,7 +15,7 @@ void AreaTable_Init_GanonsCastle() { //Exits Entrance(GANONS_CASTLE_LOBBY, {[]{return Dungeon::GanonsCastle.IsVanilla();}}), Entrance(GANONS_CASTLE_MQ_LOBBY, {[]{return Dungeon::GanonsCastle.IsMQ();}}), - Entrance(GANONS_CASTLE_GROUNDS, {[]{return true;}}), + Entrance(CASTLE_GROUNDS_FROM_GANONS_CASTLE, {[]{return true;}}), }); /*-------------------------- diff --git a/soh/soh/Enhancements/randomizer/3drando/logic.cpp b/soh/soh/Enhancements/randomizer/3drando/logic.cpp index a6ab83c77..9eb219cf1 100644 --- a/soh/soh/Enhancements/randomizer/3drando/logic.cpp +++ b/soh/soh/Enhancements/randomizer/3drando/logic.cpp @@ -298,6 +298,7 @@ namespace Logic { bool HasAllStones = false; bool HasAllMedallions = false; bool CanBuildRainbowBridge = false; + bool BuiltRainbowBridge = false; bool CanTriggerLACS = false; //Other @@ -1171,6 +1172,7 @@ namespace Logic { HasAllStones = false; HasAllMedallions = false; CanBuildRainbowBridge = false; + BuiltRainbowBridge = false; CanTriggerLACS = false; //Other diff --git a/soh/soh/Enhancements/randomizer/3drando/logic.hpp b/soh/soh/Enhancements/randomizer/3drando/logic.hpp index f847fb7d7..f6b1f8e06 100644 --- a/soh/soh/Enhancements/randomizer/3drando/logic.hpp +++ b/soh/soh/Enhancements/randomizer/3drando/logic.hpp @@ -286,6 +286,7 @@ extern bool CanUseMagicArrow; extern bool HasAllStones; extern bool HasAllMedallions; extern bool CanBuildRainbowBridge; +extern bool BuiltRainbowBridge; extern bool CanTriggerLACS; // Other diff --git a/soh/soh/Enhancements/randomizer/3drando/rando_main.cpp b/soh/soh/Enhancements/randomizer/3drando/rando_main.cpp index b57ac9774..1857b3826 100644 --- a/soh/soh/Enhancements/randomizer/3drando/rando_main.cpp +++ b/soh/soh/Enhancements/randomizer/3drando/rando_main.cpp @@ -6,7 +6,7 @@ #include "rando_main.hpp" // #include #include -#include +#include #include #define TICKS_PER_SEC 268123480.0 @@ -20,7 +20,7 @@ void RandoMain::GenerateRando(std::unordered_map cvarS // std::string settingsFileName = "./randomizer/latest_settings.json"; // CVarSetString("gLoadedPreset", settingsFileName.c_str()); - std::string fileName = Ship::Window::GetPathRelativeToAppDirectory(GenerateRandomizer(cvarSettings, excludedLocations, seedString).c_str()); + std::string fileName = LUS::Context::GetPathRelativeToAppDirectory(GenerateRandomizer(cvarSettings, excludedLocations, seedString).c_str()); CVarSetString("gSpoilerLog", fileName.c_str()); CVarSave(); diff --git a/soh/soh/Enhancements/randomizer/3drando/spoiler_log.cpp b/soh/soh/Enhancements/randomizer/3drando/spoiler_log.cpp index 6618fba8c..bebddfd97 100644 --- a/soh/soh/Enhancements/randomizer/3drando/spoiler_log.cpp +++ b/soh/soh/Enhancements/randomizer/3drando/spoiler_log.cpp @@ -27,7 +27,7 @@ #include #include -#include +#include using json = nlohmann::json; @@ -807,8 +807,8 @@ const char* SpoilerLog_Write(int language) { WriteShuffledEntrances(); WriteAllLocations(language); - if (!std::filesystem::exists(Ship::Window::GetPathRelativeToAppDirectory("Randomizer"))) { - std::filesystem::create_directory(Ship::Window::GetPathRelativeToAppDirectory("Randomizer")); + if (!std::filesystem::exists(LUS::Context::GetPathRelativeToAppDirectory("Randomizer"))) { + std::filesystem::create_directory(LUS::Context::GetPathRelativeToAppDirectory("Randomizer")); } std::string jsonString = jsonData.dump(4); @@ -823,7 +823,7 @@ const char* SpoilerLog_Write(int language) { fileNameStream << std::to_string(Settings::hashIconIndexes[i]); } std::string fileName = fileNameStream.str(); - std::ofstream jsonFile(Ship::Window::GetPathRelativeToAppDirectory( + std::ofstream jsonFile(LUS::Context::GetPathRelativeToAppDirectory( (std::string("Randomizer/") + fileName + std::string(".json")).c_str())); jsonFile << std::setw(4) << jsonString << std::endl; jsonFile.close(); diff --git a/soh/soh/Enhancements/randomizer/draw.cpp b/soh/soh/Enhancements/randomizer/draw.cpp index eb83f1bfb..69a25368c 100644 --- a/soh/soh/Enhancements/randomizer/draw.cpp +++ b/soh/soh/Enhancements/randomizer/draw.cpp @@ -12,7 +12,7 @@ extern "C" void Randomizer_DrawSmallKey(PlayState* play, GetItemEntry* getItemEntry) { s32 pad; - s8 isColoredKeysEnabled = CVarGetInteger("gRandoMatchKeyColors", 0); + s8 isColoredKeysEnabled = CVarGetInteger("gRandoMatchKeyColors", 1); s16 color_slot = getItemEntry->getItemId - RG_FOREST_TEMPLE_SMALL_KEY; s16 colors[9][3] = { { 4, 195, 46 }, // Forest Temple @@ -49,7 +49,7 @@ extern "C" void Randomizer_DrawSmallKey(PlayState* play, GetItemEntry* getItemEn extern "C" void Randomizer_DrawBossKey(PlayState* play, GetItemEntry* getItemEntry) { s32 pad; - s8 isColoredKeysEnabled = CVarGetInteger("gRandoMatchKeyColors", 0); + s8 isColoredKeysEnabled = CVarGetInteger("gRandoMatchKeyColors", 1); s16 color_slot; color_slot = getItemEntry->getItemId - RG_FOREST_TEMPLE_BOSS_KEY; s16 colors[6][3] = { diff --git a/soh/soh/Enhancements/randomizer/randomizer.cpp b/soh/soh/Enhancements/randomizer/randomizer.cpp index 5096f5ca7..6fd58e908 100644 --- a/soh/soh/Enhancements/randomizer/randomizer.cpp +++ b/soh/soh/Enhancements/randomizer/randomizer.cpp @@ -2155,7 +2155,8 @@ GetItemID Randomizer::GetItemIdFromRandomizerGet(RandomizerGet randoGet, GetItem case RG_ICE_CAVERN_MAP: if (GetRandoSettingValue(RSK_STARTING_MAPS_COMPASSES) == RO_DUNGEON_ITEM_LOC_STARTWITH || GetRandoSettingValue(RSK_STARTING_MAPS_COMPASSES) == RO_DUNGEON_ITEM_LOC_VANILLA || - GetRandoSettingValue(RSK_STARTING_MAPS_COMPASSES) == RO_DUNGEON_ITEM_LOC_OWN_DUNGEON) { + (GetRandoSettingValue(RSK_STARTING_MAPS_COMPASSES) == RO_DUNGEON_ITEM_LOC_OWN_DUNGEON && + GetRandoSettingValue(RSK_SHUFFLE_BOSS_ENTRANCES) == RO_BOSS_ROOM_ENTRANCE_SHUFFLE_OFF)) { return GI_MAP; } else { return (GetItemID)randoGet; @@ -2173,7 +2174,8 @@ GetItemID Randomizer::GetItemIdFromRandomizerGet(RandomizerGet randoGet, GetItem case RG_ICE_CAVERN_COMPASS: if (GetRandoSettingValue(RSK_STARTING_MAPS_COMPASSES) == RO_DUNGEON_ITEM_LOC_STARTWITH || GetRandoSettingValue(RSK_STARTING_MAPS_COMPASSES) == RO_DUNGEON_ITEM_LOC_VANILLA || - GetRandoSettingValue(RSK_STARTING_MAPS_COMPASSES) == RO_DUNGEON_ITEM_LOC_OWN_DUNGEON) { + (GetRandoSettingValue(RSK_STARTING_MAPS_COMPASSES) == RO_DUNGEON_ITEM_LOC_OWN_DUNGEON && + GetRandoSettingValue(RSK_SHUFFLE_BOSS_ENTRANCES) == RO_BOSS_ROOM_ENTRANCE_SHUFFLE_OFF)) { return GI_COMPASS; } else { return (GetItemID)randoGet; @@ -2186,15 +2188,16 @@ GetItemID Randomizer::GetItemIdFromRandomizerGet(RandomizerGet randoGet, GetItem case RG_SHADOW_TEMPLE_BOSS_KEY: if (GetRandoSettingValue(RSK_BOSS_KEYSANITY) == RO_DUNGEON_ITEM_LOC_STARTWITH || GetRandoSettingValue(RSK_BOSS_KEYSANITY) == RO_DUNGEON_ITEM_LOC_VANILLA || - GetRandoSettingValue(RSK_BOSS_KEYSANITY) == RO_DUNGEON_ITEM_LOC_OWN_DUNGEON) { + (GetRandoSettingValue(RSK_BOSS_KEYSANITY) == RO_DUNGEON_ITEM_LOC_OWN_DUNGEON && + GetRandoSettingValue(RSK_SHUFFLE_BOSS_ENTRANCES) == RO_BOSS_ROOM_ENTRANCE_SHUFFLE_OFF)) { return GI_KEY_BOSS; } else { return (GetItemID)randoGet; } case RG_GANONS_CASTLE_BOSS_KEY: - if (GetRandoSettingValue(RSK_GANONS_BOSS_KEY) == RO_GANON_BOSS_KEY_VANILLA || - GetRandoSettingValue(RSK_GANONS_BOSS_KEY) == RO_GANON_BOSS_KEY_OWN_DUNGEON || - GetRandoSettingValue(RSK_GANONS_BOSS_KEY) == RO_GANON_BOSS_KEY_STARTWITH) { + if (GetRandoSettingValue(RSK_GANONS_BOSS_KEY) == RO_GANON_BOSS_KEY_STARTWITH || + GetRandoSettingValue(RSK_GANONS_BOSS_KEY) == RO_GANON_BOSS_KEY_VANILLA || + GetRandoSettingValue(RSK_GANONS_BOSS_KEY) == RO_GANON_BOSS_KEY_OWN_DUNGEON) { return GI_KEY_BOSS; } else { return (GetItemID)randoGet; @@ -2210,7 +2213,8 @@ GetItemID Randomizer::GetItemIdFromRandomizerGet(RandomizerGet randoGet, GetItem case RG_GANONS_CASTLE_SMALL_KEY: if (GetRandoSettingValue(RSK_KEYSANITY) == RO_DUNGEON_ITEM_LOC_STARTWITH || GetRandoSettingValue(RSK_KEYSANITY) == RO_DUNGEON_ITEM_LOC_VANILLA || - GetRandoSettingValue(RSK_KEYSANITY) == RO_DUNGEON_ITEM_LOC_OWN_DUNGEON) { + (GetRandoSettingValue(RSK_KEYSANITY) == RO_DUNGEON_ITEM_LOC_OWN_DUNGEON && + GetRandoSettingValue(RSK_SHUFFLE_BOSS_ENTRANCES) == RO_BOSS_ROOM_ENTRANCE_SHUFFLE_OFF)) { return GI_KEY_SMALL; } else { return (GetItemID)randoGet; @@ -2387,10 +2391,13 @@ bool Randomizer::IsItemVanilla(RandomizerGet randoGet) { case RG_BOTTOM_OF_THE_WELL_SMALL_KEY: case RG_GERUDO_TRAINING_GROUNDS_SMALL_KEY: case RG_GANONS_CASTLE_SMALL_KEY: - if (GetRandoSettingValue(RSK_KEYSANITY) > 2) { - return false; + if (GetRandoSettingValue(RSK_KEYSANITY) == RO_DUNGEON_ITEM_LOC_STARTWITH || + GetRandoSettingValue(RSK_KEYSANITY) == RO_DUNGEON_ITEM_LOC_VANILLA || + (GetRandoSettingValue(RSK_KEYSANITY) == RO_DUNGEON_ITEM_LOC_OWN_DUNGEON && + GetRandoSettingValue(RSK_SHUFFLE_BOSS_ENTRANCES) == RO_BOSS_ROOM_ENTRANCE_SHUFFLE_OFF)) { + return true; } - return true; + return false; case RG_GERUDO_FORTRESS_SMALL_KEY: if (GetRandoSettingValue(RSK_GERUDO_KEYS) != RO_GERUDO_KEYS_VANILLA) { return false; @@ -2403,14 +2410,15 @@ bool Randomizer::IsItemVanilla(RandomizerGet randoGet) { case RG_SHADOW_TEMPLE_BOSS_KEY: if (GetRandoSettingValue(RSK_BOSS_KEYSANITY) == RO_DUNGEON_ITEM_LOC_STARTWITH || GetRandoSettingValue(RSK_BOSS_KEYSANITY) == RO_DUNGEON_ITEM_LOC_VANILLA || - GetRandoSettingValue(RSK_BOSS_KEYSANITY) == RO_DUNGEON_ITEM_LOC_OWN_DUNGEON) { + (GetRandoSettingValue(RSK_BOSS_KEYSANITY) == RO_DUNGEON_ITEM_LOC_OWN_DUNGEON && + GetRandoSettingValue(RSK_SHUFFLE_BOSS_ENTRANCES) == RO_BOSS_ROOM_ENTRANCE_SHUFFLE_OFF)) { return true; } return false; case RG_GANONS_CASTLE_BOSS_KEY: - if (GetRandoSettingValue(RSK_GANONS_BOSS_KEY) == RO_GANON_BOSS_KEY_VANILLA || - GetRandoSettingValue(RSK_GANONS_BOSS_KEY) == RO_GANON_BOSS_KEY_OWN_DUNGEON || - GetRandoSettingValue(RSK_GANONS_BOSS_KEY) == RO_GANON_BOSS_KEY_STARTWITH) { + if (GetRandoSettingValue(RSK_GANONS_BOSS_KEY) == RO_GANON_BOSS_KEY_STARTWITH || + GetRandoSettingValue(RSK_GANONS_BOSS_KEY) == RO_GANON_BOSS_KEY_VANILLA || + GetRandoSettingValue(RSK_GANONS_BOSS_KEY) == RO_GANON_BOSS_KEY_OWN_DUNGEON) { return true; } return false; @@ -2436,7 +2444,8 @@ bool Randomizer::IsItemVanilla(RandomizerGet randoGet) { case RG_ICE_CAVERN_MAP: if (GetRandoSettingValue(RSK_STARTING_MAPS_COMPASSES) == RO_DUNGEON_ITEM_LOC_STARTWITH || GetRandoSettingValue(RSK_STARTING_MAPS_COMPASSES) == RO_DUNGEON_ITEM_LOC_VANILLA || - GetRandoSettingValue(RSK_STARTING_MAPS_COMPASSES) == RO_DUNGEON_ITEM_LOC_OWN_DUNGEON) { + (GetRandoSettingValue(RSK_STARTING_MAPS_COMPASSES) == RO_DUNGEON_ITEM_LOC_OWN_DUNGEON && + GetRandoSettingValue(RSK_SHUFFLE_BOSS_ENTRANCES) == RO_BOSS_ROOM_ENTRANCE_SHUFFLE_OFF)) { return true; } return false; @@ -3081,7 +3090,10 @@ void DrawRandoEditor(bool& open) { } if (!open) { - CVarSetInteger("gRandomizerSettingsEnabled", 0); + if (CVarGetInteger("gRandomizerSettingsEnabled", 0)) { + CVarClear("gRandomizerSettingsEnabled"); + LUS::RequestCvarSaveOnNextTick(); + } return; } @@ -4361,7 +4373,7 @@ void DrawRandoEditor(bool& open) { excludedLocationString += ","; } CVarSetString("gRandomizeExcludedLocations", excludedLocationString.c_str()); - Ship::RequestCvarSaveOnNextTick(); + LUS::RequestCvarSaveOnNextTick(); } ImGui::SameLine(); ImGui::Text(rcObject->rcShortName.c_str()); @@ -4402,7 +4414,7 @@ void DrawRandoEditor(bool& open) { excludedLocationString += ","; } CVarSetString("gRandomizeExcludedLocations", excludedLocationString.c_str()); - Ship::RequestCvarSaveOnNextTick(); + LUS::RequestCvarSaveOnNextTick(); } ImGui::SameLine(); ImGui::Text(rcObject->rcShortName.c_str()); @@ -5443,7 +5455,7 @@ void InitRandoItemTable() { void InitRando() { - Ship::AddWindow("Randomizer", "Randomizer Settings", DrawRandoEditor); + LUS::AddWindow("Randomizer", "Randomizer Settings", DrawRandoEditor, CVarGetInteger("gRandomizerSettingsEnabled", 0)); Randomizer::CreateCustomMessages(); seedString = (char*)calloc(MAX_SEED_STRING_SIZE, sizeof(char)); InitRandoItemTable(); diff --git a/soh/soh/Enhancements/randomizer/randomizer_check_tracker.cpp b/soh/soh/Enhancements/randomizer/randomizer_check_tracker.cpp index 3caba22a6..c417f2a36 100644 --- a/soh/soh/Enhancements/randomizer/randomizer_check_tracker.cpp +++ b/soh/soh/Enhancements/randomizer/randomizer_check_tracker.cpp @@ -110,7 +110,10 @@ std::vector buttons = { BTN_A, BTN_B, BTN_CUP, BTN_CDOWN, BTN_CLEFT, void DrawCheckTracker(bool& open) { if (!open) { - CVarSetInteger("gCheckTrackerEnabled", 0); + if (CVarGetInteger("gCheckTrackerEnabled", 0)) { + CVarClear("gCheckTrackerEnabled"); + LUS::RequestCvarSaveOnNextTick(); + } return; } @@ -962,7 +965,10 @@ static const char* buttonStrings[] = { "A Button", "B Button", "C-Up", "C-Down" "Z Button", "R Button", "Start", "D-Up", "D-Down", "D-Left", "D-Right" }; void DrawCheckTrackerOptions(bool& open) { if (!open) { - CVarSetInteger("gCheckTrackerSettingsEnabled", 0); + if (CVarGetInteger("gCheckTrackerSettingsEnabled", 0)) { + CVarClear("gCheckTrackerSettingsEnabled"); + LUS::RequestCvarSaveOnNextTick(); + } return; } @@ -1023,8 +1029,8 @@ void DrawCheckTrackerOptions(bool& open) { } void InitCheckTracker() { - Ship::AddWindow("Randomizer", "Check Tracker", DrawCheckTracker, CVarGetInteger("gCheckTrackerEnabled", 0) == 1); - Ship::AddWindow("Randomizer", "Check Tracker Settings", DrawCheckTrackerOptions); + LUS::AddWindow("Randomizer", "Check Tracker", DrawCheckTracker, CVarGetInteger("gCheckTrackerEnabled", 0)); + LUS::AddWindow("Randomizer", "Check Tracker Settings", DrawCheckTrackerOptions, CVarGetInteger("gCheckTrackerSettingsEnabled", 0)); Color_Background = CVarGetColor("gCheckTrackerBgColor", Color_Bg_Default); Color_Area_Incomplete_Main = CVarGetColor("gCheckTrackerAreaMainIncompleteColor", Color_Main_Default); Color_Area_Incomplete_Extra = CVarGetColor("gCheckTrackerAreaExtraIncompleteColor", Color_Area_Incomplete_Extra_Default); @@ -1045,13 +1051,13 @@ void InitCheckTracker() { Color_Saved_Main = CVarGetColor("gCheckTrackerSavedMainColor", Color_Main_Default); Color_Saved_Extra = CVarGetColor("gCheckTrackerSavedExtraColor", Color_Saved_Extra_Default); - Ship::RegisterHook([](OSContPad* cont_pad) { + LUS::RegisterHook([](OSContPad* cont_pad) { trackerButtonsPressed = cont_pad; }); - Ship::RegisterHook([](uint32_t fileNum) { + LUS::RegisterHook([](uint32_t fileNum) { doInitialize = true; }); - Ship::RegisterHook([](uint32_t fileNum) { + LUS::RegisterHook([](uint32_t fileNum) { Teardown(); }); LocationTable_Init(); diff --git a/soh/soh/Enhancements/randomizer/randomizer_entrance_tracker.cpp b/soh/soh/Enhancements/randomizer/randomizer_entrance_tracker.cpp index 17ae15487..967229e1f 100644 --- a/soh/soh/Enhancements/randomizer/randomizer_entrance_tracker.cpp +++ b/soh/soh/Enhancements/randomizer/randomizer_entrance_tracker.cpp @@ -623,7 +623,10 @@ void InitEntranceTrackingData() { void DrawEntranceTracker(bool& open) { if (!open) { - CVarSetInteger("gEntranceTrackerEnabled", 0); + if (CVarGetInteger("gEntranceTrackerEnabled", 0)) { + CVarClear("gEntranceTrackerEnabled"); + LUS::RequestCvarSaveOnNextTick(); + } return; } @@ -919,8 +922,7 @@ void DrawEntranceTracker(bool& open) { } void InitEntranceTracker() { - Ship::AddWindow("Randomizer", "Entrance Tracker", DrawEntranceTracker, - CVarGetInteger("gEntranceTrackerEnabled", 0) == 1); + LUS::AddWindow("Randomizer", "Entrance Tracker", DrawEntranceTracker, CVarGetInteger("gEntranceTrackerEnabled", 0)); // Setup hooks for loading and clearing the entrance tracker data GameInteractor::Instance->RegisterGameHook([](int32_t fileNum) { diff --git a/soh/soh/Enhancements/randomizer/randomizer_item_tracker.cpp b/soh/soh/Enhancements/randomizer/randomizer_item_tracker.cpp index 2c95879ff..a37439750 100644 --- a/soh/soh/Enhancements/randomizer/randomizer_item_tracker.cpp +++ b/soh/soh/Enhancements/randomizer/randomizer_item_tracker.cpp @@ -452,7 +452,7 @@ void DrawItemCount(ItemTrackerItem item) { void DrawEquip(ItemTrackerItem item) { bool hasEquip = (item.data & gSaveContext.inventory.equipment) != 0; int iconSize = CVarGetInteger("gItemTrackerIconSize", 36); - ImGui::Image(Ship::GetTextureByName(hasEquip && IsValidSaveFile() ? item.name : item.nameFaded), + ImGui::Image(LUS::GetTextureByName(hasEquip && IsValidSaveFile() ? item.name : item.nameFaded), ImVec2(iconSize, iconSize), ImVec2(0, 0), ImVec2(1, 1)); UIWidgets::SetLastItemHoverText(SohUtils::GetItemName(item.id)); @@ -462,7 +462,7 @@ void DrawQuest(ItemTrackerItem item) { bool hasQuestItem = (item.data & gSaveContext.inventory.questItems) != 0; int iconSize = CVarGetInteger("gItemTrackerIconSize", 36); ImGui::BeginGroup(); - ImGui::Image(Ship::GetTextureByName(hasQuestItem && IsValidSaveFile() ? item.name : item.nameFaded), + ImGui::Image(LUS::GetTextureByName(hasQuestItem && IsValidSaveFile() ? item.name : item.nameFaded), ImVec2(iconSize, iconSize), ImVec2(0, 0), ImVec2(1, 1)); if (item.id == QUEST_SKULL_TOKEN) { @@ -524,7 +524,7 @@ void DrawItem(ItemTrackerItem item) { } ImGui::BeginGroup(); - ImGui::Image(Ship::GetTextureByName(hasItem && IsValidSaveFile() ? item.name : item.nameFaded), + ImGui::Image(LUS::GetTextureByName(hasItem && IsValidSaveFile() ? item.name : item.nameFaded), ImVec2(iconSize, iconSize), ImVec2(0, 0), ImVec2(1, 1)); DrawItemCount(item); @@ -542,7 +542,7 @@ void DrawBottle(ItemTrackerItem item) { } int iconSize = CVarGetInteger("gItemTrackerIconSize", 36); - ImGui::Image(Ship::GetTextureByName(hasItem && IsValidSaveFile() ? item.name : item.nameFaded), + ImGui::Image(LUS::GetTextureByName(hasItem && IsValidSaveFile() ? item.name : item.nameFaded), ImVec2(iconSize, iconSize), ImVec2(0, 0), ImVec2(1, 1)); UIWidgets::SetLastItemHoverText(SohUtils::GetItemName(item.id)); @@ -557,11 +557,11 @@ void DrawDungeonItem(ItemTrackerItem item) { bool hasSmallKey = (gSaveContext.inventory.dungeonKeys[item.data]) >= 0; ImGui::BeginGroup(); if (itemId == ITEM_KEY_SMALL) { - ImGui::Image(Ship::GetTextureByName(hasSmallKey && IsValidSaveFile() ? item.name : item.nameFaded), + ImGui::Image(LUS::GetTextureByName(hasSmallKey && IsValidSaveFile() ? item.name : item.nameFaded), ImVec2(iconSize, iconSize), ImVec2(0, 0), ImVec2(1, 1)); } else { - ImGui::Image(Ship::GetTextureByName(hasItem && IsValidSaveFile() ? item.name : item.nameFaded), + ImGui::Image(LUS::GetTextureByName(hasItem && IsValidSaveFile() ? item.name : item.nameFaded), ImVec2(iconSize, iconSize), ImVec2(0, 0), ImVec2(1, 1)); } @@ -601,7 +601,7 @@ void DrawSong(ItemTrackerItem item) { bool hasSong = (bitMask & gSaveContext.inventory.questItems) != 0; ImVec2 p = ImGui::GetCursorScreenPos(); ImGui::SetCursorScreenPos(ImVec2(p.x + 6, p.y)); - ImGui::Image(Ship::GetTextureByName(hasSong && IsValidSaveFile() ? item.name : item.nameFaded), + ImGui::Image(LUS::GetTextureByName(hasSong && IsValidSaveFile() ? item.name : item.nameFaded), ImVec2(iconSize / 1.5, iconSize), ImVec2(0, 0), ImVec2(1, 1)); UIWidgets::SetLastItemHoverText(SohUtils::GetQuestItemName(item.id)); } @@ -637,7 +637,7 @@ void DrawNotes(bool resizeable = false) { ItemTrackerNotes::TrackerNotesInputTextMultiline("##ItemTrackerNotes", &itemTrackerNotes, size, ImGuiInputTextFlags_AllowTabInput); if (ImGui::IsItemDeactivatedAfterEdit() && IsValidSaveFile()) { CVarSetString(("gItemTrackerNotes" + std::to_string(gSaveContext.fileNum)).c_str(), std::string(std::begin(itemTrackerNotes), std::end(itemTrackerNotes)).c_str()); - Ship::RequestCvarSaveOnNextTick(); + LUS::RequestCvarSaveOnNextTick(); } ImGui::EndGroup(); } @@ -851,7 +851,10 @@ void UpdateVectors() { void DrawItemTracker(bool& open) { UpdateVectors(); if (!open) { - CVarSetInteger("gItemTrackerEnabled", 0); + if (CVarGetInteger("gItemTrackerEnabled", 0)) { + CVarClear("gItemTrackerEnabled"); + LUS::RequestCvarSaveOnNextTick(); + } return; } int iconSize = CVarGetInteger("gItemTrackerIconSize", 36); @@ -959,7 +962,10 @@ static const char* extendedDisplayTypes[4] = { "Hidden", "Main Window", "Misc Wi void DrawItemTrackerOptions(bool& open) { if (!open) { - CVarSetInteger("gItemTrackerSettingsEnabled", 0); + if (CVarGetInteger("gItemTrackerSettingsEnabled", 0)) { + CVarClear("gItemTrackerSettingsEnabled"); + LUS::RequestCvarSaveOnNextTick(); + } return; } @@ -985,7 +991,7 @@ void DrawItemTrackerOptions(bool& open) { CVarSetFloat("gItemTrackerBgColorG", ChromaKeyBackground.y); CVarSetFloat("gItemTrackerBgColorB", ChromaKeyBackground.z); CVarSetFloat("gItemTrackerBgColorA", ChromaKeyBackground.w); - Ship::RequestCvarSaveOnNextTick(); + LUS::RequestCvarSaveOnNextTick(); } ImGui::PopItemWidth(); @@ -1081,8 +1087,8 @@ void DrawItemTrackerOptions(bool& open) { } void InitItemTracker() { - Ship::AddWindow("Randomizer", "Item Tracker", DrawItemTracker, CVarGetInteger("gItemTrackerEnabled", 0) == 1); - Ship::AddWindow("Randomizer", "Item Tracker Settings", DrawItemTrackerOptions); + LUS::AddWindow("Randomizer", "Item Tracker", DrawItemTracker, CVarGetInteger("gItemTrackerEnabled", 0)); + LUS::AddWindow("Randomizer", "Item Tracker Settings", DrawItemTrackerOptions, CVarGetInteger("gItemTrackerSettingsEnabled", 0)); float trackerBgR = CVarGetFloat("gItemTrackerBgColorR", 0); float trackerBgG = CVarGetFloat("gItemTrackerBgColorG", 0); float trackerBgB = CVarGetFloat("gItemTrackerBgColorB", 0); @@ -1097,16 +1103,16 @@ void InitItemTracker() { if (itemTrackerNotes.empty()) { itemTrackerNotes.push_back(0); } - Ship::RegisterHook([](OSContPad* cont_pad) { + LUS::RegisterHook([](OSContPad* cont_pad) { buttonsPressed = cont_pad; }); - Ship::RegisterHook([](uint32_t fileNum) { + LUS::RegisterHook([](uint32_t fileNum) { const char* initialTrackerNotes = CVarGetString(("gItemTrackerNotes" + std::to_string(fileNum)).c_str(), ""); itemTrackerNotes.resize(strlen(initialTrackerNotes) + 1); strcpy(itemTrackerNotes.Data, initialTrackerNotes); }); - Ship::RegisterHook([](uint32_t fileNum) { + LUS::RegisterHook([](uint32_t fileNum) { CVarSetString(("gItemTrackerNotes" + std::to_string(fileNum)).c_str(), ""); - Ship::RequestCvarSaveOnNextTick(); + LUS::RequestCvarSaveOnNextTick(); }); } diff --git a/soh/soh/Enhancements/savestates.cpp b/soh/soh/Enhancements/savestates.cpp index 51cb871d9..d976cb764 100644 --- a/soh/soh/Enhancements/savestates.cpp +++ b/soh/soh/Enhancements/savestates.cpp @@ -837,7 +837,7 @@ extern "C" void ProcessSaveStateRequests(void) { } void SaveStateMgr::SetCurrentSlot(unsigned int slot) { - Ship::GetGameOverlay()->TextDrawNotification(1.0f, true, "slot %u set", slot); + LUS::GetGameOverlay()->TextDrawNotification(1.0f, true, "slot %u set", slot); this->currentSlot = slot; } @@ -855,12 +855,12 @@ void SaveStateMgr::ProcessSaveStateRequests(void) { this->states[request.slot] = std::make_shared(OTRGlobals::Instance->gSaveStateMgr, request.slot); } this->states[request.slot]->Save(); - Ship::GetGameOverlay()->TextDrawNotification(1.0f, true, "saved state %u", request.slot); + LUS::GetGameOverlay()->TextDrawNotification(1.0f, true, "saved state %u", request.slot); break; case RequestType::LOAD: if (this->states.contains(request.slot)) { this->states[request.slot]->Load(); - Ship::GetGameOverlay()->TextDrawNotification(1.0f, true, "loaded state %u", request.slot); + LUS::GetGameOverlay()->TextDrawNotification(1.0f, true, "loaded state %u", request.slot); } else { SPDLOG_ERROR("Invalid SaveState slot: {}", request.type); } @@ -876,7 +876,7 @@ void SaveStateMgr::ProcessSaveStateRequests(void) { SaveStateReturn SaveStateMgr::AddRequest(const SaveStateRequest request) { if (gPlayState == nullptr) { SPDLOG_ERROR("[SOH] Can not save or load a state outside of \"GamePlay\""); - Ship::GetGameOverlay()->TextDrawNotification(1.0f, true, "states not available here", request.slot); + LUS::GetGameOverlay()->TextDrawNotification(1.0f, true, "states not available here", request.slot); return SaveStateReturn::FAIL_WRONG_GAMESTATE; } @@ -890,7 +890,7 @@ SaveStateReturn SaveStateMgr::AddRequest(const SaveStateRequest request) { return SaveStateReturn::SUCCESS; } else { SPDLOG_ERROR("Invalid SaveState slot: {}", request.type); - Ship::GetGameOverlay()->TextDrawNotification(1.0f, true, "state slot %u empty", request.slot); + LUS::GetGameOverlay()->TextDrawNotification(1.0f, true, "state slot %u empty", request.slot); return SaveStateReturn::FAIL_INVALID_SLOT; } [[unlikely]] default: diff --git a/soh/soh/Enhancements/tts/tts.cpp b/soh/soh/Enhancements/tts/tts.cpp index 7c7ae3ff7..29e39c7e5 100644 --- a/soh/soh/Enhancements/tts/tts.cpp +++ b/soh/soh/Enhancements/tts/tts.cpp @@ -681,22 +681,22 @@ void InitTTSBank() { break; } - auto sceneFile = OTRGlobals::Instance->context->GetResourceManager()->LoadFile("accessibility/texts/scenes" + languageSuffix); + auto sceneFile = LUS::Context::GetInstance()->GetResourceManager()->LoadFile("accessibility/texts/scenes" + languageSuffix); if (sceneFile != nullptr) { sceneMap = nlohmann::json::parse(sceneFile->Buffer, nullptr, true, true); } - auto miscFile = OTRGlobals::Instance->context->GetResourceManager()->LoadFile("accessibility/texts/misc" + languageSuffix); + auto miscFile = LUS::Context::GetInstance()->GetResourceManager()->LoadFile("accessibility/texts/misc" + languageSuffix); if (miscFile != nullptr) { miscMap = nlohmann::json::parse(miscFile->Buffer, nullptr, true, true); } - auto kaleidoFile = OTRGlobals::Instance->context->GetResourceManager()->LoadFile("accessibility/texts/kaleidoscope" + languageSuffix); + auto kaleidoFile = LUS::Context::GetInstance()->GetResourceManager()->LoadFile("accessibility/texts/kaleidoscope" + languageSuffix); if (kaleidoFile != nullptr) { kaleidoMap = nlohmann::json::parse(kaleidoFile->Buffer, nullptr, true, true); } - auto fileChooseFile = OTRGlobals::Instance->context->GetResourceManager()->LoadFile("accessibility/texts/filechoose" + languageSuffix); + auto fileChooseFile = LUS::Context::GetInstance()->GetResourceManager()->LoadFile("accessibility/texts/filechoose" + languageSuffix); if (fileChooseFile != nullptr) { fileChooseMap = nlohmann::json::parse(fileChooseFile->Buffer, nullptr, true, true); } diff --git a/soh/soh/Extractor/Extract.cpp b/soh/soh/Extractor/Extract.cpp index e0e5e74b3..a9ddc4f41 100644 --- a/soh/soh/Extractor/Extract.cpp +++ b/soh/soh/Extractor/Extract.cpp @@ -54,10 +54,10 @@ static constexpr uint32_t OOT_PAL_GC_DBG2 = 0x87121EFE; // 03-13-2002 build static constexpr uint32_t OOT_PAL_GC_MQ_DBG = 0x917D18F6; static const std::unordered_map verMap = { - { OOT_PAL_GC, "Pal Gamecube" }, - { OOT_PAL_GC_DBG1, "PAL Debug 1" }, - { OOT_PAL_GC_DBG2, "PAL Debug 2" }, - { OOT_PAL_GC_MQ_DBG, "PAL MQ Debug" }, + { OOT_PAL_GC, "PAL GameCube" }, + { OOT_PAL_GC_DBG1, "PAL GameCube Debug 1" }, + { OOT_PAL_GC_DBG2, "PAL GameCube Debug 2" }, + { OOT_PAL_GC_MQ_DBG, "PAL GameCube MQ Debug" }, }; // TODO only check the first 54MB of the rom. @@ -156,6 +156,40 @@ void Extractor::SetRomInfo(const std::string& path) { mCurRomSize = GetCurRomSize(); } +void Extractor::FilterRoms(std::vector& roms, RomSearchMode searchMode) { + std::ifstream inFile; + std::vector::iterator it = roms.begin(); + + while (it != roms.end()) { + std::string rom = *it; + SetRomInfo(rom); + + // Skip. We will handle rom size errors later on after filtering + if (!ValidateRomSize()) { + it++; + continue; + } + + inFile.open(rom, std::ios::in | std::ios::binary); + inFile.read((char*)mRomData.get(), mCurRomSize); + inFile.clear(); + inFile.close(); + + RomToBigEndian(mRomData.get(), mCurRomSize); + + // Rom doesn't claim to be valid + // Game type doesn't match search mode + if (!verMap.contains(GetRomVerCrc()) || + (searchMode == RomSearchMode::Vanilla && IsMasterQuest()) || + (searchMode == RomSearchMode::MQ && !IsMasterQuest())) { + it = roms.erase(it); + continue; + } + + it++; + } +} + void Extractor::GetRoms(std::vector& roms) { #ifdef _WIN32 WIN32_FIND_DATAA ffd; @@ -258,6 +292,7 @@ bool Extractor::GetRomPathFromBox() { mCurRomSize = GetCurRomSize(); return true; } + uint32_t Extractor::GetRomVerCrc() const { return BSWAP32(((uint32_t*)mRomData.get())[4]); } @@ -303,28 +338,73 @@ bool Extractor::ValidateRom(bool skipCrcTextBox) { return true; } -bool Extractor::Run() { +bool Extractor::ManuallySearchForRom() { + std::ifstream inFile; + + if (!GetRomPathFromBox()) { + ShowErrorBox("No rom selected", "No Rom selected. Exiting"); + return false; + } + + inFile.open(mCurrentRomPath, std::ios::in | std::ios::binary); + + if (!inFile.is_open()) { + return false; // TODO Handle error + } + + inFile.read((char*)mRomData.get(), mCurRomSize); + inFile.close(); + RomToBigEndian(mRomData.get(), mCurRomSize); + + if (!ValidateRom()) { + return false; + } + + return true; +} + +bool Extractor::ManuallySearchForRomMatchingType(RomSearchMode searchMode) { + if (!ManuallySearchForRom()) { + return false; + } + + char msgBuf[150]; + snprintf(msgBuf, 150, "The selected rom does not match the expected game type\nExpected type: %s.\n\nDo you want to search again?", + searchMode == RomSearchMode::MQ ? "Master Quest" : "Vanilla"); + + while ((searchMode == RomSearchMode::Vanilla && IsMasterQuest()) || + (searchMode == RomSearchMode::MQ && !IsMasterQuest())) { + int ret = ShowYesNoBox("Wrong Game Type", msgBuf); + switch (ret) { + case IDYES: + if (!ManuallySearchForRom()) { + return false; + } + continue; + case IDNO: + return false; + default: + UNREACHABLE; + break; + } + } + + return true; +} + +bool Extractor::Run(RomSearchMode searchMode) { std::vector roms; std::ifstream inFile; - uint32_t verCrc; GetRoms(roms); + FilterRoms(roms, searchMode); if (roms.empty()) { int ret = ShowYesNoBox("No roms found", "No roms found. Look for one?"); switch (ret) { case IDYES: - if (!GetRomPathFromBox()) { - ShowErrorBox("No rom selected", "No rom selected. Exiting"); - return false; - } - inFile.open(mCurrentRomPath, std::ios::in | std::ios::binary); - if (!inFile.is_open()) { - return false; // TODO Handle error - } - inFile.read((char*)mRomData.get(), mCurRomSize); - if (!ValidateRom()) { + if (!ManuallySearchForRomMatchingType(searchMode)) { return false; } break; @@ -338,27 +418,21 @@ bool Extractor::Run() { } for (const auto& rom : roms) { - int option; - SetRomInfo(rom); - if (inFile.is_open()) { - inFile.close(); - } - inFile.open(rom, std::ios::in | std::ios::binary); + if (!ValidateRomSize()) { ShowSizeErrorBox(); continue; } + + inFile.open(rom, std::ios::in | std::ios::binary); inFile.read((char*)mRomData.get(), mCurRomSize); + inFile.clear(); + inFile.close(); RomToBigEndian(mRomData.get(), mCurRomSize); - verCrc = GetRomVerCrc(); - // Rom doesn't claim to be valid - if (!verMap.contains(verCrc)) { - continue; - } + int option = ShowRomPickBox(GetRomVerCrc()); - option = ShowRomPickBox(verCrc); if (option == (int)ButtonId::YES) { if (!ValidateRom(true)) { if (rom == roms.back()) { @@ -371,21 +445,11 @@ bool Extractor::Run() { } break; } else if (option == (int)ButtonId::FIND) { - if (!GetRomPathFromBox()) { - ShowErrorBox("No rom selected", "No Rom selected. Exiting"); - return false; - } - inFile.open(mCurrentRomPath, std::ios::in | std::ios::binary); - if (!inFile.is_open()) { - return false; // TODO Handle error - } - inFile.read((char*)mRomData.get(), mCurRomSize); - if (!ValidateRom()) { + if (!ManuallySearchForRomMatchingType(searchMode)) { return false; } break; } else if (option == (int)ButtonId::NO) { - inFile.close(); if (rom == roms.back()) { ShowErrorBox("No rom provided", "No rom provided. Exiting"); return false; diff --git a/soh/soh/Extractor/Extract.h b/soh/soh/Extractor/Extract.h index 3ca23aaf3..e4eb2e5bb 100644 --- a/soh/soh/Extractor/Extract.h +++ b/soh/soh/Extractor/Extract.h @@ -19,6 +19,12 @@ static constexpr size_t MB32 = 32 * MB_BASE; static constexpr size_t MB54 = 54 * MB_BASE; static constexpr size_t MB64 = 64 * MB_BASE; +enum class RomSearchMode { + Both = 0, + Vanilla = 1, + MQ = 2, +}; + class Extractor { std::unique_ptr mRomData = std::make_unique(MB64); std::string mCurrentRomPath; @@ -33,21 +39,24 @@ class Extractor { bool ValidateRom(bool skipCrcBox = false); const char* GetZapdVerStr() const; - bool IsMasterQuest() const; - + void SetRomInfo(const std::string& path); + void FilterRoms(std::vector& roms, RomSearchMode searchMode); void GetRoms(std::vector& roms); void ShowSizeErrorBox() const; void ShowCrcErrorBox() const; int ShowRomPickBox(uint32_t verCrc) const; + bool ManuallySearchForRom(); + bool ManuallySearchForRomMatchingType(RomSearchMode searchMode); public: //TODO create some kind of abstraction for message boxes. static int ShowYesNoBox(const char* title, const char* text); static void ShowErrorBox(const char* title, const char* text); + bool IsMasterQuest() const; - bool Run(); + bool Run(RomSearchMode searchMode = RomSearchMode::Both); bool CallZapd(); const char* GetZapdStr(); }; diff --git a/soh/soh/GameMenuBar.cpp b/soh/soh/GameMenuBar.cpp index 01dfd388e..42ee23284 100644 --- a/soh/soh/GameMenuBar.cpp +++ b/soh/soh/GameMenuBar.cpp @@ -12,7 +12,7 @@ #define IMGUI_DEFINE_MATH_OPERATORS #include #include -#include +#include #include #include #include @@ -108,8 +108,8 @@ namespace GameMenuBar { // MARK: - Delegates void SetupHooks() { - Ship::RegisterHook(UpdateAudio); - Ship::RegisterHook(UpdateAudio); + LUS::RegisterHook(UpdateAudio); + LUS::RegisterHook(UpdateAudio); } void Draw() { @@ -131,8 +131,8 @@ namespace GameMenuBar { } ImGui::Text("Audio API (Needs reload)"); - auto audioBackends = Ship::GetAvailableAudioBackends(); - auto currentAudioBackend = Ship::GetCurrentAudioBackend(); + auto audioBackends = LUS::GetAvailableAudioBackends(); + auto currentAudioBackend = LUS::GetCurrentAudioBackend(); if (audioBackends.size() <= 1) { UIWidgets::DisableComponent(ImGui::GetStyle().Alpha * 0.5f); @@ -140,7 +140,7 @@ namespace GameMenuBar { if (ImGui::BeginCombo("##AApi", currentAudioBackend.second)) { for (uint8_t i = 0; i < audioBackends.size(); i++) { if (ImGui::Selectable(audioBackends[i].second, audioBackends[i] == currentAudioBackend)) { - Ship::SetCurrentAudioBackend(i, audioBackends[i]); + LUS::SetCurrentAudioBackend(i, audioBackends[i]); } } @@ -162,10 +162,13 @@ namespace GameMenuBar { ImGui::PushStyleColor(ImGuiCol_Border, ImVec4(0.22f, 0.38f, 0.56f, 1.0f)); if (ImGui::Button(GetWindowButtonText("Controller Configuration", CVarGetInteger("gControllerConfigurationEnabled", 0)).c_str(), ImVec2 (-1.0f, 0.0f))) { - bool currentValue = CVarGetInteger("gControllerConfigurationEnabled", 0); - CVarSetInteger("gControllerConfigurationEnabled", !currentValue); - Ship::RequestCvarSaveOnNextTick(); - Ship::ToggleInputEditorWindow(CVarGetInteger("gControllerConfigurationEnabled", 0)); + if (CVarGetInteger("gControllerConfigurationEnabled", 0)) { + CVarClear("gControllerConfigurationEnabled"); + } else { + CVarSetInteger("gControllerConfigurationEnabled", 1); + } + LUS::RequestCvarSaveOnNextTick(); + LUS::ToggleInputEditorWindow(CVarGetInteger("gControllerConfigurationEnabled", 0)); } UIWidgets::PaddedSeparator(); ImGui::PopStyleColor(1); @@ -190,21 +193,21 @@ namespace GameMenuBar { #ifndef __APPLE__ UIWidgets::EnhancementSliderFloat("Internal Resolution: %d %%", "##IMul", "gInternalResolution", 0.5f, 2.0f, "", 1.0f, true); UIWidgets::Tooltip("Multiplies your output resolution by the value inputted, as a more intensive but effective form of anti-aliasing"); - Ship::SetResolutionMultiplier(CVarGetFloat("gInternalResolution", 1)); + LUS::SetResolutionMultiplier(CVarGetFloat("gInternalResolution", 1)); #endif #ifndef __WIIU__ UIWidgets::PaddedEnhancementSliderInt("MSAA: %d", "##IMSAA", "gMSAAValue", 1, 8, "", 1, true, true, false); UIWidgets::Tooltip("Activates multi-sample anti-aliasing when above 1x up to 8x for 8 samples for every pixel"); - Ship::SetMSAALevel(CVarGetInteger("gMSAAValue", 1)); + LUS::SetMSAALevel(CVarGetInteger("gMSAAValue", 1)); #endif { // FPS Slider const int minFps = 20; static int maxFps; - if (Ship::WindowBackend() == Ship::Backend::DX11) { + if (LUS::WindowBackend() == LUS::Backend::DX11) { maxFps = 360; } else { - maxFps = Ship::Window::GetInstance()->GetCurrentRefreshRate(); + maxFps = LUS::Context::GetInstance()->GetWindow()->GetCurrentRefreshRate(); } int currentFps = fmax(fmin(OTRGlobals::Instance->GetInterpolationFPS(), maxFps), minFps); #ifdef __WIIU__ @@ -264,15 +267,15 @@ namespace GameMenuBar { currentFps = 60; } CVarSetInteger("gInterpolationFPS", currentFps); - Ship::RequestCvarSaveOnNextTick(); + LUS::RequestCvarSaveOnNextTick(); #else bool matchingRefreshRate = - CVarGetInteger("gMatchRefreshRate", 0) && Ship::WindowBackend() != Ship::Backend::DX11; + CVarGetInteger("gMatchRefreshRate", 0) && LUS::WindowBackend() != LUS::Backend::DX11; UIWidgets::PaddedEnhancementSliderInt( (currentFps == 20) ? "FPS: Original (20)" : "FPS: %d", "##FPSInterpolation", "gInterpolationFPS", minFps, maxFps, "", 20, true, true, false, matchingRefreshRate); #endif - if (Ship::WindowBackend() == Ship::Backend::DX11) { + if (LUS::WindowBackend() == LUS::Backend::DX11) { UIWidgets::Tooltip( "Uses Matrix Interpolation to create extra frames, resulting in smoother graphics. This is purely " "visual and does not impact game logic, execution of glitches etc.\n\n" @@ -286,13 +289,13 @@ namespace GameMenuBar { } } // END FPS Slider - if (Ship::WindowBackend() == Ship::Backend::DX11) { + if (LUS::WindowBackend() == LUS::Backend::DX11) { UIWidgets::Spacer(0); if (ImGui::Button("Match Refresh Rate")) { - int hz = Ship::Window::GetInstance()->GetCurrentRefreshRate(); + int hz = LUS::Context::GetInstance()->GetWindow()->GetCurrentRefreshRate(); if (hz >= 20 && hz <= 360) { CVarSetInteger("gInterpolationFPS", hz); - Ship::RequestCvarSaveOnNextTick(); + LUS::RequestCvarSaveOnNextTick(); } } } else { @@ -300,7 +303,7 @@ namespace GameMenuBar { } UIWidgets::Tooltip("Matches interpolation value to the current game's window refresh rate"); - if (Ship::WindowBackend() == Ship::Backend::DX11) { + if (LUS::WindowBackend() == LUS::Backend::DX11) { UIWidgets::PaddedEnhancementSliderInt(CVarGetInteger("gExtraLatencyThreshold", 80) == 0 ? "Jitter fix: Off" : "Jitter fix: >= %d FPS", "##ExtraLatencyThreshold", "gExtraLatencyThreshold", 0, 360, "", 80, true, true, false); UIWidgets::Tooltip("When Interpolation FPS setting is at least this threshold, add one frame of input lag (e.g. 16.6 ms for 60 FPS) in order to avoid jitter. This setting allows the CPU to work on one frame while GPU works on the previous frame.\nThis setting should be used when your computer is too slow to do CPU + GPU work in time."); @@ -309,8 +312,8 @@ namespace GameMenuBar { UIWidgets::PaddedSeparator(true, true, 3.0f, 3.0f); ImGui::Text("Renderer API (Needs reload)"); - auto renderingBackends = Ship::GetAvailableRenderingBackends(); - auto currentRenderingBackend = Ship::GetCurrentRenderingBackend(); + auto renderingBackends = LUS::GetAvailableRenderingBackends(); + auto currentRenderingBackend = LUS::GetCurrentRenderingBackend(); if (renderingBackends.size() <= 1) { UIWidgets::DisableComponent(ImGui::GetStyle().Alpha * 0.5f); @@ -318,7 +321,7 @@ namespace GameMenuBar { if (ImGui::BeginCombo("##RApi", currentRenderingBackend.second)) { for (uint8_t i = 0; i < renderingBackends.size(); i++) { if (ImGui::Selectable(renderingBackends[i].second, renderingBackends[i] == currentRenderingBackend)) { - Ship::SetCurrentRenderingBackend(i, renderingBackends[i]); + LUS::SetCurrentRenderingBackend(i, renderingBackends[i]); } } @@ -328,28 +331,28 @@ namespace GameMenuBar { UIWidgets::ReEnableComponent(""); } - if (Ship::Window::GetInstance()->CanDisableVerticalSync()) { + if (LUS::Context::GetInstance()->GetWindow()->CanDisableVerticalSync()) { UIWidgets::PaddedEnhancementCheckbox("Enable Vsync", "gVsyncEnabled", true, false); } - if (Ship::SupportsWindowedFullscreen()) { + if (LUS::SupportsWindowedFullscreen()) { UIWidgets::PaddedEnhancementCheckbox("Windowed fullscreen", "gSdlWindowedFullscreen", true, false); } - if (Ship::SupportsViewports()) { - UIWidgets::PaddedEnhancementCheckbox("Allow multi-windows", "gEnableMultiViewports", true, false); + if (LUS::SupportsViewports()) { + UIWidgets::PaddedEnhancementCheckbox("Allow multi-windows", "gEnableMultiViewports", true, false, false, "", UIWidgets::CheckboxGraphics::Cross, true); UIWidgets::Tooltip("Allows windows to be able to be dragged off of the main game window. Requires a reload to take effect."); } // If more filters are added to LUS, make sure to add them to the filters list here ImGui::Text("Texture Filter (Needs reload)"); - const char* filters[] = { Ship::GetSupportedTextureFilters()[0], Ship::GetSupportedTextureFilters()[1], - Ship::GetSupportedTextureFilters()[2] }; + const char* filters[] = { LUS::GetSupportedTextureFilters()[0], LUS::GetSupportedTextureFilters()[1], + LUS::GetSupportedTextureFilters()[2] }; UIWidgets::EnhancementCombobox("gTextureFilter", filters, 0); UIWidgets::Spacer(0); - Ship::DrawSettings(); + LUS::DrawSettings(); ImGui::EndMenu(); } @@ -887,11 +890,13 @@ namespace GameMenuBar { UIWidgets::Tooltip("Correctly centers the Navi text prompt on the HUD's C-Up button"); UIWidgets::PaddedEnhancementCheckbox("Fix Anubis fireballs", "gAnubisFix", true, false); UIWidgets::Tooltip("Make Anubis fireballs do fire damage when reflected back at them with the Mirror Shield"); - UIWidgets::PaddedEnhancementCheckbox("Fix Megaton Hammer crouch stab", "gCrouchStabHammerFix", true, false); + if (UIWidgets::PaddedEnhancementCheckbox("Fix Megaton Hammer crouch stab", "gCrouchStabHammerFix", true, false)) { + if (!CVarGetInteger("gCrouchStabHammerFix", 0)) { + CVarClear("gCrouchStabFix"); + } + } UIWidgets::Tooltip("Make the Megaton Hammer's crouch stab able to destroy rocks without first swinging it normally"); - if (CVarGetInteger("gCrouchStabHammerFix", 0) == 0) { - CVarSetInteger("gCrouchStabFix", 0); - } else { + if (CVarGetInteger("gCrouchStabHammerFix", 0)) { UIWidgets::PaddedEnhancementCheckbox("Remove power crouch stab", "gCrouchStabFix", true, false); UIWidgets::Tooltip("Make crouch stabbing always do the same damage as a regular slash"); } @@ -980,30 +985,42 @@ namespace GameMenuBar { if (ImGui::Button(GetWindowButtonText("Customize Game Controls", CVarGetInteger("gGameControlEditorEnabled", 0)).c_str(), ImVec2(-1.0f, 0.0f))) { - bool currentValue = CVarGetInteger("gGameControlEditorEnabled", 0); - CVarSetInteger("gGameControlEditorEnabled", !currentValue); - Ship::RequestCvarSaveOnNextTick(); - Ship::EnableWindow("Game Control Editor", CVarGetInteger("gGameControlEditorEnabled", 0)); + if (CVarGetInteger("gGameControlEditorEnabled", 0)) { + CVarClear("gGameControlEditorEnabled"); + } else { + CVarSetInteger("gGameControlEditorEnabled", 1); + } + LUS::RequestCvarSaveOnNextTick(); + LUS::EnableWindow("Game Control Editor", CVarGetInteger("gGameControlEditorEnabled", 0)); } if (ImGui::Button(GetWindowButtonText("Cosmetics Editor", CVarGetInteger("gCosmeticsEditorEnabled", 0)).c_str(), ImVec2(-1.0f, 0.0f))) { - bool currentValue = CVarGetInteger("gCosmeticsEditorEnabled", 0); - CVarSetInteger("gCosmeticsEditorEnabled", !currentValue); - Ship::RequestCvarSaveOnNextTick(); - Ship::EnableWindow("Cosmetics Editor", CVarGetInteger("gCosmeticsEditorEnabled", 0)); + if (CVarGetInteger("gCosmeticsEditorEnabled", 0)) { + CVarClear("gCosmeticsEditorEnabled"); + } else { + CVarSetInteger("gCosmeticsEditorEnabled", 1); + } + LUS::RequestCvarSaveOnNextTick(); + LUS::EnableWindow("Cosmetics Editor", CVarGetInteger("gCosmeticsEditorEnabled", 0)); } if (ImGui::Button(GetWindowButtonText("Audio Editor", CVarGetInteger("gAudioEditor.WindowOpen", 0)).c_str(), ImVec2(-1.0f, 0.0f))) { - bool currentValue = CVarGetInteger("gAudioEditor.WindowOpen", 0); - CVarSetInteger("gAudioEditor.WindowOpen", !currentValue); - Ship::RequestCvarSaveOnNextTick(); - Ship::EnableWindow("Audio Editor", CVarGetInteger("gAudioEditor.WindowOpen", 0)); + if (CVarGetInteger("gAudioEditor.WindowOpen", 0)) { + CVarClear("gAudioEditor.WindowOpen"); + } else { + CVarSetInteger("gAudioEditor.WindowOpen", 1); + } + LUS::RequestCvarSaveOnNextTick(); + LUS::EnableWindow("Audio Editor", CVarGetInteger("gAudioEditor.WindowOpen", 0)); } if (ImGui::Button(GetWindowButtonText("Gameplay Stats", CVarGetInteger("gGameplayStatsEnabled", 0)).c_str(), ImVec2(-1.0f, 0.0f))) { - bool currentValue = CVarGetInteger("gGameplayStatsEnabled", 0); - CVarSetInteger("gGameplayStatsEnabled", !currentValue); - Ship::RequestCvarSaveOnNextTick(); - Ship::EnableWindow("Gameplay Stats", CVarGetInteger("gGameplayStatsEnabled", 0)); + if (CVarGetInteger("gGameplayStatsEnabled", 0)) { + CVarClear("gGameplayStatsEnabled"); + } else { + CVarSetInteger("gGameplayStatsEnabled", 1); + } + LUS::RequestCvarSaveOnNextTick(); + LUS::EnableWindow("Gameplay Stats", CVarGetInteger("gGameplayStatsEnabled", 0)); } ImGui::PopStyleVar(3); ImGui::PopStyleColor(1); @@ -1011,9 +1028,9 @@ namespace GameMenuBar { #ifdef __SWITCH__ UIWidgets::Spacer(0); ImGui::Text("Switch performance mode"); - if (UIWidgets::EnhancementCombobox("gSwitchPerfMode", SWITCH_CPU_PROFILES, (int)Ship::SwitchProfiles::STOCK)) { - SPDLOG_INFO("Profile:: %s", SWITCH_CPU_PROFILES[CVarGetInteger("gSwitchPerfMode", (int)Ship::SwitchProfiles::STOCK)]); - Ship::Switch::ApplyOverclock(); + if (UIWidgets::EnhancementCombobox("gSwitchPerfMode", SWITCH_CPU_PROFILES, (int)LUS::SwitchProfiles::STOCK)) { + SPDLOG_INFO("Profile:: %s", SWITCH_CPU_PROFILES[CVarGetInteger("gSwitchPerfMode", (int)LUS::SwitchProfiles::STOCK)]); + LUS::Switch::ApplyOverclock(); } #endif @@ -1114,7 +1131,7 @@ namespace GameMenuBar { } else { lastBetaQuestWorld = betaQuestWorld = 0xFFEF; - CVarSetInteger("gBetaQuestWorld", betaQuestWorld); + CVarClear("gBetaQuestWorld"); } if (betaQuestEnabled != lastBetaQuestEnabled || betaQuestWorld != lastBetaQuestWorld) { @@ -1124,9 +1141,9 @@ namespace GameMenuBar { CVarSetInteger("gEnableBetaQuest", betaQuestEnabled); CVarSetInteger("gBetaQuestWorld", betaQuestWorld); - Ship::DispatchConsoleCommand("reset"); + LUS::DispatchConsoleCommand("reset"); - Ship::RequestCvarSaveOnNextTick(); + LUS::RequestCvarSaveOnNextTick(); } if (!isBetaQuestEnabled) { @@ -1158,7 +1175,7 @@ namespace GameMenuBar { }; UIWidgets::PaddedEnhancementCheckbox("Better Debug Warp Screen", "gBetterDebugWarpScreen", true, false); UIWidgets::Tooltip("Optimized debug warp screen, with the added ability to chose entrances and time of day"); - UIWidgets::PaddedEnhancementCheckbox("Debug Warp Screen Translation", "gDebugWarpScreenTranslation", true, false); + UIWidgets::PaddedEnhancementCheckbox("Debug Warp Screen Translation", "gDebugWarpScreenTranslation", true, false, false, "", UIWidgets::CheckboxGraphics::Cross, true); UIWidgets::Tooltip("Translate the Debug Warp Screen based on the game language"); UIWidgets::PaddedSeparator(); ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(12.0f, 6.0f)); @@ -1167,52 +1184,70 @@ namespace GameMenuBar { ImGui::PushStyleColor(ImGuiCol_Border, ImVec4(0.22f, 0.38f, 0.56f, 1.0f)); if (ImGui::Button(GetWindowButtonText("Stats", CVarGetInteger("gStatsEnabled", 0)).c_str(), ImVec2(-1.0f, 0.0f))) { - bool currentValue = CVarGetInteger("gStatsEnabled", 0); - CVarSetInteger("gStatsEnabled", !currentValue); - Ship::ToggleStatisticsWindow(true); - Ship::RequestCvarSaveOnNextTick(); + if (CVarGetInteger("gStatsEnabled", 0)) { + CVarClear("gStatsEnabled"); + } else { + CVarSetInteger("gStatsEnabled", 1); + } + LUS::ToggleStatisticsWindow(CVarGetInteger("gStatsEnabled", 0)); + LUS::RequestCvarSaveOnNextTick(); } UIWidgets::Tooltip("Shows the stats window, with your FPS and frametimes, and the OS you're playing on"); UIWidgets::Spacer(0); if (ImGui::Button(GetWindowButtonText("Console", CVarGetInteger("gConsoleEnabled", 0)).c_str(), ImVec2(-1.0f, 0.0f))) { - bool currentValue = CVarGetInteger("gConsoleEnabled", 0); - CVarSetInteger("gConsoleEnabled", !currentValue); - Ship::RequestCvarSaveOnNextTick(); - Ship::ToggleConsoleWindow(!currentValue); + if (CVarGetInteger("gConsoleEnabled", 0)) { + CVarClear("gConsoleEnabled"); + } else { + CVarSetInteger("gConsoleEnabled", 1); + } + LUS::RequestCvarSaveOnNextTick(); + LUS::ToggleConsoleWindow(CVarGetInteger("gConsoleEnabled", 0)); } UIWidgets::Tooltip("Enables the console window, allowing you to input commands, type help for some examples"); UIWidgets::Spacer(0); if (ImGui::Button(GetWindowButtonText("Save Editor", CVarGetInteger("gSaveEditorEnabled", 0)).c_str(), ImVec2(-1.0f, 0.0f))) { - bool currentValue = CVarGetInteger("gSaveEditorEnabled", 0); - CVarSetInteger("gSaveEditorEnabled", !currentValue); - Ship::RequestCvarSaveOnNextTick(); - Ship::EnableWindow("Save Editor", CVarGetInteger("gSaveEditorEnabled", 0)); + if (CVarGetInteger("gSaveEditorEnabled", 0)) { + CVarClear("gSaveEditorEnabled"); + } else { + CVarSetInteger("gSaveEditorEnabled", 1); + } + LUS::RequestCvarSaveOnNextTick(); + LUS::EnableWindow("Save Editor", CVarGetInteger("gSaveEditorEnabled", 0)); } UIWidgets::Spacer(0); if (ImGui::Button(GetWindowButtonText("Collision Viewer", CVarGetInteger("gCollisionViewerEnabled", 0)).c_str(), ImVec2(-1.0f, 0.0f))) { - bool currentValue = CVarGetInteger("gCollisionViewerEnabled", 0); - CVarSetInteger("gCollisionViewerEnabled", !currentValue); - Ship::RequestCvarSaveOnNextTick(); - Ship::EnableWindow("Collision Viewer", CVarGetInteger("gCollisionViewerEnabled", 0)); + if (CVarGetInteger("gCollisionViewerEnabled", 0)) { + CVarClear("gCollisionViewerEnabled"); + } else { + CVarSetInteger("gCollisionViewerEnabled", 1); + } + LUS::RequestCvarSaveOnNextTick(); + LUS::EnableWindow("Collision Viewer", CVarGetInteger("gCollisionViewerEnabled", 0)); } UIWidgets::Spacer(0); if (ImGui::Button(GetWindowButtonText("Actor Viewer", CVarGetInteger("gActorViewerEnabled", 0)).c_str(), ImVec2(-1.0f, 0.0f))) { - bool currentValue = CVarGetInteger("gActorViewerEnabled", 0); - CVarSetInteger("gActorViewerEnabled", !currentValue); - Ship::RequestCvarSaveOnNextTick(); - Ship::EnableWindow("Actor Viewer", CVarGetInteger("gActorViewerEnabled", 0)); + if (CVarGetInteger("gActorViewerEnabled", 0)) { + CVarClear("gActorViewerEnabled"); + } else { + CVarSetInteger("gActorViewerEnabled", 1); + } + LUS::RequestCvarSaveOnNextTick(); + LUS::EnableWindow("Actor Viewer", CVarGetInteger("gActorViewerEnabled", 0)); } UIWidgets::Spacer(0); if (ImGui::Button(GetWindowButtonText("Display List Viewer", CVarGetInteger("gDLViewerEnabled", 0)).c_str(), ImVec2(-1.0f, 0.0f))) { - bool currentValue = CVarGetInteger("gDLViewerEnabled", 0); - CVarSetInteger("gDLViewerEnabled", !currentValue); - Ship::RequestCvarSaveOnNextTick(); - Ship::EnableWindow("Display List Viewer", CVarGetInteger("gDLViewerEnabled", 0)); + if (CVarGetInteger("gDLViewerEnabled", 0)) { + CVarClear("gDLViewerEnabled"); + } else { + CVarSetInteger("gDLViewerEnabled", 1); + } + LUS::RequestCvarSaveOnNextTick(); + LUS::EnableWindow("Display List Viewer", CVarGetInteger("gDLViewerEnabled", 0)); } ImGui::PopStyleVar(3); ImGui::PopStyleColor(1); @@ -1235,50 +1270,68 @@ namespace GameMenuBar { #endif if (ImGui::Button(GetWindowButtonText("Randomizer Settings", CVarGetInteger("gRandomizerSettingsEnabled", 0)).c_str(), buttonSize)) { - bool currentValue = CVarGetInteger("gRandomizerSettingsEnabled", 0); - CVarSetInteger("gRandomizerSettingsEnabled", !currentValue); - Ship::RequestCvarSaveOnNextTick(); - Ship::EnableWindow("Randomizer Settings", CVarGetInteger("gRandomizerSettingsEnabled", 0)); + if (CVarGetInteger("gRandomizerSettingsEnabled", 0)) { + CVarClear("gRandomizerSettingsEnabled"); + } else { + CVarSetInteger("gRandomizerSettingsEnabled", 1); + } + LUS::RequestCvarSaveOnNextTick(); + LUS::EnableWindow("Randomizer Settings", CVarGetInteger("gRandomizerSettingsEnabled", 0)); } UIWidgets::Spacer(0); if (ImGui::Button(GetWindowButtonText("Item Tracker", CVarGetInteger("gItemTrackerEnabled", 0)).c_str(), buttonSize)) { - bool currentValue = CVarGetInteger("gItemTrackerEnabled", 0); - CVarSetInteger("gItemTrackerEnabled", !currentValue); - Ship::RequestCvarSaveOnNextTick(); - Ship::EnableWindow("Item Tracker", CVarGetInteger("gItemTrackerEnabled", 0)); + if (CVarGetInteger("gItemTrackerEnabled", 0)) { + CVarClear("gItemTrackerEnabled"); + } else { + CVarSetInteger("gItemTrackerEnabled", 1); + } + LUS::RequestCvarSaveOnNextTick(); + LUS::EnableWindow("Item Tracker", CVarGetInteger("gItemTrackerEnabled", 0)); } UIWidgets::Spacer(0); if (ImGui::Button(GetWindowButtonText("Item Tracker Settings", CVarGetInteger("gItemTrackerSettingsEnabled", 0)).c_str(), buttonSize)) { - bool currentValue = CVarGetInteger("gItemTrackerSettingsEnabled", 0); - CVarSetInteger("gItemTrackerSettingsEnabled", !currentValue); - Ship::RequestCvarSaveOnNextTick(); - Ship::EnableWindow("Item Tracker Settings", CVarGetInteger("gItemTrackerSettingsEnabled", 0)); + if (CVarGetInteger("gItemTrackerSettingsEnabled", 0)) { + CVarClear("gItemTrackerSettingsEnabled"); + } else { + CVarSetInteger("gItemTrackerSettingsEnabled", 1); + } + LUS::RequestCvarSaveOnNextTick(); + LUS::EnableWindow("Item Tracker Settings", CVarGetInteger("gItemTrackerSettingsEnabled", 0)); } UIWidgets::Spacer(0); if (ImGui::Button(GetWindowButtonText("Entrance Tracker", CVarGetInteger("gEntranceTrackerEnabled", 0)).c_str(), buttonSize)) { - bool currentValue = CVarGetInteger("gEntranceTrackerEnabled", 0); - CVarSetInteger("gEntranceTrackerEnabled", !currentValue); - Ship::RequestCvarSaveOnNextTick(); - Ship::EnableWindow("Entrance Tracker", CVarGetInteger("gEntranceTrackerEnabled", 0)); + if (CVarGetInteger("gEntranceTrackerEnabled", 0)) { + CVarClear("gEntranceTrackerEnabled"); + } else { + CVarSetInteger("gEntranceTrackerEnabled", 1); + } + LUS::RequestCvarSaveOnNextTick(); + LUS::EnableWindow("Entrance Tracker", CVarGetInteger("gEntranceTrackerEnabled", 0)); } UIWidgets::Spacer(0); if (ImGui::Button(GetWindowButtonText("Check Tracker", CVarGetInteger("gCheckTrackerEnabled", 0)).c_str(), buttonSize)) { - bool currentValue = CVarGetInteger("gCheckTrackerEnabled", 0); - CVarSetInteger("gCheckTrackerEnabled", !currentValue); - Ship::RequestCvarSaveOnNextTick(); - Ship::EnableWindow("Check Tracker", CVarGetInteger("gCheckTrackerEnabled", 0)); + if (CVarGetInteger("gCheckTrackerEnabled", 0)) { + CVarClear("gCheckTrackerEnabled"); + } else { + CVarSetInteger("gCheckTrackerEnabled", 1); + } + LUS::RequestCvarSaveOnNextTick(); + LUS::EnableWindow("Check Tracker", CVarGetInteger("gCheckTrackerEnabled", 0)); } UIWidgets::Spacer(0); if (ImGui::Button(GetWindowButtonText("Check Tracker Settings", CVarGetInteger("gCheckTrackerSettingsEnabled", 0)).c_str(), buttonSize)) { - bool currentValue = CVarGetInteger("gCheckTrackerSettingsEnabled", 0); - CVarSetInteger("gCheckTrackerSettingsEnabled", !currentValue); - Ship::RequestCvarSaveOnNextTick(); - Ship::EnableWindow("Check Tracker Settings", CVarGetInteger("gCheckTrackerSettingsEnabled", 0)); + if (CVarGetInteger("gCheckTrackerSettingsEnabled", 0)) { + CVarClear("gCheckTrackerSettingsEnabled"); + } else { + CVarSetInteger("gCheckTrackerSettingsEnabled", 1); + } + LUS::RequestCvarSaveOnNextTick(); + LUS::EnableWindow("Check Tracker Settings", CVarGetInteger("gCheckTrackerSettingsEnabled", 0)); } ImGui::PopStyleVar(3); ImGui::PopStyleColor(1); @@ -1287,11 +1340,11 @@ namespace GameMenuBar { if (ImGui::BeginMenu("Rando Enhancements")) { - UIWidgets::EnhancementCheckbox("Rando-Relevant Navi Hints", "gRandoRelevantNavi"); + UIWidgets::EnhancementCheckbox("Rando-Relevant Navi Hints", "gRandoRelevantNavi", false, "", UIWidgets::CheckboxGraphics::Cross, true); UIWidgets::Tooltip( "Replace Navi's overworld quest hints with rando-related gameplay hints." ); - UIWidgets::PaddedEnhancementCheckbox("Random Rupee Names", "gRandomizeRupeeNames", true, false); + UIWidgets::PaddedEnhancementCheckbox("Random Rupee Names", "gRandomizeRupeeNames", true, false, false, "", UIWidgets::CheckboxGraphics::Cross, true); UIWidgets::Tooltip( "When obtaining rupees, randomize what the rupee is called in the textbox." ); @@ -1318,7 +1371,7 @@ namespace GameMenuBar { "shuffle settings set to \"Any Dungeon\", \"Overworld\" or \"Anywhere\""; UIWidgets::PaddedEnhancementCheckbox("Key Colors Match Dungeon", "gRandoMatchKeyColors", true, false, - disableKeyColors, disableKeyColorsText); + disableKeyColors, disableKeyColorsText, UIWidgets::CheckboxGraphics::Cross, true); UIWidgets::Tooltip( "Matches the color of small keys and boss keys to the dungeon they belong to. " "This helps identify keys from afar and adds a little bit of flair.\n\nThis only " diff --git a/soh/soh/OTRGlobals.cpp b/soh/soh/OTRGlobals.cpp index cfbe95a02..d192de6aa 100644 --- a/soh/soh/OTRGlobals.cpp +++ b/soh/soh/OTRGlobals.cpp @@ -201,19 +201,19 @@ const char* constCameraStrings[] = { OTRGlobals::OTRGlobals() { std::vector OTRFiles; - std::string mqPath = Ship::Window::GetPathRelativeToAppDirectory("oot-mq.otr"); + std::string mqPath = LUS::Context::GetPathRelativeToAppDirectory("oot-mq.otr"); if (std::filesystem::exists(mqPath)) { OTRFiles.push_back(mqPath); } - std::string ootPath = Ship::Window::GetPathRelativeToAppDirectory("oot.otr"); + std::string ootPath = LUS::Context::GetPathRelativeToAppDirectory("oot.otr"); if (std::filesystem::exists(ootPath)) { OTRFiles.push_back(ootPath); } - std::string sohOtrPath = Ship::Window::GetPathRelativeToAppBundle("soh.otr"); + std::string sohOtrPath = LUS::Context::GetPathRelativeToAppBundle("soh.otr"); if (std::filesystem::exists(sohOtrPath)) { OTRFiles.push_back(sohOtrPath); } - std::string patchesPath = Ship::Window::GetPathRelativeToAppDirectory("mods"); + std::string patchesPath = LUS::Context::GetPathRelativeToAppDirectory("mods"); if (patchesPath.length() > 0 && std::filesystem::exists(patchesPath)) { if (std::filesystem::is_directory(patchesPath)) { for (const auto& p : std::filesystem::recursive_directory_iterator(patchesPath)) { @@ -240,21 +240,22 @@ OTRGlobals::OTRGlobals() { OOT_PAL_GC_DBG1, OOT_PAL_GC_DBG2 }; - context = Ship::Window::CreateInstance("Ship of Harkinian", "soh", OTRFiles); + // tell LUS to reserve 3 SoH specific threads (Game, Audio, Save) + context = LUS::Context::CreateInstance("Ship of Harkinian", "soh", OTRFiles, {}, 3); - context->GetResourceManager()->GetResourceLoader()->RegisterResourceFactory(Ship::ResourceType::SOH_Animation, "Animation", std::make_shared()); - context->GetResourceManager()->GetResourceLoader()->RegisterResourceFactory(Ship::ResourceType::SOH_PlayerAnimation, "PlayerAnimation", std::make_shared()); - context->GetResourceManager()->GetResourceLoader()->RegisterResourceFactory(Ship::ResourceType::SOH_Room, "Room", std::make_shared()); // Is room scene? maybe? - context->GetResourceManager()->GetResourceLoader()->RegisterResourceFactory(Ship::ResourceType::SOH_CollisionHeader, "CollisionHeader", std::make_shared()); - context->GetResourceManager()->GetResourceLoader()->RegisterResourceFactory(Ship::ResourceType::SOH_Skeleton, "Skeleton", std::make_shared()); - context->GetResourceManager()->GetResourceLoader()->RegisterResourceFactory(Ship::ResourceType::SOH_SkeletonLimb, "SkeletonLimb", std::make_shared()); - context->GetResourceManager()->GetResourceLoader()->RegisterResourceFactory(Ship::ResourceType::SOH_Path, "Path", std::make_shared()); - context->GetResourceManager()->GetResourceLoader()->RegisterResourceFactory(Ship::ResourceType::SOH_Cutscene, "Cutscene", std::make_shared()); - context->GetResourceManager()->GetResourceLoader()->RegisterResourceFactory(Ship::ResourceType::SOH_Text, "Text", std::make_shared()); - context->GetResourceManager()->GetResourceLoader()->RegisterResourceFactory(Ship::ResourceType::SOH_AudioSample, "AudioSample", std::make_shared()); - context->GetResourceManager()->GetResourceLoader()->RegisterResourceFactory(Ship::ResourceType::SOH_AudioSoundFont, "AudioSoundFont", std::make_shared()); - context->GetResourceManager()->GetResourceLoader()->RegisterResourceFactory(Ship::ResourceType::SOH_AudioSequence, "AudioSequence", std::make_shared()); - context->GetResourceManager()->GetResourceLoader()->RegisterResourceFactory(Ship::ResourceType::SOH_Background, "Background", std::make_shared()); + context->GetResourceManager()->GetResourceLoader()->RegisterResourceFactory(LUS::ResourceType::SOH_Animation, "Animation", std::make_shared()); + context->GetResourceManager()->GetResourceLoader()->RegisterResourceFactory(LUS::ResourceType::SOH_PlayerAnimation, "PlayerAnimation", std::make_shared()); + context->GetResourceManager()->GetResourceLoader()->RegisterResourceFactory(LUS::ResourceType::SOH_Room, "Room", std::make_shared()); // Is room scene? maybe? + context->GetResourceManager()->GetResourceLoader()->RegisterResourceFactory(LUS::ResourceType::SOH_CollisionHeader, "CollisionHeader", std::make_shared()); + context->GetResourceManager()->GetResourceLoader()->RegisterResourceFactory(LUS::ResourceType::SOH_Skeleton, "Skeleton", std::make_shared()); + context->GetResourceManager()->GetResourceLoader()->RegisterResourceFactory(LUS::ResourceType::SOH_SkeletonLimb, "SkeletonLimb", std::make_shared()); + context->GetResourceManager()->GetResourceLoader()->RegisterResourceFactory(LUS::ResourceType::SOH_Path, "Path", std::make_shared()); + context->GetResourceManager()->GetResourceLoader()->RegisterResourceFactory(LUS::ResourceType::SOH_Cutscene, "Cutscene", std::make_shared()); + context->GetResourceManager()->GetResourceLoader()->RegisterResourceFactory(LUS::ResourceType::SOH_Text, "Text", std::make_shared()); + context->GetResourceManager()->GetResourceLoader()->RegisterResourceFactory(LUS::ResourceType::SOH_AudioSample, "AudioSample", std::make_shared()); + context->GetResourceManager()->GetResourceLoader()->RegisterResourceFactory(LUS::ResourceType::SOH_AudioSoundFont, "AudioSoundFont", std::make_shared()); + context->GetResourceManager()->GetResourceLoader()->RegisterResourceFactory(LUS::ResourceType::SOH_AudioSequence, "AudioSequence", std::make_shared()); + context->GetResourceManager()->GetResourceLoader()->RegisterResourceFactory(LUS::ResourceType::SOH_Background, "Background", std::make_shared()); gSaveStateMgr = std::make_shared(); gRandomizer = std::make_shared(); @@ -278,7 +279,7 @@ OTRGlobals::OTRGlobals() { #if defined(__SWITCH__) SPDLOG_ERROR("Invalid OTR File!"); #elif defined(__WIIU__) - Ship::WiiU::ThrowInvalidOTR(); + LUS::WiiU::ThrowInvalidOTR(); #else SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Invalid OTR File", "Attempted to load an invalid OTR file. Try regenerating.", nullptr); @@ -324,15 +325,15 @@ bool OTRGlobals::HasOriginal() { } uint32_t OTRGlobals::GetInterpolationFPS() { - if (Ship::WindowBackend() == Ship::Backend::DX11) { + if (LUS::WindowBackend() == LUS::Backend::DX11) { return CVarGetInteger("gInterpolationFPS", 20); } if (CVarGetInteger("gMatchRefreshRate", 0)) { - return Ship::Window::GetInstance()->GetCurrentRefreshRate(); + return LUS::Context::GetInstance()->GetWindow()->GetCurrentRefreshRate(); } - return std::min(Ship::Window::GetInstance()->GetCurrentRefreshRate(), CVarGetInteger("gInterpolationFPS", 20)); + return std::min(LUS::Context::GetInstance()->GetWindow()->GetCurrentRefreshRate(), CVarGetInteger("gInterpolationFPS", 20)); } struct ExtensionEntry { @@ -694,7 +695,7 @@ extern "C" uint32_t GetGIID(uint32_t itemID) { } extern "C" void OTRExtScanner() { - auto lst = *OTRGlobals::Instance->context->GetResourceManager()->GetArchive()->ListFiles("*").get(); + auto lst = *LUS::Context::GetInstance()->GetResourceManager()->GetArchive()->ListFiles("*").get(); for (auto& rPath : lst) { std::vector raw = StringHelper::Split(rPath, "."); @@ -708,8 +709,9 @@ extern "C" void OTRExtScanner() { extern "C" void InitOTR() { #if not defined (__SWITCH__) && not defined(__WIIU__) - if (!std::filesystem::exists(Ship::Window::GetPathRelativeToAppDirectory("oot-mq.otr")) && - !std::filesystem::exists(Ship::Window::GetPathRelativeToAppDirectory("oot.otr"))){ + if (!std::filesystem::exists(LUS::Context::GetPathRelativeToAppDirectory("oot-mq.otr")) && + !std::filesystem::exists(LUS::Context::GetPathRelativeToAppDirectory("oot.otr"))){ + bool generatedOtrIsMQ = false; if (Extractor::ShowYesNoBox("No OTR Files", "No OTR files found. Generate one now?") == IDYES) { Extractor extract; if (!extract.Run()) { @@ -717,12 +719,13 @@ extern "C" void InitOTR() { exit(1); } extract.CallZapd(); + generatedOtrIsMQ = extract.IsMasterQuest(); } else { exit(1); } if (Extractor::ShowYesNoBox("Extraction Complete", "ROM Extracted. Extract another?") == IDYES) { Extractor extract; - if (!extract.Run()) { + if (!extract.Run(generatedOtrIsMQ ? RomSearchMode::Vanilla : RomSearchMode::MQ)) { Extractor::ShowErrorBox("Error", "An error occured, an OTR file may have been generated by a different step. Continuing..."); } else { extract.CallZapd(); @@ -732,12 +735,12 @@ extern "C" void InitOTR() { #endif #ifdef __SWITCH__ - Ship::Switch::Init(Ship::PreInitPhase); + LUS::Switch::Init(LUS::PreInitPhase); #elif defined(__WIIU__) - Ship::WiiU::Init(); + LUS::WiiU::Init(); #endif - Ship::AddSetupHooksDelegate(GameMenuBar::SetupHooks); - Ship::RegisterMenuDrawMethod(GameMenuBar::Draw); + LUS::AddSetupHooksDelegate(GameMenuBar::SetupHooks); + LUS::RegisterMenuDrawMethod(GameMenuBar::Draw); OTRGlobals::Instance = new OTRGlobals(); SaveManager::Instance = new SaveManager(); @@ -791,9 +794,6 @@ extern "C" void InitOTR() { extern "C" void DeinitOTR() { OTRAudio_Exit(); -#if defined(_WIN32) || defined(__APPLE__) - SpeechSynthesizerUninitialize(); -#endif #ifdef ENABLE_CROWD_CONTROL CrowdControl::Instance->Disable(); CrowdControl::Instance->Shutdown(); @@ -833,16 +833,16 @@ extern "C" uint64_t GetPerfCounter() { // C->C++ Bridge extern "C" void Graph_ProcessFrame(void (*run_one_game_iter)(void)) { - OTRGlobals::Instance->context->MainLoop(run_one_game_iter); + OTRGlobals::Instance->context->GetWindow()->MainLoop(run_one_game_iter); } extern bool ShouldClearTextureCacheAtEndOfFrame; extern "C" void Graph_StartFrame() { #ifndef __WIIU__ - using Ship::KbScancode; - int32_t dwScancode = OTRGlobals::Instance->context->GetLastScancode(); - OTRGlobals::Instance->context->SetLastScancode(-1); + using LUS::KbScancode; + int32_t dwScancode = OTRGlobals::Instance->context->GetWindow()->GetLastScancode(); + OTRGlobals::Instance->context->GetWindow()->SetLastScancode(-1); switch (dwScancode) { case KbScancode::LUS_KB_F5: { @@ -911,7 +911,7 @@ extern "C" void Graph_StartFrame() { } } #endif - OTRGlobals::Instance->context->StartFrame(); + OTRGlobals::Instance->context->GetWindow()->StartFrame(); } void RunCommands(Gfx* Commands, const std::vector>& mtx_replacements) { @@ -959,10 +959,10 @@ extern "C" void Graph_ProcessGfxCommands(Gfx* commands) { time -= fps; - OTRGlobals::Instance->context->SetTargetFps(fps); + OTRGlobals::Instance->context->GetWindow()->SetTargetFps(fps); int threshold = CVarGetInteger("gExtraLatencyThreshold", 80); - OTRGlobals::Instance->context->SetMaximumFrameLatency(threshold > 0 && target_fps >= threshold ? 2 : 1); + OTRGlobals::Instance->context->GetWindow()->SetMaximumFrameLatency(threshold > 0 && target_fps >= threshold ? 2 : 1); RunCommands(commands, mtx_replacements); @@ -978,7 +978,7 @@ extern "C" void Graph_ProcessGfxCommands(Gfx* commands) { if (ShouldClearTextureCacheAtEndOfFrame) { gfx_texture_cache_clear(); - Ship::SkeletonPatcher::UpdateSkeletons(); + LUS::SkeletonPatcher::UpdateSkeletons(); ShouldClearTextureCacheAtEndOfFrame = false; } @@ -991,19 +991,19 @@ extern "C" void Graph_ProcessGfxCommands(Gfx* commands) { float divisor_num = 0.0f; extern "C" void OTRGetPixelDepthPrepare(float x, float y) { - OTRGlobals::Instance->context->GetPixelDepthPrepare(x, y); + OTRGlobals::Instance->context->GetWindow()->GetPixelDepthPrepare(x, y); } extern "C" uint16_t OTRGetPixelDepth(float x, float y) { - return OTRGlobals::Instance->context->GetPixelDepth(x, y); + return OTRGlobals::Instance->context->GetWindow()->GetPixelDepth(x, y); } extern "C" uint32_t ResourceMgr_GetNumGameVersions() { - return OTRGlobals::Instance->context->GetResourceManager()->GetArchive()->GetGameVersions().size(); + return LUS::Context::GetInstance()->GetResourceManager()->GetArchive()->GetGameVersions().size(); } extern "C" uint32_t ResourceMgr_GetGameVersion(int index) { - return OTRGlobals::Instance->context->GetResourceManager()->GetArchive()->GetGameVersions()[index]; + return LUS::Context::GetInstance()->GetResourceManager()->GetArchive()->GetGameVersions()[index]; } uint32_t IsSceneMasterQuest(s16 sceneNum) { @@ -1048,16 +1048,16 @@ extern "C" uint32_t ResourceMgr_IsGameMasterQuest() { } extern "C" void ResourceMgr_LoadDirectory(const char* resName) { - OTRGlobals::Instance->context->GetResourceManager()->LoadDirectory(resName); + LUS::Context::GetInstance()->GetResourceManager()->LoadDirectory(resName); } extern "C" void ResourceMgr_DirtyDirectory(const char* resName) { - OTRGlobals::Instance->context->GetResourceManager()->DirtyDirectory(resName); + LUS::Context::GetInstance()->GetResourceManager()->DirtyDirectory(resName); } // OTRTODO: There is probably a more elegant way to go about this... // Kenix: This is definitely leaking memory when it's called. extern "C" char** ResourceMgr_ListFiles(const char* searchMask, int* resultSize) { - auto lst = OTRGlobals::Instance->context->GetResourceManager()->GetArchive()->ListFiles(searchMask); + auto lst = LUS::Context::GetInstance()->GetResourceManager()->GetArchive()->ListFiles(searchMask); char** result = (char**)malloc(lst->size() * sizeof(char*)); for (size_t i = 0; i < lst->size(); i++) { @@ -1081,10 +1081,10 @@ extern "C" uint8_t ResourceMgr_FileExists(const char* filePath) { } extern "C" void ResourceMgr_LoadFile(const char* resName) { - OTRGlobals::Instance->context->GetResourceManager()->LoadResource(resName); + LUS::Context::GetInstance()->GetResourceManager()->LoadResource(resName); } -std::shared_ptr GetResourceByNameHandlingMQ(const char* path) { +std::shared_ptr GetResourceByNameHandlingMQ(const char* path) { std::string Path = path; if (ResourceMgr_IsGameMasterQuest()) { size_t pos = 0; @@ -1092,7 +1092,7 @@ std::shared_ptr GetResourceByNameHandlingMQ(const char* path) { Path.replace(pos, 7, "/mq/"); } } - return OTRGlobals::Instance->context->GetResourceManager()->LoadResource(Path.c_str()); + return LUS::Context::GetInstance()->GetResourceManager()->LoadResource(Path.c_str()); } extern "C" char* GetResourceDataByNameHandlingMQ(const char* path) { @@ -1121,7 +1121,7 @@ extern "C" char* ResourceMgr_LoadFileFromDisk(const char* filePath) { extern "C" uint8_t ResourceMgr_ResourceIsBackground(char* texPath) { auto res = GetResourceByNameHandlingMQ(texPath); - return res->InitData->Type == Ship::ResourceType::SOH_Background; + return res->InitData->Type == LUS::ResourceType::SOH_Background; } extern "C" char* ResourceMgr_LoadJPEG(char* data, size_t dataSize) @@ -1169,10 +1169,10 @@ extern "C" uint16_t ResourceMgr_LoadTexHeightByName(char* texPath); extern "C" char* ResourceMgr_LoadTexOrDListByName(const char* filePath) { auto res = GetResourceByNameHandlingMQ(filePath); - if (res->InitData->Type == Ship::ResourceType::DisplayList) - return (char*)&((std::static_pointer_cast(res))->Instructions[0]); - else if (res->InitData->Type == Ship::ResourceType::Array) - return (char*)(std::static_pointer_cast(res))->Vertices.data(); + if (res->InitData->Type == LUS::ResourceType::DisplayList) + return (char*)&((std::static_pointer_cast(res))->Instructions[0]); + else if (res->InitData->Type == LUS::ResourceType::Array) + return (char*)(std::static_pointer_cast(res))->Vertices.data(); else { return (char*)GetResourceDataByNameHandlingMQ(filePath); } @@ -1181,8 +1181,8 @@ extern "C" char* ResourceMgr_LoadTexOrDListByName(const char* filePath) { extern "C" char* ResourceMgr_LoadIfDListByName(const char* filePath) { auto res = GetResourceByNameHandlingMQ(filePath); - if (res->InitData->Type == Ship::ResourceType::DisplayList) - return (char*)&((std::static_pointer_cast(res))->Instructions[0]); + if (res->InitData->Type == LUS::ResourceType::DisplayList) + return (char*)&((std::static_pointer_cast(res))->Instructions[0]); return nullptr; } @@ -1192,7 +1192,7 @@ extern "C" Sprite* GetSeedTexture(uint8_t index) { } extern "C" char* ResourceMgr_LoadPlayerAnimByName(const char* animPath) { - auto anim = std::static_pointer_cast(GetResourceByNameHandlingMQ(animPath)); + auto anim = std::static_pointer_cast(GetResourceByNameHandlingMQ(animPath)); return (char*)&anim->limbRotData[0]; } @@ -1204,7 +1204,7 @@ extern "C" void ResourceMgr_PushCurrentDirectory(char* path) extern "C" Gfx* ResourceMgr_LoadGfxByName(const char* path) { - auto res = std::static_pointer_cast(GetResourceByNameHandlingMQ(path)); + auto res = std::static_pointer_cast(GetResourceByNameHandlingMQ(path)); return (Gfx*)&res->Instructions[0]; } @@ -1218,8 +1218,8 @@ std::unordered_map> origi // Attention! This is primarily for cosmetics & bug fixes. For things like mods and model replacement you should be using OTRs // instead (When that is available). Index can be found using the commented out section below. extern "C" void ResourceMgr_PatchGfxByName(const char* path, const char* patchName, int index, Gfx instruction) { - auto res = std::static_pointer_cast( - OTRGlobals::Instance->context->GetResourceManager()->LoadResource(path)); + auto res = std::static_pointer_cast( + LUS::Context::GetInstance()->GetResourceManager()->LoadResource(path)); // Leaving this here for people attempting to find the correct Dlist index to patch /*if (strcmp("__OTR__objects/object_gi_longsword/gGiBiggoronSwordDL", path) == 0) { @@ -1253,8 +1253,8 @@ extern "C" void ResourceMgr_PatchGfxByName(const char* path, const char* patchNa extern "C" void ResourceMgr_UnpatchGfxByName(const char* path, const char* patchName) { if (originalGfx.contains(path) && originalGfx[path].contains(patchName)) { - auto res = std::static_pointer_cast( - OTRGlobals::Instance->context->GetResourceManager()->LoadResource(path)); + auto res = std::static_pointer_cast( + LUS::Context::GetInstance()->GetResourceManager()->LoadResource(path)); Gfx* gfx = (Gfx*)&res->Instructions[originalGfx[path][patchName].index]; *gfx = originalGfx[path][patchName].instruction; @@ -1265,13 +1265,13 @@ extern "C" void ResourceMgr_UnpatchGfxByName(const char* path, const char* patch extern "C" char* ResourceMgr_LoadArrayByName(const char* path) { - auto res = std::static_pointer_cast(GetResourceByNameHandlingMQ(path)); + auto res = std::static_pointer_cast(GetResourceByNameHandlingMQ(path)); return (char*)res->Scalars.data(); } extern "C" char* ResourceMgr_LoadArrayByNameAsVec3s(const char* path) { - auto res = std::static_pointer_cast(GetResourceByNameHandlingMQ(path)); + auto res = std::static_pointer_cast(GetResourceByNameHandlingMQ(path)); // if (res->CachedGameAsset != nullptr) // return (char*)res->CachedGameAsset; @@ -1292,15 +1292,15 @@ extern "C" char* ResourceMgr_LoadArrayByNameAsVec3s(const char* path) { } extern "C" CollisionHeader* ResourceMgr_LoadColByName(const char* path) { - return (CollisionHeader*)GetResourceDataByName(path, false); + return (CollisionHeader*) GetResourceDataByName(path); } extern "C" Vtx* ResourceMgr_LoadVtxByName(char* path) { - return (Vtx*)GetResourceDataByName(path, false); + return (Vtx*) GetResourceDataByName(path); } extern "C" SequenceData ResourceMgr_LoadSeqByName(const char* path) { - SequenceData* sequence = (SequenceData*)GetResourceDataByName(path, false); + SequenceData* sequence = (SequenceData*) GetResourceDataByName(path); return *sequence; } @@ -1314,7 +1314,7 @@ extern "C" SoundFontSample* ReadCustomSample(const char* path) { ExtensionEntry entry = ExtensionCache[path]; - auto sampleRaw = OTRGlobals::Instance->context->GetResourceManager()->LoadFile(entry.path); + auto sampleRaw = LUS::Context::GetInstance()->GetResourceManager()->LoadFile(entry.path); uint32_t* strem = (uint32_t*)sampleRaw->Buffer.get(); uint8_t* strem2 = (uint8_t*)strem; @@ -1365,11 +1365,11 @@ extern "C" SoundFontSample* ReadCustomSample(const char* path) { } extern "C" SoundFontSample* ResourceMgr_LoadAudioSample(const char* path) { - return (SoundFontSample*)GetResourceDataByName(path, false); + return (SoundFontSample*) GetResourceDataByName(path); } extern "C" SoundFont* ResourceMgr_LoadAudioSoundFont(const char* path) { - return (SoundFont*)GetResourceDataByName(path, false); + return (SoundFont*) GetResourceDataByName(path); } extern "C" int ResourceMgr_OTRSigCheck(char* imgData) @@ -1391,7 +1391,7 @@ extern "C" int ResourceMgr_OTRSigCheck(char* imgData) } extern "C" AnimationHeaderCommon* ResourceMgr_LoadAnimByName(const char* path) { - return (AnimationHeaderCommon*)GetResourceDataByName(path, false); + return (AnimationHeaderCommon*) GetResourceDataByName(path); } extern "C" SkeletonHeader* ResourceMgr_LoadSkeletonByName(const char* path, SkelAnime* skelAnime) { @@ -1405,21 +1405,21 @@ extern "C" SkeletonHeader* ResourceMgr_LoadSkeletonByName(const char* path, Skel bool isAlt = CVarGetInteger("gAltAssets", 0); if (isAlt) { - pathStr = Ship::Resource::gAltAssetPrefix + pathStr; + pathStr = LUS::Resource::gAltAssetPrefix + pathStr; } - SkeletonHeader* skelHeader = (SkeletonHeader*)GetResourceDataByName(pathStr.c_str(), false); + SkeletonHeader* skelHeader = (SkeletonHeader*) GetResourceDataByName(pathStr.c_str()); // If there isn't an alternate model, load the regular one if (isAlt && skelHeader == NULL) { - skelHeader = (SkeletonHeader*)GetResourceDataByName(path, false); + skelHeader = (SkeletonHeader*) GetResourceDataByName(path); } // This function is only called when a skeleton is initialized. // Therefore we can take this oppurtunity to take note of the Skeleton that is created... if (skelAnime != nullptr) { auto stringPath = std::string(path); - Ship::SkeletonPatcher::RegisterSkeleton(stringPath, skelAnime); + LUS::SkeletonPatcher::RegisterSkeleton(stringPath, skelAnime); } return skelHeader; @@ -1427,12 +1427,12 @@ extern "C" SkeletonHeader* ResourceMgr_LoadSkeletonByName(const char* path, Skel extern "C" void ResourceMgr_UnregisterSkeleton(SkelAnime* skelAnime) { if (skelAnime != nullptr) - Ship::SkeletonPatcher::UnregisterSkeleton(skelAnime); + LUS::SkeletonPatcher::UnregisterSkeleton(skelAnime); } extern "C" void ResourceMgr_ClearSkeletons(SkelAnime* skelAnime) { if (skelAnime != nullptr) - Ship::SkeletonPatcher::ClearSkeletons(); + LUS::SkeletonPatcher::ClearSkeletons(); } extern "C" s32* ResourceMgr_LoadCSByName(const char* path) { @@ -1440,7 +1440,7 @@ extern "C" s32* ResourceMgr_LoadCSByName(const char* path) { } std::filesystem::path GetSaveFile(std::shared_ptr Conf) { - const std::string fileName = Conf->getString("Game.SaveName", Ship::Window::GetPathRelativeToAppDirectory("oot_save.sav")); + const std::string fileName = Conf->getString("Game.SaveName", LUS::Context::GetPathRelativeToAppDirectory("oot_save.sav")); std::filesystem::path saveFile = std::filesystem::absolute(fileName); if (!exists(saveFile.parent_path())) { @@ -1571,30 +1571,30 @@ extern "C" void OTRGfxPrint(const char* str, void* printer, void (*printImpl)(vo } extern "C" uint32_t OTRGetCurrentWidth() { - return OTRGlobals::Instance->context->GetCurrentWidth(); + return OTRGlobals::Instance->context->GetWindow()->GetCurrentWidth(); } extern "C" uint32_t OTRGetCurrentHeight() { - return OTRGlobals::Instance->context->GetCurrentHeight(); + return OTRGlobals::Instance->context->GetWindow()->GetCurrentHeight(); } extern "C" void OTRControllerCallback(uint8_t rumble, uint8_t ledColor) { - auto controlDeck = Ship::Window::GetInstance()->GetControlDeck(); + auto controlDeck = LUS::Context::GetInstance()->GetControlDeck(); for (int i = 0; i < controlDeck->GetNumConnectedPorts(); ++i) { auto physicalDevice = controlDeck->GetDeviceFromPortIndex(i); switch (ledColor) { case 0: - physicalDevice->SetLed(i, 255, 0, 0); + physicalDevice->SetLedColor(i, {255, 0, 0}); break; case 1: - physicalDevice->SetLed(i, 0x1E, 0x69, 0x1B); + physicalDevice->SetLedColor(i, {0x1E, 0x69, 0x1B}); break; case 2: - physicalDevice->SetLed(i, 0x64, 0x14, 0x00); + physicalDevice->SetLedColor(i, {0x64, 0x14, 0x00}); break; case 3: - physicalDevice->SetLed(i, 0x00, 0x3C, 0x64); + physicalDevice->SetLedColor(i, {0x00, 0x3C, 0x64}); break; } @@ -1642,7 +1642,7 @@ extern "C" void AudioPlayer_Play(const uint8_t* buf, uint32_t len) { } extern "C" int Controller_ShouldRumble(size_t slot) { - auto controlDeck = Ship::Window::GetInstance()->GetControlDeck(); + auto controlDeck = LUS::Context::GetInstance()->GetControlDeck(); if (slot < controlDeck->GetNumConnectedPorts()) { auto physicalDevice = controlDeck->GetDeviceFromPortIndex(slot); @@ -1656,19 +1656,19 @@ extern "C" int Controller_ShouldRumble(size_t slot) { } extern "C" void Controller_BlockGameInput() { - auto controlDeck = Ship::Window::GetInstance()->GetControlDeck(); + auto controlDeck = LUS::Context::GetInstance()->GetControlDeck(); controlDeck->BlockGameInput(); } extern "C" void Controller_UnblockGameInput() { - auto controlDeck = Ship::Window::GetInstance()->GetControlDeck(); + auto controlDeck = LUS::Context::GetInstance()->GetControlDeck(); controlDeck->UnblockGameInput(); } extern "C" void Hooks_ExecuteAudioInit() { - Ship::ExecuteHooks(); + LUS::ExecuteHooks(); } extern "C" void* getN64WeirdFrame(s32 i) { @@ -1884,7 +1884,7 @@ extern "C" int CustomMessage_RetrieveIfExists(PlayState* play) { RandomizerInf randoInf = (RandomizerInf)((textId - (TEXT_SHOP_ITEM_RANDOM + NUM_SHOP_ITEMS)) + RAND_INF_SHOP_ITEMS_KF_SHOP_ITEM_1); messageEntry = OTRGlobals::Instance->gRandomizer->GetMerchantMessage(randoInf, TEXT_SHOP_ITEM_RANDOM_CONFIRM); } - } else if (CVarGetInteger("gRandomizeRupeeNames", 0) && + } else if (CVarGetInteger("gRandomizeRupeeNames", 1) && (textId == TEXT_BLUE_RUPEE || textId == TEXT_RED_RUPEE || textId == TEXT_PURPLE_RUPEE || textId == TEXT_HUGE_RUPEE)) { messageEntry = Randomizer::GetRupeeMessage(textId); @@ -1988,12 +1988,12 @@ extern "C" int CustomMessage_RetrieveIfExists(PlayState* play) { } extern "C" void Overlay_DisplayText(float duration, const char* text) { - Ship::GetGameOverlay()->TextDrawNotification(duration, true, text); + LUS::GetGameOverlay()->TextDrawNotification(duration, true, text); } extern "C" void Overlay_DisplayText_Seconds(int seconds, const char* text) { float duration = seconds * OTRGlobals::Instance->GetInterpolationFPS() * 0.05; - Ship::GetGameOverlay()->TextDrawNotification(duration, true, text); + LUS::GetGameOverlay()->TextDrawNotification(duration, true, text); } extern "C" void Entrance_ClearEntranceTrackingData(void) { diff --git a/soh/soh/OTRGlobals.h b/soh/soh/OTRGlobals.h index 2ce6d3f48..e1d448af8 100644 --- a/soh/soh/OTRGlobals.h +++ b/soh/soh/OTRGlobals.h @@ -19,7 +19,7 @@ class OTRGlobals public: static OTRGlobals* Instance; - std::shared_ptr context; + std::shared_ptr context; std::shared_ptr gSaveStateMgr; std::shared_ptr gRandomizer; diff --git a/soh/soh/SaveManager.cpp b/soh/soh/SaveManager.cpp index 82364fd08..6d928bbbd 100644 --- a/soh/soh/SaveManager.cpp +++ b/soh/soh/SaveManager.cpp @@ -7,7 +7,7 @@ #include "macros.h" #include #include -#include +#include #define NOGDI // avoid various windows defines that conflict with things in z64.h #include @@ -41,7 +41,7 @@ void SaveManager::ReadSaveFile(std::filesystem::path savePath, uintptr_t addr, v } std::filesystem::path SaveManager::GetFileName(int fileNum) { - const std::filesystem::path sSavePath(Ship::Window::GetPathRelativeToAppDirectory("Save")); + const std::filesystem::path sSavePath(LUS::Context::GetPathRelativeToAppDirectory("Save")); return sSavePath / ("file" + std::to_string(fileNum + 1) + ".sav"); } @@ -356,11 +356,11 @@ void SaveManager::SaveRandomizer(SaveContext* saveContext) { } void SaveManager::Init() { - const std::filesystem::path sSavePath(Ship::Window::GetPathRelativeToAppDirectory("Save")); + const std::filesystem::path sSavePath(LUS::Context::GetPathRelativeToAppDirectory("Save")); const std::filesystem::path sGlobalPath = sSavePath / std::string("global.sav"); - auto sOldSavePath = Ship::Window::GetPathRelativeToAppDirectory("oot_save.sav"); - auto sOldBackupSavePath = Ship::Window::GetPathRelativeToAppDirectory("oot_save.bak"); - Ship::RegisterHook([this]() { ThreadPoolWait(); }); + auto sOldSavePath = LUS::Context::GetPathRelativeToAppDirectory("oot_save.sav"); + auto sOldBackupSavePath = LUS::Context::GetPathRelativeToAppDirectory("oot_save.bak"); + LUS::RegisterHook([this]() { ThreadPoolWait(); }); GameInteractor::Instance->RegisterGameHook([this](uint32_t fileNum) { ThreadPoolWait(); }); // If the save directory does not exist, create it @@ -785,7 +785,7 @@ void SaveManager::SaveFile(int fileNum) { // Can't think of any time the promise would be needed, so use push_task instead of submit auto saveContext = new SaveContext; memcpy(saveContext, &gSaveContext, sizeof(gSaveContext)); - smThreadPool->push_task(&SaveManager::SaveFileThreaded, this, fileNum, saveContext); + smThreadPool->push_task_back(&SaveManager::SaveFileThreaded, this, fileNum, saveContext); } void SaveManager::SaveGlobal() { @@ -795,7 +795,7 @@ void SaveManager::SaveGlobal() { globalBlock["zTargetSetting"] = gSaveContext.zTargetSetting; globalBlock["language"] = gSaveContext.language; - const std::filesystem::path sSavePath(Ship::Window::GetPathRelativeToAppDirectory("Save")); + const std::filesystem::path sSavePath(LUS::Context::GetPathRelativeToAppDirectory("Save")); const std::filesystem::path sGlobalPath = sSavePath / std::string("global.sav"); std::ofstream output(sGlobalPath); @@ -2189,7 +2189,7 @@ extern "C" void Save_SaveGlobal(void) { extern "C" void Save_LoadFile(void) { SaveManager::Instance->LoadFile(gSaveContext.fileNum); - Ship::ExecuteHooks(gSaveContext.fileNum); + LUS::ExecuteHooks(gSaveContext.fileNum); } extern "C" void Save_AddLoadFunction(char* name, int version, SaveManager::LoadFunc func) { @@ -2210,7 +2210,7 @@ extern "C" void Save_CopyFile(int from, int to) { extern "C" void Save_DeleteFile(int fileNum) { SaveManager::Instance->DeleteZeldaFile(fileNum); - Ship::ExecuteHooks(fileNum); + LUS::ExecuteHooks(fileNum); } extern "C" u32 Save_Exist(int fileNum) { diff --git a/soh/soh/UIWidgets.cpp b/soh/soh/UIWidgets.cpp index 34a8febbe..30a6f6837 100644 --- a/soh/soh/UIWidgets.cpp +++ b/soh/soh/UIWidgets.cpp @@ -206,7 +206,7 @@ namespace UIWidgets { bool val = (bool)CVarGetInteger(cvarName, defaultValue); if (CustomCheckbox(text, &val, disabled, disabledGraphic)) { CVarSetInteger(cvarName, val); - Ship::RequestCvarSaveOnNextTick(); + LUS::RequestCvarSaveOnNextTick(); changed = true; } @@ -246,7 +246,7 @@ namespace UIWidgets { CVarSetInteger(cvarName, i); selected = i; changed = true; - Ship::RequestCvarSaveOnNextTick(); + LUS::RequestCvarSaveOnNextTick(); } } } @@ -259,7 +259,7 @@ namespace UIWidgets { if (disabledValue >= 0 && selected != disabledValue) { CVarSetInteger(cvarName, disabledValue); changed = true; - Ship::RequestCvarSaveOnNextTick(); + LUS::RequestCvarSaveOnNextTick(); } } @@ -348,7 +348,7 @@ namespace UIWidgets { if (changed) { CVarSetInteger(cvarName, val); - Ship::RequestCvarSaveOnNextTick(); + LUS::RequestCvarSaveOnNextTick(); } return changed; @@ -424,7 +424,7 @@ namespace UIWidgets { if (changed) { CVarSetFloat(cvarName, val); - Ship::RequestCvarSaveOnNextTick(); + LUS::RequestCvarSaveOnNextTick(); } return changed; @@ -471,7 +471,7 @@ namespace UIWidgets { int val = CVarGetInteger(cvarName, 0); if (ImGui::RadioButton(make_invisible.c_str(), id == val)) { CVarSetInteger(cvarName, id); - Ship::RequestCvarSaveOnNextTick(); + LUS::RequestCvarSaveOnNextTick(); ret = true; } ImGui::SameLine(); @@ -498,7 +498,7 @@ namespace UIWidgets { CVarSetColor(cvarName, colorsRGBA); CVarSetInteger(Cvar_RBM.c_str(), 0); //On click disable rainbow mode. - Ship::RequestCvarSaveOnNextTick(); + LUS::RequestCvarSaveOnNextTick(); changed = true; } Tooltip("Revert colors to the game's original colors (GameCube version)\nOverwrites previously chosen color"); @@ -523,7 +523,7 @@ namespace UIWidgets { NewColors.b = fmin(fmax(colors->z * 255, 0), 255); CVarSetColor(cvarName, NewColors); CVarSetInteger(Cvar_RBM.c_str(), 0); // On click disable rainbow mode. - Ship::RequestCvarSaveOnNextTick(); + LUS::RequestCvarSaveOnNextTick(); changed = true; } Tooltip("Chooses a random color\nOverwrites previously chosen color"); @@ -584,7 +584,7 @@ namespace UIWidgets { colors.a = 255.0; CVarSetColor(cvarName, colors); - Ship::RequestCvarSaveOnNextTick(); + LUS::RequestCvarSaveOnNextTick(); changed = true; } } @@ -600,7 +600,7 @@ namespace UIWidgets { colors.a = ColorRGBA.w * 255.0; CVarSetColor(cvarName, colors); - Ship::RequestCvarSaveOnNextTick(); + LUS::RequestCvarSaveOnNextTick(); changed = true; } } diff --git a/soh/soh/mq_asset_hacks.h b/soh/soh/mq_asset_hacks.h new file mode 100644 index 000000000..dacf8a54e --- /dev/null +++ b/soh/soh/mq_asset_hacks.h @@ -0,0 +1,195 @@ +#ifndef MQ_ASSET_HACKS_H +#define MQ_ASSET_HACKS_H + +#include "align_asset_macro.h" + +#define dgYdanTex_00BA18_MQ "__OTR__scenes/mq/ydan_scene/gYdanTex_00BA18" +static const ALIGN_ASSET(2) char gYdanTex_00BA18_MQ[] = dgYdanTex_00BA18_MQ; + +#define dgYdanTex_00CA18_MQ "__OTR__scenes/mq/ydan_scene/gYdanTex_00CA18" +static const ALIGN_ASSET(2) char gYdanTex_00CA18_MQ[] = dgYdanTex_00CA18_MQ; +void* D_8012A2F8_MQ[] = { + gYdanTex_00BA18_MQ, + gYdanTex_00CA18_MQ, +}; + +#define dgGoronCityNightEntranceTex_MQ "__OTR__scenes/mq/spot18_scene/gGoronCityNightEntranceTex" +static const ALIGN_ASSET(2) char gGoronCityNightEntranceTex_MQ[] = dgGoronCityNightEntranceTex_MQ; + +#define dgGoronCityDayEntranceTex_MQ "__OTR__scenes/mq/spot18_scene/gGoronCityDayEntranceTex" +static const ALIGN_ASSET(2) char gGoronCityDayEntranceTex_MQ[] = dgGoronCityDayEntranceTex_MQ; +void* sGoronCityEntranceTextures_MQ[] = { + gGoronCityDayEntranceTex_MQ, + gGoronCityNightEntranceTex_MQ, +}; + +#define dgLonLonRanchDayWindowTex_MQ "__OTR__scenes/mq/spot20_scene/gLonLonRanchDayWindowTex" +static const ALIGN_ASSET(2) char gLonLonRanchDayWindowTex_MQ[] = dgLonLonRanchDayWindowTex_MQ; + +#define dgLonLonRangeNightWindowsTex_MQ "__OTR__scenes/mq/spot20_scene/gLonLonRangeNightWindowsTex" +static const ALIGN_ASSET(2) char gLonLonRangeNightWindowsTex_MQ[] = dgLonLonRangeNightWindowsTex_MQ; +void* sLonLonRanchWindowTextures_MQ[] = { + gLonLonRanchDayWindowTex_MQ, + gLonLonRangeNightWindowsTex_MQ, +}; + +// walls of GF room where they throw you when you get caught +#define dgSpot12_009678Tex_MQ "__OTR__scenes/mq/spot12_scene/gSpot12_009678Tex" +static const ALIGN_ASSET(2) char gSpot12_009678Tex_MQ[] = dgSpot12_009678Tex_MQ; + +#define dgSpot12_00DE78Tex_MQ "__OTR__scenes/mq/spot12_scene/gSpot12_00DE78Tex" +static const ALIGN_ASSET(2) char gSpot12_00DE78Tex_MQ[] = dgSpot12_00DE78Tex_MQ; +void* D_8012A380_MQ[] = { + gSpot12_009678Tex_MQ, + gSpot12_00DE78Tex_MQ, +}; + +#define dgZorasDomainDayEntranceTex_MQ "__OTR__scenes/mq/spot07_scene/gZorasDomainDayEntranceTex" +static const ALIGN_ASSET(2) char gZorasDomainDayEntranceTex_MQ[] = dgZorasDomainDayEntranceTex_MQ; + +#define dgZorasDomainNightEntranceTex_MQ "__OTR__scenes/mq/spot07_scene/gZorasDomainNightEntranceTex" +static const ALIGN_ASSET(2) char gZorasDomainNightEntranceTex_MQ[] = dgZorasDomainNightEntranceTex_MQ; +void* sZorasDomainEntranceTextures_MQ[] = { + gZorasDomainDayEntranceTex_MQ, + gZorasDomainNightEntranceTex_MQ, +}; + +#define dgKakarikoVillageDayWindowTex_MQ "__OTR__scenes/mq/spot01_scene/gKakarikoVillageDayWindowTex" +static const ALIGN_ASSET(2) char gKakarikoVillageDayWindowTex_MQ[] = dgKakarikoVillageDayWindowTex_MQ; + +#define dgKakarikoVillageNightWindowTex_MQ "__OTR__scenes/mq/spot01_scene/gKakarikoVillageNightWindowTex" +static const ALIGN_ASSET(2) char gKakarikoVillageNightWindowTex_MQ[] = dgKakarikoVillageNightWindowTex_MQ; +void* sKakarikoWindowTextures_MQ[] = { + gKakarikoVillageDayWindowTex_MQ, + gKakarikoVillageNightWindowTex_MQ, +}; + +#define dgGuardHouseOutSideView2NightTex_MQ "__OTR__scenes/mq/miharigoya_scene/gGuardHouseOutSideView2NightTex" +static const ALIGN_ASSET(2) char gGuardHouseOutSideView2NightTex_MQ[] = dgGuardHouseOutSideView2NightTex_MQ; + +#define dgGuardHouseOutSideView2DayTex_MQ "__OTR__scenes/mq/miharigoya_scene/gGuardHouseOutSideView2DayTex" +static const ALIGN_ASSET(2) char gGuardHouseOutSideView2DayTex_MQ[] = dgGuardHouseOutSideView2DayTex_MQ; + +#define dgGuardHouseOutSideView1NightTex_MQ "__OTR__scenes/mq/miharigoya_scene/gGuardHouseOutSideView1NightTex" +static const ALIGN_ASSET(2) char gGuardHouseOutSideView1NightTex_MQ[] = dgGuardHouseOutSideView1NightTex_MQ; + +#define dgGuardHouseOutSideView1DayTex_MQ "__OTR__scenes/mq/miharigoya_scene/gGuardHouseOutSideView1DayTex" +static const ALIGN_ASSET(2) char gGuardHouseOutSideView1DayTex_MQ[] = dgGuardHouseOutSideView1DayTex_MQ; +void* sGuardHouseView2Textures_MQ[] = { + gGuardHouseOutSideView1DayTex_MQ, + gGuardHouseOutSideView1NightTex_MQ, +}; +void* sGuardHouseView1Textures_MQ[] = { + gGuardHouseOutSideView2DayTex_MQ, + gGuardHouseOutSideView2NightTex_MQ, +}; + +#define dgLonLonHouseDayEntranceTex_MQ "__OTR__scenes/mq/souko_scene/gLonLonHouseDayEntranceTex" +static const ALIGN_ASSET(2) char gLonLonHouseDayEntranceTex_MQ[] = dgLonLonHouseDayEntranceTex_MQ; + +#define dgLonLonHouseNightEntranceTex_MQ "__OTR__scenes/mq/souko_scene/gLonLonHouseNightEntranceTex" +static const ALIGN_ASSET(2) char gLonLonHouseNightEntranceTex_MQ[] = dgLonLonHouseNightEntranceTex_MQ; +void* sLonLonHouseEntranceTextures_MQ[] = { + gLonLonHouseDayEntranceTex_MQ, + gLonLonHouseNightEntranceTex_MQ, +}; + +#define dgThievesHideoutNightEntranceTex_MQ "__OTR__scenes/mq/gerudoway_scene/gThievesHideoutNightEntranceTex" +static const ALIGN_ASSET(2) char gThievesHideoutNightEntranceTex_MQ[] = dgThievesHideoutNightEntranceTex_MQ; + +#define dgThievesHideoutDayEntranceTex_MQ "__OTR__scenes/mq/gerudoway_scene/gThievesHideoutDayEntranceTex" +static const ALIGN_ASSET(2) char gThievesHideoutDayEntranceTex_MQ[] = dgThievesHideoutDayEntranceTex_MQ; +void* sThievesHideoutEntranceTextures_MQ[] = { + gThievesHideoutDayEntranceTex_MQ, + gThievesHideoutNightEntranceTex_MQ, +}; + +#define dgDCDayEntranceTex_MQ "__OTR__scenes/mq/ddan_scene/gDCDayEntranceTex" +static const ALIGN_ASSET(2) char gDCDayEntranceTex_MQ[] = dgDCDayEntranceTex_MQ; + +#define dgDCNightEntranceTex_MQ "__OTR__scenes/mq/ddan_scene/gDCNightEntranceTex" +static const ALIGN_ASSET(2) char gDCNightEntranceTex_MQ[] = dgDCNightEntranceTex_MQ; +void* gDCEntranceTextures_MQ[] = { + gDCDayEntranceTex_MQ, + gDCNightEntranceTex_MQ, +}; + +#define dgDCLavaFloor1Tex_MQ "__OTR__scenes/mq/ddan_scene/gDCLavaFloor1Tex" +static const ALIGN_ASSET(2) char gDCLavaFloor1Tex_MQ[] = dgDCLavaFloor1Tex_MQ; + +#define dgDCLavaFloor2Tex_MQ "__OTR__scenes/mq/ddan_scene/gDCLavaFloor2Tex" +static const ALIGN_ASSET(2) char gDCLavaFloor2Tex_MQ[] = dgDCLavaFloor2Tex_MQ; + +#define dgDCLavaFloor3Tex_MQ "__OTR__scenes/mq/ddan_scene/gDCLavaFloor3Tex" +static const ALIGN_ASSET(2) char gDCLavaFloor3Tex_MQ[] = dgDCLavaFloor3Tex_MQ; + +#define dgDCLavaFloor4Tex_MQ "__OTR__scenes/mq/ddan_scene/gDCLavaFloor4Tex" +static const ALIGN_ASSET(2) char gDCLavaFloor4Tex_MQ[] = dgDCLavaFloor4Tex_MQ; + +#define dgDCLavaFloor5Tex_MQ "__OTR__scenes/mq/ddan_scene/gDCLavaFloor5Tex" +static const ALIGN_ASSET(2) char gDCLavaFloor5Tex_MQ[] = dgDCLavaFloor5Tex_MQ; + +#define dgDCLavaFloor6Tex_MQ "__OTR__scenes/mq/ddan_scene/gDCLavaFloor6Tex" +static const ALIGN_ASSET(2) char gDCLavaFloor6Tex_MQ[] = dgDCLavaFloor6Tex_MQ; + +#define dgDCLavaFloor7Tex_MQ "__OTR__scenes/mq/ddan_scene/gDCLavaFloor7Tex" +static const ALIGN_ASSET(2) char gDCLavaFloor7Tex_MQ[] = dgDCLavaFloor7Tex_MQ; + +#define dgDCLavaFloor8Tex_MQ "__OTR__scenes/mq/ddan_scene/gDCLavaFloor8Tex" +static const ALIGN_ASSET(2) char gDCLavaFloor8Tex_MQ[] = dgDCLavaFloor8Tex_MQ; +void* sDCLavaFloorTextures_MQ[] = { + gDCLavaFloor1Tex_MQ, gDCLavaFloor2Tex_MQ, gDCLavaFloor3Tex_MQ, gDCLavaFloor4Tex_MQ, + gDCLavaFloor5Tex_MQ, gDCLavaFloor6Tex_MQ, gDCLavaFloor7Tex_MQ, gDCLavaFloor8Tex_MQ, +}; + +#define dgWaterTempleDayEntranceTex_MQ "__OTR__scenes/mq/MIZUsin_scene/gWaterTempleDayEntranceTex" +static const ALIGN_ASSET(2) char gWaterTempleDayEntranceTex_MQ[] = dgWaterTempleDayEntranceTex_MQ; + +#define dgWaterTempleNightEntranceTex_MQ "__OTR__scenes/mq/MIZUsin_scene/gWaterTempleNightEntranceTex" +static const ALIGN_ASSET(2) char gWaterTempleNightEntranceTex_MQ[] = dgWaterTempleNightEntranceTex_MQ; +void* D_8012A330_MQ[] = { + gWaterTempleDayEntranceTex_MQ, + gWaterTempleNightEntranceTex_MQ, +}; + +#define dgIceCavernNightEntranceTex_MQ "__OTR__scenes/mq/ice_doukutu_scene/gIceCavernNightEntranceTex" +static const ALIGN_ASSET(2) char gIceCavernNightEntranceTex_MQ[] = dgIceCavernNightEntranceTex_MQ; + +#define dgIceCavernDayEntranceTex_MQ "__OTR__scenes/mq/ice_doukutu_scene/gIceCavernDayEntranceTex" +static const ALIGN_ASSET(2) char gIceCavernDayEntranceTex_MQ[] = dgIceCavernDayEntranceTex_MQ; +void* sIceCavernEntranceTextures_MQ[] = { + gIceCavernDayEntranceTex_MQ, + gIceCavernNightEntranceTex_MQ, +}; + +#define dgGTGDayEntranceTex_MQ "__OTR__scenes/mq/men_scene/gGTGDayEntranceTex" +static const ALIGN_ASSET(2) char gGTGDayEntranceTex_MQ[] = dgGTGDayEntranceTex_MQ; + +#define dgGTGNightEntranceTex_MQ "__OTR__scenes/mq/men_scene/gGTGNightEntranceTex" +static const ALIGN_ASSET(2) char gGTGNightEntranceTex_MQ[] = dgGTGNightEntranceTex_MQ; +void* sGTGEntranceTextures_MQ[] = { + gGTGDayEntranceTex_MQ, + gGTGNightEntranceTex_MQ, +}; + +#define dgForestTempleDayEntranceTex_MQ "__OTR__scenes/mq/Bmori1_scene/gForestTempleDayEntranceTex" +static const ALIGN_ASSET(2) char gForestTempleDayEntranceTex_MQ[] = dgForestTempleDayEntranceTex_MQ; + +#define dgForestTempleNightEntranceTex_MQ "__OTR__scenes/mq/Bmori1_scene/gForestTempleNightEntranceTex" +static const ALIGN_ASSET(2) char gForestTempleNightEntranceTex_MQ[] = dgForestTempleNightEntranceTex_MQ; +void* sForestTempleEntranceTextures_MQ[] = { + gForestTempleDayEntranceTex_MQ, + gForestTempleNightEntranceTex_MQ, +}; + +#define dgSpiritTempleDayEntranceTex_MQ "__OTR__scenes/mq/jyasinzou_scene/gSpiritTempleDayEntranceTex" +static const ALIGN_ASSET(2) char gSpiritTempleDayEntranceTex_MQ[] = dgSpiritTempleDayEntranceTex_MQ; + +#define dgSpiritTempleNightEntranceTex_MQ "__OTR__scenes/mq/jyasinzou_scene/gSpiritTempleNightEntranceTex" +static const ALIGN_ASSET(2) char gSpiritTempleNightEntranceTex_MQ[] = dgSpiritTempleNightEntranceTex_MQ; +void* sSpiritTempleEntranceTextures_MQ[] = { + gSpiritTempleDayEntranceTex_MQ, + gSpiritTempleNightEntranceTex_MQ, +}; + +#endif diff --git a/soh/soh/resource/importer/AnimationFactory.cpp b/soh/soh/resource/importer/AnimationFactory.cpp index 5a6a02f8b..6a7b47799 100644 --- a/soh/soh/resource/importer/AnimationFactory.cpp +++ b/soh/soh/resource/importer/AnimationFactory.cpp @@ -2,7 +2,7 @@ #include "soh/resource/type/Animation.h" #include "spdlog/spdlog.h" -namespace Ship { +namespace LUS { std::shared_ptr AnimationFactory::ReadResource(std::shared_ptr resourceMgr, std::shared_ptr initData, std::shared_ptr reader) { @@ -25,7 +25,7 @@ std::shared_ptr AnimationFactory::ReadResource(std::shared_ptr reader, std::shared_ptr resource) { +void LUS::AnimationFactoryV0::ParseFileBinary(std::shared_ptr reader, std::shared_ptr resource) { std::shared_ptr animation = std::static_pointer_cast(resource); ResourceVersionFactory::ParseFileBinary(reader, animation); @@ -102,4 +102,4 @@ void Ship::AnimationFactoryV0::ParseFileBinary(std::shared_ptr rea SPDLOG_DEBUG("BEYTAH ANIMATION?!"); } } -} // namespace Ship +} // namespace LUS diff --git a/soh/soh/resource/importer/AnimationFactory.h b/soh/soh/resource/importer/AnimationFactory.h index c5883305e..6323e988c 100644 --- a/soh/soh/resource/importer/AnimationFactory.h +++ b/soh/soh/resource/importer/AnimationFactory.h @@ -3,7 +3,7 @@ #include "Resource.h" #include "ResourceFactory.h" -namespace Ship { +namespace LUS { class AnimationFactory : public ResourceFactory { public: std::shared_ptr ReadResource(std::shared_ptr resourceMgr, @@ -15,4 +15,4 @@ class AnimationFactoryV0 : public ResourceVersionFactory { public: void ParseFileBinary(std::shared_ptr reader, std::shared_ptr resource) override; }; -}; // namespace Ship +}; // namespace LUS diff --git a/soh/soh/resource/importer/AudioSampleFactory.cpp b/soh/soh/resource/importer/AudioSampleFactory.cpp index 80b00c21a..a04734f45 100644 --- a/soh/soh/resource/importer/AudioSampleFactory.cpp +++ b/soh/soh/resource/importer/AudioSampleFactory.cpp @@ -2,7 +2,7 @@ #include "soh/resource/type/AudioSample.h" #include "spdlog/spdlog.h" -namespace Ship { +namespace LUS { std::shared_ptr AudioSampleFactory::ReadResource(std::shared_ptr resourceMgr, std::shared_ptr initData, std::shared_ptr reader) { @@ -25,7 +25,7 @@ std::shared_ptr AudioSampleFactory::ReadResource(std::shared_ptr reader, +void LUS::AudioSampleFactoryV0::ParseFileBinary(std::shared_ptr reader, std::shared_ptr resource) { std::shared_ptr audioSample = std::static_pointer_cast(resource); @@ -67,7 +67,7 @@ void Ship::AudioSampleFactoryV0::ParseFileBinary(std::shared_ptr r audioSample->book.book = audioSample->bookData.data(); audioSample->sample.book = &audioSample->book; } -} // namespace Ship +} // namespace LUS /* @@ -90,7 +90,7 @@ extern "C" SoundFontSample* ReadCustomSample(const char* path) { ExtensionEntry entry = ExtensionCache[path]; - auto sampleRaw = OTRGlobals::Instance->context->GetResourceManager()->LoadFile(entry.path); + auto sampleRaw = LUS::Context::GetInstance()->GetResourceManager()->LoadFile(entry.path); uint32_t* strem = (uint32_t*)sampleRaw->Buffer.get(); uint8_t* strem2 = (uint8_t*)strem; diff --git a/soh/soh/resource/importer/AudioSampleFactory.h b/soh/soh/resource/importer/AudioSampleFactory.h index 582bb9baa..79b028860 100644 --- a/soh/soh/resource/importer/AudioSampleFactory.h +++ b/soh/soh/resource/importer/AudioSampleFactory.h @@ -3,7 +3,7 @@ #include "Resource.h" #include "ResourceFactory.h" -namespace Ship { +namespace LUS { class AudioSampleFactory : public ResourceFactory { public: @@ -17,4 +17,4 @@ class AudioSampleFactoryV0 : public ResourceVersionFactory public: void ParseFileBinary(std::shared_ptr reader, std::shared_ptr resource) override; }; -}; // namespace Ship +}; // namespace LUS diff --git a/soh/soh/resource/importer/AudioSequenceFactory.cpp b/soh/soh/resource/importer/AudioSequenceFactory.cpp index 40f9d420f..20cb7fc18 100644 --- a/soh/soh/resource/importer/AudioSequenceFactory.cpp +++ b/soh/soh/resource/importer/AudioSequenceFactory.cpp @@ -2,7 +2,7 @@ #include "soh/resource/type/AudioSequence.h" #include "spdlog/spdlog.h" -namespace Ship { +namespace LUS { std::shared_ptr AudioSequenceFactory::ReadResource(std::shared_ptr resourceMgr, std::shared_ptr initData, std::shared_ptr reader) { @@ -18,7 +18,7 @@ std::shared_ptr AudioSequenceFactory::ReadResource(std::shared_ptrInitData->ResourceVersion); - return nullptr; + return nullptr; } factory->ParseFileBinary(reader, resource); @@ -26,7 +26,7 @@ std::shared_ptr AudioSequenceFactory::ReadResource(std::shared_ptr reader, +void LUS::AudioSequenceFactoryV0::ParseFileBinary(std::shared_ptr reader, std::shared_ptr resource) { std::shared_ptr audioSequence = std::static_pointer_cast(resource); ResourceVersionFactory::ParseFileBinary(reader, audioSequence); @@ -50,4 +50,4 @@ void Ship::AudioSequenceFactoryV0::ParseFileBinary(std::shared_ptr audioSequence->sequence.fonts[i] = reader->ReadUByte(); } } -} // namespace Ship +} // namespace LUS diff --git a/soh/soh/resource/importer/AudioSequenceFactory.h b/soh/soh/resource/importer/AudioSequenceFactory.h index 21d45ef62..402f8788c 100644 --- a/soh/soh/resource/importer/AudioSequenceFactory.h +++ b/soh/soh/resource/importer/AudioSequenceFactory.h @@ -3,7 +3,7 @@ #include "Resource.h" #include "ResourceFactory.h" -namespace Ship { +namespace LUS { class AudioSequenceFactory : public ResourceFactory { public: @@ -17,4 +17,4 @@ class AudioSequenceFactoryV0 : public ResourceVersionFactory public: void ParseFileBinary(std::shared_ptr reader, std::shared_ptr resource) override; }; -}; // namespace Ship +}; // namespace LUS diff --git a/soh/soh/resource/importer/AudioSoundFontFactory.cpp b/soh/soh/resource/importer/AudioSoundFontFactory.cpp index cb5cdcb2d..9dc1d38c5 100644 --- a/soh/soh/resource/importer/AudioSoundFontFactory.cpp +++ b/soh/soh/resource/importer/AudioSoundFontFactory.cpp @@ -1,9 +1,9 @@ #include "soh/resource/importer/AudioSoundFontFactory.h" #include "soh/resource/type/AudioSoundFont.h" #include "spdlog/spdlog.h" -#include "libultraship/bridge.h" +#include "libultraship/libultraship.h" -namespace Ship { +namespace LUS { std::shared_ptr AudioSoundFontFactory::ReadResource(std::shared_ptr resourceMgr, std::shared_ptr initData, std::shared_ptr reader) { @@ -19,7 +19,7 @@ std::shared_ptr AudioSoundFontFactory::ReadResource(std::shared_ptrInitData->ResourceVersion); - return nullptr; + return nullptr; } factory->ParseFileBinary(reader, resource); @@ -27,7 +27,7 @@ std::shared_ptr AudioSoundFontFactory::ReadResource(std::shared_ptr reader, +void LUS::AudioSoundFontFactoryV0::ParseFileBinary(std::shared_ptr reader, std::shared_ptr resource) { std::shared_ptr audioSoundFont = std::static_pointer_cast(resource); ResourceVersionFactory::ParseFileBinary(reader, audioSoundFont); @@ -87,7 +87,8 @@ void Ship::AudioSoundFontFactoryV0::ParseFileBinary(std::shared_ptr(GetResourceDataByName(sampleFileName.c_str(), true)); + auto res = LUS::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(sampleFileName.c_str()); + drum.sound.sample = static_cast(res ? res->GetPointer() : nullptr); } audioSoundFont->drums.push_back(drum); @@ -130,7 +131,8 @@ void Ship::AudioSoundFontFactoryV0::ParseFileBinary(std::shared_ptrReadInt8(); std::string sampleFileName = reader->ReadString(); instrument.lowNotesSound.tuning = reader->ReadFloat(); - instrument.lowNotesSound.sample = static_cast(GetResourceDataByName(sampleFileName.c_str(), true)); + auto res = LUS::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(sampleFileName.c_str()); + instrument.lowNotesSound.sample = static_cast(res ? res->GetPointer() : nullptr); } else { instrument.lowNotesSound.sample = nullptr; instrument.lowNotesSound.tuning = 0; @@ -141,7 +143,8 @@ void Ship::AudioSoundFontFactoryV0::ParseFileBinary(std::shared_ptrReadInt8(); std::string sampleFileName = reader->ReadString(); instrument.normalNotesSound.tuning = reader->ReadFloat(); - instrument.normalNotesSound.sample = static_cast(GetResourceDataByName(sampleFileName.c_str(), true)); + auto res = LUS::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(sampleFileName.c_str()); + instrument.normalNotesSound.sample = static_cast(res ? res->GetPointer() : nullptr); } else { instrument.normalNotesSound.sample = nullptr; instrument.normalNotesSound.tuning = 0; @@ -152,7 +155,8 @@ void Ship::AudioSoundFontFactoryV0::ParseFileBinary(std::shared_ptrReadInt8(); std::string sampleFileName = reader->ReadString(); instrument.highNotesSound.tuning = reader->ReadFloat(); - instrument.highNotesSound.sample = static_cast(GetResourceDataByName(sampleFileName.c_str(), true)); + auto res = LUS::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(sampleFileName.c_str()); + instrument.highNotesSound.sample = static_cast(res ? res->GetPointer() : nullptr); } else { instrument.highNotesSound.sample = nullptr; instrument.highNotesSound.tuning = 0; @@ -176,11 +180,12 @@ void Ship::AudioSoundFontFactoryV0::ParseFileBinary(std::shared_ptrReadInt8(); std::string sampleFileName = reader->ReadString(); soundEffect.tuning = reader->ReadFloat(); - soundEffect.sample = static_cast(GetResourceDataByName(sampleFileName.c_str(), true)); + auto res = LUS::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(sampleFileName.c_str()); + soundEffect.sample = static_cast(res ? res->GetPointer() : nullptr); } audioSoundFont->soundEffects.push_back(soundEffect); } audioSoundFont->soundFont.soundEffects = audioSoundFont->soundEffects.data(); } -} // namespace Ship +} // namespace LUS diff --git a/soh/soh/resource/importer/AudioSoundFontFactory.h b/soh/soh/resource/importer/AudioSoundFontFactory.h index 43b56d0d5..dc142a0e7 100644 --- a/soh/soh/resource/importer/AudioSoundFontFactory.h +++ b/soh/soh/resource/importer/AudioSoundFontFactory.h @@ -3,7 +3,7 @@ #include "Resource.h" #include "ResourceFactory.h" -namespace Ship { +namespace LUS { class AudioSoundFontFactory : public ResourceFactory { public: @@ -17,4 +17,4 @@ class AudioSoundFontFactoryV0 : public ResourceVersionFactory public: void ParseFileBinary(std::shared_ptr reader, std::shared_ptr resource) override; }; -}; // namespace Ship +}; // namespace LUS diff --git a/soh/soh/resource/importer/BackgroundFactory.cpp b/soh/soh/resource/importer/BackgroundFactory.cpp index f57a403c8..4359ef952 100644 --- a/soh/soh/resource/importer/BackgroundFactory.cpp +++ b/soh/soh/resource/importer/BackgroundFactory.cpp @@ -2,7 +2,7 @@ #include "soh/resource/type/Background.h" #include "spdlog/spdlog.h" -namespace Ship { +namespace LUS { std::shared_ptr BackgroundFactory::ReadResource(std::shared_ptr resourceMgr, std::shared_ptr initData, std::shared_ptr reader) { @@ -37,4 +37,4 @@ void BackgroundFactoryV0::ParseFileBinary(std::shared_ptr reader, background->Data.push_back(reader->ReadUByte()); } } -} // namespace Ship +} // namespace LUS diff --git a/soh/soh/resource/importer/BackgroundFactory.h b/soh/soh/resource/importer/BackgroundFactory.h index 445ebe9b4..26ac35ee0 100644 --- a/soh/soh/resource/importer/BackgroundFactory.h +++ b/soh/soh/resource/importer/BackgroundFactory.h @@ -3,7 +3,7 @@ #include "resource/Resource.h" #include "resource/ResourceFactory.h" -namespace Ship { +namespace LUS { class BackgroundFactory : public ResourceFactory { public: std::shared_ptr ReadResource(std::shared_ptr resourceMgr, @@ -15,4 +15,4 @@ class BackgroundFactoryV0 : public ResourceVersionFactory { public: void ParseFileBinary(std::shared_ptr reader, std::shared_ptr resource) override; }; -}; // namespace Ship +}; // namespace LUS diff --git a/soh/soh/resource/importer/CollisionHeaderFactory.cpp b/soh/soh/resource/importer/CollisionHeaderFactory.cpp index e926d339d..afca936bc 100644 --- a/soh/soh/resource/importer/CollisionHeaderFactory.cpp +++ b/soh/soh/resource/importer/CollisionHeaderFactory.cpp @@ -2,7 +2,7 @@ #include "soh/resource/type/CollisionHeader.h" #include "spdlog/spdlog.h" -namespace Ship { +namespace LUS { std::shared_ptr CollisionHeaderFactory::ReadResource(std::shared_ptr resourceMgr, std::shared_ptr initData, std::shared_ptr reader) { @@ -11,13 +11,13 @@ std::shared_ptr CollisionHeaderFactory::ReadResource(std::shared_ptrInitData->ResourceVersion) { case 0: - factory = std::make_shared(); - break; + factory = std::make_shared(); + break; } if (factory == nullptr) { SPDLOG_ERROR("Failed to load Collision Header with version {}", resource->InitData->ResourceVersion); - return nullptr; + return nullptr; } factory->ParseFileBinary(reader, resource); @@ -25,7 +25,7 @@ std::shared_ptr CollisionHeaderFactory::ReadResource(std::shared_ptr reader, +void LUS::CollisionHeaderFactoryV0::ParseFileBinary(std::shared_ptr reader, std::shared_ptr resource) { std::shared_ptr collisionHeader = std::static_pointer_cast(resource); diff --git a/soh/soh/resource/importer/CollisionHeaderFactory.h b/soh/soh/resource/importer/CollisionHeaderFactory.h index 85c4b0f70..65c4aa424 100644 --- a/soh/soh/resource/importer/CollisionHeaderFactory.h +++ b/soh/soh/resource/importer/CollisionHeaderFactory.h @@ -3,7 +3,7 @@ #include "Resource.h" #include "ResourceFactory.h" -namespace Ship { +namespace LUS { class CollisionHeaderFactory : public ResourceFactory { public: std::shared_ptr ReadResource(std::shared_ptr resourceMgr, @@ -15,4 +15,4 @@ class CollisionHeaderFactoryV0 : public ResourceVersionFactory { public: void ParseFileBinary(std::shared_ptr reader, std::shared_ptr resource) override; }; -}; // namespace Ship +}; // namespace LUS diff --git a/soh/soh/resource/importer/CutsceneFactory.cpp b/soh/soh/resource/importer/CutsceneFactory.cpp index 89372d8a5..8dccf821a 100644 --- a/soh/soh/resource/importer/CutsceneFactory.cpp +++ b/soh/soh/resource/importer/CutsceneFactory.cpp @@ -2,7 +2,7 @@ #include "soh/resource/type/Cutscene.h" #include "spdlog/spdlog.h" -namespace Ship { +namespace LUS { std::shared_ptr CutsceneFactory::ReadResource(std::shared_ptr resourceMgr, std::shared_ptr initData, std::shared_ptr reader) { @@ -37,7 +37,7 @@ static inline uint32_t read_CMD_BBH(std::shared_ptr reader) { reader->Read((char*)&v, sizeof(uint32_t)); // swap the half word to match endianness - if (reader->GetEndianness() != Ship::Endianness::Native) { + if (reader->GetEndianness() != LUS::Endianness::Native) { uint8_t* b = (uint8_t*)&v; uint8_t tmp = b[2]; b[2] = b[3]; @@ -52,7 +52,7 @@ static inline uint32_t read_CMD_HBB(std::shared_ptr reader) { reader->Read((char*)&v, sizeof(uint32_t)); // swap the half word to match endianness - if (reader->GetEndianness() != Ship::Endianness::Native) { + if (reader->GetEndianness() != LUS::Endianness::Native) { uint8_t* b = (uint8_t*)&v; uint8_t tmp = b[0]; b[0] = b[1]; @@ -67,7 +67,7 @@ static inline uint32_t read_CMD_HH(std::shared_ptr reader) { reader->Read((char*)&v, sizeof(uint32_t)); // swap the half words to match endianness - if (reader->GetEndianness() != Ship::Endianness::Native) { + if (reader->GetEndianness() != LUS::Endianness::Native) { uint8_t* b = (uint8_t*)&v; uint8_t tmp = b[0]; b[0] = b[1]; @@ -80,7 +80,7 @@ static inline uint32_t read_CMD_HH(std::shared_ptr reader) { return v; } -void Ship::CutsceneFactoryV0::ParseFileBinary(std::shared_ptr reader, +void LUS::CutsceneFactoryV0::ParseFileBinary(std::shared_ptr reader, std::shared_ptr resource) { std::shared_ptr cutscene = std::static_pointer_cast(resource); @@ -469,4 +469,4 @@ void Ship::CutsceneFactoryV0::ParseFileBinary(std::shared_ptr read } } } -} // namespace Ship +} // namespace LUS diff --git a/soh/soh/resource/importer/CutsceneFactory.h b/soh/soh/resource/importer/CutsceneFactory.h index 9bbc439f7..92402df99 100644 --- a/soh/soh/resource/importer/CutsceneFactory.h +++ b/soh/soh/resource/importer/CutsceneFactory.h @@ -3,7 +3,7 @@ #include "Resource.h" #include "ResourceFactory.h" -namespace Ship { +namespace LUS { class CutsceneFactory : public ResourceFactory { public: @@ -17,4 +17,4 @@ class CutsceneFactoryV0 : public ResourceVersionFactory public: void ParseFileBinary(std::shared_ptr reader, std::shared_ptr resource) override; }; -}; // namespace Ship +}; // namespace LUS diff --git a/soh/soh/resource/importer/PathFactory.cpp b/soh/soh/resource/importer/PathFactory.cpp index 4d610deeb..aa227610d 100644 --- a/soh/soh/resource/importer/PathFactory.cpp +++ b/soh/soh/resource/importer/PathFactory.cpp @@ -2,7 +2,7 @@ #include "soh/resource/type/Path.h" #include "spdlog/spdlog.h" -namespace Ship { +namespace LUS { std::shared_ptr PathFactory::ReadResource(std::shared_ptr resourceMgr, std::shared_ptr initData, std::shared_ptr reader) { @@ -25,7 +25,7 @@ std::shared_ptr PathFactory::ReadResource(std::shared_ptr reader, +void LUS::PathFactoryV0::ParseFileBinary(std::shared_ptr reader, std::shared_ptr resource) { std::shared_ptr path = std::static_pointer_cast(resource); ResourceVersionFactory::ParseFileBinary(reader, path); @@ -54,4 +54,4 @@ void Ship::PathFactoryV0::ParseFileBinary(std::shared_ptr reader, path->pathData.push_back(pathDataEntry); } } -} // namespace Ship +} // namespace LUS diff --git a/soh/soh/resource/importer/PathFactory.h b/soh/soh/resource/importer/PathFactory.h index c772679a7..ad1c68e95 100644 --- a/soh/soh/resource/importer/PathFactory.h +++ b/soh/soh/resource/importer/PathFactory.h @@ -3,7 +3,7 @@ #include "Resource.h" #include "ResourceFactory.h" -namespace Ship { +namespace LUS { class PathFactory : public ResourceFactory { public: @@ -17,4 +17,4 @@ class PathFactoryV0 : public ResourceVersionFactory public: void ParseFileBinary(std::shared_ptr reader, std::shared_ptr resource) override; }; -}; // namespace Ship +}; // namespace LUS diff --git a/soh/soh/resource/importer/PlayerAnimationFactory.cpp b/soh/soh/resource/importer/PlayerAnimationFactory.cpp index 0822697fc..0db77d309 100644 --- a/soh/soh/resource/importer/PlayerAnimationFactory.cpp +++ b/soh/soh/resource/importer/PlayerAnimationFactory.cpp @@ -2,7 +2,7 @@ #include "soh/resource/type/PlayerAnimation.h" #include "spdlog/spdlog.h" -namespace Ship { +namespace LUS { std::shared_ptr PlayerAnimationFactory::ReadResource(std::shared_ptr resourceMgr, std::shared_ptr initData, std::shared_ptr reader) { @@ -26,7 +26,7 @@ std::shared_ptr PlayerAnimationFactory::ReadResource(std::shared_ptr reader, +void LUS::PlayerAnimationFactoryV0::ParseFileBinary(std::shared_ptr reader, std::shared_ptr resource) { std::shared_ptr playerAnimation = std::static_pointer_cast(resource); @@ -39,4 +39,4 @@ void Ship::PlayerAnimationFactoryV0::ParseFileBinary(std::shared_ptrlimbRotData.push_back(reader->ReadInt16()); } } -} // namespace Ship +} // namespace LUS diff --git a/soh/soh/resource/importer/PlayerAnimationFactory.h b/soh/soh/resource/importer/PlayerAnimationFactory.h index 1c57f80bb..a0fdf4a1b 100644 --- a/soh/soh/resource/importer/PlayerAnimationFactory.h +++ b/soh/soh/resource/importer/PlayerAnimationFactory.h @@ -3,7 +3,7 @@ #include "Resource.h" #include "ResourceFactory.h" -namespace Ship { +namespace LUS { class PlayerAnimationFactory : public ResourceFactory { public: std::shared_ptr ReadResource(std::shared_ptr resourceMgr, @@ -15,4 +15,4 @@ class PlayerAnimationFactoryV0 : public ResourceVersionFactory { public: void ParseFileBinary(std::shared_ptr reader, std::shared_ptr resource) override; }; -}; // namespace Ship +}; // namespace LUS diff --git a/soh/soh/resource/importer/SceneFactory.cpp b/soh/soh/resource/importer/SceneFactory.cpp index 8963bff03..3fd1abaf8 100644 --- a/soh/soh/resource/importer/SceneFactory.cpp +++ b/soh/soh/resource/importer/SceneFactory.cpp @@ -28,37 +28,37 @@ #include "soh/resource/importer/scenecommand/SetLightListFactory.h" #include "soh/resource/importer/scenecommand/SetMeshFactory.h" -namespace Ship { +namespace LUS { std::shared_ptr SceneFactory::ReadResource(std::shared_ptr resourceMgr, std::shared_ptr initData, std::shared_ptr reader) { if (SceneFactory::sceneCommandFactories.empty()) { - SceneFactory::sceneCommandFactories[Ship::SceneCommandID::SetLightingSettings] = std::make_shared(); - SceneFactory::sceneCommandFactories[Ship::SceneCommandID::SetWind] = std::make_shared(); - SceneFactory::sceneCommandFactories[Ship::SceneCommandID::SetExitList] = std::make_shared(); - SceneFactory::sceneCommandFactories[Ship::SceneCommandID::SetTimeSettings] = std::make_shared(); - SceneFactory::sceneCommandFactories[Ship::SceneCommandID::SetSkyboxModifier] = std::make_shared(); - SceneFactory::sceneCommandFactories[Ship::SceneCommandID::SetEchoSettings] = std::make_shared(); - SceneFactory::sceneCommandFactories[Ship::SceneCommandID::SetSoundSettings] = std::make_shared(); - SceneFactory::sceneCommandFactories[Ship::SceneCommandID::SetSkyboxSettings] = std::make_shared(); - SceneFactory::sceneCommandFactories[Ship::SceneCommandID::SetRoomBehavior] = std::make_shared(); - SceneFactory::sceneCommandFactories[Ship::SceneCommandID::SetCsCamera] = std::make_shared(); - SceneFactory::sceneCommandFactories[Ship::SceneCommandID::SetCameraSettings] = std::make_shared(); - SceneFactory::sceneCommandFactories[Ship::SceneCommandID::SetRoomList] = std::make_shared(); - SceneFactory::sceneCommandFactories[Ship::SceneCommandID::SetCollisionHeader] = std::make_shared(); - SceneFactory::sceneCommandFactories[Ship::SceneCommandID::SetEntranceList] = std::make_shared(); - SceneFactory::sceneCommandFactories[Ship::SceneCommandID::SetSpecialObjects] = std::make_shared(); - SceneFactory::sceneCommandFactories[Ship::SceneCommandID::SetObjectList] = std::make_shared(); - SceneFactory::sceneCommandFactories[Ship::SceneCommandID::SetStartPositionList] = std::make_shared(); - SceneFactory::sceneCommandFactories[Ship::SceneCommandID::SetActorList] = std::make_shared(); - SceneFactory::sceneCommandFactories[Ship::SceneCommandID::SetTransitionActorList] = std::make_shared(); - SceneFactory::sceneCommandFactories[Ship::SceneCommandID::EndMarker] = std::make_shared(); - SceneFactory::sceneCommandFactories[Ship::SceneCommandID::SetAlternateHeaders] = std::make_shared(); - SceneFactory::sceneCommandFactories[Ship::SceneCommandID::SetPathways] = std::make_shared(); - SceneFactory::sceneCommandFactories[Ship::SceneCommandID::SetCutscenes] = std::make_shared(); - SceneFactory::sceneCommandFactories[Ship::SceneCommandID::SetLightList] = std::make_shared(); - SceneFactory::sceneCommandFactories[Ship::SceneCommandID::SetMesh] = std::make_shared(); + SceneFactory::sceneCommandFactories[LUS::SceneCommandID::SetLightingSettings] = std::make_shared(); + SceneFactory::sceneCommandFactories[LUS::SceneCommandID::SetWind] = std::make_shared(); + SceneFactory::sceneCommandFactories[LUS::SceneCommandID::SetExitList] = std::make_shared(); + SceneFactory::sceneCommandFactories[LUS::SceneCommandID::SetTimeSettings] = std::make_shared(); + SceneFactory::sceneCommandFactories[LUS::SceneCommandID::SetSkyboxModifier] = std::make_shared(); + SceneFactory::sceneCommandFactories[LUS::SceneCommandID::SetEchoSettings] = std::make_shared(); + SceneFactory::sceneCommandFactories[LUS::SceneCommandID::SetSoundSettings] = std::make_shared(); + SceneFactory::sceneCommandFactories[LUS::SceneCommandID::SetSkyboxSettings] = std::make_shared(); + SceneFactory::sceneCommandFactories[LUS::SceneCommandID::SetRoomBehavior] = std::make_shared(); + SceneFactory::sceneCommandFactories[LUS::SceneCommandID::SetCsCamera] = std::make_shared(); + SceneFactory::sceneCommandFactories[LUS::SceneCommandID::SetCameraSettings] = std::make_shared(); + SceneFactory::sceneCommandFactories[LUS::SceneCommandID::SetRoomList] = std::make_shared(); + SceneFactory::sceneCommandFactories[LUS::SceneCommandID::SetCollisionHeader] = std::make_shared(); + SceneFactory::sceneCommandFactories[LUS::SceneCommandID::SetEntranceList] = std::make_shared(); + SceneFactory::sceneCommandFactories[LUS::SceneCommandID::SetSpecialObjects] = std::make_shared(); + SceneFactory::sceneCommandFactories[LUS::SceneCommandID::SetObjectList] = std::make_shared(); + SceneFactory::sceneCommandFactories[LUS::SceneCommandID::SetStartPositionList] = std::make_shared(); + SceneFactory::sceneCommandFactories[LUS::SceneCommandID::SetActorList] = std::make_shared(); + SceneFactory::sceneCommandFactories[LUS::SceneCommandID::SetTransitionActorList] = std::make_shared(); + SceneFactory::sceneCommandFactories[LUS::SceneCommandID::EndMarker] = std::make_shared(); + SceneFactory::sceneCommandFactories[LUS::SceneCommandID::SetAlternateHeaders] = std::make_shared(); + SceneFactory::sceneCommandFactories[LUS::SceneCommandID::SetPathways] = std::make_shared(); + SceneFactory::sceneCommandFactories[LUS::SceneCommandID::SetCutscenes] = std::make_shared(); + SceneFactory::sceneCommandFactories[LUS::SceneCommandID::SetLightList] = std::make_shared(); + SceneFactory::sceneCommandFactories[LUS::SceneCommandID::SetMesh] = std::make_shared(); } auto resource = std::make_shared(resourceMgr, initData); @@ -124,4 +124,4 @@ std::shared_ptr SceneFactoryV0::ParseSceneCommand(std::shared_ptr< return result; } -} // namespace Ship +} // namespace LUS diff --git a/soh/soh/resource/importer/SceneFactory.h b/soh/soh/resource/importer/SceneFactory.h index ddbb330c9..16863edc4 100644 --- a/soh/soh/resource/importer/SceneFactory.h +++ b/soh/soh/resource/importer/SceneFactory.h @@ -6,7 +6,7 @@ #include "Resource.h" #include "ResourceFactory.h" -namespace Ship { +namespace LUS { class SceneFactory : public ResourceFactory { public: std::shared_ptr ReadResource(std::shared_ptr resourceMgr, @@ -27,4 +27,4 @@ class SceneFactoryV0 : public ResourceVersionFactory { protected: std::shared_ptr ParseSceneCommand(std::shared_ptr scene, std::shared_ptr reader, uint32_t index); }; -}; // namespace Ship +}; // namespace LUS diff --git a/soh/soh/resource/importer/SkeletonFactory.cpp b/soh/soh/resource/importer/SkeletonFactory.cpp index 24faaecaf..4741a3f2e 100644 --- a/soh/soh/resource/importer/SkeletonFactory.cpp +++ b/soh/soh/resource/importer/SkeletonFactory.cpp @@ -1,9 +1,9 @@ #include "soh/resource/importer/SkeletonFactory.h" #include "soh/resource/type/Skeleton.h" #include -#include +#include -namespace Ship { +namespace LUS { std::shared_ptr SkeletonFactory::ReadResource(std::shared_ptr resourceMgr, std::shared_ptr initData, std::shared_ptr reader) { @@ -32,8 +32,8 @@ std::shared_ptr SkeletonFactory::ReadResourceXML(std::shared_ptr(resourceMgr, initData); std::shared_ptr factory = nullptr; - switch ((Version)resource->InitData->ResourceVersion) { - case Version::Deckard: + switch (resource->InitData->ResourceVersion) { + case 0: factory = std::make_shared(); break; } @@ -68,32 +68,32 @@ void SkeletonFactoryV0::ParseFileBinary(std::shared_ptr reader, skeleton->limbTable.push_back(limbPath); } - if (skeleton->type == Ship::SkeletonType::Curve) { + if (skeleton->type == LUS::SkeletonType::Curve) { skeleton->skeletonData.skelCurveLimbList.limbCount = skeleton->limbCount; skeleton->curveLimbArray.reserve(skeleton->skeletonData.skelCurveLimbList.limbCount); - } else if (skeleton->type == Ship::SkeletonType::Flex) { + } else if (skeleton->type == LUS::SkeletonType::Flex) { skeleton->skeletonData.flexSkeletonHeader.dListCount = skeleton->dListCount; } - if (skeleton->type == Ship::SkeletonType::Normal) { + if (skeleton->type == LUS::SkeletonType::Normal) { skeleton->skeletonData.skeletonHeader.limbCount = skeleton->limbCount; skeleton->standardLimbArray.reserve(skeleton->skeletonData.skeletonHeader.limbCount); - } else if (skeleton->type == Ship::SkeletonType::Flex) { + } else if (skeleton->type == LUS::SkeletonType::Flex) { skeleton->skeletonData.flexSkeletonHeader.sh.limbCount = skeleton->limbCount; skeleton->standardLimbArray.reserve(skeleton->skeletonData.flexSkeletonHeader.sh.limbCount); } for (size_t i = 0; i < skeleton->limbTable.size(); i++) { std::string limbStr = skeleton->limbTable[i]; - auto limb = GetResourceDataByName(limbStr.c_str(), true); - skeleton->skeletonHeaderSegments.push_back(limb); + auto limb = LUS::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(limbStr.c_str()); + skeleton->skeletonHeaderSegments.push_back(limb ? limb->GetPointer() : nullptr); } - if (skeleton->type == Ship::SkeletonType::Normal) { + if (skeleton->type == LUS::SkeletonType::Normal) { skeleton->skeletonData.skeletonHeader.segment = (void**)skeleton->skeletonHeaderSegments.data(); - } else if (skeleton->type == Ship::SkeletonType::Flex) { + } else if (skeleton->type == LUS::SkeletonType::Flex) { skeleton->skeletonData.flexSkeletonHeader.sh.segment = (void**)skeleton->skeletonHeaderSegments.data(); - } else if (skeleton->type == Ship::SkeletonType::Curve) { + } else if (skeleton->type == LUS::SkeletonType::Curve) { skeleton->skeletonData.skelCurveLimbList.limbs = (SkelCurveLimb**)skeleton->skeletonHeaderSegments.data(); } else { SPDLOG_ERROR("unknown skeleton type {}", (uint32_t)skeleton->type); @@ -142,8 +142,8 @@ void SkeletonFactoryV0::ParseFileXML(tinyxml2::XMLElement* reader, std::shared_p std::string limbName = child->Attribute("Path"); skel->limbTable.push_back(limbName); - auto limb = GetResourceDataByName(limbName.c_str(), true); - skel->skeletonHeaderSegments.push_back(limb); + auto limb = LUS::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(limbName.c_str()); + skel->skeletonHeaderSegments.push_back(limb ? limb->GetPointer() : nullptr); } child = child->NextSiblingElement(); @@ -154,4 +154,4 @@ void SkeletonFactoryV0::ParseFileXML(tinyxml2::XMLElement* reader, std::shared_p skel->skeletonData.flexSkeletonHeader.dListCount = skel->dListCount; } -} // namespace Ship +} // namespace LUS diff --git a/soh/soh/resource/importer/SkeletonFactory.h b/soh/soh/resource/importer/SkeletonFactory.h index bb898d7d3..580bff1fb 100644 --- a/soh/soh/resource/importer/SkeletonFactory.h +++ b/soh/soh/resource/importer/SkeletonFactory.h @@ -3,7 +3,7 @@ #include "Resource.h" #include "ResourceFactory.h" -namespace Ship { +namespace LUS { class SkeletonFactory : public ResourceFactory { public: @@ -21,5 +21,5 @@ class SkeletonFactoryV0 : public ResourceVersionFactory void ParseFileBinary(std::shared_ptr reader, std::shared_ptr resource) override; void ParseFileXML(tinyxml2::XMLElement* reader, std::shared_ptr resource) override; }; -}; // namespace Ship +}; // namespace LUS diff --git a/soh/soh/resource/importer/SkeletonLimbFactory.cpp b/soh/soh/resource/importer/SkeletonLimbFactory.cpp index 9401708d8..f4196c6be 100644 --- a/soh/soh/resource/importer/SkeletonLimbFactory.cpp +++ b/soh/soh/resource/importer/SkeletonLimbFactory.cpp @@ -1,9 +1,9 @@ #include "soh/resource/importer/SkeletonLimbFactory.h" #include "soh/resource/type/SkeletonLimb.h" #include "spdlog/spdlog.h" -#include "libultraship/bridge.h" +#include "libultraship/libultraship.h" -namespace Ship { +namespace LUS { std::shared_ptr SkeletonLimbFactory::ReadResource(std::shared_ptr resourceMgr, std::shared_ptr initData, std::shared_ptr reader) { @@ -32,8 +32,8 @@ std::shared_ptr SkeletonLimbFactory::ReadResourceXML(std::shared_ptr(resourceMgr, initData); std::shared_ptr factory = nullptr; - switch ((Version)resource->InitData->ResourceVersion) { - case Version::Deckard: + switch (resource->InitData->ResourceVersion) { + case 0: factory = std::make_shared(); break; } @@ -48,7 +48,7 @@ std::shared_ptr SkeletonLimbFactory::ReadResourceXML(std::shared_ptr reader, +void LUS::SkeletonLimbFactoryV0::ParseFileBinary(std::shared_ptr reader, std::shared_ptr resource) { std::shared_ptr skeletonLimb = std::static_pointer_cast(resource); @@ -126,7 +126,7 @@ void Ship::SkeletonLimbFactoryV0::ParseFileBinary(std::shared_ptr skeletonLimb->childIndex = reader->ReadUByte(); skeletonLimb->siblingIndex = reader->ReadUByte(); - if (skeletonLimb->limbType == Ship::LimbType::LOD) { + if (skeletonLimb->limbType == LUS::LimbType::LOD) { skeletonLimb->limbData.lodLimb.jointPos.x = skeletonLimb->transX; skeletonLimb->limbData.lodLimb.jointPos.y = skeletonLimb->transY; skeletonLimb->limbData.lodLimb.jointPos.z = skeletonLimb->transZ; @@ -134,19 +134,19 @@ void Ship::SkeletonLimbFactoryV0::ParseFileBinary(std::shared_ptr skeletonLimb->limbData.lodLimb.sibling = skeletonLimb->siblingIndex; if (skeletonLimb->dListPtr != "") { - auto dList = GetResourceDataByName(skeletonLimb->dListPtr.c_str(), true); - skeletonLimb->limbData.lodLimb.dLists[0] = (Gfx*)dList; + auto dList = LUS::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(skeletonLimb->dListPtr.c_str()); + skeletonLimb->limbData.lodLimb.dLists[0] = (Gfx*)(dList ? dList->GetPointer() : nullptr); } else { skeletonLimb->limbData.lodLimb.dLists[0] = nullptr; } if (skeletonLimb->dList2Ptr != "") { - auto dList = GetResourceDataByName(skeletonLimb->dList2Ptr.c_str(), true); - skeletonLimb->limbData.lodLimb.dLists[1] = (Gfx*)dList; + auto dList = LUS::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(skeletonLimb->dList2Ptr.c_str()); + skeletonLimb->limbData.lodLimb.dLists[1] = (Gfx*)(dList ? dList->GetPointer() : nullptr); } else { skeletonLimb->limbData.lodLimb.dLists[1] = nullptr; } - } else if (skeletonLimb->limbType == Ship::LimbType::Standard) { + } else if (skeletonLimb->limbType == LUS::LimbType::Standard) { skeletonLimb->limbData.standardLimb.jointPos.x = skeletonLimb->transX; skeletonLimb->limbData.standardLimb.jointPos.y = skeletonLimb->transY; skeletonLimb->limbData.standardLimb.jointPos.z = skeletonLimb->transZ; @@ -155,48 +155,50 @@ void Ship::SkeletonLimbFactoryV0::ParseFileBinary(std::shared_ptr skeletonLimb->limbData.standardLimb.dList = nullptr; if (!skeletonLimb->dListPtr.empty()) { - const auto dList = GetResourceDataByName(skeletonLimb->dListPtr.c_str(), true); - skeletonLimb->limbData.standardLimb.dList = (Gfx*)dList; + const auto dList = LUS::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(skeletonLimb->dListPtr.c_str()); + skeletonLimb->limbData.standardLimb.dList = (Gfx*)(dList ? dList->GetPointer() : nullptr); } - } else if (skeletonLimb->limbType == Ship::LimbType::Curve) { + } else if (skeletonLimb->limbType == LUS::LimbType::Curve) { skeletonLimb->limbData.skelCurveLimb.firstChildIdx = skeletonLimb->childIndex; skeletonLimb->limbData.skelCurveLimb.nextLimbIdx = skeletonLimb->siblingIndex; skeletonLimb->limbData.skelCurveLimb.dList[0] = nullptr; skeletonLimb->limbData.skelCurveLimb.dList[1] = nullptr; if (!skeletonLimb->dListPtr.empty()) { - const auto dList = GetResourceDataByName(skeletonLimb->dListPtr.c_str(), true); - skeletonLimb->limbData.skelCurveLimb.dList[0] = (Gfx*)dList; + const auto dList = LUS::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(skeletonLimb->dListPtr.c_str()); + skeletonLimb->limbData.skelCurveLimb.dList[0] = (Gfx*)(dList ? dList->GetPointer() : nullptr); } if (!skeletonLimb->dList2Ptr.empty()) { - const auto dList = GetResourceDataByName(skeletonLimb->dList2Ptr.c_str(), true); - skeletonLimb->limbData.skelCurveLimb.dList[1] = (Gfx*)dList; + const auto dList = LUS::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(skeletonLimb->dList2Ptr.c_str()); + skeletonLimb->limbData.skelCurveLimb.dList[1] = (Gfx*)(dList ? dList->GetPointer() : nullptr); } - } else if (skeletonLimb->limbType == Ship::LimbType::Skin) { + } else if (skeletonLimb->limbType == LUS::LimbType::Skin) { skeletonLimb->limbData.skinLimb.jointPos.x = skeletonLimb->transX; skeletonLimb->limbData.skinLimb.jointPos.y = skeletonLimb->transY; skeletonLimb->limbData.skinLimb.jointPos.z = skeletonLimb->transZ; skeletonLimb->limbData.skinLimb.child = skeletonLimb->childIndex; skeletonLimb->limbData.skinLimb.sibling = skeletonLimb->siblingIndex; - if (skeletonLimb->skinSegmentType == Ship::ZLimbSkinType::SkinType_DList) { + if (skeletonLimb->skinSegmentType == LUS::ZLimbSkinType::SkinType_DList) { skeletonLimb->limbData.skinLimb.segmentType = static_cast(skeletonLimb->skinSegmentType); - } else if (skeletonLimb->skinSegmentType == Ship::ZLimbSkinType::SkinType_4) { + } else if (skeletonLimb->skinSegmentType == LUS::ZLimbSkinType::SkinType_4) { skeletonLimb->limbData.skinLimb.segmentType = 4; - } else if (skeletonLimb->skinSegmentType == Ship::ZLimbSkinType::SkinType_5) { + } else if (skeletonLimb->skinSegmentType == LUS::ZLimbSkinType::SkinType_5) { skeletonLimb->limbData.skinLimb.segmentType = 5; } else { skeletonLimb->limbData.skinLimb.segmentType = 0; } - if (skeletonLimb->skinSegmentType == Ship::ZLimbSkinType::SkinType_DList) { - skeletonLimb->limbData.skinLimb.segment = GetResourceDataByName(skeletonLimb->skinDList.c_str(), true); - } else if (skeletonLimb->skinSegmentType == Ship::ZLimbSkinType::SkinType_4) { + if (skeletonLimb->skinSegmentType == LUS::ZLimbSkinType::SkinType_DList) { + auto res = LUS::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(skeletonLimb->skinDList.c_str()); + skeletonLimb->limbData.skinLimb.segment = res ? res->GetPointer() : nullptr; + } else if (skeletonLimb->skinSegmentType == LUS::ZLimbSkinType::SkinType_4) { skeletonLimb->skinAnimLimbData.totalVtxCount = skeletonLimb->skinVtxCnt; skeletonLimb->skinAnimLimbData.limbModifCount = skeletonLimb->skinLimbModifCount; skeletonLimb->skinAnimLimbData.limbModifications = skeletonLimb->skinLimbModifArray.data(); - skeletonLimb->skinAnimLimbData.dlist = (Gfx*)GetResourceDataByName(skeletonLimb->skinDList2.c_str(), true); + auto res = LUS::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(skeletonLimb->skinDList2.c_str()); + skeletonLimb->skinAnimLimbData.dlist = (Gfx*)(res ? res->GetPointer() : nullptr); for (size_t i = 0; i < skeletonLimb->skinLimbModifArray.size(); i++) { skeletonLimb->skinAnimLimbData.limbModifications[i].vtxCount = skeletonLimb->skinLimbModifVertexArrays[i].size(); @@ -254,7 +256,8 @@ void SkeletonLimbFactoryV0::ParseFileXML(tinyxml2::XMLElement* reader, std::shar limbData.lodLimb.jointPos.z = skelLimb->transZ; if (skelLimb->dListPtr != "") { - limbData.lodLimb.dLists[0] = (Gfx*)GetResourceDataByName((const char*)skelLimb->dListPtr.c_str(), true); + auto res = LUS::Context::GetInstance()->GetResourceManager()->LoadResourceProcess((const char*)skelLimb->dListPtr.c_str()); + limbData.lodLimb.dLists[0] = (Gfx*)(res ? res->GetPointer() : nullptr); } else { limbData.lodLimb.dLists[0] = nullptr; } @@ -267,4 +270,4 @@ void SkeletonLimbFactoryV0::ParseFileXML(tinyxml2::XMLElement* reader, std::shar // skelLimb->dList2Ptr = reader->Attribute("DisplayList2"); } -} // namespace Ship +} // namespace LUS diff --git a/soh/soh/resource/importer/SkeletonLimbFactory.h b/soh/soh/resource/importer/SkeletonLimbFactory.h index ba98b73c5..1d0204ab8 100644 --- a/soh/soh/resource/importer/SkeletonLimbFactory.h +++ b/soh/soh/resource/importer/SkeletonLimbFactory.h @@ -3,7 +3,7 @@ #include "Resource.h" #include "ResourceFactory.h" -namespace Ship { +namespace LUS { class SkeletonLimbFactory : public ResourceFactory { public: @@ -21,5 +21,5 @@ class SkeletonLimbFactoryV0 : public ResourceVersionFactory void ParseFileBinary(std::shared_ptr reader, std::shared_ptr resource) override; void ParseFileXML(tinyxml2::XMLElement* reader, std::shared_ptr resource) override; }; -}; // namespace Ship +}; // namespace LUS diff --git a/soh/soh/resource/importer/TextFactory.cpp b/soh/soh/resource/importer/TextFactory.cpp index fe66d6309..9dfb66dda 100644 --- a/soh/soh/resource/importer/TextFactory.cpp +++ b/soh/soh/resource/importer/TextFactory.cpp @@ -2,7 +2,7 @@ #include "soh/resource/type/Text.h" #include "spdlog/spdlog.h" -namespace Ship { +namespace LUS { std::shared_ptr TextFactory::ReadResource(std::shared_ptr resourceMgr, std::shared_ptr initData, std::shared_ptr reader) { @@ -34,8 +34,8 @@ std::shared_ptr TextFactory::ReadResourceXML(std::shared_ptr(resourceMgr, initData); std::shared_ptr factory = nullptr; - switch ((Version)resource->InitData->ResourceVersion) { - case Version::Deckard: + switch (resource->InitData->ResourceVersion) { + case 0: factory = std::make_shared(); break; } @@ -50,7 +50,7 @@ std::shared_ptr TextFactory::ReadResourceXML(std::shared_ptr reader, +void LUS::TextFactoryV0::ParseFileBinary(std::shared_ptr reader, std::shared_ptr resource) { std::shared_ptr text = std::static_pointer_cast(resource); ResourceVersionFactory::ParseFileBinary(reader, text); @@ -92,4 +92,4 @@ void TextFactoryV0::ParseFileXML(tinyxml2::XMLElement* reader, std::shared_ptr reader, std::shared_ptr resource) override; void ParseFileXML(tinyxml2::XMLElement* reader, std::shared_ptr resource) override; }; -}; // namespace Ship +}; // namespace LUS diff --git a/soh/soh/resource/importer/scenecommand/EndMarkerFactory.cpp b/soh/soh/resource/importer/scenecommand/EndMarkerFactory.cpp index fe54e6b4b..6d0483e73 100644 --- a/soh/soh/resource/importer/scenecommand/EndMarkerFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/EndMarkerFactory.cpp @@ -2,7 +2,7 @@ #include "soh/resource/type/scenecommand/EndMarker.h" #include "spdlog/spdlog.h" -namespace Ship { +namespace LUS { std::shared_ptr EndMarkerFactory::ReadResource(std::shared_ptr resourceMgr, std::shared_ptr initData, std::shared_ptr reader) { @@ -25,7 +25,7 @@ std::shared_ptr EndMarkerFactory::ReadResource(std::shared_ptr reader, +void LUS::EndMarkerFactoryV0::ParseFileBinary(std::shared_ptr reader, std::shared_ptr resource) { std::shared_ptr endMarker = std::static_pointer_cast(resource); @@ -36,4 +36,4 @@ void Ship::EndMarkerFactoryV0::ParseFileBinary(std::shared_ptr rea // This has no data. } -} // namespace Ship +} // namespace LUS diff --git a/soh/soh/resource/importer/scenecommand/EndMarkerFactory.h b/soh/soh/resource/importer/scenecommand/EndMarkerFactory.h index f64d4ed5d..606153a95 100644 --- a/soh/soh/resource/importer/scenecommand/EndMarkerFactory.h +++ b/soh/soh/resource/importer/scenecommand/EndMarkerFactory.h @@ -2,7 +2,7 @@ #include "soh/resource/importer/scenecommand/SceneCommandFactory.h" -namespace Ship { +namespace LUS { class EndMarkerFactory : public SceneCommandFactory { public: std::shared_ptr ReadResource(std::shared_ptr resourceMgr, @@ -14,4 +14,4 @@ class EndMarkerFactoryV0 : public SceneCommandVersionFactory { public: void ParseFileBinary(std::shared_ptr reader, std::shared_ptr resource) override; }; -}; // namespace Ship +}; // namespace LUS diff --git a/soh/soh/resource/importer/scenecommand/SceneCommandFactory.cpp b/soh/soh/resource/importer/scenecommand/SceneCommandFactory.cpp index 6da03e131..efa170761 100644 --- a/soh/soh/resource/importer/scenecommand/SceneCommandFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SceneCommandFactory.cpp @@ -2,7 +2,7 @@ #include "soh/resource/type/scenecommand/SceneCommand.h" #include "spdlog/spdlog.h" -namespace Ship { +namespace LUS { void SceneCommandVersionFactory::ReadCommandId(std::shared_ptr command, std::shared_ptr reader) { command->cmdId = (SceneCommandID)reader->ReadInt32(); } diff --git a/soh/soh/resource/importer/scenecommand/SceneCommandFactory.h b/soh/soh/resource/importer/scenecommand/SceneCommandFactory.h index fd3a07dce..3ab89c5b7 100644 --- a/soh/soh/resource/importer/scenecommand/SceneCommandFactory.h +++ b/soh/soh/resource/importer/scenecommand/SceneCommandFactory.h @@ -5,11 +5,11 @@ #include "ResourceFactory.h" #include "soh/resource/type/scenecommand/SceneCommand.h" -namespace Ship { +namespace LUS { class SceneCommandFactory : public ResourceFactory {}; class SceneCommandVersionFactory : public ResourceVersionFactory { protected: void ReadCommandId(std::shared_ptr command, std::shared_ptr reader); }; -}; // namespace Ship +}; // namespace LUS diff --git a/soh/soh/resource/importer/scenecommand/SetActorListFactory.cpp b/soh/soh/resource/importer/scenecommand/SetActorListFactory.cpp index 226acb410..50eeb2247 100644 --- a/soh/soh/resource/importer/scenecommand/SetActorListFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetActorListFactory.cpp @@ -2,7 +2,7 @@ #include "soh/resource/type/scenecommand/SetActorList.h" #include "spdlog/spdlog.h" -namespace Ship { +namespace LUS { std::shared_ptr SetActorListFactory::ReadResource(std::shared_ptr resourceMgr, std::shared_ptr initData, std::shared_ptr reader) { @@ -26,7 +26,7 @@ std::shared_ptr SetActorListFactory::ReadResource(std::shared_ptr reader, +void LUS::SetActorListFactoryV0::ParseFileBinary(std::shared_ptr reader, std::shared_ptr resource) { std::shared_ptr setActorList = std::static_pointer_cast(resource); ResourceVersionFactory::ParseFileBinary(reader, setActorList); @@ -51,4 +51,4 @@ void Ship::SetActorListFactoryV0::ParseFileBinary(std::shared_ptr } } -} // namespace Ship +} // namespace LUS diff --git a/soh/soh/resource/importer/scenecommand/SetActorListFactory.h b/soh/soh/resource/importer/scenecommand/SetActorListFactory.h index e36038076..fa62241fc 100644 --- a/soh/soh/resource/importer/scenecommand/SetActorListFactory.h +++ b/soh/soh/resource/importer/scenecommand/SetActorListFactory.h @@ -2,7 +2,7 @@ #include "soh/resource/importer/scenecommand/SceneCommandFactory.h" -namespace Ship { +namespace LUS { class SetActorListFactory : public SceneCommandFactory { public: std::shared_ptr ReadResource(std::shared_ptr resourceMgr, @@ -14,4 +14,4 @@ class SetActorListFactoryV0 : public SceneCommandVersionFactory { public: void ParseFileBinary(std::shared_ptr reader, std::shared_ptr resource) override; }; -}; // namespace Ship +}; // namespace LUS diff --git a/soh/soh/resource/importer/scenecommand/SetAlternateHeadersFactory.cpp b/soh/soh/resource/importer/scenecommand/SetAlternateHeadersFactory.cpp index 6b7cfb355..b01b7f1fc 100644 --- a/soh/soh/resource/importer/scenecommand/SetAlternateHeadersFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetAlternateHeadersFactory.cpp @@ -1,9 +1,9 @@ #include "soh/resource/importer/scenecommand/SetAlternateHeadersFactory.h" #include "soh/resource/type/scenecommand/SetAlternateHeaders.h" #include "spdlog/spdlog.h" -#include "libultraship/bridge.h" +#include "libultraship/libultraship.h" -namespace Ship { +namespace LUS { std::shared_ptr SetAlternateHeadersFactory::ReadResource(std::shared_ptr resourceMgr, std::shared_ptr initData, std::shared_ptr reader) { @@ -27,7 +27,7 @@ std::shared_ptr SetAlternateHeadersFactory::ReadResource(std::shared_p return resource; } -void Ship::SetAlternateHeadersFactoryV0::ParseFileBinary(std::shared_ptr reader, +void LUS::SetAlternateHeadersFactoryV0::ParseFileBinary(std::shared_ptr reader, std::shared_ptr resource) { std::shared_ptr setAlternateHeaders = std::static_pointer_cast(resource); @@ -40,11 +40,11 @@ void Ship::SetAlternateHeadersFactoryV0::ParseFileBinary(std::shared_ptrnumHeaders; i++) { auto headerName = reader->ReadString(); if (!headerName.empty()) { - setAlternateHeaders->headers.push_back(std::static_pointer_cast(LoadResource(headerName.c_str(), true))); + setAlternateHeaders->headers.push_back(std::static_pointer_cast(LUS::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(headerName.c_str()))); } else { setAlternateHeaders->headers.push_back(nullptr); } } } -} // namespace Ship +} // namespace LUS diff --git a/soh/soh/resource/importer/scenecommand/SetAlternateHeadersFactory.h b/soh/soh/resource/importer/scenecommand/SetAlternateHeadersFactory.h index e37e344a4..c9dd3f26c 100644 --- a/soh/soh/resource/importer/scenecommand/SetAlternateHeadersFactory.h +++ b/soh/soh/resource/importer/scenecommand/SetAlternateHeadersFactory.h @@ -2,7 +2,7 @@ #include "soh/resource/importer/scenecommand/SceneCommandFactory.h" -namespace Ship { +namespace LUS { class SetAlternateHeadersFactory : public SceneCommandFactory { public: std::shared_ptr ReadResource(std::shared_ptr resourceMgr, @@ -14,4 +14,4 @@ class SetAlternateHeadersFactoryV0 : public SceneCommandVersionFactory { public: void ParseFileBinary(std::shared_ptr reader, std::shared_ptr resource) override; }; -}; // namespace Ship +}; // namespace LUS diff --git a/soh/soh/resource/importer/scenecommand/SetCameraSettingsFactory.cpp b/soh/soh/resource/importer/scenecommand/SetCameraSettingsFactory.cpp index 8615cb04e..88f8522d4 100644 --- a/soh/soh/resource/importer/scenecommand/SetCameraSettingsFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetCameraSettingsFactory.cpp @@ -2,7 +2,7 @@ #include "soh/resource/type/scenecommand/SetCameraSettings.h" #include "spdlog/spdlog.h" -namespace Ship { +namespace LUS { std::shared_ptr SetCameraSettingsFactory::ReadResource(std::shared_ptr resourceMgr, std::shared_ptr initData, std::shared_ptr reader) { @@ -25,7 +25,7 @@ std::shared_ptr SetCameraSettingsFactory::ReadResource(std::shared_ptr return resource; } -void Ship::SetCameraSettingsFactoryV0::ParseFileBinary(std::shared_ptr reader, +void LUS::SetCameraSettingsFactoryV0::ParseFileBinary(std::shared_ptr reader, std::shared_ptr resource) { std::shared_ptr setCameraSettings = std::static_pointer_cast(resource); @@ -37,4 +37,4 @@ void Ship::SetCameraSettingsFactoryV0::ParseFileBinary(std::shared_ptrsettings.worldMapArea = reader->ReadInt32(); } -} // namespace Ship +} // namespace LUS diff --git a/soh/soh/resource/importer/scenecommand/SetCameraSettingsFactory.h b/soh/soh/resource/importer/scenecommand/SetCameraSettingsFactory.h index a87710bea..0271c62f0 100644 --- a/soh/soh/resource/importer/scenecommand/SetCameraSettingsFactory.h +++ b/soh/soh/resource/importer/scenecommand/SetCameraSettingsFactory.h @@ -2,7 +2,7 @@ #include "soh/resource/importer/scenecommand/SceneCommandFactory.h" -namespace Ship { +namespace LUS { class SetCameraSettingsFactory : public SceneCommandFactory { public: std::shared_ptr ReadResource(std::shared_ptr resourceMgr, @@ -14,4 +14,4 @@ class SetCameraSettingsFactoryV0 : public SceneCommandVersionFactory { public: void ParseFileBinary(std::shared_ptr reader, std::shared_ptr resource) override; }; -}; // namespace Ship +}; // namespace LUS diff --git a/soh/soh/resource/importer/scenecommand/SetCollisionHeaderFactory.cpp b/soh/soh/resource/importer/scenecommand/SetCollisionHeaderFactory.cpp index 0c60750c2..aa7a7a104 100644 --- a/soh/soh/resource/importer/scenecommand/SetCollisionHeaderFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetCollisionHeaderFactory.cpp @@ -1,9 +1,9 @@ #include "soh/resource/importer/scenecommand/SetCollisionHeaderFactory.h" #include "soh/resource/type/scenecommand/SetCollisionHeader.h" -#include "libultraship/bridge.h" +#include "libultraship/libultraship.h" #include "spdlog/spdlog.h" -namespace Ship { +namespace LUS { std::shared_ptr SetCollisionHeaderFactory::ReadResource(std::shared_ptr resourceMgr, std::shared_ptr initData, std::shared_ptr reader) { @@ -26,7 +26,7 @@ std::shared_ptr SetCollisionHeaderFactory::ReadResource(std::shared_pt return resource; } -void Ship::SetCollisionHeaderFactoryV0::ParseFileBinary(std::shared_ptr reader, +void LUS::SetCollisionHeaderFactoryV0::ParseFileBinary(std::shared_ptr reader, std::shared_ptr resource) { std::shared_ptr setCollisionHeader = std::static_pointer_cast(resource); ResourceVersionFactory::ParseFileBinary(reader, setCollisionHeader); @@ -34,7 +34,7 @@ void Ship::SetCollisionHeaderFactoryV0::ParseFileBinary(std::shared_ptrfileName = reader->ReadString(); - setCollisionHeader->collisionHeader = std::static_pointer_cast(LoadResource(setCollisionHeader->fileName.c_str(), true)); + setCollisionHeader->collisionHeader = std::static_pointer_cast(LUS::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(setCollisionHeader->fileName.c_str())); } -} // namespace Ship +} // namespace LUS diff --git a/soh/soh/resource/importer/scenecommand/SetCollisionHeaderFactory.h b/soh/soh/resource/importer/scenecommand/SetCollisionHeaderFactory.h index 0d98f31a2..361e0636b 100644 --- a/soh/soh/resource/importer/scenecommand/SetCollisionHeaderFactory.h +++ b/soh/soh/resource/importer/scenecommand/SetCollisionHeaderFactory.h @@ -2,7 +2,7 @@ #include "soh/resource/importer/scenecommand/SceneCommandFactory.h" -namespace Ship { +namespace LUS { class SetCollisionHeaderFactory : public SceneCommandFactory { public: std::shared_ptr ReadResource(std::shared_ptr resourceMgr, @@ -14,4 +14,4 @@ class SetCollisionHeaderFactoryV0 : public SceneCommandVersionFactory { public: void ParseFileBinary(std::shared_ptr reader, std::shared_ptr resource) override; }; -}; // namespace Ship +}; // namespace LUS diff --git a/soh/soh/resource/importer/scenecommand/SetCsCameraFactory.cpp b/soh/soh/resource/importer/scenecommand/SetCsCameraFactory.cpp index 93ca5a68e..e83d60749 100644 --- a/soh/soh/resource/importer/scenecommand/SetCsCameraFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetCsCameraFactory.cpp @@ -2,7 +2,7 @@ #include "soh/resource/type/scenecommand/SetCsCamera.h" #include "spdlog/spdlog.h" -namespace Ship { +namespace LUS { std::shared_ptr SetCsCameraFactory::ReadResource(std::shared_ptr resourceMgr, std::shared_ptr initData, std::shared_ptr reader) { @@ -25,7 +25,7 @@ std::shared_ptr SetCsCameraFactory::ReadResource(std::shared_ptr reader, +void LUS::SetCsCameraFactoryV0::ParseFileBinary(std::shared_ptr reader, std::shared_ptr resource) { std::shared_ptr setCsCamera = std::static_pointer_cast(resource); ResourceVersionFactory::ParseFileBinary(reader, setCsCamera); @@ -38,4 +38,4 @@ void Ship::SetCsCameraFactoryV0::ParseFileBinary(std::shared_ptr r // OTRTODO: FINISH! } -} // namespace Ship +} // namespace LUS diff --git a/soh/soh/resource/importer/scenecommand/SetCsCameraFactory.h b/soh/soh/resource/importer/scenecommand/SetCsCameraFactory.h index 69a39eb81..71a8a6a7d 100644 --- a/soh/soh/resource/importer/scenecommand/SetCsCameraFactory.h +++ b/soh/soh/resource/importer/scenecommand/SetCsCameraFactory.h @@ -2,7 +2,7 @@ #include "soh/resource/importer/scenecommand/SceneCommandFactory.h" -namespace Ship { +namespace LUS { class SetCsCameraFactory : public SceneCommandFactory { public: std::shared_ptr ReadResource(std::shared_ptr resourceMgr, @@ -14,4 +14,4 @@ class SetCsCameraFactoryV0 : public SceneCommandVersionFactory { public: void ParseFileBinary(std::shared_ptr reader, std::shared_ptr resource) override; }; -}; // namespace Ship +}; // namespace LUS diff --git a/soh/soh/resource/importer/scenecommand/SetCutscenesFactory.cpp b/soh/soh/resource/importer/scenecommand/SetCutscenesFactory.cpp index 2441af6f1..37e374282 100644 --- a/soh/soh/resource/importer/scenecommand/SetCutscenesFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetCutscenesFactory.cpp @@ -1,9 +1,9 @@ #include "soh/resource/importer/scenecommand/SetCutscenesFactory.h" #include "soh/resource/type/scenecommand/SetCutscenes.h" -#include +#include #include "spdlog/spdlog.h" -namespace Ship { +namespace LUS { std::shared_ptr SetCutscenesFactory::ReadResource(std::shared_ptr resourceMgr, std::shared_ptr initData, std::shared_ptr reader) { @@ -27,7 +27,7 @@ std::shared_ptr SetCutscenesFactory::ReadResource(std::shared_ptr reader, +void LUS::SetCutscenesFactoryV0::ParseFileBinary(std::shared_ptr reader, std::shared_ptr resource) { std::shared_ptr setCutscenes = std::static_pointer_cast(resource); ResourceVersionFactory::ParseFileBinary(reader, setCutscenes); @@ -35,7 +35,7 @@ void Ship::SetCutscenesFactoryV0::ParseFileBinary(std::shared_ptr ReadCommandId(setCutscenes, reader); setCutscenes->fileName = reader->ReadString(); - setCutscenes->cutscene = std::static_pointer_cast(LoadResource(setCutscenes->fileName.c_str(), true)); + setCutscenes->cutscene = std::static_pointer_cast(LUS::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(setCutscenes->fileName.c_str())); } -} // namespace Ship +} // namespace LUS diff --git a/soh/soh/resource/importer/scenecommand/SetCutscenesFactory.h b/soh/soh/resource/importer/scenecommand/SetCutscenesFactory.h index da594ed8a..86987e59e 100644 --- a/soh/soh/resource/importer/scenecommand/SetCutscenesFactory.h +++ b/soh/soh/resource/importer/scenecommand/SetCutscenesFactory.h @@ -2,7 +2,7 @@ #include "soh/resource/importer/scenecommand/SceneCommandFactory.h" -namespace Ship { +namespace LUS { class SetCutscenesFactory : public SceneCommandFactory { public: std::shared_ptr ReadResource(std::shared_ptr resourceMgr, @@ -14,4 +14,4 @@ class SetCutscenesFactoryV0 : public SceneCommandVersionFactory { public: void ParseFileBinary(std::shared_ptr reader, std::shared_ptr resource) override; }; -}; // namespace Ship +}; // namespace LUS diff --git a/soh/soh/resource/importer/scenecommand/SetEchoSettingsFactory.cpp b/soh/soh/resource/importer/scenecommand/SetEchoSettingsFactory.cpp index 7d1503091..5fa20f12f 100644 --- a/soh/soh/resource/importer/scenecommand/SetEchoSettingsFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetEchoSettingsFactory.cpp @@ -2,7 +2,7 @@ #include "soh/resource/type/scenecommand/SetEchoSettings.h" #include "spdlog/spdlog.h" -namespace Ship { +namespace LUS { std::shared_ptr SetEchoSettingsFactory::ReadResource(std::shared_ptr resourceMgr, std::shared_ptr initData, std::shared_ptr reader) { @@ -25,7 +25,7 @@ std::shared_ptr SetEchoSettingsFactory::ReadResource(std::shared_ptr reader, +void LUS::SetEchoSettingsFactoryV0::ParseFileBinary(std::shared_ptr reader, std::shared_ptr resource) { std::shared_ptr setEchoSettings = std::static_pointer_cast(resource); @@ -36,4 +36,4 @@ void Ship::SetEchoSettingsFactoryV0::ParseFileBinary(std::shared_ptrsettings.echo = reader->ReadInt8(); } -} // namespace Ship +} // namespace LUS diff --git a/soh/soh/resource/importer/scenecommand/SetEchoSettingsFactory.h b/soh/soh/resource/importer/scenecommand/SetEchoSettingsFactory.h index 02e01713f..1df65e56b 100644 --- a/soh/soh/resource/importer/scenecommand/SetEchoSettingsFactory.h +++ b/soh/soh/resource/importer/scenecommand/SetEchoSettingsFactory.h @@ -2,7 +2,7 @@ #include "soh/resource/importer/scenecommand/SceneCommandFactory.h" -namespace Ship { +namespace LUS { class SetEchoSettingsFactory : public SceneCommandFactory { public: std::shared_ptr ReadResource(std::shared_ptr resourceMgr, @@ -14,4 +14,4 @@ class SetEchoSettingsFactoryV0 : public SceneCommandVersionFactory { public: void ParseFileBinary(std::shared_ptr reader, std::shared_ptr resource) override; }; -}; // namespace Ship +}; // namespace LUS diff --git a/soh/soh/resource/importer/scenecommand/SetEntranceListFactory.cpp b/soh/soh/resource/importer/scenecommand/SetEntranceListFactory.cpp index 0fcb989c7..e75ccec03 100644 --- a/soh/soh/resource/importer/scenecommand/SetEntranceListFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetEntranceListFactory.cpp @@ -2,7 +2,7 @@ #include "soh/resource/type/scenecommand/SetEntranceList.h" #include "spdlog/spdlog.h" -namespace Ship { +namespace LUS { std::shared_ptr SetEntranceListFactory::ReadResource(std::shared_ptr resourceMgr, std::shared_ptr initData, std::shared_ptr reader) { @@ -25,7 +25,7 @@ std::shared_ptr SetEntranceListFactory::ReadResource(std::shared_ptr reader, +void LUS::SetEntranceListFactoryV0::ParseFileBinary(std::shared_ptr reader, std::shared_ptr resource) { std::shared_ptr setEntranceList = std::static_pointer_cast(resource); ResourceVersionFactory::ParseFileBinary(reader, setEntranceList); @@ -44,4 +44,4 @@ void Ship::SetEntranceListFactoryV0::ParseFileBinary(std::shared_ptr ReadResource(std::shared_ptr resourceMgr, @@ -14,4 +14,4 @@ class SetEntranceListFactoryV0 : public SceneCommandVersionFactory { public: void ParseFileBinary(std::shared_ptr reader, std::shared_ptr resource) override; }; -}; // namespace Ship +}; // namespace LUS diff --git a/soh/soh/resource/importer/scenecommand/SetExitListFactory.cpp b/soh/soh/resource/importer/scenecommand/SetExitListFactory.cpp index a5a033437..ca49e5f18 100644 --- a/soh/soh/resource/importer/scenecommand/SetExitListFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetExitListFactory.cpp @@ -2,7 +2,7 @@ #include "soh/resource/type/scenecommand/SetExitList.h" #include "spdlog/spdlog.h" -namespace Ship { +namespace LUS { std::shared_ptr SetExitListFactory::ReadResource(std::shared_ptr resourceMgr, std::shared_ptr initData, std::shared_ptr reader) { @@ -25,7 +25,7 @@ std::shared_ptr SetExitListFactory::ReadResource(std::shared_ptr reader, +void LUS::SetExitListFactoryV0::ParseFileBinary(std::shared_ptr reader, std::shared_ptr resource) { std::shared_ptr setExitList = std::static_pointer_cast(resource); ResourceVersionFactory::ParseFileBinary(reader, setExitList); @@ -39,4 +39,4 @@ void Ship::SetExitListFactoryV0::ParseFileBinary(std::shared_ptr r } } -} // namespace Ship +} // namespace LUS diff --git a/soh/soh/resource/importer/scenecommand/SetExitListFactory.h b/soh/soh/resource/importer/scenecommand/SetExitListFactory.h index 1cebd4441..05afafbc9 100644 --- a/soh/soh/resource/importer/scenecommand/SetExitListFactory.h +++ b/soh/soh/resource/importer/scenecommand/SetExitListFactory.h @@ -2,7 +2,7 @@ #include "soh/resource/importer/scenecommand/SceneCommandFactory.h" -namespace Ship { +namespace LUS { class SetExitListFactory : public SceneCommandFactory { public: std::shared_ptr ReadResource(std::shared_ptr resourceMgr, @@ -14,4 +14,4 @@ class SetExitListFactoryV0 : public SceneCommandVersionFactory { public: void ParseFileBinary(std::shared_ptr reader, std::shared_ptr resource) override; }; -}; // namespace Ship +}; // namespace LUS diff --git a/soh/soh/resource/importer/scenecommand/SetLightListFactory.cpp b/soh/soh/resource/importer/scenecommand/SetLightListFactory.cpp index 0d47b84b5..9b6aef5b0 100644 --- a/soh/soh/resource/importer/scenecommand/SetLightListFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetLightListFactory.cpp @@ -2,7 +2,7 @@ #include "soh/resource/type/scenecommand/SetLightList.h" #include "spdlog/spdlog.h" -namespace Ship { +namespace LUS { std::shared_ptr SetLightListFactory::ReadResource(std::shared_ptr resourceMgr, std::shared_ptr initData, std::shared_ptr reader) { @@ -26,7 +26,7 @@ std::shared_ptr SetLightListFactory::ReadResource(std::shared_ptr reader, +void LUS::SetLightListFactoryV0::ParseFileBinary(std::shared_ptr reader, std::shared_ptr resource) { std::shared_ptr setLightList = std::static_pointer_cast(resource); @@ -56,4 +56,4 @@ void Ship::SetLightListFactoryV0::ParseFileBinary(std::shared_ptr } } -} // namespace Ship +} // namespace LUS diff --git a/soh/soh/resource/importer/scenecommand/SetLightListFactory.h b/soh/soh/resource/importer/scenecommand/SetLightListFactory.h index 12805c95d..aa4cbeb6c 100644 --- a/soh/soh/resource/importer/scenecommand/SetLightListFactory.h +++ b/soh/soh/resource/importer/scenecommand/SetLightListFactory.h @@ -2,7 +2,7 @@ #include "soh/resource/importer/scenecommand/SceneCommandFactory.h" -namespace Ship { +namespace LUS { class SetLightListFactory : public SceneCommandFactory { public: std::shared_ptr ReadResource(std::shared_ptr resourceMgr, @@ -14,4 +14,4 @@ class SetLightListFactoryV0 : public SceneCommandVersionFactory { public: void ParseFileBinary(std::shared_ptr reader, std::shared_ptr resource) override; }; -}; // namespace Ship +}; // namespace LUS diff --git a/soh/soh/resource/importer/scenecommand/SetLightingSettingsFactory.cpp b/soh/soh/resource/importer/scenecommand/SetLightingSettingsFactory.cpp index 3acf90b4b..9f49d3006 100644 --- a/soh/soh/resource/importer/scenecommand/SetLightingSettingsFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetLightingSettingsFactory.cpp @@ -2,7 +2,7 @@ #include "soh/resource/type/scenecommand/SetLightingSettings.h" #include "spdlog/spdlog.h" -namespace Ship { +namespace LUS { std::shared_ptr SetLightingSettingsFactory::ReadResource(std::shared_ptr resourceMgr, std::shared_ptr initData, std::shared_ptr reader) { @@ -25,7 +25,7 @@ std::shared_ptr SetLightingSettingsFactory::ReadResource(std::shared_p return resource; } -void Ship::SetLightingSettingsFactoryV0::ParseFileBinary(std::shared_ptr reader, +void LUS::SetLightingSettingsFactoryV0::ParseFileBinary(std::shared_ptr reader, std::shared_ptr resource) { std::shared_ptr setLightingSettings = std::static_pointer_cast(resource); @@ -68,4 +68,4 @@ void Ship::SetLightingSettingsFactoryV0::ParseFileBinary(std::shared_ptr ReadResource(std::shared_ptr resourceMgr, @@ -14,4 +14,4 @@ class SetLightingSettingsFactoryV0 : public SceneCommandVersionFactory { public: void ParseFileBinary(std::shared_ptr reader, std::shared_ptr resource) override; }; -}; // namespace Ship +}; // namespace LUS diff --git a/soh/soh/resource/importer/scenecommand/SetMeshFactory.cpp b/soh/soh/resource/importer/scenecommand/SetMeshFactory.cpp index f50393b21..85967739d 100644 --- a/soh/soh/resource/importer/scenecommand/SetMeshFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetMeshFactory.cpp @@ -1,9 +1,9 @@ #include "soh/resource/importer/scenecommand/SetMeshFactory.h" #include "soh/resource/type/scenecommand/SetMesh.h" #include "spdlog/spdlog.h" -#include "libultraship/bridge.h" +#include "libultraship/libultraship.h" -namespace Ship { +namespace LUS { std::shared_ptr SetMeshFactory::ReadResource(std::shared_ptr resourceMgr, std::shared_ptr initData, std::shared_ptr reader) { @@ -27,7 +27,7 @@ std::shared_ptr SetMeshFactory::ReadResource(std::shared_ptr reader, +void LUS::SetMeshFactoryV0::ParseFileBinary(std::shared_ptr reader, std::shared_ptr resource) { std::shared_ptr setMesh = std::static_pointer_cast(resource); @@ -65,8 +65,10 @@ void Ship::SetMeshFactoryV0::ParseFileBinary(std::shared_ptr reade std::string meshOpa = reader->ReadString(); std::string meshXlu = reader->ReadString(); - dlist.opa = meshOpa != "" ? (Gfx*)GetResourceDataByName(meshOpa.c_str(), true) : 0; - dlist.xlu = meshXlu != "" ? (Gfx*)GetResourceDataByName(meshXlu.c_str(), true) : 0; + auto opaRes = LUS::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(meshOpa.c_str()); + auto xluRes = LUS::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(meshXlu.c_str()); + dlist.opa = meshOpa != "" ? (Gfx*)(opaRes ? opaRes->GetPointer() : nullptr) : 0; + dlist.xlu = meshXlu != "" ? (Gfx*)(xluRes ? xluRes->GetPointer() : nullptr) : 0; setMesh->dlists.push_back(dlist); } else if (setMesh->meshHeader.base.type == 1) { @@ -76,8 +78,10 @@ void Ship::SetMeshFactoryV0::ParseFileBinary(std::shared_ptr reade std::string imgOpa = reader->ReadString(); std::string imgXlu = reader->ReadString(); - pType.opa = imgOpa != "" ? (Gfx*)GetResourceDataByName(imgOpa.c_str(), true) : 0; - pType.xlu = imgXlu != "" ? (Gfx*)GetResourceDataByName(imgXlu.c_str(), true) : 0; + auto opaRes = LUS::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(imgOpa.c_str()); + auto xluRes = LUS::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(imgXlu.c_str()); + pType.opa = imgOpa != "" ? (Gfx*)(opaRes ? opaRes->GetPointer() : nullptr) : 0; + pType.xlu = imgXlu != "" ? (Gfx*)(xluRes ? xluRes->GetPointer() : nullptr) : 0; int32_t bgImageCount = reader->ReadUInt32(); setMesh->images.reserve(bgImageCount); @@ -122,8 +126,10 @@ void Ship::SetMeshFactoryV0::ParseFileBinary(std::shared_ptr reade std::string meshOpa = reader->ReadString(); std::string meshXlu = reader->ReadString(); - pType.opa = meshOpa != "" ? (Gfx*)GetResourceDataByName(meshOpa.c_str(), true) : 0; - pType.xlu = meshXlu != "" ? (Gfx*)GetResourceDataByName(meshXlu.c_str(), true) : 0; + opaRes = LUS::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(meshOpa.c_str()); + xluRes = LUS::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(meshXlu.c_str()); + pType.opa = meshOpa != "" ? (Gfx*)(opaRes ? opaRes->GetPointer() : nullptr) : 0; + pType.xlu = meshXlu != "" ? (Gfx*)(xluRes ? xluRes->GetPointer() : nullptr) : 0; setMesh->dlists.push_back(pType); } else if (setMesh->meshHeader.base.type == 2) { @@ -138,8 +144,10 @@ void Ship::SetMeshFactoryV0::ParseFileBinary(std::shared_ptr reade std::string meshOpa = reader->ReadString(); std::string meshXlu = reader->ReadString(); - dlist.opa = meshOpa != "" ? (Gfx*)GetResourceDataByName(meshOpa.c_str(), true) : 0; - dlist.xlu = meshXlu != "" ? (Gfx*)GetResourceDataByName(meshXlu.c_str(), true) : 0; + auto opaRes = LUS::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(meshOpa.c_str()); + auto xluRes = LUS::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(meshXlu.c_str()); + dlist.opa = meshOpa != "" ? (Gfx*)(opaRes ? opaRes->GetPointer() : nullptr) : 0; + dlist.xlu = meshXlu != "" ? (Gfx*)(xluRes ? xluRes->GetPointer() : nullptr) : 0; setMesh->dlists2.push_back(dlist); } else { @@ -159,4 +167,4 @@ void Ship::SetMeshFactoryV0::ParseFileBinary(std::shared_ptr reade } } -} // namespace Ship +} // namespace LUS diff --git a/soh/soh/resource/importer/scenecommand/SetMeshFactory.h b/soh/soh/resource/importer/scenecommand/SetMeshFactory.h index 4ba2d91b4..17eac6437 100644 --- a/soh/soh/resource/importer/scenecommand/SetMeshFactory.h +++ b/soh/soh/resource/importer/scenecommand/SetMeshFactory.h @@ -2,7 +2,7 @@ #include "soh/resource/importer/scenecommand/SceneCommandFactory.h" -namespace Ship { +namespace LUS { class SetMeshFactory : public SceneCommandFactory { public: std::shared_ptr ReadResource(std::shared_ptr resourceMgr, @@ -14,4 +14,4 @@ class SetMeshFactoryV0 : public SceneCommandVersionFactory { public: void ParseFileBinary(std::shared_ptr reader, std::shared_ptr resource) override; }; -}; // namespace Ship +}; // namespace LUS diff --git a/soh/soh/resource/importer/scenecommand/SetObjectListFactory.cpp b/soh/soh/resource/importer/scenecommand/SetObjectListFactory.cpp index d9a8a83f0..9a4801dae 100644 --- a/soh/soh/resource/importer/scenecommand/SetObjectListFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetObjectListFactory.cpp @@ -2,7 +2,7 @@ #include "soh/resource/type/scenecommand/SetObjectList.h" #include "spdlog/spdlog.h" -namespace Ship { +namespace LUS { std::shared_ptr SetObjectListFactory::ReadResource(std::shared_ptr resourceMgr, std::shared_ptr initData, std::shared_ptr reader) { @@ -25,7 +25,7 @@ std::shared_ptr SetObjectListFactory::ReadResource(std::shared_ptr reader, +void LUS::SetObjectListFactoryV0::ParseFileBinary(std::shared_ptr reader, std::shared_ptr resource) { std::shared_ptr setObjectList = std::static_pointer_cast(resource); @@ -40,4 +40,4 @@ void Ship::SetObjectListFactoryV0::ParseFileBinary(std::shared_ptr } } -} // namespace Ship +} // namespace LUS diff --git a/soh/soh/resource/importer/scenecommand/SetObjectListFactory.h b/soh/soh/resource/importer/scenecommand/SetObjectListFactory.h index c6e21d741..d0cc1ee6f 100644 --- a/soh/soh/resource/importer/scenecommand/SetObjectListFactory.h +++ b/soh/soh/resource/importer/scenecommand/SetObjectListFactory.h @@ -2,7 +2,7 @@ #include "soh/resource/importer/scenecommand/SceneCommandFactory.h" -namespace Ship { +namespace LUS { class SetObjectListFactory : public SceneCommandFactory { public: std::shared_ptr ReadResource(std::shared_ptr resourceMgr, @@ -14,4 +14,4 @@ class SetObjectListFactoryV0 : public SceneCommandVersionFactory { public: void ParseFileBinary(std::shared_ptr reader, std::shared_ptr resource) override; }; -}; // namespace Ship +}; // namespace LUS diff --git a/soh/soh/resource/importer/scenecommand/SetPathwaysFactory.cpp b/soh/soh/resource/importer/scenecommand/SetPathwaysFactory.cpp index 8e0c858da..8425e1e97 100644 --- a/soh/soh/resource/importer/scenecommand/SetPathwaysFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetPathwaysFactory.cpp @@ -1,9 +1,9 @@ #include "soh/resource/importer/scenecommand/SetPathwaysFactory.h" #include "soh/resource/type/scenecommand/SetPathways.h" #include "spdlog/spdlog.h" -#include +#include -namespace Ship { +namespace LUS { std::shared_ptr SetPathwaysFactory::ReadResource(std::shared_ptr resourceMgr, std::shared_ptr initData, std::shared_ptr reader) { @@ -26,7 +26,7 @@ std::shared_ptr SetPathwaysFactory::ReadResource(std::shared_ptr reader, +void LUS::SetPathwaysFactoryV0::ParseFileBinary(std::shared_ptr reader, std::shared_ptr resource) { std::shared_ptr setPathways = std::static_pointer_cast(resource); ResourceVersionFactory::ParseFileBinary(reader, setPathways); @@ -37,8 +37,8 @@ void Ship::SetPathwaysFactoryV0::ParseFileBinary(std::shared_ptr r setPathways->paths.reserve(setPathways->numPaths); for (uint32_t i = 0; i < setPathways->numPaths; i++) { std::string pathFileName = reader->ReadString(); - setPathways->paths.push_back(std::static_pointer_cast(LoadResource(pathFileName.c_str(), true))); + setPathways->paths.push_back(std::static_pointer_cast(LUS::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(pathFileName.c_str()))); } } -} // namespace Ship +} // namespace LUS diff --git a/soh/soh/resource/importer/scenecommand/SetPathwaysFactory.h b/soh/soh/resource/importer/scenecommand/SetPathwaysFactory.h index c1f1d4479..aa7b8a8a4 100644 --- a/soh/soh/resource/importer/scenecommand/SetPathwaysFactory.h +++ b/soh/soh/resource/importer/scenecommand/SetPathwaysFactory.h @@ -2,7 +2,7 @@ #include "soh/resource/importer/scenecommand/SceneCommandFactory.h" -namespace Ship { +namespace LUS { class SetPathwaysFactory : public SceneCommandFactory { public: std::shared_ptr ReadResource(std::shared_ptr resourceMgr, @@ -14,4 +14,4 @@ class SetPathwaysFactoryV0 : public SceneCommandVersionFactory { public: void ParseFileBinary(std::shared_ptr reader, std::shared_ptr resource) override; }; -}; // namespace Ship +}; // namespace LUS diff --git a/soh/soh/resource/importer/scenecommand/SetRoomBehaviorFactory.cpp b/soh/soh/resource/importer/scenecommand/SetRoomBehaviorFactory.cpp index 1f87c58a3..4fde10745 100644 --- a/soh/soh/resource/importer/scenecommand/SetRoomBehaviorFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetRoomBehaviorFactory.cpp @@ -2,7 +2,7 @@ #include "soh/resource/type/scenecommand/SetRoomBehavior.h" #include "spdlog/spdlog.h" -namespace Ship { +namespace LUS { std::shared_ptr SetRoomBehaviorFactory::ReadResource(std::shared_ptr resourceMgr, std::shared_ptr initData, std::shared_ptr reader) { @@ -25,7 +25,7 @@ std::shared_ptr SetRoomBehaviorFactory::ReadResource(std::shared_ptr reader, +void LUS::SetRoomBehaviorFactoryV0::ParseFileBinary(std::shared_ptr reader, std::shared_ptr resource) { std::shared_ptr setRoomBehavior = std::static_pointer_cast(resource); ResourceVersionFactory::ParseFileBinary(reader, setRoomBehavior); @@ -36,4 +36,4 @@ void Ship::SetRoomBehaviorFactoryV0::ParseFileBinary(std::shared_ptrroomBehavior.gameplayFlags2 = reader->ReadInt32(); } -} // namespace Ship +} // namespace LUS diff --git a/soh/soh/resource/importer/scenecommand/SetRoomBehaviorFactory.h b/soh/soh/resource/importer/scenecommand/SetRoomBehaviorFactory.h index 947663dda..9478f2125 100644 --- a/soh/soh/resource/importer/scenecommand/SetRoomBehaviorFactory.h +++ b/soh/soh/resource/importer/scenecommand/SetRoomBehaviorFactory.h @@ -2,7 +2,7 @@ #include "soh/resource/importer/scenecommand/SceneCommandFactory.h" -namespace Ship { +namespace LUS { class SetRoomBehaviorFactory : public SceneCommandFactory { public: std::shared_ptr ReadResource(std::shared_ptr resourceMgr, @@ -14,4 +14,4 @@ class SetRoomBehaviorFactoryV0 : public SceneCommandVersionFactory { public: void ParseFileBinary(std::shared_ptr reader, std::shared_ptr resource) override; }; -}; // namespace Ship +}; // namespace LUS diff --git a/soh/soh/resource/importer/scenecommand/SetRoomListFactory.cpp b/soh/soh/resource/importer/scenecommand/SetRoomListFactory.cpp index 67d6306ce..6f949380d 100644 --- a/soh/soh/resource/importer/scenecommand/SetRoomListFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetRoomListFactory.cpp @@ -2,7 +2,7 @@ #include "soh/resource/type/scenecommand/SetRoomList.h" #include "spdlog/spdlog.h" -namespace Ship { +namespace LUS { std::shared_ptr SetRoomListFactory::ReadResource(std::shared_ptr resourceMgr, std::shared_ptr initData, std::shared_ptr reader) { @@ -26,7 +26,7 @@ std::shared_ptr SetRoomListFactory::ReadResource(std::shared_ptr reader, +void LUS::SetRoomListFactoryV0::ParseFileBinary(std::shared_ptr reader, std::shared_ptr resource) { std::shared_ptr setRoomList = std::static_pointer_cast(resource); ResourceVersionFactory::ParseFileBinary(reader, setRoomList); @@ -48,4 +48,4 @@ void Ship::SetRoomListFactoryV0::ParseFileBinary(std::shared_ptr r } } -} // namespace Ship +} // namespace LUS diff --git a/soh/soh/resource/importer/scenecommand/SetRoomListFactory.h b/soh/soh/resource/importer/scenecommand/SetRoomListFactory.h index 19bc785de..993835fcd 100644 --- a/soh/soh/resource/importer/scenecommand/SetRoomListFactory.h +++ b/soh/soh/resource/importer/scenecommand/SetRoomListFactory.h @@ -2,7 +2,7 @@ #include "soh/resource/importer/scenecommand/SceneCommandFactory.h" -namespace Ship { +namespace LUS { class SetRoomListFactory : public SceneCommandFactory { public: std::shared_ptr ReadResource(std::shared_ptr resourceMgr, @@ -14,4 +14,4 @@ class SetRoomListFactoryV0 : public SceneCommandVersionFactory { public: void ParseFileBinary(std::shared_ptr reader, std::shared_ptr resource) override; }; -}; // namespace Ship +}; // namespace LUS diff --git a/soh/soh/resource/importer/scenecommand/SetSkyboxModifierFactory.cpp b/soh/soh/resource/importer/scenecommand/SetSkyboxModifierFactory.cpp index a7454d790..27946c4ec 100644 --- a/soh/soh/resource/importer/scenecommand/SetSkyboxModifierFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetSkyboxModifierFactory.cpp @@ -2,7 +2,7 @@ #include "soh/resource/type/scenecommand/SetSkyboxModifier.h" #include "spdlog/spdlog.h" -namespace Ship { +namespace LUS { std::shared_ptr SetSkyboxModifierFactory::ReadResource(std::shared_ptr resourceMgr, std::shared_ptr initData, std::shared_ptr reader) { @@ -25,7 +25,7 @@ std::shared_ptr SetSkyboxModifierFactory::ReadResource(std::shared_ptr return resource; } -void Ship::SetSkyboxModifierFactoryV0::ParseFileBinary(std::shared_ptr reader, +void LUS::SetSkyboxModifierFactoryV0::ParseFileBinary(std::shared_ptr reader, std::shared_ptr resource) { std::shared_ptr setSkyboxModifier = std::static_pointer_cast(resource); ResourceVersionFactory::ParseFileBinary(reader, setSkyboxModifier); @@ -36,4 +36,4 @@ void Ship::SetSkyboxModifierFactoryV0::ParseFileBinary(std::shared_ptrmodifier.sunMoonDisabled = reader->ReadInt8(); } -} // namespace Ship +} // namespace LUS diff --git a/soh/soh/resource/importer/scenecommand/SetSkyboxModifierFactory.h b/soh/soh/resource/importer/scenecommand/SetSkyboxModifierFactory.h index 40d7db4c6..d2089956a 100644 --- a/soh/soh/resource/importer/scenecommand/SetSkyboxModifierFactory.h +++ b/soh/soh/resource/importer/scenecommand/SetSkyboxModifierFactory.h @@ -2,7 +2,7 @@ #include "soh/resource/importer/scenecommand/SceneCommandFactory.h" -namespace Ship { +namespace LUS { class SetSkyboxModifierFactory : public SceneCommandFactory { public: std::shared_ptr ReadResource(std::shared_ptr resourceMgr, @@ -14,4 +14,4 @@ class SetSkyboxModifierFactoryV0 : public SceneCommandVersionFactory { public: void ParseFileBinary(std::shared_ptr reader, std::shared_ptr resource) override; }; -}; // namespace Ship +}; // namespace LUS diff --git a/soh/soh/resource/importer/scenecommand/SetSkyboxSettingsFactory.cpp b/soh/soh/resource/importer/scenecommand/SetSkyboxSettingsFactory.cpp index c62ae7eb6..4049b333d 100644 --- a/soh/soh/resource/importer/scenecommand/SetSkyboxSettingsFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetSkyboxSettingsFactory.cpp @@ -2,7 +2,7 @@ #include "soh/resource/type/scenecommand/SetSkyboxSettings.h" #include "spdlog/spdlog.h" -namespace Ship { +namespace LUS { std::shared_ptr SetSkyboxSettingsFactory::ReadResource(std::shared_ptr resourceMgr, std::shared_ptr initData, std::shared_ptr reader) { @@ -38,4 +38,4 @@ void SetSkyboxSettingsFactoryV0::ParseFileBinary(std::shared_ptr r setSkyboxSettings->settings.indoors = reader->ReadInt8(); } -} // namespace Ship +} // namespace LUS diff --git a/soh/soh/resource/importer/scenecommand/SetSkyboxSettingsFactory.h b/soh/soh/resource/importer/scenecommand/SetSkyboxSettingsFactory.h index 278e38dbb..e91b59b2e 100644 --- a/soh/soh/resource/importer/scenecommand/SetSkyboxSettingsFactory.h +++ b/soh/soh/resource/importer/scenecommand/SetSkyboxSettingsFactory.h @@ -2,7 +2,7 @@ #include "soh/resource/importer/scenecommand/SceneCommandFactory.h" -namespace Ship { +namespace LUS { class SetSkyboxSettingsFactory : public SceneCommandFactory { public: std::shared_ptr ReadResource(std::shared_ptr resourceMgr, @@ -14,4 +14,4 @@ class SetSkyboxSettingsFactoryV0 : public SceneCommandVersionFactory { public: void ParseFileBinary(std::shared_ptr reader, std::shared_ptr resource) override; }; -}; // namespace Ship +}; // namespace LUS diff --git a/soh/soh/resource/importer/scenecommand/SetSoundSettingsFactory.cpp b/soh/soh/resource/importer/scenecommand/SetSoundSettingsFactory.cpp index 5567a2041..195da1e79 100644 --- a/soh/soh/resource/importer/scenecommand/SetSoundSettingsFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetSoundSettingsFactory.cpp @@ -2,7 +2,7 @@ #include "soh/resource/type/scenecommand/SetSoundSettings.h" #include "spdlog/spdlog.h" -namespace Ship { +namespace LUS { std::shared_ptr SetSoundSettingsFactory::ReadResource(std::shared_ptr resourceMgr, std::shared_ptr initData, std::shared_ptr reader) { @@ -25,7 +25,7 @@ std::shared_ptr SetSoundSettingsFactory::ReadResource(std::shared_ptr< return resource; } -void Ship::SetSoundSettingsFactoryV0::ParseFileBinary(std::shared_ptr reader, +void LUS::SetSoundSettingsFactoryV0::ParseFileBinary(std::shared_ptr reader, std::shared_ptr resource) { std::shared_ptr setSoundSettings = std::static_pointer_cast(resource); ResourceVersionFactory::ParseFileBinary(reader, setSoundSettings); @@ -37,4 +37,4 @@ void Ship::SetSoundSettingsFactoryV0::ParseFileBinary(std::shared_ptrsettings.seqId = reader->ReadInt8(); } -} // namespace Ship +} // namespace LUS diff --git a/soh/soh/resource/importer/scenecommand/SetSoundSettingsFactory.h b/soh/soh/resource/importer/scenecommand/SetSoundSettingsFactory.h index 085ffd410..324e2a835 100644 --- a/soh/soh/resource/importer/scenecommand/SetSoundSettingsFactory.h +++ b/soh/soh/resource/importer/scenecommand/SetSoundSettingsFactory.h @@ -2,7 +2,7 @@ #include "soh/resource/importer/scenecommand/SceneCommandFactory.h" -namespace Ship { +namespace LUS { class SetSoundSettingsFactory : public SceneCommandFactory { public: std::shared_ptr ReadResource(std::shared_ptr resourceMgr, @@ -14,4 +14,4 @@ class SetSoundSettingsFactoryV0 : public SceneCommandVersionFactory { public: void ParseFileBinary(std::shared_ptr reader, std::shared_ptr resource) override; }; -}; // namespace Ship +}; // namespace LUS diff --git a/soh/soh/resource/importer/scenecommand/SetSpecialObjectsFactory.cpp b/soh/soh/resource/importer/scenecommand/SetSpecialObjectsFactory.cpp index 4fe6589b6..240fd2532 100644 --- a/soh/soh/resource/importer/scenecommand/SetSpecialObjectsFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetSpecialObjectsFactory.cpp @@ -2,7 +2,7 @@ #include "soh/resource/type/scenecommand/SetSpecialObjects.h" #include "spdlog/spdlog.h" -namespace Ship { +namespace LUS { std::shared_ptr SetSpecialObjectsFactory::ReadResource(std::shared_ptr resourceMgr, std::shared_ptr initData, std::shared_ptr reader) { @@ -25,7 +25,7 @@ std::shared_ptr SetSpecialObjectsFactory::ReadResource(std::shared_ptr return resource; } -void Ship::SetSpecialObjectsFactoryV0::ParseFileBinary(std::shared_ptr reader, +void LUS::SetSpecialObjectsFactoryV0::ParseFileBinary(std::shared_ptr reader, std::shared_ptr resource) { std::shared_ptr setSpecialObjects = std::static_pointer_cast(resource); ResourceVersionFactory::ParseFileBinary(reader, setSpecialObjects); @@ -36,4 +36,4 @@ void Ship::SetSpecialObjectsFactoryV0::ParseFileBinary(std::shared_ptrspecialObjects.globalObject = reader->ReadInt16(); } -} // namespace Ship +} // namespace LUS diff --git a/soh/soh/resource/importer/scenecommand/SetSpecialObjectsFactory.h b/soh/soh/resource/importer/scenecommand/SetSpecialObjectsFactory.h index e9ac975ca..41d68fd42 100644 --- a/soh/soh/resource/importer/scenecommand/SetSpecialObjectsFactory.h +++ b/soh/soh/resource/importer/scenecommand/SetSpecialObjectsFactory.h @@ -2,7 +2,7 @@ #include "soh/resource/importer/scenecommand/SceneCommandFactory.h" -namespace Ship { +namespace LUS { class SetSpecialObjectsFactory : public SceneCommandFactory { public: std::shared_ptr ReadResource(std::shared_ptr resourceMgr, @@ -14,4 +14,4 @@ class SetSpecialObjectsFactoryV0 : public SceneCommandVersionFactory { public: void ParseFileBinary(std::shared_ptr reader, std::shared_ptr resource) override; }; -}; // namespace Ship +}; // namespace LUS diff --git a/soh/soh/resource/importer/scenecommand/SetStartPositionListFactory.cpp b/soh/soh/resource/importer/scenecommand/SetStartPositionListFactory.cpp index 42b767613..a763fa780 100644 --- a/soh/soh/resource/importer/scenecommand/SetStartPositionListFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetStartPositionListFactory.cpp @@ -2,7 +2,7 @@ #include "soh/resource/type/scenecommand/SetStartPositionList.h" #include "spdlog/spdlog.h" -namespace Ship { +namespace LUS { std::shared_ptr SetStartPositionListFactory::ReadResource(std::shared_ptr resourceMgr, std::shared_ptr initData, std::shared_ptr reader) { @@ -27,7 +27,7 @@ std::shared_ptr SetStartPositionListFactory::ReadResource(std::shared_ return resource; } -void Ship::SetStartPositionListFactoryV0::ParseFileBinary(std::shared_ptr reader, +void LUS::SetStartPositionListFactoryV0::ParseFileBinary(std::shared_ptr reader, std::shared_ptr resource) { std::shared_ptr setStartPositionList = std::static_pointer_cast(resource); @@ -53,4 +53,4 @@ void Ship::SetStartPositionListFactoryV0::ParseFileBinary(std::shared_ptr ReadResource(std::shared_ptr resourceMgr, @@ -14,4 +14,4 @@ class SetStartPositionListFactoryV0 : public SceneCommandVersionFactory { public: void ParseFileBinary(std::shared_ptr reader, std::shared_ptr resource) override; }; -}; // namespace Ship +}; // namespace LUS diff --git a/soh/soh/resource/importer/scenecommand/SetTimeSettingsFactory.cpp b/soh/soh/resource/importer/scenecommand/SetTimeSettingsFactory.cpp index 63c7d9b29..dd7fbf8e2 100644 --- a/soh/soh/resource/importer/scenecommand/SetTimeSettingsFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetTimeSettingsFactory.cpp @@ -2,7 +2,7 @@ #include "soh/resource/type/scenecommand/SetTimeSettings.h" #include "spdlog/spdlog.h" -namespace Ship { +namespace LUS { std::shared_ptr SetTimeSettingsFactory::ReadResource(std::shared_ptr resourceMgr, std::shared_ptr initData, std::shared_ptr reader) { @@ -25,7 +25,7 @@ std::shared_ptr SetTimeSettingsFactory::ReadResource(std::shared_ptr reader, +void LUS::SetTimeSettingsFactoryV0::ParseFileBinary(std::shared_ptr reader, std::shared_ptr resource) { std::shared_ptr setTimeSettings = std::static_pointer_cast(resource); ResourceVersionFactory::ParseFileBinary(reader, setTimeSettings); @@ -37,4 +37,4 @@ void Ship::SetTimeSettingsFactoryV0::ParseFileBinary(std::shared_ptrsettings.timeIncrement = reader->ReadInt8(); } -} // namespace Ship +} // namespace LUS diff --git a/soh/soh/resource/importer/scenecommand/SetTimeSettingsFactory.h b/soh/soh/resource/importer/scenecommand/SetTimeSettingsFactory.h index ddd277d09..4d1964eaf 100644 --- a/soh/soh/resource/importer/scenecommand/SetTimeSettingsFactory.h +++ b/soh/soh/resource/importer/scenecommand/SetTimeSettingsFactory.h @@ -2,7 +2,7 @@ #include "soh/resource/importer/scenecommand/SceneCommandFactory.h" -namespace Ship { +namespace LUS { class SetTimeSettingsFactory : public SceneCommandFactory { public: std::shared_ptr ReadResource(std::shared_ptr resourceMgr, @@ -14,4 +14,4 @@ class SetTimeSettingsFactoryV0 : public SceneCommandVersionFactory { public: void ParseFileBinary(std::shared_ptr reader, std::shared_ptr resource) override; }; -}; // namespace Ship +}; // namespace LUS diff --git a/soh/soh/resource/importer/scenecommand/SetTransitionActorListFactory.cpp b/soh/soh/resource/importer/scenecommand/SetTransitionActorListFactory.cpp index 716e346c0..279129667 100644 --- a/soh/soh/resource/importer/scenecommand/SetTransitionActorListFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetTransitionActorListFactory.cpp @@ -2,7 +2,7 @@ #include "soh/resource/type/scenecommand/SetTransitionActorList.h" #include "spdlog/spdlog.h" -namespace Ship { +namespace LUS { std::shared_ptr SetTransitionActorListFactory::ReadResource(std::shared_ptr resourceMgr, std::shared_ptr initData, std::shared_ptr reader) { @@ -25,7 +25,7 @@ std::shared_ptr SetTransitionActorListFactory::ReadResource(std::share return resource; } -void Ship::SetTransitionActorListFactoryV0::ParseFileBinary(std::shared_ptr reader, +void LUS::SetTransitionActorListFactoryV0::ParseFileBinary(std::shared_ptr reader, std::shared_ptr resource) { std::shared_ptr setTransitionActorList = std::static_pointer_cast(resource); ResourceVersionFactory::ParseFileBinary(reader, setTransitionActorList); @@ -52,4 +52,4 @@ void Ship::SetTransitionActorListFactoryV0::ParseFileBinary(std::shared_ptr ReadResource(std::shared_ptr resourceMgr, @@ -14,4 +14,4 @@ class SetTransitionActorListFactoryV0 : public SceneCommandVersionFactory { public: void ParseFileBinary(std::shared_ptr reader, std::shared_ptr resource) override; }; -}; // namespace Ship +}; // namespace LUS diff --git a/soh/soh/resource/importer/scenecommand/SetWindSettingsFactory.cpp b/soh/soh/resource/importer/scenecommand/SetWindSettingsFactory.cpp index f43e7558b..6b6f5fc87 100644 --- a/soh/soh/resource/importer/scenecommand/SetWindSettingsFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetWindSettingsFactory.cpp @@ -2,7 +2,7 @@ #include "soh/resource/type/scenecommand/SetWindSettings.h" #include "spdlog/spdlog.h" -namespace Ship { +namespace LUS { std::shared_ptr SetWindSettingsFactory::ReadResource(std::shared_ptr resourceMgr, std::shared_ptr initData, std::shared_ptr reader) { @@ -25,7 +25,7 @@ std::shared_ptr SetWindSettingsFactory::ReadResource(std::shared_ptr reader, +void LUS::SetWindSettingsFactoryV0::ParseFileBinary(std::shared_ptr reader, std::shared_ptr resource) { std::shared_ptr setWind = std::static_pointer_cast(resource); ResourceVersionFactory::ParseFileBinary(reader, setWind); @@ -38,4 +38,4 @@ void Ship::SetWindSettingsFactoryV0::ParseFileBinary(std::shared_ptrsettings.windSpeed = reader->ReadUByte(); } -} // namespace Ship +} // namespace LUS diff --git a/soh/soh/resource/importer/scenecommand/SetWindSettingsFactory.h b/soh/soh/resource/importer/scenecommand/SetWindSettingsFactory.h index 2406ca80e..faad34a44 100644 --- a/soh/soh/resource/importer/scenecommand/SetWindSettingsFactory.h +++ b/soh/soh/resource/importer/scenecommand/SetWindSettingsFactory.h @@ -2,7 +2,7 @@ #include "soh/resource/importer/scenecommand/SceneCommandFactory.h" -namespace Ship { +namespace LUS { class SetWindSettingsFactory : public SceneCommandFactory { public: std::shared_ptr ReadResource(std::shared_ptr resourceMgr, @@ -14,4 +14,4 @@ class SetWindSettingsFactoryV0 : public SceneCommandVersionFactory { public: void ParseFileBinary(std::shared_ptr reader, std::shared_ptr resource) override; }; -}; // namespace Ship +}; // namespace LUS diff --git a/soh/soh/resource/type/Animation.cpp b/soh/soh/resource/type/Animation.cpp index 6f79d09e3..9ffe74ce9 100644 --- a/soh/soh/resource/type/Animation.cpp +++ b/soh/soh/resource/type/Animation.cpp @@ -1,6 +1,6 @@ #include "Animation.h" -namespace Ship { +namespace LUS { void* Animation::GetPointer() { return &animationData; } @@ -18,4 +18,4 @@ size_t Animation::GetPointerSize() { return 0; } } -} // namespace Ship \ No newline at end of file +} // namespace LUS \ No newline at end of file diff --git a/soh/soh/resource/type/Animation.h b/soh/soh/resource/type/Animation.h index ac78b1c25..910b226ed 100644 --- a/soh/soh/resource/type/Animation.h +++ b/soh/soh/resource/type/Animation.h @@ -3,7 +3,7 @@ #include "Resource.h" #include -namespace Ship { +namespace LUS { enum class AnimationType { Normal = 0, Link = 1, @@ -82,4 +82,4 @@ namespace Ship { std::vector transformDataArr; std::vector copyValuesArr; }; -}; // namespace Ship \ No newline at end of file +}; // namespace LUS \ No newline at end of file diff --git a/soh/soh/resource/type/AudioSample.cpp b/soh/soh/resource/type/AudioSample.cpp index d276b7564..d415cb67d 100644 --- a/soh/soh/resource/type/AudioSample.cpp +++ b/soh/soh/resource/type/AudioSample.cpp @@ -1,6 +1,6 @@ #include "AudioSample.h" -namespace Ship { +namespace LUS { void* AudioSample::GetPointer() { return &sample; } @@ -8,4 +8,4 @@ void* AudioSample::GetPointer() { size_t AudioSample::GetPointerSize() { return sizeof(Sample); } -} // namespace Ship \ No newline at end of file +} // namespace LUS \ No newline at end of file diff --git a/soh/soh/resource/type/AudioSample.h b/soh/soh/resource/type/AudioSample.h index 02a9fcb39..608fad810 100644 --- a/soh/soh/resource/type/AudioSample.h +++ b/soh/soh/resource/type/AudioSample.h @@ -5,7 +5,7 @@ #include "Resource.h" #include -namespace Ship { +namespace LUS { typedef struct { /* 0x00 */ uintptr_t start; /* 0x04 */ uintptr_t end; @@ -56,4 +56,4 @@ namespace Ship { uint32_t bookDataCount; std::vector bookData; }; -}; // namespace Ship +}; // namespace LUS diff --git a/soh/soh/resource/type/AudioSequence.cpp b/soh/soh/resource/type/AudioSequence.cpp index 1cfce803f..d16e64e76 100644 --- a/soh/soh/resource/type/AudioSequence.cpp +++ b/soh/soh/resource/type/AudioSequence.cpp @@ -1,6 +1,6 @@ #include "AudioSequence.h" -namespace Ship { +namespace LUS { void* AudioSequence::GetPointer() { return &sequence; @@ -9,4 +9,4 @@ void* AudioSequence::GetPointer() { size_t AudioSequence::GetPointerSize() { return sizeof(Sequence); } -} // namespace Ship +} // namespace LUS diff --git a/soh/soh/resource/type/AudioSequence.h b/soh/soh/resource/type/AudioSequence.h index 6b473fa2e..38bcaebf6 100644 --- a/soh/soh/resource/type/AudioSequence.h +++ b/soh/soh/resource/type/AudioSequence.h @@ -5,7 +5,7 @@ #include "Resource.h" #include -namespace Ship { +namespace LUS { typedef struct { char* seqData; @@ -27,4 +27,4 @@ public: Sequence sequence; std::vector sequenceData; }; -}; // namespace Ship +}; // namespace LUS diff --git a/soh/soh/resource/type/AudioSoundFont.cpp b/soh/soh/resource/type/AudioSoundFont.cpp index 018ff443d..857279573 100644 --- a/soh/soh/resource/type/AudioSoundFont.cpp +++ b/soh/soh/resource/type/AudioSoundFont.cpp @@ -1,6 +1,6 @@ #include "AudioSoundFont.h" -namespace Ship { +namespace LUS { void* AudioSoundFont::GetPointer() { return &soundFont; } @@ -8,4 +8,4 @@ void* AudioSoundFont::GetPointer() { size_t AudioSoundFont::GetPointerSize() { return sizeof(SoundFont); } -} // namespace Ship +} // namespace LUS diff --git a/soh/soh/resource/type/AudioSoundFont.h b/soh/soh/resource/type/AudioSoundFont.h index c679ff912..ace639a93 100644 --- a/soh/soh/resource/type/AudioSoundFont.h +++ b/soh/soh/resource/type/AudioSoundFont.h @@ -6,7 +6,7 @@ #include "soh/resource/type/AudioSample.h" #include -namespace Ship { +namespace LUS { typedef struct { /* 0x0 */ s16 delay; @@ -79,4 +79,4 @@ public: SoundFont soundFont; }; -}; // namespace Ship +}; // namespace LUS diff --git a/soh/soh/resource/type/Background.cpp b/soh/soh/resource/type/Background.cpp index 2d24c0be3..f9379b9c7 100644 --- a/soh/soh/resource/type/Background.cpp +++ b/soh/soh/resource/type/Background.cpp @@ -1,6 +1,6 @@ #include "Background.h" -namespace Ship { +namespace LUS { void* Background::GetPointer() { return Data.data(); } @@ -8,4 +8,4 @@ void* Background::GetPointer() { size_t Background::GetPointerSize() { return Data.size() * sizeof(uint8_t); } -} // namespace Ship +} // namespace LUS diff --git a/soh/soh/resource/type/Background.h b/soh/soh/resource/type/Background.h index a00a0c1c0..96edde32c 100644 --- a/soh/soh/resource/type/Background.h +++ b/soh/soh/resource/type/Background.h @@ -2,7 +2,7 @@ #include "resource/Resource.h" -namespace Ship { +namespace LUS { class Background : public Resource { public: using Resource::Resource; @@ -12,4 +12,4 @@ class Background : public Resource { std::vector Data; }; -}; // namespace Ship +}; // namespace LUS diff --git a/soh/soh/resource/type/CollisionHeader.cpp b/soh/soh/resource/type/CollisionHeader.cpp index dbba77011..87f5e5198 100644 --- a/soh/soh/resource/type/CollisionHeader.cpp +++ b/soh/soh/resource/type/CollisionHeader.cpp @@ -1,6 +1,6 @@ #include "CollisionHeader.h" -namespace Ship { +namespace LUS { void* CollisionHeader::GetPointer() { return &collisionHeaderData; } @@ -8,4 +8,4 @@ void* CollisionHeader::GetPointer() { size_t CollisionHeader::GetPointerSize() { return sizeof(collisionHeaderData); } -} // namespace Ship \ No newline at end of file +} // namespace LUS \ No newline at end of file diff --git a/soh/soh/resource/type/CollisionHeader.h b/soh/soh/resource/type/CollisionHeader.h index 59157f737..b830448b2 100644 --- a/soh/soh/resource/type/CollisionHeader.h +++ b/soh/soh/resource/type/CollisionHeader.h @@ -6,7 +6,7 @@ #include #include "z64math.h" -namespace Ship { +namespace LUS { typedef struct { /* 0x00 */ u16 type; @@ -93,4 +93,4 @@ public: std::vector waterBoxes; }; -}; // namespace Ship +}; // namespace LUS diff --git a/soh/soh/resource/type/Cutscene.cpp b/soh/soh/resource/type/Cutscene.cpp index e1283e4c9..2da9e91bd 100644 --- a/soh/soh/resource/type/Cutscene.cpp +++ b/soh/soh/resource/type/Cutscene.cpp @@ -1,7 +1,7 @@ #include "Cutscene.h" #include -namespace Ship { +namespace LUS { void* Cutscene::GetPointer() { return commands.data(); } @@ -9,4 +9,4 @@ void* Cutscene::GetPointer() { size_t Cutscene::GetPointerSize() { return commands.size() * sizeof(uint32_t); } -} // namespace Ship \ No newline at end of file +} // namespace LUS \ No newline at end of file diff --git a/soh/soh/resource/type/Cutscene.h b/soh/soh/resource/type/Cutscene.h index 30f4d0c61..b392c60e5 100644 --- a/soh/soh/resource/type/Cutscene.h +++ b/soh/soh/resource/type/Cutscene.h @@ -7,7 +7,7 @@ #include "Vec3f.h" #include "Color3b.h" -namespace Ship { +namespace LUS { enum class CutsceneCommands { Cmd00 = 0x0000, @@ -55,7 +55,7 @@ class Cutscene : public Resource { uint32_t endFrame; std::vector commands; }; -} // namespace Ship +} // namespace LUS ///////////// diff --git a/soh/soh/resource/type/Path.cpp b/soh/soh/resource/type/Path.cpp index 0a9e70137..74938307d 100644 --- a/soh/soh/resource/type/Path.cpp +++ b/soh/soh/resource/type/Path.cpp @@ -1,6 +1,6 @@ #include "Path.h" -namespace Ship { +namespace LUS { void* Path::GetPointer() { return pathData.data(); } @@ -8,4 +8,4 @@ void* Path::GetPointer() { size_t Path::GetPointerSize() { return pathData.size() * sizeof(PathData); } -} // namespace Ship +} // namespace LUS diff --git a/soh/soh/resource/type/Path.h b/soh/soh/resource/type/Path.h index 96afabee4..8c5c0d0ee 100644 --- a/soh/soh/resource/type/Path.h +++ b/soh/soh/resource/type/Path.h @@ -6,7 +6,7 @@ #include #include "z64math.h" -namespace Ship { +namespace LUS { typedef struct { /* 0x00 */ u8 count; // number of points in the path @@ -24,4 +24,4 @@ public: std::vector pathData; std::vector> paths; }; -}; // namespace Ship +}; // namespace LUS diff --git a/soh/soh/resource/type/PlayerAnimation.cpp b/soh/soh/resource/type/PlayerAnimation.cpp index d22d2712f..8d15140c2 100644 --- a/soh/soh/resource/type/PlayerAnimation.cpp +++ b/soh/soh/resource/type/PlayerAnimation.cpp @@ -1,7 +1,7 @@ #include "PlayerAnimation.h" #include -namespace Ship { +namespace LUS { void* PlayerAnimation::GetPointer() { return limbRotData.data(); } @@ -9,4 +9,4 @@ void* PlayerAnimation::GetPointer() { size_t PlayerAnimation::GetPointerSize() { return limbRotData.size() * sizeof(int16_t); } -} // namespace Ship \ No newline at end of file +} // namespace LUS \ No newline at end of file diff --git a/soh/soh/resource/type/PlayerAnimation.h b/soh/soh/resource/type/PlayerAnimation.h index 51685360e..cf85729e4 100644 --- a/soh/soh/resource/type/PlayerAnimation.h +++ b/soh/soh/resource/type/PlayerAnimation.h @@ -7,7 +7,7 @@ #include "Vec3f.h" #include "Color3b.h" -namespace Ship { +namespace LUS { class PlayerAnimation : public Resource { public: @@ -18,4 +18,4 @@ class PlayerAnimation : public Resource { std::vector limbRotData; }; -} // namespace Ship \ No newline at end of file +} // namespace LUS \ No newline at end of file diff --git a/soh/soh/resource/type/Scene.cpp b/soh/soh/resource/type/Scene.cpp index 947095480..bfe219e54 100644 --- a/soh/soh/resource/type/Scene.cpp +++ b/soh/soh/resource/type/Scene.cpp @@ -1,6 +1,6 @@ #include "Scene.h" -namespace Ship { +namespace LUS { void* Scene::GetPointer() { // Scene is a special type that requries C++ processing. As such, we return nothing. return nullptr; @@ -9,4 +9,4 @@ void* Scene::GetPointer() { size_t Scene::GetPointerSize() { return 0; } -} // namespace Ship +} // namespace LUS diff --git a/soh/soh/resource/type/Scene.h b/soh/soh/resource/type/Scene.h index fd156b64f..e7bb943cf 100644 --- a/soh/soh/resource/type/Scene.h +++ b/soh/soh/resource/type/Scene.h @@ -7,7 +7,7 @@ #include "scenecommand/SceneCommand.h" #include -namespace Ship { +namespace LUS { class Scene : public Resource { public: @@ -18,4 +18,4 @@ public: std::vector> commands; }; -}; // namespace Ship +}; // namespace LUS diff --git a/soh/soh/resource/type/Skeleton.cpp b/soh/soh/resource/type/Skeleton.cpp index 785b02c78..990ecd333 100644 --- a/soh/soh/resource/type/Skeleton.cpp +++ b/soh/soh/resource/type/Skeleton.cpp @@ -3,7 +3,7 @@ #include "soh/OTRGlobals.h" #include "libultraship/libultraship.h" -namespace Ship { +namespace LUS { void* Skeleton::GetPointer() { return &skeletonData; } @@ -36,9 +36,9 @@ void SkeletonPatcher::RegisterSkeleton(std::string& path, SkelAnime* skelAnime) } // Determine if we're using an alternate skeleton - if (path.starts_with(Ship::Resource::gAltAssetPrefix)) { - info.vanillaSkeletonPath = path.substr(Ship::Resource::gAltAssetPrefix.length(), - path.size() - Ship::Resource::gAltAssetPrefix.length()); + if (path.starts_with(LUS::Resource::gAltAssetPrefix)) { + info.vanillaSkeletonPath = path.substr(LUS::Resource::gAltAssetPrefix.length(), + path.size() - LUS::Resource::gAltAssetPrefix.length()); } else { info.vanillaSkeletonPath = path; } @@ -69,12 +69,12 @@ void SkeletonPatcher::UpdateSkeletons() { for (auto skel : skeletons) { Skeleton* newSkel = - (Skeleton*)OTRGlobals::Instance->context->GetResourceManager() - ->LoadResource((isHD ? Ship::Resource::gAltAssetPrefix : "") + skel.vanillaSkeletonPath, true) + (Skeleton*)LUS::Context::GetInstance()->GetResourceManager() + ->LoadResource((isHD ? LUS::Resource::gAltAssetPrefix : "") + skel.vanillaSkeletonPath, true) .get(); if (newSkel != nullptr) skel.skelAnime->skeleton = newSkel->skeletonData.skeletonHeader.segment; } } -} // namespace Ship +} // namespace LUS diff --git a/soh/soh/resource/type/Skeleton.h b/soh/soh/resource/type/Skeleton.h index e6f7cd91f..aac9c8161 100644 --- a/soh/soh/resource/type/Skeleton.h +++ b/soh/soh/resource/type/Skeleton.h @@ -5,7 +5,7 @@ #include "SkeletonLimb.h" #include -namespace Ship { +namespace LUS { enum class SkeletonType { Normal, @@ -88,4 +88,4 @@ class SkeletonPatcher { }; -} // namespace Ship \ No newline at end of file +} // namespace LUS \ No newline at end of file diff --git a/soh/soh/resource/type/SkeletonLimb.cpp b/soh/soh/resource/type/SkeletonLimb.cpp index dc3244b11..32315ec92 100644 --- a/soh/soh/resource/type/SkeletonLimb.cpp +++ b/soh/soh/resource/type/SkeletonLimb.cpp @@ -1,6 +1,6 @@ #include "SkeletonLimb.h" -namespace Ship { +namespace LUS { void* SkeletonLimb::GetPointer() { return &limbData; } @@ -21,4 +21,4 @@ size_t SkeletonLimb::GetPointerSize() { return 0; } } -} // namespace Ship +} // namespace LUS diff --git a/soh/soh/resource/type/SkeletonLimb.h b/soh/soh/resource/type/SkeletonLimb.h index 536a6a7db..0db219b93 100644 --- a/soh/soh/resource/type/SkeletonLimb.h +++ b/soh/soh/resource/type/SkeletonLimb.h @@ -4,7 +4,7 @@ #include "libultraship/libultra.h" #include "z64math.h" -namespace Ship { +namespace LUS { enum class LimbType { Invalid, Standard, @@ -129,4 +129,4 @@ public: std::vector> skinLimbModifVertexArrays; std::vector> skinLimbModifTransformationArrays; }; -} // namespace Ship \ No newline at end of file +} // namespace LUS \ No newline at end of file diff --git a/soh/soh/resource/type/Text.cpp b/soh/soh/resource/type/Text.cpp index 8fb34ecab..a8469be36 100644 --- a/soh/soh/resource/type/Text.cpp +++ b/soh/soh/resource/type/Text.cpp @@ -1,6 +1,6 @@ #include "Text.h" -namespace Ship { +namespace LUS { void* Text::GetPointer() { return messages.data(); } @@ -8,4 +8,4 @@ void* Text::GetPointer() { size_t Text::GetPointerSize() { return messages.size() * sizeof(MessageEntry); } -} // namespace Ship +} // namespace LUS diff --git a/soh/soh/resource/type/Text.h b/soh/soh/resource/type/Text.h index 8b5c3530d..5458c7135 100644 --- a/soh/soh/resource/type/Text.h +++ b/soh/soh/resource/type/Text.h @@ -5,7 +5,7 @@ #include "Resource.h" #include -namespace Ship { +namespace LUS { // TODO: we've moved away from using classes for this stuff class MessageEntry { @@ -25,4 +25,4 @@ public: std::vector messages; }; -}; // namespace Ship +}; // namespace LUS diff --git a/soh/soh/resource/type/scenecommand/EndMarker.cpp b/soh/soh/resource/type/scenecommand/EndMarker.cpp index fcea5c301..b60fab8ab 100644 --- a/soh/soh/resource/type/scenecommand/EndMarker.cpp +++ b/soh/soh/resource/type/scenecommand/EndMarker.cpp @@ -1,6 +1,6 @@ #include "EndMarker.h" -namespace Ship { +namespace LUS { void* EndMarker::GetPointer() { return &endMarker; } @@ -8,4 +8,4 @@ void* EndMarker::GetPointer() { size_t EndMarker::GetPointerSize() { return sizeof(Marker); } -} // namespace Ship +} // namespace LUS diff --git a/soh/soh/resource/type/scenecommand/EndMarker.h b/soh/soh/resource/type/scenecommand/EndMarker.h index faef8d990..f3954467e 100644 --- a/soh/soh/resource/type/scenecommand/EndMarker.h +++ b/soh/soh/resource/type/scenecommand/EndMarker.h @@ -7,7 +7,7 @@ #include "SceneCommand.h" #include -namespace Ship { +namespace LUS { typedef struct { } Marker; @@ -21,4 +21,4 @@ class EndMarker : public SceneCommand { Marker endMarker; }; -}; // namespace Ship +}; // namespace LUS diff --git a/soh/soh/resource/type/scenecommand/RomFile.h b/soh/soh/resource/type/scenecommand/RomFile.h index 9decec5f1..ebdc3dc3b 100644 --- a/soh/soh/resource/type/scenecommand/RomFile.h +++ b/soh/soh/resource/type/scenecommand/RomFile.h @@ -2,7 +2,7 @@ #include -namespace Ship { +namespace LUS { typedef struct { /* 0x00 */ uintptr_t vromStart; /* 0x04 */ uintptr_t vromEnd; diff --git a/soh/soh/resource/type/scenecommand/SceneCommand.h b/soh/soh/resource/type/scenecommand/SceneCommand.h index 4cab5fca7..353f5d910 100644 --- a/soh/soh/resource/type/scenecommand/SceneCommand.h +++ b/soh/soh/resource/type/scenecommand/SceneCommand.h @@ -6,7 +6,7 @@ #include "Resource.h" #include -namespace Ship { +namespace LUS { enum class SceneCommandID : uint8_t { SetStartPositionList = 0x00, @@ -53,4 +53,4 @@ public: SceneCommandID cmdId; }; -}; // namespace Ship +}; // namespace LUS diff --git a/soh/soh/resource/type/scenecommand/SetActorList.cpp b/soh/soh/resource/type/scenecommand/SetActorList.cpp index 3ab415eb6..4563f9db3 100644 --- a/soh/soh/resource/type/scenecommand/SetActorList.cpp +++ b/soh/soh/resource/type/scenecommand/SetActorList.cpp @@ -1,6 +1,6 @@ #include "SetActorList.h" -namespace Ship { +namespace LUS { void* SetActorList::GetPointer() { return actorList.data(); } @@ -8,4 +8,4 @@ void* SetActorList::GetPointer() { size_t SetActorList::GetPointerSize() { return actorList.size() * sizeof(ActorEntry); } -} // namespace Ship +} // namespace LUS diff --git a/soh/soh/resource/type/scenecommand/SetActorList.h b/soh/soh/resource/type/scenecommand/SetActorList.h index 0612490f0..7f05f88d1 100644 --- a/soh/soh/resource/type/scenecommand/SetActorList.h +++ b/soh/soh/resource/type/scenecommand/SetActorList.h @@ -9,7 +9,7 @@ // #include #include "z64math.h" -namespace Ship { +namespace LUS { typedef struct { /* 0x00 */ s16 id; /* 0x02 */ Vec3s pos; @@ -27,4 +27,4 @@ class SetActorList : public SceneCommand { uint32_t numActors; std::vector actorList; }; -}; // namespace Ship +}; // namespace LUS diff --git a/soh/soh/resource/type/scenecommand/SetAlternateHeaders.cpp b/soh/soh/resource/type/scenecommand/SetAlternateHeaders.cpp index 04538d4b7..15b3c97d4 100644 --- a/soh/soh/resource/type/scenecommand/SetAlternateHeaders.cpp +++ b/soh/soh/resource/type/scenecommand/SetAlternateHeaders.cpp @@ -1,6 +1,6 @@ #include "SetAlternateHeaders.h" -namespace Ship { +namespace LUS { void* SetAlternateHeaders::GetPointer() { // Like Scene, SetAlternateHeader is a special type that is only acted upon in C++. return nullptr; @@ -9,4 +9,4 @@ void* SetAlternateHeaders::GetPointer() { size_t SetAlternateHeaders::GetPointerSize() { return 0; } -} // namespace Ship +} // namespace LUS diff --git a/soh/soh/resource/type/scenecommand/SetAlternateHeaders.h b/soh/soh/resource/type/scenecommand/SetAlternateHeaders.h index a88067a4f..48c7ed915 100644 --- a/soh/soh/resource/type/scenecommand/SetAlternateHeaders.h +++ b/soh/soh/resource/type/scenecommand/SetAlternateHeaders.h @@ -11,7 +11,7 @@ #include -namespace Ship { +namespace LUS { class SetAlternateHeaders : public SceneCommand { public: @@ -23,4 +23,4 @@ class SetAlternateHeaders : public SceneCommand { uint32_t numHeaders; std::vector> headers; }; -}; // namespace Ship +}; // namespace LUS diff --git a/soh/soh/resource/type/scenecommand/SetCameraSettings.cpp b/soh/soh/resource/type/scenecommand/SetCameraSettings.cpp index 05162bbef..f88d9683d 100644 --- a/soh/soh/resource/type/scenecommand/SetCameraSettings.cpp +++ b/soh/soh/resource/type/scenecommand/SetCameraSettings.cpp @@ -1,6 +1,6 @@ #include "SetCameraSettings.h" -namespace Ship { +namespace LUS { void* SetCameraSettings::GetPointer() { return &settings; } @@ -8,4 +8,4 @@ void* SetCameraSettings::GetPointer() { size_t SetCameraSettings::GetPointerSize() { return sizeof(CameraSettings); } -} // namespace Ship +} // namespace LUS diff --git a/soh/soh/resource/type/scenecommand/SetCameraSettings.h b/soh/soh/resource/type/scenecommand/SetCameraSettings.h index 77751b51d..55491ec43 100644 --- a/soh/soh/resource/type/scenecommand/SetCameraSettings.h +++ b/soh/soh/resource/type/scenecommand/SetCameraSettings.h @@ -7,7 +7,7 @@ #include "SceneCommand.h" #include -namespace Ship { +namespace LUS { typedef struct { int8_t cameraMovement; int32_t worldMapArea; @@ -22,4 +22,4 @@ class SetCameraSettings : public SceneCommand { CameraSettings settings; }; -}; // namespace Ship +}; // namespace LUS diff --git a/soh/soh/resource/type/scenecommand/SetCollisionHeader.cpp b/soh/soh/resource/type/scenecommand/SetCollisionHeader.cpp index c8eef0d5c..0f71ac1d9 100644 --- a/soh/soh/resource/type/scenecommand/SetCollisionHeader.cpp +++ b/soh/soh/resource/type/scenecommand/SetCollisionHeader.cpp @@ -1,6 +1,6 @@ #include "SetCollisionHeader.h" -namespace Ship { +namespace LUS { void* SetCollisionHeader::GetPointer() { if (collisionHeader == nullptr) { return nullptr; @@ -14,4 +14,4 @@ size_t SetCollisionHeader::GetPointerSize() { } return collisionHeader->GetPointerSize(); } -} // namespace Ship +} // namespace LUS diff --git a/soh/soh/resource/type/scenecommand/SetCollisionHeader.h b/soh/soh/resource/type/scenecommand/SetCollisionHeader.h index 4013c36f0..34c8466bd 100644 --- a/soh/soh/resource/type/scenecommand/SetCollisionHeader.h +++ b/soh/soh/resource/type/scenecommand/SetCollisionHeader.h @@ -9,7 +9,7 @@ #include "soh/resource/type/CollisionHeader.h" // #include -namespace Ship { +namespace LUS { class SetCollisionHeader : public SceneCommand { public: using SceneCommand::SceneCommand; @@ -21,4 +21,4 @@ class SetCollisionHeader : public SceneCommand { std::shared_ptr collisionHeader; }; -}; // namespace Ship +}; // namespace LUS diff --git a/soh/soh/resource/type/scenecommand/SetCsCamera.cpp b/soh/soh/resource/type/scenecommand/SetCsCamera.cpp index 53b509a3e..1c996adda 100644 --- a/soh/soh/resource/type/scenecommand/SetCsCamera.cpp +++ b/soh/soh/resource/type/scenecommand/SetCsCamera.cpp @@ -1,6 +1,6 @@ #include "SetCsCamera.h" -namespace Ship { +namespace LUS { void* SetCsCamera::GetPointer() { return &csCamera; } @@ -8,4 +8,4 @@ void* SetCsCamera::GetPointer() { size_t SetCsCamera::GetPointerSize() { return sizeof(CsCamera); } -} // namespace Ship +} // namespace LUS diff --git a/soh/soh/resource/type/scenecommand/SetCsCamera.h b/soh/soh/resource/type/scenecommand/SetCsCamera.h index ffe77cb13..b3f1cf860 100644 --- a/soh/soh/resource/type/scenecommand/SetCsCamera.h +++ b/soh/soh/resource/type/scenecommand/SetCsCamera.h @@ -7,7 +7,7 @@ #include "SceneCommand.h" #include -namespace Ship { +namespace LUS { typedef struct { } CsCamera; @@ -21,4 +21,4 @@ class SetCsCamera : public SceneCommand { CsCamera csCamera; }; -}; // namespace Ship +}; // namespace LUS diff --git a/soh/soh/resource/type/scenecommand/SetCutscenes.cpp b/soh/soh/resource/type/scenecommand/SetCutscenes.cpp index 4b571af7b..9dc7e1098 100644 --- a/soh/soh/resource/type/scenecommand/SetCutscenes.cpp +++ b/soh/soh/resource/type/scenecommand/SetCutscenes.cpp @@ -1,6 +1,6 @@ #include "SetCutscenes.h" -namespace Ship { +namespace LUS { void* SetCutscenes::GetPointer() { if (cutscene == nullptr) { return nullptr; @@ -14,4 +14,4 @@ size_t SetCutscenes::GetPointerSize() { } return cutscene->GetPointerSize(); } -} // namespace Ship +} // namespace LUS diff --git a/soh/soh/resource/type/scenecommand/SetCutscenes.h b/soh/soh/resource/type/scenecommand/SetCutscenes.h index c0fa53dcb..98cdbcd54 100644 --- a/soh/soh/resource/type/scenecommand/SetCutscenes.h +++ b/soh/soh/resource/type/scenecommand/SetCutscenes.h @@ -9,7 +9,7 @@ #include "soh/resource/type/Cutscene.h" // #include -namespace Ship { +namespace LUS { class SetCutscenes : public SceneCommand { public: using SceneCommand::SceneCommand; @@ -20,4 +20,4 @@ class SetCutscenes : public SceneCommand { std::string fileName; std::shared_ptr cutscene; }; -}; // namespace Ship +}; // namespace LUS diff --git a/soh/soh/resource/type/scenecommand/SetEchoSettings.cpp b/soh/soh/resource/type/scenecommand/SetEchoSettings.cpp index f13ef97b7..559b807d2 100644 --- a/soh/soh/resource/type/scenecommand/SetEchoSettings.cpp +++ b/soh/soh/resource/type/scenecommand/SetEchoSettings.cpp @@ -1,6 +1,6 @@ #include "SetEchoSettings.h" -namespace Ship { +namespace LUS { void* SetEchoSettings::GetPointer() { return &settings; } @@ -8,4 +8,4 @@ void* SetEchoSettings::GetPointer() { size_t SetEchoSettings::GetPointerSize() { return sizeof(EchoSettings); } -} // namespace Ship +} // namespace LUS diff --git a/soh/soh/resource/type/scenecommand/SetEchoSettings.h b/soh/soh/resource/type/scenecommand/SetEchoSettings.h index 0256f0043..7080d8a59 100644 --- a/soh/soh/resource/type/scenecommand/SetEchoSettings.h +++ b/soh/soh/resource/type/scenecommand/SetEchoSettings.h @@ -7,7 +7,7 @@ #include "SceneCommand.h" #include -namespace Ship { +namespace LUS { typedef struct { int8_t echo; } EchoSettings; @@ -21,4 +21,4 @@ class SetEchoSettings : public SceneCommand { EchoSettings settings; }; -}; // namespace Ship +}; // namespace LUS diff --git a/soh/soh/resource/type/scenecommand/SetEntranceList.cpp b/soh/soh/resource/type/scenecommand/SetEntranceList.cpp index 34b4ae5e1..c12247bbf 100644 --- a/soh/soh/resource/type/scenecommand/SetEntranceList.cpp +++ b/soh/soh/resource/type/scenecommand/SetEntranceList.cpp @@ -1,6 +1,6 @@ #include "SetEntranceList.h" -namespace Ship { +namespace LUS { void* SetEntranceList::GetPointer() { return entrances.data(); } @@ -8,4 +8,4 @@ void* SetEntranceList::GetPointer() { size_t SetEntranceList::GetPointerSize() { return entrances.size() * sizeof(EntranceEntry); } -} // namespace Ship +} // namespace LUS diff --git a/soh/soh/resource/type/scenecommand/SetEntranceList.h b/soh/soh/resource/type/scenecommand/SetEntranceList.h index 790ff7ce3..970e0fb5c 100644 --- a/soh/soh/resource/type/scenecommand/SetEntranceList.h +++ b/soh/soh/resource/type/scenecommand/SetEntranceList.h @@ -8,7 +8,7 @@ #include "SceneCommand.h" #include -namespace Ship { +namespace LUS { typedef struct { /* 0x00 */ u8 spawn; /* 0x01 */ u8 room; @@ -25,4 +25,4 @@ class SetEntranceList : public SceneCommand { std::vector entrances; }; -}; // namespace Ship +}; // namespace LUS diff --git a/soh/soh/resource/type/scenecommand/SetExitList.cpp b/soh/soh/resource/type/scenecommand/SetExitList.cpp index eea06b6c5..b34ea20ee 100644 --- a/soh/soh/resource/type/scenecommand/SetExitList.cpp +++ b/soh/soh/resource/type/scenecommand/SetExitList.cpp @@ -1,6 +1,6 @@ #include "SetExitList.h" -namespace Ship { +namespace LUS { void* SetExitList::GetPointer() { return exits.data(); } @@ -8,4 +8,4 @@ void* SetExitList::GetPointer() { size_t SetExitList::GetPointerSize() { return exits.size() * sizeof(int16_t); } -} // namespace Ship +} // namespace LUS diff --git a/soh/soh/resource/type/scenecommand/SetExitList.h b/soh/soh/resource/type/scenecommand/SetExitList.h index 50b0c1848..b3f7f87c9 100644 --- a/soh/soh/resource/type/scenecommand/SetExitList.h +++ b/soh/soh/resource/type/scenecommand/SetExitList.h @@ -7,7 +7,7 @@ #include "SceneCommand.h" #include -namespace Ship { +namespace LUS { class SetExitList : public SceneCommand { public: using SceneCommand::SceneCommand; @@ -19,4 +19,4 @@ class SetExitList : public SceneCommand { std::vector exits; }; -}; // namespace Ship +}; // namespace LUS diff --git a/soh/soh/resource/type/scenecommand/SetLightList.cpp b/soh/soh/resource/type/scenecommand/SetLightList.cpp index 3ae6c6d0c..0e69c6f42 100644 --- a/soh/soh/resource/type/scenecommand/SetLightList.cpp +++ b/soh/soh/resource/type/scenecommand/SetLightList.cpp @@ -1,6 +1,6 @@ #include "SetLightList.h" -namespace Ship { +namespace LUS { void* SetLightList::GetPointer() { return lightList.data(); } @@ -8,4 +8,4 @@ void* SetLightList::GetPointer() { size_t SetLightList::GetPointerSize() { return lightList.size() * sizeof(LightInfo); } -} // namespace Ship +} // namespace LUS diff --git a/soh/soh/resource/type/scenecommand/SetLightList.h b/soh/soh/resource/type/scenecommand/SetLightList.h index 330e0de30..561f80d06 100644 --- a/soh/soh/resource/type/scenecommand/SetLightList.h +++ b/soh/soh/resource/type/scenecommand/SetLightList.h @@ -8,7 +8,7 @@ #include "SceneCommand.h" #include -namespace Ship { +namespace LUS { typedef struct { /* 0x0 */ s16 x; /* 0x2 */ s16 y; @@ -45,4 +45,4 @@ class SetLightList : public SceneCommand { uint32_t numLights; std::vector lightList; }; -}; // namespace Ship +}; // namespace LUS diff --git a/soh/soh/resource/type/scenecommand/SetLightingSettings.cpp b/soh/soh/resource/type/scenecommand/SetLightingSettings.cpp index 0bf3b852c..b432d03fb 100644 --- a/soh/soh/resource/type/scenecommand/SetLightingSettings.cpp +++ b/soh/soh/resource/type/scenecommand/SetLightingSettings.cpp @@ -1,6 +1,6 @@ #include "SetLightingSettings.h" -namespace Ship { +namespace LUS { void* SetLightingSettings::GetPointer() { return settings.data(); } @@ -8,4 +8,4 @@ void* SetLightingSettings::GetPointer() { size_t SetLightingSettings::GetPointerSize() { return settings.size() * sizeof(EnvLightSettings); } -} // namespace Ship +} // namespace LUS diff --git a/soh/soh/resource/type/scenecommand/SetLightingSettings.h b/soh/soh/resource/type/scenecommand/SetLightingSettings.h index ab96d7287..4bb3b4f4e 100644 --- a/soh/soh/resource/type/scenecommand/SetLightingSettings.h +++ b/soh/soh/resource/type/scenecommand/SetLightingSettings.h @@ -7,7 +7,7 @@ #include "SceneCommand.h" #include -namespace Ship { +namespace LUS { typedef struct { /* 0x00 */ u8 ambientColor[3]; /* 0x03 */ s8 light1Dir[3]; @@ -28,4 +28,4 @@ class SetLightingSettings : public SceneCommand { std::vector settings; }; -}; // namespace Ship +}; // namespace LUS diff --git a/soh/soh/resource/type/scenecommand/SetMesh.cpp b/soh/soh/resource/type/scenecommand/SetMesh.cpp index 3c7c131b2..e041bde9c 100644 --- a/soh/soh/resource/type/scenecommand/SetMesh.cpp +++ b/soh/soh/resource/type/scenecommand/SetMesh.cpp @@ -1,6 +1,6 @@ #include "SetMesh.h" -namespace Ship { +namespace LUS { void* SetMesh::GetPointer() { return &meshHeader; } @@ -8,4 +8,4 @@ void* SetMesh::GetPointer() { size_t SetMesh::GetPointerSize() { return sizeof(MeshHeader); } -} // namespace Ship +} // namespace LUS diff --git a/soh/soh/resource/type/scenecommand/SetMesh.h b/soh/soh/resource/type/scenecommand/SetMesh.h index ad3ddf278..90ec058d5 100644 --- a/soh/soh/resource/type/scenecommand/SetMesh.h +++ b/soh/soh/resource/type/scenecommand/SetMesh.h @@ -8,7 +8,7 @@ #include "libultraship/libultra.h" #include "z64math.h" -namespace Ship { +namespace LUS { typedef struct { /* 0x00 */ u8 type; } PolygonBase; @@ -100,4 +100,4 @@ class SetMesh : public SceneCommand { std::vector images; MeshHeader meshHeader; }; -}; // namespace Ship +}; // namespace LUS diff --git a/soh/soh/resource/type/scenecommand/SetObjectList.cpp b/soh/soh/resource/type/scenecommand/SetObjectList.cpp index df5746668..ea82a630b 100644 --- a/soh/soh/resource/type/scenecommand/SetObjectList.cpp +++ b/soh/soh/resource/type/scenecommand/SetObjectList.cpp @@ -1,6 +1,6 @@ #include "SetObjectList.h" -namespace Ship { +namespace LUS { void* SetObjectList::GetPointer() { return objects.data(); } @@ -8,4 +8,4 @@ void* SetObjectList::GetPointer() { size_t SetObjectList::GetPointerSize() { return objects.size() * sizeof(int16_t); } -} // namespace Ship +} // namespace LUS diff --git a/soh/soh/resource/type/scenecommand/SetObjectList.h b/soh/soh/resource/type/scenecommand/SetObjectList.h index c6afffdda..b411a35e1 100644 --- a/soh/soh/resource/type/scenecommand/SetObjectList.h +++ b/soh/soh/resource/type/scenecommand/SetObjectList.h @@ -8,7 +8,7 @@ #include "SceneCommand.h" #include -namespace Ship { +namespace LUS { class SetObjectList : public SceneCommand { public: using SceneCommand::SceneCommand; @@ -19,4 +19,4 @@ class SetObjectList : public SceneCommand { uint32_t numObjects; std::vector objects; }; -}; // namespace Ship +}; // namespace LUS diff --git a/soh/soh/resource/type/scenecommand/SetPathways.cpp b/soh/soh/resource/type/scenecommand/SetPathways.cpp index f203b8090..952e26677 100644 --- a/soh/soh/resource/type/scenecommand/SetPathways.cpp +++ b/soh/soh/resource/type/scenecommand/SetPathways.cpp @@ -1,11 +1,11 @@ #include "SetPathways.h" -namespace Ship { +namespace LUS { void* SetPathways::GetPointer() { return paths.data(); } size_t SetPathways::GetPointerSize() { - return paths.size() * sizeof(std::shared_ptr); + return paths.size() * sizeof(std::shared_ptr); } -} // namespace Ship +} // namespace LUS diff --git a/soh/soh/resource/type/scenecommand/SetPathways.h b/soh/soh/resource/type/scenecommand/SetPathways.h index 2d8c58a70..c179cf267 100644 --- a/soh/soh/resource/type/scenecommand/SetPathways.h +++ b/soh/soh/resource/type/scenecommand/SetPathways.h @@ -8,7 +8,7 @@ // #include #include "soh/resource/type/Path.h" -namespace Ship { +namespace LUS { class SetPathways : public SceneCommand { public: @@ -18,6 +18,6 @@ class SetPathways : public SceneCommand { size_t GetPointerSize(); uint32_t numPaths; - std::vector> paths; + std::vector> paths; }; -}; // namespace Ship +}; // namespace LUS diff --git a/soh/soh/resource/type/scenecommand/SetRoomBehavior.cpp b/soh/soh/resource/type/scenecommand/SetRoomBehavior.cpp index 4e9c63db6..3afdf54f9 100644 --- a/soh/soh/resource/type/scenecommand/SetRoomBehavior.cpp +++ b/soh/soh/resource/type/scenecommand/SetRoomBehavior.cpp @@ -1,6 +1,6 @@ #include "SetRoomBehavior.h" -namespace Ship { +namespace LUS { void* SetRoomBehavior::GetPointer() { return &roomBehavior; } @@ -8,4 +8,4 @@ void* SetRoomBehavior::GetPointer() { size_t SetRoomBehavior::GetPointerSize() { return sizeof(RoomBehavior); } -} // namespace Ship +} // namespace LUS diff --git a/soh/soh/resource/type/scenecommand/SetRoomBehavior.h b/soh/soh/resource/type/scenecommand/SetRoomBehavior.h index 9e4a1e81c..19a58b2f5 100644 --- a/soh/soh/resource/type/scenecommand/SetRoomBehavior.h +++ b/soh/soh/resource/type/scenecommand/SetRoomBehavior.h @@ -7,7 +7,7 @@ #include "SceneCommand.h" #include -namespace Ship { +namespace LUS { typedef struct { int8_t gameplayFlags; int32_t gameplayFlags2; @@ -22,4 +22,4 @@ class SetRoomBehavior : public SceneCommand { RoomBehavior roomBehavior; }; -}; // namespace Ship +}; // namespace LUS diff --git a/soh/soh/resource/type/scenecommand/SetRoomList.cpp b/soh/soh/resource/type/scenecommand/SetRoomList.cpp index 1bc692461..069492233 100644 --- a/soh/soh/resource/type/scenecommand/SetRoomList.cpp +++ b/soh/soh/resource/type/scenecommand/SetRoomList.cpp @@ -1,6 +1,6 @@ #include "SetRoomList.h" -namespace Ship { +namespace LUS { void* SetRoomList::GetPointer() { return rooms.data(); } @@ -8,4 +8,4 @@ void* SetRoomList::GetPointer() { size_t SetRoomList::GetPointerSize() { return rooms.size() * sizeof(RomFile); } -} // namespace Ship +} // namespace LUS diff --git a/soh/soh/resource/type/scenecommand/SetRoomList.h b/soh/soh/resource/type/scenecommand/SetRoomList.h index 4533620ec..61044a191 100644 --- a/soh/soh/resource/type/scenecommand/SetRoomList.h +++ b/soh/soh/resource/type/scenecommand/SetRoomList.h @@ -10,7 +10,7 @@ #include -namespace Ship { +namespace LUS { // typedef struct { // /* 0x00 */ uintptr_t vromStart; // /* 0x04 */ uintptr_t vromEnd; @@ -29,4 +29,4 @@ class SetRoomList : public SceneCommand { std::vector fileNames; std::vector rooms; }; -}; // namespace Ship +}; // namespace LUS diff --git a/soh/soh/resource/type/scenecommand/SetSkyboxModifier.cpp b/soh/soh/resource/type/scenecommand/SetSkyboxModifier.cpp index 302ac2667..8dee0a9c7 100644 --- a/soh/soh/resource/type/scenecommand/SetSkyboxModifier.cpp +++ b/soh/soh/resource/type/scenecommand/SetSkyboxModifier.cpp @@ -1,6 +1,6 @@ #include "SetSkyboxModifier.h" -namespace Ship { +namespace LUS { void* SetSkyboxModifier::GetPointer() { return &modifier; } @@ -8,4 +8,4 @@ void* SetSkyboxModifier::GetPointer() { size_t SetSkyboxModifier::GetPointerSize() { return sizeof(SkyboxModifier); } -} // namespace Ship +} // namespace LUS diff --git a/soh/soh/resource/type/scenecommand/SetSkyboxModifier.h b/soh/soh/resource/type/scenecommand/SetSkyboxModifier.h index ad4a008c6..8098f9e5c 100644 --- a/soh/soh/resource/type/scenecommand/SetSkyboxModifier.h +++ b/soh/soh/resource/type/scenecommand/SetSkyboxModifier.h @@ -7,7 +7,7 @@ #include "SceneCommand.h" #include -namespace Ship { +namespace LUS { typedef struct { uint8_t skyboxDisabled; uint8_t sunMoonDisabled; @@ -22,4 +22,4 @@ class SetSkyboxModifier : public SceneCommand { SkyboxModifier modifier; }; -}; // namespace Ship +}; // namespace LUS diff --git a/soh/soh/resource/type/scenecommand/SetSkyboxSettings.cpp b/soh/soh/resource/type/scenecommand/SetSkyboxSettings.cpp index 77f7bad88..e8a37e9bd 100644 --- a/soh/soh/resource/type/scenecommand/SetSkyboxSettings.cpp +++ b/soh/soh/resource/type/scenecommand/SetSkyboxSettings.cpp @@ -1,6 +1,6 @@ #include "SetSkyboxSettings.h" -namespace Ship { +namespace LUS { void* SetSkyboxSettings::GetPointer() { return &settings; } @@ -8,4 +8,4 @@ void* SetSkyboxSettings::GetPointer() { size_t SetSkyboxSettings::GetPointerSize() { return sizeof(SetSkyboxSettings); } -} // namespace Ship +} // namespace LUS diff --git a/soh/soh/resource/type/scenecommand/SetSkyboxSettings.h b/soh/soh/resource/type/scenecommand/SetSkyboxSettings.h index aa110b635..97d3694fd 100644 --- a/soh/soh/resource/type/scenecommand/SetSkyboxSettings.h +++ b/soh/soh/resource/type/scenecommand/SetSkyboxSettings.h @@ -7,7 +7,7 @@ #include "SceneCommand.h" #include -namespace Ship { +namespace LUS { typedef struct { uint8_t unk; uint8_t skyboxId; @@ -24,4 +24,4 @@ class SetSkyboxSettings : public SceneCommand { SkyboxSettings settings; }; -}; // namespace Ship +}; // namespace LUS diff --git a/soh/soh/resource/type/scenecommand/SetSoundSettings.cpp b/soh/soh/resource/type/scenecommand/SetSoundSettings.cpp index 2787442e4..1380cf410 100644 --- a/soh/soh/resource/type/scenecommand/SetSoundSettings.cpp +++ b/soh/soh/resource/type/scenecommand/SetSoundSettings.cpp @@ -1,6 +1,6 @@ #include "SetSoundSettings.h" -namespace Ship { +namespace LUS { void* SetSoundSettings::GetPointer() { return &settings; } @@ -8,4 +8,4 @@ void* SetSoundSettings::GetPointer() { size_t SetSoundSettings::GetPointerSize() { return sizeof(SoundSettings); } -} // namespace Ship +} // namespace LUS diff --git a/soh/soh/resource/type/scenecommand/SetSoundSettings.h b/soh/soh/resource/type/scenecommand/SetSoundSettings.h index c2fb20366..3287b4b96 100644 --- a/soh/soh/resource/type/scenecommand/SetSoundSettings.h +++ b/soh/soh/resource/type/scenecommand/SetSoundSettings.h @@ -7,7 +7,7 @@ #include "SceneCommand.h" #include -namespace Ship { +namespace LUS { typedef struct { uint8_t seqId; uint8_t natureAmbienceId; @@ -23,4 +23,4 @@ class SetSoundSettings : public SceneCommand { SoundSettings settings; }; -}; // namespace Ship +}; // namespace LUS diff --git a/soh/soh/resource/type/scenecommand/SetSpecialObjects.cpp b/soh/soh/resource/type/scenecommand/SetSpecialObjects.cpp index 8b7ed90e9..36c2dc7f7 100644 --- a/soh/soh/resource/type/scenecommand/SetSpecialObjects.cpp +++ b/soh/soh/resource/type/scenecommand/SetSpecialObjects.cpp @@ -1,6 +1,6 @@ #include "SetSpecialObjects.h" -namespace Ship { +namespace LUS { void* SetSpecialObjects::GetPointer() { return &specialObjects; } @@ -8,4 +8,4 @@ void* SetSpecialObjects::GetPointer() { size_t SetSpecialObjects::GetPointerSize() { return sizeof(SpecialObjects); } -} // namespace Ship +} // namespace LUS diff --git a/soh/soh/resource/type/scenecommand/SetSpecialObjects.h b/soh/soh/resource/type/scenecommand/SetSpecialObjects.h index a8f30b83b..b1a48f3a2 100644 --- a/soh/soh/resource/type/scenecommand/SetSpecialObjects.h +++ b/soh/soh/resource/type/scenecommand/SetSpecialObjects.h @@ -7,7 +7,7 @@ #include "SceneCommand.h" #include -namespace Ship { +namespace LUS { typedef struct { int8_t elfMessage; int16_t globalObject; @@ -22,4 +22,4 @@ class SetSpecialObjects : public SceneCommand { SpecialObjects specialObjects; }; -}; // namespace Ship +}; // namespace LUS diff --git a/soh/soh/resource/type/scenecommand/SetStartPositionList.cpp b/soh/soh/resource/type/scenecommand/SetStartPositionList.cpp index d162d7e7e..626503791 100644 --- a/soh/soh/resource/type/scenecommand/SetStartPositionList.cpp +++ b/soh/soh/resource/type/scenecommand/SetStartPositionList.cpp @@ -1,6 +1,6 @@ #include "SetStartPositionList.h" -namespace Ship { +namespace LUS { void* SetStartPositionList::GetPointer() { return startPositions.data(); } @@ -8,4 +8,4 @@ void* SetStartPositionList::GetPointer() { size_t SetStartPositionList::GetPointerSize() { return startPositions.size() * sizeof(ActorEntry); } -} // namespace Ship +} // namespace LUS diff --git a/soh/soh/resource/type/scenecommand/SetStartPositionList.h b/soh/soh/resource/type/scenecommand/SetStartPositionList.h index 34e7278b9..4f914b012 100644 --- a/soh/soh/resource/type/scenecommand/SetStartPositionList.h +++ b/soh/soh/resource/type/scenecommand/SetStartPositionList.h @@ -9,7 +9,7 @@ #include "soh/resource/type/scenecommand/SetActorList.h" // #include -namespace Ship { +namespace LUS { // typedef struct { // /* 0x00 */ s16 id; // /* 0x02 */ Vec3s pos; @@ -27,4 +27,4 @@ class SetStartPositionList : public SceneCommand { uint32_t numStartPositions; std::vector startPositions; }; -}; // namespace Ship +}; // namespace LUS diff --git a/soh/soh/resource/type/scenecommand/SetTimeSettings.cpp b/soh/soh/resource/type/scenecommand/SetTimeSettings.cpp index d5b56c39f..bcaa19237 100644 --- a/soh/soh/resource/type/scenecommand/SetTimeSettings.cpp +++ b/soh/soh/resource/type/scenecommand/SetTimeSettings.cpp @@ -1,6 +1,6 @@ #include "SetTimeSettings.h" -namespace Ship { +namespace LUS { void* SetTimeSettings::GetPointer() { return &settings; } @@ -8,4 +8,4 @@ void* SetTimeSettings::GetPointer() { size_t SetTimeSettings::GetPointerSize() { return sizeof(TimeSettings); } -} // namespace Ship +} // namespace LUS diff --git a/soh/soh/resource/type/scenecommand/SetTimeSettings.h b/soh/soh/resource/type/scenecommand/SetTimeSettings.h index 4eccc216a..fdc4338d8 100644 --- a/soh/soh/resource/type/scenecommand/SetTimeSettings.h +++ b/soh/soh/resource/type/scenecommand/SetTimeSettings.h @@ -7,7 +7,7 @@ #include "SceneCommand.h" #include -namespace Ship { +namespace LUS { typedef struct { uint8_t hour; uint8_t minute; @@ -23,4 +23,4 @@ class SetTimeSettings : public SceneCommand { TimeSettings settings; }; -}; // namespace Ship +}; // namespace LUS diff --git a/soh/soh/resource/type/scenecommand/SetTransitionActorList.cpp b/soh/soh/resource/type/scenecommand/SetTransitionActorList.cpp index 7b40b35cc..3cbb4cae6 100644 --- a/soh/soh/resource/type/scenecommand/SetTransitionActorList.cpp +++ b/soh/soh/resource/type/scenecommand/SetTransitionActorList.cpp @@ -1,6 +1,6 @@ #include "SetTransitionActorList.h" -namespace Ship { +namespace LUS { void* SetTransitionActorList::GetPointer() { return transitionActorList.data(); } @@ -8,4 +8,4 @@ void* SetTransitionActorList::GetPointer() { size_t SetTransitionActorList::GetPointerSize() { return transitionActorList.size() * sizeof(TransitionActorEntry); } -} // namespace Ship +} // namespace LUS diff --git a/soh/soh/resource/type/scenecommand/SetTransitionActorList.h b/soh/soh/resource/type/scenecommand/SetTransitionActorList.h index 443499aa3..20eb63c87 100644 --- a/soh/soh/resource/type/scenecommand/SetTransitionActorList.h +++ b/soh/soh/resource/type/scenecommand/SetTransitionActorList.h @@ -9,7 +9,7 @@ // #include #include "z64math.h" -namespace Ship { +namespace LUS { typedef struct { struct { s8 room; // Room to switch to @@ -31,4 +31,4 @@ class SetTransitionActorList : public SceneCommand { uint32_t numTransitionActors; std::vector transitionActorList; }; -}; // namespace Ship +}; // namespace LUS diff --git a/soh/soh/resource/type/scenecommand/SetWindSettings.cpp b/soh/soh/resource/type/scenecommand/SetWindSettings.cpp index 817ef301d..d575b1b69 100644 --- a/soh/soh/resource/type/scenecommand/SetWindSettings.cpp +++ b/soh/soh/resource/type/scenecommand/SetWindSettings.cpp @@ -1,6 +1,6 @@ #include "SetWindSettings.h" -namespace Ship { +namespace LUS { void* SetWindSettings::GetPointer() { return &settings; } @@ -8,4 +8,4 @@ void* SetWindSettings::GetPointer() { size_t SetWindSettings::GetPointerSize() { return sizeof(WindSettings); } -} // namespace Ship +} // namespace LUS diff --git a/soh/soh/resource/type/scenecommand/SetWindSettings.h b/soh/soh/resource/type/scenecommand/SetWindSettings.h index a368fdf44..3a193d1b0 100644 --- a/soh/soh/resource/type/scenecommand/SetWindSettings.h +++ b/soh/soh/resource/type/scenecommand/SetWindSettings.h @@ -7,7 +7,7 @@ #include "SceneCommand.h" #include -namespace Ship { +namespace LUS { typedef struct { int8_t windWest; int8_t windVertical; @@ -24,4 +24,4 @@ class SetWindSettings : public SceneCommand { WindSettings settings; }; -}; // namespace Ship +}; // namespace LUS diff --git a/soh/soh/z_message_OTR.cpp b/soh/soh/z_message_OTR.cpp index 9e06424b9..a11befaa0 100644 --- a/soh/soh/z_message_OTR.cpp +++ b/soh/soh/z_message_OTR.cpp @@ -1,5 +1,5 @@ #include "OTRGlobals.h" -#include +#include #include "soh/resource/type/Scene.h" #include #include "global.h" @@ -16,7 +16,7 @@ extern "C" MessageTableEntry* sStaffMessageEntryTablePtr; //extern "C" MessageTableEntry* _message_0xFFFC_nes; MessageTableEntry* OTRMessage_LoadTable(const char* filePath, bool isNES) { - auto file = std::static_pointer_cast(OTRGlobals::Instance->context->GetResourceManager()->LoadResource(filePath)); + auto file = std::static_pointer_cast(LUS::Context::GetInstance()->GetResourceManager()->LoadResource(filePath)); if (file == nullptr) return nullptr; @@ -92,7 +92,7 @@ extern "C" void OTRMessage_Init() if (sStaffMessageEntryTablePtr == NULL) { auto file2 = - std::static_pointer_cast(OTRGlobals::Instance->context->GetResourceManager()->LoadResource( + std::static_pointer_cast(LUS::Context::GetInstance()->GetResourceManager()->LoadResource( "text/staff_message_data_static/staff_message_data_static")); // OTRTODO: Should not be malloc'ing here. It's fine for now since we check that the message table is already null. sStaffMessageEntryTablePtr = (MessageTableEntry*)malloc(sizeof(MessageTableEntry) * file2->messages.size()); diff --git a/soh/soh/z_play_otr.cpp b/soh/soh/z_play_otr.cpp index 5827e4555..1980e22f8 100644 --- a/soh/soh/z_play_otr.cpp +++ b/soh/soh/z_play_otr.cpp @@ -1,5 +1,5 @@ #include "OTRGlobals.h" -#include +#include #include "soh/resource/type/Scene.h" #include #include "soh/Enhancements/game-interactor/GameInteractor.h" @@ -10,12 +10,12 @@ extern "C" void Play_InitScene(PlayState * play, s32 spawn); extern "C" void Play_InitEnvironment(PlayState * play, s16 skyboxId); void OTRPlay_InitScene(PlayState* play, s32 spawn); -s32 OTRScene_ExecuteCommands(PlayState* play, Ship::Scene* scene); +s32 OTRScene_ExecuteCommands(PlayState* play, LUS::Scene* scene); -//Ship::OTRResource* OTRPlay_LoadFile(PlayState* play, RomFile* file) { -Ship::Resource* OTRPlay_LoadFile(PlayState* play, const char* fileName) +//LUS::OTRResource* OTRPlay_LoadFile(PlayState* play, RomFile* file) { +LUS::Resource* OTRPlay_LoadFile(PlayState* play, const char* fileName) { - auto res = OTRGlobals::Instance->context->GetResourceManager()->LoadResource(fileName); + auto res = LUS::Context::GetInstance()->GetResourceManager()->LoadResource(fileName); return res.get(); } @@ -74,9 +74,9 @@ void OTRPlay_InitScene(PlayState* play, s32 spawn) { func_80096FD4(play, &play->roomCtx.curRoom); YREG(15) = 0; gSaveContext.worldMapArea = 0; - OTRScene_ExecuteCommands(play, (Ship::Scene*)play->sceneSegment); + OTRScene_ExecuteCommands(play, (LUS::Scene*)play->sceneSegment); Play_InitEnvironment(play, play->skyboxId); - /* auto data = static_cast(Ship::Window::GetInstance() + /* auto data = static_cast(LUS::Context::GetInstance() ->GetResourceManager() ->LoadResource("object_link_child\\object_link_childVtx_01FE08") .get()); diff --git a/soh/soh/z_scene_otr.cpp b/soh/soh/z_scene_otr.cpp index 6bcd1f0e2..09dffadd6 100644 --- a/soh/soh/z_scene_otr.cpp +++ b/soh/soh/z_scene_otr.cpp @@ -1,5 +1,5 @@ #include "OTRGlobals.h" -#include +#include #include "soh/resource/type/Scene.h" #include #include "global.h" @@ -33,12 +33,12 @@ #include "soh/resource/type/scenecommand/SetEchoSettings.h" #include "soh/resource/type/scenecommand/SetAlternateHeaders.h" -extern Ship::Resource* OTRPlay_LoadFile(PlayState* play, const char* fileName); +extern LUS::Resource* OTRPlay_LoadFile(PlayState* play, const char* fileName); extern "C" s32 Object_Spawn(ObjectContext* objectCtx, s16 objectId); extern "C" RomFile sNaviMsgFiles[]; -s32 OTRScene_ExecuteCommands(PlayState* play, Ship::Scene* scene); +s32 OTRScene_ExecuteCommands(PlayState* play, LUS::Scene* scene); -std::shared_ptr ResourceMgr_LoadFile(const char* path) { +std::shared_ptr ResourceMgr_LoadFile(const char* path) { std::string Path = path; if (IsGameMasterQuest()) { size_t pos = 0; @@ -46,19 +46,18 @@ std::shared_ptr ResourceMgr_LoadFile(const char* path) { Path.replace(pos, 7, "/mq/"); } } - return OTRGlobals::Instance->context->GetResourceManager()->LoadFile(Path.c_str()); + return LUS::Context::GetInstance()->GetResourceManager()->LoadFile(Path.c_str()); } // Forward Declaration of function declared in OTRGlobals.cpp -std::shared_ptr GetResourceByNameHandlingMQ(const char* path); +std::shared_ptr GetResourceByNameHandlingMQ(const char* path); -bool Scene_CommandSpawnList(PlayState* play, Ship::SceneCommand* cmd) -{ - // Ship::SetStartPositionList* cmdStartPos = std::static_pointer_cast(cmd); - Ship::SetStartPositionList* cmdStartPos = (Ship::SetStartPositionList*)cmd; +bool Scene_CommandSpawnList(PlayState* play, LUS::SceneCommand* cmd) { + // LUS::SetStartPositionList* cmdStartPos = std::static_pointer_cast(cmd); + LUS::SetStartPositionList* cmdStartPos = (LUS::SetStartPositionList*)cmd; ActorEntry* entries = (ActorEntry*)cmdStartPos->GetPointer(); - play->linkActorEntry = &entries[play->setupEntranceList[play->curSpawn].spawn];; + play->linkActorEntry = &entries[play->setupEntranceList[play->curSpawn].spawn]; play->linkAgeOnLoad = ((void)0, gSaveContext.linkAge); s16 linkObjectId = gLinkObjectIds[((void)0, gSaveContext.linkAge)]; @@ -67,9 +66,9 @@ bool Scene_CommandSpawnList(PlayState* play, Ship::SceneCommand* cmd) return false; } -bool Scene_CommandActorList(PlayState* play, Ship::SceneCommand* cmd) { - // Ship::SetActorList* cmdActor = std::static_pointer_cast(cmd); - Ship::SetActorList* cmdActor = (Ship::SetActorList*)cmd; +bool Scene_CommandActorList(PlayState* play, LUS::SceneCommand* cmd) { + // LUS::SetActorList* cmdActor = std::static_pointer_cast(cmd); + LUS::SetActorList* cmdActor = (LUS::SetActorList*)cmd; play->numSetupActors = cmdActor->numActors; play->setupActorList = (ActorEntry*)cmdActor->GetPointer(); @@ -77,27 +76,24 @@ bool Scene_CommandActorList(PlayState* play, Ship::SceneCommand* cmd) { return false; } -bool Scene_CommandUnused2(PlayState* play, Ship::SceneCommand* cmd) -{ +bool Scene_CommandUnused2(PlayState* play, LUS::SceneCommand* cmd) { // OTRTODO: Do we need to implement this? - //play->unk_11DFC = SEGMENTED_TO_VIRTUAL(cmd->unused02.segment); + // play->unk_11DFC = SEGMENTED_TO_VIRTUAL(cmd->unused02.segment); return false; } -bool Scene_CommandCollisionHeader(PlayState* play, Ship::SceneCommand* cmd) -{ - // Ship::SetCollisionHeader* cmdCol = std::static_pointer_cast(cmd); - Ship::SetCollisionHeader* cmdCol = (Ship::SetCollisionHeader*)cmd; +bool Scene_CommandCollisionHeader(PlayState* play, LUS::SceneCommand* cmd) { + // LUS::SetCollisionHeader* cmdCol = std::static_pointer_cast(cmd); + LUS::SetCollisionHeader* cmdCol = (LUS::SetCollisionHeader*)cmd; BgCheck_Allocate(&play->colCtx, play, (CollisionHeader*)cmdCol->GetPointer()); return false; } -bool Scene_CommandRoomList(PlayState* play, Ship::SceneCommand* cmd) -{ - // Ship::SetRoomList* cmdRoomList = std::static_pointer_cast(cmd); - Ship::SetRoomList* cmdRoomList = (Ship::SetRoomList*)cmd; +bool Scene_CommandRoomList(PlayState* play, LUS::SceneCommand* cmd) { + // LUS::SetRoomList* cmdRoomList = std::static_pointer_cast(cmd); + LUS::SetRoomList* cmdRoomList = (LUS::SetRoomList*)cmd; play->numRooms = cmdRoomList->numRooms; play->roomList = (RomFile*)cmdRoomList->GetPointer(); @@ -105,36 +101,34 @@ bool Scene_CommandRoomList(PlayState* play, Ship::SceneCommand* cmd) return false; } -bool Scene_CommandEntranceList(PlayState* play, Ship::SceneCommand* cmd) -{ - // Ship::SetEntranceList* otrEntrance = std::static_pointer_cast(cmd); - Ship::SetEntranceList* otrEntrance = (Ship::SetEntranceList*)cmd; +bool Scene_CommandEntranceList(PlayState* play, LUS::SceneCommand* cmd) { + // LUS::SetEntranceList* otrEntrance = std::static_pointer_cast(cmd); + LUS::SetEntranceList* otrEntrance = (LUS::SetEntranceList*)cmd; play->setupEntranceList = (EntranceEntry*)otrEntrance->GetPointer(); return false; } -bool Scene_CommandSpecialFiles(PlayState* play, Ship::SceneCommand* cmd) -{ - // Ship::SetSpecialObjects* specialCmd = std::static_pointer_cast(cmd); - Ship::SetSpecialObjects* specialCmd = (Ship::SetSpecialObjects*)cmd; +bool Scene_CommandSpecialFiles(PlayState* play, LUS::SceneCommand* cmd) { + // LUS::SetSpecialObjects* specialCmd = std::static_pointer_cast(cmd); + LUS::SetSpecialObjects* specialCmd = (LUS::SetSpecialObjects*)cmd; if (specialCmd->specialObjects.globalObject != 0) { play->objectCtx.subKeepIndex = Object_Spawn(&play->objectCtx, specialCmd->specialObjects.globalObject); } if (specialCmd->specialObjects.elfMessage != 0) { - auto res = (Ship::Blob*)OTRPlay_LoadFile(play, sNaviMsgFiles[specialCmd->specialObjects.elfMessage - 1].fileName); + auto res = + (LUS::Blob*)OTRPlay_LoadFile(play, sNaviMsgFiles[specialCmd->specialObjects.elfMessage - 1].fileName); play->cUpElfMsgs = (ElfMessage*)res->Data.data(); } return false; } -bool Scene_CommandRoomBehavior(PlayState* play, Ship::SceneCommand* cmd) -{ - // Ship::SetRoomBehavior* cmdRoom = std::static_pointer_cast(cmd); - Ship::SetRoomBehavior* cmdRoom = (Ship::SetRoomBehavior*)cmd; +bool Scene_CommandRoomBehavior(PlayState* play, LUS::SceneCommand* cmd) { + // LUS::SetRoomBehavior* cmdRoom = std::static_pointer_cast(cmd); + LUS::SetRoomBehavior* cmdRoom = (LUS::SetRoomBehavior*)cmd; play->roomCtx.curRoom.behaviorType1 = cmdRoom->roomBehavior.gameplayFlags; play->roomCtx.curRoom.behaviorType2 = cmdRoom->roomBehavior.gameplayFlags2 & 0xFF; @@ -144,21 +138,19 @@ bool Scene_CommandRoomBehavior(PlayState* play, Ship::SceneCommand* cmd) return false; } -bool Scene_CommandMeshHeader(PlayState* play, Ship::SceneCommand* cmd) -{ - // Ship::SetMesh* otrMesh = static_pointer_cast(cmd); - Ship::SetMesh* otrMesh = (Ship::SetMesh*)cmd; +bool Scene_CommandMeshHeader(PlayState* play, LUS::SceneCommand* cmd) { + // LUS::SetMesh* otrMesh = static_pointer_cast(cmd); + LUS::SetMesh* otrMesh = (LUS::SetMesh*)cmd; play->roomCtx.curRoom.meshHeader = (MeshHeader*)otrMesh->GetPointer(); return false; } -extern "C" void* func_800982FC(ObjectContext * objectCtx, s32 bankIndex, s16 objectId); +extern "C" void* func_800982FC(ObjectContext* objectCtx, s32 bankIndex, s16 objectId); -bool Scene_CommandObjectList(PlayState* play, Ship::SceneCommand* cmd) -{ - // Ship::SetObjectList* cmdObj = static_pointer_cast(cmd); - Ship::SetObjectList* cmdObj = (Ship::SetObjectList*)cmd; +bool Scene_CommandObjectList(PlayState* play, LUS::SceneCommand* cmd) { + // LUS::SetObjectList* cmdObj = static_pointer_cast(cmd); + LUS::SetObjectList* cmdObj = (LUS::SetObjectList*)cmd; s32 i; s32 j; @@ -166,12 +158,12 @@ bool Scene_CommandObjectList(PlayState* play, Ship::SceneCommand* cmd) ObjectStatus* status; ObjectStatus* status2; ObjectStatus* firstStatus; - //s16* objectEntry = SEGMENTED_TO_VIRTUAL(cmd->objectList.segment); + // s16* objectEntry = SEGMENTED_TO_VIRTUAL(cmd->objectList.segment); s16* objectEntry = (s16*)cmdObj->GetPointer(); void* nextPtr; k = 0; - //i = play->objectCtx.unk_09; + // i = play->objectCtx.unk_09; i = 0; firstStatus = &play->objectCtx.status[0]; status = &play->objectCtx.status[i]; @@ -218,31 +210,28 @@ bool Scene_CommandObjectList(PlayState* play, Ship::SceneCommand* cmd) return false; } -bool Scene_CommandLightList(PlayState* play, Ship::SceneCommand* cmd) -{ - // Ship::SetLightList* cmdLight = static_pointer_cast(cmd); - Ship::SetLightList* cmdLight = (Ship::SetLightList*)cmd; +bool Scene_CommandLightList(PlayState* play, LUS::SceneCommand* cmd) { + // LUS::SetLightList* cmdLight = static_pointer_cast(cmd); + LUS::SetLightList* cmdLight = (LUS::SetLightList*)cmd; - for (size_t i = 0; i < cmdLight->lightList.size(); i++) - { + for (size_t i = 0; i < cmdLight->lightList.size(); i++) { LightContext_InsertLight(play, &play->lightCtx, (LightInfo*)&cmdLight->lightList[i]); } return false; } -bool Scene_CommandPathList(PlayState* play, Ship::SceneCommand* cmd) -{ - // Ship::SetPathways* cmdPath = static_pointer_cast(cmd); - Ship::SetPathways* cmdPath = (Ship::SetPathways*)cmd; +bool Scene_CommandPathList(PlayState* play, LUS::SceneCommand* cmd) { + // LUS::SetPathways* cmdPath = static_pointer_cast(cmd); + LUS::SetPathways* cmdPath = (LUS::SetPathways*)cmd; play->setupPathList = (Path*)cmdPath->paths[0]->GetPointer(); return false; } -bool Scene_CommandTransitionActorList(PlayState* play, Ship::SceneCommand* cmd) { - // Ship::SetTransitionActorList* cmdActor = static_pointer_cast(cmd); - Ship::SetTransitionActorList* cmdActor = (Ship::SetTransitionActorList*)cmd; +bool Scene_CommandTransitionActorList(PlayState* play, LUS::SceneCommand* cmd) { + // LUS::SetTransitionActorList* cmdActor = static_pointer_cast(cmd); + LUS::SetTransitionActorList* cmdActor = (LUS::SetTransitionActorList*)cmd; play->transiActorCtx.numActors = cmdActor->numTransitionActors; play->transiActorCtx.list = (TransitionActorEntry*)cmdActor->GetPointer(); @@ -250,22 +239,20 @@ bool Scene_CommandTransitionActorList(PlayState* play, Ship::SceneCommand* cmd) return false; } -//void TransitionActor_InitContext(GameState* state, TransitionActorContext* transiActorCtx) { +// void TransitionActor_InitContext(GameState* state, TransitionActorContext* transiActorCtx) { // transiActorCtx->numActors = 0; //} -bool Scene_CommandLightSettingsList(PlayState* play, Ship::SceneCommand* cmd) -{ +bool Scene_CommandLightSettingsList(PlayState* play, LUS::SceneCommand* cmd) { play->envCtx.lightSettingsList = (EnvLightSettings*)cmd->GetPointer(); return false; } // Scene Command 0x11: Skybox Settings -bool Scene_CommandSkyboxSettings(PlayState* play, Ship::SceneCommand* cmd) -{ - // Ship::SetSkyboxSettings* cmdSky = static_pointer_cast(cmd); - Ship::SetSkyboxSettings* cmdSky = (Ship::SetSkyboxSettings*)cmd; +bool Scene_CommandSkyboxSettings(PlayState* play, LUS::SceneCommand* cmd) { + // LUS::SetSkyboxSettings* cmdSky = static_pointer_cast(cmd); + LUS::SetSkyboxSettings* cmdSky = (LUS::SetSkyboxSettings*)cmd; play->skyboxId = cmdSky->settings.skyboxId; play->envCtx.unk_17 = play->envCtx.unk_18 = cmdSky->settings.weather; @@ -274,10 +261,9 @@ bool Scene_CommandSkyboxSettings(PlayState* play, Ship::SceneCommand* cmd) return false; } -bool Scene_CommandSkyboxDisables(PlayState* play, Ship::SceneCommand* cmd) -{ - // Ship::SetSkyboxModifier* cmdSky = static_pointer_cast(cmd); - Ship::SetSkyboxModifier* cmdSky = (Ship::SetSkyboxModifier*)cmd; +bool Scene_CommandSkyboxDisables(PlayState* play, LUS::SceneCommand* cmd) { + // LUS::SetSkyboxModifier* cmdSky = static_pointer_cast(cmd); + LUS::SetSkyboxModifier* cmdSky = (LUS::SetSkyboxModifier*)cmd; play->envCtx.sunMoonDisabled = cmdSky->modifier.sunMoonDisabled; play->envCtx.skyboxDisabled = cmdSky->modifier.skyboxDisabled; @@ -285,10 +271,9 @@ bool Scene_CommandSkyboxDisables(PlayState* play, Ship::SceneCommand* cmd) return false; } -bool Scene_CommandTimeSettings(PlayState* play, Ship::SceneCommand* cmd) -{ - // Ship::SetTimeSettings* cmdTime = static_pointer_cast(cmd); - Ship::SetTimeSettings* cmdTime = (Ship::SetTimeSettings*)cmd; +bool Scene_CommandTimeSettings(PlayState* play, LUS::SceneCommand* cmd) { + // LUS::SetTimeSettings* cmdTime = static_pointer_cast(cmd); + LUS::SetTimeSettings* cmdTime = (LUS::SetTimeSettings*)cmd; if ((cmdTime->settings.hour != 0xFF) && (cmdTime->settings.minute != 0xFF)) { gSaveContext.skyboxTime = gSaveContext.dayTime = @@ -297,8 +282,7 @@ bool Scene_CommandTimeSettings(PlayState* play, Ship::SceneCommand* cmd) if (cmdTime->settings.timeIncrement != 0xFF) { play->envCtx.timeIncrement = cmdTime->settings.timeIncrement; - } - else { + } else { play->envCtx.timeIncrement = 0; } @@ -315,14 +299,11 @@ bool Scene_CommandTimeSettings(PlayState* play, Ship::SceneCommand* cmd) gSaveContext.skyboxTime = ((void)0, gSaveContext.dayTime); if ((gSaveContext.skyboxTime >= 0x2AAC) && (gSaveContext.skyboxTime < 0x4555)) { gSaveContext.skyboxTime = 0x3556; - } - else if ((gSaveContext.skyboxTime >= 0x4555) && (gSaveContext.skyboxTime < 0x5556)) { + } else if ((gSaveContext.skyboxTime >= 0x4555) && (gSaveContext.skyboxTime < 0x5556)) { gSaveContext.skyboxTime = 0x5556; - } - else if ((gSaveContext.skyboxTime >= 0xAAAB) && (gSaveContext.skyboxTime < 0xB556)) { + } else if ((gSaveContext.skyboxTime >= 0xAAAB) && (gSaveContext.skyboxTime < 0xB556)) { gSaveContext.skyboxTime = 0xB556; - } - else if ((gSaveContext.skyboxTime >= 0xC001) && (gSaveContext.skyboxTime < 0xCAAC)) { + } else if ((gSaveContext.skyboxTime >= 0xC001) && (gSaveContext.skyboxTime < 0xCAAC)) { gSaveContext.skyboxTime = 0xCAAC; } } @@ -330,9 +311,9 @@ bool Scene_CommandTimeSettings(PlayState* play, Ship::SceneCommand* cmd) return false; } -bool Scene_CommandWindSettings(PlayState* play, Ship::SceneCommand* cmd) { - // Ship::SetWind* cmdWind = std::static_pointer_cast(cmd); - Ship::SetWindSettings* cmdWind = (Ship::SetWindSettings*)cmd; +bool Scene_CommandWindSettings(PlayState* play, LUS::SceneCommand* cmd) { + // LUS::SetWind* cmdWind = std::static_pointer_cast(cmd); + LUS::SetWindSettings* cmdWind = (LUS::SetWindSettings*)cmd; play->envCtx.windDirection.x = cmdWind->settings.windWest; play->envCtx.windDirection.y = cmdWind->settings.windVertical; @@ -343,20 +324,19 @@ bool Scene_CommandWindSettings(PlayState* play, Ship::SceneCommand* cmd) { return false; } -bool Scene_CommandExitList(PlayState* play, Ship::SceneCommand* cmd) -{ +bool Scene_CommandExitList(PlayState* play, LUS::SceneCommand* cmd) { play->setupExitList = (s16*)cmd->GetPointer(); return false; } -bool Scene_CommandUndefined9(PlayState* play, Ship::SceneCommand* cmd) { +bool Scene_CommandUndefined9(PlayState* play, LUS::SceneCommand* cmd) { return false; } -bool Scene_CommandSoundSettings(PlayState* play, Ship::SceneCommand* cmd) { - // Ship::SetSoundSettings* cmdSnd = static_pointer_cast(cmd); - Ship::SetSoundSettings* cmdSnd = (Ship::SetSoundSettings*)cmd; +bool Scene_CommandSoundSettings(PlayState* play, LUS::SceneCommand* cmd) { + // LUS::SetSoundSettings* cmdSnd = static_pointer_cast(cmd); + LUS::SetSoundSettings* cmdSnd = (LUS::SetSoundSettings*)cmd; play->sequenceCtx.seqId = cmdSnd->settings.seqId; play->sequenceCtx.natureAmbienceId = cmdSnd->settings.natureAmbienceId; @@ -368,51 +348,45 @@ bool Scene_CommandSoundSettings(PlayState* play, Ship::SceneCommand* cmd) { return false; } -bool Scene_CommandEchoSettings(PlayState* play, Ship::SceneCommand* cmd) -{ - // Ship::SetEchoSettings* cmdEcho = static_pointer_cast(cmd); - Ship::SetEchoSettings* cmdEcho = (Ship::SetEchoSettings*)cmd; +bool Scene_CommandEchoSettings(PlayState* play, LUS::SceneCommand* cmd) { + // LUS::SetEchoSettings* cmdEcho = static_pointer_cast(cmd); + LUS::SetEchoSettings* cmdEcho = (LUS::SetEchoSettings*)cmd; play->roomCtx.curRoom.echo = cmdEcho->settings.echo; return false; } -bool Scene_CommandAlternateHeaderList(PlayState* play, Ship::SceneCommand* cmd) -{ - // Ship::SetAlternateHeaders* cmdHeaders = static_pointer_cast(cmd); - Ship::SetAlternateHeaders* cmdHeaders = (Ship::SetAlternateHeaders*)cmd; +bool Scene_CommandAlternateHeaderList(PlayState* play, LUS::SceneCommand* cmd) { + // LUS::SetAlternateHeaders* cmdHeaders = static_pointer_cast(cmd); + LUS::SetAlternateHeaders* cmdHeaders = (LUS::SetAlternateHeaders*)cmd; - //s32 pad; - //SceneCmd* altHeader; + // s32 pad; + // SceneCmd* altHeader; - //osSyncPrintf("\n[ZU]sceneset age =[%X]", ((void)0, gSaveContext.linkAge)); - //osSyncPrintf("\n[ZU]sceneset time =[%X]", ((void)0, gSaveContext.cutsceneIndex)); - //osSyncPrintf("\n[ZU]sceneset counter=[%X]", ((void)0, gSaveContext.sceneSetupIndex)); + // osSyncPrintf("\n[ZU]sceneset age =[%X]", ((void)0, gSaveContext.linkAge)); + // osSyncPrintf("\n[ZU]sceneset time =[%X]", ((void)0, gSaveContext.cutsceneIndex)); + // osSyncPrintf("\n[ZU]sceneset counter=[%X]", ((void)0, gSaveContext.sceneSetupIndex)); - if (gSaveContext.sceneSetupIndex != 0) - { - Ship::Scene* desiredHeader = std::static_pointer_cast(cmdHeaders->headers[gSaveContext.sceneSetupIndex - 1]).get(); + if (gSaveContext.sceneSetupIndex != 0) { + LUS::Scene* desiredHeader = + std::static_pointer_cast(cmdHeaders->headers[gSaveContext.sceneSetupIndex - 1]).get(); - if (desiredHeader != nullptr) - { + if (desiredHeader != nullptr) { OTRScene_ExecuteCommands(play, desiredHeader); return true; - } - else - { + } else { // "Coughh! There is no specified dataaaaa!" osSyncPrintf("\nげぼはっ! 指定されたデータがないでええっす!"); - if (gSaveContext.sceneSetupIndex == 3) - { - Ship::Scene* desiredHeader = std::static_pointer_cast(cmdHeaders->headers[gSaveContext.sceneSetupIndex - 2]).get(); + if (gSaveContext.sceneSetupIndex == 3) { + LUS::Scene* desiredHeader = + std::static_pointer_cast(cmdHeaders->headers[gSaveContext.sceneSetupIndex - 2]).get(); // "Using adult day data there!" osSyncPrintf("\nそこで、大人の昼データを使用するでええっす!!"); - if (desiredHeader != nullptr) - { + if (desiredHeader != nullptr) { OTRScene_ExecuteCommands(play, desiredHeader); return true; } @@ -422,22 +396,20 @@ bool Scene_CommandAlternateHeaderList(PlayState* play, Ship::SceneCommand* cmd) return false; } -bool Scene_CommandCutsceneData(PlayState* play, Ship::SceneCommand* cmd) -{ - // Ship::SetCutscenes* cmdCS = std::static_pointer_cast(cmd); - Ship::SetCutscenes* cmdCS = (Ship::SetCutscenes*)cmd; +bool Scene_CommandCutsceneData(PlayState* play, LUS::SceneCommand* cmd) { + // LUS::SetCutscenes* cmdCS = std::static_pointer_cast(cmd); + LUS::SetCutscenes* cmdCS = (LUS::SetCutscenes*)cmd; play->csCtx.segment = cmdCS->cutscene->commands.data(); - //osSyncPrintf("\ngame_play->demo_play.data=[%x]", play->csCtx.segment); + // osSyncPrintf("\ngame_play->demo_play.data=[%x]", play->csCtx.segment); return false; } // Camera & World Map Area -bool Scene_CommandMiscSettings(PlayState* play, Ship::SceneCommand* cmd) -{ - // Ship::SetCameraSettings* cmdCam = std::static_pointer_cast(cmd); - Ship::SetCameraSettings* cmdCam = (Ship::SetCameraSettings*)cmd; +bool Scene_CommandMiscSettings(PlayState* play, LUS::SceneCommand* cmd) { + // LUS::SetCameraSettings* cmdCam = std::static_pointer_cast(cmd); + LUS::SetCameraSettings* cmdCam = (LUS::SetCameraSettings*)cmd; YREG(15) = cmdCam->settings.cameraMovement; gSaveContext.worldMapArea = cmdCam->settings.worldMapArea; @@ -459,8 +431,7 @@ bool Scene_CommandMiscSettings(PlayState* play, Ship::SceneCommand* cmd) return false; } -bool (*sceneCommands[])(PlayState*, Ship::SceneCommand*) = -{ +bool (*sceneCommands[])(PlayState*, LUS::SceneCommand*) = { Scene_CommandSpawnList, // SCENE_CMD_ID_SPAWN_LIST Scene_CommandActorList, // SCENE_CMD_ID_ACTOR_LIST Scene_CommandUnused2, // SCENE_CMD_ID_UNUSED_2 @@ -489,20 +460,17 @@ bool (*sceneCommands[])(PlayState*, Ship::SceneCommand*) = Scene_CommandMiscSettings, // SCENE_CMD_ID_MISC_SETTINGS }; -s32 OTRScene_ExecuteCommands(PlayState* play, Ship::Scene* scene) -{ - Ship::SceneCommandID cmdCode; +s32 OTRScene_ExecuteCommands(PlayState* play, LUS::Scene* scene) { + LUS::SceneCommandID cmdCode; - for (int i = 0; i < scene->commands.size(); i++) - { + for (int i = 0; i < scene->commands.size(); i++) { auto sceneCmd = scene->commands[i]; if (sceneCmd == nullptr) // UH OH continue; - cmdCode = sceneCmd->cmdId; - //osSyncPrintf("*** Scene_Word = { code=%d, data1=%02x, data2=%04x } ***\n", cmdCode, sceneCmd->base.data1, sceneCmd->base.data2); + // osSyncPrintf("*** Scene_Word = { code=%d, data1=%02x, data2=%04x } ***\n", cmdCode, sceneCmd->base.data1, sceneCmd->base.data2); if ((int)cmdCode == 0x14) { break; @@ -511,28 +479,26 @@ s32 OTRScene_ExecuteCommands(PlayState* play, Ship::Scene* scene) if ((int)cmdCode <= 0x19) { if (sceneCommands[(int)cmdCode](play, sceneCmd.get())) break; - } - else { + } else { osSyncPrintf(VT_FGCOL(RED)); osSyncPrintf("code の値が異常です\n"); // "code variable is abnormal" osSyncPrintf(VT_RST); } - //sceneCmd++; + // sceneCmd++; } return 0; } extern "C" s32 OTRfunc_800973FC(PlayState* play, RoomContext* roomCtx) { if (roomCtx->status == 1) { - //if (!osRecvMesg(&roomCtx->loadQueue, NULL, OS_MESG_NOBLOCK)) { - if (1) - { + // if (!osRecvMesg(&roomCtx->loadQueue, NULL, OS_MESG_NOBLOCK)) { + if (1) { roomCtx->status = 0; roomCtx->curRoom.segment = roomCtx->unk_34; gSegments[3] = VIRTUAL_TO_PHYSICAL(roomCtx->unk_34); - OTRScene_ExecuteCommands(play, (Ship::Scene*)roomCtx->roomToLoad); + OTRScene_ExecuteCommands(play, (LUS::Scene*)roomCtx->roomToLoad); Player_SetBootData(play, GET_PLAYER(play)); Actor_SpawnTransitionActors(play, &play->actorCtx); @@ -560,13 +526,15 @@ extern "C" s32 OTRfunc_8009728C(PlayState* play, RoomContext* roomCtx, s32 roomN return 0; // UH OH size = play->roomList[roomNum].vromEnd - play->roomList[roomNum].vromStart; - roomCtx->unk_34 = (void*)ALIGN16((uintptr_t)roomCtx->bufPtrs[roomCtx->unk_30] - ((size + 8) * roomCtx->unk_30 + 7)); + roomCtx->unk_34 = + (void*)ALIGN16((uintptr_t)roomCtx->bufPtrs[roomCtx->unk_30] - ((size + 8) * roomCtx->unk_30 + 7)); osCreateMesgQueue(&roomCtx->loadQueue, &roomCtx->loadMsg, 1); - //DmaMgr_SendRequest2(&roomCtx->dmaRequest, roomCtx->unk_34, play->roomList[roomNum].vromStart, size, 0, + // DmaMgr_SendRequest2(&roomCtx->dmaRequest, roomCtx->unk_34, play->roomList[roomNum].vromStart, size, 0, //&roomCtx->loadQueue, NULL, __FILE__, __LINE__); - auto roomData = std::static_pointer_cast(GetResourceByNameHandlingMQ(play->roomList[roomNum].fileName)); + auto roomData = + std::static_pointer_cast(GetResourceByNameHandlingMQ(play->roomList[roomNum].fileName)); roomCtx->status = 1; roomCtx->roomToLoad = roomData.get(); diff --git a/soh/src/code/main.c b/soh/src/code/main.c index 7ecff0b63..b59a825c1 100644 --- a/soh/src/code/main.c +++ b/soh/src/code/main.c @@ -4,6 +4,7 @@ #include "global.h" #include "vt.h" +#include "stdio.h" #include #include "soh/OTRGlobals.h" diff --git a/soh/src/code/z_map_exp.c b/soh/src/code/z_map_exp.c index af1c1784d..0c267af62 100644 --- a/soh/src/code/z_map_exp.c +++ b/soh/src/code/z_map_exp.c @@ -413,7 +413,7 @@ void Map_InitData(PlayState* play, s16 room) { //gMapData->owMinimapTexSize[mapIndex], __FILE__, __LINE__); if (sEntranceIconMapIndex < 24) { - play->interfaceCtx.mapSegment[0] = GetResourceDataByName(minimapTableOW[sEntranceIconMapIndex], true); + play->interfaceCtx.mapSegment[0] = GetResourceDataByName(minimapTableOW[sEntranceIconMapIndex]); play->interfaceCtx.mapSegmentName[0] = minimapTableOW[sEntranceIconMapIndex]; } @@ -447,7 +447,8 @@ void Map_InitData(PlayState* play, s16 room) { //((gMapData->dgnMinimapTexIndexOffset[mapIndex] + room) * 0xFF0), //0xFF0, __FILE__, __LINE__); - play->interfaceCtx.mapSegment[0] = GetResourceDataByName(minimapTableDangeon[gMapData->dgnMinimapTexIndexOffset[mapIndex] + room], true); + play->interfaceCtx.mapSegment[0] = GetResourceDataByName( + minimapTableDangeon[gMapData->dgnMinimapTexIndexOffset[mapIndex] + room]); play->interfaceCtx.mapSegmentName[0] = minimapTableDangeon[gMapData->dgnMinimapTexIndexOffset[mapIndex] + room]; R_COMPASS_OFFSET_X = gMapData->roomCompassOffsetX[mapIndex][room]; R_COMPASS_OFFSET_Y = gMapData->roomCompassOffsetY[mapIndex][room]; diff --git a/soh/src/code/z_player_lib.c b/soh/src/code/z_player_lib.c index 01d5e0409..d556fcc30 100644 --- a/soh/src/code/z_player_lib.c +++ b/soh/src/code/z_player_lib.c @@ -332,8 +332,8 @@ void Player_SetBootData(PlayState* play, Player* this) { // Custom method used to determine if we're using a custom model for link uint8_t Player_IsCustomLinkModel() { - return (LINK_IS_ADULT && GetResourceIsCustomByName(gLinkAdultSkel, true)) || - (LINK_IS_CHILD && GetResourceIsCustomByName(gLinkChildSkel, true)); + return (LINK_IS_ADULT && GetResourceIsCustomByName(gLinkAdultSkel)) || + (LINK_IS_CHILD && GetResourceIsCustomByName(gLinkChildSkel)); } s32 Player_InBlockingCsMode(PlayState* play, Player* this) { diff --git a/soh/src/code/z_room.c b/soh/src/code/z_room.c index f30bb5b03..3d5acfe40 100644 --- a/soh/src/code/z_room.c +++ b/soh/src/code/z_room.c @@ -273,7 +273,7 @@ void func_8009638C(Gfx** displayList, void* source, void* tlut, u16 width, u16 h bg->b.imageFlip = 0; if (ResourceMgr_ResourceIsBackground((char*) source)) { - char* blob = (char*) GetResourceDataByName((char*) source, true); + char* blob = (char*) GetResourceDataByName((char *) source); swapAndConvertJPEG(blob); bg->b.imagePtr = (uintptr_t) blob; } diff --git a/soh/src/code/z_scene_table.c b/soh/src/code/z_scene_table.c index 9e4f845f5..5213e3190 100644 --- a/soh/src/code/z_scene_table.c +++ b/soh/src/code/z_scene_table.c @@ -23,6 +23,7 @@ #include "overlays/actors/ovl_Bg_Dodoago/z_bg_dodoago.h" +#include "soh/mq_asset_hacks.h" #include "soh/Enhancements/randomizer/adult_trade_shuffle.h" #define ENTRANCE(scene, spawn, continueBgm, displayTitleCard, fadeIn, fadeOut) \ @@ -1006,7 +1007,11 @@ void func_800995DC(PlayState* play) { { s32 pad; } - gSPSegmentLoadRes(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(D_8012A2F8[gSaveContext.nightFlag])); + if (ResourceMgr_IsGameMasterQuest()) { + gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(D_8012A2F8_MQ[gSaveContext.nightFlag])); + } else { + gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(D_8012A2F8[gSaveContext.nightFlag])); + } CLOSE_DISPS(play->state.gfxCtx); } @@ -1046,8 +1051,13 @@ void func_80099878(PlayState* play) { OPEN_DISPS(play->state.gfxCtx); gameplayFrames = play->gameplayFrames; - gSPSegmentLoadRes(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(gDCEntranceTextures[gSaveContext.nightFlag])); - gSPSegmentLoadRes(POLY_OPA_DISP++, 0x09, SEGMENTED_TO_VIRTUAL(sDCLavaFloorTextures[(s32)(gameplayFrames & 14) >> 1])); + if (ResourceMgr_IsGameMasterQuest()) { + gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(gDCEntranceTextures_MQ[gSaveContext.nightFlag])); + gSPSegment(POLY_OPA_DISP++, 0x09, SEGMENTED_TO_VIRTUAL(sDCLavaFloorTextures_MQ[(s32)(gameplayFrames & 14) >> 1])); + } else { + gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(gDCEntranceTextures[gSaveContext.nightFlag])); + gSPSegment(POLY_OPA_DISP++, 0x09, SEGMENTED_TO_VIRTUAL(sDCLavaFloorTextures[(s32)(gameplayFrames & 14) >> 1])); + } gSPSegment(POLY_XLU_DISP++, 0x09, Gfx_TwoTexScroll(play->state.gfxCtx, 0, (gameplayFrames * 1) % 256, 0, 64, 32, 1, 0, (gameplayFrames * 1) % 128, 64, 32)); @@ -1301,7 +1311,11 @@ void func_8009AFE0(PlayState* play) { { s32 pad[2]; } - gSPSegmentLoadRes(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sThievesHideoutEntranceTextures[gSaveContext.nightFlag])); + if (ResourceMgr_IsGameMasterQuest()) { + gSPSegment(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sThievesHideoutEntranceTextures_MQ[gSaveContext.nightFlag])); + } else { + gSPSegment(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sThievesHideoutEntranceTextures[gSaveContext.nightFlag])); + } CLOSE_DISPS(play->state.gfxCtx); } @@ -1323,7 +1337,11 @@ void func_8009B0FC(PlayState* play) { spAC = play->roomCtx.unk_74[1] & 0xFF; gameplayFrames = play->gameplayFrames; - gSPSegmentLoadRes(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(D_8012A330[gSaveContext.nightFlag])); + if (ResourceMgr_IsGameMasterQuest()) { + gSPSegment(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(D_8012A330_MQ[gSaveContext.nightFlag])); + } else { + gSPSegment(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(D_8012A330[gSaveContext.nightFlag])); + } if (spB0 == 1) { gSPSegment(POLY_OPA_DISP++, 0x08, @@ -1548,7 +1566,11 @@ void func_8009C3EC(PlayState* play) { OPEN_DISPS(play->state.gfxCtx); gameplayFrames = play->gameplayFrames; - gSPSegmentLoadRes(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sIceCavernEntranceTextures[gSaveContext.nightFlag])); + if (ResourceMgr_IsGameMasterQuest()) { + gSPSegment(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sIceCavernEntranceTextures_MQ[gSaveContext.nightFlag])); + } else { + gSPSegment(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sIceCavernEntranceTextures[gSaveContext.nightFlag])); + } gSPSegment(POLY_OPA_DISP++, 0x09, Gfx_TwoTexScroll(play->state.gfxCtx, 0, 127 - gameplayFrames % 128, (gameplayFrames * 1) % 128, 32, 32, 1, gameplayFrames % 128, (gameplayFrames * 1) % 128, 32, 32)); @@ -1650,7 +1672,11 @@ void func_8009CC00(PlayState* play) { OPEN_DISPS(play->state.gfxCtx); gameplayFrames = play->gameplayFrames; - gSPSegmentLoadRes(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sGTGEntranceTextures[gSaveContext.nightFlag])); + if (ResourceMgr_IsGameMasterQuest()) { + gSPSegment(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sGTGEntranceTextures_MQ[gSaveContext.nightFlag])); + } else { + gSPSegment(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sGTGEntranceTextures[gSaveContext.nightFlag])); + } gSPSegment(POLY_OPA_DISP++, 0x09, Gfx_TwoTexScroll(play->state.gfxCtx, 0, 127 - gameplayFrames % 128, (gameplayFrames * 1) % 128, 32, 32, 1, gameplayFrames % 128, (gameplayFrames * 1) % 128, 32, 32)); @@ -1746,7 +1772,11 @@ void func_8009D31C(PlayState* play) { { s32 pad[2]; } - gSPSegmentLoadRes(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sLonLonHouseEntranceTextures[gSaveContext.nightFlag])); + if (ResourceMgr_IsGameMasterQuest()) { + gSPSegment(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sLonLonHouseEntranceTextures_MQ[gSaveContext.nightFlag])); + } else { + gSPSegment(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sLonLonHouseEntranceTextures[gSaveContext.nightFlag])); + } gDPPipeSync(POLY_OPA_DISP++); gDPSetEnvColor(POLY_OPA_DISP++, 128, 128, 128, 128); @@ -1778,8 +1808,13 @@ void func_8009D438(PlayState* play) { var = gSaveContext.nightFlag; } - gSPSegmentLoadRes(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sGuardHouseView1Textures[var])); - gSPSegmentLoadRes(POLY_OPA_DISP++, 0x09, SEGMENTED_TO_VIRTUAL(sGuardHouseView2Textures[var])); + if (ResourceMgr_IsGameMasterQuest()) { + gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sGuardHouseView1Textures_MQ[var])); + gSPSegment(POLY_OPA_DISP++, 0x09, SEGMENTED_TO_VIRTUAL(sGuardHouseView2Textures_MQ[var])); + } else { + gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sGuardHouseView1Textures[var])); + gSPSegment(POLY_OPA_DISP++, 0x09, SEGMENTED_TO_VIRTUAL(sGuardHouseView2Textures[var])); + } gDPPipeSync(POLY_OPA_DISP++); gDPSetEnvColor(POLY_OPA_DISP++, 128, 128, 128, 128); @@ -1823,7 +1858,11 @@ void func_8009D758(PlayState* play) { OPEN_DISPS(play->state.gfxCtx); gameplayFrames = play->gameplayFrames; - gSPSegmentLoadRes(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sForestTempleEntranceTextures[gSaveContext.nightFlag])); + if (ResourceMgr_IsGameMasterQuest()) { + gSPSegment(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sForestTempleEntranceTextures_MQ[gSaveContext.nightFlag])); + } else { + gSPSegment(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sForestTempleEntranceTextures[gSaveContext.nightFlag])); + } gSPSegment(POLY_XLU_DISP++, 0x09, Gfx_TwoTexScroll(play->state.gfxCtx, 0, 127 - gameplayFrames % 128, (gameplayFrames * 1) % 128, 32, 32, 1, gameplayFrames % 128, (gameplayFrames * 1) % 128, 32, 32)); @@ -1853,7 +1892,11 @@ void func_8009D974(PlayState* play) { { s32 pad[2]; } - gSPSegmentLoadRes(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sSpiritTempleEntranceTextures[gSaveContext.nightFlag])); + if (ResourceMgr_IsGameMasterQuest()) { + gSPSegment(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sSpiritTempleEntranceTextures_MQ[gSaveContext.nightFlag])); + } else { + gSPSegment(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sSpiritTempleEntranceTextures[gSaveContext.nightFlag])); + } CLOSE_DISPS(play->state.gfxCtx); } @@ -1915,7 +1958,11 @@ void func_8009DD5C(PlayState* play) { { s32 pad[2]; } - gSPSegmentLoadRes(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sKakarikoWindowTextures[gSaveContext.nightFlag])); + if (ResourceMgr_IsGameMasterQuest()) { + gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sKakarikoWindowTextures_MQ[gSaveContext.nightFlag])); + } else { + gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sKakarikoWindowTextures[gSaveContext.nightFlag])); + } gDPPipeSync(POLY_OPA_DISP++); gDPSetEnvColor(POLY_OPA_DISP++, 128, 128, 128, 128); @@ -2050,8 +2097,12 @@ void func_8009E730(PlayState* play) { gDPPipeSync(POLY_OPA_DISP++); gDPSetEnvColor(POLY_OPA_DISP++, 128, 128, 128, 128); - - gSPSegmentLoadRes(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sZorasDomainEntranceTextures[gSaveContext.nightFlag])); + + if (ResourceMgr_IsGameMasterQuest()) { + gSPSegment(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sZorasDomainEntranceTextures_MQ[gSaveContext.nightFlag])); + } else { + gSPSegment(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sZorasDomainEntranceTextures[gSaveContext.nightFlag])); + } { s32 pad[2]; } @@ -2172,6 +2223,7 @@ void func_8009F074(PlayState* play) { CLOSE_DISPS(play->state.gfxCtx); } +// walls of GF room where they throw you when you get caught void* D_8012A380[] = { gSpot12_009678Tex, gSpot12_00DE78Tex, @@ -2183,7 +2235,11 @@ void func_8009F1B4(PlayState* play) { { s32 pad[2]; } - gSPSegmentLoadRes(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(D_8012A380[gSaveContext.nightFlag])); + if (ResourceMgr_IsGameMasterQuest()) { + gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(D_8012A380_MQ[gSaveContext.nightFlag])); + } else { + gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(D_8012A380[gSaveContext.nightFlag])); + } CLOSE_DISPS(play->state.gfxCtx); } @@ -2316,7 +2372,11 @@ void func_8009F9D0(PlayState* play) { gDPPipeSync(POLY_XLU_DISP++); gDPSetEnvColor(POLY_XLU_DISP++, 128, 128, 128, 128); - gSPSegmentLoadRes(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sGoronCityEntranceTextures[gSaveContext.nightFlag])); + if (ResourceMgr_IsGameMasterQuest()) { + gSPSegment(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sGoronCityEntranceTextures_MQ[gSaveContext.nightFlag])); + } else { + gSPSegment(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sGoronCityEntranceTextures[gSaveContext.nightFlag])); + } { s32 pad[2]; } @@ -2334,7 +2394,11 @@ void func_8009FB74(PlayState* play) { { s32 pad[2]; } - gSPSegmentLoadRes(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sLonLonRanchWindowTextures[gSaveContext.nightFlag])); + if (ResourceMgr_IsGameMasterQuest()) { + gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sLonLonRanchWindowTextures_MQ[gSaveContext.nightFlag])); + } else { + gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sLonLonRanchWindowTextures[gSaveContext.nightFlag])); + } gDPPipeSync(POLY_OPA_DISP++); gDPSetEnvColor(POLY_OPA_DISP++, 128, 128, 128, 128); diff --git a/soh/src/overlays/actors/ovl_Boss_Dodongo/z_boss_dodongo.c b/soh/src/overlays/actors/ovl_Boss_Dodongo/z_boss_dodongo.c index 2ae04e344..5b52ca92d 100644 --- a/soh/src/overlays/actors/ovl_Boss_Dodongo/z_boss_dodongo.c +++ b/soh/src/overlays/actors/ovl_Boss_Dodongo/z_boss_dodongo.c @@ -87,7 +87,7 @@ void func_808C12C4(u8* arg1, s16 arg2) { void func_808C1554(void* arg0, void* floorTex, s32 arg2, f32 arg3) { arg0 = GetResourceDataByNameHandlingMQ(arg0); - floorTex = GetResourceDataByName(floorTex, false); + floorTex = GetResourceDataByName(floorTex); u16* temp_s3 = SEGMENTED_TO_VIRTUAL(arg0); u16* temp_s1 = SEGMENTED_TO_VIRTUAL(floorTex); @@ -186,8 +186,8 @@ void BossDodongo_Init(Actor* thisx, PlayState* play) { Collider_SetJntSph(play, &this->collider, &this->actor, &sJntSphInit, this->items); if (Flags_GetClear(play, play->roomCtx.curRoom.num)) { // KD is dead - u16* LavaFloorTex = GetResourceDataByName(gDodongosCavernBossLavaFloorTex, false); - u16* LavaFloorRockTex = GetResourceDataByName(sLavaFloorRockTex, false); + u16* LavaFloorTex = GetResourceDataByName(gDodongosCavernBossLavaFloorTex); + u16* LavaFloorRockTex = GetResourceDataByName(sLavaFloorRockTex); temp_s1_3 = SEGMENTED_TO_VIRTUAL(LavaFloorTex); temp_s2 = SEGMENTED_TO_VIRTUAL(LavaFloorRockTex); Actor_Kill(&this->actor); @@ -1018,8 +1018,8 @@ void BossDodongo_Update(Actor* thisx, PlayState* play2) { } if (this->unk_1C6 != 0) { - u16* ptr1 = GetResourceDataByName(sLavaFloorLavaTex, false); - u16* ptr2 = GetResourceDataByName(sLavaFloorRockTex, false); + u16* ptr1 = GetResourceDataByName(sLavaFloorLavaTex); + u16* ptr2 = GetResourceDataByName(sLavaFloorRockTex); s16 i2; for (i2 = 0; i2 < 20; i2++) { diff --git a/soh/src/overlays/actors/ovl_Boss_Ganon/z_boss_ganon.c b/soh/src/overlays/actors/ovl_Boss_Ganon/z_boss_ganon.c index ec59ae35b..f27915f39 100644 --- a/soh/src/overlays/actors/ovl_Boss_Ganon/z_boss_ganon.c +++ b/soh/src/overlays/actors/ovl_Boss_Ganon/z_boss_ganon.c @@ -1220,7 +1220,7 @@ void BossGanon_SetupTowerCutscene(BossGanon* this, PlayState* play) { void BossGanon_ShatterWindows(u8 windowShatterState) { s16 i; - u8* templateTex = GetResourceDataByName(SEGMENTED_TO_VIRTUAL(gGanondorfWindowShatterTemplateTex), false); + u8* templateTex = GetResourceDataByName(SEGMENTED_TO_VIRTUAL(gGanondorfWindowShatterTemplateTex)); for (i = 0; i < ARRAY_COUNT(sWindowShatterTex); i++) { if ((sWindowShatterTex[i] != 1) && (Rand_ZeroOne() < 0.03f)) { diff --git a/soh/src/overlays/actors/ovl_En_Bdfire/z_en_bdfire.c b/soh/src/overlays/actors/ovl_En_Bdfire/z_en_bdfire.c index b9d4ef0a9..12da0cc92 100644 --- a/soh/src/overlays/actors/ovl_En_Bdfire/z_en_bdfire.c +++ b/soh/src/overlays/actors/ovl_En_Bdfire/z_en_bdfire.c @@ -19,7 +19,7 @@ void func_809BC2A4(EnBdfire* this, PlayState* play); void func_809BC598(EnBdfire* this, PlayState* play); const ActorInit En_Bdfire_InitVars = { - 0, + ACTOR_EN_BDFIRE, ACTORCAT_ENEMY, FLAGS, OBJECT_KINGDODONGO, diff --git a/soh/src/overlays/actors/ovl_En_Fhg_Fire/z_en_fhg_fire.c b/soh/src/overlays/actors/ovl_En_Fhg_Fire/z_en_fhg_fire.c index 0bbd70ca1..ac13a51f6 100644 --- a/soh/src/overlays/actors/ovl_En_Fhg_Fire/z_en_fhg_fire.c +++ b/soh/src/overlays/actors/ovl_En_Fhg_Fire/z_en_fhg_fire.c @@ -45,7 +45,7 @@ void EnFhgFire_EnergyBall(EnFhgFire* this, PlayState* play); void EnFhgFire_PhantomWarp(EnFhgFire* this, PlayState* play); const ActorInit En_Fhg_Fire_InitVars = { - 0, + ACTOR_EN_FHG_FIRE, ACTORCAT_BOSS, FLAGS, OBJECT_FHG, diff --git a/soh/src/overlays/actors/ovl_En_Goma/z_en_goma.c b/soh/src/overlays/actors/ovl_En_Goma/z_en_goma.c index 48de7b549..decc90f5b 100644 --- a/soh/src/overlays/actors/ovl_En_Goma/z_en_goma.c +++ b/soh/src/overlays/actors/ovl_En_Goma/z_en_goma.c @@ -44,7 +44,7 @@ void EnGoma_SetupJump(EnGoma* this); void EnGoma_SetupStunned(EnGoma* this, PlayState* play); const ActorInit En_Goma_InitVars = { - ACTOR_BOSS_GOMA, + ACTOR_EN_GOMA, ACTORCAT_ENEMY, FLAGS, OBJECT_GOL, diff --git a/soh/src/overlays/actors/ovl_En_Jsjutan/z_en_jsjutan.c b/soh/src/overlays/actors/ovl_En_Jsjutan/z_en_jsjutan.c index 60c51c036..e17edf9e1 100644 --- a/soh/src/overlays/actors/ovl_En_Jsjutan/z_en_jsjutan.c +++ b/soh/src/overlays/actors/ovl_En_Jsjutan/z_en_jsjutan.c @@ -397,7 +397,7 @@ void EnJsjutan_Draw(Actor* thisx, PlayState* play2) { if (this->unk_164) { this->unk_164 = false; - u8* carpTex = GetResourceDataByName(sCarpetTex, false); + u8* carpTex = GetResourceDataByName(sCarpetTex); u8* shadTex = sShadowTex; for (i = 0; i < ARRAY_COUNT(sShadowTex); i++) { if (((u16*)carpTex)[i] != 0) { // Hack to bypass ZAPD exporting textures as u64. diff --git a/soh/src/overlays/actors/ovl_En_Vb_Ball/z_en_vb_ball.c b/soh/src/overlays/actors/ovl_En_Vb_Ball/z_en_vb_ball.c index 0e859c37c..ab162f97b 100644 --- a/soh/src/overlays/actors/ovl_En_Vb_Ball/z_en_vb_ball.c +++ b/soh/src/overlays/actors/ovl_En_Vb_Ball/z_en_vb_ball.c @@ -17,7 +17,7 @@ void EnVbBall_Update(Actor* thisx, PlayState* play); void EnVbBall_Draw(Actor* thisx, PlayState* play); const ActorInit En_Vb_Ball_InitVars = { - 0, + ACTOR_EN_VB_BALL, ACTORCAT_BOSS, FLAGS, OBJECT_FD, diff --git a/soh/src/overlays/gamestates/ovl_select/z_select.c b/soh/src/overlays/gamestates/ovl_select/z_select.c index db677211e..a1d5816e1 100644 --- a/soh/src/overlays/gamestates/ovl_select/z_select.c +++ b/soh/src/overlays/gamestates/ovl_select/z_select.c @@ -1035,7 +1035,7 @@ void Select_PrintMenu(SelectContext* this, GfxPrint* printer) { GfxPrint_SetColor(printer, 200, 200, 55, 255); } - if (CVarGetInteger("gDebugWarpScreenTranslation", 0)) { + if (CVarGetInteger("gDebugWarpScreenTranslation", 1)) { switch (gSaveContext.language) { case LANGUAGE_ENG: default: @@ -1062,7 +1062,7 @@ void Select_PrintMenu(SelectContext* this, GfxPrint* printer) { GfxPrint_SetColor(printer, 155, 55, 150, 255); // Small position hack of the OPT=X text since german Link's Age overlap if translated - if (CVarGetInteger("gDebugWarpScreenTranslation", 0) && gSaveContext.language == LANGUAGE_GER) { + if (CVarGetInteger("gDebugWarpScreenTranslation", 1) && gSaveContext.language == LANGUAGE_GER) { GfxPrint_SetPos(printer, 26, 26); } else { GfxPrint_SetPos(printer, 20, 26); @@ -1091,7 +1091,7 @@ void Better_Select_PrintMenu(SelectContext* this, GfxPrint* printer) { GfxPrint_SetColor(printer, 175, 175, 175, 255); } - if (CVarGetInteger("gDebugWarpScreenTranslation", 0)) { + if (CVarGetInteger("gDebugWarpScreenTranslation", 1)) { switch (gSaveContext.language) { case LANGUAGE_ENG: default: @@ -1117,7 +1117,7 @@ void Better_Select_PrintMenu(SelectContext* this, GfxPrint* printer) { GfxPrint_SetColor(printer, 205, 100, 200, 255); GfxPrint_SetPos(printer, 3, 26); - if (CVarGetInteger("gDebugWarpScreenTranslation", 0)) { + if (CVarGetInteger("gDebugWarpScreenTranslation", 1)) { switch (gSaveContext.language) { case LANGUAGE_ENG: default: @@ -1157,7 +1157,7 @@ void Select_PrintLoadingMessage(SelectContext* this, GfxPrint* printer) { GfxPrint_SetPos(printer, 10, 15); GfxPrint_SetColor(printer, 255, 255, 255, 255); randomMsg = Rand_ZeroOne() * ARRAY_COUNT(sLoadingMessages); - if (CVarGetInteger("gDebugWarpScreenTranslation", 0)) { + if (CVarGetInteger("gDebugWarpScreenTranslation", 1)) { switch (gSaveContext.language) { case LANGUAGE_ENG: default: @@ -1188,7 +1188,7 @@ static BetterSceneSelectAgeLabels sBetterAgeLabels[] = { void Select_PrintAgeSetting(SelectContext* this, GfxPrint* printer, s32 age) { GfxPrint_SetPos(printer, 4, 26); GfxPrint_SetColor(printer, 255, 255, 55, 255); - if (CVarGetInteger("gDebugWarpScreenTranslation", 0)) { + if (CVarGetInteger("gDebugWarpScreenTranslation", 1)) { switch (gSaveContext.language) { case LANGUAGE_ENG: default: @@ -1209,7 +1209,7 @@ void Select_PrintAgeSetting(SelectContext* this, GfxPrint* printer, s32 age) { void Better_Select_PrintAgeSetting(SelectContext* this, GfxPrint* printer, s32 age) { GfxPrint_SetPos(printer, 25, 25); GfxPrint_SetColor(printer, 100, 100, 100, 255); - if (CVarGetInteger("gDebugWarpScreenTranslation", 0)) { + if (CVarGetInteger("gDebugWarpScreenTranslation", 1)) { switch (gSaveContext.language) { case LANGUAGE_ENG: case LANGUAGE_FRA: @@ -1225,7 +1225,7 @@ void Better_Select_PrintAgeSetting(SelectContext* this, GfxPrint* printer, s32 a } GfxPrint_SetColor(printer, 55, 200, 50, 255); - if (CVarGetInteger("gDebugWarpScreenTranslation", 0)) { + if (CVarGetInteger("gDebugWarpScreenTranslation", 1)) { switch (gSaveContext.language) { case LANGUAGE_ENG: default: @@ -1261,7 +1261,7 @@ void Select_PrintCutsceneSetting(SelectContext* this, GfxPrint* printer, u16 csI }; char* label; - int lang = CVarGetInteger("gDebugWarpScreenTranslation", 0) ? gSaveContext.language + 1 : 0; + int lang = CVarGetInteger("gDebugWarpScreenTranslation", 1) ? gSaveContext.language + 1 : 0; GfxPrint_SetPos(printer, 4, 25); GfxPrint_SetColor(printer, 255, 255, 55, 255); @@ -1324,7 +1324,7 @@ void Better_Select_PrintTimeSetting(SelectContext* this, GfxPrint* printer) { GfxPrint_SetColor(printer, 100, 100, 100, 255); if (gSaveContext.dayTime > 0xC000 || gSaveContext.dayTime < 0x4555) { - if (CVarGetInteger("gDebugWarpScreenTranslation", 0)) { + if (CVarGetInteger("gDebugWarpScreenTranslation", 1)) { switch (gSaveContext.language) { case LANGUAGE_ENG: default: @@ -1341,7 +1341,7 @@ void Better_Select_PrintTimeSetting(SelectContext* this, GfxPrint* printer) { label = "Night"; } } else { - if (CVarGetInteger("gDebugWarpScreenTranslation", 0)) { + if (CVarGetInteger("gDebugWarpScreenTranslation", 1)) { switch (gSaveContext.language) { case LANGUAGE_ENG: default: @@ -1358,7 +1358,7 @@ void Better_Select_PrintTimeSetting(SelectContext* this, GfxPrint* printer) { label = "Day"; } } - if (CVarGetInteger("gDebugWarpScreenTranslation", 0)) { + if (CVarGetInteger("gDebugWarpScreenTranslation", 1)) { switch (gSaveContext.language) { case LANGUAGE_ENG: default: diff --git a/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_scope_PAL.c b/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_scope_PAL.c index 48ec05600..56afb768f 100644 --- a/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_scope_PAL.c +++ b/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_scope_PAL.c @@ -3173,8 +3173,8 @@ void KaleidoScope_LoadDungeonMap(PlayState* play) { interfaceCtx->mapSegmentName[0] = sDungeonMapTexs[R_MAP_TEX_INDEX]; interfaceCtx->mapSegmentName[1] = sDungeonMapTexs[R_MAP_TEX_INDEX + 1]; - interfaceCtx->mapSegment[0] = GetResourceDataByName(sDungeonMapTexs[R_MAP_TEX_INDEX], true); - interfaceCtx->mapSegment[1] = GetResourceDataByName(sDungeonMapTexs[R_MAP_TEX_INDEX + 1], true); + interfaceCtx->mapSegment[0] = GetResourceDataByName(sDungeonMapTexs[R_MAP_TEX_INDEX]); + interfaceCtx->mapSegment[1] = GetResourceDataByName(sDungeonMapTexs[R_MAP_TEX_INDEX + 1]); } void KaleidoScope_UpdateDungeonMap(PlayState* play) {