From 6158d288829cc6e16809a873c0ec70a3ff59dad9 Mon Sep 17 00:00:00 2001 From: Martin Michelsen Date: Thu, 21 Apr 2022 11:33:16 -0700 Subject: [PATCH] fix ep2/4 government quest indexing --- README.md | 2 +- src/Quest.cc | 50 ++++++++++++++++++++++++++------------------------ 2 files changed, 27 insertions(+), 25 deletions(-) diff --git a/README.md b/README.md index 344e1f25..0d55b79e 100644 --- a/README.md +++ b/README.md @@ -42,7 +42,7 @@ There are multiple PSO quest formats out there; newserv supports most of them. S Standard quest file names should be like `q###-CATEGORY-VERSION.EXT`; battle quests should be named like `b###-VERSION.EXT`, and challenge quests should be named like `c###-VERSION.EXT`. The fields in each filename are: - `###`: quest number (this doesn't really matter; it should just be unique for the version) -- `CATEGORY`: ret = Retrieval, ext = Extermination, evt = Events, shp = Shops, vr = VR, twr = Tower, dl = Download (these don't appear during online play), 1p = Solo (BB only) +- `CATEGORY`: ret = Retrieval, ext = Extermination, evt = Events, shp = Shops, vr = VR, twr = Tower, gov = Government (BB only), dl = Download (these don't appear during online play), 1p = Solo (BB only) - `VERSION`: d1 = DreamCast v1, dc = DreamCast v2, pc = PC, gc = GameCube Episodes 1 & 2, gc3 = Episode 3, bb = Blue Burst - `EXT`: file extension (bin, dat, bin.gci, dat.gci, bin.dlq, dat.dlq, or qst) diff --git a/src/Quest.cc b/src/Quest.cc index 4e3125d2..b9b924b2 100644 --- a/src/Quest.cc +++ b/src/Quest.cc @@ -208,29 +208,20 @@ Quest::Quest(const string& bin_filename) // get the category from the second token if needed if (this->category == QuestCategory::UNKNOWN) { - if (tokens[1] == "gov") { - if (this->episode == 0) { - this->category = QuestCategory::GOVERNMENT_EPISODE_1; - } else if (this->episode == 1) { - this->category = QuestCategory::GOVERNMENT_EPISODE_2; - } else if (this->episode == 2) { - this->category = QuestCategory::GOVERNMENT_EPISODE_4; - } else { - throw invalid_argument("government quest has incorrect episode"); - } - } else { - static const unordered_map name_to_category({ - {"ret", QuestCategory::RETRIEVAL}, - {"ext", QuestCategory::EXTERMINATION}, - {"evt", QuestCategory::EVENT}, - {"shp", QuestCategory::SHOP}, - {"vr", QuestCategory::VR}, - {"twr", QuestCategory::TOWER}, - {"dl", QuestCategory::DOWNLOAD}, - {"1p", QuestCategory::SOLO}, - }); - this->category = name_to_category.at(tokens[1]); - } + static const unordered_map name_to_category({ + {"ret", QuestCategory::RETRIEVAL}, + {"ext", QuestCategory::EXTERMINATION}, + {"evt", QuestCategory::EVENT}, + {"shp", QuestCategory::SHOP}, + {"vr", QuestCategory::VR}, + {"twr", QuestCategory::TOWER}, + // Note: This will be overwritten later for Episode 2 & 4 quests - we + // haven't parsed the episode from the quest script yet + {"gov", QuestCategory::GOVERNMENT_EPISODE_1}, + {"dl", QuestCategory::DOWNLOAD}, + {"1p", QuestCategory::SOLO}, + }); + this->category = name_to_category.at(tokens[1]); tokens.erase(tokens.begin() + 1); } @@ -318,9 +309,20 @@ Quest::Quest(const string& bin_filename) this->name = header->name; this->short_description = header->short_description; this->long_description = header->long_description; + if (this->category == QuestCategory::GOVERNMENT_EPISODE_1) { + if (this->episode == 1) { + this->category = QuestCategory::GOVERNMENT_EPISODE_2; + } else if (this->episode == 2) { + this->category = QuestCategory::GOVERNMENT_EPISODE_4; + } else if (this->episode != 0) { + throw invalid_argument("government quest has invalid episode number"); + } + } break; - } + + default: + throw logic_error("invalid quest game version"); } }