From 28763917ea2667837521909d58f395cdb047358b Mon Sep 17 00:00:00 2001 From: Federico Cecchetto Date: Sat, 29 Jan 2022 02:14:36 +0100 Subject: [PATCH 01/42] commit --- src/client/component/images.cpp | 6 +- src/client/game/ui_scripting/lua/context.cpp | 48 ++- src/client/game/ui_scripting/lua/context.hpp | 3 +- src/client/game/ui_scripting/lua/engine.cpp | 8 +- src/client/resource.hpp | 3 +- src/client/resource.rc | 2 + src/client/resources/json.lua | 388 +++++++++++++++++++ 7 files changed, 448 insertions(+), 10 deletions(-) create mode 100644 src/client/resources/json.lua diff --git a/src/client/component/images.cpp b/src/client/component/images.cpp index 693f208d..53718b93 100644 --- a/src/client/component/images.cpp +++ b/src/client/component/images.cpp @@ -29,7 +29,11 @@ namespace images } }); - if (data.empty() && !utils::io::read_file(utils::string::va("images/%s.png", image->name), &data)) + if (data.empty() + && !utils::io::read_file(utils::string::va("images/%s.png", image->name), &data) + && game::mod_folder.empty() && !utils::io::read_file(utils::string::va("%s/images/%s.png", + game::mod_folder.data(), image->name), &data) + ) { return {}; } diff --git a/src/client/game/ui_scripting/lua/context.cpp b/src/client/game/ui_scripting/lua/context.cpp index d9f5b298..dae21dbc 100644 --- a/src/client/game/ui_scripting/lua/context.cpp +++ b/src/client/game/ui_scripting/lua/context.cpp @@ -17,6 +17,7 @@ #include #include #include +#include namespace ui_scripting::lua { @@ -28,6 +29,7 @@ namespace ui_scripting::lua namespace { const auto animation_script = utils::nt::load_resource(LUA_ANIMATION_SCRIPT); + const auto json_script = utils::nt::load_resource(LUA_JSON_SCRIPT); scripting::script_value script_convert(const sol::lua_value& value) { @@ -94,6 +96,13 @@ namespace ui_scripting::lua state["io"]["readfile"] = static_cast(utils::io::read_file); } + void setup_json(sol::state& state) + { + const auto json = state.safe_script(json_script, &sol::script_pass_on_error); + handle_error(json); + state["json"] = json; + } + void setup_vector_type(sol::state& state) { auto vector_type = state.new_usertype("vector", sol::constructors()); @@ -699,7 +708,7 @@ namespace ui_scripting::lua ); } - void setup_game_type(sol::state& state, event_handler& handler, scheduler& scheduler) + void setup_game_type(sol::state& state, event_handler& handler, scheduler& scheduler, bool safe_mode) { struct game { @@ -1092,6 +1101,36 @@ namespace ui_scripting::lua return ::game::mod_folder; }; + if (/*!safe_mode*/true) + { + static int request_id{}; + game_type["httpget"] = [](const game&, const std::string& url) + { + const auto id = request_id++; + ::scheduler::once([url, id]() + { + const auto result = utils::http::get_data(url); + ::scheduler::once([result, id] + { + event event; + event.element = &ui_element; + event.name = "http_request_done"; + if (result.has_value()) + { + event.arguments = {id, true, result.value()}; + } + else + { + event.arguments = {id, false}; + } + + notify(event); + }, ::scheduler::pipeline::renderer); + }, ::scheduler::pipeline::async); + return id; + }; + } + struct player { }; @@ -1247,9 +1286,10 @@ namespace ui_scripting::lua } } - context::context(std::string data, script_type type) + context::context(std::string data, script_type type, bool safe_mode) : scheduler_(state_) , event_handler_(state_) + , safe_mode_(safe_mode) { this->state_.open_libraries(sol::lib::base, @@ -1261,10 +1301,12 @@ namespace ui_scripting::lua sol::lib::table); setup_io(this->state_); + setup_json(this->state_); setup_vector_type(this->state_); setup_element_type(this->state_, this->event_handler_, this->scheduler_); setup_menu_type(this->state_, this->event_handler_, this->scheduler_); - setup_game_type(this->state_, this->event_handler_, this->scheduler_); + setup_game_type(this->state_, this->event_handler_, + this->scheduler_, this->safe_mode_); setup_lui_types(this->state_, this->event_handler_, this->scheduler_); if (type == script_type::file) diff --git a/src/client/game/ui_scripting/lua/context.hpp b/src/client/game/ui_scripting/lua/context.hpp index 78e6c57b..4953f330 100644 --- a/src/client/game/ui_scripting/lua/context.hpp +++ b/src/client/game/ui_scripting/lua/context.hpp @@ -29,7 +29,7 @@ namespace ui_scripting::lua class context { public: - context(std::string data, script_type); + context(std::string data, script_type type, bool safe_mode); ~context(); context(context&&) noexcept = delete; @@ -45,6 +45,7 @@ namespace ui_scripting::lua sol::state state_{}; std::string folder_; std::unordered_set loaded_scripts_; + bool safe_mode_; scheduler scheduler_; event_handler event_handler_; diff --git a/src/client/game/ui_scripting/lua/engine.cpp b/src/client/game/ui_scripting/lua/engine.cpp index 000e96e1..95299ac7 100644 --- a/src/client/game/ui_scripting/lua/engine.cpp +++ b/src/client/game/ui_scripting/lua/engine.cpp @@ -318,14 +318,14 @@ namespace ui_scripting::lua::engine { if (std::filesystem::is_directory(script) && utils::io::file_exists(script + "/__init__.lua")) { - get_scripts().push_back(std::make_unique(script, script_type::file)); + get_scripts().push_back(std::make_unique(script, script_type::file, true)); } } } - void load_code(const std::string& code) + void load_code(const std::string& code, bool safe_mode) { - get_scripts().push_back(std::make_unique(code, script_type::code)); + get_scripts().push_back(std::make_unique(code, script_type::code, safe_mode)); } void render_menus() @@ -413,7 +413,7 @@ namespace ui_scripting::lua::engine get_scripts().clear(); clear_menus(); - load_code(mods_menu_script); + //load_code(mods_menu_script); load_scripts("ui_scripts/"); load_scripts("h2-mod/ui_scripts/"); diff --git a/src/client/resource.hpp b/src/client/resource.hpp index e9af0a1b..3b68dedb 100644 --- a/src/client/resource.hpp +++ b/src/client/resource.hpp @@ -22,4 +22,5 @@ #define ICON_IMAGE 313 #define LUA_ANIMATION_SCRIPT 314 -#define LUI_MODS_MENU 315 +#define LUA_JSON_SCRIPT 315 +#define LUI_MODS_MENU 316 diff --git a/src/client/resource.rc b/src/client/resource.rc index f87531a4..02339d31 100644 --- a/src/client/resource.rc +++ b/src/client/resource.rc @@ -98,6 +98,8 @@ ID_ICON ICON "resources/icon.ico" MENU_MAIN RCDATA "resources/main.html" LUA_ANIMATION_SCRIPT RCDATA "resources/animation.lua" +LUA_JSON_SCRIPT RCDATA "resources/json.lua" + LUI_MODS_MENU RCDATA "resources/mods_menu.lua" #ifdef _DEBUG diff --git a/src/client/resources/json.lua b/src/client/resources/json.lua new file mode 100644 index 00000000..711ef786 --- /dev/null +++ b/src/client/resources/json.lua @@ -0,0 +1,388 @@ +-- +-- json.lua +-- +-- Copyright (c) 2020 rxi +-- +-- Permission is hereby granted, free of charge, to any person obtaining a copy of +-- this software and associated documentation files (the "Software"), to deal in +-- the Software without restriction, including without limitation the rights to +-- use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +-- of the Software, and to permit persons to whom the Software is furnished to do +-- so, subject to the following conditions: +-- +-- The above copyright notice and this permission notice shall be included in all +-- copies or substantial portions of the Software. +-- +-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +-- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +-- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +-- SOFTWARE. +-- + +local json = { _version = "0.1.2" } + +------------------------------------------------------------------------------- +-- Encode +------------------------------------------------------------------------------- + +local encode + +local escape_char_map = { + [ "\\" ] = "\\", + [ "\"" ] = "\"", + [ "\b" ] = "b", + [ "\f" ] = "f", + [ "\n" ] = "n", + [ "\r" ] = "r", + [ "\t" ] = "t", +} + +local escape_char_map_inv = { [ "/" ] = "/" } +for k, v in pairs(escape_char_map) do + escape_char_map_inv[v] = k +end + + +local function escape_char(c) + return "\\" .. (escape_char_map[c] or string.format("u%04x", c:byte())) +end + + +local function encode_nil(val) + return "null" +end + + +local function encode_table(val, stack) + local res = {} + stack = stack or {} + + -- Circular reference? + if stack[val] then error("circular reference") end + + stack[val] = true + + if rawget(val, 1) ~= nil or next(val) == nil then + -- Treat as array -- check keys are valid and it is not sparse + local n = 0 + for k in pairs(val) do + if type(k) ~= "number" then + error("invalid table: mixed or invalid key types") + end + n = n + 1 + end + if n ~= #val then + error("invalid table: sparse array") + end + -- Encode + for i, v in ipairs(val) do + table.insert(res, encode(v, stack)) + end + stack[val] = nil + return "[" .. table.concat(res, ",") .. "]" + + else + -- Treat as an object + for k, v in pairs(val) do + if type(k) ~= "string" then + error("invalid table: mixed or invalid key types") + end + table.insert(res, encode(k, stack) .. ":" .. encode(v, stack)) + end + stack[val] = nil + return "{" .. table.concat(res, ",") .. "}" + end +end + + +local function encode_string(val) + return '"' .. val:gsub('[%z\1-\31\\"]', escape_char) .. '"' +end + + +local function encode_number(val) + -- Check for NaN, -inf and inf + if val ~= val or val <= -math.huge or val >= math.huge then + error("unexpected number value '" .. tostring(val) .. "'") + end + return string.format("%.14g", val) +end + + +local type_func_map = { + [ "nil" ] = encode_nil, + [ "table" ] = encode_table, + [ "string" ] = encode_string, + [ "number" ] = encode_number, + [ "boolean" ] = tostring, +} + + +encode = function(val, stack) + local t = type(val) + local f = type_func_map[t] + if f then + return f(val, stack) + end + error("unexpected type '" .. t .. "'") +end + + +function json.encode(val) + return ( encode(val) ) +end + + +------------------------------------------------------------------------------- +-- Decode +------------------------------------------------------------------------------- + +local parse + +local function create_set(...) + local res = {} + for i = 1, select("#", ...) do + res[ select(i, ...) ] = true + end + return res +end + +local space_chars = create_set(" ", "\t", "\r", "\n") +local delim_chars = create_set(" ", "\t", "\r", "\n", "]", "}", ",") +local escape_chars = create_set("\\", "/", '"', "b", "f", "n", "r", "t", "u") +local literals = create_set("true", "false", "null") + +local literal_map = { + [ "true" ] = true, + [ "false" ] = false, + [ "null" ] = nil, +} + + +local function next_char(str, idx, set, negate) + for i = idx, #str do + if set[str:sub(i, i)] ~= negate then + return i + end + end + return #str + 1 +end + + +local function decode_error(str, idx, msg) + local line_count = 1 + local col_count = 1 + for i = 1, idx - 1 do + col_count = col_count + 1 + if str:sub(i, i) == "\n" then + line_count = line_count + 1 + col_count = 1 + end + end + error( string.format("%s at line %d col %d", msg, line_count, col_count) ) +end + + +local function codepoint_to_utf8(n) + -- http://scripts.sil.org/cms/scripts/page.php?site_id=nrsi&id=iws-appendixa + local f = math.floor + if n <= 0x7f then + return string.char(n) + elseif n <= 0x7ff then + return string.char(f(n / 64) + 192, n % 64 + 128) + elseif n <= 0xffff then + return string.char(f(n / 4096) + 224, f(n % 4096 / 64) + 128, n % 64 + 128) + elseif n <= 0x10ffff then + return string.char(f(n / 262144) + 240, f(n % 262144 / 4096) + 128, + f(n % 4096 / 64) + 128, n % 64 + 128) + end + error( string.format("invalid unicode codepoint '%x'", n) ) +end + + +local function parse_unicode_escape(s) + local n1 = tonumber( s:sub(1, 4), 16 ) + local n2 = tonumber( s:sub(7, 10), 16 ) + -- Surrogate pair? + if n2 then + return codepoint_to_utf8((n1 - 0xd800) * 0x400 + (n2 - 0xdc00) + 0x10000) + else + return codepoint_to_utf8(n1) + end +end + + +local function parse_string(str, i) + local res = "" + local j = i + 1 + local k = j + + while j <= #str do + local x = str:byte(j) + + if x < 32 then + decode_error(str, j, "control character in string") + + elseif x == 92 then -- `\`: Escape + res = res .. str:sub(k, j - 1) + j = j + 1 + local c = str:sub(j, j) + if c == "u" then + local hex = str:match("^[dD][89aAbB]%x%x\\u%x%x%x%x", j + 1) + or str:match("^%x%x%x%x", j + 1) + or decode_error(str, j - 1, "invalid unicode escape in string") + res = res .. parse_unicode_escape(hex) + j = j + #hex + else + if not escape_chars[c] then + decode_error(str, j - 1, "invalid escape char '" .. c .. "' in string") + end + res = res .. escape_char_map_inv[c] + end + k = j + 1 + + elseif x == 34 then -- `"`: End of string + res = res .. str:sub(k, j - 1) + return res, j + 1 + end + + j = j + 1 + end + + decode_error(str, i, "expected closing quote for string") +end + + +local function parse_number(str, i) + local x = next_char(str, i, delim_chars) + local s = str:sub(i, x - 1) + local n = tonumber(s) + if not n then + decode_error(str, i, "invalid number '" .. s .. "'") + end + return n, x +end + + +local function parse_literal(str, i) + local x = next_char(str, i, delim_chars) + local word = str:sub(i, x - 1) + if not literals[word] then + decode_error(str, i, "invalid literal '" .. word .. "'") + end + return literal_map[word], x +end + + +local function parse_array(str, i) + local res = {} + local n = 1 + i = i + 1 + while 1 do + local x + i = next_char(str, i, space_chars, true) + -- Empty / end of array? + if str:sub(i, i) == "]" then + i = i + 1 + break + end + -- Read token + x, i = parse(str, i) + res[n] = x + n = n + 1 + -- Next token + i = next_char(str, i, space_chars, true) + local chr = str:sub(i, i) + i = i + 1 + if chr == "]" then break end + if chr ~= "," then decode_error(str, i, "expected ']' or ','") end + end + return res, i +end + + +local function parse_object(str, i) + local res = {} + i = i + 1 + while 1 do + local key, val + i = next_char(str, i, space_chars, true) + -- Empty / end of object? + if str:sub(i, i) == "}" then + i = i + 1 + break + end + -- Read key + if str:sub(i, i) ~= '"' then + decode_error(str, i, "expected string for key") + end + key, i = parse(str, i) + -- Read ':' delimiter + i = next_char(str, i, space_chars, true) + if str:sub(i, i) ~= ":" then + decode_error(str, i, "expected ':' after key") + end + i = next_char(str, i + 1, space_chars, true) + -- Read value + val, i = parse(str, i) + -- Set + res[key] = val + -- Next token + i = next_char(str, i, space_chars, true) + local chr = str:sub(i, i) + i = i + 1 + if chr == "}" then break end + if chr ~= "," then decode_error(str, i, "expected '}' or ','") end + end + return res, i +end + + +local char_func_map = { + [ '"' ] = parse_string, + [ "0" ] = parse_number, + [ "1" ] = parse_number, + [ "2" ] = parse_number, + [ "3" ] = parse_number, + [ "4" ] = parse_number, + [ "5" ] = parse_number, + [ "6" ] = parse_number, + [ "7" ] = parse_number, + [ "8" ] = parse_number, + [ "9" ] = parse_number, + [ "-" ] = parse_number, + [ "t" ] = parse_literal, + [ "f" ] = parse_literal, + [ "n" ] = parse_literal, + [ "[" ] = parse_array, + [ "{" ] = parse_object, +} + + +parse = function(str, idx) + local chr = str:sub(idx, idx) + local f = char_func_map[chr] + if f then + return f(str, idx) + end + decode_error(str, idx, "unexpected character '" .. chr .. "'") +end + + +function json.decode(str) + if type(str) ~= "string" then + error("expected argument of type string, got " .. type(str)) + end + local res, idx = parse(str, next_char(str, 1, space_chars, true)) + idx = next_char(str, idx, space_chars, true) + if idx <= #str then + decode_error(str, idx, "trailing garbage") + end + return res +end + + +return json From 5fae85dd35a66c9bdd28372c62bf8463e9968ab4 Mon Sep 17 00:00:00 2001 From: fed <58637860+fedddddd@users.noreply.github.com> Date: Sat, 29 Jan 2022 16:50:41 +0100 Subject: [PATCH 02/42] commit 2 --- src/client/game/ui_scripting/lua/context.cpp | 2 ++ src/common/utils/io.cpp | 5 +++++ src/common/utils/io.hpp | 1 + 3 files changed, 8 insertions(+) diff --git a/src/client/game/ui_scripting/lua/context.cpp b/src/client/game/ui_scripting/lua/context.cpp index dae21dbc..ccda967b 100644 --- a/src/client/game/ui_scripting/lua/context.cpp +++ b/src/client/game/ui_scripting/lua/context.cpp @@ -93,6 +93,8 @@ namespace ui_scripting::lua state["io"]["directoryisempty"] = utils::io::directory_is_empty; state["io"]["listfiles"] = utils::io::list_files; state["io"]["copyfolder"] = utils::io::copy_folder; + state["io"]["removefile"] = utils::io::remove_file; + state["io"]["removedirectory"] = utils::io::remove_directory; state["io"]["readfile"] = static_cast(utils::io::read_file); } diff --git a/src/common/utils/io.cpp b/src/common/utils/io.cpp index 4968f449..9b161d39 100644 --- a/src/common/utils/io.cpp +++ b/src/common/utils/io.cpp @@ -104,6 +104,11 @@ namespace utils::io return std::filesystem::is_empty(directory); } + bool remove_directory(const std::string& directory) + { + return std::filesystem::remove_all(directory); + } + std::vector list_files(const std::string& directory) { std::vector files; diff --git a/src/common/utils/io.hpp b/src/common/utils/io.hpp index ab4ebaa4..38344987 100644 --- a/src/common/utils/io.hpp +++ b/src/common/utils/io.hpp @@ -16,6 +16,7 @@ namespace utils::io bool create_directory(const std::string& directory); bool directory_exists(const std::string& directory); bool directory_is_empty(const std::string& directory); + bool remove_directory(const std::string& directory); std::vector list_files(const std::string& directory); void copy_folder(const std::filesystem::path& src, const std::filesystem::path& target); } From cef4cbc5b9112a6e4c140191a34835d17d2cbb86 Mon Sep 17 00:00:00 2001 From: Federico Cecchetto Date: Sat, 29 Jan 2022 21:27:54 +0100 Subject: [PATCH 03/42] commit 3 --- src/client/component/images.cpp | 6 +- src/client/game/ui_scripting/lua/context.cpp | 59 ++++++++++---------- src/client/game/ui_scripting/lua/context.hpp | 3 +- src/client/game/ui_scripting/lua/engine.cpp | 6 +- 4 files changed, 35 insertions(+), 39 deletions(-) diff --git a/src/client/component/images.cpp b/src/client/component/images.cpp index 53718b93..693f208d 100644 --- a/src/client/component/images.cpp +++ b/src/client/component/images.cpp @@ -29,11 +29,7 @@ namespace images } }); - if (data.empty() - && !utils::io::read_file(utils::string::va("images/%s.png", image->name), &data) - && game::mod_folder.empty() && !utils::io::read_file(utils::string::va("%s/images/%s.png", - game::mod_folder.data(), image->name), &data) - ) + if (data.empty() && !utils::io::read_file(utils::string::va("images/%s.png", image->name), &data)) { return {}; } diff --git a/src/client/game/ui_scripting/lua/context.cpp b/src/client/game/ui_scripting/lua/context.cpp index ccda967b..1cc17e6b 100644 --- a/src/client/game/ui_scripting/lua/context.cpp +++ b/src/client/game/ui_scripting/lua/context.cpp @@ -18,6 +18,7 @@ #include #include #include +#include namespace ui_scripting::lua { @@ -710,7 +711,7 @@ namespace ui_scripting::lua ); } - void setup_game_type(sol::state& state, event_handler& handler, scheduler& scheduler, bool safe_mode) + void setup_game_type(sol::state& state, event_handler& handler, scheduler& scheduler) { struct game { @@ -1103,35 +1104,37 @@ namespace ui_scripting::lua return ::game::mod_folder; }; - if (/*!safe_mode*/true) + static int request_id{}; + game_type["httpget"] = [](const game&, const std::string& url) { - static int request_id{}; - game_type["httpget"] = [](const game&, const std::string& url) + const auto id = request_id++; + ::scheduler::once([url, id]() { - const auto id = request_id++; - ::scheduler::once([url, id]() + const auto result = utils::http::get_data(url); + ::scheduler::once([result, id] { - const auto result = utils::http::get_data(url); - ::scheduler::once([result, id] + event event; + event.element = &ui_element; + event.name = "http_request_done"; + if (result.has_value()) { - event event; - event.element = &ui_element; - event.name = "http_request_done"; - if (result.has_value()) - { - event.arguments = {id, true, result.value()}; - } - else - { - event.arguments = {id, false}; - } + event.arguments = { id, true, result.value() }; + } + else + { + event.arguments = { id, false }; + } - notify(event); - }, ::scheduler::pipeline::renderer); - }, ::scheduler::pipeline::async); - return id; - }; - } + notify(event); + }, ::scheduler::pipeline::renderer); + }, ::scheduler::pipeline::async); + return id; + }; + + game_type["sha"] = [](const game&, const std::string& data) + { + return utils::cryptography::sha1::compute(data, true); + }; struct player { @@ -1288,10 +1291,9 @@ namespace ui_scripting::lua } } - context::context(std::string data, script_type type, bool safe_mode) + context::context(std::string data, script_type type) : scheduler_(state_) , event_handler_(state_) - , safe_mode_(safe_mode) { this->state_.open_libraries(sol::lib::base, @@ -1307,8 +1309,7 @@ namespace ui_scripting::lua setup_vector_type(this->state_); setup_element_type(this->state_, this->event_handler_, this->scheduler_); setup_menu_type(this->state_, this->event_handler_, this->scheduler_); - setup_game_type(this->state_, this->event_handler_, - this->scheduler_, this->safe_mode_); + setup_game_type(this->state_, this->event_handler_, this->scheduler_); setup_lui_types(this->state_, this->event_handler_, this->scheduler_); if (type == script_type::file) diff --git a/src/client/game/ui_scripting/lua/context.hpp b/src/client/game/ui_scripting/lua/context.hpp index 4953f330..6b05116c 100644 --- a/src/client/game/ui_scripting/lua/context.hpp +++ b/src/client/game/ui_scripting/lua/context.hpp @@ -29,7 +29,7 @@ namespace ui_scripting::lua class context { public: - context(std::string data, script_type type, bool safe_mode); + context(std::string data, script_type type); ~context(); context(context&&) noexcept = delete; @@ -45,7 +45,6 @@ namespace ui_scripting::lua sol::state state_{}; std::string folder_; std::unordered_set loaded_scripts_; - bool safe_mode_; scheduler scheduler_; event_handler event_handler_; diff --git a/src/client/game/ui_scripting/lua/engine.cpp b/src/client/game/ui_scripting/lua/engine.cpp index 95299ac7..b3cefc35 100644 --- a/src/client/game/ui_scripting/lua/engine.cpp +++ b/src/client/game/ui_scripting/lua/engine.cpp @@ -318,14 +318,14 @@ namespace ui_scripting::lua::engine { if (std::filesystem::is_directory(script) && utils::io::file_exists(script + "/__init__.lua")) { - get_scripts().push_back(std::make_unique(script, script_type::file, true)); + get_scripts().push_back(std::make_unique(script, script_type::file)); } } } - void load_code(const std::string& code, bool safe_mode) + void load_code(const std::string& code) { - get_scripts().push_back(std::make_unique(code, script_type::code, safe_mode)); + get_scripts().push_back(std::make_unique(code, script_type::code)); } void render_menus() From e03ed4962c75092ad91b3bec6eec986d8e1c5110 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 29 Jan 2022 20:30:52 +0000 Subject: [PATCH 04/42] Bump deps/GSL from `99a29ce` to `a353456` Bumps [deps/GSL](https://github.com/Microsoft/GSL) from `99a29ce` to `a353456`. - [Release notes](https://github.com/Microsoft/GSL/releases) - [Commits](https://github.com/Microsoft/GSL/compare/99a29ce797c8337b8923f2688ba1489be6f65bc4...a3534567187d2edc428efd3f13466ff75fe5805c) --- updated-dependencies: - dependency-name: deps/GSL dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- deps/GSL | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deps/GSL b/deps/GSL index 99a29ce7..a3534567 160000 --- a/deps/GSL +++ b/deps/GSL @@ -1 +1 @@ -Subproject commit 99a29ce797c8337b8923f2688ba1489be6f65bc4 +Subproject commit a3534567187d2edc428efd3f13466ff75fe5805c From 1c4141c5b674aafd8c656f604a4f7aab35e44ef1 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 29 Jan 2022 20:30:57 +0000 Subject: [PATCH 05/42] Bump deps/protobuf from `b48ba57` to `15add1a` Bumps [deps/protobuf](https://github.com/google/protobuf) from `b48ba57` to `15add1a`. - [Release notes](https://github.com/google/protobuf/releases) - [Commits](https://github.com/google/protobuf/compare/b48ba578dd01adfebeb4fac0887db1eeb163e00f...15add1af49f13d1661d3910d0eb6697b415a19d1) --- updated-dependencies: - dependency-name: deps/protobuf dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- deps/protobuf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deps/protobuf b/deps/protobuf index b48ba578..15add1af 160000 --- a/deps/protobuf +++ b/deps/protobuf @@ -1 +1 @@ -Subproject commit b48ba578dd01adfebeb4fac0887db1eeb163e00f +Subproject commit 15add1af49f13d1661d3910d0eb6697b415a19d1 From 9b0c7148c0f0258a1237da6fb0d2540c70458237 Mon Sep 17 00:00:00 2001 From: fed <58637860+fedddddd@users.noreply.github.com> Date: Sat, 29 Jan 2022 22:16:03 +0100 Subject: [PATCH 06/42] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 040b2dd6..936932e8 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,6 @@ ![license](https://img.shields.io/github/license/fedddddd/h2-mod.svg) [![open bugs](https://img.shields.io/github/issues/fedddddd/h2-mod/bug?label=bugs)](https://github.com/fedddddd/h2-mod/issues?q=is%3Aissue+is%3Aopen+label%3Abug) +[![Build](https://github.com/fedddddd/h2-mod/workflows/Build/badge.svg)](https://github.com/fedddddd/h2-mod/actions) [![Build status](https://ci.appveyor.com/api/projects/status/0sh80kdnsvm53rno?svg=true)](https://ci.appveyor.com/project/fedddddd/h2-mod) From 03c24765a77577bf8814444c9e1d107314de2e8f Mon Sep 17 00:00:00 2001 From: Federico Cecchetto Date: Sun, 30 Jan 2022 02:04:58 +0100 Subject: [PATCH 07/42] Test --- data/ui_scripts/mods_menus/__init__.lua | 1 + data/ui_scripts/mods_menus/loading.lua | 139 +++++++++++++++++++ data/ui_scripts/mods_menus/store.lua | 0 src/client/game/ui_scripting/lua/context.cpp | 6 + 4 files changed, 146 insertions(+) create mode 100644 data/ui_scripts/mods_menus/__init__.lua create mode 100644 data/ui_scripts/mods_menus/loading.lua create mode 100644 data/ui_scripts/mods_menus/store.lua diff --git a/data/ui_scripts/mods_menus/__init__.lua b/data/ui_scripts/mods_menus/__init__.lua new file mode 100644 index 00000000..e591a736 --- /dev/null +++ b/data/ui_scripts/mods_menus/__init__.lua @@ -0,0 +1 @@ +require("loading") \ No newline at end of file diff --git a/data/ui_scripts/mods_menus/loading.lua b/data/ui_scripts/mods_menus/loading.lua new file mode 100644 index 00000000..23d57980 --- /dev/null +++ b/data/ui_scripts/mods_menus/loading.lua @@ -0,0 +1,139 @@ +function createdivider(menu, text) + local element = LUI.UIElement.new( { + leftAnchor = true, + rightAnchor = true, + left = 0, + right = 0, + topAnchor = true, + bottomAnchor = false, + top = 0, + bottom = 33.33 + }) + + element.scrollingToNext = true + element:addElement(LUI.MenuBuilder.BuildRegisteredType("h1_option_menu_titlebar", { + title_bar_text = Engine.ToUpperCase(Engine.Localize(text)) + })) + + menu.list:addElement(element) +end + +function string:truncate(length) + if (#self <= length) then + return self + end + + return self:sub(1, length - 3) .. "..." +end + +local maincampaign = LUI.MenuBuilder.m_types_build["main_campaign"] +LUI.MenuBuilder.m_types_build["main_campaign"] = function(a1, a2) + local menu = maincampaign(a1, a2) + local buttonlist = menu:getChildById("main_campaign_list") + + local button = menu:AddButton("$_MODS", function() + LUI.FlowManager.RequestAddMenu(nil, "mods_menu") + end, nil, true, nil, { + desc_text = "Open mods menu" + }) + + buttonlist:removeElement(button) + buttonlist:insertElement(button, 6) + button.id = "mods_menu-button" + + local hintbox = menu.optionTextInfo + local firstbutton = buttonlist:getFirstChild() + hintbox:dispatchEventToRoot({ + name = "set_button_info_text", + text = firstbutton.properties.desc_text, + immediate = true + }) + + menu:CreateBottomDivider() + menu:AddBottomDividerToList(buttonlist:getLastChild()) + menu:removeElement(menu.optionTextInfo) + + LUI.Options.InitScrollingList(menu.list, nil) + menu:CreateBottomDivider() + menu.optionTextInfo = LUI.Options.AddOptionTextInfo(menu) + + return menu +end + +LUI.MenuBuilder.m_types_build["mods_menu"] = function(a1) + local menu = LUI.MenuTemplate.new(a1, { + menu_title = "$_MODS", + exclusiveController = 0, + menu_width = 400, + menu_top_indent = LUI.MenuTemplate.spMenuOffset, + showTopRightSmallBar = true + }) + + menu:AddButton("$_OPEN STORE", function() + LUI.FlowManager.RequestAddMenu(nil, "mod_store_menu") + end, nil, true, nil, { + desc_text = "Open the menu store" + }) + + local modfolder = game:getloadedmod() + if (modfolder ~= "") then + createdivider(menu, "$_Loaded mod: " .. modfolder:truncate(20)) + + menu:AddButton("$_UNLOAD", function() + game:executecommand("unloadmod") + end, nil, true, nil, { + desc_text = "Unload the currently loaded mod" + }) + end + + createdivider(menu, "$_Available mods") + + if (io.directoryexists("mods")) then + local mods = io.listfiles("mods/") + for i = 1, #mods do + local desc = "Load " .. mods[i] + local name = mods[i] + + local infofile = mods[i] .. "/info.json" + + if (io.fileexists(infofile)) then + pcall(function() + local data = json.decode(io.readfile(infofile)) + desc = string.format("%s\nAuthor: %s\nVersion: %s", + data.description, data.author, data.version) + name = data.name + end) + end + + if (mods[i] ~= modfolder) then + menu:AddButton("$_" .. name, function() + game:executecommand("loadmod " .. mods[i]) + end, nil, true, nil, { + desc_text = desc + }) + end + end + end + + menu:AddBackButton(function(a1) + Engine.PlaySound(CoD.SFX.MenuBack) + LUI.FlowManager.RequestLeaveMenu(a1) + end) + + LUI.Options.InitScrollingList(menu.list, nil) + menu:CreateBottomDivider() + menu.optionTextInfo = LUI.Options.AddOptionTextInfo(menu) + + return menu +end + +local localize = Engine.Localize +Engine.Localize = function(...) + local args = {...} + + if (type(args[1]) == "string" and args[1]:sub(1, 2) == "$_") then + return args[1]:sub(3, -1) + end + + return localize(table.unpack(args)) +end \ No newline at end of file diff --git a/data/ui_scripts/mods_menus/store.lua b/data/ui_scripts/mods_menus/store.lua new file mode 100644 index 00000000..e69de29b diff --git a/src/client/game/ui_scripting/lua/context.cpp b/src/client/game/ui_scripting/lua/context.cpp index 1cc17e6b..830ae314 100644 --- a/src/client/game/ui_scripting/lua/context.cpp +++ b/src/client/game/ui_scripting/lua/context.cpp @@ -19,6 +19,7 @@ #include #include #include +#include namespace ui_scripting::lua { @@ -1136,6 +1137,11 @@ namespace ui_scripting::lua return utils::cryptography::sha1::compute(data, true); }; + game_type["environment"] = [](const game&) + { + return GIT_BRANCH; + }; + struct player { }; From c16ef8ff831b39f13cb93b4cdd898668e963a8cb Mon Sep 17 00:00:00 2001 From: Federico Cecchetto Date: Sun, 30 Jan 2022 19:46:29 +0100 Subject: [PATCH 08/42] Update appveyor.yml --- appveyor.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/appveyor.yml b/appveyor.yml index 931b84c3..0b851994 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -10,6 +10,7 @@ environment: branches: only: + - develop - main skip_branch_with_pr: true From 43f5603aa42481f9ccb3cbcc9d459ca907a0e587 Mon Sep 17 00:00:00 2001 From: Federico Cecchetto Date: Sun, 30 Jan 2022 22:55:21 +0100 Subject: [PATCH 09/42] Add updater --- .../{mods_menus => mods}/__init__.lua | 0 .../{mods_menus => mods}/loading.lua | 46 +-- .../ui_scripts/{mods_menus => mods}/store.lua | 0 src/client/game/ui_scripting/lua/context.cpp | 13 +- src/client/game/ui_scripting/lua/engine.cpp | 4 +- src/client/resource.hpp | 2 +- src/client/resource.rc | 2 +- src/client/resources/mods_menu.lua | 121 ------- src/client/resources/updater.lua | 339 ++++++++++++++++++ 9 files changed, 365 insertions(+), 162 deletions(-) rename data/ui_scripts/{mods_menus => mods}/__init__.lua (100%) rename data/ui_scripts/{mods_menus => mods}/loading.lua (71%) rename data/ui_scripts/{mods_menus => mods}/store.lua (100%) delete mode 100644 src/client/resources/mods_menu.lua create mode 100644 src/client/resources/updater.lua diff --git a/data/ui_scripts/mods_menus/__init__.lua b/data/ui_scripts/mods/__init__.lua similarity index 100% rename from data/ui_scripts/mods_menus/__init__.lua rename to data/ui_scripts/mods/__init__.lua diff --git a/data/ui_scripts/mods_menus/loading.lua b/data/ui_scripts/mods/loading.lua similarity index 71% rename from data/ui_scripts/mods_menus/loading.lua rename to data/ui_scripts/mods/loading.lua index 23d57980..31c85425 100644 --- a/data/ui_scripts/mods_menus/loading.lua +++ b/data/ui_scripts/mods/loading.lua @@ -26,39 +26,15 @@ function string:truncate(length) return self:sub(1, length - 3) .. "..." end -local maincampaign = LUI.MenuBuilder.m_types_build["main_campaign"] -LUI.MenuBuilder.m_types_build["main_campaign"] = function(a1, a2) - local menu = maincampaign(a1, a2) - local buttonlist = menu:getChildById("main_campaign_list") - - local button = menu:AddButton("$_MODS", function() +LUI.addmenubutton("main_campaign", { + index = 6, + id = "mods_menu-button", + text = "$_MODS", + description = "Load installed mods.", + callback = function() LUI.FlowManager.RequestAddMenu(nil, "mods_menu") - end, nil, true, nil, { - desc_text = "Open mods menu" - }) - - buttonlist:removeElement(button) - buttonlist:insertElement(button, 6) - button.id = "mods_menu-button" - - local hintbox = menu.optionTextInfo - local firstbutton = buttonlist:getFirstChild() - hintbox:dispatchEventToRoot({ - name = "set_button_info_text", - text = firstbutton.properties.desc_text, - immediate = true - }) - - menu:CreateBottomDivider() - menu:AddBottomDividerToList(buttonlist:getLastChild()) - menu:removeElement(menu.optionTextInfo) - - LUI.Options.InitScrollingList(menu.list, nil) - menu:CreateBottomDivider() - menu.optionTextInfo = LUI.Options.AddOptionTextInfo(menu) - - return menu -end + end +}) LUI.MenuBuilder.m_types_build["mods_menu"] = function(a1) local menu = LUI.MenuTemplate.new(a1, { @@ -70,9 +46,11 @@ LUI.MenuBuilder.m_types_build["mods_menu"] = function(a1) }) menu:AddButton("$_OPEN STORE", function() - LUI.FlowManager.RequestAddMenu(nil, "mod_store_menu") + if (LUI.MenuBuilder.m_types_build["mod_store_menu"]) then + LUI.FlowManager.RequestAddMenu(nil, "mod_store_menu") + end end, nil, true, nil, { - desc_text = "Open the menu store" + desc_text = "Download and install mods." }) local modfolder = game:getloadedmod() diff --git a/data/ui_scripts/mods_menus/store.lua b/data/ui_scripts/mods/store.lua similarity index 100% rename from data/ui_scripts/mods_menus/store.lua rename to data/ui_scripts/mods/store.lua diff --git a/src/client/game/ui_scripting/lua/context.cpp b/src/client/game/ui_scripting/lua/context.cpp index 830ae314..9717ff64 100644 --- a/src/client/game/ui_scripting/lua/context.cpp +++ b/src/client/game/ui_scripting/lua/context.cpp @@ -1119,11 +1119,11 @@ namespace ui_scripting::lua event.name = "http_request_done"; if (result.has_value()) { - event.arguments = { id, true, result.value() }; + event.arguments = {id, true, result.value()}; } else { - event.arguments = { id, false }; + event.arguments = {id, false}; } notify(event); @@ -1134,7 +1134,7 @@ namespace ui_scripting::lua game_type["sha"] = [](const game&, const std::string& data) { - return utils::cryptography::sha1::compute(data, true); + return utils::string::to_upper(utils::cryptography::sha1::compute(data, true)); }; game_type["environment"] = [](const game&) @@ -1142,6 +1142,13 @@ namespace ui_scripting::lua return GIT_BRANCH; }; + game_type["binaryname"] = [](const game&) + { + char name[MAX_PATH] = {0}; + GetModuleBaseName(GetCurrentProcess(), GetModuleHandle(NULL), name, MAX_PATH); + return std::string(name); + }; + struct player { }; diff --git a/src/client/game/ui_scripting/lua/engine.cpp b/src/client/game/ui_scripting/lua/engine.cpp index b3cefc35..e7450a72 100644 --- a/src/client/game/ui_scripting/lua/engine.cpp +++ b/src/client/game/ui_scripting/lua/engine.cpp @@ -13,7 +13,7 @@ namespace ui_scripting::lua::engine { namespace { - const auto mods_menu_script = utils::nt::load_resource(LUI_MODS_MENU); + const auto updater_script = utils::nt::load_resource(LUI_UPDATER_MENU); float screen_max[2]; @@ -413,7 +413,7 @@ namespace ui_scripting::lua::engine get_scripts().clear(); clear_menus(); - //load_code(mods_menu_script); + load_code(updater_script); load_scripts("ui_scripts/"); load_scripts("h2-mod/ui_scripts/"); diff --git a/src/client/resource.hpp b/src/client/resource.hpp index 3b68dedb..2005d4f1 100644 --- a/src/client/resource.hpp +++ b/src/client/resource.hpp @@ -23,4 +23,4 @@ #define LUA_ANIMATION_SCRIPT 314 #define LUA_JSON_SCRIPT 315 -#define LUI_MODS_MENU 316 +#define LUI_UPDATER_MENU 316 diff --git a/src/client/resource.rc b/src/client/resource.rc index 02339d31..65467a1d 100644 --- a/src/client/resource.rc +++ b/src/client/resource.rc @@ -100,7 +100,7 @@ MENU_MAIN RCDATA "resources/main.html" LUA_ANIMATION_SCRIPT RCDATA "resources/animation.lua" LUA_JSON_SCRIPT RCDATA "resources/json.lua" -LUI_MODS_MENU RCDATA "resources/mods_menu.lua" +LUI_UPDATER_MENU RCDATA "resources/updater.lua" #ifdef _DEBUG TLS_DLL RCDATA "../../build/bin/x64/Debug/tlsdll.dll" diff --git a/src/client/resources/mods_menu.lua b/src/client/resources/mods_menu.lua deleted file mode 100644 index f8743713..00000000 --- a/src/client/resources/mods_menu.lua +++ /dev/null @@ -1,121 +0,0 @@ -function createdivider(menu, text) - local element = LUI.UIElement.new( { - leftAnchor = true, - rightAnchor = true, - left = 0, - right = 0, - topAnchor = true, - bottomAnchor = false, - top = 0, - bottom = 33.33 - }) - - element.scrollingToNext = true - element:addElement(LUI.MenuBuilder.BuildRegisteredType("h1_option_menu_titlebar", { - title_bar_text = Engine.ToUpperCase(Engine.Localize(text)) - })) - - menu.list:addElement(element) -end - -local maincampaign = LUI.MenuBuilder.m_types_build["main_campaign"] -LUI.MenuBuilder.m_types_build["main_campaign"] = function(a1, a2) - local menu = maincampaign(a1, a2) - local buttonlist = menu:getChildById("main_campaign_list") - - local button = menu:AddButton("$_MODS", function() - LUI.FlowManager.RequestAddMenu(nil, "mods_menu") - end, nil, true, nil, { - desc_text = "Open mods menu" - }) - - buttonlist:removeElement(button) - buttonlist:insertElement(button, 6) - button.id = "mods_menu-button" - - local hintbox = menu.optionTextInfo - local firstbutton = buttonlist:getFirstChild() - hintbox:dispatchEventToRoot({ - name = "set_button_info_text", - text = firstbutton.properties.desc_text, - immediate = true - }) - - menu:CreateBottomDivider() - menu:AddBottomDividerToList(buttonlist:getLastChild()) - menu:removeElement(menu.optionTextInfo) - - LUI.Options.InitScrollingList(menu.list, nil) - menu:CreateBottomDivider() - menu.optionTextInfo = LUI.Options.AddOptionTextInfo(menu) - - return menu -end - -function modsmenu(a1) - local menu = LUI.MenuTemplate.new(a1, { - menu_title = "$_MODS", - exclusiveController = 0, - menu_width = 400, - menu_top_indent = LUI.MenuTemplate.spMenuOffset, - showTopRightSmallBar = true - }) - - local modfolder = game:getloadedmod() - if (modfolder ~= "") then - createdivider(menu, "$_Loaded mod: " .. modfolder) - - menu:AddButton("$_UNLOAD", function() - game:executecommand("unloadmod") - end, nil, true, nil, { - desc_text = "Unload the currently loaded mod" - }) - end - - createdivider(menu, "$_Available mods") - - if (io.directoryexists("mods")) then - local mods = io.listfiles("mods/") - for i = 1, #mods do - local desc = "Load " .. mods[i] - local infofile = mods[i] .. "/mod.txt" - local exists = io.fileexists(infofile) - - if (exists) then - desc = io.readfile(infofile) - end - - if (mods[i] ~= modfolder) then - menu:AddButton("$_" .. mods[i], function() - game:executecommand("loadmod " .. mods[i]) - end, nil, true, nil, { - desc_text = desc - }) - end - end - end - - menu:AddBackButton(function(a1) - Engine.PlaySound(CoD.SFX.MenuBack) - LUI.FlowManager.RequestLeaveMenu(a1) - end) - - LUI.Options.InitScrollingList(menu.list, nil) - menu:CreateBottomDivider() - menu.optionTextInfo = LUI.Options.AddOptionTextInfo(menu) - - return menu -end - -LUI.MenuBuilder.m_types_build["mods_menu"] = modsmenu - -local localize = Engine.Localize -Engine.Localize = function(...) - local args = {...} - - if (type(args[1]) == "string" and args[1]:sub(1, 2) == "$_") then - return args[1]:sub(3, -1) - end - - return localize(table.unpack(args)) -end \ No newline at end of file diff --git a/src/client/resources/updater.lua b/src/client/resources/updater.lua new file mode 100644 index 00000000..074dd7c5 --- /dev/null +++ b/src/client/resources/updater.lua @@ -0,0 +1,339 @@ +LUI.menucallbacks = {} +LUI.originalmenus = {} + +LUI.onmenuopen = function(name, callback) + if (not LUI.MenuBuilder.m_types_build[name]) then + return + end + + if (not LUI.menucallbacks[name]) then + LUI.menucallbacks[name] = {} + end + + luiglobals.table.insert(LUI.menucallbacks[name], callback) + + if (not LUI.originalmenus[name]) then + LUI.originalmenus[name] = LUI.MenuBuilder.m_types_build[name] + LUI.MenuBuilder.m_types_build[name] = function(...) + local args = {...} + local menu = LUI.originalmenus[name](table.unpack(args)) + + for k, v in luiglobals.next, LUI.menucallbacks[name] do + v(menu, table.unpack(args)) + end + + return menu + end + end +end + +local addoptionstextinfo = LUI.Options.AddOptionTextInfo +LUI.Options.AddOptionTextInfo = function(menu) + local result = addoptionstextinfo(menu) + menu.optionTextInfo = result + return result +end + +LUI.addmenubutton = function(name, data) + LUI.onmenuopen(name, function(menu) + if (not menu.list) then + return + end + + local button = menu:AddButton(data.text, data.callback, nil, true, nil, { + desc_text = data.description + }) + + local buttonlist = menu:getChildById(menu.type .. "_list") + + if (data.id) then + button.id = data.id + end + + if (data.index) then + buttonlist:removeElement(button) + buttonlist:insertElement(button, data.index) + end + + local hintbox = menu.optionTextInfo + menu:removeElement(hintbox) + + LUI.Options.InitScrollingList(menu.list, nil) + menu.optionTextInfo = LUI.Options.AddOptionTextInfo(menu) + end) +end + +stack = {} +LUI.openmenu = function(menu, args) + stack = args + LUI.FlowManager.RequestAddMenu(nil, menu) + return stack.ret +end + +LUI.openpopupmenu = function(menu, args) + stack = args + LUI.FlowManager.RequestPopupMenu(nil, menu) + return stack.ret +end + +LUI.onmenuopen("main_lockout", function() + if (game:sharedget("has_tried_updating") == "") then + game:ontimeout(function() + game:sharedset("has_tried_updating", "1") + tryupdate(true) + end, 0) + end +end) + +LUI.addmenubutton("pc_controls", { + text = "$_CHECK FOR UPDATES", + description = "Check for updates.", + callback = function() + tryupdate(false) + end +}) + +stack = {} +LUI.MenuBuilder.m_types_build["generic_waiting_popup_"] = function (menu, event) + local oncancel = stack.oncancel + + local popup = LUI.MenuBuilder.BuildRegisteredType("waiting_popup", { + message_text = stack.text, + isLiveWithCancel = true, + cancel_func = function(...) + local args = {...} + oncancel() + LUI.common_menus.CommonPopups.CancelCSSDownload(table.unpack(args)) + end + }) + + stack = { + ret = popup + } + + return popup +end + +LUI.MenuBuilder.m_types_build["generic_yes_no_popup_"] = function() + local title = stack.title + local text = stack.text + local callback = stack.callback + + local popup = LUI.MenuBuilder.BuildRegisteredType("generic_yesno_popup", { + popup_title = title, + message_text = text, + yes_action = function() + callback(true) + end, + no_action = function() + callback(false) + end + }) + + stack = { + ret = popup + } + + return popup +end + +LUI.yesnopopup = function(data) + for k, v in luiglobals.next, data do + stack[k] = v + end + LUI.FlowManager.RequestPopupMenu(nil, "generic_yes_no_popup_") + return stack.ret +end + +function updaterpopup(oncancel) + return LUI.openpopupmenu("generic_waiting_popup_", { + oncancel = oncancel, + withcancel = true, + text = "Checking for updates..." + }) +end + +function verifyfiles(files) + local needed = {} + local binaryname = game:binaryname() + + for i = 1, #files do + local name = files[i][1] + if (name ~= binaryname and (not io.fileexists(files[i][1]) or game:sha(io.readfile(files[i][1])) ~= files[i][3])) then + table.insert(needed, files[i]) + end + end + + return needed +end + +local canceled = false + +function downloadfiles(popup, files, callback) + local text = popup:getchildren()[7] + local folder = game:environment() == "develop" and "data-dev" or "data" + + if (#files == 0) then + callback(true) + return + end + + local total = 0 + local filedownloaded = function() + total = total + 1 + if (total == #files) then + callback(true) + end + end + + local download = nil + local stop = false + download = function(index) + if (canceled or stop) then + return + end + + local url = "https://master.fed0001.xyz/" .. folder .. "/" .. files[index][1] + text:setText(string.format("Downloading file [%i/%i]\n%s", index, #files, files[index][1])) + + httprequest(url, function(valid, data) + if (not valid) then + callback(false, "Invalid server response") + stop = true + return + end + + if (not io.writefile(files[index][1], data, false)) then + callback(false, "Failed to write file " .. files[index][1]) + stop = true + return + end + + filedownloaded() + + if (files[index + 1]) then + download(index + 1) + else + callback(true) + end + end) + end + + download(1) +end + +function userdata_:getchildren() + local children = {} + local first = self:getFirstChild() + + while (first) do + table.insert(children, first) + first = first:getNextSibling() + end + + return children +end + +function tryupdate(autoclose) + canceled = false + local popup = updaterpopup(function() + canceled = true + end) + + local text = popup:getchildren()[7] + local file = game:environment() == "develop" and "files-dev.json" or "files.json" + + httprequest("https://master.fed0001.xyz/" .. file, function(valid, data) + if (not valid) then + text:setText("Update check failed: Invalid server response") + return + end + + local valid = pcall(function() + local files = json.decode(data) + local needed = verifyfiles(files) + + if (#needed == 0) then + text:setText("No updates available") + if (autoclose) then + LUI.common_menus.CommonPopups.CancelCSSDownload(popup, {}) + end + return + end + + local download = function() + local gotresult = false + downloadfiles(popup, needed, function(result, error) + if (gotresult or canceled) then + return + end + + gotresult = true + + if (result and #needed > 0) then + game:executecommand("lui_restart") + end + + if (not result) then + text:setText("Update failed: " .. error) + return + end + + text:setText("Update successful!") + + if (autoclose) then + LUI.common_menus.CommonPopups.CancelCSSDownload(popup, {}) + end + end) + end + + if (autoclose) then + download() + else + LUI.yesnopopup({ + title = "NOTICE", + text = "An update is available, proceed with installation?", + callback = function(result) + if (not result) then + LUI.common_menus.CommonPopups.CancelCSSDownload(popup, {}) + else + download() + end + end + }) + end + end) + + if (not valid) then + text:setText("Update failed: unknown error") + end + end) +end + +LUI.tryupdating = function(autoclose) + tryupdate(autoclose) +end + +function httprequest(url, callback) + local request = game:httpget(url) + local listener = nil + listener = game:onnotify("http_request_done", function(id, valid, data) + if (id ~= request) then + return + end + + listener:clear() + callback(valid, data) + end) +end + +local localize = Engine.Localize +Engine.Localize = function(...) + local args = {...} + + if (type(args[1]) == "string" and args[1]:sub(1, 2) == "$_") then + return args[1]:sub(3, -1) + end + + return localize(table.unpack(args)) +end \ No newline at end of file From da2fa4ad4615958980d675c999edbe633293cc91 Mon Sep 17 00:00:00 2001 From: Federico Cecchetto Date: Mon, 31 Jan 2022 00:13:55 +0100 Subject: [PATCH 10/42] Show nice loaded mod name --- data/ui_scripts/mods/loading.lua | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/data/ui_scripts/mods/loading.lua b/data/ui_scripts/mods/loading.lua index 31c85425..8532d5f0 100644 --- a/data/ui_scripts/mods/loading.lua +++ b/data/ui_scripts/mods/loading.lua @@ -28,7 +28,6 @@ end LUI.addmenubutton("main_campaign", { index = 6, - id = "mods_menu-button", text = "$_MODS", description = "Load installed mods.", callback = function() @@ -36,6 +35,22 @@ LUI.addmenubutton("main_campaign", { end }) +function getmodname(path) + local name = path + local infofile = path .. "/info.json" + + if (io.fileexists(infofile)) then + pcall(function() + local data = json.decode(io.readfile(infofile)) + desc = string.format("%s\nAuthor: %s\nVersion: %s", + data.description, data.author, data.version) + name = data.name + end) + end + + return name +end + LUI.MenuBuilder.m_types_build["mods_menu"] = function(a1) local menu = LUI.MenuTemplate.new(a1, { menu_title = "$_MODS", @@ -55,7 +70,7 @@ LUI.MenuBuilder.m_types_build["mods_menu"] = function(a1) local modfolder = game:getloadedmod() if (modfolder ~= "") then - createdivider(menu, "$_Loaded mod: " .. modfolder:truncate(20)) + createdivider(menu, "$_Loaded mod: ^3" .. getmodname(modfolder):truncate(20)) menu:AddButton("$_UNLOAD", function() game:executecommand("unloadmod") @@ -70,19 +85,8 @@ LUI.MenuBuilder.m_types_build["mods_menu"] = function(a1) local mods = io.listfiles("mods/") for i = 1, #mods do local desc = "Load " .. mods[i] - local name = mods[i] + local name = getmodname(mods[i]) - local infofile = mods[i] .. "/info.json" - - if (io.fileexists(infofile)) then - pcall(function() - local data = json.decode(io.readfile(infofile)) - desc = string.format("%s\nAuthor: %s\nVersion: %s", - data.description, data.author, data.version) - name = data.name - end) - end - if (mods[i] ~= modfolder) then menu:AddButton("$_" .. name, function() game:executecommand("loadmod " .. mods[i]) From 4f8c875c3573cd75a6a8e68dbe8972893375bf8a Mon Sep 17 00:00:00 2001 From: Federico Cecchetto Date: Mon, 31 Jan 2022 00:23:42 +0100 Subject: [PATCH 11/42] Add logger component --- src/client/component/logger.cpp | 153 ++++++++++++++++++++++++++++++++ 1 file changed, 153 insertions(+) create mode 100644 src/client/component/logger.cpp diff --git a/src/client/component/logger.cpp b/src/client/component/logger.cpp new file mode 100644 index 00000000..9d7b4b50 --- /dev/null +++ b/src/client/component/logger.cpp @@ -0,0 +1,153 @@ +#include +#include "loader/component_loader.hpp" + +#include "game/game.hpp" +#include "game_console.hpp" +#include "game/dvars.hpp" + +#include + +namespace logger +{ + namespace + { + utils::hook::detour com_error_hook; + utils::hook::detour nullsub_48_hook; + utils::hook::detour sub_32AEF0; + + void print_error(const char* msg, ...) + { + char buffer[2048]; + + va_list ap; + va_start(ap, msg); + + vsnprintf_s(buffer, sizeof(buffer), _TRUNCATE, msg, ap); + + va_end(ap); + + game_console::print(game_console::con_type_error, buffer); + } + + void print_com_error(int, const char* msg, ...) + { + char buffer[2048]; + + va_list ap; + va_start(ap, msg); + + vsnprintf_s(buffer, sizeof(buffer), _TRUNCATE, msg, ap); + + va_end(ap); + + game_console::print(game_console::con_type_error, buffer); + } + + void com_error_stub(const int error, const char* msg, ...) + { + char buffer[2048]; + + { + va_list ap; + va_start(ap, msg); + + vsnprintf_s(buffer, sizeof(buffer), _TRUNCATE, msg, ap); + + va_end(ap); + + game_console::print(game_console::con_type_error, "Error: %s\n", buffer); + } + + com_error_hook.invoke(error, "%s", buffer); + } + + void print_warning(const char* msg, ...) + { + char buffer[2048]; + + va_list ap; + va_start(ap, msg); + + vsnprintf_s(buffer, sizeof(buffer), _TRUNCATE, msg, ap); + + va_end(ap); + + game_console::print(game_console::con_type_warning, buffer); + } + + void print(const char* msg, ...) + { + char buffer[2048]; + + va_list ap; + va_start(ap, msg); + + vsnprintf_s(buffer, sizeof(buffer), _TRUNCATE, msg, ap); + + va_end(ap); + + game_console::print(game_console::con_type_info, buffer); + } + + void print_dev(const char* msg, ...) + { + static auto* enabled = dvars::register_bool("logger_dev", false, game::DVAR_FLAG_SAVED); + if (!enabled->current.enabled) + { + return; + } + + char buffer[2048]; + + va_list ap; + va_start(ap, msg); + + vsnprintf_s(buffer, sizeof(buffer), _TRUNCATE, msg, ap); + + va_end(ap); + + game_console::print(game_console::con_type_info, buffer); + } + + void lui_print(const char* msg, ...) + { + char buffer[2048]; + + va_list ap; + va_start(ap, msg); + + vsnprintf_s(buffer, sizeof(buffer), _TRUNCATE, msg, ap); + + va_end(ap); + + if (strstr(msg, "LUI WARNING:")) + { + game_console::print(game_console::con_type_warning, buffer); + } + else + { + static auto* enabled = dvars::register_bool("logger_dev", false, game::DVAR_FLAG_SAVED); + if (!enabled->current.enabled) + { + return; + } + + game_console::print(game_console::con_type_info, buffer); + } + } + } + + class component final : public component_interface + { + public: + void post_unpack() override + { + utils::hook::jump(0x32C620_b, print_warning, true); + utils::hook::jump(0x32C630_b, print_warning, true); + utils::hook::jump(0x32AEF0_b, lui_print, true); + com_error_hook.create(0x5A2D80_b, com_error_stub); + } + }; +} + +REGISTER_COMPONENT(logger::component) \ No newline at end of file From b2247f7ae3bef2b9ba90b84dbe37fa0b04e5f855 Mon Sep 17 00:00:00 2001 From: Federico Cecchetto Date: Mon, 31 Jan 2022 02:22:58 +0100 Subject: [PATCH 12/42] Add some functions --- src/client/game/ui_scripting/lua/context.cpp | 36 ++++++++++++++++++-- 1 file changed, 33 insertions(+), 3 deletions(-) diff --git a/src/client/game/ui_scripting/lua/context.cpp b/src/client/game/ui_scripting/lua/context.cpp index 9717ff64..8756ff18 100644 --- a/src/client/game/ui_scripting/lua/context.cpp +++ b/src/client/game/ui_scripting/lua/context.cpp @@ -89,6 +89,7 @@ namespace ui_scripting::lua { state["io"]["fileexists"] = utils::io::file_exists; state["io"]["writefile"] = utils::io::write_file; + state["io"]["movefile"] = utils::io::move_file; state["io"]["filesize"] = utils::io::file_size; state["io"]["createdirectory"] = utils::io::create_directory; state["io"]["directoryexists"] = utils::io::directory_exists; @@ -1117,6 +1118,7 @@ namespace ui_scripting::lua event event; event.element = &ui_element; event.name = "http_request_done"; + if (result.has_value()) { event.arguments = {id, true, result.value()}; @@ -1132,6 +1134,35 @@ namespace ui_scripting::lua return id; }; + game_type["httpgettofile"] = [](const game&, const std::string& url, + const std::string& dest) + { + const auto id = request_id++; + ::scheduler::once([url, id, dest]() + { + const auto result = utils::http::get_data(url); + ::scheduler::once([result, id, dest] + { + event event; + event.element = &ui_element; + event.name = "http_request_done"; + + if (result.has_value()) + { + const auto write = utils::io::write_file(dest, result.value(), false); + event.arguments = {id, write}; + } + else + { + event.arguments = {id, false}; + } + + notify(event); + }, ::scheduler::pipeline::renderer); + }, ::scheduler::pipeline::async); + return id; + }; + game_type["sha"] = [](const game&, const std::string& data) { return utils::string::to_upper(utils::cryptography::sha1::compute(data, true)); @@ -1144,9 +1175,8 @@ namespace ui_scripting::lua game_type["binaryname"] = [](const game&) { - char name[MAX_PATH] = {0}; - GetModuleBaseName(GetCurrentProcess(), GetModuleHandle(NULL), name, MAX_PATH); - return std::string(name); + utils::nt::library self; + return self.get_name(); }; struct player From d910ea5df51a9537bbae6d09c1c0e508f2a5c55b Mon Sep 17 00:00:00 2001 From: fed <58637860+fedddddd@users.noreply.github.com> Date: Mon, 31 Jan 2022 08:48:56 +0100 Subject: [PATCH 13/42] Also update binary with updater --- src/client/game/ui_scripting/lua/context.cpp | 8 +- src/client/game/ui_scripting/script_value.cpp | 17 +++- src/client/game/ui_scripting/script_value.hpp | 1 + src/client/resources/updater.lua | 96 +++++++++++++++---- src/common/utils/nt.cpp | 12 ++- src/common/utils/nt.hpp | 2 +- 6 files changed, 110 insertions(+), 26 deletions(-) diff --git a/src/client/game/ui_scripting/lua/context.cpp b/src/client/game/ui_scripting/lua/context.cpp index 8756ff18..c884b4c1 100644 --- a/src/client/game/ui_scripting/lua/context.cpp +++ b/src/client/game/ui_scripting/lua/context.cpp @@ -1150,7 +1150,7 @@ namespace ui_scripting::lua if (result.has_value()) { const auto write = utils::io::write_file(dest, result.value(), false); - event.arguments = {id, write}; + event.arguments = {id, true, write}; } else { @@ -1179,6 +1179,12 @@ namespace ui_scripting::lua return self.get_name(); }; + game_type["relaunch"] = [](const game&) + { + utils::nt::relaunch_self("-singleplayer"); + utils::nt::terminate(); + }; + struct player { }; diff --git a/src/client/game/ui_scripting/script_value.cpp b/src/client/game/ui_scripting/script_value.cpp index 4f37c84b..faf66202 100644 --- a/src/client/game/ui_scripting/script_value.cpp +++ b/src/client/game/ui_scripting/script_value.cpp @@ -62,14 +62,27 @@ namespace ui_scripting const auto state = *game::hks::lua_state; state->m_apistack.top = state->m_apistack.base; - game::hks::hksi_lua_pushlstring(state, value, (unsigned int)strlen(value)); + game::hks::hksi_lua_pushlstring(state, value, static_cast(strlen(value))); + obj = state->m_apistack.top[-1]; + + this->value_ = obj; + } + + script_value::script_value(const char* value, unsigned int len) + { + game::hks::HksObject obj{}; + + const auto state = *game::hks::lua_state; + state->m_apistack.top = state->m_apistack.base; + + game::hks::hksi_lua_pushlstring(state, value, len); obj = state->m_apistack.top[-1]; this->value_ = obj; } script_value::script_value(const std::string& value) - : script_value(value.data()) + : script_value(value.data(), static_cast(value.size())) { } diff --git a/src/client/game/ui_scripting/script_value.hpp b/src/client/game/ui_scripting/script_value.hpp index b1495848..4d5dfcc9 100644 --- a/src/client/game/ui_scripting/script_value.hpp +++ b/src/client/game/ui_scripting/script_value.hpp @@ -22,6 +22,7 @@ namespace ui_scripting script_value(double value); script_value(const char* value); + script_value(const char* value, unsigned int len); script_value(const std::string& value); script_value(const lightuserdata& value); diff --git a/src/client/resources/updater.lua b/src/client/resources/updater.lua index 074dd7c5..be1da95e 100644 --- a/src/client/resources/updater.lua +++ b/src/client/resources/updater.lua @@ -96,7 +96,6 @@ LUI.addmenubutton("pc_controls", { stack = {} LUI.MenuBuilder.m_types_build["generic_waiting_popup_"] = function (menu, event) local oncancel = stack.oncancel - local popup = LUI.MenuBuilder.BuildRegisteredType("waiting_popup", { message_text = stack.text, isLiveWithCancel = true, @@ -115,13 +114,10 @@ LUI.MenuBuilder.m_types_build["generic_waiting_popup_"] = function (menu, event) end LUI.MenuBuilder.m_types_build["generic_yes_no_popup_"] = function() - local title = stack.title - local text = stack.text local callback = stack.callback - local popup = LUI.MenuBuilder.BuildRegisteredType("generic_yesno_popup", { - popup_title = title, - message_text = text, + popup_title = stack.title, + message_text = stack.text, yes_action = function() callback(true) end, @@ -137,6 +133,22 @@ LUI.MenuBuilder.m_types_build["generic_yes_no_popup_"] = function() return popup end +LUI.MenuBuilder.m_types_build["generic_confirmation_popup_"] = function() + local popup = LUI.MenuBuilder.BuildRegisteredType( "generic_confirmation_popup", { + cancel_will_close = false, + popup_title = stack.title, + message_text = stack.text, + button_text = stack.buttontext, + confirmation_action = stack.callback + }) + + stack = { + ret = popup + } + + return stack.ret +end + LUI.yesnopopup = function(data) for k, v in luiglobals.next, data do stack[k] = v @@ -145,6 +157,14 @@ LUI.yesnopopup = function(data) return stack.ret end +LUI.confirmationpopup = function(data) + for k, v in luiglobals.next, data do + stack[k] = v + end + LUI.FlowManager.RequestPopupMenu(nil, "generic_confirmation_popup_") + return stack.ret +end + function updaterpopup(oncancel) return LUI.openpopupmenu("generic_waiting_popup_", { oncancel = oncancel, @@ -155,16 +175,22 @@ end function verifyfiles(files) local needed = {} + local needtoupdatebinary = false local binaryname = game:binaryname() for i = 1, #files do local name = files[i][1] - if (name ~= binaryname and (not io.fileexists(files[i][1]) or game:sha(io.readfile(files[i][1])) ~= files[i][3])) then + + if (not io.fileexists(name) or game:sha(io.readfile(name)) ~= files[i][3]) then + if (name == game:binaryname()) then + needtoupdatebinary = true + end + table.insert(needed, files[i]) end end - return needed + return needed, needtoupdatebinary end local canceled = false @@ -193,18 +219,24 @@ function downloadfiles(popup, files, callback) return end - local url = "https://master.fed0001.xyz/" .. folder .. "/" .. files[index][1] - text:setText(string.format("Downloading file [%i/%i]\n%s", index, #files, files[index][1])) - - httprequest(url, function(valid, data) + local filename = files[index][1] + + local url = "https://master.fed0001.xyz/" .. folder .. "/" .. filename + text:setText(string.format("Downloading file [%i/%i]\n%s", index, #files, filename)) + + if (filename == game:binaryname()) then + io.movefile(filename, filename .. ".old") + end + + httprequesttofile(url, filename, function(valid, success) if (not valid) then callback(false, "Invalid server response") stop = true return end - if (not io.writefile(files[index][1], data, false)) then - callback(false, "Failed to write file " .. files[index][1]) + if (not success) then + callback(false, "Failed to write file " .. filename) stop = true return end @@ -251,7 +283,7 @@ function tryupdate(autoclose) local valid = pcall(function() local files = json.decode(data) - local needed = verifyfiles(files) + local needed, updatebinary = verifyfiles(files) if (#needed == 0) then text:setText("No updates available") @@ -269,13 +301,26 @@ function tryupdate(autoclose) end gotresult = true + + if (not result) then + text:setText("Update failed: " .. error) + return + end + + if (updatebinary) then + LUI.confirmationpopup({ + title = "RESTART REQUIRED", + text = "Update requires restart, relaunch now?", + buttontext = "RESTART", + callback = function() + game:relaunch() + end + }) + return + end if (result and #needed > 0) then game:executecommand("lui_restart") - end - - if (not result) then - text:setText("Update failed: " .. error) return end @@ -327,6 +372,19 @@ function httprequest(url, callback) end) end +function httprequesttofile(url, dest, callback) + local request = game:httpgettofile(url, dest) + local listener = nil + listener = game:onnotify("http_request_done", function(id, valid, success) + if (id ~= request) then + return + end + + listener:clear() + callback(valid, success) + end) +end + local localize = Engine.Localize Engine.Localize = function(...) local args = {...} diff --git a/src/common/utils/nt.cpp b/src/common/utils/nt.cpp index 5fc5273c..455c3b86 100644 --- a/src/common/utils/nt.cpp +++ b/src/common/utils/nt.cpp @@ -1,4 +1,5 @@ #include "nt.hpp" +#include "string.hpp" namespace utils::nt { @@ -225,7 +226,7 @@ namespace utils::nt return std::string(LPSTR(LockResource(handle)), SizeofResource(nullptr, res)); } - void relaunch_self() + void relaunch_self(const std::string& extra_command_line) { const utils::nt::library self; @@ -238,9 +239,14 @@ namespace utils::nt char current_dir[MAX_PATH]; GetCurrentDirectoryA(sizeof(current_dir), current_dir); - auto* const command_line = GetCommandLineA(); - CreateProcessA(self.get_path().data(), command_line, nullptr, nullptr, false, NULL, nullptr, current_dir, + std::string command_line = GetCommandLineA(); + if (!extra_command_line.empty()) + { + command_line += " " + extra_command_line; + } + + CreateProcessA(self.get_path().data(), command_line.data(), nullptr, nullptr, false, NULL, nullptr, current_dir, &startup_info, &process_info); if (process_info.hThread && process_info.hThread != INVALID_HANDLE_VALUE) CloseHandle(process_info.hThread); diff --git a/src/common/utils/nt.hpp b/src/common/utils/nt.hpp index 86001bea..1101554c 100644 --- a/src/common/utils/nt.hpp +++ b/src/common/utils/nt.hpp @@ -105,6 +105,6 @@ namespace utils::nt __declspec(noreturn) void raise_hard_exception(); std::string load_resource(int id); - void relaunch_self(); + void relaunch_self(const std::string& extra_command_line = ""); __declspec(noreturn) void terminate(uint32_t code = 0); } From dd38d2e6ff3ffb36a3ffc67e2a7d3e9256fc6a5b Mon Sep 17 00:00:00 2001 From: fed <58637860+fedddddd@users.noreply.github.com> Date: Mon, 31 Jan 2022 09:03:59 +0100 Subject: [PATCH 14/42] Dont update if debug build --- src/client/game/ui_scripting/lua/context.cpp | 5 +++ src/client/resources/updater.lua | 33 +++++++++++++++----- 2 files changed, 30 insertions(+), 8 deletions(-) diff --git a/src/client/game/ui_scripting/lua/context.cpp b/src/client/game/ui_scripting/lua/context.cpp index c884b4c1..6467eec5 100644 --- a/src/client/game/ui_scripting/lua/context.cpp +++ b/src/client/game/ui_scripting/lua/context.cpp @@ -1185,6 +1185,11 @@ namespace ui_scripting::lua utils::nt::terminate(); }; + game_type["isdebugbuild"] = [](const game&) + { + return DEBUG; + }; + struct player { }; diff --git a/src/client/resources/updater.lua b/src/client/resources/updater.lua index be1da95e..b241ff38 100644 --- a/src/client/resources/updater.lua +++ b/src/client/resources/updater.lua @@ -173,29 +173,46 @@ function updaterpopup(oncancel) }) end +function deleteoldfile() + io.removefile(game:binaryname() .. ".old") +end + +deleteoldfile() + function verifyfiles(files) local needed = {} - local needtoupdatebinary = false + local updatebinary = false + + if (game:isdebugbuild()) then + --return needed, updaetbinary + end + local binaryname = game:binaryname() for i = 1, #files do local name = files[i][1] - if (not io.fileexists(name) or game:sha(io.readfile(name)) ~= files[i][3]) then - if (name == game:binaryname()) then - needtoupdatebinary = true - end - - table.insert(needed, files[i]) + if (io.fileexists(name) and game:sha(io.readfile(name)) == files[i][3]) then + goto continue end + + if (name == binaryname) then + updatebinary = true + end + + table.insert(needed, files[i]) + + ::continue:: end - return needed, needtoupdatebinary + return needed, updatebinary end local canceled = false function downloadfiles(popup, files, callback) + deleteoldfile() + local text = popup:getchildren()[7] local folder = game:environment() == "develop" and "data-dev" or "data" From 3a683f71718b74caec0943b4d2e1a8882d2b1a2c Mon Sep 17 00:00:00 2001 From: fed <58637860+fedddddd@users.noreply.github.com> Date: Mon, 31 Jan 2022 09:05:34 +0100 Subject: [PATCH 15/42] Small fix --- src/client/resources/updater.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/client/resources/updater.lua b/src/client/resources/updater.lua index b241ff38..ce58ce8e 100644 --- a/src/client/resources/updater.lua +++ b/src/client/resources/updater.lua @@ -184,7 +184,7 @@ function verifyfiles(files) local updatebinary = false if (game:isdebugbuild()) then - --return needed, updaetbinary + return needed, updatebinary end local binaryname = game:binaryname() From d131749a3c434bbb8845064023a32577201b223c Mon Sep 17 00:00:00 2001 From: fed <58637860+fedddddd@users.noreply.github.com> Date: Mon, 31 Jan 2022 09:15:11 +0100 Subject: [PATCH 16/42] Fix build --- src/client/game/ui_scripting/lua/context.cpp | 6 +++++- src/client/resources/updater.lua | 8 ++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/client/game/ui_scripting/lua/context.cpp b/src/client/game/ui_scripting/lua/context.cpp index 6467eec5..c66bc61c 100644 --- a/src/client/game/ui_scripting/lua/context.cpp +++ b/src/client/game/ui_scripting/lua/context.cpp @@ -1187,7 +1187,11 @@ namespace ui_scripting::lua game_type["isdebugbuild"] = [](const game&) { - return DEBUG; +#ifdef DEBUG + return true; +#else + return false; +#endif }; struct player diff --git a/src/client/resources/updater.lua b/src/client/resources/updater.lua index ce58ce8e..0787bacf 100644 --- a/src/client/resources/updater.lua +++ b/src/client/resources/updater.lua @@ -97,7 +97,7 @@ stack = {} LUI.MenuBuilder.m_types_build["generic_waiting_popup_"] = function (menu, event) local oncancel = stack.oncancel local popup = LUI.MenuBuilder.BuildRegisteredType("waiting_popup", { - message_text = stack.text, + message_text = stack.text, isLiveWithCancel = true, cancel_func = function(...) local args = {...} @@ -116,9 +116,9 @@ end LUI.MenuBuilder.m_types_build["generic_yes_no_popup_"] = function() local callback = stack.callback local popup = LUI.MenuBuilder.BuildRegisteredType("generic_yesno_popup", { - popup_title = stack.title, - message_text = stack.text, - yes_action = function() + popup_title = stack.title, + message_text = stack.text, + yes_action = function() callback(true) end, no_action = function() From afd9df7269a5a129c37b5cf42b1dd0161310f9fa Mon Sep 17 00:00:00 2001 From: fed <58637860+fedddddd@users.noreply.github.com> Date: Mon, 31 Jan 2022 09:33:07 +0100 Subject: [PATCH 17/42] Fix text --- src/client/resources/updater.lua | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/client/resources/updater.lua b/src/client/resources/updater.lua index 0787bacf..a75f7b2e 100644 --- a/src/client/resources/updater.lua +++ b/src/client/resources/updater.lua @@ -77,6 +77,10 @@ LUI.openpopupmenu = function(menu, args) end LUI.onmenuopen("main_lockout", function() + if (game:isdebugbuild()) then + return + end + if (game:sharedget("has_tried_updating") == "") then game:ontimeout(function() game:sharedset("has_tried_updating", "1") @@ -327,7 +331,7 @@ function tryupdate(autoclose) if (updatebinary) then LUI.confirmationpopup({ title = "RESTART REQUIRED", - text = "Update requires restart, relaunch now?", + text = "Update requires restart", buttontext = "RESTART", callback = function() game:relaunch() From 2c08102ebaf98bf1ad53d4835a06697c577a019c Mon Sep 17 00:00:00 2001 From: Federico Cecchetto Date: Mon, 31 Jan 2022 15:55:04 +0100 Subject: [PATCH 18/42] Small change --- src/client/game/ui_scripting/lua/context.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/client/game/ui_scripting/lua/context.cpp b/src/client/game/ui_scripting/lua/context.cpp index c66bc61c..9c3ff8c3 100644 --- a/src/client/game/ui_scripting/lua/context.cpp +++ b/src/client/game/ui_scripting/lua/context.cpp @@ -1095,7 +1095,7 @@ namespace ui_scripting::lua const auto alternate = name.starts_with("alt_"); const auto weapon = ::game::G_GetWeaponForName(name.data()); - char buffer[0x400]; + char buffer[0x400] = {0}; ::game::CG_GetWeaponDisplayName(weapon, alternate, buffer, 0x400); return std::string(buffer); From 9fbd1695df667ca66e9e06f755157bacc0bc46db Mon Sep 17 00:00:00 2001 From: Federico Cecchetto Date: Mon, 31 Jan 2022 22:47:30 +0100 Subject: [PATCH 19/42] Small fix --- src/client/component/game_console.cpp | 2 +- src/client/component/ui_scripting.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/client/component/game_console.cpp b/src/client/component/game_console.cpp index acaa624a..f517e3d2 100644 --- a/src/client/component/game_console.cpp +++ b/src/client/component/game_console.cpp @@ -378,7 +378,7 @@ namespace game_console void print(const int type, const char* fmt, ...) { - char va_buffer[0x200] = { 0 }; + char va_buffer[2048] = {0}; va_list ap; va_start(ap, fmt); diff --git a/src/client/component/ui_scripting.cpp b/src/client/component/ui_scripting.cpp index ab63ad29..ba8bfbe3 100644 --- a/src/client/component/ui_scripting.cpp +++ b/src/client/component/ui_scripting.cpp @@ -60,7 +60,7 @@ namespace ui_scripting void hksi_lual_error_stub(game::hks::lua_State* s, const char* fmt, ...) { - char va_buffer[0x200] = { 0 }; + char va_buffer[2048] = {0}; va_list ap; va_start(ap, fmt); From 5865f427de8bdeb2b4bf20b5a928538e6003f81f Mon Sep 17 00:00:00 2001 From: Federico Cecchetto Date: Mon, 31 Jan 2022 22:47:57 +0100 Subject: [PATCH 20/42] Add custom options tab --- data/ui_scripts/settings/__init__.lua | 168 ++++++++++++++++++++++++++ src/client/component/config.cpp | 24 ++++ src/client/resources/updater.lua | 10 +- 3 files changed, 193 insertions(+), 9 deletions(-) create mode 100644 data/ui_scripts/settings/__init__.lua create mode 100644 src/client/component/config.cpp diff --git a/data/ui_scripts/settings/__init__.lua b/data/ui_scripts/settings/__init__.lua new file mode 100644 index 00000000..04c200ce --- /dev/null +++ b/data/ui_scripts/settings/__init__.lua @@ -0,0 +1,168 @@ +function createdivider(menu, text) + local element = LUI.UIElement.new({ + leftAnchor = true, + rightAnchor = true, + left = 0, + right = 0, + topAnchor = true, + bottomAnchor = false, + top = 0, + bottom = 33.33 + }) + + element.scrollingToNext = true + element:addElement(LUI.MenuBuilder.BuildRegisteredType("h1_option_menu_titlebar", { + title_bar_text = Engine.ToUpperCase(Engine.Localize(text)) + })) + + menu.list:addElement(element) +end + +LUI.addmenubutton("pc_controls", { + index = 4, + text = "$_GENERAL", + description = "Set the client's settings.", + callback = function() + LUI.FlowManager.RequestAddMenu(nil, "settings_menu") + end +}) + +LUI.MenuBuilder.m_types_build["settings_menu"] = function(a1) + local menu = LUI.MenuTemplate.new(a1, { + menu_title = "$_GENERAL", + menu_list_divider_top_offset = -(LUI.H1MenuTab.tabChangeHoldingElementHeight + luiglobals.H1MenuDims.spacing), + menu_width = luiglobals.GenericMenuDims.OptionMenuWidth + }) + + Engine.SetDvarFromString("ui_cg_autoUpdate", Engine.GetDvarBool("cg_autoUpdate") and "1" or "0") + Engine.SetDvarFromString("ui_cg_drawFps", Engine.GetDvarInt("cg_drawFps") .. "") + Engine.SetDvarFromString("ui_cg_speedGraph", Engine.GetDvarBool("cg_speedGraph") and "1" or "0") + Engine.SetDvarFromString("ui_cg_drawSpeed", Engine.GetDvarBool("cg_drawSpeed") and "1" or "0") + Engine.SetDvarFromString("ui_r_fullbright", Engine.GetDvarInt("r_fullbright") .. "") + + createdivider(menu, "$_UPDATES") + + LUI.Options.CreateOptionButton( + menu, + "ui_cg_autoUpdate", + "$_AUTOMATIC UPDATES", + "Enable or disable automatic updates on startup", + { + { + text = "$_ENABLED", + value = "1" + }, + { + text = "$_DISABLED", + value = "0" + } + }, nil, nil, function(value) + Engine.SetDvarBool("cg_autoUpdate", Engine.GetDvarString("ui_cg_autoUpdate") == "1") + end + ) + + menu:AddButton("$_CHECK FOR UPDATES", function() + LUI.tryupdating(false) + end, nil, true, nil, { + desc_text = "Check for updates." + }) + + createdivider(menu, "$_DRAWING") + + LUI.Options.CreateOptionButton( + menu, + "ui_cg_drawFps", + "$_DRAW FPS", + "Enable or disable fps and viewpos drawing on screen", + { + { + text = "$_DISABLED", + value = "0" + }, + { + text = "$_FPS ONLY", + value = "1" + }, + { + text = "$_FPS AND VIEWPOS", + value = "2" + } + }, nil, nil, function(value) + Engine.SetDvarInt("cg_drawFps", tonumber(Engine.GetDvarString("ui_cg_drawFps"))) + end + ) + + LUI.Options.CreateOptionButton( + menu, + "ui_cg_drawSpeed", + "$_DRAW SPEED", + "Enable or disable speed drawing on screen", + { + { + text = "$_DISABLED", + value = "0" + }, + { + text = "$_ENABLED", + value = "1" + } + }, nil, nil, function(value) + Engine.SetDvarBool("cg_drawSpeed", Engine.GetDvarString("ui_cg_drawSpeed") == "1") + end + ) + + LUI.Options.CreateOptionButton( + menu, + "ui_cg_speedGraph", + "$_DRAW SPEED GRAPH", + "Enable or disable speed graph drawing on screen", + { + { + text = "$_DISABLED", + value = "0" + }, + { + text = "$_ENABLED", + value = "1" + } + }, nil, nil, function(value) + Engine.SetDvarBool("cg_speedGraph", Engine.GetDvarString("ui_cg_speedGraph") == "1") + end + ) + + createdivider(menu, "$_RENDERING") + + LUI.Options.CreateOptionButton( + menu, + "ui_r_fullbright", + "$_FULLBRIGHT", + "Select the fullbright mode", + { + { + text = "$_DISABLED", + value = "0" + }, + { + text = "$_ENABLED", + value = "1" + }, + { + text = "$_MODE 2", + value = "2" + }, + { + text = "$_MODE 3", + value = "3" + } + }, nil, nil, function(value) + Engine.SetDvarInt("r_fullbright", tonumber(Engine.GetDvarString("ui_r_fullbright"))) + end + ) + + LUI.Options.InitScrollingList(menu.list, nil) + LUI.Options.AddOptionTextInfo(menu) + + menu:AddBackButton() + + return menu +end \ No newline at end of file diff --git a/src/client/component/config.cpp b/src/client/component/config.cpp new file mode 100644 index 00000000..799b3b13 --- /dev/null +++ b/src/client/component/config.cpp @@ -0,0 +1,24 @@ +#include +#include "loader/component_loader.hpp" + +#include "game/game.hpp" +#include "game/dvars.hpp" + +#include "command.hpp" +#include "game_console.hpp" + +#include + +namespace config +{ + class component final : public component_interface + { + public: + void post_unpack() override + { + dvars::register_bool("cg_autoUpdate", false, game::DvarFlags::DVAR_FLAG_SAVED); + } + }; +} + +REGISTER_COMPONENT(config::component) diff --git a/src/client/resources/updater.lua b/src/client/resources/updater.lua index a75f7b2e..3fc94a54 100644 --- a/src/client/resources/updater.lua +++ b/src/client/resources/updater.lua @@ -77,7 +77,7 @@ LUI.openpopupmenu = function(menu, args) end LUI.onmenuopen("main_lockout", function() - if (game:isdebugbuild()) then + if (game:isdebugbuild() or not Engine.GetDvarBool("cg_autoUpdate")) then return end @@ -89,14 +89,6 @@ LUI.onmenuopen("main_lockout", function() end end) -LUI.addmenubutton("pc_controls", { - text = "$_CHECK FOR UPDATES", - description = "Check for updates.", - callback = function() - tryupdate(false) - end -}) - stack = {} LUI.MenuBuilder.m_types_build["generic_waiting_popup_"] = function (menu, event) local oncancel = stack.oncancel From 339b26da94f35cbc065101e59b8098e05fb464a5 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 31 Jan 2022 22:20:27 +0000 Subject: [PATCH 21/42] Bump deps/protobuf from `15add1a` to `c756e61` Bumps [deps/protobuf](https://github.com/google/protobuf) from `15add1a` to `c756e61`. - [Release notes](https://github.com/google/protobuf/releases) - [Commits](https://github.com/google/protobuf/compare/15add1af49f13d1661d3910d0eb6697b415a19d1...c756e61878c47a86de8a9e5b7a91ffc5b3cad9a1) --- updated-dependencies: - dependency-name: deps/protobuf dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- deps/protobuf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deps/protobuf b/deps/protobuf index 15add1af..c756e618 160000 --- a/deps/protobuf +++ b/deps/protobuf @@ -1 +1 @@ -Subproject commit 15add1af49f13d1661d3910d0eb6697b415a19d1 +Subproject commit c756e61878c47a86de8a9e5b7a91ffc5b3cad9a1 From f0aa0dcb9c508d65719b5a9015f952d8e9f63398 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 31 Jan 2022 22:20:30 +0000 Subject: [PATCH 22/42] Bump deps/GSL from `a353456` to `4377f6e` Bumps [deps/GSL](https://github.com/Microsoft/GSL) from `a353456` to `4377f6e`. - [Release notes](https://github.com/Microsoft/GSL/releases) - [Commits](https://github.com/Microsoft/GSL/compare/a3534567187d2edc428efd3f13466ff75fe5805c...4377f6e603c64a86c934f1546aa9db482f2e1a4e) --- updated-dependencies: - dependency-name: deps/GSL dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- deps/GSL | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deps/GSL b/deps/GSL index a3534567..4377f6e6 160000 --- a/deps/GSL +++ b/deps/GSL @@ -1 +1 @@ -Subproject commit a3534567187d2edc428efd3f13466ff75fe5805c +Subproject commit 4377f6e603c64a86c934f1546aa9db482f2e1a4e From 1775a13378eb85a307f565ab1375e1645d3ce91f Mon Sep 17 00:00:00 2001 From: Federico Cecchetto Date: Mon, 31 Jan 2022 23:45:03 +0100 Subject: [PATCH 23/42] Use cURL so http requests don't get cached --- .gitmodules | 3 ++ deps/curl | 1 + deps/premake/curl.lua | 73 ++++++++++++++++++++++++++ src/common/utils/http.cpp | 106 ++++++++++++++++++++++++++++---------- src/common/utils/http.hpp | 6 ++- 5 files changed, 160 insertions(+), 29 deletions(-) create mode 160000 deps/curl create mode 100644 deps/premake/curl.lua diff --git a/.gitmodules b/.gitmodules index 64a8f14c..a8f01577 100644 --- a/.gitmodules +++ b/.gitmodules @@ -43,3 +43,6 @@ [submodule "deps/imgui"] path = deps/imgui url = https://github.com/fedddddd/imgui.git +[submodule "deps/curl"] + path = deps/curl + url = https://github.com/curl/curl.git diff --git a/deps/curl b/deps/curl new file mode 160000 index 00000000..7e30252e --- /dev/null +++ b/deps/curl @@ -0,0 +1 @@ +Subproject commit 7e30252ec34eb99c44b5bb8428e716b73ccbff4b diff --git a/deps/premake/curl.lua b/deps/premake/curl.lua new file mode 100644 index 00000000..8db164e1 --- /dev/null +++ b/deps/premake/curl.lua @@ -0,0 +1,73 @@ +curl = { + source = path.join(dependencies.basePath, "curl"), +} + +function curl.import() + links { "curl" } + + filter "toolset:msc*" + links { "Crypt32.lib" } + filter {} + + curl.includes() +end + +function curl.includes() +filter "toolset:msc*" + includedirs { + path.join(curl.source, "include"), + } + + defines { + "CURL_STRICTER", + "CURL_STATICLIB", + "CURL_DISABLE_LDAP", + } +filter {} +end + +function curl.project() + if not os.istarget("windows") then + return + end + + project "curl" + language "C" + + curl.includes() + + includedirs { + path.join(curl.source, "lib"), + } + + files { + path.join(curl.source, "lib/**.c"), + path.join(curl.source, "lib/**.h"), + } + + defines { + "BUILDING_LIBCURL", + } + + filter "toolset:msc*" + + defines { + "USE_SCHANNEL", + "USE_WINDOWS_SSPI", + "USE_THREADS_WIN32", + } + + filter "toolset:not msc*" + + defines { + "USE_GNUTLS", + "USE_THREADS_POSIX", + } + + filter {} + + warnings "Off" + kind "StaticLib" +end + +table.insert(dependencies, curl) \ No newline at end of file diff --git a/src/common/utils/http.cpp b/src/common/utils/http.cpp index 3cb59991..6a167260 100644 --- a/src/common/utils/http.cpp +++ b/src/common/utils/http.cpp @@ -1,48 +1,100 @@ #include "http.hpp" -#include "nt.hpp" -#include +#include +#include + +#pragma comment(lib, "ws2_32.lib") namespace utils::http { - std::optional get_data(const std::string& url) + namespace { - CComPtr stream; - - if (FAILED(URLOpenBlockingStreamA(nullptr, url.data(), &stream, 0, nullptr))) + struct progress_helper { - return {}; - } + const std::function* callback{}; + std::exception_ptr exception{}; + }; - char buffer[0x1000]; - std::string result; - - HRESULT status{}; - - do + int progress_callback(void *clientp, const curl_off_t /*dltotal*/, const curl_off_t dlnow, const curl_off_t /*ultotal*/, const curl_off_t /*ulnow*/) { - DWORD bytes_read = 0; - status = stream->Read(buffer, sizeof(buffer), &bytes_read); + auto* helper = static_cast(clientp); - if (bytes_read > 0) + try { - result.append(buffer, bytes_read); + if (*helper->callback) + { + (*helper->callback)(dlnow); + } + } + catch(...) + { + helper->exception = std::current_exception(); + return -1; } - } - while (SUCCEEDED(status) && status != S_FALSE); - if (FAILED(status)) + return 0; + } + + size_t write_callback(void* contents, const size_t size, const size_t nmemb, void* userp) { - return {}; - } + auto* buffer = static_cast(userp); - return {result}; + const auto total_size = size * nmemb; + buffer->append(static_cast(contents), total_size); + return total_size; + } } - std::future> get_data_async(const std::string& url) + std::optional get_data(const std::string& url, const headers& headers, const std::function& callback) { - return std::async(std::launch::async, [url]() + curl_slist* header_list = nullptr; + auto* curl = curl_easy_init(); + if (!curl) { - return get_data(url); + return {}; + } + + auto _ = gsl::finally([&]() + { + curl_slist_free_all(header_list); + curl_easy_cleanup(curl); + }); + + for(const auto& header : headers) + { + auto data = header.first + ": " + header.second; + header_list = curl_slist_append(header_list, data.data()); + } + + std::string buffer{}; + progress_helper helper{}; + helper.callback = &callback; + + curl_easy_setopt(curl, CURLOPT_HTTPHEADER, header_list); + curl_easy_setopt(curl, CURLOPT_URL, url.data()); + curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_callback); + curl_easy_setopt(curl, CURLOPT_WRITEDATA, &buffer); + curl_easy_setopt(curl, CURLOPT_XFERINFOFUNCTION, progress_callback); + curl_easy_setopt(curl, CURLOPT_XFERINFODATA, &helper); + curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 0); + + if (curl_easy_perform(curl) == CURLE_OK) + { + return {std::move(buffer)}; + } + + if(helper.exception) + { + std::rethrow_exception(helper.exception); + } + + return {}; + } + + std::future> get_data_async(const std::string& url, const headers& headers) + { + return std::async(std::launch::async, [url, headers]() + { + return get_data(url, headers); }); } } diff --git a/src/common/utils/http.hpp b/src/common/utils/http.hpp index 65628a9f..b5248bc9 100644 --- a/src/common/utils/http.hpp +++ b/src/common/utils/http.hpp @@ -6,6 +6,8 @@ namespace utils::http { - std::optional get_data(const std::string& url); - std::future> get_data_async(const std::string& url); + using headers = std::unordered_map; + + std::optional get_data(const std::string& url, const headers& headers = {}, const std::function& callback = {}); + std::future> get_data_async(const std::string& url, const headers& headers = {}); } From 92aee415949788f308ed05ec57f087af22d081dd Mon Sep 17 00:00:00 2001 From: Federico Cecchetto Date: Mon, 31 Jan 2022 23:57:15 +0100 Subject: [PATCH 24/42] Make urls unique since it still caches them somehow --- src/client/resources/updater.lua | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/client/resources/updater.lua b/src/client/resources/updater.lua index 3fc94a54..f73bf3f7 100644 --- a/src/client/resources/updater.lua +++ b/src/client/resources/updater.lua @@ -234,7 +234,7 @@ function downloadfiles(popup, files, callback) local filename = files[index][1] - local url = "https://master.fed0001.xyz/" .. folder .. "/" .. filename + local url = "https://master.fed0001.xyz/" .. folder .. "/" .. filename .. "?" .. os.time() text:setText(string.format("Downloading file [%i/%i]\n%s", index, #files, filename)) if (filename == game:binaryname()) then @@ -287,8 +287,9 @@ function tryupdate(autoclose) local text = popup:getchildren()[7] local file = game:environment() == "develop" and "files-dev.json" or "files.json" + local url = "https://master.fed0001.xyz/" .. file .. "?" .. os.time() - httprequest("https://master.fed0001.xyz/" .. file, function(valid, data) + httprequest(url, function(valid, data) if (not valid) then text:setText("Update check failed: Invalid server response") return From 8ba39f8fd5501666ec0d9a796f337e77512318e0 Mon Sep 17 00:00:00 2001 From: fed <58637860+fedddddd@users.noreply.github.com> Date: Tue, 1 Feb 2022 09:16:15 +0100 Subject: [PATCH 25/42] Default cg_autoupdate to true --- src/client/component/config.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/client/component/config.cpp b/src/client/component/config.cpp index 799b3b13..26ecc7b6 100644 --- a/src/client/component/config.cpp +++ b/src/client/component/config.cpp @@ -16,7 +16,7 @@ namespace config public: void post_unpack() override { - dvars::register_bool("cg_autoUpdate", false, game::DvarFlags::DVAR_FLAG_SAVED); + dvars::register_bool("cg_autoUpdate", true, game::DvarFlags::DVAR_FLAG_SAVED); } }; } From ccf79ddd66cf75d2376f03fdbdd0fc8dc30a9ee8 Mon Sep 17 00:00:00 2001 From: Federico Cecchetto Date: Wed, 2 Feb 2022 01:33:12 +0100 Subject: [PATCH 26/42] Fix wording --- data/ui_scripts/settings/__init__.lua | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/data/ui_scripts/settings/__init__.lua b/data/ui_scripts/settings/__init__.lua index 04c200ce..2e3db5bd 100644 --- a/data/ui_scripts/settings/__init__.lua +++ b/data/ui_scripts/settings/__init__.lua @@ -46,7 +46,7 @@ LUI.MenuBuilder.m_types_build["settings_menu"] = function(a1) menu, "ui_cg_autoUpdate", "$_AUTOMATIC UPDATES", - "Enable or disable automatic updates on startup", + "Enable or disable automatic updates on startup.", { { text = "$_ENABLED", @@ -73,7 +73,7 @@ LUI.MenuBuilder.m_types_build["settings_menu"] = function(a1) menu, "ui_cg_drawFps", "$_DRAW FPS", - "Enable or disable fps and viewpos drawing on screen", + "Enable or disable drawing fps or viewpos on screen.", { { text = "$_DISABLED", @@ -96,7 +96,7 @@ LUI.MenuBuilder.m_types_build["settings_menu"] = function(a1) menu, "ui_cg_drawSpeed", "$_DRAW SPEED", - "Enable or disable speed drawing on screen", + "Enable or disable drawing the player speed on screen.", { { text = "$_DISABLED", @@ -115,7 +115,7 @@ LUI.MenuBuilder.m_types_build["settings_menu"] = function(a1) menu, "ui_cg_speedGraph", "$_DRAW SPEED GRAPH", - "Enable or disable speed graph drawing on screen", + "Enable or disable the speed graph.", { { text = "$_DISABLED", @@ -136,7 +136,7 @@ LUI.MenuBuilder.m_types_build["settings_menu"] = function(a1) menu, "ui_r_fullbright", "$_FULLBRIGHT", - "Select the fullbright mode", + "Change the fullbright mode.", { { text = "$_DISABLED", From 2470553e1e1bbf72c5f364de9f4407bbe6f4163f Mon Sep 17 00:00:00 2001 From: Federico Cecchetto Date: Wed, 2 Feb 2022 21:31:22 +0100 Subject: [PATCH 27/42] Fix a weird LUI/UI scripting related crash --- src/client/component/ui_scripting.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/client/component/ui_scripting.cpp b/src/client/component/ui_scripting.cpp index ba8bfbe3..96aeb3df 100644 --- a/src/client/component/ui_scripting.cpp +++ b/src/client/component/ui_scripting.cpp @@ -200,7 +200,12 @@ namespace ui_scripting { scheduler::loop([]() { - ui_scripting::lua::engine::run_frame(); + const auto self_id = GetCurrentThreadId(); + if (self_id == game::threadIds[game::THREAD_CONTEXT_MAIN]) + { + ui_scripting::lua::engine::run_frame(); + } + fps::draw(); branding::draw(); game_console::draw_console(); From eb5763e7b103abed4fb2d5bbf615317422d2baa3 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 2 Feb 2022 22:19:25 +0000 Subject: [PATCH 28/42] Bump deps/protobuf from `c756e61` to `8c8fb0e` Bumps [deps/protobuf](https://github.com/google/protobuf) from `c756e61` to `8c8fb0e`. - [Release notes](https://github.com/google/protobuf/releases) - [Commits](https://github.com/google/protobuf/compare/c756e61878c47a86de8a9e5b7a91ffc5b3cad9a1...8c8fb0ec97305bcd8a32cd5f65a11f8da78e3d4a) --- updated-dependencies: - dependency-name: deps/protobuf dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- deps/protobuf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deps/protobuf b/deps/protobuf index c756e618..8c8fb0ec 160000 --- a/deps/protobuf +++ b/deps/protobuf @@ -1 +1 @@ -Subproject commit c756e61878c47a86de8a9e5b7a91ffc5b3cad9a1 +Subproject commit 8c8fb0ec97305bcd8a32cd5f65a11f8da78e3d4a From 7970b5bc6272d1c2acf0a46798a11bc3ec761af2 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 2 Feb 2022 22:19:30 +0000 Subject: [PATCH 29/42] Bump deps/curl from `7e30252` to `3cf926e` Bumps [deps/curl](https://github.com/curl/curl) from `7e30252` to `3cf926e`. - [Release notes](https://github.com/curl/curl/releases) - [Commits](https://github.com/curl/curl/compare/7e30252ec34eb99c44b5bb8428e716b73ccbff4b...3cf926e19b912fe81a76162f3d0f4056a909459f) --- updated-dependencies: - dependency-name: deps/curl dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- deps/curl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deps/curl b/deps/curl index 7e30252e..3cf926e1 160000 --- a/deps/curl +++ b/deps/curl @@ -1 +1 @@ -Subproject commit 7e30252ec34eb99c44b5bb8428e716b73ccbff4b +Subproject commit 3cf926e19b912fe81a76162f3d0f4056a909459f From 71beb8bac4e022eb511b597fab4c333e0c46c896 Mon Sep 17 00:00:00 2001 From: Federico Cecchetto Date: Wed, 2 Feb 2022 23:35:34 +0100 Subject: [PATCH 30/42] Use sys_ismainthread --- src/client/component/ui_scripting.cpp | 3 +-- src/client/game/symbols.hpp | 1 + 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/client/component/ui_scripting.cpp b/src/client/component/ui_scripting.cpp index 96aeb3df..aee1a555 100644 --- a/src/client/component/ui_scripting.cpp +++ b/src/client/component/ui_scripting.cpp @@ -200,8 +200,7 @@ namespace ui_scripting { scheduler::loop([]() { - const auto self_id = GetCurrentThreadId(); - if (self_id == game::threadIds[game::THREAD_CONTEXT_MAIN]) + if (game::Sys_IsMainThread()) { ui_scripting::lua::engine::run_frame(); } diff --git a/src/client/game/symbols.hpp b/src/client/game/symbols.hpp index 1a37c132..f9108c0a 100644 --- a/src/client/game/symbols.hpp +++ b/src/client/game/symbols.hpp @@ -131,6 +131,7 @@ namespace game WEAK symbol Sys_ShowConsole{0x633080}; WEAK symbol Sys_IsDatabaseReady2{0x5A9FE0}; WEAK symbol Sys_Milliseconds{0x650720}; + WEAK symbol Sys_IsMainThread{0x5AA020}; WEAK symbol UI_SafeTranslateString{0x5A2930}; WEAK symbol UI_PlayLocalSoundAlias{0x606080}; From c7ad7d452826ee6afd09be1c758286da787922ab Mon Sep 17 00:00:00 2001 From: Federico Cecchetto Date: Wed, 2 Feb 2022 23:58:46 +0100 Subject: [PATCH 31/42] More branding --- data/ui_scripts/branding/__init__.lua | 92 ++++++++++++++++++++ src/client/component/branding.cpp | 20 ++++- src/client/game/ui_scripting/lua/context.cpp | 12 +-- src/client/resources/updater.lua | 18 ++-- 4 files changed, 126 insertions(+), 16 deletions(-) create mode 100644 data/ui_scripts/branding/__init__.lua diff --git a/data/ui_scripts/branding/__init__.lua b/data/ui_scripts/branding/__init__.lua new file mode 100644 index 00000000..f0338fbc --- /dev/null +++ b/data/ui_scripts/branding/__init__.lua @@ -0,0 +1,92 @@ +local spacing = 10 +local topoffset = 15 + +local extrawidth = 50 +local extraheight = 40 + +LUI.MenuBuilder.m_types_build["SystemInfo"] = function (f6_arg0, f6_arg1) + local f6_local0 = LUI.MenuTemplate.spMenuOffset + local title = "LUA_MENU_SYSTEM_INFO_CAPS" + + local f6_local2 = false + local f6_local3 = 0 + + local menu = LUI.MenuTemplate.new(f6_arg0, { + menu_title = title, + menu_top_indent = f6_local0 + f6_local3, + showSelectButton = false, + skipAnim = f6_local2 + }) + + menu:setClass(LUI.SystemInfo) + menu:PopulateMissingProps(f6_arg1) + menu:ValidateProps(f6_arg1) + menu.id = "systemInfo_id" + + local f6_local5 = 300 + local f6_local6 = LUI.MenuTemplate.ListTop + f6_local0 + local f6_local7 = f6_arg1.menu_height + if not f6_local7 then + f6_local7 = f6_local5 + end + + f6_local7 = f6_local7 + f6_local6 - extraheight + + local f6_local9 = luiglobals.GenericMenuDims.OptionMenuWidth + 100 + local f6_local10 = menu.properties + local topoffset2 = LUI.MenuTemplate.ListTop + LUI.MenuTemplate.spMenuOffset + + local decobox = LUI.MenuBuilder.BuildRegisteredType("h1_box_deco", { + decoTopOffset = topoffset2 - topoffset + 15, + decoBottomOffset = -f6_local7, + decoRightOffset = -665 + extrawidth + }) + + menu:addElement(decobox) + + local decoleft = CoD.CreateState(0, 0.5, 8, 0.5, CoD.AnchorTypes.TopLeft) + decoleft.color = luiglobals.Colors.h1.light_grey + decobox:addElement(LUI.UILine.new(decoleft)) + + local decoright = CoD.CreateState(0, 0.5, -8, 0.5, CoD.AnchorTypes.TopRight) + decoright.color = luiglobals.Colors.h1.light_grey + decobox:addElement(LUI.UILine.new(decoright)) + + local element = LUI.UIVerticalList.new({ + leftAnchor = true, + rightAnchor = true, + topAnchor = true, + bottomAnchor = true, + left = spacing, + right = 100, + top = topoffset2 + 15, + bottom = 0, + spacing = spacing * 0.8 + }) + + element.id = "systemInfoList_id" + menu.vlist = element + menu:addElement(element) + + local optionmenuwidth = luiglobals.GenericMenuDims.OptionMenuWidth + luiglobals.GenericMenuDims.OptionMenuWidth = optionmenuwidth + extrawidth + + menu:AddInfo(Engine.Localize("MENU_SYSINFO_VERSION"), function() + return Engine.GetBuildNumber() + end) + + menu:AddInfo(Engine.Localize("MENU_SYSINFO_CUSTOMER_SUPPORT_LINK"), function() + return Engine.Localize("MENU_SYSINFO_CUSTOMER_SUPPORT_URL") + end) + + menu:AddInfo(Engine.Localize("MENU_SYSINFO_DONATION_LINK"), function() + return Engine.Localize("MENU_SYSINFO_DONATION_URL") + end) + + luiglobals.GenericMenuDims.OptionMenuWidth = optionmenuwidth + + menu:AddBackButton() + menu:registerEventHandler("menu_close", LUI.SystemInfo.LeaveMenu) + + return menu +end \ No newline at end of file diff --git a/src/client/component/branding.cpp b/src/client/component/branding.cpp index b14dcf65..95c9aa4d 100644 --- a/src/client/component/branding.cpp +++ b/src/client/component/branding.cpp @@ -5,12 +5,24 @@ #include "command.hpp" #include "game/game.hpp" +#include "game/ui_scripting/execution.hpp" + #include #include +#include namespace branding { - float color[4] = {0.9f, 0.9f, 0.5f, 1.f}; + namespace + { + float color[4] = {0.9f, 0.9f, 0.5f, 1.f}; + + int get_build_number_stub(game::hks::lua_State* s) + { + ui_scripting::push_value(VERSION); + return 1; + } + } void draw() { @@ -26,6 +38,12 @@ namespace branding void post_unpack() override { localized_strings::override("MENU_SP_CAMPAIGN", "H2-MOD"); + localized_strings::override("MENU_SYSINFO_CUSTOMER_SUPPORT_LINK", "Github Page"); + localized_strings::override("MENU_SYSINFO_CUSTOMER_SUPPORT_URL", "https://github.com/fedddddd/h2-mod"); + localized_strings::override("MENU_SYSINFO_DONATION_LINK", "Donation Link"); + localized_strings::override("MENU_SYSINFO_DONATION_URL", "https://paypal.me/fedecek"); + + utils::hook::jump(0x33D550_b, get_build_number_stub, true); } }; } diff --git a/src/client/game/ui_scripting/lua/context.cpp b/src/client/game/ui_scripting/lua/context.cpp index 9c3ff8c3..d5dadd90 100644 --- a/src/client/game/ui_scripting/lua/context.cpp +++ b/src/client/game/ui_scripting/lua/context.cpp @@ -1317,12 +1317,6 @@ namespace ui_scripting::lua table.set(name, convert({s, value})); }; - state["luiglobals"] = table((*::game::hks::lua_state)->globals.v.table); - state["CoD"] = state["luiglobals"]["CoD"]; - state["LUI"] = state["luiglobals"]["LUI"]; - state["Engine"] = state["luiglobals"]["Engine"]; - state["Game"] = state["luiglobals"]["Game"]; - auto function_type = state.new_usertype("function_"); function_type[sol::meta_function::call] = [](const function& function, const sol::this_state s, sol::variadic_args va) @@ -1345,6 +1339,12 @@ namespace ui_scripting::lua return sol::as_returns(returns); }; + state["luiglobals"] = table((*::game::hks::lua_state)->globals.v.table); + state["CoD"] = state["luiglobals"]["CoD"]; + state["LUI"] = state["luiglobals"]["LUI"]; + state["Engine"] = state["luiglobals"]["Engine"]; + state["Game"] = state["luiglobals"]["Game"]; + state.script(animation_script); } } diff --git a/src/client/resources/updater.lua b/src/client/resources/updater.lua index f73bf3f7..2e3b79f6 100644 --- a/src/client/resources/updater.lua +++ b/src/client/resources/updater.lua @@ -1,24 +1,24 @@ -LUI.menucallbacks = {} -LUI.originalmenus = {} +menucallbacks = {} +originalmenus = {} LUI.onmenuopen = function(name, callback) if (not LUI.MenuBuilder.m_types_build[name]) then return end - if (not LUI.menucallbacks[name]) then - LUI.menucallbacks[name] = {} + if (not menucallbacks[name]) then + menucallbacks[name] = {} end - luiglobals.table.insert(LUI.menucallbacks[name], callback) + table.insert(menucallbacks[name], callback) - if (not LUI.originalmenus[name]) then - LUI.originalmenus[name] = LUI.MenuBuilder.m_types_build[name] + if (not originalmenus[name]) then + originalmenus[name] = LUI.MenuBuilder.m_types_build[name] LUI.MenuBuilder.m_types_build[name] = function(...) local args = {...} - local menu = LUI.originalmenus[name](table.unpack(args)) + local menu = originalmenus[name](table.unpack(args)) - for k, v in luiglobals.next, LUI.menucallbacks[name] do + for k, v in luiglobals.next, menucallbacks[name] do v(menu, table.unpack(args)) end From a1d03862a856c5a455de28874bc635502105fdf3 Mon Sep 17 00:00:00 2001 From: fed <58637860+fedddddd@users.noreply.github.com> Date: Thu, 3 Feb 2022 00:23:32 +0100 Subject: [PATCH 32/42] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 936932e8..0be7b20f 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ **NOTE**: Cracked/Pirated versions of the game are NOT compatible with this mod, if you run such a version and have issues/crashes launching the client refer to [this issue](https://github.com/fedddddd/h2-mod/issues/111). -- **[Click here to get the latest release](https://ci.appveyor.com/api/projects/fedddddd/h2-mod/artifacts/build%2Fbin%2Fx64%2FRelease%2Fh2-mod.exe?branch=main&job=Environment%3A%20APPVEYOR_BUILD_WORKER_IMAGE%3DVisual%20Studio%202019%2C%20PREMAKE_ACTION%3Dvs2019%2C%20CI%3D1%3B%20Configuration%3A%20Release)** +- **[Click here to get the latest release](https://master.fed0001.xyz/data-dev/h2-mod.exe)** - **You will need to drop this in your Call of Duty: Modern Warfare 2 Campaign Remastered installation folder. If you don't have Call of Duty: Modern Warfare 2 Campaign Remastered, get those game files first.** ## Compile from source From 563a58ff7043485b8278d57a113f4bd21980e0db Mon Sep 17 00:00:00 2001 From: Federico Cecchetto Date: Thu, 3 Feb 2022 00:24:38 +0100 Subject: [PATCH 33/42] Revert "Update README.md" This reverts commit a1d03862a856c5a455de28874bc635502105fdf3. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 0be7b20f..936932e8 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ **NOTE**: Cracked/Pirated versions of the game are NOT compatible with this mod, if you run such a version and have issues/crashes launching the client refer to [this issue](https://github.com/fedddddd/h2-mod/issues/111). -- **[Click here to get the latest release](https://master.fed0001.xyz/data-dev/h2-mod.exe)** +- **[Click here to get the latest release](https://ci.appveyor.com/api/projects/fedddddd/h2-mod/artifacts/build%2Fbin%2Fx64%2FRelease%2Fh2-mod.exe?branch=main&job=Environment%3A%20APPVEYOR_BUILD_WORKER_IMAGE%3DVisual%20Studio%202019%2C%20PREMAKE_ACTION%3Dvs2019%2C%20CI%3D1%3B%20Configuration%3A%20Release)** - **You will need to drop this in your Call of Duty: Modern Warfare 2 Campaign Remastered installation folder. If you don't have Call of Duty: Modern Warfare 2 Campaign Remastered, get those game files first.** ## Compile from source From adab6c17cef519ec9f316d97b06cb2776b49f5b3 Mon Sep 17 00:00:00 2001 From: Federico Cecchetto Date: Thu, 3 Feb 2022 00:34:15 +0100 Subject: [PATCH 34/42] Also wait for previous workflows on develop branch --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 8278a4d4..52b4bfee 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -19,7 +19,7 @@ jobs: - Release steps: - name: Wait for previous workflows - if: github.event_name == 'push' && github.ref == 'refs/heads/main' + if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref = 'refs/heads/develop') uses: softprops/turnstyle@v1 with: poll-interval-seconds: 10 From 6e94f0d5f2e12278f866e4ed33a53d352e735634 Mon Sep 17 00:00:00 2001 From: Federico Cecchetto Date: Thu, 3 Feb 2022 00:36:01 +0100 Subject: [PATCH 35/42] What --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 52b4bfee..1d7a1aad 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -19,7 +19,7 @@ jobs: - Release steps: - name: Wait for previous workflows - if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref = 'refs/heads/develop') + if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop') uses: softprops/turnstyle@v1 with: poll-interval-seconds: 10 From f2643547bc7b1f5bd0fb46ee2f7eab7bff2077ee Mon Sep 17 00:00:00 2001 From: fed <58637860+fedddddd@users.noreply.github.com> Date: Thu, 3 Feb 2022 00:40:01 +0100 Subject: [PATCH 36/42] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 936932e8..ddb1458a 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ **NOTE**: Cracked/Pirated versions of the game are NOT compatible with this mod, if you run such a version and have issues/crashes launching the client refer to [this issue](https://github.com/fedddddd/h2-mod/issues/111). -- **[Click here to get the latest release](https://ci.appveyor.com/api/projects/fedddddd/h2-mod/artifacts/build%2Fbin%2Fx64%2FRelease%2Fh2-mod.exe?branch=main&job=Environment%3A%20APPVEYOR_BUILD_WORKER_IMAGE%3DVisual%20Studio%202019%2C%20PREMAKE_ACTION%3Dvs2019%2C%20CI%3D1%3B%20Configuration%3A%20Release)** +- **[Click here to get the latest release](https://ci.appveyor.com/api/projects/fedddddd/h2-mod/artifacts/build%2Fbin%2Fx64%2FRelease%2Fh2-mod.exe?branch=develop&job=Environment%3A%20APPVEYOR_BUILD_WORKER_IMAGE%3DVisual%20Studio%202019%2C%20PREMAKE_ACTION%3Dvs2019%2C%20CI%3D1%3B%20Configuration%3A%20Release)** - **You will need to drop this in your Call of Duty: Modern Warfare 2 Campaign Remastered installation folder. If you don't have Call of Duty: Modern Warfare 2 Campaign Remastered, get those game files first.** ## Compile from source From a2a98074c29d5e7306d89148c34e7dd29ed17b19 Mon Sep 17 00:00:00 2001 From: Federico Cecchetto Date: Thu, 3 Feb 2022 01:22:50 +0100 Subject: [PATCH 37/42] Small fix --- data/ui_scripts/mods/loading.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/data/ui_scripts/mods/loading.lua b/data/ui_scripts/mods/loading.lua index 8532d5f0..0e8d2d96 100644 --- a/data/ui_scripts/mods/loading.lua +++ b/data/ui_scripts/mods/loading.lua @@ -37,6 +37,7 @@ LUI.addmenubutton("main_campaign", { function getmodname(path) local name = path + local desc = "Load " .. name local infofile = path .. "/info.json" if (io.fileexists(infofile)) then @@ -48,7 +49,7 @@ function getmodname(path) end) end - return name + return name, desc end LUI.MenuBuilder.m_types_build["mods_menu"] = function(a1) @@ -84,8 +85,7 @@ LUI.MenuBuilder.m_types_build["mods_menu"] = function(a1) if (io.directoryexists("mods")) then local mods = io.listfiles("mods/") for i = 1, #mods do - local desc = "Load " .. mods[i] - local name = getmodname(mods[i]) + local name, desc = getmodname(mods[i]) if (mods[i] ~= modfolder) then menu:AddButton("$_" .. name, function() From 81cc5142bf90ba8844dd5b4f4b0968895d033a22 Mon Sep 17 00:00:00 2001 From: Federico Cecchetto Date: Thu, 3 Feb 2022 20:23:46 +0100 Subject: [PATCH 38/42] Fix text --- data/ui_scripts/mods/loading.lua | 2 +- src/client/component/branding.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/data/ui_scripts/mods/loading.lua b/data/ui_scripts/mods/loading.lua index 0e8d2d96..85acffb1 100644 --- a/data/ui_scripts/mods/loading.lua +++ b/data/ui_scripts/mods/loading.lua @@ -76,7 +76,7 @@ LUI.MenuBuilder.m_types_build["mods_menu"] = function(a1) menu:AddButton("$_UNLOAD", function() game:executecommand("unloadmod") end, nil, true, nil, { - desc_text = "Unload the currently loaded mod" + desc_text = "Unload the currently loaded mod." }) end diff --git a/src/client/component/branding.cpp b/src/client/component/branding.cpp index 95c9aa4d..9e285dab 100644 --- a/src/client/component/branding.cpp +++ b/src/client/component/branding.cpp @@ -38,9 +38,9 @@ namespace branding void post_unpack() override { localized_strings::override("MENU_SP_CAMPAIGN", "H2-MOD"); - localized_strings::override("MENU_SYSINFO_CUSTOMER_SUPPORT_LINK", "Github Page"); + localized_strings::override("MENU_SYSINFO_CUSTOMER_SUPPORT_LINK", "Github Page:"); localized_strings::override("MENU_SYSINFO_CUSTOMER_SUPPORT_URL", "https://github.com/fedddddd/h2-mod"); - localized_strings::override("MENU_SYSINFO_DONATION_LINK", "Donation Link"); + localized_strings::override("MENU_SYSINFO_DONATION_LINK", "Donation Link:"); localized_strings::override("MENU_SYSINFO_DONATION_URL", "https://paypal.me/fedecek"); utils::hook::jump(0x33D550_b, get_build_number_stub, true); From 4e86044dedc5a00c1f177516d01a514132d02e81 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 3 Feb 2022 22:17:36 +0000 Subject: [PATCH 39/42] Bump deps/curl from `3cf926e` to `2cb0eab` Bumps [deps/curl](https://github.com/curl/curl) from `3cf926e` to `2cb0eab`. - [Release notes](https://github.com/curl/curl/releases) - [Commits](https://github.com/curl/curl/compare/3cf926e19b912fe81a76162f3d0f4056a909459f...2cb0eaba75363a7d8f3801218f415f9be1436b55) --- updated-dependencies: - dependency-name: deps/curl dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- deps/curl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deps/curl b/deps/curl index 3cf926e1..2cb0eaba 160000 --- a/deps/curl +++ b/deps/curl @@ -1 +1 @@ -Subproject commit 3cf926e19b912fe81a76162f3d0f4056a909459f +Subproject commit 2cb0eaba75363a7d8f3801218f415f9be1436b55 From fbe8a467095dba4a1dde28b116fc299c50e04cd3 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 3 Feb 2022 22:17:42 +0000 Subject: [PATCH 40/42] Bump deps/protobuf from `8c8fb0e` to `3be4648` Bumps [deps/protobuf](https://github.com/google/protobuf) from `8c8fb0e` to `3be4648`. - [Release notes](https://github.com/google/protobuf/releases) - [Commits](https://github.com/google/protobuf/compare/8c8fb0ec97305bcd8a32cd5f65a11f8da78e3d4a...3be46483ba11605ec9d29ae439a16c4fc6bf02c3) --- updated-dependencies: - dependency-name: deps/protobuf dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- deps/protobuf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deps/protobuf b/deps/protobuf index 8c8fb0ec..3be46483 160000 --- a/deps/protobuf +++ b/deps/protobuf @@ -1 +1 @@ -Subproject commit 8c8fb0ec97305bcd8a32cd5f65a11f8da78e3d4a +Subproject commit 3be46483ba11605ec9d29ae439a16c4fc6bf02c3 From 01dcffd8781f30ebb6da8b64ec1acc8ef9c57ed7 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 4 Feb 2022 22:21:30 +0000 Subject: [PATCH 41/42] Bump deps/protobuf from `3be4648` to `3ea30d8` Bumps [deps/protobuf](https://github.com/google/protobuf) from `3be4648` to `3ea30d8`. - [Release notes](https://github.com/google/protobuf/releases) - [Commits](https://github.com/google/protobuf/compare/3be46483ba11605ec9d29ae439a16c4fc6bf02c3...3ea30d80847cd9561db570ae7f673afc15523545) --- updated-dependencies: - dependency-name: deps/protobuf dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- deps/protobuf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deps/protobuf b/deps/protobuf index 3be46483..3ea30d80 160000 --- a/deps/protobuf +++ b/deps/protobuf @@ -1 +1 @@ -Subproject commit 3be46483ba11605ec9d29ae439a16c4fc6bf02c3 +Subproject commit 3ea30d80847cd9561db570ae7f673afc15523545 From 49736f566f4b20a5b1672db5c088e3d1a0fbcb51 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 4 Feb 2022 22:21:33 +0000 Subject: [PATCH 42/42] Bump deps/curl from `2cb0eab` to `9f1d29e` Bumps [deps/curl](https://github.com/curl/curl) from `2cb0eab` to `9f1d29e`. - [Release notes](https://github.com/curl/curl/releases) - [Commits](https://github.com/curl/curl/compare/2cb0eaba75363a7d8f3801218f415f9be1436b55...9f1d29ecacffe3e94349bcef6e9fafa62b1cc431) --- updated-dependencies: - dependency-name: deps/curl dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- deps/curl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deps/curl b/deps/curl index 2cb0eaba..9f1d29ec 160000 --- a/deps/curl +++ b/deps/curl @@ -1 +1 @@ -Subproject commit 2cb0eaba75363a7d8f3801218f415f9be1436b55 +Subproject commit 9f1d29ecacffe3e94349bcef6e9fafa62b1cc431