[Merge] develop -> bugs/mod-downloading

This commit is contained in:
TheApadayo 2017-06-19 16:31:58 -04:00
commit b66bb9dc2e
3 changed files with 60 additions and 10 deletions

View File

@ -8,16 +8,18 @@ The format is based on [Keep a Changelog v0.3.0](http://keepachangelog.com/en/0.
### Added
- Show friend avatars when they play IW4x (request)
- Display a toast when an update is available.
- Use the hourglass cursor while loading assets (with the native cursor feature).
- Show bots in parenthesis after the number of players in the serverlist (request).
### Changed
- Show friend avatars when they play IW4x (request).
### Fixed
- Fix lags and frame drops caused by server sorting
- Fix demos on custom maps
- Fix lags and frame drops caused by server sorting.
- Fix demos on custom maps.
## [0.5.0] - 2017-06-04

View File

@ -32,7 +32,7 @@ namespace Components
if (needPassword)
{
std::string pass = Dvar::Var("password").get<std::string>();
if (!pass.length())
if (!pass.length())
{
// shouldn't ever happen but this is safe
Party::ConnectError("A password is required to connect to this server!");
@ -205,8 +205,33 @@ namespace Components
}
}
std::string url = "http://" + download->target.getString() + "/file/" + (download->isMap ? "map/" : "") + file.name
+ (download->isPrivate ? ("?password=" + download->hashedPassword) : "");
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->isPrivate ? ("?password=" + download->hashedPassword) : "");
}
Download::FileDownload fDownload;
fDownload.file = file;
@ -394,7 +419,7 @@ namespace Components
mg_printf(nc, ("HTTP/1.1 403 Forbidden\r\n"s +
"Content-Type: text/html\r\n"s +
"Connection: close\r\n"s +
"\r\n"s +
"\r\n"s +
((passLen == 0) ? "Password Required"s : "Invalid Password"s)).c_str());
nc->flags |= MG_F_SEND_AND_CLOSE;
@ -787,6 +812,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
{
@ -795,6 +826,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)

View File

@ -154,7 +154,7 @@ namespace Components
Utils::Hook::Set<BYTE>(0x5AC2CF, 0xEB); // CL_ParseGamestate
Utils::Hook::Set<BYTE>(0x5AC2C3, 0xEB); // CL_ParseGamestate
// AnonymousAddRequest
// AnonymousAddRequest
Utils::Hook::Set<BYTE>(0x5B5E18, 0xEB);
Utils::Hook::Set<BYTE>(0x5B5E64, 0xEB);
Utils::Hook::Nop(0x5B5E5C, 2);
@ -217,7 +217,7 @@ namespace Components
Utils::Hook::Set<BYTE>(0x4D6171, 0);
Utils::Hook::Nop(0x4077A1, 5); // PartyMigrate_Frame
// Patch playlist stuff for non-party behavior
// Patch playlist stuff for non-party behavior
Utils::Hook::Set<Game::dvar_t**>(0x4A4093, &partyEnable);
Utils::Hook::Set<Game::dvar_t**>(0x4573F1, &partyEnable);
Utils::Hook::Set<Game::dvar_t**>(0x5B1A0C, &partyEnable);
@ -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.");