add multiplayer status

This commit is contained in:
Chris Danford
2006-04-21 00:43:32 +00:00
parent 63989c4aee
commit bead3edf0e
4 changed files with 43 additions and 15 deletions
+9
View File
@@ -446,6 +446,15 @@ REGISTER_WITH_LUA_FUNCTION( LuaStage );
LuaXToString( Stage ); LuaXToString( Stage );
static const char *MultiPlayerStatusNames[] = {
"Joined",
"NotJoined",
"Unplugged",
"MissingMultitap",
};
XToString( MultiPlayerStatus, NUM_MultiPlayerStatus );
/* /*
* (c) 2001-2004 Chris Danford * (c) 2001-2004 Chris Danford
* All rights reserved. * All rights reserved.
+12
View File
@@ -454,6 +454,18 @@ enum ProfileLoadResult
}; };
enum MultiPlayerStatus
{
MultiPlayerStatus_Joined,
MultiPlayerStatus_NotJoined,
MultiPlayerStatus_Unplugged,
MultiPlayerStatus_MissingMultitap,
NUM_MultiPlayerStatus,
MultiPlayerStatus_INVALID
};
const RString& MultiPlayerStatusToString( MultiPlayerStatus i );
#endif #endif
/* /*
+10 -3
View File
@@ -171,7 +171,7 @@ void GameState::Reset()
FOREACH_PlayerNumber( p ) FOREACH_PlayerNumber( p )
m_bSideIsJoined[p] = false; m_bSideIsJoined[p] = false;
FOREACH_MultiPlayer( p ) FOREACH_MultiPlayer( p )
m_bIsMultiPlayerJoined[p] = false; m_MultiPlayerStatus[p] = MultiPlayerStatus_NotJoined;
MEMCARDMAN->UnlockCards(); MEMCARDMAN->UnlockCards();
// m_iCoins = 0; // don't reset coin count! // m_iCoins = 0; // don't reset coin count!
m_MasterPlayerNumber = PLAYER_INVALID; m_MasterPlayerNumber = PLAYER_INVALID;
@@ -819,13 +819,13 @@ bool GameState::IsPlayerEnabled( PlayerNumber pn ) const
bool GameState::IsMultiPlayerEnabled( MultiPlayer mp ) const bool GameState::IsMultiPlayerEnabled( MultiPlayer mp ) const
{ {
return m_bIsMultiPlayerJoined[ mp ]; return m_MultiPlayerStatus[ mp ] == MultiPlayerStatus_Joined;
} }
bool GameState::IsPlayerEnabled( const PlayerState* pPlayerState ) const bool GameState::IsPlayerEnabled( const PlayerState* pPlayerState ) const
{ {
if( pPlayerState->m_mp != MultiPlayer_INVALID ) if( pPlayerState->m_mp != MultiPlayer_INVALID )
return m_bIsMultiPlayerJoined[ pPlayerState->m_mp ]; return IsMultiPlayerEnabled( pPlayerState->m_mp );
if( pPlayerState->m_PlayerNumber != PLAYER_INVALID ) if( pPlayerState->m_PlayerNumber != PLAYER_INVALID )
return IsPlayerEnabled( pPlayerState->m_PlayerNumber ); return IsPlayerEnabled( pPlayerState->m_PlayerNumber );
return false; return false;
@@ -1799,6 +1799,12 @@ public:
p->m_pPlayerState[pn]->PushSelf(L); p->m_pPlayerState[pn]->PushSelf(L);
return 1; return 1;
} }
static int GetMultiPlayerState( T* p, lua_State *L )
{
MultiPlayer mp = (MultiPlayer)IArg(1);
p->m_pMultiPlayerState[mp]->PushSelf(L);
return 1;
}
static int ApplyGameCommand( T* p, lua_State *L ) static int ApplyGameCommand( T* p, lua_State *L )
{ {
PlayerNumber pn = PLAYER_INVALID; PlayerNumber pn = PLAYER_INVALID;
@@ -1984,6 +1990,7 @@ public:
ADD_METHOD( GetMasterPlayerNumber ); ADD_METHOD( GetMasterPlayerNumber );
ADD_METHOD( GetMultiplayer ); ADD_METHOD( GetMultiplayer );
ADD_METHOD( GetPlayerState ); ADD_METHOD( GetPlayerState );
ADD_METHOD( GetMultiPlayerState );
ADD_METHOD( ApplyGameCommand ); ADD_METHOD( ApplyGameCommand );
ADD_METHOD( GetCurrentSong ); ADD_METHOD( GetCurrentSong );
ADD_METHOD( SetCurrentSong ); ADD_METHOD( SetCurrentSong );
+1 -1
View File
@@ -56,7 +56,7 @@ public:
BroadcastOnChangePtr<const Game> m_pCurGame; BroadcastOnChangePtr<const Game> m_pCurGame;
BroadcastOnChangePtr<const Style> m_pCurStyle; BroadcastOnChangePtr<const Style> m_pCurStyle;
bool m_bSideIsJoined[NUM_PLAYERS]; // left side, right side bool m_bSideIsJoined[NUM_PLAYERS]; // left side, right side
bool m_bIsMultiPlayerJoined[NUM_MultiPlayer]; MultiPlayerStatus m_MultiPlayerStatus[NUM_MultiPlayer];
BroadcastOnChange<PlayMode> m_PlayMode; // many screens display different info depending on this value BroadcastOnChange<PlayMode> m_PlayMode; // many screens display different info depending on this value
int m_iCoins; // not "credits" int m_iCoins; // not "credits"
PlayerNumber m_MasterPlayerNumber; // used in Styles where one player controls both sides PlayerNumber m_MasterPlayerNumber; // used in Styles where one player controls both sides