Party Fix (#690)
This commit is contained in:
parent
dcf701562f
commit
165681f393
@ -400,31 +400,19 @@ namespace Components
|
|||||||
{
|
{
|
||||||
const Utils::InfoString info(data);
|
const Utils::InfoString info(data);
|
||||||
|
|
||||||
const auto _0 = gsl::finally([&]
|
|
||||||
{
|
|
||||||
ServerList::Insert(address, info);
|
|
||||||
Friends::UpdateServer(address, info.get("hostname"), info.get("mapname"));
|
|
||||||
});
|
|
||||||
|
|
||||||
// Handle connection
|
// Handle connection
|
||||||
if (!Container.valid)
|
if (Party::Container.valid)
|
||||||
{
|
{
|
||||||
return;
|
if (Party::Container.target == address)
|
||||||
}
|
|
||||||
|
|
||||||
if (Container.target == address)
|
|
||||||
{
|
{
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Invalidate handler for future packets
|
// Invalidate handler for future packets
|
||||||
Container.valid = false;
|
Party::Container.valid = false;
|
||||||
Container.info = info;
|
Party::Container.info = info;
|
||||||
|
|
||||||
Container.matchType = atoi(info.get("matchtype").data());
|
Party::Container.matchType = atoi(info.get("matchtype").data());
|
||||||
const auto securityLevel = static_cast<uint32_t>(std::strtol(info.get("securityLevel").data(), nullptr, 10));
|
auto securityLevel = static_cast<std::uint32_t>(atoi(info.get("securityLevel").data()));
|
||||||
bool isUsermap = !info.get("usermaphash").empty();
|
bool isUsermap = !info.get("usermaphash").empty();
|
||||||
const auto usermapHash = static_cast<uint32_t>(std::strtol(info.get("usermaphash").data(), nullptr, 10));
|
auto usermapHash = static_cast<std::uint32_t>(atoi(info.get("usermaphash").data()));
|
||||||
|
|
||||||
std::string mod = (*Game::fs_gameDirVar)->current.string;
|
std::string mod = (*Game::fs_gameDirVar)->current.string;
|
||||||
|
|
||||||
@ -440,59 +428,42 @@ namespace Components
|
|||||||
Download::SV_wwwBaseUrl.set("");
|
Download::SV_wwwBaseUrl.set("");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (info.get("challenge") != Container.challenge)
|
if (info.get("challenge") != Party::Container.challenge)
|
||||||
{
|
{
|
||||||
ConnectError("Invalid join response: Challenge mismatch.");
|
Party::ConnectError("Invalid join response: Challenge mismatch.");
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
else if (securityLevel > Auth::GetSecurityLevel())
|
||||||
if (securityLevel > Auth::GetSecurityLevel())
|
|
||||||
{
|
{
|
||||||
|
|
||||||
Command::Execute("closemenu popup_reconnectingtoparty");
|
Command::Execute("closemenu popup_reconnectingtoparty");
|
||||||
Auth::IncreaseSecurityLevel(securityLevel, "reconnect");
|
Auth::IncreaseSecurityLevel(securityLevel, "reconnect");
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
else if (!Party::Container.matchType)
|
||||||
if (!Container.matchType)
|
|
||||||
{
|
{
|
||||||
ConnectError("Server is not hosting a match.");
|
Party::ConnectError("Server is not hosting a match.");
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
else if (Party::Container.matchType > 2 || Party::Container.matchType < 0)
|
||||||
if (Container.matchType > 2 || Container.matchType < 0)
|
|
||||||
{
|
{
|
||||||
ConnectError("Invalid join response: Unknown matchtype");
|
Party::ConnectError("Invalid join response: Unknown matchtype");
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
else if (Party::Container.info.get("mapname").empty() || Party::Container.info.get("gametype").empty())
|
||||||
if (Container.info.get("mapname").empty() || Container.info.get("gametype").empty())
|
|
||||||
{
|
{
|
||||||
ConnectError("Invalid map or gametype.");
|
Party::ConnectError("Invalid map or gametype.");
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
else if (Party::Container.info.get("isPrivate") == "1"s && !Dvar::Var("password").get<std::string>().length())
|
||||||
if (Container.info.get("isPrivate") == "1"s && !Dvar::Var("password").get<std::string>().empty())
|
|
||||||
{
|
{
|
||||||
ConnectError("A password is required to join this server! Set it at the bottom of the serverlist.");
|
Party::ConnectError("A password is required to join this server! Set it at the bottom of the serverlist.");
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
else if (isUsermap && usermapHash != Maps::GetUsermapHash(info.get("mapname")))
|
||||||
if (isUsermap && usermapHash != Maps::GetUsermapHash(info.get("mapname")))
|
|
||||||
{
|
{
|
||||||
Command::Execute("closemenu popup_reconnectingtoparty");
|
Command::Execute("closemenu popup_reconnectingtoparty");
|
||||||
Download::InitiateMapDownload(info.get("mapname"), info.get("isPrivate") == "1"s);
|
Download::InitiateMapDownload(info.get("mapname"), info.get("isPrivate") == "1");
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
else if (!info.get("fs_game").empty() && Utils::String::ToLower(mod) != Utils::String::ToLower(info.get("fs_game")))
|
||||||
if (!info.get("fs_game").empty() && Utils::String::ToLower(mod) != Utils::String::ToLower(info.get("fs_game")))
|
|
||||||
{
|
{
|
||||||
Command::Execute("closemenu popup_reconnectingtoparty");
|
Command::Execute("closemenu popup_reconnectingtoparty");
|
||||||
Download::InitiateClientDownload(info.get("fs_game"), info.get("isPrivate") == "1"s);
|
Download::InitiateClientDownload(info.get("fs_game"), info.get("isPrivate") == "1"s);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
else if (!Dvar::Var("fs_game").get<std::string>().empty() && info.get("fs_game").empty())
|
||||||
if (*(*Game::fs_gameDirVar)->current.string && info.get("fs_game").empty())
|
|
||||||
{
|
{
|
||||||
Game::Dvar_SetString(*Game::fs_gameDirVar, "");
|
Game::Dvar_SetString(*Game::fs_gameDirVar, "");
|
||||||
|
|
||||||
@ -502,21 +473,18 @@ namespace Components
|
|||||||
}
|
}
|
||||||
|
|
||||||
Command::Execute("reconnect", false);
|
Command::Execute("reconnect", false);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
if (!Maps::CheckMapInstalled(Container.info.get("mapname"), true))
|
|
||||||
{
|
{
|
||||||
return;
|
if (!Maps::CheckMapInstalled(Party::Container.info.get("mapname"), true)) return;
|
||||||
}
|
|
||||||
|
|
||||||
Container.motd = info.get("sv_motd");
|
Party::Container.motd = info.get("sv_motd");
|
||||||
|
|
||||||
if (Container.matchType == 1) // Party
|
if (Party::Container.matchType == 1) // Party
|
||||||
{
|
{
|
||||||
// Send playlist request
|
// Send playlist request
|
||||||
Container.requestTime = Game::Sys_Milliseconds();
|
Party::Container.requestTime = Game::Sys_Milliseconds();
|
||||||
Container.awaitingPlaylist = true;
|
Party::Container.awaitingPlaylist = true;
|
||||||
Network::SendCommand(Party::Container.target, "getplaylist", Dvar::Var("password").get<std::string>());
|
Network::SendCommand(Party::Container.target, "getplaylist", Dvar::Var("password").get<std::string>());
|
||||||
|
|
||||||
// This is not a safe method
|
// This is not a safe method
|
||||||
@ -526,7 +494,7 @@ namespace Components
|
|||||||
Command::Execute("disconnect", true);
|
Command::Execute("disconnect", true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (Container.matchType == 2) // Match
|
else if (Party::Container.matchType == 2) // Match
|
||||||
{
|
{
|
||||||
int clients;
|
int clients;
|
||||||
int maxClients;
|
int maxClients;
|
||||||
@ -544,7 +512,7 @@ namespace Components
|
|||||||
|
|
||||||
if (clients >= maxClients)
|
if (clients >= maxClients)
|
||||||
{
|
{
|
||||||
ConnectError("@EXE_SERVERISFULL");
|
Party::ConnectError("@EXE_SERVERISFULL");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -553,9 +521,15 @@ namespace Components
|
|||||||
Game::Menus_CloseAll(Game::uiContext);
|
Game::Menus_CloseAll(Game::uiContext);
|
||||||
|
|
||||||
Game::_XSESSION_INFO hostInfo;
|
Game::_XSESSION_INFO hostInfo;
|
||||||
Game::CL_ConnectFromParty(0, &hostInfo, *Container.target.get(), 0, 0, Container.info.get("mapname").data(), Container.info.get("gametype").data());
|
Game::CL_ConnectFromParty(0, &hostInfo, *Party::Container.target.get(), 0, 0, Party::Container.info.get("mapname").data(), Party::Container.info.get("gametype").data());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ServerList::Insert(address, info);
|
||||||
|
Friends::UpdateServer(address, info.get("hostname"), info.get("mapname"));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user