Author: alink
Date: Sat Jun 30 23:13:50 2007
New Revision: 18577

URL: http://svn.gna.org/viewcvs/wesnoth?rev=18577&view=rev
Log:
add a function to clear haloes of a unit. For simplify a little the code (same 
block used several times)
and because even when we don't call redraw_unit(), its haloes will still be 
drawn.
So this function to control this too, all for the final goal to reduce 
invisible drawing

Modified:
    trunk/src/unit.cpp
    trunk/src/unit.hpp

Modified: trunk/src/unit.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/unit.cpp?rev=18577&r1=18576&r2=18577&view=diff
==============================================================================
--- trunk/src/unit.cpp (original)
+++ trunk/src/unit.cpp Sat Jun 30 23:13:50 2007
@@ -335,12 +335,7 @@
 
 unit::~unit()
 {
-       if(unit_halo_ != halo::NO_HALO)  {
-               halo::remove(unit_halo_);
-       }
-       if(unit_anim_halo_ != halo::NO_HALO) {
-               halo::remove(unit_anim_halo_);
-       }
+       clear_haloes();
 
        delete anim_;
 
@@ -1644,14 +1639,7 @@
                        (invisible(hex,disp.get_units(),disp.get_teams()) &&
                        disp.get_teams()[disp.viewing_team()].is_enemy(side())) 
){
 
-               if(unit_halo_ != halo::NO_HALO) {
-                       halo::remove(unit_halo_);
-                       unit_halo_ = halo::NO_HALO;
-               }
-               if(unit_anim_halo_ != halo::NO_HALO) {
-                       halo::remove(unit_anim_halo_);
-                       unit_anim_halo_ = halo::NO_HALO;
-               }
+               clear_haloes();
                if(anim_) anim_->update_last_draw_time();
                return;
        }
@@ -1873,6 +1861,18 @@
 
        refreshing_ = false;
        anim_->update_last_draw_time();
+}
+
+void clear_haloes()
+{
+       if(unit_halo_ != halo::NO_HALO) {
+               halo::remove(unit_halo_);
+               unit_halo_ = halo::NO_HALO;
+       }
+       if(unit_anim_halo_ != halo::NO_HALO) {
+               halo::remove(unit_anim_halo_);
+               unit_anim_halo_ = halo::NO_HALO;
+       }
 }
 
 std::set<gamemap::location> unit::overlaps(const game_display &disp, const 
gamemap::location &loc) const
@@ -3103,12 +3103,5 @@
        hidden_ = state;
        if(!state) return;
        // we need to get rid of haloes immediately to avoid display glitches
-       if(unit_halo_ != halo::NO_HALO) {
-               halo::remove(unit_halo_);
-               unit_halo_ = halo::NO_HALO;
-       }
-       if(unit_anim_halo_ != halo::NO_HALO) {
-               halo::remove(unit_anim_halo_);
-               unit_anim_halo_ = halo::NO_HALO;
-       }
-}
+       clear_haloes();
+}

Modified: trunk/src/unit.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/unit.hpp?rev=18577&r1=18576&r2=18577&view=diff
==============================================================================
--- trunk/src/unit.hpp (original)
+++ trunk/src/unit.hpp Sat Jun 30 23:13:50 2007
@@ -170,6 +170,9 @@
                // a sdl surface, ready for display for place where we need a 
fix image of the unit
                const surface still_image(bool scaled = false) const;
                void redraw_unit(game_display& disp,gamemap::location hex);
+               // clear unit_halo_ and unit_anim_halo_
+               void clear_haloes();
+               
 
                void set_standing(const game_display& disp,const 
gamemap::location& loc, bool with_bars = true);
                void set_defending(const game_display &disp,const 
gamemap::location& loc, int damage,const attack_type* attack,const attack_type* 
secondary_attack,int swing_num);


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

Reply via email to