diff options
Diffstat (limited to 'tools/validator/validator.cpp')
| -rw-r--r-- | tools/validator/validator.cpp | 550 |
1 files changed, 550 insertions, 0 deletions
| diff --git a/tools/validator/validator.cpp b/tools/validator/validator.cpp new file mode 100644 index 0000000..dd41f5c --- /dev/null +++ b/tools/validator/validator.cpp | |||
| @@ -0,0 +1,550 @@ | |||
| 1 | #include "validator.h" | ||
| 2 | |||
| 3 | #include <iostream> | ||
| 4 | |||
| 5 | #include "proto/human.pb.h" | ||
| 6 | #include "structs.h" | ||
| 7 | #include "util/identifiers.h" | ||
| 8 | |||
| 9 | namespace com::fourisland::lingo2_archipelago { | ||
| 10 | namespace { | ||
| 11 | |||
| 12 | class Validator { | ||
| 13 | public: | ||
| 14 | explicit Validator(const CollectedInfo& info) : info_(info) {} | ||
| 15 | |||
| 16 | void Validate() const { | ||
| 17 | for (const auto& [map_name, map_info] : info_.maps) { | ||
| 18 | ValidateMap(map_name, map_info); | ||
| 19 | } | ||
| 20 | for (const auto& [room_identifier, room_info] : info_.rooms) { | ||
| 21 | ValidateRoom(room_identifier, room_info); | ||
| 22 | } | ||
| 23 | for (const auto& [door_identifier, door_info] : info_.doors) { | ||
| 24 | ValidateDoor(door_identifier, door_info); | ||
| 25 | } | ||
| 26 | for (const auto& [port_identifier, port_info] : info_.ports) { | ||
| 27 | ValidatePort(port_identifier, port_info); | ||
| 28 | } | ||
| 29 | for (const auto& [painting_identifier, painting_info] : info_.paintings) { | ||
| 30 | ValidatePainting(painting_identifier, painting_info); | ||
| 31 | } | ||
| 32 | for (const auto& [panel_identifier, panel_info] : info_.panels) { | ||
| 33 | ValidatePanel(panel_identifier, panel_info); | ||
| 34 | } | ||
| 35 | for (const auto& [keyholder_identifier, keyholder_info] : | ||
| 36 | info_.keyholders) { | ||
| 37 | ValidateKeyholder(keyholder_identifier, keyholder_info); | ||
| 38 | } | ||
| 39 | for (const auto& [letter_identifier, letter_info] : info_.letters) { | ||
| 40 | ValidateLetter(letter_identifier, letter_info); | ||
| 41 | } | ||
| 42 | for (const auto& [ending_name, ending_info] : info_.endings) { | ||
| 43 | ValidateEnding(ending_name, ending_info); | ||
| 44 | } | ||
| 45 | for (const auto& [panel_name, panel_info] : info_.panel_names) { | ||
| 46 | ValidatePanelName(panel_name, panel_info); | ||
| 47 | } | ||
| 48 | for (const auto& [prog_name, prog_info] : info_.progressives) { | ||
| 49 | ValidateProgressive(prog_name, prog_info); | ||
| 50 | } | ||
| 51 | for (const auto& [group_name, group_info] : info_.door_groups) { | ||
| 52 | ValidateDoorGroup(group_name, group_info); | ||
| 53 | } | ||
| 54 | } | ||
| 55 | |||
| 56 | private: | ||
| 57 | void ValidateMap(const std::string& map_name, const MapInfo& map_info) const { | ||
| 58 | for (const auto& [node_path, node_info] : map_info.game_nodes) { | ||
| 59 | if (node_info.uses > 1) { | ||
| 60 | std::cout << "Map " << map_name << " node " << node_path | ||
| 61 | << " is used in multiple places." << std::endl; | ||
| 62 | } else if (node_info.uses == 0) { | ||
| 63 | std::cout << "Map " << map_name << " node " << node_path | ||
| 64 | << " is not used." << std::endl; | ||
| 65 | } | ||
| 66 | |||
| 67 | if (!node_info.defined) { | ||
| 68 | std::cout << "Map " << map_name << " node " << node_path | ||
| 69 | << " is not defined in the game file." << std::endl; | ||
| 70 | } | ||
| 71 | } | ||
| 72 | } | ||
| 73 | |||
| 74 | void ValidateRoom(const RoomIdentifier& room_identifier, | ||
| 75 | const RoomInfo& room_info) const { | ||
| 76 | if (room_info.definitions.empty()) { | ||
| 77 | std::cout << "Room " << room_identifier.ShortDebugString() | ||
| 78 | << " has no definition, but was referenced:" << std::endl; | ||
| 79 | |||
| 80 | for (const DoorIdentifier& door_identifier : | ||
| 81 | room_info.doors_referenced_by) { | ||
| 82 | std::cout << " DOOR " << door_identifier.ShortDebugString() | ||
| 83 | << std::endl; | ||
| 84 | } | ||
| 85 | |||
| 86 | for (const PanelIdentifier& panel_identifier : | ||
| 87 | room_info.panels_referenced_by) { | ||
| 88 | std::cout << " PANEL " << panel_identifier.ShortDebugString() | ||
| 89 | << std::endl; | ||
| 90 | } | ||
| 91 | |||
| 92 | for (const HumanConnection& connection : | ||
| 93 | room_info.connections_referenced_by) { | ||
| 94 | std::cout << " CONNECTION " << connection.ShortDebugString() | ||
| 95 | << std::endl; | ||
| 96 | } | ||
| 97 | } else if (room_info.definitions.size() > 1) { | ||
| 98 | std::cout << "Room " << room_identifier.ShortDebugString() | ||
| 99 | << " was defined multiple times." << std::endl; | ||
| 100 | } | ||
| 101 | } | ||
| 102 | |||
| 103 | bool DoesDoorNeedLocationName(const HumanDoor& h_door, | ||
| 104 | const std::string& map_name) const { | ||
| 105 | if (h_door.type() != DoorType::STANDARD) { | ||
| 106 | return false; | ||
| 107 | } | ||
| 108 | |||
| 109 | if (h_door.keyholders_size() > 0 || h_door.endings_size() > 0 || | ||
| 110 | h_door.complete_at() > 0) { | ||
| 111 | return true; | ||
| 112 | } | ||
| 113 | |||
| 114 | if (h_door.panels_size() > 4) { | ||
| 115 | return true; | ||
| 116 | } | ||
| 117 | |||
| 118 | std::set<std::string> map_areas; | ||
| 119 | for (const PanelIdentifier& pi : h_door.panels()) { | ||
| 120 | auto full_pi = | ||
| 121 | GetCompletePanelIdentifierWithoutAnswer(pi, map_name, std::nullopt); | ||
| 122 | if (full_pi) { | ||
| 123 | auto panel_info_it = info_.panels.find(*full_pi); | ||
| 124 | if (panel_info_it != info_.panels.end()) { | ||
| 125 | const PanelInfo& panel_info = panel_info_it->second; | ||
| 126 | |||
| 127 | map_areas.insert(panel_info.map_area_name); | ||
| 128 | } | ||
| 129 | } | ||
| 130 | } | ||
| 131 | |||
| 132 | if (map_areas.size() > 1) { | ||
| 133 | return true; | ||
| 134 | } | ||
| 135 | |||
| 136 | return false; | ||
| 137 | } | ||
| 138 | |||
| 139 | void ValidateDoor(const DoorIdentifier& door_identifier, | ||
| 140 | const DoorInfo& door_info) const { | ||
| 141 | if (door_info.definitions.empty()) { | ||
| 142 | std::cout << "Door " << door_identifier.ShortDebugString() | ||
| 143 | << " has no definition, but was referenced:" << std::endl; | ||
| 144 | |||
| 145 | for (const DoorIdentifier& other_door_identifier : | ||
| 146 | door_info.doors_referenced_by) { | ||
| 147 | std::cout << " DOOR " << other_door_identifier.ShortDebugString() | ||
| 148 | << std::endl; | ||
| 149 | } | ||
| 150 | |||
| 151 | for (const PanelIdentifier& panel_identifier : | ||
| 152 | door_info.panels_referenced_by) { | ||
| 153 | std::cout << " PANEL " << panel_identifier.ShortDebugString() | ||
| 154 | << std::endl; | ||
| 155 | } | ||
| 156 | |||
| 157 | for (const PaintingIdentifier& painting_identifier : | ||
| 158 | door_info.paintings_referenced_by) { | ||
| 159 | std::cout << " PAINTING " << painting_identifier.ShortDebugString() | ||
| 160 | << std::endl; | ||
| 161 | } | ||
| 162 | |||
| 163 | for (const PortIdentifier& port_identifier : | ||
| 164 | door_info.ports_referenced_by) { | ||
| 165 | std::cout << " PORT " << port_identifier.ShortDebugString() | ||
| 166 | << std::endl; | ||
| 167 | } | ||
| 168 | |||
| 169 | for (const HumanConnection& connection : | ||
| 170 | door_info.connections_referenced_by) { | ||
| 171 | std::cout << " CONNECTION " << connection.ShortDebugString() | ||
| 172 | << std::endl; | ||
| 173 | } | ||
| 174 | |||
| 175 | for (const std::string& prog_name : | ||
| 176 | door_info.progressives_referenced_by) { | ||
| 177 | std::cout << " PROGRESSIVE " << prog_name << std::endl; | ||
| 178 | } | ||
| 179 | |||
| 180 | for (const std::string& group_name : | ||
| 181 | door_info.door_groups_referenced_by) { | ||
| 182 | std::cout << " DOOR GROUP " << group_name << std::endl; | ||
| 183 | } | ||
| 184 | |||
| 185 | if (door_info.has_id) { | ||
| 186 | std::cout << " An AP ID is present." << std::endl; | ||
| 187 | } | ||
| 188 | } else if (door_info.definitions.size() > 1) { | ||
| 189 | std::cout << "Door " << door_identifier.ShortDebugString() | ||
| 190 | << " was defined multiple times." << std::endl; | ||
| 191 | } | ||
| 192 | |||
| 193 | if (door_info.malformed_identifiers.HasAny()) { | ||
| 194 | std::cout << "Door " << door_identifier.ShortDebugString() | ||
| 195 | << " has malformed identifiers:" << std::endl; | ||
| 196 | |||
| 197 | for (const PaintingIdentifier& painting_identifier : | ||
| 198 | door_info.malformed_identifiers.paintings) { | ||
| 199 | std::cout << " PAINTING " << painting_identifier.ShortDebugString() | ||
| 200 | << std::endl; | ||
| 201 | } | ||
| 202 | |||
| 203 | for (const PanelIdentifier& panel_identifier : | ||
| 204 | door_info.malformed_identifiers.panels) { | ||
| 205 | std::cout << " PANEL " << panel_identifier.ShortDebugString() | ||
| 206 | << std::endl; | ||
| 207 | } | ||
| 208 | |||
| 209 | for (const KeyholderIdentifier& keyholder_identifier : | ||
| 210 | door_info.malformed_identifiers.keyholders) { | ||
| 211 | std::cout << " KEYHOLDER " << keyholder_identifier.ShortDebugString() | ||
| 212 | << std::endl; | ||
| 213 | } | ||
| 214 | } | ||
| 215 | |||
| 216 | for (const HumanDoor& h_door : door_info.definitions) { | ||
| 217 | if (DoesDoorNeedLocationName(h_door, door_identifier.map()) && | ||
| 218 | !h_door.has_location_name()) { | ||
| 219 | std::cout << "Door " << door_identifier.ShortDebugString() | ||
| 220 | << " needs an explicit location name." << std::endl; | ||
| 221 | } | ||
| 222 | |||
| 223 | if (h_door.double_letters() && | ||
| 224 | (h_door.type() == DoorType::STANDARD || | ||
| 225 | h_door.type() == DoorType::LOCATION_ONLY || | ||
| 226 | h_door.type() == DoorType::GRAVESTONE)) { | ||
| 227 | std::cout << "Door " << door_identifier.ShortDebugString() | ||
| 228 | << " is a location that depends on double_letters." | ||
| 229 | << std::endl; | ||
| 230 | } | ||
| 231 | |||
| 232 | bool needs_id = (h_door.type() != DoorType::EVENT); | ||
| 233 | if (door_info.has_id != needs_id) { | ||
| 234 | if (needs_id) { | ||
| 235 | std::cout << "Door " << door_identifier.ShortDebugString() | ||
| 236 | << " is missing an AP ID." << std::endl; | ||
| 237 | } else { | ||
| 238 | std::cout << "Door " << door_identifier.ShortDebugString() | ||
| 239 | << " should not have an AP ID." << std::endl; | ||
| 240 | } | ||
| 241 | } | ||
| 242 | } | ||
| 243 | } | ||
| 244 | |||
| 245 | void ValidatePort(const PortIdentifier& port_identifier, | ||
| 246 | const PortInfo& port_info) const { | ||
| 247 | if (port_info.definitions.empty()) { | ||
| 248 | std::cout << "Port " << port_identifier.ShortDebugString() | ||
| 249 | << " has no definition, but was referenced:" << std::endl; | ||
| 250 | |||
| 251 | for (const HumanConnection& connection : | ||
| 252 | port_info.connections_referenced_by) { | ||
| 253 | std::cout << " CONNECTION " << connection.ShortDebugString() | ||
| 254 | << std::endl; | ||
| 255 | } | ||
| 256 | } else if (port_info.definitions.size() > 1) { | ||
| 257 | std::cout << "Port " << port_identifier.ShortDebugString() | ||
| 258 | << " was defined multiple times." << std::endl; | ||
| 259 | } | ||
| 260 | |||
| 261 | if (!port_info.target_connections_referenced_by.empty()) { | ||
| 262 | for (const HumanPort& port : port_info.definitions) { | ||
| 263 | if (port.has_required_door()) { | ||
| 264 | std::cout << "Port " << port_identifier.ShortDebugString() | ||
| 265 | << " has a required door but is the target of a connection:" | ||
| 266 | << std::endl; | ||
| 267 | |||
| 268 | for (const HumanConnection& connection : | ||
| 269 | port_info.target_connections_referenced_by) { | ||
| 270 | std::cout << " CONNECTION " << connection.ShortDebugString() | ||
| 271 | << std::endl; | ||
| 272 | } | ||
| 273 | } | ||
| 274 | } | ||
| 275 | } | ||
| 276 | } | ||
| 277 | |||
| 278 | void ValidatePainting(const PaintingIdentifier& painting_identifier, | ||
| 279 | const PaintingInfo& painting_info) const { | ||
| 280 | if (painting_info.definitions.empty()) { | ||
| 281 | std::cout << "Painting " << painting_identifier.ShortDebugString() | ||
| 282 | << " has no definition, but was referenced:" << std::endl; | ||
| 283 | |||
| 284 | for (const DoorIdentifier& door_identifier : | ||
| 285 | painting_info.doors_referenced_by) { | ||
| 286 | std::cout << " DOOR " << door_identifier.ShortDebugString() | ||
| 287 | << std::endl; | ||
| 288 | } | ||
| 289 | |||
| 290 | for (const HumanConnection& connection : | ||
| 291 | painting_info.connections_referenced_by) { | ||
| 292 | std::cout << " CONNECTION " << connection.ShortDebugString() | ||
| 293 | << std::endl; | ||
| 294 | } | ||
| 295 | } else if (painting_info.definitions.size() > 1) { | ||
| 296 | std::cout << "Painting " << painting_identifier.ShortDebugString() | ||
| 297 | << " was defined multiple times." << std::endl; | ||
| 298 | } | ||
| 299 | |||
| 300 | if (!painting_info.target_connections_referenced_by.empty()) { | ||
| 301 | for (const HumanPainting& painting : painting_info.definitions) { | ||
| 302 | if (painting.has_required_door()) { | ||
| 303 | std::cout << "Painting " << painting_identifier.ShortDebugString() | ||
| 304 | << " has a required door but is the target of a connection:" | ||
| 305 | << std::endl; | ||
| 306 | |||
| 307 | for (const HumanConnection& connection : | ||
| 308 | painting_info.target_connections_referenced_by) { | ||
| 309 | std::cout << " CONNECTION " << connection.ShortDebugString() | ||
| 310 | << std::endl; | ||
| 311 | } | ||
| 312 | } | ||
| 313 | } | ||
| 314 | } | ||
| 315 | } | ||
| 316 | |||
| 317 | void ValidatePanel(const PanelIdentifier& panel_identifier, | ||
| 318 | const PanelInfo& panel_info) const { | ||
| 319 | if (panel_identifier.name().empty()) { | ||
| 320 | std::cout << "Panel " << panel_identifier.ShortDebugString() | ||
| 321 | << " has no name." << std::endl; | ||
| 322 | } | ||
| 323 | |||
| 324 | if (panel_info.definitions.empty()) { | ||
| 325 | std::cout << "Panel " << panel_identifier.ShortDebugString() | ||
| 326 | << " has no definition, but was referenced:" << std::endl; | ||
| 327 | |||
| 328 | for (const DoorIdentifier& door_identifier : | ||
| 329 | panel_info.doors_referenced_by) { | ||
| 330 | std::cout << " DOOR " << door_identifier.ShortDebugString() | ||
| 331 | << std::endl; | ||
| 332 | } | ||
| 333 | |||
| 334 | for (const HumanConnection& connection : | ||
| 335 | panel_info.connections_referenced_by) { | ||
| 336 | std::cout << " CONNECTION " << connection.ShortDebugString() | ||
| 337 | << std::endl; | ||
| 338 | } | ||
| 339 | |||
| 340 | if (panel_info.has_id) { | ||
| 341 | std::cout << " An AP ID is present." << std::endl; | ||
| 342 | } | ||
| 343 | } else if (panel_info.definitions.size() > 1) { | ||
| 344 | std::cout << "Panel " << panel_identifier.ShortDebugString() | ||
| 345 | << " was defined multiple times." << std::endl; | ||
| 346 | } | ||
| 347 | |||
| 348 | for (const auto& [answer, proxy_info] : panel_info.proxies) { | ||
| 349 | if (proxy_info.definitions.empty()) { | ||
| 350 | std::cout << "Panel " << panel_identifier.ShortDebugString() | ||
| 351 | << " with answer \"" << answer | ||
| 352 | << "\" has no definition, but was referenced:" << std::endl; | ||
| 353 | |||
| 354 | for (const DoorIdentifier& door_identifier : | ||
| 355 | proxy_info.doors_referenced_by) { | ||
| 356 | std::cout << " DOOR " << door_identifier.ShortDebugString() | ||
| 357 | << std::endl; | ||
| 358 | } | ||
| 359 | |||
| 360 | for (const HumanConnection& connection : | ||
| 361 | proxy_info.connections_referenced_by) { | ||
| 362 | std::cout << " CONNECTION " << connection.ShortDebugString() | ||
| 363 | << std::endl; | ||
| 364 | } | ||
| 365 | } else if (proxy_info.definitions.size() > 1) { | ||
| 366 | std::cout << "Panel " << panel_identifier.ShortDebugString() | ||
| 367 | << " with answer \"" << answer | ||
| 368 | << "\" was defined multiple times." << std::endl; | ||
| 369 | } | ||
| 370 | } | ||
| 371 | |||
| 372 | if (!panel_info.has_id) { | ||
| 373 | std::cout << "Panel " << panel_identifier.ShortDebugString() | ||
| 374 | << " is missing an AP ID." << std::endl; | ||
| 375 | } | ||
| 376 | |||
| 377 | if (!panel_info.target_connections_referenced_by.empty()) { | ||
| 378 | for (const HumanPanel& panel : panel_info.definitions) { | ||
| 379 | if (panel.has_required_door()) { | ||
| 380 | std::cout << "Panel " << panel_identifier.ShortDebugString() | ||
| 381 | << " has a required door but is the target of a connection:" | ||
| 382 | << std::endl; | ||
| 383 | |||
| 384 | for (const HumanConnection& connection : | ||
| 385 | panel_info.target_connections_referenced_by) { | ||
| 386 | std::cout << " CONNECTION " << connection.ShortDebugString() | ||
| 387 | << std::endl; | ||
| 388 | } | ||
| 389 | } | ||
| 390 | } | ||
| 391 | } | ||
| 392 | } | ||
| 393 | |||
| 394 | void ValidateKeyholder(const KeyholderIdentifier& keyholder_identifier, | ||
| 395 | const KeyholderInfo& keyholder_info) const { | ||
| 396 | if (keyholder_info.definitions.empty()) { | ||
| 397 | std::cout << "Keyholder " << keyholder_identifier.ShortDebugString() | ||
| 398 | << " has no definition, but was referenced:" << std::endl; | ||
| 399 | |||
| 400 | for (const DoorIdentifier& door_identifier : | ||
| 401 | keyholder_info.doors_referenced_by) { | ||
| 402 | std::cout << " DOOR " << door_identifier.ShortDebugString() | ||
| 403 | << std::endl; | ||
| 404 | } | ||
| 405 | |||
| 406 | if (keyholder_info.has_id) { | ||
| 407 | std::cout << " An AP ID is present." << std::endl; | ||
| 408 | } | ||
| 409 | } else if (keyholder_info.definitions.size() > 1) { | ||
| 410 | std::cout << "Keyholder " << keyholder_identifier.ShortDebugString() | ||
| 411 | << " was defined multiple times." << std::endl; | ||
| 412 | } | ||
| 413 | |||
| 414 | for (const HumanKeyholder& h_keyholder : keyholder_info.definitions) { | ||
| 415 | bool needs_id = (h_keyholder.has_key()); | ||
| 416 | |||
| 417 | if (needs_id != keyholder_info.has_id) { | ||
| 418 | if (needs_id) { | ||
| 419 | std::cout << "Keyholder " << keyholder_identifier.ShortDebugString() | ||
| 420 | << " is missing an AP ID." << std::endl; | ||
| 421 | } else { | ||
| 422 | std::cout << "Keyholder " << keyholder_identifier.ShortDebugString() | ||
| 423 | << " should not have an AP ID." << std::endl; | ||
| 424 | } | ||
| 425 | } | ||
| 426 | } | ||
| 427 | } | ||
| 428 | |||
| 429 | void ValidateLetter(const LetterIdentifier& letter_identifier, | ||
| 430 | const LetterInfo& letter_info) const { | ||
| 431 | std::string letter_name = std::string(1, std::get<0>(letter_identifier)) + | ||
| 432 | (std::get<1>(letter_identifier) ? "2" : "1"); | ||
| 433 | |||
| 434 | if (letter_info.defined_in.empty()) { | ||
| 435 | std::cout << "Letter " << letter_name | ||
| 436 | << " has no definition, but was referenced:" << std::endl; | ||
| 437 | |||
| 438 | if (letter_info.has_id) { | ||
| 439 | std::cout << " An AP ID is present." << std::endl; | ||
| 440 | } | ||
| 441 | } else if (letter_info.defined_in.size() > 1) { | ||
| 442 | std::cout << "Letter " << letter_name | ||
| 443 | << " was defined in multiple places:" << std::endl; | ||
| 444 | |||
| 445 | for (const RoomIdentifier& room_identifier : letter_info.defined_in) { | ||
| 446 | std::cout << " " << room_identifier.ShortDebugString() << std::endl; | ||
| 447 | } | ||
| 448 | } | ||
| 449 | |||
| 450 | if (!letter_info.has_id) { | ||
| 451 | std::cout << "Letter " << letter_name << " is missing an AP ID." | ||
| 452 | << std::endl; | ||
| 453 | } | ||
| 454 | } | ||
| 455 | |||
| 456 | void ValidateEnding(const std::string& ending_name, | ||
| 457 | const EndingInfo& ending_info) const { | ||
| 458 | if (ending_info.defined_in.empty()) { | ||
| 459 | std::cout << "Ending " << ending_name | ||
| 460 | << " has no definition, but was referenced:" << std::endl; | ||
| 461 | |||
| 462 | for (const DoorIdentifier& door_identifier : | ||
| 463 | ending_info.doors_referenced_by) { | ||
| 464 | std::cout << " DOOR " << door_identifier.ShortDebugString() | ||
| 465 | << std::endl; | ||
| 466 | } | ||
| 467 | |||
| 468 | if (ending_info.has_id) { | ||
| 469 | std::cout << " An AP ID is present." << std::endl; | ||
| 470 | } | ||
| 471 | } else if (ending_info.defined_in.size() > 1) { | ||
| 472 | std::cout << "Ending " << ending_name | ||
| 473 | << " was defined in multiple places:" << std::endl; | ||
| 474 | |||
| 475 | for (const RoomIdentifier& room_identifier : ending_info.defined_in) { | ||
| 476 | std::cout << " " << room_identifier.ShortDebugString() << std::endl; | ||
| 477 | } | ||
| 478 | } | ||
| 479 | |||
| 480 | if (!ending_info.has_id) { | ||
| 481 | std::cout << "Ending " << ending_name << " is missing an AP ID." | ||
| 482 | << std::endl; | ||
| 483 | } | ||
| 484 | } | ||
| 485 | |||
| 486 | void ValidatePanelName(const std::string& panel_name, | ||
| 487 | const PanelNameInfo& panel_info) const { | ||
| 488 | if (panel_info.panels_used_by.size() > 1) { | ||
| 489 | std::cout << "The location name \"" << panel_name | ||
| 490 | << "\" is used by multiple panels:" << std::endl; | ||
| 491 | |||
| 492 | for (const PanelIdentifier& panel_identifier : | ||
| 493 | panel_info.panels_used_by) { | ||
| 494 | std::cout << " PANEL " << panel_identifier.ShortDebugString() | ||
| 495 | << std::endl; | ||
| 496 | } | ||
| 497 | } | ||
| 498 | } | ||
| 499 | |||
| 500 | void ValidateProgressive(const std::string& prog_name, | ||
| 501 | const ProgressiveInfo& prog_info) const { | ||
| 502 | if (prog_info.definitions.empty()) { | ||
| 503 | std::cout << "Progressive \"" << prog_name | ||
| 504 | << "\" has no definition, but was referenced:" << std::endl; | ||
| 505 | |||
| 506 | if (prog_info.has_id) { | ||
| 507 | std::cout << " An AP ID is present." << std::endl; | ||
| 508 | } | ||
| 509 | } else if (prog_info.definitions.size() > 1) { | ||
| 510 | std::cout << "Progressive \"" << prog_name | ||
| 511 | << "\" has multiple definitions." << std::endl; | ||
| 512 | } | ||
| 513 | |||
| 514 | if (!prog_info.has_id) { | ||
| 515 | std::cout << "Progressive \"" << prog_name << "\" is missing an AP ID." | ||
| 516 | << std::endl; | ||
| 517 | } | ||
| 518 | } | ||
| 519 | |||
| 520 | void ValidateDoorGroup(const std::string& group_name, | ||
| 521 | const DoorGroupInfo& group_info) const { | ||
| 522 | if (group_info.definitions.empty()) { | ||
| 523 | std::cout << "Door group \"" << group_name | ||
| 524 | << "\" has no definition, but was referenced:" << std::endl; | ||
| 525 | |||
| 526 | if (group_info.has_id) { | ||
| 527 | std::cout << " An AP ID is present." << std::endl; | ||
| 528 | } | ||
| 529 | } else if (group_info.definitions.size() > 1) { | ||
| 530 | std::cout << "Door group \"" << group_name | ||
| 531 | << "\" has multiple definitions." << std::endl; | ||
| 532 | } | ||
| 533 | |||
| 534 | if (!group_info.has_id) { | ||
| 535 | std::cout << "Door group \"" << group_name << "\" is missing an AP ID." | ||
| 536 | << std::endl; | ||
| 537 | } | ||
| 538 | } | ||
| 539 | |||
| 540 | const CollectedInfo& info_; | ||
| 541 | }; | ||
| 542 | |||
| 543 | } // namespace | ||
| 544 | |||
| 545 | void ValidateCollectedInfo(const CollectedInfo& info) { | ||
| 546 | Validator validator(info); | ||
| 547 | validator.Validate(); | ||
| 548 | } | ||
| 549 | |||
| 550 | } // namespace com::fourisland::lingo2_archipelago | ||
