write a better config

This commit is contained in:
quaK 2022-09-18 16:38:50 +03:00
parent 7b1a343014
commit ac1ac5f5bf
4 changed files with 33 additions and 7 deletions

View File

@ -116,7 +116,11 @@ namespace command
return 0;
}
const auto dvar = game::Dvar_FindVar(args[0]);
auto* dvar = game::Dvar_FindVar(args[0]);
if (dvar == nullptr)
{
dvar = game::Dvar_FindMalleableVar(atoi(args[0]));
}
if (dvar)
{
@ -125,8 +129,8 @@ namespace command
const auto current = game::Dvar_ValueToString(dvar, dvar->current);
const auto reset = game::Dvar_ValueToString(dvar, dvar->reset);
console::info("\"%s\" is: \"%s\" default: \"%s\" checksum: 0x%08lX type: %i\n",
args[0], current, reset, dvar->checksum, dvar->type);
console::info("\"%s\" is: \"%s\" default: \"%s\" checksum: %d type: %i\n",
dvars::dvar_get_name(dvar).data(), current, reset, dvar->checksum, dvar->type);
const auto dvar_info = dvars::dvar_get_description(dvar);

View File

@ -51,8 +51,8 @@ namespace console
return nativeconsole;
}
static volatile bool ingame = false;
static volatile bool exit = false;
static std::atomic_bool ingame = false;
static std::atomic_bool exit = false;
DWORD WINAPI console(LPVOID)
{

View File

@ -2,6 +2,7 @@
#include "loader/component_loader.hpp"
#include "game/game.hpp"
#include "game/dvars.hpp"
#include <utils/hook.hpp>
#include <utils/string.hpp>
@ -10,7 +11,23 @@ namespace patches
{
namespace
{
void dvar_write_single_variable_stub(const game::dvar_t* dvar, int* user_data)
{
if ((dvar->flags & game::DVAR_FLAG_SAVED) != 0)
{
const char* val = game::Dvar_DisplayableLatchedValue(dvar);
auto h = *user_data;
auto dvar_name = dvars::dvar_get_name(dvar);
if (!dvar_name.empty())
{
game::FS_Printf(h, "seta %s \"%s\"\n", dvar_name.data(), val);
}
else
{
game::FS_Printf(h, "setcl %d \"%s\"\n", dvar->checksum, val);
}
}
}
}
class component final : public component_interface
@ -18,7 +35,8 @@ namespace patches
public:
void post_unpack() override
{
// write better config
utils::hook::jump(0xBB2A50_b, dvar_write_single_variable_stub);
}
};
}

View File

@ -47,13 +47,17 @@ namespace game
WEAK symbol<void(const char* name, const char* string)> Dvar_SetCommand{ 0xCECB30 };
WEAK symbol<dvar_t* (const char* name)> Dvar_FindVar{ 0xCEA460 };
WEAK symbol<dvar_t* (unsigned int checksum)> Dvar_FindMalleableVar{ 0xCEA3C0 };
WEAK symbol<void(const dvar_t* dvar)> Dvar_ClearModified{ 0xCE9E90 };
WEAK symbol<const char* (const dvar_t* dvar)> Dvar_DisplayableLatchedValue{ 0xCEA1D0 };
WEAK symbol<void(char* buffer, int index)> Dvar_GetCombinedString{ 0xBB1F30 };
WEAK symbol<const char* (dvar_t* dvar, DvarValue value)> Dvar_ValueToString{ 0xCEED00 };
WEAK symbol<int(const char* name)> Dvar_GenerateChecksum{ 0xCEA520 };
#define Dvar_GenerateHash(name) \
Dvar_GenerateChecksum(name);
WEAK symbol<void(int h, const char* fmt, ...)> FS_Printf{ 0xCDD1C0 };
WEAK symbol<const char* (int, int, int)> Key_KeynumToString{ 0x9A95E0 };
WEAK symbol<bool()> LUI_CoD_InFrontEnd{ 0x615080 };