The International Simutrans Forum

Development => Patches & Projects => Incorporated Patches and Solved Bug Reports => Topic started by: kierongreen on July 22, 2013, 10:07:59 AM

Title: Ancient bug regarding bridge maximum heights
Post by: kierongreen on July 22, 2013, 10:07:59 AM
Interesting bug I've discovered lurking for years. The check for bridge height in brueckebauer::finde_end used to be this:

  // check for height
  sint16 height = pos.z -welt->lookup_kartenboden(pos.get_2d())->get_hoehe();
  if(besch->get_max_height()!=0  &&  height>besch->get_max_height()) {
    error_msg = "bridge is too high for its type!";
    return koord3d::invalid;
  }

Which seems fine - until you realise that pos.z isn't the height of the bridge deck, rather that of the tile that the bridge starts on (which can now be anything up to 2 tiles below the deck)...

I've fixed this in commit 6600 by making the following change:

-        sint16 height = pos.z -welt->lookup_kartenboden(pos.get_2d())->get_hoehe();
+        sint16 height = pos.z+max_height-welt->lookup_kartenboden(pos.get_2d())->get_hoehe();


As such height is now the height from bridge deck to ground level. However this might affect some paksets so don't know whether should think about any compatibility code when loading the besch?
Title: Re: Ancient bug regarding bridge maximum heights
Post by: Dwachs on July 22, 2013, 01:09:06 PM
I have no idea, which would be the best ...
Title: Re: Ancient bug regarding bridge maximum heights
Post by: prissi on July 22, 2013, 09:59:25 PM
It does not affect existing bridges. So just use the intended (your code) function is perfectly acceptable. For the double height code this needs to be reviewed int he paksets anyway.
Title: Re: Ancient bug regarding bridge maximum heights
Post by: kierongreen on July 22, 2013, 10:10:52 PM
Great - the 7 tile height limit is more of an issue now with double heights I have to say, trying to think of a way round it...