Exemple #1
0
void CScreenJoin::JoinCurGame()
{
	// Get the currently selected game server...

	if (m_nSelectedServer >= m_cServerList.size())
		return;

	const CServerEntry &cServerAddr = m_cServerList[m_nSelectedServer];

	if (IsCurrentGame(cServerAddr.m_sAddress.c_str()))
	{
        HLOCALOBJ hPlayerObj = g_pLTClient->GetClientObject();
		if (g_pGameClientShell->IsWorldLoaded() && hPlayerObj)
		{
			ChangeState(eState_Inactive);
			g_pInterfaceMgr->ChangeState(GS_PLAYING);
		}
		return;
	}

	// Check the number of players to make sure it's not full
	// NYI

	// Check the version number
	// NYI

	// Check for password protection...
	// NYI

	if (!DoJoinGame(m_cServerList[m_nSelectedServer]))
	{
		ChangeState(eState_Inactive);
		g_pInterfaceMgr->LoadFailed();
		g_pInterfaceMgr->ConnectionFailed(0);
	}
}
void CFolderJoin::JoinCurGame(LTBOOL bPasswordSet)
{
	// Get the currently selected game server...

	CGameSpyServer* pGame = GetGameSpyClientMgr()->GetServerFromHandle(m_pCurServerHandle);
    if (!pGame) return;

	if (IsCurrentGame(pGame))
	{
        HLOCALOBJ hPlayerObj = g_pLTClient->GetClientObject();
		if (g_pGameClientShell->IsInWorld() && hPlayerObj)
		{
			g_pInterfaceMgr->ChangeState(GS_PLAYING);
		}
		return;
	}

	if (pGame->GetNumPlayers() >= pGame->GetMaxPlayers())
	{
        HSTRING hString = g_pLTClient->FormatString(IDS_SERVERFULL);
		g_pInterfaceMgr->ShowMessageBox(hString,LTMB_OK,LTNULL,LTNULL);
		g_pLTClient->FreeString(hString);
		return;
	}

	char sVer[16];
	sprintf(sVer,"%d.%.3d",GAME_HANDSHAKE_VER_MAJOR,(GAME_HANDSHAKE_VER_MINOR-1));
	char* sGameVer = pGame->GetStringValue("gamever");
	if (sGameVer && stricmp(sVer,sGameVer)!=0)
	{
        HSTRING hString = g_pLTClient->FormatString(IDS_SERVER_WRONGVERSION);
		g_pInterfaceMgr->ShowMessageBox(hString,LTMB_OK,LTNULL,LTNULL,g_pInterfaceResMgr->IsEnglish());
		g_pLTClient->FreeString(hString);
		return;
	}


	// Check for password protection...

	char* sPassword = pGame->GetStringValue("Password");
	if (sPassword && sPassword[0] != '\0')
	{
		if (bPasswordSet)
		{
			if (stricmp(m_szPassword, sPassword) != 0)
			{
                HSTRING hString = g_pLTClient->FormatString(IDS_ACCESSDENIED);
			    g_pInterfaceMgr->ShowMessageBox(hString,LTMB_OK,LTNULL,LTNULL);
				g_pLTClient->FreeString(hString);
				return;
			}
		}
		else
		{
			AskForPassword();
			return;
		}
	}

	if (!DoJoinGame(pGame))
	{
		g_pInterfaceMgr->LoadFailed();
		g_pInterfaceMgr->ConnectionFailed(nConnectError);
	}
}