diff --git a/src/Components/Modules/Auth.cpp b/src/Components/Modules/Auth.cpp index 4e811189..3bdfa0bc 100644 --- a/src/Components/Modules/Auth.cpp +++ b/src/Components/Modules/Auth.cpp @@ -219,7 +219,7 @@ namespace Components void Auth::StoreKey() { - if (!Dedicated::IsEnabled() && !ZoneBuilder::IsEnabled()) + if (!Dedicated::IsEnabled() && !ZoneBuilder::IsEnabled() && Auth::GuidKey.IsValid()) { Proto::Auth::Certificate cert; cert.set_token(Auth::GuidToken.ToString()); @@ -363,7 +363,9 @@ namespace Components Localization::Set("MPUI_SECURITY_INCREASE_MESSAGE", ""); + // Load the key Auth::LoadKey(true); + Steam::SteamUser()->GetSteamID(); QuickPatch::OnFrame(Auth::Frame); diff --git a/src/Components/Modules/ConnectProtocol.cpp b/src/Components/Modules/ConnectProtocol.cpp index 442e61ff..d1f0719e 100644 --- a/src/Components/Modules/ConnectProtocol.cpp +++ b/src/Components/Modules/ConnectProtocol.cpp @@ -16,7 +16,7 @@ namespace Components ConnectProtocol::EvaluateProtocol(); } - return (ConnectProtocol::ConnectContainer.ConnectString.size() > 0); + return (!ConnectProtocol::ConnectContainer.ConnectString.empty()); } bool ConnectProtocol::InstallProtocol() diff --git a/src/Components/Modules/ConnectProtocol.hpp b/src/Components/Modules/ConnectProtocol.hpp index 078c7722..d3bcea8c 100644 --- a/src/Components/Modules/ConnectProtocol.hpp +++ b/src/Components/Modules/ConnectProtocol.hpp @@ -22,4 +22,4 @@ namespace Components static void EvaluateProtocol(); static bool InstallProtocol(); }; -} \ No newline at end of file +} diff --git a/src/Components/Modules/IPCPipe.cpp b/src/Components/Modules/IPCPipe.cpp index 38999f43..38d396f4 100644 --- a/src/Components/Modules/IPCPipe.cpp +++ b/src/Components/Modules/IPCPipe.cpp @@ -248,7 +248,7 @@ namespace Components if (IPCPipe::ServerPipe) delete IPCPipe::ServerPipe; if (IPCPipe::ClientPipe) delete IPCPipe::ClientPipe; - IPCPipe::ServerPipe = 0; - IPCPipe::ClientPipe = 0; + IPCPipe::ServerPipe = nullptr; + IPCPipe::ClientPipe = nullptr; } } diff --git a/src/Components/Modules/Network.cpp b/src/Components/Modules/Network.cpp index 6b298c52..1fcee988 100644 --- a/src/Components/Modules/Network.cpp +++ b/src/Components/Modules/Network.cpp @@ -109,6 +109,11 @@ namespace Components } bool Network::Address::IsLoopback() { + if (this->GetIP().full == 0x100007f) // 127.0.0.1 + { + return true; + } + return Game::NET_IsLocalAddress(this->address); } bool Network::Address::IsValid() diff --git a/src/Components/Modules/Party.cpp b/src/Components/Modules/Party.cpp index e5d90938..cffa59b5 100644 --- a/src/Components/Modules/Party.cpp +++ b/src/Components/Modules/Party.cpp @@ -90,6 +90,23 @@ namespace Components SteamID id = Party::GenerateLobbyId(); + // Temporary workaround + // TODO: Patch the 127.0.0.1 -> loopback mapping in the party code + if (Party::Container.Target.IsLoopback()) + { + if (*Game::numIP) + { + Party::Container.Target.SetIP(*Game::localIP); + Party::Container.Target.SetType(Game::netadrtype_t::NA_IP); + + Logger::Print("Trying to connect to party with loopback address, using a local ip instead: %s\n", Party::Container.Target.GetCString()); + } + else + { + Logger::Print("Trying to connect to party with loopback address, but no local ip was found.\n"); + } + } + Party::LobbyMap[id.Bits] = Party::Container.Target; Game::Steam_JoinLobby(id, 0); @@ -220,6 +237,9 @@ namespace Components Utils::Hook::Xor(0x4D376D, Game::dvar_flag::DVAR_FLAG_LATCHED); Utils::Hook::Xor(0x5E3789, Game::dvar_flag::DVAR_FLAG_LATCHED); + // Patch Live_PlayerHasLoopbackAddr + //Utils::Hook::Set(0x418F30, 0x90C3C033); + Command::Add("connect", [] (Command::Params params) { if (params.Length() < 2) diff --git a/src/Components/Modules/QuickPatch.cpp b/src/Components/Modules/QuickPatch.cpp index b0ca2afa..fc6d724c 100644 --- a/src/Components/Modules/QuickPatch.cpp +++ b/src/Components/Modules/QuickPatch.cpp @@ -327,6 +327,9 @@ namespace Components Utils::Hook::Set(0x45B98F, 0x5188FB); // profile_setBlacklevel Utils::Hook::Set(0x45B9A5, 0x5188FB); // profile_toggleCanSkipOffensiveMissions + // Patch SV_IsClientUsingOnlineStatsOffline + Utils::Hook::Set(0x46B710, 0x90C3C033); + // Fix mouse pitch adjustments UIScript::Add("updateui_mousePitch", [] () { diff --git a/src/Main.cpp b/src/Main.cpp index a6e597a8..4ecf77e4 100644 --- a/src/Main.cpp +++ b/src/Main.cpp @@ -4,10 +4,24 @@ namespace Main { static Utils::Hook EntryPointHook; + void SetEnvironment() + { + wchar_t exeName[512]; + GetModuleFileName(GetModuleHandle(NULL), exeName, sizeof(exeName) / 2); + + wchar_t* exeBaseName = wcsrchr(exeName, L'\\'); + exeBaseName[0] = L'\0'; + exeBaseName++; + + SetCurrentDirectory(exeName); + } + void Initialize() { Main::EntryPointHook.Uninstall(); + SetEnvironment(); + Utils::Cryptography::Initialize(); Components::Loader::Initialize();