diff options
Diffstat (limited to 'tools/validator')
| -rw-r--r-- | tools/validator/human_processor.cpp | 20 | ||||
| -rw-r--r-- | tools/validator/structs.h | 5 | ||||
| -rw-r--r-- | tools/validator/validator.cpp | 15 |
3 files changed, 39 insertions, 1 deletions
| diff --git a/tools/validator/human_processor.cpp b/tools/validator/human_processor.cpp index af40980..5a7e78a 100644 --- a/tools/validator/human_processor.cpp +++ b/tools/validator/human_processor.cpp | |||
| @@ -62,7 +62,7 @@ class HumanProcessor { | |||
| 62 | } | 62 | } |
| 63 | 63 | ||
| 64 | void ProcessMetadataFile(std::filesystem::path path, | 64 | void ProcessMetadataFile(std::filesystem::path path, |
| 65 | const std::string& current_map_name) { | 65 | const std::string& current_map_name) { |
| 66 | if (!std::filesystem::exists(path)) { | 66 | if (!std::filesystem::exists(path)) { |
| 67 | return; | 67 | return; |
| 68 | } | 68 | } |
| @@ -115,6 +115,10 @@ class HumanProcessor { | |||
| 115 | for (const HumanKeyholder& h_keyholder : h_room.keyholders()) { | 115 | for (const HumanKeyholder& h_keyholder : h_room.keyholders()) { |
| 116 | ProcessKeyholder(h_keyholder, current_map_name, h_room.name()); | 116 | ProcessKeyholder(h_keyholder, current_map_name, h_room.name()); |
| 117 | } | 117 | } |
| 118 | |||
| 119 | for (const HumanEnding& h_ending : h_room.endings()) { | ||
| 120 | ProcessEnding(h_ending, current_map_name, h_room.name()); | ||
| 121 | } | ||
| 118 | } | 122 | } |
| 119 | 123 | ||
| 120 | void ProcessPanel(const HumanPanel& h_panel, | 124 | void ProcessPanel(const HumanPanel& h_panel, |
| @@ -235,6 +239,20 @@ class HumanProcessor { | |||
| 235 | map_info.game_nodes[h_keyholder.path()].uses++; | 239 | map_info.game_nodes[h_keyholder.path()].uses++; |
| 236 | } | 240 | } |
| 237 | 241 | ||
| 242 | void ProcessEnding(const HumanEnding& h_ending, | ||
| 243 | const std::string& current_map_name, | ||
| 244 | const std::string& current_room_name) { | ||
| 245 | EndingInfo& ending_info = info_.endings[h_ending.name()]; | ||
| 246 | |||
| 247 | RoomIdentifier room_identifier; | ||
| 248 | room_identifier.set_map(current_map_name); | ||
| 249 | room_identifier.set_name(current_room_name); | ||
| 250 | ending_info.defined_in.push_back(room_identifier); | ||
| 251 | |||
| 252 | MapInfo& map_info = info_.maps[current_map_name]; | ||
| 253 | map_info.game_nodes[h_ending.path()].uses++; | ||
| 254 | } | ||
| 255 | |||
| 238 | void ProcessDoorsFile(std::filesystem::path path, | 256 | void ProcessDoorsFile(std::filesystem::path path, |
| 239 | const std::string& current_map_name) { | 257 | const std::string& current_map_name) { |
| 240 | if (!std::filesystem::exists(path)) { | 258 | if (!std::filesystem::exists(path)) { |
| diff --git a/tools/validator/structs.h b/tools/validator/structs.h index 406dc0c..f7d9dc1 100644 --- a/tools/validator/structs.h +++ b/tools/validator/structs.h | |||
| @@ -90,6 +90,10 @@ struct LetterInfo { | |||
| 90 | std::vector<RoomIdentifier> defined_in; | 90 | std::vector<RoomIdentifier> defined_in; |
| 91 | }; | 91 | }; |
| 92 | 92 | ||
| 93 | struct EndingInfo { | ||
| 94 | std::vector<RoomIdentifier> defined_in; | ||
| 95 | }; | ||
| 96 | |||
| 93 | struct CollectedInfo { | 97 | struct CollectedInfo { |
| 94 | std::map<std::string, MapInfo> maps; | 98 | std::map<std::string, MapInfo> maps; |
| 95 | std::map<RoomIdentifier, RoomInfo, RoomIdentifierLess> rooms; | 99 | std::map<RoomIdentifier, RoomInfo, RoomIdentifierLess> rooms; |
| @@ -100,6 +104,7 @@ struct CollectedInfo { | |||
| 100 | std::map<KeyholderIdentifier, KeyholderInfo, KeyholderIdentifierLess> | 104 | std::map<KeyholderIdentifier, KeyholderInfo, KeyholderIdentifierLess> |
| 101 | keyholders; | 105 | keyholders; |
| 102 | std::map<LetterIdentifier, LetterInfo> letters; | 106 | std::map<LetterIdentifier, LetterInfo> letters; |
| 107 | std::map<std::string, EndingInfo> endings; | ||
| 103 | }; | 108 | }; |
| 104 | 109 | ||
| 105 | } // namespace com::fourisland::lingo2_archipelago | 110 | } // namespace com::fourisland::lingo2_archipelago |
| diff --git a/tools/validator/validator.cpp b/tools/validator/validator.cpp index 6d01b7c..bc6b854 100644 --- a/tools/validator/validator.cpp +++ b/tools/validator/validator.cpp | |||
| @@ -238,6 +238,18 @@ void ValidateLetter(const LetterIdentifier& letter_identifier, | |||
| 238 | } | 238 | } |
| 239 | } | 239 | } |
| 240 | 240 | ||
| 241 | void ValidateEnding(const std::string& ending_name, | ||
| 242 | const EndingInfo& ending_info) { | ||
| 243 | if (ending_info.defined_in.size() > 1) { | ||
| 244 | std::cout << "Ending " << ending_name | ||
| 245 | << " was defined in multiple places:" << std::endl; | ||
| 246 | |||
| 247 | for (const RoomIdentifier& room_identifier : ending_info.defined_in) { | ||
| 248 | std::cout << " " << room_identifier.ShortDebugString() << std::endl; | ||
| 249 | } | ||
| 250 | } | ||
| 251 | } | ||
| 252 | |||
| 241 | } // namespace | 253 | } // namespace |
| 242 | 254 | ||
| 243 | void ValidateCollectedInfo(const CollectedInfo& info) { | 255 | void ValidateCollectedInfo(const CollectedInfo& info) { |
| @@ -265,6 +277,9 @@ void ValidateCollectedInfo(const CollectedInfo& info) { | |||
| 265 | for (const auto& [letter_identifier, letter_info] : info.letters) { | 277 | for (const auto& [letter_identifier, letter_info] : info.letters) { |
| 266 | ValidateLetter(letter_identifier, letter_info); | 278 | ValidateLetter(letter_identifier, letter_info); |
| 267 | } | 279 | } |
| 280 | for (const auto& [ending_name, ending_info] : info.endings) { | ||
| 281 | ValidateEnding(ending_name, ending_info); | ||
| 282 | } | ||
| 268 | } | 283 | } |
| 269 | 284 | ||
| 270 | } // namespace com::fourisland::lingo2_archipelago | 285 | } // namespace com::fourisland::lingo2_archipelago |
