From c3d5732c11077e3ff6de30505b16275a9035c006 Mon Sep 17 00:00:00 2001 From: Chris Beck Date: Wed, 8 Apr 2015 16:59:56 -0400 Subject: [PATCH] remove support for legacy-style unit abilities descriptions Conflicts: src/unit_types.cpp src/unit_types.hpp --- src/unit_abilities.cpp | 8 +++---- src/unit_types.cpp | 49 ++---------------------------------------- src/unit_types.hpp | 6 ------ 3 files changed, 6 insertions(+), 57 deletions(-) diff --git a/src/unit_abilities.cpp b/src/unit_abilities.cpp index 2216b24abe54..71053a09d8fa 100644 --- a/src/unit_abilities.cpp +++ b/src/unit_abilities.cpp @@ -264,7 +264,7 @@ std::vector > unit::ability_tooltips(st res.push_back(boost::make_tuple( ab.cfg["name"].t_str(), name, - legacy::ability_description(ab.cfg["description"].t_str()) )); + ab.cfg["description"].t_str() )); if ( active_list ) active_list->push_back(true); } @@ -282,7 +282,7 @@ std::vector > unit::ability_tooltips(st res.push_back(boost::make_tuple( default_value(ab.cfg, "name_inactive", "name").t_str(), name, - legacy::ability_description(default_value(ab.cfg, "description_inactive", "description").t_str()) )); + default_value(ab.cfg, "description_inactive", "description").t_str() )); active_list->push_back(false); } } @@ -592,7 +592,7 @@ std::vector > attack_type::special_tooltips( if ( !active_list || special_active(sp.cfg, AFFECT_EITHER) ) { const t_string &name = sp.cfg["name"]; if (!name.empty()) { - res.push_back(std::make_pair(name, legacy::ability_description(sp.cfg["description"].t_str()) )); + res.push_back(std::make_pair(name, sp.cfg["description"].t_str() )); if ( active_list ) active_list->push_back(true); } @@ -600,7 +600,7 @@ std::vector > attack_type::special_tooltips( t_string const &name = default_value(sp.cfg, "name_inactive", "name").t_str(); if (!name.empty()) { res.push_back(std::make_pair( - name, legacy::ability_description(default_value(sp.cfg, "description_inactive", "description").t_str()) )); + name, default_value(sp.cfg, "description_inactive", "description").t_str() )); active_list->push_back(false); } } diff --git a/src/unit_types.cpp b/src/unit_types.cpp index afdd46f31abb..8548d24d0010 100644 --- a/src/unit_types.cpp +++ b/src/unit_types.cpp @@ -301,7 +301,7 @@ void unit_type::build_help_index(const movement_type_map &mv_types, const config::attribute_value &name = ab.cfg["name"]; if (!name.empty()) { abilities_.push_back(name.t_str()); - ability_tooltips_.push_back( legacy::ability_description(ab.cfg["description"].t_str()) ); + ability_tooltips_.push_back( ab.cfg["description"].t_str() ); } } } @@ -318,7 +318,7 @@ void unit_type::build_help_index(const movement_type_map &mv_types, const config::attribute_value &name = ab.cfg["name"]; if (!name.empty()) { adv_abilities_.push_back(name.t_str()); - adv_ability_tooltips_.push_back( legacy::ability_description(ab.cfg["description"].t_str()) ); + adv_ability_tooltips_.push_back( ab.cfg["description"].t_str() ); } } } @@ -1240,48 +1240,3 @@ void adjust_profile(std::string &small, std::string &big, std::string const &def big = small; } } - - -namespace legacy { - /** - * Strips the name of an ability/special from its description. - * This adapts the pre-1.11.1 style of ":\n" to - * the current style of simply "". - */ - t_string ability_description(const t_string & description) - { - /// @deprecated This function is legacy support. Remove it post-1.12. - - // We identify the legacy format by a colon ending the first line. - std::string desc_str = description.str(); - const size_t colon_pos = desc_str.find(':'); - const size_t first_end_line = desc_str.find_first_of("\r\n"); - const size_t space_pos = desc_str.find(' '); - if ( colon_pos != std::string::npos && colon_pos + 1 == first_end_line && !(space_pos != std::string::npos && space_pos < colon_pos)) - { - // Try to avoid spamming the deprecation message. - static std::set< std::string > reported; - const std::string name = desc_str.substr(0, colon_pos); - if ( reported.count(name) == 0 ) - { - reported.insert(name); - // Inform the player. - lg::wml_error << '"' << name << '"' - << " follows a deprecated format for its description," - << " using its name as the first line. Support" - << " for that format will be removed in 1.12.\n"; - } - - // Strip the name from the description. - // This is sort of bad in that it messes with retranslating, if the - // player changes the game's language while playing. However, this - // is temporary, so I think simplicity trumps in this case. - desc_str.erase(0, colon_pos + 2); - return t_string(desc_str); - } - - // Not legacy, so this function just falls through. - return description; - } -} - diff --git a/src/unit_types.hpp b/src/unit_types.hpp index 4c7143cd97e9..1a55165c46ac 100644 --- a/src/unit_types.hpp +++ b/src/unit_types.hpp @@ -342,11 +342,6 @@ extern unit_type_data unit_types; void adjust_profile(std::string &small, std::string &big, std::string const &def); -namespace legacy { - /// Strips the name of an ability/special from its description. - t_string ability_description(const t_string & description); -} - struct unit_experience_accelerator { unit_experience_accelerator(int modifier); ~unit_experience_accelerator(); @@ -355,5 +350,4 @@ struct unit_experience_accelerator { int old_value_; }; - #endif