diff options
Diffstat (limited to 'tools/datapacker/main.cpp')
| -rw-r--r-- | tools/datapacker/main.cpp | 51 |
1 files changed, 48 insertions, 3 deletions
| 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_; |
