Some fixes
This commit is contained in:
parent
6d2a5bf5bc
commit
0829fa8b01
@ -66,6 +66,14 @@ namespace download
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void menu_error(const std::string& error)
|
||||||
|
{
|
||||||
|
scheduler::once([=]()
|
||||||
|
{
|
||||||
|
party::menu_error(error);
|
||||||
|
}, scheduler::pipeline::lui);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void start_download(const game::netadr_s& target, const utils::info_string& info)
|
void start_download(const game::netadr_s& target, const utils::info_string& info)
|
||||||
@ -81,7 +89,7 @@ namespace download
|
|||||||
}
|
}
|
||||||
|
|
||||||
return scheduler::cond_continue;
|
return scheduler::cond_continue;
|
||||||
});
|
}, scheduler::pipeline::main);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -94,7 +102,7 @@ namespace download
|
|||||||
const auto base = info.get("sv_wwwBaseUrl");
|
const auto base = info.get("sv_wwwBaseUrl");
|
||||||
if (base.empty())
|
if (base.empty())
|
||||||
{
|
{
|
||||||
party::menu_error("Download failed: Server doesn't have 'sv_wwwBaseUrl' dvar set.");
|
menu_error("Download failed: Server doesn't have 'sv_wwwBaseUrl' dvar set.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -129,7 +137,7 @@ namespace download
|
|||||||
const auto data = utils::http::get_data(url, {}, {}, &progress_callback);
|
const auto data = utils::http::get_data(url, {}, {}, &progress_callback);
|
||||||
if (!data.has_value())
|
if (!data.has_value())
|
||||||
{
|
{
|
||||||
party::menu_error("Download failed: An unknown error occurred, please try again.");
|
menu_error("Download failed: An unknown error occurred, please try again.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -141,7 +149,7 @@ namespace download
|
|||||||
const auto& result = data.value();
|
const auto& result = data.value();
|
||||||
if (result.code != CURLE_OK)
|
if (result.code != CURLE_OK)
|
||||||
{
|
{
|
||||||
party::menu_error(utils::string::va("Download failed: %s (%i)\n", result.code, curl_easy_strerror(result.code)));
|
menu_error(utils::string::va("Download failed: %s (%i)\n", result.code, curl_easy_strerror(result.code)));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -153,7 +161,6 @@ namespace download
|
|||||||
ui_scripting::notify("mod_download_done", {});
|
ui_scripting::notify("mod_download_done", {});
|
||||||
}, scheduler::pipeline::lui);
|
}, scheduler::pipeline::lui);
|
||||||
|
|
||||||
// reconnect back to target after download of mod is finished
|
|
||||||
scheduler::once([=]()
|
scheduler::once([=]()
|
||||||
{
|
{
|
||||||
party::connect(target);
|
party::connect(target);
|
||||||
@ -176,9 +183,8 @@ namespace download
|
|||||||
scheduler::once([]()
|
scheduler::once([]()
|
||||||
{
|
{
|
||||||
ui_scripting::notify("mod_download_done", {});
|
ui_scripting::notify("mod_download_done", {});
|
||||||
}, scheduler::pipeline::lui);
|
|
||||||
|
|
||||||
party::menu_error("Download for server mod has been cancelled.");
|
party::menu_error("Download for server mod has been cancelled.");
|
||||||
|
}, scheduler::pipeline::lui);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -155,7 +155,7 @@ namespace party
|
|||||||
const auto server_fs_game = utils::string::to_lower(info.get("fs_game"));
|
const auto server_fs_game = utils::string::to_lower(info.get("fs_game"));
|
||||||
if (!server_fs_game.starts_with("mods/") || server_fs_game.contains('.'))
|
if (!server_fs_game.starts_with("mods/") || server_fs_game.contains('.'))
|
||||||
{
|
{
|
||||||
console::info("Invalid server fs_game value %s\n", server_fs_game.data());
|
menu_error(utils::string::va("Invalid server fs_game value %s\n", server_fs_game.data()));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -218,21 +218,14 @@ namespace party
|
|||||||
|
|
||||||
void menu_error(const std::string& error)
|
void menu_error(const std::string& error)
|
||||||
{
|
{
|
||||||
// print error to console
|
|
||||||
console::error("%s\n", error.data());
|
console::error("%s\n", error.data());
|
||||||
|
|
||||||
scheduler::once([&]()
|
|
||||||
{
|
|
||||||
// check if popup_acceptinginvite is open and close if so
|
|
||||||
if (game::Menu_IsMenuOpenAndVisible(0, "popup_acceptinginvite"))
|
if (game::Menu_IsMenuOpenAndVisible(0, "popup_acceptinginvite"))
|
||||||
{
|
{
|
||||||
utils::hook::invoke<void>(0x26BE80_b, 0, "popup_acceptinginvite", 0, *game::hks::lua_state); // LUI_LeaveMenuByName
|
utils::hook::invoke<void>(0x26BE80_b, 0, "popup_acceptinginvite", 0, *game::hks::lua_state); // LUI_LeaveMenuByName
|
||||||
}
|
}
|
||||||
|
|
||||||
// set ui error information
|
|
||||||
utils::hook::invoke<void>(0x17D770_b, error.data(), "MENU_NOTICE"); // Com_SetLocalizedErrorMessage
|
utils::hook::invoke<void>(0x17D770_b, error.data(), "MENU_NOTICE"); // Com_SetLocalizedErrorMessage
|
||||||
utils::hook::set(0x2ED2F78_b, 1);
|
*reinterpret_cast<int*>(0x2ED2F78_b) = 1;
|
||||||
}, scheduler::pipeline::lui);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void clear_sv_motd()
|
void clear_sv_motd()
|
||||||
@ -745,8 +738,6 @@ namespace party
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// returning true doesn't exactly mean there is a error, but more or less means that we are cancelling the connection for more than one different reason.
|
|
||||||
// if there is a genuine error that occurs, menu_error is called within the function.
|
|
||||||
if (download_mod(target, info))
|
if (download_mod(target, info))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
|
Loading…
Reference in New Issue
Block a user