Author: silene
Date: Sat May  9 18:18:43 2009
New Revision: 35507

URL: http://svn.gna.org/viewcvs/wesnoth?rev=35507&view=rev
Log:
Fixed units not being animated when partly out of the screen.

Modified:
    trunk/src/display.cpp
    trunk/src/display.hpp
    trunk/src/game_display.cpp

Modified: trunk/src/display.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/display.cpp?rev=35507&r1=35506&r2=35507&view=diff
==============================================================================
--- trunk/src/display.cpp (original)
+++ trunk/src/display.cpp Sat May  9 18:18:43 2009
@@ -1532,6 +1532,16 @@
        return !outside_area(map_area(), x, y);
 }
 
+bool display::tile_nearly_on_screen(const map_location& loc)
+{
+       int x = get_location_x(loc);
+       int y = get_location_y(loc);
+       const SDL_Rect &area = map_area();
+       int hw = hex_width(), hs = hex_size();
+       return !(x + hs >= area.x - hw && x < area.x + area.w - hw &&
+                y + hs >= area.y - hs && y < area.y - area.h - hs);
+}
+
 void display::scroll_to_xy(int screenxpos, int screenypos, SCROLL_TYPE 
scroll_type, bool force)
 {
        if(!force && !preferences::scroll_to_action()) return;

Modified: trunk/src/display.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/display.hpp?rev=35507&r1=35506&r2=35507&view=diff
==============================================================================
--- trunk/src/display.hpp (original)
+++ trunk/src/display.hpp Sat May  9 18:18:43 2009
@@ -433,6 +433,9 @@
 
        /** Check if a tile is fully on screen. */
        bool tile_on_screen(const map_location& loc);
+
+       /** Checks if location @a loc or one of the adjacent tiles is visible 
on screen. */
+       bool tile_nearly_on_screen(const map_location &loc);
 
        /**
         * Draws invalidated items.

Modified: trunk/src/game_display.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/game_display.cpp?rev=35507&r1=35506&r2=35507&view=diff
==============================================================================
--- trunk/src/game_display.cpp (original)
+++ trunk/src/game_display.cpp Sat May  9 18:18:43 2009
@@ -890,10 +890,10 @@
        for (unit_map::iterator u = units_.begin(),
             u_end = units_.end(); u != u_end; ++u)
        {
-               if (!tile_on_screen(u->first)) continue;
+               if (!tile_nearly_on_screen(u->first)) continue;
                u->second.refresh(*this, u->first);
        }
-       if (temp_unit_ && tile_on_screen(temp_unit_loc_))
+       if (temp_unit_ && tile_nearly_on_screen(temp_unit_loc_))
                temp_unit_->refresh(*this, temp_unit_loc_);
        bool new_inval = true;
        while(new_inval) {
@@ -901,10 +901,10 @@
                for (unit_map::iterator u = units_.begin(),
                     u_end = units_.end(); u != u_end; ++u)
                {
-                       if (!tile_on_screen(u->first)) continue;
+                       if (!tile_nearly_on_screen(u->first)) continue;
                        new_inval |= u->second.invalidate(u->first);
                }
-               if (temp_unit_ && tile_on_screen(temp_unit_loc_)) {
+               if (temp_unit_ && tile_nearly_on_screen(temp_unit_loc_)) {
                        //new_inval |=invalidate(temp_unit_loc_);
                        new_inval |=temp_unit_->invalidate(temp_unit_loc_);
                }


_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits

Reply via email to