From c7c0211afbb821c966d214a13b73dd0f62ffc90d Mon Sep 17 00:00:00 2001 From: xensik Date: Tue, 15 Mar 2022 17:00:55 +0100 Subject: [PATCH] update resolvers --- src/h1/xsk/resolver.cpp | 41 +++++++++++++++++++++++++++ src/h1/xsk/resolver.hpp | 1 + src/h2/xsk/resolver.cpp | 25 +++++++++++++++++ src/h2/xsk/resolver.hpp | 1 + src/iw5/xsk/resolver.cpp | 51 ++++++++++++++++++++++++++++++++++ src/iw5/xsk/resolver.hpp | 1 + src/iw6/xsk/resolver.cpp | 48 ++++++++++++++++++++++++++++++++ src/iw6/xsk/resolver.hpp | 1 + src/iw7/xsk/resolver.cpp | 25 +++++++++++++++++ src/iw7/xsk/resolver.hpp | 1 + src/iw8/xsk/resolver.cpp | 25 +++++++++++++++++ src/iw8/xsk/resolver.hpp | 1 + src/s1/xsk/resolver.cpp | 25 +++++++++++++++++ src/s1/xsk/resolver.hpp | 1 + src/s2/xsk/resolver.cpp | 25 +++++++++++++++++ src/s2/xsk/resolver.hpp | 1 + src/s4/xsk/resolver.cpp | 25 +++++++++++++++++ src/s4/xsk/resolver.hpp | 1 + src/t6/xsk/resolver.cpp | 60 ++++++++++++++++++++-------------------- 19 files changed, 329 insertions(+), 30 deletions(-) diff --git a/src/h1/xsk/resolver.cpp b/src/h1/xsk/resolver.cpp index abfa5904..3f732be0 100644 --- a/src/h1/xsk/resolver.cpp +++ b/src/h1/xsk/resolver.cpp @@ -240,6 +240,47 @@ auto resolver::file_data(const std::string& name) -> std::tuple paths +{ + "character"sv, + "codescripts"sv, + "common_scripts"sv, + "destructible_scripts"sv, + "maps"sv, + "mptype"sv, + "soundscripts"sv, + "vehicle_scripts"sv, + "xmodelalias"sv, + "maps/animated_models"sv, + "maps/createart"sv, + "maps/createfx"sv, + "maps/mp"sv, + "maps/mp/gametypes"sv, + "maps/mp/killstreaks"sv, + "maps/mp/perks"sv, +}; + +auto resolver::fs_to_game_path(const std::filesystem::path& file) -> std::filesystem::path +{ + auto result = std::filesystem::path(); + auto root = false; + + for (auto& entry : file) + { + if (!root && paths.contains(entry.string())) + { + result = entry; + root = true; + } + else if (paths.contains(result.string())) + { + result /= entry; + } + } + + return result.empty() ? file : result; +} + const std::array, 154> opcode_list {{ { 0x17, "SET_NEW_LOCAL_VARIABLE_FIELD_CACHED0" }, diff --git a/src/h1/xsk/resolver.hpp b/src/h1/xsk/resolver.hpp index 6032cfc9..aa8236fe 100644 --- a/src/h1/xsk/resolver.hpp +++ b/src/h1/xsk/resolver.hpp @@ -34,6 +34,7 @@ public: static auto make_token(std::string_view str) -> std::string; static auto file_data(const std::string& name) -> std::tuple; + static auto fs_to_game_path(const std::filesystem::path& file) -> std::filesystem::path; }; } // namespace xsk::gsc::h1 diff --git a/src/h2/xsk/resolver.cpp b/src/h2/xsk/resolver.cpp index 53a080a4..0dd49c11 100644 --- a/src/h2/xsk/resolver.cpp +++ b/src/h2/xsk/resolver.cpp @@ -240,6 +240,31 @@ auto resolver::file_data(const std::string& name) -> std::tuple paths +{ +}; + +auto resolver::fs_to_game_path(const std::filesystem::path& file) -> std::filesystem::path +{ + auto result = std::filesystem::path(); + auto root = false; + + for (auto& entry : file) + { + if (!root && paths.contains(entry.string())) + { + result = entry; + root = true; + } + else if (paths.contains(result.string())) + { + result /= entry; + } + } + + return result.empty() ? file : result; +} + const std::array, 154> opcode_list {{ { 0x17, "SET_NEW_LOCAL_VARIABLE_FIELD_CACHED0" }, diff --git a/src/h2/xsk/resolver.hpp b/src/h2/xsk/resolver.hpp index cbc90a28..765e1058 100644 --- a/src/h2/xsk/resolver.hpp +++ b/src/h2/xsk/resolver.hpp @@ -34,6 +34,7 @@ public: static auto make_token(std::string_view str) -> std::string; static auto file_data(const std::string& name) -> std::tuple; + static auto fs_to_game_path(const std::filesystem::path& file) -> std::filesystem::path; }; } // namespace xsk::gsc::h2 diff --git a/src/iw5/xsk/resolver.cpp b/src/iw5/xsk/resolver.cpp index 1958af30..d2f63147 100644 --- a/src/iw5/xsk/resolver.cpp +++ b/src/iw5/xsk/resolver.cpp @@ -296,6 +296,57 @@ auto resolver::file_data(const std::string& name) -> std::tuple paths +{ + "aitype"sv, + "animscripts"sv, + "character"sv, + "codescripts"sv, + "common_scripts"sv, + "maps"sv, + "mptype"sv, + "vehicle_scripts"sv, + "xmodelalias"sv, + "animscripts/civilian"sv, + "animscripts/dog"sv, + "animscripts/hummer_turret"sv, + "animscripts/riotshield"sv, + "animscripts/saw"sv, + "animscripts/scripted"sv, + "animscripts/technical"sv, + "animscripts/traverse"sv, + "maps/animated_models"sv, + "maps/cinematic_setups"sv, + "maps/createart"sv, + "maps/createfx"sv, + "maps/gametypes"sv, + "maps/mp"sv, + "maps/mp/gametypes"sv, + "maps/mp/killstreaks"sv, + "maps/mp/perks"sv, +}; + +auto resolver::fs_to_game_path(const std::filesystem::path& file) -> std::filesystem::path +{ + auto result = std::filesystem::path(); + auto root = false; + + for (auto& entry : file) + { + if (!root && paths.contains(entry.string())) + { + result = entry; + root = true; + } + else if (paths.contains(result.string())) + { + result /= entry; + } + } + + return result.empty() ? file : result; +} + const std::array, 153> opcode_list {{ { 0x00, "END" }, diff --git a/src/iw5/xsk/resolver.hpp b/src/iw5/xsk/resolver.hpp index 2b5cd728..38727dbb 100644 --- a/src/iw5/xsk/resolver.hpp +++ b/src/iw5/xsk/resolver.hpp @@ -37,6 +37,7 @@ public: static auto make_token(std::string_view str) -> std::string; static auto file_data(const std::string& name) -> std::tuple; + static auto fs_to_game_path(const std::filesystem::path& file) -> std::filesystem::path; }; } // namespace xsk::gsc::iw5 diff --git a/src/iw6/xsk/resolver.cpp b/src/iw6/xsk/resolver.cpp index 4cae160c..eb5e187a 100644 --- a/src/iw6/xsk/resolver.cpp +++ b/src/iw6/xsk/resolver.cpp @@ -240,6 +240,54 @@ auto resolver::file_data(const std::string& name) -> std::tuple paths +{ + "character"sv, + "codescripts"sv, + "common_scripts"sv, + "destructible_scripts"sv, + "maps"sv, + "vehicle_scripts"sv, + "xmodelalias"sv, + "maps/animated_models"sv, + "maps/createart"sv, + "maps/createfx"sv, + "maps/interactive_models"sv, + "maps/mp"sv, + "maps/mp/agents"sv, + "maps/mp/alien"sv, + "maps/mp/bots"sv, + "maps/mp/gametypes"sv, + "maps/mp/killstreaks"sv, + "maps/mp/perks"sv, + "maps/mp/agents/alien"sv, + "maps/mp/agents/dog"sv, + "maps/mp/agents/alien/alien_ancestor"sv, + "maps/mp/agents/alien/alien_kraken"sv, + "maps/mp/agents/alien/alien_spider"sv, +}; + +auto resolver::fs_to_game_path(const std::filesystem::path& file) -> std::filesystem::path +{ + auto result = std::filesystem::path(); + auto root = false; + + for (auto& entry : file) + { + if (!root && paths.contains(entry.string())) + { + result = entry; + root = true; + } + else if (paths.contains(result.string())) + { + result /= entry; + } + } + + return result.empty() ? file : result; +} + const std::array, 153> opcode_list {{ { 0x17, "SET_NEW_LOCAL_VARIABLE_FIELD_CACHED0" }, diff --git a/src/iw6/xsk/resolver.hpp b/src/iw6/xsk/resolver.hpp index a88a2727..a0d53397 100644 --- a/src/iw6/xsk/resolver.hpp +++ b/src/iw6/xsk/resolver.hpp @@ -34,6 +34,7 @@ public: static auto make_token(std::string_view str) -> std::string; static auto file_data(const std::string& name) -> std::tuple; + static auto fs_to_game_path(const std::filesystem::path& file) -> std::filesystem::path; }; } // namespace xsk::gsc::iw6 diff --git a/src/iw7/xsk/resolver.cpp b/src/iw7/xsk/resolver.cpp index d27eb597..2aba7f5b 100644 --- a/src/iw7/xsk/resolver.cpp +++ b/src/iw7/xsk/resolver.cpp @@ -240,6 +240,31 @@ auto resolver::file_data(const std::string& name) -> std::tuple paths +{ +}; + +auto resolver::fs_to_game_path(const std::filesystem::path& file) -> std::filesystem::path +{ + auto result = std::filesystem::path(); + auto root = false; + + for (auto& entry : file) + { + if (!root && paths.contains(entry.string())) + { + result = entry; + root = true; + } + else if (paths.contains(result.string())) + { + result /= entry; + } + } + + return result.empty() ? file : result; +} + const std::array, 153> opcode_list {{ { 0x17, "SET_NEW_LOCAL_VARIABLE_FIELD_CACHED0" }, diff --git a/src/iw7/xsk/resolver.hpp b/src/iw7/xsk/resolver.hpp index acab0249..aa896b12 100644 --- a/src/iw7/xsk/resolver.hpp +++ b/src/iw7/xsk/resolver.hpp @@ -34,6 +34,7 @@ public: static auto make_token(std::string_view str) -> std::string; static auto file_data(const std::string& name) -> std::tuple; + static auto fs_to_game_path(const std::filesystem::path& file) -> std::filesystem::path; }; } // namespace xsk::gsc::iw7 diff --git a/src/iw8/xsk/resolver.cpp b/src/iw8/xsk/resolver.cpp index 4543a097..33be4551 100644 --- a/src/iw8/xsk/resolver.cpp +++ b/src/iw8/xsk/resolver.cpp @@ -240,6 +240,31 @@ auto resolver::file_data(const std::string& name) -> std::tuple paths +{ +}; + +auto resolver::fs_to_game_path(const std::filesystem::path& file) -> std::filesystem::path +{ + auto result = std::filesystem::path(); + auto root = false; + + for (auto& entry : file) + { + if (!root && paths.contains(entry.string())) + { + result = entry; + root = true; + } + else if (paths.contains(result.string())) + { + result /= entry; + } + } + + return result.empty() ? file : result; +} + const std::array, 190> opcode_list {{ { 0x00, "CAST_FIELD_OBJECT" }, diff --git a/src/iw8/xsk/resolver.hpp b/src/iw8/xsk/resolver.hpp index b918e189..1607a4a8 100644 --- a/src/iw8/xsk/resolver.hpp +++ b/src/iw8/xsk/resolver.hpp @@ -34,6 +34,7 @@ public: static auto make_token(std::string_view str) -> std::string; static auto file_data(const std::string& name) -> std::tuple; + static auto fs_to_game_path(const std::filesystem::path& file) -> std::filesystem::path; }; } // namespace xsk::gsc::iw8 diff --git a/src/s1/xsk/resolver.cpp b/src/s1/xsk/resolver.cpp index 890aad8a..34cc153d 100644 --- a/src/s1/xsk/resolver.cpp +++ b/src/s1/xsk/resolver.cpp @@ -240,6 +240,31 @@ auto resolver::file_data(const std::string& name) -> std::tuple paths +{ +}; + +auto resolver::fs_to_game_path(const std::filesystem::path& file) -> std::filesystem::path +{ + auto result = std::filesystem::path(); + auto root = false; + + for (auto& entry : file) + { + if (!root && paths.contains(entry.string())) + { + result = entry; + root = true; + } + else if (paths.contains(result.string())) + { + result /= entry; + } + } + + return result.empty() ? file : result; +} + const std::array, 154> opcode_list {{ { 0x17, "SET_NEW_LOCAL_VARIABLE_FIELD_CACHED0" }, diff --git a/src/s1/xsk/resolver.hpp b/src/s1/xsk/resolver.hpp index 7d047319..93ab0cae 100644 --- a/src/s1/xsk/resolver.hpp +++ b/src/s1/xsk/resolver.hpp @@ -34,6 +34,7 @@ public: static auto make_token(std::string_view str) -> std::string; static auto file_data(const std::string& name) -> std::tuple; + static auto fs_to_game_path(const std::filesystem::path& file) -> std::filesystem::path; }; } // namespace xsk::gsc::s1 diff --git a/src/s2/xsk/resolver.cpp b/src/s2/xsk/resolver.cpp index d77c0c30..6921d668 100644 --- a/src/s2/xsk/resolver.cpp +++ b/src/s2/xsk/resolver.cpp @@ -240,6 +240,31 @@ auto resolver::file_data(const std::string& name) -> std::tuple paths +{ +}; + +auto resolver::fs_to_game_path(const std::filesystem::path& file) -> std::filesystem::path +{ + auto result = std::filesystem::path(); + auto root = false; + + for (auto& entry : file) + { + if (!root && paths.contains(entry.string())) + { + result = entry; + root = true; + } + else if (paths.contains(result.string())) + { + result /= entry; + } + } + + return result.empty() ? file : result; +} + const std::array, 155> opcode_list {{ { 0x17, "SET_NEW_LOCAL_VARIABLE_FIELD_CACHED0" }, diff --git a/src/s2/xsk/resolver.hpp b/src/s2/xsk/resolver.hpp index 3a14c366..5e9a70c1 100644 --- a/src/s2/xsk/resolver.hpp +++ b/src/s2/xsk/resolver.hpp @@ -34,6 +34,7 @@ public: static auto make_token(std::string_view str) -> std::string; static auto file_data(const std::string& name) -> std::tuple; + static auto fs_to_game_path(const std::filesystem::path& file) -> std::filesystem::path; }; } // namespace xsk::gsc::s2 diff --git a/src/s4/xsk/resolver.cpp b/src/s4/xsk/resolver.cpp index f9b776d5..f9da26f7 100644 --- a/src/s4/xsk/resolver.cpp +++ b/src/s4/xsk/resolver.cpp @@ -240,6 +240,31 @@ auto resolver::file_data(const std::string& name) -> std::tuple paths +{ +}; + +auto resolver::fs_to_game_path(const std::filesystem::path& file) -> std::filesystem::path +{ + auto result = std::filesystem::path(); + auto root = false; + + for (auto& entry : file) + { + if (!root && paths.contains(entry.string())) + { + result = entry; + root = true; + } + else if (paths.contains(result.string())) + { + result /= entry; + } + } + + return result.empty() ? file : result; +} + const std::array, 190> opcode_list {{ { 0x00, "CAST_FIELD_OBJECT" }, diff --git a/src/s4/xsk/resolver.hpp b/src/s4/xsk/resolver.hpp index 8ef0de67..92e6190f 100644 --- a/src/s4/xsk/resolver.hpp +++ b/src/s4/xsk/resolver.hpp @@ -34,6 +34,7 @@ public: static auto make_token(std::string_view str) -> std::string; static auto file_data(const std::string& name) -> std::tuple; + static auto fs_to_game_path(const std::filesystem::path& file) -> std::filesystem::path; }; } // namespace xsk::gsc::s4 diff --git a/src/t6/xsk/resolver.cpp b/src/t6/xsk/resolver.cpp index 8031ed93..eea62291 100644 --- a/src/t6/xsk/resolver.cpp +++ b/src/t6/xsk/resolver.cpp @@ -100,37 +100,37 @@ auto resolver::file_data(const std::string& name) -> std::tuple paths +std::set paths { - "aitype", - "animscripts", - "character", - "codescripts", - "common_scripts", - "maps", - "mpbody", - "xmodelalias", - "animscripts/ai_subclass", - "animscripts/aitype", - "animscripts/bigdog", - "animscripts/traverse", - "animscripts/turret", - "maps/ai_subclass", - "maps/createart", - "maps/createfx", - "maps/gametypes", - "maps/mp", - "maps/voice", - "maps/mp/animscripts", - "maps/mp/animscripts/traverse", - "maps/mp/bots", - "maps/mp/createart", - "maps/mp/createfx", - "maps/mp/gametypes", - "maps/mp/gametypes_zm", - "maps/mp/killstreaks", - "maps/mp/teams", - "maps/mp/zombies", + "aitype"sv, + "animscripts"sv, + "character"sv, + "codescripts"sv, + "common_scripts"sv, + "maps"sv, + "mpbody"sv, + "xmodelalias"sv, + "animscripts/ai_subclass"sv, + "animscripts/aitype"sv, + "animscripts/bigdog"sv, + "animscripts/traverse"sv, + "animscripts/turret"sv, + "maps/ai_subclass"sv, + "maps/createart"sv, + "maps/createfx"sv, + "maps/gametypes"sv, + "maps/mp"sv, + "maps/voice"sv, + "maps/mp/animscripts"sv, + "maps/mp/animscripts/traverse"sv, + "maps/mp/bots"sv, + "maps/mp/createart"sv, + "maps/mp/createfx"sv, + "maps/mp/gametypes"sv, + "maps/mp/gametypes_zm"sv, + "maps/mp/killstreaks"sv, + "maps/mp/teams"sv, + "maps/mp/zombies"sv, }; auto resolver::fs_to_game_path(const std::filesystem::path& file) -> std::filesystem::path