add macros: FOREACH_HumanPlayer, FOREACH_EnabledPlayer
This commit is contained in:
@@ -784,11 +784,8 @@ void GameState::GetFinalEvalStatsAndSongs( StageStats& statsOut, vector<Song*>&
|
|||||||
|
|
||||||
/* XXX: I have no idea if this is correct--but it's better than overflowing,
|
/* XXX: I have no idea if this is correct--but it's better than overflowing,
|
||||||
* anyway. -glenn */
|
* anyway. -glenn */
|
||||||
for( int p=0; p<NUM_PLAYERS; p++ )
|
FOREACH_EnabledPlayer( p )
|
||||||
{
|
{
|
||||||
if( !IsPlayerEnabled(p) )
|
|
||||||
continue;
|
|
||||||
|
|
||||||
for( int r = 0; r < NUM_RADAR_CATEGORIES; r++)
|
for( int r = 0; r < NUM_RADAR_CATEGORIES; r++)
|
||||||
{
|
{
|
||||||
statsOut.fRadarPossible[p][r] /= vSongsOut.size();
|
statsOut.fRadarPossible[p][r] /= vSongsOut.size();
|
||||||
@@ -813,7 +810,7 @@ void GameState::ApplyModifiers( PlayerNumber pn, CString sModifiers )
|
|||||||
* of gameplay. */
|
* of gameplay. */
|
||||||
void GameState::StoreSelectedOptions()
|
void GameState::StoreSelectedOptions()
|
||||||
{
|
{
|
||||||
for( int p=0; p<NUM_PLAYERS; p++ )
|
FOREACH_PlayerNumber( p )
|
||||||
this->m_StoredPlayerOptions[p] = this->m_PlayerOptions[p];
|
this->m_StoredPlayerOptions[p] = this->m_PlayerOptions[p];
|
||||||
m_StoredSongOptions = m_SongOptions;
|
m_StoredSongOptions = m_SongOptions;
|
||||||
}
|
}
|
||||||
@@ -1038,13 +1035,8 @@ void GameState::AdjustFailType()
|
|||||||
|
|
||||||
/* Find the easiest difficulty notes selected by either player. */
|
/* Find the easiest difficulty notes selected by either player. */
|
||||||
Difficulty dc = DIFFICULTY_INVALID;
|
Difficulty dc = DIFFICULTY_INVALID;
|
||||||
for( int p=0; p<NUM_PLAYERS; p++ )
|
FOREACH_HumanPlayer( p )
|
||||||
{
|
|
||||||
if( !this->IsHumanPlayer(p) )
|
|
||||||
continue; // skip
|
|
||||||
|
|
||||||
dc = min(dc, this->m_pCurNotes[p]->GetDifficulty());
|
dc = min(dc, this->m_pCurNotes[p]->GetDifficulty());
|
||||||
}
|
|
||||||
|
|
||||||
/* Reset the fail type to the default. */
|
/* Reset the fail type to the default. */
|
||||||
SongOptions so;
|
SongOptions so;
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
|
|
||||||
#include "PlayerNumber.h"
|
#include "PlayerNumber.h"
|
||||||
#include "ThemeManager.h"
|
#include "ThemeManager.h"
|
||||||
|
#include "GameState.h"
|
||||||
|
|
||||||
|
|
||||||
#define COLOR_P1 THEME->GetMetricC("Common","ColorP1")
|
#define COLOR_P1 THEME->GetMetricC("Common","ColorP1")
|
||||||
@@ -33,3 +34,23 @@ RageColor PlayerToColor( int p )
|
|||||||
return PlayerToColor( (PlayerNumber)p );
|
return PlayerToColor( (PlayerNumber)p );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PlayerNumber GetNextHumanPlayer( PlayerNumber pn )
|
||||||
|
{
|
||||||
|
for( PlayerNumber p=(PlayerNumber)(pn+1); p<NUM_PLAYERS; ((int&)p)++ )
|
||||||
|
{
|
||||||
|
if( GAMESTATE->IsHumanPlayer(p) )
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
return PLAYER_INVALID;
|
||||||
|
}
|
||||||
|
|
||||||
|
PlayerNumber GetNextEnabledPlayer( PlayerNumber pn )
|
||||||
|
{
|
||||||
|
for( PlayerNumber p=(PlayerNumber)(pn+1); p<NUM_PLAYERS; ((int&)p)++ )
|
||||||
|
{
|
||||||
|
if( GAMESTATE->IsPlayerEnabled(p) )
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
return PLAYER_INVALID;
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -28,6 +28,11 @@ enum PlayerNumber {
|
|||||||
PLAYER_INVALID
|
PLAYER_INVALID
|
||||||
};
|
};
|
||||||
#define FOREACH_PlayerNumber( pn ) FOREACH_ENUM( PlayerNumber, NUM_PLAYERS, pn )
|
#define FOREACH_PlayerNumber( pn ) FOREACH_ENUM( PlayerNumber, NUM_PLAYERS, pn )
|
||||||
|
#define FOREACH_HumanPlayer( pn ) for( PlayerNumber pn=(PlayerNumber)0; pn!=PLAYER_INVALID; pn=GetNextHumanPlayer(pn) )
|
||||||
|
#define FOREACH_EnabledPlayer( pn ) for( PlayerNumber pn=(PlayerNumber)0; pn!=PLAYER_INVALID; pn=GetNextEnabledPlayer(pn) )
|
||||||
|
|
||||||
|
PlayerNumber GetNextHumanPlayer( PlayerNumber pn );
|
||||||
|
PlayerNumber GetNextEnabledPlayer( PlayerNumber pn );
|
||||||
|
|
||||||
const PlayerNumber OPPOSITE_PLAYER[NUM_PLAYERS] = { PLAYER_2, PLAYER_1 };
|
const PlayerNumber OPPOSITE_PLAYER[NUM_PLAYERS] = { PLAYER_2, PLAYER_1 };
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user