From aac47c97772d12852f62e9f90379999fc72976a2 Mon Sep 17 00:00:00 2001 From: Shenjoku Date: Mon, 29 Apr 2013 16:29:55 -0400 Subject: [PATCH 1/7] Fix potential leak in Font --- src/Font.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Font.cpp b/src/Font.cpp index a2f9824993..e0c3841bbc 100644 --- a/src/Font.cpp +++ b/src/Font.cpp @@ -741,8 +741,6 @@ void Font::Load( const RString &sIniPath, RString sChars ) { const RString &sTexturePath = asTexturePaths[i]; - FontPage *pPage = new FontPage; - // Grab the page name, eg "foo" from "Normal [foo].png". RString sPagename = GetPageNameFromFileName( sTexturePath ); @@ -750,6 +748,9 @@ void Font::Load( const RString &sIniPath, RString sChars ) if( sTexturePath.find("-stroke") != string::npos ) continue; + // Create this down here so it doesn't leak if the continue gets triggered. + FontPage *pPage = new FontPage; + // Load settings for this page from the INI. FontPageSettings cfg; LoadFontPageSettings( cfg, ini, sTexturePath, "common", sChars ); From 569ca0f98443740f6ebaba15a47984c51534c6b7 Mon Sep 17 00:00:00 2001 From: Shenjoku Date: Mon, 29 Apr 2013 16:30:54 -0400 Subject: [PATCH 2/7] fix leak in LifeMeterTime --- src/LifeMeterTime.cpp | 6 ++++++ src/LifeMeterTime.h | 2 ++ 2 files changed, 8 insertions(+) diff --git a/src/LifeMeterTime.cpp b/src/LifeMeterTime.cpp index d2eba75565..a113d26fae 100644 --- a/src/LifeMeterTime.cpp +++ b/src/LifeMeterTime.cpp @@ -48,6 +48,12 @@ LifeMeterTime::LifeMeterTime() { m_fLifeTotalGainedSeconds = 0; m_fLifeTotalLostSeconds = 0; + m_pStream = NULL; +} + +LifeMeterTime::~LifeMeterTime() +{ + delete m_pStream; } void LifeMeterTime::Load( const PlayerState *pPlayerState, PlayerStageStats *pPlayerStageStats ) diff --git a/src/LifeMeterTime.h b/src/LifeMeterTime.h index d2bd54e69c..c975286739 100644 --- a/src/LifeMeterTime.h +++ b/src/LifeMeterTime.h @@ -16,6 +16,8 @@ class LifeMeterTime : public LifeMeter public: LifeMeterTime(); + virtual ~LifeMeterTime(); + virtual void Load( const PlayerState *pPlayerState, PlayerStageStats *pPlayerStageStats ); virtual void Update( float fDeltaTime ); From 91b1892d0925f3db4f0309b74c955605a2ebb8cc Mon Sep 17 00:00:00 2001 From: Shenjoku Date: Mon, 29 Apr 2013 16:33:32 -0400 Subject: [PATCH 3/7] Fix leak in MenuTimer --- src/MenuTimer.cpp | 5 +++++ src/MenuTimer.h | 1 + 2 files changed, 6 insertions(+) diff --git a/src/MenuTimer.cpp b/src/MenuTimer.cpp index 59e420a799..066b593e29 100644 --- a/src/MenuTimer.cpp +++ b/src/MenuTimer.cpp @@ -22,6 +22,11 @@ MenuTimer::MenuTimer() WARNING_COMMAND = NULL; } +MenuTimer::~MenuTimer() +{ + delete WARNING_COMMAND; +} + void MenuTimer::Load( RString sMetricsGroup ) { m_sprFrame.Load( THEME->GetPathG(sMetricsGroup, "Frame") ); diff --git a/src/MenuTimer.h b/src/MenuTimer.h index cd3a211c54..f95c5c5c1b 100644 --- a/src/MenuTimer.h +++ b/src/MenuTimer.h @@ -15,6 +15,7 @@ class MenuTimer : public ActorFrame { public: MenuTimer(); + virtual ~MenuTimer(); void Load( RString sMetricsGroup ); virtual void Update( float fDeltaTime ); From 1d1f37380ea593d7c25ae4090b69f7200d694fdf Mon Sep 17 00:00:00 2001 From: Shenjoku Date: Mon, 29 Apr 2013 16:38:37 -0400 Subject: [PATCH 4/7] Make sure StreamDisplay children are deleted --- src/StreamDisplay.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/StreamDisplay.cpp b/src/StreamDisplay.cpp index f278f92c1b..d6ddba882e 100644 --- a/src/StreamDisplay.cpp +++ b/src/StreamDisplay.cpp @@ -21,6 +21,8 @@ StreamDisplay::StreamDisplay() m_fPassingAlpha = 0; m_fHotAlpha = 0; m_bAlwaysBounce = false; + + m_bDeleteChildren = true; } void StreamDisplay::Load( const RString & /* unreferenced: _sMetricsGroup */) From 15eaad8c867c4231627898908b7f68801c43fddf Mon Sep 17 00:00:00 2001 From: Jason Felds Date: Mon, 29 Apr 2013 19:17:30 -0400 Subject: [PATCH 5/7] Don't include the internal header. Use a standard header to include instead. --- src/archutils/Darwin/arch_setup.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/archutils/Darwin/arch_setup.h b/src/archutils/Darwin/arch_setup.h index 2b21c5ddaf..5df4ca9414 100644 --- a/src/archutils/Darwin/arch_setup.h +++ b/src/archutils/Darwin/arch_setup.h @@ -44,7 +44,7 @@ extern "C" int SM_main( int argc, char *argv[] ); #define HAVE_BYTE_SWAPS // Define the work around if needed. -#include +#include #include #if _GLIBCXX_USE_C99 # define NEED_CSTDLIB_WORKAROUND From 7e8c75a71b3491b2aa543e054819cccb031f97cb Mon Sep 17 00:00:00 2001 From: "Devin J. Pohly" Date: Mon, 29 Apr 2013 20:24:07 -0400 Subject: [PATCH 6/7] remove check for ancient llabs() bug --- src/archutils/Darwin/arch_setup.h | 9 --------- 1 file changed, 9 deletions(-) diff --git a/src/archutils/Darwin/arch_setup.h b/src/archutils/Darwin/arch_setup.h index 5df4ca9414..f28541ef4d 100644 --- a/src/archutils/Darwin/arch_setup.h +++ b/src/archutils/Darwin/arch_setup.h @@ -43,15 +43,6 @@ extern "C" int SM_main( int argc, char *argv[] ); #define ArchSwap16(n) OSSwapInt16((n)) #define HAVE_BYTE_SWAPS -// Define the work around if needed. -#include -#include -#if _GLIBCXX_USE_C99 -# define NEED_CSTDLIB_WORKAROUND -#else -inline int64_t llabs( int64_t x ) { return x < 0LL ? -x : x; } -#endif - #define attribute_deprecated // Shut ffmpeg up! #endif From 78d5be779fc47b551c595242511235c7bfb36d2e Mon Sep 17 00:00:00 2001 From: Flameshadowxeroshin Date: Wed, 1 May 2013 22:11:27 -0500 Subject: [PATCH 7/7] Add metric [Gameplay] UseInternalScoring. Turn it off to prevent the game from touching custom scoring stuff. It is by default on. --- Themes/_fallback/metrics.ini | 1 + src/ScoreKeeperNormal.cpp | 133 ++++++++++++++++++----------------- src/ScoreKeeperNormal.h | 1 + 3 files changed, 71 insertions(+), 64 deletions(-) diff --git a/Themes/_fallback/metrics.ini b/Themes/_fallback/metrics.ini index 0502e26b1a..247ec13a85 100644 --- a/Themes/_fallback/metrics.ini +++ b/Themes/_fallback/metrics.ini @@ -572,6 +572,7 @@ MinScoreToMaintainCombo=ComboMaintain() MaxScoreToIncrementMissCombo='TapNoteScore_Miss' MineHitIncrementsMissCombo=false AvoidMineIncrementsCombo=false +UseInternalScoring=true # When you hit it, you know. ToastyTriggersAt=250 diff --git a/src/ScoreKeeperNormal.cpp b/src/ScoreKeeperNormal.cpp index 9c7748f091..2ff68dd11b 100644 --- a/src/ScoreKeeperNormal.cpp +++ b/src/ScoreKeeperNormal.cpp @@ -89,6 +89,7 @@ void ScoreKeeperNormal::Load( m_MaxScoreToIncrementMissCombo.Load( "Gameplay", "MaxScoreToIncrementMissCombo" ); m_MineHitIncrementsMissCombo.Load( "Gameplay", "MineHitIncrementsMissCombo" ); m_AvoidMineIncrementsCombo.Load( "Gameplay", "AvoidMineIncrementsCombo" ); + m_UseInternalScoring.Load( "Gameplay", "UseInternalScoring" ); // Toasty triggers (idea from 3.9+) // Multiple toasty support doesn't seem to be working right now. @@ -299,76 +300,80 @@ void ScoreKeeperNormal::HandleTapScoreNone() void ScoreKeeperNormal::AddScoreInternal( TapNoteScore score ) { - int &iScore = m_pPlayerStageStats->m_iScore; - int &iCurMaxScore = m_pPlayerStageStats->m_iCurMaxScore; - - // See Aaron In Japan for more details about the scoring formulas. - // Note: this assumes no custom scoring systems are in use. - int p = 0; // score multiplier - - switch( score ) + if( m_UseInternalScoring ) { - case TNS_W1: p = 10; break; - case TNS_W2: p = GAMESTATE->ShowW1()? 9:10; break; - case TNS_W3: p = 5; break; - default: p = 0; break; - } + + int &iScore = m_pPlayerStageStats->m_iScore; + int &iCurMaxScore = m_pPlayerStageStats->m_iCurMaxScore; - m_iTapNotesHit++; + // See Aaron In Japan for more details about the scoring formulas. + // Note: this assumes no custom scoring systems are in use. + int p = 0; // score multiplier - const int N = m_iNumTapsAndHolds; - const int sum = (N * (N + 1)) / 2; - const int Z = m_iMaxPossiblePoints/10; - - // Don't use a multiplier if the player has failed - if( m_pPlayerStageStats->m_bFailed ) - { - iScore += p; - // make score evenly divisible by 5 - // only update this on the next step, to make it less *obvious* - /* Round to the nearest 5, instead of always rounding down, so a base score - * of 9 will round to 10, not 5. */ - if (p > 0) - iScore = ((iScore+2) / 5) * 5; - } - else - { - iScore += GetScore(p, Z, sum, m_iTapNotesHit); - const int &iCurrentCombo = m_pPlayerStageStats->m_iCurCombo; - iScore += m_ComboBonusFactor[score] * iCurrentCombo; - } - - // Subtract the maximum this step could have been worth from the bonus. - m_iPointBonus -= GetScore(10, Z, sum, m_iTapNotesHit); - // And add the maximum this step could have been worth to the max score up to now. - iCurMaxScore += GetScore(10, Z, sum, m_iTapNotesHit); - - if ( m_iTapNotesHit == m_iNumTapsAndHolds && score >= TNS_W2 ) - { - if( !m_pPlayerStageStats->m_bFailed ) - iScore += m_iPointBonus; - if ( m_bIsLastSongInCourse ) + switch( score ) { - iScore += 100000000 - m_iMaxScoreSoFar; - iCurMaxScore += 100000000 - m_iMaxScoreSoFar; - - /* If we're in Endless mode, we'll come around here again, so reset - * the bonus counter. */ - m_iMaxScoreSoFar = 0; + case TNS_W1: p = 10; break; + case TNS_W2: p = GAMESTATE->ShowW1()? 9:10; break; + case TNS_W3: p = 5; break; + default: p = 0; break; } - iCurMaxScore += m_iPointBonus; + + m_iTapNotesHit++; + + const int N = m_iNumTapsAndHolds; + const int sum = (N * (N + 1)) / 2; + const int Z = m_iMaxPossiblePoints/10; + + // Don't use a multiplier if the player has failed + if( m_pPlayerStageStats->m_bFailed ) + { + iScore += p; + // make score evenly divisible by 5 + // only update this on the next step, to make it less *obvious* + /* Round to the nearest 5, instead of always rounding down, so a base score + * of 9 will round to 10, not 5. */ + if (p > 0) + iScore = ((iScore+2) / 5) * 5; + } + else + { + iScore += GetScore(p, Z, sum, m_iTapNotesHit); + const int &iCurrentCombo = m_pPlayerStageStats->m_iCurCombo; + iScore += m_ComboBonusFactor[score] * iCurrentCombo; + } + + // Subtract the maximum this step could have been worth from the bonus. + m_iPointBonus -= GetScore(10, Z, sum, m_iTapNotesHit); + // And add the maximum this step could have been worth to the max score up to now. + iCurMaxScore += GetScore(10, Z, sum, m_iTapNotesHit); + + if ( m_iTapNotesHit == m_iNumTapsAndHolds && score >= TNS_W2 ) + { + if( !m_pPlayerStageStats->m_bFailed ) + iScore += m_iPointBonus; + if ( m_bIsLastSongInCourse ) + { + iScore += 100000000 - m_iMaxScoreSoFar; + iCurMaxScore += 100000000 - m_iMaxScoreSoFar; + + /* If we're in Endless mode, we'll come around here again, so reset + * the bonus counter. */ + m_iMaxScoreSoFar = 0; + } + iCurMaxScore += m_iPointBonus; + } + + ASSERT_M( iScore >= 0, "iScore < 0 before re-rounding" ); + + // Undo rounding from the last tap, and re-round. + iScore += m_iScoreRemainder; + m_iScoreRemainder = (iScore % m_iRoundTo); + iScore = iScore - m_iScoreRemainder; + + ASSERT_M( iScore >= 0, "iScore < 0 after re-rounding" ); + + // LOG->Trace( "score: %i", iScore ); } - - ASSERT_M( iScore >= 0, "iScore < 0 before re-rounding" ); - - // Undo rounding from the last tap, and re-round. - iScore += m_iScoreRemainder; - m_iScoreRemainder = (iScore % m_iRoundTo); - iScore = iScore - m_iScoreRemainder; - - ASSERT_M( iScore >= 0, "iScore < 0 after re-rounding" ); - - // LOG->Trace( "score: %i", iScore ); } void ScoreKeeperNormal::HandleTapScore( const TapNote &tn ) diff --git a/src/ScoreKeeperNormal.h b/src/ScoreKeeperNormal.h index 20e8b78a42..59da85f0d1 100644 --- a/src/ScoreKeeperNormal.h +++ b/src/ScoreKeeperNormal.h @@ -40,6 +40,7 @@ class ScoreKeeperNormal: public ScoreKeeper ThemeMetric m_MaxScoreToIncrementMissCombo; ThemeMetric m_MineHitIncrementsMissCombo; ThemeMetric m_AvoidMineIncrementsCombo; + ThemeMetric m_UseInternalScoring; //ThemeMetric m_vToastyTriggers; ThemeMetric m_ToastyTrigger;