More usermap fixes
This commit is contained in:
parent
c0c0d40533
commit
803973d29e
@ -232,7 +232,7 @@ namespace fastfiles
|
|||||||
}
|
}
|
||||||
|
|
||||||
utils::hook::detour sys_createfile_hook;
|
utils::hook::detour sys_createfile_hook;
|
||||||
HANDLE sys_create_file_stub(game::Sys_Folder folder, const char* base_filename)
|
HANDLE sys_create_file(game::Sys_Folder folder, const char* base_filename, bool ignore_usermap)
|
||||||
{
|
{
|
||||||
const auto* fs_basepath = game::Dvar_FindVar("fs_basepath");
|
const auto* fs_basepath = game::Dvar_FindVar("fs_basepath");
|
||||||
const auto* fs_game = game::Dvar_FindVar("fs_game");
|
const auto* fs_game = game::Dvar_FindVar("fs_game");
|
||||||
@ -264,11 +264,14 @@ namespace fastfiles
|
|||||||
return handle;
|
return handle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!ignore_usermap)
|
||||||
|
{
|
||||||
const auto usermap = find_usermap(name);
|
const auto usermap = find_usermap(name);
|
||||||
if (usermap != INVALID_HANDLE_VALUE)
|
if (usermap != INVALID_HANDLE_VALUE)
|
||||||
{
|
{
|
||||||
return usermap;
|
return usermap;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (name.ends_with(".ff"))
|
if (name.ends_with(".ff"))
|
||||||
{
|
{
|
||||||
@ -278,6 +281,11 @@ namespace fastfiles
|
|||||||
return handle;
|
return handle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
HANDLE sys_create_file_stub(game::Sys_Folder folder, const char* base_filename)
|
||||||
|
{
|
||||||
|
return sys_create_file(folder, base_filename, false);
|
||||||
|
}
|
||||||
|
|
||||||
utils::hook::detour db_file_exists_hook;
|
utils::hook::detour db_file_exists_hook;
|
||||||
bool db_file_exists_stub(const char* file, int a2)
|
bool db_file_exists_stub(const char* file, int a2)
|
||||||
{
|
{
|
||||||
@ -396,11 +404,11 @@ namespace fastfiles
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool exists(const std::string& zone)
|
bool exists(const std::string& zone, bool ignore_usermap)
|
||||||
{
|
{
|
||||||
const auto is_localized = game::DB_IsLocalized(zone.data());
|
const auto is_localized = game::DB_IsLocalized(zone.data());
|
||||||
const auto handle = game::Sys_CreateFile((is_localized ? game::SF_ZONE_LOC : game::SF_ZONE),
|
const auto handle = sys_create_file((is_localized ? game::SF_ZONE_LOC : game::SF_ZONE),
|
||||||
utils::string::va("%s.ff", zone.data()));
|
utils::string::va("%s.ff", zone.data()), ignore_usermap);
|
||||||
|
|
||||||
if (handle != INVALID_HANDLE_VALUE)
|
if (handle != INVALID_HANDLE_VALUE)
|
||||||
{
|
{
|
||||||
@ -474,15 +482,7 @@ namespace fastfiles
|
|||||||
|
|
||||||
bool is_stock_map(const std::string& name)
|
bool is_stock_map(const std::string& name)
|
||||||
{
|
{
|
||||||
for (auto map = &game::maps[0]; map->unk; ++map)
|
return fastfiles::exists(name, true);
|
||||||
{
|
|
||||||
if (map->name == name)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class component final : public component_interface
|
class component final : public component_interface
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
namespace fastfiles
|
namespace fastfiles
|
||||||
{
|
{
|
||||||
bool exists(const std::string& zone);
|
bool exists(const std::string& zone, bool ignore_usermap = false);
|
||||||
|
|
||||||
std::string get_current_fastfile();
|
std::string get_current_fastfile();
|
||||||
|
|
||||||
|
@ -151,10 +151,14 @@ namespace party
|
|||||||
|
|
||||||
utils::hook::detour cl_disconnect_hook;
|
utils::hook::detour cl_disconnect_hook;
|
||||||
|
|
||||||
void cl_disconnect_stub(int showMainMenu) // possibly bool
|
void cl_disconnect_stub(int show_main_menu) // possibly bool
|
||||||
{
|
{
|
||||||
party::clear_sv_motd();
|
party::clear_sv_motd();
|
||||||
cl_disconnect_hook.invoke<void>(showMainMenu);
|
if (!game::VirtualLobby_Loaded())
|
||||||
|
{
|
||||||
|
fastfiles::clear_usermap();
|
||||||
|
}
|
||||||
|
cl_disconnect_hook.invoke<void>(show_main_menu);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::optional<std::string> get_file_hash(const std::string& file)
|
std::optional<std::string> get_file_hash(const std::string& file)
|
||||||
@ -288,7 +292,7 @@ namespace party
|
|||||||
catch (const std::exception& e)
|
catch (const std::exception& e)
|
||||||
{
|
{
|
||||||
menu_error(e.what());
|
menu_error(e.what());
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@ -301,11 +305,11 @@ namespace party
|
|||||||
const std::string usermap_hash = game::MSG_ReadStringLine(msg,
|
const std::string usermap_hash = game::MSG_ReadStringLine(msg,
|
||||||
buffer, static_cast<unsigned int>(sizeof(buffer)));
|
buffer, static_cast<unsigned int>(sizeof(buffer)));
|
||||||
|
|
||||||
if (!fastfiles::is_stock_map(mapname))
|
if (!game::SV_Loaded() && !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() || (usermap_hash.empty() || hash.value() != usermap_hash))
|
||||||
{
|
{
|
||||||
command::execute("disconnect");
|
command::execute("disconnect");
|
||||||
scheduler::once([]
|
scheduler::once([]
|
||||||
@ -837,13 +841,15 @@ namespace party
|
|||||||
|
|
||||||
if (!fastfiles::is_stock_map(mapname))
|
if (!fastfiles::is_stock_map(mapname))
|
||||||
{
|
{
|
||||||
const auto hash = get_file_hash(utils::string::va("usermaps/%s/%s.ff", mapname.data(), mapname.data()));
|
const auto hash = get_file_hash(
|
||||||
|
utils::string::va("usermaps\\%s\\%s.ff", mapname.data(), mapname.data()));
|
||||||
if (hash.has_value())
|
if (hash.has_value())
|
||||||
{
|
{
|
||||||
info.set("usermaphash", hash.value());
|
info.set("usermaphash", hash.value());
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto load_file_hash = get_file_hash(utils::string::va("usermaps/%s/%s_load.ff", mapname.data(), mapname.data()));
|
const auto load_file_hash = get_file_hash(
|
||||||
|
utils::string::va("usermaps\\%s\\%s_load.ff", mapname.data(), mapname.data()));
|
||||||
if (load_file_hash.has_value())
|
if (load_file_hash.has_value())
|
||||||
{
|
{
|
||||||
info.set("usermaploadhash", load_file_hash.value());
|
info.set("usermaploadhash", load_file_hash.value());
|
||||||
|
@ -180,4 +180,9 @@ namespace utils::string
|
|||||||
if (!exact && text.find(input) != std::string::npos) return true;
|
if (!exact && text.find(input) != std::string::npos) return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool is_numeric(const std::string& text)
|
||||||
|
{
|
||||||
|
return std::to_string(atoi(text.data())) == text;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -99,4 +99,6 @@ namespace utils::string
|
|||||||
std::string replace(std::string str, const std::string& from, const std::string& to);
|
std::string replace(std::string str, const std::string& from, const std::string& to);
|
||||||
|
|
||||||
bool match_compare(const std::string& input, const std::string& text, const bool exact);
|
bool match_compare(const std::string& input, const std::string& text, const bool exact);
|
||||||
|
|
||||||
|
bool is_numeric(const std::string& text);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user