Merge pull request #351 from diamante0018/debug-dvars
[Dvar] Better dvar settings for debugging
This commit is contained in:
commit
69f395e2a7
@ -432,7 +432,7 @@ namespace Components
|
||||
Scheduler::Loop(Auth::Frame, Scheduler::Pipeline::MAIN);
|
||||
|
||||
// Register dvar
|
||||
Dvar::Register<int>("sv_securityLevel", 23, 0, 512, Game::dvar_flag::DVAR_SERVERINFO, "Security level for GUID certificates (POW)");
|
||||
Dvar::Register<int>("sv_securityLevel", 23, 0, 512, Game::DVAR_SERVERINFO, "Security level for GUID certificates (POW)");
|
||||
|
||||
// Install registration hook
|
||||
Utils::Hook(0x6265F9, Auth::DirectConnectStub, HOOK_JUMP).install()->quick();
|
||||
|
@ -75,7 +75,7 @@ namespace Components
|
||||
[[maybe_unused]] float y, float min, float max, [[maybe_unused]] int flags, const char* description)
|
||||
{
|
||||
return Game::Dvar_RegisterVec2(dvarName, -60.0f,
|
||||
474.0f, min, max, Game::dvar_flag::DVAR_ROM, description);
|
||||
474.0f, min, max, Game::DVAR_ROM, description);
|
||||
}
|
||||
|
||||
void Branding::RegisterBrandingDvars()
|
||||
@ -86,11 +86,11 @@ namespace Components
|
||||
constexpr auto value = false;
|
||||
#endif
|
||||
Branding::CGDrawVersion = Dvar::Register<bool>("cg_drawVersion", value,
|
||||
Game::dvar_flag::DVAR_NONE, "Draw the game version");
|
||||
Game::DVAR_NONE, "Draw the game version");
|
||||
Branding::CGDrawVersionX = Dvar::Register<float>("cg_drawVersionX", 10.0f,
|
||||
0.0f, 512.0f, Game::dvar_flag::DVAR_NONE, "X offset for the version string");
|
||||
0.0f, 512.0f, Game::DVAR_NONE, "X offset for the version string");
|
||||
Branding::CGDrawVersionY = Dvar::Register<float>("cg_drawVersionY", 455.0f,
|
||||
0.0f, 512.0f, Game::dvar_flag::DVAR_NONE, "Y offset for the version string");
|
||||
0.0f, 512.0f, Game::DVAR_NONE, "Y offset for the version string");
|
||||
}
|
||||
|
||||
Branding::Branding()
|
||||
|
@ -45,10 +45,10 @@ namespace Components
|
||||
Bullet::Bullet()
|
||||
{
|
||||
BGSurfacePenetration = Dvar::Register<float>("bg_surfacePenetration", 0.0f,
|
||||
0.0f, std::numeric_limits<float>::max(), Game::dvar_flag::DVAR_CODINFO,
|
||||
0.0f, std::numeric_limits<float>::max(), Game::DVAR_CODINFO,
|
||||
"Set to a value greater than 0 to override the surface penetration depth");
|
||||
BGBulletRange = Game::Dvar_RegisterFloat("bg_bulletRange", 8192.0f,
|
||||
0.0f, std::numeric_limits<float>::max(), Game::dvar_flag::DVAR_CODINFO,
|
||||
0.0f, std::numeric_limits<float>::max(), Game::DVAR_CODINFO,
|
||||
"Max range used when calculating the bullet end position");
|
||||
|
||||
Utils::Hook(0x4F6980, BG_GetSurfacePenetrationDepthStub, HOOK_JUMP).install()->quick();
|
||||
|
@ -192,7 +192,7 @@ namespace Components
|
||||
{
|
||||
Scheduler::Once([]
|
||||
{
|
||||
CardTitles::CustomTitleDvar = Dvar::Register<const char*>("customtitle", "", Game::dvar_flag::DVAR_USERINFO | Game::dvar_flag::DVAR_ARCHIVE, "Custom card title");
|
||||
CardTitles::CustomTitleDvar = Dvar::Register<const char*>("customtitle", "", Game::DVAR_USERINFO | Game::DVAR_ARCHIVE, "Custom card title");
|
||||
}, Scheduler::Pipeline::MAIN);
|
||||
|
||||
ServerCommands::OnCommand(21, [](Command::Params* params)
|
||||
|
@ -410,7 +410,7 @@ namespace Components
|
||||
Chat::Chat()
|
||||
{
|
||||
cg_chatWidth = Dvar::Register<int>("cg_chatWidth", 52, 1, std::numeric_limits<int>::max(), Game::DVAR_ARCHIVE, "The normalized maximum width of a chat message");
|
||||
sv_disableChat = Dvar::Register<bool>("sv_disableChat", false, Game::dvar_flag::DVAR_NONE, "Disable chat messages from clients");
|
||||
sv_disableChat = Dvar::Register<bool>("sv_disableChat", false, Game::DVAR_NONE, "Disable chat messages from clients");
|
||||
Events::OnSVInit(AddChatCommands);
|
||||
|
||||
// Intercept chat sending
|
||||
|
@ -75,7 +75,7 @@ namespace Components
|
||||
// Create clantag dvar
|
||||
Scheduler::Once([]
|
||||
{
|
||||
Dvar::Register<const char*>("clantag", "", Game::dvar_flag::DVAR_USERINFO | Game::dvar_flag::DVAR_ARCHIVE,
|
||||
Dvar::Register<const char*>("clantag", "", Game::DVAR_USERINFO | Game::DVAR_ARCHIVE,
|
||||
"If set, your clantag will be shown on the scoreboard.");
|
||||
}, Scheduler::Pipeline::MAIN);
|
||||
|
||||
|
@ -748,7 +748,7 @@ namespace Components
|
||||
{
|
||||
if (Dedicated::IsEnabled()) return;
|
||||
|
||||
Dvar::Register<bool>("r_useD3D9Ex", false, Game::dvar_flag::DVAR_ARCHIVE, "Use extended d3d9 interface!");
|
||||
Dvar::Register<bool>("r_useD3D9Ex", false, Game::DVAR_ARCHIVE, "Use extended d3d9 interface!");
|
||||
|
||||
// Hook Interface creation
|
||||
Utils::Hook::Set(0x6D74D0, D3D9Ex::Direct3DCreate9Stub);
|
||||
|
@ -227,7 +227,7 @@ namespace Components
|
||||
};
|
||||
|
||||
DebugOverlay = Game::Dvar_RegisterEnum("debugOverlay", debugOverlayNames_0, 0,
|
||||
Game::dvar_flag::DVAR_NONE, "Toggles the display of various debug info.");
|
||||
Game::DVAR_NONE, "Toggles the display of various debug info.");
|
||||
}
|
||||
|
||||
Debug::Debug()
|
||||
|
@ -135,7 +135,7 @@ namespace Components
|
||||
|
||||
Game::dvar_t* Dedicated::Dvar_RegisterSVNetworkFps(const char* dvarName, int, int min, int, int, const char* description)
|
||||
{
|
||||
return Game::Dvar_RegisterInt(dvarName, 1000, min, 1000, Game::dvar_flag::DVAR_NONE, description);
|
||||
return Game::Dvar_RegisterInt(dvarName, 1000, min, 1000, Game::DVAR_NONE, description);
|
||||
}
|
||||
|
||||
void Dedicated::AddDedicatedCommands()
|
||||
@ -206,7 +206,7 @@ namespace Components
|
||||
Dedicated::Dedicated()
|
||||
{
|
||||
Dedicated::COMLogFilter = Dvar::Register<bool>("com_logFilter", true,
|
||||
Game::dvar_flag::DVAR_LATCH, "Removes ~95% of unneeded lines from the log");
|
||||
Game::DVAR_LATCH, "Removes ~95% of unneeded lines from the log");
|
||||
|
||||
if (Dedicated::IsEnabled() || ZoneBuilder::IsEnabled())
|
||||
{
|
||||
@ -214,7 +214,7 @@ namespace Components
|
||||
Scheduler::Loop(Steam::SteamAPI_RunCallbacks, Scheduler::Pipeline::SERVER);
|
||||
|
||||
Dedicated::SVLanOnly = Dvar::Register<bool>("sv_lanOnly", false,
|
||||
Game::dvar_flag::DVAR_NONE, "Don't act as node");
|
||||
Game::DVAR_NONE, "Don't act as node");
|
||||
|
||||
Utils::Hook(0x60BE98, Dedicated::InitDedicatedServer, HOOK_CALL).install()->quick();
|
||||
|
||||
@ -281,8 +281,8 @@ namespace Components
|
||||
{
|
||||
Scheduler::Once([]
|
||||
{
|
||||
Dvar::Register<const char*>("sv_sayName", "^7Console", Game::dvar_flag::DVAR_NONE, "The name to pose as for 'say' commands");
|
||||
Dvar::Register<const char*>("sv_motd", "", Game::dvar_flag::DVAR_NONE, "A custom message of the day for servers");
|
||||
Dvar::Register<const char*>("sv_sayName", "^7Console", Game::DVAR_NONE, "The name to pose as for 'say' commands");
|
||||
Dvar::Register<const char*>("sv_motd", "", Game::DVAR_NONE, "A custom message of the day for servers");
|
||||
}, Scheduler::Pipeline::MAIN);
|
||||
|
||||
Events::OnSVInit(Dedicated::AddDedicatedCommands);
|
||||
|
@ -14,8 +14,8 @@ namespace Components
|
||||
|
||||
Discovery::Discovery()
|
||||
{
|
||||
Dvar::Register<int>("net_discoveryPortRangeMin", 25000, 0, 65535, Game::dvar_flag::DVAR_ARCHIVE, "Minimum scan range port for local server discovery");
|
||||
Dvar::Register<int>("net_discoveryPortRangeMax", 35000, 1, 65536, Game::dvar_flag::DVAR_ARCHIVE, "Maximum scan range port for local server discovery");
|
||||
Dvar::Register<int>("net_discoveryPortRangeMin", 25000, 0, 65535, Game::DVAR_ARCHIVE, "Minimum scan range port for local server discovery");
|
||||
Dvar::Register<int>("net_discoveryPortRangeMax", 35000, 1, 65536, Game::DVAR_ARCHIVE, "Maximum scan range port for local server discovery");
|
||||
|
||||
// An additional thread prevents lags
|
||||
// Not sure if that's the best way though
|
||||
|
@ -903,9 +903,9 @@ namespace Components
|
||||
{
|
||||
Scheduler::Once([]
|
||||
{
|
||||
Dvar::Register<const char*>("ui_dl_timeLeft", "", Game::dvar_flag::DVAR_NONE, "");
|
||||
Dvar::Register<const char*>("ui_dl_progress", "", Game::dvar_flag::DVAR_NONE, "");
|
||||
Dvar::Register<const char*>("ui_dl_transRate", "", Game::dvar_flag::DVAR_NONE, "");
|
||||
Dvar::Register<const char*>("ui_dl_timeLeft", "", Game::DVAR_NONE, "");
|
||||
Dvar::Register<const char*>("ui_dl_progress", "", Game::DVAR_NONE, "");
|
||||
Dvar::Register<const char*>("ui_dl_transRate", "", Game::DVAR_NONE, "");
|
||||
}, Scheduler::Pipeline::MAIN);
|
||||
|
||||
UIScript::Add("mod_download_cancel", [](UIScript::Token)
|
||||
@ -916,13 +916,13 @@ namespace Components
|
||||
|
||||
Scheduler::Once([]
|
||||
{
|
||||
Dvar::Register<bool>("sv_wwwDownload", false, Game::dvar_flag::DVAR_ARCHIVE, "Set to true to enable downloading maps/mods from an external server.");
|
||||
Dvar::Register<const char*>("sv_wwwBaseUrl", "", Game::dvar_flag::DVAR_ARCHIVE, "Set to the base url for the external map download.");
|
||||
Dvar::Register<bool>("sv_wwwDownload", false, Game::DVAR_ARCHIVE, "Set to true to enable downloading maps/mods from an external server.");
|
||||
Dvar::Register<const char*>("sv_wwwBaseUrl", "", Game::DVAR_ARCHIVE, "Set to the base url for the external map download.");
|
||||
|
||||
// Force users to enable this because we don't want to accidentally turn everyone's pc into a http server into all their files again
|
||||
// not saying we are but ya know... accidents happen
|
||||
// by having it saved we force the user to enable it in config_mp because it only checks the dvar on startup to see if we should init download or not
|
||||
Dvar::Register<bool>("mod_force_download_server", false, Game::dvar_flag::DVAR_ARCHIVE, "Set to true to force the client to run the download server for mods (for mods in private matches).");
|
||||
Dvar::Register<bool>("mod_force_download_server", false, Game::DVAR_ARCHIVE, "Set to true to force the client to run the download server for mods (for mods in private matches).");
|
||||
}, Scheduler::Pipeline::MAIN);
|
||||
|
||||
Scheduler::Loop([]
|
||||
|
@ -52,14 +52,14 @@ namespace Components
|
||||
template <> unsigned int Dvar::Var::get()
|
||||
{
|
||||
if (this->dvar == nullptr)
|
||||
return 0u;
|
||||
return 0;
|
||||
|
||||
if (this->dvar->type == Game::dvar_type::DVAR_TYPE_INT)
|
||||
{
|
||||
return this->dvar->current.unsignedInt;
|
||||
}
|
||||
|
||||
return 0u;
|
||||
return 0;
|
||||
}
|
||||
|
||||
template <> float Dvar::Var::get()
|
||||
@ -77,7 +77,7 @@ namespace Components
|
||||
|
||||
template <> float* Dvar::Var::get()
|
||||
{
|
||||
static Game::vec4_t vector{ 0.f, 0.f, 0.f, 0.f };
|
||||
static Game::vec4_t vector{0.f, 0.f, 0.f, 0.f};
|
||||
|
||||
if (this->dvar == nullptr)
|
||||
return vector;
|
||||
@ -249,7 +249,7 @@ namespace Components
|
||||
}
|
||||
}
|
||||
|
||||
return Dvar::Register<const char*>(name, username.data(), flags | Game::dvar_flag::DVAR_ARCHIVE, description).get<Game::dvar_t*>();
|
||||
return Dvar::Register<const char*>(name, username.data(), flags | Game::DVAR_ARCHIVE, description).get<Game::dvar_t*>();
|
||||
}
|
||||
|
||||
void Dvar::SetFromStringByNameSafeExternal(const char* dvarName, const char* string)
|
||||
@ -311,7 +311,7 @@ namespace Components
|
||||
{
|
||||
// Save the dvar original value if it has the archive flag
|
||||
const auto* dvar = Game::Dvar_FindVar(dvarName);
|
||||
if (dvar != nullptr && dvar->flags & Game::dvar_flag::DVAR_ARCHIVE)
|
||||
if (dvar != nullptr && dvar->flags & Game::DVAR_ARCHIVE)
|
||||
{
|
||||
if (Dvar::AreArchiveDvarsProtected())
|
||||
{
|
||||
@ -328,28 +328,56 @@ namespace Components
|
||||
Utils::Hook::Call<void(const char*, const char*)>(0x4F52E0)(dvarName, value);
|
||||
}
|
||||
|
||||
void Dvar::OnRegisterVariant([[maybe_unused]] Game::dvar_t* dvar)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
dvar->flags &= ~Game::DVAR_CHEAT;
|
||||
#endif
|
||||
}
|
||||
|
||||
__declspec(naked) void Dvar::Dvar_RegisterVariant_Stub()
|
||||
{
|
||||
__asm
|
||||
{
|
||||
pushad
|
||||
|
||||
push eax
|
||||
call Dvar::OnRegisterVariant
|
||||
add esp, 0x4
|
||||
|
||||
popad
|
||||
|
||||
// Game's code
|
||||
pop edi
|
||||
pop esi
|
||||
pop ebp
|
||||
pop ebx
|
||||
ret
|
||||
}
|
||||
}
|
||||
|
||||
Dvar::Dvar()
|
||||
{
|
||||
// set flags of cg_drawFPS to archive
|
||||
Utils::Hook::Or<BYTE>(0x4F8F69, Game::dvar_flag::DVAR_ARCHIVE);
|
||||
Utils::Hook::Or<BYTE>(0x4F8F69, Game::DVAR_ARCHIVE);
|
||||
|
||||
// un-cheat camera_thirdPersonCrosshairOffset and add archive flags
|
||||
Utils::Hook::Xor<BYTE>(0x447B41, Game::dvar_flag::DVAR_CHEAT | Game::dvar_flag::DVAR_ARCHIVE);
|
||||
Utils::Hook::Xor<BYTE>(0x447B41, Game::DVAR_CHEAT | Game::DVAR_ARCHIVE);
|
||||
|
||||
// un-cheat cg_fov and add archive flags
|
||||
Utils::Hook::Xor<BYTE>(0x4F8E35, Game::dvar_flag::DVAR_CHEAT | Game::dvar_flag::DVAR_ARCHIVE);
|
||||
Utils::Hook::Xor<BYTE>(0x4F8E35, Game::DVAR_CHEAT | Game::DVAR_ARCHIVE);
|
||||
|
||||
// un-cheat cg_fovscale and add archive flags
|
||||
Utils::Hook::Xor<BYTE>(0x4F8E68, Game::dvar_flag::DVAR_CHEAT | Game::dvar_flag::DVAR_ARCHIVE);
|
||||
Utils::Hook::Xor<BYTE>(0x4F8E68, Game::DVAR_CHEAT | Game::DVAR_ARCHIVE);
|
||||
|
||||
// un-cheat cg_debugInfoCornerOffset and add archive flags
|
||||
Utils::Hook::Xor<BYTE>(0x4F8FC2, Game::dvar_flag::DVAR_CHEAT | Game::dvar_flag::DVAR_ARCHIVE);
|
||||
Utils::Hook::Xor<BYTE>(0x4F8FC2, Game::DVAR_CHEAT | Game::DVAR_ARCHIVE);
|
||||
|
||||
// remove archive flags for cg_hudchatposition
|
||||
Utils::Hook::Xor<BYTE>(0x4F9992, Game::dvar_flag::DVAR_ARCHIVE);
|
||||
Utils::Hook::Xor<BYTE>(0x4F9992, Game::DVAR_ARCHIVE);
|
||||
|
||||
// remove write protection from fs_game
|
||||
Utils::Hook::Xor<DWORD>(0x6431EA, Game::dvar_flag::DVAR_INIT);
|
||||
Utils::Hook::Xor<DWORD>(0x6431EA, Game::DVAR_INIT);
|
||||
|
||||
// set cg_fov max to 160.0
|
||||
// because that's the max on SP
|
||||
@ -361,19 +389,19 @@ namespace Components
|
||||
Utils::Hook::Set<float*>(0x408078, &volume);
|
||||
|
||||
// Uncheat ui_showList
|
||||
Utils::Hook::Xor<BYTE>(0x6310DC, Game::dvar_flag::DVAR_CHEAT);
|
||||
Utils::Hook::Xor<BYTE>(0x6310DC, Game::DVAR_CHEAT);
|
||||
|
||||
// Uncheat ui_debugMode
|
||||
Utils::Hook::Xor<BYTE>(0x6312DE, Game::dvar_flag::DVAR_CHEAT);
|
||||
Utils::Hook::Xor<BYTE>(0x6312DE, Game::DVAR_CHEAT);
|
||||
|
||||
// Hook dvar 'name' registration
|
||||
Utils::Hook(0x40531C, Dvar::Dvar_RegisterName, HOOK_CALL).install()->quick();
|
||||
|
||||
// un-cheat safeArea_* and add archive flags
|
||||
Utils::Hook::Xor<INT>(0x42E3F5, Game::dvar_flag::DVAR_ROM | Game::dvar_flag::DVAR_ARCHIVE); //safeArea_adjusted_horizontal
|
||||
Utils::Hook::Xor<INT>(0x42E423, Game::dvar_flag::DVAR_ROM | Game::dvar_flag::DVAR_ARCHIVE); //safeArea_adjusted_vertical
|
||||
Utils::Hook::Xor<BYTE>(0x42E398, Game::dvar_flag::DVAR_CHEAT | Game::dvar_flag::DVAR_ARCHIVE); //safeArea_horizontal
|
||||
Utils::Hook::Xor<BYTE>(0x42E3C4, Game::dvar_flag::DVAR_CHEAT | Game::dvar_flag::DVAR_ARCHIVE); //safeArea_vertical
|
||||
Utils::Hook::Xor<INT>(0x42E3F5, Game::DVAR_ROM | Game::DVAR_ARCHIVE); //safeArea_adjusted_horizontal
|
||||
Utils::Hook::Xor<INT>(0x42E423, Game::DVAR_ROM | Game::DVAR_ARCHIVE); //safeArea_adjusted_vertical
|
||||
Utils::Hook::Xor<BYTE>(0x42E398, Game::DVAR_CHEAT | Game::DVAR_ARCHIVE); //safeArea_horizontal
|
||||
Utils::Hook::Xor<BYTE>(0x42E3C4, Game::DVAR_CHEAT | Game::DVAR_ARCHIVE); //safeArea_vertical
|
||||
|
||||
// Don't allow setting cheat protected dvars via menus
|
||||
Utils::Hook(0x63C897, Dvar::SetFromStringByNameExternal, HOOK_CALL).install()->quick();
|
||||
@ -404,6 +432,10 @@ namespace Components
|
||||
|
||||
// Reset archive dvars when client leaves a server
|
||||
Events::OnSteamDisconnect(Dvar::ResetDvarsValue);
|
||||
|
||||
// For debugging
|
||||
Utils::Hook(0x6483FA, Dvar::Dvar_RegisterVariant_Stub, HOOK_JUMP).install()->quick();
|
||||
Utils::Hook(0x648438, Dvar::Dvar_RegisterVariant_Stub, HOOK_JUMP).install()->quick();
|
||||
}
|
||||
|
||||
Dvar::~Dvar()
|
||||
|
@ -8,10 +8,10 @@ namespace Components
|
||||
class Flag
|
||||
{
|
||||
public:
|
||||
Flag(Game::dvar_flag flag) : val(flag) {}
|
||||
Flag(unsigned __int16 flag) : Flag(static_cast<Game::dvar_flag>(flag)) {}
|
||||
Flag(Game::DvarFlags flag) : val(flag) {}
|
||||
Flag(unsigned __int16 flag) : Flag(static_cast<Game::DvarFlags>(flag)) {}
|
||||
|
||||
Game::dvar_flag val;
|
||||
Game::DvarFlags val;
|
||||
};
|
||||
|
||||
class Var
|
||||
@ -60,5 +60,8 @@ namespace Components
|
||||
static bool AreArchiveDvarsProtected();
|
||||
static void SaveArchiveDvar(const Game::dvar_t* var);
|
||||
static void DvarSetFromStringByNameStub(const char* dvarName, const char* value);
|
||||
|
||||
static void OnRegisterVariant(Game::dvar_t* dvar);
|
||||
static void Dvar_RegisterVariant_Stub();
|
||||
};
|
||||
}
|
||||
|
@ -495,7 +495,7 @@ namespace Components
|
||||
|
||||
FastFiles::FastFiles()
|
||||
{
|
||||
Dvar::Register<bool>("ui_zoneDebug", false, Game::dvar_flag::DVAR_ARCHIVE, "Display current loaded zone.");
|
||||
Dvar::Register<bool>("ui_zoneDebug", false, Game::DVAR_ARCHIVE, "Display current loaded zone.");
|
||||
|
||||
// Fix XSurface assets
|
||||
Utils::Hook(0x0048E8A5, FastFiles::Load_XSurfaceArray, HOOK_CALL).install()->quick();
|
||||
|
@ -277,7 +277,7 @@ namespace Components
|
||||
// Overwrite SetString
|
||||
Utils::Hook(0x4CE5EE, Localization::SetStringStub, HOOK_CALL).install()->quick();
|
||||
|
||||
Localization::UseLocalization = Dvar::Register<bool>("ui_localize", true, Game::dvar_flag::DVAR_NONE, "Use localization strings");
|
||||
Localization::UseLocalization = Dvar::Register<bool>("ui_localize", true, Game::DVAR_NONE, "Use localization strings");
|
||||
|
||||
// Generate localized entries for custom classes above 10
|
||||
AssetHandler::OnLoad([](Game::XAssetType type, Game::XAssetHeader asset, const std::string& name, bool* /*restrict*/)
|
||||
|
@ -364,7 +364,7 @@ namespace Components
|
||||
|
||||
Logger::Logger()
|
||||
{
|
||||
Dvar::Register<bool>("iw4x_onelog", false, Game::dvar_flag::DVAR_LATCH | Game::dvar_flag::DVAR_ARCHIVE, "Only write the game log to the 'userraw' OS folder");
|
||||
Dvar::Register<bool>("iw4x_onelog", false, Game::DVAR_LATCH | Game::DVAR_ARCHIVE, "Only write the game log to the 'userraw' OS folder");
|
||||
Utils::Hook(0x642139, Logger::BuildOSPathStub, HOOK_JUMP).install()->quick();
|
||||
|
||||
Logger::PipeOutput(nullptr);
|
||||
|
@ -306,9 +306,9 @@ namespace Components
|
||||
Utils::Hook::Set<void(*)()>(0x4152E8, SV_MapRotate_f);
|
||||
|
||||
SVRandomMapRotation = Dvar::Register<bool>("sv_randomMapRotation", false,
|
||||
Game::dvar_flag::DVAR_ARCHIVE, "Randomize map rotation when true");
|
||||
Game::DVAR_ARCHIVE, "Randomize map rotation when true");
|
||||
SVDontRotate = Dvar::Register<bool>("sv_dontRotate", false,
|
||||
Game::dvar_flag::DVAR_NONE, "Do not perform map rotation");
|
||||
Game::DVAR_NONE, "Do not perform map rotation");
|
||||
}
|
||||
|
||||
bool MapRotation::unitTest()
|
||||
|
@ -93,7 +93,7 @@ namespace Components
|
||||
if (Dedicated::IsEnabled()) return;
|
||||
|
||||
ModList::CurrentMod = 0;
|
||||
Dvar::Register("cl_modVidRestart", true, Game::dvar_flag::DVAR_ARCHIVE, "Perform a vid_restart when loading a mod.");
|
||||
Dvar::Register("cl_modVidRestart", true, Game::DVAR_ARCHIVE, "Perform a vid_restart when loading a mod.");
|
||||
|
||||
UIScript::Add("LoadMods", ModList::UIScript_LoadMods);
|
||||
UIScript::Add("RunMod", ModList::UIScript_RunMod);
|
||||
|
@ -76,9 +76,9 @@ namespace Components
|
||||
return Party::Container.motd;
|
||||
}
|
||||
|
||||
Game::dvar_t* Party::RegisterMinPlayers(const char* name, int /*value*/, int /*min*/, int max, Game::dvar_flag flag, const char* description)
|
||||
Game::dvar_t* Party::RegisterMinPlayers(const char* name, int /*value*/, int /*min*/, int max, Game::DvarFlags flag, const char* description)
|
||||
{
|
||||
return Dvar::Register<int>(name, 1, 1, max, Game::dvar_flag::DVAR_INIT | flag, description).get<Game::dvar_t*>();
|
||||
return Dvar::Register<int>(name, 1, 1, max, Game::DVAR_INIT | flag, description).get<Game::dvar_t*>();
|
||||
}
|
||||
|
||||
bool Party::PlaylistAwaiting()
|
||||
@ -154,8 +154,8 @@ namespace Components
|
||||
|
||||
Party::Party()
|
||||
{
|
||||
Party::PartyEnable = Dvar::Register<bool>("party_enable", Dedicated::IsEnabled(), Game::dvar_flag::DVAR_NONE, "Enable party system");
|
||||
Dvar::Register<bool>("xblive_privatematch", true, Game::dvar_flag::DVAR_INIT, "");
|
||||
Party::PartyEnable = Dvar::Register<bool>("party_enable", Dedicated::IsEnabled(), Game::DVAR_NONE, "Enable party system");
|
||||
Dvar::Register<bool>("xblive_privatematch", true, Game::DVAR_INIT, "");
|
||||
|
||||
// various changes to SV_DirectConnect-y stuff to allow non-party joinees
|
||||
Utils::Hook::Set<WORD>(0x460D96, 0x90E9);
|
||||
@ -254,12 +254,12 @@ namespace Components
|
||||
Utils::Hook::Set<const char*>(0x5E3772, "sv_maxclients");
|
||||
|
||||
// Unlatch maxclient dvars
|
||||
Utils::Hook::Xor<BYTE>(0x426187, Game::dvar_flag::DVAR_LATCH);
|
||||
Utils::Hook::Xor<BYTE>(0x4D374E, Game::dvar_flag::DVAR_LATCH);
|
||||
Utils::Hook::Xor<BYTE>(0x5E376A, Game::dvar_flag::DVAR_LATCH);
|
||||
Utils::Hook::Xor<DWORD>(0x4261A1, Game::dvar_flag::DVAR_LATCH);
|
||||
Utils::Hook::Xor<DWORD>(0x4D376D, Game::dvar_flag::DVAR_LATCH);
|
||||
Utils::Hook::Xor<DWORD>(0x5E3789, Game::dvar_flag::DVAR_LATCH);
|
||||
Utils::Hook::Xor<BYTE>(0x426187, Game::DVAR_LATCH);
|
||||
Utils::Hook::Xor<BYTE>(0x4D374E, Game::DVAR_LATCH);
|
||||
Utils::Hook::Xor<BYTE>(0x5E376A, Game::DVAR_LATCH);
|
||||
Utils::Hook::Xor<DWORD>(0x4261A1, Game::DVAR_LATCH);
|
||||
Utils::Hook::Xor<DWORD>(0x4D376D, Game::DVAR_LATCH);
|
||||
Utils::Hook::Xor<DWORD>(0x5E3789, Game::DVAR_LATCH);
|
||||
|
||||
// Patch Live_PlayerHasLoopbackAddr
|
||||
//Utils::Hook::Set<DWORD>(0x418F30, 0x90C3C033);
|
||||
|
@ -50,7 +50,7 @@ namespace Components
|
||||
|
||||
static SteamID GenerateLobbyId();
|
||||
|
||||
static Game::dvar_t* RegisterMinPlayers(const char* name, int value, int min, int max, Game::dvar_flag flag, const char* description);
|
||||
static Game::dvar_t* RegisterMinPlayers(const char* name, int value, int min, int max, Game::DvarFlags flag, const char* description);
|
||||
|
||||
static DWORD UIDvarIntStub(char* dvar);
|
||||
};
|
||||
|
@ -106,7 +106,7 @@ namespace Components
|
||||
|
||||
PlayerName::PlayerName()
|
||||
{
|
||||
sv_allowColoredNames = Dvar::Register<bool>("sv_allowColoredNames", true, Game::dvar_flag::DVAR_NONE, "Allow colored names on the server");
|
||||
sv_allowColoredNames = Dvar::Register<bool>("sv_allowColoredNames", true, Game::DVAR_NONE, "Allow colored names on the server");
|
||||
|
||||
// Disable SV_UpdateUserinfo_f, to block changing the name ingame
|
||||
Utils::Hook::Set<BYTE>(0x6258D0, 0xC3);
|
||||
|
@ -248,7 +248,7 @@ namespace Components
|
||||
Utils::Hook(0x4F66A3, CL_KeyEvent_ConsoleEscape_Stub, HOOK_JUMP).install()->quick();
|
||||
|
||||
// Intermission time dvar
|
||||
Game::Dvar_RegisterFloat("scr_intermissionTime", 10, 0, 120, Game::dvar_flag::DVAR_NONE, "Time in seconds before match server loads the next map");
|
||||
Game::Dvar_RegisterFloat("scr_intermissionTime", 10, 0, 120, Game::DVAR_NONE, "Time in seconds before match server loads the next map");
|
||||
|
||||
g_antilag = Game::Dvar_RegisterBool("g_antilag", true, Game::DVAR_CODINFO, "Perform antilag");
|
||||
Utils::Hook(0x5D6D56, QuickPatch::ClientEventsFireWeaponStub, HOOK_JUMP).install()->quick();
|
||||
@ -328,7 +328,7 @@ namespace Components
|
||||
|
||||
// Numerical ping (cg_scoreboardPingText 1)
|
||||
Utils::Hook::Set<BYTE>(0x45888E, 1);
|
||||
Utils::Hook::Set<BYTE>(0x45888C, Game::dvar_flag::DVAR_CHEAT);
|
||||
Utils::Hook::Set<BYTE>(0x45888C, Game::DVAR_CHEAT);
|
||||
|
||||
// increase font sizes for chat on higher resolutions
|
||||
static float float13 = 13.0f;
|
||||
|
@ -78,8 +78,8 @@ namespace Components
|
||||
|
||||
Scheduler::Once([]
|
||||
{
|
||||
RCon::RconPassword = Dvar::Register<const char*>("rcon_password", "", Game::dvar_flag::DVAR_NONE, "The password for rcon");
|
||||
RCon::RconLogRequests = Dvar::Register<bool>("rcon_log_requests", false, Game::dvar_flag::DVAR_NONE, "Print remote commands in the output log");
|
||||
RCon::RconPassword = Dvar::Register<const char*>("rcon_password", "", Game::DVAR_NONE, "The password for rcon");
|
||||
RCon::RconLogRequests = Dvar::Register<bool>("rcon_log_requests", false, Game::DVAR_NONE, "Print remote commands in the output log");
|
||||
}, Scheduler::Pipeline::MAIN);
|
||||
|
||||
Network::OnPacket("rcon", [](const Network::Address& address, [[maybe_unused]] const std::string& data)
|
||||
|
@ -149,7 +149,7 @@ namespace Components
|
||||
Utils::Hook(0x467C03, RawMouse::IN_Init, HOOK_CALL).install()->quick();
|
||||
Utils::Hook(0x64D095, RawMouse::IN_Init, HOOK_JUMP).install()->quick();
|
||||
|
||||
RawMouse::M_RawInput = Dvar::Register<bool>("m_rawinput", true, Game::dvar_flag::DVAR_ARCHIVE, "Use raw mouse input, Improves accuracy & has better support for higher polling rates. Use in_restart to take effect if not enabled.");
|
||||
RawMouse::M_RawInput = Dvar::Register<bool>("m_rawinput", true, Game::DVAR_ARCHIVE, "Use raw mouse input, Improves accuracy & has better support for higher polling rates. Use in_restart to take effect if not enabled.");
|
||||
|
||||
Window::OnWndMessage(WM_INPUT, RawMouse::OnRawInput);
|
||||
Window::OnCreate(RawMouse::IN_RawMouse_Init);
|
||||
|
@ -779,14 +779,14 @@ namespace Components
|
||||
Scheduler::Once([]
|
||||
{
|
||||
ServerList::UIServerSelected = Dvar::Register<bool>("ui_serverSelected", false,
|
||||
Game::dvar_flag::DVAR_NONE, "Whether a server has been selected in the serverlist");
|
||||
Game::DVAR_NONE, "Whether a server has been selected in the serverlist");
|
||||
ServerList::UIServerSelectedMap = Dvar::Register<const char*>("ui_serverSelectedMap", "mp_afghan",
|
||||
Game::dvar_flag::DVAR_NONE, "Map of the selected server");
|
||||
Game::DVAR_NONE, "Map of the selected server");
|
||||
|
||||
ServerList::NETServerQueryLimit = Dvar::Register<int>("net_serverQueryLimit", 1,
|
||||
1, 10, Dedicated::IsEnabled() ? Game::dvar_flag::DVAR_NONE : Game::dvar_flag::DVAR_ARCHIVE, "Amount of server queries per frame");
|
||||
1, 10, Dedicated::IsEnabled() ? Game::DVAR_NONE : Game::DVAR_ARCHIVE, "Amount of server queries per frame");
|
||||
ServerList::NETServerFrames = Dvar::Register<int>("net_serverFrames", 30,
|
||||
1, 60, Dedicated::IsEnabled() ? Game::dvar_flag::DVAR_NONE : Game::dvar_flag::DVAR_ARCHIVE, "Amount of server query frames per second");
|
||||
1, 60, Dedicated::IsEnabled() ? Game::DVAR_NONE : Game::DVAR_ARCHIVE, "Amount of server query frames per second");
|
||||
}, Scheduler::Pipeline::MAIN);
|
||||
|
||||
// Fix ui_netsource dvar
|
||||
@ -829,8 +829,8 @@ namespace Components
|
||||
|
||||
// Set default masterServerName + port and save it
|
||||
Utils::Hook::Set<const char*>(0x60AD92, "master.xlabs.dev");
|
||||
Utils::Hook::Set<BYTE>(0x60AD90, Game::dvar_flag::DVAR_NONE); // masterServerName
|
||||
Utils::Hook::Set<BYTE>(0x60ADC6, Game::dvar_flag::DVAR_NONE); // masterPort
|
||||
Utils::Hook::Set<BYTE>(0x60AD90, Game::DVAR_NONE); // masterServerName
|
||||
Utils::Hook::Set<BYTE>(0x60ADC6, Game::DVAR_NONE); // masterPort
|
||||
|
||||
// Add server list feeder
|
||||
UIFeeder::Add(2.0f, ServerList::GetServerCount, ServerList::GetServerText, ServerList::SelectServer);
|
||||
|
@ -1599,10 +1599,10 @@ namespace Components
|
||||
{
|
||||
currentColorTable = &colorTableDefault;
|
||||
|
||||
cg_newColors = Dvar::Register<bool>("cg_newColors", true, Game::dvar_flag::DVAR_ARCHIVE, "Use Warfare 2 color code style.");
|
||||
cg_fontIconAutocomplete = Dvar::Register<bool>("cg_fontIconAutocomplete", true, Game::dvar_flag::DVAR_ARCHIVE, "Show autocomplete for fonticons when typing.");
|
||||
cg_fontIconAutocompleteHint = Dvar::Register<bool>("cg_fontIconAutocompleteHint", true, Game::dvar_flag::DVAR_ARCHIVE, "Show hint text in autocomplete for fonticons.");
|
||||
sv_customTextColor = Game::Dvar_RegisterColor("sv_customTextColor", 1, 0.7f, 0, 1, Game::dvar_flag::DVAR_CODINFO, "Color for the extended color code.");
|
||||
cg_newColors = Dvar::Register<bool>("cg_newColors", true, Game::DVAR_ARCHIVE, "Use Warfare 2 color code style.");
|
||||
cg_fontIconAutocomplete = Dvar::Register<bool>("cg_fontIconAutocomplete", true, Game::DVAR_ARCHIVE, "Show autocomplete for fonticons when typing.");
|
||||
cg_fontIconAutocompleteHint = Dvar::Register<bool>("cg_fontIconAutocompleteHint", true, Game::DVAR_ARCHIVE, "Show hint text in autocomplete for fonticons.");
|
||||
sv_customTextColor = Game::Dvar_RegisterColor("sv_customTextColor", 1, 0.7f, 0, 1, Game::DVAR_CODINFO, "Color for the extended color code.");
|
||||
|
||||
// Initialize font icons when initializing UI
|
||||
Utils::Hook(0x4B5422, UI_Init_Hk, HOOK_CALL).install()->quick();
|
||||
@ -1617,11 +1617,11 @@ namespace Components
|
||||
Utils::Hook(0x417770, ColorIndex, HOOK_JUMP).install()->quick();
|
||||
|
||||
// Add a colorblind mode for team colors
|
||||
r_colorBlind = Dvar::Register<bool>("r_colorBlind", false, Game::dvar_flag::DVAR_ARCHIVE, "Use color-blindness-friendly colors");
|
||||
r_colorBlind = Dvar::Register<bool>("r_colorBlind", false, Game::DVAR_ARCHIVE, "Use color-blindness-friendly colors");
|
||||
// A dark red
|
||||
g_ColorBlind_EnemyTeam = Game::Dvar_RegisterColor("g_ColorBlind_EnemyTeam", 0.659f, 0.088f, 0.145f, 1, Game::dvar_flag::DVAR_ARCHIVE, "Enemy team color for colorblind mode");
|
||||
g_ColorBlind_EnemyTeam = Game::Dvar_RegisterColor("g_ColorBlind_EnemyTeam", 0.659f, 0.088f, 0.145f, 1, Game::DVAR_ARCHIVE, "Enemy team color for colorblind mode");
|
||||
// A bright yellow
|
||||
g_ColorBlind_MyTeam = Game::Dvar_RegisterColor("g_ColorBlind_MyTeam", 1, 0.859f, 0.125f, 1, Game::dvar_flag::DVAR_ARCHIVE, "Ally team color for colorblind mode");
|
||||
g_ColorBlind_MyTeam = Game::Dvar_RegisterColor("g_ColorBlind_MyTeam", 1, 0.859f, 0.125f, 1, Game::DVAR_ARCHIVE, "Ally team color for colorblind mode");
|
||||
|
||||
// Replace team colors with colorblind team colors when colorblind is enabled
|
||||
Utils::Hook(0x406530, GetUnpackedColorByNameStub, HOOK_JUMP).install()->quick();
|
||||
|
@ -342,8 +342,8 @@ namespace Components
|
||||
|
||||
Theatre::Theatre()
|
||||
{
|
||||
Dvar::Register<bool>("cl_autoRecord", true, Game::dvar_flag::DVAR_ARCHIVE, "Automatically record games.");
|
||||
Dvar::Register<int>("cl_demosKeep", 30, 1, 999, Game::dvar_flag::DVAR_ARCHIVE, "How many demos to keep with autorecord.");
|
||||
Dvar::Register<bool>("cl_autoRecord", true, Game::DVAR_ARCHIVE, "Automatically record games.");
|
||||
Dvar::Register<int>("cl_demosKeep", 30, 1, 999, Game::DVAR_ARCHIVE, "How many demos to keep with autorecord.");
|
||||
|
||||
Utils::Hook(0x5A8370, Theatre::GamestateWriteStub, HOOK_CALL).install()->quick();
|
||||
Utils::Hook(0x5A85D2, Theatre::RecordGamestateStub, HOOK_CALL).install()->quick();
|
||||
|
@ -383,9 +383,9 @@ namespace Components
|
||||
|
||||
Scheduler::Once([]
|
||||
{
|
||||
Dvar::Register<const char*>("ui_map_long", "Afghan", Game::dvar_flag::DVAR_NONE, "");
|
||||
Dvar::Register<const char*>("ui_map_name", "mp_afghan", Game::dvar_flag::DVAR_NONE, "");
|
||||
Dvar::Register<const char*>("ui_map_desc", "", Game::dvar_flag::DVAR_NONE, "");
|
||||
Dvar::Register<const char*>("ui_map_long", "Afghan", Game::DVAR_NONE, "");
|
||||
Dvar::Register<const char*>("ui_map_name", "mp_afghan", Game::DVAR_NONE, "");
|
||||
Dvar::Register<const char*>("ui_map_desc", "", Game::DVAR_NONE, "");
|
||||
}, Scheduler::Pipeline::MAIN);
|
||||
|
||||
// Get feeder item count
|
||||
|
@ -165,8 +165,8 @@ namespace Components
|
||||
Window::Window()
|
||||
{
|
||||
// Borderless window
|
||||
Window::NoBorder = Dvar::Register<bool>("r_noborder", true, Game::dvar_flag::DVAR_ARCHIVE, "Do not use a border in windowed mode");
|
||||
Window::NativeCursor = Dvar::Register<bool>("ui_nativeCursor", false, Game::dvar_flag::DVAR_ARCHIVE, "Display native cursor");
|
||||
Window::NoBorder = Dvar::Register<bool>("r_noborder", true, Game::DVAR_ARCHIVE, "Do not use a border in windowed mode");
|
||||
Window::NativeCursor = Dvar::Register<bool>("ui_nativeCursor", false, Game::DVAR_ARCHIVE, "Display native cursor");
|
||||
|
||||
Utils::Hook(0x507643, Window::StyleHookStub, HOOK_CALL).install()->quick();
|
||||
|
||||
|
@ -125,6 +125,7 @@ namespace Game
|
||||
Dvar_RegisterEnum_t Dvar_RegisterEnum = Dvar_RegisterEnum_t(0x412E40);
|
||||
Dvar_RegisterString_t Dvar_RegisterString = Dvar_RegisterString_t(0x4FC7E0);
|
||||
Dvar_RegisterColor_t Dvar_RegisterColor = Dvar_RegisterColor_t(0x4F28E0);
|
||||
Dvar_RegisterVec3Color_t Dvar_RegisterVec3Color = Dvar_RegisterVec3Color_t(0x4918B0);
|
||||
|
||||
Dvar_GetUnpackedColorByName_t Dvar_GetUnpackedColorByName = Dvar_GetUnpackedColorByName_t(0x406530);
|
||||
Dvar_FindVar_t Dvar_FindVar = Dvar_FindVar_t(0x4D5390);
|
||||
|
@ -298,6 +298,9 @@ namespace Game
|
||||
typedef dvar_t*(__cdecl * Dvar_RegisterColor_t)(const char* dvarName, float r, float g, float b, float a, unsigned __int16 flags, const char* description);
|
||||
extern Dvar_RegisterColor_t Dvar_RegisterColor;
|
||||
|
||||
typedef dvar_t*(__cdecl * Dvar_RegisterVec3Color_t)(const char* dvarName, float x, float y, float z, float max, unsigned __int16 flags, const char* description);
|
||||
extern Dvar_RegisterVec3Color_t Dvar_RegisterVec3Color;
|
||||
|
||||
typedef void(__cdecl * Dvar_SetFromStringByName_t)(const char* dvarName, const char* string);
|
||||
extern Dvar_SetFromStringByName_t Dvar_SetFromStringByName;
|
||||
|
||||
|
@ -133,7 +133,7 @@ namespace Game
|
||||
SURF_TYPE_COUNT
|
||||
};
|
||||
|
||||
enum dvar_flag : unsigned __int16
|
||||
enum DvarFlags : unsigned __int16
|
||||
{
|
||||
DVAR_NONE = 0, // No flags
|
||||
DVAR_ARCHIVE = 1 << 0, // Set to cause it to be saved to config_mp.cfg of the client
|
||||
|
Loading…
Reference in New Issue
Block a user