diff options
| -rw-r--r-- | CMakeLists.txt | 1 | ||||
| -rw-r--r-- | apworld/player_logic.py | 6 | ||||
| -rw-r--r-- | apworld/static_logic.py | 12 | ||||
| -rw-r--r-- | data/ids.txtpb | 215 | ||||
| -rw-r--r-- | proto/common.proto | 5 | ||||
| -rw-r--r-- | proto/data.proto | 25 | ||||
| -rw-r--r-- | proto/human.proto | 2 | ||||
| -rw-r--r-- | tools/assign_ids/CMakeLists.txt | 4 | ||||
| -rw-r--r-- | tools/assign_ids/main.cpp | 30 | ||||
| -rw-r--r-- | tools/datapacker/CMakeLists.txt | 4 | ||||
| -rw-r--r-- | tools/datapacker/container.cpp | 77 | ||||
| -rw-r--r-- | tools/datapacker/container.h | 13 | ||||
| -rw-r--r-- | tools/datapacker/main.cpp | 51 | ||||
| -rw-r--r-- | tools/util/CMakeLists.txt | 5 | ||||
| -rw-r--r-- | tools/util/naming.cpp | 11 | ||||
| -rw-r--r-- | tools/util/naming.h | 8 |
16 files changed, 362 insertions, 107 deletions
| diff --git a/CMakeLists.txt b/CMakeLists.txt index fab2c86..f15a970 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt | |||
| @@ -3,5 +3,6 @@ cmake_minimum_required(VERSION 3.28) | |||
| 3 | project(lingo2_archipelago) | 3 | project(lingo2_archipelago) |
| 4 | 4 | ||
| 5 | add_subdirectory(proto) | 5 | add_subdirectory(proto) |
| 6 | add_subdirectory(tools/util) | ||
| 6 | add_subdirectory(tools/assign_ids) | 7 | add_subdirectory(tools/assign_ids) |
| 7 | add_subdirectory(tools/datapacker) | 8 | add_subdirectory(tools/datapacker) |
| diff --git a/apworld/player_logic.py b/apworld/player_logic.py index 1efdbc1..a3b86bf 100644 --- a/apworld/player_logic.py +++ b/apworld/player_logic.py | |||
| @@ -18,3 +18,9 @@ class Lingo2PlayerLogic: | |||
| 18 | for door in world.static_logic.objects.doors: | 18 | for door in world.static_logic.objects.doors: |
| 19 | if door.type in [common_pb2.DoorType.STANDARD, common_pb2.DoorType.LOCATION_ONLY]: | 19 | if door.type in [common_pb2.DoorType.STANDARD, common_pb2.DoorType.LOCATION_ONLY]: |
| 20 | self.locations_by_room.setdefault(door.room_id, []).append(PlayerLocation(door.ap_id)) | 20 | self.locations_by_room.setdefault(door.room_id, []).append(PlayerLocation(door.ap_id)) |
| 21 | |||
| 22 | for letter in world.static_logic.objects.letters: | ||
| 23 | self.locations_by_room.setdefault(letter.room_id, []).append(PlayerLocation(letter.ap_id)) | ||
| 24 | |||
| 25 | for mastery in world.static_logic.objects.masteries: | ||
| 26 | self.locations_by_room.setdefault(mastery.room_id, []).append(PlayerLocation(mastery.ap_id)) | ||
| diff --git a/apworld/static_logic.py b/apworld/static_logic.py index 1cab340..4fc38f8 100644 --- a/apworld/static_logic.py +++ b/apworld/static_logic.py | |||
| @@ -26,5 +26,17 @@ class Lingo2StaticLogic: | |||
| 26 | item_name = f"{self.objects.maps[door.map_id].name} - {door.name}" | 26 | item_name = f"{self.objects.maps[door.map_id].name} - {door.name}" |
| 27 | self.item_id_to_name[door.ap_id] = item_name | 27 | self.item_id_to_name[door.ap_id] = item_name |
| 28 | 28 | ||
| 29 | for letter in self.objects.letters: | ||
| 30 | letter_name = f"{letter.key.upper()}{'' if letter.double else '2'}" | ||
| 31 | location_name = f"{self.objects.maps[self.objects.rooms[letter.room_id].map_id].name} - {letter_name}" | ||
| 32 | self.location_id_to_name[letter.ap_id] = location_name | ||
| 33 | |||
| 34 | if not letter.double: | ||
| 35 | self.item_id_to_name[letter.ap_id] = letter_name | ||
| 36 | |||
| 37 | for mastery in self.objects.masteries: | ||
| 38 | location_name = f"{self.objects.maps[self.objects.rooms[mastery.room_id].map_id].name} - Mastery" | ||
| 39 | self.location_id_to_name[mastery.ap_id] = location_name | ||
| 40 | |||
| 29 | self.item_name_to_id = {name: ap_id for ap_id, name in self.item_id_to_name.items()} | 41 | self.item_name_to_id = {name: ap_id for ap_id, name in self.item_id_to_name.items()} |
| 30 | self.location_name_to_id = {name: ap_id for ap_id, name in self.location_id_to_name.items()} | 42 | self.location_name_to_id = {name: ap_id for ap_id, name in self.location_id_to_name.items()} |
| diff --git a/data/ids.txtpb b/data/ids.txtpb index b762422..c4be6b5 100644 --- a/data/ids.txtpb +++ b/data/ids.txtpb | |||
| @@ -641,6 +641,97 @@ maps { | |||
| 641 | } | 641 | } |
| 642 | } | 642 | } |
| 643 | maps { | 643 | maps { |
| 644 | key: "the_butterfly" | ||
| 645 | value { | ||
| 646 | rooms { | ||
| 647 | key: "Main Area" | ||
| 648 | value { | ||
| 649 | panels { | ||
| 650 | key: "ARTICLE" | ||
| 651 | value: 262 | ||
| 652 | } | ||
| 653 | panels { | ||
| 654 | key: "BOOK" | ||
| 655 | value: 263 | ||
| 656 | } | ||
| 657 | panels { | ||
| 658 | key: "BUILDING" | ||
| 659 | value: 256 | ||
| 660 | } | ||
| 661 | panels { | ||
| 662 | key: "CATERPILLAR" | ||
| 663 | value: 258 | ||
| 664 | } | ||
| 665 | panels { | ||
| 666 | key: "CONSTITUTION" | ||
| 667 | value: 252 | ||
| 668 | } | ||
| 669 | panels { | ||
| 670 | key: "CREATURE" | ||
| 671 | value: 261 | ||
| 672 | } | ||
| 673 | panels { | ||
| 674 | key: "GAME" | ||
| 675 | value: 253 | ||
| 676 | } | ||
| 677 | panels { | ||
| 678 | key: "GENE" | ||
| 679 | value: 260 | ||
| 680 | } | ||
| 681 | panels { | ||
| 682 | key: "KNOWLEDGE" | ||
| 683 | value: 259 | ||
| 684 | } | ||
| 685 | panels { | ||
| 686 | key: "PERSONALITY" | ||
| 687 | value: 251 | ||
| 688 | } | ||
| 689 | panels { | ||
| 690 | key: "POSITION (1)" | ||
| 691 | value: 265 | ||
| 692 | } | ||
| 693 | panels { | ||
| 694 | key: "POSITION (2)" | ||
| 695 | value: 266 | ||
| 696 | } | ||
| 697 | panels { | ||
| 698 | key: "POSITION (3)" | ||
| 699 | value: 267 | ||
| 700 | } | ||
| 701 | panels { | ||
| 702 | key: "SCHOOL" | ||
| 703 | value: 255 | ||
| 704 | } | ||
| 705 | panels { | ||
| 706 | key: "SCIENCE" | ||
| 707 | value: 254 | ||
| 708 | } | ||
| 709 | panels { | ||
| 710 | key: "SPECIES" | ||
| 711 | value: 250 | ||
| 712 | } | ||
| 713 | panels { | ||
| 714 | key: "STRUCTURE" | ||
| 715 | value: 257 | ||
| 716 | } | ||
| 717 | panels { | ||
| 718 | key: "TEXT" | ||
| 719 | value: 264 | ||
| 720 | } | ||
| 721 | } | ||
| 722 | } | ||
| 723 | rooms { | ||
| 724 | key: "Mastery" | ||
| 725 | value { | ||
| 726 | masteries { | ||
| 727 | key: "MASTERY" | ||
| 728 | value: 268 | ||
| 729 | } | ||
| 730 | } | ||
| 731 | } | ||
| 732 | } | ||
| 733 | } | ||
| 734 | maps { | ||
| 644 | key: "the_entry" | 735 | key: "the_entry" |
| 645 | value { | 736 | value { |
| 646 | doors { | 737 | doors { |
| @@ -1171,107 +1262,43 @@ maps { | |||
| 1171 | } | 1262 | } |
| 1172 | } | 1263 | } |
| 1173 | } | 1264 | } |
| 1174 | special { | 1265 | letters { |
| 1175 | key: "A" | 1266 | key: "a2" |
| 1176 | value: 105 | 1267 | value: 277 |
| 1177 | } | ||
| 1178 | special { | ||
| 1179 | key: "B" | ||
| 1180 | value: 106 | ||
| 1181 | } | ||
| 1182 | special { | ||
| 1183 | key: "C" | ||
| 1184 | value: 107 | ||
| 1185 | } | ||
| 1186 | special { | ||
| 1187 | key: "D" | ||
| 1188 | value: 108 | ||
| 1189 | } | ||
| 1190 | special { | ||
| 1191 | key: "E" | ||
| 1192 | value: 109 | ||
| 1193 | } | ||
| 1194 | special { | ||
| 1195 | key: "F" | ||
| 1196 | value: 110 | ||
| 1197 | } | ||
| 1198 | special { | ||
| 1199 | key: "G" | ||
| 1200 | value: 111 | ||
| 1201 | } | ||
| 1202 | special { | ||
| 1203 | key: "H" | ||
| 1204 | value: 112 | ||
| 1205 | } | ||
| 1206 | special { | ||
| 1207 | key: "I" | ||
| 1208 | value: 113 | ||
| 1209 | } | ||
| 1210 | special { | ||
| 1211 | key: "J" | ||
| 1212 | value: 114 | ||
| 1213 | } | ||
| 1214 | special { | ||
| 1215 | key: "K" | ||
| 1216 | value: 115 | ||
| 1217 | } | ||
| 1218 | special { | ||
| 1219 | key: "L" | ||
| 1220 | value: 116 | ||
| 1221 | } | ||
| 1222 | special { | ||
| 1223 | key: "M" | ||
| 1224 | value: 117 | ||
| 1225 | } | ||
| 1226 | special { | ||
| 1227 | key: "N" | ||
| 1228 | value: 118 | ||
| 1229 | } | ||
| 1230 | special { | ||
| 1231 | key: "O" | ||
| 1232 | value: 119 | ||
| 1233 | } | ||
| 1234 | special { | ||
| 1235 | key: "P" | ||
| 1236 | value: 120 | ||
| 1237 | } | ||
| 1238 | special { | ||
| 1239 | key: "Q" | ||
| 1240 | value: 121 | ||
| 1241 | } | 1268 | } |
| 1242 | special { | 1269 | letters { |
| 1243 | key: "R" | 1270 | key: "b2" |
| 1244 | value: 122 | 1271 | value: 269 |
| 1245 | } | 1272 | } |
| 1246 | special { | 1273 | letters { |
| 1247 | key: "S" | 1274 | key: "d1" |
| 1248 | value: 123 | 1275 | value: 271 |
| 1249 | } | 1276 | } |
| 1250 | special { | 1277 | letters { |
| 1251 | key: "T" | 1278 | key: "h1" |
| 1252 | value: 124 | 1279 | value: 273 |
| 1253 | } | 1280 | } |
| 1254 | special { | 1281 | letters { |
| 1255 | key: "U" | 1282 | key: "i1" |
| 1256 | value: 125 | 1283 | value: 274 |
| 1257 | } | 1284 | } |
| 1258 | special { | 1285 | letters { |
| 1259 | key: "V" | 1286 | key: "l1" |
| 1260 | value: 126 | 1287 | value: 270 |
| 1261 | } | 1288 | } |
| 1262 | special { | 1289 | letters { |
| 1263 | key: "W" | 1290 | key: "n1" |
| 1264 | value: 127 | 1291 | value: 275 |
| 1265 | } | 1292 | } |
| 1266 | special { | 1293 | letters { |
| 1267 | key: "X" | 1294 | key: "q2" |
| 1268 | value: 128 | 1295 | value: 249 |
| 1269 | } | 1296 | } |
| 1270 | special { | 1297 | letters { |
| 1271 | key: "Y" | 1298 | key: "t1" |
| 1272 | value: 129 | 1299 | value: 276 |
| 1273 | } | 1300 | } |
| 1274 | special { | 1301 | letters { |
| 1275 | key: "Z" | 1302 | key: "x1" |
| 1276 | value: 130 | 1303 | value: 272 |
| 1277 | } | 1304 | } |
| diff --git a/proto/common.proto b/proto/common.proto index 03ad436..e300e94 100644 --- a/proto/common.proto +++ b/proto/common.proto | |||
| @@ -7,11 +7,6 @@ message Proxy { | |||
| 7 | string path = 2; | 7 | string path = 2; |
| 8 | } | 8 | } |
| 9 | 9 | ||
| 10 | message Letter { | ||
| 11 | string key = 1; | ||
| 12 | bool double = 2; | ||
| 13 | } | ||
| 14 | |||
| 15 | enum DoorType { | 10 | enum DoorType { |
| 16 | DOOR_TYPE_UNKNOWN = 0; | 11 | DOOR_TYPE_UNKNOWN = 0; |
| 17 | 12 | ||
| diff --git a/proto/data.proto b/proto/data.proto index bd8cdc3..dd7a2a3 100644 --- a/proto/data.proto +++ b/proto/data.proto | |||
| @@ -83,6 +83,26 @@ message Port { | |||
| 83 | uint64 required_door = 6; | 83 | uint64 required_door = 6; |
| 84 | } | 84 | } |
| 85 | 85 | ||
| 86 | message Letter { | ||
| 87 | uint64 id = 3; | ||
| 88 | uint64 ap_id = 5; | ||
| 89 | uint64 room_id = 4; | ||
| 90 | |||
| 91 | string key = 1; | ||
| 92 | bool double = 2; | ||
| 93 | |||
| 94 | string path = 6; | ||
| 95 | } | ||
| 96 | |||
| 97 | message Mastery { | ||
| 98 | uint64 id = 1; | ||
| 99 | uint64 ap_id = 2; | ||
| 100 | uint64 room_id = 3; | ||
| 101 | |||
| 102 | string name = 4; | ||
| 103 | string path = 5; | ||
| 104 | } | ||
| 105 | |||
| 86 | message Room { | 106 | message Room { |
| 87 | uint64 id = 1; | 107 | uint64 id = 1; |
| 88 | uint64 map_id = 8; | 108 | uint64 map_id = 8; |
| @@ -91,9 +111,10 @@ message Room { | |||
| 91 | 111 | ||
| 92 | repeated uint64 panels = 4; | 112 | repeated uint64 panels = 4; |
| 93 | repeated uint64 paintings = 5; | 113 | repeated uint64 paintings = 5; |
| 94 | repeated Letter letters = 6; | 114 | repeated uint64 letters = 6; |
| 95 | repeated uint64 ports = 7; | 115 | repeated uint64 ports = 7; |
| 96 | repeated uint64 doors = 9; | 116 | repeated uint64 doors = 9; |
| 117 | repeated uint64 masteries = 10; | ||
| 97 | } | 118 | } |
| 98 | 119 | ||
| 99 | message Map { | 120 | message Map { |
| @@ -108,6 +129,8 @@ message AllObjects { | |||
| 108 | repeated Panel panels = 3; | 129 | repeated Panel panels = 3; |
| 109 | repeated Painting paintings = 4; | 130 | repeated Painting paintings = 4; |
| 110 | repeated Port ports = 5; | 131 | repeated Port ports = 5; |
| 132 | repeated Letter letters = 9; | ||
| 133 | repeated Mastery masteries = 10; | ||
| 111 | repeated Connection connections = 6; | 134 | repeated Connection connections = 6; |
| 112 | map<string, uint64> special_ids = 8; | 135 | map<string, uint64> special_ids = 8; |
| 113 | } | 136 | } |
| diff --git a/proto/human.proto b/proto/human.proto index 88aca38..3edd984 100644 --- a/proto/human.proto +++ b/proto/human.proto | |||
| @@ -153,6 +153,7 @@ message HumanRoom { | |||
| 153 | message IdMappings { | 153 | message IdMappings { |
| 154 | message RoomIds { | 154 | message RoomIds { |
| 155 | map<string, uint64> panels = 1; | 155 | map<string, uint64> panels = 1; |
| 156 | map<string, uint64> masteries = 2; | ||
| 156 | } | 157 | } |
| 157 | 158 | ||
| 158 | message MapIds { | 159 | message MapIds { |
| @@ -162,4 +163,5 @@ message IdMappings { | |||
| 162 | 163 | ||
| 163 | map<string, MapIds> maps = 1; | 164 | map<string, MapIds> maps = 1; |
| 164 | map<string, uint64> special = 2; | 165 | map<string, uint64> special = 2; |
| 166 | map<string, uint64> letters = 3; | ||
| 165 | } | 167 | } |
| diff --git a/tools/assign_ids/CMakeLists.txt b/tools/assign_ids/CMakeLists.txt index 0a9f62d..bc89347 100644 --- a/tools/assign_ids/CMakeLists.txt +++ b/tools/assign_ids/CMakeLists.txt | |||
| @@ -5,5 +5,5 @@ add_executable(assign_ids | |||
| 5 | ) | 5 | ) |
| 6 | set_property(TARGET assign_ids PROPERTY CXX_STANDARD 20) | 6 | set_property(TARGET assign_ids PROPERTY CXX_STANDARD 20) |
| 7 | set_property(TARGET assign_ids PROPERTY CXX_STANDARD_REQUIRED ON) | 7 | set_property(TARGET assign_ids PROPERTY CXX_STANDARD_REQUIRED ON) |
| 8 | target_include_directories(assign_ids PUBLIC ${CMAKE_BINARY_DIR}) | 8 | target_include_directories(assign_ids PUBLIC ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR}/tools) |
| 9 | target_link_libraries(assign_ids PUBLIC protos protobuf::libprotobuf) | 9 | target_link_libraries(assign_ids PUBLIC protos protobuf::libprotobuf util) |
| diff --git a/tools/assign_ids/main.cpp b/tools/assign_ids/main.cpp index f10a21c..eba4fd6 100644 --- a/tools/assign_ids/main.cpp +++ b/tools/assign_ids/main.cpp | |||
| @@ -9,6 +9,7 @@ | |||
| 9 | #include <string> | 9 | #include <string> |
| 10 | 10 | ||
| 11 | #include "proto/human.pb.h" | 11 | #include "proto/human.pb.h" |
| 12 | #include "util/naming.h" | ||
| 12 | 13 | ||
| 13 | namespace com::fourisland::lingo2_archipelago { | 14 | namespace com::fourisland::lingo2_archipelago { |
| 14 | namespace { | 15 | namespace { |
| @@ -155,6 +156,35 @@ class AssignIds { | |||
| 155 | panels[h_panel.name()] = next_id_++; | 156 | panels[h_panel.name()] = next_id_++; |
| 156 | } | 157 | } |
| 157 | } | 158 | } |
| 159 | |||
| 160 | for (const HumanLetter& h_letter : h_room.letters()) { | ||
| 161 | std::string lettername = | ||
| 162 | GetLetterName(h_letter.key(), h_letter.double_()); | ||
| 163 | |||
| 164 | if (!id_mappings_.letters().contains(lettername)) { | ||
| 165 | auto& letters = *id_mappings_.mutable_letters(); | ||
| 166 | letters[lettername] = next_id_++; | ||
| 167 | } | ||
| 168 | } | ||
| 169 | |||
| 170 | for (const HumanMastery& h_mastery : h_room.masteries()) { | ||
| 171 | if (!id_mappings_.maps().contains(current_map_name) || | ||
| 172 | !id_mappings_.maps() | ||
| 173 | .at(current_map_name) | ||
| 174 | .rooms() | ||
| 175 | .contains(h_room.name()) || | ||
| 176 | !id_mappings_.maps() | ||
| 177 | .at(current_map_name) | ||
| 178 | .rooms() | ||
| 179 | .at(h_room.name()) | ||
| 180 | .masteries() | ||
| 181 | .contains(h_mastery.name())) { | ||
| 182 | auto& maps = *id_mappings_.mutable_maps(); | ||
| 183 | auto& rooms = *maps[current_map_name].mutable_rooms(); | ||
| 184 | auto& masteries = *rooms[h_room.name()].mutable_masteries(); | ||
| 185 | masteries[h_mastery.name()] = next_id_++; | ||
| 186 | } | ||
| 187 | } | ||
| 158 | } | 188 | } |
| 159 | 189 | ||
| 160 | private: | 190 | private: |
| diff --git a/tools/datapacker/CMakeLists.txt b/tools/datapacker/CMakeLists.txt index 0274043..1ef04e2 100644 --- a/tools/datapacker/CMakeLists.txt +++ b/tools/datapacker/CMakeLists.txt | |||
| @@ -6,5 +6,5 @@ add_executable(datapacker | |||
| 6 | ) | 6 | ) |
| 7 | set_property(TARGET datapacker PROPERTY CXX_STANDARD 20) | 7 | set_property(TARGET datapacker PROPERTY CXX_STANDARD 20) |
| 8 | set_property(TARGET datapacker PROPERTY CXX_STANDARD_REQUIRED ON) | 8 | set_property(TARGET datapacker PROPERTY CXX_STANDARD_REQUIRED ON) |
| 9 | target_include_directories(datapacker PUBLIC ${CMAKE_BINARY_DIR}) | 9 | target_include_directories(datapacker PUBLIC ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR}/tools) |
| 10 | target_link_libraries(datapacker PUBLIC protos protobuf::libprotobuf) | 10 | target_link_libraries(datapacker PUBLIC protos util protobuf::libprotobuf) |
| diff --git a/tools/datapacker/container.cpp b/tools/datapacker/container.cpp index ead3818..29fa1a5 100644 --- a/tools/datapacker/container.cpp +++ b/tools/datapacker/container.cpp | |||
| @@ -1,5 +1,9 @@ | |||
| 1 | #include "container.h" | 1 | #include "container.h" |
| 2 | 2 | ||
| 3 | #include <iostream> | ||
| 4 | |||
| 5 | #include "util/naming.h" | ||
| 6 | |||
| 3 | namespace com::fourisland::lingo2_archipelago { | 7 | namespace com::fourisland::lingo2_archipelago { |
| 4 | 8 | ||
| 5 | uint64_t Container::FindOrAddMap(std::string map_name) { | 9 | uint64_t Container::FindOrAddMap(std::string map_name) { |
| @@ -169,6 +173,79 @@ uint64_t Container::FindOrAddPanel(std::optional<std::string> map_name, | |||
| 169 | } | 173 | } |
| 170 | } | 174 | } |
| 171 | 175 | ||
| 176 | uint64_t Container::FindOrAddLetter(std::string key, bool double_) { | ||
| 177 | std::string letter_name = GetLetterName(key, double_); | ||
| 178 | |||
| 179 | auto it = letter_id_by_name_.find(letter_name); | ||
| 180 | if (it == letter_id_by_name_.end()) { | ||
| 181 | uint64_t new_id = all_objects_.letters_size(); | ||
| 182 | Letter* letter = all_objects_.add_letters(); | ||
| 183 | letter->set_id(new_id); | ||
| 184 | letter->set_key(key); | ||
| 185 | |||
| 186 | if (double_) { | ||
| 187 | letter->set_double_(double_); | ||
| 188 | } | ||
| 189 | |||
| 190 | letter_id_by_name_[letter_name] = new_id; | ||
| 191 | |||
| 192 | return new_id; | ||
| 193 | } else { | ||
| 194 | return it->second; | ||
| 195 | } | ||
| 196 | } | ||
| 197 | |||
| 198 | uint64_t Container::FindLetterByName(std::string letter_name) { | ||
| 199 | auto it = letter_id_by_name_.find(letter_name); | ||
| 200 | if (it == letter_id_by_name_.end()) { | ||
| 201 | std::cout << "Could not find letter by name: " << letter_name << std::endl; | ||
| 202 | exit(2); | ||
| 203 | } else { | ||
| 204 | return it->second; | ||
| 205 | } | ||
| 206 | } | ||
| 207 | |||
| 208 | uint64_t Container::FindOrAddMastery(std::optional<std::string> map_name, | ||
| 209 | std::optional<std::string> room_name, | ||
| 210 | std::string mastery_name, | ||
| 211 | std::optional<std::string> map_fallback, | ||
| 212 | std::optional<std::string> room_fallback) { | ||
| 213 | if (!map_name) { | ||
| 214 | if (!map_fallback) { | ||
| 215 | std::cout << "No map name provided for " << mastery_name << std::endl; | ||
| 216 | map_name = "global"; | ||
| 217 | } else { | ||
| 218 | map_name = map_fallback; | ||
| 219 | } | ||
| 220 | } | ||
| 221 | |||
| 222 | if (!room_name) { | ||
| 223 | if (!room_fallback) { | ||
| 224 | std::cout << "No room name provided for " << mastery_name << std::endl; | ||
| 225 | room_name = "global"; | ||
| 226 | } else { | ||
| 227 | room_name = room_fallback; | ||
| 228 | } | ||
| 229 | } | ||
| 230 | |||
| 231 | auto& room_container = | ||
| 232 | mastery_id_by_map_room_mastery_names_[*map_name][*room_name]; | ||
| 233 | auto it = room_container.find(mastery_name); | ||
| 234 | if (it == room_container.end()) { | ||
| 235 | uint64_t new_id = all_objects_.masteries_size(); | ||
| 236 | Mastery* mastery = all_objects_.add_masteries(); | ||
| 237 | mastery->set_id(new_id); | ||
| 238 | mastery->set_room_id(FindOrAddRoom(map_name, *room_name, std::nullopt)); | ||
| 239 | mastery->set_name(mastery_name); | ||
| 240 | |||
| 241 | room_container[mastery_name] = new_id; | ||
| 242 | |||
| 243 | return new_id; | ||
| 244 | } else { | ||
| 245 | return it->second; | ||
| 246 | } | ||
| 247 | } | ||
| 248 | |||
| 172 | uint64_t Container::FindOrAddDoor(std::optional<std::string> map_name, | 249 | uint64_t Container::FindOrAddDoor(std::optional<std::string> map_name, |
| 173 | std::string door_name, | 250 | std::string door_name, |
| 174 | std::optional<std::string> map_fallback) { | 251 | std::optional<std::string> map_fallback) { |
| diff --git a/tools/datapacker/container.h b/tools/datapacker/container.h index 571a066..652a025 100644 --- a/tools/datapacker/container.h +++ b/tools/datapacker/container.h | |||
| @@ -36,6 +36,16 @@ 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_); | ||
| 40 | |||
| 41 | uint64_t FindLetterByName(std::string letter_name); | ||
| 42 | |||
| 43 | uint64_t FindOrAddMastery(std::optional<std::string> map_name, | ||
| 44 | std::optional<std::string> room_name, | ||
| 45 | std::string mastery_name, | ||
| 46 | std::optional<std::string> map_fallback, | ||
| 47 | std::optional<std::string> room_fallback); | ||
| 48 | |||
| 39 | uint64_t FindOrAddDoor(std::optional<std::string> map_name, | 49 | uint64_t FindOrAddDoor(std::optional<std::string> map_name, |
| 40 | std::string door_name, | 50 | std::string door_name, |
| 41 | std::optional<std::string> map_fallback); | 51 | std::optional<std::string> map_fallback); |
| @@ -56,6 +66,9 @@ class Container { | |||
| 56 | port_id_by_map_room_port_names_; | 66 | port_id_by_map_room_port_names_; |
| 57 | std::map<std::string, std::map<std::string, std::map<std::string, uint64_t>>> | 67 | std::map<std::string, std::map<std::string, std::map<std::string, uint64_t>>> |
| 58 | panel_id_by_map_room_panel_names_; | 68 | panel_id_by_map_room_panel_names_; |
| 69 | std::map<std::string, uint64_t> letter_id_by_name_; | ||
| 70 | std::map<std::string, std::map<std::string, std::map<std::string, uint64_t>>> | ||
| 71 | mastery_id_by_map_room_mastery_names_; | ||
| 59 | std::map<std::string, std::map<std::string, uint64_t>> | 72 | std::map<std::string, std::map<std::string, uint64_t>> |
| 60 | door_id_by_map_door_names_; | 73 | door_id_by_map_door_names_; |
| 61 | }; | 74 | }; |
| diff --git a/tools/datapacker/main.cpp b/tools/datapacker/main.cpp index 28dbc6b..2ad97b0 100644 --- a/tools/datapacker/main.cpp +++ b/tools/datapacker/main.cpp | |||
| @@ -101,9 +101,14 @@ class DataPacker { | |||
| 101 | room.add_ports(ProcessPort(h_port, current_map_name, room.name())); | 101 | room.add_ports(ProcessPort(h_port, current_map_name, room.name())); |
| 102 | } | 102 | } |
| 103 | 103 | ||
| 104 | std::copy( | 104 | for (const HumanLetter& h_letter : h_room.letters()) { |
| 105 | h_room.letters().begin(), h_room.letters().end(), | 105 | room.add_letters(ProcessLetter(h_letter, current_map_name, room.name())); |
| 106 | google::protobuf::RepeatedFieldBackInserter(room.mutable_letters())); | 106 | } |
| 107 | |||
| 108 | for (const HumanMastery& h_mastery : h_room.masteries()) { | ||
| 109 | room.add_masteries( | ||
| 110 | ProcessMastery(h_mastery, current_map_name, room.name())); | ||
| 111 | } | ||
| 107 | } | 112 | } |
| 108 | 113 | ||
| 109 | uint64_t ProcessPanel(const HumanPanel& h_panel, | 114 | uint64_t ProcessPanel(const HumanPanel& h_panel, |
| @@ -197,6 +202,33 @@ class DataPacker { | |||
| 197 | return port_id; | 202 | return port_id; |
| 198 | } | 203 | } |
| 199 | 204 | ||
| 205 | uint64_t ProcessLetter(const HumanLetter& h_letter, | ||
| 206 | const std::string& current_map_name, | ||
| 207 | const std::string& current_room_name) { | ||
| 208 | uint64_t letter_id = | ||
| 209 | container_.FindOrAddLetter(h_letter.key(), h_letter.double_()); | ||
| 210 | Letter& letter = *container_.all_objects().mutable_letters(letter_id); | ||
| 211 | |||
| 212 | letter.set_room_id(container_.FindOrAddRoom( | ||
| 213 | current_map_name, current_room_name, std::nullopt)); | ||
| 214 | letter.set_path(h_letter.path()); | ||
| 215 | |||
| 216 | return letter_id; | ||
| 217 | } | ||
| 218 | |||
| 219 | uint64_t ProcessMastery(const HumanMastery& h_mastery, | ||
| 220 | const std::string& current_map_name, | ||
| 221 | const std::string& current_room_name) { | ||
| 222 | uint64_t mastery_id = container_.FindOrAddMastery( | ||
| 223 | current_map_name, current_room_name, h_mastery.name(), std::nullopt, | ||
| 224 | std::nullopt); | ||
| 225 | Mastery& mastery = *container_.all_objects().mutable_masteries(mastery_id); | ||
| 226 | |||
| 227 | mastery.set_path(h_mastery.path()); | ||
| 228 | |||
| 229 | return mastery_id; | ||
| 230 | } | ||
| 231 | |||
| 200 | void ProcessDoorsFile(std::filesystem::path path, | 232 | void ProcessDoorsFile(std::filesystem::path path, |
| 201 | const std::string& current_map_name) { | 233 | const std::string& current_map_name) { |
| 202 | if (!std::filesystem::exists(path)) { | 234 | if (!std::filesystem::exists(path)) { |
| @@ -410,6 +442,14 @@ class DataPacker { | |||
| 410 | map_name, room_name, panel_name, std::nullopt, std::nullopt); | 442 | map_name, room_name, panel_name, std::nullopt, std::nullopt); |
| 411 | container_.all_objects().mutable_panels(panel_id)->set_ap_id(ap_id); | 443 | container_.all_objects().mutable_panels(panel_id)->set_ap_id(ap_id); |
| 412 | } | 444 | } |
| 445 | |||
| 446 | for (const auto& [mastery_name, ap_id] : room.masteries()) { | ||
| 447 | uint64_t mastery_id = container_.FindOrAddMastery( | ||
| 448 | map_name, room_name, mastery_name, std::nullopt, std::nullopt); | ||
| 449 | container_.all_objects() | ||
| 450 | .mutable_masteries(mastery_id) | ||
| 451 | ->set_ap_id(ap_id); | ||
| 452 | } | ||
| 413 | } | 453 | } |
| 414 | } | 454 | } |
| 415 | 455 | ||
| @@ -417,6 +457,11 @@ class DataPacker { | |||
| 417 | for (const auto& [tag, id] : ids.special()) { | 457 | for (const auto& [tag, id] : ids.special()) { |
| 418 | specials[tag] = id; | 458 | specials[tag] = id; |
| 419 | } | 459 | } |
| 460 | |||
| 461 | for (const auto& [letter_name, ap_id] : ids.letters()) { | ||
| 462 | uint64_t letter_id = container_.FindLetterByName(letter_name); | ||
| 463 | container_.all_objects().mutable_letters(letter_id)->set_ap_id(ap_id); | ||
| 464 | } | ||
| 420 | } | 465 | } |
| 421 | 466 | ||
| 422 | std::string mapdir_; | 467 | std::string mapdir_; |
| diff --git a/tools/util/CMakeLists.txt b/tools/util/CMakeLists.txt new file mode 100644 index 0000000..8eb8d3b --- /dev/null +++ b/tools/util/CMakeLists.txt | |||
| @@ -0,0 +1,5 @@ | |||
| 1 | add_library(util | ||
| 2 | naming.cpp | ||
| 3 | ) | ||
| 4 | set_property(TARGET util PROPERTY CXX_STANDARD 20) | ||
| 5 | set_property(TARGET util PROPERTY CXX_STANDARD_REQUIRED ON) | ||
| diff --git a/tools/util/naming.cpp b/tools/util/naming.cpp new file mode 100644 index 0000000..12594c5 --- /dev/null +++ b/tools/util/naming.cpp | |||
| @@ -0,0 +1,11 @@ | |||
| 1 | #include "naming.h" | ||
| 2 | |||
| 3 | #include <sstream> | ||
| 4 | |||
| 5 | std::string GetLetterName(std::string key, bool double_) { | ||
| 6 | std::ostringstream lettername_s; | ||
| 7 | lettername_s << key; | ||
| 8 | lettername_s << (double_ ? "2" : "1"); | ||
| 9 | |||
| 10 | return lettername_s.str(); | ||
| 11 | } | ||
| diff --git a/tools/util/naming.h b/tools/util/naming.h new file mode 100644 index 0000000..7d61309 --- /dev/null +++ b/tools/util/naming.h | |||
| @@ -0,0 +1,8 @@ | |||
| 1 | #ifndef TOOLS_UTIL_NAMING_H_ | ||
| 2 | #define TOOLS_UTIL_NAMING_H_ | ||
| 3 | |||
| 4 | #include <string> | ||
| 5 | |||
| 6 | std::string GetLetterName(std::string key, bool double_); | ||
| 7 | |||
| 8 | #endif /* TOOLS_UTIL_NAMING_H_ */ | ||
