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.h | |
| 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.h')
| -rw-r--r-- | tools/util/identifiers.h | 85 |
1 files changed, 85 insertions, 0 deletions
| diff --git a/tools/util/identifiers.h b/tools/util/identifiers.h new file mode 100644 index 0000000..341dee1 --- /dev/null +++ b/tools/util/identifiers.h | |||
| @@ -0,0 +1,85 @@ | |||
| 1 | #ifndef TOOLS_UTIL_IDENTIFIERS_H_ | ||
| 2 | #define TOOLS_UTIL_IDENTIFIERS_H_ | ||
| 3 | |||
| 4 | #include <optional> | ||
| 5 | #include <string> | ||
| 6 | #include <utility> | ||
| 7 | |||
| 8 | #include "proto/human.pb.h" | ||
| 9 | |||
| 10 | namespace com::fourisland::lingo2_archipelago { | ||
| 11 | |||
| 12 | class RoomIdentifierLess { | ||
| 13 | public: | ||
| 14 | bool operator()(const RoomIdentifier& lhs, const RoomIdentifier& rhs) const { | ||
| 15 | return std::tie(lhs.map(), lhs.name()) < std::tie(rhs.map(), rhs.name()); | ||
| 16 | } | ||
| 17 | }; | ||
| 18 | |||
| 19 | class DoorIdentifierLess { | ||
| 20 | public: | ||
| 21 | bool operator()(const DoorIdentifier& lhs, const DoorIdentifier& rhs) const { | ||
| 22 | return std::tie(lhs.map(), lhs.name()) < std::tie(rhs.map(), rhs.name()); | ||
| 23 | } | ||
| 24 | }; | ||
| 25 | |||
| 26 | class PortIdentifierLess { | ||
| 27 | public: | ||
| 28 | bool operator()(const PortIdentifier& lhs, const PortIdentifier& rhs) const { | ||
| 29 | return std::tie(lhs.map(), lhs.room(), lhs.name()) < | ||
| 30 | std::tie(rhs.map(), rhs.room(), rhs.name()); | ||
| 31 | } | ||
| 32 | }; | ||
| 33 | |||
| 34 | class PaintingIdentifierLess { | ||
| 35 | public: | ||
| 36 | bool operator()(const PaintingIdentifier& lhs, | ||
| 37 | const PaintingIdentifier& rhs) const { | ||
| 38 | return std::tie(lhs.map(), lhs.room(), lhs.name()) < | ||
| 39 | std::tie(rhs.map(), rhs.room(), rhs.name()); | ||
| 40 | } | ||
| 41 | }; | ||
| 42 | |||
| 43 | class PanelIdentifierLess { | ||
| 44 | public: | ||
| 45 | bool operator()(const PanelIdentifier& lhs, | ||
| 46 | const PanelIdentifier& rhs) const { | ||
| 47 | return std::tie(lhs.map(), lhs.room(), lhs.name(), lhs.answer()) < | ||
| 48 | std::tie(rhs.map(), rhs.room(), rhs.name(), rhs.answer()); | ||
| 49 | } | ||
| 50 | }; | ||
| 51 | |||
| 52 | class KeyholderIdentifierLess { | ||
| 53 | public: | ||
| 54 | bool operator()(const KeyholderIdentifier& lhs, | ||
| 55 | const KeyholderIdentifier& rhs) const { | ||
| 56 | return std::tie(lhs.map(), lhs.room(), lhs.name(), lhs.key()) < | ||
| 57 | std::tie(rhs.map(), rhs.room(), rhs.name(), rhs.key()); | ||
| 58 | } | ||
| 59 | }; | ||
| 60 | |||
| 61 | std::optional<RoomIdentifier> GetCompleteRoomIdentifier( | ||
| 62 | RoomIdentifier identifier, std::optional<std::string> map_name); | ||
| 63 | |||
| 64 | std::optional<DoorIdentifier> GetCompleteDoorIdentifier( | ||
| 65 | DoorIdentifier identifier, std::optional<std::string> map_name); | ||
| 66 | |||
| 67 | std::optional<PortIdentifier> GetCompletePortIdentifier( | ||
| 68 | PortIdentifier identifier, std::optional<std::string> map_name, | ||
| 69 | std::optional<std::string> room_name); | ||
| 70 | |||
| 71 | std::optional<PaintingIdentifier> GetCompletePaintingIdentifier( | ||
| 72 | PaintingIdentifier identifier, std::optional<std::string> map_name, | ||
| 73 | std::optional<std::string> room_name); | ||
| 74 | |||
| 75 | std::optional<PanelIdentifier> GetCompletePanelIdentifierWithoutAnswer( | ||
| 76 | PanelIdentifier identifier, std::optional<std::string> map_name, | ||
| 77 | std::optional<std::string> room_name); | ||
| 78 | |||
| 79 | std::optional<KeyholderIdentifier> GetCompleteKeyholderIdentifierWithoutKey( | ||
| 80 | KeyholderIdentifier identifier, const std::string& map_name, | ||
| 81 | std::optional<std::string> room_name); | ||
| 82 | |||
| 83 | } // namespace com::fourisland::lingo2_archipelago | ||
| 84 | |||
| 85 | #endif /* TOOLS_UTIL_IDENTIFIERS_H_ */ | ||
