Skip to content

Commit

Permalink
Replace resources::teams with resources::gameboard->teams()
Browse files Browse the repository at this point in the history
  • Loading branch information
Vultraz committed Aug 10, 2016
1 parent 65a8c44 commit 6235e18
Show file tree
Hide file tree
Showing 62 changed files with 246 additions and 242 deletions.
2 changes: 1 addition & 1 deletion src/actions/advancement.cpp
Expand Up @@ -172,7 +172,7 @@ namespace
{
//the 'side' parameter might differ from side_num_-
int res = 0;
team t = (*resources::teams)[side_num_ - 1];
team t = resources::gameboard->teams()[side_num_ - 1];
//i wonder how this got included here ?
bool is_mp = resources::controller->is_networked_mp();
bool is_current_side = resources::controller->current_side() == side_num_;
Expand Down
4 changes: 2 additions & 2 deletions src/actions/attack.cpp
Expand Up @@ -124,7 +124,7 @@ battle_context_unit_stats::battle_context_unit_stats(const unit &u,
drains = !opp.get_state("undrainable") && weapon->get_special_bool("drains");
petrifies = weapon->get_special_bool("petrifies");
poisons = !opp.get_state("unpoisonable") && weapon->get_special_bool("poison") && !opp.get_state(unit::STATE_POISONED);
backstab_pos = is_attacker && backstab_check(u_loc, opp_loc, units, *resources::teams);
backstab_pos = is_attacker && backstab_check(u_loc, opp_loc, units, resources::gameboard->teams());
rounds = weapon->get_specials("berserk").highest("value", 1).first;
firststrike = weapon->get_special_bool("firststrike");
{
Expand Down Expand Up @@ -843,7 +843,7 @@ namespace {
// The event could have killed either the attacker or
// defender, so we have to make sure they still exist
refresh_bc();
if(!a_.valid() || !d_.valid() || !(*resources::teams)[a_.get_unit().side() - 1].is_enemy(d_.get_unit().side())) {
if(!a_.valid() || !d_.valid() || !resources::gameboard->teams()[a_.get_unit().side() - 1].is_enemy(d_.get_unit().side())) {
actions::recalculate_fog(defender_side);
if (update_display_){
resources::screen->redraw_minimap();
Expand Down
18 changes: 9 additions & 9 deletions src/actions/create.cpp
Expand Up @@ -60,7 +60,7 @@ namespace actions {

const std::set<std::string> get_recruits(int side, const map_location &recruit_loc)
{
const team & current_team = (*resources::teams)[side -1];
const team & current_team = resources::gameboard->teams()[side -1];

LOG_NG << "getting recruit list for side " << side << " at location " << recruit_loc << "\n";

Expand Down Expand Up @@ -132,7 +132,7 @@ namespace { // Helpers for get_recalls()
std::vector< unit_const_ptr > & result,
std::set<size_t> * already_added = nullptr)
{
const team& leader_team = (*resources::teams)[leader->side()-1];
const team& leader_team = resources::gameboard->teams()[leader->side()-1];
const std::string& save_id = leader_team.save_id();

const unit_filter ufilt(vconfig(leader->recall_filter()), resources::filter_con);
Expand Down Expand Up @@ -187,7 +187,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::teams)[side-1], resources::gameboard->map(), false) )
else if ( find_it->is_visible_to_team(resources::gameboard->teams()[side-1], resources::gameboard->map(), false) )
{
// This hex is visibly occupied, so we cannot recall here.
allow_local = false;
Expand Down Expand Up @@ -217,7 +217,7 @@ std::vector<unit_const_ptr > get_recalls(int side, const map_location &recall_lo
if ( !leader_in_place )
{
// Return the full recall list.
for (const unit_const_ptr & recall : (*resources::teams)[side-1].recall_list())
for (const unit_const_ptr & recall : resources::gameboard->teams()[side-1].recall_list())
{
result.push_back(recall);
}
Expand All @@ -242,7 +242,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::teams)[recaller.side()-1];
team& recall_team = (*resources::gameboard).teams()[recaller.side()-1];
scoped_recall_unit this_unit("this_unit", recall_team.save_id(),
recall_team.recall_list().find_index(recall_unit.id()));

Expand Down Expand Up @@ -418,7 +418,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 ( util::contains((*resources::teams)[side-1].recruits(), unit_type) )
if ( util::contains(resources::gameboard->teams()[side-1].recruits(), unit_type) )
check_type.clear();

// If the check location is not valid, we will never get an "OK" result.
Expand Down Expand Up @@ -582,8 +582,8 @@ namespace { // Helpers for place_recruit()
int min_dist = INT_MAX;

for ( unit_itor = units.begin(); unit_itor != units.end(); ++unit_itor ) {
if ((*resources::teams)[unit_itor->side()-1].is_enemy(new_unit.side()) &&
unit_itor->is_visible_to_team((*resources::teams)[new_unit.side()-1], *map, false)) {
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], *map, false)) {
int dist = distance_between(unit_itor->get_location(),recruit_loc) - unit_itor->level();
if (dist < min_dist) {
min_dist = dist;
Expand Down Expand Up @@ -649,7 +649,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::teams)[u->side()-1].spend_gold(cost);
resources::gameboard->teams()[u->side()-1].spend_gold(cost);

if ( show ) {
unit_display::unit_recruited(current_loc, leader_loc);
Expand Down
4 changes: 2 additions & 2 deletions src/actions/heal.cpp
Expand Up @@ -84,7 +84,7 @@ namespace {
POISON_STATUS poison_progress(int side, const unit & patient,
std::vector<unit *> & healers)
{
const std::vector<team> &teams = *resources::teams;
const std::vector<team> &teams = resources::gameboard->teams();
unit_map &units = *resources::units;

POISON_STATUS curing = POISON_NORMAL;
Expand Down Expand Up @@ -349,7 +349,7 @@ void calculate_healing(int side, bool update_display)
}

const team & viewing_team =
(*resources::teams)[resources::screen->viewing_team()];
resources::gameboard->teams()[resources::screen->viewing_team()];
if (!resources::controller->is_skipping_replay() && update_display &&
patient.is_visible_to_team(viewing_team, resources::gameboard->map(), false) )
{
Expand Down
8 changes: 4 additions & 4 deletions src/actions/move.cpp
Expand Up @@ -139,7 +139,7 @@ void move_unit_spectator::set_unit(const unit_map::const_iterator &u)

bool get_village(const map_location& loc, int side, bool *action_timebonus, bool fire_event)
{
std::vector<team> &teams = *resources::teams;
std::vector<team> &teams = resources::gameboard->teams();
team *t = unsigned(side - 1) < teams.size() ? &teams[side - 1] : nullptr;
if (t && t->owns_village(loc)) {
return false;
Expand Down Expand Up @@ -363,7 +363,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::teams)[current_side_-1]),
current_team_(&resources::gameboard->teams()[current_side_-1]),
current_uses_fog_(current_team_->fog_or_shroud() &&
current_team_->auto_shroud_updates()),
move_loc_(begin_),
Expand Down Expand Up @@ -791,7 +791,7 @@ namespace { // Private helpers for move_unit()

// Update the current unit data.
current_side_ = found ? move_it_->side() : orig_side_;
current_team_ = &(*resources::teams)[current_side_-1];
current_team_ = &resources::gameboard->teams()[current_side_-1];
current_uses_fog_ = current_team_->fog_or_shroud() &&
( current_side_ != orig_side_ ||
current_team_->auto_shroud_updates() );
Expand Down Expand Up @@ -1238,7 +1238,7 @@ size_t move_unit_and_record(const std::vector<map_location> &steps,
//if we have no fog activated then we always skip sighted
if(resources::units->find(steps.front()) != resources::units->end())
{
const team &current_team = (*resources::teams)[
const team &current_team = resources::gameboard->teams()[
resources::units->find(steps.front())->side() - 1];
continued_move |= !current_team.fog_or_shroud();
}
Expand Down
2 changes: 1 addition & 1 deletion src/actions/undo.cpp
Expand Up @@ -449,7 +449,7 @@ void undo_list::redo()
bool undo_list::apply_shroud_changes() const
{
game_display &disp = *resources::screen;
team &tm = (*resources::teams)[side_ - 1];
team &tm = resources::gameboard->teams()[side_ - 1];
// No need to do clearing if fog/shroud has been kept up-to-date.
if ( tm.auto_shroud_updates() || !tm.fog_or_shroud() ) {
return false;
Expand Down
5 changes: 3 additions & 2 deletions src/actions/undo_dismiss_action.cpp
@@ -1,3 +1,4 @@
#include "game_board.hpp"
#include "undo_dismiss_action.hpp"
#include "resources.hpp"
#include "team.hpp"
Expand All @@ -23,7 +24,7 @@ void dismiss_action::write(config & cfg) const
*/
bool dismiss_action::undo(int side)
{
team &current_team = (*resources::teams)[side-1];
team &current_team = resources::gameboard->teams()[side-1];

current_team.recall_list().add(dismissed_unit);
execute_undo_umc_wml();
Expand All @@ -36,7 +37,7 @@ bool dismiss_action::undo(int side)
*/
bool dismiss_action::redo(int side)
{
team &current_team = (*resources::teams)[side-1];
team &current_team = resources::gameboard->teams()[side-1];

resources::recorder->redo(replay_data);
replay_data.clear();
Expand Down
5 changes: 3 additions & 2 deletions src/actions/undo_recall_action.cpp
Expand Up @@ -2,6 +2,7 @@
#include "create.hpp"

#include "gui/dialogs/transient_message.hpp"
#include "game_board.hpp"
#include "resources.hpp"
#include "team.hpp"
#include "replay.hpp"
Expand Down Expand Up @@ -39,7 +40,7 @@ bool recall_action::undo(int side)
{
game_display & gui = *resources::screen;
unit_map & units = *resources::units;
team &current_team = (*resources::teams)[side-1];
team &current_team = resources::gameboard->teams()[side-1];

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

map_location loc = route.front();
map_location from = recall_from;
Expand Down
5 changes: 3 additions & 2 deletions src/actions/undo_recruit_action.cpp
Expand Up @@ -2,6 +2,7 @@
#include "create.hpp"

#include "gui/dialogs/transient_message.hpp"
#include "game_board.hpp"
#include "resources.hpp"
#include "team.hpp"
#include "replay.hpp"
Expand Down Expand Up @@ -40,7 +41,7 @@ bool recruit_action::undo(int side)
{
game_display & gui = *resources::screen;
unit_map & units = *resources::units;
team &current_team = (*resources::teams)[side-1];
team &current_team = resources::gameboard->teams()[side-1];

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

map_location loc = route.front();
map_location from = recruit_from;
Expand Down
14 changes: 7 additions & 7 deletions src/actions/vision.cpp
Expand Up @@ -82,7 +82,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::teams)[viewer.side()-1]);
create_jamming_map(local_jamming, resources::gameboard->teams()[viewer.side()-1]);
jamming = &local_jamming;
}

Expand Down Expand Up @@ -462,7 +462,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::teams)[viewer.side()-1];
team & viewing_team = resources::gameboard->teams()[viewer.side()-1];

// Abort if there is nothing to clear.
if ( !viewing_team.fog_or_shroud() )
Expand Down Expand Up @@ -494,7 +494,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::teams)[viewer.side()-1];
team & viewing_team = resources::gameboard->teams()[viewer.side()-1];
// A pair of dummy variables needed to simplify some logic.
size_t enemies, friends;

Expand Down Expand Up @@ -595,7 +595,7 @@ void shroud_clearer::invalidate_after_clear()
*/
std::vector<int> get_sides_not_seeing(const unit & target)
{
const std::vector<team> & teams = *resources::teams;
const std::vector<team> & teams = resources::gameboard->teams();
std::vector<int> not_seeing;

size_t team_size = teams.size();
Expand Down Expand Up @@ -631,7 +631,7 @@ bool actor_sighted(const unit & target, const std::vector<int> * cache)
* 5) Sides that do not use fog or shroud CAN get sighted events.
*/
{
const std::vector<team> & teams = *resources::teams;
const std::vector<team> & teams = resources::gameboard->teams();
const size_t teams_size = teams.size();
const map_location & target_loc = target.get_location();

Expand Down Expand Up @@ -704,7 +704,7 @@ bool actor_sighted(const unit & target, const std::vector<int> * cache)
*/
void recalculate_fog(int side)
{
team &tm = (*resources::teams)[side - 1];
team &tm = resources::gameboard->teams()[side - 1];

if (!tm.uses_fog())
return;
Expand Down Expand Up @@ -753,7 +753,7 @@ void recalculate_fog(int side)
*/
bool clear_shroud(int side, bool reset_fog, bool fire_events)
{
team &tm = (*resources::teams)[side - 1];
team &tm = resources::gameboard->teams()[side - 1];
if (!tm.uses_shroud() && !tm.uses_fog())
return false;

Expand Down
4 changes: 2 additions & 2 deletions src/ai/actions.cpp
Expand Up @@ -165,7 +165,7 @@ game_info& action_result::get_info() const

team& action_result::get_my_team() const
{
return (*resources::teams)[side_-1];
return resources::gameboard->teams()[side_-1];
}


Expand Down Expand Up @@ -377,7 +377,7 @@ bool move_result::test_route(const unit &un)
}

team &my_team = get_my_team();
const pathfind::shortest_path_calculator calc(un, my_team, *resources::teams, resources::gameboard->map());
const pathfind::shortest_path_calculator calc(un, my_team, resources::gameboard->teams(), resources::gameboard->map());

//allowed teleports
pathfind::teleport_map allowed_teleports = pathfind::get_teleport_locations(un, my_team, true);///@todo 1.9: see_all -> false
Expand Down
8 changes: 4 additions & 4 deletions src/ai/contexts.cpp
Expand Up @@ -107,7 +107,7 @@ void readwrite_context_impl::raise_gamestate_changed() const

team& readwrite_context_impl::current_team_w()
{
return (*resources::teams)[get_side()-1];
return resources::gameboard->teams()[get_side()-1];
}

attack_result_ptr readwrite_context_impl::execute_attack_action(const map_location& attacker_loc, const map_location& defender_loc, int attacker_weapon){
Expand Down Expand Up @@ -336,7 +336,7 @@ void readonly_context_impl::diagnostic(const std::string& msg)

const team& readonly_context_impl::current_team() const
{
return (*resources::teams)[get_side()-1];
return resources::gameboard->teams()[get_side()-1];
}


Expand Down Expand Up @@ -429,8 +429,8 @@ void readonly_context_impl::calculate_moves(const unit_map& units, std::map<map_

// Don't take friendly villages
if(!enemy && resources::gameboard->map().is_village(dst)) {
for(size_t n = 0; n != resources::teams->size(); ++n) {
if((*resources::teams)[n].owns_village(dst)) {
for(size_t n = 0; n != resources::gameboard->teams().size(); ++n) {
if(resources::gameboard->teams()[n].owns_village(dst)) {
int side = n + 1;
if (get_side() != side && !current_team().is_enemy(side)) {
friend_owns = true;
Expand Down
2 changes: 1 addition & 1 deletion src/ai/default/aspect_attacks.cpp
Expand Up @@ -147,7 +147,7 @@ void aspect_attacks_base::do_attack_analysis(
}
const gamemap &map_ = resources::gameboard->map();
unit_map &units_ = *resources::units;
std::vector<team> &teams_ = *resources::teams;
std::vector<team> &teams_ = resources::gameboard->teams();


const size_t max_positions = 1000;
Expand Down

0 comments on commit 6235e18

Please sign in to comment.