The International Simutrans Forum

 

Author Topic: [r7148] Broken elevated-way-bridge behaviour  (Read 3173 times)

0 Members and 1 Guest are viewing this topic.

Offline Spacethingy

  • *
  • Posts: 177
[r7148] Broken elevated-way-bridge behaviour
« 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:






Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 9438
  • Languages: De,EN,JP
Re: [r7148] Broken elevated-way-bridge behaviour
« Reply #1 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 ... )

Offline kierongreen

  • Dev Team, Coder/patcher
  • Devotee
  • *
  • Posts: 2269
Re: [r7148] Broken elevated-way-bridge behaviour
« Reply #2 on: April 20, 2014, 06:31:32 PM »
Code: [Select]
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.
« Last Edit: April 20, 2014, 06:40:38 PM by kierongreen »

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 9438
  • Languages: De,EN,JP
Re: [r7148] Broken elevated-way-bridge behaviour
« Reply #3 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.

Offline Dwachs

  • DevTeam, Coder/patcher
  • Administrator
  • *
  • Posts: 4564
  • Languages: EN, DE, AT
Re: [r7148] Broken elevated-way-bridge behaviour
« Reply #4 on: April 21, 2014, 07:53:55 AM »
You get single ribi when building downward bridge from elevated way to ground.

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 9438
  • Languages: De,EN,JP
Re: [r7148] Broken elevated-way-bridge behaviour
« Reply #5 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 ...

Offline Dwachs

  • DevTeam, Coder/patcher
  • Administrator
  • *
  • Posts: 4564
  • Languages: EN, DE, AT
Re: [r7148] Broken elevated-way-bridge behaviour
« Reply #6 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.

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 9438
  • Languages: De,EN,JP
Re: [r7148] Broken elevated-way-bridge behaviour
« Reply #7 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.

Offline Spacethingy

  • *
  • Posts: 177
Re: [r7148] Broken elevated-way-bridge behaviour
« Reply #8 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:



...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. :)

Offline Ters

  • Coder/patcher
  • Devotee
  • *
  • Posts: 5454
  • Languages: EN, NO
Re: [r7148] Broken elevated-way-bridge behaviour
« Reply #9 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.

Offline Spacethingy

  • *
  • Posts: 177
Re: [r7148] Broken elevated-way-bridge behaviour
« Reply #10 on: April 23, 2014, 08:36:31 PM »
Well well! I never noticed that. That's actually rather useful, in terms of eye-candy:



Upper bridge with deleted pylons for better looking road.