Merge pull request #56 from ineedbots/develop

Register the GSC HTTP functions reguardless of being in Dedicated to prevent Script Compile Error
This commit is contained in:
Dss0 2020-12-17 14:23:14 +01:00 committed by GitHub
commit dc992cfb72
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 26 additions and 27 deletions

View File

@ -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<ScriptDownload>(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<ScriptDownload>(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()

View File

@ -39,7 +39,7 @@ namespace Components
static std::vector<std::string> ScriptNameStack;
static unsigned short FunctionName;
static std::unordered_map<std::string, std::string> ScriptStorage;
static std::unordered_map<int, std::string> Script::ScriptBaseProgramNum;
static std::unordered_map<int, std::string> ScriptBaseProgramNum;
static Utils::Signal<Scheduler::Callback> VMShutdownSignal;