From ebb934b2056eb2b4b8aadb1964b8b5ce86c1b0a3 Mon Sep 17 00:00:00 2001 From: Nick Gasson Date: Sun, 10 Jan 2010 15:12:00 +0000 Subject: [PATCH] Detect stopping at stations --- src/Engine.cpp | 4 +++- src/Game.cpp | 13 ++++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/Engine.cpp b/src/Engine.cpp index 1c6b44c..02118ba 100644 --- a/src/Engine.cpp +++ b/src/Engine.cpp @@ -205,10 +205,12 @@ void Engine::update(int aDelta) // mySpeed = max(mySpeed + a, 0.0); mySpeed += a; - if (abs(mySpeed) < STOP_SPEED * deltaSeconds) { + if (abs(mySpeed) < STOP_SPEED && myThrottle == 0) { mySpeed = 0.0; haveStopped = true; } + else + haveStopped = false; //debug() << "P=" << netP << ", Q=" << Q // << ", B=" << B diff --git a/src/Game.cpp b/src/Game.cpp index 609fb1c..ec81983 100644 --- a/src/Game.cpp +++ b/src/Game.cpp @@ -58,6 +58,7 @@ private: void leftStation(); Vector cameraPosition(float aRadius) const; void switchToBirdCamera(); + void stoppedAtStation(); IMapPtr map; ITrainPtr train; @@ -159,6 +160,11 @@ void Game::overlay() const colour::WHITE, statusMsg); } +void Game::stoppedAtStation() +{ + debug() << "Stopped at " << activeStation->name(); +} + void Game::update(IPickBufferPtr aPickBuffer, int aDelta) { train->update(aDelta); @@ -224,8 +230,13 @@ void Game::lookAhead() // Are we sitting on a station? if (it.status == TRACK_STATION) { - setStatus("Stop here for station " + it.station->name()); nearStation(it.station); + + if (train->controller()->stopped()) + stoppedAtStation(); + else + setStatus("Stop here for station " + it.station->name()); + return; } -- 2.39.2