]> git.tdb.fi Git - r2c2.git/blobdiff - source/designer/designer.cpp
Prefer is_turnout() when checking if a track is, in fact, a turnout
[r2c2.git] / source / designer / designer.cpp
index 3d068d0ad42d4252adb1561f45874e46bb6790ee..4ad5274e1cce7754c9742890b4b26607449f9ef6 100644 (file)
@@ -537,8 +537,9 @@ void Designer::update_object_icon(Object &obj)
                        overlay->add_graphic(obj3d, "trackcircuit");
                        overlay->set_label(obj3d, lexical_cast<string>(saddr));
                }
-               else if(unsigned taddr = track->get_turnout_address())
+               else if(track->get_type().is_turnout())
                {
+                       unsigned taddr = track->get_turnout_address();
                        if(taddr<0x800)
                        {
                                overlay->add_graphic(obj3d, "turnout");
@@ -595,7 +596,7 @@ string Designer::tooltip(int x, int y)
                {
                        if(mode!=CATALOGUE && abs(track->get_tilt()).radians()>1e-4)
                                info += format(" (slope %.1f%%)", abs(tan(track->get_tilt())*100));
-                       if(track->get_turnout_address())
+                       if(track->get_type().is_turnout())
                                info += format(" (turnout %d)", track->get_turnout_address());
                        else if(track->get_sensor_address())
                                info += format(" (sensor %d)", track->get_sensor_address());
@@ -623,8 +624,8 @@ void Designer::show_route(const Route &route)
                Track3D &t3d = layout_3d->get_3d(**i);
                Path3D *path = new Path3D(t3d);
                path->set_color(GL::Color(0.5, 0.8, 1.0));
-               if(unsigned taddr = (*i)->get_turnout_address())
-                       path->set_path(route.get_turnout(taddr));
+               if((*i)->get_type().is_turnout())
+                       path->set_path(route.get_turnout((*i)->get_turnout_address()));
                highlight_paths.push_back(path);
        }
 }