The International Simutrans Forum

 

Author Topic: Upgrading bridges  (Read 4803 times)

0 Members and 1 Guest are viewing this topic.

Offline jamespetts gb

  • Simutrans-Extended project coordinator
  • Devotee
  • *
  • Posts: 18753
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Upgrading bridges
« on: April 13, 2014, 12:14:29 PM »
I am not sure whether extension requests is the best place to put this, or whether it should go into "technical documentation", but I suppose that it also constitutes an extension request, so I add it here.

It would be helpful to be able to upgrade bridges in the same way as one can upgrade track, simply by dragging a new bridge over an existing bridge rather than deleting the existing bridge and building a new one. I am considering adding this feature in Experimental, but thought it better to enquire first as to why this is not in Standard in case there are particular difficulties in doing this that do not exist with, say, elevated ways, which can be replaced in this way, and, if there are, any thoughts on how they might be overcome.

One of the reasons that I want to add this to Experimental is that I wish to make a system in which upgrading a bridge costs less than building a new one provided that the old and new bridge are defined as being in the same group according to .dat file parameters that I plan to add, as a workaround to the fact that bridges and ways are not currently separate (one would have multiple versions of the same type of bridge defined in the .dat files, each with a different way so that one can upgrade/downgrade between them at only the cost of the way itself).

Thank you in advance for any help.

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 9584
  • Languages: De,EN,JP
Re: Upgrading bridges
« Reply #1 on: April 13, 2014, 02:40:10 PM »
In real life upgrading a bridge is not possible beyond a new surface. Instead the old has to be teared down, since foundation and pillar etc. are only as strong as needed, and would not suffice with a bigger bridge.

Of course, you could upgrade a cobblestone to asphalt surface; but speed and weight limit would be the same for both, since they are rather given by geometry and built.

Offline jamespetts gb

  • Simutrans-Extended project coordinator
  • Devotee
  • *
  • Posts: 18753
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Re: Upgrading bridges
« Reply #2 on: April 13, 2014, 02:46:02 PM »
Yes, that is the plan: to have groups based on a series of essentially the same bridge with different surfaces (for road) or tracks (for rail). The speed limit may stay the same or vary depending on whether the main limitation was the surface/tracks or the structure. Do I understand that the fact that bridges are not upgraded in reality is the reason that dragging to upgrade is not possible in Simutrans, rather than any technical limitation?

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 9584
  • Languages: De,EN,JP
Re: Upgrading bridges
« Reply #3 on: April 13, 2014, 02:49:16 PM »
Upgrading is trivial, you just have to exchange the besch of the bridge. But for realism, a bridge cannot be upgraded. Its speed limit and weight limit are given and not fast track will change this.

The upgrading with double height code requires even more check. What has to be always similar is same pillar distance, but now you have to check for same double height ramp allowance (if needed).

Offline jamespetts gb

  • Simutrans-Extended project coordinator
  • Devotee
  • *
  • Posts: 18753
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Re: Upgrading bridges
« Reply #4 on: April 13, 2014, 03:06:15 PM »
Thank you - that is helpful. As stated, in terms of realism, what I am trying to accomplish is a workaround to not being able to treat the road/tracks on a bridge as separate from the bridge itself, rather than actually upgrading the bridge.

Although, I should note that there seems to be an anomaly in that it is possible already to upgrade elevated ways, which are, in engineering terms, nearly identical to bridges.

Offline Sarlock

  • Devotee
  • *
  • Posts: 1340
  • Languages: EN
Re: Upgrading bridges
« Reply #5 on: April 13, 2014, 04:48:46 PM »
It indeed would be nice to be able to drag a new bridge over an existing one and replace it... the cost should be equal to bulldozing the old bridge and placing the new one -- I don't think you can heavily refurbish an existing bridge to significantly increase weight limit/speed without spending as much or more than a new bridge in the same spot.

It would certainly be much easier than having to bulldoze each bridge and replace... especially on an existing line with heavy traffic in a game you can't pause (online game).

Offline AP

  • Devotee
  • *
  • Posts: 1202
  • Languages: EN
Re: Upgrading bridges
« Reply #6 on: April 13, 2014, 05:20:22 PM »
Just a suggestion - it may be worth considering allowing upgrading e.g. rail bridges to road (subject to weight restrictions) - unless of course that is a bridge too far.(ahem!).

E.g. Connel Ferry Bridge, scotland. There must be other examples.

Offline jamespetts gb

  • Simutrans-Extended project coordinator
  • Devotee
  • *
  • Posts: 18753
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Re: Upgrading bridges
« Reply #7 on: April 13, 2014, 05:25:46 PM »
Just a suggestion - it may be worth considering allowing upgrading e.g. rail bridges to road (subject to weight restrictions) - unless of course that is a bridge too far.(ahem!).

E.g. Connel Ferry Bridge, scotland. There must be other examples.

That would be much harder to achieve in the code, alas. One day, perhaps.

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 9584
  • Languages: De,EN,JP
Re: Upgrading bridges
« Reply #8 on: April 13, 2014, 07:52:24 PM »
Since the way type is in the besch of a bridge, updating bridges to different waytypes could be done by just exchanging the default way on the bridge (it is invisble).

Offline jamespetts gb

  • Simutrans-Extended project coordinator
  • Devotee
  • *
  • Posts: 18753
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Re: Upgrading bridges
« Reply #9 on: April 13, 2014, 08:05:38 PM »
Hmm, interesting. This might be a little difficult to make work with the tools, perhaps...?

Offline kierongreen

  • Dev Team, Coder/patcher
  • Devotee
  • *
  • Posts: 2269
Re: Upgrading bridges
« Reply #10 on: April 13, 2014, 10:00:07 PM »
Quote
E.g. Connel Ferry Bridge, scotland. There must be other examples.
Which is even more complicated as it started out as a rail-only bridge, a roadway was added later, and finally the track was removed. Does look nice though and very near where I live! Actually just up the branch to Ballahulish at Cregan another rail bridge was first converted into a cycle track then completely rebuilt into a new road bridge.

Offline jamespetts gb

  • Simutrans-Extended project coordinator
  • Devotee
  • *
  • Posts: 18753
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Re: Upgrading bridges
« Reply #11 on: December 30, 2014, 09:36:08 PM »
Reviving this old topic for a moment, as I am currently looking into making bridges upgradable; I am having some trouble finding which parts of the UI stop the player actually dragging a bridge over an existing bridge. I assume that it is in breukenbauer.cc or simwerkz.cc somewhere? Those are somewhat of a tangle for checking position, angle, ground, slope, height and a myriad other physical features before building, and it is hard to deduce how the code is intended to work. Any assistance on this would be much appreciated.

Offline Ters

  • Coder/patcher
  • Devotee
  • *
  • Posts: 5555
  • Languages: EN, NO
Re: Upgrading bridges
« Reply #12 on: December 30, 2014, 10:15:59 PM »
There are two things that might cause problems: One is the fact that bridges are build on the ground, but are also themselves ground. That means that the bridge builder will try to build on top of the ground that is the other bridge, rather than being built where the other bridge is. The other thing is that bridges must either be build alone, or from the end of an existing way. When an existing bridge exists, neither of these conditions hold, as there is a existing way with no free ends.

Tunnels can be upgraded in place, so whatever they do differently might give a clue.

Offline jamespetts gb

  • Simutrans-Extended project coordinator
  • Devotee
  • *
  • Posts: 18753
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Re: Upgrading bridges
« Reply #13 on: December 30, 2014, 10:40:08 PM »
Thank you for that.

There do indeed seem to be multiple blockages to dragging a bridge over another bridge. The main issue seems to be in uint8 wkz_brueckenbau_t::is_valid_pos(  spieler_t *sp, const koord3d &pos, const char *&error, const koord3d &start ). I have cleared out one blockage:

Code: [Select]
if(  gr->get_typ()!=grund_t::boden  &&  gr->get_typ()!=grund_t::monorailboden  &&
        gr->get_typ()!=grund_t::tunnelboden && gr->get_typ() != grund_t::brueckenboden ) {
      return false;
   }

instead of

Code: [Select]
if(  gr->get_typ()!=grund_t::boden  &&  gr->get_typ()!=grund_t::monorailboden  &&
        gr->get_typ()!=grund_t::tunnelboden  ) {
      return false;
   }

in bool brueckenbauer_t::ist_ende_ok(spieler_t *sp, const grund_t *gr, waytype_t wt, ribi_t::ribi r ), which is called from is_valid_pos.

However, the next place that that function returns a zero is:

Code: [Select]
// ribi from slope
      rw |= ribi_typ(gr->get_grund_hang());
      if(  rw!=ribi_t::keine && !ribi_t::ist_einfach(rw)  ) {
         return 0;
      }

"Keine" means "nothing", I think, and Google tells me that "Einfach" means "simply". However, I never quite got the hang of the ribi system, so I do not really understand this. Even if I manually move the caret onwards in MSVC, however, another blockage occurs when brueckenbauer_t::finde_ende returns a negative result on the second click (I do not think that clicking and dragging really works when setting breakpoints in the debugger, as they trigger after the first click and prevent dragging).

Edit: Altering bool brueckenbauer_t::is_blocked so as to add != grund_t::brueckenboden && to

Code: [Select]
else if(  gr2->get_typ() != grund_t::boden  && gr2->get_typ() != grund_t::tunnelboden  ) {
            // not through bridges
            return true;
        }

also seems necessary (but not sufficient), but also allows bridges to cross each other at right angles at the same height, which is clearly not desirable.
« Last Edit: December 30, 2014, 10:53:37 PM by jamespetts »

Offline An_dz

  • Web Admin
  • Administrator
  • *
  • Posts: 2908
  • D'oh
    • by An_dz
  • Languages: pt, en, it, (de)
Re: Upgrading bridges
« Reply #14 on: December 31, 2014, 12:46:34 AM »
"Keine" means "nothing", I think, and Google tells me that "Einfach" means "simply". However, I never quite got the hang of the ribi system, so I do not really understand this.
Keine is nothing/none, Einfach is simple/simply, the function ist_einfach() seems to translate to is_simple().

My knowledge of ribi is limited to way ribi (NWSE ?) but the basic is that there is one bit for every direction (NWSE) and i guess there's one for setting as slope and one for half height.

Bing translator is better than Google for German. I get better translations

Offline kierongreen

  • Dev Team, Coder/patcher
  • Devotee
  • *
  • Posts: 2269
Re: Upgrading bridges
« Reply #15 on: December 31, 2014, 01:57:11 AM »
It means you can only start a bridge from the end of a way (which if there's already a bridge there then the ribi will instead be straight).

Offline Ters

  • Coder/patcher
  • Devotee
  • *
  • Posts: 5555
  • Languages: EN, NO
Re: Upgrading bridges
« Reply #16 on: December 31, 2014, 09:44:09 AM »
The correct translation of einfach in this context is single/one-way. It means that there is only a single ribi set, which in turn means that it is a free end. A way enters the tile, but does not leave it (or the other way around). So it is the second of the two obstacles I mentioned. With this check removed, it will be possible to build a bridge in the middle of a road.

Offline jamespetts gb

  • Simutrans-Extended project coordinator
  • Devotee
  • *
  • Posts: 18753
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Re: Upgrading bridges
« Reply #17 on: December 31, 2014, 10:53:59 AM »
Yes, I see. The most trouble that I had (and where I gave up) was with the issue described above with brueckenbauer_t::is_blocked, where allowing it to be built if there was a bridge there already allowed bridges to cross at the same height at right angles, but still did not allow bridges to be dragged over existing bridges.