From 53c69088e2d5d7c22cfa0b3688f1ba704f9f7f1a Mon Sep 17 00:00:00 2001 From: AJ Kelly Date: Thu, 10 Jun 2010 14:23:31 -0500 Subject: [PATCH] Fix crashes in Rave/Battle mode. --- src/GameState.cpp | 17 ++++++++++++++++- src/ScreenGameplay.cpp | 20 +++++++++++--------- 2 files changed, 27 insertions(+), 10 deletions(-) diff --git a/src/GameState.cpp b/src/GameState.cpp index 413739084e..9d7bd635ec 100644 --- a/src/GameState.cpp +++ b/src/GameState.cpp @@ -694,7 +694,9 @@ void GameState::BeginStage() ASSERT( m_iNumStagesOfThisSong != -1 ); FOREACH_EnabledPlayer( p ) { - if( !IsEventMode() ) + // only do this check with human players, assume CPU players (Rave) + // always have tokens. -aj (this could probably be moved below, even.) + if( !IsEventMode() && !IsCpuPlayer(p) ) ASSERT( m_iPlayerStageTokens[p] >= m_iNumStagesOfThisSong ); m_iPlayerStageTokens[p] -= m_iNumStagesOfThisSong; } @@ -959,6 +961,13 @@ void GameState::UpdateSongPosition( float fPositionSeconds, const TimingData &ti // "Crash reason : -243478.890625 -48695.773438" ASSERT_M( m_fSongBeat > -2000, ssprintf("Song beat %f at %f seconds", m_fSongBeat, fPositionSeconds) ); + //if( m_iWarpBeginRow != -1 || m_iWarpEndRow == -1 ) + if( m_iWarpBeginRow != -1 && m_iWarpEndRow == -1 ) + { + // we got a warp in this section. + LOG->Trace("warp at %i jumps to %i",m_iWarpBeginRow,m_iWarpEndRow); + // i hate this part because how the shit do i convert rows to seconds? + } /* // xxx testing: only do this on monotune survivor if( m_pCurSong && m_pCurSong->GetDisplayFullTitle() == "monotune survivor" ) @@ -2169,6 +2178,11 @@ public: DEFINE_METHOD( GetPlayerDisplayName, GetPlayerDisplayName(Enum::Check(L, 1)) ) DEFINE_METHOD( GetMasterPlayerNumber, m_MasterPlayerNumber ) DEFINE_METHOD( GetMultiplayer, m_bMultiplayer ) + static int SetMultiplayer( T* p, lua_State *L ) + { + p->m_bMultiplayer = BArg(1); + return 0; + } DEFINE_METHOD( GetNumMultiplayerNoteFields, m_iNumMultiplayerNoteFields ) DEFINE_METHOD( ShowW1, ShowW1() ) @@ -2444,6 +2458,7 @@ public: ADD_METHOD( GetPlayerDisplayName ); ADD_METHOD( GetMasterPlayerNumber ); ADD_METHOD( GetMultiplayer ); + ADD_METHOD( SetMultiplayer ); ADD_METHOD( GetNumMultiplayerNoteFields ); ADD_METHOD( SetNumMultiplayerNoteFields ); ADD_METHOD( ShowW1 ); diff --git a/src/ScreenGameplay.cpp b/src/ScreenGameplay.cpp index 31ff8706db..6de0a8eff3 100644 --- a/src/ScreenGameplay.cpp +++ b/src/ScreenGameplay.cpp @@ -401,6 +401,15 @@ void ScreenGameplay::Init() /* Called once per stage (single song or single course). */ GAMESTATE->BeginStage(); + if(!GAMESTATE->IsCourseMode() && !GAMESTATE->m_bDemonstrationOrJukebox) + { + // fill in difficulty of CPU players with that of the first human player + FOREACH_PotentialCpuPlayer(p) + GAMESTATE->m_pCurSteps[p].Set( GAMESTATE->m_pCurSteps[ GAMESTATE->GetFirstHumanPlayer() ] ); + + FOREACH_EnabledPlayer(p) + ASSERT( GAMESTATE->m_pCurSteps[p].Get() ); + } /* Increment the course play count. */ if( GAMESTATE->IsCourseMode() && !GAMESTATE->m_bDemonstrationOrJukebox ) @@ -734,6 +743,7 @@ void ScreenGameplay::Init() pi->GetPlayerStageStats()->m_vpPossibleSteps = pi->m_vpStepsQueue; } + LOG->Trace("[ScreenGameplay::Init] loading scorekeepers"); FOREACH_EnabledPlayerInfo( m_vPlayerInfo, pi ) { ASSERT( !pi->m_vpStepsQueue.empty() ); @@ -802,8 +812,6 @@ bool ScreenGameplay::Center1Player() const // fill in m_apSongsQueue, m_vpStepsQueue, m_asModifiersQueue void ScreenGameplay::InitSongQueues() { - LOG->Trace("InitSongQueues"); - if( GAMESTATE->IsCourseMode() ) { Course* pCourse = GAMESTATE->m_pCurCourse; @@ -936,6 +944,7 @@ bool ScreenGameplay::IsLastSong() void ScreenGameplay::SetupSong( int iSongIndex ) { + LOG->Trace("[ScreenGameplay::SetupSong] begin"); FOREACH_EnabledPlayerInfo( m_vPlayerInfo, pi ) { /* This is the first beat that can be changed without it being visible. Until @@ -1028,13 +1037,6 @@ void ScreenGameplay::SetupSong( int iSongIndex ) /* Hack: Course modifiers that are set to start immediately shouldn't tween on. */ pi->GetPlayerState()->m_PlayerOptions.SetCurrentToLevel( ModsLevel_Stage ); } - - // fill in difficulty of CPU players with that of the first human player - FOREACH_PotentialCpuPlayer(p) - GAMESTATE->m_pCurSteps[p].Set( GAMESTATE->m_pCurSteps[ GAMESTATE->GetFirstHumanPlayer() ] ); - - FOREACH_EnabledPlayer(p) - ASSERT( GAMESTATE->m_pCurSteps[p].Get() ); } void ScreenGameplay::ReloadCurrentSong()