diff options
| author | Star Rauchenberger <fefferburbia@gmail.com> | 2025-09-01 12:54:46 -0400 |
|---|---|---|
| committer | Star Rauchenberger <fefferburbia@gmail.com> | 2025-09-01 12:54:46 -0400 |
| commit | a3972a65b9b443a6085a6ac40b153442e190f382 (patch) | |
| tree | 8291258115a066f99c972005557208cb9dbd8899 /tools/datapacker | |
| parent | d142ae3408d3e26e12d7dfaa6a7ccbcf56042957 (diff) | |
| download | lingo2-archipelago-a3972a65b9b443a6085a6ac40b153442e190f382.tar.gz lingo2-archipelago-a3972a65b9b443a6085a6ac40b153442e190f382.tar.bz2 lingo2-archipelago-a3972a65b9b443a6085a6ac40b153442e190f382.zip | |
Added progressive doors
Diffstat (limited to 'tools/datapacker')
| -rw-r--r-- | tools/datapacker/container.cpp | 17 | ||||
| -rw-r--r-- | tools/datapacker/container.h | 3 | ||||
| -rw-r--r-- | tools/datapacker/main.cpp | 33 |
3 files changed, 51 insertions, 2 deletions
| diff --git a/tools/datapacker/container.cpp b/tools/datapacker/container.cpp index 2c68552..624caf8 100644 --- a/tools/datapacker/container.cpp +++ b/tools/datapacker/container.cpp | |||
| @@ -331,6 +331,23 @@ uint64_t Container::FindOrAddDoor(std::optional<std::string> map_name, | |||
| 331 | } | 331 | } |
| 332 | } | 332 | } |
| 333 | 333 | ||
| 334 | uint64_t Container::FindOrAddProgressive(std::string prog_name) { | ||
| 335 | auto it = progressive_id_by_name_.find(prog_name); | ||
| 336 | |||
| 337 | if (it == progressive_id_by_name_.end()) { | ||
| 338 | uint64_t new_id = all_objects_.progressives_size(); | ||
| 339 | Progressive* progressive = all_objects_.add_progressives(); | ||
| 340 | progressive->set_id(new_id); | ||
| 341 | progressive->set_name(prog_name); | ||
| 342 | |||
| 343 | progressive_id_by_name_[prog_name] = new_id; | ||
| 344 | |||
| 345 | return new_id; | ||
| 346 | } else { | ||
| 347 | return it->second; | ||
| 348 | } | ||
| 349 | } | ||
| 350 | |||
| 334 | void Container::AddConnection(const Connection& connection) { | 351 | void Container::AddConnection(const Connection& connection) { |
| 335 | *all_objects_.add_connections() = connection; | 352 | *all_objects_.add_connections() = connection; |
| 336 | } | 353 | } |
| diff --git a/tools/datapacker/container.h b/tools/datapacker/container.h index 68f5875..8cec560 100644 --- a/tools/datapacker/container.h +++ b/tools/datapacker/container.h | |||
| @@ -60,6 +60,8 @@ class Container { | |||
| 60 | 60 | ||
| 61 | void AddConnection(const Connection& connection); | 61 | void AddConnection(const Connection& connection); |
| 62 | 62 | ||
| 63 | uint64_t FindOrAddProgressive(std::string prog_name); | ||
| 64 | |||
| 63 | AllObjects& all_objects() { return all_objects_; } | 65 | AllObjects& all_objects() { return all_objects_; } |
| 64 | 66 | ||
| 65 | private: | 67 | private: |
| @@ -82,6 +84,7 @@ class Container { | |||
| 82 | std::map<std::string, std::map<std::string, uint64_t>> | 84 | std::map<std::string, std::map<std::string, uint64_t>> |
| 83 | door_id_by_map_door_names_; | 85 | door_id_by_map_door_names_; |
| 84 | std::map<std::string, uint64_t> ending_id_by_name_; | 86 | std::map<std::string, uint64_t> ending_id_by_name_; |
| 87 | std::map<std::string, uint64_t> progressive_id_by_name_; | ||
| 85 | }; | 88 | }; |
| 86 | 89 | ||
| 87 | } // namespace com::fourisland::lingo2_archipelago | 90 | } // namespace com::fourisland::lingo2_archipelago |
| diff --git a/tools/datapacker/main.cpp b/tools/datapacker/main.cpp index 4923fce..5ed82cc 100644 --- a/tools/datapacker/main.cpp +++ b/tools/datapacker/main.cpp | |||
| @@ -43,6 +43,7 @@ class DataPacker { | |||
| 43 | 43 | ||
| 44 | ProcessConnectionsFile(datadir_path / "connections.txtpb", std::nullopt); | 44 | ProcessConnectionsFile(datadir_path / "connections.txtpb", std::nullopt); |
| 45 | ProcessMaps(datadir_path); | 45 | ProcessMaps(datadir_path); |
| 46 | ProcessProgressivesFile(datadir_path / "progressives.txtpb"); | ||
| 46 | ProcessIdsFile(datadir_path / "ids.yaml"); | 47 | ProcessIdsFile(datadir_path / "ids.yaml"); |
| 47 | 48 | ||
| 48 | { | 49 | { |
| @@ -104,7 +105,7 @@ class DataPacker { | |||
| 104 | container_.FindOrAddRoom(current_map_name, h_room.name(), std::nullopt); | 105 | container_.FindOrAddRoom(current_map_name, h_room.name(), std::nullopt); |
| 105 | Room& room = *container_.all_objects().mutable_rooms(room_id); | 106 | Room& room = *container_.all_objects().mutable_rooms(room_id); |
| 106 | 107 | ||
| 107 | //room.set_display_name(h_room.display_name()); | 108 | // room.set_display_name(h_room.display_name()); |
| 108 | 109 | ||
| 109 | if (h_room.has_panel_display_name()) { | 110 | if (h_room.has_panel_display_name()) { |
| 110 | room.set_panel_display_name(h_room.panel_display_name()); | 111 | room.set_panel_display_name(h_room.panel_display_name()); |
| @@ -388,7 +389,7 @@ class DataPacker { | |||
| 388 | door.add_doors( | 389 | door.add_doors( |
| 389 | container_.FindOrAddDoor(map_name, di.name(), current_map_name)); | 390 | container_.FindOrAddDoor(map_name, di.name(), current_map_name)); |
| 390 | } | 391 | } |
| 391 | 392 | ||
| 392 | for (const std::string& ending_name : h_door.endings()) { | 393 | for (const std::string& ending_name : h_door.endings()) { |
| 393 | door.add_endings(container_.FindOrAddEnding(ending_name)); | 394 | door.add_endings(container_.FindOrAddEnding(ending_name)); |
| 394 | } | 395 | } |
| @@ -544,6 +545,29 @@ class DataPacker { | |||
| 544 | } | 545 | } |
| 545 | } | 546 | } |
| 546 | 547 | ||
| 548 | void ProcessProgressivesFile(std::filesystem::path path) { | ||
| 549 | if (!std::filesystem::exists(path)) { | ||
| 550 | return; | ||
| 551 | } | ||
| 552 | |||
| 553 | auto h_progs = ReadMessageFromFile<HumanProgressives>(path.string()); | ||
| 554 | |||
| 555 | for (const HumanProgressive& h_prog : h_progs.progressives()) { | ||
| 556 | ProcessProgressive(h_prog); | ||
| 557 | } | ||
| 558 | } | ||
| 559 | |||
| 560 | void ProcessProgressive(const HumanProgressive& h_prog) { | ||
| 561 | uint64_t prog_id = container_.FindOrAddProgressive(h_prog.name()); | ||
| 562 | Progressive& prog = *container_.all_objects().mutable_progressives(prog_id); | ||
| 563 | |||
| 564 | for (const DoorIdentifier& di : h_prog.doors()) { | ||
| 565 | uint64_t door_id = | ||
| 566 | container_.FindOrAddDoor(di.map(), di.name(), std::nullopt); | ||
| 567 | prog.add_doors(door_id); | ||
| 568 | } | ||
| 569 | } | ||
| 570 | |||
| 547 | void ProcessIdsFile(std::filesystem::path path) { | 571 | void ProcessIdsFile(std::filesystem::path path) { |
| 548 | auto ids = ReadIdsFromYaml(path.string()); | 572 | auto ids = ReadIdsFromYaml(path.string()); |
| 549 | 573 | ||
| @@ -585,6 +609,11 @@ class DataPacker { | |||
| 585 | uint64_t ending_id = container_.FindOrAddEnding(ending_name); | 609 | uint64_t ending_id = container_.FindOrAddEnding(ending_name); |
| 586 | container_.all_objects().mutable_endings(ending_id)->set_ap_id(ap_id); | 610 | container_.all_objects().mutable_endings(ending_id)->set_ap_id(ap_id); |
| 587 | } | 611 | } |
| 612 | |||
| 613 | for (const auto& [prog_name, ap_id] : ids.progressives()) { | ||
| 614 | uint64_t prog_id = container_.FindOrAddProgressive(prog_name); | ||
| 615 | container_.all_objects().mutable_progressives(prog_id)->set_ap_id(ap_id); | ||
| 616 | } | ||
| 588 | } | 617 | } |
| 589 | 618 | ||
| 590 | std::string mapdir_; | 619 | std::string mapdir_; |
