about summary refs log tree commit diff stats
path: root/tools/validator/main.cpp
blob: 1a72e9abc255156afb53b0413ebe1e25b82e9e77 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include "godot_processor.h"
#include "human_processor.h"
#include "structs.h"
#include "validator.h"

namespace com::fourisland::lingo2_archipelago {
namespace {

void Run(const std::string& mapdir, const std::string& repodir) {
  CollectedInfo info;

  ProcessHumanData(mapdir, info);
  ProcessGodotData(repodir, info);

  ValidateCollectedInfo(info);
}

}  // namespace
}  // namespace com::fourisland::lingo2_archipelago

int main(int argc, char** argv) {
  if (argc != 3) {
    std::cout << "Incorrect argument count." << std::endl;
    std::cout << "Usage: validator [path to map directory] [path to Lingo 2 repository]" << std::endl;
    return 1;
  }

  std::string mapdir = argv[1];
  std::string repodir = argv[2];

  com::fourisland::lingo2_archipelago::Run(mapdir, repodir);

  return 0;
}
lass="n">std::string& map_name, MapInfo& map_info) { std::filesystem::path scene_path = std::filesystem::path(repodir_) / "objects" / "scenes" / (map_name + ".tscn"); std::string scene_path_str = scene_path.string(); std::cout << "Processing " << scene_path_str << std::endl; GodotScene scene = ReadGodotSceneFromFile(scene_path_str); for (const GodotNode& node : scene.GetNodes()) { ProcessMapNode(scene, node, map_info); } } void ProcessMapNode(const GodotScene& scene, const GodotNode& node, MapInfo& map_info) { if (std::holds_alternative<GodotExtResourceRef>(node.instance_type)) { const GodotExtResourceRef& ext_resource_ref = std::get<GodotExtResourceRef>(node.instance_type); const GodotExtResource* ext_resource = scene.GetExtResource(ext_resource_ref.id); if (ext_resource != nullptr && (kImportantNodeTypes.count(ext_resource->path) || ext_resource->path.starts_with("res://objects/meshes/paintings/"))) { map_info.game_nodes[node.GetPath()].defined = true; } } } private: std::string repodir_; CollectedInfo& info_; }; } // namespace void ProcessGodotData(const std::string& repodir, CollectedInfo& info) { GodotProcessor godot_processor(repodir, info); godot_processor.Run(); } } // namespace com::fourisland::lingo2_archipelago