#include #include #include #include #include #include #include #include #include "proto/human.pb.h" #include "util/naming.h" namespace com::fourisland::lingo2_archipelago { namespace { template T ReadMessageFromFile(const std::string& path) { std::cout << "Processing " << path << std::endl; std::ifstream file(path); std::stringstream buffer; buffer << file.rdbuf(); T message; google::protobuf::TextFormat::ParseFromString(buffer.str(), &message); return message; } class AssignIds { public: AssignIds(const std::string& mapdir) : mapdir_(mapdir) {} void Run() { std::filesystem::path datadir_path = mapdir_; std::filesystem::path ids_path = datadir_path / "ids.txtpb"; ReadIds(ids_path); ProcessMaps(datadir_path); WriteIds(ids_path); std::cout << "Next ID: " << next_id_ << std::endl; } void ReadIds(std::filesystem::path path) { id_mappings_ = ReadMessageFromFile(path.string()); for (const auto& [_, map] : id_mappings_.maps()) { for (const auto& [_, id] : map.doors()) { if (id > next_id_) { next_id_ = id; } } for (const auto& [_, room] : map.rooms()) { for (const auto& [_, id] : room.panels()) { if (id > next_id_) { next_id_ = id; } } for (const auto& [_, id] : room.masteries()) { if (id > next_id_) { next_id_ = id; } } } } for (const auto& [_, id] : id_mappings_.special()) { if (id > next_id_) { next_id_ = id; } } for (const auto& [_, id] : id_mappings_.letters()) { if (id > next_id_) { next_id_ = id; } } next_id_++; } void WriteIds(std::filesystem::path path) { std::string output; google::protobuf::TextFormat::PrintToString(id_mappings_, &output); { std::ofstream outputfile(path.string()); outputfile << output; } } void ProcessMaps(std::filesystem::path path) { std::filesystem::path maps_dir = path / "maps"; for (auto const& dir_entry : std::filesystem::directory_iterator(maps_dir)) { ProcessMap(dir_entry.path()); } } void ProcessMap(std::filesystem::path path) { std::string map_name = path.filename(); ProcessDoorsFile(path / "doors.txtpb", map_name); ProcessRooms(path / "rooms", map_name); } void ProcessDoorsFile(std::filesystem::path path, const std::string& current_map_name) { if (!std::filesystem::exists(path)) { return; } auto doors = ReadMessageFromFile(path.string()); for (const HumanDoor& door : doors.doors()) { ProcessDoor(door, current_map_name); } } void ProcessDoor(const HumanDoor& h_door, const std::string& current_map_name) { if (h_door.type() == DoorType::EVENT) { return; } if (!id_mappings_.maps().contains(current_map_name) || !id_mappings_.maps() .at(current_map_name) .doors() .contains(h_door.name())) { auto& maps = *id_mappings_.mutable_maps(); auto& doors = *maps[current_map_name].mutable_doors(); doors[h_door.name()] = next_id_++; } } void ProcessRooms(std::filesystem::path path, const std::string& current_map_name) { for (auto const& dir_entry : std::filesystem::directory_iterator(path)) { auto room = ReadMessageFromFile(dir_entry.path().string()); ProcessRoom(room, current_map_name); } } void ProcessRoom(const HumanRoom& h_room, const std::string& current_map_name) { for (const HumanPanel& h_panel : h_room.panels()) { if (!id_mappings_.maps().contains(current_map_name) || !id_mappings_.maps() .at(current_map_name) .rooms() .contains(h_room.name()) || !id_mappings_.maps() .at(current_map_name) .rooms() .at(h_room.name()) .panels() .contains(h_panel.name())) { auto& maps = *id_mappings_.mutable_maps(); auto& rooms = *maps[current_map_name].mutable_rooms(); auto& panels = *rooms[h_room.name()].mutable_panels(); panels[h_panel.name()] = next_id_++; } } for (const HumanLetter& h_letter : h_room.letters()) { std::string lettername = GetLetterName(h_letter.key(), h_letter.level2()); if (!id_mappings_.letters().contains(lettername)) { auto& letters = *id_mappings_.mutable_letters(); letters[lettername] = next_id_++; } } for (const HumanMastery& h_mastery : h_room.masteries()) { if (!id_mappings_.maps().contains(current_map_name) || !id_mappings_.maps() .at(current_map_name) .rooms() .contains(h_room.name()) || !id_mappings_.maps() .at(current_map_name) .rooms() .at(h_room.name()) .masteries() .contains(h_mastery.name())) { auto& maps = *id_mappings_.mutable_maps(); auto& rooms = *maps[current_map_name].mutable_rooms(); auto& masteries = *rooms[h_room.name()].mutable_masteries(); masteries[h_mastery.name()] = next_id_++; } } } private: std::string mapdir_; uint64_t next_id_ = 0; IdMappings id_mappings_; }; } // namespace } // namespace com::fourisland::lingo2_archipelago int main(int argc, char** argv) { if (argc != 2) { std::cout << "Incorrect argument count." << std::endl; std::cout << "Usage: assign_ids [path to map directory]" << std::endl; return 1; } std::string mapdir = argv[1]; com::fourisland::lingo2_archipelago::AssignIds assign_ids(mapdir); assign_ids.Run(); return 0; }#n62'>62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101
name: "Starting Room"
panel_display_name: "Starting Room"
panels {
  name: "HI"
  path: "Panels/Entry/entry_proxying_1"
  clue: "hi"
  answer: "hi"
  proxies { answer: "hi" path: "Panels/Entry/entry_proxied_1" }
  proxies { answer: "bye" path: "Panels/Entry/entry_proxied_2" }
  proxies { answer: "hidden" path: "Panels/Entry/entry_proxied_5" }
  proxies { answer: "high" path: "Panels/Entry/entry_proxied_3" }
  proxies { answer: "hide" path: "Panels/Entry/entry_proxied_4" }
  proxies { answer: "thewords" path: "Components/Listeners/entry_proxied_6" }
}
panels {
  name: "TRICK"
  path: "Panels/Entry/side_1"
  clue: "trick"
  answer: "trick"
  proxies { answer: "treat" path: "Panels/Entry/side_proxy_1" }
}
panels {
  name: "EYE"
  path: "Panels/Entry/front_1"
  clue: "eye"
  answer: "i"
  #symbols: ZERO
  # This panel blocks getting N1 and T1. We will mod it to be I/I with no symbol
  # when symbol shuffle is on.
}
panels {
  name: "HINT"
  path: "Panels/Entry/second_right"
  clue: "hint"
  answer: "hint"
}
panels {
  name: "THIN"
  path: "Panels/Entry/second_left"
  clue: "thin"
  answer: "thin"
}
panels {
  name: "THAN"
  path: "Panels/D/d_entry"
  clue: "than"
  answer: "than"
}
panels {
  name: "Gift Maps"
  exclude_from_panelsanity: true
  path: "Components/GiftMapEntrance/Panel"
  clue: "player"
  answer: ""
  # The puzzle solution doesn't matter. We'll change it to the player's name
  # for fun.
  symbols: QUESTION
  proxies { answer: "gongus" path: "Components/GiftMapEntrance/GongusPanel" }
  proxies { answer: "hatkirby" path: "Components/GiftMapEntrance/HatkirbyPanel" }
  proxies { answer: "icely" path: "Components/GiftMapEntrance/IcelyPanel" }
  proxies { answer: "kirby" path: "Components/GiftMapEntrance/KirbyPanel" }
  proxies { answer: "kiwi" path: "Components/GiftMapEntrance/KiwiPanel" }
  proxies { answer: "q" path: "Components/GiftMapEntrance/QPanel" }
  proxies { answer: "souvey" path: "Components/GiftMapEntrance/SouveyPanel" }
  proxies { answer: "star" path: "Components/GiftMapEntrance/StarPanel" }
  required_door { name: "Gift Maps Entrance" }
}
letters {
  key: "h"
  path: "Components/Collectables/h"
}
letters {
  key: "i"
  path: "Components/Collectables/i"
}
letters {
  key: "n"
  path: "Components/Collectables/n"
}
letters {
  key: "t"
  path: "Components/Collectables/t"
}
# Maze painting should stay vanilla as a hint.
paintings {
  name: "OWL"
  path: "Components/Paintings/owl"
  move: true # how do
  enter_only: true
  orientation: "north"
  required_door { name: "Least Blue Last Panels" }
  display_name: "Near Trick Painting"
}
paintings {
  name: "PAINS"
  path: "Components/Paintings/pains3"
  enter_only: true
  orientation: "east"
  required_door { name: "Near D Room Painting" }
  display_name: "Near D Room Painting"
}