Skip to content
Permalink
Browse files

Addendum to 779d6e0 (Fixed joining a custom server due to minimum cli…

…ent requirements)
  • Loading branch information...
ccw808 committed Jun 30, 2019
1 parent 779d6e0 commit b65e6b0a4423f9e330932df501601ad9fed03489
@@ -768,8 +768,10 @@ bool MinClientReqCheck(CScriptArgReader& argStream, const char* szVersionReq, co
{
if (pResource->GetMinClientReq() < szVersionReq)
{
#if MTASA_VERSION_TYPE == VERSION_TYPE_RELEASE
if (szReason)
argStream.SetVersionWarning(szVersionReq, "client", szReason);
#endif
return false;
}
}
@@ -1705,10 +1705,8 @@ void CGame::Packet_PlayerJoinData(CPlayerJoinDataPacket& Packet)
pPlayer->SetSerial(strExtra, 1);
pPlayer->SetPlayerVersion(strPlayerVersion);

// Only do min client version checks if not a custom build or server has a build number
#if (MTASA_VERSION_TYPE > VERSION_TYPE_CUSTOM) || (MTASA_VERSION_BUILD > 0)
// Check if client must update
if (IsBelowMinimumClient(pPlayer->GetPlayerVersion()))
if (IsBelowMinimumClient(pPlayer->GetPlayerVersion()) && !pPlayer->ShouldIgnoreMinClientVersionChecks())
{
// Tell the console
CLogger::LogPrintf("CONNECT: %s failed to connect (Client version is below minimum) (%s)\n", szNick,
@@ -1721,7 +1719,7 @@ void CGame::Packet_PlayerJoinData(CPlayerJoinDataPacket& Packet)
}

// Check if client should optionally update
if (Packet.IsOptionalUpdateInfoRequired() && IsBelowRecommendedClient(pPlayer->GetPlayerVersion()))
if (Packet.IsOptionalUpdateInfoRequired() && IsBelowRecommendedClient(pPlayer->GetPlayerVersion()) && !pPlayer->ShouldIgnoreMinClientVersionChecks())
{
// Tell the console
CLogger::LogPrintf("CONNECT: %s advised to update (Client version is below recommended) (%s)\n", szNick,
@@ -1732,7 +1730,6 @@ void CGame::Packet_PlayerJoinData(CPlayerJoinDataPacket& Packet)
DisconnectPlayer(this, *pPlayer, "");
return;
}
#endif

// Check the serial for validity
if (CBan* pBan = m_pBanManager->GetBanFromSerial(pPlayer->GetSerial().c_str()))
@@ -206,6 +206,16 @@ void CPlayer::SetNick(const char* szNick)
m_strNick.AssignLeft(szNick, MAX_PLAYER_NICK_LENGTH);
}

// Ignore min client version checks if is a custom build and both player and server have build number of 0
bool CPlayer::ShouldIgnoreMinClientVersionChecks()
{
#if (MTASA_VERSION_TYPE == VERSION_TYPE_CUSTOM) && (MTASA_VERSION_BUILD == 0)
if (GetPlayerVersion().GetBuildNumber() == 0)
return true;
#endif
return false;
}

const char* CPlayer::GetSourceIP()
{
if (m_strIP.empty())
@@ -95,6 +95,7 @@ class CPlayer : public CPed, public CClient
void SetBitStreamVersion(unsigned short usBitStreamVersion) { m_usBitStreamVersion = usBitStreamVersion; };
void SetPlayerVersion(const CMtaVersion& strPlayerVersion);
const CMtaVersion& GetPlayerVersion() { return m_strPlayerVersion; };
bool ShouldIgnoreMinClientVersionChecks();

bool IsMuted() { return m_bIsMuted; };
void SetMuted(bool bSetMuted) { m_bIsMuted = bSetMuted; };
@@ -691,7 +691,7 @@ bool CResource::GetCompatibilityStatus(SString& strOutStatus)
{
uint uiNumIncompatiblePlayers = 0;
for (std::list<CPlayer*>::const_iterator iter = g_pGame->GetPlayerManager()->IterBegin(); iter != g_pGame->GetPlayerManager()->IterEnd(); iter++)
if ((*iter)->IsJoined() && m_strMinClientReqFromMetaXml > (*iter)->GetPlayerVersion())
if ((*iter)->IsJoined() && m_strMinClientReqFromMetaXml > (*iter)->GetPlayerVersion() && !(*iter)->ShouldIgnoreMinClientVersionChecks())
uiNumIncompatiblePlayers++;

if (uiNumIncompatiblePlayers > 0)

0 comments on commit b65e6b0

Please sign in to comment.
You can’t perform that action at this time.