diff --git a/src/Components/Modules/Download.cpp b/src/Components/Modules/Download.cpp index 23551e56..3abdf5d5 100644 --- a/src/Components/Modules/Download.cpp +++ b/src/Components/Modules/Download.cpp @@ -474,8 +474,8 @@ namespace Components static std::string mapnamePre; static json11::Json jsonList; - std::string mapname = Maps::GetUserMap()->getName(); - if (!Maps::GetUserMap()->isValid()) + std::string mapname = (Party::IsInUserMapLobby() ? Dvar::Var("ui_mapname").get() : Maps::GetUserMap()->getName()); + if (!Maps::GetUserMap()->isValid() && !Party::IsInUserMapLobby()) { mapnamePre.clear(); jsonList = std::vector(); @@ -607,7 +607,7 @@ namespace Components isMap = true; url = url.substr(4); - std::string mapname = Maps::GetUserMap()->getName(); + std::string mapname = (Party::IsInUserMapLobby() ? Dvar::Var("ui_mapname").get() : Maps::GetUserMap()->getName()); bool isValidFile = false; for (int i = 0; i < ARRAYSIZE(Maps::UserMapFiles); ++i) @@ -619,7 +619,7 @@ namespace Components } } - if (!Maps::GetUserMap()->isValid() || !isValidFile) + if ((!Maps::GetUserMap()->isValid() && !Party::IsInUserMapLobby()) || !isValidFile) { Download::Forbid(nc); return; diff --git a/src/Components/Modules/Maps.cpp b/src/Components/Modules/Maps.cpp index 098e1207..757c7a37 100644 --- a/src/Components/Modules/Maps.cpp +++ b/src/Components/Modules/Maps.cpp @@ -409,7 +409,7 @@ namespace Components Maps::UserMap.clear(); } - if (Utils::IO::DirectoryExists(Utils::String::VA("usermaps/%s", mapname)) && Utils::IO::FileExists(Utils::String::VA("usermaps/%s/%s.ff", mapname, mapname))) + if (Maps::IsUserMap(mapname)) { Maps::UserMap = Maps::UserMapContainer(mapname); Maps::UserMap.loadIwd(); @@ -710,6 +710,11 @@ namespace Components return false; } + bool Maps::IsUserMap(std::string mapname) + { + return Utils::IO::DirectoryExists(Utils::String::VA("usermaps/%s", mapname.data())) && Utils::IO::FileExists(Utils::String::VA("usermaps/%s/%s.ff", mapname.data(), mapname.data())); + } + Game::XAssetEntry* Maps::GetAssetEntryPool() { return *reinterpret_cast(0x48E6F4); diff --git a/src/Components/Modules/Maps.hpp b/src/Components/Modules/Maps.hpp index 6f43abf5..e2bdfe0c 100644 --- a/src/Components/Modules/Maps.hpp +++ b/src/Components/Modules/Maps.hpp @@ -65,6 +65,7 @@ namespace Components static Game::XAssetEntry* GetAssetEntryPool(); static bool IsCustomMap(); + static bool IsUserMap(std::string mapname); private: class DLC diff --git a/src/Components/Modules/Party.cpp b/src/Components/Modules/Party.cpp index 2059f435..2779c286 100644 --- a/src/Components/Modules/Party.cpp +++ b/src/Components/Modules/Party.cpp @@ -138,6 +138,16 @@ namespace Components return Utils::Hook::Call(0x4D5390)(dvar); } + bool Party::IsInLobby() + { + return (!Dvar::Var("sv_running").get() && Dvar::Var("party_enable").get() && Dvar::Var("party_host").get()); + } + + bool Party::IsInUserMapLobby() + { + return (Party::IsInLobby() && Maps::IsUserMap(Dvar::Var("ui_mapname").get())); + } + Party::Party() { static Game::dvar_t* partyEnable = Dvar::Register("party_enable", Dedicated::IsEnabled(), Game::dvar_flag::DVAR_FLAG_NONE, "Enable party system").get(); @@ -336,22 +346,26 @@ namespace Components info.set("securityLevel", Utils::String::VA("%i", Dvar::Var("sv_securityLevel").get())); info.set("sv_running", (Dvar::Var("sv_running").get() ? "1" : "0")); + // Ensure mapname is set + if (info.get("mapname").empty() || Party::IsInLobby()) + { + info.set("mapname", Dvar::Var("ui_mapname").get()); + } + if (Maps::GetUserMap()->isValid()) { info.set("usermaphash", Utils::String::VA("%i", Maps::GetUserMap()->getHash())); } + else if (Party::IsInUserMapLobby()) + { + info.set("usermaphash", Utils::String::VA("%i", Maps::GetUsermapHash(info.get("mapname")))); + } if (Dedicated::IsEnabled()) { info.set("sv_motd", Dvar::Var("sv_motd").get()); } - // Ensure mapname is set - if (info.get("mapname").empty() || (Dvar::Var("party_enable").get() && Dvar::Var("party_host").get() && !Dvar::Var("sv_running").get())) - { - info.set("mapname", Dvar::Var("ui_mapname").get()); - } - // Set matchtype // 0 - No match, connecting not possible // 1 - Party, use Steam_JoinLobby to connect diff --git a/src/Components/Modules/Party.hpp b/src/Components/Modules/Party.hpp index 8994ce0f..056c9acf 100644 --- a/src/Components/Modules/Party.hpp +++ b/src/Components/Modules/Party.hpp @@ -19,6 +19,9 @@ namespace Components static void ConnectError(std::string message); + static bool IsInUserMapLobby(); + static bool IsInLobby(); + static std::string GetMotd(); private: