[Download] Correctly download maps from lobby servers
This commit is contained in:
parent
012384987e
commit
390418e34e
@ -474,8 +474,8 @@ namespace Components
|
|||||||
static std::string mapnamePre;
|
static std::string mapnamePre;
|
||||||
static json11::Json jsonList;
|
static json11::Json jsonList;
|
||||||
|
|
||||||
std::string mapname = Maps::GetUserMap()->getName();
|
std::string mapname = (Party::IsInUserMapLobby() ? Dvar::Var("ui_mapname").get<std::string>() : Maps::GetUserMap()->getName());
|
||||||
if (!Maps::GetUserMap()->isValid())
|
if (!Maps::GetUserMap()->isValid() && !Party::IsInUserMapLobby())
|
||||||
{
|
{
|
||||||
mapnamePre.clear();
|
mapnamePre.clear();
|
||||||
jsonList = std::vector<json11::Json>();
|
jsonList = std::vector<json11::Json>();
|
||||||
@ -607,7 +607,7 @@ namespace Components
|
|||||||
isMap = true;
|
isMap = true;
|
||||||
url = url.substr(4);
|
url = url.substr(4);
|
||||||
|
|
||||||
std::string mapname = Maps::GetUserMap()->getName();
|
std::string mapname = (Party::IsInUserMapLobby() ? Dvar::Var("ui_mapname").get<std::string>() : Maps::GetUserMap()->getName());
|
||||||
|
|
||||||
bool isValidFile = false;
|
bool isValidFile = false;
|
||||||
for (int i = 0; i < ARRAYSIZE(Maps::UserMapFiles); ++i)
|
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);
|
Download::Forbid(nc);
|
||||||
return;
|
return;
|
||||||
|
@ -409,7 +409,7 @@ namespace Components
|
|||||||
Maps::UserMap.clear();
|
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 = Maps::UserMapContainer(mapname);
|
||||||
Maps::UserMap.loadIwd();
|
Maps::UserMap.loadIwd();
|
||||||
@ -710,6 +710,11 @@ namespace Components
|
|||||||
return false;
|
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()
|
Game::XAssetEntry* Maps::GetAssetEntryPool()
|
||||||
{
|
{
|
||||||
return *reinterpret_cast<Game::XAssetEntry**>(0x48E6F4);
|
return *reinterpret_cast<Game::XAssetEntry**>(0x48E6F4);
|
||||||
|
@ -65,6 +65,7 @@ namespace Components
|
|||||||
|
|
||||||
static Game::XAssetEntry* GetAssetEntryPool();
|
static Game::XAssetEntry* GetAssetEntryPool();
|
||||||
static bool IsCustomMap();
|
static bool IsCustomMap();
|
||||||
|
static bool IsUserMap(std::string mapname);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
class DLC
|
class DLC
|
||||||
|
@ -138,6 +138,16 @@ namespace Components
|
|||||||
return Utils::Hook::Call<DWORD(char*)>(0x4D5390)(dvar);
|
return Utils::Hook::Call<DWORD(char*)>(0x4D5390)(dvar);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Party::IsInLobby()
|
||||||
|
{
|
||||||
|
return (!Dvar::Var("sv_running").get<bool>() && Dvar::Var("party_enable").get<bool>() && Dvar::Var("party_host").get<bool>());
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Party::IsInUserMapLobby()
|
||||||
|
{
|
||||||
|
return (Party::IsInLobby() && Maps::IsUserMap(Dvar::Var("ui_mapname").get<const char*>()));
|
||||||
|
}
|
||||||
|
|
||||||
Party::Party()
|
Party::Party()
|
||||||
{
|
{
|
||||||
static Game::dvar_t* partyEnable = Dvar::Register<bool>("party_enable", Dedicated::IsEnabled(), Game::dvar_flag::DVAR_FLAG_NONE, "Enable party system").get<Game::dvar_t*>();
|
static Game::dvar_t* partyEnable = Dvar::Register<bool>("party_enable", Dedicated::IsEnabled(), Game::dvar_flag::DVAR_FLAG_NONE, "Enable party system").get<Game::dvar_t*>();
|
||||||
@ -336,22 +346,26 @@ namespace Components
|
|||||||
info.set("securityLevel", Utils::String::VA("%i", Dvar::Var("sv_securityLevel").get<int>()));
|
info.set("securityLevel", Utils::String::VA("%i", Dvar::Var("sv_securityLevel").get<int>()));
|
||||||
info.set("sv_running", (Dvar::Var("sv_running").get<bool>() ? "1" : "0"));
|
info.set("sv_running", (Dvar::Var("sv_running").get<bool>() ? "1" : "0"));
|
||||||
|
|
||||||
|
// Ensure mapname is set
|
||||||
|
if (info.get("mapname").empty() || Party::IsInLobby())
|
||||||
|
{
|
||||||
|
info.set("mapname", Dvar::Var("ui_mapname").get<const char*>());
|
||||||
|
}
|
||||||
|
|
||||||
if (Maps::GetUserMap()->isValid())
|
if (Maps::GetUserMap()->isValid())
|
||||||
{
|
{
|
||||||
info.set("usermaphash", Utils::String::VA("%i", Maps::GetUserMap()->getHash()));
|
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())
|
if (Dedicated::IsEnabled())
|
||||||
{
|
{
|
||||||
info.set("sv_motd", Dvar::Var("sv_motd").get<std::string>());
|
info.set("sv_motd", Dvar::Var("sv_motd").get<std::string>());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ensure mapname is set
|
|
||||||
if (info.get("mapname").empty() || (Dvar::Var("party_enable").get<bool>() && Dvar::Var("party_host").get<bool>() && !Dvar::Var("sv_running").get<bool>()))
|
|
||||||
{
|
|
||||||
info.set("mapname", Dvar::Var("ui_mapname").get<const char*>());
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set matchtype
|
// Set matchtype
|
||||||
// 0 - No match, connecting not possible
|
// 0 - No match, connecting not possible
|
||||||
// 1 - Party, use Steam_JoinLobby to connect
|
// 1 - Party, use Steam_JoinLobby to connect
|
||||||
|
@ -19,6 +19,9 @@ namespace Components
|
|||||||
|
|
||||||
static void ConnectError(std::string message);
|
static void ConnectError(std::string message);
|
||||||
|
|
||||||
|
static bool IsInUserMapLobby();
|
||||||
|
static bool IsInLobby();
|
||||||
|
|
||||||
static std::string GetMotd();
|
static std::string GetMotd();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
Loading…
Reference in New Issue
Block a user