From c88f4184eaa48efbdc69e76eb3c8a4a206434ad3 Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Sat, 16 Aug 2025 14:52:24 -0400 Subject: 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). --- tools/util/identifiers.cpp | 102 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 102 insertions(+) create mode 100644 tools/util/identifiers.cpp (limited to 'tools/util/identifiers.cpp') 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 @@ +#include "identifiers.h" + +#include + +#include "proto/human.pb.h" + +namespace com::fourisland::lingo2_archipelago { + +std::optional GetCompleteRoomIdentifier( + RoomIdentifier identifier, std::optional map_name) { + if (!identifier.has_map()) { + if (!map_name) { + return std::nullopt; + } + identifier.set_map(*map_name); + } + return identifier; +} + +std::optional GetCompleteDoorIdentifier( + DoorIdentifier identifier, std::optional map_name) { + if (!identifier.has_map()) { + if (!map_name) { + return std::nullopt; + } + identifier.set_map(*map_name); + } + return identifier; +} + +std::optional GetCompletePortIdentifier( + PortIdentifier identifier, std::optional map_name, + std::optional room_name) { + if (!identifier.has_map()) { + if (!map_name) { + return std::nullopt; + } + identifier.set_map(*map_name); + } + if (!identifier.has_room()) { + if (!room_name) { + return std::nullopt; + } + identifier.set_room(*room_name); + } + return identifier; +} + +std::optional GetCompletePaintingIdentifier( + PaintingIdentifier identifier, std::optional map_name, + std::optional room_name) { + if (!identifier.has_map()) { + if (!map_name) { + return std::nullopt; + } + identifier.set_map(*map_name); + } + if (!identifier.has_room()) { + if (!room_name) { + return std::nullopt; + } + identifier.set_room(*room_name); + } + return identifier; +} + +std::optional GetCompletePanelIdentifierWithoutAnswer( + PanelIdentifier identifier, std::optional map_name, + std::optional room_name) { + if (!identifier.has_map()) { + if (!map_name) { + return std::nullopt; + } + identifier.set_map(*map_name); + } + if (!identifier.has_room()) { + if (!room_name) { + return std::nullopt; + } + identifier.set_room(*room_name); + } + identifier.clear_answer(); + return identifier; +} + +std::optional GetCompleteKeyholderIdentifierWithoutKey( + KeyholderIdentifier identifier, const std::string& map_name, + std::optional room_name) { + if (!identifier.has_map()) { + identifier.set_map(map_name); + } + if (!identifier.has_room()) { + if (!room_name) { + return std::nullopt; + } + identifier.set_room(*room_name); + } + identifier.clear_key(); + return identifier; +} + +} // namespace com::fourisland::lingo2_archipelago -- cgit 1.4.1