Skip to content

Commit

Permalink
Fix incorrect way desc of bridge ramp
Browse files Browse the repository at this point in the history
  • Loading branch information
teamhimeh committed Dec 31, 2023
1 parent ac93b9e commit 7296ca9
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
33 changes: 33 additions & 0 deletions obj/bruecke.cc
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ void bruecke_t::finish_rd()
}
}
}
fix_ramp_desc_if_needed(gr);

player_t *player=get_owner();
// change maintenance
Expand Down Expand Up @@ -218,6 +219,38 @@ void bruecke_t::finish_rd()
}


// Old versions may set incorrect way desc to a bridge ramp.
void bruecke_t::fix_ramp_desc_if_needed(const grund_t* gr) {
if( desc->get_waytype()==powerline_wt ) {
// no ramps for powerlines
return;
}
weg_t* weg = gr->get_weg_nr(0);
// check if the tile is a ramp
const slope_t::type slope = gr->get_grund_hang();
if( slope==slope_t::flat ) {
// This tile is a middle of the bridge.
return;
}
grund_t* adjacent_bridge_gr = NULL;
for(uint8 i=0; i<4; i++) {
grund_t* agr;
if( !gr->get_neighbour(agr, desc->get_waytype(), (1<<i)) || agr->get_typ()!=grund_t::brueckenboden || agr->get_grund_hang()!=slope_t::flat ) {
// This is not a flat bridge tile
continue;
}
adjacent_bridge_gr = agr;
break;
}
const weg_t* adjacent_bridge_weg = adjacent_bridge_gr ? adjacent_bridge_gr->get_weg_nr(0) : NULL;
if( !adjacent_bridge_weg ) {
// adjacent bridge tile not found?
return;
}
weg->set_desc(adjacent_bridge_weg->get_desc());
}


// correct speed and maintenance
void bruecke_t::cleanup( player_t *player2 )
{
Expand Down
2 changes: 2 additions & 0 deletions obj/bruecke.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ class bruecke_t : public obj_no_info_t
const bridge_desc_t *desc;
bridge_desc_t::img_t img;

void fix_ramp_desc_if_needed(const grund_t*);

protected:
void rdwr(loadsave_t *file) OVERRIDE;

Expand Down

0 comments on commit 7296ca9

Please sign in to comment.