]> git.tdb.fi Git - r2c2.git/commitdiff
Don't segfault if an emergency doesn't have a block
authorMikko Rasa <tdb@tdb.fi>
Fri, 13 Feb 2015 00:48:03 +0000 (02:48 +0200)
committerMikko Rasa <tdb@tdb.fi>
Fri, 13 Feb 2015 00:48:03 +0000 (02:48 +0200)
source/engineer/engineer.cpp

index fc93cf66b6076555a76129c745b1900f6dd78eff..68533bc11520114862acfed734c50cd07c91010b 100644 (file)
@@ -314,10 +314,13 @@ Object *Engineer::pick_object(const Vector &p)
 void Engineer::emergency(Block *block, const string &msg)
 {
        set_status(msg);
-       TrackChain3D *tch3d = new TrackChain3D(layout_3d, *block);
-       tch3d->set_color(GL::Color(1.0f, 0.0f, 0.0f));
-       tch3d->set_layer(2);
-       emergencies.push_back(tch3d);
+       if(block)
+       {
+               TrackChain3D *tch3d = new TrackChain3D(layout_3d, *block);
+               tch3d->set_color(GL::Color(1.0f, 0.0f, 0.0f));
+               tch3d->set_layer(2);
+               emergencies.push_back(tch3d);
+       }
 }
 
 void Engineer::halt_event(bool h)