Apply patch #1081
This commit is contained in:
parent
f47ed28793
commit
ac3df3bd02
4 changed files with 33 additions and 8 deletions
|
@ -12,3 +12,13 @@ The release team should empty this file after each release.
|
|||
|
||||
***
|
||||
|
||||
The advanceto key in [unit_type] was changed to advances_to, as internally it
|
||||
is immediately renamed to advances_to and used that way in both unit.cpp and
|
||||
unit_types.cpp, along with being the key that is actually used in [unit],
|
||||
thus being what *should* be edited in stored units.
|
||||
|
||||
The advanceto key is now deprecated and will be removed in 1.5.6,
|
||||
wmllint can make the required changes.
|
||||
|
||||
***
|
||||
|
||||
|
|
|
@ -30,6 +30,8 @@ Version 1.5.3+svn:
|
|||
* fix bug where max_experience of stored units was not the true max when
|
||||
playing with under 100% exp. settings
|
||||
* prevent some negative/nonsense values in direct WML unit modifications
|
||||
* Renamed the advanceto key in [unit_type] to advances_to in order to be
|
||||
consistent with its own and [unit]'s internals.
|
||||
* Miscellaneous and bug fixes:
|
||||
* Changed side_drop handling not to automaticaly assign AI for side if
|
||||
leader is dead (bug #12186)
|
||||
|
|
|
@ -2179,6 +2179,7 @@ if __name__ == '__main__':
|
|||
# In unit type definitions
|
||||
if under("unit_type") or under("female") or under("unit"):
|
||||
line = line.replace("unit_description=", "description=")
|
||||
line = line.replace("advanceto=", "advances_to=")
|
||||
# Inside themes
|
||||
if within("theme"):
|
||||
line = line.replace("[unit_description]", "[unit_name]")
|
||||
|
|
|
@ -898,9 +898,16 @@ void unit_type::build_created(const config& cfg, const movement_type_map& mv_typ
|
|||
}
|
||||
|
||||
const std::string& advance_to_val = cfg["advanceto"];
|
||||
if(advance_to_val != "null" && advance_to_val != "")
|
||||
if(advance_to_val != "null" && advance_to_val != "") {
|
||||
advances_to_ = utils::split(advance_to_val);
|
||||
DBG_UT << "unit_type '" << id_ << "' advances to : " << advance_to_val << "\n";
|
||||
lg::wml_error << "Usage of 'advanceto' is deprecated; support for this will be removed in 1.5.6. (use 'advances_to' instead)\n";
|
||||
}
|
||||
// This overwrites the previous if both exist, should preserve backwards compatibility
|
||||
const std::string& advances_to_val = cfg["advances_to"];
|
||||
if(advances_to_val != "null" && advances_to_val != "")
|
||||
advances_to_ = utils::split(advances_to_val);
|
||||
DBG_UT << "unit_type '" << id_ << "' advanceto : " << advance_to_val << "\n";
|
||||
DBG_UT << "unit_type '" << id_ << "' advances to : " << advances_to_val << "\n";
|
||||
|
||||
build_status_ = CREATED;
|
||||
}
|
||||
|
@ -1313,19 +1320,24 @@ unit_type& unit_type_data::unit_type_map_wrapper::build_unit_type(const std::str
|
|||
void unit_type_data::unit_type_map_wrapper::add_advancefrom(const config& unit_cfg) const
|
||||
{
|
||||
//find the units this one can advance into and add advancefrom information for them
|
||||
std::vector<std::string> advance_to = utils::split(unit_cfg["advanceto"]);
|
||||
if ( (advance_to.size() > 0) && (advance_to[0] != "null") ){
|
||||
std::vector<std::string> advances_to = utils::split(unit_cfg["advanceto"]);
|
||||
// Storing advances_to here to check if it contains anything,
|
||||
// if it does, overwrite the deprecated key.
|
||||
const std::string& advances_to_val = unit_cfg["advances_to"];
|
||||
if(advances_to_val != "null" && advances_to_val != "")
|
||||
advances_to = utils::split(advances_to_val);
|
||||
if ( (advances_to.size() > 0) && (advances_to[0] != "null") ){
|
||||
int count = 0;
|
||||
for (std::vector<std::string>::const_iterator i_adv = advance_to.begin(); i_adv != advance_to.end(); i_adv++){
|
||||
for (std::vector<std::string>::const_iterator i_adv = advances_to.begin(); i_adv != advances_to.end(); i_adv++){
|
||||
count++;
|
||||
DBG_UT << "Unit: " << unit_cfg["id"] << ", AdvanceTo " << count << ": " << *i_adv << "\n";
|
||||
unit_type_map::iterator itor_advanceto = types_.find(*i_adv);
|
||||
if(itor_advanceto == types_.end()) {
|
||||
unit_type_map::iterator itor_advances_to = types_.find(*i_adv);
|
||||
if(itor_advances_to == types_.end()) {
|
||||
// if we can't add the advancefrom information yet, we should
|
||||
// just remember it for later (to prevent infinite recursion)
|
||||
future_advancefroms[*i_adv].insert(unit_cfg["id"]);
|
||||
} else {
|
||||
itor_advanceto->second.add_advancesfrom(unit_cfg["id"]);
|
||||
itor_advances_to->second.add_advancesfrom(unit_cfg["id"]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue