Exemple #1
0
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;
}
Exemple #2
0
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;
}
Exemple #3
0
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;
}
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;
}
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;
}
Exemple #6
0
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;
}