Author: silene
Date: Thu May 21 16:57:46 2009
New Revision: 35787

URL: http://svn.gna.org/viewcvs/wesnoth?rev=35787&view=rev
Log:
Used unit::loc_ for temporary units too. Removed game_display::temp_unit_loc_. 
Removed legacy unit::set_standing.

Modified:
    trunk/src/actions.cpp
    trunk/src/game_display.cpp
    trunk/src/game_display.hpp
    trunk/src/unit.cpp
    trunk/src/unit.hpp
    trunk/src/unit_animation.cpp
    trunk/src/unit_display.cpp

Modified: trunk/src/actions.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/actions.cpp?rev=35787&r1=35786&r2=35787&view=diff
==============================================================================
--- trunk/src/actions.cpp (original)
+++ trunk/src/actions.cpp Thu May 21 16:57:46 2009
@@ -1577,13 +1577,13 @@
        }
 
        if(a_.valid()) {
-               a_.get_unit().set_standing(a_.iter_->first);
+               a_.get_unit().set_standing();
                if(a_.xp_)
                        a_.get_unit().get_experience(a_.xp_);
        }
 
        if(d_.valid()) {
-               d_.get_unit().set_standing(d_.iter_->first);
+               d_.get_unit().set_standing();
                if(d_.xp_)
                        d_.get_unit().get_experience(d_.xp_);
        }

Modified: trunk/src/game_display.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/game_display.cpp?rev=35787&r1=35786&r2=35787&view=diff
==============================================================================
--- trunk/src/game_display.cpp (original)
+++ trunk/src/game_display.cpp Thu May 21 16:57:46 2009
@@ -47,7 +47,6 @@
                display(video, &map, theme_cfg, cfg, level),
                units_(units),
                temp_unit_(NULL),
-               temp_unit_loc_(),
                attack_indicator_src_(),
                attack_indicator_dst_(),
                energy_bar_rects_(),
@@ -272,7 +271,9 @@
 std::vector<map_location> game_display::get_invalidated_unit_locations() {
        std::vector<map_location> unit_locations;
        foreach (const map_location& loc, invalidated_) {
-               if ((temp_unit_ && temp_unit_loc_ == loc) || units_.find(loc) 
!= units_.end()) {
+               if ((temp_unit_ && temp_unit_->get_location() == loc) ||
+                   units_.find(loc) != units_.end())
+               {
                        unit_locations.push_back(loc);
                }
        }
@@ -406,8 +407,8 @@
                        u_it->second.redraw_unit(*this, loc);
                        //simulate_delay += 1;
                }
-               if (temp_unit_ && temp_unit_loc_ == loc) {
-                       temp_unit_->redraw_unit(*this, temp_unit_loc_);
+               if (temp_unit_ && temp_unit_->get_location() == loc) {
+                       temp_unit_->redraw_unit(*this, loc);
                        //simulate_delay += 1;
                }
        }
@@ -893,8 +894,8 @@
                if (!tile_nearly_on_screen(u->first)) continue;
                u->second.refresh(*this, u->first);
        }
-       if (temp_unit_ && tile_nearly_on_screen(temp_unit_loc_))
-               temp_unit_->refresh(*this, temp_unit_loc_);
+       if (temp_unit_ && tile_nearly_on_screen(temp_unit_->get_location()))
+               temp_unit_->refresh(*this, temp_unit_->get_location());
        bool new_inval = true;
        while(new_inval) {
                new_inval = false;
@@ -904,9 +905,9 @@
                        if (!tile_nearly_on_screen(u->first)) continue;
                        new_inval |= u->second.invalidate(u->first);
                }
-               if (temp_unit_ && tile_nearly_on_screen(temp_unit_loc_)) {
+               if (temp_unit_ && 
tile_nearly_on_screen(temp_unit_->get_location())) {
                        //new_inval |=invalidate(temp_unit_loc_);
-                       new_inval |=temp_unit_->invalidate(temp_unit_loc_);
+                       new_inval 
|=temp_unit_->invalidate(temp_unit_->get_location());
                }
        }
 }
@@ -917,18 +918,17 @@
        debugHighlights_[loc] += amount;
 }
 
-void game_display::place_temporary_unit(unit &u, const map_location& loc)
+void game_display::place_temporary_unit(unit &u)
 {
        temp_unit_ = &u;
-       temp_unit_loc_ = loc;
-       invalidate(loc);
+       invalidate(u.get_location());
 }
 
 void game_display::remove_temporary_unit()
 {
        if(!temp_unit_) return;
 
-       invalidate(temp_unit_loc_);
+       invalidate(temp_unit_->get_location());
        // Redraw with no location to get rid of haloes
        temp_unit_->clear_haloes();
        temp_unit_ = NULL;

Modified: trunk/src/game_display.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/game_display.hpp?rev=35787&r1=35786&r2=35787&view=diff
==============================================================================
--- trunk/src/game_display.hpp (original)
+++ trunk/src/game_display.hpp Thu May 21 16:57:46 2009
@@ -186,7 +186,7 @@
 
 public:
        /** Temporarily place a unit on map (moving: can overlap others). */
-       void place_temporary_unit(unit &u, const map_location& loc);
+       void place_temporary_unit(unit &u);
        void remove_temporary_unit();
 
        /** Set the attack direction indicator. */
@@ -306,7 +306,6 @@
        unit_map& units_;
 
        unit *temp_unit_;
-       map_location temp_unit_loc_;
 
        // Locations of the attack direction indicator's parts
        map_location attack_indicator_src_;

Modified: trunk/src/unit.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/unit.cpp?rev=35787&r1=35786&r2=35787&view=diff
==============================================================================
--- trunk/src/unit.cpp (original)
+++ trunk/src/unit.cpp Thu May 21 16:57:46 2009
@@ -1792,15 +1792,17 @@
        return unit_image;
 }
 
-void unit::set_standing(const map_location& loc, bool with_bars)
+void unit::set_standing(bool with_bars)
 {
        game_display * disp =  game_display::get_singleton();
        map_location arr[6];
-       get_adjacent_tiles(loc, arr);
+       get_adjacent_tiles(loc_, arr);
        if (preferences::show_standing_animations()&& !incapacitated()) {
-               
start_animation(INT_MAX,loc,choose_animation(*disp,loc,"standing"),with_bars,true,"",0,STATE_STANDING);
+               start_animation(INT_MAX, loc_, choose_animation(*disp, loc_, 
"standing"),
+                       with_bars, true, "", 0, STATE_STANDING);
        } else {
-               
start_animation(INT_MAX,loc,choose_animation(*disp,loc,"_disabled_"),with_bars,true,"",0,STATE_STANDING);
+               start_animation(INT_MAX, loc_, choose_animation(*disp, loc_, 
"_disabled_"),
+                       with_bars, true, "", 0, STATE_STANDING);
        }
 }
 
@@ -1830,7 +1832,7 @@
     // everything except standing select and idle
     const bool accelerate = (state != STATE_FORGET && state != STATE_STANDING);
        if(!animation) {
-               set_standing(loc,with_bars);
+               set_standing(with_bars);
                return ;
        }
        state_ =state;
@@ -1876,7 +1878,7 @@
 
 
        if(!anim_) {
-               set_standing(loc);
+               set_standing();
        }
        anim_->update_last_draw_time();
        frame_parameters params;
@@ -3116,7 +3118,7 @@
 {
        if (state_ == STATE_FORGET && anim_ && 
anim_->animation_finished_potential())
        {
-               set_standing(loc);
+               set_standing();
                return;
        }
        if (state_ != STATE_STANDING || get_current_animation_tick() < 
next_idling_ ||

Modified: trunk/src/unit.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/unit.hpp?rev=35787&r1=35786&r2=35787&view=diff
==============================================================================
--- trunk/src/unit.hpp (original)
+++ trunk/src/unit.hpp Thu May 21 16:57:46 2009
@@ -204,10 +204,7 @@
        /** Clear unit_halo_  */
        void clear_haloes();
 
-
-       void set_standing(const map_location& loc, bool with_bars = true);
-       void set_standing(bool with_bars = true)
-       { set_standing(loc_, with_bars); }
+       void set_standing(bool with_bars = true);
 
        void set_idling(const game_display& disp,const map_location& loc);
        void set_selecting();
@@ -223,7 +220,7 @@
        int cost () const { return unit_value_; }
 
        const map_location &get_location() const { return loc_; }
-       /** To be called by unit_map only. (For now.) */
+       /** To be called by unit_map or for temporary units only. */
        void set_location(const map_location &loc) { loc_ = loc; }
 
        const map_location& get_goto() const { return goto_; }

Modified: trunk/src/unit_animation.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/unit_animation.cpp?rev=35787&r1=35786&r2=35787&view=diff
==============================================================================
--- trunk/src/unit_animation.cpp (original)
+++ trunk/src/unit_animation.cpp Thu May 21 16:57:46 2009
@@ -1080,6 +1080,6 @@
 void unit_animator::set_all_standing()
 {
         for(std::vector<anim_elem>::iterator anim = animated_units_.begin(); 
anim != animated_units_.end();anim++) {
-                anim->my_unit->set_standing(anim->src);
+               anim->my_unit->set_standing();
         }
 }

Modified: trunk/src/unit_display.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/unit_display.cpp?rev=35787&r1=35786&r2=35787&view=diff
==============================================================================
--- trunk/src/unit_display.cpp (original)
+++ trunk/src/unit_display.cpp Thu May 21 16:57:46 2009
@@ -34,16 +34,19 @@
        }
        disp->scroll_to_tiles(a,b,game_display::ONSCREEN,true,0.0,false);
 
+       temp_unit.set_location(a);
        if (!disp->fogged(a)) { // teleport
-               disp->place_temporary_unit(temp_unit,a);
+               disp->place_temporary_unit(temp_unit);
                temp_unit.set_facing(a.get_relative_dir(b));
                unit_animator animator;
                animator.add_animation(&temp_unit,"pre_teleport",a);
                animator.start_animations();
                animator.wait_for_end();
        }
+
+       temp_unit.set_location(b);
        if (!disp->fogged(b)) { // teleport
-               disp->place_temporary_unit(temp_unit,b);
+               disp->place_temporary_unit(temp_unit);
                temp_unit.set_facing(a.get_relative_dir(b));
                
disp->scroll_to_tiles(b,a,game_display::ONSCREEN,true,0.0,false);
                unit_animator animator;
@@ -51,7 +54,8 @@
                animator.start_animations();
                animator.wait_for_end();
        }
-       temp_unit.set_standing(b);
+
+       temp_unit.set_standing();
        disp->update_display();
        events::pump();
 }
@@ -64,7 +68,8 @@
        }
 
 
-       disp->place_temporary_unit(temp_unit,a);
+       temp_unit.set_location(a);
+       disp->place_temporary_unit(temp_unit);
        temp_unit.set_facing(a.get_relative_dir(b));
        unit_animator animator;
        animator.replace_anim_if_invalid(&temp_unit,"movement",a,b);
@@ -143,9 +148,10 @@
        // Original unit is usually hidden (but still on map, so count is 
correct)
        unit temp_unit = u;
        u.set_hidden(true);
-       temp_unit.set_standing(path[0],false);
+       u.set_location(path[0]);
+       temp_unit.set_standing(false);
        temp_unit.set_hidden(false);
-       disp->place_temporary_unit(temp_unit,path[0]);
+       disp->place_temporary_unit(temp_unit);
        if(!invisible) {
                // Scroll to the path, but only if it fully fits on screen.
                // If it does not fit we might be able to do a better scroll 
later.
@@ -175,7 +181,8 @@
                if(!invisible) {
                        if (!disp->tile_fully_on_screen(path[i]) || 
!disp->tile_fully_on_screen(path[i+1])) {
                                // prevent the unit from dissappearing if we 
scroll here with i == 0
-                               disp->place_temporary_unit(temp_unit,path[i]);
+                               temp_unit.set_location(path[i]);
+                               disp->place_temporary_unit(temp_unit);
                                // scroll in as much of the remaining path as 
possible
                                std::vector<map_location> remaining_path;
                                for(size_t j = i; j < path.size(); j++) {
@@ -197,8 +204,9 @@
                }
        }
        disp->remove_temporary_unit();
+       u.set_location(path[path.size() - 1]);
        u.set_facing(path[path.size()-2].get_relative_dir(path[path.size()-1]));
-       u.set_standing(path[path.size()-1]);
+       u.set_standing();
 
        u.set_hidden(was_hidden);
        disp->invalidate_unit_after_move(path[0], path[path.size()-1]);
@@ -260,7 +268,7 @@
        unit defender = def->second;
        bool was_hidden = defender.get_hidden();
        def->second.set_hidden(true);
-       disp->place_temporary_unit(defender,def->first);
+       disp->place_temporary_unit(defender);
 
 
        att->second.set_facing(a.get_relative_dir(b));


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

Reply via email to