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.h | 85 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 tools/util/identifiers.h (limited to 'tools/util/identifiers.h') 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 @@ +#ifndef TOOLS_UTIL_IDENTIFIERS_H_ +#define TOOLS_UTIL_IDENTIFIERS_H_ + +#include +#include +#include + +#include "proto/human.pb.h" + +namespace com::fourisland::lingo2_archipelago { + +class RoomIdentifierLess { + public: + bool operator()(const RoomIdentifier& lhs, const RoomIdentifier& rhs) const { + return std::tie(lhs.map(), lhs.name()) < std::tie(rhs.map(), rhs.name()); + } +}; + +class DoorIdentifierLess { + public: + bool operator()(const DoorIdentifier& lhs, const DoorIdentifier& rhs) const { + return std::tie(lhs.map(), lhs.name()) < std::tie(rhs.map(), rhs.name()); + } +}; + +class PortIdentifierLess { + public: + bool operator()(const PortIdentifier& lhs, const PortIdentifier& rhs) const { + return std::tie(lhs.map(), lhs.room(), lhs.name()) < + std::tie(rhs.map(), rhs.room(), rhs.name()); + } +}; + +class PaintingIdentifierLess { + public: + bool operator()(const PaintingIdentifier& lhs, + const PaintingIdentifier& rhs) const { + return std::tie(lhs.map(), lhs.room(), lhs.name()) < + std::tie(rhs.map(), rhs.room(), rhs.name()); + } +}; + +class PanelIdentifierLess { + public: + bool operator()(const PanelIdentifier& lhs, + const PanelIdentifier& rhs) const { + return std::tie(lhs.map(), lhs.room(), lhs.name(), lhs.answer()) < + std::tie(rhs.map(), rhs.room(), rhs.name(), rhs.answer()); + } +}; + +class KeyholderIdentifierLess { + public: + bool operator()(const KeyholderIdentifier& lhs, + const KeyholderIdentifier& rhs) const { + return std::tie(lhs.map(), lhs.room(), lhs.name(), lhs.key()) < + std::tie(rhs.map(), rhs.room(), rhs.name(), rhs.key()); + } +}; + +std::optional GetCompleteRoomIdentifier( + RoomIdentifier identifier, std::optional map_name); + +std::optional GetCompleteDoorIdentifier( + DoorIdentifier identifier, std::optional map_name); + +std::optional GetCompletePortIdentifier( + PortIdentifier identifier, std::optional map_name, + std::optional room_name); + +std::optional GetCompletePaintingIdentifier( + PaintingIdentifier identifier, std::optional map_name, + std::optional room_name); + +std::optional GetCompletePanelIdentifierWithoutAnswer( + PanelIdentifier identifier, std::optional map_name, + std::optional room_name); + +std::optional GetCompleteKeyholderIdentifierWithoutKey( + KeyholderIdentifier identifier, const std::string& map_name, + std::optional room_name); + +} // namespace com::fourisland::lingo2_archipelago + +#endif /* TOOLS_UTIL_IDENTIFIERS_H_ */ -- cgit 1.4.1