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?
I have no idea, which would be the best ...
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.
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...