diff --git a/src/mouse_events.cpp b/src/mouse_events.cpp index bd2b9224a0e..d4e7489d6b2 100644 --- a/src/mouse_events.cpp +++ b/src/mouse_events.cpp @@ -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); diff --git a/src/unit.cpp b/src/unit.cpp index 2c59fc1e002..2899cf17f28 100644 --- a/src/unit.cpp +++ b/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::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::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::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()); + unit_animation::initialize_anims(animations_,**i.first); } } // end while } else { // for times = per level & level = 0 we still need to rebuild the descriptions diff --git a/src/unit_animation.cpp b/src/unit_animation.cpp index 56f2fb883cf..aad5a6bd530 100644 --- a/src/unit_animation.cpp +++ b/src/unit_animation.cpp @@ -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 & animations, const config & cfg, std::vector tmp_attacks) +void unit_animation::initialize_anims( std::vector & 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 & animations, //lg::wml_error<<"attack animations are deprecate, support will be removed in 1.3.11 (in unit "<::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 "< & animations, const config & cfg, std::vector tmp_attacks); + static void initialize_anims( std::vector & 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 diff --git a/src/unit_types.cpp b/src/unit_types.cpp index b23f1d87652..8d0f934e7e8 100644 --- a/src/unit_types.cpp +++ b/src/unit_types.cpp @@ -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 "<(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 unit_type::attacks(bool with_animations) const +std::vector unit_type::attacks() const { std::vector 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; diff --git a/src/unit_types.hpp b/src/unit_types.hpp index 52a370eee62..ac9b21f31c8 100644 --- a/src/unit_types.hpp +++ b/src/unit_types.hpp @@ -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 attacks(bool with_animations = false) const; + std::vector attacks() const; const unit_movement_type& movement_type() const { return movementType_; } int experience_needed(bool with_acceleration=true) const;