diff options
| author | John Schoenick <[email protected]> | 2015-09-09 18:35:41 -0700 |
|---|---|---|
| committer | John Schoenick <[email protected]> | 2015-09-09 18:35:41 -0700 |
| commit | 0d8dceea4310fde5706b3ce1c70609d72a38efdf (patch) | |
| tree | c831ef32c2c801a5c5a80401736b52c7b5a528ec /mp/src/game/server/team_control_point_master.cpp | |
| parent | Updated the SDK with the latest code from the TF and HL2 branches. (diff) | |
| download | source-sdk-2013-0d8dceea4310fde5706b3ce1c70609d72a38efdf.tar.xz source-sdk-2013-0d8dceea4310fde5706b3ce1c70609d72a38efdf.zip | |
Diffstat (limited to 'mp/src/game/server/team_control_point_master.cpp')
| -rw-r--r-- | mp/src/game/server/team_control_point_master.cpp | 65 |
1 files changed, 22 insertions, 43 deletions
diff --git a/mp/src/game/server/team_control_point_master.cpp b/mp/src/game/server/team_control_point_master.cpp index 956f7ddb..9b007e06 100644 --- a/mp/src/game/server/team_control_point_master.cpp +++ b/mp/src/game/server/team_control_point_master.cpp @@ -1056,65 +1056,44 @@ bool CTeamControlPointMaster::IsBaseControlPoint( int iPointIndex ) int CTeamControlPointMaster::GetBaseControlPoint( int iTeam ) { int iRetVal = -1; - int nLowestValue = 999, nHighestValue = -1; - int iLowestIndex = 0, iHighestIndex = 0; + int nLowestValue = 999; + int nHighestValue = -1; + CTeamControlPoint *pLowestPoint = NULL; + CTeamControlPoint *pHighestPoint = NULL; - for( int i = 0 ; i < (int)m_ControlPoints.Count() ; i++ ) + for( unsigned int i = 0 ; i < m_ControlPoints.Count() ; i++ ) { CTeamControlPoint *pPoint = m_ControlPoints[i]; - int iPointIndex = m_ControlPoints[i]->GetPointIndex(); - - if ( PlayingMiniRounds() && iTeam > LAST_SHARED_TEAM ) + if ( !PlayingMiniRounds() || ( IsInRound( pPoint ) && ( iTeam > LAST_SHARED_TEAM ) ) ) { - if ( IsInRound( pPoint ) ) // is this point in the current round? - { - if ( iPointIndex > nHighestValue ) - { - nHighestValue = iPointIndex; - iHighestIndex = i; - } + int nTempValue = pPoint->GetPointIndex(); - if ( iPointIndex < nLowestValue ) - { - nLowestValue = iPointIndex; - iLowestIndex = i; - } - } - } - else - { - if ( pPoint->GetDefaultOwner() != iTeam ) + if ( nTempValue > nHighestValue ) { - continue; + nHighestValue = nTempValue; + pHighestPoint = pPoint; } - // If it's the first or the last point, it's their base - if ( iPointIndex == 0 || iPointIndex == (((int)m_ControlPoints.Count())-1) ) + if ( nTempValue < nLowestValue ) { - iRetVal = iPointIndex; - break; + nLowestValue = nTempValue; + pLowestPoint = pPoint; } } } - if ( PlayingMiniRounds() && iTeam > LAST_SHARED_TEAM ) + if ( pLowestPoint && pHighestPoint ) { - if ( nLowestValue != 999 && nHighestValue != -1 ) + // which point is owned by this team? + if ( ( pLowestPoint->GetDefaultOwner() == iTeam && pHighestPoint->GetDefaultOwner() == iTeam ) || // if the same team owns both, take the highest value to be the last point + ( pHighestPoint->GetDefaultOwner() == iTeam ) ) { - CTeamControlPoint *pLowestPoint = m_ControlPoints[iLowestIndex]; - CTeamControlPoint *pHighestPoint = m_ControlPoints[iHighestIndex]; - - // which point is owned by this team? - if ( ( pLowestPoint->GetDefaultOwner() == iTeam && pHighestPoint->GetDefaultOwner() == iTeam ) || // if the same team owns both, take the highest value to be the last point - ( pHighestPoint->GetDefaultOwner() == iTeam ) ) - { - iRetVal = nHighestValue; - } - else if ( pLowestPoint->GetDefaultOwner() == iTeam ) - { - iRetVal = nLowestValue; - } + iRetVal = nHighestValue; + } + else if ( pLowestPoint->GetDefaultOwner() == iTeam ) + { + iRetVal = nLowestValue; } } |