diff --git a/simhalt.cc b/simhalt.cc index 9c77b4fd3..dae7a87ab 100644 --- a/simhalt.cc +++ b/simhalt.cc @@ -265,21 +265,23 @@ koord haltestelle_t::get_next_pos( koord start ) const * It is the avarage of all tiles' coordinate weighed by level of the building */ void haltestelle_t::recalc_basis_pos() { - koord cent; + koord cent, cent_max, cent_min; + cent_max = cent_min = init_pos; sint32 level_sum; - cent = koord(); level_sum = 0; FOR(slist_tpl, const& i, tiles) { if( gebaeude_t* const gb = i.grund->find() ) { sint16 lv; lv = gb->get_tile()->get_desc()->get_level() + 1; - cent += gb->get_pos().get_2d() * lv; + cent_max.clip_max(gb->get_pos().get_2d()); + cent_min.clip_min(gb->get_pos().get_2d()); level_sum += lv; } } + cent = (cent_max + cent_min) / 2; if ( level_sum > 0 ) { - grund_t *new_center = get_ground_closest_to( cent/level_sum ); + grund_t *new_center = get_ground_closest_to( cent ); if( new_center != tiles.front().grund && new_center->get_text()==NULL ) { // move the name to new center, if there is not yet a name on it new_center->set_text( tiles.front().grund->get_text() );