about summary refs log tree commit diff stats
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/assign_ids/main.cpp35
-rw-r--r--tools/datapacker/main.cpp10
-rw-r--r--tools/util/ids_yaml_format.cpp13
-rw-r--r--tools/validator/human_processor.cpp20
-rw-r--r--tools/validator/structs.h1
-rw-r--r--tools/validator/validator.cpp18
6 files changed, 89 insertions, 8 deletions
diff --git a/tools/assign_ids/main.cpp b/tools/assign_ids/main.cpp index 357566a..4cf7c3f 100644 --- a/tools/assign_ids/main.cpp +++ b/tools/assign_ids/main.cpp
@@ -65,6 +65,7 @@ class AssignIds {
65 UpdateNextId(room.panels()); 65 UpdateNextId(room.panels());
66 UpdateNextId(room.masteries()); 66 UpdateNextId(room.masteries());
67 UpdateNextId(room.keyholders()); 67 UpdateNextId(room.keyholders());
68 UpdateNextId(room.ports());
68 } 69 }
69 } 70 }
70 71
@@ -111,7 +112,8 @@ class AssignIds {
111 112
112 void ProcessDoor(const HumanDoor& h_door, 113 void ProcessDoor(const HumanDoor& h_door,
113 const std::string& current_map_name) { 114 const std::string& current_map_name) {
114 if (h_door.type() == DoorType::EVENT && !h_door.latch()) { 115 if (h_door.type() == DoorType::EVENT && !h_door.latch() &&
116 !h_door.legacy_location()) {
115 return; 117 return;
116 } 118 }
117 119
@@ -245,6 +247,37 @@ class AssignIds {
245 .at(h_keyholder.name()); 247 .at(h_keyholder.name());
246 } 248 }
247 } 249 }
250
251 for (const HumanPort& h_port : h_room.ports()) {
252 if (h_port.no_shuffle()) {
253 continue;
254 }
255
256 auto& maps = *output_.mutable_maps();
257 auto& rooms = *maps[current_map_name].mutable_rooms();
258 auto& ports = *rooms[h_room.name()].mutable_ports();
259
260 if (!id_mappings_.maps().contains(current_map_name) ||
261 !id_mappings_.maps()
262 .at(current_map_name)
263 .rooms()
264 .contains(h_room.name()) ||
265 !id_mappings_.maps()
266 .at(current_map_name)
267 .rooms()
268 .at(h_room.name())
269 .ports()
270 .contains(h_port.name())) {
271 ports[h_port.name()] = next_id_++;
272 } else {
273 ports[h_port.name()] = id_mappings_.maps()
274 .at(current_map_name)
275 .rooms()
276 .at(h_room.name())
277 .ports()
278 .at(h_port.name());
279 }
280 }
248 } 281 }
249 282
250 void ProcessSpecialIds() { 283 void ProcessSpecialIds() {
diff --git a/tools/datapacker/main.cpp b/tools/datapacker/main.cpp index bda4ee4..8109bf5 100644 --- a/tools/datapacker/main.cpp +++ b/tools/datapacker/main.cpp
@@ -436,6 +436,10 @@ class DataPacker {
436 if (h_door.has_latch()) { 436 if (h_door.has_latch()) {
437 door.set_latch(h_door.latch()); 437 door.set_latch(h_door.latch());
438 } 438 }
439
440 if (h_door.has_legacy_location()) {
441 door.set_legacy_location(h_door.legacy_location());
442 }
439 } 443 }
440 444
441 void ProcessConnectionsFile(std::filesystem::path path, 445 void ProcessConnectionsFile(std::filesystem::path path,
@@ -679,6 +683,12 @@ class DataPacker {
679 .mutable_keyholders(keyholder_id) 683 .mutable_keyholders(keyholder_id)
680 ->set_ap_id(ap_id); 684 ->set_ap_id(ap_id);
681 } 685 }
686
687 for (const auto& [port_name, ap_id] : room.ports()) {
688 uint64_t port_id = container_.FindOrAddPort(
689 map_name, room_name, port_name, std::nullopt, std::nullopt);
690 container_.all_objects().mutable_ports(port_id)->set_ap_id(ap_id);
691 }
682 } 692 }
683 } 693 }
684 694
diff --git a/tools/util/ids_yaml_format.cpp b/tools/util/ids_yaml_format.cpp index 71bfd63..5b9113b 100644 --- a/tools/util/ids_yaml_format.cpp +++ b/tools/util/ids_yaml_format.cpp
@@ -64,6 +64,13 @@ IdMappings ReadIdsFromYaml(const std::string& filename) {
64 keyholder_it.second.as<uint64_t>(); 64 keyholder_it.second.as<uint64_t>();
65 } 65 }
66 } 66 }
67
68 if (room_it.second["ports"]) {
69 for (const auto& port_it : room_it.second["ports"]) {
70 (*room_ids.mutable_ports())[port_it.first.as<std::string>()] =
71 port_it.second.as<uint64_t>();
72 }
73 }
67 } 74 }
68 } 75 }
69 76
@@ -146,6 +153,12 @@ void WriteIdsAsYaml(const IdMappings& ids, const std::string& filename) {
146 keyholder_id; 153 keyholder_id;
147 }); 154 });
148 155
156 OperateOnSortedMap(
157 room_ids.ports(),
158 [&room_node](const std::string& port_name, uint64_t port_id) {
159 room_node["ports"][port_name] = port_id;
160 });
161
149 map_node["rooms"][room_name] = std::move(room_node); 162 map_node["rooms"][room_name] = std::move(room_node);
150 }); 163 });
151 164
diff --git a/tools/validator/human_processor.cpp b/tools/validator/human_processor.cpp index 407d951..ffa9765 100644 --- a/tools/validator/human_processor.cpp +++ b/tools/validator/human_processor.cpp
@@ -570,12 +570,14 @@ class HumanProcessor {
570 auto ids = ReadIdsFromYaml(path.string()); 570 auto ids = ReadIdsFromYaml(path.string());
571 571
572 DoorIdentifier di; 572 DoorIdentifier di;
573 PanelIdentifier pi; 573 PanelIdentifier pai;
574 PortIdentifier poi;
574 KeyholderIdentifier ki; 575 KeyholderIdentifier ki;
575 576
576 for (const auto& [map_name, map] : ids.maps()) { 577 for (const auto& [map_name, map] : ids.maps()) {
577 di.set_map(map_name); 578 di.set_map(map_name);
578 pi.set_map(map_name); 579 pai.set_map(map_name);
580 poi.set_map(map_name);
579 ki.set_map(map_name); 581 ki.set_map(map_name);
580 582
581 for (const auto& [door_name, ap_id] : map.doors()) { 583 for (const auto& [door_name, ap_id] : map.doors()) {
@@ -586,13 +588,14 @@ class HumanProcessor {
586 } 588 }
587 589
588 for (const auto& [room_name, room] : map.rooms()) { 590 for (const auto& [room_name, room] : map.rooms()) {
589 pi.set_room(room_name); 591 pai.set_room(room_name);
592 poi.set_room(room_name);
590 ki.set_room(room_name); 593 ki.set_room(room_name);
591 594
592 for (const auto& [panel_name, ap_id] : room.panels()) { 595 for (const auto& [panel_name, ap_id] : room.panels()) {
593 pi.set_name(panel_name); 596 pai.set_name(panel_name);
594 597
595 PanelInfo& panel_info = info_.panels[pi]; 598 PanelInfo& panel_info = info_.panels[pai];
596 panel_info.has_id = true; 599 panel_info.has_id = true;
597 } 600 }
598 601
@@ -606,6 +609,13 @@ class HumanProcessor {
606 KeyholderInfo& keyholder_info = info_.keyholders[ki]; 609 KeyholderInfo& keyholder_info = info_.keyholders[ki];
607 keyholder_info.has_id = true; 610 keyholder_info.has_id = true;
608 } 611 }
612
613 for (const auto& [port_name, ap_id] : room.ports()) {
614 poi.set_name(port_name);
615
616 PortInfo& port_info = info_.ports[poi];
617 port_info.has_id = true;
618 }
609 } 619 }
610 } 620 }
611 621
diff --git a/tools/validator/structs.h b/tools/validator/structs.h index 51215e9..62974a8 100644 --- a/tools/validator/structs.h +++ b/tools/validator/structs.h
@@ -56,6 +56,7 @@ struct DoorInfo {
56 56
57struct PortInfo { 57struct PortInfo {
58 std::vector<HumanPort> definitions; 58 std::vector<HumanPort> definitions;
59 bool has_id = false;
59 60
60 std::vector<HumanConnection> connections_referenced_by; 61 std::vector<HumanConnection> connections_referenced_by;
61 std::vector<HumanConnection> target_connections_referenced_by; 62 std::vector<HumanConnection> target_connections_referenced_by;
diff --git a/tools/validator/validator.cpp b/tools/validator/validator.cpp index e1fc138..fe36be7 100644 --- a/tools/validator/validator.cpp +++ b/tools/validator/validator.cpp
@@ -227,7 +227,7 @@ class Validator {
227 227
228 if (h_door.type() == DoorType::STANDARD || 228 if (h_door.type() == DoorType::STANDARD ||
229 h_door.type() == DoorType::LOCATION_ONLY || 229 h_door.type() == DoorType::LOCATION_ONLY ||
230 h_door.type() == DoorType::GRAVESTONE) { 230 h_door.type() == DoorType::GRAVESTONE || h_door.legacy_location()) {
231 if (h_door.double_letters()) { 231 if (h_door.double_letters()) {
232 std::cout << "Door " << door_identifier.ShortDebugString() 232 std::cout << "Door " << door_identifier.ShortDebugString()
233 << " is a location that depends on double_letters." 233 << " is a location that depends on double_letters."
@@ -240,7 +240,8 @@ class Validator {
240 } 240 }
241 } 241 }
242 242
243 bool needs_id = (h_door.type() != DoorType::EVENT || h_door.latch()); 243 bool needs_id = (h_door.type() != DoorType::EVENT || h_door.latch() ||
244 h_door.legacy_location());
244 if (door_info.has_id != needs_id) { 245 if (door_info.has_id != needs_id) {
245 if (needs_id) { 246 if (needs_id) {
246 std::cout << "Door " << door_identifier.ShortDebugString() 247 std::cout << "Door " << door_identifier.ShortDebugString()
@@ -268,6 +269,10 @@ class Validator {
268 for (const std::string& map_name : port_info.map_worldport_entrances) { 269 for (const std::string& map_name : port_info.map_worldport_entrances) {
269 std::cout << " MAP (worldport_entrance) " << map_name << std::endl; 270 std::cout << " MAP (worldport_entrance) " << map_name << std::endl;
270 } 271 }
272
273 if (port_info.has_id) {
274 std::cout << " An AP ID is present." << std::endl;
275 }
271 } else if (port_info.definitions.size() > 1) { 276 } else if (port_info.definitions.size() > 1) {
272 std::cout << "Port " << port_identifier.ShortDebugString() 277 std::cout << "Port " << port_identifier.ShortDebugString()
273 << " was defined multiple times." << std::endl; 278 << " was defined multiple times." << std::endl;
@@ -300,6 +305,15 @@ class Validator {
300 std::cout << "Port " << port_identifier.ShortDebugString() 305 std::cout << "Port " << port_identifier.ShortDebugString()
301 << " is shuffleable and missing a rotation." << std::endl; 306 << " is shuffleable and missing a rotation." << std::endl;
302 } 307 }
308 if (!port_info.has_id) {
309 std::cout << "Port " << port_identifier.ShortDebugString()
310 << " is missing an AP ID." << std::endl;
311 }
312 } else {
313 if (port_info.has_id) {
314 std::cout << "Port " << port_identifier.ShortDebugString()
315 << " should not have an AP ID." << std::endl;
316 }
303 } 317 }
304 } 318 }
305 } 319 }