]> git.tdb.fi Git - r2c2.git/blobdiff - source/engineer/trainproperties.cpp
Further adjustments to changes in GLtk
[r2c2.git] / source / engineer / trainproperties.cpp
index f36035f52c31f1e2250f779f560ea0e578336e38..d92750e41725fd7d65e7071fbcfefc7e785c5cb1 100644 (file)
@@ -1,7 +1,8 @@
 #include <msp/gltk/label.h>
-#include <msp/strings/formatter.h>
+#include <msp/strings/format.h>
 #include <msp/strings/lexicalcast.h>
 #include "libr2c2/driver.h"
+#include "libr2c2/trainrouter.h"
 #include "libr2c2/vehicle.h"
 #include "libr2c2/vehicletype.h"
 #include "engineer.h"
@@ -87,9 +88,10 @@ TrainProperties::TrainProperties(Engineer &e, Train *t):
 
        if(train)
        {
-               ent_addr->set_text(lexical_cast(train->get_address()));
+               ent_addr->set_text(lexical_cast<string>(train->get_address()));
                ent_name->set_text(train->get_name());
-               drp_priority->set_selected_index(train->get_priority()+2);
+               if(TrainRouter *router = train->get_ai_of_type<TrainRouter>())
+                       drp_priority->set_selected_index(router->get_priority()+2);
 
                unsigned n_vehicles = train->get_n_vehicles();
                for(unsigned i=1; i<n_vehicles; ++i)
@@ -115,7 +117,8 @@ void TrainProperties::on_ok_clicked()
        }
 
        train->set_name(ent_name->get_text());
-       train->set_priority(drp_priority->get_selected_index()-2);
+       if(TrainRouter *router = train->get_ai_of_type<TrainRouter>())
+               router->set_priority(drp_priority->get_selected_index()-2);
 
        // The locomotive is vehicle 0 so we need to add 1
        for(set<unsigned>::const_iterator i=rem_vehicles.end(); i!=rem_vehicles.begin();)
@@ -171,5 +174,5 @@ const VehicleType &TrainProperties::get_vehicle_type(unsigned n, bool loco)
                ++i;
        }
 
-       throw InvalidParameterValue("Vehicle type index out of range");
+       throw out_of_range("TrainProperties::get_vehicle_type");
 }