Is the parenthesis in line 603 wilfully placed as it is?
fence_west = (flags&has_way1)==0 || (static_cast<weg_t*>(obj_bei(0))->get_ribi_unmasked()&ribi_t::west)==0
&& ( (flags&has_way2)==0 || (static_cast<weg_t *>(obj_bei(1))->get_ribi_unmasked()&ribi_t::west)==0);
I and my complier would prefer (since && has precedence before ||)
fence_west = ( (flags&has_way1)==0 || (static_cast<weg_t*>(obj_bei(0))->get_ribi_unmasked()&ribi_t::west)==0 )
&& ( (flags&has_way2)==0 || (static_cast<weg_t *>(obj_bei(1))->get_ribi_unmasked()&ribi_t::west)==0);
However, the code seems to be ok.
Actually, if no way1 is there there will be no way2. Using short curcuit evaluation the evaluation will without extra paranthese stop after way1==0; with parentheses it will always have to check for way2, even if way1 is not there.
what about this:
fence_west = (flags&has_way1)==0 ||
( (static_cast<weg_t*>(obj_bei(0))->get_ribi_unmasked()&ribi_t::west)==0 &&
( (flags&has_way2)==0 || (static_cast<weg_t >(obj_bei(1))->get_ribi_unmasked()&ribi_t::west)==0) );
Those are the intended (and need to go also on the other direction then ...