Exemplo n.º 1
0
// ----------------------------------------------------------------------- //
//
//	ROUTINE:	CMissionMgr::StartGameNew
//
//	PURPOSE:	Start the game from the beginning.
//
// ----------------------------------------------------------------------- //
bool CMissionMgr::StartGameNew( )
{
	// Default to use the first mission.
	int nFirstMission = 0;

	// Starting new game.
	g_pInterfaceMgr->StartingNewGame( );

	// If this is a multiplayer game, then get use the campaign file to determine
	// the first mission.
	if( IsMultiplayerGame( ))
	{
		// Get the first mission to play from the missions file.
		char szMission[4];
		CUserProfile* pUserProfile = g_pProfileMgr->GetCurrentProfile( );
		char const* pszCampaignFile = GetCampaignFile( pUserProfile->m_ServerGameOptions );
		if (!CWinUtil::FileExist( pszCampaignFile ))
			return false;

		CWinUtil::WinGetPrivateProfileString( "MissionList", "Mission0", "0", szMission, 
			ARRAY_LEN( szMission ), pszCampaignFile );
		nFirstMission = atoi( szMission );
	}

	// Get the level name for the first mission/level.
	char const* pszLevelFilename = GetLevelFromMission( nFirstMission, 0 );
	if( !pszLevelFilename )
		return false;

	// Start from the first level.
	if( !StartGameFromLevel( pszLevelFilename ))
		return false;

	return true;
}
Exemplo n.º 2
0
void CScreenHostMission::UpdateCampaignName()
{
	bool isDefault = (m_pProfile->m_ServerGameOptions.IsDefaultCampaign());
	if (!isDefault)
	{
		char const* pszCampaignFile = GetCampaignFile( m_pProfile->m_ServerGameOptions );

		if (!CWinUtil::FileExist( pszCampaignFile ))
		{
			m_pProfile->m_ServerGameOptions.SetCampaignName(DEFAULT_CAMPAIGN);
			isDefault = true;
		}
	}



	if (isDefault)
	{
		char szTmp[64];
		LoadString(IDS_HOST_CAMPAIGN_DEFAULT,szTmp,sizeof(szTmp));
		m_pCurrent->SetString(FormatTempString(IDS_CURRENT_CAMPAIGN,szTmp));
		m_pLevels->Enable(false);
	}
	else
	{
		m_pCurrent->SetString(FormatTempString(IDS_CURRENT_CAMPAIGN,m_pProfile->m_ServerGameOptions.GetCampaignName()));
		m_pLevels->Enable(true);
	}
}
Exemplo n.º 3
0
// Change in focus
void    CScreenHostLevels::OnFocus(LTBOOL bFocus)
{
	if (bFocus)
	{
		m_pAvailMissions->Enable(LTFALSE);
		m_pAdd->Enable(LTTRUE);
		m_pSelMissions->Enable(LTFALSE);
		m_pRemove->Enable(LTTRUE);

		CUserProfile* pUserProfile = g_pProfileMgr->GetCurrentProfile( );
		m_sCampaignFile = GetCampaignFile( pUserProfile->m_ServerGameOptions );
		
		if(!CWinUtil::FileExist( m_sCampaignFile.c_str() ) )
		{
			//TODO handle more cleanly
			g_pLTClient->CPrint("Could not load campaign file %s.",  m_sCampaignFile.c_str() );
			m_sCampaignFile = "";
		}



		FillAvailList();

		LoadMissionList();

		if (!m_pSelMissions->GetNumControls())
		{
			MakeDefaultMissionList();
		}

		if (g_pGameClientShell->GetGameType() != eGameTypeCooperative)
		{
			m_pLoopToggle->Enable(LTFALSE);
			m_bLoopMissions = LTTRUE;
		}
		else
		{
			m_pLoopToggle->Enable(LTTRUE);
		}

		UpdateButtons();
        UpdateData(LTFALSE);

	}
	else
	{
		UpdateData();

		if (m_sCampaignFile.length())
		{
			SaveMissionList();
		}
		m_pAvailMissions->RemoveAll();
		m_pSelMissions->RemoveAll();
	}
	CBaseScreen::OnFocus(bFocus);

}
Exemplo n.º 4
0
bool CServerMissionMgr::SetupCampaign( char const* pszCampaignName )
{
	// Clear all missions from our campaign.
	m_Campaign.clear( );

	ServerGameOptions const& serverGameOptions = g_pGameServerShell->GetServerGameOptions( );
	char const* pszCampaignFile = GetCampaignFile( serverGameOptions );

	// If the campaignfile is blank, then just use all missions.
	if( !pszCampaignFile || !pszCampaignFile[0] )
	{
		for( int nMissionId = 0; nMissionId < g_pMissionButeMgr->GetNumMissions( ); nMissionId++ )
		{
			m_Campaign.push_back( nMissionId );
		}

		// Default to not looping.
		m_bLoopCampaign = false;

		return true;
	}

	// Read the missionid's for this campaign.
	char szMissionId[4];
	char szCampaignIndexKeyName[32];
	int nCampaignIndex = 0;
	while( 1 )
	{
		// Create the key name for this entry.
		sprintf( szCampaignIndexKeyName, "Mission%d", nCampaignIndex );

		// Get the missionid for this entry.
		CWinUtil::WinGetPrivateProfileString( "MissionList", szCampaignIndexKeyName, "", szMissionId, 
			ARRAY_LEN( szMissionId ), pszCampaignFile );

		// If there wasn't a missionid, then we reached the end.
		if( !szMissionId[0] )
			break;

		// Get the mission id.
		int nMissionId = atoi( szMissionId );

		// Make sure it's a valid mission.
		if( nMissionId < g_pMissionButeMgr->GetNumMissions( ))
			m_Campaign.push_back( nMissionId );

		nCampaignIndex++;
	}

	// Get the looping flag.
	char szLoop[4];
	CWinUtil::WinGetPrivateProfileString( "MissionList", "LoopMissions", "0", szLoop, 
		ARRAY_LEN( szLoop ), pszCampaignFile );
	m_bLoopCampaign = !!atoi( szLoop );

	return true;
}