diff options
| author | Star Rauchenberger <fefferburbia@gmail.com> | 2025-08-16 14:52:24 -0400 |
|---|---|---|
| committer | Star Rauchenberger <fefferburbia@gmail.com> | 2025-08-16 14:52:24 -0400 |
| commit | c88f4184eaa48efbdc69e76eb3c8a4a206434ad3 (patch) | |
| tree | c1da4c419d90debafdd7f71347fe5f3194ff13ee /tools/util/identifiers.cpp | |
| parent | ac600120eb923e99c534f5c405f7f529c1b25bcf (diff) | |
| download | lingo2-archipelago-c88f4184eaa48efbdc69e76eb3c8a4a206434ad3.tar.gz lingo2-archipelago-c88f4184eaa48efbdc69e76eb3c8a4a206434ad3.tar.bz2 lingo2-archipelago-c88f4184eaa48efbdc69e76eb3c8a4a206434ad3.zip | |
Started writing a data validator
Currently, it can check whether identifiers point to non-existent objects, or whether multiple objects share the same identifier. It can also determine whether an identifier is underspecified (e.g. a door doesn't specify a room, or a global connection doesn't specify a map).
Diffstat (limited to 'tools/util/identifiers.cpp')
| -rw-r--r-- | tools/util/identifiers.cpp | 102 |
1 files changed, 102 insertions, 0 deletions
| diff --git a/tools/util/identifiers.cpp b/tools/util/identifiers.cpp new file mode 100644 index 0000000..5b51c57 --- /dev/null +++ b/tools/util/identifiers.cpp | |||
| @@ -0,0 +1,102 @@ | |||
| 1 | #include "identifiers.h" | ||
| 2 | |||
| 3 | #include <string> | ||
| 4 | |||
| 5 | #include "proto/human.pb.h" | ||
| 6 | |||
| 7 | namespace com::fourisland::lingo2_archipelago { | ||
| 8 | |||
| 9 | std::optional<RoomIdentifier> GetCompleteRoomIdentifier( | ||
| 10 | RoomIdentifier identifier, std::optional<std::string> map_name) { | ||
| 11 | if (!identifier.has_map()) { | ||
| 12 | if (!map_name) { | ||
| 13 | return std::nullopt; | ||
| 14 | } | ||
| 15 | identifier.set_map(*map_name); | ||
| 16 | } | ||
| 17 | return identifier; | ||
| 18 | } | ||
| 19 | |||
| 20 | std::optional<DoorIdentifier> GetCompleteDoorIdentifier( | ||
| 21 | DoorIdentifier identifier, std::optional<std::string> map_name) { | ||
| 22 | if (!identifier.has_map()) { | ||
| 23 | if (!map_name) { | ||
| 24 | return std::nullopt; | ||
| 25 | } | ||
| 26 | identifier.set_map(*map_name); | ||
| 27 | } | ||
| 28 | return identifier; | ||
| 29 | } | ||
| 30 | |||
| 31 | std::optional<PortIdentifier> GetCompletePortIdentifier( | ||
| 32 | PortIdentifier identifier, std::optional<std::string> map_name, | ||
| 33 | std::optional<std::string> room_name) { | ||
| 34 | if (!identifier.has_map()) { | ||
| 35 | if (!map_name) { | ||
| 36 | return std::nullopt; | ||
| 37 | } | ||
| 38 | identifier.set_map(*map_name); | ||
| 39 | } | ||
| 40 | if (!identifier.has_room()) { | ||
| 41 | if (!room_name) { | ||
| 42 | return std::nullopt; | ||
| 43 | } | ||
| 44 | identifier.set_room(*room_name); | ||
| 45 | } | ||
| 46 | return identifier; | ||
| 47 | } | ||
| 48 | |||
| 49 | std::optional<PaintingIdentifier> GetCompletePaintingIdentifier( | ||
| 50 | PaintingIdentifier identifier, std::optional<std::string> map_name, | ||
| 51 | std::optional<std::string> room_name) { | ||
| 52 | if (!identifier.has_map()) { | ||
| 53 | if (!map_name) { | ||
| 54 | return std::nullopt; | ||
| 55 | } | ||
| 56 | identifier.set_map(*map_name); | ||
| 57 | } | ||
| 58 | if (!identifier.has_room()) { | ||
| 59 | if (!room_name) { | ||
| 60 | return std::nullopt; | ||
| 61 | } | ||
| 62 | identifier.set_room(*room_name); | ||
| 63 | } | ||
| 64 | return identifier; | ||
| 65 | } | ||
| 66 | |||
| 67 | std::optional<PanelIdentifier> GetCompletePanelIdentifierWithoutAnswer( | ||
| 68 | PanelIdentifier identifier, std::optional<std::string> map_name, | ||
| 69 | std::optional<std::string> room_name) { | ||
| 70 | if (!identifier.has_map()) { | ||
| 71 | if (!map_name) { | ||
| 72 | return std::nullopt; | ||
| 73 | } | ||
| 74 | identifier.set_map(*map_name); | ||
| 75 | } | ||
| 76 | if (!identifier.has_room()) { | ||
| 77 | if (!room_name) { | ||
| 78 | return std::nullopt; | ||
| 79 | } | ||
| 80 | identifier.set_room(*room_name); | ||
| 81 | } | ||
| 82 | identifier.clear_answer(); | ||
| 83 | return identifier; | ||
| 84 | } | ||
| 85 | |||
| 86 | std::optional<KeyholderIdentifier> GetCompleteKeyholderIdentifierWithoutKey( | ||
| 87 | KeyholderIdentifier identifier, const std::string& map_name, | ||
| 88 | std::optional<std::string> room_name) { | ||
| 89 | if (!identifier.has_map()) { | ||
| 90 | identifier.set_map(map_name); | ||
| 91 | } | ||
| 92 | if (!identifier.has_room()) { | ||
| 93 | if (!room_name) { | ||
| 94 | return std::nullopt; | ||
| 95 | } | ||
| 96 | identifier.set_room(*room_name); | ||
| 97 | } | ||
| 98 | identifier.clear_key(); | ||
| 99 | return identifier; | ||
| 100 | } | ||
| 101 | |||
| 102 | } // namespace com::fourisland::lingo2_archipelago | ||
