tiny changes

This commit is contained in:
m 2022-09-25 10:46:55 -05:00
parent 367548e86e
commit 4e9e2b8b16
4 changed files with 21 additions and 34 deletions

View File

@ -8,6 +8,7 @@
#include "game/dvars.hpp"
#include "dvars.hpp"
#include "console.hpp"
#include "gsc.hpp"
#include <utils/hook.hpp>
#include <utils/string.hpp>
@ -80,12 +81,11 @@ namespace dedicated
return console_command_queue;
}
void execute_console_command(const int client, const char* command)
void execute_console_command([[maybe_unused]] const int local_client_num, const char* command)
{
if (game::Live_SyncOnlineDataFlags(0) == 0)
{
game::Cbuf_AddText(client, 0, command);
game::Cbuf_AddText(client, 0, "\n");
command::execute(command);
}
else
{
@ -100,8 +100,7 @@ namespace dedicated
for (const auto& command : queue)
{
game::Cbuf_AddText(0, 0, command.data());
game::Cbuf_AddText(0, 0, "\n");
command::execute(command);
}
}
@ -110,21 +109,6 @@ namespace dedicated
std::this_thread::sleep_for(1ms);
}
game::dvar_t* gscr_set_dynamic_dvar()
{
/*
auto s = game::Scr_GetString(0);
auto* dvar = game::Dvar_FindVar(s);
if (dvar && !strncmp("scr_", dvar->name, 4))
{
return dvar;
}
*/
return gscr_set_dynamic_dvar_hook.invoke<game::dvar_t*>();
}
void kill_server()
{
const auto* svs_clients = *game::mp::svs_clients;
@ -237,15 +221,18 @@ namespace dedicated
a.popad64();
a.jmp(0x157DDF_b);
}), true);//
}), true);
// return 0 so the game doesn't override the cfg
gsc::function::add("isusingmatchrulesdata", []()
{
game::Scr_AddInt(0);
});
// delay console commands until the initialization is done // COULDN'T FOUND
// utils::hook::call(0x1400D808C, execute_console_command);
// utils::hook::nop(0x1400D80A4, 5);
// patch GScr_SetDynamicDvar to behave better
gscr_set_dynamic_dvar_hook.create(0x43CF60_b, &gscr_set_dynamic_dvar);
utils::hook::nop(0x189514_b, 248); // don't load config file
utils::hook::nop(0x156C46_b, 5); // ^
utils::hook::set<uint8_t>(0x17F470_b, 0xC3); // don't save config file

View File

@ -588,7 +588,7 @@ namespace gsc
namespace method
{
void add(const std::string& name, builtin_method method)
void add(const std::string& name, scripting::script_function method)
{
if (xsk::gsc::h1::resolver::find_method(name))
{
@ -668,7 +668,7 @@ namespace gsc
utils::hook::nop(SELECT_VALUE(0x3CB723_b, 0x512783_b), 8);
utils::hook::call(SELECT_VALUE(0x3CB723_b, 0x512783_b), vm_call_builtin_function_stub);
gsc::function::add("print", []()
function::add("print", []()
{
const auto num = game::Scr_GetNumParam();
std::string buffer{};
@ -683,7 +683,7 @@ namespace gsc
console::info("%s\n", buffer.data());
});
gsc::function::add("assert", []()
function::add("assert", []()
{
const auto expr = get_argument(0).as<int>();
if (!expr)
@ -692,7 +692,7 @@ namespace gsc
}
});
gsc::function::add("assertex", []()
function::add("assertex", []()
{
const auto expr = get_argument(0).as<int>();
if (!expr)
@ -702,7 +702,7 @@ namespace gsc
}
});
gsc::function::add("replacefunc", []()
function::add("replacefunc", []()
{
const auto what = get_argument(0).get_raw();
const auto with = get_argument(1).get_raw();

View File

@ -22,12 +22,12 @@ namespace slowmotion
if (game::Scr_GetNumParam() >= 2)
{
end = game::Scr_GetFloat(1u);
end = game::Scr_GetFloat(1);
}
if (game::Scr_GetNumParam() >= 3)
{
duration = static_cast<int>(game::Scr_GetFloat(2u) * 1000.0f);
duration = static_cast<int>(game::Scr_GetFloat(2) * 1000.0f);
}
game::SV_SetConfigstring(10, utils::string::va("%i %i %g %g", *game::mp::gameTime, duration, start, end));

View File

@ -158,9 +158,9 @@ namespace game
WEAK symbol<void(unsigned int id, scr_string_t stringValue,
unsigned int paramcount)> Scr_NotifyId{0x3C92E0, 0x510340};
WEAK symbol<const float*(const float* v)> Scr_AllocVector{0x3C42D0, 0x50B330};
WEAK symbol<float(int index)> Scr_GetFloat{0x3C87D0, 0x50F870};
WEAK symbol<const char*(int index)> Scr_GetString{0x3C8CC0, 0x50FCB0};
WEAK symbol<int()> Scr_GetNumParam{0x3C89E0, 0x50F9D0};
WEAK symbol<float(unsigned int index)> Scr_GetFloat{0x3C87D0, 0x50F870};
WEAK symbol<const char*(unsigned int index)> Scr_GetString{0x3C8CC0, 0x50FCB0};
WEAK symbol<unsigned int()> Scr_GetNumParam{0x3C89E0, 0x50F9D0};
WEAK symbol<void()> Scr_ClearOutParams{0x3C7EF0, 0x50F070};
WEAK symbol<scr_entref_t(unsigned int entId)> Scr_GetEntityIdRef{0x3C6760, 0x50D8E0};
WEAK symbol<unsigned int(int classnum, unsigned int entnum)> Scr_GetEntityId{0x3C66B0, 0x50D830};