Author: sapient
Date: Tue Jul 8 06:51:06 2008
New Revision: 27835
URL: http://svn.gna.org/viewcvs/wesnoth?rev=27835&view=rev
Log:
add count= to [have_location] as well
Modified:
trunk/changelog
trunk/src/game_events.cpp
Modified: trunk/changelog
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/changelog?rev=27835&r1=27834&r2=27835&view=diff
==============================================================================
--- trunk/changelog (original)
+++ trunk/changelog Tue Jul 8 06:51:06 2008
@@ -23,7 +23,7 @@
* WML engine:
* When examining stored units, now the attacks, max_hitpoints, max_moves,
and max_experience are the "real" values and can also be modified.
- * new attribute count= for the [have_unit] conditional
+ * new attribute count= for [have_unit] and [have_location] conditionals
* max_attacks in [unit] now also works for values bigger than 1
* the "zoc" key works for [unit_type] too, and for [unit] accepts other
boolean values than 1 and 0 (bug #11889).
Modified: trunk/src/game_events.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/game_events.cpp?rev=27835&r1=27834&r2=27835&view=diff
==============================================================================
--- trunk/src/game_events.cpp (original)
+++ trunk/src/game_events.cpp Tue Jul 8 06:51:06 2008
@@ -219,6 +219,7 @@
static bool internal_conditional_passed(const unit_map* units,
const vconfig cond, bool& backwards_compat)
{
+ static std::vector<std::pair<int,int> > default_counts =
utils::parse_ranges("1-99999");
// If the if statement requires we have a certain unit,
// then check for that.
@@ -229,7 +230,6 @@
if(units == NULL)
return false;
- static std::vector<std::pair<int,int> > default_counts
= utils::parse_ranges("1-999");
std::vector<std::pair<int,int> > counts =
(*u).has_attribute("count")
? utils::parse_ranges((*u)["count"]) :
default_counts;
std::vector<std::pair<int,int> >::const_iterator count,
count_end = counts.end();
@@ -264,7 +264,17 @@
std::set<gamemap::location> res;
assert(game_map != NULL && units != NULL && status_ptr
!= NULL);
terrain_filter(*v, *game_map, *status_ptr,
*units).get_locations(res);
- if(res.empty()) {
+
+ std::vector<std::pair<int,int> > counts =
(*v).has_attribute("count")
+ ? utils::parse_ranges((*v)["count"]) :
default_counts;
+ std::vector<std::pair<int,int> >::const_iterator count,
count_end = counts.end();
+ bool count_matches = false;
+ for (count = counts.begin(); count != count_end &&
!count_matches; ++count) {
+ if(count->first <= res.size() && res.size() <=
count->second) {
+ count_matches = true;
+ }
+ }
+ if(!count_matches) {
return false;
}
}
_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits