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.
This commit is contained in:
parent
da6770c14f
commit
1534298d7a
4 changed files with 23 additions and 5 deletions
|
@ -307,11 +307,6 @@ void unit_creator::post_create(const map_location &loc, const unit &new_unit, bo
|
|||
|
||||
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)) {
|
||||
|
|
|
@ -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 @@ protected:
|
|||
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());
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
|
|
@ -247,3 +247,18 @@ unit_map::unit_iterator unit_map::find_leader(int side)
|
|||
}
|
||||
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;
|
||||
}
|
|
@ -217,6 +217,7 @@ public:
|
|||
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); }
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue