about summary refs log tree commit diff stats
path: root/CMakeLists.txt
diff options
context:
space:
mode:
authorStar Rauchenberger <fefferburbia@gmail.com>2025-08-30 10:58:54 -0400
committerStar Rauchenberger <fefferburbia@gmail.com>2025-08-30 10:58:54 -0400
commit3b77044a6a53d38a6960eb2a5855283a00b24d75 (patch)
treeb32a19aa6b1cf3646e1796660ba11d0306c36947 /CMakeLists.txt
parent9b9f1248528090f5cdd37770a7df5b15d8804d86 (diff)
downloadlingo2-archipelago-3b77044a6a53d38a6960eb2a5855283a00b24d75.tar.gz
lingo2-archipelago-3b77044a6a53d38a6960eb2a5855283a00b24d75.tar.bz2
lingo2-archipelago-3b77044a6a53d38a6960eb2a5855283a00b24d75.zip
[Apworld] Require CC access + letters for CC color doors
Diffstat (limited to 'CMakeLists.txt')
0 files changed, 0 insertions, 0 deletions
/a> 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270
#include "validator.h"

#include <iostream>

#include "proto/human.pb.h"
#include "structs.h"
#include "util/identifiers.h"

namespace com::fourisland::lingo2_archipelago {
namespace {

void ValidateMap(const std::string& map_name, const MapInfo& map_info) {
  for (const auto& [node_path, node_info] : map_info.game_nodes) {
    if (node_info.uses > 1) {
      std::cout << "Map " << map_name << " node " << node_path
                << " is used in multiple places." << std::endl;
    } else if (node_info.uses == 0) {
      std::cout << "Map " << map_name << " node " << node_path
                << " is not used." << std::endl;
    }

    if (!node_info.defined) {
      std::cout << "Map " << map_name << " node " << node_path
                << " is not defined in the game file." << std::endl;
    }
  }
}

void ValidateRoom(const RoomIdentifier& room_identifier,
                  const RoomInfo& room_info) {
  if (room_info.definitions.empty()) {
    std::cout << "Room " << room_identifier.ShortDebugString()
              << " has no definition, but was referenced:" << std::endl;

    for (const DoorIdentifier& door_identifier :
         room_info.doors_referenced_by) {
      std::cout << "    DOOR " << door_identifier.ShortDebugString()
                << std::endl;
    }

    for (const PanelIdentifier& panel_identifier :
         room_info.panels_referenced_by) {
      std::cout << "    PANEL " << panel_identifier.ShortDebugString()
                << std::endl;
    }

    for (const HumanConnection& connection :
         room_info.connections_referenced_by) {
      std::cout << "    CONNECTION " << connection.ShortDebugString()
                << std::endl;
    }
  } else if (room_info.definitions.size() > 1) {
    std::cout << "Room " << room_identifier.ShortDebugString()
              << " was defined multiple times." << std::endl;
  }
}

void ValidateDoor(const DoorIdentifier& door_identifier,
                  const DoorInfo& door_info) {
  if (door_info.definitions.empty()) {
    std::cout << "Door " << door_identifier.ShortDebugString()
              << " has no definition, but was referenced:" << std::endl;

    for (const DoorIdentifier& other_door_identifier :
         door_info.doors_referenced_by) {
      std::cout << "    DOOR " << other_door_identifier.ShortDebugString()
                << std::endl;
    }

    for (const PanelIdentifier& panel_identifier :
         door_info.panels_referenced_by) {
      std::cout << "    PANEL " << panel_identifier.ShortDebugString()
                << std::endl;
    }

    for (const PaintingIdentifier& painting_identifier :
         door_info.paintings_referenced_by) {
      std::cout << "    PAINTING " << painting_identifier.ShortDebugString()
                << std::endl;
    }

    for (const PortIdentifier& port_identifier :
         door_info.ports_referenced_by) {
      std::cout << "    PORT " << port_identifier.ShortDebugString()
                << std::endl;
    }

    for (const HumanConnection& connection :
         door_info.connections_referenced_by) {
      std::cout << "    CONNECTION " << connection.ShortDebugString()
                << std::endl;
    }
  } else if (door_info.definitions.size() > 1) {
    std::cout << "Door " << door_identifier.ShortDebugString()
              << " was defined multiple times." << std::endl;
  }

  if (door_info.malformed_identifiers.HasAny()) {
    std::cout << "Door " << door_identifier.ShortDebugString()
              << " has malformed identifiers:" << std::endl;

    for (const PaintingIdentifier& painting_identifier :
         door_info.malformed_identifiers.paintings) {
      std::cout << "    PAINTING " << painting_identifier.ShortDebugString()
                << std::endl;
    }

    for (const PanelIdentifier& panel_identifier :
         door_info.malformed_identifiers.panels) {
      std::cout << "    PANEL " << panel_identifier.ShortDebugString()
                << std::endl;
    }

    for (const KeyholderIdentifier& keyholder_identifier :
         door_info.malformed_identifiers.keyholders) {
      std::cout << "    KEYHOLDER " << keyholder_identifier.ShortDebugString()
                << std::endl;
    }
  }
}

void ValidatePort(const PortIdentifier& port_identifier,
                  const PortInfo& port_info) {
  if (port_info.definitions.empty()) {
    std::cout << "Port " << port_identifier.ShortDebugString()
              << " has no definition, but was referenced:" << std::endl;

    for (const HumanConnection& connection :
         port_info.connections_referenced_by) {
      std::cout << "    CONNECTION " << connection.ShortDebugString()
                << std::endl;
    }
  } else if (port_info.definitions.size() > 1) {
    std::cout << "Port " << port_identifier.ShortDebugString()
              << " was defined multiple times." << std::endl;
  }
}

void ValidatePainting(const PaintingIdentifier& painting_identifier,
                      const PaintingInfo& painting_info) {
  if (painting_info.definitions.empty()) {
    std::cout << "Painting " << painting_identifier.ShortDebugString()
              << " has no definition, but was referenced:" << std::endl;

    for (const DoorIdentifier& door_identifier :
         painting_info.doors_referenced_by) {
      std::cout << "    DOOR " << door_identifier.ShortDebugString()
                << std::endl;
    }

    for (const HumanConnection& connection :
         painting_info.connections_referenced_by) {
      std::cout << "    CONNECTION " << connection.ShortDebugString()
                << std::endl;
    }
  } else if (painting_info.definitions.size() > 1) {
    std::cout << "Painting " << painting_identifier.ShortDebugString()
              << " was defined multiple times." << std::endl;
  }
}

void ValidatePanel(const PanelIdentifier& panel_identifier,
                   const PanelInfo& panel_info) {
  if (panel_info.definitions.empty()) {
    std::cout << "Panel " << panel_identifier.ShortDebugString()
              << " has no definition, but was referenced:" << std::endl;

    for (const DoorIdentifier& door_identifier :
         panel_info.doors_referenced_by) {
      std::cout << "    DOOR " << door_identifier.ShortDebugString()
                << std::endl;
    }

    for (const HumanConnection& connection :
         panel_info.connections_referenced_by) {
      std::cout << "    CONNECTION " << connection.ShortDebugString()
                << std::endl;
    }
  } else if (panel_info.definitions.size() > 1) {
    std::cout << "Panel " << panel_identifier.ShortDebugString()
              << " was defined multiple times." << std::endl;
  }

  for (const auto& [answer, proxy_info] : panel_info.proxies) {
    if (proxy_info.definitions.empty()) {
      std::cout << "Panel " << panel_identifier.ShortDebugString()
                << " with answer \"" << answer
                << "\" has no definition, but was referenced:" << std::endl;

      for (const DoorIdentifier& door_identifier :
           proxy_info.doors_referenced_by) {
        std::cout << "    DOOR " << door_identifier.ShortDebugString()
                  << std::endl;
      }

      for (const HumanConnection& connection :
           proxy_info.connections_referenced_by) {
        std::cout << "    CONNECTION " << connection.ShortDebugString()
                  << std::endl;
      }
    } else if (proxy_info.definitions.size() > 1) {
      std::cout << "Panel " << panel_identifier.ShortDebugString()
                << " with answer \"" << answer
                << "\" was defined multiple times." << std::endl;
    }
  }
}

void ValidateKeyholder(const KeyholderIdentifier& keyholder_identifier,
                       const KeyholderInfo& keyholder_info) {
  if (keyholder_info.definitions.empty()) {
    std::cout << "Keyholder " << keyholder_identifier.ShortDebugString()
              << " has no definition, but was referenced:" << std::endl;

    for (const DoorIdentifier& door_identifier :
         keyholder_info.doors_referenced_by) {
      std::cout << "    DOOR " << door_identifier.ShortDebugString()
                << std::endl;
    }
  } else if (keyholder_info.definitions.size() > 1) {
    std::cout << "Keyholder " << keyholder_identifier.ShortDebugString()
              << " was defined multiple times." << std::endl;
  }
}

void ValidateLetter(const LetterIdentifier& letter_identifier,
                    const LetterInfo& letter_info) {
  std::string letter_name = std::string(1, std::get<0>(letter_identifier)) +
                            (std::get<1>(letter_identifier) ? "2" : "1");

  if (letter_info.defined_in.size() > 1) {
    std::cout << "Letter " << letter_name
              << " was defined in multiple places:" << std::endl;

    for (const RoomIdentifier& room_identifier : letter_info.defined_in) {
      std::cout << "    " << room_identifier.ShortDebugString() << std::endl;
    }
  }
}

}  // namespace

void ValidateCollectedInfo(const CollectedInfo& info) {
  for (const auto& [map_name, map_info] : info.maps) {
    ValidateMap(map_name, map_info);
  }
  for (const auto& [room_identifier, room_info] : info.rooms) {
    ValidateRoom(room_identifier, room_info);
  }
  for (const auto& [door_identifier, door_info] : info.doors) {
    ValidateDoor(door_identifier, door_info);
  }
  for (const auto& [port_identifier, port_info] : info.ports) {
    ValidatePort(port_identifier, port_info);
  }
  for (const auto& [painting_identifier, painting_info] : info.paintings) {
    ValidatePainting(painting_identifier, painting_info);
  }
  for (const auto& [panel_identifier, panel_info] : info.panels) {
    ValidatePanel(panel_identifier, panel_info);
  }
  for (const auto& [keyholder_identifier, keyholder_info] : info.keyholders) {
    ValidateKeyholder(keyholder_identifier, keyholder_info);
  }
  for (const auto& [letter_identifier, letter_info] : info.letters) {
    ValidateLetter(letter_identifier, letter_info);
  }
}

}  // namespace com::fourisland::lingo2_archipelago