From 0e3d4a596b3e1f6a2f8c3f6cb206f6421e1d3198 Mon Sep 17 00:00:00 2001 From: FutureRave Date: Mon, 6 Dec 2021 12:27:28 +0000 Subject: [PATCH] Refined logic a bit --- src/Components/Modules/Dvar.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/Components/Modules/Dvar.cpp b/src/Components/Modules/Dvar.cpp index 496bb488..7d225cea 100644 --- a/src/Components/Modules/Dvar.cpp +++ b/src/Components/Modules/Dvar.cpp @@ -192,8 +192,11 @@ namespace Components void Dvar::ResetDvarsValue() { - Command::Execute("exec archivedvars.cfg"); - // Cleanup + if (!Utils::IO::FileExists(Dvar::ArchiveDvarPath)) + return + + Command::Execute("exec archivedvars.cfg", true); + // Clean up Utils::IO::RemoveFile(Dvar::ArchiveDvarPath); } @@ -364,8 +367,8 @@ namespace Components // Hook Dvar_SetFromStringByName inside CG_SetClientDvarFromServer so we can reset dvars when the player leaves the server Utils::Hook(0x59386A, Dvar::DvarSetFromStringByNameStub, HOOK_CALL).install()->quick(); - // If the game closed abruptly the file would have not been deleted - Utils::IO::RemoveFile(Dvar::ArchiveDvarPath); + // If the game closed abruptly the dvars would have not been restored + Dvar::ResetDvarsValue(); } Dvar::~Dvar()