dynamic GAMESTATE->m_ActiveAttacks
fix crash
This commit is contained in:
@@ -28,14 +28,12 @@ void AttackDisplay::Update( float fDelta )
|
|||||||
{
|
{
|
||||||
ActorFrame::Update( fDelta );
|
ActorFrame::Update( fDelta );
|
||||||
|
|
||||||
// FIXME: Make GAMESTATE->m_ActiveAttacks a vector
|
|
||||||
if( GAMESTATE->m_bAttackBeganThisUpdate[m_PlayerNumber] )
|
if( GAMESTATE->m_bAttackBeganThisUpdate[m_PlayerNumber] )
|
||||||
{
|
{
|
||||||
// don't handle this again
|
// don't handle this again
|
||||||
GAMESTATE->m_bAttackBeganThisUpdate[m_PlayerNumber] = false;
|
GAMESTATE->m_bAttackBeganThisUpdate[m_PlayerNumber] = false;
|
||||||
|
|
||||||
int s;
|
for( unsigned s=0; s<GAMESTATE->m_ActiveAttacks[m_PlayerNumber].size(); s++ )
|
||||||
for( s=0; s<GameState::MAX_SIMULTANEOUS_ATTACKS; s++ )
|
|
||||||
{
|
{
|
||||||
if( GAMESTATE->m_ActiveAttacks[m_PlayerNumber][s].fStartSecond >= 0 )
|
if( GAMESTATE->m_ActiveAttacks[m_PlayerNumber][s].fStartSecond >= 0 )
|
||||||
continue; /* hasn't started yet */
|
continue; /* hasn't started yet */
|
||||||
@@ -46,13 +44,13 @@ void AttackDisplay::Update( float fDelta )
|
|||||||
if( GAMESTATE->m_ActiveAttacks[m_PlayerNumber][s].IsBlank() )
|
if( GAMESTATE->m_ActiveAttacks[m_PlayerNumber][s].IsBlank() )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
CString sText = GAMESTATE->m_ActiveAttacks[m_PlayerNumber][s].sModifier;
|
||||||
|
|
||||||
|
m_textAttack.SetDiffuseAlpha( 1 );
|
||||||
|
m_textAttack.SetText( sText );
|
||||||
|
m_textAttack.Command( TEXT_ON_COMMAND(m_PlayerNumber) );
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
CString sText = GAMESTATE->m_ActiveAttacks[m_PlayerNumber][s].sModifier;
|
|
||||||
|
|
||||||
m_textAttack.SetDiffuseAlpha( 1 );
|
|
||||||
m_textAttack.SetText( sText );
|
|
||||||
m_textAttack.Command( TEXT_ON_COMMAND(m_PlayerNumber) );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+12
-24
@@ -155,14 +155,14 @@ void GameState::Update( float fDelta )
|
|||||||
{
|
{
|
||||||
for( int p=0; p<NUM_PLAYERS; p++ )
|
for( int p=0; p<NUM_PLAYERS; p++ )
|
||||||
{
|
{
|
||||||
int s;
|
unsigned s;
|
||||||
|
|
||||||
m_CurrentPlayerOptions[p].Approach( m_PlayerOptions[p], fDelta );
|
m_CurrentPlayerOptions[p].Approach( m_PlayerOptions[p], fDelta );
|
||||||
|
|
||||||
bool RebuildPlayerOptions = false;
|
bool RebuildPlayerOptions = false;
|
||||||
|
|
||||||
/* See if any delayed attacks are starting. */
|
/* See if any delayed attacks are starting. */
|
||||||
for( s=0; s<MAX_SIMULTANEOUS_ATTACKS; s++ )
|
for( s=0; s<m_ActiveAttacks[p].size(); s++ )
|
||||||
{
|
{
|
||||||
if( m_ActiveAttacks[p][s].fStartSecond < 0 )
|
if( m_ActiveAttacks[p][s].fStartSecond < 0 )
|
||||||
continue; /* already started */
|
continue; /* already started */
|
||||||
@@ -177,7 +177,7 @@ void GameState::Update( float fDelta )
|
|||||||
/* See if any attacks are ending. */
|
/* See if any attacks are ending. */
|
||||||
m_bAttackEndedThisUpdate[p] = false;
|
m_bAttackEndedThisUpdate[p] = false;
|
||||||
|
|
||||||
for( s=0; s<MAX_SIMULTANEOUS_ATTACKS; s++ )
|
for( s=0; s<m_ActiveAttacks[p].size(); s++ )
|
||||||
{
|
{
|
||||||
if( m_ActiveAttacks[p][s].fStartSecond >= 0 )
|
if( m_ActiveAttacks[p][s].fStartSecond >= 0 )
|
||||||
continue; /* hasn't started yet */
|
continue; /* hasn't started yet */
|
||||||
@@ -191,8 +191,7 @@ void GameState::Update( float fDelta )
|
|||||||
continue; /* continuing */
|
continue; /* continuing */
|
||||||
|
|
||||||
/* ending */
|
/* ending */
|
||||||
m_ActiveAttacks[p][s].fSecsRemaining = 0;
|
m_ActiveAttacks[p].erase( m_ActiveAttacks[p].begin()+s, m_ActiveAttacks[p].begin()+s+1 );
|
||||||
m_ActiveAttacks[p][s].sModifier = "";
|
|
||||||
m_bAttackEndedThisUpdate[p] = true;
|
m_bAttackEndedThisUpdate[p] = true;
|
||||||
RebuildPlayerOptions = true;
|
RebuildPlayerOptions = true;
|
||||||
}
|
}
|
||||||
@@ -697,30 +696,19 @@ void GameState::LaunchAttack( PlayerNumber target, Attack a )
|
|||||||
|
|
||||||
m_bAttackBeganThisUpdate[target] = true;
|
m_bAttackBeganThisUpdate[target] = true;
|
||||||
|
|
||||||
// search for an open slot
|
m_ActiveAttacks[target].push_back( a );
|
||||||
for( int s=0; s<MAX_SIMULTANEOUS_ATTACKS; s++ )
|
m_ModsToApply[target].push_back( a );
|
||||||
{
|
GAMESTATE->RebuildPlayerOptionsFromActiveAttacks( target );
|
||||||
if( m_ActiveAttacks[target][s].fSecsRemaining <= 0 )
|
|
||||||
{
|
|
||||||
m_ActiveAttacks[target][s] = a;
|
|
||||||
m_ModsToApply[target].push_back( a );
|
|
||||||
GAMESTATE->RebuildPlayerOptionsFromActiveAttacks( target );
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
LOG->Warn("Couldn't launch attack '%s' against p%i: no empty attack slots",
|
|
||||||
a.sModifier.c_str(), target );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameState::RemoveActiveAttacksForPlayer( PlayerNumber pn, AttackLevel al )
|
void GameState::RemoveActiveAttacksForPlayer( PlayerNumber pn, AttackLevel al )
|
||||||
{
|
{
|
||||||
for( int s=0; s<MAX_SIMULTANEOUS_ATTACKS; s++ )
|
for( unsigned s=0; s<m_ActiveAttacks[pn].size(); s++ )
|
||||||
{
|
{
|
||||||
if( al != NUM_ATTACK_LEVELS && al != m_ActiveAttacks[pn][s].level )
|
if( al != NUM_ATTACK_LEVELS && al != m_ActiveAttacks[pn][s].level )
|
||||||
continue;
|
continue;
|
||||||
m_ActiveAttacks[pn][s].fSecsRemaining = 0;
|
m_ActiveAttacks[pn].erase( m_ActiveAttacks[pn].begin()+s, m_ActiveAttacks[pn].begin()+s+1 );
|
||||||
m_ActiveAttacks[pn][s].sModifier = "";
|
--s;
|
||||||
}
|
}
|
||||||
RebuildPlayerOptionsFromActiveAttacks( (PlayerNumber)pn );
|
RebuildPlayerOptionsFromActiveAttacks( (PlayerNumber)pn );
|
||||||
}
|
}
|
||||||
@@ -739,7 +727,7 @@ void GameState::RebuildPlayerOptionsFromActiveAttacks( PlayerNumber pn )
|
|||||||
{
|
{
|
||||||
// rebuild player options
|
// rebuild player options
|
||||||
PlayerOptions po = m_StoredPlayerOptions[pn];
|
PlayerOptions po = m_StoredPlayerOptions[pn];
|
||||||
for( int s=0; s<MAX_SIMULTANEOUS_ATTACKS; s++ )
|
for( unsigned s=0; s<m_ActiveAttacks[pn].size(); s++ )
|
||||||
{
|
{
|
||||||
if( m_ActiveAttacks[pn][s].fStartSecond >= 0 )
|
if( m_ActiveAttacks[pn][s].fStartSecond >= 0 )
|
||||||
continue; /* hasn't started yet */
|
continue; /* hasn't started yet */
|
||||||
@@ -752,7 +740,7 @@ int GameState::GetSumOfActiveAttackLevels( PlayerNumber pn )
|
|||||||
{
|
{
|
||||||
int iSum = 0;
|
int iSum = 0;
|
||||||
|
|
||||||
for( int s=0; s<MAX_SIMULTANEOUS_ATTACKS; s++ )
|
for( unsigned s=0; s<m_ActiveAttacks[pn].size(); s++ )
|
||||||
if( m_ActiveAttacks[pn][s].fSecsRemaining > 0 && m_ActiveAttacks[pn][s].level != NUM_ATTACK_LEVELS )
|
if( m_ActiveAttacks[pn][s].fSecsRemaining > 0 && m_ActiveAttacks[pn][s].level != NUM_ATTACK_LEVELS )
|
||||||
iSum += m_ActiveAttacks[pn][s].level;
|
iSum += m_ActiveAttacks[pn][s].level;
|
||||||
|
|
||||||
|
|||||||
@@ -163,8 +163,7 @@ public:
|
|||||||
StageStats m_CurStageStats; // current stage (not necessarily passed if Extra Stage)
|
StageStats m_CurStageStats; // current stage (not necessarily passed if Extra Stage)
|
||||||
|
|
||||||
// used in PLAY_MODE_BATTLE and PLAY_MODE_RAVE
|
// used in PLAY_MODE_BATTLE and PLAY_MODE_RAVE
|
||||||
enum { MAX_SIMULTANEOUS_ATTACKS=16 };
|
AttackArray m_ActiveAttacks[NUM_PLAYERS];
|
||||||
Attack m_ActiveAttacks[NUM_PLAYERS][MAX_SIMULTANEOUS_ATTACKS];
|
|
||||||
|
|
||||||
vector<Attack> m_ModsToApply[NUM_PLAYERS];
|
vector<Attack> m_ModsToApply[NUM_PLAYERS];
|
||||||
|
|
||||||
|
|||||||
@@ -760,7 +760,7 @@ void ScreenGameplay::LoadNextSong()
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Hack: Course modifiers that are set to start immediately shouldn't tween on. */
|
/* Hack: Course modifiers that are set to start immediately shouldn't tween on. */
|
||||||
for( int s=0; s < GameState::MAX_SIMULTANEOUS_ATTACKS; s++ )
|
for( unsigned s=0; s<GAMESTATE->m_ActiveAttacks[p].size(); s++ )
|
||||||
{
|
{
|
||||||
if( GAMESTATE->m_ActiveAttacks[p][s].fStartSecond == 0 )
|
if( GAMESTATE->m_ActiveAttacks[p][s].fStartSecond == 0 )
|
||||||
GAMESTATE->m_ActiveAttacks[p][s].fStartSecond = -1;
|
GAMESTATE->m_ActiveAttacks[p][s].fStartSecond = -1;
|
||||||
|
|||||||
Reference in New Issue
Block a user