From fab33acbf2c878309ac2c078f4fa4fa17f24bc9d Mon Sep 17 00:00:00 2001 From: fed <58637860+fedddddd@users.noreply.github.com> Date: Sat, 1 Oct 2022 20:23:22 +0200 Subject: [PATCH] Important fixes --- src/client/component/fonts.cpp | 12 ++---------- src/client/component/gsc.cpp | 29 +++++++++++++++-------------- src/client/component/patches.cpp | 1 - 3 files changed, 17 insertions(+), 25 deletions(-) diff --git a/src/client/component/fonts.cpp b/src/client/component/fonts.cpp index 185d63b2..c273347c 100644 --- a/src/client/component/fonts.cpp +++ b/src/client/component/fonts.cpp @@ -140,15 +140,7 @@ namespace fonts void* ui_asset_cache_stub() { - if (!game::Com_InFrontend()) - { - bank_font = game::R_RegisterFont("fonts/bank.ttf", 32); - } - else - { - bank_font = nullptr; - } - + bank_font = game::R_RegisterFont("fonts/bank.ttf", 32); return ui_asset_cache_hook.invoke(); } @@ -248,7 +240,7 @@ namespace fonts } data_.fonts.clear(); - utils::hook::set(0x14EE3ACB8, 0); // reset registered font count + *reinterpret_cast(0x14EE3ACB8) = 0; // reset registered font count }); } diff --git a/src/client/component/gsc.cpp b/src/client/component/gsc.cpp index 41dcaa94..7e3cf59a 100644 --- a/src/client/component/gsc.cpp +++ b/src/client/component/gsc.cpp @@ -306,7 +306,7 @@ namespace gsc } } - void builtin_call_error() + void builtin_call_error(const std::string& error) { const auto pos = game::scr_function_stack->pos; const auto function_id = *reinterpret_cast( @@ -314,13 +314,13 @@ namespace gsc if (function_id > 0x1000) { - console::warn("in call to builtin method \"%s\"", - xsk::gsc::h2::resolver::method_name(function_id).data()); + console::warn("in call to builtin method \"%s\"%s", + xsk::gsc::h2::resolver::method_name(function_id).data(), error.data()); } else { - console::warn("in call to builtin function \"%s\"", - xsk::gsc::h2::resolver::function_name(function_id).data()); + console::warn("in call to builtin function \"%s\"%s", + xsk::gsc::h2::resolver::function_name(function_id).data(), error.data()); } } @@ -335,25 +335,26 @@ namespace gsc console::warn("*********** script runtime error *************\n"); const auto opcode_id = *reinterpret_cast(0x14BAA93E8); + const std::string error = gsc_error.has_value() + ? utils::string::va(": %s", gsc_error.value().data()) + : ""; + if ((opcode_id >= 0x1A && opcode_id <= 0x20) || (opcode_id >= 0xA9 && opcode_id <= 0xAF)) { - builtin_call_error(); + builtin_call_error(error); } else { const auto opcode = get_opcode_name(opcode_id); - const std::string error_str = gsc_error.has_value() - ? utils::string::va(": %s", gsc_error.value().data()) - : ""; if (opcode.has_value()) { console::warn("while processing instruction %s%s\n", - opcode.value().data(), error_str.data()); + opcode.value().data(), error.data()); } else { console::warn("while processing instruction 0x%X%s\n", - opcode_id, error_str.data()); + opcode_id, error.data()); } } @@ -627,12 +628,12 @@ namespace gsc if (what.type != game::SCRIPT_FUNCTION) { - throw std::runtime_error("replaceFunc: parameter 1 must be a function"); + throw std::runtime_error("parameter 1 must be a function"); } if (with.type != game::SCRIPT_FUNCTION) { - throw std::runtime_error("replaceFunc: parameter 2 must be a function"); + throw std::runtime_error("parameter 2 must be a function"); } notifies::set_gsc_hook(what.u.codePosValue, with.u.codePosValue); @@ -643,7 +644,7 @@ namespace gsc const auto name = get_argument(0); if (!name.is()) { - throw std::runtime_error("getsoundlength: parameter 1 must be a string"); + throw std::runtime_error("parameter 1 must be a string"); } const auto name_str = name.as(); diff --git a/src/client/component/patches.cpp b/src/client/component/patches.cpp index 445fb1e7..510d5710 100644 --- a/src/client/component/patches.cpp +++ b/src/client/component/patches.cpp @@ -107,7 +107,6 @@ namespace patches gscr_set_save_dvar_hook.create(0x140504C60, &gscr_set_save_dvar_stub); // Make cg_fov and cg_fovscale saved dvars - cg_fov = dvars::register_float("cg_fov", 65.f, 40.f, 200.f, game::DVAR_FLAG_SAVED, "The field of view angle in degrees for client 0"); cg_fovScale = dvars::register_float("cg_fovScale", 1.f, 0.1f, 2.f,