コード例 #1
0
ファイル: MissionMgr.cpp プロジェクト: rickyharis39/nolf2
bool CMissionMgr::HandleExitLevel( ILTMessage_Read& msg  )
{
	msg.ReadString( m_sNewWorldName.GetBuffer( MAX_PATH ), MAX_PATH );
	m_sNewWorldName.ReleaseBuffer( );
	m_bExitingMission = msg.Readbool( );
	m_bRestoringLevel = msg.Readbool( );
	m_bServerWaiting  = msg.Readbool( );

	int nMissionId, nLevel;

	// Check if this is a valid mission level.
	if (g_pMissionButeMgr->IsMissionLevel( m_sNewWorldName, nMissionId, nLevel))
	{
		m_nNewMission = nMissionId;
		m_nNewLevel = nLevel;
	}
	else
	{
		m_nNewMission = -1;
		m_nNewLevel = -1;
	}

	//m_bServerWaiting should only be false in the case where we are loading a game,
	if (!m_bServerWaiting)
	{
		//  if we are the host, we are already on the preload screen
		if (g_pClientMultiplayerMgr->IsConnectedToRemoteServer( ) )
			g_pInterfaceMgr->ChangeState(GS_LOADINGLEVEL);
		return true;

	}


	m_bNewMission = m_bExitingMission;

	// Check if we didn't get a new world.
	if( m_sNewWorldName.IsEmpty( ))
	{
		// Just go back to the main menu.
		g_pInterfaceMgr->ChangeState( GS_SCREEN );
		return true;
	}

	// Consider ourselves to be exiting.
	m_bExitingLevel = true;

	// Change to the exiting level state.
	g_pInterfaceMgr->ChangeState(GS_EXITINGLEVEL);

	return true;
}
コード例 #2
0
ファイル: ScmdServer.cpp プロジェクト: rickyharis39/nolf2
bool ScmdServer_Impl::HandleBanClient( HCLIENT hClient, ILTMessage_Read& msg )
{
	// Read the id of the client to boot.
	uint16 nClientId = msg.Readuint16( );

	bool bOk = true;
	HCLIENT hBanClient = g_pLTServer->GetClientHandle( nClientId );
	if( !hBanClient )
	{
		bOk = false;
	}

	if( bOk )
	{
		uint8 aClientIP[4];
		uint16 nPort;
		g_pLTServer->GetClientAddr( hBanClient, aClientIP, &nPort );

		BanIPMgr::ClientIP clientIP = { aClientIP[0], aClientIP[1], aClientIP[2], aClientIP[3] };

		// Ban the client.
		bOk = BanIPMgr::Instance( ).AddBan( clientIP );
	}

	// Tell the client if it worked.
	ScmdCommandStatus eScmdCommandStatus = ( bOk ) ? kScmdCommandStatusOk : kScmdCommandStatusFailed;
	if( !SendStatusMessage( hClient, kScmdCommandBanClient, eScmdCommandStatus ))
		return false;

	return true;
}
コード例 #3
0
ファイル: ScmdServer.cpp プロジェクト: rickyharis39/nolf2
bool ScmdServer_Impl::HandleSetMission( HCLIENT hClient, ILTMessage_Read& msg )
{
	// Read the mission index desired.
	uint8 nMissionIndex = msg.Readuint8( );

	// Check to make sure the mission index is within range.
	Campaign& campaign = g_pServerMissionMgr->GetCampaign( );
	if( nMissionIndex >= campaign.size( ))
	{
		// Tell the client it failed.
		if( !SendStatusMessage( hClient, kScmdCommandSetMission, kScmdCommandStatusFailed ))
			return false;

		return true;
	}

	// Tell the client it worked.
	if( !SendStatusMessage( hClient, kScmdCommandSetMission, kScmdCommandStatusOk ))
		return false;

	// Do the switch.
	g_pServerMissionMgr->SwitchToCampaignIndex( nMissionIndex );

	return true;
}
コード例 #4
0
bool CServerMissionMgr::OnMessage( HCLIENT hSender, ILTMessage_Read& msg )
{
	msg.SeekTo(0);
	uint8 messageID = msg.Readuint8();

	switch (messageID)
	{
		case MID_START_GAME:			HandleStartGame			( hSender, msg );	return true;
		case MID_START_LEVEL:			HandleStartLevel		( hSender, msg );	return true;
		case MID_EXIT_LEVEL:			HandleExitLevel			( hSender, msg );	return true;
		case MID_MULTIPLAYER_OPTIONS:	HandleMultiplayerOptions( hSender, msg );	return true;

		default:
			break;
	}

	return false;
}
コード例 #5
0
ファイル: ScmdServer.cpp プロジェクト: rickyharis39/nolf2
bool ScmdServer_Impl::OnMessage( HCLIENT hClient, ILTMessage_Read& msg )
{
	// Make sure we're initialized.
	if( !m_bInitialized )
		return false;

	msg.SeekTo( 0 );
	uint8 messageID = msg.Readuint8( );

	switch( messageID )
	{
		case MID_SCMD:			
			HandleScmdMessage( hClient, msg );	
			return true;

		default:
			break;
	}

	return false;
}
コード例 #6
0
bool CPhysicsCollisionSystemFX::Update( )
{
	if( !CSpecialFX::Update( ))
		return false;

	ILTMessage_Read *pMsg = m_cInitMsg->Clone( );

	// Read the message to see if all dependent objects are available...
	uint32 nNumObjects = pMsg->Readuint32( );

	for( uint32 nObject = 0; nObject < nNumObjects; ++nObject )
	{
		// If any of the objects are invalid we can't create the system.
		// Try again next update...
		if( pMsg->ReadObject( ) == INVALID_HOBJECT )
			return true;
	}

	CreatePhysicsCollisionSystem( );
	
	// After the collision system has been setup this object is no longer needed...
	return false;
}
コード例 #7
0
ファイル: ScmdServer.cpp プロジェクト: rickyharis39/nolf2
bool ScmdServer_Impl::HandleAddBan( HCLIENT hClient, ILTMessage_Read& msg )
{
	// Read the IP.
	char szBanIP[16];
	msg.ReadString( szBanIP, ARRAY_LEN( szBanIP ));

	bool bSuccess = BanIPMgr::Instance( ).AddBan( szBanIP );

	// Tell the client if it worked or not.
	if( !SendStatusMessage( hClient, kScmdCommandAddBan, ( bSuccess ) ? kScmdCommandStatusOk : 
		kScmdCommandStatusFailed ))
		return false;

	return true;
}
コード例 #8
0
ファイル: ScmdServer.cpp プロジェクト: rickyharis39/nolf2
bool ScmdServer_Impl::HandleBootId( HCLIENT hClient, ILTMessage_Read& msg )
{
	// Read the id of the client to boot.
	uint16 nClientId = msg.Readuint16( );

	// Boot the client.
	bool bBooted = BootClient( true, nClientId, "" );

	// Tell the client if it worked.
	ScmdCommandStatus eScmdCommandStatus = ( bBooted ) ? kScmdCommandStatusOk : kScmdCommandStatusFailed;
	if( !SendStatusMessage( hClient, kScmdCommandBootId, eScmdCommandStatus ))
		return false;

	return true;
}
コード例 #9
0
ファイル: ScmdServer.cpp プロジェクト: rickyharis39/nolf2
bool ScmdServer_Impl::HandleBootName( HCLIENT hClient, ILTMessage_Read& msg )
{
	// Read the name of the player to boot.
	char szPlayerName[MAX_PLAYER_NAME];
	msg.ReadString( szPlayerName, ARRAY_LEN( szPlayerName ));

	// Boot the client.
	bool bBooted = BootClient( false, 0, szPlayerName );

	// Tell the client if it worked.
	ScmdCommandStatus eScmdCommandStatus = ( bBooted ) ? kScmdCommandStatusOk : kScmdCommandStatusFailed;
	if( !SendStatusMessage( hClient, kScmdCommandBootName, eScmdCommandStatus ))
		return false;

	return true;
}
コード例 #10
0
ファイル: ScmdServer.cpp プロジェクト: rickyharis39/nolf2
bool ScmdServer_Impl::HandleLogin( HCLIENT hClient, ILTMessage_Read& msg )
{
	// Check if we're already controlled by an admin.
	if( m_eAdminControl != kAdminControlNone )
	{
		if( !SendStatusMessage( hClient, kScmdCommandLogin, kScmdCommandStatusAdminAlreadyLoggedIn ))
			return false;

		return true;
	}

	// Read the password they sent in.
	uint32 nHashedPassword = msg.Readuint32( );

	// Read the current password.
	uint32 nCurrentHashedPassword = str_Hash( m_sPassword.c_str( ));

	// Make sure the hashed values match.
	if( nCurrentHashedPassword != nHashedPassword )
	{
		if( !SendStatusMessage( hClient, kScmdCommandLogin, kScmdCommandStatusIncorrectPassword ))
			return false;

		return true;
	}

	// Admin is now controlled.
	m_eAdminControl = ( hClient ) ? kAdminControlClient : kAdminControlServerapp;

	// This is our admin.  It will be NULL for a standalone server.
	m_hAdminClient = hClient;

	// If the admin was just taken by a client, then tell all the clients.
	if( m_eAdminControl == kAdminControlClient )
	{
		CPlayerObj* pPlayerObj = ( CPlayerObj* )g_pLTServer->GetClientUserData( hClient );
		g_pGameServerShell->SendPlayerInfoMsgToClients( NULL, pPlayerObj, MID_PI_UPDATE );
	}

	// Tell the client it worked.
	if( !SendStatusMessage( hClient, kScmdCommandLogin, kScmdCommandStatusOk ))
		return false;

	return true;
}
コード例 #11
0
ファイル: ServerUtilities.cpp プロジェクト: Arc0re/lithtech
//////////////////////////////////////////////////////////////////////////
// Function name   : SendToClientsExcept
// Description     : Sends a message to all clients except the one specified.
// Return type     : LTRESULT - LT_OK on success. Will stop on failure.
// Argument        : ILTMessage_Read& msg - message to send.
// Argument        : HCLIENT hExceptClient - The client to skip.
// Argument        : uint32 nFlags - message flags.
//////////////////////////////////////////////////////////////////////////
LTRESULT SendToClientsExcept( ILTMessage_Read& msg, HCLIENT hExceptClient, uint32 nFlags )
{
	ServerConnectionMgr::GameClientDataList::iterator iter = ServerConnectionMgr::Instance( ).GetGameClientDataList( ).begin( );
	for( ; iter != ServerConnectionMgr::Instance( ).GetGameClientDataList( ).end( ); iter++ )
	{
		GameClientData* pGameClientData = *iter;
		if( pGameClientData->GetClient() == hExceptClient )
			continue;

		LTRESULT hRes = g_pLTServer->SendToClient( &msg, pGameClientData->GetClient(), nFlags );
		if( hRes != LT_OK )
			return hRes;

		// Start over.
		msg.Seek( 0 );
	}

	return LT_OK;
}
コード例 #12
0
bool CServerMissionMgr::Load( ILTMessage_Read& msg, uint32 dwSaveFlags )
{
	msg.ReadString( m_sCampaignFile.GetBuffer( MAX_PATH ), MAX_PATH );
	m_sCampaignFile.ReleaseBuffer( );

	m_Campaign.clear( );
	int nNumCampaignEntries = msg.Readuint8( );
	for( int nCampaignIndex = 0; nCampaignIndex < nNumCampaignEntries; ++nCampaignIndex )
	{
		m_Campaign.push_back( msg.Readuint8( ));
	}
	m_nCurCampaignIndex = msg.Readuint8( );

	ServerMissionSettings ss = m_ServerSettings;
	ss.m_bUseSkills = msg.Readbool();
	ss.m_bFriendlyFire = msg.Readbool();
	ss.m_nMPDifficulty = msg.Readuint8();
	ss.m_fPlayerDiffFactor = msg.Readfloat();
	SetServerSettings(ss);

	

	return true;
}
コード例 #13
0
ファイル: ScmdServer.cpp プロジェクト: rickyharis39/nolf2
bool ScmdServer_Impl::HandleRemoveBan( HCLIENT hClient, ILTMessage_Read& msg )
{
	// Read the banid.
	uint8 nBanId = msg.Readuint8( );

	bool bOk = true;

	// Index into the ban list.
	BanIPMgr::BanList const& banList = BanIPMgr::Instance( ).GetBanList( );

	// Make sure the id is in range.
	if( nBanId >= banList.size( ))
	{
		bOk = false;
	}

	if( bOk )
	{
		// Index into ban list and remove the ban.
		BanIPMgr::BanList::const_iterator iter = banList.begin( );
		for( uint8 nId = 0; iter != banList.end( ); iter++, nId++ )
		{
			if( nId == nBanId )
			{
				BanIPMgr::ClientIP const& clientIP = *iter;
				bOk = BanIPMgr::Instance( ).RemoveBan( clientIP );
				break;
			}
		}
	}

	// Tell the client if it worked or not.
	if( !SendStatusMessage( hClient, kScmdCommandRemoveBan, ( bOk ) ? kScmdCommandStatusOk : 
		kScmdCommandStatusFailed ))
		return false;

	return true;
}
コード例 #14
0
bool CServerMissionMgr::HandleStartLevel( HCLIENT hSender, ILTMessage_Read& msg )
{
	char szStartLevel[MAX_PATH];

	msg.ReadString( szStartLevel, ARRAY_LEN( szStartLevel ));

	// Starting level from scratch, so this is a new mission for us.
	m_bNewMission = true;

	// Setup mission based on level.
	if( !SetMissionBasedOnLevel( szStartLevel ))
		return false;

	// Setup the campaign index.
	if( !m_bCustomLevel )
		m_nCurCampaignIndex = FindNextCampaignIndex( -1, m_nCurrentMission );

	// Load the level.
	if( !g_pServerSaveLoadMgr->LoadNewLevel( szStartLevel ))
		return false;

	return true;
}
コード例 #15
0
ファイル: ScmdServer.cpp プロジェクト: rickyharis39/nolf2
bool ScmdServer_Impl::HandleScmdMessage( HCLIENT hClient, ILTMessage_Read& msg )
{
	// Check if SCMD commands are not allowed.
	if( !m_bAllowScmdCommands )
	{
		return true;
	}

	// Read the scmd command.
	ScmdCommand eScmdCommand = ( ScmdCommand )msg.Readuint8( );

	// Check if we're not controlled by an admin.  Since Login is the only
	// command you can send without being logged in, it has special handling.
	if( eScmdCommand != kScmdCommandLogin &&
		( m_eAdminControl == kAdminControlNone ) ||
		( m_eAdminControl == kAdminControlClient && hClient != m_hAdminClient ) ||
		( m_eAdminControl == kAdminControlServerapp && hClient != NULL ))
	{
		// Doesn't have privileges.
		SendStatusMessage( hClient, eScmdCommand, kScmdCommandStatusNotLoggedIn );
		return false;
	}


	switch( eScmdCommand )
	{
		case kScmdCommandLogin:
			return HandleLogin( hClient, msg );
			break;

		case kScmdCommandLogout:
			return HandleLogout( hClient, msg );
			break;

		case kScmdCommandListClients:
			return HandleListClients( hClient, msg );
			break;

		case kScmdCommandListMissions:
			return HandleListMissions( hClient, msg );
			break;

		case kScmdCommandNextMission:
			return HandleNextMission( hClient, msg );
			break;

		case kScmdCommandNextRound:
			return HandleNextRound( hClient, msg );
			break;

		case kScmdCommandSetMission:
			return HandleSetMission( hClient, msg );
			break;

		case kScmdCommandBootName:
			return HandleBootName( hClient, msg );
			break;

		case kScmdCommandBootId:
			return HandleBootId( hClient, msg );
			break;

		case kScmdCommandAddBan:
			return HandleAddBan( hClient, msg );
			break;

		case kScmdCommandRemoveBan:
			return HandleRemoveBan( hClient, msg );
			break;

		case kScmdCommandListBans:
			return HandleListBans( hClient, msg );
			break;

		case kScmdCommandBanClient:
			return HandleBanClient( hClient, msg );
			break;

		case kScmdCommandListGameOptions:
			return HandleListGameOptions( hClient, msg );
			break;

		case kScmdCommandSetGameOption:
			return HandleSetGameOption( hClient, msg );
			break;

	}

	return false;
}
コード例 #16
0
ファイル: ScmdServer.cpp プロジェクト: rickyharis39/nolf2
bool ScmdServer_Impl::HandleSetGameOption( HCLIENT hClient, ILTMessage_Read& msg )
{
	bool bOk = true;

	// Get the game option they are setting.
	uint8 nGameOption = msg.Readuint8( );

	// Read in the value.
	char szVal[256];
	msg.ReadString( szVal, ARRAY_LEN( szVal ));

	ServerMissionSettings sms = g_pServerMissionMgr->GetServerSettings();
	switch( g_pGameServerShell->GetGameType( ))
	{
		case eGameTypeDeathmatch:
		{
			switch( nGameOption )
			{
				// Runspeed.
				case 0:
				{
					SetGameOption( sms.m_nRunSpeed, atoi( szVal ), 100, 150 );
				}
				break;
				// Score limit.
				case 1:
				{
					SetGameOption( sms.m_nScoreLimit, atoi( szVal ), 0, 255 );
				}
				break;
				// Time limit.
				case 2:
				{
					SetGameOption( sms.m_nTimeLimit, atoi( szVal ), 0, 255 );
				}
				break;
				// Rounds.
				case 3:
				{
					SetGameOption( sms.m_nRounds, atoi( szVal ), 1, 255 );
				}
				break;
				default:
				{
					bOk = false;
				}
				break;
			}
		}
		break;

		case eGameTypeTeamDeathmatch:
		{
			switch( nGameOption )
			{
				// Runspeed.
				case 0:
				{
					SetGameOption( sms.m_nRunSpeed, atoi( szVal ), 100, 150 );
				}
				break;
				// Score limit.
				case 1:
				{
					SetGameOption( sms.m_nScoreLimit, atoi( szVal ), 0, 255 );
				}
				break;
				// Time limit.
				case 2:
				{
					SetGameOption( sms.m_nTimeLimit, atoi( szVal ), 0, 255 );
				}
				break;
				// Rounds.
				case 3:
				{
					SetGameOption( sms.m_nRounds, atoi( szVal ), 1, 255 );
				}
				break;
				// Friendly fire.
				case 4:
				{
					SetGameOption( sms.m_bFriendlyFire, ( bool )( !!atoi( szVal )), false, true );
				}
				break;
				default:
				{
					bOk = false;
				}
				break;
			}
		}
		break;

		case eGameTypeDoomsDay:
		{
			switch( nGameOption )
			{
				// Runspeed.
				case 0:
				{
					SetGameOption( sms.m_nRunSpeed, atoi( szVal ), 100, 150 );
				}
				break;
				// Time limit.
				case 1:
				{
					SetGameOption( sms.m_nTimeLimit, atoi( szVal ), 0, 255 );
				}
				break;
				// Rounds.
				case 2:
				{
					SetGameOption( sms.m_nRounds, atoi( szVal ), 1, 255 );
				}
				break;
				// Friendly fire.
				case 3:
				{
					SetGameOption( sms.m_bFriendlyFire, ( bool )( !!atoi( szVal )), false, true );
				}
				break;
				default:
				{
					bOk = false;
				}
				break;
			}
		}
		break;

		case eGameTypeCooperative:
		{
			switch( nGameOption )
			{
				// Friendly fire.
				case 0:
				{
					SetGameOption( sms.m_bFriendlyFire, ( bool )( !!atoi( szVal )), false, true );
				}
				break;

				// mp difficulty.
				case 1:
				{
					SetGameOption( sms.m_nMPDifficulty, atoi( szVal ), 0, 255 );
				}
				break;

				// player diff factor.
				case 2:
				{
					SetGameOption( sms.m_fPlayerDiffFactor, ( float )atof( szVal ), 0.0f, 20.0f );
				}
				break;

				default:
				{
					bOk = false;
				}
				break;
			}
		}
		break;

		default:
		{
			bOk = false;
		}
		break;
	}
	
	// We need to tell the host client about the new settings.
	if( bOk )
	{
		// Record any changes.
		g_pServerMissionMgr->SetServerSettings(sms);

		// Try to find a local host if one exists.
		HCLIENT hHost = g_pLTServer->GetNextClient( NULL );
		while( hHost )
		{
			uint32 nClientInfoFlags = g_pLTServer->GetClientInfoFlags( hHost );
			if( nClientInfoFlags & CIF_LOCAL )
			{
				break;
			}

			hHost = g_pLTServer->GetNextClient( hHost );
		}
		
		// If we have a host, tell them about the new settings.
		if( hHost )
		{
			CAutoMessage cMsg;
			cMsg.Writeuint8( MID_MULTIPLAYER_OPTIONS );
			cMsg.Writeuint8( sms.m_nRunSpeed);
			cMsg.Writeuint8( sms.m_nScoreLimit);
			cMsg.Writeuint8( sms.m_nTimeLimit);
			cMsg.Writeuint8( sms.m_nRounds);
			cMsg.Writebool( sms.m_bFriendlyFire);
			cMsg.Writeuint8( sms.m_nMPDifficulty);
			cMsg.Writefloat( sms.m_fPlayerDiffFactor);
			g_pLTServer->SendToClient( cMsg.Read( ), hHost, MESSAGE_GUARANTEED );
		}
	}

	SendStatusMessage( hClient, kScmdCommandSetGameOption, ( bOk ) ? kScmdCommandStatusOk : kScmdCommandStatusFailed );

	return true;
}