diff options
Diffstat (limited to 'tools')
| -rw-r--r-- | tools/assign_ids/main.cpp | 249 | ||||
| -rw-r--r-- | tools/datapacker/container.cpp | 64 | ||||
| -rw-r--r-- | tools/datapacker/container.h | 11 | ||||
| -rw-r--r-- | tools/datapacker/main.cpp | 230 | ||||
| -rw-r--r-- | tools/util/CMakeLists.txt | 8 | ||||
| -rw-r--r-- | tools/util/godot_scene.cpp | 207 | ||||
| -rw-r--r-- | tools/util/godot_scene.h | 57 | ||||
| -rw-r--r-- | tools/util/identifiers.cpp | 102 | ||||
| -rw-r--r-- | tools/util/identifiers.h | 85 | ||||
| -rw-r--r-- | tools/util/ids_yaml_format.cpp | 203 | ||||
| -rw-r--r-- | tools/util/ids_yaml_format.h | 16 | ||||
| -rw-r--r-- | tools/util/naming.cpp | 8 | ||||
| -rw-r--r-- | tools/util/naming.h | 6 | ||||
| -rw-r--r-- | tools/validator/CMakeLists.txt | 13 | ||||
| -rw-r--r-- | tools/validator/godot_processor.cpp | 72 | ||||
| -rw-r--r-- | tools/validator/godot_processor.h | 14 | ||||
| -rw-r--r-- | tools/validator/human_processor.cpp | 660 | ||||
| -rw-r--r-- | tools/validator/human_processor.h | 14 | ||||
| -rw-r--r-- | tools/validator/main.cpp | 34 | ||||
| -rw-r--r-- | tools/validator/structs.h | 149 | ||||
| -rw-r--r-- | tools/validator/validator.cpp | 587 | ||||
| -rw-r--r-- | tools/validator/validator.h | 12 |
22 files changed, 2724 insertions, 77 deletions
| diff --git a/tools/assign_ids/main.cpp b/tools/assign_ids/main.cpp index 349c258..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> |
| @@ -9,6 +10,7 @@ | |||
| 9 | #include <string> | 10 | #include <string> |
| 10 | 11 | ||
| 11 | #include "proto/human.pb.h" | 12 | #include "proto/human.pb.h" |
| 13 | #include "util/ids_yaml_format.h" | ||
| 12 | #include "util/naming.h" | 14 | #include "util/naming.h" |
| 13 | 15 | ||
| 14 | namespace com::fourisland::lingo2_archipelago { | 16 | namespace com::fourisland::lingo2_archipelago { |
| @@ -34,11 +36,15 @@ class AssignIds { | |||
| 34 | 36 | ||
| 35 | void Run() { | 37 | void Run() { |
| 36 | std::filesystem::path datadir_path = mapdir_; | 38 | std::filesystem::path datadir_path = mapdir_; |
| 37 | std::filesystem::path ids_path = datadir_path / "ids.txtpb"; | 39 | std::filesystem::path ids_path = datadir_path / "ids.yaml"; |
| 38 | 40 | ||
| 39 | ReadIds(ids_path); | 41 | ReadIds(ids_path); |
| 40 | 42 | ||
| 41 | 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"); | ||
| 42 | 48 | ||
| 43 | WriteIds(ids_path); | 49 | WriteIds(ids_path); |
| 44 | 50 | ||
| @@ -46,53 +52,34 @@ class AssignIds { | |||
| 46 | } | 52 | } |
| 47 | 53 | ||
| 48 | void ReadIds(std::filesystem::path path) { | 54 | void ReadIds(std::filesystem::path path) { |
| 49 | id_mappings_ = ReadMessageFromFile<IdMappings>(path.string()); | 55 | if (!std::filesystem::exists(path)) { |
| 56 | return; | ||
| 57 | } | ||
| 58 | |||
| 59 | id_mappings_ = ReadIdsFromYaml(path.string()); | ||
| 50 | 60 | ||
| 51 | for (const auto& [_, map] : id_mappings_.maps()) { | 61 | for (const auto& [_, map] : id_mappings_.maps()) { |
| 52 | for (const auto& [_, id] : map.doors()) { | 62 | UpdateNextId(map.doors()); |
| 53 | if (id > next_id_) { | ||
| 54 | next_id_ = id; | ||
| 55 | } | ||
| 56 | } | ||
| 57 | 63 | ||
| 58 | for (const auto& [_, room] : map.rooms()) { | 64 | for (const auto& [_, room] : map.rooms()) { |
| 59 | for (const auto& [_, id] : room.panels()) { | 65 | UpdateNextId(room.panels()); |
| 60 | if (id > next_id_) { | 66 | UpdateNextId(room.masteries()); |
| 61 | next_id_ = id; | 67 | UpdateNextId(room.keyholders()); |
| 62 | } | 68 | UpdateNextId(room.ports()); |
| 63 | } | ||
| 64 | |||
| 65 | for (const auto& [_, id] : room.masteries()) { | ||
| 66 | if (id > next_id_) { | ||
| 67 | next_id_ = id; | ||
| 68 | } | ||
| 69 | } | ||
| 70 | } | 69 | } |
| 71 | } | 70 | } |
| 72 | 71 | ||
| 73 | for (const auto& [_, id] : id_mappings_.special()) { | 72 | UpdateNextId(id_mappings_.special()); |
| 74 | if (id > next_id_) { | 73 | UpdateNextId(id_mappings_.letters()); |
| 75 | next_id_ = id; | 74 | UpdateNextId(id_mappings_.endings()); |
| 76 | } | 75 | UpdateNextId(id_mappings_.progressives()); |
| 77 | } | 76 | UpdateNextId(id_mappings_.door_groups()); |
| 78 | |||
| 79 | for (const auto& [_, id] : id_mappings_.letters()) { | ||
| 80 | if (id > next_id_) { | ||
| 81 | next_id_ = id; | ||
| 82 | } | ||
| 83 | } | ||
| 84 | 77 | ||
| 85 | next_id_++; | 78 | next_id_++; |
| 86 | } | 79 | } |
| 87 | 80 | ||
| 88 | void WriteIds(std::filesystem::path path) { | 81 | void WriteIds(std::filesystem::path path) { |
| 89 | std::string output; | 82 | WriteIdsAsYaml(output_, path.string()); |
| 90 | google::protobuf::TextFormat::PrintToString(id_mappings_, &output); | ||
| 91 | |||
| 92 | { | ||
| 93 | std::ofstream outputfile(path.string()); | ||
| 94 | outputfile << output; | ||
| 95 | } | ||
| 96 | } | 83 | } |
| 97 | 84 | ||
| 98 | void ProcessMaps(std::filesystem::path path) { | 85 | void ProcessMaps(std::filesystem::path path) { |
| @@ -104,7 +91,7 @@ class AssignIds { | |||
| 104 | } | 91 | } |
| 105 | 92 | ||
| 106 | void ProcessMap(std::filesystem::path path) { | 93 | void ProcessMap(std::filesystem::path path) { |
| 107 | std::string map_name = path.filename(); | 94 | std::string map_name = path.filename().string(); |
| 108 | 95 | ||
| 109 | ProcessDoorsFile(path / "doors.txtpb", map_name); | 96 | ProcessDoorsFile(path / "doors.txtpb", map_name); |
| 110 | ProcessRooms(path / "rooms", map_name); | 97 | ProcessRooms(path / "rooms", map_name); |
| @@ -125,18 +112,23 @@ class AssignIds { | |||
| 125 | 112 | ||
| 126 | void ProcessDoor(const HumanDoor& h_door, | 113 | void ProcessDoor(const HumanDoor& h_door, |
| 127 | const std::string& current_map_name) { | 114 | const std::string& current_map_name) { |
| 128 | if (h_door.type() == DoorType::EVENT) { | 115 | if (h_door.type() == DoorType::EVENT && !h_door.latch() && |
| 116 | !h_door.legacy_location()) { | ||
| 129 | return; | 117 | return; |
| 130 | } | 118 | } |
| 131 | 119 | ||
| 120 | auto& maps = *output_.mutable_maps(); | ||
| 121 | auto& doors = *maps[current_map_name].mutable_doors(); | ||
| 122 | |||
| 132 | if (!id_mappings_.maps().contains(current_map_name) || | 123 | if (!id_mappings_.maps().contains(current_map_name) || |
| 133 | !id_mappings_.maps() | 124 | !id_mappings_.maps() |
| 134 | .at(current_map_name) | 125 | .at(current_map_name) |
| 135 | .doors() | 126 | .doors() |
| 136 | .contains(h_door.name())) { | 127 | .contains(h_door.name())) { |
| 137 | auto& maps = *id_mappings_.mutable_maps(); | ||
| 138 | auto& doors = *maps[current_map_name].mutable_doors(); | ||
| 139 | 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()); | ||
| 140 | } | 132 | } |
| 141 | } | 133 | } |
| 142 | 134 | ||
| @@ -151,6 +143,10 @@ class AssignIds { | |||
| 151 | void ProcessRoom(const HumanRoom& h_room, | 143 | void ProcessRoom(const HumanRoom& h_room, |
| 152 | const std::string& current_map_name) { | 144 | const std::string& current_map_name) { |
| 153 | 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 | |||
| 154 | if (!id_mappings_.maps().contains(current_map_name) || | 150 | if (!id_mappings_.maps().contains(current_map_name) || |
| 155 | !id_mappings_.maps() | 151 | !id_mappings_.maps() |
| 156 | .at(current_map_name) | 152 | .at(current_map_name) |
| @@ -162,24 +158,33 @@ class AssignIds { | |||
| 162 | .at(h_room.name()) | 158 | .at(h_room.name()) |
| 163 | .panels() | 159 | .panels() |
| 164 | .contains(h_panel.name())) { | 160 | .contains(h_panel.name())) { |
| 165 | auto& maps = *id_mappings_.mutable_maps(); | ||
| 166 | auto& rooms = *maps[current_map_name].mutable_rooms(); | ||
| 167 | auto& panels = *rooms[h_room.name()].mutable_panels(); | ||
| 168 | 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()); | ||
| 169 | } | 169 | } |
| 170 | } | 170 | } |
| 171 | 171 | ||
| 172 | for (const HumanLetter& h_letter : h_room.letters()) { | 172 | for (const HumanLetter& h_letter : h_room.letters()) { |
| 173 | std::string lettername = | 173 | std::string lettername = GetLetterName(h_letter.key(), h_letter.level2()); |
| 174 | GetLetterName(h_letter.key(), h_letter.double_()); | ||
| 175 | 174 | ||
| 175 | auto& letters = *output_.mutable_letters(); | ||
| 176 | if (!id_mappings_.letters().contains(lettername)) { | 176 | if (!id_mappings_.letters().contains(lettername)) { |
| 177 | auto& letters = *id_mappings_.mutable_letters(); | ||
| 178 | letters[lettername] = next_id_++; | 177 | letters[lettername] = next_id_++; |
| 178 | } else { | ||
| 179 | letters[lettername] = id_mappings_.letters().at(lettername); | ||
| 179 | } | 180 | } |
| 180 | } | 181 | } |
| 181 | 182 | ||
| 182 | 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 | |||
| 183 | if (!id_mappings_.maps().contains(current_map_name) || | 188 | if (!id_mappings_.maps().contains(current_map_name) || |
| 184 | !id_mappings_.maps() | 189 | !id_mappings_.maps() |
| 185 | .at(current_map_name) | 190 | .at(current_map_name) |
| @@ -191,20 +196,164 @@ class AssignIds { | |||
| 191 | .at(h_room.name()) | 196 | .at(h_room.name()) |
| 192 | .masteries() | 197 | .masteries() |
| 193 | .contains(h_mastery.name())) { | 198 | .contains(h_mastery.name())) { |
| 194 | auto& maps = *id_mappings_.mutable_maps(); | ||
| 195 | auto& rooms = *maps[current_map_name].mutable_rooms(); | ||
| 196 | auto& masteries = *rooms[h_room.name()].mutable_masteries(); | ||
| 197 | 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()); | ||
| 207 | } | ||
| 208 | } | ||
| 209 | |||
| 210 | for (const HumanEnding& h_ending : h_room.endings()) { | ||
| 211 | auto& endings = *output_.mutable_endings(); | ||
| 212 | |||
| 213 | if (!id_mappings_.endings().contains(h_ending.name())) { | ||
| 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); | ||
| 198 | } | 338 | } |
| 199 | } | 339 | } |
| 200 | } | 340 | } |
| 201 | 341 | ||
| 202 | 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 | |||
| 203 | std::string mapdir_; | 351 | std::string mapdir_; |
| 204 | 352 | ||
| 205 | uint64_t next_id_ = 0; | 353 | uint64_t next_id_ = 1; |
| 206 | 354 | ||
| 207 | IdMappings id_mappings_; | 355 | IdMappings id_mappings_; |
| 356 | IdMappings output_; | ||
| 208 | }; | 357 | }; |
| 209 | 358 | ||
| 210 | } // namespace | 359 | } // namespace |
| diff --git a/tools/datapacker/container.cpp b/tools/datapacker/container.cpp index bb58ec5..4a656b3 100644 --- a/tools/datapacker/container.cpp +++ b/tools/datapacker/container.cpp | |||
| @@ -79,7 +79,7 @@ uint64_t Container::FindOrAddPainting( | |||
| 79 | auto it = room_container.find(painting_name); | 79 | auto it = room_container.find(painting_name); |
| 80 | if (it == room_container.end()) { | 80 | if (it == room_container.end()) { |
| 81 | uint64_t new_id = all_objects_.paintings_size(); | 81 | uint64_t new_id = all_objects_.paintings_size(); |
| 82 | Painting* painting = all_objects_.add_paintings(); | 82 | PaintingData* painting = all_objects_.add_paintings(); |
| 83 | painting->set_id(new_id); | 83 | painting->set_id(new_id); |
| 84 | painting->set_room_id(FindOrAddRoom(map_name, *room_name, std::nullopt)); | 84 | painting->set_room_id(FindOrAddRoom(map_name, *room_name, std::nullopt)); |
| 85 | painting->set_name(painting_name); | 85 | painting->set_name(painting_name); |
| @@ -160,7 +160,7 @@ uint64_t Container::FindOrAddPanel(std::optional<std::string> map_name, | |||
| 160 | auto it = room_container.find(panel_name); | 160 | auto it = room_container.find(panel_name); |
| 161 | if (it == room_container.end()) { | 161 | if (it == room_container.end()) { |
| 162 | uint64_t new_id = all_objects_.panels_size(); | 162 | uint64_t new_id = all_objects_.panels_size(); |
| 163 | Panel* panel = all_objects_.add_panels(); | 163 | PanelData* panel = all_objects_.add_panels(); |
| 164 | panel->set_id(new_id); | 164 | panel->set_id(new_id); |
| 165 | panel->set_room_id(FindOrAddRoom(map_name, *room_name, std::nullopt)); | 165 | panel->set_room_id(FindOrAddRoom(map_name, *room_name, std::nullopt)); |
| 166 | panel->set_name(panel_name); | 166 | panel->set_name(panel_name); |
| @@ -173,8 +173,8 @@ uint64_t Container::FindOrAddPanel(std::optional<std::string> map_name, | |||
| 173 | } | 173 | } |
| 174 | } | 174 | } |
| 175 | 175 | ||
| 176 | uint64_t Container::FindOrAddLetter(std::string key, bool double_) { | 176 | uint64_t Container::FindOrAddLetter(std::string key, bool level2) { |
| 177 | std::string letter_name = GetLetterName(key, double_); | 177 | std::string letter_name = GetLetterName(key, level2); |
| 178 | 178 | ||
| 179 | auto it = letter_id_by_name_.find(letter_name); | 179 | auto it = letter_id_by_name_.find(letter_name); |
| 180 | if (it == letter_id_by_name_.end()) { | 180 | if (it == letter_id_by_name_.end()) { |
| @@ -183,8 +183,8 @@ uint64_t Container::FindOrAddLetter(std::string key, bool double_) { | |||
| 183 | letter->set_id(new_id); | 183 | letter->set_id(new_id); |
| 184 | letter->set_key(key); | 184 | letter->set_key(key); |
| 185 | 185 | ||
| 186 | if (double_) { | 186 | if (level2) { |
| 187 | letter->set_double_(double_); | 187 | letter->set_level2(level2); |
| 188 | } | 188 | } |
| 189 | 189 | ||
| 190 | letter_id_by_name_[letter_name] = new_id; | 190 | letter_id_by_name_[letter_name] = new_id; |
| @@ -205,6 +205,22 @@ uint64_t Container::FindLetterByName(std::string letter_name) { | |||
| 205 | } | 205 | } |
| 206 | } | 206 | } |
| 207 | 207 | ||
| 208 | uint64_t Container::FindOrAddEnding(std::string ending_name) { | ||
| 209 | auto it = ending_id_by_name_.find(ending_name); | ||
| 210 | if (it == ending_id_by_name_.end()) { | ||
| 211 | uint64_t new_id = all_objects_.endings_size(); | ||
| 212 | Ending* ending = all_objects_.add_endings(); | ||
| 213 | ending->set_id(new_id); | ||
| 214 | ending->set_name(ending_name); | ||
| 215 | |||
| 216 | ending_id_by_name_[ending_name] = new_id; | ||
| 217 | |||
| 218 | return new_id; | ||
| 219 | } else { | ||
| 220 | return it->second; | ||
| 221 | } | ||
| 222 | } | ||
| 223 | |||
| 208 | uint64_t Container::FindOrAddMastery(std::optional<std::string> map_name, | 224 | uint64_t Container::FindOrAddMastery(std::optional<std::string> map_name, |
| 209 | std::optional<std::string> room_name, | 225 | std::optional<std::string> room_name, |
| 210 | std::string mastery_name, | 226 | std::string mastery_name, |
| @@ -273,7 +289,7 @@ uint64_t Container::FindOrAddKeyholder( | |||
| 273 | auto it = room_container.find(keyholder_name); | 289 | auto it = room_container.find(keyholder_name); |
| 274 | if (it == room_container.end()) { | 290 | if (it == room_container.end()) { |
| 275 | uint64_t new_id = all_objects_.keyholders_size(); | 291 | uint64_t new_id = all_objects_.keyholders_size(); |
| 276 | Keyholder* keyholder = all_objects_.add_keyholders(); | 292 | KeyholderData* keyholder = all_objects_.add_keyholders(); |
| 277 | keyholder->set_id(new_id); | 293 | keyholder->set_id(new_id); |
| 278 | keyholder->set_room_id(FindOrAddRoom(map_name, *room_name, std::nullopt)); | 294 | keyholder->set_room_id(FindOrAddRoom(map_name, *room_name, std::nullopt)); |
| 279 | keyholder->set_name(keyholder_name); | 295 | keyholder->set_name(keyholder_name); |
| @@ -315,6 +331,40 @@ uint64_t Container::FindOrAddDoor(std::optional<std::string> map_name, | |||
| 315 | } | 331 | } |
| 316 | } | 332 | } |
| 317 | 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 | |||
| 318 | void Container::AddConnection(const Connection& connection) { | 368 | void Container::AddConnection(const Connection& connection) { |
| 319 | *all_objects_.add_connections() = connection; | 369 | *all_objects_.add_connections() = connection; |
| 320 | } | 370 | } |
| diff --git a/tools/datapacker/container.h b/tools/datapacker/container.h index 7ee5b5b..bc02ba4 100644 --- a/tools/datapacker/container.h +++ b/tools/datapacker/container.h | |||
| @@ -36,10 +36,12 @@ class Container { | |||
| 36 | std::optional<std::string> map_fallback, | 36 | std::optional<std::string> map_fallback, |
| 37 | std::optional<std::string> room_fallback); | 37 | std::optional<std::string> room_fallback); |
| 38 | 38 | ||
| 39 | uint64_t FindOrAddLetter(std::string key, bool double_); | 39 | uint64_t FindOrAddLetter(std::string key, bool level2); |
| 40 | 40 | ||
| 41 | uint64_t FindLetterByName(std::string letter_name); | 41 | uint64_t FindLetterByName(std::string letter_name); |
| 42 | 42 | ||
| 43 | uint64_t FindOrAddEnding(std::string ending_name); | ||
| 44 | |||
| 43 | uint64_t FindOrAddMastery(std::optional<std::string> map_name, | 45 | uint64_t FindOrAddMastery(std::optional<std::string> map_name, |
| 44 | std::optional<std::string> room_name, | 46 | std::optional<std::string> room_name, |
| 45 | std::string mastery_name, | 47 | std::string mastery_name, |
| @@ -58,6 +60,10 @@ class Container { | |||
| 58 | 60 | ||
| 59 | void AddConnection(const Connection& connection); | 61 | void AddConnection(const Connection& connection); |
| 60 | 62 | ||
| 63 | uint64_t FindOrAddProgressive(std::string prog_name); | ||
| 64 | |||
| 65 | uint64_t FindOrAddDoorGroup(std::string group_name); | ||
| 66 | |||
| 61 | AllObjects& all_objects() { return all_objects_; } | 67 | AllObjects& all_objects() { return all_objects_; } |
| 62 | 68 | ||
| 63 | private: | 69 | private: |
| @@ -79,6 +85,9 @@ class Container { | |||
| 79 | keyholder_id_by_map_room_keyholder_names_; | 85 | keyholder_id_by_map_room_keyholder_names_; |
| 80 | std::map<std::string, std::map<std::string, uint64_t>> | 86 | std::map<std::string, std::map<std::string, uint64_t>> |
| 81 | door_id_by_map_door_names_; | 87 | door_id_by_map_door_names_; |
| 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_; | ||
| 82 | }; | 91 | }; |
| 83 | 92 | ||
| 84 | } // namespace com::fourisland::lingo2_archipelago | 93 | } // namespace com::fourisland::lingo2_archipelago |
| diff --git a/tools/datapacker/main.cpp b/tools/datapacker/main.cpp index d3908b4..8109bf5 100644 --- a/tools/datapacker/main.cpp +++ b/tools/datapacker/main.cpp | |||
| @@ -14,6 +14,7 @@ | |||
| 14 | #include "container.h" | 14 | #include "container.h" |
| 15 | #include "proto/data.pb.h" | 15 | #include "proto/data.pb.h" |
| 16 | #include "proto/human.pb.h" | 16 | #include "proto/human.pb.h" |
| 17 | #include "util/ids_yaml_format.h" | ||
| 17 | 18 | ||
| 18 | namespace com::fourisland::lingo2_archipelago { | 19 | namespace com::fourisland::lingo2_archipelago { |
| 19 | namespace { | 20 | namespace { |
| @@ -42,7 +43,10 @@ class DataPacker { | |||
| 42 | 43 | ||
| 43 | ProcessConnectionsFile(datadir_path / "connections.txtpb", std::nullopt); | 44 | ProcessConnectionsFile(datadir_path / "connections.txtpb", std::nullopt); |
| 44 | ProcessMaps(datadir_path); | 45 | ProcessMaps(datadir_path); |
| 45 | ProcessIdsFile(datadir_path / "ids.txtpb"); | 46 | ProcessProgressivesFile(datadir_path / "progressives.txtpb"); |
| 47 | ProcessDoorGroupsFile(datadir_path / "door_groups.txtpb"); | ||
| 48 | ProcessGlobalMetadataFile(datadir_path / "metadata.txtpb"); | ||
| 49 | ProcessIdsFile(datadir_path / "ids.yaml"); | ||
| 46 | 50 | ||
| 47 | { | 51 | { |
| 48 | std::ofstream outputfile(outputpath_); | 52 | std::ofstream outputfile(outputpath_); |
| @@ -65,13 +69,38 @@ class DataPacker { | |||
| 65 | } | 69 | } |
| 66 | 70 | ||
| 67 | void ProcessMap(std::filesystem::path path) { | 71 | void ProcessMap(std::filesystem::path path) { |
| 68 | std::string map_name = path.filename(); | 72 | std::string map_name = path.filename().string(); |
| 69 | 73 | ||
| 74 | ProcessMapMetadataFile(path / "metadata.txtpb", map_name); | ||
| 70 | ProcessConnectionsFile(path / "connections.txtpb", map_name); | 75 | ProcessConnectionsFile(path / "connections.txtpb", map_name); |
| 71 | ProcessDoorsFile(path / "doors.txtpb", map_name); | 76 | ProcessDoorsFile(path / "doors.txtpb", map_name); |
| 72 | ProcessRooms(path / "rooms", map_name); | 77 | ProcessRooms(path / "rooms", map_name); |
| 73 | } | 78 | } |
| 74 | 79 | ||
| 80 | void ProcessMapMetadataFile(std::filesystem::path path, | ||
| 81 | const std::string& map_name) { | ||
| 82 | if (!std::filesystem::exists(path)) { | ||
| 83 | return; | ||
| 84 | } | ||
| 85 | |||
| 86 | auto metadata = ReadMessageFromFile<HumanMap>(path.string()); | ||
| 87 | |||
| 88 | uint64_t map_id = container_.FindOrAddMap(map_name); | ||
| 89 | Map& map = *container_.all_objects().mutable_maps(map_id); | ||
| 90 | |||
| 91 | map.set_type(metadata.type()); | ||
| 92 | |||
| 93 | if (metadata.has_display_name()) { | ||
| 94 | map.set_display_name(metadata.display_name()); | ||
| 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 | } | ||
| 102 | } | ||
| 103 | |||
| 75 | void ProcessRooms(std::filesystem::path path, | 104 | void ProcessRooms(std::filesystem::path path, |
| 76 | const std::string& current_map_name) { | 105 | const std::string& current_map_name) { |
| 77 | for (auto const& dir_entry : std::filesystem::directory_iterator(path)) { | 106 | for (auto const& dir_entry : std::filesystem::directory_iterator(path)) { |
| @@ -86,7 +115,11 @@ class DataPacker { | |||
| 86 | container_.FindOrAddRoom(current_map_name, h_room.name(), std::nullopt); | 115 | container_.FindOrAddRoom(current_map_name, h_room.name(), std::nullopt); |
| 87 | Room& room = *container_.all_objects().mutable_rooms(room_id); | 116 | Room& room = *container_.all_objects().mutable_rooms(room_id); |
| 88 | 117 | ||
| 89 | room.set_display_name(h_room.display_name()); | 118 | // room.set_display_name(h_room.display_name()); |
| 119 | |||
| 120 | if (h_room.has_panel_display_name()) { | ||
| 121 | room.set_panel_display_name(h_room.panel_display_name()); | ||
| 122 | } | ||
| 90 | 123 | ||
| 91 | for (const HumanPanel& h_panel : h_room.panels()) { | 124 | for (const HumanPanel& h_panel : h_room.panels()) { |
| 92 | room.add_panels(ProcessPanel(h_panel, current_map_name, room.name())); | 125 | room.add_panels(ProcessPanel(h_panel, current_map_name, room.name())); |
| @@ -114,6 +147,10 @@ class DataPacker { | |||
| 114 | room.add_keyholders( | 147 | room.add_keyholders( |
| 115 | ProcessKeyholder(h_keyholder, current_map_name, room.name())); | 148 | ProcessKeyholder(h_keyholder, current_map_name, room.name())); |
| 116 | } | 149 | } |
| 150 | |||
| 151 | for (const HumanEnding& h_ending : h_room.endings()) { | ||
| 152 | room.add_endings(ProcessEnding(h_ending, current_map_name, room.name())); | ||
| 153 | } | ||
| 117 | } | 154 | } |
| 118 | 155 | ||
| 119 | uint64_t ProcessPanel(const HumanPanel& h_panel, | 156 | uint64_t ProcessPanel(const HumanPanel& h_panel, |
| @@ -122,7 +159,7 @@ class DataPacker { | |||
| 122 | uint64_t panel_id = | 159 | uint64_t panel_id = |
| 123 | container_.FindOrAddPanel(current_map_name, current_room_name, | 160 | container_.FindOrAddPanel(current_map_name, current_room_name, |
| 124 | h_panel.name(), std::nullopt, std::nullopt); | 161 | h_panel.name(), std::nullopt, std::nullopt); |
| 125 | Panel& panel = *container_.all_objects().mutable_panels(panel_id); | 162 | PanelData& panel = *container_.all_objects().mutable_panels(panel_id); |
| 126 | 163 | ||
| 127 | panel.set_path(h_panel.path()); | 164 | panel.set_path(h_panel.path()); |
| 128 | panel.set_clue(h_panel.clue()); | 165 | panel.set_clue(h_panel.clue()); |
| @@ -153,6 +190,10 @@ class DataPacker { | |||
| 153 | map_name, h_panel.required_room().name(), current_map_name)); | 190 | map_name, h_panel.required_room().name(), current_map_name)); |
| 154 | } | 191 | } |
| 155 | 192 | ||
| 193 | if (h_panel.has_display_name()) { | ||
| 194 | panel.set_display_name(h_panel.display_name()); | ||
| 195 | } | ||
| 196 | |||
| 156 | return panel_id; | 197 | return panel_id; |
| 157 | } | 198 | } |
| 158 | 199 | ||
| @@ -162,16 +203,16 @@ class DataPacker { | |||
| 162 | uint64_t painting_id = container_.FindOrAddPainting( | 203 | uint64_t painting_id = container_.FindOrAddPainting( |
| 163 | current_map_name, current_room_name, h_painting.name(), std::nullopt, | 204 | current_map_name, current_room_name, h_painting.name(), std::nullopt, |
| 164 | std::nullopt); | 205 | std::nullopt); |
| 165 | Painting& painting = | 206 | PaintingData& painting = |
| 166 | *container_.all_objects().mutable_paintings(painting_id); | 207 | *container_.all_objects().mutable_paintings(painting_id); |
| 167 | 208 | ||
| 168 | painting.set_path(h_painting.path()); | 209 | painting.set_path(h_painting.path()); |
| 169 | painting.set_display_name(h_painting.display_name()); | 210 | painting.set_display_name(h_painting.display_name()); |
| 170 | painting.set_orientation(h_painting.orientation()); | 211 | painting.set_orientation(h_painting.orientation()); |
| 171 | 212 | ||
| 172 | if (h_painting.has_gravity()) { | 213 | // Setting this explicitly because the Godot protobuf doesn't support |
| 173 | painting.set_gravity(h_painting.gravity()); | 214 | // custom defaults. |
| 174 | } | 215 | painting.set_gravity(h_painting.gravity()); |
| 175 | 216 | ||
| 176 | if (h_painting.has_move()) { | 217 | if (h_painting.has_move()) { |
| 177 | painting.set_move(h_painting.move()); | 218 | painting.set_move(h_painting.move()); |
| @@ -206,12 +247,19 @@ class DataPacker { | |||
| 206 | Port& port = *container_.all_objects().mutable_ports(port_id); | 247 | Port& port = *container_.all_objects().mutable_ports(port_id); |
| 207 | 248 | ||
| 208 | port.set_path(h_port.path()); | 249 | port.set_path(h_port.path()); |
| 209 | port.set_orientation(h_port.orientation()); | 250 | port.set_display_name(h_port.display_name()); |
| 210 | 251 | ||
| 211 | if (h_port.has_gravity()) { | 252 | if (h_port.no_shuffle()) { |
| 212 | port.set_gravity(h_port.gravity()); | 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()); | ||
| 213 | } | 257 | } |
| 214 | 258 | ||
| 259 | // Setting this explicitly because the Godot protobuf doesn't support | ||
| 260 | // custom defaults. | ||
| 261 | port.set_gravity(h_port.gravity()); | ||
| 262 | |||
| 215 | if (h_port.has_required_door()) { | 263 | if (h_port.has_required_door()) { |
| 216 | std::optional<std::string> map_name = | 264 | std::optional<std::string> map_name = |
| 217 | h_port.required_door().has_map() | 265 | h_port.required_door().has_map() |
| @@ -228,7 +276,7 @@ class DataPacker { | |||
| 228 | const std::string& current_map_name, | 276 | const std::string& current_map_name, |
| 229 | const std::string& current_room_name) { | 277 | const std::string& current_room_name) { |
| 230 | uint64_t letter_id = | 278 | uint64_t letter_id = |
| 231 | container_.FindOrAddLetter(h_letter.key(), h_letter.double_()); | 279 | container_.FindOrAddLetter(h_letter.key(), h_letter.level2()); |
| 232 | Letter& letter = *container_.all_objects().mutable_letters(letter_id); | 280 | Letter& letter = *container_.all_objects().mutable_letters(letter_id); |
| 233 | 281 | ||
| 234 | letter.set_room_id(container_.FindOrAddRoom( | 282 | letter.set_room_id(container_.FindOrAddRoom( |
| @@ -257,14 +305,31 @@ class DataPacker { | |||
| 257 | uint64_t keyholder_id = container_.FindOrAddKeyholder( | 305 | uint64_t keyholder_id = container_.FindOrAddKeyholder( |
| 258 | current_map_name, current_room_name, h_keyholder.name(), std::nullopt, | 306 | current_map_name, current_room_name, h_keyholder.name(), std::nullopt, |
| 259 | std::nullopt); | 307 | std::nullopt); |
| 260 | Keyholder& keyholder = | 308 | KeyholderData& keyholder = |
| 261 | *container_.all_objects().mutable_keyholders(keyholder_id); | 309 | *container_.all_objects().mutable_keyholders(keyholder_id); |
| 262 | 310 | ||
| 263 | keyholder.set_path(h_keyholder.path()); | 311 | keyholder.set_path(h_keyholder.path()); |
| 264 | 312 | ||
| 313 | if (h_keyholder.has_key()) { | ||
| 314 | keyholder.set_key(h_keyholder.key()); | ||
| 315 | } | ||
| 316 | |||
| 265 | return keyholder_id; | 317 | return keyholder_id; |
| 266 | } | 318 | } |
| 267 | 319 | ||
| 320 | uint64_t ProcessEnding(const HumanEnding& h_ending, | ||
| 321 | const std::string& current_map_name, | ||
| 322 | const std::string& current_room_name) { | ||
| 323 | uint64_t ending_id = container_.FindOrAddEnding(h_ending.name()); | ||
| 324 | Ending& ending = *container_.all_objects().mutable_endings(ending_id); | ||
| 325 | |||
| 326 | ending.set_room_id(container_.FindOrAddRoom( | ||
| 327 | current_map_name, current_room_name, std::nullopt)); | ||
| 328 | ending.set_path(h_ending.path()); | ||
| 329 | |||
| 330 | return ending_id; | ||
| 331 | } | ||
| 332 | |||
| 268 | void ProcessDoorsFile(std::filesystem::path path, | 333 | void ProcessDoorsFile(std::filesystem::path path, |
| 269 | const std::string& current_map_name) { | 334 | const std::string& current_map_name) { |
| 270 | if (!std::filesystem::exists(path)) { | 335 | if (!std::filesystem::exists(path)) { |
| @@ -296,8 +361,8 @@ class DataPacker { | |||
| 296 | h_door.receivers().begin(), h_door.receivers().end(), | 361 | h_door.receivers().begin(), h_door.receivers().end(), |
| 297 | google::protobuf::RepeatedFieldBackInserter(door.mutable_receivers())); | 362 | google::protobuf::RepeatedFieldBackInserter(door.mutable_receivers())); |
| 298 | std::copy( | 363 | std::copy( |
| 299 | h_door.switches().begin(), h_door.switches().end(), | 364 | h_door.senders().begin(), h_door.senders().end(), |
| 300 | google::protobuf::RepeatedFieldBackInserter(door.mutable_switches())); | 365 | google::protobuf::RepeatedFieldBackInserter(door.mutable_senders())); |
| 301 | 366 | ||
| 302 | for (const PaintingIdentifier& pi : h_door.move_paintings()) { | 367 | for (const PaintingIdentifier& pi : h_door.move_paintings()) { |
| 303 | std::optional<std::string> map_name = | 368 | std::optional<std::string> map_name = |
| @@ -339,6 +404,17 @@ class DataPacker { | |||
| 339 | container_.FindOrAddRoom(map_name, ri.name(), current_map_name)); | 404 | container_.FindOrAddRoom(map_name, ri.name(), current_map_name)); |
| 340 | } | 405 | } |
| 341 | 406 | ||
| 407 | for (const DoorIdentifier& di : h_door.doors()) { | ||
| 408 | std::optional<std::string> map_name = | ||
| 409 | di.has_map() ? std::optional<std::string>(di.map()) : std::nullopt; | ||
| 410 | door.add_doors( | ||
| 411 | container_.FindOrAddDoor(map_name, di.name(), current_map_name)); | ||
| 412 | } | ||
| 413 | |||
| 414 | if (h_door.has_white_ending()) { | ||
| 415 | door.set_white_ending(h_door.white_ending()); | ||
| 416 | } | ||
| 417 | |||
| 342 | if (h_door.has_control_center_color()) { | 418 | if (h_door.has_control_center_color()) { |
| 343 | door.set_control_center_color(h_door.control_center_color()); | 419 | door.set_control_center_color(h_door.control_center_color()); |
| 344 | } | 420 | } |
| @@ -348,6 +424,22 @@ class DataPacker { | |||
| 348 | } | 424 | } |
| 349 | 425 | ||
| 350 | door.set_type(h_door.type()); | 426 | door.set_type(h_door.type()); |
| 427 | |||
| 428 | if (h_door.has_location_name()) { | ||
| 429 | door.set_location_name(h_door.location_name()); | ||
| 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 | } | ||
| 351 | } | 443 | } |
| 352 | 444 | ||
| 353 | void ProcessConnectionsFile(std::filesystem::path path, | 445 | void ProcessConnectionsFile(std::filesystem::path path, |
| @@ -399,6 +491,26 @@ class DataPacker { | |||
| 399 | r_connection.set_required_door(door_id); | 491 | r_connection.set_required_door(door_id); |
| 400 | } | 492 | } |
| 401 | 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 | |||
| 402 | container_.AddConnection(f_connection); | 514 | container_.AddConnection(f_connection); |
| 403 | if (!human_connection.oneway()) { | 515 | if (!human_connection.oneway()) { |
| 404 | container_.AddConnection(r_connection); | 516 | container_.AddConnection(r_connection); |
| @@ -482,8 +594,65 @@ class DataPacker { | |||
| 482 | } | 594 | } |
| 483 | } | 595 | } |
| 484 | 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 | |||
| 485 | void ProcessIdsFile(std::filesystem::path path) { | 654 | void ProcessIdsFile(std::filesystem::path path) { |
| 486 | auto ids = ReadMessageFromFile<IdMappings>(path.string()); | 655 | auto ids = ReadIdsFromYaml(path.string()); |
| 487 | 656 | ||
| 488 | for (const auto& [map_name, map] : ids.maps()) { | 657 | for (const auto& [map_name, map] : ids.maps()) { |
| 489 | for (const auto& [door_name, ap_id] : map.doors()) { | 658 | for (const auto& [door_name, ap_id] : map.doors()) { |
| @@ -506,6 +675,20 @@ class DataPacker { | |||
| 506 | .mutable_masteries(mastery_id) | 675 | .mutable_masteries(mastery_id) |
| 507 | ->set_ap_id(ap_id); | 676 | ->set_ap_id(ap_id); |
| 508 | } | 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 | } | ||
| 509 | } | 692 | } |
| 510 | } | 693 | } |
| 511 | 694 | ||
| @@ -518,6 +701,21 @@ class DataPacker { | |||
| 518 | uint64_t letter_id = container_.FindLetterByName(letter_name); | 701 | uint64_t letter_id = container_.FindLetterByName(letter_name); |
| 519 | container_.all_objects().mutable_letters(letter_id)->set_ap_id(ap_id); | 702 | container_.all_objects().mutable_letters(letter_id)->set_ap_id(ap_id); |
| 520 | } | 703 | } |
| 704 | |||
| 705 | for (const auto& [ending_name, ap_id] : ids.endings()) { | ||
| 706 | uint64_t ending_id = container_.FindOrAddEnding(ending_name); | ||
| 707 | container_.all_objects().mutable_endings(ending_id)->set_ap_id(ap_id); | ||
| 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 | } | ||
| 521 | } | 719 | } |
| 522 | 720 | ||
| 523 | std::string mapdir_; | 721 | std::string mapdir_; |
| diff --git a/tools/util/CMakeLists.txt b/tools/util/CMakeLists.txt index 8eb8d3b..0859a58 100644 --- a/tools/util/CMakeLists.txt +++ b/tools/util/CMakeLists.txt | |||
| @@ -1,5 +1,13 @@ | |||
| 1 | find_package(Protobuf REQUIRED) | ||
| 2 | find_package(yaml-cpp REQUIRED) | ||
| 3 | |||
| 1 | add_library(util | 4 | add_library(util |
| 5 | godot_scene.cpp | ||
| 6 | identifiers.cpp | ||
| 7 | ids_yaml_format.cpp | ||
| 2 | naming.cpp | 8 | naming.cpp |
| 3 | ) | 9 | ) |
| 4 | set_property(TARGET util PROPERTY CXX_STANDARD 20) | 10 | set_property(TARGET util PROPERTY CXX_STANDARD 20) |
| 5 | set_property(TARGET util PROPERTY CXX_STANDARD_REQUIRED ON) | 11 | set_property(TARGET util PROPERTY CXX_STANDARD_REQUIRED ON) |
| 12 | target_include_directories(util PUBLIC ${CMAKE_BINARY_DIR}) | ||
| 13 | target_link_libraries(util PUBLIC protos protobuf::libprotobuf yaml-cpp::yaml-cpp) | ||
| diff --git a/tools/util/godot_scene.cpp b/tools/util/godot_scene.cpp new file mode 100644 index 0000000..f788d21 --- /dev/null +++ b/tools/util/godot_scene.cpp | |||
| @@ -0,0 +1,207 @@ | |||
| 1 | #include "godot_scene.h" | ||
| 2 | |||
| 3 | #include <fstream> | ||
| 4 | #include <sstream> | ||
| 5 | #include <string_view> | ||
| 6 | #include <variant> | ||
| 7 | |||
| 8 | namespace com::fourisland::lingo2_archipelago { | ||
| 9 | |||
| 10 | namespace { | ||
| 11 | |||
| 12 | struct Heading { | ||
| 13 | std::string type; | ||
| 14 | |||
| 15 | std::string id; | ||
| 16 | std::string path; | ||
| 17 | std::string resource_type; | ||
| 18 | |||
| 19 | std::string name; | ||
| 20 | std::string parent; | ||
| 21 | GodotInstanceType instance_type; | ||
| 22 | }; | ||
| 23 | |||
| 24 | Heading ParseTscnHeading(std::string_view line) { | ||
| 25 | std::string original_line(line); | ||
| 26 | Heading heading; | ||
| 27 | |||
| 28 | if (line[0] != '[') { | ||
| 29 | std::ostringstream errormsg; | ||
| 30 | errormsg << "Heading must start with [." << std::endl | ||
| 31 | << "Bad heading: " << original_line; | ||
| 32 | throw std::invalid_argument(errormsg.str()); | ||
| 33 | } | ||
| 34 | |||
| 35 | line.remove_prefix(1); | ||
| 36 | int divider = line.find_first_of(" ]"); | ||
| 37 | if (divider == std::string_view::npos) { | ||
| 38 | std::ostringstream errormsg; | ||
| 39 | errormsg << "Malformatted heading: " << line << std::endl | ||
| 40 | << "Original line: " << original_line; | ||
| 41 | throw std::invalid_argument(errormsg.str()); | ||
| 42 | } | ||
| 43 | |||
| 44 | heading.type = std::string(line.substr(0, divider)); | ||
| 45 | line.remove_prefix(divider + 1); | ||
| 46 | |||
| 47 | while (!line.empty()) { | ||
| 48 | divider = line.find_first_of("="); | ||
| 49 | if (divider == std::string_view::npos) { | ||
| 50 | std::ostringstream errormsg; | ||
| 51 | errormsg << "Malformatted heading: " << line << std::endl | ||
| 52 | << "Original line: " << original_line; | ||
| 53 | throw std::invalid_argument(errormsg.str()); | ||
| 54 | } | ||
| 55 | |||
| 56 | std::string key(line.substr(0, divider)); | ||
| 57 | line.remove_prefix(divider + 1); | ||
| 58 | |||
| 59 | if (line[0] == '"') { | ||
| 60 | line.remove_prefix(1); | ||
| 61 | divider = line.find_first_of("\""); | ||
| 62 | |||
| 63 | if (divider == std::string_view::npos) { | ||
| 64 | std::ostringstream errormsg; | ||
| 65 | errormsg << "Malformatted heading: " << line << std::endl | ||
| 66 | << "Original line: " << original_line; | ||
| 67 | throw std::invalid_argument(errormsg.str()); | ||
| 68 | } | ||
| 69 | |||
| 70 | std::string strval(line.substr(0, divider)); | ||
| 71 | line.remove_prefix(divider + 2); | ||
| 72 | |||
| 73 | if (key == "name") { | ||
| 74 | heading.name = strval; | ||
| 75 | } else if (key == "parent") { | ||
| 76 | heading.parent = strval; | ||
| 77 | } else if (key == "path") { | ||
| 78 | heading.path = strval; | ||
| 79 | } else if (key == "type") { | ||
| 80 | heading.resource_type = strval; | ||
| 81 | } else if (key == "id") { | ||
| 82 | heading.id = strval; | ||
| 83 | } | ||
| 84 | } else if (line[0] == 'S' || line[0] == 'E') { | ||
| 85 | GodotInstanceType rrval; | ||
| 86 | char internal = line[0]; | ||
| 87 | |||
| 88 | line.remove_prefix(13); // SubResource(" | ||
| 89 | divider = line.find_first_of("\""); | ||
| 90 | |||
| 91 | if (divider == std::string_view::npos) { | ||
| 92 | std::ostringstream errormsg; | ||
| 93 | errormsg << "Malformatted heading: " << line << std::endl | ||
| 94 | << "Original line: " << original_line; | ||
| 95 | throw std::invalid_argument(errormsg.str()); | ||
| 96 | } | ||
| 97 | |||
| 98 | std::string refid = std::string(line.substr(0, divider)); | ||
| 99 | line.remove_prefix(divider + 3); | ||
| 100 | |||
| 101 | GodotInstanceType instance_type; | ||
| 102 | if (internal == 'E') { | ||
| 103 | instance_type = GodotExtResourceRef{.id = refid}; | ||
| 104 | } else { | ||
| 105 | // SubResource is not supported right now. | ||
| 106 | } | ||
| 107 | |||
| 108 | if (key == "instance") { | ||
| 109 | heading.instance_type = instance_type; | ||
| 110 | } else { | ||
| 111 | // Other keys aren't supported right now. | ||
| 112 | } | ||
| 113 | } else { | ||
| 114 | divider = line.find_first_of(" ]"); | ||
| 115 | |||
| 116 | if (divider == std::string_view::npos) { | ||
| 117 | std::ostringstream errormsg; | ||
| 118 | errormsg << "Malformatted heading: " << line << std::endl | ||
| 119 | << "Original line: " << original_line; | ||
| 120 | throw std::invalid_argument(errormsg.str()); | ||
| 121 | } | ||
| 122 | |||
| 123 | int numval = std::atoi(line.substr(0, divider).data()); | ||
| 124 | line.remove_prefix(divider + 1); | ||
| 125 | |||
| 126 | // keyvals_[key] = numval; | ||
| 127 | } | ||
| 128 | } | ||
| 129 | |||
| 130 | return heading; | ||
| 131 | } | ||
| 132 | |||
| 133 | } // namespace | ||
| 134 | |||
| 135 | std::string GodotNode::GetPath() const { | ||
| 136 | if (parent.empty() || parent == ".") { | ||
| 137 | return name; | ||
| 138 | } else { | ||
| 139 | return parent + "/" + name; | ||
| 140 | } | ||
| 141 | } | ||
| 142 | |||
| 143 | GodotScene ReadGodotSceneFromFile(const std::string& path) { | ||
| 144 | std::map<std::string, GodotExtResource> ext_resources; | ||
| 145 | std::vector<GodotNode> nodes; | ||
| 146 | |||
| 147 | std::ifstream input(path); | ||
| 148 | |||
| 149 | std::string line; | ||
| 150 | bool section_started = false; | ||
| 151 | Heading cur_heading; | ||
| 152 | std::ostringstream cur_value; | ||
| 153 | bool value_started = false; | ||
| 154 | auto handle_end_of_section = [&]() { | ||
| 155 | section_started = false; | ||
| 156 | value_started = false; | ||
| 157 | |||
| 158 | if (cur_heading.type == "sub_resource") { | ||
| 159 | // sub_resources_[std::get<int>(cur_heading.GetKeyval("id"))] = | ||
| 160 | // {cur_heading, cur_value.str(), ""}; | ||
| 161 | } else { | ||
| 162 | // other_.emplace_back(cur_heading, cur_value.str()); | ||
| 163 | } | ||
| 164 | |||
| 165 | cur_value = {}; | ||
| 166 | }; | ||
| 167 | while (std::getline(input, line)) { | ||
| 168 | if (section_started && (line.empty() || line[0] == '[')) { | ||
| 169 | handle_end_of_section(); | ||
| 170 | } | ||
| 171 | if (!line.empty() && line[0] == '[') { | ||
| 172 | Heading heading = ParseTscnHeading(line); | ||
| 173 | if (heading.type == "gd_scene") { | ||
| 174 | // file_descriptor_ = heading; | ||
| 175 | } else if (heading.type == "ext_resource") { | ||
| 176 | GodotExtResource ext_resource; | ||
| 177 | ext_resource.path = heading.path; | ||
| 178 | ext_resource.type = heading.resource_type; | ||
| 179 | |||
| 180 | ext_resources[heading.id] = ext_resource; | ||
| 181 | } else if (heading.type == "node") { | ||
| 182 | if (heading.parent != "") { | ||
| 183 | nodes.push_back(GodotNode{.name = heading.name, | ||
| 184 | .parent = heading.parent, | ||
| 185 | .instance_type = heading.instance_type}); | ||
| 186 | } | ||
| 187 | } else { | ||
| 188 | cur_heading = heading; | ||
| 189 | section_started = true; | ||
| 190 | } | ||
| 191 | } else if (!line.empty()) { | ||
| 192 | if (value_started) { | ||
| 193 | cur_value << std::endl; | ||
| 194 | } else { | ||
| 195 | value_started = true; | ||
| 196 | } | ||
| 197 | cur_value << line; | ||
| 198 | } | ||
| 199 | } | ||
| 200 | if (section_started) { | ||
| 201 | handle_end_of_section(); | ||
| 202 | } | ||
| 203 | |||
| 204 | return GodotScene(std::move(ext_resources), std::move(nodes)); | ||
| 205 | } | ||
| 206 | |||
| 207 | } // namespace com::fourisland::lingo2_archipelago | ||
| diff --git a/tools/util/godot_scene.h b/tools/util/godot_scene.h new file mode 100644 index 0000000..17f3f50 --- /dev/null +++ b/tools/util/godot_scene.h | |||
| @@ -0,0 +1,57 @@ | |||
| 1 | #ifndef TOOLS_UTIL_TSCN_H_ | ||
| 2 | #define TOOLS_UTIL_TSCN_H_ | ||
| 3 | |||
| 4 | #include <map> | ||
| 5 | #include <memory> | ||
| 6 | #include <string> | ||
| 7 | #include <utility> | ||
| 8 | #include <variant> | ||
| 9 | #include <vector> | ||
| 10 | |||
| 11 | namespace com::fourisland::lingo2_archipelago { | ||
| 12 | |||
| 13 | struct GodotExtResource { | ||
| 14 | std::string type; | ||
| 15 | std::string path; | ||
| 16 | }; | ||
| 17 | |||
| 18 | struct GodotExtResourceRef { | ||
| 19 | std::string id; | ||
| 20 | }; | ||
| 21 | |||
| 22 | using GodotInstanceType = std::variant<std::monostate, GodotExtResourceRef>; | ||
| 23 | |||
| 24 | struct GodotNode { | ||
| 25 | std::string name; | ||
| 26 | std::string parent; | ||
| 27 | GodotInstanceType instance_type; | ||
| 28 | |||
| 29 | std::string GetPath() const; | ||
| 30 | }; | ||
| 31 | |||
| 32 | class GodotScene { | ||
| 33 | public: | ||
| 34 | GodotScene(std::map<std::string, GodotExtResource> ext_resources, | ||
| 35 | std::vector<GodotNode> nodes) | ||
| 36 | : ext_resources_(std::move(ext_resources)), nodes_(std::move(nodes)) {} | ||
| 37 | |||
| 38 | const GodotExtResource* GetExtResource(const std::string& id) const { | ||
| 39 | auto it = ext_resources_.find(id); | ||
| 40 | if (it != ext_resources_.end()) { | ||
| 41 | return &it->second; | ||
| 42 | } else { | ||
| 43 | return nullptr; | ||
| 44 | } | ||
| 45 | } | ||
| 46 | const std::vector<GodotNode>& GetNodes() const { return nodes_; } | ||
| 47 | |||
| 48 | private: | ||
| 49 | std::map<std::string, GodotExtResource> ext_resources_; | ||
| 50 | std::vector<GodotNode> nodes_; | ||
| 51 | }; | ||
| 52 | |||
| 53 | GodotScene ReadGodotSceneFromFile(const std::string& path); | ||
| 54 | |||
| 55 | } // namespace com::fourisland::lingo2_archipelago | ||
| 56 | |||
| 57 | #endif /* TOOLS_UTIL_TSCN_H_ */ | ||
| diff --git a/tools/util/identifiers.cpp b/tools/util/identifiers.cpp new file mode 100644 index 0000000..5b51c57 --- /dev/null +++ b/tools/util/identifiers.cpp | |||
| @@ -0,0 +1,102 @@ | |||
| 1 | #include "identifiers.h" | ||
| 2 | |||
| 3 | #include <string> | ||
| 4 | |||
| 5 | #include "proto/human.pb.h" | ||
| 6 | |||
| 7 | namespace com::fourisland::lingo2_archipelago { | ||
| 8 | |||
| 9 | std::optional<RoomIdentifier> GetCompleteRoomIdentifier( | ||
| 10 | RoomIdentifier identifier, std::optional<std::string> map_name) { | ||
| 11 | if (!identifier.has_map()) { | ||
| 12 | if (!map_name) { | ||
| 13 | return std::nullopt; | ||
| 14 | } | ||
| 15 | identifier.set_map(*map_name); | ||
| 16 | } | ||
| 17 | return identifier; | ||
| 18 | } | ||
| 19 | |||
| 20 | std::optional<DoorIdentifier> GetCompleteDoorIdentifier( | ||
| 21 | DoorIdentifier identifier, std::optional<std::string> map_name) { | ||
| 22 | if (!identifier.has_map()) { | ||
| 23 | if (!map_name) { | ||
| 24 | return std::nullopt; | ||
| 25 | } | ||
| 26 | identifier.set_map(*map_name); | ||
| 27 | } | ||
| 28 | return identifier; | ||
| 29 | } | ||
| 30 | |||
| 31 | std::optional<PortIdentifier> GetCompletePortIdentifier( | ||
| 32 | PortIdentifier identifier, std::optional<std::string> map_name, | ||
| 33 | std::optional<std::string> room_name) { | ||
| 34 | if (!identifier.has_map()) { | ||
| 35 | if (!map_name) { | ||
| 36 | return std::nullopt; | ||
| 37 | } | ||
| 38 | identifier.set_map(*map_name); | ||
| 39 | } | ||
| 40 | if (!identifier.has_room()) { | ||
| 41 | if (!room_name) { | ||
| 42 | return std::nullopt; | ||
| 43 | } | ||
| 44 | identifier.set_room(*room_name); | ||
| 45 | } | ||
| 46 | return identifier; | ||
| 47 | } | ||
| 48 | |||
| 49 | std::optional<PaintingIdentifier> GetCompletePaintingIdentifier( | ||
| 50 | PaintingIdentifier identifier, std::optional<std::string> map_name, | ||
| 51 | std::optional<std::string> room_name) { | ||
| 52 | if (!identifier.has_map()) { | ||
| 53 | if (!map_name) { | ||
| 54 | return std::nullopt; | ||
| 55 | } | ||
| 56 | identifier.set_map(*map_name); | ||
| 57 | } | ||
| 58 | if (!identifier.has_room()) { | ||
| 59 | if (!room_name) { | ||
| 60 | return std::nullopt; | ||
| 61 | } | ||
| 62 | identifier.set_room(*room_name); | ||
| 63 | } | ||
| 64 | return identifier; | ||
| 65 | } | ||
| 66 | |||
| 67 | std::optional<PanelIdentifier> GetCompletePanelIdentifierWithoutAnswer( | ||
| 68 | PanelIdentifier identifier, std::optional<std::string> map_name, | ||
| 69 | std::optional<std::string> room_name) { | ||
| 70 | if (!identifier.has_map()) { | ||
| 71 | if (!map_name) { | ||
| 72 | return std::nullopt; | ||
| 73 | } | ||
| 74 | identifier.set_map(*map_name); | ||
| 75 | } | ||
| 76 | if (!identifier.has_room()) { | ||
| 77 | if (!room_name) { | ||
| 78 | return std::nullopt; | ||
| 79 | } | ||
| 80 | identifier.set_room(*room_name); | ||
| 81 | } | ||
| 82 | identifier.clear_answer(); | ||
| 83 | return identifier; | ||
| 84 | } | ||
| 85 | |||
| 86 | std::optional<KeyholderIdentifier> GetCompleteKeyholderIdentifierWithoutKey( | ||
| 87 | KeyholderIdentifier identifier, const std::string& map_name, | ||
| 88 | std::optional<std::string> room_name) { | ||
| 89 | if (!identifier.has_map()) { | ||
| 90 | identifier.set_map(map_name); | ||
| 91 | } | ||
| 92 | if (!identifier.has_room()) { | ||
| 93 | if (!room_name) { | ||
| 94 | return std::nullopt; | ||
| 95 | } | ||
| 96 | identifier.set_room(*room_name); | ||
| 97 | } | ||
| 98 | identifier.clear_key(); | ||
| 99 | return identifier; | ||
| 100 | } | ||
| 101 | |||
| 102 | } // namespace com::fourisland::lingo2_archipelago | ||
| diff --git a/tools/util/identifiers.h b/tools/util/identifiers.h new file mode 100644 index 0000000..341dee1 --- /dev/null +++ b/tools/util/identifiers.h | |||
| @@ -0,0 +1,85 @@ | |||
| 1 | #ifndef TOOLS_UTIL_IDENTIFIERS_H_ | ||
| 2 | #define TOOLS_UTIL_IDENTIFIERS_H_ | ||
| 3 | |||
| 4 | #include <optional> | ||
| 5 | #include <string> | ||
| 6 | #include <utility> | ||
| 7 | |||
| 8 | #include "proto/human.pb.h" | ||
| 9 | |||
| 10 | namespace com::fourisland::lingo2_archipelago { | ||
| 11 | |||
| 12 | class RoomIdentifierLess { | ||
| 13 | public: | ||
| 14 | bool operator()(const RoomIdentifier& lhs, const RoomIdentifier& rhs) const { | ||
| 15 | return std::tie(lhs.map(), lhs.name()) < std::tie(rhs.map(), rhs.name()); | ||
| 16 | } | ||
| 17 | }; | ||
| 18 | |||
| 19 | class DoorIdentifierLess { | ||
| 20 | public: | ||
| 21 | bool operator()(const DoorIdentifier& lhs, const DoorIdentifier& rhs) const { | ||
| 22 | return std::tie(lhs.map(), lhs.name()) < std::tie(rhs.map(), rhs.name()); | ||
| 23 | } | ||
| 24 | }; | ||
| 25 | |||
| 26 | class PortIdentifierLess { | ||
| 27 | public: | ||
| 28 | bool operator()(const PortIdentifier& lhs, const PortIdentifier& rhs) const { | ||
| 29 | return std::tie(lhs.map(), lhs.room(), lhs.name()) < | ||
| 30 | std::tie(rhs.map(), rhs.room(), rhs.name()); | ||
| 31 | } | ||
| 32 | }; | ||
| 33 | |||
| 34 | class PaintingIdentifierLess { | ||
| 35 | public: | ||
| 36 | bool operator()(const PaintingIdentifier& lhs, | ||
| 37 | const PaintingIdentifier& rhs) const { | ||
| 38 | return std::tie(lhs.map(), lhs.room(), lhs.name()) < | ||
| 39 | std::tie(rhs.map(), rhs.room(), rhs.name()); | ||
| 40 | } | ||
| 41 | }; | ||
| 42 | |||
| 43 | class PanelIdentifierLess { | ||
| 44 | public: | ||
| 45 | bool operator()(const PanelIdentifier& lhs, | ||
| 46 | const PanelIdentifier& rhs) const { | ||
| 47 | return std::tie(lhs.map(), lhs.room(), lhs.name(), lhs.answer()) < | ||
| 48 | std::tie(rhs.map(), rhs.room(), rhs.name(), rhs.answer()); | ||
| 49 | } | ||
| 50 | }; | ||
| 51 | |||
| 52 | class KeyholderIdentifierLess { | ||
| 53 | public: | ||
| 54 | bool operator()(const KeyholderIdentifier& lhs, | ||
| 55 | const KeyholderIdentifier& rhs) const { | ||
| 56 | return std::tie(lhs.map(), lhs.room(), lhs.name(), lhs.key()) < | ||
| 57 | std::tie(rhs.map(), rhs.room(), rhs.name(), rhs.key()); | ||
| 58 | } | ||
| 59 | }; | ||
| 60 | |||
| 61 | std::optional<RoomIdentifier> GetCompleteRoomIdentifier( | ||
| 62 | RoomIdentifier identifier, std::optional<std::string> map_name); | ||
| 63 | |||
| 64 | std::optional<DoorIdentifier> GetCompleteDoorIdentifier( | ||
| 65 | DoorIdentifier identifier, std::optional<std::string> map_name); | ||
| 66 | |||
| 67 | std::optional<PortIdentifier> GetCompletePortIdentifier( | ||
| 68 | PortIdentifier identifier, std::optional<std::string> map_name, | ||
| 69 | std::optional<std::string> room_name); | ||
| 70 | |||
| 71 | std::optional<PaintingIdentifier> GetCompletePaintingIdentifier( | ||
| 72 | PaintingIdentifier identifier, std::optional<std::string> map_name, | ||
| 73 | std::optional<std::string> room_name); | ||
| 74 | |||
| 75 | std::optional<PanelIdentifier> GetCompletePanelIdentifierWithoutAnswer( | ||
| 76 | PanelIdentifier identifier, std::optional<std::string> map_name, | ||
| 77 | std::optional<std::string> room_name); | ||
| 78 | |||
| 79 | std::optional<KeyholderIdentifier> GetCompleteKeyholderIdentifierWithoutKey( | ||
| 80 | KeyholderIdentifier identifier, const std::string& map_name, | ||
| 81 | std::optional<std::string> room_name); | ||
| 82 | |||
| 83 | } // namespace com::fourisland::lingo2_archipelago | ||
| 84 | |||
| 85 | #endif /* TOOLS_UTIL_IDENTIFIERS_H_ */ | ||
| diff --git a/tools/util/ids_yaml_format.cpp b/tools/util/ids_yaml_format.cpp new file mode 100644 index 0000000..5b9113b --- /dev/null +++ b/tools/util/ids_yaml_format.cpp | |||
| @@ -0,0 +1,203 @@ | |||
| 1 | #include "ids_yaml_format.h" | ||
| 2 | |||
| 3 | #include <yaml-cpp/yaml.h> | ||
| 4 | |||
| 5 | #include <fstream> | ||
| 6 | #include <functional> | ||
| 7 | |||
| 8 | namespace com::fourisland::lingo2_archipelago { | ||
| 9 | namespace { | ||
| 10 | |||
| 11 | template <typename T> | ||
| 12 | void OperateOnSortedMap( | ||
| 13 | const T& map, std::function<void(const std::string& name, | ||
| 14 | const typename T::mapped_type& value)> | ||
| 15 | callback) { | ||
| 16 | std::vector<std::string> names; | ||
| 17 | for (const auto& it : map) { | ||
| 18 | names.push_back(it.first); | ||
| 19 | } | ||
| 20 | |||
| 21 | std::sort(names.begin(), names.end()); | ||
| 22 | |||
| 23 | for (const std::string& name : names) { | ||
| 24 | callback(name, map.at(name)); | ||
| 25 | } | ||
| 26 | } | ||
| 27 | |||
| 28 | } // namespace | ||
| 29 | |||
| 30 | IdMappings ReadIdsFromYaml(const std::string& filename) { | ||
| 31 | IdMappings result; | ||
| 32 | |||
| 33 | YAML::Node document = YAML::LoadFile(filename); | ||
| 34 | |||
| 35 | if (document["maps"]) { | ||
| 36 | for (const auto& map_it : document["maps"]) { | ||
| 37 | IdMappings::MapIds& map_ids = | ||
| 38 | (*result.mutable_maps())[map_it.first.as<std::string>()]; | ||
| 39 | |||
| 40 | if (map_it.second["rooms"]) { | ||
| 41 | for (const auto& room_it : map_it.second["rooms"]) { | ||
| 42 | IdMappings::RoomIds& room_ids = | ||
| 43 | (*map_ids.mutable_rooms())[room_it.first.as<std::string>()]; | ||
| 44 | |||
| 45 | if (room_it.second["panels"]) { | ||
| 46 | for (const auto& panel_it : room_it.second["panels"]) { | ||
| 47 | (*room_ids.mutable_panels())[panel_it.first.as<std::string>()] = | ||
| 48 | panel_it.second.as<uint64_t>(); | ||
| 49 | } | ||
| 50 | } | ||
| 51 | |||
| 52 | if (room_it.second["masteries"]) { | ||
| 53 | for (const auto& mastery_it : room_it.second["masteries"]) { | ||
| 54 | (*room_ids | ||
| 55 | .mutable_masteries())[mastery_it.first.as<std::string>()] = | ||
| 56 | mastery_it.second.as<uint64_t>(); | ||
| 57 | } | ||
| 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 | } | ||
| 74 | } | ||
| 75 | } | ||
| 76 | |||
| 77 | if (map_it.second["doors"]) { | ||
| 78 | for (const auto& door_it : map_it.second["doors"]) { | ||
| 79 | (*map_ids.mutable_doors())[door_it.first.as<std::string>()] = | ||
| 80 | door_it.second.as<uint64_t>(); | ||
| 81 | } | ||
| 82 | } | ||
| 83 | } | ||
| 84 | } | ||
| 85 | |||
| 86 | if (document["letters"]) { | ||
| 87 | for (const auto& letter_it : document["letters"]) { | ||
| 88 | (*result.mutable_letters())[letter_it.first.as<std::string>()] = | ||
| 89 | letter_it.second.as<uint64_t>(); | ||
| 90 | } | ||
| 91 | } | ||
| 92 | |||
| 93 | if (document["endings"]) { | ||
| 94 | for (const auto& ending_it : document["endings"]) { | ||
| 95 | (*result.mutable_endings())[ending_it.first.as<std::string>()] = | ||
| 96 | ending_it.second.as<uint64_t>(); | ||
| 97 | } | ||
| 98 | } | ||
| 99 | |||
| 100 | if (document["special"]) { | ||
| 101 | for (const auto& special_it : document["special"]) { | ||
| 102 | (*result.mutable_special())[special_it.first.as<std::string>()] = | ||
| 103 | special_it.second.as<uint64_t>(); | ||
| 104 | } | ||
| 105 | } | ||
| 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 | |||
| 121 | return result; | ||
| 122 | } | ||
| 123 | |||
| 124 | void WriteIdsAsYaml(const IdMappings& ids, const std::string& filename) { | ||
| 125 | YAML::Node result; | ||
| 126 | |||
| 127 | OperateOnSortedMap(ids.maps(), [&result](const std::string& map_name, | ||
| 128 | const IdMappings::MapIds& map_ids) { | ||
| 129 | YAML::Node map_node; | ||
| 130 | |||
| 131 | OperateOnSortedMap( | ||
| 132 | map_ids.rooms(), [&map_node](const std::string& room_name, | ||
| 133 | const IdMappings::RoomIds& room_ids) { | ||
| 134 | YAML::Node room_node; | ||
| 135 | |||
| 136 | OperateOnSortedMap( | ||
| 137 | room_ids.panels(), | ||
| 138 | [&room_node](const std::string& panel_name, uint64_t panel_id) { | ||
| 139 | room_node["panels"][panel_name] = panel_id; | ||
| 140 | }); | ||
| 141 | |||
| 142 | OperateOnSortedMap(room_ids.masteries(), | ||
| 143 | [&room_node](const std::string& mastery_name, | ||
| 144 | uint64_t mastery_id) { | ||
| 145 | room_node["masteries"][mastery_name] = | ||
| 146 | mastery_id; | ||
| 147 | }); | ||
| 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 | |||
| 162 | map_node["rooms"][room_name] = std::move(room_node); | ||
| 163 | }); | ||
| 164 | |||
| 165 | OperateOnSortedMap( | ||
| 166 | map_ids.doors(), | ||
| 167 | [&map_node](const std::string& door_name, uint64_t door_id) { | ||
| 168 | map_node["doors"][door_name] = door_id; | ||
| 169 | }); | ||
| 170 | |||
| 171 | result["maps"][map_name] = std::move(map_node); | ||
| 172 | }); | ||
| 173 | |||
| 174 | OperateOnSortedMap(ids.letters(), [&result](const std::string& letter_name, | ||
| 175 | uint64_t letter_id) { | ||
| 176 | result["letters"][letter_name] = letter_id; | ||
| 177 | }); | ||
| 178 | |||
| 179 | OperateOnSortedMap(ids.endings(), [&result](const std::string& ending_name, | ||
| 180 | uint64_t ending_id) { | ||
| 181 | result["endings"][ending_name] = ending_id; | ||
| 182 | }); | ||
| 183 | |||
| 184 | OperateOnSortedMap(ids.special(), [&result](const std::string& special_name, | ||
| 185 | uint64_t special_id) { | ||
| 186 | result["special"][special_name] = special_id; | ||
| 187 | }); | ||
| 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 | |||
| 199 | std::ofstream output_stream(filename); | ||
| 200 | output_stream << result << std::endl; | ||
| 201 | } | ||
| 202 | |||
| 203 | } // namespace com::fourisland::lingo2_archipelago | ||
| diff --git a/tools/util/ids_yaml_format.h b/tools/util/ids_yaml_format.h new file mode 100644 index 0000000..d926369 --- /dev/null +++ b/tools/util/ids_yaml_format.h | |||
| @@ -0,0 +1,16 @@ | |||
| 1 | #ifndef TOOLS_UTIL_IDS_YAML_FORMAT_H_ | ||
| 2 | #define TOOLS_UTIL_IDS_YAML_FORMAT_H_ | ||
| 3 | |||
| 4 | #include <string> | ||
| 5 | |||
| 6 | #include "proto/human.pb.h" | ||
| 7 | |||
| 8 | namespace com::fourisland::lingo2_archipelago { | ||
| 9 | |||
| 10 | IdMappings ReadIdsFromYaml(const std::string& filename); | ||
| 11 | |||
| 12 | void WriteIdsAsYaml(const IdMappings& ids, const std::string& filename); | ||
| 13 | |||
| 14 | } // namespace com::fourisland::lingo2_archipelago | ||
| 15 | |||
| 16 | #endif /* TOOLS_UTIL_IDS_YAML_FORMAT_H_ */ | ||
| diff --git a/tools/util/naming.cpp b/tools/util/naming.cpp index 12594c5..8229c6d 100644 --- a/tools/util/naming.cpp +++ b/tools/util/naming.cpp | |||
| @@ -2,10 +2,14 @@ | |||
| 2 | 2 | ||
| 3 | #include <sstream> | 3 | #include <sstream> |
| 4 | 4 | ||
| 5 | std::string GetLetterName(std::string key, bool double_) { | 5 | namespace com::fourisland::lingo2_archipelago { |
| 6 | |||
| 7 | std::string GetLetterName(std::string key, bool level2) { | ||
| 6 | std::ostringstream lettername_s; | 8 | std::ostringstream lettername_s; |
| 7 | lettername_s << key; | 9 | lettername_s << key; |
| 8 | lettername_s << (double_ ? "2" : "1"); | 10 | lettername_s << (level2 ? "2" : "1"); |
| 9 | 11 | ||
| 10 | return lettername_s.str(); | 12 | return lettername_s.str(); |
| 11 | } | 13 | } |
| 14 | |||
| 15 | } // namespace com::fourisland::lingo2_archipelago | ||
| diff --git a/tools/util/naming.h b/tools/util/naming.h index 7d61309..85e2db0 100644 --- a/tools/util/naming.h +++ b/tools/util/naming.h | |||
| @@ -3,6 +3,10 @@ | |||
| 3 | 3 | ||
| 4 | #include <string> | 4 | #include <string> |
| 5 | 5 | ||
| 6 | std::string GetLetterName(std::string key, bool double_); | 6 | namespace com::fourisland::lingo2_archipelago { |
| 7 | |||
| 8 | std::string GetLetterName(std::string key, bool level2); | ||
| 9 | |||
| 10 | } // namespace com::fourisland::lingo2_archipelago | ||
| 7 | 11 | ||
| 8 | #endif /* TOOLS_UTIL_NAMING_H_ */ | 12 | #endif /* TOOLS_UTIL_NAMING_H_ */ |
| diff --git a/tools/validator/CMakeLists.txt b/tools/validator/CMakeLists.txt new file mode 100644 index 0000000..1a8fd9c --- /dev/null +++ b/tools/validator/CMakeLists.txt | |||
| @@ -0,0 +1,13 @@ | |||
| 1 | find_package(fmt REQUIRED) | ||
| 2 | find_package(Protobuf REQUIRED) | ||
| 3 | |||
| 4 | add_executable(validator | ||
| 5 | godot_processor.cpp | ||
| 6 | human_processor.cpp | ||
| 7 | main.cpp | ||
| 8 | validator.cpp | ||
| 9 | ) | ||
| 10 | set_property(TARGET validator PROPERTY CXX_STANDARD 20) | ||
| 11 | set_property(TARGET validator PROPERTY CXX_STANDARD_REQUIRED ON) | ||
| 12 | target_include_directories(validator PUBLIC ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR}/tools) | ||
| 13 | target_link_libraries(validator PUBLIC protos util fmt::fmt protobuf::libprotobuf) | ||
| diff --git a/tools/validator/godot_processor.cpp b/tools/validator/godot_processor.cpp new file mode 100644 index 0000000..ad2be78 --- /dev/null +++ b/tools/validator/godot_processor.cpp | |||
| @@ -0,0 +1,72 @@ | |||
| 1 | #include "godot_processor.h" | ||
| 2 | |||
| 3 | #include <filesystem> | ||
| 4 | #include <iostream> | ||
| 5 | #include <memory> | ||
| 6 | #include <set> | ||
| 7 | |||
| 8 | #include "structs.h" | ||
| 9 | #include "util/godot_scene.h" | ||
| 10 | |||
| 11 | namespace com::fourisland::lingo2_archipelago { | ||
| 12 | |||
| 13 | namespace { | ||
| 14 | |||
| 15 | static const std::set<std::string> kImportantNodeTypes = { | ||
| 16 | "res://objects/nodes/panel.tscn", "res://objects/nodes/worldport.tscn", | ||
| 17 | "res://objects/nodes/keyHolder.tscn", | ||
| 18 | "res://objects/nodes/collectable.tscn"}; | ||
| 19 | |||
| 20 | class GodotProcessor { | ||
| 21 | public: | ||
| 22 | GodotProcessor(const std::string& repodir, CollectedInfo& info) | ||
| 23 | : repodir_(repodir), info_(info) {} | ||
| 24 | |||
| 25 | void Run() { | ||
| 26 | for (auto& [map_name, map_info] : info_.maps) { | ||
| 27 | ProcessMap(map_name, map_info); | ||
| 28 | } | ||
| 29 | } | ||
| 30 | |||
| 31 | void ProcessMap(const std::string& map_name, MapInfo& map_info) { | ||
| 32 | std::filesystem::path scene_path = std::filesystem::path(repodir_) / | ||
| 33 | "objects" / "scenes" / | ||
| 34 | (map_name + ".tscn"); | ||
| 35 | std::string scene_path_str = scene_path.string(); | ||
| 36 | std::cout << "Processing " << scene_path_str << std::endl; | ||
| 37 | |||
| 38 | GodotScene scene = ReadGodotSceneFromFile(scene_path_str); | ||
| 39 | for (const GodotNode& node : scene.GetNodes()) { | ||
| 40 | ProcessMapNode(scene, node, map_info); | ||
| 41 | } | ||
| 42 | } | ||
| 43 | |||
| 44 | void ProcessMapNode(const GodotScene& scene, const GodotNode& node, | ||
| 45 | MapInfo& map_info) { | ||
| 46 | if (std::holds_alternative<GodotExtResourceRef>(node.instance_type)) { | ||
| 47 | const GodotExtResourceRef& ext_resource_ref = | ||
| 48 | std::get<GodotExtResourceRef>(node.instance_type); | ||
| 49 | const GodotExtResource* ext_resource = | ||
| 50 | scene.GetExtResource(ext_resource_ref.id); | ||
| 51 | |||
| 52 | if (ext_resource != nullptr && | ||
| 53 | (kImportantNodeTypes.count(ext_resource->path) || | ||
| 54 | ext_resource->path.starts_with("res://objects/meshes/paintings/"))) { | ||
| 55 | map_info.game_nodes[node.GetPath()].defined = true; | ||
| 56 | } | ||
| 57 | } | ||
| 58 | } | ||
| 59 | |||
| 60 | private: | ||
| 61 | std::string repodir_; | ||
| 62 | CollectedInfo& info_; | ||
| 63 | }; | ||
| 64 | |||
| 65 | } // namespace | ||
| 66 | |||
| 67 | void ProcessGodotData(const std::string& repodir, CollectedInfo& info) { | ||
| 68 | GodotProcessor godot_processor(repodir, info); | ||
| 69 | godot_processor.Run(); | ||
| 70 | } | ||
| 71 | |||
| 72 | } // namespace com::fourisland::lingo2_archipelago | ||
| diff --git a/tools/validator/godot_processor.h b/tools/validator/godot_processor.h new file mode 100644 index 0000000..97bcea6 --- /dev/null +++ b/tools/validator/godot_processor.h | |||
| @@ -0,0 +1,14 @@ | |||
| 1 | #ifndef TOOLS_VALIDATOR_GODOT_PROCESSOR_H_ | ||
| 2 | #define TOOLS_VALIDATOR_GODOT_PROCESSOR_H_ | ||
| 3 | |||
| 4 | #include <string> | ||
| 5 | |||
| 6 | namespace com::fourisland::lingo2_archipelago { | ||
| 7 | |||
| 8 | struct CollectedInfo; | ||
| 9 | |||
| 10 | void ProcessGodotData(const std::string& repodir, CollectedInfo& info); | ||
| 11 | |||
| 12 | } // namespace com::fourisland::lingo2_archipelago | ||
| 13 | |||
| 14 | #endif /* TOOLS_VALIDATOR_GODOT_PROCESSOR_H_ */ | ||
| diff --git a/tools/validator/human_processor.cpp b/tools/validator/human_processor.cpp new file mode 100644 index 0000000..ffa9765 --- /dev/null +++ b/tools/validator/human_processor.cpp | |||
| @@ -0,0 +1,660 @@ | |||
| 1 | #include "human_processor.h" | ||
| 2 | |||
| 3 | #include <fmt/core.h> | ||
| 4 | #include <google/protobuf/message.h> | ||
| 5 | #include <google/protobuf/text_format.h> | ||
| 6 | |||
| 7 | #include <filesystem> | ||
| 8 | #include <fstream> | ||
| 9 | #include <iostream> | ||
| 10 | #include <map> | ||
| 11 | #include <optional> | ||
| 12 | #include <sstream> | ||
| 13 | #include <string> | ||
| 14 | |||
| 15 | #include "structs.h" | ||
| 16 | #include "util/ids_yaml_format.h" | ||
| 17 | |||
| 18 | namespace com::fourisland::lingo2_archipelago { | ||
| 19 | namespace { | ||
| 20 | |||
| 21 | template <typename T> | ||
| 22 | T ReadMessageFromFile(const std::string& path) { | ||
| 23 | std::cout << "Processing " << path << std::endl; | ||
| 24 | |||
| 25 | std::ifstream file(path); | ||
| 26 | std::stringstream buffer; | ||
| 27 | buffer << file.rdbuf(); | ||
| 28 | |||
| 29 | T message; | ||
| 30 | google::protobuf::TextFormat::ParseFromString(buffer.str(), &message); | ||
| 31 | |||
| 32 | return message; | ||
| 33 | } | ||
| 34 | |||
| 35 | class HumanProcessor { | ||
| 36 | public: | ||
| 37 | HumanProcessor(const std::string& mapdir, CollectedInfo& info) | ||
| 38 | : mapdir_(mapdir), info_(info) {} | ||
| 39 | |||
| 40 | void Run() { | ||
| 41 | std::filesystem::path datadir_path = mapdir_; | ||
| 42 | |||
| 43 | ProcessConnectionsFile(datadir_path / "connections.txtpb", std::nullopt); | ||
| 44 | ProcessMaps(datadir_path); | ||
| 45 | ProcessProgressivesFile(datadir_path / "progressives.txtpb"); | ||
| 46 | ProcessDoorGroupsFile(datadir_path / "door_groups.txtpb"); | ||
| 47 | ProcessIdsFile(datadir_path / "ids.yaml"); | ||
| 48 | } | ||
| 49 | |||
| 50 | private: | ||
| 51 | void ProcessMaps(std::filesystem::path path) { | ||
| 52 | std::filesystem::path maps_dir = path / "maps"; | ||
| 53 | for (auto const& dir_entry : | ||
| 54 | std::filesystem::directory_iterator(maps_dir)) { | ||
| 55 | ProcessMap(dir_entry.path()); | ||
| 56 | } | ||
| 57 | } | ||
| 58 | |||
| 59 | void ProcessMap(std::filesystem::path path) { | ||
| 60 | std::string map_name = path.filename().string(); | ||
| 61 | |||
| 62 | ProcessMetadataFile(path / "metadata.txtpb", map_name); | ||
| 63 | ProcessConnectionsFile(path / "connections.txtpb", map_name); | ||
| 64 | ProcessDoorsFile(path / "doors.txtpb", map_name); | ||
| 65 | ProcessRooms(path / "rooms", map_name); | ||
| 66 | } | ||
| 67 | |||
| 68 | void ProcessMetadataFile(std::filesystem::path path, | ||
| 69 | const std::string& current_map_name) { | ||
| 70 | if (!std::filesystem::exists(path)) { | ||
| 71 | return; | ||
| 72 | } | ||
| 73 | |||
| 74 | MapInfo& map_info = info_.maps[current_map_name]; | ||
| 75 | |||
| 76 | auto metadata = ReadMessageFromFile<HumanMap>(path.string()); | ||
| 77 | for (const std::string& path : metadata.excluded_nodes()) { | ||
| 78 | map_info.game_nodes[path].uses++; | ||
| 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 | } | ||
| 95 | } | ||
| 96 | |||
| 97 | void ProcessRooms(std::filesystem::path path, | ||
| 98 | const std::string& current_map_name) { | ||
| 99 | for (auto const& dir_entry : std::filesystem::directory_iterator(path)) { | ||
| 100 | auto room = ReadMessageFromFile<HumanRoom>(dir_entry.path().string()); | ||
| 101 | ProcessRoom(room, current_map_name); | ||
| 102 | } | ||
| 103 | } | ||
| 104 | |||
| 105 | void ProcessRoom(const HumanRoom& h_room, | ||
| 106 | const std::string& current_map_name) { | ||
| 107 | RoomIdentifier room_identifier; | ||
| 108 | room_identifier.set_map(current_map_name); | ||
| 109 | room_identifier.set_name(h_room.name()); | ||
| 110 | |||
| 111 | RoomInfo& room_info = info_.rooms[room_identifier]; | ||
| 112 | room_info.definitions.push_back(h_room); | ||
| 113 | |||
| 114 | for (const HumanPanel& h_panel : h_room.panels()) { | ||
| 115 | ProcessPanel(h_panel, current_map_name, h_room); | ||
| 116 | } | ||
| 117 | |||
| 118 | for (const HumanPainting& h_painting : h_room.paintings()) { | ||
| 119 | ProcessPainting(h_painting, current_map_name, h_room.name()); | ||
| 120 | } | ||
| 121 | |||
| 122 | for (const HumanPort& h_port : h_room.ports()) { | ||
| 123 | ProcessPort(h_port, current_map_name, h_room.name()); | ||
| 124 | } | ||
| 125 | |||
| 126 | for (const HumanLetter& h_letter : h_room.letters()) { | ||
| 127 | ProcessLetter(h_letter, current_map_name, h_room.name()); | ||
| 128 | } | ||
| 129 | |||
| 130 | for (const HumanMastery& h_mastery : h_room.masteries()) { | ||
| 131 | ProcessMastery(h_mastery, current_map_name, h_room.name()); | ||
| 132 | } | ||
| 133 | |||
| 134 | for (const HumanKeyholder& h_keyholder : h_room.keyholders()) { | ||
| 135 | ProcessKeyholder(h_keyholder, current_map_name, h_room.name()); | ||
| 136 | } | ||
| 137 | |||
| 138 | for (const HumanEnding& h_ending : h_room.endings()) { | ||
| 139 | ProcessEnding(h_ending, current_map_name, h_room.name()); | ||
| 140 | } | ||
| 141 | } | ||
| 142 | |||
| 143 | void ProcessPanel(const HumanPanel& h_panel, | ||
| 144 | const std::string& current_map_name, | ||
| 145 | const HumanRoom& h_room) { | ||
| 146 | PanelIdentifier panel_identifier; | ||
| 147 | panel_identifier.set_map(current_map_name); | ||
| 148 | panel_identifier.set_room(h_room.name()); | ||
| 149 | panel_identifier.set_name(h_panel.name()); | ||
| 150 | |||
| 151 | PanelInfo& panel_info = info_.panels[panel_identifier]; | ||
| 152 | panel_info.definitions.push_back(h_panel); | ||
| 153 | |||
| 154 | MapInfo& map_info = info_.maps[current_map_name]; | ||
| 155 | map_info.game_nodes[h_panel.path()].uses++; | ||
| 156 | |||
| 157 | for (const Proxy& h_proxy : h_panel.proxies()) { | ||
| 158 | ProxyInfo& proxy_info = panel_info.proxies[h_proxy.answer()]; | ||
| 159 | proxy_info.definitions.push_back(h_proxy); | ||
| 160 | |||
| 161 | map_info.game_nodes[h_proxy.path()].uses++; | ||
| 162 | } | ||
| 163 | |||
| 164 | if (h_panel.has_required_door()) { | ||
| 165 | DoorIdentifier required_door_identifier = | ||
| 166 | *GetCompleteDoorIdentifier(h_panel.required_door(), current_map_name); | ||
| 167 | DoorInfo& required_door_info = info_.doors[required_door_identifier]; | ||
| 168 | required_door_info.panels_referenced_by.push_back(panel_identifier); | ||
| 169 | } | ||
| 170 | |||
| 171 | if (h_panel.has_required_room()) { | ||
| 172 | RoomIdentifier required_room_identifier = | ||
| 173 | *GetCompleteRoomIdentifier(h_panel.required_room(), current_map_name); | ||
| 174 | RoomInfo& required_room_info = info_.rooms[required_room_identifier]; | ||
| 175 | required_room_info.panels_referenced_by.push_back(panel_identifier); | ||
| 176 | } | ||
| 177 | |||
| 178 | std::string map_area_name = current_map_name; | ||
| 179 | if (h_room.has_panel_display_name()) { | ||
| 180 | map_area_name = | ||
| 181 | fmt::format("{} ({})", current_map_name, h_room.panel_display_name()); | ||
| 182 | } | ||
| 183 | |||
| 184 | panel_info.map_area_name = map_area_name; | ||
| 185 | |||
| 186 | std::string panelsanity_name; | ||
| 187 | if (h_panel.has_display_name()) { | ||
| 188 | panelsanity_name = | ||
| 189 | fmt::format("{} - {}", map_area_name, h_panel.display_name()); | ||
| 190 | } else { | ||
| 191 | panelsanity_name = fmt::format("{} - {}", map_area_name, h_panel.name()); | ||
| 192 | } | ||
| 193 | info_.panel_names[panelsanity_name].panels_used_by.push_back( | ||
| 194 | panel_identifier); | ||
| 195 | } | ||
| 196 | |||
| 197 | void ProcessPainting(const HumanPainting& h_painting, | ||
| 198 | const std::string& current_map_name, | ||
| 199 | const std::string& current_room_name) { | ||
| 200 | PaintingIdentifier painting_identifier; | ||
| 201 | painting_identifier.set_map(current_map_name); | ||
| 202 | painting_identifier.set_room(current_room_name); | ||
| 203 | painting_identifier.set_name(h_painting.name()); | ||
| 204 | |||
| 205 | PaintingInfo& painting_info = info_.paintings[painting_identifier]; | ||
| 206 | painting_info.definitions.push_back(h_painting); | ||
| 207 | |||
| 208 | MapInfo& map_info = info_.maps[current_map_name]; | ||
| 209 | map_info.game_nodes[h_painting.path()].uses++; | ||
| 210 | |||
| 211 | if (h_painting.has_required_door()) { | ||
| 212 | DoorIdentifier required_door_identifier = *GetCompleteDoorIdentifier( | ||
| 213 | h_painting.required_door(), current_map_name); | ||
| 214 | DoorInfo& required_door_info = info_.doors[required_door_identifier]; | ||
| 215 | required_door_info.paintings_referenced_by.push_back(painting_identifier); | ||
| 216 | } | ||
| 217 | } | ||
| 218 | |||
| 219 | void ProcessPort(const HumanPort& h_port, const std::string& current_map_name, | ||
| 220 | const std::string& current_room_name) { | ||
| 221 | PortIdentifier port_identifier; | ||
| 222 | port_identifier.set_map(current_map_name); | ||
| 223 | port_identifier.set_room(current_room_name); | ||
| 224 | port_identifier.set_name(h_port.name()); | ||
| 225 | |||
| 226 | PortInfo& port_info = info_.ports[port_identifier]; | ||
| 227 | port_info.definitions.push_back(h_port); | ||
| 228 | |||
| 229 | MapInfo& map_info = info_.maps[current_map_name]; | ||
| 230 | map_info.game_nodes[h_port.path()].uses++; | ||
| 231 | |||
| 232 | if (h_port.has_required_door()) { | ||
| 233 | DoorIdentifier required_door_identifier = | ||
| 234 | *GetCompleteDoorIdentifier(h_port.required_door(), current_map_name); | ||
| 235 | DoorInfo& required_door_info = info_.doors[required_door_identifier]; | ||
| 236 | required_door_info.ports_referenced_by.push_back(port_identifier); | ||
| 237 | } | ||
| 238 | } | ||
| 239 | |||
| 240 | void ProcessLetter(const HumanLetter& h_letter, | ||
| 241 | const std::string& current_map_name, | ||
| 242 | const std::string& current_room_name) { | ||
| 243 | LetterIdentifier letter_identifier = | ||
| 244 | std::make_tuple(h_letter.key()[0], h_letter.level2()); | ||
| 245 | LetterInfo& letter_info = info_.letters[letter_identifier]; | ||
| 246 | |||
| 247 | RoomIdentifier room_identifier; | ||
| 248 | room_identifier.set_map(current_map_name); | ||
| 249 | room_identifier.set_name(current_room_name); | ||
| 250 | letter_info.defined_in.push_back(room_identifier); | ||
| 251 | |||
| 252 | MapInfo& map_info = info_.maps[current_map_name]; | ||
| 253 | map_info.game_nodes[h_letter.path()].uses++; | ||
| 254 | } | ||
| 255 | |||
| 256 | void ProcessMastery(const HumanMastery& h_mastery, | ||
| 257 | const std::string& current_map_name, | ||
| 258 | const std::string& current_room_name) { | ||
| 259 | MapInfo& map_info = info_.maps[current_map_name]; | ||
| 260 | map_info.game_nodes[h_mastery.path()].uses++; | ||
| 261 | } | ||
| 262 | |||
| 263 | void ProcessKeyholder(const HumanKeyholder& h_keyholder, | ||
| 264 | const std::string& current_map_name, | ||
| 265 | const std::string& current_room_name) { | ||
| 266 | KeyholderIdentifier keyholder_identifier; | ||
| 267 | keyholder_identifier.set_map(current_map_name); | ||
| 268 | keyholder_identifier.set_room(current_room_name); | ||
| 269 | keyholder_identifier.set_name(h_keyholder.name()); | ||
| 270 | |||
| 271 | KeyholderInfo& keyholder_info = info_.keyholders[keyholder_identifier]; | ||
| 272 | keyholder_info.definitions.push_back(h_keyholder); | ||
| 273 | |||
| 274 | MapInfo& map_info = info_.maps[current_map_name]; | ||
| 275 | map_info.game_nodes[h_keyholder.path()].uses++; | ||
| 276 | } | ||
| 277 | |||
| 278 | void ProcessEnding(const HumanEnding& h_ending, | ||
| 279 | const std::string& current_map_name, | ||
| 280 | const std::string& current_room_name) { | ||
| 281 | EndingInfo& ending_info = info_.endings[h_ending.name()]; | ||
| 282 | |||
| 283 | RoomIdentifier room_identifier; | ||
| 284 | room_identifier.set_map(current_map_name); | ||
| 285 | room_identifier.set_name(current_room_name); | ||
| 286 | ending_info.defined_in.push_back(room_identifier); | ||
| 287 | |||
| 288 | MapInfo& map_info = info_.maps[current_map_name]; | ||
| 289 | map_info.game_nodes[h_ending.path()].uses++; | ||
| 290 | } | ||
| 291 | |||
| 292 | void ProcessDoorsFile(std::filesystem::path path, | ||
| 293 | const std::string& current_map_name) { | ||
| 294 | if (!std::filesystem::exists(path)) { | ||
| 295 | return; | ||
| 296 | } | ||
| 297 | |||
| 298 | auto doors = ReadMessageFromFile<HumanDoors>(path.string()); | ||
| 299 | |||
| 300 | for (const HumanDoor& door : doors.doors()) { | ||
| 301 | ProcessDoor(door, current_map_name); | ||
| 302 | } | ||
| 303 | } | ||
| 304 | |||
| 305 | void ProcessDoor(const HumanDoor& h_door, | ||
| 306 | const std::string& current_map_name) { | ||
| 307 | DoorIdentifier door_identifier; | ||
| 308 | door_identifier.set_map(current_map_name); | ||
| 309 | door_identifier.set_name(h_door.name()); | ||
| 310 | |||
| 311 | DoorInfo& door_info = info_.doors[door_identifier]; | ||
| 312 | door_info.definitions.push_back(h_door); | ||
| 313 | |||
| 314 | if (h_door.has_location_room()) { | ||
| 315 | RoomIdentifier location_room_identifier; | ||
| 316 | location_room_identifier.set_map(current_map_name); | ||
| 317 | location_room_identifier.set_name(h_door.location_room()); | ||
| 318 | info_.rooms[location_room_identifier].doors_referenced_by.push_back( | ||
| 319 | door_identifier); | ||
| 320 | } | ||
| 321 | |||
| 322 | for (const PaintingIdentifier& pi : h_door.move_paintings()) { | ||
| 323 | auto complete_painting_identifier = | ||
| 324 | GetCompletePaintingIdentifier(pi, current_map_name, std::nullopt); | ||
| 325 | if (complete_painting_identifier) { | ||
| 326 | PaintingInfo& move_painting_info = | ||
| 327 | info_.paintings[*complete_painting_identifier]; | ||
| 328 | move_painting_info.doors_referenced_by.push_back(door_identifier); | ||
| 329 | } else { | ||
| 330 | door_info.malformed_identifiers.paintings.push_back(pi); | ||
| 331 | } | ||
| 332 | } | ||
| 333 | |||
| 334 | for (const PanelIdentifier& pi : h_door.panels()) { | ||
| 335 | auto complete_panel_identifier = GetCompletePanelIdentifierWithoutAnswer( | ||
| 336 | pi, current_map_name, std::nullopt); | ||
| 337 | if (complete_panel_identifier) { | ||
| 338 | PanelInfo& panel_info = info_.panels[*complete_panel_identifier]; | ||
| 339 | panel_info.doors_referenced_by.push_back(door_identifier); | ||
| 340 | |||
| 341 | if (pi.has_answer()) { | ||
| 342 | panel_info.proxies[pi.answer()].doors_referenced_by.push_back( | ||
| 343 | door_identifier); | ||
| 344 | } | ||
| 345 | } else { | ||
| 346 | door_info.malformed_identifiers.panels.push_back(pi); | ||
| 347 | } | ||
| 348 | } | ||
| 349 | |||
| 350 | for (const KeyholderIdentifier& ki : h_door.keyholders()) { | ||
| 351 | auto complete_keyholder_identifier = | ||
| 352 | GetCompleteKeyholderIdentifierWithoutKey(ki, current_map_name, | ||
| 353 | std::nullopt); | ||
| 354 | if (complete_keyholder_identifier) { | ||
| 355 | KeyholderInfo& keyholder_info = | ||
| 356 | info_.keyholders[*complete_keyholder_identifier]; | ||
| 357 | keyholder_info.doors_referenced_by.push_back(door_identifier); | ||
| 358 | } else { | ||
| 359 | door_info.malformed_identifiers.keyholders.push_back(ki); | ||
| 360 | } | ||
| 361 | } | ||
| 362 | |||
| 363 | for (const RoomIdentifier& ri : h_door.rooms()) { | ||
| 364 | RoomIdentifier complete_room_identifier = | ||
| 365 | *GetCompleteRoomIdentifier(ri, current_map_name); | ||
| 366 | RoomInfo& room_info = info_.rooms[complete_room_identifier]; | ||
| 367 | room_info.doors_referenced_by.push_back(door_identifier); | ||
| 368 | } | ||
| 369 | |||
| 370 | for (const DoorIdentifier& di : h_door.doors()) { | ||
| 371 | DoorIdentifier complete_door_identifier = | ||
| 372 | *GetCompleteDoorIdentifier(di, current_map_name); | ||
| 373 | DoorInfo& other_door_info = info_.doors[complete_door_identifier]; | ||
| 374 | other_door_info.doors_referenced_by.push_back(door_identifier); | ||
| 375 | } | ||
| 376 | } | ||
| 377 | |||
| 378 | void ProcessConnectionsFile(std::filesystem::path path, | ||
| 379 | std::optional<std::string> current_map_name) { | ||
| 380 | if (!std::filesystem::exists(path)) { | ||
| 381 | return; | ||
| 382 | } | ||
| 383 | |||
| 384 | auto connections = ReadMessageFromFile<HumanConnections>(path.string()); | ||
| 385 | |||
| 386 | for (const HumanConnection& connection : connections.connections()) { | ||
| 387 | ProcessConnection(connection, current_map_name); | ||
| 388 | } | ||
| 389 | } | ||
| 390 | |||
| 391 | void ProcessConnection(const HumanConnection& human_connection, | ||
| 392 | const std::optional<std::string>& current_map_name) { | ||
| 393 | if (human_connection.has_from_room()) { | ||
| 394 | if (current_map_name) { | ||
| 395 | RoomIdentifier room_identifier; | ||
| 396 | room_identifier.set_map(*current_map_name); | ||
| 397 | room_identifier.set_name(human_connection.from_room()); | ||
| 398 | |||
| 399 | RoomInfo& room_info = info_.rooms[room_identifier]; | ||
| 400 | room_info.connections_referenced_by.push_back(human_connection); | ||
| 401 | } else { | ||
| 402 | // Not sure where else to store this right now. | ||
| 403 | std::cout << "A global connection used from_room." << std::endl; | ||
| 404 | } | ||
| 405 | } else if (human_connection.has_from()) { | ||
| 406 | ProcessSingleConnection(human_connection, human_connection.from(), | ||
| 407 | current_map_name, | ||
| 408 | /*is_target=*/!human_connection.oneway() && | ||
| 409 | !human_connection.bypass_target_door()); | ||
| 410 | } | ||
| 411 | |||
| 412 | if (human_connection.has_to_room()) { | ||
| 413 | if (current_map_name) { | ||
| 414 | RoomIdentifier room_identifier; | ||
| 415 | room_identifier.set_map(*current_map_name); | ||
| 416 | room_identifier.set_name(human_connection.to_room()); | ||
| 417 | |||
| 418 | RoomInfo& room_info = info_.rooms[room_identifier]; | ||
| 419 | room_info.connections_referenced_by.push_back(human_connection); | ||
| 420 | } else { | ||
| 421 | // Not sure where else to store this right now. | ||
| 422 | std::cout << "A global connection used to_room." << std::endl; | ||
| 423 | } | ||
| 424 | } else if (human_connection.has_to()) { | ||
| 425 | ProcessSingleConnection( | ||
| 426 | human_connection, human_connection.to(), current_map_name, | ||
| 427 | /*is_target=*/!human_connection.bypass_target_door()); | ||
| 428 | } | ||
| 429 | |||
| 430 | if (human_connection.has_door()) { | ||
| 431 | auto door_identifier = | ||
| 432 | GetCompleteDoorIdentifier(human_connection.door(), current_map_name); | ||
| 433 | if (door_identifier) { | ||
| 434 | DoorInfo& door_info = info_.doors[*door_identifier]; | ||
| 435 | door_info.connections_referenced_by.push_back(human_connection); | ||
| 436 | } else { | ||
| 437 | // Not sure where else to store this right now. | ||
| 438 | std::cout | ||
| 439 | << "A connection used the following malformed door identifier: " | ||
| 440 | << human_connection.door().ShortDebugString() << std::endl; | ||
| 441 | } | ||
| 442 | } | ||
| 443 | } | ||
| 444 | |||
| 445 | void ProcessSingleConnection( | ||
| 446 | const HumanConnection& human_connection, | ||
| 447 | const HumanConnection::Endpoint& endpoint, | ||
| 448 | const std::optional<std::string>& current_map_name, bool is_target) { | ||
| 449 | if (endpoint.has_room()) { | ||
| 450 | auto room_identifier = | ||
| 451 | GetCompleteRoomIdentifier(endpoint.room(), current_map_name); | ||
| 452 | if (room_identifier) { | ||
| 453 | RoomInfo& room_info = info_.rooms[*room_identifier]; | ||
| 454 | room_info.connections_referenced_by.push_back(human_connection); | ||
| 455 | } else { | ||
| 456 | // Not sure where else to store this right now. | ||
| 457 | std::cout | ||
| 458 | << "A connection used the following malformed room identifier: " | ||
| 459 | << endpoint.room().ShortDebugString() << std::endl; | ||
| 460 | } | ||
| 461 | } else if (endpoint.has_painting()) { | ||
| 462 | auto painting_identifier = GetCompletePaintingIdentifier( | ||
| 463 | endpoint.painting(), current_map_name, std::nullopt); | ||
| 464 | if (painting_identifier) { | ||
| 465 | PaintingInfo& painting_info = info_.paintings[*painting_identifier]; | ||
| 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 | } | ||
| 472 | } else { | ||
| 473 | // Not sure where else to store this right now. | ||
| 474 | std::cout | ||
| 475 | << "A connection used the following malformed painting identifier: " | ||
| 476 | << endpoint.painting().ShortDebugString() << std::endl; | ||
| 477 | } | ||
| 478 | } else if (endpoint.has_port()) { | ||
| 479 | auto port_identifier = GetCompletePortIdentifier( | ||
| 480 | endpoint.port(), current_map_name, std::nullopt); | ||
| 481 | if (port_identifier) { | ||
| 482 | PortInfo& port_info = info_.ports[*port_identifier]; | ||
| 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 | } | ||
| 489 | } else { | ||
| 490 | // Not sure where else to store this right now. | ||
| 491 | std::cout | ||
| 492 | << "A connection used the following malformed port identifier: " | ||
| 493 | << endpoint.port().ShortDebugString() << std::endl; | ||
| 494 | } | ||
| 495 | } else if (endpoint.has_panel()) { | ||
| 496 | auto panel_identifier = GetCompletePanelIdentifierWithoutAnswer( | ||
| 497 | endpoint.panel(), current_map_name, std::nullopt); | ||
| 498 | if (panel_identifier) { | ||
| 499 | PanelInfo& panel_info = info_.panels[*panel_identifier]; | ||
| 500 | panel_info.connections_referenced_by.push_back(human_connection); | ||
| 501 | |||
| 502 | if (endpoint.panel().has_answer()) { | ||
| 503 | panel_info.proxies[endpoint.panel().answer()] | ||
| 504 | .connections_referenced_by.push_back(human_connection); | ||
| 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; | ||
| 562 | } | ||
| 563 | |||
| 564 | DoorInfo& door_info = info_.doors[di]; | ||
| 565 | door_info.door_groups_referenced_by.push_back(h_group.name()); | ||
| 566 | } | ||
| 567 | } | ||
| 568 | |||
| 569 | void ProcessIdsFile(std::filesystem::path path) { | ||
| 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 | } | ||
| 647 | } | ||
| 648 | |||
| 649 | std::string mapdir_; | ||
| 650 | CollectedInfo& info_; | ||
| 651 | }; | ||
| 652 | |||
| 653 | } // namespace | ||
| 654 | |||
| 655 | void ProcessHumanData(const std::string& mapdir, CollectedInfo& info) { | ||
| 656 | HumanProcessor human_processor(mapdir, info); | ||
| 657 | human_processor.Run(); | ||
| 658 | } | ||
| 659 | |||
| 660 | } // namespace com::fourisland::lingo2_archipelago | ||
| diff --git a/tools/validator/human_processor.h b/tools/validator/human_processor.h new file mode 100644 index 0000000..52f174f --- /dev/null +++ b/tools/validator/human_processor.h | |||
| @@ -0,0 +1,14 @@ | |||
| 1 | #ifndef TOOLS_VALIDATOR_HUMAN_PROCESSOR_H_ | ||
| 2 | #define TOOLS_VALIDATOR_HUMAN_PROCESSOR_H_ | ||
| 3 | |||
| 4 | #include <string> | ||
| 5 | |||
| 6 | namespace com::fourisland::lingo2_archipelago { | ||
| 7 | |||
| 8 | struct CollectedInfo; | ||
| 9 | |||
| 10 | void ProcessHumanData(const std::string& mapdir, CollectedInfo& info); | ||
| 11 | |||
| 12 | } // namespace com::fourisland::lingo2_archipelago | ||
| 13 | |||
| 14 | #endif /* TOOLS_VALIDATOR_HUMAN_PROCESSOR_H_ */ | ||
| diff --git a/tools/validator/main.cpp b/tools/validator/main.cpp new file mode 100644 index 0000000..1a72e9a --- /dev/null +++ b/tools/validator/main.cpp | |||
| @@ -0,0 +1,34 @@ | |||
| 1 | #include "godot_processor.h" | ||
| 2 | #include "human_processor.h" | ||
| 3 | #include "structs.h" | ||
| 4 | #include "validator.h" | ||
| 5 | |||
| 6 | namespace com::fourisland::lingo2_archipelago { | ||
| 7 | namespace { | ||
| 8 | |||
| 9 | void Run(const std::string& mapdir, const std::string& repodir) { | ||
| 10 | CollectedInfo info; | ||
| 11 | |||
| 12 | ProcessHumanData(mapdir, info); | ||
| 13 | ProcessGodotData(repodir, info); | ||
| 14 | |||
| 15 | ValidateCollectedInfo(info); | ||
| 16 | } | ||
| 17 | |||
| 18 | } // namespace | ||
| 19 | } // namespace com::fourisland::lingo2_archipelago | ||
| 20 | |||
| 21 | int main(int argc, char** argv) { | ||
| 22 | if (argc != 3) { | ||
| 23 | std::cout << "Incorrect argument count." << std::endl; | ||
| 24 | std::cout << "Usage: validator [path to map directory] [path to Lingo 2 repository]" << std::endl; | ||
| 25 | return 1; | ||
| 26 | } | ||
| 27 | |||
| 28 | std::string mapdir = argv[1]; | ||
| 29 | std::string repodir = argv[2]; | ||
| 30 | |||
| 31 | com::fourisland::lingo2_archipelago::Run(mapdir, repodir); | ||
| 32 | |||
| 33 | return 0; | ||
| 34 | } | ||
| diff --git a/tools/validator/structs.h b/tools/validator/structs.h new file mode 100644 index 0000000..62974a8 --- /dev/null +++ b/tools/validator/structs.h | |||
| @@ -0,0 +1,149 @@ | |||
| 1 | #ifndef TOOLS_VALIDATOR_STRUCTS_H_ | ||
| 2 | #define TOOLS_VALIDATOR_STRUCTS_H_ | ||
| 3 | |||
| 4 | #include <map> | ||
| 5 | #include <string> | ||
| 6 | #include <vector> | ||
| 7 | |||
| 8 | #include "proto/human.pb.h" | ||
| 9 | #include "util/identifiers.h" | ||
| 10 | |||
| 11 | namespace com::fourisland::lingo2_archipelago { | ||
| 12 | |||
| 13 | struct MalformedIdentifiers { | ||
| 14 | std::vector<PaintingIdentifier> paintings; | ||
| 15 | std::vector<PanelIdentifier> panels; | ||
| 16 | std::vector<KeyholderIdentifier> keyholders; | ||
| 17 | |||
| 18 | bool HasAny() const { | ||
| 19 | return !paintings.empty() || !panels.empty() || !keyholders.empty(); | ||
| 20 | } | ||
| 21 | }; | ||
| 22 | |||
| 23 | struct GameNodeInfo { | ||
| 24 | bool defined = false; | ||
| 25 | int uses = 0; | ||
| 26 | }; | ||
| 27 | |||
| 28 | struct MapInfo { | ||
| 29 | std::map<std::string, GameNodeInfo> game_nodes; | ||
| 30 | |||
| 31 | std::optional<PortIdentifier> malformed_worldport_entrance; | ||
| 32 | }; | ||
| 33 | |||
| 34 | struct RoomInfo { | ||
| 35 | std::vector<HumanRoom> definitions; | ||
| 36 | |||
| 37 | std::vector<DoorIdentifier> doors_referenced_by; | ||
| 38 | std::vector<PanelIdentifier> panels_referenced_by; | ||
| 39 | std::vector<HumanConnection> connections_referenced_by; | ||
| 40 | }; | ||
| 41 | |||
| 42 | struct DoorInfo { | ||
| 43 | std::vector<HumanDoor> definitions; | ||
| 44 | bool has_id = false; | ||
| 45 | |||
| 46 | std::vector<HumanConnection> connections_referenced_by; | ||
| 47 | std::vector<DoorIdentifier> doors_referenced_by; | ||
| 48 | std::vector<PanelIdentifier> panels_referenced_by; | ||
| 49 | std::vector<PaintingIdentifier> paintings_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; | ||
| 53 | |||
| 54 | MalformedIdentifiers malformed_identifiers; | ||
| 55 | }; | ||
| 56 | |||
| 57 | struct PortInfo { | ||
| 58 | std::vector<HumanPort> definitions; | ||
| 59 | bool has_id = false; | ||
| 60 | |||
| 61 | std::vector<HumanConnection> connections_referenced_by; | ||
| 62 | std::vector<HumanConnection> target_connections_referenced_by; | ||
| 63 | std::vector<std::string> map_worldport_entrances; | ||
| 64 | }; | ||
| 65 | |||
| 66 | struct PaintingInfo { | ||
| 67 | std::vector<HumanPainting> definitions; | ||
| 68 | |||
| 69 | std::vector<HumanConnection> connections_referenced_by; | ||
| 70 | std::vector<HumanConnection> target_connections_referenced_by; | ||
| 71 | std::vector<DoorIdentifier> doors_referenced_by; | ||
| 72 | }; | ||
| 73 | |||
| 74 | struct ProxyInfo { | ||
| 75 | std::vector<Proxy> definitions; | ||
| 76 | |||
| 77 | std::vector<HumanConnection> connections_referenced_by; | ||
| 78 | std::vector<DoorIdentifier> doors_referenced_by; | ||
| 79 | }; | ||
| 80 | |||
| 81 | struct PanelInfo { | ||
| 82 | std::vector<HumanPanel> definitions; | ||
| 83 | bool has_id = false; | ||
| 84 | |||
| 85 | std::string map_area_name; | ||
| 86 | |||
| 87 | std::vector<HumanConnection> connections_referenced_by; | ||
| 88 | std::vector<HumanConnection> target_connections_referenced_by; | ||
| 89 | std::vector<DoorIdentifier> doors_referenced_by; | ||
| 90 | |||
| 91 | std::map<std::string, ProxyInfo> proxies; | ||
| 92 | }; | ||
| 93 | |||
| 94 | struct KeyholderInfo { | ||
| 95 | std::vector<HumanKeyholder> definitions; | ||
| 96 | bool has_id = false; | ||
| 97 | |||
| 98 | std::vector<DoorIdentifier> doors_referenced_by; | ||
| 99 | }; | ||
| 100 | |||
| 101 | using LetterIdentifier = std::tuple<char, bool>; | ||
| 102 | |||
| 103 | struct LetterInfo { | ||
| 104 | std::vector<RoomIdentifier> defined_in; | ||
| 105 | bool has_id = false; | ||
| 106 | }; | ||
| 107 | |||
| 108 | struct EndingInfo { | ||
| 109 | std::vector<RoomIdentifier> defined_in; | ||
| 110 | bool has_id = false; | ||
| 111 | }; | ||
| 112 | |||
| 113 | struct PanelNameInfo { | ||
| 114 | std::vector<PanelIdentifier> panels_used_by; | ||
| 115 | }; | ||
| 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 | |||
| 131 | struct CollectedInfo { | ||
| 132 | std::map<std::string, MapInfo> maps; | ||
| 133 | std::map<RoomIdentifier, RoomInfo, RoomIdentifierLess> rooms; | ||
| 134 | std::map<DoorIdentifier, DoorInfo, DoorIdentifierLess> doors; | ||
| 135 | std::map<PortIdentifier, PortInfo, PortIdentifierLess> ports; | ||
| 136 | std::map<PaintingIdentifier, PaintingInfo, PaintingIdentifierLess> paintings; | ||
| 137 | std::map<PanelIdentifier, PanelInfo, PanelIdentifierLess> panels; | ||
| 138 | std::map<KeyholderIdentifier, KeyholderInfo, KeyholderIdentifierLess> | ||
| 139 | keyholders; | ||
| 140 | std::map<LetterIdentifier, LetterInfo> letters; | ||
| 141 | std::map<std::string, EndingInfo> endings; | ||
| 142 | std::map<std::string, PanelNameInfo> panel_names; | ||
| 143 | std::map<std::string, ProgressiveInfo> progressives; | ||
| 144 | std::map<std::string, DoorGroupInfo> door_groups; | ||
| 145 | }; | ||
| 146 | |||
| 147 | } // namespace com::fourisland::lingo2_archipelago | ||
| 148 | |||
| 149 | #endif /* TOOLS_VALIDATOR_STRUCTS_H_ */ | ||
| diff --git a/tools/validator/validator.cpp b/tools/validator/validator.cpp new file mode 100644 index 0000000..fe36be7 --- /dev/null +++ b/tools/validator/validator.cpp | |||
| @@ -0,0 +1,587 @@ | |||
| 1 | #include "validator.h" | ||
| 2 | |||
| 3 | #include <iostream> | ||
| 4 | |||
| 5 | #include "proto/human.pb.h" | ||
| 6 | #include "structs.h" | ||
| 7 | #include "util/identifiers.h" | ||
| 8 | |||
| 9 | namespace com::fourisland::lingo2_archipelago { | ||
| 10 | namespace { | ||
| 11 | |||
| 12 | class Validator { | ||
| 13 | public: | ||
| 14 | explicit Validator(const CollectedInfo& info) : info_(info) {} | ||
| 15 | |||
| 16 | void Validate() const { | ||
| 17 | for (const auto& [map_name, map_info] : info_.maps) { | ||
| 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); | ||
| 53 | } | ||
| 54 | } | ||
| 55 | |||
| 56 | private: | ||
| 57 | void ValidateMap(const std::string& map_name, const MapInfo& map_info) const { | ||
| 58 | for (const auto& [node_path, node_info] : map_info.game_nodes) { | ||
| 59 | if (node_info.uses > 1) { | ||
| 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 | } | ||
| 66 | |||
| 67 | if (!node_info.defined) { | ||
| 68 | std::cout << "Map " << map_name << " node " << node_path | ||
| 69 | << " is not defined in the game file." << std::endl; | ||
| 70 | } | ||
| 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 | } | ||
| 77 | } | ||
| 78 | |||
| 79 | void ValidateRoom(const RoomIdentifier& room_identifier, | ||
| 80 | const RoomInfo& room_info) const { | ||
| 81 | if (room_info.definitions.empty()) { | ||
| 82 | std::cout << "Room " << room_identifier.ShortDebugString() | ||
| 83 | << " has no definition, but was referenced:" << std::endl; | ||
| 84 | |||
| 85 | for (const DoorIdentifier& door_identifier : | ||
| 86 | room_info.doors_referenced_by) { | ||
| 87 | std::cout << " DOOR " << door_identifier.ShortDebugString() | ||
| 88 | << std::endl; | ||
| 89 | } | ||
| 90 | |||
| 91 | for (const PanelIdentifier& panel_identifier : | ||
| 92 | room_info.panels_referenced_by) { | ||
| 93 | std::cout << " PANEL " << panel_identifier.ShortDebugString() | ||
| 94 | << std::endl; | ||
| 95 | } | ||
| 96 | |||
| 97 | for (const HumanConnection& connection : | ||
| 98 | room_info.connections_referenced_by) { | ||
| 99 | std::cout << " CONNECTION " << connection.ShortDebugString() | ||
| 100 | << std::endl; | ||
| 101 | } | ||
| 102 | } else if (room_info.definitions.size() > 1) { | ||
| 103 | std::cout << "Room " << room_identifier.ShortDebugString() | ||
| 104 | << " was defined multiple times." << std::endl; | ||
| 105 | } | ||
| 106 | } | ||
| 107 | |||
| 108 | bool DoesDoorNeedLocationName(const HumanDoor& h_door, | ||
| 109 | const std::string& map_name) const { | ||
| 110 | if (h_door.type() != DoorType::STANDARD) { | ||
| 111 | return false; | ||
| 112 | } | ||
| 113 | |||
| 114 | if (h_door.keyholders_size() > 0 || h_door.white_ending() || | ||
| 115 | h_door.complete_at() > 0) { | ||
| 116 | return true; | ||
| 117 | } | ||
| 118 | |||
| 119 | if (h_door.panels_size() > 4) { | ||
| 120 | return true; | ||
| 121 | } | ||
| 122 | |||
| 123 | std::set<std::string> map_areas; | ||
| 124 | for (const PanelIdentifier& pi : h_door.panels()) { | ||
| 125 | auto full_pi = | ||
| 126 | GetCompletePanelIdentifierWithoutAnswer(pi, map_name, std::nullopt); | ||
| 127 | if (full_pi) { | ||
| 128 | auto panel_info_it = info_.panels.find(*full_pi); | ||
| 129 | if (panel_info_it != info_.panels.end()) { | ||
| 130 | const PanelInfo& panel_info = panel_info_it->second; | ||
| 131 | |||
| 132 | map_areas.insert(panel_info.map_area_name); | ||
| 133 | } | ||
| 134 | } | ||
| 135 | } | ||
| 136 | |||
| 137 | if (map_areas.size() > 1) { | ||
| 138 | return true; | ||
| 139 | } | ||
| 140 | |||
| 141 | return false; | ||
| 142 | } | ||
| 143 | |||
| 144 | void ValidateDoor(const DoorIdentifier& door_identifier, | ||
| 145 | const DoorInfo& door_info) const { | ||
| 146 | if (door_info.definitions.empty()) { | ||
| 147 | std::cout << "Door " << door_identifier.ShortDebugString() | ||
| 148 | << " has no definition, but was referenced:" << std::endl; | ||
| 149 | |||
| 150 | for (const DoorIdentifier& other_door_identifier : | ||
| 151 | door_info.doors_referenced_by) { | ||
| 152 | std::cout << " DOOR " << other_door_identifier.ShortDebugString() | ||
| 153 | << std::endl; | ||
| 154 | } | ||
| 155 | |||
| 156 | for (const PanelIdentifier& panel_identifier : | ||
| 157 | door_info.panels_referenced_by) { | ||
| 158 | std::cout << " PANEL " << panel_identifier.ShortDebugString() | ||
| 159 | << std::endl; | ||
| 160 | } | ||
| 161 | |||
| 162 | for (const PaintingIdentifier& painting_identifier : | ||
| 163 | door_info.paintings_referenced_by) { | ||
| 164 | std::cout << " PAINTING " << painting_identifier.ShortDebugString() | ||
| 165 | << std::endl; | ||
| 166 | } | ||
| 167 | |||
| 168 | for (const PortIdentifier& port_identifier : | ||
| 169 | door_info.ports_referenced_by) { | ||
| 170 | std::cout << " PORT " << port_identifier.ShortDebugString() | ||
| 171 | << std::endl; | ||
| 172 | } | ||
| 173 | |||
| 174 | for (const HumanConnection& connection : | ||
| 175 | door_info.connections_referenced_by) { | ||
| 176 | std::cout << " CONNECTION " << connection.ShortDebugString() | ||
| 177 | << std::endl; | ||
| 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 | } | ||
| 193 | } else if (door_info.definitions.size() > 1) { | ||
| 194 | std::cout << "Door " << door_identifier.ShortDebugString() | ||
| 195 | << " was defined multiple times." << std::endl; | ||
| 196 | } | ||
| 197 | |||
| 198 | if (door_info.malformed_identifiers.HasAny()) { | ||
| 199 | std::cout << "Door " << door_identifier.ShortDebugString() | ||
| 200 | << " has malformed identifiers:" << std::endl; | ||
| 201 | |||
| 202 | for (const PaintingIdentifier& painting_identifier : | ||
| 203 | door_info.malformed_identifiers.paintings) { | ||
| 204 | std::cout << " PAINTING " << painting_identifier.ShortDebugString() | ||
| 205 | << std::endl; | ||
| 206 | } | ||
| 207 | |||
| 208 | for (const PanelIdentifier& panel_identifier : | ||
| 209 | door_info.malformed_identifiers.panels) { | ||
| 210 | std::cout << " PANEL " << panel_identifier.ShortDebugString() | ||
| 211 | << std::endl; | ||
| 212 | } | ||
| 213 | |||
| 214 | for (const KeyholderIdentifier& keyholder_identifier : | ||
| 215 | door_info.malformed_identifiers.keyholders) { | ||
| 216 | std::cout << " KEYHOLDER " << keyholder_identifier.ShortDebugString() | ||
| 217 | << std::endl; | ||
| 218 | } | ||
| 219 | } | ||
| 220 | |||
| 221 | for (const HumanDoor& h_door : door_info.definitions) { | ||
| 222 | if (DoesDoorNeedLocationName(h_door, door_identifier.map()) && | ||
| 223 | !h_door.has_location_name()) { | ||
| 224 | std::cout << "Door " << door_identifier.ShortDebugString() | ||
| 225 | << " needs an explicit location name." << std::endl; | ||
| 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 | } | ||
| 254 | } | ||
| 255 | } | ||
| 256 | |||
| 257 | void ValidatePort(const PortIdentifier& port_identifier, | ||
| 258 | const PortInfo& port_info) const { | ||
| 259 | if (port_info.definitions.empty()) { | ||
| 260 | std::cout << "Port " << port_identifier.ShortDebugString() | ||
| 261 | << " has no definition, but was referenced:" << std::endl; | ||
| 262 | |||
| 263 | for (const HumanConnection& connection : | ||
| 264 | port_info.connections_referenced_by) { | ||
| 265 | std::cout << " CONNECTION " << connection.ShortDebugString() | ||
| 266 | << std::endl; | ||
| 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 | } | ||
| 276 | } else if (port_info.definitions.size() > 1) { | ||
| 277 | std::cout << "Port " << port_identifier.ShortDebugString() | ||
| 278 | << " was defined multiple times." << std::endl; | ||
| 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 | } | ||
| 319 | } | ||
| 320 | |||
| 321 | void ValidatePainting(const PaintingIdentifier& painting_identifier, | ||
| 322 | const PaintingInfo& painting_info) const { | ||
| 323 | if (painting_info.definitions.empty()) { | ||
| 324 | std::cout << "Painting " << painting_identifier.ShortDebugString() | ||
| 325 | << " has no definition, but was referenced:" << std::endl; | ||
| 326 | |||
| 327 | for (const DoorIdentifier& door_identifier : | ||
| 328 | painting_info.doors_referenced_by) { | ||
| 329 | std::cout << " DOOR " << door_identifier.ShortDebugString() | ||
| 330 | << std::endl; | ||
| 331 | } | ||
| 332 | |||
| 333 | for (const HumanConnection& connection : | ||
| 334 | painting_info.connections_referenced_by) { | ||
| 335 | std::cout << " CONNECTION " << connection.ShortDebugString() | ||
| 336 | << std::endl; | ||
| 337 | } | ||
| 338 | } else if (painting_info.definitions.size() > 1) { | ||
| 339 | std::cout << "Painting " << painting_identifier.ShortDebugString() | ||
| 340 | << " was defined multiple times." << std::endl; | ||
| 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 | } | ||
| 358 | } | ||
| 359 | |||
| 360 | void ValidatePanel(const PanelIdentifier& panel_identifier, | ||
| 361 | const PanelInfo& panel_info) const { | ||
| 362 | if (panel_identifier.name().empty()) { | ||
| 363 | std::cout << "Panel " << panel_identifier.ShortDebugString() | ||
| 364 | << " has no name." << std::endl; | ||
| 365 | } | ||
| 366 | |||
| 367 | if (panel_info.definitions.empty()) { | ||
| 368 | std::cout << "Panel " << panel_identifier.ShortDebugString() | ||
| 369 | << " has no definition, but was referenced:" << std::endl; | ||
| 370 | |||
| 371 | for (const DoorIdentifier& door_identifier : | ||
| 372 | panel_info.doors_referenced_by) { | ||
| 373 | std::cout << " DOOR " << door_identifier.ShortDebugString() | ||
| 374 | << std::endl; | ||
| 375 | } | ||
| 376 | |||
| 377 | for (const HumanConnection& connection : | ||
| 378 | panel_info.connections_referenced_by) { | ||
| 379 | std::cout << " CONNECTION " << connection.ShortDebugString() | ||
| 380 | << std::endl; | ||
| 381 | } | ||
| 382 | |||
| 383 | if (panel_info.has_id) { | ||
| 384 | std::cout << " An AP ID is present." << std::endl; | ||
| 385 | } | ||
| 386 | } else if (panel_info.definitions.size() > 1) { | ||
| 387 | std::cout << "Panel " << panel_identifier.ShortDebugString() | ||
| 388 | << " was defined multiple times." << std::endl; | ||
| 389 | } | ||
| 390 | |||
| 391 | for (const auto& [answer, proxy_info] : panel_info.proxies) { | ||
| 392 | if (proxy_info.definitions.empty()) { | ||
| 393 | std::cout << "Panel " << panel_identifier.ShortDebugString() | ||
| 394 | << " with answer \"" << answer | ||
| 395 | << "\" has no definition, but was referenced:" << std::endl; | ||
| 396 | |||
| 397 | for (const DoorIdentifier& door_identifier : | ||
| 398 | proxy_info.doors_referenced_by) { | ||
| 399 | std::cout << " DOOR " << door_identifier.ShortDebugString() | ||
| 400 | << std::endl; | ||
| 401 | } | ||
| 402 | |||
| 403 | for (const HumanConnection& connection : | ||
| 404 | proxy_info.connections_referenced_by) { | ||
| 405 | std::cout << " CONNECTION " << connection.ShortDebugString() | ||
| 406 | << std::endl; | ||
| 407 | } | ||
| 408 | } else if (proxy_info.definitions.size() > 1) { | ||
| 409 | std::cout << "Panel " << panel_identifier.ShortDebugString() | ||
| 410 | << " with answer \"" << answer | ||
| 411 | << "\" was defined multiple times." << std::endl; | ||
| 412 | } | ||
| 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 | } | ||
| 435 | } | ||
| 436 | |||
| 437 | void ValidateKeyholder(const KeyholderIdentifier& keyholder_identifier, | ||
| 438 | const KeyholderInfo& keyholder_info) const { | ||
| 439 | if (keyholder_info.definitions.empty()) { | ||
| 440 | std::cout << "Keyholder " << keyholder_identifier.ShortDebugString() | ||
| 441 | << " has no definition, but was referenced:" << std::endl; | ||
| 442 | |||
| 443 | for (const DoorIdentifier& door_identifier : | ||
| 444 | keyholder_info.doors_referenced_by) { | ||
| 445 | std::cout << " DOOR " << door_identifier.ShortDebugString() | ||
| 446 | << std::endl; | ||
| 447 | } | ||
| 448 | |||
| 449 | if (keyholder_info.has_id) { | ||
| 450 | std::cout << " An AP ID is present." << std::endl; | ||
| 451 | } | ||
| 452 | } else if (keyholder_info.definitions.size() > 1) { | ||
| 453 | std::cout << "Keyholder " << keyholder_identifier.ShortDebugString() | ||
| 454 | << " was defined multiple times." << std::endl; | ||
| 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 | } | ||
| 470 | } | ||
| 471 | |||
| 472 | void ValidateLetter(const LetterIdentifier& letter_identifier, | ||
| 473 | const LetterInfo& letter_info) const { | ||
| 474 | std::string letter_name = std::string(1, std::get<0>(letter_identifier)) + | ||
| 475 | (std::get<1>(letter_identifier) ? "2" : "1"); | ||
| 476 | |||
| 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) { | ||
| 485 | std::cout << "Letter " << letter_name | ||
| 486 | << " was defined in multiple places:" << std::endl; | ||
| 487 | |||
| 488 | for (const RoomIdentifier& room_identifier : letter_info.defined_in) { | ||
| 489 | std::cout << " " << room_identifier.ShortDebugString() << std::endl; | ||
| 490 | } | ||
| 491 | } | ||
| 492 | |||
| 493 | if (!letter_info.has_id) { | ||
| 494 | std::cout << "Letter " << letter_name << " is missing an AP ID." | ||
| 495 | << std::endl; | ||
| 496 | } | ||
| 497 | } | ||
| 498 | |||
| 499 | void ValidateEnding(const std::string& ending_name, | ||
| 500 | const EndingInfo& ending_info) const { | ||
| 501 | if (ending_info.defined_in.empty()) { | ||
| 502 | std::cout << "Ending " << ending_name | ||
| 503 | << " has no definition, but was referenced:" << std::endl; | ||
| 504 | |||
| 505 | if (ending_info.has_id) { | ||
| 506 | std::cout << " An AP ID is present." << std::endl; | ||
| 507 | } | ||
| 508 | } else if (ending_info.defined_in.size() > 1) { | ||
| 509 | std::cout << "Ending " << ending_name | ||
| 510 | << " was defined in multiple places:" << std::endl; | ||
| 511 | |||
| 512 | for (const RoomIdentifier& room_identifier : ending_info.defined_in) { | ||
| 513 | std::cout << " " << room_identifier.ShortDebugString() << std::endl; | ||
| 514 | } | ||
| 515 | } | ||
| 516 | |||
| 517 | if (!ending_info.has_id) { | ||
| 518 | std::cout << "Ending " << ending_name << " is missing an AP ID." | ||
| 519 | << std::endl; | ||
| 520 | } | ||
| 521 | } | ||
| 522 | |||
| 523 | void ValidatePanelName(const std::string& panel_name, | ||
| 524 | const PanelNameInfo& panel_info) const { | ||
| 525 | if (panel_info.panels_used_by.size() > 1) { | ||
| 526 | std::cout << "The location name \"" << panel_name | ||
| 527 | << "\" is used by multiple panels:" << std::endl; | ||
| 528 | |||
| 529 | for (const PanelIdentifier& panel_identifier : | ||
| 530 | panel_info.panels_used_by) { | ||
| 531 | std::cout << " PANEL " << panel_identifier.ShortDebugString() | ||
| 532 | << std::endl; | ||
| 533 | } | ||
| 534 | } | ||
| 535 | } | ||
| 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 | |||
| 577 | const CollectedInfo& info_; | ||
| 578 | }; | ||
| 579 | |||
| 580 | } // namespace | ||
| 581 | |||
| 582 | void ValidateCollectedInfo(const CollectedInfo& info) { | ||
| 583 | Validator validator(info); | ||
| 584 | validator.Validate(); | ||
| 585 | } | ||
| 586 | |||
| 587 | } // namespace com::fourisland::lingo2_archipelago | ||
| diff --git a/tools/validator/validator.h b/tools/validator/validator.h new file mode 100644 index 0000000..33bc7c9 --- /dev/null +++ b/tools/validator/validator.h | |||
| @@ -0,0 +1,12 @@ | |||
| 1 | #ifndef TOOLS_VALIDATOR_VALIDATOR_H | ||
| 2 | #define TOOLS_VALIDATOR_VALIDATOR_H | ||
| 3 | |||
| 4 | namespace com::fourisland::lingo2_archipelago { | ||
| 5 | |||
| 6 | struct CollectedInfo; | ||
| 7 | |||
| 8 | void ValidateCollectedInfo(const CollectedInfo& info); | ||
| 9 | |||
| 10 | } // namespace com::fourisland::lingo2_archipelago | ||
| 11 | |||
| 12 | #endif /* TOOLS_VALIDATOR_VALIDATOR_H */ | ||
