diff options
| author | louist103 <35883445+louist103@users.noreply.github.com> | 2022-12-05 23:19:25 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-12-05 23:19:25 -0500 |
| commit | a80f36ca0f003a3901fc781505f707ca2ef4c63a (patch) | |
| tree | 2b9cec4c873c194ada5449f276a18bf0090483be /ZAPD/ZRoom | |
| parent | 645444f209bfeca025b3862548a59d31ef9bca08 (diff) | |
Read from an external file for entrance lists (#271)
* Read from entrance list file
* Remove switch.
* Add check for special entrances.
* Ignore warning for GCC in specific spot.
* u
Diffstat (limited to 'ZAPD/ZRoom')
| -rw-r--r-- | ZAPD/ZRoom/Commands/SetActorList.h | 3 | ||||
| -rw-r--r-- | ZAPD/ZRoom/Commands/SetExitList.cpp | 4 | ||||
| -rw-r--r-- | ZAPD/ZRoom/Commands/SetRoomList.cpp | 5 | ||||
| -rw-r--r-- | ZAPD/ZRoom/ZNames.h | 25 |
4 files changed, 27 insertions, 10 deletions
diff --git a/ZAPD/ZRoom/Commands/SetActorList.h b/ZAPD/ZRoom/Commands/SetActorList.h index 4d21616..9122c15 100644 --- a/ZAPD/ZRoom/Commands/SetActorList.h +++ b/ZAPD/ZRoom/Commands/SetActorList.h @@ -1,7 +1,7 @@ #pragma once -#include "ZRoom/ZRoomCommand.h" #include "ZActorList.h" +#include "ZRoom/ZRoomCommand.h" class SetActorList : public ZRoomCommand { @@ -14,7 +14,6 @@ public: void ParseRawData() override; void DeclareReferences(const std::string& prefix) override; - std::string GetBodySourceCode() const override; RoomCommand GetRoomCommand() const override; diff --git a/ZAPD/ZRoom/Commands/SetExitList.cpp b/ZAPD/ZRoom/Commands/SetExitList.cpp index f94ef21..80ccc6b 100644 --- a/ZAPD/ZRoom/Commands/SetExitList.cpp +++ b/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) @@ -44,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/ZAPD/ZRoom/Commands/SetRoomList.cpp b/ZAPD/ZRoom/Commands/SetRoomList.cpp index 3e68202..24969a1 100644 --- a/ZAPD/ZRoom/Commands/SetRoomList.cpp +++ b/ZAPD/ZRoom/Commands/SetRoomList.cpp @@ -105,8 +105,9 @@ std::string RomFile::GetBodySourceCode() const if (!isFirst) declaration += "\n"; - declaration += StringHelper::Sprintf("\t{ (uintptr_t)_%sSegmentRomStart, (uintptr_t)_%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/ZAPD/ZRoom/ZNames.h b/ZAPD/ZRoom/ZNames.h index 94e08de..667407c 100644 --- a/ZAPD/ZRoom/ZNames.h +++ b/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(); } }; |
