The International Simutrans Forum

Development => Patches & Projects => Incorporated Patches and Solved Bug Reports => Topic started by: Fifty on July 04, 2014, 01:27:30 AM

Title: Bug - r7264 Crash with remover tool on powerline bridge
Post by: Fifty on July 04, 2014, 01:27:30 AM
The latest powerline bug crashing my servers:

If you build a powerline bridge, and then use the remover tool on any tile on top of the the powerline bridge that is not one of the two ends, simutrans will crash.
Title: Re: Bug - r6274 Crash with remover tool on powerline bridge
Post by: Ters on July 04, 2014, 05:23:22 AM
Can you confirm that you have to use the remove tool twice? I can only reproduce it on r7248 when I do that. r6274 sounds way old, though. Typo?
Title: Re: Bug - r7264 Crash with remover tool on powerline bridge
Post by: Fifty on July 04, 2014, 01:33:21 PM
Typo: r7264...

And yes, upon closer inspection you do seem to have to use the remover tool twice, the first time it deducts four credits like removing a standard powerline, and then the second time it crashes.
Title: Re: Bug - r7264 Crash with remover tool on powerline bridge
Post by: Ters on July 04, 2014, 03:51:09 PM
Preventing the crash is in itself simple enough, but I think the actual error is what happens on the first click. Some special handling of powerlines, intended for powerlines on flat ground, seems to kick in when it shouldn't.
Title: Re: Bug - r7264 Crash with remover tool on powerline bridge
Post by: Ters on July 05, 2014, 02:47:02 PM
I think this might do the trick. This causes the remover tool to not find anything to remove when clicking on a powerline bridge span, which should be consistent with other bridges. It might be unfortunate that the return value is true. If so, a bigger change is needed.
Title: Re: Bug - r7264 Crash with remover tool on powerline bridge
Post by: kierongreen on July 24, 2014, 01:57:59 PM
Fixed in 7267 - I've adopted a different fix from Ters though. While that patch did stop the crash I thought it was safer to solve the problem in brueckenbauer where the problem actually occurs:

Index: bauer/brueckenbauer.cc
===================================================================
--- bauer/brueckenbauer.cc (revision 7264)
+++ bauer/brueckenbauer.cc (working copy)
@@ -436,7 +436,7 @@
return true;
}
// now check for end of rampless bridges
- ribi_t::ribi ribi = gr->get_weg_ribi_unmasked( gr->get_weg_nr(0)->get_waytype() );
+ ribi_t::ribi ribi = gr->get_weg_ribi_unmasked( gr->get_leitung() ? powerline_wt : gr->get_weg_nr(0)->get_waytype() );
for(  int i=0;  i<4;  i++  ) {
if(  ribi_t::nsow[i] & ribi  ) {
grund_t *to = welt->lookup( gr->get_pos()+koord(ribi_t::nsow[i]) );