Match time_of_day AI aspect against the current ToD id, not its name

This allows ToD-dependent AI configuration in pretty much all cases to
actually work. It seems all mainline WML was coded expecting this aspect
to match the ids, not names, which is only logical since the name
attribute is a user-visible translatable string -- using this for
matching would result in code that only works for certain translations
or lack thereof.

This bug appears to have been first introduced by Crab_ in commit
f788542095 ("fixed parsing of [target]
tags..."), for version 1.7.4.
This commit is contained in:
Ignacio R. Morelle 2013-10-02 22:35:33 -03:00
parent 40d81d1e25
commit b7ad119de2
2 changed files with 4 additions and 1 deletions

View file

@ -27,6 +27,9 @@ Version 1.11.6+dev:
* New Recruitment CA located in src/ai/recruitment is now default CA
* Created new AI cfg "Strong AI (RCA)" with stronger recruitment
* Created new AI cfg "Old Recruitment CA" in ai/dev/ to use the old CA
* Fixed time_of_day aspect so it matches time-of-day ids, not names
(e.g. "Morning" vs "morning"), so most use cases of ToD-dependent AI
configuration work again (suspected version 1.7.4 regression).
* Campaigns:
* Legend of Wesmere:
* Removed now redundant MP code.

View file

@ -1302,7 +1302,7 @@ bool readonly_context_impl::is_active(const std::string &time_of_day, const std:
{
if(time_of_day.empty() == false) {
const std::vector<std::string>& times = utils::split(time_of_day);
if(std::count(times.begin(),times.end(),resources::tod_manager->get_time_of_day().name) == 0) {
if(std::count(times.begin(),times.end(),resources::tod_manager->get_time_of_day().id) == 0) {
return false;
}
}