From fd1f1a5df8633ee59a3fbf8736898058da9694f3 Mon Sep 17 00:00:00 2001 From: Jason Felds Date: Sun, 13 Feb 2011 10:46:05 -0500 Subject: [PATCH 1/5] Place back in alphabetical order. --- Xcode/stepmania.xcodeproj/project.pbxproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Xcode/stepmania.xcodeproj/project.pbxproj b/Xcode/stepmania.xcodeproj/project.pbxproj index dedd8ea04a..2a8a86ed48 100644 --- a/Xcode/stepmania.xcodeproj/project.pbxproj +++ b/Xcode/stepmania.xcodeproj/project.pbxproj @@ -3692,8 +3692,6 @@ AA6EFDC804770AF1005F316C /* DataStructures */ = { isa = PBXGroup; children = ( - EE906F8812BF3C7C00146C96 /* FileDownload.cpp */, - EE906F8912BF3C7C00146C96 /* FileDownload.h */, AA84B7050996F8370085EECB /* AdjustSync.cpp */, AA84B7060996F8370085EECB /* AdjustSync.h */, AAFF5541054E736D00D02EE9 /* Attack.cpp */, @@ -3731,6 +3729,8 @@ AA8F136F0624BAB200C6A467 /* EnumHelper.h */, AAE7808506081A000034E65F /* ezsockets.cpp */, AAE7808606081A000034E65F /* ezsockets.h */, + EE906F8812BF3C7C00146C96 /* FileDownload.cpp */, + EE906F8912BF3C7C00146C96 /* FileDownload.h */, AA6EFDD104770C79005F316C /* Font.cpp */, AA6EFDD204770C79005F316C /* Font.h */, AA6EFDD304770C79005F316C /* FontCharAliases.cpp */, From d6f08c27cb410ac6b47762bcb2c0c63785115ab0 Mon Sep 17 00:00:00 2001 From: Jason Felds Date: Sun, 13 Feb 2011 11:14:58 -0500 Subject: [PATCH 2/5] Hodgepodge of doxygen. Long way to go. --- src/CourseUtil.h | 8 +-- src/GameManager.h | 16 ++++-- src/Grade.h | 39 +++++++++----- src/NoteTypes.cpp | 25 ++++++++- src/NoteTypes.h | 127 ++++++++++++++++++++++++++++---------------- src/ProductInfo.h | 51 ++++++++++++------ src/RadarValues.h | 26 +++++++-- src/ScoreKeeper.h | 8 +-- src/SongManager.cpp | 1 + src/SongManager.h | 11 ++-- src/SongUtil.cpp | 6 ++- src/SongUtil.h | 52 ++++++++++++++++-- src/Steps.cpp | 2 +- src/Steps.h | 83 ++++++++++++++++++++++++----- 14 files changed, 342 insertions(+), 113 deletions(-) diff --git a/src/CourseUtil.h b/src/CourseUtil.h index 80bf355c6f..d0c4738cef 100644 --- a/src/CourseUtil.h +++ b/src/CourseUtil.h @@ -1,4 +1,4 @@ -/* CourseUtil - Utility functions that deal with Course. */ +/** @brief CourseUtil - Utility functions that deal with Course. */ #ifndef COURSEUTIL_H #define COURSEUTIL_H @@ -93,8 +93,10 @@ private: #endif -/* - * (c) 2001-2004 Chris Danford +/** + * @file + * @author Chris Danford (c) 2001-2004 + * @section LICENSE * All rights reserved. * * Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/GameManager.h b/src/GameManager.h index 9f6bf091e9..666700bb62 100644 --- a/src/GameManager.h +++ b/src/GameManager.h @@ -1,4 +1,4 @@ -/* GameManager - Manages Games and Styles. */ +/** @brief GameManager - Manages Games and Styles. */ #ifndef GAMEMANAGER_H #define GAMEMANAGER_H @@ -10,12 +10,16 @@ struct lua_State; #include "GameConstantsAndTypes.h" #include "GameInput.h" +/** @brief The collective information about a Steps' Type. */ struct StepsTypeInfo { const char *szName; + /** @brief The number of tracks, or columns, of this type. */ int iNumTracks; - bool bAllowAutogen; // allow this type to be autogen'd to other types - StepsTypeCategory m_StepsTypeCategory; // what is the most basic StyleType this is used with? + /** @brief A flag to determine if we allow this type to be autogen'ed to other types. */ + bool bAllowAutogen; + /** @brief The most basic StyleType that this StpesTypeInfo is used with. */ + StepsTypeCategory m_StepsTypeCategory; RString GetLocalizedString() const; }; @@ -55,8 +59,10 @@ extern GameManager* GAMEMAN; // global and accessable from anywhere in our progr #endif -/* - * (c) 2001-2004 Chris Danford, Glenn Maynard +/** + * @file + * @author Chris Danford, Glenn Maynard (c) 2001-2004 + * @section LICENSE * All rights reserved. * * Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Grade.h b/src/Grade.h index 34d6dc2286..c520f39c6c 100644 --- a/src/Grade.h +++ b/src/Grade.h @@ -1,4 +1,4 @@ -/* Grade - Mark the player receives after clearing a song. */ +/** @brief Grade - Mark the player receives after clearing a song. */ #ifndef GRADE_H #define GRADE_H @@ -7,16 +7,21 @@ #include "EnumHelper.h" #include "ThemeMetric.h" +/** + * @brief Have a specific number of passing grade tiers. + * + * TODO: Look into flexible grading tiers. */ #define NUM_Grade_TierS 20 +/** @brief The list of grading tiers available. */ enum Grade { - Grade_Tier01, // = AAAA - Grade_Tier02, // = AAA - Grade_Tier03, // = AA - Grade_Tier04, // = A - Grade_Tier05, // = B - Grade_Tier06, // = C - Grade_Tier07, // = D + Grade_Tier01, /**< Usually an AAAA */ + Grade_Tier02, /**< Usually an AAA */ + Grade_Tier03, /**< Usually an AA */ + Grade_Tier04, /**< Usually an A */ + Grade_Tier05, /**< Usually a B */ + Grade_Tier06, /**< Usually a C */ + Grade_Tier07, /**< Usually a D */ Grade_Tier08, Grade_Tier09, Grade_Tier10, @@ -30,14 +35,20 @@ enum Grade Grade_Tier18, Grade_Tier19, Grade_Tier20, - Grade_Failed, // = E + Grade_Failed, /**< Usually an E */ NUM_Grade, Grade_Invalid, }; #define Grade_NoData Grade_Invalid -/* This is in the header so the test sets don't require Grade.cpp (through PrefsManager), - * since that pulls in ThemeManager. */ +/** + * @brief Convert the grade supplied to a string representation. + * + * This is in the header so the test sets don't require Grade.cpp (through PrefsManager), + * since that pulls in ThemeManager. + * @param g the grade to convert. + * @return the string reprsentation. + */ static inline RString GradeToString( Grade g ) { ASSERT_M( (g >= 0 && g= TNS_W5). */ + /** + * @brief Offset, in seconds, for a tap grade. + * + * Negative numbers mean the note was hit early; positive numbers mean + * it was hit late. These values are only meaningful for graded taps + * (tns >= TNS_W5). */ float fTapNoteOffset; - // If the whole row has been judged, all taps on the row will be set to hidden. + /** @brief If the whole row has been judged, all taps on the row will be set to hidden. */ bool bHidden; // XML XNode* CreateNode() const; void LoadFromNode( const XNode* pNode ); }; - +/** @brief The result of holding (or letting go of) a hold note. */ struct HoldNoteResult { HoldNoteResult() : hns(HNS_None), fLife(1.f), fOverlappedTime(0), iLastHeldRow(0), iCheckpointsHit(0), iCheckpointsMissed(0), bHeld(false), bActive(false) { } @@ -34,46 +39,58 @@ struct HoldNoteResult HoldNoteScore hns; - /* 1.0 means this HoldNote has full life. - * 0.0 means this HoldNote is dead + /** + * @brief the current life of the hold. + * + * 1.0 means this HoldNote has full life. + * + * 0.0 means this HoldNote is dead. + * * When this value hits 0.0 for the first time, m_HoldScore becomes HNS_LetGo. * If the life is > 0.0 when the HoldNote ends, then m_HoldScore becomes HNS_Held. */ float fLife; - /* The number of seconds the hold note has overlapped the current beat, or 0 - * if it doesn't overlap. */ + /** @brief The number of seconds the hold note has overlapped the current beat. + * + * This value is 0 if it doesn't overlap. */ float fOverlappedTime; - /* Last index where fLife was greater than 0. If the tap was missed, this + /** @brief Last index where fLife was greater than 0. If the tap was missed, this * will be the first index of the hold. */ int iLastHeldRow; - // If checkpoint holds are enabled, the number of checkpoints hit and missed. + /** @brief If checkpoint holds are enabled, the number of checkpoints hit. */ int iCheckpointsHit; + /** @brief If checkpoint holds are enabled, the number of checkpoints missed. */ int iCheckpointsMissed; - bool bHeld; // Was button held during last update? - bool bActive; // Is life > 0 && overlaps current beat + /** @brief Was the button held during the last update? */ + bool bHeld; + /** @brief Is there life in the hold and does it overlap the current beat? */ + bool bActive; // XML XNode* CreateNode() const; void LoadFromNode( const XNode* pNode ); }; +/** @brief The various properties of a tap note. */ struct TapNote { + /** @brief What is the TapNote's core type? */ enum Type { - empty, // no note here - tap, // step on this - hold_head, // graded like a tap - hold_tail, // in 2sand3s mode, holds are deleted and hold_tail is added - mine, // don't step! - lift, // up - attack, - autoKeysound, - fake, // not scored for or against + empty, /**< There is no note here. */ + tap, /**< The player simply steps on this. */ + hold_head, /**< This is graded like the Tap type, but should be held. */ + hold_tail, /**< In 2sand3s mode, holds are deleted and hold_tail is added. */ + mine, /**< In most modes, it is suggested to not step on these mines. */ + lift, /**< Lift your foot up when it crosses the target area. */ + attack, /**< Hitting this note causes an attack to take place. */ + autoKeysound, /**< A special sound is played when this note crosses the target area. */ + fake, /**< This arrow can't be scored for or against the player. */ }; + /** @brief The list of a TapNote's sub types. */ enum SubType { hold_head_hold, @@ -82,18 +99,24 @@ struct TapNote NUM_SubType, SubType_Invalid }; + /** @brief The different places a TapNote could come from. */ enum Source { - original, // part of the original NoteData - addition, // additional note added by a transform + original, /**< This note is part of the original NoteData. */ + addition, /**< This note is additional note added by a transform. */ }; - + /** @brief The core note type that is about to cross the target area. */ Type type; - SubType subType; // Only used if type is hold_head. + /** @brief The sub type of the note. This is only used if the type is hold_head. */ + SubType subType; + /** @brief The originating source of the TapNote. */ Source source; + /** @brief The result of hitting or missing the TapNote. */ TapNoteResult result; - PlayerNumber pn; // used in routine mode - bool bHopoPossible; // set just before gameplay begins + /** @brief The Player that is supposed to hit this note. This is mainly for Routine Mode. */ + PlayerNumber pn; + /** @brief Can this note be hammered on or pulled off? This is set before gameplay begins. */ + bool bHopoPossible; // used only if Type == attack: RString sAttackModifiers; @@ -173,30 +196,42 @@ extern TapNote TAP_ORIGINAL_FAKE; // 'F' extern TapNote TAP_ADDITION_TAP; extern TapNote TAP_ADDITION_MINE; -// TODO: Don't have a hard-coded track limit. +/** + * @brief The number of tracks allowed. + * + * TODO: Don't have a hard-coded track limit. + */ const int MAX_NOTE_TRACKS = 16; -/* This is a divisor for our "fixed-point" time/beat representation. It must be +/** + * @brief The number of rows per beat. + * + * This is a divisor for our "fixed-point" time/beat representation. It must be * evenly divisible by 2, 3, and 4, to exactly represent 8th, 12th and 16th notes. */ const int ROWS_PER_BEAT = 48; -// In the editor, enforce a reasonable limit on the number of notes. +/** + * @brief Enforce a maximum number of notes per measure in the step editor. + * + * TODO: See if there is a way to de-hard-code this number. + */ const int MAX_NOTES_PER_MEASURE = 50; - +/** @brief The max number of rows allowed for a Steps pattern. */ const int MAX_NOTE_ROW = (1<<30); +/** @brief The list of quantized note types allowed at present. */ enum NoteType { - NOTE_TYPE_4TH, // quarter note - NOTE_TYPE_8TH, // eighth note - NOTE_TYPE_12TH, // quarter note triplet - NOTE_TYPE_16TH, // sixteenth note - NOTE_TYPE_24TH, // eighth note triplet - NOTE_TYPE_32ND, // thirty-second note - NOTE_TYPE_48TH, // sixteenth note triplet - NOTE_TYPE_64TH, // sixty-fourth note - NOTE_TYPE_192ND,// sixty-fourth note triplet + NOTE_TYPE_4TH, /**< quarter note */ + NOTE_TYPE_8TH, /**< eighth note */ + NOTE_TYPE_12TH, /**< quarter note triplet */ + NOTE_TYPE_16TH, /**< sixteenth note */ + NOTE_TYPE_24TH, /**< eighth note triplet */ + NOTE_TYPE_32ND, /**< thirty-second note */ + NOTE_TYPE_48TH, /**< sixteenth note triplet */ + NOTE_TYPE_64TH, /**< sixty-fourth note */ + NOTE_TYPE_192ND,/**< sixty-fourth note triplet */ NUM_NoteType, NoteType_Invalid }; @@ -225,8 +260,10 @@ inline float NoteRowToBeat( int iRow ) { return iRow / (float)ROWS_PER_BEAT; } #endif -/* - * (c) 2001-2004 Chris Danford, Glenn Maynard +/** + * @file + * @author Chris Danford, Glenn Maynard (c) 2001-2004 + * @section LICENSE * All rights reserved. * * Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/ProductInfo.h b/src/ProductInfo.h index 81cb2b2764..f64d44756e 100644 --- a/src/ProductInfo.h +++ b/src/ProductInfo.h @@ -1,30 +1,48 @@ -/* ProductInfo - Branding strings. Don't forget to also change ProductInfo.inc! */ +/** @brief ProductInfo - Branding strings. Don't forget to also change ProductInfo.inc! */ #ifndef PRODUCT_INFO_H #define PRODUCT_INFO_H -// A friendly string to refer to the product in crash dialogs, etc - i.e. "StepMania" not "StepMania4" +/** + * @brief A friendly string to refer to the product in crash dialogs, etc. + * + * As an example, use "StepMania" here, not "StepMania4". + */ #define PRODUCT_FAMILY_BARE sm-ssc -// A unique name for each application that you might want installed side-by-side with other applications - i.e. "StepMania4" not "StepMania" (would conflict with StepMania 3.x) +/** + * @brief A unique name for each application that you might want installed side-by-side with other applications. + * + * As an example, use "StepMania4" here, not "StepMania". + * It would cause a conflict with older versions such as StepMania 3.X. + */ #define PRODUCT_ID_BARE sm-ssc -/* Version info displayed to the user. +/** + * @brief Version info displayed to the user. + * * These are the 'official' version designations: + *
    + *
  • "experimental: pre-release versions.
  • * - * "experimental: pre-release versions - * "private beta v0.0": hmm, think about it for a second there. - * ==Public versions== - * "v0.0 alpha #": Alpha versions (bug squashing, polishing until we reach beta) - * "v0.0 beta #": Beta versions (bug squashing, _focus_ is on high priority bugs) - * "v0.0 rc#": Release Candidates (if there are no problems, move on to final) - * "v0.0": Final Releases -*/ + *
  • "private beta v0.0": hmm, think about it for a second there.
  • + * + *
  • ==Public versions== + * - "v0.0 alpha #": Alpha versions (bug squashing, polishing until we reach beta) + * - "v0.0 beta #": Beta versions (bug squashing, _focus_ is on high priority bugs) + * - "v0.0 rc#": Release Candidates (if there are no problems, move on to final) + * - "v0.0": Final Releases + *
+ */ #ifndef PRODUCT_VER_BARE #define PRODUCT_VER_BARE v1.2.1 #endif -// A unique ID for a build of an application. This is used in crash reports and in the network code's version handling +/** + * @brief A unique ID for a build of an application. + * + * This is used in crash reports and in the network code's version handling. + */ #define PRODUCT_ID_VER_BARE PRODUCT_ID_BARE PRODUCT_VER_BARE // These cannot be #undef'd so make them unlikely to conflict with anything @@ -37,14 +55,17 @@ #define PRODUCT_ID_VER PRODUCT_XSTRINGIFY(PRODUCT_ID_VER_BARE) #define VIDEO_TROUBLESHOOTING_URL "http://www.stepmania.com/stepmania/mediawiki.php?title=Video_Driver_Troubleshooting" +/** @brief The URL to report bugs on the program. */ #define REPORT_BUG_URL "http://ssc.ajworld.net/sm-ssc/bugtracker/" #define CAN_INSTALL_PACKAGES true #endif -/* - * (c) 2003-2005 Chris Danford +/** + * @file + * @author Chris Danford (c) 2003-2005 + * @section LICENSE * All rights reserved. * * Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/RadarValues.h b/src/RadarValues.h index c738129fc7..0d217102d3 100644 --- a/src/RadarValues.h +++ b/src/RadarValues.h @@ -1,4 +1,4 @@ -/* RadarValues - Cached song statistics. */ +/** @brief RadarValues - Cached song statistics. */ #ifndef RARAR_VALUES_H #define RARAR_VALUES_H @@ -6,11 +6,12 @@ #include "GameConstantsAndTypes.h" #include "ThemeMetric.h" +/** @brief Unknown radar values are given a default value. */ #define RADAR_VAL_UNKNOWN -1 class XNode; struct lua_State; - +/** @brief The collection of radar values. */ struct RadarValues { union Values @@ -40,12 +41,22 @@ struct RadarValues void MakeUnknown(); void Zero(); + /** + * @brief Add one set of radar values to another. + * @param other The other set of radar values to add. + * @return the new set of radar values. + */ RadarValues& operator+=( const RadarValues& other ) { FOREACH_ENUM( RadarCategory, rc ) m_Values.f[rc] += other.m_Values.f[rc]; return *this; } + /** + * @brief Determine if one set of radar values are equal to another. + * @param other The otehr set of radar values. + * @return true if the two sets are equal, false otherwise. + */ bool operator==( const RadarValues& other ) const { FOREACH_ENUM( RadarCategory, rc ) @@ -55,6 +66,11 @@ struct RadarValues } return true; } + /** + * @brief Determine if one set of radar values are not equal to another. + * @param other The otehr set of radar values. + * @return true if the two sets are not equal, false otherwise. + */ bool operator!=( const RadarValues& other ) const { return !operator==( other ); @@ -76,8 +92,10 @@ struct RadarValues #endif -/* - * (c) 2001-2004 Chris Danford +/** + * @file + * @author Chris Danford (c) 2001-2004 + * @section LICENSE * All rights reserved. * * Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/ScoreKeeper.h b/src/ScoreKeeper.h index c3fca1d813..3accf2e6fa 100644 --- a/src/ScoreKeeper.h +++ b/src/ScoreKeeper.h @@ -1,4 +1,4 @@ -/* ScoreKeeper - Abstract class to handle scorekeeping, stat-taking, etc. */ +/** @brief ScoreKeeper - Abstract class to handle scorekeeping, stat-taking, etc. */ #ifndef SCORE_KEEPER_H #define SCORE_KEEPER_H @@ -65,8 +65,10 @@ protected: #endif -/* - * (c) 2001-2006 Chris Danford, Glenn Maynard, Steve Checkoway +/** + * @file + * @author Chris Danford, Glenn Maynard, Steve Checkoway (c) 2001-2006 + * @section LICENSE * All rights reserved. * * Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/SongManager.cpp b/src/SongManager.cpp index 2d9bb1f737..7ed727cd74 100644 --- a/src/SongManager.cpp +++ b/src/SongManager.cpp @@ -41,6 +41,7 @@ const RString ADDITIONAL_SONGS_DIR = "/AdditionalSongs/"; const RString ADDITIONAL_COURSES_DIR = "/AdditionalCourses/"; const RString EDIT_SUBDIR = "Edits/"; +/** @brief The file that contains various random attacks. */ const RString ATTACK_FILE = "/Data/RandomAttacks.txt"; static const ThemeMetric EXTRA_COLOR ( "SongManager", "ExtraColor" ); diff --git a/src/SongManager.h b/src/SongManager.h index 50e20a7405..c62df7f23f 100644 --- a/src/SongManager.h +++ b/src/SongManager.h @@ -1,4 +1,4 @@ -/* SongManager - Holder for all Songs and Steps. */ +/** @brief SongManager - Holder for all Songs and Steps. */ #ifndef SONGMANAGER_H #define SONGMANAGER_H @@ -21,9 +21,12 @@ struct lua_State; #include "RageTexturePreloader.h" #include "RageUtil.h" +/** @brief The max number of edit steps a profile can have. */ const int MAX_EDIT_STEPS_PER_PROFILE = 200; +/** @brief The max number of edit courses a profile can have. */ const int MAX_EDIT_COURSES_PER_PROFILE = 20; +/** @brief The holder for the Songs and its Steps. */ class SongManager { public: @@ -181,8 +184,10 @@ extern SongManager* SONGMAN; // global and accessable from anywhere in our progr #endif -/* - * (c) 2001-2004 Chris Danford, Glenn Maynard +/** + * @file + * @author Chris Danford, Glenn Maynard (c) 2001-2004 + * @section LICENSE * All rights reserved. * * Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/SongUtil.cpp b/src/SongUtil.cpp index e9e59fedb0..6e075c3334 100644 --- a/src/SongUtil.cpp +++ b/src/SongUtil.cpp @@ -280,7 +280,11 @@ void SongUtil::AdjustDuplicateSteps( Song *pSong ) * These are confusing, and they're ambiguous when passed to GetStepsByID. */ } } - +/** + * @brief Remove the initial whitespace characters. + * @param s the string to left trim. + * @return the trimmed string. + */ static RString RemoveInitialWhitespace( RString s ) { size_t i = s.find_first_not_of(" \t\r\n"); diff --git a/src/SongUtil.h b/src/SongUtil.h index be42f8a7c9..3d2aa5956e 100644 --- a/src/SongUtil.h +++ b/src/SongUtil.h @@ -1,4 +1,4 @@ -/* SongUtil - Utility functions that deal with Song. */ +/** @brief SongUtil - Utility functions that deal with Song. */ #ifndef SONG_UTIL_H #define SONG_UTIL_H @@ -13,6 +13,7 @@ class Steps; class Profile; class XNode; +/** @brief The criteria for dealing with songs. */ class SongCriteria { public: @@ -22,12 +23,26 @@ public: enum Selectable { Selectable_Yes, Selectable_No, Selectable_DontCare } m_Selectable; bool m_bUseSongAllowedList; vector m_vpSongAllowedList; + /** @brief How many songs does this take max? Don't use this if it's -1. */ int m_iMaxStagesForSong; // don't filter if -1 // float m_fMinBPM; // don't filter if -1 // float m_fMaxBPM; // don't filter if -1 - enum Tutorial { Tutorial_Yes, Tutorial_No, Tutorial_DontCare } m_Tutorial; - enum Locked { Locked_Locked, Locked_Unlocked, Locked_DontCare } m_Locked; + /** @brief Is this song used for tutorial purposes? */ + enum Tutorial + { + Tutorial_Yes, /**< This song is used for tutorial purposes. */ + Tutorial_No, /**< This song is not used for tutorial purposes. */ + Tutorial_DontCare /**< This song can or cannot be used for tutorial purposes. */ + } m_Tutorial; + /** @brief Is this song used for locking/unlocking purposes? */ + enum Locked + { + Locked_Locked, /**< This song is a locked song. */ + Locked_Unlocked, /**< This song is an unlocked song. */ + Locked_DontCare /**< This song can or cannot be locked or unlocked. */ + } m_Locked; + /** @brief Set up some initial song criteria. */ SongCriteria() { m_bUseSongGenreAllowedList = false; @@ -40,9 +55,20 @@ public: m_Locked = Locked_DontCare; } + /** + * @brief Determine if the song matches the current criteria. + * @param p the song to compare against the criteria. + * @return true of the song matches the criteria, false otherwise. + */ bool Matches( const Song *p ) const; + /** + * @brief Determine if two sets of criteria are equivalent. + * @param other the other criteria. + * @return true if the two sets of criteria are equal, false otherwise. + */ bool operator==( const SongCriteria &other ) const { +/** @brief A quick way to match every part of the song criterium. */ #define X(x) (x == other.x) return X(m_sGroupName) && @@ -58,9 +84,15 @@ public: X(m_Locked); #undef X } + /** + * @brief Determine if two sets of criteria are not equivalent. + * @param other the other criteria. + * @return true if the two sets of criteria are not equal, false otherwise. + */ bool operator!=( const SongCriteria &other ) const { return !operator==( other ); } }; +/** @brief A set of song utilities to make working with songs easier. */ namespace SongUtil { void GetSteps( @@ -114,6 +146,14 @@ namespace SongUtil int CompareSongPointersByGroup(const Song *pSong1, const Song *pSong2); + /** + * @brief Determine if the requested description for an edit is unique. + * @param pSong the song the edit is for. + * @param st the steps type for the edit. + * @param sPreferredDescription the requested description. + * @param pExclude the steps that want the description. + * @return true if it is unique, false otherwise. + */ bool IsEditDescriptionUnique( const Song* pSong, StepsType st, const RString &sPreferredDescription, const Steps *pExclude ); RString MakeUniqueEditDescription( const Song* pSong, StepsType st, const RString &sPreferredDescription ); bool ValidateCurrentEditStepsDescription( const RString &sAnswer, RString &sErrorOut ); @@ -160,8 +200,10 @@ public: #endif -/* - * (c) 2001-2004 Chris Danford, Glenn Maynard +/** + * @file + * @author Chris Danford, Glenn Maynard (c) 2001-2004 + * @section LICENSE * All rights reserved. * * Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Steps.cpp b/src/Steps.cpp index 02d46b5dda..852c5b0b47 100644 --- a/src/Steps.cpp +++ b/src/Steps.cpp @@ -397,7 +397,7 @@ void Steps::SetCachedRadarValues( const RadarValues v[NUM_PLAYERS] ) // lua start #include "LuaBinding.h" - +/** @brief Allow Lua to have access to the Steps. */ class LunaSteps: public Luna { public: diff --git a/src/Steps.h b/src/Steps.h index 36c7f382a5..532857381a 100644 --- a/src/Steps.h +++ b/src/Steps.h @@ -1,4 +1,4 @@ -/* Steps - Holds note information for a Song. A Song may have one or more Notes. */ +/** @brief Steps - Holds note information for a Song. A Song may have one or more Notes. */ #ifndef STEPS_H #define STEPS_H @@ -14,12 +14,20 @@ class Profile; class NoteData; struct lua_State; +/** + * @brief Allow only 12 characters for the length of edits. + * + * This is a holdover from In The Groove: this may perhaps be not needed in the future. + */ const int MAX_EDIT_STEPS_DESCRIPTION_LENGTH = 12; +/** @brief The collective note pattern and information of the Steps that are played. */ class Steps { public: + /** @brief Set up the Steps with initial values. */ Steps(); + /** @brief Destroy the Steps that are no longer needed. */ ~Steps(); // initializers @@ -29,17 +37,51 @@ public: void Compress() const; void Decompress() const; - bool IsAutogen() const { return parent != NULL; } // Was created by autogen? + /** + * @brief Determine if these steps were created by the autogenerator. + * @return true if they were, false otherwise. + */ + bool IsAutogen() const { return parent != NULL; } - // Use a special value of difficulty + /** + * @brief Determine if this set of Steps is an edit. + * + * Edits have a special value of difficulty to make it easy to determine. + * @return true if this is an edit, false otherwise. + */ bool IsAnEdit() const { return m_Difficulty == Difficulty_Edit; } + /** + * @brief Determine if this set of Steps is a player edit. + * + * Player edits also have to be loaded from a player's profile slot, not the machine. + * @return true if this is a player edit, false otherwise. */ bool IsAPlayerEdit() const { return IsAnEdit() && GetLoadedFromProfileSlot() < ProfileSlot_Machine; } + /** + * @brief Determine if these steps were loaded from a player's profile. + * @return true if they were from a player profile, false otherwise. + */ bool WasLoadedFromProfile() const { return m_LoadedFromProfile != ProfileSlot_Invalid; } ProfileSlot GetLoadedFromProfileSlot() const { return m_LoadedFromProfile; } + /** + * @brief Retrieve the description used for this edit. + * @return the description used for this edit. + */ RString GetDescription() const { return Real()->m_sDescription; } + /** + * @brief Retrieve the difficulty used for this edit. + * @return the difficulty used for this edit. + */ Difficulty GetDifficulty() const { return Real()->m_Difficulty; } + /** + * @brief Retrieve the meter used for this edit. + * @return the meter used for this edit. + */ int GetMeter() const { return Real()->m_iMeter; } const RadarValues& GetRadarValues( PlayerNumber pn ) const { return Real()->m_CachedRadarValues[pn]; } + /** + * @brief Retrieve the author credit used for this edit. + * @return the author credit used for this edit. + */ RString GetCredit() const { return Real()->m_sCredit; } void SetFilename( RString fn ) { m_sFilename = fn; } @@ -77,7 +119,10 @@ private: inline const Steps *Real() const { return parent ? parent : this; } void DeAutogen( bool bCopyNoteData = true ); /* If this Steps is autogenerated, make it a real Steps. */ - /* If this Steps is autogenerated, this will point to the autogen + /** + * @brief Identify this Steps' parent. + * + * If this Steps is autogenerated, this will point to the autogen * source. If this is true, m_sNoteDataCompressed will always be empty. */ const Steps *parent; @@ -88,23 +133,35 @@ private: mutable bool m_bNoteDataIsFilled; mutable RString m_sNoteDataCompressed; + /** @brief The name of the file where these steps are stored. */ RString m_sFilename; - bool m_bSavedToDisk; // true if this was loaded from disk or has been saved to disk. - ProfileSlot m_LoadedFromProfile; // ProfileSlot_Invalid if wasn't loaded from a profile + /** @brief true if these Steps were loaded from or saved to disk. */ + bool m_bSavedToDisk; + /** @brief What profile was used? This is ProfileSlot_Invalid if not from a profile. */ + ProfileSlot m_LoadedFromProfile; /* These values are pulled from the autogen source first, if there is one. */ - mutable unsigned m_iHash; // only used if m_Difficulty == Difficulty_Edit - RString m_sDescription; // Edit name, or something meaningful - Difficulty m_Difficulty; // difficulty classification - int m_iMeter; // difficulty rating from MIN_METER to MAX_METER + /** @brief The hash of the steps. This is used only for Edit Steps. */ + mutable unsigned m_iHash; + /** @brief The name of the edit, or some other useful description. + This used to also contain the step author's name. */ + RString m_sDescription; + /** @brief The difficulty that these steps are assigned to. */ + Difficulty m_Difficulty; + /** @brief The numeric difficulty of the Steps, ranging from MIN_METER to MAX_METER. */ + int m_iMeter; + /** @brief The radar values used for each player. */ RadarValues m_CachedRadarValues[NUM_PLAYERS]; - RString m_sCredit; // Step author + /** @brief The name of the person who created the Steps. */ + RString m_sCredit; }; #endif -/* - * (c) 2001-2004 Chris Danford, Glenn Maynard +/** + * @file + * @author Chris Danford, Glenn Maynard (c) 2001-2004 + * @section LICENSE * All rights reserved. * * Permission is hereby granted, free of charge, to any person obtaining a From 39aa06f3063e7076552600e502343a23eedf1466 Mon Sep 17 00:00:00 2001 From: AJ Kelly Date: Sun, 13 Feb 2011 10:57:07 -0600 Subject: [PATCH 3/5] comment and cleanup --- src/Song.h | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/Song.h b/src/Song.h index 4fb810754b..942534491c 100644 --- a/src/Song.h +++ b/src/Song.h @@ -94,10 +94,9 @@ public: // Directory this song data came from: const RString &GetSongDir() const { return m_sSongDir; } - /* Filename associated with this file. This will always have a - * .SSC extension. If we loaded a .SSC, this will point to it, - * but if we loaded any other type, this will point to a - * generated .SSC filename. */ + /* Filename associated with this file. This will always have a .SSC + * extension. If we loaded a .SSC, this will point to it, but if we loaded + * any other type, this will point to a generated .SSC filename. */ RString m_sSongFileName; RString m_sGroupName; @@ -123,7 +122,7 @@ public: // "title subtitle" RString GetDisplayFullTitle() const; RString GetTranslitFullTitle() const; - + // allow versioning with the song. float m_fVersion; From 0c756e1e7526840680d2dc7a83732f116596f816 Mon Sep 17 00:00:00 2001 From: AJ Kelly Date: Sun, 13 Feb 2011 11:06:34 -0600 Subject: [PATCH 4/5] song: update .ssc version to v0.51 .ssc v0.51: make version the very first tag, limit it to two decimal places. --- src/NotesLoaderSSC.cpp | 324 ++++++++++++++++++++--------------------- src/NotesWriterSSC.cpp | 60 ++++---- src/Song.cpp | 3 +- 3 files changed, 185 insertions(+), 202 deletions(-) diff --git a/src/NotesLoaderSSC.cpp b/src/NotesLoaderSSC.cpp index dfe36d5abc..b4be9ce8d2 100644 --- a/src/NotesLoaderSSC.cpp +++ b/src/NotesLoaderSSC.cpp @@ -31,9 +31,9 @@ bool LoadFromBGSSCChangesString( BackgroundChange &change, const RString &sBGCha { vector aBGChangeValues; split( sBGChangeExpression, "=", aBGChangeValues, false ); - + aBGChangeValues.resize( min((int)aBGChangeValues.size(),11) ); - + switch( aBGChangeValues.size() ) { case 11: @@ -91,7 +91,7 @@ bool LoadFromBGSSCChangesString( BackgroundChange &change, const RString &sBGCha change.m_fStartBeat = StringToFloat( aBGChangeValues[0] ); // fall through } - + return aBGChangeValues.size() >= 2; } @@ -99,115 +99,115 @@ bool SSCLoader::LoadFromDir( const RString &sPath, Song &out ) { vector aFileNames; GetApplicableFiles( sPath, aFileNames ); - + if( aFileNames.size() > 1 ) { LOG->UserLog( "Song", sPath, "has more than one SSC file. Only one SSC file is allowed per song." ); return false; } - + ASSERT( aFileNames.size() == 1 ); // Ensure one was found entirely. - + return LoadFromSSCFile( sPath + aFileNames[0], out ); } bool SSCLoader::LoadFromSSCFile( const RString &sPath, Song &out, bool bFromCache ) { LOG->Trace( "Song::LoadFromSSCFile(%s)", sPath.c_str() ); - + MsdFile msd; if( !msd.ReadFile( sPath, true ) ) { LOG->UserLog( "Song file", sPath, "couldn't be opened: %s", msd.GetError().c_str() ); return false; } - + out.m_Timing.m_sFile = sPath; // songs still have their fallback timing. - + int state = GETTING_SONG_INFO; const unsigned values = msd.GetNumValues(); Steps* pNewNotes; - + for( unsigned i = 0; i < values; i++ ) { const MsdFile::value_t &sParams = msd.GetValue(i); RString sValueName = sParams[0]; sValueName.MakeUpper(); - + switch (state) { case GETTING_SONG_INFO: { - if( sValueName=="TITLE" ) + if( sValueName=="VERSION" ) + { + out.m_fVersion = StringToFloat( sParams[1] ); + } + + else if( sValueName=="TITLE" ) { out.m_sMainTitle = sParams[1]; } - + else if( sValueName=="SUBTITLE" ) { out.m_sSubTitle = sParams[1]; } - + else if( sValueName=="ARTIST" ) { out.m_sArtist = sParams[1]; } - + else if( sValueName=="TITLETRANSLIT" ) { out.m_sMainTitleTranslit = sParams[1]; } - + else if( sValueName=="SUBTITLETRANSLIT" ) { out.m_sSubTitleTranslit = sParams[1]; } - + else if( sValueName=="ARTISTTRANSLIT" ) { out.m_sArtistTranslit = sParams[1]; } - - else if( sValueName=="VERSION" ) - { - out.m_fVersion = StringToFloat( sParams[1] ); - } - + else if( sValueName=="GENRE" ) { out.m_sGenre = sParams[1]; } - + else if( sValueName=="CREDIT" ) { out.m_sCredit = sParams[1]; } - + else if( sValueName=="BANNER" ) { out.m_sBannerFile = sParams[1]; } - + else if( sValueName=="BACKGROUND" ) { out.m_sBackgroundFile = sParams[1]; } - + else if( sValueName=="LYRICSPATH" ) { out.m_sLyricsFile = sParams[1]; } - + else if( sValueName=="CDTITLE" ) { out.m_sCDTitleFile = sParams[1]; } - + else if( sValueName=="MUSIC" ) { out.m_sMusicFile = sParams[1]; } - + else if( sValueName=="INSTRUMENTTRACK" ) { vector vs1; @@ -224,34 +224,34 @@ bool SSCLoader::LoadFromSSCFile( const RString &sPath, Song &out, bool bFromCach } } } - + else if( sValueName=="MUSICLENGTH" ) { if( !bFromCache ) continue; out.m_fMusicLengthSeconds = StringToFloat( sParams[1] ); } - + else if( sValueName=="LASTBEATHINT" ) { out.m_fSpecifiedLastBeat = StringToFloat( sParams[1] ); } - + else if( sValueName=="MUSICBYTES" ) { - ; /* ignore */ + ; // ignore } - + else if( sValueName=="SAMPLESTART" ) { out.m_fMusicSampleStartSeconds = HHMMSSToSeconds( sParams[1] ); } - + else if( sValueName=="SAMPLELENGTH" ) { out.m_fMusicSampleLengthSeconds = HHMMSSToSeconds( sParams[1] ); } - + else if( sValueName=="DISPLAYBPM" ) { // #DISPLAYBPM:[xxx][xxx:xxx]|[*]; @@ -267,7 +267,7 @@ bool SSCLoader::LoadFromSSCFile( const RString &sPath, Song &out, bool bFromCach out.m_fSpecifiedBPMMax = StringToFloat( sParams[2] ); } } - + else if( sValueName=="SELECTABLE" ) { if(!stricmp(sParams[1],"YES")) @@ -286,13 +286,13 @@ bool SSCLoader::LoadFromSSCFile( const RString &sPath, Song &out, bool bFromCach else LOG->UserLog( "Song file", sPath, "has an unknown #SELECTABLE value, \"%s\"; ignored.", sParams[1].c_str() ); } - + else if( sValueName.Left(strlen("BGCHANGES"))=="BGCHANGES" || sValueName=="ANIMATIONS" ) { BackgroundLayer iLayer = BACKGROUND_LAYER_1; if( sscanf(sValueName, "BGCHANGES%d", &*ConvertValue(&iLayer)) == 1 ) enum_add(iLayer, -1); // #BGCHANGES2 = BACKGROUND_LAYER_2 - + bool bValid = iLayer>=0 && iLayer aBGChangeExpressions; split( sParams[1], ",", aBGChangeExpressions ); - + for( unsigned b=0; b aFGChangeExpressions; split( sParams[1], ",", aFGChangeExpressions ); - + for( unsigned b=0; b sBits; split( sParams[j], "=", sBits, false ); - + // Need an identifer and a value for this to work if( sBits.size() < 2 ) continue; - + TrimLeft( sBits[0] ); TrimRight( sBits[0] ); - + if( !sBits[0].CompareNoCase("TIME") ) attack.fStartSecond = strtof( sBits[1], NULL ); else if( !sBits[0].CompareNoCase("LEN") ) @@ -361,35 +361,32 @@ bool SSCLoader::LoadFromSSCFile( const RString &sPath, Song &out, bool bFromCach else if( !sBits[0].CompareNoCase("MODS") ) { attack.sModifiers = sBits[1]; - + if( end != -9999 ) { attack.fSecsRemaining = end - attack.fStartSecond; end = -9999; } - + if( attack.fSecsRemaining < 0.0f ) attack.fSecsRemaining = 0.0f; - + out.m_Attacks.push_back( attack ); } } } - + else if( sValueName=="OFFSET" ) { out.m_Timing.m_fBeat0OffsetInSeconds = StringToFloat( sParams[1] ); } - /* - * Below are the song based timings that - * should only be used if the steps do - * not have their own timing. - */ + /* Below are the song based timings that should only be used + * if the steps do not have their own timing. */ else if( sValueName=="STOPS" ) { vector arrayFreezeExpressions; split( sParams[1], ",", arrayFreezeExpressions ); - + for( unsigned f=0; f arrayFreezeValues; @@ -398,14 +395,14 @@ bool SSCLoader::LoadFromSSCFile( const RString &sPath, Song &out, bool bFromCach { // XXX: Hard to tell which file caused this. LOG->UserLog( "Song file", "(UNKNOWN)", "has an invalid #%s value \"%s\" (must have exactly one '='), ignored.", - sValueName.c_str(), arrayFreezeExpressions[f].c_str() ); + sValueName.c_str(), arrayFreezeExpressions[f].c_str() ); continue; } - + const float fFreezeBeat = StringToFloat( arrayFreezeValues[0] ); const float fFreezeSeconds = StringToFloat( arrayFreezeValues[1] ); StopSegment new_seg( BeatToNoteRow(fFreezeBeat), fFreezeSeconds ); - + if(fFreezeSeconds > 0.0f) { // LOG->Trace( "Adding a freeze segment: beat: %f, seconds = %f", new_seg.m_fStartBeat, new_seg.m_fStopSeconds ); @@ -428,7 +425,7 @@ bool SSCLoader::LoadFromSSCFile( const RString &sPath, Song &out, bool bFromCach { vector arrayDelayExpressions; split( sParams[1], ",", arrayDelayExpressions ); - + for( unsigned f=0; f arrayDelayValues; @@ -437,29 +434,29 @@ bool SSCLoader::LoadFromSSCFile( const RString &sPath, Song &out, bool bFromCach { // XXX: Hard to tell which file caused this. LOG->UserLog( "Song file", "(UNKNOWN)", "has an invalid #%s value \"%s\" (must have exactly one '='), ignored.", - sValueName.c_str(), arrayDelayExpressions[f].c_str() ); + sValueName.c_str(), arrayDelayExpressions[f].c_str() ); continue; } - + const float fFreezeBeat = StringToFloat( arrayDelayValues[0] ); const float fFreezeSeconds = StringToFloat( arrayDelayValues[1] ); - + StopSegment new_seg( BeatToNoteRow(fFreezeBeat), fFreezeSeconds, true ); - + // LOG->Trace( "Adding a delay segment: beat: %f, seconds = %f", new_seg.m_fStartBeat, new_seg.m_fStopSeconds ); - + if(fFreezeSeconds > 0.0f) out.m_Timing.AddStopSegment( new_seg ); else LOG->UserLog( "Song file", "(UNKNOWN)", "has an invalid delay at beat %f, length %f.", fFreezeBeat, fFreezeSeconds ); } } - + else if( sValueName=="BPMS" ) { vector arrayBPMChangeExpressions; split( sParams[1], ",", arrayBPMChangeExpressions ); - + for( unsigned b=0; b arrayBPMChangeValues; @@ -468,15 +465,13 @@ bool SSCLoader::LoadFromSSCFile( const RString &sPath, Song &out, bool bFromCach if( arrayBPMChangeValues.size() != 2 ) { LOG->UserLog( "Song file", "(UNKNOWN)", "has an invalid #%s value \"%s\" (must have exactly one '='), ignored.", - sValueName.c_str(), arrayBPMChangeExpressions[b].c_str() ); + sValueName.c_str(), arrayBPMChangeExpressions[b].c_str() ); continue; } - + const float fBeat = StringToFloat( arrayBPMChangeValues[0] ); const float fNewBPM = StringToFloat( arrayBPMChangeValues[1] ); - - - + if(fNewBPM > 0.0f) out.m_Timing.AddBPMSegment( BPMSegment(BeatToNoteRow(fBeat), fNewBPM) ); else @@ -490,57 +485,57 @@ bool SSCLoader::LoadFromSSCFile( const RString &sPath, Song &out, bool bFromCach } } } - + else if( sValueName=="TIMESIGNATURES" ) { vector vs1; split( sParams[1], ",", vs1 ); - + FOREACH_CONST( RString, vs1, s1 ) { vector vs2; split( *s1, "=", vs2 ); - + if( vs2.size() < 3 ) { LOG->UserLog( "Song file", "(UNKNOWN)", "has an invalid time signature change with %i values.", (int)vs2.size() ); continue; } - + const float fBeat = StringToFloat( vs2[0] ); - + TimeSignatureSegment seg; seg.m_iStartRow = BeatToNoteRow(fBeat); seg.m_iNumerator = atoi( vs2[1] ); seg.m_iDenominator = atoi( vs2[2] ); - + if( fBeat < 0 ) { LOG->UserLog( "Song file", "(UNKNOWN)", "has an invalid time signature change with beat %f.", fBeat ); continue; } - + if( seg.m_iNumerator < 1 ) { LOG->UserLog( "Song file", "(UNKNOWN)", "has an invalid time signature change with beat %f, iNumerator %i.", fBeat, seg.m_iNumerator ); continue; } - + if( seg.m_iDenominator < 1 ) { LOG->UserLog( "Song file", "(UNKNOWN)", "has an invalid time signature change with beat %f, iDenominator %i.", fBeat, seg.m_iDenominator ); continue; } - + out.m_Timing.AddTimeSignatureSegment( seg ); } } - + else if( sValueName=="TICKCOUNTS" ) { vector arrayTickcountExpressions; split( sParams[1], ",", arrayTickcountExpressions ); - + for( unsigned f=0; f arrayTickcountValues; @@ -549,14 +544,14 @@ bool SSCLoader::LoadFromSSCFile( const RString &sPath, Song &out, bool bFromCach { // XXX: Hard to tell which file caused this. LOG->UserLog( "Song file", "(UNKNOWN)", "has an invalid #%s value \"%s\" (must have exactly one '='), ignored.", - sValueName.c_str(), arrayTickcountExpressions[f].c_str() ); + sValueName.c_str(), arrayTickcountExpressions[f].c_str() ); continue; } - + const float fTickcountBeat = StringToFloat( arrayTickcountValues[0] ); const int iTicks = atoi( arrayTickcountValues[1] ); TickcountSegment new_seg( BeatToNoteRow(fTickcountBeat), iTicks ); - + if(iTicks >= 1 && iTicks <= ROWS_PER_BEAT ) // Constants { // LOG->Trace( "Adding a tickcount segment: beat: %f, ticks = %d", fTickcountBeat, iTicks ); @@ -568,12 +563,12 @@ bool SSCLoader::LoadFromSSCFile( const RString &sPath, Song &out, bool bFromCach } } } - + else if( sValueName=="COMBOS" ) {/* vector arrayComboExpressions; split( sParams[1], ",", arrayComboExpressions ); - + for( unsigned f=0; f arrayComboValues; @@ -581,7 +576,7 @@ bool SSCLoader::LoadFromSSCFile( const RString &sPath, Song &out, bool bFromCach if( arrayComboValues.size() != 2 ) { LOG->UserLog( "Song file", "(UNKNOWN)", "has an invalid #%s value \"%s\" (must have exactly one '='), ignored.", - sValueName.c_str(), arrayComboExpressions[f].c_str() ); + sValueName.c_str(), arrayComboExpressions[f].c_str() ); continue; } const float fComboBeat = StringToFloat( arrayComboValues[0] ); @@ -591,42 +586,39 @@ bool SSCLoader::LoadFromSSCFile( const RString &sPath, Song &out, bool bFromCach } */ } - - /* - * The following are cache tags. - * Never fill their values directly: - * only from the cached version. - */ + + /* The following are cache tags. Never fill their values + * directly: only from the cached version. */ else if( sValueName=="FIRSTBEAT" ) { if( bFromCache ) out.m_fFirstBeat = StringToFloat( sParams[1] ); } - + else if( sValueName=="LASTBEAT" ) { if( bFromCache ) out.m_fLastBeat = StringToFloat( sParams[1] ); } - + else if( sValueName=="SONGFILENAME" ) { if( bFromCache ) out.m_sSongFileName = sParams[1]; } - + else if( sValueName=="HASMUSIC" ) { if( bFromCache ) out.m_bHasMusic = atoi( sParams[1] ) != 0; } - + else if( sValueName=="HASBANNER" ) { if( bFromCache ) out.m_bHasBanner = atoi( sParams[1] ) != 0; } - + // This tag will get us to the next section. else if( sValueName=="NOTEDATA" ) { @@ -641,22 +633,22 @@ bool SSCLoader::LoadFromSSCFile( const RString &sPath, Song &out, bool bFromCach { pNewNotes->m_StepsType = GAMEMAN->StringToStepsType( sParams[1] ); } - + else if( sValueName=="DESCRIPTION" ) { pNewNotes->SetDescription( sParams[1] ); } - + else if( sValueName=="DIFFICULTY" ) { pNewNotes->SetDifficulty( DwiCompatibleStringToDifficulty( sParams[1] ) ); } - + else if( sValueName=="METER" ) { pNewNotes->SetMeter( atoi( sParams[1] ) ); } - + else if( sValueName=="RADARVALUES" ) { vector saValues; @@ -670,12 +662,12 @@ bool SSCLoader::LoadFromSSCFile( const RString &sPath, Song &out, bool bFromCach pNewNotes->SetCachedRadarValues( v ); } } - + else if( sValueName=="CREDIT" ) { pNewNotes->SetCredit( sParams[1] ); } - + else if( sValueName=="NOTES" ) { state = GETTING_SONG_INFO; @@ -684,14 +676,14 @@ bool SSCLoader::LoadFromSSCFile( const RString &sPath, Song &out, bool bFromCach pNewNotes->TidyUpData(); out.AddSteps( pNewNotes ); } - + else if( sValueName=="BPMS" ) { /* state = GETTING_STEP_TIMING_INFO; vector arrayBPMChangeExpressions; split( sParams[1], ",", arrayBPMChangeExpressions ); - + for( unsigned b=0; b arrayBPMChangeValues; @@ -700,15 +692,13 @@ bool SSCLoader::LoadFromSSCFile( const RString &sPath, Song &out, bool bFromCach if( arrayBPMChangeValues.size() != 2 ) { LOG->UserLog( "Song file", "(UNKNOWN)", "has an invalid #%s value \"%s\" (must have exactly one '='), ignored.", - sValueName.c_str(), arrayBPMChangeExpressions[b].c_str() ); + sValueName.c_str(), arrayBPMChangeExpressions[b].c_str() ); continue; } - + const float fBeat = StringToFloat( arrayBPMChangeValues[0] ); const float fNewBPM = StringToFloat( arrayBPMChangeValues[1] ); - - - + if(fNewBPM > 0.0f) pNewNotes->m_Timing.AddBPMSegment( BPMSegment(BeatToNoteRow(fBeat), fNewBPM) ); else @@ -732,7 +722,7 @@ bool SSCLoader::LoadFromSSCFile( const RString &sPath, Song &out, bool bFromCach /* vector arrayFreezeExpressions; split( sParams[1], ",", arrayFreezeExpressions ); - + for( unsigned f=0; f arrayFreezeValues; @@ -741,14 +731,14 @@ bool SSCLoader::LoadFromSSCFile( const RString &sPath, Song &out, bool bFromCach { // XXX: Hard to tell which file caused this. LOG->UserLog( "Song file", "(UNKNOWN)", "has an invalid #%s value \"%s\" (must have exactly one '='), ignored.", - sValueName.c_str(), arrayFreezeExpressions[f].c_str() ); + sValueName.c_str(), arrayFreezeExpressions[f].c_str() ); continue; } - + const float fFreezeBeat = StringToFloat( arrayFreezeValues[0] ); const float fFreezeSeconds = StringToFloat( arrayFreezeValues[1] ); StopSegment new_seg( BeatToNoteRow(fFreezeBeat), fFreezeSeconds ); - + if(fFreezeSeconds > 0.0f) { // LOG->Trace( "Adding a freeze segment: beat: %f, seconds = %f", new_seg.m_fStartBeat, new_seg.m_fStopSeconds ); @@ -773,7 +763,7 @@ bool SSCLoader::LoadFromSSCFile( const RString &sPath, Song &out, bool bFromCach /* vector arrayDelayExpressions; split( sParams[1], ",", arrayDelayExpressions ); - + for( unsigned f=0; f arrayDelayValues; @@ -782,17 +772,17 @@ bool SSCLoader::LoadFromSSCFile( const RString &sPath, Song &out, bool bFromCach { // XXX: Hard to tell which file caused this. LOG->UserLog( "Song file", "(UNKNOWN)", "has an invalid #%s value \"%s\" (must have exactly one '='), ignored.", - sValueName.c_str(), arrayDelayExpressions[f].c_str() ); + sValueName.c_str(), arrayDelayExpressions[f].c_str() ); continue; } - + const float fFreezeBeat = StringToFloat( arrayDelayValues[0] ); const float fFreezeSeconds = StringToFloat( arrayDelayValues[1] ); - + StopSegment new_seg( BeatToNoteRow(fFreezeBeat), fFreezeSeconds, true ); - + // LOG->Trace( "Adding a delay segment: beat: %f, seconds = %f", new_seg.m_fStartBeat, new_seg.m_fStopSeconds ); - + if(fFreezeSeconds > 0.0f) pNewNotes->m_Timing.AddStopSegment( new_seg ); else @@ -805,54 +795,54 @@ bool SSCLoader::LoadFromSSCFile( const RString &sPath, Song &out, bool bFromCach /* vector vs1; split( sParams[1], ",", vs1 ); - + FOREACH_CONST( RString, vs1, s1 ) { vector vs2; split( *s1, "=", vs2 ); - + if( vs2.size() < 3 ) { LOG->UserLog( "Song file", "(UNKNOWN)", "has an invalid time signature change with %i values.", (int)vs2.size() ); continue; } - + const float fBeat = StringToFloat( vs2[0] ); - + TimeSignatureSegment seg; seg.m_iStartRow = BeatToNoteRow(fBeat); seg.m_iNumerator = atoi( vs2[1] ); seg.m_iDenominator = atoi( vs2[2] ); - + if( fBeat < 0 ) { LOG->UserLog( "Song file", "(UNKNOWN)", "has an invalid time signature change with beat %f.", fBeat ); continue; } - + if( seg.m_iNumerator < 1 ) { LOG->UserLog( "Song file", "(UNKNOWN)", "has an invalid time signature change with beat %f, iNumerator %i.", fBeat, seg.m_iNumerator ); continue; } - + if( seg.m_iDenominator < 1 ) { LOG->UserLog( "Song file", "(UNKNOWN)", "has an invalid time signature change with beat %f, iDenominator %i.", fBeat, seg.m_iDenominator ); continue; } - + pNewNotes->m_Timing.AddTimeSignatureSegment( seg ); } */ } - + else if( sValueName=="TICKCOUNTS" ) { /* vector arrayTickcountExpressions; split( sParams[1], ",", arrayTickcountExpressions ); - + for( unsigned f=0; f arrayTickcountValues; @@ -861,14 +851,14 @@ bool SSCLoader::LoadFromSSCFile( const RString &sPath, Song &out, bool bFromCach { // XXX: Hard to tell which file caused this. LOG->UserLog( "Song file", "(UNKNOWN)", "has an invalid #%s value \"%s\" (must have exactly one '='), ignored.", - sValueName.c_str(), arrayTickcountExpressions[f].c_str() ); + sValueName.c_str(), arrayTickcountExpressions[f].c_str() ); continue; } - + const float fTickcountBeat = StringToFloat( arrayTickcountValues[0] ); const int iTicks = atoi( arrayTickcountValues[1] ); TickcountSegment new_seg( BeatToNoteRow(fTickcountBeat), iTicks ); - + if(iTicks >= 1 && iTicks <= ROWS_PER_BEAT ) // Constants { // LOG->Trace( "Adding a tickcount segment: beat: %f, ticks = %d", fTickcountBeat, iTicks ); @@ -881,13 +871,12 @@ bool SSCLoader::LoadFromSSCFile( const RString &sPath, Song &out, bool bFromCach } */ } - else if( sValueName=="COMBOS" ) { /* vector arrayComboExpressions; split( sParams[1], ",", arrayComboExpressions ); - + for( unsigned f=0; f arrayComboValues; @@ -895,7 +884,7 @@ bool SSCLoader::LoadFromSSCFile( const RString &sPath, Song &out, bool bFromCach if( arrayComboValues.size() != 2 ) { LOG->UserLog( "Song file", "(UNKNOWN)", "has an invalid #%s value \"%s\" (must have exactly one '='), ignored.", - sValueName.c_str(), arrayComboExpressions[f].c_str() ); + sValueName.c_str(), arrayComboExpressions[f].c_str() ); continue; } const float fComboBeat = StringToFloat( arrayComboValues[0] ); @@ -910,10 +899,9 @@ bool SSCLoader::LoadFromSSCFile( const RString &sPath, Song &out, bool bFromCach pNewNotes->m_Timing.m_fBeat0OffsetInSeconds = StringToFloat( sParams[1] ); */ } - + else if( sValueName=="NOTES" ) { - state = GETTING_SONG_INFO; // pNewNotes->m_Timing.m_fBeat0OffsetInSeconds = out.m_Timing.m_fBeat0OffsetInSeconds; pNewNotes->SetSMNoteData( sParams[1] ); @@ -935,21 +923,21 @@ void SSCLoader::GetApplicableFiles( const RString &sPath, vector &out ) bool SSCLoader::LoadEditFromFile( RString sEditFilePath, ProfileSlot slot, bool bAddStepsToSong ) { LOG->Trace( "SSCLoader::LoadEditFromFile(%s)", sEditFilePath.c_str() ); - + int iBytes = FILEMAN->GetFileSizeInBytes( sEditFilePath ); if( iBytes > MAX_EDIT_STEPS_SIZE_BYTES ) { LOG->UserLog( "Edit file", sEditFilePath, "is unreasonably large. It won't be loaded." ); return false; } - + MsdFile msd; if( !msd.ReadFile( sEditFilePath, true ) ) // unescape { LOG->UserLog( "Edit file", sEditFilePath, "couldn't be opened: %s", msd.GetError().c_str() ); return false; } - + return LoadEditFromMsd( msd, sEditFilePath, slot, bAddStepsToSong ); } @@ -965,7 +953,7 @@ bool SSCLoader::LoadEditFromMsd( const MsdFile &msd, const RString &sEditFilePat const MsdFile::value_t &sParams = msd.GetValue(i); RString sValueName = sParams[0]; sValueName.MakeUpper(); - + // handle the data if( sValueName=="SONG" ) { @@ -1001,25 +989,25 @@ bool SSCLoader::LoadEditFromMsd( const MsdFile &msd, const RString &sEditFilePat pNewNotes->m_StepsType = GAMEMAN->StringToStepsType( sParams[1] ); bSSCFormat = true; } - + else if( sValueName=="DESCRIPTION" ) { pNewNotes->SetDescription( sParams[1] ); bSSCFormat = true; } - + else if( sValueName=="DIFFICULTY" ) { pNewNotes->SetDifficulty( DwiCompatibleStringToDifficulty( sParams[1] ) ); bSSCFormat = true; } - + else if( sValueName=="METER" ) { pNewNotes->SetMeter( atoi( sParams[1] ) ); bSSCFormat = true; } - + else if( sValueName=="RADARVALUES" ) { vector saValues; @@ -1034,13 +1022,13 @@ bool SSCLoader::LoadEditFromMsd( const MsdFile &msd, const RString &sEditFilePat } bSSCFormat = true; } - + else if( sValueName=="CREDIT" ) { pNewNotes->SetCredit( sParams[1] ); bSSCFormat = true; } - + // TimingData for Steps isn't set yet, but still prepare for it. else if( sValueName=="BPMS" ) { @@ -1066,7 +1054,7 @@ bool SSCLoader::LoadEditFromMsd( const MsdFile &msd, const RString &sEditFilePat { bSSCFormat = true; } - + else if( sValueName=="NOTES" ) { if( pSong == NULL ) @@ -1074,16 +1062,16 @@ bool SSCLoader::LoadEditFromMsd( const MsdFile &msd, const RString &sEditFilePat LOG->UserLog( "Edit file", sEditFilePath, "doesn't have a #SONG tag preceeding the first #NOTES tag." ); return false; } - + if ( !bSSCFormat && iNumParams < 7 ) { LOG->UserLog( "Edit file", sEditFilePath, "has %d fields in a #NOTES tag, but should have at least 7.", iNumParams ); continue; } - + if( !bAddStepsToSong ) return true; - + if( bSSCFormat ) { pNewNotes->SetSMNoteData( sParams[1] ); @@ -1097,11 +1085,11 @@ bool SSCLoader::LoadEditFromMsd( const MsdFile &msd, const RString &sEditFilePat sParams[1], sParams[2], sParams[3], sParams[4], sParams[5], sParams[6], *pNewNotes); } - + pNewNotes->SetLoadedFromProfile( slot ); pNewNotes->SetDifficulty( Difficulty_Edit ); pNewNotes->SetFilename( sEditFilePath ); - + if( pSong->IsEditAlreadyLoaded(pNewNotes) ) { LOG->UserLog( "Edit file", sEditFilePath, "is a duplicate of another edit that was already loaded." ); @@ -1117,7 +1105,7 @@ bool SSCLoader::LoadEditFromMsd( const MsdFile &msd, const RString &sEditFilePat LOG->UserLog( "Edit file", sEditFilePath, "has an unexpected value \"%s\".", sValueName.c_str() ); } } - + return true; } @@ -1139,7 +1127,7 @@ void SSCLoader::TidyUpData( Song &song, bool bFromCache ) /* BGChanges have been sorted. On the odd chance that a BGChange exists * with a very high beat, search the whole list. */ bool bHasNoSongBgTag = false; - + for( unsigned i = 0; !bHasNoSongBgTag && i < bg.size(); ++i ) { if( !bg[i].m_def.m_sFile1.CompareNoCase(NO_SONG_BG_FILE) ) @@ -1148,7 +1136,7 @@ void SSCLoader::TidyUpData( Song &song, bool bFromCache ) bHasNoSongBgTag = true; } } - + // If there's no -nosongbg- tag, add the song BG. if( !bHasNoSongBgTag ) do { @@ -1156,19 +1144,19 @@ void SSCLoader::TidyUpData( Song &song, bool bFromCache ) * must not call IsAFile(song.GetBackgroundPath()) when loading cache. */ if( bFromCache ) break; - + /* If BGChanges already exist after the last beat, don't add the * background in the middle. */ if( !bg.empty() && bg.back().m_fStartBeat-0.0001f >= song.m_fLastBeat ) break; - + // If the last BGA is already the song BGA, don't add a duplicate. if( !bg.empty() && !bg.back().m_def.m_sFile1.CompareNoCase(song.m_sBackgroundFile) ) break; - + if( !IsAFile( song.GetBackgroundPath() ) ) break; - + bg.push_back( BackgroundChange(song.m_fLastBeat,song.m_sBackgroundFile) ); } while(0); } diff --git a/src/NotesWriterSSC.cpp b/src/NotesWriterSSC.cpp index 2e1eaa1507..5c7e8f3a68 100644 --- a/src/NotesWriterSSC.cpp +++ b/src/NotesWriterSSC.cpp @@ -39,14 +39,13 @@ static RString BackgroundChangeToString( const BackgroundChange &bgc ) static void WriteGlobalTags( RageFile &f, const Song &out ) { - //f.PutLine( ssprintf( "#SMVERSION:;", SmEscape(RString("ssc-v1.0")).c_str() ) ); + f.PutLine( ssprintf( "#VERSION:%.2f;", out.m_fVersion ) ); f.PutLine( ssprintf( "#TITLE:%s;", SmEscape(out.m_sMainTitle).c_str() ) ); f.PutLine( ssprintf( "#SUBTITLE:%s;", SmEscape(out.m_sSubTitle).c_str() ) ); f.PutLine( ssprintf( "#ARTIST:%s;", SmEscape(out.m_sArtist).c_str() ) ); f.PutLine( ssprintf( "#TITLETRANSLIT:%s;", SmEscape(out.m_sMainTitleTranslit).c_str() ) ); f.PutLine( ssprintf( "#SUBTITLETRANSLIT:%s;", SmEscape(out.m_sSubTitleTranslit).c_str() ) ); f.PutLine( ssprintf( "#ARTISTTRANSLIT:%s;", SmEscape(out.m_sArtistTranslit).c_str() ) ); - f.PutLine( ssprintf( "#VERSION:%f;", out.m_fVersion ) ); f.PutLine( ssprintf( "#GENRE:%s;", SmEscape(out.m_sGenre).c_str() ) ); f.PutLine( ssprintf( "#CREDIT:%s;", SmEscape(out.m_sCredit).c_str() ) ); f.PutLine( ssprintf( "#BANNER:%s;", SmEscape(out.m_sBannerFile).c_str() ) ); @@ -54,7 +53,7 @@ static void WriteGlobalTags( RageFile &f, const Song &out ) f.PutLine( ssprintf( "#LYRICSPATH:%s;", SmEscape(out.m_sLyricsFile).c_str() ) ); f.PutLine( ssprintf( "#CDTITLE:%s;", SmEscape(out.m_sCDTitleFile).c_str() ) ); f.PutLine( ssprintf( "#MUSIC:%s;", SmEscape(out.m_sMusicFile).c_str() ) ); - + { vector vs; FOREACH_ENUM( InstrumentTrack, it ) @@ -98,7 +97,6 @@ static void WriteGlobalTags( RageFile &f, const Song &out ) break; } - f.Write( "#BPMS:" ); for( unsigned i=0; i &lines ) for( unsigned i = 0; i < lines.size(); ++i ) TrimRight( lines[i] ); - /* Skip leading blanks. */ + // Skip leading blanks. unsigned j = 0; while( j < lines.size() && lines.size() == 0 ) ++j; @@ -266,7 +264,7 @@ static RString GetSSCNotesTag( const Song &song, const Steps &in, bool bSavingCa lines.push_back( ssprintf( "#DESCRIPTION:%s;", SmEscape(in.GetDescription()).c_str() ) ); lines.push_back( ssprintf( "#DIFFICULTY:%s;", DifficultyToString(in.GetDifficulty()).c_str() ) ); lines.push_back( ssprintf( "#METER:%d;", in.GetMeter() ) ); - + vector asRadarValues; FOREACH_PlayerNumber( pn ) { @@ -277,15 +275,15 @@ static RString GetSSCNotesTag( const Song &song, const Steps &in, bool bSavingCa lines.push_back( ssprintf( "#RADARVALUES:%s:", join(",",asRadarValues).c_str() ) ); lines.push_back( ssprintf( "#CREDIT:%s;", SmEscape(in.GetCredit()).c_str() ) ); - - // TODO: Remove this block, uncommon below block for Split Timing. -Wolfman2000 + + // TODO: Remove this block, uncomment below block for Split Timing. -Wolfman2000 lines.push_back( "#BPMS:;" ); lines.push_back( "#STOPS:;" ); lines.push_back( "#DELAYS:;" ); lines.push_back( "#TIMESIGNATURES:;" ); lines.push_back( "#TICKCOUNTS:;" ); // lines.push_back( "#COMBOS:;" ); - + /* vector asBPMValues; for( unsigned i=0; i asStopValues; for( unsigned i=0; i asDelayValues; for( unsigned i=0; i asTimeSigValues; FOREACH_CONST( TimeSignatureSegment, in.m_Timing.m_vTimeSignatureSegments, iter ) @@ -329,36 +326,35 @@ static RString GetSSCNotesTag( const Song &song, const Steps &in, bool bSavingCa iter2++; } lines.push_back( ssprintf( "#TIMESIGNATURES:%s;", join("\n,", asTimeSigValues).c_str() ) ); - + ASSERT( !in.m_Timing.m_TickcountSegments.empty() ); vector asTickValues; for( unsigned i=0; i asComboValues; for( unsigned i=0; i int flags = RageFile::WRITE; /* If we're not saving cache, we're saving real data, so enable SLOW_FLUSH - * to prevent data loss. If we're saving cache, this will slow things down + * to prevent data loss. If we're saving cache, this will slow things down * too much. */ if( !bSavingCache ) flags |= RageFile::SLOW_FLUSH; diff --git a/src/Song.cpp b/src/Song.cpp index a4b62e0bab..b4e7fe088d 100644 --- a/src/Song.cpp +++ b/src/Song.cpp @@ -36,6 +36,7 @@ #include #include +const static float VERSION_NUMBER = 0.51f; const int FILE_CACHE_VERSION = 163; // increment this to invalidate cache const float DEFAULT_MUSIC_SAMPLE_LENGTH = 12.f; @@ -52,8 +53,6 @@ static const char *InstrumentTrackNames[] = { XToString( InstrumentTrack ); StringToX( InstrumentTrack ); -const static float VERSION_NUMBER = 0.5f; - Song::Song() { FOREACH_BackgroundLayer( i ) From bd8860bb7df7f4cbf8a241170a4f4bc28209e62c Mon Sep 17 00:00:00 2001 From: AJ Kelly Date: Sun, 13 Feb 2011 11:34:35 -0600 Subject: [PATCH 5/5] next version will be sm-ssc v1.2.2; add .ssc format changelog --- Docs/Changelog_SSCformat.txt | 17 +++++++++++++++++ Docs/Changelog_sm-ssc.txt | 2 +- 2 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 Docs/Changelog_SSCformat.txt diff --git a/Docs/Changelog_SSCformat.txt b/Docs/Changelog_SSCformat.txt new file mode 100644 index 0000000000..ae2eb57362 --- /dev/null +++ b/Docs/Changelog_SSCformat.txt @@ -0,0 +1,17 @@ +.ssc Format Changelog +________________________________________________________________________________ +In case anyone else wishes to implement the .ssc format in their own simulator, +a changelog is provided here between each version. + +Notice: .ssc is not a finalized format at the moment. There are plans for a +change to JSON, but it is unsure if this will be done. + +Implement .ssc at your own risk. +________________________________________________________________________________ + +[v0.51] - AJ +* Move VERSION tag to the first line. +* Limit VERSION tag to two decimal places. + +[v0.5] - Wolfman2000 +* Initial MSD-based version. \ No newline at end of file diff --git a/Docs/Changelog_sm-ssc.txt b/Docs/Changelog_sm-ssc.txt index 89f80b615e..6c226e527b 100644 --- a/Docs/Changelog_sm-ssc.txt +++ b/Docs/Changelog_sm-ssc.txt @@ -10,7 +10,7 @@ supported but exist anyways.) _____________________________________________________________________________ ================================================================================ -sm-ssc v1.?.? | 20110??? +sm-ssc v1.2.2 | 20110??? -------------------------------------------------------------------------------- 20110212