From 8ac6089ff33982fe6a330f19dfa0eae66373e26f Mon Sep 17 00:00:00 2001 From: Nick Gasson Date: Sun, 10 Jan 2010 16:19:58 +0000 Subject: [PATCH] Add some debugging for reversing on points issue --- src/Train.cpp | 35 +++++++++++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 4 deletions(-) diff --git a/src/Train.cpp b/src/Train.cpp index bc5e120..1ae86bb 100644 --- a/src/Train.cpp +++ b/src/Train.cpp @@ -24,6 +24,7 @@ #include #include #include +#include #include #include @@ -88,6 +89,7 @@ private: void updateSmokePosition(int aDelta); void makeFollow(track::Choice aChoice); void flipLeader(); + void dumpFollowQueue() const; static track::Connection reverseToken(const track::TravelToken& token); static void transformToPart(const Part& p); @@ -165,6 +167,30 @@ void Train::makeFollow(track::Choice aChoice) } } +void Train::dumpFollowQueue() const +{ + ostringstream ss; + + const Part& leader = leading(); + + for (list::const_iterator it = parts.begin(); + it != parts.end(); ++it) { + + if (*it == leader) + ss << ">"; + + if ((*it).followQueue.empty()) + ss << "-"; + else { + ss << (*it).followQueue.front(); + } + + ss << " "; + } + + debug() << ss.str(); +} + Train::Part& Train::engine() { assert(parts.size() > 0); @@ -196,7 +222,6 @@ void Train::flipLeader() // Move the train along the line a bit void Train::move(double aDistance) { - for (list::iterator it = parts.begin(); it != parts.end(); ++it) { @@ -205,9 +230,9 @@ void Train::move(double aDistance) double sign = (aDistance >= 0.0 ? 1.0 : -1.0) * (*it).movementSign; const double step = 0.25; - //debug() << "move d=" << aDistance << " s=" << sign - // << " ms=" << (*it).movementSign; - + debug() << "move d=" << aDistance << " s=" << sign + << " ms=" << (*it).movementSign; + do { (*it).segmentDelta += min(step, d) * sign; @@ -283,6 +308,8 @@ void Train::update(int aDelta) move(engine().vehicle->speed() * deltaSeconds / M_PER_UNIT); velocityVector = partPosition(engine()) - oldPos; + + dumpFollowQueue(); } // Called when the train enters a new segment -- 2.39.2