From 46a340af3d66f4e8285f53565f7f841cc7cdde18 Mon Sep 17 00:00:00 2001 From: /dev/urandom Date: Tue, 27 Mar 2018 00:53:47 +0200 Subject: [PATCH 1/3] [Download] Enable when running as client. This fixes mods being unusable in private matches. --- src/Components/Modules/Download.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Components/Modules/Download.cpp b/src/Components/Modules/Download.cpp index 3abdf5d5..27ee8de6 100644 --- a/src/Components/Modules/Download.cpp +++ b/src/Components/Modules/Download.cpp @@ -802,7 +802,7 @@ namespace Components Download::Download() { - if (Dedicated::IsEnabled()) + if (!ZoneBuilder::IsEnabled()) { Download::Terminate = false; ZeroMemory(&Download::Mgr, sizeof Download::Mgr); From 1ccd665d1d8457c8505e48c2f4df1cfcaee72e24 Mon Sep 17 00:00:00 2001 From: /dev/urandom Date: Tue, 27 Mar 2018 02:02:25 +0200 Subject: [PATCH 2/3] [Changelog] Mention private match fix. --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 477cca07..9ed5c69e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,8 @@ The format is based on [Keep a Changelog v0.3.0](http://keepachangelog.com/en/0. ### Fixed +- Fix mods not working in private matches. + ## [0.5.4] - 2017-07-09 ### Added From e11e4ae5a9638dbba51a7463cd1993ce99736f6f Mon Sep 17 00:00:00 2001 From: TheApadayo Date: Mon, 22 Oct 2018 18:58:09 -0400 Subject: [PATCH 3/3] [Download] Add Dvar for protection and also properly shutdown server even when running on a client --- src/Components/Modules/Download.cpp | 12 +++++++++--- src/Components/Modules/Download.hpp | 1 + 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/Components/Modules/Download.cpp b/src/Components/Modules/Download.cpp index 27ee8de6..acc49a12 100644 --- a/src/Components/Modules/Download.cpp +++ b/src/Components/Modules/Download.cpp @@ -8,6 +8,7 @@ namespace Components std::thread Download::ServerThread; bool Download::Terminate; + bool Download::ServerRunning; #pragma region Client @@ -802,9 +803,8 @@ namespace Components Download::Download() { - if (!ZoneBuilder::IsEnabled()) + if (Dedicated::IsEnabled() || Dvar::Var("mod_force_download_server").get()) { - Download::Terminate = false; ZeroMemory(&Download::Mgr, sizeof Download::Mgr); mg_mgr_init(&Download::Mgr, nullptr); @@ -828,6 +828,7 @@ namespace Components } }); + Download::ServerRunning = true; Download::Terminate = false; Download::ServerThread = std::thread([] { @@ -856,6 +857,11 @@ namespace Components { Dvar::Register("sv_wwwDownload", false, Game::dvar_flag::DVAR_FLAG_DEDISAVED, "Set to true to enable downloading maps/mods from an external server."); Dvar::Register("sv_wwwBaseUrl", "", Game::dvar_flag::DVAR_FLAG_DEDISAVED, "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("mod_force_download_server", false, Game::dvar_flag::DVAR_FLAG_SAVED, "Set to true to force the client to run the download server for mods (for mods in private matches)."); }); Scheduler::OnFrame([]() @@ -932,7 +938,7 @@ namespace Components Download::~Download() { - if (Dedicated::IsEnabled()) + if (Download::ServerRunning) { mg_mgr_free(&Download::Mgr); } diff --git a/src/Components/Modules/Download.hpp b/src/Components/Modules/Download.hpp index 911e983e..8feb6071 100644 --- a/src/Components/Modules/Download.hpp +++ b/src/Components/Modules/Download.hpp @@ -210,6 +210,7 @@ namespace Components static std::vector> ScriptDownloads; static std::thread ServerThread; static bool Terminate; + static bool ServerRunning; static bool VerifyPassword(mg_connection *nc, http_message* message);