remove code planned for removal post 1.3.10
This commit is contained in:
parent
9ff94ab766
commit
f13eacc6e7
6 changed files with 17 additions and 86 deletions
|
@ -1338,7 +1338,7 @@ bool mouse_handler::attack_enemy_(unit_map::iterator attacker, unit_map::iterato
|
|||
const battle_context::unit_stats& att = bc_vector[i].get_attacker_stats();
|
||||
const battle_context::unit_stats& def = bc_vector[i].get_defender_stats();
|
||||
config tmp_config;
|
||||
attack_type no_weapon(tmp_config, "fake_attack", false);
|
||||
attack_type no_weapon(tmp_config);
|
||||
const attack_type& attw = attack_type(*att.weapon);
|
||||
const attack_type& defw = attack_type(def.weapon ? *def.weapon : no_weapon);
|
||||
|
||||
|
|
29
src/unit.cpp
29
src/unit.cpp
|
@ -508,7 +508,7 @@ void unit::advance_to(const unit_type* t, bool use_traits)
|
|||
max_hit_points_ = t->hitpoints();
|
||||
max_movement_ = t->movement();
|
||||
emit_zoc_ = t->level();
|
||||
attacks_ = t->attacks(true);
|
||||
attacks_ = t->attacks();
|
||||
unit_value_ = t->cost();
|
||||
flying_ = t->movement_type().is_flying();
|
||||
|
||||
|
@ -1248,29 +1248,14 @@ void unit::read(const config& cfg, bool use_traits)
|
|||
t_atks.merge_with(u_atks);
|
||||
for(range = t_atks.child_range("attack");
|
||||
range.first != range.second; ++range.first) {
|
||||
attacks_.push_back(attack_type(**range.first,id()));
|
||||
}
|
||||
std::vector<attack_type>::iterator at;
|
||||
for(at = attacks_.begin(); at != attacks_.end(); ++at) {
|
||||
at->get_cfg().clear_children("animation");
|
||||
}
|
||||
for(at = attacks_b_.begin(); at != attacks_b_.end(); ++at) {
|
||||
at->get_cfg().clear_children("animation");
|
||||
attacks_.push_back(attack_type(**range.first));
|
||||
}
|
||||
} else {
|
||||
for(config::const_child_itors range = cfg.child_range("attack");
|
||||
range.first != range.second; ++range.first) {
|
||||
attacks_.push_back(attack_type(**range.first,id()));
|
||||
attacks_.push_back(attack_type(**range.first));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
std::vector<attack_type>::iterator at;
|
||||
for(at = attacks_.begin(); at != attacks_.end(); ++at) {
|
||||
at->get_cfg().clear_children("animation");
|
||||
}
|
||||
for(at = attacks_b_.begin(); at != attacks_b_.end(); ++at) {
|
||||
at->get_cfg().clear_children("animation");
|
||||
}
|
||||
}
|
||||
cfg_.clear_children("attack");
|
||||
const config* status_flags = cfg.child("status");
|
||||
|
@ -1333,7 +1318,7 @@ void unit::read(const config& cfg, bool use_traits)
|
|||
animations_ = ut->animations_;
|
||||
cfg_.clear_children("animation");
|
||||
} else {
|
||||
unit_animation::initialize_anims(animations_,cfg_,type()->attacks(true));
|
||||
unit_animation::initialize_anims(animations_,cfg_);
|
||||
}
|
||||
} else {
|
||||
// Remove animations from private cfg, since they're not needed there now
|
||||
|
@ -2387,9 +2372,7 @@ void unit::add_modification(const std::string& type, const config& mod, bool no_
|
|||
if(!description.empty()) cfg_["unit_description"] = description;
|
||||
//help::unit_topic_generator(*this, (**i.first)["help_topic"]);
|
||||
} else if(apply_to == "new_attack") {
|
||||
attacks_.push_back(attack_type(**i.first,id()));
|
||||
// TODO backward compat code, to be removed in 1.3.10, support for old attack format ([animation] in [attack] )
|
||||
animations_.insert(animations_.end(),attacks_.back().animation_.begin(),attacks_.back().animation_.end());
|
||||
attacks_.push_back(attack_type(**i.first));
|
||||
} else if(apply_to == "remove_attacks") {
|
||||
int num_attacks= attacks_.size();
|
||||
for(std::vector<attack_type>::iterator a = attacks_.begin(); a != attacks_.end(); ++a) {
|
||||
|
@ -2605,7 +2588,7 @@ void unit::add_modification(const std::string& type, const config& mod, bool no_
|
|||
game_config::add_color_info(**i.first);
|
||||
LOG_UT << "applying image_mod \n";
|
||||
} else if (apply_to == "new_animation") {
|
||||
unit_animation::initialize_anims(animations_,**i.first,std::vector<attack_type>());
|
||||
unit_animation::initialize_anims(animations_,**i.first);
|
||||
}
|
||||
} // end while
|
||||
} else { // for times = per level & level = 0 we still need to rebuild the descriptions
|
||||
|
|
|
@ -259,22 +259,7 @@ int unit_animation::matches(const game_display &disp,const gamemap::location& lo
|
|||
}
|
||||
|
||||
|
||||
void unit_animation::back_compat_add_name(const std::string name,const std::string range)
|
||||
{
|
||||
config tmp;
|
||||
event_.push_back("attack");
|
||||
if(!name.empty()) {
|
||||
tmp["name"] = name;
|
||||
primary_attack_filter_.push_back(tmp);
|
||||
}
|
||||
if(!range.empty()) {
|
||||
tmp["range"] = range;
|
||||
primary_attack_filter_.push_back(tmp);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void unit_animation::initialize_anims( std::vector<unit_animation> & animations, const config & cfg, std::vector<attack_type> tmp_attacks)
|
||||
void unit_animation::initialize_anims( std::vector<unit_animation> & animations, const config & cfg)
|
||||
{
|
||||
config expanded_cfg;
|
||||
config::child_list::const_iterator anim_itor;
|
||||
|
@ -428,22 +413,7 @@ void unit_animation::initialize_anims( std::vector<unit_animation> & animations,
|
|||
//lg::wml_error<<"attack animations are deprecate, support will be removed in 1.3.11 (in unit "<<cfg["name"]<<")\n";
|
||||
//lg::wml_error<<"please put it with an [animation] tag and apply_to=attack flag\n";
|
||||
}
|
||||
// get old animation format, to be removed circum 1.3.10
|
||||
for(std::vector<attack_type>::iterator attacks_itor = tmp_attacks.begin() ; attacks_itor!= tmp_attacks.end();attacks_itor++) {
|
||||
animations.insert(animations.end(),attacks_itor->animation_.begin(),attacks_itor->animation_.end());
|
||||
// this has been detected elsewhere, no deprecation message needed here
|
||||
}
|
||||
animations.push_back(unit_animation(-150,unit_frame(image::locator(cfg["image"]),300),"attack",unit_animation::DEFAULT_ANIM));
|
||||
if(!cfg["image_short"].empty()) {
|
||||
animations.push_back(unit_animation(-150,unit_frame(image::locator(cfg["image_short"]),300),"attack",unit_animation::DEFAULT_ANIM));
|
||||
animations.back().back_compat_add_name("","melee");
|
||||
lg::wml_error<<"image_short is deprecated, support will be removed in 1.3.10 (in unit "<<cfg["name"]<<")\n";
|
||||
}
|
||||
if(!cfg["image_long"].empty()) {
|
||||
animations.push_back(unit_animation(-150,unit_frame(image::locator(cfg["image_long"]),300),"attack",unit_animation::DEFAULT_ANIM));
|
||||
animations.back().back_compat_add_name("","ranged");
|
||||
lg::wml_error<<"image_long is deprecated, support will be removed in 1.3.10 (in unit "<<cfg["name"]<<")\n";
|
||||
}
|
||||
// always have an attack animation
|
||||
expanded_cfg = unit_animation::prepare_animation(cfg,"death");
|
||||
const config::child_list& deaths = expanded_cfg.get_children("death");
|
||||
|
|
|
@ -34,7 +34,7 @@ class unit_animation
|
|||
public:
|
||||
typedef enum { MATCH_FAIL=-2 , DEFAULT_ANIM=-1};
|
||||
typedef enum { HIT, MISS, KILL, INVALID} hit_type;
|
||||
static void initialize_anims( std::vector<unit_animation> & animations, const config & cfg, std::vector<attack_type> tmp_attacks);
|
||||
static void initialize_anims( std::vector<unit_animation> & animations, const config & cfg);
|
||||
|
||||
int matches(const game_display &disp,const gamemap::location& loc,const unit* my_unit,const std::string & event="",const int value=0,hit_type hit=INVALID,const attack_type* attack=NULL,const attack_type* second_attack = NULL, int swing_num =0) const;
|
||||
|
||||
|
@ -53,11 +53,6 @@ class unit_animation
|
|||
const int get_current_frame_begin_time() const{ return unit_anim_.get_current_frame_begin_time() ; };
|
||||
void redraw();
|
||||
|
||||
// only to support all [attack_anim] format, to remove at 1.3.10 time
|
||||
void back_compat_add_name(const std::string name="",const std::string range ="");
|
||||
// to be privatized post 1.3.10
|
||||
static config prepare_animation(const config &cfg,const std::string animation_tag);
|
||||
explicit unit_animation(const config& cfg,const std::string frame_string ="");
|
||||
friend class unit;
|
||||
protected:
|
||||
// reserved to class unit, for the special case of redrawing the unit base frame
|
||||
|
@ -72,6 +67,8 @@ class unit_animation
|
|||
fixed_t highlight_ratio(const float default_val = 1.0) const{ return unit_anim_.highlight_ratio(default_val); };
|
||||
double offset(double default_val =0.0) const{ return unit_anim_.offset(default_val); };
|
||||
private:
|
||||
static config prepare_animation(const config &cfg,const std::string animation_tag);
|
||||
explicit unit_animation(const config& cfg,const std::string frame_string ="");
|
||||
unit_animation(){};
|
||||
explicit unit_animation(int start_time,const unit_frame &frame,const std::string& even="",const int variation=0);
|
||||
class crude_animation:public animated<unit_frame>
|
||||
|
|
|
@ -34,28 +34,9 @@
|
|||
|
||||
|
||||
|
||||
attack_type::attack_type(const config& cfg,const std::string& id, bool with_animations)
|
||||
attack_type::attack_type(const config& cfg)
|
||||
{
|
||||
cfg_ = cfg;
|
||||
if (with_animations) {
|
||||
const config expanded_cfg = unit_animation::prepare_animation(cfg,"animation");
|
||||
// TODO: prepare animation should be privatized once the code is removed
|
||||
const config::child_list& animations = expanded_cfg.get_children("animation");
|
||||
for(config::child_list::const_iterator d = animations.begin(); d != animations.end(); ++d) {
|
||||
lg::wml_error<<"attack animation directly in attack is deprecated, support will be removed in 1.3.10 (in unit "<<id<<")\n";
|
||||
lg::wml_error<<"please put it with an [attack_anim] tag in the [unit] and filter on the attack name\n";
|
||||
animation_.push_back(unit_animation(**d));
|
||||
animation_.back().back_compat_add_name(cfg["name"]);
|
||||
}
|
||||
if(cfg.child("frame") || cfg.child("missile_frame") || cfg.child("sound")) {
|
||||
lg::wml_error<<"using frame directly in attack is VERY deprecated, support will be removed in 1.3.10 (in unit "<<id<<")\n";
|
||||
if(animation_.empty()) {
|
||||
animation_.push_back(unit_animation(cfg));
|
||||
animation_.back().back_compat_add_name(cfg["name"]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
id_ = cfg["name"];
|
||||
description_ = cfg["description"];
|
||||
if (description_.empty())
|
||||
|
@ -627,7 +608,7 @@ unit_type::unit_type(const config& cfg, const movement_type_map& mv_types,
|
|||
|
||||
experience_needed_=lexical_cast_default<int>(cfg_["experience"],500);
|
||||
|
||||
unit_animation::initialize_anims(animations_,cfg,attacks(true));
|
||||
unit_animation::initialize_anims(animations_,cfg);
|
||||
flag_rgb_ = cfg["flag_rgb"];
|
||||
game_config::add_color_info(cfg);
|
||||
// Deprecation messages, only seen when unit is parsed for the first time.
|
||||
|
@ -712,12 +693,12 @@ const t_string& unit_type::unit_description() const
|
|||
}
|
||||
|
||||
|
||||
std::vector<attack_type> unit_type::attacks(bool with_animations) const
|
||||
std::vector<attack_type> unit_type::attacks() const
|
||||
{
|
||||
std::vector<attack_type> res;
|
||||
for(config::const_child_itors range = cfg_.child_range("attack");
|
||||
range.first != range.second; ++range.first) {
|
||||
res.push_back(attack_type(**range.first,id(), with_animations));
|
||||
res.push_back(attack_type(**range.first));
|
||||
}
|
||||
|
||||
return res;
|
||||
|
|
|
@ -37,7 +37,7 @@ class attack_type
|
|||
{
|
||||
public:
|
||||
|
||||
attack_type(const config& cfg, const std::string& id, bool with_animations=true);
|
||||
attack_type(const config& cfg);
|
||||
const t_string& name() const { return description_; }
|
||||
const std::string& id() const { return id_; }
|
||||
const std::string& type() const { return type_; }
|
||||
|
@ -184,7 +184,7 @@ public:
|
|||
const std::string& flag_rgb() const { return flag_rgb_; }
|
||||
|
||||
int hitpoints() const { return atoi(cfg_["hitpoints"].c_str()); }
|
||||
std::vector<attack_type> attacks(bool with_animations = false) const;
|
||||
std::vector<attack_type> attacks() const;
|
||||
const unit_movement_type& movement_type() const { return movementType_; }
|
||||
|
||||
int experience_needed(bool with_acceleration=true) const;
|
||||
|
|
Loading…
Add table
Reference in a new issue