diff options
Diffstat (limited to 'tools')
| -rw-r--r-- | tools/assign_ids/main.cpp | 228 | ||||
| -rw-r--r-- | tools/datapacker/container.cpp | 34 | ||||
| -rw-r--r-- | tools/datapacker/container.h | 6 | ||||
| -rw-r--r-- | tools/datapacker/main.cpp | 149 | ||||
| -rw-r--r-- | tools/util/godot_scene.cpp | 6 | ||||
| -rw-r--r-- | tools/util/ids_yaml_format.cpp | 52 | ||||
| -rw-r--r-- | tools/validator/human_processor.cpp | 183 | ||||
| -rw-r--r-- | tools/validator/structs.h | 32 | ||||
| -rw-r--r-- | tools/validator/validator.cpp | 226 | ||||
| -rw-r--r-- | tools/validator/validator.h | 2 |
10 files changed, 842 insertions, 76 deletions
| diff --git a/tools/assign_ids/main.cpp b/tools/assign_ids/main.cpp index e65e5e4..4cf7c3f 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,27 @@ 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 | UpdateNextId(room.ports()); |
| 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 | } | 69 | } |
| 88 | } | 70 | } |
| 89 | 71 | ||
| 90 | for (const auto& [_, id] : id_mappings_.endings()) { | 72 | UpdateNextId(id_mappings_.special()); |
| 91 | if (id > next_id_) { | 73 | UpdateNextId(id_mappings_.letters()); |
| 92 | next_id_ = id; | 74 | UpdateNextId(id_mappings_.endings()); |
| 93 | } | 75 | UpdateNextId(id_mappings_.progressives()); |
| 94 | } | 76 | UpdateNextId(id_mappings_.door_groups()); |
| 95 | 77 | ||
| 96 | next_id_++; | 78 | next_id_++; |
| 97 | } | 79 | } |
| 98 | 80 | ||
| 99 | void WriteIds(std::filesystem::path path) { | 81 | void WriteIds(std::filesystem::path path) { |
| 100 | WriteIdsAsYaml(id_mappings_, path.string()); | 82 | WriteIdsAsYaml(output_, path.string()); |
| 101 | } | 83 | } |
| 102 | 84 | ||
| 103 | void ProcessMaps(std::filesystem::path path) { | 85 | void ProcessMaps(std::filesystem::path path) { |
| @@ -130,18 +112,23 @@ class AssignIds { | |||
| 130 | 112 | ||
| 131 | void ProcessDoor(const HumanDoor& h_door, | 113 | void ProcessDoor(const HumanDoor& h_door, |
| 132 | const std::string& current_map_name) { | 114 | const std::string& current_map_name) { |
| 133 | if (h_door.type() == DoorType::EVENT) { | 115 | if (h_door.type() == DoorType::EVENT && !h_door.latch() && |
| 116 | !h_door.legacy_location()) { | ||
| 134 | return; | 117 | return; |
| 135 | } | 118 | } |
| 136 | 119 | ||
| 120 | auto& maps = *output_.mutable_maps(); | ||
| 121 | auto& doors = *maps[current_map_name].mutable_doors(); | ||
| 122 | |||
| 137 | if (!id_mappings_.maps().contains(current_map_name) || | 123 | if (!id_mappings_.maps().contains(current_map_name) || |
| 138 | !id_mappings_.maps() | 124 | !id_mappings_.maps() |
| 139 | .at(current_map_name) | 125 | .at(current_map_name) |
| 140 | .doors() | 126 | .doors() |
| 141 | .contains(h_door.name())) { | 127 | .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_++; | 128 | doors[h_door.name()] = next_id_++; |
| 129 | } else { | ||
| 130 | doors[h_door.name()] = | ||
| 131 | id_mappings_.maps().at(current_map_name).doors().at(h_door.name()); | ||
| 145 | } | 132 | } |
| 146 | } | 133 | } |
| 147 | 134 | ||
| @@ -156,6 +143,10 @@ class AssignIds { | |||
| 156 | void ProcessRoom(const HumanRoom& h_room, | 143 | void ProcessRoom(const HumanRoom& h_room, |
| 157 | const std::string& current_map_name) { | 144 | const std::string& current_map_name) { |
| 158 | for (const HumanPanel& h_panel : h_room.panels()) { | 145 | for (const HumanPanel& h_panel : h_room.panels()) { |
| 146 | auto& maps = *output_.mutable_maps(); | ||
| 147 | auto& rooms = *maps[current_map_name].mutable_rooms(); | ||
| 148 | auto& panels = *rooms[h_room.name()].mutable_panels(); | ||
| 149 | |||
| 159 | if (!id_mappings_.maps().contains(current_map_name) || | 150 | if (!id_mappings_.maps().contains(current_map_name) || |
| 160 | !id_mappings_.maps() | 151 | !id_mappings_.maps() |
| 161 | .at(current_map_name) | 152 | .at(current_map_name) |
| @@ -167,23 +158,33 @@ class AssignIds { | |||
| 167 | .at(h_room.name()) | 158 | .at(h_room.name()) |
| 168 | .panels() | 159 | .panels() |
| 169 | .contains(h_panel.name())) { | 160 | .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_++; | 161 | panels[h_panel.name()] = next_id_++; |
| 162 | } else { | ||
| 163 | panels[h_panel.name()] = id_mappings_.maps() | ||
| 164 | .at(current_map_name) | ||
| 165 | .rooms() | ||
| 166 | .at(h_room.name()) | ||
| 167 | .panels() | ||
| 168 | .at(h_panel.name()); | ||
| 174 | } | 169 | } |
| 175 | } | 170 | } |
| 176 | 171 | ||
| 177 | for (const HumanLetter& h_letter : h_room.letters()) { | 172 | for (const HumanLetter& h_letter : h_room.letters()) { |
| 178 | std::string lettername = GetLetterName(h_letter.key(), h_letter.level2()); | 173 | std::string lettername = GetLetterName(h_letter.key(), h_letter.level2()); |
| 179 | 174 | ||
| 175 | auto& letters = *output_.mutable_letters(); | ||
| 180 | if (!id_mappings_.letters().contains(lettername)) { | 176 | if (!id_mappings_.letters().contains(lettername)) { |
| 181 | auto& letters = *id_mappings_.mutable_letters(); | ||
| 182 | letters[lettername] = next_id_++; | 177 | letters[lettername] = next_id_++; |
| 178 | } else { | ||
| 179 | letters[lettername] = id_mappings_.letters().at(lettername); | ||
| 183 | } | 180 | } |
| 184 | } | 181 | } |
| 185 | 182 | ||
| 186 | for (const HumanMastery& h_mastery : h_room.masteries()) { | 183 | for (const HumanMastery& h_mastery : h_room.masteries()) { |
| 184 | auto& maps = *output_.mutable_maps(); | ||
| 185 | auto& rooms = *maps[current_map_name].mutable_rooms(); | ||
| 186 | auto& masteries = *rooms[h_room.name()].mutable_masteries(); | ||
| 187 | |||
| 187 | if (!id_mappings_.maps().contains(current_map_name) || | 188 | if (!id_mappings_.maps().contains(current_map_name) || |
| 188 | !id_mappings_.maps() | 189 | !id_mappings_.maps() |
| 189 | .at(current_map_name) | 190 | .at(current_map_name) |
| @@ -195,27 +196,164 @@ class AssignIds { | |||
| 195 | .at(h_room.name()) | 196 | .at(h_room.name()) |
| 196 | .masteries() | 197 | .masteries() |
| 197 | .contains(h_mastery.name())) { | 198 | .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_++; | 199 | masteries[h_mastery.name()] = next_id_++; |
| 200 | } else { | ||
| 201 | masteries[h_mastery.name()] = id_mappings_.maps() | ||
| 202 | .at(current_map_name) | ||
| 203 | .rooms() | ||
| 204 | .at(h_room.name()) | ||
| 205 | .masteries() | ||
| 206 | .at(h_mastery.name()); | ||
| 202 | } | 207 | } |
| 203 | } | 208 | } |
| 204 | 209 | ||
| 205 | for (const HumanEnding& h_ending : h_room.endings()) { | 210 | for (const HumanEnding& h_ending : h_room.endings()) { |
| 211 | auto& endings = *output_.mutable_endings(); | ||
| 212 | |||
| 206 | if (!id_mappings_.endings().contains(h_ending.name())) { | 213 | if (!id_mappings_.endings().contains(h_ending.name())) { |
| 207 | auto& endings = *id_mappings_.mutable_endings(); | ||
| 208 | endings[h_ending.name()] = next_id_++; | 214 | endings[h_ending.name()] = next_id_++; |
| 215 | } else { | ||
| 216 | endings[h_ending.name()] = id_mappings_.endings().at(h_ending.name()); | ||
| 217 | } | ||
| 218 | } | ||
| 219 | |||
| 220 | for (const HumanKeyholder& h_keyholder : h_room.keyholders()) { | ||
| 221 | if (!h_keyholder.has_key()) { | ||
| 222 | continue; | ||
| 223 | } | ||
| 224 | |||
| 225 | auto& maps = *output_.mutable_maps(); | ||
| 226 | auto& rooms = *maps[current_map_name].mutable_rooms(); | ||
| 227 | auto& keyholders = *rooms[h_room.name()].mutable_keyholders(); | ||
| 228 | |||
| 229 | if (!id_mappings_.maps().contains(current_map_name) || | ||
| 230 | !id_mappings_.maps() | ||
| 231 | .at(current_map_name) | ||
| 232 | .rooms() | ||
| 233 | .contains(h_room.name()) || | ||
| 234 | !id_mappings_.maps() | ||
| 235 | .at(current_map_name) | ||
| 236 | .rooms() | ||
| 237 | .at(h_room.name()) | ||
| 238 | .keyholders() | ||
| 239 | .contains(h_keyholder.name())) { | ||
| 240 | keyholders[h_keyholder.name()] = next_id_++; | ||
| 241 | } else { | ||
| 242 | keyholders[h_keyholder.name()] = id_mappings_.maps() | ||
| 243 | .at(current_map_name) | ||
| 244 | .rooms() | ||
| 245 | .at(h_room.name()) | ||
| 246 | .keyholders() | ||
| 247 | .at(h_keyholder.name()); | ||
| 248 | } | ||
| 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 | } | ||
| 281 | } | ||
| 282 | |||
| 283 | void ProcessSpecialIds() { | ||
| 284 | auto& specials = *output_.mutable_special(); | ||
| 285 | |||
| 286 | for (const auto& [special_name, ap_id] : id_mappings_.special()) { | ||
| 287 | specials[special_name] = ap_id; | ||
| 288 | } | ||
| 289 | } | ||
| 290 | |||
| 291 | void ProcessProgressivesFile(std::filesystem::path path) { | ||
| 292 | if (!std::filesystem::exists(path)) { | ||
| 293 | return; | ||
| 294 | } | ||
| 295 | |||
| 296 | auto h_progs = ReadMessageFromFile<HumanProgressives>(path.string()); | ||
| 297 | auto& progs = *output_.mutable_progressives(); | ||
| 298 | |||
| 299 | for (const HumanProgressive& h_prog : h_progs.progressives()) { | ||
| 300 | if (!id_mappings_.progressives().contains(h_prog.name())) { | ||
| 301 | progs[h_prog.name()] = next_id_++; | ||
| 302 | } else { | ||
| 303 | progs[h_prog.name()] = id_mappings_.progressives().at(h_prog.name()); | ||
| 304 | } | ||
| 305 | } | ||
| 306 | } | ||
| 307 | |||
| 308 | void ProcessDoorGroupsFile(std::filesystem::path path) { | ||
| 309 | if (!std::filesystem::exists(path)) { | ||
| 310 | return; | ||
| 311 | } | ||
| 312 | |||
| 313 | auto h_groups = ReadMessageFromFile<HumanDoorGroups>(path.string()); | ||
| 314 | auto& groups = *output_.mutable_door_groups(); | ||
| 315 | |||
| 316 | for (const HumanDoorGroup& h_group : h_groups.door_groups()) { | ||
| 317 | if (!id_mappings_.door_groups().contains(h_group.name())) { | ||
| 318 | groups[h_group.name()] = next_id_++; | ||
| 319 | } else { | ||
| 320 | groups[h_group.name()] = id_mappings_.door_groups().at(h_group.name()); | ||
| 321 | } | ||
| 322 | } | ||
| 323 | } | ||
| 324 | |||
| 325 | void ProcessGlobalMetadataFile(std::filesystem::path path) { | ||
| 326 | if (!std::filesystem::exists(path)) { | ||
| 327 | return; | ||
| 328 | } | ||
| 329 | |||
| 330 | auto h_metadata = ReadMessageFromFile<HumanGlobalMetadata>(path.string()); | ||
| 331 | auto& specials = *output_.mutable_special(); | ||
| 332 | |||
| 333 | for (const std::string& h_special : h_metadata.special_names()) { | ||
| 334 | if (!id_mappings_.special().contains(h_special)) { | ||
| 335 | specials[h_special] = next_id_++; | ||
| 336 | } else { | ||
| 337 | specials[h_special] = id_mappings_.special().at(h_special); | ||
| 209 | } | 338 | } |
| 210 | } | 339 | } |
| 211 | } | 340 | } |
| 212 | 341 | ||
| 213 | private: | 342 | private: |
| 343 | void UpdateNextId(const google::protobuf::Map<std::string, uint64_t>& ids) { | ||
| 344 | for (const auto& [_, id] : ids) { | ||
| 345 | if (id > next_id_) { | ||
| 346 | next_id_ = id; | ||
| 347 | } | ||
| 348 | } | ||
| 349 | } | ||
| 350 | |||
| 214 | std::string mapdir_; | 351 | std::string mapdir_; |
| 215 | 352 | ||
| 216 | uint64_t next_id_ = 1; | 353 | uint64_t next_id_ = 1; |
| 217 | 354 | ||
| 218 | IdMappings id_mappings_; | 355 | IdMappings id_mappings_; |
| 356 | IdMappings output_; | ||
| 219 | }; | 357 | }; |
| 220 | 358 | ||
| 221 | } // namespace | 359 | } // 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 cc83ca1..8109bf5 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 | { |
| @@ -85,9 +88,17 @@ class DataPacker { | |||
| 85 | uint64_t map_id = container_.FindOrAddMap(map_name); | 88 | uint64_t map_id = container_.FindOrAddMap(map_name); |
| 86 | Map& map = *container_.all_objects().mutable_maps(map_id); | 89 | Map& map = *container_.all_objects().mutable_maps(map_id); |
| 87 | 90 | ||
| 91 | map.set_type(metadata.type()); | ||
| 92 | |||
| 88 | if (metadata.has_display_name()) { | 93 | if (metadata.has_display_name()) { |
| 89 | map.set_display_name(metadata.display_name()); | 94 | map.set_display_name(metadata.display_name()); |
| 90 | } | 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 | } | ||
| 91 | } | 102 | } |
| 92 | 103 | ||
| 93 | void ProcessRooms(std::filesystem::path path, | 104 | void ProcessRooms(std::filesystem::path path, |
| @@ -104,7 +115,7 @@ class DataPacker { | |||
| 104 | container_.FindOrAddRoom(current_map_name, h_room.name(), std::nullopt); | 115 | container_.FindOrAddRoom(current_map_name, h_room.name(), std::nullopt); |
| 105 | Room& room = *container_.all_objects().mutable_rooms(room_id); | 116 | Room& room = *container_.all_objects().mutable_rooms(room_id); |
| 106 | 117 | ||
| 107 | //room.set_display_name(h_room.display_name()); | 118 | // room.set_display_name(h_room.display_name()); |
| 108 | 119 | ||
| 109 | if (h_room.has_panel_display_name()) { | 120 | if (h_room.has_panel_display_name()) { |
| 110 | room.set_panel_display_name(h_room.panel_display_name()); | 121 | room.set_panel_display_name(h_room.panel_display_name()); |
| @@ -236,7 +247,14 @@ class DataPacker { | |||
| 236 | Port& port = *container_.all_objects().mutable_ports(port_id); | 247 | Port& port = *container_.all_objects().mutable_ports(port_id); |
| 237 | 248 | ||
| 238 | port.set_path(h_port.path()); | 249 | port.set_path(h_port.path()); |
| 239 | 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 | } | ||
| 240 | 258 | ||
| 241 | // Setting this explicitly because the Godot protobuf doesn't support | 259 | // Setting this explicitly because the Godot protobuf doesn't support |
| 242 | // custom defaults. | 260 | // custom defaults. |
| @@ -292,6 +310,10 @@ class DataPacker { | |||
| 292 | 310 | ||
| 293 | keyholder.set_path(h_keyholder.path()); | 311 | keyholder.set_path(h_keyholder.path()); |
| 294 | 312 | ||
| 313 | if (h_keyholder.has_key()) { | ||
| 314 | keyholder.set_key(h_keyholder.key()); | ||
| 315 | } | ||
| 316 | |||
| 295 | return keyholder_id; | 317 | return keyholder_id; |
| 296 | } | 318 | } |
| 297 | 319 | ||
| @@ -339,8 +361,8 @@ class DataPacker { | |||
| 339 | h_door.receivers().begin(), h_door.receivers().end(), | 361 | h_door.receivers().begin(), h_door.receivers().end(), |
| 340 | google::protobuf::RepeatedFieldBackInserter(door.mutable_receivers())); | 362 | google::protobuf::RepeatedFieldBackInserter(door.mutable_receivers())); |
| 341 | std::copy( | 363 | std::copy( |
| 342 | h_door.switches().begin(), h_door.switches().end(), | 364 | h_door.senders().begin(), h_door.senders().end(), |
| 343 | google::protobuf::RepeatedFieldBackInserter(door.mutable_switches())); | 365 | google::protobuf::RepeatedFieldBackInserter(door.mutable_senders())); |
| 344 | 366 | ||
| 345 | for (const PaintingIdentifier& pi : h_door.move_paintings()) { | 367 | for (const PaintingIdentifier& pi : h_door.move_paintings()) { |
| 346 | std::optional<std::string> map_name = | 368 | std::optional<std::string> map_name = |
| @@ -388,9 +410,9 @@ class DataPacker { | |||
| 388 | door.add_doors( | 410 | door.add_doors( |
| 389 | container_.FindOrAddDoor(map_name, di.name(), current_map_name)); | 411 | container_.FindOrAddDoor(map_name, di.name(), current_map_name)); |
| 390 | } | 412 | } |
| 391 | 413 | ||
| 392 | for (const std::string& ending_name : h_door.endings()) { | 414 | if (h_door.has_white_ending()) { |
| 393 | door.add_endings(container_.FindOrAddEnding(ending_name)); | 415 | door.set_white_ending(h_door.white_ending()); |
| 394 | } | 416 | } |
| 395 | 417 | ||
| 396 | if (h_door.has_control_center_color()) { | 418 | if (h_door.has_control_center_color()) { |
| @@ -406,6 +428,18 @@ class DataPacker { | |||
| 406 | if (h_door.has_location_name()) { | 428 | if (h_door.has_location_name()) { |
| 407 | door.set_location_name(h_door.location_name()); | 429 | door.set_location_name(h_door.location_name()); |
| 408 | } | 430 | } |
| 431 | |||
| 432 | if (h_door.has_double_letters()) { | ||
| 433 | door.set_double_letters(h_door.double_letters()); | ||
| 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 | } | ||
| 409 | } | 443 | } |
| 410 | 444 | ||
| 411 | void ProcessConnectionsFile(std::filesystem::path path, | 445 | void ProcessConnectionsFile(std::filesystem::path path, |
| @@ -457,6 +491,26 @@ class DataPacker { | |||
| 457 | r_connection.set_required_door(door_id); | 491 | r_connection.set_required_door(door_id); |
| 458 | } | 492 | } |
| 459 | 493 | ||
| 494 | if (human_connection.has_roof_access()) { | ||
| 495 | f_connection.set_roof_access(human_connection.roof_access()); | ||
| 496 | r_connection.set_roof_access(human_connection.roof_access()); | ||
| 497 | } | ||
| 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 | |||
| 460 | container_.AddConnection(f_connection); | 514 | container_.AddConnection(f_connection); |
| 461 | if (!human_connection.oneway()) { | 515 | if (!human_connection.oneway()) { |
| 462 | container_.AddConnection(r_connection); | 516 | container_.AddConnection(r_connection); |
| @@ -540,6 +594,63 @@ class DataPacker { | |||
| 540 | } | 594 | } |
| 541 | } | 595 | } |
| 542 | 596 | ||
| 597 | void ProcessProgressivesFile(std::filesystem::path path) { | ||
| 598 | if (!std::filesystem::exists(path)) { | ||
| 599 | return; | ||
| 600 | } | ||
| 601 | |||
| 602 | auto h_progs = ReadMessageFromFile<HumanProgressives>(path.string()); | ||
| 603 | |||
| 604 | for (const HumanProgressive& h_prog : h_progs.progressives()) { | ||
| 605 | ProcessProgressive(h_prog); | ||
| 606 | } | ||
| 607 | } | ||
| 608 | |||
| 609 | void ProcessProgressive(const HumanProgressive& h_prog) { | ||
| 610 | uint64_t prog_id = container_.FindOrAddProgressive(h_prog.name()); | ||
| 611 | Progressive& prog = *container_.all_objects().mutable_progressives(prog_id); | ||
| 612 | |||
| 613 | for (const DoorIdentifier& di : h_prog.doors()) { | ||
| 614 | uint64_t door_id = | ||
| 615 | container_.FindOrAddDoor(di.map(), di.name(), std::nullopt); | ||
| 616 | prog.add_doors(door_id); | ||
| 617 | } | ||
| 618 | } | ||
| 619 | |||
| 620 | void ProcessDoorGroupsFile(std::filesystem::path path) { | ||
| 621 | if (!std::filesystem::exists(path)) { | ||
| 622 | return; | ||
| 623 | } | ||
| 624 | |||
| 625 | auto h_groups = ReadMessageFromFile<HumanDoorGroups>(path.string()); | ||
| 626 | |||
| 627 | for (const HumanDoorGroup& h_group : h_groups.door_groups()) { | ||
| 628 | ProcessDoorGroup(h_group); | ||
| 629 | } | ||
| 630 | } | ||
| 631 | |||
| 632 | void ProcessDoorGroup(const HumanDoorGroup& h_group) { | ||
| 633 | uint64_t group_id = container_.FindOrAddDoorGroup(h_group.name()); | ||
| 634 | DoorGroup& group = *container_.all_objects().mutable_door_groups(group_id); | ||
| 635 | |||
| 636 | group.set_type(h_group.type()); | ||
| 637 | |||
| 638 | for (const DoorIdentifier& di : h_group.doors()) { | ||
| 639 | uint64_t door_id = | ||
| 640 | container_.FindOrAddDoor(di.map(), di.name(), std::nullopt); | ||
| 641 | group.add_doors(door_id); | ||
| 642 | } | ||
| 643 | } | ||
| 644 | |||
| 645 | void ProcessGlobalMetadataFile(std::filesystem::path path) { | ||
| 646 | if (!std::filesystem::exists(path)) { | ||
| 647 | return; | ||
| 648 | } | ||
| 649 | |||
| 650 | auto h_metadata = ReadMessageFromFile<HumanGlobalMetadata>(path.string()); | ||
| 651 | *container_.all_objects().mutable_version() = h_metadata.version(); | ||
| 652 | } | ||
| 653 | |||
| 543 | void ProcessIdsFile(std::filesystem::path path) { | 654 | void ProcessIdsFile(std::filesystem::path path) { |
| 544 | auto ids = ReadIdsFromYaml(path.string()); | 655 | auto ids = ReadIdsFromYaml(path.string()); |
| 545 | 656 | ||
| @@ -564,6 +675,20 @@ class DataPacker { | |||
| 564 | .mutable_masteries(mastery_id) | 675 | .mutable_masteries(mastery_id) |
| 565 | ->set_ap_id(ap_id); | 676 | ->set_ap_id(ap_id); |
| 566 | } | 677 | } |
| 678 | |||
| 679 | for (const auto& [keyholder_name, ap_id] : room.keyholders()) { | ||
| 680 | uint64_t keyholder_id = container_.FindOrAddKeyholder( | ||
| 681 | map_name, room_name, keyholder_name, std::nullopt, std::nullopt); | ||
| 682 | container_.all_objects() | ||
| 683 | .mutable_keyholders(keyholder_id) | ||
| 684 | ->set_ap_id(ap_id); | ||
| 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 | } | ||
| 567 | } | 692 | } |
| 568 | } | 693 | } |
| 569 | 694 | ||
| @@ -581,6 +706,16 @@ class DataPacker { | |||
| 581 | uint64_t ending_id = container_.FindOrAddEnding(ending_name); | 706 | uint64_t ending_id = container_.FindOrAddEnding(ending_name); |
| 582 | container_.all_objects().mutable_endings(ending_id)->set_ap_id(ap_id); | 707 | container_.all_objects().mutable_endings(ending_id)->set_ap_id(ap_id); |
| 583 | } | 708 | } |
| 709 | |||
| 710 | for (const auto& [prog_name, ap_id] : ids.progressives()) { | ||
| 711 | uint64_t prog_id = container_.FindOrAddProgressive(prog_name); | ||
| 712 | container_.all_objects().mutable_progressives(prog_id)->set_ap_id(ap_id); | ||
| 713 | } | ||
| 714 | |||
| 715 | for (const auto& [group_name, ap_id] : ids.door_groups()) { | ||
| 716 | uint64_t group_id = container_.FindOrAddDoorGroup(group_name); | ||
| 717 | container_.all_objects().mutable_door_groups(group_id)->set_ap_id(ap_id); | ||
| 718 | } | ||
| 584 | } | 719 | } |
| 585 | 720 | ||
| 586 | std::string mapdir_; | 721 | 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..5b9113b 100644 --- a/tools/util/ids_yaml_format.cpp +++ b/tools/util/ids_yaml_format.cpp | |||
| @@ -56,6 +56,21 @@ 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 | } | ||
| 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 | } | ||
| 59 | } | 74 | } |
| 60 | } | 75 | } |
| 61 | 76 | ||
| @@ -89,6 +104,20 @@ IdMappings ReadIdsFromYaml(const std::string& filename) { | |||
| 89 | } | 104 | } |
| 90 | } | 105 | } |
| 91 | 106 | ||
| 107 | if (document["progressives"]) { | ||
| 108 | for (const auto& prog_it : document["progressives"]) { | ||
| 109 | (*result.mutable_progressives())[prog_it.first.as<std::string>()] = | ||
| 110 | prog_it.second.as<uint64_t>(); | ||
| 111 | } | ||
| 112 | } | ||
| 113 | |||
| 114 | if (document["door_groups"]) { | ||
| 115 | for (const auto& group_it : document["door_groups"]) { | ||
| 116 | (*result.mutable_door_groups())[group_it.first.as<std::string>()] = | ||
| 117 | group_it.second.as<uint64_t>(); | ||
| 118 | } | ||
| 119 | } | ||
| 120 | |||
| 92 | return result; | 121 | return result; |
| 93 | } | 122 | } |
| 94 | 123 | ||
| @@ -117,6 +146,19 @@ void WriteIdsAsYaml(const IdMappings& ids, const std::string& filename) { | |||
| 117 | mastery_id; | 146 | mastery_id; |
| 118 | }); | 147 | }); |
| 119 | 148 | ||
| 149 | OperateOnSortedMap(room_ids.keyholders(), | ||
| 150 | [&room_node](const std::string& keyholder_name, | ||
| 151 | uint64_t keyholder_id) { | ||
| 152 | room_node["keyholders"][keyholder_name] = | ||
| 153 | keyholder_id; | ||
| 154 | }); | ||
| 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 | |||
| 120 | map_node["rooms"][room_name] = std::move(room_node); | 162 | map_node["rooms"][room_name] = std::move(room_node); |
| 121 | }); | 163 | }); |
| 122 | 164 | ||
| @@ -144,6 +186,16 @@ void WriteIdsAsYaml(const IdMappings& ids, const std::string& filename) { | |||
| 144 | result["special"][special_name] = special_id; | 186 | result["special"][special_name] = special_id; |
| 145 | }); | 187 | }); |
| 146 | 188 | ||
| 189 | OperateOnSortedMap(ids.progressives(), | ||
| 190 | [&result](const std::string& prog_name, uint64_t prog_id) { | ||
| 191 | result["progressives"][prog_name] = prog_id; | ||
| 192 | }); | ||
| 193 | |||
| 194 | OperateOnSortedMap(ids.door_groups(), [&result](const std::string& group_name, | ||
| 195 | uint64_t group_id) { | ||
| 196 | result["door_groups"][group_name] = group_id; | ||
| 197 | }); | ||
| 198 | |||
| 147 | std::ofstream output_stream(filename); | 199 | std::ofstream output_stream(filename); |
| 148 | output_stream << result << std::endl; | 200 | output_stream << result << std::endl; |
| 149 | } | 201 | } |
| diff --git a/tools/validator/human_processor.cpp b/tools/validator/human_processor.cpp index 0f63936..ffa9765 100644 --- a/tools/validator/human_processor.cpp +++ b/tools/validator/human_processor.cpp | |||
| @@ -13,6 +13,7 @@ | |||
| 13 | #include <string> | 13 | #include <string> |
| 14 | 14 | ||
| 15 | #include "structs.h" | 15 | #include "structs.h" |
| 16 | #include "util/ids_yaml_format.h" | ||
| 16 | 17 | ||
| 17 | namespace com::fourisland::lingo2_archipelago { | 18 | namespace com::fourisland::lingo2_archipelago { |
| 18 | namespace { | 19 | namespace { |
| @@ -41,7 +42,9 @@ class HumanProcessor { | |||
| 41 | 42 | ||
| 42 | ProcessConnectionsFile(datadir_path / "connections.txtpb", std::nullopt); | 43 | ProcessConnectionsFile(datadir_path / "connections.txtpb", std::nullopt); |
| 43 | ProcessMaps(datadir_path); | 44 | ProcessMaps(datadir_path); |
| 44 | ProcessIdsFile(datadir_path / "ids.txtpb"); | 45 | ProcessProgressivesFile(datadir_path / "progressives.txtpb"); |
| 46 | ProcessDoorGroupsFile(datadir_path / "door_groups.txtpb"); | ||
| 47 | ProcessIdsFile(datadir_path / "ids.yaml"); | ||
| 45 | } | 48 | } |
| 46 | 49 | ||
| 47 | private: | 50 | private: |
| @@ -74,6 +77,21 @@ class HumanProcessor { | |||
| 74 | for (const std::string& path : metadata.excluded_nodes()) { | 77 | for (const std::string& path : metadata.excluded_nodes()) { |
| 75 | map_info.game_nodes[path].uses++; | 78 | map_info.game_nodes[path].uses++; |
| 76 | } | 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 | } | ||
| 77 | } | 95 | } |
| 78 | 96 | ||
| 79 | void ProcessRooms(std::filesystem::path path, | 97 | void ProcessRooms(std::filesystem::path path, |
| @@ -355,11 +373,6 @@ class HumanProcessor { | |||
| 355 | DoorInfo& other_door_info = info_.doors[complete_door_identifier]; | 373 | DoorInfo& other_door_info = info_.doors[complete_door_identifier]; |
| 356 | other_door_info.doors_referenced_by.push_back(door_identifier); | 374 | other_door_info.doors_referenced_by.push_back(door_identifier); |
| 357 | } | 375 | } |
| 358 | |||
| 359 | for (const std::string& ei : h_door.endings()) { | ||
| 360 | EndingInfo& ending_info = info_.endings[ei]; | ||
| 361 | ending_info.doors_referenced_by.push_back(door_identifier); | ||
| 362 | } | ||
| 363 | } | 376 | } |
| 364 | 377 | ||
| 365 | void ProcessConnectionsFile(std::filesystem::path path, | 378 | void ProcessConnectionsFile(std::filesystem::path path, |
| @@ -391,7 +404,9 @@ class HumanProcessor { | |||
| 391 | } | 404 | } |
| 392 | } else if (human_connection.has_from()) { | 405 | } else if (human_connection.has_from()) { |
| 393 | ProcessSingleConnection(human_connection, human_connection.from(), | 406 | ProcessSingleConnection(human_connection, human_connection.from(), |
| 394 | current_map_name); | 407 | current_map_name, |
| 408 | /*is_target=*/!human_connection.oneway() && | ||
| 409 | !human_connection.bypass_target_door()); | ||
| 395 | } | 410 | } |
| 396 | 411 | ||
| 397 | if (human_connection.has_to_room()) { | 412 | if (human_connection.has_to_room()) { |
| @@ -407,8 +422,9 @@ class HumanProcessor { | |||
| 407 | std::cout << "A global connection used to_room." << std::endl; | 422 | std::cout << "A global connection used to_room." << std::endl; |
| 408 | } | 423 | } |
| 409 | } else if (human_connection.has_to()) { | 424 | } else if (human_connection.has_to()) { |
| 410 | ProcessSingleConnection(human_connection, human_connection.to(), | 425 | ProcessSingleConnection( |
| 411 | current_map_name); | 426 | human_connection, human_connection.to(), current_map_name, |
| 427 | /*is_target=*/!human_connection.bypass_target_door()); | ||
| 412 | } | 428 | } |
| 413 | 429 | ||
| 414 | if (human_connection.has_door()) { | 430 | if (human_connection.has_door()) { |
| @@ -429,7 +445,7 @@ class HumanProcessor { | |||
| 429 | void ProcessSingleConnection( | 445 | void ProcessSingleConnection( |
| 430 | const HumanConnection& human_connection, | 446 | const HumanConnection& human_connection, |
| 431 | const HumanConnection::Endpoint& endpoint, | 447 | const HumanConnection::Endpoint& endpoint, |
| 432 | const std::optional<std::string>& current_map_name) { | 448 | const std::optional<std::string>& current_map_name, bool is_target) { |
| 433 | if (endpoint.has_room()) { | 449 | if (endpoint.has_room()) { |
| 434 | auto room_identifier = | 450 | auto room_identifier = |
| 435 | GetCompleteRoomIdentifier(endpoint.room(), current_map_name); | 451 | GetCompleteRoomIdentifier(endpoint.room(), current_map_name); |
| @@ -448,6 +464,11 @@ class HumanProcessor { | |||
| 448 | if (painting_identifier) { | 464 | if (painting_identifier) { |
| 449 | PaintingInfo& painting_info = info_.paintings[*painting_identifier]; | 465 | PaintingInfo& painting_info = info_.paintings[*painting_identifier]; |
| 450 | painting_info.connections_referenced_by.push_back(human_connection); | 466 | painting_info.connections_referenced_by.push_back(human_connection); |
| 467 | |||
| 468 | if (is_target) { | ||
| 469 | painting_info.target_connections_referenced_by.push_back( | ||
| 470 | human_connection); | ||
| 471 | } | ||
| 451 | } else { | 472 | } else { |
| 452 | // Not sure where else to store this right now. | 473 | // Not sure where else to store this right now. |
| 453 | std::cout | 474 | std::cout |
| @@ -460,6 +481,11 @@ class HumanProcessor { | |||
| 460 | if (port_identifier) { | 481 | if (port_identifier) { |
| 461 | PortInfo& port_info = info_.ports[*port_identifier]; | 482 | PortInfo& port_info = info_.ports[*port_identifier]; |
| 462 | port_info.connections_referenced_by.push_back(human_connection); | 483 | port_info.connections_referenced_by.push_back(human_connection); |
| 484 | |||
| 485 | if (is_target) { | ||
| 486 | port_info.target_connections_referenced_by.push_back( | ||
| 487 | human_connection); | ||
| 488 | } | ||
| 463 | } else { | 489 | } else { |
| 464 | // Not sure where else to store this right now. | 490 | // Not sure where else to store this right now. |
| 465 | std::cout | 491 | std::cout |
| @@ -477,12 +503,147 @@ class HumanProcessor { | |||
| 477 | panel_info.proxies[endpoint.panel().answer()] | 503 | panel_info.proxies[endpoint.panel().answer()] |
| 478 | .connections_referenced_by.push_back(human_connection); | 504 | .connections_referenced_by.push_back(human_connection); |
| 479 | } | 505 | } |
| 506 | |||
| 507 | if (is_target) { | ||
| 508 | panel_info.target_connections_referenced_by.push_back( | ||
| 509 | human_connection); | ||
| 510 | } | ||
| 511 | } | ||
| 512 | } | ||
| 513 | } | ||
| 514 | |||
| 515 | void ProcessProgressivesFile(std::filesystem::path path) { | ||
| 516 | if (!std::filesystem::exists(path)) { | ||
| 517 | return; | ||
| 518 | } | ||
| 519 | |||
| 520 | auto h_progs = ReadMessageFromFile<HumanProgressives>(path.string()); | ||
| 521 | |||
| 522 | for (const HumanProgressive& h_prog : h_progs.progressives()) { | ||
| 523 | ProcessProgressive(h_prog); | ||
| 524 | } | ||
| 525 | } | ||
| 526 | |||
| 527 | void ProcessProgressive(const HumanProgressive& h_prog) { | ||
| 528 | ProgressiveInfo& prog_info = info_.progressives[h_prog.name()]; | ||
| 529 | prog_info.definitions.push_back(h_prog); | ||
| 530 | |||
| 531 | for (const DoorIdentifier& di : h_prog.doors()) { | ||
| 532 | if (!di.has_map()) { | ||
| 533 | prog_info.malformed_doors.push_back(di); | ||
| 534 | continue; | ||
| 535 | } | ||
| 536 | |||
| 537 | DoorInfo& door_info = info_.doors[di]; | ||
| 538 | door_info.progressives_referenced_by.push_back(h_prog.name()); | ||
| 539 | } | ||
| 540 | } | ||
| 541 | |||
| 542 | void ProcessDoorGroupsFile(std::filesystem::path path) { | ||
| 543 | if (!std::filesystem::exists(path)) { | ||
| 544 | return; | ||
| 545 | } | ||
| 546 | |||
| 547 | auto h_groups = ReadMessageFromFile<HumanDoorGroups>(path.string()); | ||
| 548 | |||
| 549 | for (const HumanDoorGroup& h_group : h_groups.door_groups()) { | ||
| 550 | ProcessDoorGroup(h_group); | ||
| 551 | } | ||
| 552 | } | ||
| 553 | |||
| 554 | void ProcessDoorGroup(const HumanDoorGroup& h_group) { | ||
| 555 | DoorGroupInfo& group_info = info_.door_groups[h_group.name()]; | ||
| 556 | group_info.definitions.push_back(h_group); | ||
| 557 | |||
| 558 | for (const DoorIdentifier& di : h_group.doors()) { | ||
| 559 | if (!di.has_map()) { | ||
| 560 | group_info.malformed_doors.push_back(di); | ||
| 561 | continue; | ||
| 480 | } | 562 | } |
| 563 | |||
| 564 | DoorInfo& door_info = info_.doors[di]; | ||
| 565 | door_info.door_groups_referenced_by.push_back(h_group.name()); | ||
| 481 | } | 566 | } |
| 482 | } | 567 | } |
| 483 | 568 | ||
| 484 | void ProcessIdsFile(std::filesystem::path path) { | 569 | void ProcessIdsFile(std::filesystem::path path) { |
| 485 | // Ignore this for now. | 570 | auto ids = ReadIdsFromYaml(path.string()); |
| 571 | |||
| 572 | DoorIdentifier di; | ||
| 573 | PanelIdentifier pai; | ||
| 574 | PortIdentifier poi; | ||
| 575 | KeyholderIdentifier ki; | ||
| 576 | |||
| 577 | for (const auto& [map_name, map] : ids.maps()) { | ||
| 578 | di.set_map(map_name); | ||
| 579 | pai.set_map(map_name); | ||
| 580 | poi.set_map(map_name); | ||
| 581 | ki.set_map(map_name); | ||
| 582 | |||
| 583 | for (const auto& [door_name, ap_id] : map.doors()) { | ||
| 584 | di.set_name(door_name); | ||
| 585 | |||
| 586 | DoorInfo& door_info = info_.doors[di]; | ||
| 587 | door_info.has_id = true; | ||
| 588 | } | ||
| 589 | |||
| 590 | for (const auto& [room_name, room] : map.rooms()) { | ||
| 591 | pai.set_room(room_name); | ||
| 592 | poi.set_room(room_name); | ||
| 593 | ki.set_room(room_name); | ||
| 594 | |||
| 595 | for (const auto& [panel_name, ap_id] : room.panels()) { | ||
| 596 | pai.set_name(panel_name); | ||
| 597 | |||
| 598 | PanelInfo& panel_info = info_.panels[pai]; | ||
| 599 | panel_info.has_id = true; | ||
| 600 | } | ||
| 601 | |||
| 602 | for (const auto& [mastery_name, ap_id] : room.masteries()) { | ||
| 603 | // TODO: Mastery | ||
| 604 | } | ||
| 605 | |||
| 606 | for (const auto& [keyholder_name, ap_id] : room.keyholders()) { | ||
| 607 | ki.set_name(keyholder_name); | ||
| 608 | |||
| 609 | KeyholderInfo& keyholder_info = info_.keyholders[ki]; | ||
| 610 | keyholder_info.has_id = true; | ||
| 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 | } | ||
| 619 | } | ||
| 620 | } | ||
| 621 | |||
| 622 | for (const auto& [tag, id] : ids.special()) { | ||
| 623 | // TODO: Specials | ||
| 624 | } | ||
| 625 | |||
| 626 | for (const auto& [letter_name, ap_id] : ids.letters()) { | ||
| 627 | LetterIdentifier li = | ||
| 628 | std::make_tuple(letter_name[0], letter_name[1] == '2'); | ||
| 629 | LetterInfo& letter_info = info_.letters[li]; | ||
| 630 | letter_info.has_id = true; | ||
| 631 | } | ||
| 632 | |||
| 633 | for (const auto& [ending_name, ap_id] : ids.endings()) { | ||
| 634 | EndingInfo& ending_info = info_.endings[ending_name]; | ||
| 635 | ending_info.has_id = true; | ||
| 636 | } | ||
| 637 | |||
| 638 | for (const auto& [prog_name, ap_id] : ids.progressives()) { | ||
| 639 | ProgressiveInfo& prog_info = info_.progressives[prog_name]; | ||
| 640 | prog_info.has_id = true; | ||
| 641 | } | ||
| 642 | |||
| 643 | for (const auto& [group_name, ap_id] : ids.door_groups()) { | ||
| 644 | DoorGroupInfo& group_info = info_.door_groups[group_name]; | ||
| 645 | group_info.has_id = true; | ||
| 646 | } | ||
| 486 | } | 647 | } |
| 487 | 648 | ||
| 488 | std::string mapdir_; | 649 | std::string mapdir_; |
| diff --git a/tools/validator/structs.h b/tools/validator/structs.h index 0ca96fe..62974a8 100644 --- a/tools/validator/structs.h +++ b/tools/validator/structs.h | |||
| @@ -27,6 +27,8 @@ struct GameNodeInfo { | |||
| 27 | 27 | ||
| 28 | struct MapInfo { | 28 | struct 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 | ||
| 32 | struct RoomInfo { | 34 | struct RoomInfo { |
| @@ -39,26 +41,33 @@ struct RoomInfo { | |||
| 39 | 41 | ||
| 40 | struct DoorInfo { | 42 | struct DoorInfo { |
| 41 | std::vector<HumanDoor> definitions; | 43 | std::vector<HumanDoor> definitions; |
| 44 | bool has_id = false; | ||
| 42 | 45 | ||
| 43 | std::vector<HumanConnection> connections_referenced_by; | 46 | std::vector<HumanConnection> connections_referenced_by; |
| 44 | std::vector<DoorIdentifier> doors_referenced_by; | 47 | std::vector<DoorIdentifier> doors_referenced_by; |
| 45 | std::vector<PanelIdentifier> panels_referenced_by; | 48 | std::vector<PanelIdentifier> panels_referenced_by; |
| 46 | std::vector<PaintingIdentifier> paintings_referenced_by; | 49 | std::vector<PaintingIdentifier> paintings_referenced_by; |
| 47 | std::vector<PortIdentifier> ports_referenced_by; | 50 | std::vector<PortIdentifier> ports_referenced_by; |
| 51 | std::vector<std::string> progressives_referenced_by; | ||
| 52 | std::vector<std::string> door_groups_referenced_by; | ||
| 48 | 53 | ||
| 49 | MalformedIdentifiers malformed_identifiers; | 54 | MalformedIdentifiers malformed_identifiers; |
| 50 | }; | 55 | }; |
| 51 | 56 | ||
| 52 | struct PortInfo { | 57 | struct PortInfo { |
| 53 | std::vector<HumanPort> definitions; | 58 | std::vector<HumanPort> definitions; |
| 59 | bool has_id = false; | ||
| 54 | 60 | ||
| 55 | std::vector<HumanConnection> connections_referenced_by; | 61 | std::vector<HumanConnection> connections_referenced_by; |
| 62 | std::vector<HumanConnection> target_connections_referenced_by; | ||
| 63 | std::vector<std::string> map_worldport_entrances; | ||
| 56 | }; | 64 | }; |
| 57 | 65 | ||
| 58 | struct PaintingInfo { | 66 | struct PaintingInfo { |
| 59 | std::vector<HumanPainting> definitions; | 67 | std::vector<HumanPainting> definitions; |
| 60 | 68 | ||
| 61 | std::vector<HumanConnection> connections_referenced_by; | 69 | std::vector<HumanConnection> connections_referenced_by; |
| 70 | std::vector<HumanConnection> target_connections_referenced_by; | ||
| 62 | std::vector<DoorIdentifier> doors_referenced_by; | 71 | std::vector<DoorIdentifier> doors_referenced_by; |
| 63 | }; | 72 | }; |
| 64 | 73 | ||
| @@ -71,10 +80,12 @@ struct ProxyInfo { | |||
| 71 | 80 | ||
| 72 | struct PanelInfo { | 81 | struct PanelInfo { |
| 73 | std::vector<HumanPanel> definitions; | 82 | std::vector<HumanPanel> definitions; |
| 83 | bool has_id = false; | ||
| 74 | 84 | ||
| 75 | std::string map_area_name; | 85 | std::string map_area_name; |
| 76 | 86 | ||
| 77 | std::vector<HumanConnection> connections_referenced_by; | 87 | std::vector<HumanConnection> connections_referenced_by; |
| 88 | std::vector<HumanConnection> target_connections_referenced_by; | ||
| 78 | std::vector<DoorIdentifier> doors_referenced_by; | 89 | std::vector<DoorIdentifier> doors_referenced_by; |
| 79 | 90 | ||
| 80 | std::map<std::string, ProxyInfo> proxies; | 91 | std::map<std::string, ProxyInfo> proxies; |
| @@ -82,6 +93,7 @@ struct PanelInfo { | |||
| 82 | 93 | ||
| 83 | struct KeyholderInfo { | 94 | struct KeyholderInfo { |
| 84 | std::vector<HumanKeyholder> definitions; | 95 | std::vector<HumanKeyholder> definitions; |
| 96 | bool has_id = false; | ||
| 85 | 97 | ||
| 86 | std::vector<DoorIdentifier> doors_referenced_by; | 98 | std::vector<DoorIdentifier> doors_referenced_by; |
| 87 | }; | 99 | }; |
| @@ -90,18 +102,32 @@ using LetterIdentifier = std::tuple<char, bool>; | |||
| 90 | 102 | ||
| 91 | struct LetterInfo { | 103 | struct LetterInfo { |
| 92 | std::vector<RoomIdentifier> defined_in; | 104 | std::vector<RoomIdentifier> defined_in; |
| 105 | bool has_id = false; | ||
| 93 | }; | 106 | }; |
| 94 | 107 | ||
| 95 | struct EndingInfo { | 108 | struct EndingInfo { |
| 96 | std::vector<RoomIdentifier> defined_in; | 109 | std::vector<RoomIdentifier> defined_in; |
| 97 | 110 | bool has_id = false; | |
| 98 | std::vector<DoorIdentifier> doors_referenced_by; | ||
| 99 | }; | 111 | }; |
| 100 | 112 | ||
| 101 | struct PanelNameInfo { | 113 | struct PanelNameInfo { |
| 102 | std::vector<PanelIdentifier> panels_used_by; | 114 | std::vector<PanelIdentifier> panels_used_by; |
| 103 | }; | 115 | }; |
| 104 | 116 | ||
| 117 | struct ProgressiveInfo { | ||
| 118 | std::vector<HumanProgressive> definitions; | ||
| 119 | bool has_id = false; | ||
| 120 | |||
| 121 | std::vector<DoorIdentifier> malformed_doors; | ||
| 122 | }; | ||
| 123 | |||
| 124 | struct DoorGroupInfo { | ||
| 125 | std::vector<HumanDoorGroup> definitions; | ||
| 126 | bool has_id = false; | ||
| 127 | |||
| 128 | std::vector<DoorIdentifier> malformed_doors; | ||
| 129 | }; | ||
| 130 | |||
| 105 | struct CollectedInfo { | 131 | struct CollectedInfo { |
| 106 | std::map<std::string, MapInfo> maps; | 132 | std::map<std::string, MapInfo> maps; |
| 107 | std::map<RoomIdentifier, RoomInfo, RoomIdentifierLess> rooms; | 133 | std::map<RoomIdentifier, RoomInfo, RoomIdentifierLess> rooms; |
| @@ -114,6 +140,8 @@ struct CollectedInfo { | |||
| 114 | std::map<LetterIdentifier, LetterInfo> letters; | 140 | std::map<LetterIdentifier, LetterInfo> letters; |
| 115 | std::map<std::string, EndingInfo> endings; | 141 | std::map<std::string, EndingInfo> endings; |
| 116 | std::map<std::string, PanelNameInfo> panel_names; | 142 | std::map<std::string, PanelNameInfo> panel_names; |
| 143 | std::map<std::string, ProgressiveInfo> progressives; | ||
| 144 | std::map<std::string, DoorGroupInfo> door_groups; | ||
| 117 | }; | 145 | }; |
| 118 | 146 | ||
| 119 | } // namespace com::fourisland::lingo2_archipelago | 147 | } // namespace com::fourisland::lingo2_archipelago |
| diff --git a/tools/validator/validator.cpp b/tools/validator/validator.cpp index f5524c3..fe36be7 100644 --- a/tools/validator/validator.cpp +++ b/tools/validator/validator.cpp | |||
| @@ -45,6 +45,12 @@ class Validator { | |||
| 45 | for (const auto& [panel_name, panel_info] : info_.panel_names) { | 45 | for (const auto& [panel_name, panel_info] : info_.panel_names) { |
| 46 | ValidatePanelName(panel_name, panel_info); | 46 | ValidatePanelName(panel_name, panel_info); |
| 47 | } | 47 | } |
| 48 | for (const auto& [prog_name, prog_info] : info_.progressives) { | ||
| 49 | ValidateProgressive(prog_name, prog_info); | ||
| 50 | } | ||
| 51 | for (const auto& [group_name, group_info] : info_.door_groups) { | ||
| 52 | ValidateDoorGroup(group_name, group_info); | ||
| 53 | } | ||
| 48 | } | 54 | } |
| 49 | 55 | ||
| 50 | private: | 56 | private: |
| @@ -63,6 +69,11 @@ class Validator { | |||
| 63 | << " is not defined in the game file." << std::endl; | 69 | << " is not defined in the game file." << std::endl; |
| 64 | } | 70 | } |
| 65 | } | 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 | } | ||
| 66 | } | 77 | } |
| 67 | 78 | ||
| 68 | void ValidateRoom(const RoomIdentifier& room_identifier, | 79 | void ValidateRoom(const RoomIdentifier& room_identifier, |
| @@ -100,7 +111,8 @@ class Validator { | |||
| 100 | return false; | 111 | return false; |
| 101 | } | 112 | } |
| 102 | 113 | ||
| 103 | if (h_door.keyholders_size() > 0 || h_door.endings_size() > 0) { | 114 | if (h_door.keyholders_size() > 0 || h_door.white_ending() || |
| 115 | h_door.complete_at() > 0) { | ||
| 104 | return true; | 116 | return true; |
| 105 | } | 117 | } |
| 106 | 118 | ||
| @@ -164,6 +176,20 @@ class Validator { | |||
| 164 | std::cout << " CONNECTION " << connection.ShortDebugString() | 176 | std::cout << " CONNECTION " << connection.ShortDebugString() |
| 165 | << std::endl; | 177 | << std::endl; |
| 166 | } | 178 | } |
| 179 | |||
| 180 | for (const std::string& prog_name : | ||
| 181 | door_info.progressives_referenced_by) { | ||
| 182 | std::cout << " PROGRESSIVE " << prog_name << std::endl; | ||
| 183 | } | ||
| 184 | |||
| 185 | for (const std::string& group_name : | ||
| 186 | door_info.door_groups_referenced_by) { | ||
| 187 | std::cout << " DOOR GROUP " << group_name << std::endl; | ||
| 188 | } | ||
| 189 | |||
| 190 | if (door_info.has_id) { | ||
| 191 | std::cout << " An AP ID is present." << std::endl; | ||
| 192 | } | ||
| 167 | } else if (door_info.definitions.size() > 1) { | 193 | } else if (door_info.definitions.size() > 1) { |
| 168 | std::cout << "Door " << door_identifier.ShortDebugString() | 194 | std::cout << "Door " << door_identifier.ShortDebugString() |
| 169 | << " was defined multiple times." << std::endl; | 195 | << " was defined multiple times." << std::endl; |
| @@ -198,6 +224,33 @@ class Validator { | |||
| 198 | std::cout << "Door " << door_identifier.ShortDebugString() | 224 | std::cout << "Door " << door_identifier.ShortDebugString() |
| 199 | << " needs an explicit location name." << std::endl; | 225 | << " needs an explicit location name." << std::endl; |
| 200 | } | 226 | } |
| 227 | |||
| 228 | if (h_door.type() == DoorType::STANDARD || | ||
| 229 | h_door.type() == DoorType::LOCATION_ONLY || | ||
| 230 | h_door.type() == DoorType::GRAVESTONE || h_door.legacy_location()) { | ||
| 231 | if (h_door.double_letters()) { | ||
| 232 | std::cout << "Door " << door_identifier.ShortDebugString() | ||
| 233 | << " is a location that depends on double_letters." | ||
| 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 | } | ||
| 241 | } | ||
| 242 | |||
| 243 | bool needs_id = (h_door.type() != DoorType::EVENT || h_door.latch() || | ||
| 244 | h_door.legacy_location()); | ||
| 245 | if (door_info.has_id != needs_id) { | ||
| 246 | if (needs_id) { | ||
| 247 | std::cout << "Door " << door_identifier.ShortDebugString() | ||
| 248 | << " is missing an AP ID." << std::endl; | ||
| 249 | } else { | ||
| 250 | std::cout << "Door " << door_identifier.ShortDebugString() | ||
| 251 | << " should not have an AP ID." << std::endl; | ||
| 252 | } | ||
| 253 | } | ||
| 201 | } | 254 | } |
| 202 | } | 255 | } |
| 203 | 256 | ||
| @@ -212,10 +265,57 @@ class Validator { | |||
| 212 | std::cout << " CONNECTION " << connection.ShortDebugString() | 265 | std::cout << " CONNECTION " << connection.ShortDebugString() |
| 213 | << std::endl; | 266 | << std::endl; |
| 214 | } | 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 | } | ||
| 215 | } else if (port_info.definitions.size() > 1) { | 276 | } else if (port_info.definitions.size() > 1) { |
| 216 | std::cout << "Port " << port_identifier.ShortDebugString() | 277 | std::cout << "Port " << port_identifier.ShortDebugString() |
| 217 | << " was defined multiple times." << std::endl; | 278 | << " was defined multiple times." << std::endl; |
| 218 | } | 279 | } |
| 280 | |||
| 281 | if (!port_info.target_connections_referenced_by.empty()) { | ||
| 282 | for (const HumanPort& port : port_info.definitions) { | ||
| 283 | if (port.has_required_door()) { | ||
| 284 | std::cout << "Port " << port_identifier.ShortDebugString() | ||
| 285 | << " has a required door but is the target of a connection:" | ||
| 286 | << std::endl; | ||
| 287 | |||
| 288 | for (const HumanConnection& connection : | ||
| 289 | port_info.target_connections_referenced_by) { | ||
| 290 | std::cout << " CONNECTION " << connection.ShortDebugString() | ||
| 291 | << std::endl; | ||
| 292 | } | ||
| 293 | } | ||
| 294 | } | ||
| 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 | } | ||
| 219 | } | 319 | } |
| 220 | 320 | ||
| 221 | void ValidatePainting(const PaintingIdentifier& painting_identifier, | 321 | void ValidatePainting(const PaintingIdentifier& painting_identifier, |
| @@ -239,6 +339,22 @@ class Validator { | |||
| 239 | std::cout << "Painting " << painting_identifier.ShortDebugString() | 339 | std::cout << "Painting " << painting_identifier.ShortDebugString() |
| 240 | << " was defined multiple times." << std::endl; | 340 | << " was defined multiple times." << std::endl; |
| 241 | } | 341 | } |
| 342 | |||
| 343 | if (!painting_info.target_connections_referenced_by.empty()) { | ||
| 344 | for (const HumanPainting& painting : painting_info.definitions) { | ||
| 345 | if (painting.has_required_door()) { | ||
| 346 | std::cout << "Painting " << painting_identifier.ShortDebugString() | ||
| 347 | << " has a required door but is the target of a connection:" | ||
| 348 | << std::endl; | ||
| 349 | |||
| 350 | for (const HumanConnection& connection : | ||
| 351 | painting_info.target_connections_referenced_by) { | ||
| 352 | std::cout << " CONNECTION " << connection.ShortDebugString() | ||
| 353 | << std::endl; | ||
| 354 | } | ||
| 355 | } | ||
| 356 | } | ||
| 357 | } | ||
| 242 | } | 358 | } |
| 243 | 359 | ||
| 244 | void ValidatePanel(const PanelIdentifier& panel_identifier, | 360 | void ValidatePanel(const PanelIdentifier& panel_identifier, |
| @@ -263,6 +379,10 @@ class Validator { | |||
| 263 | std::cout << " CONNECTION " << connection.ShortDebugString() | 379 | std::cout << " CONNECTION " << connection.ShortDebugString() |
| 264 | << std::endl; | 380 | << std::endl; |
| 265 | } | 381 | } |
| 382 | |||
| 383 | if (panel_info.has_id) { | ||
| 384 | std::cout << " An AP ID is present." << std::endl; | ||
| 385 | } | ||
| 266 | } else if (panel_info.definitions.size() > 1) { | 386 | } else if (panel_info.definitions.size() > 1) { |
| 267 | std::cout << "Panel " << panel_identifier.ShortDebugString() | 387 | std::cout << "Panel " << panel_identifier.ShortDebugString() |
| 268 | << " was defined multiple times." << std::endl; | 388 | << " was defined multiple times." << std::endl; |
| @@ -291,6 +411,27 @@ class Validator { | |||
| 291 | << "\" was defined multiple times." << std::endl; | 411 | << "\" was defined multiple times." << std::endl; |
| 292 | } | 412 | } |
| 293 | } | 413 | } |
| 414 | |||
| 415 | if (!panel_info.has_id) { | ||
| 416 | std::cout << "Panel " << panel_identifier.ShortDebugString() | ||
| 417 | << " is missing an AP ID." << std::endl; | ||
| 418 | } | ||
| 419 | |||
| 420 | if (!panel_info.target_connections_referenced_by.empty()) { | ||
| 421 | for (const HumanPanel& panel : panel_info.definitions) { | ||
| 422 | if (panel.has_required_door()) { | ||
| 423 | std::cout << "Panel " << panel_identifier.ShortDebugString() | ||
| 424 | << " has a required door but is the target of a connection:" | ||
| 425 | << std::endl; | ||
| 426 | |||
| 427 | for (const HumanConnection& connection : | ||
| 428 | panel_info.target_connections_referenced_by) { | ||
| 429 | std::cout << " CONNECTION " << connection.ShortDebugString() | ||
| 430 | << std::endl; | ||
| 431 | } | ||
| 432 | } | ||
| 433 | } | ||
| 434 | } | ||
| 294 | } | 435 | } |
| 295 | 436 | ||
| 296 | void ValidateKeyholder(const KeyholderIdentifier& keyholder_identifier, | 437 | void ValidateKeyholder(const KeyholderIdentifier& keyholder_identifier, |
| @@ -304,10 +445,28 @@ class Validator { | |||
| 304 | std::cout << " DOOR " << door_identifier.ShortDebugString() | 445 | std::cout << " DOOR " << door_identifier.ShortDebugString() |
| 305 | << std::endl; | 446 | << std::endl; |
| 306 | } | 447 | } |
| 448 | |||
| 449 | if (keyholder_info.has_id) { | ||
| 450 | std::cout << " An AP ID is present." << std::endl; | ||
| 451 | } | ||
| 307 | } else if (keyholder_info.definitions.size() > 1) { | 452 | } else if (keyholder_info.definitions.size() > 1) { |
| 308 | std::cout << "Keyholder " << keyholder_identifier.ShortDebugString() | 453 | std::cout << "Keyholder " << keyholder_identifier.ShortDebugString() |
| 309 | << " was defined multiple times." << std::endl; | 454 | << " was defined multiple times." << std::endl; |
| 310 | } | 455 | } |
| 456 | |||
| 457 | for (const HumanKeyholder& h_keyholder : keyholder_info.definitions) { | ||
| 458 | bool needs_id = (h_keyholder.has_key()); | ||
| 459 | |||
| 460 | if (needs_id != keyholder_info.has_id) { | ||
| 461 | if (needs_id) { | ||
| 462 | std::cout << "Keyholder " << keyholder_identifier.ShortDebugString() | ||
| 463 | << " is missing an AP ID." << std::endl; | ||
| 464 | } else { | ||
| 465 | std::cout << "Keyholder " << keyholder_identifier.ShortDebugString() | ||
| 466 | << " should not have an AP ID." << std::endl; | ||
| 467 | } | ||
| 468 | } | ||
| 469 | } | ||
| 311 | } | 470 | } |
| 312 | 471 | ||
| 313 | void ValidateLetter(const LetterIdentifier& letter_identifier, | 472 | void ValidateLetter(const LetterIdentifier& letter_identifier, |
| @@ -315,7 +474,14 @@ class Validator { | |||
| 315 | std::string letter_name = std::string(1, std::get<0>(letter_identifier)) + | 474 | std::string letter_name = std::string(1, std::get<0>(letter_identifier)) + |
| 316 | (std::get<1>(letter_identifier) ? "2" : "1"); | 475 | (std::get<1>(letter_identifier) ? "2" : "1"); |
| 317 | 476 | ||
| 318 | if (letter_info.defined_in.size() > 1) { | 477 | if (letter_info.defined_in.empty()) { |
| 478 | std::cout << "Letter " << letter_name | ||
| 479 | << " has no definition, but was referenced:" << std::endl; | ||
| 480 | |||
| 481 | if (letter_info.has_id) { | ||
| 482 | std::cout << " An AP ID is present." << std::endl; | ||
| 483 | } | ||
| 484 | } else if (letter_info.defined_in.size() > 1) { | ||
| 319 | std::cout << "Letter " << letter_name | 485 | std::cout << "Letter " << letter_name |
| 320 | << " was defined in multiple places:" << std::endl; | 486 | << " was defined in multiple places:" << std::endl; |
| 321 | 487 | ||
| @@ -323,6 +489,11 @@ class Validator { | |||
| 323 | std::cout << " " << room_identifier.ShortDebugString() << std::endl; | 489 | std::cout << " " << room_identifier.ShortDebugString() << std::endl; |
| 324 | } | 490 | } |
| 325 | } | 491 | } |
| 492 | |||
| 493 | if (!letter_info.has_id) { | ||
| 494 | std::cout << "Letter " << letter_name << " is missing an AP ID." | ||
| 495 | << std::endl; | ||
| 496 | } | ||
| 326 | } | 497 | } |
| 327 | 498 | ||
| 328 | void ValidateEnding(const std::string& ending_name, | 499 | void ValidateEnding(const std::string& ending_name, |
| @@ -331,10 +502,8 @@ class Validator { | |||
| 331 | std::cout << "Ending " << ending_name | 502 | std::cout << "Ending " << ending_name |
| 332 | << " has no definition, but was referenced:" << std::endl; | 503 | << " has no definition, but was referenced:" << std::endl; |
| 333 | 504 | ||
| 334 | for (const DoorIdentifier& door_identifier : | 505 | if (ending_info.has_id) { |
| 335 | ending_info.doors_referenced_by) { | 506 | std::cout << " An AP ID is present." << std::endl; |
| 336 | std::cout << " DOOR " << door_identifier.ShortDebugString() | ||
| 337 | << std::endl; | ||
| 338 | } | 507 | } |
| 339 | } else if (ending_info.defined_in.size() > 1) { | 508 | } else if (ending_info.defined_in.size() > 1) { |
| 340 | std::cout << "Ending " << ending_name | 509 | std::cout << "Ending " << ending_name |
| @@ -344,6 +513,11 @@ class Validator { | |||
| 344 | std::cout << " " << room_identifier.ShortDebugString() << std::endl; | 513 | std::cout << " " << room_identifier.ShortDebugString() << std::endl; |
| 345 | } | 514 | } |
| 346 | } | 515 | } |
| 516 | |||
| 517 | if (!ending_info.has_id) { | ||
| 518 | std::cout << "Ending " << ending_name << " is missing an AP ID." | ||
| 519 | << std::endl; | ||
| 520 | } | ||
| 347 | } | 521 | } |
| 348 | 522 | ||
| 349 | void ValidatePanelName(const std::string& panel_name, | 523 | void ValidatePanelName(const std::string& panel_name, |
| @@ -360,6 +534,46 @@ class Validator { | |||
| 360 | } | 534 | } |
| 361 | } | 535 | } |
| 362 | 536 | ||
| 537 | void ValidateProgressive(const std::string& prog_name, | ||
| 538 | const ProgressiveInfo& prog_info) const { | ||
| 539 | if (prog_info.definitions.empty()) { | ||
| 540 | std::cout << "Progressive \"" << prog_name | ||
| 541 | << "\" has no definition, but was referenced:" << std::endl; | ||
| 542 | |||
| 543 | if (prog_info.has_id) { | ||
| 544 | std::cout << " An AP ID is present." << std::endl; | ||
| 545 | } | ||
| 546 | } else if (prog_info.definitions.size() > 1) { | ||
| 547 | std::cout << "Progressive \"" << prog_name | ||
| 548 | << "\" has multiple definitions." << std::endl; | ||
| 549 | } | ||
| 550 | |||
| 551 | if (!prog_info.has_id) { | ||
| 552 | std::cout << "Progressive \"" << prog_name << "\" is missing an AP ID." | ||
| 553 | << std::endl; | ||
| 554 | } | ||
| 555 | } | ||
| 556 | |||
| 557 | void ValidateDoorGroup(const std::string& group_name, | ||
| 558 | const DoorGroupInfo& group_info) const { | ||
| 559 | if (group_info.definitions.empty()) { | ||
| 560 | std::cout << "Door group \"" << group_name | ||
| 561 | << "\" has no definition, but was referenced:" << std::endl; | ||
| 562 | |||
| 563 | if (group_info.has_id) { | ||
| 564 | std::cout << " An AP ID is present." << std::endl; | ||
| 565 | } | ||
| 566 | } else if (group_info.definitions.size() > 1) { | ||
| 567 | std::cout << "Door group \"" << group_name | ||
| 568 | << "\" has multiple definitions." << std::endl; | ||
| 569 | } | ||
| 570 | |||
| 571 | if (!group_info.has_id) { | ||
| 572 | std::cout << "Door group \"" << group_name << "\" is missing an AP ID." | ||
| 573 | << std::endl; | ||
| 574 | } | ||
| 575 | } | ||
| 576 | |||
| 363 | const CollectedInfo& info_; | 577 | const CollectedInfo& info_; |
| 364 | }; | 578 | }; |
| 365 | 579 | ||
| 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 | ||
| 4 | namespace com::fourisland::lingo2_archipelago { | 4 | namespace com::fourisland::lingo2_archipelago { |
