diff options
author | Star Rauchenberger <fefferburbia@gmail.com> | 2025-08-18 12:56:13 -0400 |
---|---|---|
committer | Star Rauchenberger <fefferburbia@gmail.com> | 2025-08-18 12:56:13 -0400 |
commit | 1ac21d4a67ddd211fda841aa6e368bc2cf52a3d6 (patch) | |
tree | bdcf651c156c27982e37bddb7cb7e0b09aa90d5a /tools/validator/godot_processor.cpp | |
parent | 15b8794bbe80be0bcf1f482674455efe002cec2c (diff) | |
download | lingo2-archipelago-1ac21d4a67ddd211fda841aa6e368bc2cf52a3d6.tar.gz lingo2-archipelago-1ac21d4a67ddd211fda841aa6e368bc2cf52a3d6.tar.bz2 lingo2-archipelago-1ac21d4a67ddd211fda841aa6e368bc2cf52a3d6.zip |
Validate that nodes in game files are used
You can now also list out nodes that you are explicitly not mapping out. The current state of the repo does produce some warnings when the validator is run and they're either endings, paintings that I'm not sure what to do with yet, and weird proxy stuff I'm not sure how to handle yet.
Diffstat (limited to 'tools/validator/godot_processor.cpp')
-rw-r--r-- | tools/validator/godot_processor.cpp | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/tools/validator/godot_processor.cpp b/tools/validator/godot_processor.cpp new file mode 100644 index 0000000..f345cff --- /dev/null +++ b/tools/validator/godot_processor.cpp | |||
@@ -0,0 +1,76 @@ | |||
1 | #include "godot_processor.h" | ||
2 | |||
3 | #include <filesystem> | ||
4 | #include <iostream> | ||
5 | #include <memory> | ||
6 | #include <set> | ||
7 | |||
8 | #include "structs.h" | ||
9 | #include "util/godot_scene.h" | ||
10 | |||
11 | namespace com::fourisland::lingo2_archipelago { | ||
12 | |||
13 | namespace { | ||
14 | |||
15 | static const std::set<std::string> kImportantNodeTypes = { | ||
16 | "res://objects/nodes/panel.tscn", "res://objects/nodes/worldport.tscn", | ||
17 | "res://objects/nodes/keyHolder.tscn", | ||
18 | "res://objects/nodes/collectable.tscn"}; | ||
19 | |||
20 | class GodotProcessor { | ||
21 | public: | ||
22 | GodotProcessor(const std::string& repodir, CollectedInfo& info) | ||
23 | : repodir_(repodir), info_(info) {} | ||
24 | |||
25 | void Run() { | ||
26 | for (auto& [map_name, map_info] : info_.maps) { | ||
27 | ProcessMap(map_name, map_info); | ||
28 | } | ||
29 | } | ||
30 | |||
31 | void ProcessMap(const std::string& map_name, MapInfo& map_info) { | ||
32 | std::filesystem::path scene_path = std::filesystem::path(repodir_) / | ||
33 | "objects" / "scenes" / | ||
34 | (map_name + ".tscn"); | ||
35 | std::string scene_path_str = scene_path.string(); | ||
36 | std::cout << "Processing " << scene_path_str << std::endl; | ||
37 | |||
38 | std::unique_ptr<GodotScene> scene = | ||
39 | ReadGodotSceneFromFile(scene_path_str); | ||
40 | |||
41 | ProcessMapNode(*scene, scene->GetRoot(), map_info); | ||
42 | } | ||
43 | |||
44 | void ProcessMapNode(const GodotScene& scene, const GodotNode& node, | ||
45 | MapInfo& map_info) { | ||
46 | if (std::holds_alternative<GodotExtResourceRef>(node.GetInstanceType())) { | ||
47 | const GodotExtResourceRef& ext_resource_ref = | ||
48 | std::get<GodotExtResourceRef>(node.GetInstanceType()); | ||
49 | const GodotExtResource* ext_resource = | ||
50 | scene.GetExtResource(ext_resource_ref.id); | ||
51 | |||
52 | if (ext_resource != nullptr && | ||
53 | (kImportantNodeTypes.count(ext_resource->path) || | ||
54 | ext_resource->path.starts_with("res://objects/meshes/paintings/"))) { | ||
55 | map_info.game_nodes[node.GetPath()].defined = true; | ||
56 | } | ||
57 | } | ||
58 | |||
59 | for (const auto& [child_name, child_node] : node.GetChildren()) { | ||
60 | ProcessMapNode(scene, *child_node, map_info); | ||
61 | } | ||
62 | } | ||
63 | |||
64 | private: | ||
65 | std::string repodir_; | ||
66 | CollectedInfo& info_; | ||
67 | }; | ||
68 | |||
69 | } // namespace | ||
70 | |||
71 | void ProcessGodotData(const std::string& repodir, CollectedInfo& info) { | ||
72 | GodotProcessor godot_processor(repodir, info); | ||
73 | godot_processor.Run(); | ||
74 | } | ||
75 | |||
76 | } // namespace com::fourisland::lingo2_archipelago | ||