From 64690cdb407faefa3d19fd37479f2abb555184e4 Mon Sep 17 00:00:00 2001 From: Chris Danford Date: Wed, 15 Jun 2005 01:59:40 +0000 Subject: [PATCH] use DEFAULT_WEIGHT_POUNDS if weight not explicitly set --- stepmania/src/Player.cpp | 54 ++++++++++++++--------------- stepmania/src/Profile.cpp | 72 ++++++++++++++++----------------------- stepmania/src/Profile.h | 1 + 3 files changed, 55 insertions(+), 72 deletions(-) diff --git a/stepmania/src/Player.cpp b/stepmania/src/Player.cpp index 8dde5d1a18..ef64d01e7d 100644 --- a/stepmania/src/Player.cpp +++ b/stepmania/src/Player.cpp @@ -806,37 +806,33 @@ void Player::HandleStep( int col, const RageTimer &tm, bool bHeld ) Profile* pProfile = PROFILEMAN->GetProfile(pn); if( pProfile ) { - int iLbs = pProfile->m_iWeightPounds; - if( iLbs != 0 ) + int iNumTracksHeld = 0; + for( int t=0; tGetCurrentStyle()->StyleInputToGameInput( StyleI ); - float fSecsHeld = INPUTMAPPER->GetSecsHeld( GameI ); - if( fSecsHeld > 0 ) - iNumTracksHeld++; - } - - float fCals = 0; - switch( iNumTracksHeld ) - { - case 0: - // autoplay is on, or this is a computer player - iNumTracksHeld = 1; - // fall through - default: - { - float fCalsFor100Lbs = SCALE( iNumTracksHeld, 1, 2, 0.029f, 0.193f ); - float fCalsFor200Lbs = SCALE( iNumTracksHeld, 1, 2, 0.052f, 0.334f ); - fCals = SCALE( iLbs, 100.f, 200.f, fCalsFor100Lbs, fCalsFor200Lbs ); - } - break; - } - - m_pPlayerStageStats->fCaloriesBurned += fCals; + const StyleInput StyleI( pn, t ); + const GameInput GameI = GAMESTATE->GetCurrentStyle()->StyleInputToGameInput( StyleI ); + float fSecsHeld = INPUTMAPPER->GetSecsHeld( GameI ); + if( fSecsHeld > 0 ) + iNumTracksHeld++; } + + float fCals = 0; + switch( iNumTracksHeld ) + { + case 0: + // autoplay is on, or this is a computer player + iNumTracksHeld = 1; + // fall through + default: + { + float fCalsFor100Lbs = SCALE( iNumTracksHeld, 1, 2, 0.029f, 0.193f ); + float fCalsFor200Lbs = SCALE( iNumTracksHeld, 1, 2, 0.052f, 0.334f ); + fCals = SCALE( pProfile->GetCalculatedWeightPounds(), 100.f, 200.f, fCalsFor100Lbs, fCalsFor200Lbs ); + } + break; + } + + m_pPlayerStageStats->fCaloriesBurned += fCals; } } diff --git a/stepmania/src/Profile.cpp b/stepmania/src/Profile.cpp index cb5cc4c227..6622fedd8b 100644 --- a/stepmania/src/Profile.cpp +++ b/stepmania/src/Profile.cpp @@ -46,7 +46,8 @@ const CString LASTGOOD_SUBDIR = "LastGood/"; * 10 /* HighScores per Steps */ \ * 1024 /* size in bytes of a HighScores XNode */ -#define MAX_DISPLAY_NAME_LENGTH 12 +const int MAX_DISPLAY_NAME_LENGTH = 12; +const int DEFAULT_WEIGHT_POUNDS = 120; #if defined(_MSC_VER) #pragma warning (disable : 4706) // assignment within conditional expression @@ -103,10 +104,10 @@ void Profile::InitGeneralData() m_iTotalMines = 0; m_iTotalHands = 0; - for( int i=0; i::const_iterator i = m_SongHighScores.begin(); - i != m_SongHighScores.end(); - ++i ) + FOREACHM_CONST( SongID, HighScoresForASong, m_SongHighScores, i ) { const SongID &id = i->first; Song* pSong = id.ToSong(); @@ -317,9 +318,7 @@ float Profile::GetSongsActual( StepsType st, Difficulty dc ) const CHECKPOINT_M( ssprintf("Profile::GetSongsActual: song %s", pSong->GetSongDir().c_str()) ); const HighScoresForASong &hsfas = i->second; - for( map::const_iterator j = hsfas.m_StepsHighScores.begin(); - j != hsfas.m_StepsHighScores.end(); - ++j ) + FOREACHM_CONST( StepsID, HighScoresForASteps, hsfas.m_StepsHighScores, j ) { const StepsID &id = j->first; Steps* pSteps = id.ToSteps( pSong, true ); @@ -385,9 +384,7 @@ float Profile::GetCoursesActual( StepsType st, CourseDifficulty cd ) const float fTotalPercents = 0; // add course high scores - for( map::const_iterator i = m_CourseHighScores.begin(); - i != m_CourseHighScores.end(); - i++ ) + FOREACHM_CONST( CourseID, HighScoresForACourse, m_CourseHighScores, i ) { CourseID id = i->first; const Course* pCourse = id.ToCourse(); @@ -403,9 +400,7 @@ float Profile::GetCoursesActual( StepsType st, CourseDifficulty cd ) const const HighScoresForACourse &hsfac = i->second; - for( map::const_iterator j = hsfac.m_TrailHighScores.begin(); - j != hsfac.m_TrailHighScores.end(); - ++j ) + FOREACHM_CONST( TrailID, HighScoresForATrail, hsfac.m_TrailHighScores, j ) { const TrailID &id = j->first; Trail* pTrail = id.ToTrail( pCourse, true ); @@ -474,9 +469,7 @@ int Profile::GetSongNumTimesPlayed( const SongID& songID ) const return 0; int iTotalNumTimesPlayed = 0; - for( map::const_iterator j = hsSong->m_StepsHighScores.begin(); - j != hsSong->m_StepsHighScores.end(); - j++ ) + FOREACHM_CONST( StepsID, HighScoresForASteps, hsSong->m_StepsHighScores, j ) { const HighScoresForASteps &hsSteps = j->second; @@ -590,8 +583,7 @@ void Profile::GetGrades( const Song* pSong, StepsType st, int iCounts[NUM_GRADES FOREACH_Grade(g) { - map::const_iterator it; - for( it = hsSong->m_StepsHighScores.begin(); it != hsSong->m_StepsHighScores.end(); ++it ) + FOREACHM_CONST( StepsID, HighScoresForASteps, hsSong->m_StepsHighScores, it ) { const StepsID &id = it->first; if( !id.MatchesStepsType(st) ) @@ -646,9 +638,7 @@ int Profile::GetCourseNumTimesPlayed( const CourseID &courseID ) const return 0; int iTotalNumTimesPlayed = 0; - for( map::const_iterator j = hsCourse->m_TrailHighScores.begin(); - j != hsCourse->m_TrailHighScores.end(); - j++ ) + FOREACHM_CONST( TrailID, HighScoresForATrail, hsCourse->m_TrailHighScores, j ) { const HighScoresForATrail &hsTrail = j->second; @@ -914,6 +904,7 @@ XNode* Profile::SaveGeneralDataCreateNode() const // redundant to the game app. pGeneralDataNode->AppendChild( "DisplayName", GetDisplayName() ); pGeneralDataNode->AppendChild( "IsMachine", IsMachine() ); + pGeneralDataNode->AppendChild( "IsWeightSet", m_iWeightPounds != 0 ); pGeneralDataNode->AppendChild( "Guid", m_sGuid ); pGeneralDataNode->AppendChild( "SortOrder", SortOrderToString(m_SortOrder) ); @@ -928,7 +919,7 @@ XNode* Profile::SaveGeneralDataCreateNode() const pGeneralDataNode->AppendChild( "TotalCaloriesBurned", m_fTotalCaloriesBurned ); pGeneralDataNode->AppendChild( "GoalType", m_GoalType ); pGeneralDataNode->AppendChild( "GoalCalories", m_iGoalCalories ); - pGeneralDataNode->AppendChild( "GoalSeconds", m_iGoalSeconds ); + pGeneralDataNode->AppendChild( "GoalSeconds", m_iGoalSeconds ); pGeneralDataNode->AppendChild( "LastPlayedMachineGuid", m_sLastPlayedMachineGuid ); pGeneralDataNode->AppendChild( "LastPlayedDate", m_LastPlayedDate ); pGeneralDataNode->AppendChild( "TotalDancePoints", m_iTotalDancePoints ); @@ -949,13 +940,13 @@ XNode* Profile::SaveGeneralDataCreateNode() const { XNode* pDefaultModifiers = pGeneralDataNode->AppendChild("DefaultModifiers"); - for( map::const_iterator it = m_sDefaultModifiers.begin(); it != m_sDefaultModifiers.end(); ++it ) + FOREACHM_CONST( CString, CString, m_sDefaultModifiers, it ) pDefaultModifiers->AppendChild( it->first, it->second ); } { XNode* pUnlockedSongs = pGeneralDataNode->AppendChild("UnlockedSongs"); - for( set::const_iterator it = m_UnlockedSongs.begin(); it != m_UnlockedSongs.end(); ++it ) + FOREACHS_CONST( int, m_UnlockedSongs, it ) pUnlockedSongs->AppendChild( ssprintf("Unlock%i", *it) ); } @@ -972,9 +963,7 @@ XNode* Profile::SaveGeneralDataCreateNode() const { XNode* pNumSongsPlayedByStyle = pGeneralDataNode->AppendChild("NumSongsPlayedByStyle"); - for( map::const_iterator iter = m_iNumSongsPlayedByStyle.begin(); - iter != m_iNumSongsPlayedByStyle.end(); - iter++ ) + FOREACHM_CONST( StyleID, int, m_iNumSongsPlayedByStyle, iter ) { const StyleID &s = iter->first; int iNumPlays = iter->second; @@ -1063,7 +1052,7 @@ Profile::LoadResult Profile::LoadEditableDataFromDir( CString sDir ) m_sDisplayName = WStringToCString(wstr); // TODO: strip invalid chars? if( m_iWeightPounds != 0 ) - CLAMP( m_iWeightPounds, 50, 500 ); + CLAMP( m_iWeightPounds, 20, 1000 ); return success; } @@ -1209,13 +1198,10 @@ void Profile::AddStepTotals( int iTotalTapsAndHolds, int iTotalJumps, int iTotal m_iTotalMines += iTotalMines; m_iTotalHands += iTotalHands; - if( m_iWeightPounds != 0 ) - { - m_fTotalCaloriesBurned += fCaloriesBurned; + m_fTotalCaloriesBurned += fCaloriesBurned; - DateTime date = DateTime::GetNowDate(); - m_mapDayToCaloriesBurned[date] += fCaloriesBurned; - } + DateTime date = DateTime::GetNowDate(); + m_mapDayToCaloriesBurned[date] += fCaloriesBurned; } XNode* Profile::SaveSongScoresCreateNode() const diff --git a/stepmania/src/Profile.h b/stepmania/src/Profile.h index b006752473..8c8afeb6ab 100644 --- a/stepmania/src/Profile.h +++ b/stepmania/src/Profile.h @@ -66,6 +66,7 @@ public: CString GetDisplayName() const; CString GetDisplayTotalCaloriesBurned() const; // remove me and use Lua instead CString GetDisplayTotalCaloriesBurnedToday() const; // remove me and use Lua instead + int GetCalculatedWeightPounds() const; // returns a default value if m_iWeightPounds isn't set float GetCaloriesBurnedToday() const; int GetTotalNumSongsPassed() const; int GetTotalStepsWithTopGrade( StepsType st, Difficulty d, Grade g ) const;