convert ints and casts to use PlayerNumber and macros

This commit is contained in:
Chris Danford
2004-08-30 04:35:14 +00:00
parent 081c1e24b5
commit cf9b4af6cb
9 changed files with 110 additions and 157 deletions
+8 -5
View File
@@ -436,13 +436,16 @@ void BGAnimationLayer::LoadFromIni( CString sAniDir, CString sLayer )
int player;
if( ini.GetValue( sLayer, "Player", player ) )
{
if( player > 0 && player <= NUM_PLAYERS )
PlayerNumber pn = (PlayerNumber)(player-1);
if( pn>=0 && pn<NUM_PLAYERS )
{
if( !GAMESTATE->IsPlayerEnabled(player-1) )
if( !GAMESTATE->IsPlayerEnabled(pn) )
return;
} else
LOG->Warn("BGA \"%s\" %s has an invalid Player field",
sAniDir.c_str(), sLayer.c_str() );
}
else
{
LOG->Warn("BGA \"%s\" %s has an invalid Player field", sAniDir.c_str(), sLayer.c_str() );
}
}
}
+6 -13
View File
@@ -71,7 +71,7 @@ BeginnerHelper::~BeginnerHelper()
{
}
void BeginnerHelper::ShowStepCircle( int pn, int CSTEP )
void BeginnerHelper::ShowStepCircle( PlayerNumber pn, int CSTEP )
{
int isc=0; // Save OR issues within array boundries.. it's worth the extra few bytes of memory.
switch(CSTEP)
@@ -89,7 +89,7 @@ void BeginnerHelper::ShowStepCircle( int pn, int CSTEP )
m_sStepCircle[pn][isc].SetZoom(0);
}
void BeginnerHelper::AddPlayer( int pn, NoteData *pSteps )
void BeginnerHelper::AddPlayer( PlayerNumber pn, NoteData *pSteps )
{
ASSERT(!m_bInitialized);
ASSERT(pSteps != NULL);
@@ -268,7 +268,7 @@ void BeginnerHelper::DrawPrimitives()
}
}
void BeginnerHelper::Step( int pn, int CSTEP )
void BeginnerHelper::Step( PlayerNumber pn, int CSTEP )
{
m_pDancer[pn]->StopTweening();
m_pDancer[pn]->SetRotationY(0); // Make sure we're not still inside of a JUMPUD tween.
@@ -324,12 +324,8 @@ void BeginnerHelper::Update( float fDeltaTime )
// the row we want to check on this update
int iCurRow = BeatToNoteRowNotRounded(GAMESTATE->m_fSongBeat + 0.4f);
for(int pn=0; pn<NUM_PLAYERS; pn++)
FOREACH_EnabledPlayer( pn )
{
// Skip if not enabled
if(!m_bPlayerEnabled[pn])
continue;
for(int iRow=m_iLastRowChecked; iRow<iCurRow; iRow++)
{
// Check if there are any notes at all on this row.. If not, save scanning.
@@ -357,12 +353,9 @@ void BeginnerHelper::Update( float fDeltaTime )
m_sFlash.Update(fDeltaTime);
float beat = (fDeltaTime*GAMESTATE->m_fCurBPS);
for(int pu=0; pu<NUM_PLAYERS; pu++)
// If this is not a human player, the dancer is not shown
FOREACH_HumanPlayer( pu )
{
// If this is not a human player, the dancer is not shown
if(!GAMESTATE->IsHumanPlayer(pu))
continue;
// Update dancer's animation and StepCircles
m_pDancer[pu]->Update( beat );
for(int scu=0; scu<NUM_PLAYERS; scu++)
+3 -3
View File
@@ -17,15 +17,15 @@ public:
bool Initialize( int iDancePadType );
bool IsInitialized() { return m_bInitialized; }
static bool CanUse();
void AddPlayer( int pn, NoteData *pSteps );
void ShowStepCircle( int pn, int CSTEP );
void AddPlayer( PlayerNumber pn, NoteData *pSteps );
void ShowStepCircle( PlayerNumber pn, int CSTEP );
bool m_bShowBackground;
void Update( float fDeltaTime );
virtual void DrawPrimitives();
protected:
void Step( int pn, int CSTEP );
void Step( PlayerNumber pn, int CSTEP );
NoteData m_NoteData[NUM_PLAYERS];
bool m_bPlayerEnabled[NUM_PLAYERS];
+62 -78
View File
@@ -372,18 +372,15 @@ void ConditionalBGA::CheckBgaRequirements(BgaCondInfo info)
bool foundmatchingdiff=false;
for(unsigned d=0;d<info.difficulties.size();d++)
{
for(unsigned pn=0; pn<NUM_PLAYERS;pn++)
FOREACH_EnabledPlayer( pn )
{
if(GAMESTATE->IsPlayerEnabled(pn))
if(GAMESTATE->m_pCurSteps[pn] != NULL)
{
if(GAMESTATE->m_pCurSteps[pn] != NULL)
if(GAMESTATE->m_pCurSteps[pn]->GetDifficulty() == info.difficulties[d])
{
if(GAMESTATE->m_pCurSteps[pn]->GetDifficulty() == info.difficulties[d])
{
foundmatchingdiff = true;
LOG->Info("Found Valid Difficulty");
foundmatchingdiff = true;
LOG->Info("Found Valid Difficulty");
}
}
}
}
@@ -395,53 +392,48 @@ void ConditionalBGA::CheckBgaRequirements(BgaCondInfo info)
{
PlayerOptions po = info.disallowedpo;
bool bModsValid = true;
for(unsigned pn=0;pn<NUM_PLAYERS;pn++)
FOREACH_EnabledPlayer( pn )
{
if(GAMESTATE->IsPlayerEnabled(pn))
unsigned md;
for(md=0;md<PlayerOptions::NUM_ACCELS;md++)
{
unsigned md;
for(md=0;md<PlayerOptions::NUM_ACCELS;md++)
if(po.m_fAccels[md] != 0.0f && GAMESTATE->m_PlayerOptions[pn].m_fAccels[md] != 0.0f)
{
if(po.m_fAccels[md] != 0.0f && GAMESTATE->m_PlayerOptions[pn].m_fAccels[md] != 0.0f)
{
bModsValid=false;
LOG->Info("Found Invalid Accel Mod");
}
bModsValid=false;
LOG->Info("Found Invalid Accel Mod");
}
for(md=0;md<PlayerOptions::NUM_EFFECTS;md++)
}
for(md=0;md<PlayerOptions::NUM_EFFECTS;md++)
{
if(po.m_fEffects[md] != 0.0f && GAMESTATE->m_PlayerOptions[pn].m_fEffects[md] != 0.0f)
{
if(po.m_fEffects[md] != 0.0f && GAMESTATE->m_PlayerOptions[pn].m_fEffects[md] != 0.0f)
{
bModsValid=false;
LOG->Info("Found Invalid Effect Mod");
}
bModsValid=false;
LOG->Info("Found Invalid Effect Mod");
}
for(md=0;md<PlayerOptions::NUM_APPEARANCES;md++)
}
for(md=0;md<PlayerOptions::NUM_APPEARANCES;md++)
{
if(po.m_fAppearances[md] != 0.0f && GAMESTATE->m_PlayerOptions[pn].m_fAppearances[md] != 0.0f)
{
if(po.m_fAppearances[md] != 0.0f && GAMESTATE->m_PlayerOptions[pn].m_fAppearances[md] != 0.0f)
{
bModsValid=false;
LOG->Info("Found Invalid Appearance Mod");
}
bModsValid=false;
LOG->Info("Found Invalid Appearance Mod");
}
for(md=0;md<PlayerOptions::NUM_TURNS;md++)
}
for(md=0;md<PlayerOptions::NUM_TURNS;md++)
{
if(po.m_bTurns[md] != 0.0f && GAMESTATE->m_PlayerOptions[pn].m_bTurns[md] != 0.0f)
{
if(po.m_bTurns[md] != 0.0f && GAMESTATE->m_PlayerOptions[pn].m_bTurns[md] != 0.0f)
{
bModsValid=false;
LOG->Info("Found Invalid Turn Mod");
}
bModsValid=false;
LOG->Info("Found Invalid Turn Mod");
}
for(md=0;md<PlayerOptions::NUM_TRANSFORMS;md++)
}
for(md=0;md<PlayerOptions::NUM_TRANSFORMS;md++)
{
if(po.m_bTransforms[md] != 0.0f && GAMESTATE->m_PlayerOptions[pn].m_bTransforms[md] != 0.0f)
{
if(po.m_bTransforms[md] != 0.0f && GAMESTATE->m_PlayerOptions[pn].m_bTransforms[md] != 0.0f)
{
bModsValid=false;
LOG->Info("Found Invalid Transform Mod");
}
bModsValid=false;
LOG->Info("Found Invalid Transform Mod");
}
}
}
valid = bModsValid;
@@ -454,28 +446,25 @@ void ConditionalBGA::CheckBgaRequirements(BgaCondInfo info)
for(unsigned d=0;d<info.songmeters.size();d++)
{
LOG->Info("MeterRating: %d",info.songmeters[d]);
for(int pn=0;pn<NUM_PLAYERS;pn++)
FOREACH_EnabledPlayer( pn )
{
if(GAMESTATE->IsPlayerEnabled(pn))
if(GAMESTATE->m_pCurSteps[pn] != NULL)
{
if(GAMESTATE->m_pCurSteps[pn] != NULL)
if(info.songmeters[d] < 0) // negative values stored mean we want to check a value greaterthan or equal to its negative
{
if(info.songmeters[d] < 0) // negative values stored mean we want to check a value greaterthan or equal to its negative
{
// first make it positive then check to see if the footrating is >= to it
int tmp = 0 - info.songmeters[d];
if(GAMESTATE->m_pCurSteps[pn]->GetMeter() >= tmp)
{
LOG->Info("Found Valid MeterRating");
foundmatchingmeter = true;
}
}
else if(GAMESTATE->m_pCurSteps[pn]->GetMeter() == info.songmeters[d])
// first make it positive then check to see if the footrating is >= to it
int tmp = 0 - info.songmeters[d];
if(GAMESTATE->m_pCurSteps[pn]->GetMeter() >= tmp)
{
LOG->Info("Found Valid MeterRating");
foundmatchingmeter = true;
}
}
else if(GAMESTATE->m_pCurSteps[pn]->GetMeter() == info.songmeters[d])
{
LOG->Info("Found Valid MeterRating");
foundmatchingmeter = true;
}
}
}
}
@@ -509,15 +498,12 @@ void ConditionalBGA::CheckBgaRequirements(BgaCondInfo info)
{
LOG->Info("Checking Single Grade");
bool foundaplayerwithgrade = false;
for(unsigned pn=0; pn<NUM_PLAYERS;pn++)
FOREACH_EnabledPlayer( pn )
{
if(GAMESTATE->IsPlayerEnabled(pn))
if(g_CurStageStats.GetGrade(pn) == info.grades[0])
{
if(g_CurStageStats.GetGrade((PlayerNumber)pn) == info.grades[0])
{
LOG->Info("Found Valid Grade");
foundaplayerwithgrade = true;
}
LOG->Info("Found Valid Grade");
foundaplayerwithgrade = true;
}
}
foundmatchinggrades = foundaplayerwithgrade;
@@ -622,23 +608,21 @@ void ConditionalBGA::CheckBgaRequirements(BgaCondInfo info)
}
else if(info.cleared == CBGA_CSMAXCOMBO)
{
for(unsigned pn=0;pn<NUM_PLAYERS;pn++)
if(GAMESTATE->IsPlayerEnabled(pn))
if(g_CurStageStats.FullCombo((PlayerNumber)pn))
{
foundclearcond = true;
LOG->Info("MaxCombo Condition");
}
FOREACH_EnabledPlayer( pn )
if(g_CurStageStats.FullCombo((PlayerNumber)pn))
{
foundclearcond = true;
LOG->Info("MaxCombo Condition");
}
}
else if(info.cleared == CBGA_CSBROKECOMBO)
{
for(unsigned pn=0;pn<NUM_PLAYERS;pn++)
if(GAMESTATE->IsPlayerEnabled(pn))
if(!g_CurStageStats.FullCombo((PlayerNumber)pn))
{
LOG->Info("BrokenCombo Condition");
foundclearcond = true;
}
FOREACH_EnabledPlayer( pn )
if(!g_CurStageStats.FullCombo((PlayerNumber)pn))
{
LOG->Info("BrokenCombo Condition");
foundclearcond = true;
}
}
valid = foundclearcond;
-3
View File
@@ -75,16 +75,13 @@ public:
void GetPlayerInfo( PlayerNumber pn, bool& bIsEnabledOut, bool& bIsHumanOut );
bool IsPlayerEnabled( PlayerNumber pn ) const;
bool IsPlayerEnabled( int p ) const { return IsPlayerEnabled( (PlayerNumber)p ); };
int GetNumPlayersEnabled() const;
bool PlayerUsingBothSides() const;
bool IsHumanPlayer( PlayerNumber pn ) const;
bool IsHumanPlayer( int p ) const { return IsHumanPlayer( (PlayerNumber)p ); };
int GetNumHumanPlayers() const;
PlayerNumber GetFirstHumanPlayer() const;
bool IsCpuPlayer( PlayerNumber pn ) const;
bool IsCpuPlayer( int p ) const { return IsCpuPlayer( (PlayerNumber)p ); };
bool AnyPlayersAreCpu() const;
void GetCharacters( vector<Character*> &apCharactersOut );
+6 -7
View File
@@ -22,18 +22,17 @@ ScreenEndlessBreak::ScreenEndlessBreak( CString sName ) : Screen( sName )
m_sprBreakPicture.Load( THEME->GetPathToG("Common fallback takingabreak") );
else if( GAMESTATE->GetNumPlayersEnabled() > 1 ) // More than 1 player is present.
{
int PlayerToUse = 999; /* If this was 0 by default, the first player would
always be selected. Make it an insane number so
we always generate a random player. */
while (!GAMESTATE->IsPlayerEnabled(PlayerToUse))
PlayerNumber pn;
do
{
PlayerToUse = (int)(rand()*NUM_PLAYERS); // Is there a danger of this becoming an endless loop??
if( (GAMESTATE->IsPlayerEnabled(PlayerToUse)) && (GAMESTATE->m_pCurCharacters[PlayerToUse] != NULL) )
pn = (PlayerNumber)(rand()%NUM_PLAYERS);
if( GAMESTATE->IsPlayerEnabled(pn) && (GAMESTATE->m_pCurCharacters[pn] != NULL) )
{
m_sprBreakPicture.LoadTABreakFromCharacter( GAMESTATE->m_pCurCharacters[PlayerToUse] );
m_sprBreakPicture.LoadTABreakFromCharacter( GAMESTATE->m_pCurCharacters[pn] );
break;
}
}
while( !GAMESTATE->IsPlayerEnabled(pn) );
}
}
else // Characters not enabled.
+9 -17
View File
@@ -307,11 +307,8 @@ void ScreenOptions::Init( InputMode im, OptionRowData OptionRows[], int iNumOpti
if( row.m_bRowIsLong )
{
// init text
for( unsigned p=0; p<NUM_PLAYERS; p++ )
FOREACH_HumanPlayer( p )
{
if( !GAMESTATE->IsHumanPlayer(p) )
continue; // skip
BitmapText *bt = new BitmapText;
textItems.push_back( bt );
@@ -334,20 +331,15 @@ void ScreenOptions::Init( InputMode im, OptionRowData OptionRows[], int iNumOpti
}
// init underlines
FOREACH_HumanPlayer( p )
{
for( unsigned p=0; p<NUM_PLAYERS; p++ )
{
if( !GAMESTATE->IsHumanPlayer(p) )
continue; // skip
OptionsCursor *ul = new OptionsCursor;
row.m_Underline[p].push_back( ul );
ul->Load( (PlayerNumber)p, true );
int iWidth, iX, iY;
GetWidthXY( (PlayerNumber) p, r, c, iWidth, iX, iY );
ul->SetX( float(iX) );
ul->SetWidth( float(iWidth) );
}
OptionsCursor *ul = new OptionsCursor;
row.m_Underline[p].push_back( ul );
ul->Load( (PlayerNumber)p, true );
int iWidth, iX, iY;
GetWidthXY( (PlayerNumber) p, r, c, iWidth, iX, iY );
ul->SetX( float(iX) );
ul->SetWidth( float(iWidth) );
}
}
+7 -14
View File
@@ -277,17 +277,13 @@ void ScreenSelectMode::SetCharacters()
GAMESTATE->GetCharacters( apCharactersToUse );
}
}
for(int pn=0; pn<NUM_PLAYERS; pn++)
FOREACH_EnabledPlayer( pn )
{
if(GAMESTATE->IsPlayerEnabled(pn))
if(ENABLE_CHAR_SELECT && m_iCurrentChar[pn] != -1)
{
if(ENABLE_CHAR_SELECT && m_iCurrentChar[pn] != -1)
{
Character* pChar = apCharactersToUse[m_iCurrentChar[pn]];
GAMESTATE->m_pCurCharacters[pn] = pChar;
}
Character* pChar = apCharactersToUse[m_iCurrentChar[pn]];
GAMESTATE->m_pCurCharacters[pn] = pChar;
}
}
}
@@ -345,14 +341,11 @@ void ScreenSelectMode::Update( float fDelta )
void ScreenSelectMode::DrawPrimitives()
{
ScreenSelect::DrawPrimitives();
for(int pn=0; pn<NUM_PLAYERS; pn++)
FOREACH_EnabledPlayer( pn )
{
if(GAMESTATE->IsPlayerEnabled(pn))
if(ENABLE_CHAR_SELECT)
{
if(ENABLE_CHAR_SELECT)
{
m_CurChar[pn].Draw();
}
m_CurChar[pn].Draw();
}
}
}
+6 -14
View File
@@ -248,7 +248,7 @@ bool StageStats::OnePassed() const
bool StageStats::AllFailed() const
{
FOREACH_PlayerNumber( pn )
if( GAMESTATE->IsPlayerEnabled(PlayerNumber(pn)) )
if( GAMESTATE->IsPlayerEnabled(pn) )
if( !bFailed[pn] )
return false;
return true;
@@ -462,24 +462,16 @@ float StageStats::GetPercentageOfTaps( PlayerNumber pn, TapNoteScore tns ) const
static Grade GetBestGrade()
{
Grade g = NUM_GRADES;
for( unsigned pn=0; pn<NUM_PLAYERS; ++pn )
{
if( !GAMESTATE->IsPlayerEnabled(pn) )
continue;
g = min( g, g_CurStageStats.GetGrade( (PlayerNumber)pn ) );
}
FOREACH_EnabledPlayer( pn )
g = min( g, g_CurStageStats.GetGrade( pn ) );
return g;
}
static Grade GetWorstGrade()
{
Grade g = GRADE_TIER_1;
for( unsigned pn=0; pn<NUM_PLAYERS; ++pn )
{
if( !GAMESTATE->IsPlayerEnabled(pn) )
continue;
g = max( g, g_CurStageStats.GetGrade( (PlayerNumber)pn ) );
}
FOREACH_EnabledPlayer( pn )
g = max( g, g_CurStageStats.GetGrade( pn ) );
return g;
}
@@ -516,7 +508,7 @@ Grade GetGrade( int n, PlayerNumber pn )
bool OneGotGrade( int n, Grade g )
{
FOREACH_HumanPlayer( pn )
if( GetGrade( n, (PlayerNumber)pn ) == g )
if( GetGrade( n, pn ) == g )
return true;
return false;