fix freeze on fog limit
This commit is contained in:
parent
7e81d96612
commit
812b22e947
5 changed files with 35 additions and 34 deletions
|
@ -1221,7 +1221,7 @@ void display::draw_minimap(int x, int y, int w, int h)
|
|||
}
|
||||
|
||||
|
||||
void display::draw_unit_on_tile(int x, int y,double offset)
|
||||
void display::draw_unit_on_tile(int x, int y)
|
||||
{
|
||||
|
||||
const gamemap::location src(x,y);
|
||||
|
@ -1232,16 +1232,8 @@ void display::draw_unit_on_tile(int x, int y,double offset)
|
|||
}
|
||||
|
||||
|
||||
const gamemap::location dst= src.get_direction(it->second.facing());
|
||||
const double xsrc = get_location_x(src);
|
||||
const double ysrc = get_location_y(src);
|
||||
const double xdst = get_location_x(dst);
|
||||
const double ydst = get_location_y(dst);
|
||||
|
||||
const int posx = int(offset*xdst + (1.0-offset)*xsrc);
|
||||
const int posy = int(offset*ydst + (1.0-offset)*ysrc);
|
||||
|
||||
it->second.refresh_unit(*this,src,posx,posy,true);
|
||||
it->second.refresh_unit(*this,src,true);
|
||||
|
||||
|
||||
}
|
||||
|
@ -1331,7 +1323,7 @@ void display::draw_terrain_on_tile(int x, int y, image::TYPE image_type, ADJACEN
|
|||
}
|
||||
}
|
||||
|
||||
void display::draw_tile(int x, int y, double offset)
|
||||
void display::draw_tile(int x, int y)
|
||||
{
|
||||
reach_map::iterator reach = reach_map_.end();
|
||||
|
||||
|
@ -1434,7 +1426,7 @@ void display::draw_tile(int x, int y, double offset)
|
|||
}
|
||||
|
||||
draw_footstep(loc,xpos,ypos);
|
||||
draw_unit_on_tile(x,y,offset);
|
||||
draw_unit_on_tile(x,y);
|
||||
|
||||
if(!is_shrouded) {
|
||||
draw_terrain_on_tile(x,y,image_type,ADJACENT_FOREGROUND);
|
||||
|
|
|
@ -195,7 +195,7 @@ public:
|
|||
//then it will be used, otherwise the unit's default image will be used.
|
||||
//alpha controls how faded the unit is. If blend_to is not 0, then the
|
||||
//unit will be alpha-blended to blend_to instead of the background colour
|
||||
void draw_tile(int x, int y,double offset=0);
|
||||
void draw_tile(int x, int y);
|
||||
|
||||
//function to float a label above a tile
|
||||
void float_label(const gamemap::location& loc, const std::string& text,
|
||||
|
@ -208,7 +208,7 @@ private:
|
|||
//composes and draws the terrains on a tile
|
||||
void draw_terrain_on_tile(int x, int y, image::TYPE image_type, ADJACENT_TERRAIN_TYPE type);
|
||||
|
||||
void draw_unit_on_tile(int x, int y,double offset);
|
||||
void draw_unit_on_tile(int x, int y);
|
||||
|
||||
|
||||
gui::button::TYPE string_to_button_type(std::string type);
|
||||
|
|
16
src/unit.cpp
16
src/unit.cpp
|
@ -1019,6 +1019,7 @@ const surface unit::still_image() const
|
|||
void unit::set_standing(int acceleration)
|
||||
{
|
||||
state_ = STATE_STANDING;
|
||||
offset_=0;
|
||||
if(anim_) {
|
||||
delete anim_;
|
||||
anim_ = NULL;
|
||||
|
@ -1696,7 +1697,7 @@ void unit::restart_animation(int start_time, int acceleration) {
|
|||
anim_->start_animation(start_time,1,acceleration);
|
||||
}
|
||||
|
||||
void unit::refresh_unit(display& disp,gamemap::location hex,const int& x, const int& y,bool with_status)
|
||||
void unit::refresh_unit(display& disp,gamemap::location hex,bool with_status)
|
||||
{
|
||||
const gamemap & map = disp.get_map();
|
||||
if(hidden_) {
|
||||
|
@ -1715,8 +1716,15 @@ void unit::refresh_unit(display& disp,gamemap::location hex,const int& x, const
|
|||
return;
|
||||
}
|
||||
refreshing_ = true;
|
||||
gamemap::location adjacent[6];
|
||||
get_adjacent_tiles(hex, adjacent);
|
||||
const gamemap::location dst= hex.get_direction(facing());
|
||||
const double xsrc = disp.get_location_x(hex);
|
||||
const double ysrc = disp.get_location_y(hex);
|
||||
const double xdst = disp.get_location_x(dst);
|
||||
const double ydst = disp.get_location_y(dst);
|
||||
|
||||
const int x = int(offset_*xdst + (1.0-offset_)*xsrc);
|
||||
const int y = int(offset_*ydst + (1.0-offset_)*ysrc);
|
||||
|
||||
if(!anim_) set_standing(disp.turbo()?5:1);
|
||||
const gamemap::TERRAIN terrain = map.get_terrain(hex);
|
||||
const double submerge = is_flying() ? 0.0 : map.get_terrain_info(terrain).unit_submerge();
|
||||
|
@ -1820,6 +1828,8 @@ void unit::refresh_unit(display& disp,gamemap::location hex,const int& x, const
|
|||
ellipse_front.assign(image::get_image(image::locator(buf,team_rgb_range(),temp_rgb)));
|
||||
}
|
||||
|
||||
gamemap::location adjacent[6];
|
||||
get_adjacent_tiles(hex, adjacent);
|
||||
disp.draw_tile(hex.x, hex.y);
|
||||
if(state_ != STATE_STANDING) {
|
||||
for(int tile = 0; tile != 6; ++tile) {
|
||||
|
|
|
@ -142,7 +142,7 @@ public:
|
|||
const std::string& absolute_image() const {return type_->image();}
|
||||
// a sdl surface, ready for display for place where we need a fix image of the unit
|
||||
const surface still_image() const;
|
||||
void refresh_unit(display& disp,gamemap::location hex,const int& x,const int& y, bool with_status =false);
|
||||
void refresh_unit(display& disp,gamemap::location hex, bool with_status =false);
|
||||
|
||||
void set_standing(int acceleration);
|
||||
void set_defending(int damage, std::string range, int acceleration);
|
||||
|
@ -160,6 +160,7 @@ public:
|
|||
void set_poisoned(int damage,int acceleration);
|
||||
void restart_animation(int start_time, int acceleration);
|
||||
const unit_animation* get_animation() const { return anim_;};
|
||||
void set_offset(double offset){offset_ = offset;}
|
||||
|
||||
void set_facing(gamemap::location::DIRECTION);
|
||||
gamemap::location::DIRECTION facing() const;
|
||||
|
@ -265,6 +266,7 @@ private:
|
|||
bool unrenamable_;
|
||||
|
||||
unit_animation *anim_;
|
||||
double offset_;
|
||||
std::string user_image_;
|
||||
|
||||
void reset_modifications();
|
||||
|
|
|
@ -88,17 +88,12 @@ void move_unit_between(display& disp, const gamemap& map, const gamemap::locatio
|
|||
const unsigned int start_time = SDL_GetTicks();
|
||||
int mvt_time = SDL_GetTicks() -start_time;
|
||||
disp.scroll_to_tiles(a.x,a.y,b.x,b.y,display::ONSCREEN);
|
||||
const double xsrc = disp.get_location_x(a);
|
||||
const double ysrc = disp.get_location_y(a);
|
||||
const double xdst = disp.get_location_x(b);
|
||||
const double ydst = disp.get_location_y(b);
|
||||
while(mvt_time < total_mvt_time) {
|
||||
u.set_walking(map.underlying_mvt_terrain(src_terrain),acceleration);
|
||||
const double pos =double(mvt_time)/total_mvt_time;
|
||||
const int posx = int(pos*xdst + (1.0-pos)*xsrc);
|
||||
const int posy = int(pos*ydst + (1.0-pos)*ysrc);
|
||||
disp.draw_tile(a.x,a.y);
|
||||
u.refresh_unit(disp,a,posx,posy);
|
||||
u.set_offset(pos);
|
||||
u.refresh_unit(disp,a);
|
||||
disp.update_display();
|
||||
events::pump();
|
||||
if(!disp.turbo()) SDL_Delay(10);
|
||||
|
@ -242,7 +237,7 @@ bool unit_attack_ranged(display& disp,const gamemap& map, unit_map& units,
|
|||
}
|
||||
while(!attacker.get_animation()->animation_finished() ) {
|
||||
disp.draw_tile(a.x,a.y);
|
||||
//if(leader_loc.valid()) leader->second.refresh_unit(disp,map,disp.get_location_x(leader_loc),disp.get_location_y(leader_loc));
|
||||
if(leader_loc.valid()) disp.draw_tile(leader_loc.x,leader_loc.y);
|
||||
disp.update_display();
|
||||
events::pump();
|
||||
if(!disp.turbo()) SDL_Delay(10);
|
||||
|
@ -270,8 +265,8 @@ bool unit_attack_ranged(display& disp,const gamemap& map, unit_map& units,
|
|||
const int posy = int(pos*ysrc + (1.0-pos)*ydst);
|
||||
disp.draw_tile(b.x,b.y);
|
||||
disp.draw_tile(a.x,a.y);
|
||||
//if(leader_loc.valid()) leader->second.refresh_unit(disp,leader_loc.x,leader_loc.y);
|
||||
if(pos > 0.0 && pos < 1.0) {
|
||||
if(leader_loc.valid()) disp.draw_tile(leader_loc.x,leader_loc.y);
|
||||
if(pos > 0.0 && pos < 1.0 && (!disp.fogged(b.x,b.y) || !disp.fogged(a.x,a.y))) {
|
||||
const unit_frame& missile_frame = missile_animation.get_current_frame();
|
||||
const std::string *missile_image = NULL;
|
||||
if(dir == unit_animation::VERTICAL) {
|
||||
|
@ -392,9 +387,10 @@ bool unit_attack(display& disp, unit_map& units, const gamemap& map,
|
|||
while(animation_time < 0 && !hide) {
|
||||
const double pos = animation_time < attacker.get_animation()->get_first_frame_time()?0.0:
|
||||
(1.0 - double(animation_time)/double(attacker.get_animation()->get_first_frame_time()));
|
||||
disp.draw_tile(a.x,a.y,pos*0.6);
|
||||
//defender.refresh_unit(disp,disp.get_location_x(b), disp.get_location_y(b));
|
||||
//if(leader_loc.valid()) leader->second.refresh_unit(disp,leader_loc.x,leader_loc.y);
|
||||
attacker.set_offset(pos*0.6);
|
||||
disp.draw_tile(a.x,a.y);
|
||||
disp.draw_tile(b.x,b.y);
|
||||
if(leader_loc.valid()) disp.draw_tile(leader_loc.x,leader_loc.y);
|
||||
disp.update_display();
|
||||
events::pump();
|
||||
if(!disp.turbo()) SDL_Delay(10);
|
||||
|
@ -412,9 +408,10 @@ bool unit_attack(display& disp, unit_map& units, const gamemap& map,
|
|||
!defender.get_animation()->animation_finished() ||
|
||||
(leader_loc.valid() && !leader->second.get_animation()->animation_finished() )) {
|
||||
const double pos = (1.0-double(animation_time)/double(end_time));
|
||||
disp.draw_tile(a.x,a.y,pos*0.6);
|
||||
//defender.refresh_unit(disp,disp.get_location_x(b), disp.get_location_y(b));
|
||||
//if(leader_loc.valid()) leader->second.refresh_unit(disp,leader_loc.x,leader_loc.y);
|
||||
attacker.set_offset(pos*0.6);
|
||||
disp.draw_tile(a.x,a.y);
|
||||
disp.draw_tile(b.x,b.y);
|
||||
if(leader_loc.valid()) disp.draw_tile(leader_loc.x,leader_loc.y);
|
||||
disp.update_display();
|
||||
events::pump();
|
||||
if(!disp.turbo()) SDL_Delay(10);
|
||||
|
|
Loading…
Add table
Reference in a new issue