mirror of
https://github.com/wesnoth/wesnoth
synced 2025-05-01 20:05:41 +00:00
fix missiles not being displayed properly,
...disabling halos will cause all misssiles to disapear, though
This commit is contained in:
parent
3a846f7d3a
commit
42a055aa79
@ -52,7 +52,7 @@ private:
|
||||
|
||||
std::string current_image_;
|
||||
|
||||
bool reverse_;
|
||||
ORIENTATION orientation_;
|
||||
|
||||
int origx_, origy_, x_, y_;
|
||||
double origzoom_, zoom_;
|
||||
@ -68,7 +68,7 @@ bool hide_halo = false;
|
||||
static const SDL_Rect empty_rect = {0,0,0,0};
|
||||
|
||||
effect::effect(int xpos, int ypos, const std::string& img, ORIENTATION orientation, int lifetime)
|
||||
: images_(img), reverse_(orientation == REVERSE), origx_(xpos), origy_(ypos), x_(xpos), y_(ypos),
|
||||
: images_(img), orientation_(orientation), origx_(xpos), origy_(ypos), x_(xpos), y_(ypos),
|
||||
origzoom_(disp->zoom()), zoom_(disp->zoom()), surf_(NULL), buffer_(NULL), rect_(empty_rect)
|
||||
{
|
||||
wassert(disp != NULL);
|
||||
@ -115,9 +115,12 @@ void effect::rezoom()
|
||||
y_ = int((origy_*zoom_)/origzoom_);
|
||||
|
||||
surf_.assign(image::get_image(current_image_,image::UNSCALED));
|
||||
if(surf_ != NULL && reverse_) {
|
||||
if(surf_ != NULL && (orientation_ == HREVERSE || orientation_ == HVREVERSE)) {
|
||||
surf_.assign(image::reverse_image(surf_));
|
||||
}
|
||||
if(surf_ != NULL && (orientation_ == VREVERSE || orientation_ == HVREVERSE)) {
|
||||
surf_.assign(flop_surface(surf_));
|
||||
}
|
||||
|
||||
if(surf_ != NULL && zoom_ != 1.0) {
|
||||
surf_.assign(scale_surface(surf_,int(surf_->w*zoom_),int(surf_->h*zoom_)));
|
||||
|
@ -39,7 +39,7 @@ private:
|
||||
bool old;
|
||||
};
|
||||
|
||||
enum ORIENTATION { NORMAL, REVERSE };
|
||||
enum ORIENTATION { NORMAL, HREVERSE, VREVERSE, HVREVERSE };
|
||||
|
||||
///function to add a haloing effect using 'image'
|
||||
///centered on (x,y)
|
||||
|
@ -1594,7 +1594,7 @@ void unit::redraw_unit(display& disp,gamemap::location hex)
|
||||
unit_anim_halo_ = halo::add(x+d+static_cast<int>(current_frame.halo_x*disp.zoom()),
|
||||
y+d+static_cast<int>(current_frame.halo_y*disp.zoom()),
|
||||
current_frame.halo[sub_halo].first,
|
||||
halo::REVERSE);
|
||||
halo::HREVERSE);
|
||||
}
|
||||
}
|
||||
if(image_name.empty()) {
|
||||
|
@ -250,6 +250,20 @@ bool unit_attack_ranged(display& disp, unit_map& units,
|
||||
|
||||
const bool vflip = b.y > a.y || b.y == a.y && is_even(a.x);
|
||||
const bool hflip = b.x < a.x;
|
||||
halo::ORIENTATION orientation;
|
||||
if(hflip) {
|
||||
if(vflip) {
|
||||
orientation = halo::HVREVERSE;
|
||||
} else {
|
||||
orientation = halo::HREVERSE;
|
||||
}
|
||||
} else {
|
||||
if(vflip) {
|
||||
orientation = halo::VREVERSE;
|
||||
} else {
|
||||
orientation = halo::NORMAL;
|
||||
}
|
||||
}
|
||||
const unit_animation::FRAME_DIRECTION dir = (a.x == b.x) ? unit_animation::VERTICAL:unit_animation::DIAGONAL;
|
||||
|
||||
defender.set_defending(disp,b,damage,&attack);
|
||||
@ -259,7 +273,8 @@ bool unit_attack_ranged(display& disp, unit_map& units,
|
||||
defender.restart_animation(disp,start_time);
|
||||
animation_time = defender.get_animation()->get_animation_time();
|
||||
bool sound_played = false ;
|
||||
int missile_halo =0;
|
||||
int missile_frame_halo =0;
|
||||
int missile_halo =0;
|
||||
while(!defender.get_animation()->animation_finished() ||
|
||||
(leader_loc.valid() && !leader->second.get_animation()->animation_finished())) {
|
||||
const double pos = animation_time < missile_animation.get_first_frame_time()?1.0:
|
||||
@ -270,19 +285,17 @@ bool unit_attack_ranged(display& disp, unit_map& units,
|
||||
disp.invalidate(a);
|
||||
if(leader_loc.valid()) disp.invalidate(leader_loc);
|
||||
halo::remove(missile_halo);
|
||||
halo::remove(missile_frame_halo);
|
||||
missile_halo = 0;
|
||||
missile_frame_halo = 0;
|
||||
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;
|
||||
std::string missile_image= missile_frame.image;
|
||||
const int d = disp.hex_size() / 2;
|
||||
if(dir == unit_animation::VERTICAL) {
|
||||
missile_image = &missile_frame.image;
|
||||
missile_image = missile_frame.image;
|
||||
} else {
|
||||
missile_image = &missile_frame.image_diagonal;
|
||||
}
|
||||
surface img(image::get_image(image::locator(*missile_image)));
|
||||
|
||||
if(hflip) {
|
||||
img.assign(image::reverse_image(img));
|
||||
missile_image = missile_frame.image_diagonal;
|
||||
}
|
||||
if(!missile_frame.halo.empty()) {
|
||||
int time = missile_frame.begin_time;
|
||||
@ -295,20 +308,15 @@ bool unit_attack_ranged(display& disp, unit_map& units,
|
||||
if(sub_halo >= missile_frame.halo.size()) sub_halo = missile_frame.halo.size() -1;
|
||||
|
||||
|
||||
if(hflip) {
|
||||
const int d = disp.hex_size() / 2;
|
||||
missile_halo = halo::add(posx+d-missile_frame.halo_x,
|
||||
posy+d+missile_frame.halo_y,
|
||||
missile_frame.halo[sub_halo].first);
|
||||
} else {
|
||||
const int d = disp.hex_size() / 2;
|
||||
missile_halo = halo::add(posx+d+missile_frame.halo_x,
|
||||
posy+d+missile_frame.halo_y,
|
||||
missile_frame.halo[sub_halo].first,
|
||||
halo::REVERSE);
|
||||
}
|
||||
orientation);
|
||||
}
|
||||
disp.draw_unit(posx, posy , img,vflip);
|
||||
missile_frame_halo = halo::add(posx+d,
|
||||
posy+d,
|
||||
missile_image,
|
||||
orientation);
|
||||
|
||||
}
|
||||
if(damage > 0 && !hide && animation_time > 0 && !sound_played) {
|
||||
@ -323,6 +331,8 @@ bool unit_attack_ranged(display& disp, unit_map& units,
|
||||
}
|
||||
halo::remove(missile_halo);
|
||||
missile_halo = 0;
|
||||
halo::remove(missile_frame_halo);
|
||||
missile_frame_halo = 0;
|
||||
if(def->second.take_hit(damage)) {
|
||||
dead = true;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user