From 74ac1668858da2c149efcf0dcf4c1d8f13ae708e Mon Sep 17 00:00:00 2001 From: INeedBots Date: Wed, 16 Dec 2020 11:45:28 -0600 Subject: [PATCH 1/2] [Download] Register HTTP GSC functions to prevent script compile errors --- src/Components/Modules/Download.cpp | 51 ++++++++++++++--------------- 1 file changed, 25 insertions(+), 26 deletions(-) diff --git a/src/Components/Modules/Download.cpp b/src/Components/Modules/Download.cpp index 08e61095..f4c25566 100644 --- a/src/Components/Modules/Download.cpp +++ b/src/Components/Modules/Download.cpp @@ -964,36 +964,35 @@ namespace Components Download::ScriptDownloads.clear(); }); - if (Dedicated::IsEnabled() || Flags::HasFlag("scriptablehttp")) + Script::AddFunction("httpGet", [](Game::scr_entref_t) { - Script::AddFunction("httpGet", [](Game::scr_entref_t) + if (!Dedicated::IsEnabled() && !Flags::HasFlag("scriptablehttp")) return; + if (Game::Scr_GetNumParam() < 1) return; + + std::string url = Game::Scr_GetString(0); + unsigned int object = Game::AllocObject(); + + Game::Scr_AddObject(object); + + Download::ScriptDownloads.push_back(std::make_shared(url, object)); + Game::RemoveRefToObject(object); + }); + + Script::AddFunction("httpCancel", [](Game::scr_entref_t) + { + if (!Dedicated::IsEnabled() && !Flags::HasFlag("scriptablehttp")) return; + if (Game::Scr_GetNumParam() < 1) return; + + unsigned int object = Game::Scr_GetObject(0); + for (auto& download : Download::ScriptDownloads) { - if (Game::Scr_GetNumParam() < 1) return; - - std::string url = Game::Scr_GetString(0); - unsigned int object = Game::AllocObject(); - - Game::Scr_AddObject(object); - - Download::ScriptDownloads.push_back(std::make_shared(url, object)); - Game::RemoveRefToObject(object); - }); - - Script::AddFunction("httpCancel", [](Game::scr_entref_t) - { - if (Game::Scr_GetNumParam() < 1) return; - - unsigned int object = Game::Scr_GetObject(0); - for (auto& download : Download::ScriptDownloads) + if (object == download->getObject()) { - if (object == download->getObject()) - { - download->cancel(); - break; - } + download->cancel(); + break; } - }); - } + } + }); } Download::~Download() From f61e7709964c5af6167280c8a9419af609bcf07b Mon Sep 17 00:00:00 2001 From: INeedBots Date: Wed, 16 Dec 2020 21:49:26 -0600 Subject: [PATCH 2/2] [Script] Fixed compiling on C++20 again --- src/Components/Modules/Script.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Components/Modules/Script.hpp b/src/Components/Modules/Script.hpp index 49a75b78..f13b6891 100644 --- a/src/Components/Modules/Script.hpp +++ b/src/Components/Modules/Script.hpp @@ -39,7 +39,7 @@ namespace Components static std::vector ScriptNameStack; static unsigned short FunctionName; static std::unordered_map ScriptStorage; - static std::unordered_map Script::ScriptBaseProgramNum; + static std::unordered_map ScriptBaseProgramNum; static Utils::Signal VMShutdownSignal;