From a0efc346bd08666d0153e84caccac3b7cbe0fef9 Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Fri, 9 Apr 2004 02:16:34 +0000 Subject: [PATCH] fix GAMESTATE->m_iCpuSkill going out of bounds --- stepmania/src/PlayerAI.cpp | 4 ++-- stepmania/src/ScreenGameplay.cpp | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/stepmania/src/PlayerAI.cpp b/stepmania/src/PlayerAI.cpp index c2521848c5..4fa9dcc782 100644 --- a/stepmania/src/PlayerAI.cpp +++ b/stepmania/src/PlayerAI.cpp @@ -82,8 +82,8 @@ TapNoteScore PlayerAI::GetTapNoteScore( PlayerNumber pn ) GAMESTATE->m_iLastPositiveSumOfAttackLevels[pn] : 0; - ASSERT( iCpuSkill>=0 && iCpuSkillm_PlayerController[pn] == PC_CPU ); + ASSERT_M( iCpuSkill>=0 && iCpuSkillm_PlayerController[pn] == PC_CPU, ssprintf("%i", GAMESTATE->m_PlayerController[pn]) ); iCpuSkill -= iSumOfAttackLevels*3; CLAMP( iCpuSkill, 0, NUM_SKILL_LEVELS-1 ); diff --git a/stepmania/src/ScreenGameplay.cpp b/stepmania/src/ScreenGameplay.cpp index 4b8932a1b9..d1ba1f192a 100644 --- a/stepmania/src/ScreenGameplay.cpp +++ b/stepmania/src/ScreenGameplay.cpp @@ -933,6 +933,8 @@ void ScreenGameplay::LoadNextSong() GAMESTATE->m_PlayerController[p] = PC_CPU; int iMeter = GAMESTATE->m_pCurNotes[p]->GetMeter(); int iNewSkill = SCALE( iMeter, MIN_METER, MAX_METER, 0, NUM_SKILL_LEVELS-1 ); + /* Watch out: songs aren't actually bound by MAX_METER. */ + iNewSkill = clamp( iNewSkill, 0, NUM_SKILL_LEVELS-1 ); GAMESTATE->m_iCpuSkill[p] = iNewSkill; } else if( PREFSMAN->m_bAutoPlay )