Important fixes

This commit is contained in:
fed 2022-10-01 20:23:22 +02:00
parent 59c3652513
commit fab33acbf2
3 changed files with 17 additions and 25 deletions

View File

@ -140,15 +140,7 @@ namespace fonts
void* ui_asset_cache_stub() void* ui_asset_cache_stub()
{ {
if (!game::Com_InFrontend()) bank_font = game::R_RegisterFont("fonts/bank.ttf", 32);
{
bank_font = game::R_RegisterFont("fonts/bank.ttf", 32);
}
else
{
bank_font = nullptr;
}
return ui_asset_cache_hook.invoke<void*>(); return ui_asset_cache_hook.invoke<void*>();
} }
@ -248,7 +240,7 @@ namespace fonts
} }
data_.fonts.clear(); data_.fonts.clear();
utils::hook::set<int>(0x14EE3ACB8, 0); // reset registered font count *reinterpret_cast<int*>(0x14EE3ACB8) = 0; // reset registered font count
}); });
} }

View File

@ -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 pos = game::scr_function_stack->pos;
const auto function_id = *reinterpret_cast<std::uint16_t*>( const auto function_id = *reinterpret_cast<std::uint16_t*>(
@ -314,13 +314,13 @@ namespace gsc
if (function_id > 0x1000) if (function_id > 0x1000)
{ {
console::warn("in call to builtin method \"%s\"", console::warn("in call to builtin method \"%s\"%s",
xsk::gsc::h2::resolver::method_name(function_id).data()); xsk::gsc::h2::resolver::method_name(function_id).data(), error.data());
} }
else else
{ {
console::warn("in call to builtin function \"%s\"", console::warn("in call to builtin function \"%s\"%s",
xsk::gsc::h2::resolver::function_name(function_id).data()); xsk::gsc::h2::resolver::function_name(function_id).data(), error.data());
} }
} }
@ -335,25 +335,26 @@ namespace gsc
console::warn("*********** script runtime error *************\n"); console::warn("*********** script runtime error *************\n");
const auto opcode_id = *reinterpret_cast<std::uint8_t*>(0x14BAA93E8); const auto opcode_id = *reinterpret_cast<std::uint8_t*>(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)) if ((opcode_id >= 0x1A && opcode_id <= 0x20) || (opcode_id >= 0xA9 && opcode_id <= 0xAF))
{ {
builtin_call_error(); builtin_call_error(error);
} }
else else
{ {
const auto opcode = get_opcode_name(opcode_id); 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()) if (opcode.has_value())
{ {
console::warn("while processing instruction %s%s\n", console::warn("while processing instruction %s%s\n",
opcode.value().data(), error_str.data()); opcode.value().data(), error.data());
} }
else else
{ {
console::warn("while processing instruction 0x%X%s\n", 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) 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) 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); notifies::set_gsc_hook(what.u.codePosValue, with.u.codePosValue);
@ -643,7 +644,7 @@ namespace gsc
const auto name = get_argument(0); const auto name = get_argument(0);
if (!name.is<std::string>()) if (!name.is<std::string>())
{ {
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<std::string>(); const auto name_str = name.as<std::string>();

View File

@ -107,7 +107,6 @@ namespace patches
gscr_set_save_dvar_hook.create(0x140504C60, &gscr_set_save_dvar_stub); gscr_set_save_dvar_hook.create(0x140504C60, &gscr_set_save_dvar_stub);
// Make cg_fov and cg_fovscale saved dvars // Make cg_fov and cg_fovscale saved dvars
cg_fov = dvars::register_float("cg_fov", 65.f, 40.f, 200.f, 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"); 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, cg_fovScale = dvars::register_float("cg_fovScale", 1.f, 0.1f, 2.f,