Deployed more display_context::get_team (cont. f9a021e and 921bbc2)

This commit is contained in:
Charles Dang 2017-04-26 05:13:17 +11:00
parent cbd7d44f62
commit 06199650e6
19 changed files with 37 additions and 37 deletions

View file

@ -59,7 +59,7 @@ namespace actions {
const std::set<std::string> get_recruits(int side, const map_location &recruit_loc)
{
const team & current_team = resources::gameboard->teams()[side -1];
const team & current_team = resources::gameboard->get_team(side);
LOG_NG << "getting recruit list for side " << side << " at location " << recruit_loc << "\n";
@ -131,7 +131,7 @@ namespace { // Helpers for get_recalls()
std::vector< unit_const_ptr > & result,
std::set<size_t> * already_added = nullptr)
{
const team& leader_team = resources::gameboard->teams()[leader->side()-1];
const team& leader_team = resources::gameboard->get_team(leader->side());
const std::string& save_id = leader_team.save_id();
const unit_filter ufilt(vconfig(leader->recall_filter()), resources::filter_con);
@ -186,7 +186,7 @@ std::vector<unit_const_ptr > get_recalls(int side, const map_location &recall_lo
add_leader_filtered_recalls(find_it.get_shared_ptr(), result);
return result;
}
else if ( find_it->is_visible_to_team(resources::gameboard->teams()[side-1], *resources::gameboard, false) )
else if ( find_it->is_visible_to_team(resources::gameboard->get_team(side), *resources::gameboard, false) )
{
// This hex is visibly occupied, so we cannot recall here.
allow_local = false;
@ -246,7 +246,7 @@ namespace { // Helpers for check_recall_location()
return RECRUIT_NO_LEADER;
// Make sure the recalling unit can recall this specific unit.
team& recall_team = (*resources::gameboard).teams()[recaller.side()-1];
team& recall_team = (*resources::gameboard).get_team(recaller.side());
scoped_recall_unit this_unit("this_unit", recall_team.save_id(),
recall_team.recall_list().find_index(recall_unit.id()));
@ -422,7 +422,7 @@ RECRUIT_CHECK check_recruit_location(const int side, map_location &recruit_locat
// If the specified unit type is in the team's recruit list, there is no
// need to check each leader's list.
if ( utils::contains(resources::gameboard->teams()[side-1].recruits(), unit_type) )
if ( utils::contains(resources::gameboard->get_team(side).recruits(), unit_type) )
check_type.clear();
// If the check location is not valid, we will never get an "OK" result.
@ -586,8 +586,8 @@ namespace { // Helpers for place_recruit()
int min_dist = INT_MAX;
for ( unit_itor = units.begin(); unit_itor != units.end(); ++unit_itor ) {
if (resources::gameboard->teams()[unit_itor->side()-1].is_enemy(new_unit.side()) &&
unit_itor->is_visible_to_team(resources::gameboard->teams()[new_unit.side()-1], *resources::gameboard, false)) {
if (resources::gameboard->get_team(unit_itor->side()).is_enemy(new_unit.side()) &&
unit_itor->is_visible_to_team(resources::gameboard->get_team(new_unit.side()), *resources::gameboard, false)) {
int dist = distance_between(unit_itor->get_location(),recruit_loc) - unit_itor->level();
if (dist < min_dist) {
min_dist = dist;
@ -653,7 +653,7 @@ place_recruit_result place_recruit(unit_ptr u, const map_location &recruit_locat
new_unit_itor->set_hidden(true);
}
preferences::encountered_units().insert(new_unit_itor->type_id());
resources::gameboard->teams()[u->side()-1].spend_gold(cost);
resources::gameboard->get_team(u->side()).spend_gold(cost);
if ( show ) {
unit_display::unit_recruited(current_loc, leader_loc);

View file

@ -366,7 +366,7 @@ namespace { // Private helpers for move_unit()
orig_dir_(move_it_->facing()),
goto_( is_ai_move() ? move_it_->get_goto() : route.back() ),
current_side_(orig_side_),
current_team_(&resources::gameboard->teams()[current_side_-1]),
current_team_(&resources::gameboard->get_team(current_side_)),
current_uses_fog_(current_team_->fog_or_shroud() &&
current_team_->auto_shroud_updates()),
move_loc_(begin_),
@ -824,7 +824,7 @@ namespace { // Private helpers for move_unit()
// Update the current unit data.
current_side_ = found ? move_it_->side() : orig_side_;
current_team_ = &resources::gameboard->teams()[current_side_-1];
current_team_ = &resources::gameboard->get_team(current_side_);
current_uses_fog_ = current_team_->fog_or_shroud() &&
( current_side_ != orig_side_ ||
current_team_->auto_shroud_updates() );

View file

@ -37,7 +37,7 @@ void dismiss_action::write(config & cfg) const
*/
bool dismiss_action::undo(int side)
{
team &current_team = resources::gameboard->teams()[side-1];
team &current_team = resources::gameboard->get_team(side);
current_team.recall_list().add(dismissed_unit);
execute_undo_umc_wml();

View file

@ -53,7 +53,7 @@ bool recall_action::undo(int side)
{
game_display & gui = *resources::screen;
unit_map & units = resources::gameboard->units();
team &current_team = resources::gameboard->teams()[side-1];
team &current_team = resources::gameboard->get_team(side);
const map_location & recall_loc = route.front();
unit_map::iterator un_it = units.find(recall_loc);

View file

@ -54,7 +54,7 @@ bool recruit_action::undo(int side)
{
game_display & gui = *resources::screen;
unit_map & units = resources::gameboard->units();
team &current_team = resources::gameboard->teams()[side-1];
team &current_team = resources::gameboard->get_team(side);
const map_location & recruit_loc = route.front();
unit_map::iterator un_it = units.find(recruit_loc);

View file

@ -83,7 +83,7 @@ static bool can_see(const unit & viewer, const map_location & loc,
// Make sure we have a "jamming" map.
std::map<map_location, int> local_jamming;
if ( jamming == nullptr ) {
create_jamming_map(local_jamming, resources::gameboard->teams()[viewer.side()-1]);
create_jamming_map(local_jamming, resources::gameboard->get_team(viewer.side()));
jamming = &local_jamming;
}
@ -463,7 +463,7 @@ bool shroud_clearer::clear_unit(const map_location &view_loc, team &view_team,
bool shroud_clearer::clear_unit(const map_location &view_loc, const unit &viewer,
bool can_delay, bool invalidate, bool instant)
{
team & viewing_team = resources::gameboard->teams()[viewer.side()-1];
team & viewing_team = resources::gameboard->get_team(viewer.side());
// Abort if there is nothing to clear.
if ( !viewing_team.fog_or_shroud() )
@ -495,7 +495,7 @@ bool shroud_clearer::clear_unit(const map_location &view_loc, const unit &viewer
*/
bool shroud_clearer::clear_dest(const map_location &dest, const unit &viewer)
{
team & viewing_team = resources::gameboard->teams()[viewer.side()-1];
team & viewing_team = resources::gameboard->get_team(viewer.side());
// A pair of dummy variables needed to simplify some logic.
size_t enemies, friends;

View file

@ -166,7 +166,7 @@ game_info& action_result::get_info() const
team& action_result::get_my_team() const
{
return resources::gameboard->teams()[side_-1];
return resources::gameboard->get_team(side_);
}

View file

@ -104,7 +104,7 @@ void readwrite_context_impl::raise_gamestate_changed() const
team& readwrite_context_impl::current_team_w()
{
return resources::gameboard->teams()[get_side()-1];
return resources::gameboard->get_team(get_side());
}
attack_result_ptr readwrite_context_impl::execute_attack_action(const map_location& attacker_loc, const map_location& defender_loc, int attacker_weapon){
@ -333,7 +333,7 @@ void readonly_context_impl::diagnostic(const std::string& msg)
const team& readonly_context_impl::current_team() const
{
return resources::gameboard->teams()[get_side()-1];
return resources::gameboard->get_team(get_side());
}

View file

@ -369,7 +369,7 @@ variant formula_ai::get_value(const std::string& key) const
} else if(key == "my_side")
{
return variant(std::make_shared<team_callable>(resources::gameboard->teams()[get_side()-1]));
return variant(std::make_shared<team_callable>(resources::gameboard->get_team(get_side())));
} else if(key == "my_side_number")
{

View file

@ -122,7 +122,7 @@ bool simulated_move(int side, const map_location& from, const map_location& to,
bool simulated_recall(int side, const std::string& unit_id, const map_location& recall_location){
LOG_AI_SIM_ACTIONS << "Simulated recall" << std::endl;
team own_team = resources::gameboard->teams()[side-1];
team own_team = resources::gameboard->get_team(side);
unit_ptr recall_unit = own_team.recall_list().extract_if_matches_id(unit_id);
helper_place_unit(*recall_unit, recall_location);
@ -141,7 +141,7 @@ bool simulated_recruit(int side, const unit_type* u, const map_location& recruit
const unit recruit_unit(*u, side, false); // Random traits, name and gender are not needed. This will cause "duplicate id conflicts" inside unit_map::insert(), but engine will manage this issue correctly.
helper_place_unit(recruit_unit, recruit_location);
resources::gameboard->teams()[side-1].spend_gold(u->cost());
resources::gameboard->get_team(side).spend_gold(u->cost());
LOG_AI_SIM_ACTIONS << "recruit " << u->type_name() << " at "
<< recruit_location << " spend " << u->cost() << " gold" << std::endl;

View file

@ -44,7 +44,7 @@ void ai_testing::log_turn_end(unsigned int side)
void ai_testing::log_turn(const char* msg, unsigned int side)
{
assert(side>=1);
team& current_team = resources::gameboard->teams()[side-1];
team& current_team = resources::gameboard->get_team(side);
int _turn_number = resources::tod_manager->turn();
int _units = resources::gameboard->side_units(side);

View file

@ -40,12 +40,12 @@ bool display_context::would_be_discovered(const map_location & loc, int side_num
continue;
}
const unit & u = *u_it;
if (teams()[side_num-1].is_enemy(u.side()) && !u.incapacitated()) {
if (get_team(side_num).is_enemy(u.side()) && !u.incapacitated()) {
// Enemy spotted in adjacent tiles, check if we can see him.
// Watch out to call invisible with see_all=true to avoid infinite recursive calls!
if(see_all) {
return true;
} else if (!teams()[side_num-1].fogged(u_loc)
} else if (!get_team(side_num).fogged(u_loc)
&& !u.invisible(u_loc, *this, true)) {
return true;
}

View file

@ -111,7 +111,7 @@ void game_board::check_victory(bool & continue_level, bool & found_player, bool
for (const unit & i : units())
{
DBG_EE << "Found a unit: " << i.id() << " on side " << i.side() << std::endl;
const team& tm = teams()[i.side()-1];
const team& tm = get_team(i.side());
DBG_EE << "That team's defeat condition is: " << tm.defeat_condition() << std::endl;
if (i.can_recruit() && tm.defeat_condition() == team::DEFEAT_CONDITION::NO_LEADER) {
not_defeated.insert(i.side());

View file

@ -162,7 +162,7 @@ namespace { // Support functions
continue;
}
pathfind::shortest_path_calculator calc(fake_unit,
resources::gameboard->teams()[fake_unit.side()-1],
resources::gameboard->get_team(fake_unit.side()),
resources::gameboard->teams(),
*game_map);

View file

@ -342,7 +342,7 @@ bool game_state::can_recruit_on(const map_location& leader_loc, const map_locati
// that comes to pass, just return.
return false;
}
const team & view_team = board_.teams()[side-1];
const team & view_team = board_.get_team(side);
if ( view_team.shrouded(recruit_loc) )
return false;

View file

@ -119,7 +119,7 @@ map_location find_vacant_tile(const map_location& loc, VACANT_TILE_TYPE vacancy,
map_location find_vacant_castle(const unit & leader)
{
return find_vacant_tile(leader.get_location(), VACANT_CASTLE,
nullptr, &resources::gameboard->teams()[leader.side()-1]);
nullptr, &resources::gameboard->get_team(leader.side()));
}
@ -635,7 +635,7 @@ marked_route mark_route(const plain_route &rt)
int turns = 0;
int movement = u.movement_left();
const team& unit_team = resources::gameboard->teams()[u.side()-1];
const team& unit_team = resources::gameboard->get_team(u.side());
bool zoc = false;
std::vector<map_location>::const_iterator i = rt.steps.begin();

View file

@ -121,7 +121,7 @@ std::map<int,config> mp_sync::get_user_choice_multiple_sides(const std::string &
for(int side : sides)
{
assert(1 <= side && side <= max_side);
if( resources::gameboard->teams()[side-1].is_empty())
if( resources::gameboard->get_team(side).is_empty())
{
empty_sides.insert(side);
}
@ -187,7 +187,7 @@ config mp_sync::get_user_choice(const std::string &name, const mp_sync::user_cho
side = resources::controller->current_side();
LOG_REPLAY << " side changed to " << side << "\n";
}
is_side_null_controlled = resources::gameboard->teams()[side-1].is_empty();
is_side_null_controlled = resources::gameboard->get_team(side).is_empty();
LOG_REPLAY << "get_user_choice_called with"
<< " name=" << name
@ -203,7 +203,7 @@ config mp_sync::get_user_choice(const std::string &name, const mp_sync::user_cho
//i think in that case we should better use uch.random_choice(),
//which could return something like config_of("invalid", true);
side = 1;
while ( side <= max_side && resources::gameboard->teams()[side-1].is_empty() )
while ( side <= max_side && resources::gameboard->get_team(side).is_empty() )
side++;
assert(side <= max_side);
}
@ -239,7 +239,7 @@ user_choice_manager::user_choice_manager(const std::string &name, const mp_sync:
for(int side : required_)
{
assert(1 <= side && side <= max_side);
const team& t = resources::gameboard->teams()[side-1];
const team& t = resources::gameboard->get_team(side);
assert(!t.is_empty());
if(side != current_side_)
{
@ -318,7 +318,7 @@ void user_choice_manager::update_local_choice()
sides_str += " ";
sides_str += std::to_string(side);
//and it is local
if(resources::gameboard->teams()[side-1].is_local() && !resources::gameboard->teams()[side-1].is_idle())
if(resources::gameboard->get_team(side).is_local() && !resources::gameboard->get_team(side).is_idle())
{
//then we have to make a local choice.
local_choice_ = side;

View file

@ -217,7 +217,7 @@ void unit_mover::replace_temporary(unit_ptr u)
u->set_hidden(true);
// Update cached data.
is_enemy_ = resources::gameboard->teams()[u->side()-1].is_enemy(disp_->viewing_side());
is_enemy_ = resources::gameboard->get_team(u->side()).is_enemy(disp_->viewing_side());
}

View file

@ -209,7 +209,7 @@ action_ptr find_action_at(map_location hex, team_filter team_filter)
std::deque<action_ptr> find_actions_of(unit const &target)
{
return resources::gameboard->teams()[target.side()-1].get_side_actions()->actions_of(target);
return resources::gameboard->get_team(target.side()).get_side_actions()->actions_of(target);
}
} //end namespace wb