Skip to content

Commit

Permalink
remove support for legacy-style unit abilities descriptions
Browse files Browse the repository at this point in the history
Conflicts:
	src/unit_types.cpp
	src/unit_types.hpp
  • Loading branch information
cbeck88 committed Apr 8, 2015
1 parent 03e2f3f commit c3d5732
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 57 deletions.
8 changes: 4 additions & 4 deletions src/unit_abilities.cpp
Expand Up @@ -264,7 +264,7 @@ std::vector<boost::tuple<t_string,t_string,t_string> > 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);
}
Expand All @@ -282,7 +282,7 @@ std::vector<boost::tuple<t_string,t_string,t_string> > 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);
}
}
Expand Down Expand Up @@ -592,15 +592,15 @@ std::vector<std::pair<t_string, t_string> > 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);
}
} else {
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);
}
}
Expand Down
49 changes: 2 additions & 47 deletions src/unit_types.cpp
Expand Up @@ -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() );
}
}
}
Expand All @@ -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() );
}
}
}
Expand Down Expand Up @@ -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 "<name>:\n<description>" to
* the current style of simply "<description>".
*/
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;
}
}

6 changes: 0 additions & 6 deletions src/unit_types.hpp
Expand Up @@ -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();
Expand All @@ -355,5 +350,4 @@ struct unit_experience_accelerator {
int old_value_;
};


#endif

0 comments on commit c3d5732

Please sign in to comment.