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.cpp55
-rw-r--r--tools/util/ids_yaml_format.cpp13
-rw-r--r--tools/validator/human_processor.cpp40
-rw-r--r--tools/validator/structs.h6
-rw-r--r--tools/validator/validator.cpp67
-rw-r--r--tools/validator/validator.h2
7 files changed, 185 insertions, 33 deletions
diff --git a/tools/assign_ids/main.cpp b/tools/assign_ids/main.cpp index 3e16f78..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) { 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 6bbb461..8109bf5 100644 --- a/tools/datapacker/main.cpp +++ b/tools/datapacker/main.cpp
@@ -88,9 +88,17 @@ class DataPacker {
88 uint64_t map_id = container_.FindOrAddMap(map_name); 88 uint64_t map_id = container_.FindOrAddMap(map_name);
89 Map& map = *container_.all_objects().mutable_maps(map_id); 89 Map& map = *container_.all_objects().mutable_maps(map_id);
90 90
91 map.set_type(metadata.type());
92
91 if (metadata.has_display_name()) { 93 if (metadata.has_display_name()) {
92 map.set_display_name(metadata.display_name()); 94 map.set_display_name(metadata.display_name());
93 } 95 }
96
97 if (metadata.has_worldport_entrance()) {
98 map.set_worldport_entrance(container_.FindOrAddPort(
99 map_name, metadata.worldport_entrance().room(),
100 metadata.worldport_entrance().name(), std::nullopt, std::nullopt));
101 }
94 } 102 }
95 103
96 void ProcessRooms(std::filesystem::path path, 104 void ProcessRooms(std::filesystem::path path,
@@ -239,7 +247,14 @@ class DataPacker {
239 Port& port = *container_.all_objects().mutable_ports(port_id); 247 Port& port = *container_.all_objects().mutable_ports(port_id);
240 248
241 port.set_path(h_port.path()); 249 port.set_path(h_port.path());
242 port.set_orientation(h_port.orientation()); 250 port.set_display_name(h_port.display_name());
251
252 if (h_port.no_shuffle()) {
253 port.set_no_shuffle(h_port.no_shuffle());
254 } else {
255 *port.mutable_destination() = h_port.destination();
256 port.set_rotation(h_port.rotation());
257 }
243 258
244 // Setting this explicitly because the Godot protobuf doesn't support 259 // Setting this explicitly because the Godot protobuf doesn't support
245 // custom defaults. 260 // custom defaults.
@@ -345,6 +360,9 @@ class DataPacker {
345 std::copy( 360 std::copy(
346 h_door.receivers().begin(), h_door.receivers().end(), 361 h_door.receivers().begin(), h_door.receivers().end(),
347 google::protobuf::RepeatedFieldBackInserter(door.mutable_receivers())); 362 google::protobuf::RepeatedFieldBackInserter(door.mutable_receivers()));
363 std::copy(
364 h_door.senders().begin(), h_door.senders().end(),
365 google::protobuf::RepeatedFieldBackInserter(door.mutable_senders()));
348 366
349 for (const PaintingIdentifier& pi : h_door.move_paintings()) { 367 for (const PaintingIdentifier& pi : h_door.move_paintings()) {
350 std::optional<std::string> map_name = 368 std::optional<std::string> map_name =
@@ -393,8 +411,8 @@ class DataPacker {
393 container_.FindOrAddDoor(map_name, di.name(), current_map_name)); 411 container_.FindOrAddDoor(map_name, di.name(), current_map_name));
394 } 412 }
395 413
396 for (const std::string& ending_name : h_door.endings()) { 414 if (h_door.has_white_ending()) {
397 door.add_endings(container_.FindOrAddEnding(ending_name)); 415 door.set_white_ending(h_door.white_ending());
398 } 416 }
399 417
400 if (h_door.has_control_center_color()) { 418 if (h_door.has_control_center_color()) {
@@ -414,6 +432,14 @@ class DataPacker {
414 if (h_door.has_double_letters()) { 432 if (h_door.has_double_letters()) {
415 door.set_double_letters(h_door.double_letters()); 433 door.set_double_letters(h_door.double_letters());
416 } 434 }
435
436 if (h_door.has_latch()) {
437 door.set_latch(h_door.latch());
438 }
439
440 if (h_door.has_legacy_location()) {
441 door.set_legacy_location(h_door.legacy_location());
442 }
417 } 443 }
418 444
419 void ProcessConnectionsFile(std::filesystem::path path, 445 void ProcessConnectionsFile(std::filesystem::path path,
@@ -470,6 +496,21 @@ class DataPacker {
470 r_connection.set_roof_access(human_connection.roof_access()); 496 r_connection.set_roof_access(human_connection.roof_access());
471 } 497 }
472 498
499 if (human_connection.has_purple_ending()) {
500 f_connection.set_purple_ending(human_connection.purple_ending());
501 r_connection.set_purple_ending(human_connection.purple_ending());
502 }
503
504 if (human_connection.has_cyan_ending()) {
505 f_connection.set_cyan_ending(human_connection.cyan_ending());
506 r_connection.set_cyan_ending(human_connection.cyan_ending());
507 }
508
509 if (human_connection.has_vanilla_only()) {
510 f_connection.set_vanilla_only(human_connection.vanilla_only());
511 r_connection.set_vanilla_only(human_connection.vanilla_only());
512 }
513
473 container_.AddConnection(f_connection); 514 container_.AddConnection(f_connection);
474 if (!human_connection.oneway()) { 515 if (!human_connection.oneway()) {
475 container_.AddConnection(r_connection); 516 container_.AddConnection(r_connection);
@@ -607,7 +648,7 @@ class DataPacker {
607 } 648 }
608 649
609 auto h_metadata = ReadMessageFromFile<HumanGlobalMetadata>(path.string()); 650 auto h_metadata = ReadMessageFromFile<HumanGlobalMetadata>(path.string());
610 container_.all_objects().set_version(h_metadata.version()); 651 *container_.all_objects().mutable_version() = h_metadata.version();
611 } 652 }
612 653
613 void ProcessIdsFile(std::filesystem::path path) { 654 void ProcessIdsFile(std::filesystem::path path) {
@@ -642,6 +683,12 @@ class DataPacker {
642 .mutable_keyholders(keyholder_id) 683 .mutable_keyholders(keyholder_id)
643 ->set_ap_id(ap_id); 684 ->set_ap_id(ap_id);
644 } 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 }
645 } 692 }
646 } 693 }
647 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 2c978bf..ffa9765 100644 --- a/tools/validator/human_processor.cpp +++ b/tools/validator/human_processor.cpp
@@ -77,6 +77,21 @@ class HumanProcessor {
77 for (const std::string& path : metadata.excluded_nodes()) { 77 for (const std::string& path : metadata.excluded_nodes()) {
78 map_info.game_nodes[path].uses++; 78 map_info.game_nodes[path].uses++;
79 } 79 }
80
81 for (const std::string& path : metadata.custom_nodes()) {
82 map_info.game_nodes[path].defined = true;
83 }
84
85 if (metadata.has_worldport_entrance()) {
86 auto port_identifier = GetCompletePortIdentifier(
87 metadata.worldport_entrance(), current_map_name, std::nullopt);
88 if (port_identifier) {
89 PortInfo& port_info = info_.ports[*port_identifier];
90 port_info.map_worldport_entrances.push_back(current_map_name);
91 } else {
92 map_info.malformed_worldport_entrance = metadata.worldport_entrance();
93 }
94 }
80 } 95 }
81 96
82 void ProcessRooms(std::filesystem::path path, 97 void ProcessRooms(std::filesystem::path path,
@@ -358,11 +373,6 @@ class HumanProcessor {
358 DoorInfo& other_door_info = info_.doors[complete_door_identifier]; 373 DoorInfo& other_door_info = info_.doors[complete_door_identifier];
359 other_door_info.doors_referenced_by.push_back(door_identifier); 374 other_door_info.doors_referenced_by.push_back(door_identifier);
360 } 375 }
361
362 for (const std::string& ei : h_door.endings()) {
363 EndingInfo& ending_info = info_.endings[ei];
364 ending_info.doors_referenced_by.push_back(door_identifier);
365 }
366 } 376 }
367 377
368 void ProcessConnectionsFile(std::filesystem::path path, 378 void ProcessConnectionsFile(std::filesystem::path path,
@@ -560,12 +570,14 @@ class HumanProcessor {
560 auto ids = ReadIdsFromYaml(path.string()); 570 auto ids = ReadIdsFromYaml(path.string());
561 571
562 DoorIdentifier di; 572 DoorIdentifier di;
563 PanelIdentifier pi; 573 PanelIdentifier pai;
574 PortIdentifier poi;
564 KeyholderIdentifier ki; 575 KeyholderIdentifier ki;
565 576
566 for (const auto& [map_name, map] : ids.maps()) { 577 for (const auto& [map_name, map] : ids.maps()) {
567 di.set_map(map_name); 578 di.set_map(map_name);
568 pi.set_map(map_name); 579 pai.set_map(map_name);
580 poi.set_map(map_name);
569 ki.set_map(map_name); 581 ki.set_map(map_name);
570 582
571 for (const auto& [door_name, ap_id] : map.doors()) { 583 for (const auto& [door_name, ap_id] : map.doors()) {
@@ -576,13 +588,14 @@ class HumanProcessor {
576 } 588 }
577 589
578 for (const auto& [room_name, room] : map.rooms()) { 590 for (const auto& [room_name, room] : map.rooms()) {
579 pi.set_room(room_name); 591 pai.set_room(room_name);
592 poi.set_room(room_name);
580 ki.set_room(room_name); 593 ki.set_room(room_name);
581 594
582 for (const auto& [panel_name, ap_id] : room.panels()) { 595 for (const auto& [panel_name, ap_id] : room.panels()) {
583 pi.set_name(panel_name); 596 pai.set_name(panel_name);
584 597
585 PanelInfo& panel_info = info_.panels[pi]; 598 PanelInfo& panel_info = info_.panels[pai];
586 panel_info.has_id = true; 599 panel_info.has_id = true;
587 } 600 }
588 601
@@ -596,6 +609,13 @@ class HumanProcessor {
596 KeyholderInfo& keyholder_info = info_.keyholders[ki]; 609 KeyholderInfo& keyholder_info = info_.keyholders[ki];
597 keyholder_info.has_id = true; 610 keyholder_info.has_id = true;
598 } 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 }
599 } 619 }
600 } 620 }
601 621
diff --git a/tools/validator/structs.h b/tools/validator/structs.h index d1d45f2..62974a8 100644 --- a/tools/validator/structs.h +++ b/tools/validator/structs.h
@@ -27,6 +27,8 @@ struct GameNodeInfo {
27 27
28struct MapInfo { 28struct MapInfo {
29 std::map<std::string, GameNodeInfo> game_nodes; 29 std::map<std::string, GameNodeInfo> game_nodes;
30
31 std::optional<PortIdentifier> malformed_worldport_entrance;
30}; 32};
31 33
32struct RoomInfo { 34struct RoomInfo {
@@ -54,9 +56,11 @@ struct DoorInfo {
54 56
55struct PortInfo { 57struct PortInfo {
56 std::vector<HumanPort> definitions; 58 std::vector<HumanPort> definitions;
59 bool has_id = false;
57 60
58 std::vector<HumanConnection> connections_referenced_by; 61 std::vector<HumanConnection> connections_referenced_by;
59 std::vector<HumanConnection> target_connections_referenced_by; 62 std::vector<HumanConnection> target_connections_referenced_by;
63 std::vector<std::string> map_worldport_entrances;
60}; 64};
61 65
62struct PaintingInfo { 66struct PaintingInfo {
@@ -104,8 +108,6 @@ struct LetterInfo {
104struct EndingInfo { 108struct EndingInfo {
105 std::vector<RoomIdentifier> defined_in; 109 std::vector<RoomIdentifier> defined_in;
106 bool has_id = false; 110 bool has_id = false;
107
108 std::vector<DoorIdentifier> doors_referenced_by;
109}; 111};
110 112
111struct PanelNameInfo { 113struct PanelNameInfo {
diff --git a/tools/validator/validator.cpp b/tools/validator/validator.cpp index dd41f5c..fe36be7 100644 --- a/tools/validator/validator.cpp +++ b/tools/validator/validator.cpp
@@ -69,6 +69,11 @@ class Validator {
69 << " is not defined in the game file." << std::endl; 69 << " is not defined in the game file." << std::endl;
70 } 70 }
71 } 71 }
72
73 if (map_info.malformed_worldport_entrance) {
74 std::cout << "The worldport entrance for map " << map_name
75 << " is malformed." << std::endl;
76 }
72 } 77 }
73 78
74 void ValidateRoom(const RoomIdentifier& room_identifier, 79 void ValidateRoom(const RoomIdentifier& room_identifier,
@@ -106,7 +111,7 @@ class Validator {
106 return false; 111 return false;
107 } 112 }
108 113
109 if (h_door.keyholders_size() > 0 || h_door.endings_size() > 0 || 114 if (h_door.keyholders_size() > 0 || h_door.white_ending() ||
110 h_door.complete_at() > 0) { 115 h_door.complete_at() > 0) {
111 return true; 116 return true;
112 } 117 }
@@ -220,16 +225,23 @@ class Validator {
220 << " needs an explicit location name." << std::endl; 225 << " needs an explicit location name." << std::endl;
221 } 226 }
222 227
223 if (h_door.double_letters() && 228 if (h_door.type() == DoorType::STANDARD ||
224 (h_door.type() == DoorType::STANDARD || 229 h_door.type() == DoorType::LOCATION_ONLY ||
225 h_door.type() == DoorType::LOCATION_ONLY || 230 h_door.type() == DoorType::GRAVESTONE || h_door.legacy_location()) {
226 h_door.type() == DoorType::GRAVESTONE)) { 231 if (h_door.double_letters()) {
227 std::cout << "Door " << door_identifier.ShortDebugString() 232 std::cout << "Door " << door_identifier.ShortDebugString()
228 << " is a location that depends on double_letters." 233 << " is a location that depends on double_letters."
229 << std::endl; 234 << std::endl;
235 }
236
237 if (!h_door.has_location_room()) {
238 std::cout << "Door " << door_identifier.ShortDebugString()
239 << " is missing a location_room." << std::endl;
240 }
230 } 241 }
231 242
232 bool needs_id = (h_door.type() != DoorType::EVENT); 243 bool needs_id = (h_door.type() != DoorType::EVENT || h_door.latch() ||
244 h_door.legacy_location());
233 if (door_info.has_id != needs_id) { 245 if (door_info.has_id != needs_id) {
234 if (needs_id) { 246 if (needs_id) {
235 std::cout << "Door " << door_identifier.ShortDebugString() 247 std::cout << "Door " << door_identifier.ShortDebugString()
@@ -253,6 +265,14 @@ class Validator {
253 std::cout << " CONNECTION " << connection.ShortDebugString() 265 std::cout << " CONNECTION " << connection.ShortDebugString()
254 << std::endl; 266 << std::endl;
255 } 267 }
268
269 for (const std::string& map_name : port_info.map_worldport_entrances) {
270 std::cout << " MAP (worldport_entrance) " << map_name << std::endl;
271 }
272
273 if (port_info.has_id) {
274 std::cout << " An AP ID is present." << std::endl;
275 }
256 } else if (port_info.definitions.size() > 1) { 276 } else if (port_info.definitions.size() > 1) {
257 std::cout << "Port " << port_identifier.ShortDebugString() 277 std::cout << "Port " << port_identifier.ShortDebugString()
258 << " was defined multiple times." << std::endl; 278 << " was defined multiple times." << std::endl;
@@ -273,6 +293,29 @@ class Validator {
273 } 293 }
274 } 294 }
275 } 295 }
296
297 for (const HumanPort& port : port_info.definitions) {
298 if (!port.no_shuffle()) {
299 if (!port.has_destination()) {
300 std::cout << "Port " << port_identifier.ShortDebugString()
301 << " is shuffleable and missing a destination."
302 << std::endl;
303 }
304 if (!port.has_rotation()) {
305 std::cout << "Port " << port_identifier.ShortDebugString()
306 << " is shuffleable and missing a rotation." << std::endl;
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 }
317 }
318 }
276 } 319 }
277 320
278 void ValidatePainting(const PaintingIdentifier& painting_identifier, 321 void ValidatePainting(const PaintingIdentifier& painting_identifier,
@@ -459,12 +502,6 @@ class Validator {
459 std::cout << "Ending " << ending_name 502 std::cout << "Ending " << ending_name
460 << " has no definition, but was referenced:" << std::endl; 503 << " has no definition, but was referenced:" << std::endl;
461 504
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) { 505 if (ending_info.has_id) {
469 std::cout << " An AP ID is present." << std::endl; 506 std::cout << " An AP ID is present." << std::endl;
470 } 507 }
diff --git a/tools/validator/validator.h b/tools/validator/validator.h index b710429..33bc7c9 100644 --- a/tools/validator/validator.h +++ b/tools/validator/validator.h
@@ -1,4 +1,4 @@
1#ifndef TOOLS_VALIDATOR_VALIDATOR_H_ 1#ifndef TOOLS_VALIDATOR_VALIDATOR_H
2#define TOOLS_VALIDATOR_VALIDATOR_H 2#define TOOLS_VALIDATOR_VALIDATOR_H
3 3
4namespace com::fourisland::lingo2_archipelago { 4namespace com::fourisland::lingo2_archipelago {