News:

Use the "Forum Search"
It may help you to find anything in the forum ;).

[bug+fix] Delete tunnels

Started by gerw, August 27, 2009, 06:50:26 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

gerw

If you delete a tunnel, to which a vehicle wants to drive, you get a Segfault.

Index: vehicle/simvehikel.cc
===================================================================
--- vehicle/simvehikel.cc (revision 2615)
+++ vehicle/simvehikel.cc (working copy)
@@ -2400,7 +2400,7 @@
}

const grund_t *gr = welt->lookup(pos_next);
- if(gr->get_top()>250) {
+ if( !gr || gr->get_top()>250 ) {
// too many objects here
return false;
}

Dwachs

I cant reproduce the crash. Do I have to delete the tunnel in the right milli second?
Parsley, sage, rosemary, and maggikraut.

gerw

I had a train, waiting at a signal. And then I clicked continuously on the next tile.

Anyway, it must also been fixed for cars etc:

Index: vehicle/simvehikel.cc
===================================================================
--- vehicle/simvehikel.cc (revision 2614)
+++ vehicle/simvehikel.cc (working copy)
@@ -1905,7 +1905,10 @@
// check for traffic lights (only relevant for the first car in a convoi)
if(ist_erstes) {
// pruefe auf Schienenkreuzung
- strasse_t *str=(strasse_t *)gr->get_weg(road_wt);
+ strasse_t *str = NULL;
+ if( gr ) {
+ str = (strasse_t *)gr->get_weg(road_wt);
+ }

if(str==NULL  ||  gr->get_top()>250) {
// too many cars here or no street
@@ -2400,7 +2403,7 @@
}

const grund_t *gr = welt->lookup(pos_next);
- if(gr->get_top()>250) {
+ if(  !gr  ||  gr->get_top() > 250  ) {
// too many objects here
return false;
}
@@ -2880,6 +2883,9 @@

if(ist_erstes) {
grund_t *gr = welt->lookup( pos_next );
+ if( !gr ) {
+ return false;
+ }

weg_t *w = gr->get_weg(water_wt);
if(w  &&  w->is_crossing()) {

Dwachs

Actually, your fix in waggon_t::ist_weg_frei was not enough: it leads to trains waiting forever that the next tile will be free. The convoi has to search a new route.
Parsley, sage, rosemary, and maggikraut.