From 3c26cedd030c464e3b8a5576a98c19eb45134658 Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Thu, 7 Aug 2025 14:28:56 -0400 Subject: Process the rest of the defined protos --- data/maps/the_entry/doors.txtpb | 14 +- data/maps/the_entry/rooms/Entry Exit.txtpb | 2 +- data/maps/the_entry/rooms/Starting Room.txtpb | 6 +- proto/common.proto | 18 ++- proto/data.proto | 8 +- proto/human.proto | 19 +-- tools/datapacker/container.h | 2 +- tools/datapacker/main.cpp | 200 +++++++++++++++++++++++++- 8 files changed, 238 insertions(+), 31 deletions(-) diff --git a/data/maps/the_entry/doors.txtpb b/data/maps/the_entry/doors.txtpb index 99e7e02..c43020c 100644 --- a/data/maps/the_entry/doors.txtpb +++ b/data/maps/the_entry/doors.txtpb @@ -141,7 +141,7 @@ doors { name: "Control Center White Door" type: CONTROL_CENTER_COLOR receivers: "Components/Doors/back_left_7" - control_center_color: white + control_center_color: "white" } # exit_1 should maybe just be removed. # entry_proxied_1 is part of the vanilla intro. @@ -265,4 +265,16 @@ doors { panels { room: "Least Blue Last" name: "TRUST" } panels { room: "Least Blue Last" name: "LABEL" } panels { room: "Least Blue Last" name: "AIL" } +} +doors { + name: "Red Room Painting" + type: STANDARD + move_paintings { room: "Right Eye" name: "PSYCHIC" } + panels { room: "Right Eye" name: "FAINT" } +} +doors { + name: "Third Eye Painting" + type: STANDARD + move_paintings { room: "Eye Room" name: "GALLERY" } + panels { room: "Eye Room" name: "I" } } \ No newline at end of file diff --git a/data/maps/the_entry/rooms/Entry Exit.txtpb b/data/maps/the_entry/rooms/Entry Exit.txtpb index a6ce2c4..4f4ac28 100644 --- a/data/maps/the_entry/rooms/Entry Exit.txtpb +++ b/data/maps/the_entry/rooms/Entry Exit.txtpb @@ -3,5 +3,5 @@ display_name: "Starting Room" ports { name: "GREAT" path: "Components/Warps/worldport2" - orientation: north + orientation: "north" } \ No newline at end of file diff --git a/data/maps/the_entry/rooms/Starting Room.txtpb b/data/maps/the_entry/rooms/Starting Room.txtpb index 98882a3..eaf493c 100644 --- a/data/maps/the_entry/rooms/Starting Room.txtpb +++ b/data/maps/the_entry/rooms/Starting Room.txtpb @@ -32,7 +32,7 @@ panels { answer: "hint" } panels { - id: "THIN" + name: "THIN" path: "Panels/Entry/second_left" clue: "thin" answer: "thin" @@ -54,7 +54,7 @@ paintings { move: true # how do enter_only: true orientation: "north" - required_door { door: "Least Blue Last Panels" } + required_door { name: "Least Blue Last Panels" } display_name: "Near Trick Painting" } paintings { @@ -62,7 +62,7 @@ paintings { path: "Components/Paintings/pains3" enter_only: true orientation: "east" - required_door { door: "Near D Room Painting" } + required_door { name: "Near D Room Painting" } display_name: "Near D Room Painting" } ports { diff --git a/proto/common.proto b/proto/common.proto index eb1d6b5..a066cae 100644 --- a/proto/common.proto +++ b/proto/common.proto @@ -8,6 +8,22 @@ message Proxy { } message Letter { - string letter = 1; + string key = 1; bool double = 2; } + +enum DoorType { + DOOR_TYPE_UNKNOWN = 0; + + // This door is a location unless panelsanity is on, and it is an item as long as door shuffle is on. + STANDARD = 1; + + // This door is never an item or a location. + EVENT = 2; + + // This door is never a location, and is an item as long as door shuffle is on. + ITEM_ONLY = 3; + + // This door is never a location, and is an item as long as control center color shuffle is on. + CONTROL_CENTER_COLOR = 4; +} diff --git a/proto/data.proto b/proto/data.proto index b3b6e6b..37d59f3 100644 --- a/proto/data.proto +++ b/proto/data.proto @@ -23,7 +23,7 @@ message Connection { message Door { uint64 id = 1; - uint64 map_id = 10; + uint64 map_id = 9; string name = 2; repeated string receivers = 3; @@ -33,8 +33,7 @@ message Door { string control_center_color = 6; repeated string switches = 7; - repeated string location_tags = 8; - repeated string item_tags = 9; + DoorType type = 8; } message Panel { @@ -42,8 +41,7 @@ message Panel { uint64 room_id = 2; string name = 3; - string nodepath = 4; - + string path = 4; string clue = 5; string answer = 6; repeated string symbols = 7; diff --git a/proto/human.proto b/proto/human.proto index cdbb8b9..49eaccd 100644 --- a/proto/human.proto +++ b/proto/human.proto @@ -62,22 +62,6 @@ message HumanConnections { } message HumanDoor { - enum DoorType { - DOOR_TYPE_UNKNOWN = 0; - - // This door is a location unless panelsanity is on, and it is an item as long as door shuffle is on. - STANDARD = 1; - - // This door is never an item or a location. - EVENT = 2; - - // This door is never a location, and is an item as long as door shuffle is on. - ITEM_ONLY = 3; - - // This door is never a location, and is an item as long as control center color shuffle is on. - CONTROL_CENTER_COLOR = 4; - } - string name = 1; repeated string receivers = 2; @@ -87,8 +71,7 @@ message HumanDoor { string control_center_color = 6; repeated string switches = 7; - repeated string location_tags = 4; - repeated string item_tags = 5; + DoorType type = 4; } message HumanDoors { diff --git a/tools/datapacker/container.h b/tools/datapacker/container.h index 96e5a50..571a066 100644 --- a/tools/datapacker/container.h +++ b/tools/datapacker/container.h @@ -42,7 +42,7 @@ class Container { void AddConnection(const Connection& connection); - const AllObjects& all_objects() const { return all_objects_; } + AllObjects& all_objects() { return all_objects_; } private: AllObjects all_objects_; diff --git a/tools/datapacker/main.cpp b/tools/datapacker/main.cpp index b2ec068..e63f940 100644 --- a/tools/datapacker/main.cpp +++ b/tools/datapacker/main.cpp @@ -1,6 +1,7 @@ #include #include +#include #include #include #include @@ -19,6 +20,8 @@ namespace { template T ReadMessageFromFile(const std::string& path) { + std::cout << "Processing " << path << std::endl; + std::ifstream file(path); std::stringstream buffer; buffer << file.rdbuf(); @@ -38,6 +41,7 @@ class DataPacker { std::filesystem::path datadir_path = mapdir_; ProcessConnectionsFile(datadir_path / "connections.txtpb", std::nullopt); + ProcessMaps(datadir_path); { std::ofstream outputfile(outputpath_); @@ -51,6 +55,200 @@ class DataPacker { } private: + void ProcessMaps(std::filesystem::path path) { + std::filesystem::path maps_dir = path / "maps"; + for (auto const& dir_entry : + std::filesystem::directory_iterator(maps_dir)) { + ProcessMap(dir_entry.path()); + } + } + + void ProcessMap(std::filesystem::path path) { + std::string map_name = path.filename(); + + ProcessConnectionsFile(path / "connections.txtpb", map_name); + ProcessDoorsFile(path / "doors.txtpb", map_name); + ProcessRooms(path / "rooms", map_name); + } + + void ProcessRooms(std::filesystem::path path, + const std::string& current_map_name) { + for (auto const& dir_entry : std::filesystem::directory_iterator(path)) { + auto room = ReadMessageFromFile(dir_entry.path().string()); + ProcessRoom(room, current_map_name); + } + } + + void ProcessRoom(const HumanRoom& h_room, + const std::string& current_map_name) { + uint64_t room_id = + container_.FindOrAddRoom(current_map_name, h_room.name(), std::nullopt); + Room& room = *container_.all_objects().mutable_rooms(room_id); + + room.set_display_name(h_room.display_name()); + + for (const HumanPanel& h_panel : h_room.panels()) { + room.add_panels(ProcessPanel(h_panel, current_map_name, room.name())); + } + + for (const HumanPainting& h_painting : h_room.paintings()) { + room.add_paintings( + ProcessPainting(h_painting, current_map_name, room.name())); + } + + for (const HumanPort& h_port : h_room.ports()) { + room.add_ports(ProcessPort(h_port, current_map_name, room.name())); + } + + std::copy( + h_room.letters().begin(), h_room.letters().end(), + google::protobuf::RepeatedFieldBackInserter(room.mutable_letters())); + } + + uint64_t ProcessPanel(const HumanPanel& h_panel, + const std::string& current_map_name, + const std::string& current_room_name) { + uint64_t panel_id = + container_.FindOrAddPanel(current_map_name, current_room_name, + h_panel.name(), std::nullopt, std::nullopt); + Panel& panel = *container_.all_objects().mutable_panels(panel_id); + + panel.set_path(h_panel.path()); + panel.set_clue(h_panel.clue()); + panel.set_answer(h_panel.answer()); + + std::copy( + h_panel.symbols().begin(), h_panel.symbols().end(), + google::protobuf::RepeatedFieldBackInserter(panel.mutable_symbols())); + std::copy( + h_panel.proxies().begin(), h_panel.proxies().end(), + google::protobuf::RepeatedFieldBackInserter(panel.mutable_proxies())); + + if (h_panel.has_required_door()) { + std::optional map_name = + h_panel.required_door().has_map() + ? std::optional(h_panel.required_door().map()) + : std::nullopt; + panel.set_required_door(container_.FindOrAddDoor( + map_name, h_panel.required_door().name(), current_map_name)); + } + + return panel_id; + } + + uint64_t ProcessPainting(const HumanPainting& h_painting, + const std::string& current_map_name, + const std::string& current_room_name) { + uint64_t painting_id = container_.FindOrAddPainting( + current_map_name, current_room_name, h_painting.name(), std::nullopt, + std::nullopt); + Painting& painting = + *container_.all_objects().mutable_paintings(painting_id); + + painting.set_path(h_painting.path()); + painting.set_display_name(h_painting.display_name()); + painting.set_orientation(h_painting.orientation()); + + if (h_painting.has_flipped()) { + painting.set_flipped(h_painting.flipped()); + } + + if (h_painting.has_move()) { + painting.set_move(h_painting.move()); + } + + if (h_painting.has_enter_only()) { + painting.set_enter_only(h_painting.enter_only()); + } + + if (h_painting.has_required_door()) { + std::optional map_name = + h_painting.required_door().has_map() + ? std::optional(h_painting.required_door().map()) + : std::nullopt; + painting.set_required_door(container_.FindOrAddDoor( + map_name, h_painting.required_door().name(), current_map_name)); + } + + return painting_id; + } + + uint64_t ProcessPort(const HumanPort& h_port, + const std::string& current_map_name, + const std::string& current_room_name) { + uint64_t port_id = + container_.FindOrAddPort(current_map_name, current_room_name, + h_port.name(), std::nullopt, std::nullopt); + Port& port = *container_.all_objects().mutable_ports(port_id); + + port.set_path(h_port.path()); + port.set_orientation(h_port.orientation()); + + if (h_port.has_required_door()) { + std::optional map_name = + h_port.required_door().has_map() + ? std::optional(h_port.required_door().map()) + : std::nullopt; + port.set_required_door(container_.FindOrAddDoor( + map_name, h_port.required_door().name(), current_map_name)); + } + + return port_id; + } + + void ProcessDoorsFile(std::filesystem::path path, + const std::string& current_map_name) { + if (!std::filesystem::exists(path)) { + return; + } + + auto doors = ReadMessageFromFile(path.string()); + + for (const HumanDoor& door : doors.doors()) { + ProcessDoor(door, current_map_name); + } + } + + void ProcessDoor(const HumanDoor& h_door, + const std::string& current_map_name) { + uint64_t door_id = + container_.FindOrAddDoor(current_map_name, h_door.name(), std::nullopt); + Door& door = *container_.all_objects().mutable_doors(door_id); + + std::copy( + h_door.receivers().begin(), h_door.receivers().end(), + google::protobuf::RepeatedFieldBackInserter(door.mutable_receivers())); + std::copy( + h_door.switches().begin(), h_door.switches().end(), + google::protobuf::RepeatedFieldBackInserter(door.mutable_switches())); + + for (const PaintingIdentifier& pi : h_door.move_paintings()) { + std::optional map_name = + pi.has_map() ? std::optional(pi.map()) : std::nullopt; + door.add_move_paintings(container_.FindOrAddPainting( + map_name, pi.room(), pi.name(), current_map_name, std::nullopt)); + } + + for (const PanelIdentifier& pi : h_door.panels()) { + ProxyIdentifier* proxy = door.add_panels(); + + std::optional map_name = + pi.has_map() ? std::optional(pi.map()) : std::nullopt; + proxy->set_panel(container_.FindOrAddPanel( + map_name, pi.room(), pi.name(), current_map_name, std::nullopt)); + + if (pi.has_answer()) { + proxy->set_answer(pi.answer()); + } + } + + if (h_door.has_control_center_color()) { + door.set_control_center_color(h_door.control_center_color()); + } + + door.set_type(h_door.type()); + } + void ProcessConnectionsFile(std::filesystem::path path, std::optional current_map_name) { if (!std::filesystem::exists(path)) { @@ -80,7 +278,7 @@ class DataPacker { r_connection.set_to_room(f_connection.from_room()); if (human_connection.has_to_room()) { - r_connection.set_to_room(container_.FindOrAddRoom( + r_connection.set_from_room(container_.FindOrAddRoom( std::nullopt, human_connection.to_room(), current_map_name)); } else if (human_connection.has_to()) { ProcessSingleConnection(human_connection.to(), current_map_name, -- cgit 1.4.1