Author: jhinrichs
Date: Sun Feb 14 01:45:51 2010
New Revision: 41193

URL: http://svn.gna.org/viewcvs/wesnoth?rev=41193&view=rev
Log:
With multiple leaders for one side make sure, that the first leader name (the 
one with the lowest underlying_id) is mentioned in the turn dialog and not the 
last.

Modified:
    trunk/src/actions.cpp
    trunk/src/gamestatus.cpp
    trunk/src/unit_map.cpp
    trunk/src/unit_map.hpp

Modified: trunk/src/actions.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/actions.cpp?rev=41193&r1=41192&r2=41193&view=diff
==============================================================================
--- trunk/src/actions.cpp (original)
+++ trunk/src/actions.cpp Sun Feb 14 01:45:51 2010
@@ -307,11 +307,6 @@
 
        bool show = show_ && (resources::screen !=NULL) && 
!resources::screen->fogged(loc);
        bool animate = show && anim;
-       // If the new unit is a leader, use its name as the player name.
-       if (rename_side_ && new_unit.can_recruit()) {
-               team_.set_current_player(new_unit.name());
-       }
-
 
        if (get_village_) {
                if (resources::game_map->is_village(loc)) {

Modified: trunk/src/gamestatus.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gamestatus.cpp?rev=41193&r1=41192&r2=41193&view=diff
==============================================================================
--- trunk/src/gamestatus.cpp (original)
+++ trunk/src/gamestatus.cpp Sun Feb 14 01:45:51 2010
@@ -28,6 +28,7 @@
 #include "log.hpp"
 #include "game_preferences.hpp"
 #include "replay.hpp"
+#include "resources.hpp"
 #include "statistics.hpp"
 #include "unit.hpp"
 #include "unit_id.hpp"
@@ -936,6 +937,12 @@
                        uc.add_unit(cfg);
 
                }
+
+               // Find the first leader and use its name as the player name.
+               unit_map::iterator u = 
resources::units->find_first_leader(t_->side());
+               if (u != resources::units->end())
+                       t_->set_current_player(u->second.name());
+
        }
 
 };

Modified: trunk/src/unit_map.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/unit_map.cpp?rev=41193&r1=41192&r2=41193&view=diff
==============================================================================
--- trunk/src/unit_map.cpp (original)
+++ trunk/src/unit_map.cpp Sun Feb 14 01:45:51 2010
@@ -247,3 +247,18 @@
        }
        return i_end;
 }
+
+unit_map::unit_iterator unit_map::find_first_leader(int side)
+{
+       unit_map::iterator i = begin(), i_end = end();
+       unit_map::iterator first_leader = end();
+       size_t min_underlying_id = -1;
+
+       for (; i != i_end; ++i) {
+               if (static_cast<int>(i->second.side()) == side && 
i->second.can_recruit()){
+                       if ((first_leader == end()) || 
(i->second.underlying_id() < first_leader->second.underlying_id()) )
+                               first_leader = i;
+               }
+       }
+       return first_leader;
+}

Modified: trunk/src/unit_map.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/unit_map.hpp?rev=41193&r1=41192&r2=41193&view=diff
==============================================================================
--- trunk/src/unit_map.hpp (original)
+++ trunk/src/unit_map.hpp Sun Feb 14 01:45:51 2010
@@ -217,6 +217,7 @@
        unit_iterator find_leader(int side);
        const_unit_iterator find_leader(int side) const
        { return const_cast<unit_map *>(this)->find_leader(side); }
+       unit_iterator find_first_leader(int side);
 
        size_t count(const map_location& loc) const { return lmap_.count(loc); }
 


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

Reply via email to