diff options
author | Star Rauchenberger <fefferburbia@gmail.com> | 2025-08-12 16:55:17 -0400 |
---|---|---|
committer | Star Rauchenberger <fefferburbia@gmail.com> | 2025-08-12 16:55:17 -0400 |
commit | 4c8a38dfc0121343396d2a0d734cf1445d05b60c (patch) | |
tree | ccaf6dd1dc6fee60ced5ae19c5d0bb5db1217fcb /tools/datapacker | |
parent | 447a222b57e498f7904033c59e68d21d6a246abd (diff) | |
download | lingo2-archipelago-4c8a38dfc0121343396d2a0d734cf1445d05b60c.tar.gz lingo2-archipelago-4c8a38dfc0121343396d2a0d734cf1445d05b60c.tar.bz2 lingo2-archipelago-4c8a38dfc0121343396d2a0d734cf1445d05b60c.zip |
Converted to proto2
This will let us use an older version of protobuf in Python, and allows us to use the Godot protobuf implementation at all. Scalar fields with custom defaults in data.proto were changed to not have a default, because Godot doesn't handle it properly. The equivalent fields in human.proto still have the defaults, and datapacker copies the default value in if necessary. The Panel message in data.proto was also renamed to PanelData because otherwise it conflicts with the native Godot class named Panel. The double field in Letter was renamed to level2, because Godot couldn't handle it well. Finally, common.proto was removed and its contents were moved into data.proto, which allows us to generate code for Python without needing to edit it. NOTE: I had to slightly modify the Godot protobuf code generator. I'll need to upload that somewhere.
Diffstat (limited to 'tools/datapacker')
-rw-r--r-- | tools/datapacker/container.cpp | 10 | ||||
-rw-r--r-- | tools/datapacker/container.h | 2 | ||||
-rw-r--r-- | tools/datapacker/main.cpp | 16 |
3 files changed, 14 insertions, 14 deletions
diff --git a/tools/datapacker/container.cpp b/tools/datapacker/container.cpp index bb58ec5..ffcb75a 100644 --- a/tools/datapacker/container.cpp +++ b/tools/datapacker/container.cpp | |||
@@ -160,7 +160,7 @@ uint64_t Container::FindOrAddPanel(std::optional<std::string> map_name, | |||
160 | auto it = room_container.find(panel_name); | 160 | auto it = room_container.find(panel_name); |
161 | if (it == room_container.end()) { | 161 | if (it == room_container.end()) { |
162 | uint64_t new_id = all_objects_.panels_size(); | 162 | uint64_t new_id = all_objects_.panels_size(); |
163 | Panel* panel = all_objects_.add_panels(); | 163 | PanelData* panel = all_objects_.add_panels(); |
164 | panel->set_id(new_id); | 164 | panel->set_id(new_id); |
165 | panel->set_room_id(FindOrAddRoom(map_name, *room_name, std::nullopt)); | 165 | panel->set_room_id(FindOrAddRoom(map_name, *room_name, std::nullopt)); |
166 | panel->set_name(panel_name); | 166 | panel->set_name(panel_name); |
@@ -173,8 +173,8 @@ uint64_t Container::FindOrAddPanel(std::optional<std::string> map_name, | |||
173 | } | 173 | } |
174 | } | 174 | } |
175 | 175 | ||
176 | uint64_t Container::FindOrAddLetter(std::string key, bool double_) { | 176 | uint64_t Container::FindOrAddLetter(std::string key, bool level2) { |
177 | std::string letter_name = GetLetterName(key, double_); | 177 | std::string letter_name = GetLetterName(key, level2); |
178 | 178 | ||
179 | auto it = letter_id_by_name_.find(letter_name); | 179 | auto it = letter_id_by_name_.find(letter_name); |
180 | if (it == letter_id_by_name_.end()) { | 180 | if (it == letter_id_by_name_.end()) { |
@@ -183,8 +183,8 @@ uint64_t Container::FindOrAddLetter(std::string key, bool double_) { | |||
183 | letter->set_id(new_id); | 183 | letter->set_id(new_id); |
184 | letter->set_key(key); | 184 | letter->set_key(key); |
185 | 185 | ||
186 | if (double_) { | 186 | if (level2) { |
187 | letter->set_double_(double_); | 187 | letter->set_level2(level2); |
188 | } | 188 | } |
189 | 189 | ||
190 | letter_id_by_name_[letter_name] = new_id; | 190 | letter_id_by_name_[letter_name] = new_id; |
diff --git a/tools/datapacker/container.h b/tools/datapacker/container.h index 7ee5b5b..e1a84d8 100644 --- a/tools/datapacker/container.h +++ b/tools/datapacker/container.h | |||
@@ -36,7 +36,7 @@ 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_); | 39 | uint64_t FindOrAddLetter(std::string key, bool level2); |
40 | 40 | ||
41 | uint64_t FindLetterByName(std::string letter_name); | 41 | uint64_t FindLetterByName(std::string letter_name); |
42 | 42 | ||
diff --git a/tools/datapacker/main.cpp b/tools/datapacker/main.cpp index d3908b4..8b87ab1 100644 --- a/tools/datapacker/main.cpp +++ b/tools/datapacker/main.cpp | |||
@@ -122,7 +122,7 @@ class DataPacker { | |||
122 | uint64_t panel_id = | 122 | uint64_t panel_id = |
123 | container_.FindOrAddPanel(current_map_name, current_room_name, | 123 | container_.FindOrAddPanel(current_map_name, current_room_name, |
124 | h_panel.name(), std::nullopt, std::nullopt); | 124 | h_panel.name(), std::nullopt, std::nullopt); |
125 | Panel& panel = *container_.all_objects().mutable_panels(panel_id); | 125 | PanelData& panel = *container_.all_objects().mutable_panels(panel_id); |
126 | 126 | ||
127 | panel.set_path(h_panel.path()); | 127 | panel.set_path(h_panel.path()); |
128 | panel.set_clue(h_panel.clue()); | 128 | panel.set_clue(h_panel.clue()); |
@@ -169,9 +169,9 @@ class DataPacker { | |||
169 | painting.set_display_name(h_painting.display_name()); | 169 | painting.set_display_name(h_painting.display_name()); |
170 | painting.set_orientation(h_painting.orientation()); | 170 | painting.set_orientation(h_painting.orientation()); |
171 | 171 | ||
172 | if (h_painting.has_gravity()) { | 172 | // Setting this explicitly because the Godot protobuf doesn't support |
173 | painting.set_gravity(h_painting.gravity()); | 173 | // custom defaults. |
174 | } | 174 | painting.set_gravity(h_painting.gravity()); |
175 | 175 | ||
176 | if (h_painting.has_move()) { | 176 | if (h_painting.has_move()) { |
177 | painting.set_move(h_painting.move()); | 177 | painting.set_move(h_painting.move()); |
@@ -208,9 +208,9 @@ class DataPacker { | |||
208 | port.set_path(h_port.path()); | 208 | port.set_path(h_port.path()); |
209 | port.set_orientation(h_port.orientation()); | 209 | port.set_orientation(h_port.orientation()); |
210 | 210 | ||
211 | if (h_port.has_gravity()) { | 211 | // Setting this explicitly because the Godot protobuf doesn't support |
212 | port.set_gravity(h_port.gravity()); | 212 | // custom defaults. |
213 | } | 213 | port.set_gravity(h_port.gravity()); |
214 | 214 | ||
215 | if (h_port.has_required_door()) { | 215 | if (h_port.has_required_door()) { |
216 | std::optional<std::string> map_name = | 216 | std::optional<std::string> map_name = |
@@ -228,7 +228,7 @@ class DataPacker { | |||
228 | const std::string& current_map_name, | 228 | const std::string& current_map_name, |
229 | const std::string& current_room_name) { | 229 | const std::string& current_room_name) { |
230 | uint64_t letter_id = | 230 | uint64_t letter_id = |
231 | container_.FindOrAddLetter(h_letter.key(), h_letter.double_()); | 231 | container_.FindOrAddLetter(h_letter.key(), h_letter.level2()); |
232 | Letter& letter = *container_.all_objects().mutable_letters(letter_id); | 232 | Letter& letter = *container_.all_objects().mutable_letters(letter_id); |
233 | 233 | ||
234 | letter.set_room_id(container_.FindOrAddRoom( | 234 | letter.set_room_id(container_.FindOrAddRoom( |