feature: name g_log dvar
This commit is contained in:
parent
6378f8c392
commit
69cae13da1
@ -2,6 +2,7 @@
|
||||
#include "loader/component_loader.hpp"
|
||||
|
||||
#include "game/game.hpp"
|
||||
#include "game/utils.hpp"
|
||||
|
||||
#include <utils/hook.hpp>
|
||||
#include <utils/string.hpp>
|
||||
@ -11,6 +12,8 @@ namespace game_log
|
||||
{
|
||||
namespace
|
||||
{
|
||||
const game::dvar_t* g_log;
|
||||
|
||||
void g_scr_log_print()
|
||||
{
|
||||
char string[1024]{};
|
||||
@ -41,10 +44,10 @@ namespace game_log
|
||||
|
||||
va_list ap;
|
||||
va_start(ap, fmt);
|
||||
vsprintf_s(va_buffer, fmt, ap);
|
||||
vsnprintf_s(va_buffer, _TRUNCATE, fmt, ap);
|
||||
va_end(ap);
|
||||
|
||||
const auto* file = "games_mp.log";
|
||||
const auto* file = g_log ? g_log->current.value.string : "games_mp.log";
|
||||
const auto time = *game::level_time / 1000;
|
||||
|
||||
utils::io::write_file(file, utils::string::va("%3i:%i%i %s",
|
||||
@ -54,6 +57,12 @@ namespace game_log
|
||||
va_buffer
|
||||
), true);
|
||||
}
|
||||
|
||||
const game::dvar_t* register_g_log_stub()
|
||||
{
|
||||
g_log = game::register_dvar_string("g_log", "games_mp.log", game::DVAR_NONE, "Log file path");
|
||||
return g_log;
|
||||
}
|
||||
}
|
||||
|
||||
class component final : public server_component
|
||||
@ -64,6 +73,11 @@ namespace game_log
|
||||
// Fix format string vulnerability & make it work
|
||||
utils::hook::jump(0x1402D9300_g, g_scr_log_print);
|
||||
utils::hook::jump(0x1402A7BB0_g, g_log_printf_stub);
|
||||
|
||||
utils::hook::call(0x1402A82D6_g, register_g_log_stub);
|
||||
|
||||
// G_InitGame: because we changed the dvar g_log from a bool dvar to a string dvar we need to skip a bunch of related code to force it
|
||||
utils::hook::jump(0x1402AC00E_g, 0x1402AC061_g, true);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -11,12 +11,12 @@ namespace loot
|
||||
{
|
||||
namespace
|
||||
{
|
||||
game::dvar_t* dvar_cg_unlockall_loot;
|
||||
game::dvar_t* dvar_cg_unlockall_purchases;
|
||||
game::dvar_t* dvar_cg_unlockall_attachments;
|
||||
game::dvar_t* dvar_cg_unlockall_camos_and_reticles;
|
||||
game::dvar_t* dvar_cg_unlockall_calling_cards;
|
||||
game::dvar_t* dvar_cg_unlockall_specialists_outfits;
|
||||
const game::dvar_t* dvar_cg_unlockall_loot;
|
||||
const game::dvar_t* dvar_cg_unlockall_purchases;
|
||||
const game::dvar_t* dvar_cg_unlockall_attachments;
|
||||
const game::dvar_t* dvar_cg_unlockall_camos_and_reticles;
|
||||
const game::dvar_t* dvar_cg_unlockall_calling_cards;
|
||||
const game::dvar_t* dvar_cg_unlockall_specialists_outfits;
|
||||
|
||||
utils::hook::detour loot_getitemquantity_hook;
|
||||
utils::hook::detour liveinventory_getitemquantity_hook;
|
||||
|
@ -104,18 +104,18 @@ namespace game
|
||||
WEAK symbol<const char*(const dvar_t* dvar)> Dvar_GetString{0x1422BF590, 0x140575E30};
|
||||
WEAK symbol<const char*(const dvar_t* dvar)> Dvar_DisplayableValue{0x1422BC080};
|
||||
WEAK symbol<bool(const dvar_t* dvar)> Dvar_GetBool{0x1422BCED0};
|
||||
WEAK symbol<dvar_t*(dvarStrHash_t hash, const char* dvarName, bool value, dvarFlags_e flags,
|
||||
WEAK symbol<dvar_t*(dvarStrHash_t hash, const char* dvarName, bool value, int flags,
|
||||
const char* description)> Dvar_RegisterBool{
|
||||
0x1422D0900, 0x14057B500
|
||||
};
|
||||
WEAK symbol<dvar_t*(dvarStrHash_t hash, const char* dvarName, bool value, dvarFlags_e flags,
|
||||
WEAK symbol<dvar_t*(dvarStrHash_t hash, const char* dvarName, bool value, int flags,
|
||||
const char* description)> Dvar_SessionModeRegisterBool{
|
||||
0x1422D0D40, 0x14057BAA0
|
||||
};
|
||||
WEAK symbol<void(dvarStrHash_t hash, bool value, eModes mode)> Dvar_SessionModeSetDefaultBool{
|
||||
0x1422D0E90, 0x14057BCE0
|
||||
};
|
||||
WEAK symbol<dvar_t*(dvarStrHash_t hash, const char* dvarName, const char* value, dvarFlags_e flags,
|
||||
WEAK symbol<dvar_t*(dvarStrHash_t hash, const char* dvarName, const char* value, int flags,
|
||||
const char* description)> Dvar_RegisterString{
|
||||
0x1422D0B70
|
||||
};
|
||||
|
@ -38,7 +38,7 @@ namespace game
|
||||
return dvar->current.value.enabled;
|
||||
}
|
||||
|
||||
dvar_t* register_sessionmode_dvar_bool(const char* dvar_name, const bool value, const dvarFlags_e flags, const char* description, const eModes mode)
|
||||
const dvar_t* register_sessionmode_dvar_bool(const char* dvar_name, const bool value, const int flags, const char* description, const eModes mode)
|
||||
{
|
||||
const auto hash = Dvar_GenerateHash(dvar_name);
|
||||
auto registered_dvar = Dvar_SessionModeRegisterBool(hash, dvar_name, value, flags, description);
|
||||
@ -63,7 +63,7 @@ namespace game
|
||||
return registered_dvar;
|
||||
}
|
||||
|
||||
dvar_t* register_dvar_bool(const char* dvar_name, const bool value, const dvarFlags_e flags, const char* description)
|
||||
const dvar_t* register_dvar_bool(const char* dvar_name, const bool value, const int flags, const char* description)
|
||||
{
|
||||
const auto hash = Dvar_GenerateHash(dvar_name);
|
||||
auto registered_dvar = Dvar_RegisterBool(hash, dvar_name, value, flags, description);
|
||||
@ -76,6 +76,19 @@ namespace game
|
||||
return registered_dvar;
|
||||
}
|
||||
|
||||
const dvar_t* register_dvar_string(const char* dvar_name, const char* value, const int flags, const char* description)
|
||||
{
|
||||
const auto hash = Dvar_GenerateHash(dvar_name);
|
||||
auto registered_dvar = Dvar_RegisterString(hash, dvar_name, value, flags, description);
|
||||
|
||||
if (registered_dvar)
|
||||
{
|
||||
registered_dvar->debugName = dvar_name;
|
||||
}
|
||||
|
||||
return registered_dvar;
|
||||
}
|
||||
|
||||
void dvar_add_flags(const char* dvar_name, const dvarFlags_e flags)
|
||||
{
|
||||
auto dvar = Dvar_FindVar(dvar_name);
|
||||
|
@ -8,8 +8,9 @@ namespace game
|
||||
int get_dvar_int(const char* dvar_name);
|
||||
bool get_dvar_bool(const char* dvar_name);
|
||||
|
||||
dvar_t* register_dvar_bool(const char* dvar_name, bool value, dvarFlags_e flags, const char* description);
|
||||
dvar_t* register_sessionmode_dvar_bool(const char* dvar_name, const bool value, const dvarFlags_e flags, const char* description, const eModes mode = MODE_COUNT);
|
||||
const dvar_t* register_dvar_bool(const char* dvar_name, bool value, int flags, const char* description);
|
||||
const dvar_t* register_sessionmode_dvar_bool(const char* dvar_name, bool value, int flags, const char* description, eModes mode = MODE_COUNT);
|
||||
const dvar_t* register_dvar_string(const char* dvar_name, const char* value, int flags, const char* description);
|
||||
void dvar_add_flags(const char* dvar, dvarFlags_e flags);
|
||||
void dvar_set_flags(const char* dvar_name, dvarFlags_e flags);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user