diff options
Diffstat (limited to 'tools')
| -rw-r--r-- | tools/validator/human_processor.cpp | 20 | ||||
| -rw-r--r-- | tools/validator/structs.h | 9 | ||||
| -rw-r--r-- | tools/validator/validator.cpp | 12 |
3 files changed, 40 insertions, 1 deletions
| diff --git a/tools/validator/human_processor.cpp b/tools/validator/human_processor.cpp index 26aee56..0846bb8 100644 --- a/tools/validator/human_processor.cpp +++ b/tools/validator/human_processor.cpp | |||
| @@ -114,9 +114,14 @@ class HumanProcessor { | |||
| 114 | panel_info.definitions.push_back(h_panel); | 114 | panel_info.definitions.push_back(h_panel); |
| 115 | panel_info.proxies[h_panel.answer()].definitions.push_back(Proxy()); | 115 | panel_info.proxies[h_panel.answer()].definitions.push_back(Proxy()); |
| 116 | 116 | ||
| 117 | MapInfo& map_info = info_.maps[current_map_name]; | ||
| 118 | map_info.game_nodes[h_panel.path()].uses++; | ||
| 119 | |||
| 117 | for (const Proxy& h_proxy : h_panel.proxies()) { | 120 | for (const Proxy& h_proxy : h_panel.proxies()) { |
| 118 | ProxyInfo& proxy_info = panel_info.proxies[h_proxy.answer()]; | 121 | ProxyInfo& proxy_info = panel_info.proxies[h_proxy.answer()]; |
| 119 | proxy_info.definitions.push_back(h_proxy); | 122 | proxy_info.definitions.push_back(h_proxy); |
| 123 | |||
| 124 | map_info.game_nodes[h_proxy.path()].uses++; | ||
| 120 | } | 125 | } |
| 121 | 126 | ||
| 122 | if (h_panel.has_required_door()) { | 127 | if (h_panel.has_required_door()) { |
| @@ -145,6 +150,9 @@ class HumanProcessor { | |||
| 145 | PaintingInfo& painting_info = info_.paintings[painting_identifier]; | 150 | PaintingInfo& painting_info = info_.paintings[painting_identifier]; |
| 146 | painting_info.definitions.push_back(h_painting); | 151 | painting_info.definitions.push_back(h_painting); |
| 147 | 152 | ||
| 153 | MapInfo& map_info = info_.maps[current_map_name]; | ||
| 154 | map_info.game_nodes[h_painting.path()].uses++; | ||
| 155 | |||
| 148 | if (h_painting.has_required_door()) { | 156 | if (h_painting.has_required_door()) { |
| 149 | DoorIdentifier required_door_identifier = *GetCompleteDoorIdentifier( | 157 | DoorIdentifier required_door_identifier = *GetCompleteDoorIdentifier( |
| 150 | h_painting.required_door(), current_map_name); | 158 | h_painting.required_door(), current_map_name); |
| @@ -163,6 +171,9 @@ class HumanProcessor { | |||
| 163 | PortInfo& port_info = info_.ports[port_identifier]; | 171 | PortInfo& port_info = info_.ports[port_identifier]; |
| 164 | port_info.definitions.push_back(h_port); | 172 | port_info.definitions.push_back(h_port); |
| 165 | 173 | ||
| 174 | MapInfo& map_info = info_.maps[current_map_name]; | ||
| 175 | map_info.game_nodes[h_port.path()].uses++; | ||
| 176 | |||
| 166 | if (h_port.has_required_door()) { | 177 | if (h_port.has_required_door()) { |
| 167 | DoorIdentifier required_door_identifier = | 178 | DoorIdentifier required_door_identifier = |
| 168 | *GetCompleteDoorIdentifier(h_port.required_door(), current_map_name); | 179 | *GetCompleteDoorIdentifier(h_port.required_door(), current_map_name); |
| @@ -182,12 +193,16 @@ class HumanProcessor { | |||
| 182 | room_identifier.set_map(current_map_name); | 193 | room_identifier.set_map(current_map_name); |
| 183 | room_identifier.set_name(current_room_name); | 194 | room_identifier.set_name(current_room_name); |
| 184 | letter_info.defined_in.push_back(room_identifier); | 195 | letter_info.defined_in.push_back(room_identifier); |
| 196 | |||
| 197 | MapInfo& map_info = info_.maps[current_map_name]; | ||
| 198 | map_info.game_nodes[h_letter.path()].uses++; | ||
| 185 | } | 199 | } |
| 186 | 200 | ||
| 187 | void ProcessMastery(const HumanMastery& h_mastery, | 201 | void ProcessMastery(const HumanMastery& h_mastery, |
| 188 | const std::string& current_map_name, | 202 | const std::string& current_map_name, |
| 189 | const std::string& current_room_name) { | 203 | const std::string& current_room_name) { |
| 190 | // Nothing really to validate about masteries yet. | 204 | MapInfo& map_info = info_.maps[current_map_name]; |
| 205 | map_info.game_nodes[h_mastery.path()].uses++; | ||
| 191 | } | 206 | } |
| 192 | 207 | ||
| 193 | void ProcessKeyholder(const HumanKeyholder& h_keyholder, | 208 | void ProcessKeyholder(const HumanKeyholder& h_keyholder, |
| @@ -200,6 +215,9 @@ class HumanProcessor { | |||
| 200 | 215 | ||
| 201 | KeyholderInfo& keyholder_info = info_.keyholders[keyholder_identifier]; | 216 | KeyholderInfo& keyholder_info = info_.keyholders[keyholder_identifier]; |
| 202 | keyholder_info.definitions.push_back(h_keyholder); | 217 | keyholder_info.definitions.push_back(h_keyholder); |
| 218 | |||
| 219 | MapInfo& map_info = info_.maps[current_map_name]; | ||
| 220 | map_info.game_nodes[h_keyholder.path()].uses++; | ||
| 203 | } | 221 | } |
| 204 | 222 | ||
| 205 | void ProcessDoorsFile(std::filesystem::path path, | 223 | void ProcessDoorsFile(std::filesystem::path path, |
| diff --git a/tools/validator/structs.h b/tools/validator/structs.h index c3427f4..1b61f77 100644 --- a/tools/validator/structs.h +++ b/tools/validator/structs.h | |||
| @@ -20,6 +20,14 @@ struct MalformedIdentifiers { | |||
| 20 | } | 20 | } |
| 21 | }; | 21 | }; |
| 22 | 22 | ||
| 23 | struct GameNodeInfo { | ||
| 24 | int uses = 0; | ||
| 25 | }; | ||
| 26 | |||
| 27 | struct MapInfo { | ||
| 28 | std::map<std::string, GameNodeInfo> game_nodes; | ||
| 29 | }; | ||
| 30 | |||
| 23 | struct RoomInfo { | 31 | struct RoomInfo { |
| 24 | std::vector<HumanRoom> definitions; | 32 | std::vector<HumanRoom> definitions; |
| 25 | 33 | ||
| @@ -82,6 +90,7 @@ struct LetterInfo { | |||
| 82 | }; | 90 | }; |
| 83 | 91 | ||
| 84 | struct CollectedInfo { | 92 | struct CollectedInfo { |
| 93 | std::map<std::string, MapInfo> maps; | ||
| 85 | std::map<RoomIdentifier, RoomInfo, RoomIdentifierLess> rooms; | 94 | std::map<RoomIdentifier, RoomInfo, RoomIdentifierLess> rooms; |
| 86 | std::map<DoorIdentifier, DoorInfo, DoorIdentifierLess> doors; | 95 | std::map<DoorIdentifier, DoorInfo, DoorIdentifierLess> doors; |
| 87 | std::map<PortIdentifier, PortInfo, PortIdentifierLess> ports; | 96 | std::map<PortIdentifier, PortInfo, PortIdentifierLess> ports; |
| diff --git a/tools/validator/validator.cpp b/tools/validator/validator.cpp index 3381ed2..f2ec280 100644 --- a/tools/validator/validator.cpp +++ b/tools/validator/validator.cpp | |||
| @@ -9,6 +9,15 @@ | |||
| 9 | namespace com::fourisland::lingo2_archipelago { | 9 | namespace com::fourisland::lingo2_archipelago { |
| 10 | namespace { | 10 | namespace { |
| 11 | 11 | ||
| 12 | void ValidateMap(const std::string& map_name, const MapInfo& map_info) { | ||
| 13 | for (const auto& [node_path, node_info] : map_info.game_nodes) { | ||
| 14 | if (node_info.uses > 1) { | ||
| 15 | std::cout << "Map " << map_name << " node " << node_path | ||
| 16 | << " is used in multiple places." << std::endl; | ||
| 17 | } | ||
| 18 | } | ||
| 19 | } | ||
| 20 | |||
| 12 | void ValidateRoom(const RoomIdentifier& room_identifier, | 21 | void ValidateRoom(const RoomIdentifier& room_identifier, |
| 13 | const RoomInfo& room_info) { | 22 | const RoomInfo& room_info) { |
| 14 | if (room_info.definitions.empty()) { | 23 | if (room_info.definitions.empty()) { |
| @@ -224,6 +233,9 @@ void ValidateLetter(const LetterIdentifier& letter_identifier, | |||
| 224 | } // namespace | 233 | } // namespace |
| 225 | 234 | ||
| 226 | void ValidateCollectedInfo(const CollectedInfo& info) { | 235 | void ValidateCollectedInfo(const CollectedInfo& info) { |
| 236 | for (const auto& [map_name, map_info] : info.maps) { | ||
| 237 | ValidateMap(map_name, map_info); | ||
| 238 | } | ||
| 227 | for (const auto& [room_identifier, room_info] : info.rooms) { | 239 | for (const auto& [room_identifier, room_info] : info.rooms) { |
| 228 | ValidateRoom(room_identifier, room_info); | 240 | ValidateRoom(room_identifier, room_info); |
| 229 | } | 241 | } |
