The International Simutrans Forum

Development => Patches & Projects => Incorporated Patches and Solved Bug Reports => Topic started by: gerw on August 27, 2009, 06:50:26 pm

Title: [bug+fix] Delete tunnels
Post by: gerw on August 27, 2009, 06:50:26 pm
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;
  }
Title: Re: [bug+fix] Delete tunnels
Post by: Dwachs on August 27, 2009, 07:15:01 pm
I cant reproduce the crash. Do I have to delete the tunnel in the right milli second?
Title: Re: [bug+fix] Delete tunnels
Post by: gerw on August 28, 2009, 06:23:29 am
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()) {
Title: Re: [bug+fix] Delete tunnels
Post by: Dwachs on September 04, 2009, 06:49:16 pm
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.