[Merge] feature/www-download -> develop
This commit is contained in:
commit
1799379e42
@ -192,7 +192,32 @@ namespace Components
|
||||
}
|
||||
}
|
||||
|
||||
std::string url = "http://" + download->target.getString() + "/file/" + (download->isMap ? "map/" : "") + file.name;
|
||||
std::string host = "http://" + download->target.getString();
|
||||
std::string fastHost = "http://" + Dvar::Var("sv_wwwBaseUrl").get<std::string>();
|
||||
|
||||
std::string url;
|
||||
|
||||
// file directory for fasthost looks like this
|
||||
// /-usermaps
|
||||
// /-mp_test
|
||||
// -mp_test.ff
|
||||
// -mp_test.iwd
|
||||
// /-mp_whatever
|
||||
// /-mp_whatever.ff
|
||||
// /-mods
|
||||
// /-mod1
|
||||
// -mod1.iwd
|
||||
// -mod.ff
|
||||
// /-mod2
|
||||
// ...
|
||||
if (Dvar::Var("sv_wwwDownload").get<bool>())
|
||||
{
|
||||
url = fastHost + path;
|
||||
}
|
||||
else
|
||||
{
|
||||
url = host + "/file/" + (download->isMap ? "map/" : "") + file.name;
|
||||
}
|
||||
|
||||
Download::FileDownload fDownload;
|
||||
fDownload.file = file;
|
||||
@ -738,6 +763,12 @@ namespace Components
|
||||
mg_mgr_poll(&Download::Mgr, 100);
|
||||
}
|
||||
});
|
||||
|
||||
Dvar::OnInit([]()
|
||||
{
|
||||
Dvar::Register<bool>("sv_wwwDownload", false, Game::dvar_flag::DVAR_FLAG_DEDISAVED, "Set to true to enable downloading maps/mods from an external server.");
|
||||
Dvar::Register<const char*>("sv_wwwBaseUrl", "", Game::dvar_flag::DVAR_FLAG_DEDISAVED, "Set to the base url for the external map download.");
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -746,6 +777,8 @@ namespace Components
|
||||
Dvar::Register<const char*>("ui_dl_timeLeft", "", Game::dvar_flag::DVAR_FLAG_NONE, "");
|
||||
Dvar::Register<const char*>("ui_dl_progress", "", Game::dvar_flag::DVAR_FLAG_NONE, "");
|
||||
Dvar::Register<const char*>("ui_dl_transRate", "", Game::dvar_flag::DVAR_FLAG_NONE, "");
|
||||
Dvar::Register<bool>("sv_wwwDownload", false, Game::dvar_flag::DVAR_FLAG_DEDISAVED, "Set to true to enable downloading maps/mods from an external server.");
|
||||
Dvar::Register<const char*>("sv_wwwBaseUrl", "", Game::dvar_flag::DVAR_FLAG_DEDISAVED, "Set to the base url for the external map download.");
|
||||
});
|
||||
|
||||
UIScript::Add("mod_download_cancel", [] (UIScript::Token)
|
||||
|
@ -370,6 +370,9 @@ namespace Components
|
||||
info.set("matchtype", "0");
|
||||
}
|
||||
|
||||
info.set("wwwDownload", (Dvar::Var("sv_wwwDownload").get<bool>() ? "1" : "0"));
|
||||
info.set("wwwUrl", Dvar::Var("sv_wwwBaseUrl").get<std::string>());
|
||||
|
||||
Network::SendCommand(address, "infoResponse", "\\" + info.build());
|
||||
});
|
||||
|
||||
@ -393,6 +396,18 @@ namespace Components
|
||||
|
||||
std::string mod = Dvar::Var("fs_game").get<std::string>();
|
||||
|
||||
// set fast server stuff here so its updated when we go to download stuff
|
||||
if (info.get("wwwDownload") == "1"s)
|
||||
{
|
||||
Dvar::Var("sv_wwwDownload").set(true);
|
||||
Dvar::Var("sv_wwwBaseUrl").set(info.get("wwwUrl"));
|
||||
}
|
||||
else
|
||||
{
|
||||
Dvar::Var("sv_wwwDownload").set(false);
|
||||
Dvar::Var("sv_wwwBaseUrl").set("");
|
||||
}
|
||||
|
||||
if (info.get("challenge") != Party::Container.challenge)
|
||||
{
|
||||
Party::ConnectError("Invalid join response: Challenge mismatch.");
|
||||
|
Loading…
Reference in New Issue
Block a user