diff options
Diffstat (limited to 'tools')
| -rw-r--r-- | tools/assign_ids/main.cpp | 193 | ||||
| -rw-r--r-- | tools/datapacker/container.cpp | 34 | ||||
| -rw-r--r-- | tools/datapacker/container.h | 6 | ||||
| -rw-r--r-- | tools/datapacker/main.cpp | 111 | ||||
| -rw-r--r-- | tools/util/godot_scene.cpp | 6 | ||||
| -rw-r--r-- | tools/util/ids_yaml_format.cpp | 39 | ||||
| -rw-r--r-- | tools/validator/CMakeLists.txt | 3 | ||||
| -rw-r--r-- | tools/validator/human_processor.cpp | 178 | ||||
| -rw-r--r-- | tools/validator/structs.h | 33 | ||||
| -rw-r--r-- | tools/validator/validator.cpp | 661 |
10 files changed, 997 insertions, 267 deletions
| diff --git a/tools/assign_ids/main.cpp b/tools/assign_ids/main.cpp index e65e5e4..3e16f78 100644 --- a/tools/assign_ids/main.cpp +++ b/tools/assign_ids/main.cpp | |||
| @@ -2,6 +2,7 @@ | |||
| 2 | #include <google/protobuf/text_format.h> | 2 | #include <google/protobuf/text_format.h> |
| 3 | 3 | ||
| 4 | #include <cstdint> | 4 | #include <cstdint> |
| 5 | #include <filesystem> | ||
| 5 | #include <fstream> | 6 | #include <fstream> |
| 6 | #include <iostream> | 7 | #include <iostream> |
| 7 | #include <map> | 8 | #include <map> |
| @@ -40,6 +41,10 @@ class AssignIds { | |||
| 40 | ReadIds(ids_path); | 41 | ReadIds(ids_path); |
| 41 | 42 | ||
| 42 | ProcessMaps(datadir_path); | 43 | ProcessMaps(datadir_path); |
| 44 | ProcessSpecialIds(); | ||
| 45 | ProcessProgressivesFile(datadir_path / "progressives.txtpb"); | ||
| 46 | ProcessDoorGroupsFile(datadir_path / "door_groups.txtpb"); | ||
| 47 | ProcessGlobalMetadataFile(datadir_path / "metadata.txtpb"); | ||
| 43 | 48 | ||
| 44 | WriteIds(ids_path); | 49 | WriteIds(ids_path); |
| 45 | 50 | ||
| @@ -54,50 +59,26 @@ class AssignIds { | |||
| 54 | id_mappings_ = ReadIdsFromYaml(path.string()); | 59 | id_mappings_ = ReadIdsFromYaml(path.string()); |
| 55 | 60 | ||
| 56 | for (const auto& [_, map] : id_mappings_.maps()) { | 61 | for (const auto& [_, map] : id_mappings_.maps()) { |
| 57 | for (const auto& [_, id] : map.doors()) { | 62 | UpdateNextId(map.doors()); |
| 58 | if (id > next_id_) { | ||
| 59 | next_id_ = id; | ||
| 60 | } | ||
| 61 | } | ||
| 62 | 63 | ||
| 63 | for (const auto& [_, room] : map.rooms()) { | 64 | for (const auto& [_, room] : map.rooms()) { |
| 64 | for (const auto& [_, id] : room.panels()) { | 65 | UpdateNextId(room.panels()); |
| 65 | if (id > next_id_) { | 66 | UpdateNextId(room.masteries()); |
| 66 | next_id_ = id; | 67 | UpdateNextId(room.keyholders()); |
| 67 | } | ||
| 68 | } | ||
| 69 | |||
| 70 | for (const auto& [_, id] : room.masteries()) { | ||
| 71 | if (id > next_id_) { | ||
| 72 | next_id_ = id; | ||
| 73 | } | ||
| 74 | } | ||
| 75 | } | ||
| 76 | } | ||
| 77 | |||
| 78 | for (const auto& [_, id] : id_mappings_.special()) { | ||
| 79 | if (id > next_id_) { | ||
| 80 | next_id_ = id; | ||
| 81 | } | ||
| 82 | } | ||
| 83 | |||
| 84 | for (const auto& [_, id] : id_mappings_.letters()) { | ||
| 85 | if (id > next_id_) { | ||
| 86 | next_id_ = id; | ||
| 87 | } | 68 | } |
| 88 | } | 69 | } |
| 89 | 70 | ||
| 90 | for (const auto& [_, id] : id_mappings_.endings()) { | 71 | UpdateNextId(id_mappings_.special()); |
| 91 | if (id > next_id_) { | 72 | UpdateNextId(id_mappings_.letters()); |
| 92 | next_id_ = id; | 73 | UpdateNextId(id_mappings_.endings()); |
| 93 | } | 74 | UpdateNextId(id_mappings_.progressives()); |
| 94 | } | 75 | UpdateNextId(id_mappings_.door_groups()); |
| 95 | 76 | ||
| 96 | next_id_++; | 77 | next_id_++; |
| 97 | } | 78 | } |
| 98 | 79 | ||
| 99 | void WriteIds(std::filesystem::path path) { | 80 | void WriteIds(std::filesystem::path path) { |
| 100 | WriteIdsAsYaml(id_mappings_, path.string()); | 81 | WriteIdsAsYaml(output_, path.string()); |
| 101 | } | 82 | } |
| 102 | 83 | ||
| 103 | void ProcessMaps(std::filesystem::path path) { | 84 | void ProcessMaps(std::filesystem::path path) { |
| @@ -134,14 +115,18 @@ class AssignIds { | |||
| 134 | return; | 115 | return; |
| 135 | } | 116 | } |
| 136 | 117 | ||
| 118 | auto& maps = *output_.mutable_maps(); | ||
| 119 | auto& doors = *maps[current_map_name].mutable_doors(); | ||
| 120 | |||
| 137 | if (!id_mappings_.maps().contains(current_map_name) || | 121 | if (!id_mappings_.maps().contains(current_map_name) || |
| 138 | !id_mappings_.maps() | 122 | !id_mappings_.maps() |
| 139 | .at(current_map_name) | 123 | .at(current_map_name) |
| 140 | .doors() | 124 | .doors() |
| 141 | .contains(h_door.name())) { | 125 | .contains(h_door.name())) { |
| 142 | auto& maps = *id_mappings_.mutable_maps(); | ||
| 143 | auto& doors = *maps[current_map_name].mutable_doors(); | ||
| 144 | doors[h_door.name()] = next_id_++; | 126 | doors[h_door.name()] = next_id_++; |
| 127 | } else { | ||
| 128 | doors[h_door.name()] = | ||
| 129 | id_mappings_.maps().at(current_map_name).doors().at(h_door.name()); | ||
| 145 | } | 130 | } |
| 146 | } | 131 | } |
| 147 | 132 | ||
| @@ -156,6 +141,10 @@ class AssignIds { | |||
| 156 | void ProcessRoom(const HumanRoom& h_room, | 141 | void ProcessRoom(const HumanRoom& h_room, |
| 157 | const std::string& current_map_name) { | 142 | const std::string& current_map_name) { |
| 158 | for (const HumanPanel& h_panel : h_room.panels()) { | 143 | for (const HumanPanel& h_panel : h_room.panels()) { |
| 144 | auto& maps = *output_.mutable_maps(); | ||
| 145 | auto& rooms = *maps[current_map_name].mutable_rooms(); | ||
| 146 | auto& panels = *rooms[h_room.name()].mutable_panels(); | ||
| 147 | |||
| 159 | if (!id_mappings_.maps().contains(current_map_name) || | 148 | if (!id_mappings_.maps().contains(current_map_name) || |
| 160 | !id_mappings_.maps() | 149 | !id_mappings_.maps() |
| 161 | .at(current_map_name) | 150 | .at(current_map_name) |
| @@ -167,23 +156,33 @@ class AssignIds { | |||
| 167 | .at(h_room.name()) | 156 | .at(h_room.name()) |
| 168 | .panels() | 157 | .panels() |
| 169 | .contains(h_panel.name())) { | 158 | .contains(h_panel.name())) { |
| 170 | auto& maps = *id_mappings_.mutable_maps(); | ||
| 171 | auto& rooms = *maps[current_map_name].mutable_rooms(); | ||
| 172 | auto& panels = *rooms[h_room.name()].mutable_panels(); | ||
| 173 | panels[h_panel.name()] = next_id_++; | 159 | panels[h_panel.name()] = next_id_++; |
| 160 | } else { | ||
| 161 | panels[h_panel.name()] = id_mappings_.maps() | ||
| 162 | .at(current_map_name) | ||
| 163 | .rooms() | ||
| 164 | .at(h_room.name()) | ||
| 165 | .panels() | ||
| 166 | .at(h_panel.name()); | ||
| 174 | } | 167 | } |
| 175 | } | 168 | } |
| 176 | 169 | ||
| 177 | for (const HumanLetter& h_letter : h_room.letters()) { | 170 | for (const HumanLetter& h_letter : h_room.letters()) { |
| 178 | std::string lettername = GetLetterName(h_letter.key(), h_letter.level2()); | 171 | std::string lettername = GetLetterName(h_letter.key(), h_letter.level2()); |
| 179 | 172 | ||
| 173 | auto& letters = *output_.mutable_letters(); | ||
| 180 | if (!id_mappings_.letters().contains(lettername)) { | 174 | if (!id_mappings_.letters().contains(lettername)) { |
| 181 | auto& letters = *id_mappings_.mutable_letters(); | ||
| 182 | letters[lettername] = next_id_++; | 175 | letters[lettername] = next_id_++; |
| 176 | } else { | ||
| 177 | letters[lettername] = id_mappings_.letters().at(lettername); | ||
| 183 | } | 178 | } |
| 184 | } | 179 | } |
| 185 | 180 | ||
| 186 | for (const HumanMastery& h_mastery : h_room.masteries()) { | 181 | for (const HumanMastery& h_mastery : h_room.masteries()) { |
| 182 | auto& maps = *output_.mutable_maps(); | ||
| 183 | auto& rooms = *maps[current_map_name].mutable_rooms(); | ||
| 184 | auto& masteries = *rooms[h_room.name()].mutable_masteries(); | ||
| 185 | |||
| 187 | if (!id_mappings_.maps().contains(current_map_name) || | 186 | if (!id_mappings_.maps().contains(current_map_name) || |
| 188 | !id_mappings_.maps() | 187 | !id_mappings_.maps() |
| 189 | .at(current_map_name) | 188 | .at(current_map_name) |
| @@ -195,27 +194,133 @@ class AssignIds { | |||
| 195 | .at(h_room.name()) | 194 | .at(h_room.name()) |
| 196 | .masteries() | 195 | .masteries() |
| 197 | .contains(h_mastery.name())) { | 196 | .contains(h_mastery.name())) { |
| 198 | auto& maps = *id_mappings_.mutable_maps(); | ||
| 199 | auto& rooms = *maps[current_map_name].mutable_rooms(); | ||
| 200 | auto& masteries = *rooms[h_room.name()].mutable_masteries(); | ||
| 201 | masteries[h_mastery.name()] = next_id_++; | 197 | masteries[h_mastery.name()] = next_id_++; |
| 198 | } else { | ||
| 199 | masteries[h_mastery.name()] = id_mappings_.maps() | ||
| 200 | .at(current_map_name) | ||
| 201 | .rooms() | ||
| 202 | .at(h_room.name()) | ||
| 203 | .masteries() | ||
| 204 | .at(h_mastery.name()); | ||
| 202 | } | 205 | } |
| 203 | } | 206 | } |
| 204 | 207 | ||
| 205 | for (const HumanEnding& h_ending : h_room.endings()) { | 208 | for (const HumanEnding& h_ending : h_room.endings()) { |
| 209 | auto& endings = *output_.mutable_endings(); | ||
| 210 | |||
| 206 | if (!id_mappings_.endings().contains(h_ending.name())) { | 211 | if (!id_mappings_.endings().contains(h_ending.name())) { |
| 207 | auto& endings = *id_mappings_.mutable_endings(); | ||
| 208 | endings[h_ending.name()] = next_id_++; | 212 | endings[h_ending.name()] = next_id_++; |
| 213 | } else { | ||
| 214 | endings[h_ending.name()] = id_mappings_.endings().at(h_ending.name()); | ||
| 215 | } | ||
| 216 | } | ||
| 217 | |||
| 218 | for (const HumanKeyholder& h_keyholder : h_room.keyholders()) { | ||
| 219 | if (!h_keyholder.has_key()) { | ||
| 220 | continue; | ||
| 221 | } | ||
| 222 | |||
| 223 | auto& maps = *output_.mutable_maps(); | ||
| 224 | auto& rooms = *maps[current_map_name].mutable_rooms(); | ||
| 225 | auto& keyholders = *rooms[h_room.name()].mutable_keyholders(); | ||
| 226 | |||
| 227 | if (!id_mappings_.maps().contains(current_map_name) || | ||
| 228 | !id_mappings_.maps() | ||
| 229 | .at(current_map_name) | ||
| 230 | .rooms() | ||
| 231 | .contains(h_room.name()) || | ||
| 232 | !id_mappings_.maps() | ||
| 233 | .at(current_map_name) | ||
| 234 | .rooms() | ||
| 235 | .at(h_room.name()) | ||
| 236 | .keyholders() | ||
| 237 | .contains(h_keyholder.name())) { | ||
| 238 | keyholders[h_keyholder.name()] = next_id_++; | ||
| 239 | } else { | ||
| 240 | keyholders[h_keyholder.name()] = id_mappings_.maps() | ||
| 241 | .at(current_map_name) | ||
| 242 | .rooms() | ||
| 243 | .at(h_room.name()) | ||
| 244 | .keyholders() | ||
| 245 | .at(h_keyholder.name()); | ||
| 246 | } | ||
| 247 | } | ||
| 248 | } | ||
| 249 | |||
| 250 | void ProcessSpecialIds() { | ||
| 251 | auto& specials = *output_.mutable_special(); | ||
| 252 | |||
| 253 | for (const auto& [special_name, ap_id] : id_mappings_.special()) { | ||
| 254 | specials[special_name] = ap_id; | ||
| 255 | } | ||
| 256 | } | ||
| 257 | |||
| 258 | void ProcessProgressivesFile(std::filesystem::path path) { | ||
| 259 | if (!std::filesystem::exists(path)) { | ||
| 260 | return; | ||
| 261 | } | ||
| 262 | |||
| 263 | auto h_progs = ReadMessageFromFile<HumanProgressives>(path.string()); | ||
| 264 | auto& progs = *output_.mutable_progressives(); | ||
| 265 | |||
| 266 | for (const HumanProgressive& h_prog : h_progs.progressives()) { | ||
| 267 | if (!id_mappings_.progressives().contains(h_prog.name())) { | ||
| 268 | progs[h_prog.name()] = next_id_++; | ||
| 269 | } else { | ||
| 270 | progs[h_prog.name()] = id_mappings_.progressives().at(h_prog.name()); | ||
| 271 | } | ||
| 272 | } | ||
| 273 | } | ||
| 274 | |||
| 275 | void ProcessDoorGroupsFile(std::filesystem::path path) { | ||
| 276 | if (!std::filesystem::exists(path)) { | ||
| 277 | return; | ||
| 278 | } | ||
| 279 | |||
| 280 | auto h_groups = ReadMessageFromFile<HumanDoorGroups>(path.string()); | ||
| 281 | auto& groups = *output_.mutable_door_groups(); | ||
| 282 | |||
| 283 | for (const HumanDoorGroup& h_group : h_groups.door_groups()) { | ||
| 284 | if (!id_mappings_.door_groups().contains(h_group.name())) { | ||
| 285 | groups[h_group.name()] = next_id_++; | ||
| 286 | } else { | ||
| 287 | groups[h_group.name()] = id_mappings_.door_groups().at(h_group.name()); | ||
| 288 | } | ||
| 289 | } | ||
| 290 | } | ||
| 291 | |||
| 292 | void ProcessGlobalMetadataFile(std::filesystem::path path) { | ||
| 293 | if (!std::filesystem::exists(path)) { | ||
| 294 | return; | ||
| 295 | } | ||
| 296 | |||
| 297 | auto h_metadata = ReadMessageFromFile<HumanGlobalMetadata>(path.string()); | ||
| 298 | auto& specials = *output_.mutable_special(); | ||
| 299 | |||
| 300 | for (const std::string& h_special : h_metadata.special_names()) { | ||
| 301 | if (!id_mappings_.special().contains(h_special)) { | ||
| 302 | specials[h_special] = next_id_++; | ||
| 303 | } else { | ||
| 304 | specials[h_special] = id_mappings_.special().at(h_special); | ||
| 209 | } | 305 | } |
| 210 | } | 306 | } |
| 211 | } | 307 | } |
| 212 | 308 | ||
| 213 | private: | 309 | private: |
| 310 | void UpdateNextId(const google::protobuf::Map<std::string, uint64_t>& ids) { | ||
| 311 | for (const auto& [_, id] : ids) { | ||
| 312 | if (id > next_id_) { | ||
| 313 | next_id_ = id; | ||
| 314 | } | ||
| 315 | } | ||
| 316 | } | ||
| 317 | |||
| 214 | std::string mapdir_; | 318 | std::string mapdir_; |
| 215 | 319 | ||
| 216 | uint64_t next_id_ = 1; | 320 | uint64_t next_id_ = 1; |
| 217 | 321 | ||
| 218 | IdMappings id_mappings_; | 322 | IdMappings id_mappings_; |
| 323 | IdMappings output_; | ||
| 219 | }; | 324 | }; |
| 220 | 325 | ||
| 221 | } // namespace | 326 | } // namespace |
| diff --git a/tools/datapacker/container.cpp b/tools/datapacker/container.cpp index 2c68552..4a656b3 100644 --- a/tools/datapacker/container.cpp +++ b/tools/datapacker/container.cpp | |||
| @@ -331,6 +331,40 @@ uint64_t Container::FindOrAddDoor(std::optional<std::string> map_name, | |||
| 331 | } | 331 | } |
| 332 | } | 332 | } |
| 333 | 333 | ||
| 334 | uint64_t Container::FindOrAddProgressive(std::string prog_name) { | ||
| 335 | auto it = progressive_id_by_name_.find(prog_name); | ||
| 336 | |||
| 337 | if (it == progressive_id_by_name_.end()) { | ||
| 338 | uint64_t new_id = all_objects_.progressives_size(); | ||
| 339 | Progressive* progressive = all_objects_.add_progressives(); | ||
| 340 | progressive->set_id(new_id); | ||
| 341 | progressive->set_name(prog_name); | ||
| 342 | |||
| 343 | progressive_id_by_name_[prog_name] = new_id; | ||
| 344 | |||
| 345 | return new_id; | ||
| 346 | } else { | ||
| 347 | return it->second; | ||
| 348 | } | ||
| 349 | } | ||
| 350 | |||
| 351 | uint64_t Container::FindOrAddDoorGroup(std::string group_name) { | ||
| 352 | auto it = door_group_id_by_name_.find(group_name); | ||
| 353 | |||
| 354 | if (it == door_group_id_by_name_.end()) { | ||
| 355 | uint64_t new_id = all_objects_.door_groups_size(); | ||
| 356 | DoorGroup* door_group = all_objects_.add_door_groups(); | ||
| 357 | door_group->set_id(new_id); | ||
| 358 | door_group->set_name(group_name); | ||
| 359 | |||
| 360 | door_group_id_by_name_[group_name] = new_id; | ||
| 361 | |||
| 362 | return new_id; | ||
| 363 | } else { | ||
| 364 | return it->second; | ||
| 365 | } | ||
| 366 | } | ||
| 367 | |||
| 334 | void Container::AddConnection(const Connection& connection) { | 368 | void Container::AddConnection(const Connection& connection) { |
| 335 | *all_objects_.add_connections() = connection; | 369 | *all_objects_.add_connections() = connection; |
| 336 | } | 370 | } |
| diff --git a/tools/datapacker/container.h b/tools/datapacker/container.h index 68f5875..bc02ba4 100644 --- a/tools/datapacker/container.h +++ b/tools/datapacker/container.h | |||
| @@ -60,6 +60,10 @@ class Container { | |||
| 60 | 60 | ||
| 61 | void AddConnection(const Connection& connection); | 61 | void AddConnection(const Connection& connection); |
| 62 | 62 | ||
| 63 | uint64_t FindOrAddProgressive(std::string prog_name); | ||
| 64 | |||
| 65 | uint64_t FindOrAddDoorGroup(std::string group_name); | ||
| 66 | |||
| 63 | AllObjects& all_objects() { return all_objects_; } | 67 | AllObjects& all_objects() { return all_objects_; } |
| 64 | 68 | ||
| 65 | private: | 69 | private: |
| @@ -82,6 +86,8 @@ class Container { | |||
| 82 | std::map<std::string, std::map<std::string, uint64_t>> | 86 | std::map<std::string, std::map<std::string, uint64_t>> |
| 83 | door_id_by_map_door_names_; | 87 | door_id_by_map_door_names_; |
| 84 | std::map<std::string, uint64_t> ending_id_by_name_; | 88 | std::map<std::string, uint64_t> ending_id_by_name_; |
| 89 | std::map<std::string, uint64_t> progressive_id_by_name_; | ||
| 90 | std::map<std::string, uint64_t> door_group_id_by_name_; | ||
| 85 | }; | 91 | }; |
| 86 | 92 | ||
| 87 | } // namespace com::fourisland::lingo2_archipelago | 93 | } // namespace com::fourisland::lingo2_archipelago |
| diff --git a/tools/datapacker/main.cpp b/tools/datapacker/main.cpp index d820360..c13a4df 100644 --- a/tools/datapacker/main.cpp +++ b/tools/datapacker/main.cpp | |||
| @@ -43,6 +43,9 @@ class DataPacker { | |||
| 43 | 43 | ||
| 44 | ProcessConnectionsFile(datadir_path / "connections.txtpb", std::nullopt); | 44 | ProcessConnectionsFile(datadir_path / "connections.txtpb", std::nullopt); |
| 45 | ProcessMaps(datadir_path); | 45 | ProcessMaps(datadir_path); |
| 46 | ProcessProgressivesFile(datadir_path / "progressives.txtpb"); | ||
| 47 | ProcessDoorGroupsFile(datadir_path / "door_groups.txtpb"); | ||
| 48 | ProcessGlobalMetadataFile(datadir_path / "metadata.txtpb"); | ||
| 46 | ProcessIdsFile(datadir_path / "ids.yaml"); | 49 | ProcessIdsFile(datadir_path / "ids.yaml"); |
| 47 | 50 | ||
| 48 | { | 51 | { |
| @@ -104,7 +107,11 @@ class DataPacker { | |||
| 104 | container_.FindOrAddRoom(current_map_name, h_room.name(), std::nullopt); | 107 | container_.FindOrAddRoom(current_map_name, h_room.name(), std::nullopt); |
| 105 | Room& room = *container_.all_objects().mutable_rooms(room_id); | 108 | Room& room = *container_.all_objects().mutable_rooms(room_id); |
| 106 | 109 | ||
| 107 | room.set_display_name(h_room.display_name()); | 110 | // room.set_display_name(h_room.display_name()); |
| 111 | |||
| 112 | if (h_room.has_panel_display_name()) { | ||
| 113 | room.set_panel_display_name(h_room.panel_display_name()); | ||
| 114 | } | ||
| 108 | 115 | ||
| 109 | for (const HumanPanel& h_panel : h_room.panels()) { | 116 | for (const HumanPanel& h_panel : h_room.panels()) { |
| 110 | room.add_panels(ProcessPanel(h_panel, current_map_name, room.name())); | 117 | room.add_panels(ProcessPanel(h_panel, current_map_name, room.name())); |
| @@ -175,6 +182,10 @@ class DataPacker { | |||
| 175 | map_name, h_panel.required_room().name(), current_map_name)); | 182 | map_name, h_panel.required_room().name(), current_map_name)); |
| 176 | } | 183 | } |
| 177 | 184 | ||
| 185 | if (h_panel.has_display_name()) { | ||
| 186 | panel.set_display_name(h_panel.display_name()); | ||
| 187 | } | ||
| 188 | |||
| 178 | return panel_id; | 189 | return panel_id; |
| 179 | } | 190 | } |
| 180 | 191 | ||
| @@ -284,6 +295,10 @@ class DataPacker { | |||
| 284 | 295 | ||
| 285 | keyholder.set_path(h_keyholder.path()); | 296 | keyholder.set_path(h_keyholder.path()); |
| 286 | 297 | ||
| 298 | if (h_keyholder.has_key()) { | ||
| 299 | keyholder.set_key(h_keyholder.key()); | ||
| 300 | } | ||
| 301 | |||
| 287 | return keyholder_id; | 302 | return keyholder_id; |
| 288 | } | 303 | } |
| 289 | 304 | ||
| @@ -331,8 +346,8 @@ class DataPacker { | |||
| 331 | h_door.receivers().begin(), h_door.receivers().end(), | 346 | h_door.receivers().begin(), h_door.receivers().end(), |
| 332 | google::protobuf::RepeatedFieldBackInserter(door.mutable_receivers())); | 347 | google::protobuf::RepeatedFieldBackInserter(door.mutable_receivers())); |
| 333 | std::copy( | 348 | std::copy( |
| 334 | h_door.switches().begin(), h_door.switches().end(), | 349 | h_door.senders().begin(), h_door.senders().end(), |
| 335 | google::protobuf::RepeatedFieldBackInserter(door.mutable_switches())); | 350 | google::protobuf::RepeatedFieldBackInserter(door.mutable_senders())); |
| 336 | 351 | ||
| 337 | for (const PaintingIdentifier& pi : h_door.move_paintings()) { | 352 | for (const PaintingIdentifier& pi : h_door.move_paintings()) { |
| 338 | std::optional<std::string> map_name = | 353 | std::optional<std::string> map_name = |
| @@ -380,7 +395,7 @@ class DataPacker { | |||
| 380 | door.add_doors( | 395 | door.add_doors( |
| 381 | container_.FindOrAddDoor(map_name, di.name(), current_map_name)); | 396 | container_.FindOrAddDoor(map_name, di.name(), current_map_name)); |
| 382 | } | 397 | } |
| 383 | 398 | ||
| 384 | for (const std::string& ending_name : h_door.endings()) { | 399 | for (const std::string& ending_name : h_door.endings()) { |
| 385 | door.add_endings(container_.FindOrAddEnding(ending_name)); | 400 | door.add_endings(container_.FindOrAddEnding(ending_name)); |
| 386 | } | 401 | } |
| @@ -394,6 +409,14 @@ class DataPacker { | |||
| 394 | } | 409 | } |
| 395 | 410 | ||
| 396 | door.set_type(h_door.type()); | 411 | door.set_type(h_door.type()); |
| 412 | |||
| 413 | if (h_door.has_location_name()) { | ||
| 414 | door.set_location_name(h_door.location_name()); | ||
| 415 | } | ||
| 416 | |||
| 417 | if (h_door.has_double_letters()) { | ||
| 418 | door.set_double_letters(h_door.double_letters()); | ||
| 419 | } | ||
| 397 | } | 420 | } |
| 398 | 421 | ||
| 399 | void ProcessConnectionsFile(std::filesystem::path path, | 422 | void ProcessConnectionsFile(std::filesystem::path path, |
| @@ -445,6 +468,11 @@ class DataPacker { | |||
| 445 | r_connection.set_required_door(door_id); | 468 | r_connection.set_required_door(door_id); |
| 446 | } | 469 | } |
| 447 | 470 | ||
| 471 | if (human_connection.has_roof_access()) { | ||
| 472 | f_connection.set_roof_access(human_connection.roof_access()); | ||
| 473 | r_connection.set_roof_access(human_connection.roof_access()); | ||
| 474 | } | ||
| 475 | |||
| 448 | container_.AddConnection(f_connection); | 476 | container_.AddConnection(f_connection); |
| 449 | if (!human_connection.oneway()) { | 477 | if (!human_connection.oneway()) { |
| 450 | container_.AddConnection(r_connection); | 478 | container_.AddConnection(r_connection); |
| @@ -528,6 +556,63 @@ class DataPacker { | |||
| 528 | } | 556 | } |
| 529 | } | 557 | } |
| 530 | 558 | ||
| 559 | void ProcessProgressivesFile(std::filesystem::path path) { | ||
| 560 | if (!std::filesystem::exists(path)) { | ||
| 561 | return; | ||
| 562 | } | ||
| 563 | |||
| 564 | auto h_progs = ReadMessageFromFile<HumanProgressives>(path.string()); | ||
| 565 | |||
| 566 | for (const HumanProgressive& h_prog : h_progs.progressives()) { | ||
| 567 | ProcessProgressive(h_prog); | ||
| 568 | } | ||
| 569 | } | ||
| 570 | |||
| 571 | void ProcessProgressive(const HumanProgressive& h_prog) { | ||
| 572 | uint64_t prog_id = container_.FindOrAddProgressive(h_prog.name()); | ||
| 573 | Progressive& prog = *container_.all_objects().mutable_progressives(prog_id); | ||
| 574 | |||
| 575 | for (const DoorIdentifier& di : h_prog.doors()) { | ||
| 576 | uint64_t door_id = | ||
| 577 | container_.FindOrAddDoor(di.map(), di.name(), std::nullopt); | ||
| 578 | prog.add_doors(door_id); | ||
| 579 | } | ||
| 580 | } | ||
| 581 | |||
| 582 | void ProcessDoorGroupsFile(std::filesystem::path path) { | ||
| 583 | if (!std::filesystem::exists(path)) { | ||
| 584 | return; | ||
| 585 | } | ||
| 586 | |||
| 587 | auto h_groups = ReadMessageFromFile<HumanDoorGroups>(path.string()); | ||
| 588 | |||
| 589 | for (const HumanDoorGroup& h_group : h_groups.door_groups()) { | ||
| 590 | ProcessDoorGroup(h_group); | ||
| 591 | } | ||
| 592 | } | ||
| 593 | |||
| 594 | void ProcessDoorGroup(const HumanDoorGroup& h_group) { | ||
| 595 | uint64_t group_id = container_.FindOrAddDoorGroup(h_group.name()); | ||
| 596 | DoorGroup& group = *container_.all_objects().mutable_door_groups(group_id); | ||
| 597 | |||
| 598 | group.set_type(h_group.type()); | ||
| 599 | |||
| 600 | for (const DoorIdentifier& di : h_group.doors()) { | ||
| 601 | uint64_t door_id = | ||
| 602 | container_.FindOrAddDoor(di.map(), di.name(), std::nullopt); | ||
| 603 | group.add_doors(door_id); | ||
| 604 | } | ||
| 605 | } | ||
| 606 | |||
| 607 | void ProcessGlobalMetadataFile(std::filesystem::path path) { | ||
| 608 | if (!std::filesystem::exists(path)) { | ||
| 609 | return; | ||
| 610 | } | ||
| 611 | |||
| 612 | auto h_metadata = ReadMessageFromFile<HumanGlobalMetadata>(path.string()); | ||
| 613 | container_.all_objects().set_version(h_metadata.version()); | ||
| 614 | } | ||
| 615 | |||
| 531 | void ProcessIdsFile(std::filesystem::path path) { | 616 | void ProcessIdsFile(std::filesystem::path path) { |
| 532 | auto ids = ReadIdsFromYaml(path.string()); | 617 | auto ids = ReadIdsFromYaml(path.string()); |
| 533 | 618 | ||
| @@ -552,6 +637,14 @@ class DataPacker { | |||
| 552 | .mutable_masteries(mastery_id) | 637 | .mutable_masteries(mastery_id) |
| 553 | ->set_ap_id(ap_id); | 638 | ->set_ap_id(ap_id); |
| 554 | } | 639 | } |
| 640 | |||
| 641 | for (const auto& [keyholder_name, ap_id] : room.keyholders()) { | ||
| 642 | uint64_t keyholder_id = container_.FindOrAddKeyholder( | ||
| 643 | map_name, room_name, keyholder_name, std::nullopt, std::nullopt); | ||
| 644 | container_.all_objects() | ||
| 645 | .mutable_keyholders(keyholder_id) | ||
| 646 | ->set_ap_id(ap_id); | ||
| 647 | } | ||
| 555 | } | 648 | } |
| 556 | } | 649 | } |
| 557 | 650 | ||
| @@ -569,6 +662,16 @@ class DataPacker { | |||
| 569 | uint64_t ending_id = container_.FindOrAddEnding(ending_name); | 662 | uint64_t ending_id = container_.FindOrAddEnding(ending_name); |
| 570 | container_.all_objects().mutable_endings(ending_id)->set_ap_id(ap_id); | 663 | container_.all_objects().mutable_endings(ending_id)->set_ap_id(ap_id); |
| 571 | } | 664 | } |
| 665 | |||
| 666 | for (const auto& [prog_name, ap_id] : ids.progressives()) { | ||
| 667 | uint64_t prog_id = container_.FindOrAddProgressive(prog_name); | ||
| 668 | container_.all_objects().mutable_progressives(prog_id)->set_ap_id(ap_id); | ||
| 669 | } | ||
| 670 | |||
| 671 | for (const auto& [group_name, ap_id] : ids.door_groups()) { | ||
| 672 | uint64_t group_id = container_.FindOrAddDoorGroup(group_name); | ||
| 673 | container_.all_objects().mutable_door_groups(group_id)->set_ap_id(ap_id); | ||
| 674 | } | ||
| 572 | } | 675 | } |
| 573 | 676 | ||
| 574 | std::string mapdir_; | 677 | std::string mapdir_; |
| diff --git a/tools/util/godot_scene.cpp b/tools/util/godot_scene.cpp index 1e77c9e..f788d21 100644 --- a/tools/util/godot_scene.cpp +++ b/tools/util/godot_scene.cpp | |||
| @@ -1,10 +1,8 @@ | |||
| 1 | #include "godot_scene.h" | 1 | #include "godot_scene.h" |
| 2 | 2 | ||
| 3 | #include <absl/strings/str_split.h> | ||
| 4 | #include <absl/strings/string_view.h> | ||
| 5 | |||
| 6 | #include <fstream> | 3 | #include <fstream> |
| 7 | #include <sstream> | 4 | #include <sstream> |
| 5 | #include <string_view> | ||
| 8 | #include <variant> | 6 | #include <variant> |
| 9 | 7 | ||
| 10 | namespace com::fourisland::lingo2_archipelago { | 8 | namespace com::fourisland::lingo2_archipelago { |
| @@ -23,7 +21,7 @@ struct Heading { | |||
| 23 | GodotInstanceType instance_type; | 21 | GodotInstanceType instance_type; |
| 24 | }; | 22 | }; |
| 25 | 23 | ||
| 26 | Heading ParseTscnHeading(absl::string_view line) { | 24 | Heading ParseTscnHeading(std::string_view line) { |
| 27 | std::string original_line(line); | 25 | std::string original_line(line); |
| 28 | Heading heading; | 26 | Heading heading; |
| 29 | 27 | ||
| diff --git a/tools/util/ids_yaml_format.cpp b/tools/util/ids_yaml_format.cpp index f72f60e..71bfd63 100644 --- a/tools/util/ids_yaml_format.cpp +++ b/tools/util/ids_yaml_format.cpp | |||
| @@ -56,6 +56,14 @@ IdMappings ReadIdsFromYaml(const std::string& filename) { | |||
| 56 | mastery_it.second.as<uint64_t>(); | 56 | mastery_it.second.as<uint64_t>(); |
| 57 | } | 57 | } |
| 58 | } | 58 | } |
| 59 | |||
| 60 | if (room_it.second["keyholders"]) { | ||
| 61 | for (const auto& keyholder_it : room_it.second["keyholders"]) { | ||
| 62 | (*room_ids.mutable_keyholders())[keyholder_it.first | ||
| 63 | .as<std::string>()] = | ||
| 64 | keyholder_it.second.as<uint64_t>(); | ||
| 65 | } | ||
| 66 | } | ||
| 59 | } | 67 | } |
| 60 | } | 68 | } |
| 61 | 69 | ||
| @@ -89,6 +97,20 @@ IdMappings ReadIdsFromYaml(const std::string& filename) { | |||
| 89 | } | 97 | } |
| 90 | } | 98 | } |
| 91 | 99 | ||
| 100 | if (document["progressives"]) { | ||
| 101 | for (const auto& prog_it : document["progressives"]) { | ||
| 102 | (*result.mutable_progressives())[prog_it.first.as<std::string>()] = | ||
| 103 | prog_it.second.as<uint64_t>(); | ||
| 104 | } | ||
| 105 | } | ||
| 106 | |||
| 107 | if (document["door_groups"]) { | ||
| 108 | for (const auto& group_it : document["door_groups"]) { | ||
| 109 | (*result.mutable_door_groups())[group_it.first.as<std::string>()] = | ||
| 110 | group_it.second.as<uint64_t>(); | ||
| 111 | } | ||
| 112 | } | ||
| 113 | |||
| 92 | return result; | 114 | return result; |
| 93 | } | 115 | } |
| 94 | 116 | ||
| @@ -117,6 +139,13 @@ void WriteIdsAsYaml(const IdMappings& ids, const std::string& filename) { | |||
| 117 | mastery_id; | 139 | mastery_id; |
| 118 | }); | 140 | }); |
| 119 | 141 | ||
| 142 | OperateOnSortedMap(room_ids.keyholders(), | ||
| 143 | [&room_node](const std::string& keyholder_name, | ||
| 144 | uint64_t keyholder_id) { | ||
| 145 | room_node["keyholders"][keyholder_name] = | ||
| 146 | keyholder_id; | ||
| 147 | }); | ||
| 148 | |||
| 120 | map_node["rooms"][room_name] = std::move(room_node); | 149 | map_node["rooms"][room_name] = std::move(room_node); |
| 121 | }); | 150 | }); |
| 122 | 151 | ||
| @@ -144,6 +173,16 @@ void WriteIdsAsYaml(const IdMappings& ids, const std::string& filename) { | |||
| 144 | result["special"][special_name] = special_id; | 173 | result["special"][special_name] = special_id; |
| 145 | }); | 174 | }); |
| 146 | 175 | ||
| 176 | OperateOnSortedMap(ids.progressives(), | ||
| 177 | [&result](const std::string& prog_name, uint64_t prog_id) { | ||
| 178 | result["progressives"][prog_name] = prog_id; | ||
| 179 | }); | ||
| 180 | |||
| 181 | OperateOnSortedMap(ids.door_groups(), [&result](const std::string& group_name, | ||
| 182 | uint64_t group_id) { | ||
| 183 | result["door_groups"][group_name] = group_id; | ||
| 184 | }); | ||
| 185 | |||
| 147 | std::ofstream output_stream(filename); | 186 | std::ofstream output_stream(filename); |
| 148 | output_stream << result << std::endl; | 187 | output_stream << result << std::endl; |
| 149 | } | 188 | } |
| diff --git a/tools/validator/CMakeLists.txt b/tools/validator/CMakeLists.txt index 967b890..1a8fd9c 100644 --- a/tools/validator/CMakeLists.txt +++ b/tools/validator/CMakeLists.txt | |||
| @@ -1,3 +1,4 @@ | |||
| 1 | find_package(fmt REQUIRED) | ||
| 1 | find_package(Protobuf REQUIRED) | 2 | find_package(Protobuf REQUIRED) |
| 2 | 3 | ||
| 3 | add_executable(validator | 4 | add_executable(validator |
| @@ -9,4 +10,4 @@ add_executable(validator | |||
| 9 | set_property(TARGET validator PROPERTY CXX_STANDARD 20) | 10 | set_property(TARGET validator PROPERTY CXX_STANDARD 20) |
| 10 | set_property(TARGET validator PROPERTY CXX_STANDARD_REQUIRED ON) | 11 | set_property(TARGET validator PROPERTY CXX_STANDARD_REQUIRED ON) |
| 11 | target_include_directories(validator PUBLIC ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR}/tools) | 12 | target_include_directories(validator PUBLIC ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR}/tools) |
| 12 | target_link_libraries(validator PUBLIC protos util protobuf::libprotobuf) | 13 | target_link_libraries(validator PUBLIC protos util fmt::fmt protobuf::libprotobuf) |
| diff --git a/tools/validator/human_processor.cpp b/tools/validator/human_processor.cpp index fb06d31..2c978bf 100644 --- a/tools/validator/human_processor.cpp +++ b/tools/validator/human_processor.cpp | |||
| @@ -1,5 +1,6 @@ | |||
| 1 | #include "human_processor.h" | 1 | #include "human_processor.h" |
| 2 | 2 | ||
| 3 | #include <fmt/core.h> | ||
| 3 | #include <google/protobuf/message.h> | 4 | #include <google/protobuf/message.h> |
| 4 | #include <google/protobuf/text_format.h> | 5 | #include <google/protobuf/text_format.h> |
| 5 | 6 | ||
| @@ -12,6 +13,7 @@ | |||
| 12 | #include <string> | 13 | #include <string> |
| 13 | 14 | ||
| 14 | #include "structs.h" | 15 | #include "structs.h" |
| 16 | #include "util/ids_yaml_format.h" | ||
| 15 | 17 | ||
| 16 | namespace com::fourisland::lingo2_archipelago { | 18 | namespace com::fourisland::lingo2_archipelago { |
| 17 | namespace { | 19 | namespace { |
| @@ -40,7 +42,9 @@ class HumanProcessor { | |||
| 40 | 42 | ||
| 41 | ProcessConnectionsFile(datadir_path / "connections.txtpb", std::nullopt); | 43 | ProcessConnectionsFile(datadir_path / "connections.txtpb", std::nullopt); |
| 42 | ProcessMaps(datadir_path); | 44 | ProcessMaps(datadir_path); |
| 43 | ProcessIdsFile(datadir_path / "ids.txtpb"); | 45 | ProcessProgressivesFile(datadir_path / "progressives.txtpb"); |
| 46 | ProcessDoorGroupsFile(datadir_path / "door_groups.txtpb"); | ||
| 47 | ProcessIdsFile(datadir_path / "ids.yaml"); | ||
| 44 | } | 48 | } |
| 45 | 49 | ||
| 46 | private: | 50 | private: |
| @@ -93,7 +97,7 @@ class HumanProcessor { | |||
| 93 | room_info.definitions.push_back(h_room); | 97 | room_info.definitions.push_back(h_room); |
| 94 | 98 | ||
| 95 | for (const HumanPanel& h_panel : h_room.panels()) { | 99 | for (const HumanPanel& h_panel : h_room.panels()) { |
| 96 | ProcessPanel(h_panel, current_map_name, h_room.name()); | 100 | ProcessPanel(h_panel, current_map_name, h_room); |
| 97 | } | 101 | } |
| 98 | 102 | ||
| 99 | for (const HumanPainting& h_painting : h_room.paintings()) { | 103 | for (const HumanPainting& h_painting : h_room.paintings()) { |
| @@ -123,10 +127,10 @@ class HumanProcessor { | |||
| 123 | 127 | ||
| 124 | void ProcessPanel(const HumanPanel& h_panel, | 128 | void ProcessPanel(const HumanPanel& h_panel, |
| 125 | const std::string& current_map_name, | 129 | const std::string& current_map_name, |
| 126 | const std::string& current_room_name) { | 130 | const HumanRoom& h_room) { |
| 127 | PanelIdentifier panel_identifier; | 131 | PanelIdentifier panel_identifier; |
| 128 | panel_identifier.set_map(current_map_name); | 132 | panel_identifier.set_map(current_map_name); |
| 129 | panel_identifier.set_room(current_room_name); | 133 | panel_identifier.set_room(h_room.name()); |
| 130 | panel_identifier.set_name(h_panel.name()); | 134 | panel_identifier.set_name(h_panel.name()); |
| 131 | 135 | ||
| 132 | PanelInfo& panel_info = info_.panels[panel_identifier]; | 136 | PanelInfo& panel_info = info_.panels[panel_identifier]; |
| @@ -155,6 +159,24 @@ class HumanProcessor { | |||
| 155 | RoomInfo& required_room_info = info_.rooms[required_room_identifier]; | 159 | RoomInfo& required_room_info = info_.rooms[required_room_identifier]; |
| 156 | required_room_info.panels_referenced_by.push_back(panel_identifier); | 160 | required_room_info.panels_referenced_by.push_back(panel_identifier); |
| 157 | } | 161 | } |
| 162 | |||
| 163 | std::string map_area_name = current_map_name; | ||
| 164 | if (h_room.has_panel_display_name()) { | ||
| 165 | map_area_name = | ||
| 166 | fmt::format("{} ({})", current_map_name, h_room.panel_display_name()); | ||
| 167 | } | ||
| 168 | |||
| 169 | panel_info.map_area_name = map_area_name; | ||
| 170 | |||
| 171 | std::string panelsanity_name; | ||
| 172 | if (h_panel.has_display_name()) { | ||
| 173 | panelsanity_name = | ||
| 174 | fmt::format("{} - {}", map_area_name, h_panel.display_name()); | ||
| 175 | } else { | ||
| 176 | panelsanity_name = fmt::format("{} - {}", map_area_name, h_panel.name()); | ||
| 177 | } | ||
| 178 | info_.panel_names[panelsanity_name].panels_used_by.push_back( | ||
| 179 | panel_identifier); | ||
| 158 | } | 180 | } |
| 159 | 181 | ||
| 160 | void ProcessPainting(const HumanPainting& h_painting, | 182 | void ProcessPainting(const HumanPainting& h_painting, |
| @@ -372,7 +394,9 @@ class HumanProcessor { | |||
| 372 | } | 394 | } |
| 373 | } else if (human_connection.has_from()) { | 395 | } else if (human_connection.has_from()) { |
| 374 | ProcessSingleConnection(human_connection, human_connection.from(), | 396 | ProcessSingleConnection(human_connection, human_connection.from(), |
| 375 | current_map_name); | 397 | current_map_name, |
| 398 | /*is_target=*/!human_connection.oneway() && | ||
| 399 | !human_connection.bypass_target_door()); | ||
| 376 | } | 400 | } |
| 377 | 401 | ||
| 378 | if (human_connection.has_to_room()) { | 402 | if (human_connection.has_to_room()) { |
| @@ -388,8 +412,9 @@ class HumanProcessor { | |||
| 388 | std::cout << "A global connection used to_room." << std::endl; | 412 | std::cout << "A global connection used to_room." << std::endl; |
| 389 | } | 413 | } |
| 390 | } else if (human_connection.has_to()) { | 414 | } else if (human_connection.has_to()) { |
| 391 | ProcessSingleConnection(human_connection, human_connection.to(), | 415 | ProcessSingleConnection( |
| 392 | current_map_name); | 416 | human_connection, human_connection.to(), current_map_name, |
| 417 | /*is_target=*/!human_connection.bypass_target_door()); | ||
| 393 | } | 418 | } |
| 394 | 419 | ||
| 395 | if (human_connection.has_door()) { | 420 | if (human_connection.has_door()) { |
| @@ -410,7 +435,7 @@ class HumanProcessor { | |||
| 410 | void ProcessSingleConnection( | 435 | void ProcessSingleConnection( |
| 411 | const HumanConnection& human_connection, | 436 | const HumanConnection& human_connection, |
| 412 | const HumanConnection::Endpoint& endpoint, | 437 | const HumanConnection::Endpoint& endpoint, |
| 413 | const std::optional<std::string>& current_map_name) { | 438 | const std::optional<std::string>& current_map_name, bool is_target) { |
| 414 | if (endpoint.has_room()) { | 439 | if (endpoint.has_room()) { |
| 415 | auto room_identifier = | 440 | auto room_identifier = |
| 416 | GetCompleteRoomIdentifier(endpoint.room(), current_map_name); | 441 | GetCompleteRoomIdentifier(endpoint.room(), current_map_name); |
| @@ -429,6 +454,11 @@ class HumanProcessor { | |||
| 429 | if (painting_identifier) { | 454 | if (painting_identifier) { |
| 430 | PaintingInfo& painting_info = info_.paintings[*painting_identifier]; | 455 | PaintingInfo& painting_info = info_.paintings[*painting_identifier]; |
| 431 | 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 | } | ||
| 432 | } else { | 462 | } else { |
| 433 | // Not sure where else to store this right now. | 463 | // Not sure where else to store this right now. |
| 434 | std::cout | 464 | std::cout |
| @@ -441,6 +471,11 @@ class HumanProcessor { | |||
| 441 | if (port_identifier) { | 471 | if (port_identifier) { |
| 442 | PortInfo& port_info = info_.ports[*port_identifier]; | 472 | PortInfo& port_info = info_.ports[*port_identifier]; |
| 443 | 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 | } | ||
| 444 | } else { | 479 | } else { |
| 445 | // Not sure where else to store this right now. | 480 | // Not sure where else to store this right now. |
| 446 | std::cout | 481 | std::cout |
| @@ -458,12 +493,137 @@ class HumanProcessor { | |||
| 458 | panel_info.proxies[endpoint.panel().answer()] | 493 | panel_info.proxies[endpoint.panel().answer()] |
| 459 | .connections_referenced_by.push_back(human_connection); | 494 | .connections_referenced_by.push_back(human_connection); |
| 460 | } | 495 | } |
| 496 | |||
| 497 | if (is_target) { | ||
| 498 | panel_info.target_connections_referenced_by.push_back( | ||
| 499 | human_connection); | ||
| 500 | } | ||
| 461 | } | 501 | } |
| 462 | } | 502 | } |
| 463 | } | 503 | } |
| 464 | 504 | ||
| 505 | void ProcessProgressivesFile(std::filesystem::path path) { | ||
| 506 | if (!std::filesystem::exists(path)) { | ||
| 507 | return; | ||
| 508 | } | ||
| 509 | |||
| 510 | auto h_progs = ReadMessageFromFile<HumanProgressives>(path.string()); | ||
| 511 | |||
| 512 | for (const HumanProgressive& h_prog : h_progs.progressives()) { | ||
| 513 | ProcessProgressive(h_prog); | ||
| 514 | } | ||
| 515 | } | ||
| 516 | |||
| 517 | void ProcessProgressive(const HumanProgressive& h_prog) { | ||
| 518 | ProgressiveInfo& prog_info = info_.progressives[h_prog.name()]; | ||
| 519 | prog_info.definitions.push_back(h_prog); | ||
| 520 | |||
| 521 | for (const DoorIdentifier& di : h_prog.doors()) { | ||
| 522 | if (!di.has_map()) { | ||
| 523 | prog_info.malformed_doors.push_back(di); | ||
| 524 | continue; | ||
| 525 | } | ||
| 526 | |||
| 527 | DoorInfo& door_info = info_.doors[di]; | ||
| 528 | door_info.progressives_referenced_by.push_back(h_prog.name()); | ||
| 529 | } | ||
| 530 | } | ||
| 531 | |||
| 532 | void ProcessDoorGroupsFile(std::filesystem::path path) { | ||
| 533 | if (!std::filesystem::exists(path)) { | ||
| 534 | return; | ||
| 535 | } | ||
| 536 | |||
| 537 | auto h_groups = ReadMessageFromFile<HumanDoorGroups>(path.string()); | ||
| 538 | |||
| 539 | for (const HumanDoorGroup& h_group : h_groups.door_groups()) { | ||
| 540 | ProcessDoorGroup(h_group); | ||
| 541 | } | ||
| 542 | } | ||
| 543 | |||
| 544 | void ProcessDoorGroup(const HumanDoorGroup& h_group) { | ||
| 545 | DoorGroupInfo& group_info = info_.door_groups[h_group.name()]; | ||
| 546 | group_info.definitions.push_back(h_group); | ||
| 547 | |||
| 548 | for (const DoorIdentifier& di : h_group.doors()) { | ||
| 549 | if (!di.has_map()) { | ||
| 550 | group_info.malformed_doors.push_back(di); | ||
| 551 | continue; | ||
| 552 | } | ||
| 553 | |||
| 554 | DoorInfo& door_info = info_.doors[di]; | ||
| 555 | door_info.door_groups_referenced_by.push_back(h_group.name()); | ||
| 556 | } | ||
| 557 | } | ||
| 558 | |||
| 465 | void ProcessIdsFile(std::filesystem::path path) { | 559 | void ProcessIdsFile(std::filesystem::path path) { |
| 466 | // Ignore this for now. | 560 | auto ids = ReadIdsFromYaml(path.string()); |
| 561 | |||
| 562 | DoorIdentifier di; | ||
| 563 | PanelIdentifier pi; | ||
| 564 | KeyholderIdentifier ki; | ||
| 565 | |||
| 566 | for (const auto& [map_name, map] : ids.maps()) { | ||
| 567 | di.set_map(map_name); | ||
| 568 | pi.set_map(map_name); | ||
| 569 | ki.set_map(map_name); | ||
| 570 | |||
| 571 | for (const auto& [door_name, ap_id] : map.doors()) { | ||
| 572 | di.set_name(door_name); | ||
| 573 | |||
| 574 | DoorInfo& door_info = info_.doors[di]; | ||
| 575 | door_info.has_id = true; | ||
| 576 | } | ||
| 577 | |||
| 578 | for (const auto& [room_name, room] : map.rooms()) { | ||
| 579 | pi.set_room(room_name); | ||
| 580 | ki.set_room(room_name); | ||
| 581 | |||
| 582 | for (const auto& [panel_name, ap_id] : room.panels()) { | ||
| 583 | pi.set_name(panel_name); | ||
| 584 | |||
| 585 | PanelInfo& panel_info = info_.panels[pi]; | ||
| 586 | panel_info.has_id = true; | ||
| 587 | } | ||
| 588 | |||
| 589 | for (const auto& [mastery_name, ap_id] : room.masteries()) { | ||
| 590 | // TODO: Mastery | ||
| 591 | } | ||
| 592 | |||
| 593 | for (const auto& [keyholder_name, ap_id] : room.keyholders()) { | ||
| 594 | ki.set_name(keyholder_name); | ||
| 595 | |||
| 596 | KeyholderInfo& keyholder_info = info_.keyholders[ki]; | ||
| 597 | keyholder_info.has_id = true; | ||
| 598 | } | ||
| 599 | } | ||
| 600 | } | ||
| 601 | |||
| 602 | for (const auto& [tag, id] : ids.special()) { | ||
| 603 | // TODO: Specials | ||
| 604 | } | ||
| 605 | |||
| 606 | for (const auto& [letter_name, ap_id] : ids.letters()) { | ||
| 607 | LetterIdentifier li = | ||
| 608 | std::make_tuple(letter_name[0], letter_name[1] == '2'); | ||
| 609 | LetterInfo& letter_info = info_.letters[li]; | ||
| 610 | letter_info.has_id = true; | ||
| 611 | } | ||
| 612 | |||
| 613 | for (const auto& [ending_name, ap_id] : ids.endings()) { | ||
| 614 | EndingInfo& ending_info = info_.endings[ending_name]; | ||
| 615 | ending_info.has_id = true; | ||
| 616 | } | ||
| 617 | |||
| 618 | for (const auto& [prog_name, ap_id] : ids.progressives()) { | ||
| 619 | ProgressiveInfo& prog_info = info_.progressives[prog_name]; | ||
| 620 | prog_info.has_id = true; | ||
| 621 | } | ||
| 622 | |||
| 623 | for (const auto& [group_name, ap_id] : ids.door_groups()) { | ||
| 624 | DoorGroupInfo& group_info = info_.door_groups[group_name]; | ||
| 625 | group_info.has_id = true; | ||
| 626 | } | ||
| 467 | } | 627 | } |
| 468 | 628 | ||
| 469 | std::string mapdir_; | 629 | std::string mapdir_; |
| diff --git a/tools/validator/structs.h b/tools/validator/structs.h index 958038d..d1d45f2 100644 --- a/tools/validator/structs.h +++ b/tools/validator/structs.h | |||
| @@ -39,12 +39,15 @@ struct RoomInfo { | |||
| 39 | 39 | ||
| 40 | struct DoorInfo { | 40 | struct DoorInfo { |
| 41 | std::vector<HumanDoor> definitions; | 41 | std::vector<HumanDoor> definitions; |
| 42 | bool has_id = false; | ||
| 42 | 43 | ||
| 43 | std::vector<HumanConnection> connections_referenced_by; | 44 | std::vector<HumanConnection> connections_referenced_by; |
| 44 | std::vector<DoorIdentifier> doors_referenced_by; | 45 | std::vector<DoorIdentifier> doors_referenced_by; |
| 45 | std::vector<PanelIdentifier> panels_referenced_by; | 46 | std::vector<PanelIdentifier> panels_referenced_by; |
| 46 | std::vector<PaintingIdentifier> paintings_referenced_by; | 47 | std::vector<PaintingIdentifier> paintings_referenced_by; |
| 47 | std::vector<PortIdentifier> ports_referenced_by; | 48 | std::vector<PortIdentifier> ports_referenced_by; |
| 49 | std::vector<std::string> progressives_referenced_by; | ||
| 50 | std::vector<std::string> door_groups_referenced_by; | ||
| 48 | 51 | ||
| 49 | MalformedIdentifiers malformed_identifiers; | 52 | MalformedIdentifiers malformed_identifiers; |
| 50 | }; | 53 | }; |
| @@ -53,12 +56,14 @@ struct PortInfo { | |||
| 53 | std::vector<HumanPort> definitions; | 56 | std::vector<HumanPort> definitions; |
| 54 | 57 | ||
| 55 | std::vector<HumanConnection> connections_referenced_by; | 58 | std::vector<HumanConnection> connections_referenced_by; |
| 59 | std::vector<HumanConnection> target_connections_referenced_by; | ||
| 56 | }; | 60 | }; |
| 57 | 61 | ||
| 58 | struct PaintingInfo { | 62 | struct PaintingInfo { |
| 59 | std::vector<HumanPainting> definitions; | 63 | std::vector<HumanPainting> definitions; |
| 60 | 64 | ||
| 61 | std::vector<HumanConnection> connections_referenced_by; | 65 | std::vector<HumanConnection> connections_referenced_by; |
| 66 | std::vector<HumanConnection> target_connections_referenced_by; | ||
| 62 | std::vector<DoorIdentifier> doors_referenced_by; | 67 | std::vector<DoorIdentifier> doors_referenced_by; |
| 63 | }; | 68 | }; |
| 64 | 69 | ||
| @@ -71,8 +76,12 @@ struct ProxyInfo { | |||
| 71 | 76 | ||
| 72 | struct PanelInfo { | 77 | struct PanelInfo { |
| 73 | std::vector<HumanPanel> definitions; | 78 | std::vector<HumanPanel> definitions; |
| 79 | bool has_id = false; | ||
| 80 | |||
| 81 | std::string map_area_name; | ||
| 74 | 82 | ||
| 75 | std::vector<HumanConnection> connections_referenced_by; | 83 | std::vector<HumanConnection> connections_referenced_by; |
| 84 | std::vector<HumanConnection> target_connections_referenced_by; | ||
| 76 | std::vector<DoorIdentifier> doors_referenced_by; | 85 | std::vector<DoorIdentifier> doors_referenced_by; |
| 77 | 86 | ||
| 78 | std::map<std::string, ProxyInfo> proxies; | 87 | std::map<std::string, ProxyInfo> proxies; |
| @@ -80,6 +89,7 @@ struct PanelInfo { | |||
| 80 | 89 | ||
| 81 | struct KeyholderInfo { | 90 | struct KeyholderInfo { |
| 82 | std::vector<HumanKeyholder> definitions; | 91 | std::vector<HumanKeyholder> definitions; |
| 92 | bool has_id = false; | ||
| 83 | 93 | ||
| 84 | std::vector<DoorIdentifier> doors_referenced_by; | 94 | std::vector<DoorIdentifier> doors_referenced_by; |
| 85 | }; | 95 | }; |
| @@ -88,14 +98,34 @@ using LetterIdentifier = std::tuple<char, bool>; | |||
| 88 | 98 | ||
| 89 | struct LetterInfo { | 99 | struct LetterInfo { |
| 90 | std::vector<RoomIdentifier> defined_in; | 100 | std::vector<RoomIdentifier> defined_in; |
| 101 | bool has_id = false; | ||
| 91 | }; | 102 | }; |
| 92 | 103 | ||
| 93 | struct EndingInfo { | 104 | struct EndingInfo { |
| 94 | std::vector<RoomIdentifier> defined_in; | 105 | std::vector<RoomIdentifier> defined_in; |
| 106 | bool has_id = false; | ||
| 95 | 107 | ||
| 96 | std::vector<DoorIdentifier> doors_referenced_by; | 108 | std::vector<DoorIdentifier> doors_referenced_by; |
| 97 | }; | 109 | }; |
| 98 | 110 | ||
| 111 | struct PanelNameInfo { | ||
| 112 | std::vector<PanelIdentifier> panels_used_by; | ||
| 113 | }; | ||
| 114 | |||
| 115 | struct ProgressiveInfo { | ||
| 116 | std::vector<HumanProgressive> definitions; | ||
| 117 | bool has_id = false; | ||
| 118 | |||
| 119 | std::vector<DoorIdentifier> malformed_doors; | ||
| 120 | }; | ||
| 121 | |||
| 122 | struct DoorGroupInfo { | ||
| 123 | std::vector<HumanDoorGroup> definitions; | ||
| 124 | bool has_id = false; | ||
| 125 | |||
| 126 | std::vector<DoorIdentifier> malformed_doors; | ||
| 127 | }; | ||
| 128 | |||
| 99 | struct CollectedInfo { | 129 | struct CollectedInfo { |
| 100 | std::map<std::string, MapInfo> maps; | 130 | std::map<std::string, MapInfo> maps; |
| 101 | std::map<RoomIdentifier, RoomInfo, RoomIdentifierLess> rooms; | 131 | std::map<RoomIdentifier, RoomInfo, RoomIdentifierLess> rooms; |
| @@ -107,6 +137,9 @@ struct CollectedInfo { | |||
| 107 | keyholders; | 137 | keyholders; |
| 108 | std::map<LetterIdentifier, LetterInfo> letters; | 138 | std::map<LetterIdentifier, LetterInfo> letters; |
| 109 | std::map<std::string, EndingInfo> endings; | 139 | std::map<std::string, EndingInfo> endings; |
| 140 | std::map<std::string, PanelNameInfo> panel_names; | ||
| 141 | std::map<std::string, ProgressiveInfo> progressives; | ||
| 142 | std::map<std::string, DoorGroupInfo> door_groups; | ||
| 110 | }; | 143 | }; |
| 111 | 144 | ||
| 112 | } // namespace com::fourisland::lingo2_archipelago | 145 | } // namespace com::fourisland::lingo2_archipelago |
| diff --git a/tools/validator/validator.cpp b/tools/validator/validator.cpp index f802460..dd41f5c 100644 --- a/tools/validator/validator.cpp +++ b/tools/validator/validator.cpp | |||
| @@ -9,291 +9,542 @@ | |||
| 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) { | 12 | class Validator { |
| 13 | for (const auto& [node_path, node_info] : map_info.game_nodes) { | 13 | public: |
| 14 | if (node_info.uses > 1) { | 14 | explicit Validator(const CollectedInfo& info) : info_(info) {} |
| 15 | std::cout << "Map " << map_name << " node " << node_path | ||
| 16 | << " is used in multiple places." << std::endl; | ||
| 17 | } else if (node_info.uses == 0) { | ||
| 18 | std::cout << "Map " << map_name << " node " << node_path | ||
| 19 | << " is not used." << std::endl; | ||
| 20 | } | ||
| 21 | 15 | ||
| 22 | if (!node_info.defined) { | 16 | void Validate() const { |
| 23 | std::cout << "Map " << map_name << " node " << node_path | 17 | for (const auto& [map_name, map_info] : info_.maps) { |
| 24 | << " is not defined in the game file." << std::endl; | 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); | ||
| 25 | } | 53 | } |
| 26 | } | 54 | } |
| 27 | } | ||
| 28 | 55 | ||
| 29 | void ValidateRoom(const RoomIdentifier& room_identifier, | 56 | private: |
| 30 | const RoomInfo& room_info) { | 57 | void ValidateMap(const std::string& map_name, const MapInfo& map_info) const { |
| 31 | if (room_info.definitions.empty()) { | 58 | for (const auto& [node_path, node_info] : map_info.game_nodes) { |
| 32 | std::cout << "Room " << room_identifier.ShortDebugString() | 59 | if (node_info.uses > 1) { |
| 33 | << " has no definition, but was referenced:" << std::endl; | 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 | } | ||
| 34 | 66 | ||
| 35 | for (const DoorIdentifier& door_identifier : | 67 | if (!node_info.defined) { |
| 36 | room_info.doors_referenced_by) { | 68 | std::cout << "Map " << map_name << " node " << node_path |
| 37 | std::cout << " DOOR " << door_identifier.ShortDebugString() | 69 | << " is not defined in the game file." << std::endl; |
| 38 | << std::endl; | 70 | } |
| 39 | } | 71 | } |
| 72 | } | ||
| 40 | 73 | ||
| 41 | for (const PanelIdentifier& panel_identifier : | 74 | void ValidateRoom(const RoomIdentifier& room_identifier, |
| 42 | room_info.panels_referenced_by) { | 75 | const RoomInfo& room_info) const { |
| 43 | std::cout << " PANEL " << panel_identifier.ShortDebugString() | 76 | if (room_info.definitions.empty()) { |
| 44 | << std::endl; | 77 | std::cout << "Room " << room_identifier.ShortDebugString() |
| 45 | } | 78 | << " has no definition, but was referenced:" << std::endl; |
| 46 | 79 | ||
| 47 | for (const HumanConnection& connection : | 80 | for (const DoorIdentifier& door_identifier : |
| 48 | room_info.connections_referenced_by) { | 81 | room_info.doors_referenced_by) { |
| 49 | std::cout << " CONNECTION " << connection.ShortDebugString() | 82 | std::cout << " DOOR " << door_identifier.ShortDebugString() |
| 50 | << std::endl; | 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; | ||
| 51 | } | 100 | } |
| 52 | } else if (room_info.definitions.size() > 1) { | ||
| 53 | std::cout << "Room " << room_identifier.ShortDebugString() | ||
| 54 | << " was defined multiple times." << std::endl; | ||
| 55 | } | 101 | } |
| 56 | } | ||
| 57 | |||
| 58 | void ValidateDoor(const DoorIdentifier& door_identifier, | ||
| 59 | const DoorInfo& door_info) { | ||
| 60 | if (door_info.definitions.empty()) { | ||
| 61 | std::cout << "Door " << door_identifier.ShortDebugString() | ||
| 62 | << " has no definition, but was referenced:" << std::endl; | ||
| 63 | 102 | ||
| 64 | for (const DoorIdentifier& other_door_identifier : | 103 | bool DoesDoorNeedLocationName(const HumanDoor& h_door, |
| 65 | door_info.doors_referenced_by) { | 104 | const std::string& map_name) const { |
| 66 | std::cout << " DOOR " << other_door_identifier.ShortDebugString() | 105 | if (h_door.type() != DoorType::STANDARD) { |
| 67 | << std::endl; | 106 | return false; |
| 68 | } | 107 | } |
| 69 | 108 | ||
| 70 | for (const PanelIdentifier& panel_identifier : | 109 | if (h_door.keyholders_size() > 0 || h_door.endings_size() > 0 || |
| 71 | door_info.panels_referenced_by) { | 110 | h_door.complete_at() > 0) { |
| 72 | std::cout << " PANEL " << panel_identifier.ShortDebugString() | 111 | return true; |
| 73 | << std::endl; | ||
| 74 | } | 112 | } |
| 75 | 113 | ||
| 76 | for (const PaintingIdentifier& painting_identifier : | 114 | if (h_door.panels_size() > 4) { |
| 77 | door_info.paintings_referenced_by) { | 115 | return true; |
| 78 | std::cout << " PAINTING " << painting_identifier.ShortDebugString() | ||
| 79 | << std::endl; | ||
| 80 | } | 116 | } |
| 81 | 117 | ||
| 82 | for (const PortIdentifier& port_identifier : | 118 | std::set<std::string> map_areas; |
| 83 | door_info.ports_referenced_by) { | 119 | for (const PanelIdentifier& pi : h_door.panels()) { |
| 84 | std::cout << " PORT " << port_identifier.ShortDebugString() | 120 | auto full_pi = |
| 85 | << std::endl; | 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 | } | ||
| 86 | } | 130 | } |
| 87 | 131 | ||
| 88 | for (const HumanConnection& connection : | 132 | if (map_areas.size() > 1) { |
| 89 | door_info.connections_referenced_by) { | 133 | return true; |
| 90 | std::cout << " CONNECTION " << connection.ShortDebugString() | ||
| 91 | << std::endl; | ||
| 92 | } | 134 | } |
| 93 | } else if (door_info.definitions.size() > 1) { | 135 | |
| 94 | std::cout << "Door " << door_identifier.ShortDebugString() | 136 | return false; |
| 95 | << " was defined multiple times." << std::endl; | ||
| 96 | } | 137 | } |
| 97 | 138 | ||
| 98 | if (door_info.malformed_identifiers.HasAny()) { | 139 | void ValidateDoor(const DoorIdentifier& door_identifier, |
| 99 | std::cout << "Door " << door_identifier.ShortDebugString() | 140 | const DoorInfo& door_info) const { |
| 100 | << " has malformed identifiers:" << std::endl; | 141 | if (door_info.definitions.empty()) { |
| 142 | std::cout << "Door " << door_identifier.ShortDebugString() | ||
| 143 | << " has no definition, but was referenced:" << std::endl; | ||
| 101 | 144 | ||
| 102 | for (const PaintingIdentifier& painting_identifier : | 145 | for (const DoorIdentifier& other_door_identifier : |
| 103 | door_info.malformed_identifiers.paintings) { | 146 | door_info.doors_referenced_by) { |
| 104 | std::cout << " PAINTING " << painting_identifier.ShortDebugString() | 147 | std::cout << " DOOR " << other_door_identifier.ShortDebugString() |
| 105 | << std::endl; | 148 | << std::endl; |
| 106 | } | 149 | } |
| 107 | 150 | ||
| 108 | for (const PanelIdentifier& panel_identifier : | 151 | for (const PanelIdentifier& panel_identifier : |
| 109 | door_info.malformed_identifiers.panels) { | 152 | door_info.panels_referenced_by) { |
| 110 | std::cout << " PANEL " << panel_identifier.ShortDebugString() | 153 | std::cout << " PANEL " << panel_identifier.ShortDebugString() |
| 111 | << std::endl; | 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; | ||
| 112 | } | 191 | } |
| 113 | 192 | ||
| 114 | for (const KeyholderIdentifier& keyholder_identifier : | 193 | if (door_info.malformed_identifiers.HasAny()) { |
| 115 | door_info.malformed_identifiers.keyholders) { | 194 | std::cout << "Door " << door_identifier.ShortDebugString() |
| 116 | std::cout << " KEYHOLDER " << keyholder_identifier.ShortDebugString() | 195 | << " has malformed identifiers:" << std::endl; |
| 117 | << 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 | } | ||
| 118 | } | 214 | } |
| 119 | } | ||
| 120 | } | ||
| 121 | 215 | ||
| 122 | void ValidatePort(const PortIdentifier& port_identifier, | 216 | for (const HumanDoor& h_door : door_info.definitions) { |
| 123 | const PortInfo& port_info) { | 217 | if (DoesDoorNeedLocationName(h_door, door_identifier.map()) && |
| 124 | if (port_info.definitions.empty()) { | 218 | !h_door.has_location_name()) { |
| 125 | std::cout << "Port " << port_identifier.ShortDebugString() | 219 | std::cout << "Door " << door_identifier.ShortDebugString() |
| 126 | << " has no definition, but was referenced:" << std::endl; | 220 | << " needs an explicit location name." << std::endl; |
| 221 | } | ||
| 127 | 222 | ||
| 128 | for (const HumanConnection& connection : | 223 | if (h_door.double_letters() && |
| 129 | port_info.connections_referenced_by) { | 224 | (h_door.type() == DoorType::STANDARD || |
| 130 | std::cout << " CONNECTION " << connection.ShortDebugString() | 225 | h_door.type() == DoorType::LOCATION_ONLY || |
| 131 | << std::endl; | 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 | } | ||
| 132 | } | 242 | } |
| 133 | } else if (port_info.definitions.size() > 1) { | ||
| 134 | std::cout << "Port " << port_identifier.ShortDebugString() | ||
| 135 | << " was defined multiple times." << std::endl; | ||
| 136 | } | 243 | } |
| 137 | } | ||
| 138 | 244 | ||
| 139 | void ValidatePainting(const PaintingIdentifier& painting_identifier, | 245 | void ValidatePort(const PortIdentifier& port_identifier, |
| 140 | const PaintingInfo& painting_info) { | 246 | const PortInfo& port_info) const { |
| 141 | if (painting_info.definitions.empty()) { | 247 | if (port_info.definitions.empty()) { |
| 142 | std::cout << "Painting " << painting_identifier.ShortDebugString() | 248 | std::cout << "Port " << port_identifier.ShortDebugString() |
| 143 | << " has no definition, but was referenced:" << std::endl; | 249 | << " has no definition, but was referenced:" << std::endl; |
| 144 | 250 | ||
| 145 | for (const DoorIdentifier& door_identifier : | 251 | for (const HumanConnection& connection : |
| 146 | painting_info.doors_referenced_by) { | 252 | port_info.connections_referenced_by) { |
| 147 | std::cout << " DOOR " << door_identifier.ShortDebugString() | 253 | std::cout << " CONNECTION " << connection.ShortDebugString() |
| 148 | << std::endl; | 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; | ||
| 149 | } | 259 | } |
| 150 | 260 | ||
| 151 | for (const HumanConnection& connection : | 261 | if (!port_info.target_connections_referenced_by.empty()) { |
| 152 | painting_info.connections_referenced_by) { | 262 | for (const HumanPort& port : port_info.definitions) { |
| 153 | std::cout << " CONNECTION " << connection.ShortDebugString() | 263 | if (port.has_required_door()) { |
| 154 | << std::endl; | 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 | } | ||
| 155 | } | 275 | } |
| 156 | } else if (painting_info.definitions.size() > 1) { | ||
| 157 | std::cout << "Painting " << painting_identifier.ShortDebugString() | ||
| 158 | << " was defined multiple times." << std::endl; | ||
| 159 | } | 276 | } |
| 160 | } | ||
| 161 | 277 | ||
| 162 | void ValidatePanel(const PanelIdentifier& panel_identifier, | 278 | void ValidatePainting(const PaintingIdentifier& painting_identifier, |
| 163 | const PanelInfo& panel_info) { | 279 | const PaintingInfo& painting_info) const { |
| 164 | if (panel_identifier.name().empty()) { | 280 | if (painting_info.definitions.empty()) { |
| 165 | std::cout << "Panel " << panel_identifier.ShortDebugString() | 281 | std::cout << "Painting " << painting_identifier.ShortDebugString() |
| 166 | << " has no name." << std::endl; | 282 | << " has no definition, but was referenced:" << std::endl; |
| 167 | } | ||
| 168 | 283 | ||
| 169 | if (panel_info.definitions.empty()) { | 284 | for (const DoorIdentifier& door_identifier : |
| 170 | std::cout << "Panel " << panel_identifier.ShortDebugString() | 285 | painting_info.doors_referenced_by) { |
| 171 | << " has no definition, but was referenced:" << std::endl; | 286 | std::cout << " DOOR " << door_identifier.ShortDebugString() |
| 287 | << std::endl; | ||
| 288 | } | ||
| 172 | 289 | ||
| 173 | for (const DoorIdentifier& door_identifier : | 290 | for (const HumanConnection& connection : |
| 174 | panel_info.doors_referenced_by) { | 291 | painting_info.connections_referenced_by) { |
| 175 | std::cout << " DOOR " << door_identifier.ShortDebugString() | 292 | std::cout << " CONNECTION " << connection.ShortDebugString() |
| 176 | << std::endl; | 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; | ||
| 177 | } | 298 | } |
| 178 | 299 | ||
| 179 | for (const HumanConnection& connection : | 300 | if (!painting_info.target_connections_referenced_by.empty()) { |
| 180 | panel_info.connections_referenced_by) { | 301 | for (const HumanPainting& painting : painting_info.definitions) { |
| 181 | std::cout << " CONNECTION " << connection.ShortDebugString() | 302 | if (painting.has_required_door()) { |
| 182 | << std::endl; | 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 | } | ||
| 183 | } | 314 | } |
| 184 | } else if (panel_info.definitions.size() > 1) { | ||
| 185 | std::cout << "Panel " << panel_identifier.ShortDebugString() | ||
| 186 | << " was defined multiple times." << std::endl; | ||
| 187 | } | 315 | } |
| 188 | 316 | ||
| 189 | for (const auto& [answer, proxy_info] : panel_info.proxies) { | 317 | void ValidatePanel(const PanelIdentifier& panel_identifier, |
| 190 | if (proxy_info.definitions.empty()) { | 318 | const PanelInfo& panel_info) const { |
| 319 | if (panel_identifier.name().empty()) { | ||
| 191 | std::cout << "Panel " << panel_identifier.ShortDebugString() | 320 | std::cout << "Panel " << panel_identifier.ShortDebugString() |
| 192 | << " with answer \"" << answer | 321 | << " has no name." << std::endl; |
| 193 | << "\" has no definition, but was referenced:" << 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; | ||
| 194 | 327 | ||
| 195 | for (const DoorIdentifier& door_identifier : | 328 | for (const DoorIdentifier& door_identifier : |
| 196 | proxy_info.doors_referenced_by) { | 329 | panel_info.doors_referenced_by) { |
| 197 | std::cout << " DOOR " << door_identifier.ShortDebugString() | 330 | std::cout << " DOOR " << door_identifier.ShortDebugString() |
| 198 | << std::endl; | 331 | << std::endl; |
| 199 | } | 332 | } |
| 200 | 333 | ||
| 201 | for (const HumanConnection& connection : | 334 | for (const HumanConnection& connection : |
| 202 | proxy_info.connections_referenced_by) { | 335 | panel_info.connections_referenced_by) { |
| 203 | std::cout << " CONNECTION " << connection.ShortDebugString() | 336 | std::cout << " CONNECTION " << connection.ShortDebugString() |
| 204 | << std::endl; | 337 | << std::endl; |
| 205 | } | 338 | } |
| 206 | } else if (proxy_info.definitions.size() > 1) { | 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) { | ||
| 207 | std::cout << "Panel " << panel_identifier.ShortDebugString() | 344 | std::cout << "Panel " << panel_identifier.ShortDebugString() |
| 208 | << " with answer \"" << answer | 345 | << " was defined multiple times." << std::endl; |
| 209 | << "\" 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 | } | ||
| 210 | } | 391 | } |
| 211 | } | 392 | } |
| 212 | } | ||
| 213 | 393 | ||
| 214 | void ValidateKeyholder(const KeyholderIdentifier& keyholder_identifier, | 394 | void ValidateKeyholder(const KeyholderIdentifier& keyholder_identifier, |
| 215 | const KeyholderInfo& keyholder_info) { | 395 | const KeyholderInfo& keyholder_info) const { |
| 216 | if (keyholder_info.definitions.empty()) { | 396 | if (keyholder_info.definitions.empty()) { |
| 217 | std::cout << "Keyholder " << keyholder_identifier.ShortDebugString() | 397 | std::cout << "Keyholder " << keyholder_identifier.ShortDebugString() |
| 218 | << " has no definition, but was referenced:" << std::endl; | 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 | } | ||
| 219 | 413 | ||
| 220 | for (const DoorIdentifier& door_identifier : | 414 | for (const HumanKeyholder& h_keyholder : keyholder_info.definitions) { |
| 221 | keyholder_info.doors_referenced_by) { | 415 | bool needs_id = (h_keyholder.has_key()); |
| 222 | std::cout << " DOOR " << door_identifier.ShortDebugString() | 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." | ||
| 223 | << std::endl; | 452 | << std::endl; |
| 224 | } | 453 | } |
| 225 | } else if (keyholder_info.definitions.size() > 1) { | ||
| 226 | std::cout << "Keyholder " << keyholder_identifier.ShortDebugString() | ||
| 227 | << " was defined multiple times." << std::endl; | ||
| 228 | } | 454 | } |
| 229 | } | ||
| 230 | 455 | ||
| 231 | void ValidateLetter(const LetterIdentifier& letter_identifier, | 456 | void ValidateEnding(const std::string& ending_name, |
| 232 | const LetterInfo& letter_info) { | 457 | const EndingInfo& ending_info) const { |
| 233 | std::string letter_name = std::string(1, std::get<0>(letter_identifier)) + | 458 | if (ending_info.defined_in.empty()) { |
| 234 | (std::get<1>(letter_identifier) ? "2" : "1"); | 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; | ||
| 235 | 474 | ||
| 236 | if (letter_info.defined_in.size() > 1) { | 475 | for (const RoomIdentifier& room_identifier : ending_info.defined_in) { |
| 237 | std::cout << "Letter " << letter_name | 476 | std::cout << " " << room_identifier.ShortDebugString() << std::endl; |
| 238 | << " was defined in multiple places:" << std::endl; | 477 | } |
| 478 | } | ||
| 239 | 479 | ||
| 240 | for (const RoomIdentifier& room_identifier : letter_info.defined_in) { | 480 | if (!ending_info.has_id) { |
| 241 | std::cout << " " << room_identifier.ShortDebugString() << std::endl; | 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 | } | ||
| 242 | } | 497 | } |
| 243 | } | 498 | } |
| 244 | } | ||
| 245 | 499 | ||
| 246 | void ValidateEnding(const std::string& ending_name, | 500 | void ValidateProgressive(const std::string& prog_name, |
| 247 | const EndingInfo& ending_info) { | 501 | const ProgressiveInfo& prog_info) const { |
| 248 | if (ending_info.defined_in.empty()) { | 502 | if (prog_info.definitions.empty()) { |
| 249 | std::cout << "Ending " << ending_name | 503 | std::cout << "Progressive \"" << prog_name |
| 250 | << " has no definition, but was referenced:" << std::endl; | 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 | } | ||
| 251 | 513 | ||
| 252 | for (const DoorIdentifier& door_identifier : | 514 | if (!prog_info.has_id) { |
| 253 | ending_info.doors_referenced_by) { | 515 | std::cout << "Progressive \"" << prog_name << "\" is missing an AP ID." |
| 254 | std::cout << " DOOR " << door_identifier.ShortDebugString() | ||
| 255 | << std::endl; | 516 | << std::endl; |
| 256 | } | 517 | } |
| 257 | } else if (ending_info.defined_in.size() > 1) { | 518 | } |
| 258 | std::cout << "Ending " << ending_name | ||
| 259 | << " was defined in multiple places:" << std::endl; | ||
| 260 | 519 | ||
| 261 | for (const RoomIdentifier& room_identifier : ending_info.defined_in) { | 520 | void ValidateDoorGroup(const std::string& group_name, |
| 262 | std::cout << " " << room_identifier.ShortDebugString() << std::endl; | 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; | ||
| 263 | } | 537 | } |
| 264 | } | 538 | } |
| 265 | } | 539 | |
| 540 | const CollectedInfo& info_; | ||
| 541 | }; | ||
| 266 | 542 | ||
| 267 | } // namespace | 543 | } // namespace |
| 268 | 544 | ||
| 269 | void ValidateCollectedInfo(const CollectedInfo& info) { | 545 | void ValidateCollectedInfo(const CollectedInfo& info) { |
| 270 | for (const auto& [map_name, map_info] : info.maps) { | 546 | Validator validator(info); |
| 271 | ValidateMap(map_name, map_info); | 547 | validator.Validate(); |
| 272 | } | ||
| 273 | for (const auto& [room_identifier, room_info] : info.rooms) { | ||
| 274 | ValidateRoom(room_identifier, room_info); | ||
| 275 | } | ||
| 276 | for (const auto& [door_identifier, door_info] : info.doors) { | ||
| 277 | ValidateDoor(door_identifier, door_info); | ||
| 278 | } | ||
| 279 | for (const auto& [port_identifier, port_info] : info.ports) { | ||
| 280 | ValidatePort(port_identifier, port_info); | ||
| 281 | } | ||
| 282 | for (const auto& [painting_identifier, painting_info] : info.paintings) { | ||
| 283 | ValidatePainting(painting_identifier, painting_info); | ||
| 284 | } | ||
| 285 | for (const auto& [panel_identifier, panel_info] : info.panels) { | ||
| 286 | ValidatePanel(panel_identifier, panel_info); | ||
| 287 | } | ||
| 288 | for (const auto& [keyholder_identifier, keyholder_info] : info.keyholders) { | ||
| 289 | ValidateKeyholder(keyholder_identifier, keyholder_info); | ||
| 290 | } | ||
| 291 | for (const auto& [letter_identifier, letter_info] : info.letters) { | ||
| 292 | ValidateLetter(letter_identifier, letter_info); | ||
| 293 | } | ||
| 294 | for (const auto& [ending_name, ending_info] : info.endings) { | ||
| 295 | ValidateEnding(ending_name, ending_info); | ||
| 296 | } | ||
| 297 | } | 548 | } |
| 298 | 549 | ||
| 299 | } // namespace com::fourisland::lingo2_archipelago | 550 | } // namespace com::fourisland::lingo2_archipelago |
