Change TrailEntry so it uses a StepsID instead of a Steps*.

Now Edit Mode can change the Steps pointers without causing crashes
because of the Trails.  (Exception: deleted song or steps.)
This commit is contained in:
John Bauer
2006-11-10 05:47:10 +00:00
parent 5d2bf93725
commit 00b40c7468
3 changed files with 14 additions and 6 deletions
+8
View File
@@ -69,6 +69,7 @@ namespace StepsUtil
class StepsID class StepsID
{ {
private:
StepsType st; StepsType st;
Difficulty dc; Difficulty dc;
RString sDescription; RString sDescription;
@@ -89,6 +90,13 @@ public:
static void ClearCache(); static void ClearCache();
StepsType GetStepsType() const { return st; } StepsType GetStepsType() const { return st; }
bool operator==( const StepsID &other ) const
{
#define X(x) (x == other.x)
return X(st) && X(dc) && X(sDescription) && X(uHash);
#undef X
}
}; };
#endif #endif
+3 -3
View File
@@ -21,7 +21,7 @@ bool TrailEntry::operator== ( const TrailEntry &rhs ) const
#define EQUAL(a) (a==rhs.a) #define EQUAL(a) (a==rhs.a)
return return
EQUAL(pSong) && EQUAL(pSong) &&
EQUAL(pSteps) && EQUAL(m_StepsID) &&
EQUAL(Modifiers) && EQUAL(Modifiers) &&
EQUAL(Attacks) && EQUAL(Attacks) &&
EQUAL(bSecret) && EQUAL(bSecret) &&
@@ -32,12 +32,12 @@ bool TrailEntry::operator== ( const TrailEntry &rhs ) const
Steps *TrailEntry::GetSteps() const Steps *TrailEntry::GetSteps() const
{ {
return pSteps; return m_StepsID.ToSteps( pSong, false );
} }
void TrailEntry::SetSteps(Steps *steps) void TrailEntry::SetSteps(Steps *steps)
{ {
pSteps = steps; m_StepsID.FromSteps( steps );
} }
bool TrailEntry::ContainsTransformOrTurn() const bool TrailEntry::ContainsTransformOrTurn() const
+3 -3
View File
@@ -4,8 +4,9 @@
#define TRAIL_H #define TRAIL_H
#include "Attack.h" #include "Attack.h"
#include "RadarValues.h"
#include "Difficulty.h" #include "Difficulty.h"
#include "RadarValues.h"
#include "StepsUtil.h"
class Song; class Song;
class Steps; class Steps;
@@ -16,7 +17,6 @@ struct TrailEntry
public: public:
TrailEntry(): TrailEntry():
pSong(NULL), pSong(NULL),
pSteps(NULL),
bSecret(false), bSecret(false),
iLowMeter(-1), iLowMeter(-1),
iHighMeter(-1), iHighMeter(-1),
@@ -29,7 +29,7 @@ public:
bool ContainsTransformOrTurn() const; bool ContainsTransformOrTurn() const;
Song* pSong; Song* pSong;
Steps* pSteps; StepsID m_StepsID;
RString Modifiers; RString Modifiers;
AttackArray Attacks; AttackArray Attacks;
bool bSecret; // show "???" bool bSecret; // show "???"