From ca8f660c4fc7dc87c5e70e678c400aac1c520f3a Mon Sep 17 00:00:00 2001 From: AJ Kelly Date: Tue, 2 Feb 2010 16:00:10 -0600 Subject: [PATCH] syncing changes from ssc svn, mostly. [Course.cpp] HasTimedMods() now actually checks for timed mods (technically non-global) instead of being a clone of HasMods() [Player.cpp] add MAX_HOLD_LIFE/[Player] MaxHoldLife metric [ScreenGameplay] looking into places to put loading of replay data, perhaps? [elsewhere] lots of cleanup, and I'm sure there's lots more to be done. add a todo to ProductivityHelpers. --- .../Scripts/03 ProductivityHelpers.lua | 1 + src/Course.cpp | 89 +++++++++---------- src/HoldJudgment.h | 2 - src/Player.cpp | 12 ++- src/PlayerAI.cpp | 1 + src/ScreenGameplay.cpp | 6 ++ src/ScreenGameplay.h | 1 + src/ScreenSelectMaster.cpp | 14 +-- src/ScreenSyncOverlay.cpp | 6 +- src/StepMania.cpp | 14 +-- src/StepsDisplay.cpp | 20 +++-- src/arch/ArchHooks/ArchHooks.h | 4 +- 12 files changed, 93 insertions(+), 77 deletions(-) diff --git a/Themes/_fallback/Scripts/03 ProductivityHelpers.lua b/Themes/_fallback/Scripts/03 ProductivityHelpers.lua index 30d7e471bf..a75213c87f 100644 --- a/Themes/_fallback/Scripts/03 ProductivityHelpers.lua +++ b/Themes/_fallback/Scripts/03 ProductivityHelpers.lua @@ -209,6 +209,7 @@ function FailCombo() -- The combo that causes game failure. return Combo[sGame] end; +-- todo: use tables for some of these -aj function HoldTiming() if GAMESTATE:GetCurrentGame():GetName() == "pump" then return 0; diff --git a/src/Course.cpp b/src/Course.cpp index dbfd92b508..dfda217e03 100644 --- a/src/Course.cpp +++ b/src/Course.cpp @@ -137,23 +137,23 @@ void Course::SetCourseType( CourseType ct ) m_iLives = -1; if( !m_vEntries.empty() ) m_vEntries[0].fGainSeconds = 0; - + switch( ct ) { default: ASSERT(0); case COURSE_TYPE_NONSTOP: - break; + break; case COURSE_TYPE_ONI: m_iLives = 4; - break; + break; case COURSE_TYPE_ENDLESS: m_bRepeat = true; - break; + break; case COURSE_TYPE_SURVIVAL: if( !m_vEntries.empty() ) m_vEntries[0].fGainSeconds = 120; - break; - } + break; + } } PlayMode Course::GetPlayMode() const @@ -222,7 +222,7 @@ bool Course::IsPlayableIn( StepsType st ) const FOREACH_CONST( CourseEntry, m_vEntries, e ) { SongCriteria soc = e->songCriteria; - + Song *pSong = e->songID.ToSong(); if( pSong ) { @@ -233,27 +233,27 @@ bool Course::IsPlayableIn( StepsType st ) const soc.m_Locked = SongCriteria::Locked_Unlocked; if( !soc.m_bUseSongAllowedList ) soc.m_iMaxStagesForSong = 1; - + StepsCriteria stc = e->stepsCriteria; stc.m_st = st; stc.m_Locked = StepsCriteria::Locked_Unlocked; - + const bool bSameSongCriteria = e != m_vEntries.begin() && (e-1)->songCriteria == soc; const bool bSameStepsCriteria = e != m_vEntries.begin() && (e-1)->stepsCriteria == stc; - + if( pSong ) { - if( StepsUtil::HasMatching(pSong, stc) ) + if( StepsUtil::HasMatching(pSong, stc) ) return true; } else if( !(bSameSongCriteria && bSameStepsCriteria) ) { if( StepsUtil::HasMatching(soc, stc) ) - return true; + return true; } - + } - + return false; } @@ -307,18 +307,14 @@ Trail* Course::GetTrail( StepsType st, CourseDifficulty cd ) const { ASSERT( cd != Difficulty_Invalid ); - // // Check to see if the Trail cache is out of date - // if( m_iTrailCacheSeed != GAMESTATE->m_iStageSeed ) { RegenerateNonFixedTrails(); m_iTrailCacheSeed = GAMESTATE->m_iStageSeed; } - // // Look in the Trail cache - // { TrailCache_t::iterator it = m_TrailCache.find( CacheEntry(st, cd) ); if( it != m_TrailCache.end() ) @@ -335,22 +331,18 @@ Trail* Course::GetTrail( StepsType st, CourseDifficulty cd ) const Trail* Course::GetTrailForceRegenCache( StepsType st, CourseDifficulty cd ) const { - // // Construct a new Trail, add it to the cache, then return it. - // CacheData &cache = m_TrailCache[ CacheEntry(st, cd) ]; Trail &trail = cache.trail; trail.Init(); if( !GetTrailSorted(st, cd, trail) ) { - /* This course difficulty doesn't exist. */ + // This course difficulty doesn't exist. cache.null = true; return NULL; } - // // If we have cached RadarValues for this trail, insert them. - // { RadarCache_t::const_iterator it = m_RadarCache.find( CacheEntry( st, cd ) ); if( it != m_RadarCache.end() ) @@ -453,10 +445,8 @@ bool Course::GetTrailUnsorted( StepsType st, CourseDifficulty cd, Trail &trail ) return false; } - // // Construct a new Trail, add it to the cache, then return it. - // - /* Different seed for each course, but the same for the whole round: */ + // Different seed for each course, but the same for the whole round: RandomGen rnd( GAMESTATE->m_iStageSeed + GetHashForString(m_sMainTitle) ); vector tmp_entries; @@ -471,7 +461,7 @@ bool Course::GetTrailUnsorted( StepsType st, CourseDifficulty cd, Trail &trail ) const vector &entries = m_bShuffle ? tmp_entries:m_vEntries; - /* This can take some time, so don't fill it out unless we need it. */ + // This can take some time, so don't fill it out unless we need it. vector vSongsByMostPlayed; vector AllSongsShuffled; @@ -479,7 +469,7 @@ bool Course::GetTrailUnsorted( StepsType st, CourseDifficulty cd, Trail &trail ) trail.m_CourseType = GetCourseType(); trail.m_CourseDifficulty = cd; - /* Set to true if CourseDifficulty is able to change something. */ + // Set to true if CourseDifficulty is able to change something. bool bCourseDifficultyIsSignificant = (cd == Difficulty_Medium); vector vpAllPossibleSongs; @@ -490,7 +480,7 @@ bool Course::GetTrailUnsorted( StepsType st, CourseDifficulty cd, Trail &trail ) { SongAndSteps resolved; // fill this in SongCriteria soc = e->songCriteria; - + Song *pSong = e->songID.ToSong(); if( pSong ) { @@ -505,7 +495,7 @@ bool Course::GetTrailUnsorted( StepsType st, CourseDifficulty cd, Trail &trail ) StepsCriteria stc = e->stepsCriteria; stc.m_st = st; stc.m_Locked = StepsCriteria::Locked_Unlocked; - + const bool bSameSongCriteria = e != entries.begin() && (e-1)->songCriteria == soc; const bool bSameStepsCriteria = e != entries.begin() && (e-1)->stepsCriteria == stc; @@ -525,7 +515,6 @@ bool Course::GetTrailUnsorted( StepsType st, CourseDifficulty cd, Trail &trail ) if( trail.m_vEntries.size() > 0 && vSongAndSteps.size() > 1 ) { const TrailEntry &teLast = trail.m_vEntries.back(); - RemoveIf( vSongAndSteps, SongIsEqual(teLast.pSong) ); } @@ -539,14 +528,14 @@ bool Course::GetTrailUnsorted( StepsType st, CourseDifficulty cd, Trail &trail ) FOREACH_CONST( SongAndSteps, vSongAndSteps, sas ) { StepsVector &v = mapSongToSteps[sas->pSong]; - + v.push_back( sas->pSteps ); if( v.size() == 1 ) vpSongs.push_back( sas->pSong ); } CourseSortSongs( e->songSort, vpSongs, rnd ); - + ASSERT( e->iChooseIndex >= 0 ); if( e->iChooseIndex < int(vSongAndSteps.size()) ) { @@ -651,9 +640,9 @@ bool Course::GetTrailUnsorted( StepsType st, CourseDifficulty cd, Trail &trail ) trail.m_vEntries.push_back( te ); // LOG->Trace( "Chose: %s, %d", te.pSong->GetSongDir().c_str(), te.pSteps->GetMeter() ); - + if( IsAnEdit() && MAX_SONGS_IN_EDIT_COURSE > 0 && - int(trail.m_vEntries.size()) >= MAX_SONGS_IN_EDIT_COURSE ) + int(trail.m_vEntries.size()) >= MAX_SONGS_IN_EDIT_COURSE ) { break; } @@ -723,13 +712,22 @@ bool Course::HasMods() const bool Course::HasTimedMods() const { - // ???: This seems to be the exact same as Course::HasMods(). -aj + // What makes this different from the SM4 implementation is that + // HasTimedMods now searches for bGlobal in the attacks; if one of + // them is false, it has timed mods. Also returning false will probably + // take longer than expected. -aj FOREACH_CONST( CourseEntry, m_vEntries, e ) { if( !e->attacks.empty() ) - return true; + { + for( unsigned s=0; s < e->attacks.size(); s++ ) + { + Attack &attack = e->attacks[s]; + if(!attack.bGlobal) + return true; + } + } } - return false; } @@ -779,7 +777,7 @@ void Course::Invalidate( const Song *pStaleSong ) // Invalidate any Trails that contain this song. // If we find a Trail that contains this song, then it's part of a - // non-fixed entry. So, regenerating the Trail will force different + // non-fixed entry. So, regenerating the Trail will force different // songs to be chosen. FOREACH_ENUM( StepsType,st ) { @@ -820,7 +818,7 @@ RageColor Course::GetColor() const switch( PREFSMAN->m_CourseSortOrder ) { case COURSE_SORT_PREFERRED: - return SORT_PREFERRED_COLOR; //This will also be used for autogen'd courses in some cases. + return SORT_PREFERRED_COLOR; //This will also be used for autogen'd courses in some cases. case COURSE_SORT_SONGS: if( m_vEntries.size() >= 7 ) return SORT_LEVEL2_COLOR; @@ -848,7 +846,7 @@ RageColor Course::GetColor() const else return SORT_LEVEL4_COLOR; default: FAIL_M( ssprintf("Invalid course sort %d.", int(PREFSMAN->m_CourseSortOrder)) ); - return RageColor(1,1,1,1); // white, never should reach here + return RageColor(1,1,1,1); // white; should never reach here } } @@ -911,9 +909,8 @@ void Course::UpdateCourseStats( StepsType st ) m_SortOrder_TotalDifficulty += pTrail != NULL? pTrail->GetTotalMeter():0; - // OPTIMIZATION: Ranking info isn't dependant on style, so - // call it sparingly. Its handled on startup and when - // themes change.. + // OPTIMIZATION: Ranking info isn't dependent on style, so call it + // sparingly. It's handled on startup and when themes change. LOG->Trace("%s: Total feet: %d", this->m_sMainTitle.c_str(), @@ -923,7 +920,7 @@ void Course::UpdateCourseStats( StepsType st ) bool Course::IsRanking() const { vector rankingsongs; - + split(THEME->GetMetric("ScreenRanking", "CoursesToShow"), ",", rankingsongs); for(unsigned i=0; i < rankingsongs.size(); i++) @@ -960,7 +957,7 @@ void Course::GetAllCachedTrails( vector &out ) bool Course::ShowInDemonstrationAndRanking() const { // Don't show endless courses in Ranking. - // todo: make this a metric? -aj + // todo: make this a metric of course types not to show? -aj return !IsEndless(); } diff --git a/src/HoldJudgment.h b/src/HoldJudgment.h index a9ab9f0294..015ec7859a 100644 --- a/src/HoldJudgment.h +++ b/src/HoldJudgment.h @@ -19,9 +19,7 @@ public: void LoadFromMultiPlayer( MultiPlayer mp ); virtual void HandleMessage( const Message &msg ); - // // Lua - // virtual void PushSelf( lua_State *L ); protected: diff --git a/src/Player.cpp b/src/Player.cpp index a47f1939ec..3ecc322c07 100644 --- a/src/Player.cpp +++ b/src/Player.cpp @@ -127,7 +127,7 @@ static Preference g_bEnableMineSoundPlayback ( "EnableMineHitSound", true Preference g_fTimingWindowHopo ( "TimingWindowHopo", 0.25 ); // max time between notes in a hopo chain Preference g_fTimingWindowStrum ( "TimingWindowStrum", 0.1f ); // max time between strum and when the frets must match ThemeMetric INITIAL_HOLD_LIFE ( "Player", "InitialHoldLife" ); -ThemeMetric MAX_HOLD_LIFE ( "Player", "MaxHoldLife" ); +ThemeMetric MAX_HOLD_LIFE ( "Player", "MaxHoldLife" ); // sm-ssc addition ThemeMetric PENALIZE_TAP_SCORE_NONE ( "Player", "PenalizeTapScoreNone" ); ThemeMetric JUDGE_HOLD_NOTES_ON_SAME_ROW_TOGETHER ( "Player", "JudgeHoldNotesOnSameRowTogether" ); ThemeMetric HOLD_CHECKPOINTS ( "Player", "HoldCheckpoints" ); @@ -137,7 +137,7 @@ ThemeMetric REQUIRE_STEP_ON_HOLD_HEADS ( "Player", "RequireStepOnHoldHeads //ThemeMetric REQUIRE_STEP_ON_TAP_NOTES ( "Player", "RequireStepOnTapNotes" ); // parastar stuff; leave in though ThemeMetric ROLL_BODY_INCREMENTS_COMBO ( "Player", "RollBodyIncrementsCombo" ); ThemeMetric CHECKPOINTS_TAPS_SEPARATE_JUDGMENT ( "Player", "CheckpointsTapsSeparateJudgment" ); -ThemeMetric SCORE_MISSED_HOLDS_AND_ROLLS ( "Player", "ScoreMissedHoldsAndRolls" ); +ThemeMetric SCORE_MISSED_HOLDS_AND_ROLLS ( "Player", "ScoreMissedHoldsAndRolls" ); // sm-ssc addition float Player::GetWindowSeconds( TimingWindow tw ) { @@ -374,6 +374,7 @@ void Player::Init( for( int i = 0; i < GAMESTATE->GetCurrentStyle()->m_iColsPerPlayer; ++i ) { HoldJudgment *pJudgment = new HoldJudgment; + // xxx: assumes sprite; todo: don't force 1x2 -aj pJudgment->Load( THEME->GetPathG("HoldJudgment","label 1x2") ); m_vpHoldJudgment[i] = pJudgment; this->AddChild( m_vpHoldJudgment[i] ); @@ -671,6 +672,7 @@ void Player::Update( float fDeltaTime ) // Update Y positions { + // todo: unhardcode hold judgment cmds -aj for( int c=0; cGetCurrentStyle()->m_iColsPerPlayer; c++ ) { float fPercentReverse = m_pPlayerState->m_PlayerOptions.GetCurrent().GetReversePercentForColumn(c); @@ -1040,7 +1042,7 @@ void Player::UpdateHoldNotes( int iSongRow, float fDeltaTime, vectorm_PlayerController == PC_AUTOPLAY ) { - if( m_pPlayerStageStats ) m_pPlayerStageStats->m_bDisqualified = true; } diff --git a/src/PlayerAI.cpp b/src/PlayerAI.cpp index 1b22c75c10..1376e0324b 100644 --- a/src/PlayerAI.cpp +++ b/src/PlayerAI.cpp @@ -75,6 +75,7 @@ TapNoteScore PlayerAI::GetTapNoteScore( const PlayerState* pPlayerState ) return TNS_W1; /* + // handle replay data playback -aj if( pPlayerState->m_PlayerController == PC_REPLAY ) { // ghost house diff --git a/src/ScreenGameplay.cpp b/src/ScreenGameplay.cpp index 3f103d3ae6..0ae0f23057 100644 --- a/src/ScreenGameplay.cpp +++ b/src/ScreenGameplay.cpp @@ -2811,6 +2811,12 @@ void ScreenGameplay::SaveReplay() } } +/* +bool ScreenGameplay::LoadReplay() +{ + // Load +} +*/ // lua start #include "LuaBinding.h" diff --git a/src/ScreenGameplay.h b/src/ScreenGameplay.h index 358b718fe4..e02146d2e4 100644 --- a/src/ScreenGameplay.h +++ b/src/ScreenGameplay.h @@ -177,6 +177,7 @@ protected: virtual void SaveStats(); virtual void StageFinished( bool bBackedOut ); void SaveReplay(); + //bool LoadReplay(); bool AllAreFailing(); virtual void InitSongQueues(); diff --git a/src/ScreenSelectMaster.cpp b/src/ScreenSelectMaster.cpp index 98ef6f0a59..4991d6a653 100644 --- a/src/ScreenSelectMaster.cpp +++ b/src/ScreenSelectMaster.cpp @@ -474,7 +474,8 @@ void ScreenSelectMaster::UpdateSelectableChoices() vector vpns; GetActiveElementPlayerNumbers( vpns ); - if(m_bUsingTwoLists && m_iSelectedList == 1) // using two lists and on the 2nd list + // using two lists and on the 2nd list + if(m_bUsingTwoLists && m_iSelectedList == 1) { for( unsigned c=0; cPlayCommand( "List2Enabled" ); } - + FOREACH( PlayerNumber, vpns, p ) if( m_vsprScroll[*p][c].IsLoaded() ) { m_vsprScroll[*p][c]->PlayCommand( "List2Enabled" ); } - } + } for( unsigned c=0; cPlayCommand( "List2Enabled" ); m_vsprIconB[c]->PlayCommand( m_aGameCommandsB[c].IsPlayable()? "Enabled":"Disabled" ); - + // we will make element 0 the new selection, so it will gain focus if(c==0) m_vsprIconB[c]->PlayCommand( "GainFocus" ); else // everything else loses focus m_vsprIconB[c]->PlayCommand( "LoseFocus" ); } - + FOREACH( PlayerNumber, vpns, p ) if( m_vsprScrollB[*p][c].IsLoaded() ) { @@ -516,11 +517,10 @@ void ScreenSelectMaster::UpdateSelectableChoices() m_vsprScrollB[*p][c]->PlayCommand( "LoseFocus" ); } - } + } } else { - for( unsigned c=0; c vs; if( g_bShowAutoplay ) @@ -126,14 +124,12 @@ void ScreenSyncOverlay::UpdateText() { AdjustSync::GetSyncChangeTextGlobal( vs ); AdjustSync::GetSyncChangeTextSong( vs ); - } + } m_textStatus.SetText( join("\n",vs) ); - // // Update SyncInfo - // bool bVisible = GAMESTATE->m_SongOptions.GetCurrent().m_AutosyncType != SongOptions::AUTOSYNC_OFF; m_textAdjustments.SetVisible( bVisible ); if( bVisible ) diff --git a/src/StepMania.cpp b/src/StepMania.cpp index ac1c7b5877..9602c3dfb0 100644 --- a/src/StepMania.cpp +++ b/src/StepMania.cpp @@ -103,8 +103,10 @@ void StepMania::GetPreferredVideoModeParams( VideoModeParams ¶msOut ) int iWidth = PREFSMAN->m_iDisplayWidth; if( PREFSMAN->m_bWindowed ) { - //float fRatio = PREFSMAN->m_iDisplayWidth / PREFSMAN->m_iDisplayHeight; - //iWidth = PREFSMAN->m_iDisplayHeight * fRatio; + /* + float fRatio = PREFSMAN->m_iDisplayWidth / PREFSMAN->m_iDisplayHeight; + iWidth = PREFSMAN->m_iDisplayHeight * fRatio; + */ iWidth = PREFSMAN->m_iDisplayHeight * PREFSMAN->m_fDisplayAspectRatio; } @@ -645,11 +647,11 @@ bool CheckVideoDefaultSettings() { // Video card changed since last run RString sVideoDriver = GetVideoDriverName(); - + LOG->Trace( "Last seen video driver: %s", PREFSMAN->m_sLastSeenVideoDriver.Get().c_str() ); VideoCardDefaults defaults; - + for( unsigned i=0; iTrace( "Video card has changed from %s to %s. Applying new defaults.", PREFSMAN->m_sLastSeenVideoDriver.Get().c_str(), sVideoDriver.c_str() ); } - + if( bSetDefaultVideoParams ) { PREFSMAN->m_sVideoRenderers.Set( defaults.sVideoRenderers ); @@ -915,7 +917,7 @@ static void WriteLogHeader() #endif // this code should only be enabled in distributed builds - LOG->Info("sm-ssc is Copyright ©2009 the spinal shark collective, all rights reserved. Commercial use of this binary is prohibited by law and will be prosecuted to the fullest extent of the law."); + LOG->Info("sm-ssc is Copyright ©2009 the spinal shark collective, all rights reserved. Commercial use of this binary is prohibited by law and will be prosecuted to the fullest extent of the law."); // end limited code time_t cur_time; diff --git a/src/StepsDisplay.cpp b/src/StepsDisplay.cpp index a7274716e2..7a839d60df 100644 --- a/src/StepsDisplay.cpp +++ b/src/StepsDisplay.cpp @@ -59,7 +59,6 @@ void StepsDisplay::Load( const RString &sMetricsGroup, const PlayerState *pPlaye m_bShowStepsType.Load(m_sMetricsGroup,"ShowStepsType"); m_sZeroMeterString.Load(m_sMetricsGroup,"ZeroMeterString"); - m_sprFrame.Load( THEME->GetPathG(m_sMetricsGroup,"frame") ); m_sprFrame->SetName( "Frame" ); ActorUtil::LoadAllCommandsAndSetXYAndOnCommand( m_sprFrame, m_sMetricsGroup ); @@ -67,7 +66,7 @@ void StepsDisplay::Load( const RString &sMetricsGroup, const PlayerState *pPlaye if( m_bShowTicks ) { - RString sChars = "10"; // on, off + RString sChars = "10"; // on, off (todo: make this metricable -aj) m_textTicks.SetName( "Ticks" ); m_textTicks.LoadFromTextureAndChars( THEME->GetPathF(m_sMetricsGroup,"ticks"), sChars ); ActorUtil::LoadAllCommandsAndSetXYAndOnCommand( m_textTicks, m_sMetricsGroup ); @@ -84,7 +83,7 @@ void StepsDisplay::Load( const RString &sMetricsGroup, const PlayerState *pPlaye // These commands should have been loaded by SetXYAndOnCommand above. ASSERT( m_textMeter.HasCommand("Set") ); } - + if( m_bShowDescription ) { m_textDescription.SetName( "Description" ); @@ -92,7 +91,7 @@ void StepsDisplay::Load( const RString &sMetricsGroup, const PlayerState *pPlaye ActorUtil::LoadAllCommandsAndSetXYAndOnCommand( m_textDescription, m_sMetricsGroup ); this->AddChild( &m_textDescription ); } - + if( m_bShowAutogen ) { m_sprAutogen.Load( THEME->GetPathG(m_sMetricsGroup,"Autogen") ); @@ -242,13 +241,24 @@ void StepsDisplay::SetInternal( const SetParams ¶ms ) { m_textDescription.SetText( sDisplayDescription ); } - + if( m_bShowAutogen ) { bool b = params.pSteps && params.pSteps->IsAutogen(); m_sprAutogen->SetVisible( b ); } + if( m_bShowStepsType ) + { + if( params.st != StepsType_Invalid ) + { + /* + RString sStepsType = GAMEMAN->GetStepsTypeInfo(params.st).szName; + m_sprStepsType.Load( THEME->GetPathG(m_sMetricsGroup,"StepsType "+sStepsType) ); + */ + } + } + this->HandleMessage( msg ); } diff --git a/src/arch/ArchHooks/ArchHooks.h b/src/arch/ArchHooks/ArchHooks.h index b4cae22b44..847149d7e6 100644 --- a/src/arch/ArchHooks/ArchHooks.h +++ b/src/arch/ArchHooks/ArchHooks.h @@ -107,12 +107,12 @@ public: * Return true if the application has input focus. */ bool AppHasFocus() const { return m_bHasFocus; } - + /* * Returns true if the application's focus has changed since last called. */ bool AppFocusChanged(); - + /* * Open a URL in the default web browser */