diff options
-rw-r--r-- | data/maps/the_entry/doors.txtpb | 14 | ||||
-rw-r--r-- | data/maps/the_entry/rooms/Entry Exit.txtpb | 2 | ||||
-rw-r--r-- | data/maps/the_entry/rooms/Starting Room.txtpb | 6 | ||||
-rw-r--r-- | proto/common.proto | 18 | ||||
-rw-r--r-- | proto/data.proto | 8 | ||||
-rw-r--r-- | proto/human.proto | 19 | ||||
-rw-r--r-- | tools/datapacker/container.h | 2 | ||||
-rw-r--r-- | 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 { | |||
141 | name: "Control Center White Door" | 141 | name: "Control Center White Door" |
142 | type: CONTROL_CENTER_COLOR | 142 | type: CONTROL_CENTER_COLOR |
143 | receivers: "Components/Doors/back_left_7" | 143 | receivers: "Components/Doors/back_left_7" |
144 | control_center_color: white | 144 | control_center_color: "white" |
145 | } | 145 | } |
146 | # exit_1 should maybe just be removed. | 146 | # exit_1 should maybe just be removed. |
147 | # entry_proxied_1 is part of the vanilla intro. | 147 | # entry_proxied_1 is part of the vanilla intro. |
@@ -265,4 +265,16 @@ doors { | |||
265 | panels { room: "Least Blue Last" name: "TRUST" } | 265 | panels { room: "Least Blue Last" name: "TRUST" } |
266 | panels { room: "Least Blue Last" name: "LABEL" } | 266 | panels { room: "Least Blue Last" name: "LABEL" } |
267 | panels { room: "Least Blue Last" name: "AIL" } | 267 | panels { room: "Least Blue Last" name: "AIL" } |
268 | } | ||
269 | doors { | ||
270 | name: "Red Room Painting" | ||
271 | type: STANDARD | ||
272 | move_paintings { room: "Right Eye" name: "PSYCHIC" } | ||
273 | panels { room: "Right Eye" name: "FAINT" } | ||
274 | } | ||
275 | doors { | ||
276 | name: "Third Eye Painting" | ||
277 | type: STANDARD | ||
278 | move_paintings { room: "Eye Room" name: "GALLERY" } | ||
279 | panels { room: "Eye Room" name: "I" } | ||
268 | } \ No newline at end of file | 280 | } \ 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" | |||
3 | ports { | 3 | ports { |
4 | name: "GREAT" | 4 | name: "GREAT" |
5 | path: "Components/Warps/worldport2" | 5 | path: "Components/Warps/worldport2" |
6 | orientation: north | 6 | orientation: "north" |
7 | } \ No newline at end of file | 7 | } \ 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 { | |||
32 | answer: "hint" | 32 | answer: "hint" |
33 | } | 33 | } |
34 | panels { | 34 | panels { |
35 | id: "THIN" | 35 | name: "THIN" |
36 | path: "Panels/Entry/second_left" | 36 | path: "Panels/Entry/second_left" |
37 | clue: "thin" | 37 | clue: "thin" |
38 | answer: "thin" | 38 | answer: "thin" |
@@ -54,7 +54,7 @@ paintings { | |||
54 | move: true # how do | 54 | move: true # how do |
55 | enter_only: true | 55 | enter_only: true |
56 | orientation: "north" | 56 | orientation: "north" |
57 | required_door { door: "Least Blue Last Panels" } | 57 | required_door { name: "Least Blue Last Panels" } |
58 | display_name: "Near Trick Painting" | 58 | display_name: "Near Trick Painting" |
59 | } | 59 | } |
60 | paintings { | 60 | paintings { |
@@ -62,7 +62,7 @@ paintings { | |||
62 | path: "Components/Paintings/pains3" | 62 | path: "Components/Paintings/pains3" |
63 | enter_only: true | 63 | enter_only: true |
64 | orientation: "east" | 64 | orientation: "east" |
65 | required_door { door: "Near D Room Painting" } | 65 | required_door { name: "Near D Room Painting" } |
66 | display_name: "Near D Room Painting" | 66 | display_name: "Near D Room Painting" |
67 | } | 67 | } |
68 | ports { | 68 | 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 { | |||
8 | } | 8 | } |
9 | 9 | ||
10 | message Letter { | 10 | message Letter { |
11 | string letter = 1; | 11 | string key = 1; |
12 | bool double = 2; | 12 | bool double = 2; |
13 | } | 13 | } |
14 | |||
15 | enum DoorType { | ||
16 | DOOR_TYPE_UNKNOWN = 0; | ||
17 | |||
18 | // This door is a location unless panelsanity is on, and it is an item as long as door shuffle is on. | ||
19 | STANDARD = 1; | ||
20 | |||
21 | // This door is never an item or a location. | ||
22 | EVENT = 2; | ||
23 | |||
24 | // This door is never a location, and is an item as long as door shuffle is on. | ||
25 | ITEM_ONLY = 3; | ||
26 | |||
27 | // This door is never a location, and is an item as long as control center color shuffle is on. | ||
28 | CONTROL_CENTER_COLOR = 4; | ||
29 | } | ||
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 { | |||
23 | 23 | ||
24 | message Door { | 24 | message Door { |
25 | uint64 id = 1; | 25 | uint64 id = 1; |
26 | uint64 map_id = 10; | 26 | uint64 map_id = 9; |
27 | string name = 2; | 27 | string name = 2; |
28 | 28 | ||
29 | repeated string receivers = 3; | 29 | repeated string receivers = 3; |
@@ -33,8 +33,7 @@ message Door { | |||
33 | string control_center_color = 6; | 33 | string control_center_color = 6; |
34 | repeated string switches = 7; | 34 | repeated string switches = 7; |
35 | 35 | ||
36 | repeated string location_tags = 8; | 36 | DoorType type = 8; |
37 | repeated string item_tags = 9; | ||
38 | } | 37 | } |
39 | 38 | ||
40 | message Panel { | 39 | message Panel { |
@@ -42,8 +41,7 @@ message Panel { | |||
42 | uint64 room_id = 2; | 41 | uint64 room_id = 2; |
43 | string name = 3; | 42 | string name = 3; |
44 | 43 | ||
45 | string nodepath = 4; | 44 | string path = 4; |
46 | |||
47 | string clue = 5; | 45 | string clue = 5; |
48 | string answer = 6; | 46 | string answer = 6; |
49 | repeated string symbols = 7; | 47 | 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 { | |||
62 | } | 62 | } |
63 | 63 | ||
64 | message HumanDoor { | 64 | message HumanDoor { |
65 | enum DoorType { | ||
66 | DOOR_TYPE_UNKNOWN = 0; | ||
67 | |||
68 | // This door is a location unless panelsanity is on, and it is an item as long as door shuffle is on. | ||
69 | STANDARD = 1; | ||
70 | |||
71 | // This door is never an item or a location. | ||
72 | EVENT = 2; | ||
73 | |||
74 | // This door is never a location, and is an item as long as door shuffle is on. | ||
75 | ITEM_ONLY = 3; | ||
76 | |||
77 | // This door is never a location, and is an item as long as control center color shuffle is on. | ||
78 | CONTROL_CENTER_COLOR = 4; | ||
79 | } | ||
80 | |||
81 | string name = 1; | 65 | string name = 1; |
82 | 66 | ||
83 | repeated string receivers = 2; | 67 | repeated string receivers = 2; |
@@ -87,8 +71,7 @@ message HumanDoor { | |||
87 | string control_center_color = 6; | 71 | string control_center_color = 6; |
88 | repeated string switches = 7; | 72 | repeated string switches = 7; |
89 | 73 | ||
90 | repeated string location_tags = 4; | 74 | DoorType type = 4; |
91 | repeated string item_tags = 5; | ||
92 | } | 75 | } |
93 | 76 | ||
94 | message HumanDoors { | 77 | 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 { | |||
42 | 42 | ||
43 | void AddConnection(const Connection& connection); | 43 | void AddConnection(const Connection& connection); |
44 | 44 | ||
45 | const AllObjects& all_objects() const { return all_objects_; } | 45 | AllObjects& all_objects() { return all_objects_; } |
46 | 46 | ||
47 | private: | 47 | private: |
48 | AllObjects all_objects_; | 48 | 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 @@ | |||
1 | #include <google/protobuf/message.h> | 1 | #include <google/protobuf/message.h> |
2 | #include <google/protobuf/text_format.h> | 2 | #include <google/protobuf/text_format.h> |
3 | 3 | ||
4 | #include <algorithm> | ||
4 | #include <cstdint> | 5 | #include <cstdint> |
5 | #include <filesystem> | 6 | #include <filesystem> |
6 | #include <fstream> | 7 | #include <fstream> |
@@ -19,6 +20,8 @@ namespace { | |||
19 | 20 | ||
20 | template <typename T> | 21 | template <typename T> |
21 | T ReadMessageFromFile(const std::string& path) { | 22 | T ReadMessageFromFile(const std::string& path) { |
23 | std::cout << "Processing " << path << std::endl; | ||
24 | |||
22 | std::ifstream file(path); | 25 | std::ifstream file(path); |
23 | std::stringstream buffer; | 26 | std::stringstream buffer; |
24 | buffer << file.rdbuf(); | 27 | buffer << file.rdbuf(); |
@@ -38,6 +41,7 @@ class DataPacker { | |||
38 | std::filesystem::path datadir_path = mapdir_; | 41 | std::filesystem::path datadir_path = mapdir_; |
39 | 42 | ||
40 | ProcessConnectionsFile(datadir_path / "connections.txtpb", std::nullopt); | 43 | ProcessConnectionsFile(datadir_path / "connections.txtpb", std::nullopt); |
44 | ProcessMaps(datadir_path); | ||
41 | 45 | ||
42 | { | 46 | { |
43 | std::ofstream outputfile(outputpath_); | 47 | std::ofstream outputfile(outputpath_); |
@@ -51,6 +55,200 @@ class DataPacker { | |||
51 | } | 55 | } |
52 | 56 | ||
53 | private: | 57 | private: |
58 | void ProcessMaps(std::filesystem::path path) { | ||
59 | std::filesystem::path maps_dir = path / "maps"; | ||
60 | for (auto const& dir_entry : | ||
61 | std::filesystem::directory_iterator(maps_dir)) { | ||
62 | ProcessMap(dir_entry.path()); | ||
63 | } | ||
64 | } | ||
65 | |||
66 | void ProcessMap(std::filesystem::path path) { | ||
67 | std::string map_name = path.filename(); | ||
68 | |||
69 | ProcessConnectionsFile(path / "connections.txtpb", map_name); | ||
70 | ProcessDoorsFile(path / "doors.txtpb", map_name); | ||
71 | ProcessRooms(path / "rooms", map_name); | ||
72 | } | ||
73 | |||
74 | void ProcessRooms(std::filesystem::path path, | ||
75 | const std::string& current_map_name) { | ||
76 | for (auto const& dir_entry : std::filesystem::directory_iterator(path)) { | ||
77 | auto room = ReadMessageFromFile<HumanRoom>(dir_entry.path().string()); | ||
78 | ProcessRoom(room, current_map_name); | ||
79 | } | ||
80 | } | ||
81 | |||
82 | void ProcessRoom(const HumanRoom& h_room, | ||
83 | const std::string& current_map_name) { | ||
84 | uint64_t room_id = | ||
85 | container_.FindOrAddRoom(current_map_name, h_room.name(), std::nullopt); | ||
86 | Room& room = *container_.all_objects().mutable_rooms(room_id); | ||
87 | |||
88 | room.set_display_name(h_room.display_name()); | ||
89 | |||
90 | for (const HumanPanel& h_panel : h_room.panels()) { | ||
91 | room.add_panels(ProcessPanel(h_panel, current_map_name, room.name())); | ||
92 | } | ||
93 | |||
94 | for (const HumanPainting& h_painting : h_room.paintings()) { | ||
95 | room.add_paintings( | ||
96 | ProcessPainting(h_painting, current_map_name, room.name())); | ||
97 | } | ||
98 | |||
99 | for (const HumanPort& h_port : h_room.ports()) { | ||
100 | room.add_ports(ProcessPort(h_port, current_map_name, room.name())); | ||
101 | } | ||
102 | |||
103 | std::copy( | ||
104 | h_room.letters().begin(), h_room.letters().end(), | ||
105 | google::protobuf::RepeatedFieldBackInserter(room.mutable_letters())); | ||
106 | } | ||
107 | |||
108 | uint64_t ProcessPanel(const HumanPanel& h_panel, | ||
109 | const std::string& current_map_name, | ||
110 | const std::string& current_room_name) { | ||
111 | uint64_t panel_id = | ||
112 | container_.FindOrAddPanel(current_map_name, current_room_name, | ||
113 | h_panel.name(), std::nullopt, std::nullopt); | ||
114 | Panel& panel = *container_.all_objects().mutable_panels(panel_id); | ||
115 | |||
116 | panel.set_path(h_panel.path()); | ||
117 | panel.set_clue(h_panel.clue()); | ||
118 | panel.set_answer(h_panel.answer()); | ||
119 | |||
120 | std::copy( | ||
121 | h_panel.symbols().begin(), h_panel.symbols().end(), | ||
122 | google::protobuf::RepeatedFieldBackInserter(panel.mutable_symbols())); | ||
123 | std::copy( | ||
124 | h_panel.proxies().begin(), h_panel.proxies().end(), | ||
125 | google::protobuf::RepeatedFieldBackInserter(panel.mutable_proxies())); | ||
126 | |||
127 | if (h_panel.has_required_door()) { | ||
128 | std::optional<std::string> map_name = | ||
129 | h_panel.required_door().has_map() | ||
130 | ? std::optional<std::string>(h_panel.required_door().map()) | ||
131 | : std::nullopt; | ||
132 | panel.set_required_door(container_.FindOrAddDoor( | ||
133 | map_name, h_panel.required_door().name(), current_map_name)); | ||
134 | } | ||
135 | |||
136 | return panel_id; | ||
137 | } | ||
138 | |||
139 | uint64_t ProcessPainting(const HumanPainting& h_painting, | ||
140 | const std::string& current_map_name, | ||
141 | const std::string& current_room_name) { | ||
142 | uint64_t painting_id = container_.FindOrAddPainting( | ||
143 | current_map_name, current_room_name, h_painting.name(), std::nullopt, | ||
144 | std::nullopt); | ||
145 | Painting& painting = | ||
146 | *container_.all_objects().mutable_paintings(painting_id); | ||
147 | |||
148 | painting.set_path(h_painting.path()); | ||
149 | painting.set_display_name(h_painting.display_name()); | ||
150 | painting.set_orientation(h_painting.orientation()); | ||
151 | |||
152 | if (h_painting.has_flipped()) { | ||
153 | painting.set_flipped(h_painting.flipped()); | ||
154 | } | ||
155 | |||
156 | if (h_painting.has_move()) { | ||
157 | painting.set_move(h_painting.move()); | ||
158 | } | ||
159 | |||
160 | if (h_painting.has_enter_only()) { | ||
161 | painting.set_enter_only(h_painting.enter_only()); | ||
162 | } | ||
163 | |||
164 | if (h_painting.has_required_door()) { | ||
165 | std::optional<std::string> map_name = | ||
166 | h_painting.required_door().has_map() | ||
167 | ? std::optional<std::string>(h_painting.required_door().map()) | ||
168 | : std::nullopt; | ||
169 | painting.set_required_door(container_.FindOrAddDoor( | ||
170 | map_name, h_painting.required_door().name(), current_map_name)); | ||
171 | } | ||
172 | |||
173 | return painting_id; | ||
174 | } | ||
175 | |||
176 | uint64_t ProcessPort(const HumanPort& h_port, | ||
177 | const std::string& current_map_name, | ||
178 | const std::string& current_room_name) { | ||
179 | uint64_t port_id = | ||
180 | container_.FindOrAddPort(current_map_name, current_room_name, | ||
181 | h_port.name(), std::nullopt, std::nullopt); | ||
182 | Port& port = *container_.all_objects().mutable_ports(port_id); | ||
183 | |||
184 | port.set_path(h_port.path()); | ||
185 | port.set_orientation(h_port.orientation()); | ||
186 | |||
187 | if (h_port.has_required_door()) { | ||
188 | std::optional<std::string> map_name = | ||
189 | h_port.required_door().has_map() | ||
190 | ? std::optional<std::string>(h_port.required_door().map()) | ||
191 | : std::nullopt; | ||
192 | port.set_required_door(container_.FindOrAddDoor( | ||
193 | map_name, h_port.required_door().name(), current_map_name)); | ||
194 | } | ||
195 | |||
196 | return port_id; | ||
197 | } | ||
198 | |||
199 | void ProcessDoorsFile(std::filesystem::path path, | ||
200 | const std::string& current_map_name) { | ||
201 | if (!std::filesystem::exists(path)) { | ||
202 | return; | ||
203 | } | ||
204 | |||
205 | auto doors = ReadMessageFromFile<HumanDoors>(path.string()); | ||
206 | |||
207 | for (const HumanDoor& door : doors.doors()) { | ||
208 | ProcessDoor(door, current_map_name); | ||
209 | } | ||
210 | } | ||
211 | |||
212 | void ProcessDoor(const HumanDoor& h_door, | ||
213 | const std::string& current_map_name) { | ||
214 | uint64_t door_id = | ||
215 | container_.FindOrAddDoor(current_map_name, h_door.name(), std::nullopt); | ||
216 | Door& door = *container_.all_objects().mutable_doors(door_id); | ||
217 | |||
218 | std::copy( | ||
219 | h_door.receivers().begin(), h_door.receivers().end(), | ||
220 | google::protobuf::RepeatedFieldBackInserter(door.mutable_receivers())); | ||
221 | std::copy( | ||
222 | h_door.switches().begin(), h_door.switches().end(), | ||
223 | google::protobuf::RepeatedFieldBackInserter(door.mutable_switches())); | ||
224 | |||
225 | for (const PaintingIdentifier& pi : h_door.move_paintings()) { | ||
226 | std::optional<std::string> map_name = | ||
227 | pi.has_map() ? std::optional<std::string>(pi.map()) : std::nullopt; | ||
228 | door.add_move_paintings(container_.FindOrAddPainting( | ||
229 | map_name, pi.room(), pi.name(), current_map_name, std::nullopt)); | ||
230 | } | ||
231 | |||
232 | for (const PanelIdentifier& pi : h_door.panels()) { | ||
233 | ProxyIdentifier* proxy = door.add_panels(); | ||
234 | |||
235 | std::optional<std::string> map_name = | ||
236 | pi.has_map() ? std::optional<std::string>(pi.map()) : std::nullopt; | ||
237 | proxy->set_panel(container_.FindOrAddPanel( | ||
238 | map_name, pi.room(), pi.name(), current_map_name, std::nullopt)); | ||
239 | |||
240 | if (pi.has_answer()) { | ||
241 | proxy->set_answer(pi.answer()); | ||
242 | } | ||
243 | } | ||
244 | |||
245 | if (h_door.has_control_center_color()) { | ||
246 | door.set_control_center_color(h_door.control_center_color()); | ||
247 | } | ||
248 | |||
249 | door.set_type(h_door.type()); | ||
250 | } | ||
251 | |||
54 | void ProcessConnectionsFile(std::filesystem::path path, | 252 | void ProcessConnectionsFile(std::filesystem::path path, |
55 | std::optional<std::string> current_map_name) { | 253 | std::optional<std::string> current_map_name) { |
56 | if (!std::filesystem::exists(path)) { | 254 | if (!std::filesystem::exists(path)) { |
@@ -80,7 +278,7 @@ class DataPacker { | |||
80 | r_connection.set_to_room(f_connection.from_room()); | 278 | r_connection.set_to_room(f_connection.from_room()); |
81 | 279 | ||
82 | if (human_connection.has_to_room()) { | 280 | if (human_connection.has_to_room()) { |
83 | r_connection.set_to_room(container_.FindOrAddRoom( | 281 | r_connection.set_from_room(container_.FindOrAddRoom( |
84 | std::nullopt, human_connection.to_room(), current_map_name)); | 282 | std::nullopt, human_connection.to_room(), current_map_name)); |
85 | } else if (human_connection.has_to()) { | 283 | } else if (human_connection.has_to()) { |
86 | ProcessSingleConnection(human_connection.to(), current_map_name, | 284 | ProcessSingleConnection(human_connection.to(), current_map_name, |