The International Simutrans Forum

Development => Bug Reports => Topic started by: Spacethingy on April 20, 2014, 03:57:36 PM

Title: [r7148] Broken elevated-way-bridge behaviour
Post by: Spacethingy on April 20, 2014, 03:57:36 PM
Building a bridge between sections of elevated way tries to create a tile of raised land under the start of the bridge. This creates graphical bugs and breaks route-finding. If a ground-level way exists under the start of the bridge (i.e. the raised tile can't be created), the game crashes:


(http://i.imgur.com/MXuyGTp.png)


(http://i.imgur.com/E9IzbJj.png)
Title: Re: [r7148] Broken elevated-way-bridge behaviour
Post by: prissi on April 20, 2014, 06:06:08 PM
Such a ramp is not allowed. On elevated ways, a bridge cannot go up, only straight or down.

However, bridges and evelated ways had several issues. I hope I fixed them in r7158 (since I wanted to release tonight ... )
Title: Re: [r7148] Broken elevated-way-bridge behaviour
Post by: kierongreen on April 20, 2014, 06:31:32 PM

Index: simwerkz.cc
===================================================================
--- simwerkz.cc   (revision 7157)
+++ simwerkz.cc   (working copy)
@@ -2487,10 +2487,18 @@

    error = NULL;
    grund_t *gr = welt->lookup(pos);
-   if(  gr==NULL  ||  !hang_t::ist_wegbar(gr->get_grund_hang())  ||  !brueckenbauer_t::ist_ende_ok( sp, gr, wt, (is_first_click() ? 0 : ribi_typ(pos-start)) )  ) {
+
+   if(  gr==NULL  ||  !hang_t::ist_wegbar(gr->get_grund_hang())  ) {
       return 0;
    }

+   if(  is_first_click()  &&  (gr->get_typ()==grund_t::monorailboden  ||  !brueckenbauer_t::ist_ende_ok( sp, gr, wt, 0 ))  ) {
+      return 0;
+   }
+   else if(  !is_first_click()  &&  !brueckenbauer_t::ist_ende_ok( sp, gr, wt, ribi_typ(pos-start) )  ) {
+      return 0;
+   }
+
    if(  welt->lookup( pos + koord3d(0, 0, 1))  ||  (welt->get_settings().get_way_height_clearance()==2  &&  welt->lookup( pos + koord3d(0, 0, 2) ))  ) {
       return 0;
    }

This fixes issue but is a little messy so if anyone has a cleaner solution feel free to commit that instead!
-----------------
Edit - looked at 7158. Your solution (making level bridges when joining two elevated ways) appears to result in either broken ribis or bridge sections which cannot be demolished afterwards.
Title: Re: [r7148] Broken elevated-way-bridge behaviour
Post by: prissi on April 20, 2014, 09:14:12 PM
I tested the demolition: It works fine when clicking on either end of the bridge not the middle. (There it was not allowed before either). I could also not reproduce a single ribi on creation.
Title: Re: [r7148] Broken elevated-way-bridge behaviour
Post by: Dwachs on April 21, 2014, 07:53:55 AM
You get single ribi when building downward bridge from elevated way to ground.
Title: Re: [r7148] Broken elevated-way-bridge behaviour
Post by: prissi on April 21, 2014, 11:08:20 PM
THanks, and demolishion was also broken. Well, when this is fixed I intend to do a release candidate. THe pak64, installer and pak64.japan are ready ...
Title: Re: [r7148] Broken elevated-way-bridge behaviour
Post by: Dwachs on April 23, 2014, 09:22:52 AM
as to r7160: imho it is not necessary to check for first and last tile.

There are some checks for karten_boden, which are generically true: In the code added with 7160, gr->ist_karten_boden() is always true. All tiles in end_list are ground tiles (karten_boden) anyway.

Also the if-condition on line 847 looks strange.
Title: Re: [r7148] Broken elevated-way-bridge behaviour
Post by: prissi on April 23, 2014, 12:23:03 PM
A single tile ramp or a single tile bridge between to elevated ways needed checks for the upper end. But the other checks should be indeed made in the part deletion routine.
Title: Re: [r7148] Broken elevated-way-bridge behaviour
Post by: Spacethingy on April 23, 2014, 03:57:39 PM
As of r7164 this is kind of fixed, but for one weird little thing: connecting two elevated ways with a bridge works, as shown below:

(http://i.imgur.com/wY1sQKE.png)

...but for some odd reason, the bridge pylons can be deleted, when clicking on the ground level, as demonstrated by the lower track (which is actually just the same as the upper track). This doesn't seem to do anything, other than change the graphics. :)
Title: Re: [r7148] Broken elevated-way-bridge behaviour
Post by: Ters on April 23, 2014, 06:03:33 PM
It is normal that pylons can be deleted. That's the case with all kinds of bridges I have seen.
Title: Re: [r7148] Broken elevated-way-bridge behaviour
Post by: Spacethingy on April 23, 2014, 08:36:31 PM
Well well! I never noticed that. That's actually rather useful, in terms of eye-candy:


(http://i.imgur.com/fPpo778.png)
Upper bridge with deleted pylons for better looking road.