Remove some redundant on_board() and is_keep() calls.

(on_board() is part of is_castle() and
is_keep() is part of can_recruit_on().)
This commit is contained in:
J. Tyne 2012-07-08 18:02:25 +00:00
parent 5dc6a7b178
commit 461b89e3dd
3 changed files with 5 additions and 17 deletions

View file

@ -328,9 +328,6 @@ void unit_creator::post_create(const map_location &loc, const unit &new_unit, bo
bool can_recruit_on(const gamemap& map, const map_location& leader, const map_location& loc)
{
if(!map.on_board(loc))
return false;
if(!map.is_castle(loc))
return false;
@ -364,9 +361,8 @@ const std::set<std::string> get_recruits_for_location(int side, const map_locati
if (!(u->can_recruit() && u->side() == side))
continue;
//Check if the leader is on the right keep.
if (resources::game_map->is_keep(u->get_location())
&& (can_recruit_on(*resources::game_map, u->get_location(), recruit_loc))) {
// Check if the leader is on a connected keep.
if ( can_recruit_on(*resources::game_map, u->get_location(), recruit_loc) ) {
leader_in_place= true;
local_result.insert(u->recruits().begin(), u->recruits().end());
} else
@ -410,9 +406,8 @@ const std::vector<const unit*> get_recalls_for_location(int side, const map_loca
if (!(u->can_recruit() && u->side() == side))
continue;
//Check if the leader is on the right keep.
if (resources::game_map->is_keep(u->get_location())
&& (can_recruit_on(*resources::game_map, u->get_location(), recall_loc)))
// Check if the leader is on a connected keep.
if ( can_recruit_on(*resources::game_map, u->get_location(), recall_loc) )
leader_in_place= true;
else continue;
@ -649,7 +644,6 @@ void place_recruit(const unit &u, const map_location &recruit_location, const ma
for(; leader != resources::units->end(); ++leader)
if (leader->can_recruit() &&
leader->side() == new_unit.side() &&
resources::game_map->is_keep(leader->get_location()) &&
can_recruit_on(*resources::game_map, leader->get_location(), recruit_location))
break;
if (show) {

View file

@ -460,7 +460,6 @@ side_actions::iterator side_actions::bump_earlier(side_actions::iterator positio
if(recruit_recall_loc.valid()) {
unit const* leader = bump_earlier->get_unit();
if(leader->can_recruit()
&& resources::game_map->is_keep(leader->get_location())
&& can_recruit_on(*resources::game_map, leader->get_location(), recruit_recall_loc)) {
if(unit const* backup_leader = find_backup_leader(*leader)) {
side_actions::iterator it = find_first_action_of(*backup_leader);

View file

@ -68,9 +68,7 @@ unit const* find_backup_leader(unit const& leader)
assert(resources::game_map->is_keep(leader.get_location()));
BOOST_FOREACH(unit const& unit, *resources::units)
{
if (unit.can_recruit() &&
resources::game_map->is_keep(unit.get_location()) &&
unit.id() != leader.id())
if (unit.can_recruit() && unit.id() != leader.id())
{
if (can_recruit_on(*resources::game_map, unit.get_location(), leader.get_location()))
return &unit;
@ -83,9 +81,6 @@ unit* find_recruiter(size_t team_index, map_location const& hex)
{
gamemap& map = *resources::game_map;
if(!map.on_board(hex))
return NULL;
if(!map.is_castle(hex))
return NULL;