Some fixes
This commit is contained in:
parent
d3124bf989
commit
c0c0d40533
@ -64,8 +64,13 @@ namespace download
|
|||||||
if (now - last_update > 20ms)
|
if (now - last_update > 20ms)
|
||||||
{
|
{
|
||||||
last_update = std::chrono::high_resolution_clock::now();
|
last_update = std::chrono::high_resolution_clock::now();
|
||||||
const auto fraction = static_cast<float>(static_cast<double>(progress) /
|
auto fraction = 0.f;
|
||||||
static_cast<double>(std::max(size_t(1), total)));
|
if (total > 0)
|
||||||
|
{
|
||||||
|
fraction = static_cast<float>(static_cast<double>(progress) /
|
||||||
|
static_cast<double>(total));
|
||||||
|
}
|
||||||
|
|
||||||
scheduler::once([=]()
|
scheduler::once([=]()
|
||||||
{
|
{
|
||||||
ui_scripting::notify("mod_download_progress",
|
ui_scripting::notify("mod_download_progress",
|
||||||
|
@ -172,19 +172,27 @@ namespace party
|
|||||||
void check_download_map(const utils::info_string& info, std::vector<download::file_t>& files)
|
void check_download_map(const utils::info_string& info, std::vector<download::file_t>& files)
|
||||||
{
|
{
|
||||||
const auto mapname = info.get("mapname");
|
const auto mapname = info.get("mapname");
|
||||||
const auto usermap_hash = info.get("usermaphash");
|
if (fastfiles::is_stock_map(mapname))
|
||||||
const auto usermap_load_hash = info.get("usermaploadhash");
|
|
||||||
|
|
||||||
const auto check_file = [&](const std::string& key, const std::string& filename)
|
|
||||||
{
|
{
|
||||||
if (mapname.contains('.') || mapname.contains("::"))
|
return;
|
||||||
{
|
}
|
||||||
throw std::runtime_error(utils::string::va("Invalid server mapname value %s\n", mapname.data()));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if (mapname.contains('.') || mapname.contains("::"))
|
||||||
|
{
|
||||||
|
throw std::runtime_error(utils::string::va("Invalid server mapname value %s\n", mapname.data()));
|
||||||
|
}
|
||||||
|
|
||||||
|
const auto check_file = [&](const std::string& key, const std::string& ext, bool optional)
|
||||||
|
{
|
||||||
|
const auto filename = utils::string::va("usermaps/%s/%s%s", mapname.data(), mapname.data(), ext.data());
|
||||||
const auto source_hash = info.get(key);
|
const auto source_hash = info.get(key);
|
||||||
if (source_hash.empty())
|
if (source_hash.empty())
|
||||||
{
|
{
|
||||||
|
if (!optional)
|
||||||
|
{
|
||||||
|
throw std::runtime_error(utils::string::va("Server %s is empty", key.data()));
|
||||||
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -196,8 +204,8 @@ namespace party
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
check_file("usermaphash", utils::string::va("usermaps/%s/%s.ff", mapname.data(), mapname.data()));
|
check_file("usermaphash", ".ff", false);
|
||||||
check_file("usermaploadhash", utils::string::va("usermaps/%s/%s_load.ff", mapname.data(), mapname.data()));
|
check_file("usermaploadhash", "_load.ff", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool check_download_mod(const utils::info_string& info, std::vector<download::file_t>& files)
|
bool check_download_mod(const utils::info_string& info, std::vector<download::file_t>& files)
|
||||||
@ -295,7 +303,7 @@ namespace party
|
|||||||
|
|
||||||
if (!fastfiles::is_stock_map(mapname))
|
if (!fastfiles::is_stock_map(mapname))
|
||||||
{
|
{
|
||||||
const auto filename = utils::string::va("usermaps/%s/%s.ff", mapname, mapname);
|
const auto filename = utils::string::va("usermaps\\%s\\%s.ff", mapname, mapname);
|
||||||
const auto hash = get_file_hash(filename);
|
const auto hash = get_file_hash(filename);
|
||||||
if (!hash.has_value() || hash.value() != usermap_hash)
|
if (!hash.has_value() || hash.value() != usermap_hash)
|
||||||
{
|
{
|
||||||
@ -338,7 +346,7 @@ namespace party
|
|||||||
utils::hook::detour net_out_of_band_print_hook;
|
utils::hook::detour net_out_of_band_print_hook;
|
||||||
void net_out_of_band_print_stub(game::netsrc_t sock, game::netadr_s* addr, const char* data)
|
void net_out_of_band_print_stub(game::netsrc_t sock, game::netadr_s* addr, const char* data)
|
||||||
{
|
{
|
||||||
if (!strstr(data, "loadingnewmap"))
|
if (!std::strstr(data, "loadingnewmap"))
|
||||||
{
|
{
|
||||||
return net_out_of_band_print_hook.invoke<void>(sock, addr, data);
|
return net_out_of_band_print_hook.invoke<void>(sock, addr, data);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user