diff --git a/simutrans/trunk/display/clip_num.h b/simutrans/trunk/display/clip_num.h index 0506273..24f343d 100644 --- a/simutrans/trunk/display/clip_num.h +++ b/simutrans/trunk/display/clip_num.h @@ -13,6 +13,7 @@ #define CLIP_NUM_DEFAULT_VALUE 0 #define CLIP_NUM_COMMA , #define CLIP_NUM_DEFAULT_ZERO = CLIP_NUM_DEFAULT_VALUE +#define CLIP_NUM_INDEX [clip_num] #else @@ -21,6 +22,7 @@ #define CLIP_NUM_COMMA #define CLIP_NUM_DEFAULT_VALUE #define CLIP_NUM_DEFAULT_ZERO +#define CLIP_NUM_INDEX #endif diff --git a/simutrans/trunk/simplan.cc b/simutrans/trunk/simplan.cc index e523286..422bf83 100644 --- a/simutrans/trunk/simplan.cc +++ b/simutrans/trunk/simplan.cc @@ -419,8 +419,31 @@ void planquadrat_t::angehoben() } +#ifdef MULTI_THREAD +static clip_dimension save_cr[MAX_THREADS]; +static bool cr_active[MAX_THREADS]; +#else +static clip_dimension save_cr; +static bool cr_active; +#endif + +void planquadrat_t::toggle_horizontal_clip(CLIP_NUM_DEF0) +{ + if (cr_active CLIP_NUM_INDEX) { + // effectively swap save_cr and active clipping rectangle + clip_dimension cr = display_get_clip_wh(CLIP_NUM_VAR); + clip_dimension &sr = save_cr CLIP_NUM_INDEX; + // clip according to saved clipping rectangle + display_set_clip_wh(sr.x, sr.y, sr.w, sr.h CLIP_NUM_PAR ); + // and copy + sr = cr; + } +} + + void planquadrat_t::display_obj(const sint16 xpos, const sint16 ypos, const sint16 raster_tile_width, bool is_global, const sint8 hmin, const sint8 hmax CLIP_NUM_DEF) const { + cr_active CLIP_NUM_INDEX = false; grund_t *gr0 = get_kartenboden(); if( gr0->get_flag( grund_t::dirty ) ) { gr0->set_all_obj_dirty(); // prevent artifacts with smart hide cursor @@ -459,9 +482,11 @@ void planquadrat_t::display_obj(const sint16 xpos, const sint16 ypos, const sint } else { // clip everything at the next tile above - clip_dimension p_cr; if( i < ground_size ) { + + clip_dimension &p_cr = save_cr CLIP_NUM_INDEX; p_cr = display_get_clip_wh( CLIP_NUM_VAR ); + for( uint8 j = i; j < ground_size; j++ ) { const sint8 h = data.some[j]->get_hoehe(); const sint8 htop = h + slope_t::max_diff(data.some[j]->get_grund_hang()); @@ -475,12 +500,16 @@ void planquadrat_t::display_obj(const sint16 xpos, const sint16 ypos, const sint const sint16 yh = ypos - tile_raster_scale_y( (h - h0) * TILE_HEIGHT_STEP, raster_tile_width ) + ((3 * raster_tile_width) >> 2); if( yh >= p_cr.y ) { display_set_clip_wh(p_cr.x, yh, p_cr.w, p_cr.h + p_cr.y - yh CLIP_NUM_PAR ); + cr_active CLIP_NUM_INDEX = true; } break; } } gr0->display_obj_all( xpos, ypos, raster_tile_width, is_global CLIP_NUM_PAR ); - display_set_clip_wh( p_cr.x, p_cr.y, p_cr.w, p_cr.h CLIP_NUM_PAR ); // restore clipping + if (cr_active CLIP_NUM_INDEX) { + display_set_clip_wh( p_cr.x, p_cr.y, p_cr.w, p_cr.h CLIP_NUM_PAR ); // restore clipping + cr_active CLIP_NUM_INDEX = false; + } } else { gr0->display_obj_all( xpos, ypos, raster_tile_width, is_global CLIP_NUM_PAR ); diff --git a/simutrans/trunk/simplan.h b/simutrans/trunk/simplan.h index d456370..a859d13 100644 --- a/simutrans/trunk/simplan.h +++ b/simutrans/trunk/simplan.h @@ -244,6 +244,8 @@ public: void display_tileoverlay(sint16 xpos, sint16 ypos, const sint8 hmin, const sint8 hmax) const; void display_overlay(sint16 xpos, sint16 ypos) const; + + static void toggle_horizontal_clip(CLIP_NUM_DEF0); }; #endif diff --git a/simutrans/trunk/vehicle/simvehicle.cc b/simutrans/trunk/vehicle/simvehicle.cc index e4c6f9e..31eccd8 100644 --- a/simutrans/trunk/vehicle/simvehicle.cc +++ b/simutrans/trunk/vehicle/simvehicle.cc @@ -4228,12 +4228,14 @@ void air_vehicle_t::display_after(int xpos_org, int ypos_org, bool is_global) co xpos += tile_raster_scale_x(get_xoff(), raster_width); get_screen_offset( xpos, ypos, raster_width ); + planquadrat_t::toggle_horizontal_clip(CLIP_NUM_PAR); // will be dirty // the aircraft!!! display_color( image, xpos, ypos, get_player_nr(), true, true/*get_flag(obj_t::dirty)*/ CLIP_NUM_PAR); #ifndef MULTI_THREAD vehicle_t::display_after( xpos_org, ypos_org - tile_raster_scale_y( current_flughohe - hoff - 2, raster_width ), is_global ); #endif + planquadrat_t::toggle_horizontal_clip(CLIP_NUM_PAR); } #ifdef MULTI_THREAD }