allow multiple dummy players

This commit is contained in:
Chris Danford
2007-07-12 11:01:25 +00:00
parent 408eccea98
commit 663640b0c2
2 changed files with 32 additions and 7 deletions
+29 -5
View File
@@ -102,6 +102,7 @@ PlayerInfo::PlayerInfo()
m_pn = PLAYER_INVALID; m_pn = PLAYER_INVALID;
m_mp = MultiPlayer_Invalid; m_mp = MultiPlayer_Invalid;
m_bIsDummy = false; m_bIsDummy = false;
m_iDummyIndex = 0;
m_pLifeMeter = NULL; m_pLifeMeter = NULL;
m_ptextCourseSongNumber = NULL; m_ptextCourseSongNumber = NULL;
m_ptextStepsDescription = NULL; m_ptextStepsDescription = NULL;
@@ -189,10 +190,12 @@ void PlayerInfo::Load( PlayerNumber pn, MultiPlayer mp, bool bShowNoteField )
} }
} }
void PlayerInfo::LoadDummyP1() void PlayerInfo::LoadDummyP1( int iDummyIndex )
{ {
m_pn = PLAYER_1; m_pn = PLAYER_1;
m_bPlayerEnabled = IsEnabled();
m_bIsDummy = true; m_bIsDummy = true;
m_iDummyIndex = iDummyIndex;
// don't init any of the scoring objects // don't init any of the scoring objects
m_pPlayer = new Player( m_NoteData, true ); m_pPlayer = new Player( m_NoteData, true );
@@ -446,7 +449,8 @@ void ScreenGameplay::Init()
FOREACH_EnabledPlayerInfo( m_vPlayerInfo, pi ) FOREACH_EnabledPlayerInfo( m_vPlayerInfo, pi )
{ {
pi->m_pPlayer->SetName( ssprintf("Player%s", pi->GetName().c_str()) ); RString sName = ssprintf("Player%s", pi->GetName().c_str());
pi->m_pPlayer->SetName( sName );
// If pi->m_pn is set, then the player will be visible. If not, then it's not // If pi->m_pn is set, then the player will be visible. If not, then it's not
// visible and don't bother setting its position. // visible and don't bother setting its position.
@@ -870,7 +874,9 @@ void ScreenGameplay::SetupSong( int iSongIndex )
/* This is the first beat that can be changed without it being visible. Until /* This is the first beat that can be changed without it being visible. Until
* we draw for the first time, any beat can be changed. */ * we draw for the first time, any beat can be changed. */
pi->GetPlayerState()->m_fLastDrawnBeat = -100; pi->GetPlayerState()->m_fLastDrawnBeat = -100;
GAMESTATE->m_pCurSteps[ pi->GetStepsAndTrailIndex() ].Set( pi->m_vpStepsQueue[iSongIndex] );
Steps *pSteps = pi->m_vpStepsQueue[iSongIndex];
GAMESTATE->m_pCurSteps[ pi->GetStepsAndTrailIndex() ].Set( pSteps );
/* Load new NoteData into Player. Do this before /* Load new NoteData into Player. Do this before
* RebuildPlayerOptionsFromActiveAttacks or else transform mods will get * RebuildPlayerOptionsFromActiveAttacks or else transform mods will get
@@ -880,7 +886,22 @@ void ScreenGameplay::SetupSong( int iSongIndex )
* is very bad for transforms like AddMines. * is very bad for transforms like AddMines.
*/ */
NoteData originalNoteData; NoteData originalNoteData;
GAMESTATE->m_pCurSteps[ pi->GetStepsAndTrailIndex() ]->GetNoteData( originalNoteData ); if( pi->m_bIsDummy )
{
switch( pi->m_iDummyIndex )
{
//case 0:
// pSteps = SongUtil::GetOneSteps( GAMESTATE->m_pCurSong, pSteps->m_StepsType, Difficulty_Easy );
// break;
case 1:
pSteps = SongUtil::GetOneSteps( GAMESTATE->m_pCurSong, pSteps->m_StepsType, Difficulty_Medium );
break;
case 2:
pSteps = SongUtil::GetOneSteps( GAMESTATE->m_pCurSong, pSteps->m_StepsType, Difficulty_Hard );
break;
}
}
pSteps->GetNoteData( originalNoteData );
const Style* pStyle = GAMESTATE->GetCurrentStyle(); const Style* pStyle = GAMESTATE->GetCurrentStyle();
NoteData ndTransformed; NoteData ndTransformed;
@@ -2677,7 +2698,10 @@ public:
{ {
PlayerNumber pn = Enum::Check<PlayerNumber>( L, 1 ); PlayerNumber pn = Enum::Check<PlayerNumber>( L, 1 );
LifeMeter *pLM = p->GetPlayerInfo(pn)->m_pLifeMeter; PlayerInfo *pi = p->GetPlayerInfo(pn);
if( pi == NULL )
return 0;
LifeMeter *pLM = pi->m_pLifeMeter;
if( pLM == NULL ) if( pLM == NULL )
return 0; return 0;
+3 -2
View File
@@ -44,7 +44,7 @@ public:
~PlayerInfo(); ~PlayerInfo();
void Load( PlayerNumber pn, MultiPlayer mp, bool bShowNoteField ); void Load( PlayerNumber pn, MultiPlayer mp, bool bShowNoteField );
void LoadDummyP1(); void LoadDummyP1( int iDummyIndex );
void ShowOniGameOver(); void ShowOniGameOver();
MultiPlayer GetPlayerStateAndStageStatsIndex() { return m_pn == PLAYER_INVALID ? m_mp : (MultiPlayer)m_pn; } MultiPlayer GetPlayerStateAndStageStatsIndex() { return m_pn == PLAYER_INVALID ? m_mp : (MultiPlayer)m_pn; }
@@ -56,7 +56,7 @@ public:
RString GetName() const RString GetName() const
{ {
if( m_bIsDummy ) if( m_bIsDummy )
return "Dummy"; return ssprintf("Dummy%d",m_iDummyIndex);
if( IsMultiPlayer() ) if( IsMultiPlayer() )
return MultiPlayerToString( m_mp ); return MultiPlayerToString( m_mp );
else else
@@ -71,6 +71,7 @@ public:
PlayerNumber m_pn; PlayerNumber m_pn;
MultiPlayer m_mp; MultiPlayer m_mp;
bool m_bIsDummy; bool m_bIsDummy;
int m_iDummyIndex;
bool m_bPlayerEnabled; // IsEnabled cache for iterators bool m_bPlayerEnabled; // IsEnabled cache for iterators
PlayerState m_PlayerStateDummy; PlayerState m_PlayerStateDummy;
PlayerStageStats m_PlayerStageStatsDummy; PlayerStageStats m_PlayerStageStatsDummy;