remove the last bits of game logic from animations,

animations can now be skiped entirely during fast replay
This commit is contained in:
Jérémy Rosen 2006-10-15 19:43:55 +00:00
parent 8853743de2
commit f5ebed8a80
3 changed files with 25 additions and 44 deletions

View file

@ -835,11 +835,15 @@ attack::attack(display& gui, const gamemap& map,
}
}
bool dies = unit_display::unit_attack(gui_,units_,attacker_,defender_,
damage_defender_takes,
*a_stats_->weapon,d_stats_->weapon,
update_display_,abs_n_attack_);
unit_display::unit_attack(gui_,units_,attacker_,defender_,
damage_defender_takes,
*a_stats_->weapon,d_stats_->weapon,
update_display_,abs_n_attack_);
bool dies = d_->second.take_hit(damage_defender_takes);
LOG_NG << "defender took " << damage_defender_takes << (dies ? " and died" : "") << "\n";
if(dies) {
unit_display::unit_die(gui_,defender_,d_->second,a_stats_->weapon,d_stats_->weapon);
}
attack_stats.attack_result(hits ? (dies ? statistics::attack_context::KILLS : statistics::attack_context::HITS)
: statistics::attack_context::MISSES, attacker_damage_);
@ -1038,11 +1042,15 @@ attack::attack(display& gui, const gamemap& map,
}
}
bool dies = unit_display::unit_attack(gui_,units_,defender_,attacker_,
damage_attacker_takes,
*d_stats_->weapon,a_stats_->weapon,
update_display_,abs_n_defend_);
unit_display::unit_attack(gui_,units_,defender_,attacker_,
damage_attacker_takes,
*d_stats_->weapon,a_stats_->weapon,
update_display_,abs_n_defend_);
bool dies = a_->second.take_hit(damage_attacker_takes);
LOG_NG << "attacker took " << damage_attacker_takes << (dies ? " and died" : "") << "\n";
if(dies) {
unit_display::unit_die(gui_,defender_,d_->second,a_stats_->weapon,d_stats_->weapon);
}
if(ran_results == NULL) {
config cfg;
cfg["hits"] = (hits ? "yes" : "no");

View file

@ -186,14 +186,11 @@ void unit_die(display& disp,const gamemap::location& loc, unit& u, const attack_
events::pump();
disp.delay(10);
}
u.set_standing(disp,loc);
disp.update_display();
events::pump();
}
namespace {
bool unit_attack_ranged(display& disp, unit_map& units,
void unit_attack_ranged(display& disp, unit_map& units,
const gamemap::location& a, const gamemap::location& b,
int damage, const attack_type& attack, const attack_type* secondary_attack,bool update_display, int swing)
@ -223,7 +220,6 @@ bool unit_attack_ranged(display& disp, unit_map& units,
gamemap::location update_tiles[6];
get_adjacent_tiles(b,update_tiles);
bool dead = false;
@ -363,26 +359,16 @@ bool unit_attack_ranged(display& disp, unit_map& units,
missile_halo = 0;
halo::remove(missile_frame_halo);
missile_frame_halo = 0;
if(def->second.take_hit(damage)) {
dead = true;
}
if(dead) {
unit_display::unit_die(disp,def->first,def->second,&attack);
if(leader_loc.valid()) leader->second.set_standing(disp,leader_loc);
att->second.set_standing(disp,a);
}
disp.update_display();
events::pump();
return dead;
if(leader_loc.valid()) leader->second.set_standing(disp,leader_loc);
att->second.set_standing(disp,a);
def->second.set_standing(disp,b);
}
} //end anon namespace
bool unit_attack(display& disp, unit_map& units,
void unit_attack(display& disp, unit_map& units,
const gamemap::location& a, const gamemap::location& b, int damage,
const attack_type& attack, const attack_type* secondary_attack,
bool update_display, int swing)
@ -437,11 +423,6 @@ bool unit_attack(display& disp, unit_map& units,
gamemap::location update_tiles[6];
get_adjacent_tiles(b,update_tiles);
bool dead = false;
attacker.restart_animation(disp,start_time);
defender.restart_animation(disp,start_time);
@ -449,9 +430,6 @@ bool unit_attack(display& disp, unit_map& units,
int animation_time = start_time;
bool played_center = false;
if(def->second.take_hit(damage)) {
dead = true;
}
while(!hide && (
attacker.state() != unit::STATE_STANDING ||
defender.state() != unit::STATE_STANDING ||
@ -496,16 +474,11 @@ bool unit_attack(display& disp, unit_map& units,
animation_time = attacker.get_animation()->get_animation_time();
}
if(leader_loc.valid()) leader->second.set_standing(disp,leader_loc);
att->second.set_standing(disp,a);
def->second.set_standing(disp,b);
if(dead) {
unit_display::unit_die(disp,def->first,def->second,&attack);
if(leader_loc.valid()) leader->second.set_standing(disp,leader_loc);
att->second.set_standing(disp,a);
}
disp.update_display();
events::pump();
return dead;
}
} // end unit display namespace

View file

@ -37,7 +37,7 @@ void unit_die(display& disp, const gamemap::location& loc, unit& u, const attack
///displayed if the unit dies.
///true is returned if the defending unit is dead, and should be removed from the
///playing field.
bool unit_attack(display& disp, unit_map& units,
void unit_attack(display& disp, unit_map& units,
const gamemap::location& a, const gamemap::location& b, int damage,
const attack_type& attack, const attack_type* secondary_attack,
bool update_display, int swing);