Skip to main content
Topic: [bug+fix] Delete tunnels (Read 2460 times) previous topic - next topic

[bug+fix] Delete tunnels

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

Code: [Select]
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;
  }

Re: [bug+fix] Delete tunnels

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

Re: [bug+fix] Delete tunnels

Reply #2
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:

Code: [Select]
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
- str****e_t *str=(str****e_t *)gr->get_weg(road_wt);
+ str****e_t *str = NULL;
+ if( gr ) {
+ str = (str****e_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()) {

 

Re: [bug+fix] Delete tunnels

Reply #3
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.