Fixed a bug in some transitions...

...due to the fact that an empty string should match.
Added some consts to items which are const.
This commit is contained in:
Mark de Wever 2006-12-15 16:40:37 +00:00
parent 2e057bb986
commit f7f25037e8
2 changed files with 26 additions and 8 deletions

View File

@ -205,7 +205,7 @@ void terrain_builder::rebuild_all()
build_terrains();
}
bool terrain_builder::rule_valid(const building_rule &rule)
bool terrain_builder::rule_valid(const building_rule &rule) const
{
//if the rule has no constraints, it is invalid
if(rule.constraints.empty())
@ -637,7 +637,7 @@ void terrain_builder::add_rule(building_ruleset& rules, building_rule &rule)
}
void terrain_builder::add_rotated_rules(building_ruleset& rules, building_rule& tpl, const std::string &rotations)
void terrain_builder::add_rotated_rules(building_ruleset& rules, building_rule& tpl, const std::string &rotations)
{
if(rotations.empty()) {
// Adds the parsed built terrain to the list
@ -773,14 +773,21 @@ void terrain_builder::parse_config(const config &cfg)
}
bool terrain_builder::terrain_matches(t_translation::t_letter letter,
const t_translation::t_list& terrains)
const t_translation::t_list& terrains) const
{
// we return true on an empty list terrain_matches returns false on an empty list
return terrains.empty()? true : t_translation::terrain_matches(letter, terrains);
}
bool terrain_builder::terrain_matches(t_translation::t_letter letter,
const t_translation::t_match& terrain) const
{
// we return true on an empty list terrain_matches returns false on an empty list
return terrain.terrain.empty()? true : t_translation::terrain_matches(letter, terrain);
}
bool terrain_builder::rule_matches(const terrain_builder::building_rule &rule,
const gamemap::location &loc, int rule_index, bool check_loc)
const gamemap::location &loc, const int rule_index, const bool check_loc) const
{
if(rule.location_constraints.valid() && rule.location_constraints != loc) {
return false;
@ -798,7 +805,7 @@ bool terrain_builder::rule_matches(const terrain_builder::building_rule &rule,
return false;
}
if(!t_translation::terrain_matches(map_.get_terrain(tloc), cons->second.terrain_types_match)) {
if(!terrain_matches(map_.get_terrain(tloc), cons->second.terrain_types_match)) {
return false;
}
}

View File

@ -389,7 +389,7 @@ private:
*
* @return true if the rule is valid, false if it is not.
*/
bool rule_valid(const building_rule &rule);
bool rule_valid(const building_rule &rule) const;
/**
* Starts the animation on a rule.
@ -615,7 +615,18 @@ private:
*
* @return returns true if "letter" matches the list, false if it does not and empty list matches.
*/
bool terrain_matches(t_translation::t_letter letter, const t_translation::t_list &terrains);
bool terrain_matches(t_translation::t_letter letter, const t_translation::t_list &terrains) const;
/**
* Checks whether a terrain letter matches a given list of terrain letters
*
* @param letter The terrain to check
* @param terrain The terrain match structure which to check the terrain.
* See previous definition for more details.
*
* @return returns true if "letter" matches the list, false if it does not and empty list matches.
*/
bool terrain_matches(t_translation::t_letter letter, const t_translation::t_match &terrain) const;
/**
* Checks whether a rule matches a given location in the map.
@ -634,7 +645,7 @@ private:
* checked.
*/
bool rule_matches(const building_rule &rule, const gamemap::location &loc,
int rule_index, bool check_loc);
const int rule_index, const bool check_loc) const;
/**
* Applies a rule at a given location: applies the result of a matching