mail[Wesnoth-commits] r27279 - in /trunk: changelog src/display.cpp


Others Months | Index by Date | Thread Index
>>   [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Header


Content

Posted by alinktomine on June 18, 2008 - 14:26:
Author: alink
Date: Wed Jun 18 14:26:31 2008
New Revision: 27279

URL: http://svn.gna.org/viewcvs/wesnoth?rev=27279&view=rev
Log:
Re-use the fix of r27228 from boucman (decapitation of moving units)
to fix another glitch (decapitation of unit on a keep, when invalidating 
north)
Also did some rewriting (for readibility and shorthen the copy-paste part)
but didn't change the logic

Modified:
    trunk/changelog
    trunk/src/display.cpp

Modified: trunk/changelog
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/changelog?rev=27279&r1=27278&r2=27279&view=diff
==============================================================================
--- trunk/changelog (original)
+++ trunk/changelog Wed Jun 18 14:26:31 2008
@@ -161,6 +161,7 @@
    * fix bug #11630 (preventing redo and rename during opponent's turn).
    * fix a regression about missing default portrait in dialogs.
    * fix false move-cursor around enemies after some dialog events.
+   * fix some unit decapitation when placed on a keep
 
 Version 1.5.0:
  * campaigns:

Modified: trunk/src/display.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/display.cpp?rev=27279&r1=27278&r2=27279&view=diff
==============================================================================
--- trunk/src/display.cpp (original)
+++ trunk/src/display.cpp Wed Jun 18 14:26:31 2008
@@ -2025,16 +2025,19 @@
 bool display::invalidate_rectangle(const gamemap::location& first_corner, 
const gamemap::location& second_corner) {
        // unused variable - const SDL_Rect& rect = map_area();
        bool result = false;
-       for (int x = minimum<int>(first_corner.x,second_corner.x); x <= 
maximum<int>(first_corner.x,second_corner.x);x++) {
-               for (int y = minimum<int>(first_corner.y,second_corner.y); y 
<= maximum<int>(first_corner.y,second_corner.y);y++) {
+
+       const int min_x = minimum<int>(first_corner.x,second_corner.x);
+       const int min_y = minimum<int>(first_corner.y,second_corner.y);
+       const int max_x = maximum<int>(first_corner.x,second_corner.x);
+       const int max_y = maximum<int>(first_corner.y,second_corner.y);
+
+       for (int x = min_x; x <= max_x;x++) {
+               for (int y = min_y; y <= max_y;y++) {
                        result |= invalidate(gamemap::location(x,y));
                }
-               // take a margin on Y because of "misaligned hexes" 
-               if(is_odd(x)) {
-                       result |= 
invalidate(gamemap::location(x,minimum<int>(first_corner.y,second_corner.y)-1));
-               } else {
-                       result |= 
invalidate(gamemap::location(x,maximum<int>(first_corner.y,second_corner.y)+1));
-               }
+               // take a margin on Y because of "misaligned hexes"
+               gamemap::location margein(x, is_odd(x) ? min_y-1 : max_y+1);
+               result |= invalidate(margein);
        }
        return result;
 }
@@ -2043,12 +2046,25 @@
        const SDL_Rect& rect = map_area();
        return invalidate_rectangle(pixel_position_to_hex(x1 - rect.x+xpos_, 
y1 - rect.y+ypos_),pixel_position_to_hex(x2 - rect.x+xpos_, y2 - 
rect.y+ypos_));
 }
+
 bool display::rectangle_need_update(const gamemap::location& first_corner, 
const gamemap::location& second_corner) const {
-       for (int x = minimum<int>(first_corner.x,second_corner.x); x <= 
maximum<int>(first_corner.x,second_corner.x);x++) {
-               for (int y = minimum<int>(first_corner.y,second_corner.y); y 
<= maximum<int>(first_corner.y,second_corner.y);y++) {
-                       if(invalidated_.find(gamemap::location(x,y)) != 
invalidated_.end()) return true;
-               }
-       }
+       const int min_x = minimum<int>(first_corner.x,second_corner.x);
+       const int min_y = minimum<int>(first_corner.y,second_corner.y);
+       const int max_x = maximum<int>(first_corner.x,second_corner.x);
+       const int max_y = maximum<int>(first_corner.y,second_corner.y);
+
+       for (int x = min_x; x <= max_x;x++) {
+               for (int y = min_y; y <= max_y;y++) {
+                       // take a margin on Y because of "misaligned hexes"
+                       if(invalidated_.find(gamemap::location(x,y)) != 
invalidated_.end())
+                               return true;
+               }
+               // take a margin on Y because of "misaligned hexes"
+               gamemap::location margein(x, is_odd(x) ? min_y-1 : max_y+1);
+               if(invalidated_.find(margein) != invalidated_.end())
+                       return true;
+       }
+
        return false;
 }
 




Related Messages


Powered by MHonArc, Updated Wed Jun 18 15:02:07 2008