diff options
Diffstat (limited to 'tools/validator')
-rw-r--r-- | tools/validator/human_processor.cpp | 26 | ||||
-rw-r--r-- | tools/validator/structs.h | 3 | ||||
-rw-r--r-- | tools/validator/validator.cpp | 48 |
3 files changed, 73 insertions, 4 deletions
diff --git a/tools/validator/human_processor.cpp b/tools/validator/human_processor.cpp index 561225e..2c978bf 100644 --- a/tools/validator/human_processor.cpp +++ b/tools/validator/human_processor.cpp | |||
@@ -394,7 +394,9 @@ class HumanProcessor { | |||
394 | } | 394 | } |
395 | } else if (human_connection.has_from()) { | 395 | } else if (human_connection.has_from()) { |
396 | ProcessSingleConnection(human_connection, human_connection.from(), | 396 | ProcessSingleConnection(human_connection, human_connection.from(), |
397 | current_map_name); | 397 | current_map_name, |
398 | /*is_target=*/!human_connection.oneway() && | ||
399 | !human_connection.bypass_target_door()); | ||
398 | } | 400 | } |
399 | 401 | ||
400 | if (human_connection.has_to_room()) { | 402 | if (human_connection.has_to_room()) { |
@@ -410,8 +412,9 @@ class HumanProcessor { | |||
410 | std::cout << "A global connection used to_room." << std::endl; | 412 | std::cout << "A global connection used to_room." << std::endl; |
411 | } | 413 | } |
412 | } else if (human_connection.has_to()) { | 414 | } else if (human_connection.has_to()) { |
413 | ProcessSingleConnection(human_connection, human_connection.to(), | 415 | ProcessSingleConnection( |
414 | current_map_name); | 416 | human_connection, human_connection.to(), current_map_name, |
417 | /*is_target=*/!human_connection.bypass_target_door()); | ||
415 | } | 418 | } |
416 | 419 | ||
417 | if (human_connection.has_door()) { | 420 | if (human_connection.has_door()) { |
@@ -432,7 +435,7 @@ class HumanProcessor { | |||
432 | void ProcessSingleConnection( | 435 | void ProcessSingleConnection( |
433 | const HumanConnection& human_connection, | 436 | const HumanConnection& human_connection, |
434 | const HumanConnection::Endpoint& endpoint, | 437 | const HumanConnection::Endpoint& endpoint, |
435 | const std::optional<std::string>& current_map_name) { | 438 | const std::optional<std::string>& current_map_name, bool is_target) { |
436 | if (endpoint.has_room()) { | 439 | if (endpoint.has_room()) { |
437 | auto room_identifier = | 440 | auto room_identifier = |
438 | GetCompleteRoomIdentifier(endpoint.room(), current_map_name); | 441 | GetCompleteRoomIdentifier(endpoint.room(), current_map_name); |
@@ -451,6 +454,11 @@ class HumanProcessor { | |||
451 | if (painting_identifier) { | 454 | if (painting_identifier) { |
452 | PaintingInfo& painting_info = info_.paintings[*painting_identifier]; | 455 | PaintingInfo& painting_info = info_.paintings[*painting_identifier]; |
453 | painting_info.connections_referenced_by.push_back(human_connection); | 456 | painting_info.connections_referenced_by.push_back(human_connection); |
457 | |||
458 | if (is_target) { | ||
459 | painting_info.target_connections_referenced_by.push_back( | ||
460 | human_connection); | ||
461 | } | ||
454 | } else { | 462 | } else { |
455 | // Not sure where else to store this right now. | 463 | // Not sure where else to store this right now. |
456 | std::cout | 464 | std::cout |
@@ -463,6 +471,11 @@ class HumanProcessor { | |||
463 | if (port_identifier) { | 471 | if (port_identifier) { |
464 | PortInfo& port_info = info_.ports[*port_identifier]; | 472 | PortInfo& port_info = info_.ports[*port_identifier]; |
465 | port_info.connections_referenced_by.push_back(human_connection); | 473 | port_info.connections_referenced_by.push_back(human_connection); |
474 | |||
475 | if (is_target) { | ||
476 | port_info.target_connections_referenced_by.push_back( | ||
477 | human_connection); | ||
478 | } | ||
466 | } else { | 479 | } else { |
467 | // Not sure where else to store this right now. | 480 | // Not sure where else to store this right now. |
468 | std::cout | 481 | std::cout |
@@ -480,6 +493,11 @@ class HumanProcessor { | |||
480 | panel_info.proxies[endpoint.panel().answer()] | 493 | panel_info.proxies[endpoint.panel().answer()] |
481 | .connections_referenced_by.push_back(human_connection); | 494 | .connections_referenced_by.push_back(human_connection); |
482 | } | 495 | } |
496 | |||
497 | if (is_target) { | ||
498 | panel_info.target_connections_referenced_by.push_back( | ||
499 | human_connection); | ||
500 | } | ||
483 | } | 501 | } |
484 | } | 502 | } |
485 | } | 503 | } |
diff --git a/tools/validator/structs.h b/tools/validator/structs.h index 17ed33a..d1d45f2 100644 --- a/tools/validator/structs.h +++ b/tools/validator/structs.h | |||
@@ -56,12 +56,14 @@ struct PortInfo { | |||
56 | std::vector<HumanPort> definitions; | 56 | std::vector<HumanPort> definitions; |
57 | 57 | ||
58 | std::vector<HumanConnection> connections_referenced_by; | 58 | std::vector<HumanConnection> connections_referenced_by; |
59 | std::vector<HumanConnection> target_connections_referenced_by; | ||
59 | }; | 60 | }; |
60 | 61 | ||
61 | struct PaintingInfo { | 62 | struct PaintingInfo { |
62 | std::vector<HumanPainting> definitions; | 63 | std::vector<HumanPainting> definitions; |
63 | 64 | ||
64 | std::vector<HumanConnection> connections_referenced_by; | 65 | std::vector<HumanConnection> connections_referenced_by; |
66 | std::vector<HumanConnection> target_connections_referenced_by; | ||
65 | std::vector<DoorIdentifier> doors_referenced_by; | 67 | std::vector<DoorIdentifier> doors_referenced_by; |
66 | }; | 68 | }; |
67 | 69 | ||
@@ -79,6 +81,7 @@ struct PanelInfo { | |||
79 | std::string map_area_name; | 81 | std::string map_area_name; |
80 | 82 | ||
81 | std::vector<HumanConnection> connections_referenced_by; | 83 | std::vector<HumanConnection> connections_referenced_by; |
84 | std::vector<HumanConnection> target_connections_referenced_by; | ||
82 | std::vector<DoorIdentifier> doors_referenced_by; | 85 | std::vector<DoorIdentifier> doors_referenced_by; |
83 | 86 | ||
84 | std::map<std::string, ProxyInfo> proxies; | 87 | std::map<std::string, ProxyInfo> proxies; |
diff --git a/tools/validator/validator.cpp b/tools/validator/validator.cpp index 4149caa..e4c6324 100644 --- a/tools/validator/validator.cpp +++ b/tools/validator/validator.cpp | |||
@@ -256,6 +256,22 @@ class Validator { | |||
256 | std::cout << "Port " << port_identifier.ShortDebugString() | 256 | std::cout << "Port " << port_identifier.ShortDebugString() |
257 | << " was defined multiple times." << std::endl; | 257 | << " was defined multiple times." << std::endl; |
258 | } | 258 | } |
259 | |||
260 | if (!port_info.target_connections_referenced_by.empty()) { | ||
261 | for (const HumanPort& port : port_info.definitions) { | ||
262 | if (port.has_required_door()) { | ||
263 | std::cout << "Port " << port_identifier.ShortDebugString() | ||
264 | << " has a required door but is the target of a connection:" | ||
265 | << std::endl; | ||
266 | |||
267 | for (const HumanConnection& connection : | ||
268 | port_info.target_connections_referenced_by) { | ||
269 | std::cout << " CONNECTION " << connection.ShortDebugString() | ||
270 | << std::endl; | ||
271 | } | ||
272 | } | ||
273 | } | ||
274 | } | ||
259 | } | 275 | } |
260 | 276 | ||
261 | void ValidatePainting(const PaintingIdentifier& painting_identifier, | 277 | void ValidatePainting(const PaintingIdentifier& painting_identifier, |
@@ -279,6 +295,22 @@ class Validator { | |||
279 | std::cout << "Painting " << painting_identifier.ShortDebugString() | 295 | std::cout << "Painting " << painting_identifier.ShortDebugString() |
280 | << " was defined multiple times." << std::endl; | 296 | << " was defined multiple times." << std::endl; |
281 | } | 297 | } |
298 | |||
299 | if (!painting_info.target_connections_referenced_by.empty()) { | ||
300 | for (const HumanPainting& painting : painting_info.definitions) { | ||
301 | if (painting.has_required_door()) { | ||
302 | std::cout << "Painting " << painting_identifier.ShortDebugString() | ||
303 | << " has a required door but is the target of a connection:" | ||
304 | << std::endl; | ||
305 | |||
306 | for (const HumanConnection& connection : | ||
307 | painting_info.target_connections_referenced_by) { | ||
308 | std::cout << " CONNECTION " << connection.ShortDebugString() | ||
309 | << std::endl; | ||
310 | } | ||
311 | } | ||
312 | } | ||
313 | } | ||
282 | } | 314 | } |
283 | 315 | ||
284 | void ValidatePanel(const PanelIdentifier& panel_identifier, | 316 | void ValidatePanel(const PanelIdentifier& panel_identifier, |
@@ -340,6 +372,22 @@ class Validator { | |||
340 | std::cout << "Panel " << panel_identifier.ShortDebugString() | 372 | std::cout << "Panel " << panel_identifier.ShortDebugString() |
341 | << " is missing an AP ID." << std::endl; | 373 | << " is missing an AP ID." << std::endl; |
342 | } | 374 | } |
375 | |||
376 | if (!panel_info.target_connections_referenced_by.empty()) { | ||
377 | for (const HumanPanel& panel : panel_info.definitions) { | ||
378 | if (panel.has_required_door()) { | ||
379 | std::cout << "Panel " << panel_identifier.ShortDebugString() | ||
380 | << " has a required door but is the target of a connection:" | ||
381 | << std::endl; | ||
382 | |||
383 | for (const HumanConnection& connection : | ||
384 | panel_info.target_connections_referenced_by) { | ||
385 | std::cout << " CONNECTION " << connection.ShortDebugString() | ||
386 | << std::endl; | ||
387 | } | ||
388 | } | ||
389 | } | ||
390 | } | ||
343 | } | 391 | } |
344 | 392 | ||
345 | void ValidateKeyholder(const KeyholderIdentifier& keyholder_identifier, | 393 | void ValidateKeyholder(const KeyholderIdentifier& keyholder_identifier, |