Author: alink
Date: Sat May 16 19:15:00 2009
New Revision: 35655
URL: http://svn.gna.org/viewcvs/wesnoth?rev=35655&view=rev
Log:
Add a new function propagate_invalidation()
Not used yet but meant to replace the slower set_intersection in
unit_animation.cpp
Modified:
trunk/src/display.cpp
trunk/src/display.hpp
Modified: trunk/src/display.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/display.cpp?rev=35655&r1=35654&r2=35655&view=diff
==============================================================================
--- trunk/src/display.cpp (original)
+++ trunk/src/display.cpp Sat May 16 19:15:00 2009
@@ -2329,6 +2329,32 @@
return ret;
}
+bool display::propagate_invalidation(const std::set<map_location>& locs)
+{
+ if(invalidateAll_)
+ return false;
+
+ bool has_inval = false;
+ std::set<map_location>::const_iterator i = locs.begin();
+ for(; i != locs.end() && !has_inval; ++i) {
+ has_inval = invalidated_.count(*i);
+ }
+
+ // if no invalidation or one but nothing to propagate, return false
+ if (!has_inval || locs.size()<=1)
+ return false;
+
+ // propagate invalidation (but skip the already invalidated hex)
+ bool res = false;
+ std::set<map_location>::const_iterator j = locs.begin();
+ for(; j != locs.end(); ++j) {
+ if(j != i)
+ res |= invalidated_.insert(*j).second;
+ }
+
+ return res; // always true, but cleaner like that
+}
+
bool display::invalidate_visible_locations_in_rect(const SDL_Rect& rect)
{
return invalidate_locations_in_rect(intersect_rects(map_area(),rect));
Modified: trunk/src/display.hpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/display.hpp?rev=35655&r1=35654&r2=35655&view=diff
==============================================================================
--- trunk/src/display.hpp (original)
+++ trunk/src/display.hpp Sat May 16 19:15:00 2009
@@ -268,6 +268,12 @@
bool invalidate(const map_location& loc);
bool invalidate(const std::set<map_location>& locs);
+
+ /**
+ * If this set is partially invalidated, invalidate all its hexes.
+ * Returns if any new invalidation was needed
+ */
+ bool propagate_invalidation(const std::set<map_location>& locs);
/** invalidate all hexes under the rectangle rect (in screen
coordinates) */
bool invalidate_locations_in_rect(const SDL_Rect& rect);
_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits