upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/runtime/test/mods_test.cpp
diff options
context:
space:
mode:
authorItsNotRexed <300290919+ItsNotRexed@users.noreply.github.com>2026-11-23 06:28:03 -0500
committerItsNotRexed <300290919+ItsNotRexed@users.noreply.github.com>2026-11-23 06:28:03 -0500
commit561b65a832218fbb9e6d2effd392a8eef093a3f8 (patch)
tree039a055a8fb00d648dffcfb82e2f96d143229bf1 /runtime/test/mods_test.cpp
parenta4d7182243ddcbe1f729ba0845e2932ee6df7423 (diff)
parent3faac557b1584d39004357918e60325b4d4ff0fe (diff)
Merge remote-tracking branch 'origin/main' into triage-r44
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> # Conflicts: # .github/workflows/runtime.yml # tests/test_first_look_shim_report.py
Diffstat (limited to 'runtime/test/mods_test.cpp')
-rw-r--r--runtime/test/mods_test.cpp28
1 files changed, 28 insertions, 0 deletions
diff --git a/runtime/test/mods_test.cpp b/runtime/test/mods_test.cpp
index d6d369426..c61182c3c 100644
--- a/runtime/test/mods_test.cpp
+++ b/runtime/test/mods_test.cpp
@@ -56,6 +56,34 @@ int main() {
56 check(!parse_mod("[1,2]", "m", mod, error), "a manifest that is not an object is refused"); 56 check(!parse_mod("[1,2]", "m", mod, error), "a manifest that is not an object is refused");
57 check(parse_mod("{}", "folder_name", mod, error) && mod.name == "folder_name", "the name defaults to the folder"); 57 check(parse_mod("{}", "folder_name", mod, error) && mod.name == "folder_name", "the name defaults to the folder");
58 58
59 // "camera": first-person view (docs/modding.md, "First-person view")
60 check(parse_mod(R"({"camera":{"view_mode":"first_person","first_person_value":4,"contexts":[0]}})", "fp", mod,
61 error) && mod.camera.set && mod.camera.first_person && mod.camera.first_person_value == 4 &&
62 mod.camera.contexts.size() == 1 && mod.camera.contexts[0] == 0,
63 "a first-person camera section parses");
64 check(parse_mod(R"({"camera":{"view_mode":"default"}})", "d", mod, error) && mod.camera.set &&
65 !mod.camera.first_person,
66 "\"default\" leaves the game's view mode");
67 check(!parse_mod(R"({"camera":{"view_mode":"top_down"}})", "x", mod, error), "an unknown view mode is refused");
68 check(!parse_mod(R"({"camera":{"view_mode":"first_person","first_person_value":4.5}})", "x", mod, error),
69 "a fractional enum value is refused");
70 check(!parse_mod(R"({"camera":{"view_mode":"first_person","contexts":"all"}})", "x", mod, error),
71 "contexts must be a list");
72
73 Mod fp_on_foot, fp_everywhere, off;
74 check(parse_mod(R"({"camera":{"view_mode":"first_person","contexts":[0]}})", "a", fp_on_foot, error) &&
75 parse_mod(R"({"camera":{"view_mode":"first_person","first_person_value":7}})", "b", fp_everywhere,
76 error) &&
77 parse_mod(R"({"enabled":false,"camera":{"view_mode":"default"}})", "c", off, error),
78 "three camera mods parse");
79 set_active_camera(camera_of({fp_on_foot}));
80 check(override_view_mode(2, 0) == 4, "on foot (context 0) the view becomes first person");
81 check(override_view_mode(2, 1) == 2, "a context the mod does not list keeps the game's view");
82 set_active_camera(camera_of({fp_on_foot, fp_everywhere, off}));
83 check(override_view_mode(1, 5) == 7, "the last enabled camera mod decides (a disabled one is skipped)");
84 set_active_camera(camera_of({}));
85 check(override_view_mode(3, 0) == 3, "with no camera mod the game's view mode passes through");
86
59 const auto dir = std::filesystem::temp_directory_path() / "leonida_mods_test"; 87 const auto dir = std::filesystem::temp_directory_path() / "leonida_mods_test";
60 std::filesystem::remove_all(dir); 88 std::filesystem::remove_all(dir);
61 write(dir / "a_mandy" / "mod.json", 89 write(dir / "a_mandy" / "mod.json",