]> git.tdb.fi Git - r2c2.git/commitdiff
Instead of setting the speed of all locomotives, just enable halt mode
authorMikko Rasa <tdb@tdb.fi>
Wed, 2 Apr 2014 20:15:49 +0000 (23:15 +0300)
committerMikko Rasa <tdb@tdb.fi>
Wed, 2 Apr 2014 20:15:49 +0000 (23:15 +0300)
The old code was causing an exception and segfault with ArduControl,
since locomotive IDs are not equal to their addresses.

source/engineer/engineer.cpp

index 49edd48d0d86b7cd8e4bdae246e62c72637d0188..19e515c2d2074a291b0ec0cf731e30f5a7eb676b 100644 (file)
@@ -121,17 +121,15 @@ Engineer::Engineer(int argc, char **argv):
 
 Engineer::~Engineer()
 {
-       const map<unsigned, Train *> &trains = layout.get_trains();
-       for(map<unsigned, Train *>::const_iterator i=trains.begin(); i!=trains.end(); ++i)
-               layout.get_driver().set_loco_speed(i->first, 0);
-       layout.get_driver().flush();
-
        if(!options.simulate)
        {
                layout.save_dynamic(options.state_fn+".tmp");
                FS::rename(options.state_fn+".tmp", options.state_fn);
        }
 
+       layout.get_driver().halt(true);
+       layout.get_driver().flush();
+
        delete overlay;
        delete root_arrangement;
        delete root;