diff --git a/display/viewport.cc b/display/viewport.cc index 1bb785ed1..2020db796 100644 --- a/display/viewport.cc +++ b/display/viewport.cc @@ -308,6 +308,7 @@ viewport_t::viewport_t( karte_t *world, const koord ij_off , sint16 x_off , sint assert(world); follow_convoi = convoihandle_t(); + is_auto_ugm_follow_convoi = false; this->ij_off = ij_off; this->x_off = x_off; diff --git a/display/viewport.h b/display/viewport.h index d5a1c6990..2f9e45b2c 100644 --- a/display/viewport.h +++ b/display/viewport.h @@ -99,6 +99,12 @@ private: */ convoihandle_t follow_convoi; + /* + * The current convoi to follow. + * @author shingoushori + */ + bool is_auto_ugm_follow_convoi; + /** * Converts map_coord to map2d_coord actually used for main view. */ @@ -253,6 +259,9 @@ public: */ convoihandle_t get_follow_convoi() const { return follow_convoi; } + void set_auto_ugm_follow_convoi(bool janein) { is_auto_ugm_follow_convoi = janein; } + bool get_auto_ugm_follow_convoi() { return is_auto_ugm_follow_convoi; } + /** * @} */ diff --git a/gui/convoi_info_t.cc b/gui/convoi_info_t.cc index f17dee74a..921e7bda6 100644 --- a/gui/convoi_info_t.cc +++ b/gui/convoi_info_t.cc @@ -391,9 +391,13 @@ bool convoi_info_t::action_triggered( gui_action_creator_t *comp,value_t /* */) if(welt->get_viewport()->get_follow_convoi()==cnv) { // stop following welt->get_viewport()->set_follow_convoi( convoihandle_t() ); + welt->get_viewport()->set_auto_ugm_follow_convoi(false); } else { welt->get_viewport()->set_follow_convoi(cnv); + if(event_get_last_control_shift() == 2) { + welt->get_viewport()->set_auto_ugm_follow_convoi(true); + } } return true; } diff --git a/simworld.cc b/simworld.cc index c2f33ea52..38b0e6ebf 100644 --- a/simworld.cc +++ b/simworld.cc @@ -3550,6 +3550,19 @@ void karte_t::sync_step(uint32 delta_t, bool do_sync_step, bool display ) new_xoff -= tile_raster_scale_x(-v.get_xoff(), rw); new_yoff -= tile_raster_scale_y(-v.get_yoff(), rw) + tile_raster_scale_y(new_pos.z * TILE_HEIGHT_STEP, rw); viewport->change_world_position( new_pos.get_2d(), -new_xoff, -new_yoff ); + + // auto underground + if(viewport->get_auto_ugm_follow_convoi()){ + grund_t *gr = lookup_kartenboden(new_pos.get_2d()); + if(new_pos.z < gr->get_hoehe()) { + grund_t::set_underground_mode(grund_t::ugm_level, new_pos.z); + } + else { + grund_t::set_underground_mode(grund_t::ugm_none, 0); + } + // recalc all images on map + update_underground(); + } } }