diff options
| author | Star Rauchenberger <fefferburbia@gmail.com> | 2025-08-09 11:51:20 -0400 |
|---|---|---|
| committer | Star Rauchenberger <fefferburbia@gmail.com> | 2025-08-09 11:51:20 -0400 |
| commit | 9ca8681ca5f134d65eaa4b5ae68d57ba67fe98d6 (patch) | |
| tree | 6d58ffe2e9a60eac681b22b0cb0bd03baf74990c /tools/datapacker/container.cpp | |
| parent | 3fcc676cd3b9b3b24a8755612a459d498879b1df (diff) | |
| download | lingo2-archipelago-9ca8681ca5f134d65eaa4b5ae68d57ba67fe98d6.tar.gz lingo2-archipelago-9ca8681ca5f134d65eaa4b5ae68d57ba67fe98d6.tar.bz2 lingo2-archipelago-9ca8681ca5f134d65eaa4b5ae68d57ba67fe98d6.zip | |
Added support for masteries
Also assigned IDs for the_butterfly, as well as already configured letters.
Diffstat (limited to 'tools/datapacker/container.cpp')
| -rw-r--r-- | tools/datapacker/container.cpp | 77 |
1 files changed, 77 insertions, 0 deletions
| diff --git a/tools/datapacker/container.cpp b/tools/datapacker/container.cpp index ead3818..29fa1a5 100644 --- a/tools/datapacker/container.cpp +++ b/tools/datapacker/container.cpp | |||
| @@ -1,5 +1,9 @@ | |||
| 1 | #include "container.h" | 1 | #include "container.h" |
| 2 | 2 | ||
| 3 | #include <iostream> | ||
| 4 | |||
| 5 | #include "util/naming.h" | ||
| 6 | |||
| 3 | namespace com::fourisland::lingo2_archipelago { | 7 | namespace com::fourisland::lingo2_archipelago { |
| 4 | 8 | ||
| 5 | uint64_t Container::FindOrAddMap(std::string map_name) { | 9 | uint64_t Container::FindOrAddMap(std::string map_name) { |
| @@ -169,6 +173,79 @@ uint64_t Container::FindOrAddPanel(std::optional<std::string> map_name, | |||
| 169 | } | 173 | } |
| 170 | } | 174 | } |
| 171 | 175 | ||
| 176 | uint64_t Container::FindOrAddLetter(std::string key, bool double_) { | ||
| 177 | std::string letter_name = GetLetterName(key, double_); | ||
| 178 | |||
| 179 | auto it = letter_id_by_name_.find(letter_name); | ||
| 180 | if (it == letter_id_by_name_.end()) { | ||
| 181 | uint64_t new_id = all_objects_.letters_size(); | ||
| 182 | Letter* letter = all_objects_.add_letters(); | ||
| 183 | letter->set_id(new_id); | ||
| 184 | letter->set_key(key); | ||
| 185 | |||
| 186 | if (double_) { | ||
| 187 | letter->set_double_(double_); | ||
| 188 | } | ||
| 189 | |||
| 190 | letter_id_by_name_[letter_name] = new_id; | ||
| 191 | |||
| 192 | return new_id; | ||
| 193 | } else { | ||
| 194 | return it->second; | ||
| 195 | } | ||
| 196 | } | ||
| 197 | |||
| 198 | uint64_t Container::FindLetterByName(std::string letter_name) { | ||
| 199 | auto it = letter_id_by_name_.find(letter_name); | ||
| 200 | if (it == letter_id_by_name_.end()) { | ||
| 201 | std::cout << "Could not find letter by name: " << letter_name << std::endl; | ||
| 202 | exit(2); | ||
| 203 | } else { | ||
| 204 | return it->second; | ||
| 205 | } | ||
| 206 | } | ||
| 207 | |||
| 208 | uint64_t Container::FindOrAddMastery(std::optional<std::string> map_name, | ||
| 209 | std::optional<std::string> room_name, | ||
| 210 | std::string mastery_name, | ||
| 211 | std::optional<std::string> map_fallback, | ||
| 212 | std::optional<std::string> room_fallback) { | ||
| 213 | if (!map_name) { | ||
| 214 | if (!map_fallback) { | ||
| 215 | std::cout << "No map name provided for " << mastery_name << std::endl; | ||
| 216 | map_name = "global"; | ||
| 217 | } else { | ||
| 218 | map_name = map_fallback; | ||
| 219 | } | ||
| 220 | } | ||
| 221 | |||
| 222 | if (!room_name) { | ||
| 223 | if (!room_fallback) { | ||
| 224 | std::cout << "No room name provided for " << mastery_name << std::endl; | ||
| 225 | room_name = "global"; | ||
| 226 | } else { | ||
| 227 | room_name = room_fallback; | ||
| 228 | } | ||
| 229 | } | ||
| 230 | |||
| 231 | auto& room_container = | ||
| 232 | mastery_id_by_map_room_mastery_names_[*map_name][*room_name]; | ||
| 233 | auto it = room_container.find(mastery_name); | ||
| 234 | if (it == room_container.end()) { | ||
| 235 | uint64_t new_id = all_objects_.masteries_size(); | ||
| 236 | Mastery* mastery = all_objects_.add_masteries(); | ||
| 237 | mastery->set_id(new_id); | ||
| 238 | mastery->set_room_id(FindOrAddRoom(map_name, *room_name, std::nullopt)); | ||
| 239 | mastery->set_name(mastery_name); | ||
| 240 | |||
| 241 | room_container[mastery_name] = new_id; | ||
| 242 | |||
| 243 | return new_id; | ||
| 244 | } else { | ||
| 245 | return it->second; | ||
| 246 | } | ||
| 247 | } | ||
| 248 | |||
| 172 | uint64_t Container::FindOrAddDoor(std::optional<std::string> map_name, | 249 | uint64_t Container::FindOrAddDoor(std::optional<std::string> map_name, |
| 173 | std::string door_name, | 250 | std::string door_name, |
| 174 | std::optional<std::string> map_fallback) { | 251 | std::optional<std::string> map_fallback) { |
