Replace resources::teams with resources::gameboard->teams()
This commit is contained in:
parent
65a8c44495
commit
6235e18bbd
62 changed files with 246 additions and 242 deletions
|
@ -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_;
|
||||
|
|
|
@ -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");
|
||||
{
|
||||
|
@ -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();
|
||||
|
|
|
@ -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";
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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()));
|
||||
|
||||
|
@ -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.
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
@ -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) )
|
||||
{
|
||||
|
|
|
@ -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;
|
||||
|
@ -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_),
|
||||
|
@ -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() );
|
||||
|
@ -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 ¤t_team = (*resources::teams)[
|
||||
const team ¤t_team = resources::gameboard->teams()[
|
||||
resources::units->find(steps.front())->side() - 1];
|
||||
continued_move |= !current_team.fog_or_shroud();
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
#include "game_board.hpp"
|
||||
#include "undo_dismiss_action.hpp"
|
||||
#include "resources.hpp"
|
||||
#include "team.hpp"
|
||||
|
@ -23,7 +24,7 @@ void dismiss_action::write(config & cfg) const
|
|||
*/
|
||||
bool dismiss_action::undo(int side)
|
||||
{
|
||||
team ¤t_team = (*resources::teams)[side-1];
|
||||
team ¤t_team = resources::gameboard->teams()[side-1];
|
||||
|
||||
current_team.recall_list().add(dismissed_unit);
|
||||
execute_undo_umc_wml();
|
||||
|
@ -36,7 +37,7 @@ bool dismiss_action::undo(int side)
|
|||
*/
|
||||
bool dismiss_action::redo(int side)
|
||||
{
|
||||
team ¤t_team = (*resources::teams)[side-1];
|
||||
team ¤t_team = resources::gameboard->teams()[side-1];
|
||||
|
||||
resources::recorder->redo(replay_data);
|
||||
replay_data.clear();
|
||||
|
|
|
@ -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"
|
||||
|
@ -39,7 +40,7 @@ bool recall_action::undo(int side)
|
|||
{
|
||||
game_display & gui = *resources::screen;
|
||||
unit_map & units = *resources::units;
|
||||
team ¤t_team = (*resources::teams)[side-1];
|
||||
team ¤t_team = resources::gameboard->teams()[side-1];
|
||||
|
||||
const map_location & recall_loc = route.front();
|
||||
unit_map::iterator un_it = units.find(recall_loc);
|
||||
|
@ -78,7 +79,7 @@ bool recall_action::undo(int side)
|
|||
bool recall_action::redo(int side)
|
||||
{
|
||||
game_display & gui = *resources::screen;
|
||||
team ¤t_team = (*resources::teams)[side-1];
|
||||
team ¤t_team = resources::gameboard->teams()[side-1];
|
||||
|
||||
map_location loc = route.front();
|
||||
map_location from = recall_from;
|
||||
|
|
|
@ -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"
|
||||
|
@ -40,7 +41,7 @@ bool recruit_action::undo(int side)
|
|||
{
|
||||
game_display & gui = *resources::screen;
|
||||
unit_map & units = *resources::units;
|
||||
team ¤t_team = (*resources::teams)[side-1];
|
||||
team ¤t_team = resources::gameboard->teams()[side-1];
|
||||
|
||||
const map_location & recruit_loc = route.front();
|
||||
unit_map::iterator un_it = units.find(recruit_loc);
|
||||
|
@ -71,7 +72,7 @@ bool recruit_action::undo(int side)
|
|||
bool recruit_action::redo(int side)
|
||||
{
|
||||
game_display & gui = *resources::screen;
|
||||
team ¤t_team = (*resources::teams)[side-1];
|
||||
team ¤t_team = resources::gameboard->teams()[side-1];
|
||||
|
||||
map_location loc = route.front();
|
||||
map_location from = recruit_from;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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() )
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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();
|
||||
|
@ -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();
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
||||
|
|
|
@ -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];
|
||||
}
|
||||
|
||||
|
||||
|
@ -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
|
||||
|
|
|
@ -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){
|
||||
|
@ -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];
|
||||
}
|
||||
|
||||
|
||||
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -84,7 +84,7 @@ double goto_phase::evaluate()
|
|||
}
|
||||
// end of passive_leader
|
||||
|
||||
const pathfind::shortest_path_calculator calc(*ui, current_team(), *resources::teams, resources::gameboard->map());
|
||||
const pathfind::shortest_path_calculator calc(*ui, current_team(), resources::gameboard->teams(), resources::gameboard->map());
|
||||
|
||||
const pathfind::teleport_map allowed_teleports = pathfind::get_teleport_locations(*ui, current_team());
|
||||
|
||||
|
@ -300,7 +300,7 @@ double move_leader_to_goals_phase::evaluate()
|
|||
}
|
||||
}
|
||||
|
||||
pathfind::shortest_path_calculator calc(*leader, current_team(), *resources::teams, resources::gameboard->map());
|
||||
pathfind::shortest_path_calculator calc(*leader, current_team(), resources::gameboard->teams(), resources::gameboard->map());
|
||||
pathfind::plain_route route = a_star_search(leader->get_location(), dst_, 1000.0, &calc,
|
||||
resources::gameboard->map().w(), resources::gameboard->map().h());
|
||||
if(route.steps.empty()) {
|
||||
|
@ -415,7 +415,7 @@ double move_leader_to_keep_phase::evaluate()
|
|||
continue;
|
||||
}
|
||||
|
||||
const pathfind::shortest_path_calculator calc(*leader, current_team(), *resources::teams, resources::gameboard->map());
|
||||
const pathfind::shortest_path_calculator calc(*leader, current_team(), resources::gameboard->teams(), resources::gameboard->map());
|
||||
|
||||
const pathfind::teleport_map allowed_teleports = pathfind::get_teleport_locations(*leader, current_team());
|
||||
|
||||
|
@ -437,7 +437,7 @@ double move_leader_to_keep_phase::evaluate()
|
|||
const unit* leader = best_leader;
|
||||
const map_location keep = best_keep;
|
||||
const pathfind::paths leader_paths(*leader, false, true, current_team());
|
||||
const pathfind::shortest_path_calculator calc(*leader, current_team(), *resources::teams, resources::gameboard->map());
|
||||
const pathfind::shortest_path_calculator calc(*leader, current_team(), resources::gameboard->teams(), resources::gameboard->map());
|
||||
const pathfind::teleport_map allowed_teleports = pathfind::get_teleport_locations(*leader, current_team());
|
||||
|
||||
if (leader_paths.destinations.contains(keep) && units_.count(keep) == 0) {
|
||||
|
@ -659,7 +659,7 @@ void get_villages_phase::find_villages(
|
|||
|
||||
size_t min_distance = 100000;
|
||||
const gamemap &map_ = resources::gameboard->map();
|
||||
std::vector<team> &teams_ = *resources::teams;
|
||||
std::vector<team> &teams_ = resources::gameboard->teams();
|
||||
|
||||
// When a unit is dispatched we need to make sure we don't
|
||||
// dispatch this unit a second time, so store them here.
|
||||
|
@ -1598,7 +1598,7 @@ double leader_shares_keep_phase::evaluate()
|
|||
return BAD_SCORE;
|
||||
}
|
||||
bool allied_leaders_available = false;
|
||||
for(team &tmp_team : *resources::teams) {
|
||||
for(team &tmp_team : resources::gameboard->teams()) {
|
||||
if(!current_team().is_enemy(tmp_team.side())){
|
||||
std::vector<unit_map::unit_iterator> allied_leaders = resources::units->find_leaders(get_side());
|
||||
if (!allied_leaders.empty()){
|
||||
|
@ -1640,7 +1640,7 @@ void leader_shares_keep_phase::execute()
|
|||
//for each leader, check if he's allied and can reach our keep
|
||||
for(path_map::const_iterator i = possible_moves.begin(); i != possible_moves.end(); ++i){
|
||||
const unit_map::const_iterator itor = resources::units->find(i->first);
|
||||
team &leader_team = (*resources::teams)[itor->side() - 1];
|
||||
team &leader_team = resources::gameboard->teams()[itor->side() - 1];
|
||||
if(itor != resources::units->end() && itor->can_recruit() && itor->side() != get_side() && (leader_team.total_income() + leader_team.gold() > leader_team.minimum_recruit_price())){
|
||||
pathfind::paths::dest_vect::const_iterator tokeep = i->second.destinations.find(keep);
|
||||
if(tokeep != i->second.destinations.end()){
|
||||
|
|
|
@ -636,7 +636,7 @@ void move_to_targets_phase::access_points(const move_map& srcdst, const map_loca
|
|||
for(move_map::const_iterator i = locs.first; i != locs.second; ++i) {
|
||||
const map_location& loc = i->second;
|
||||
if (int(distance_between(loc,dst)) <= u_it->total_movement()) {
|
||||
pathfind::shortest_path_calculator calc(*u_it, current_team(), *resources::teams, map_);
|
||||
pathfind::shortest_path_calculator calc(*u_it, current_team(), resources::gameboard->teams(), map_);
|
||||
const pathfind::teleport_map allowed_teleports = pathfind::get_teleport_locations(*u_it, current_team());
|
||||
pathfind::plain_route rt = a_star_search(loc, dst, u_it->total_movement(), &calc, map_.w(), map_.h(), &allowed_teleports);
|
||||
if(rt.steps.empty() == false) {
|
||||
|
|
|
@ -82,7 +82,7 @@ int default_ai_context_impl::count_free_hexes_in_castle(const map_location &loc,
|
|||
if (u == units_.end()
|
||||
|| (current_team().is_enemy(u->side())
|
||||
&& u->invisible(adj[n]))
|
||||
|| ((&(*resources::teams)[u->side() - 1]) == ¤t_team()
|
||||
|| ((&resources::gameboard->teams()[u->side() - 1]) == ¤t_team()
|
||||
&& u->movement_left() > 0)) {
|
||||
ret += 1;
|
||||
}
|
||||
|
@ -135,7 +135,7 @@ std::vector<target> default_ai_context_impl::find_targets(const move_map& enemy_
|
|||
unit_map &units_ = *resources::units;
|
||||
unit_map::iterator leader = units_.find_leader(get_side());
|
||||
const gamemap &map_ = resources::gameboard->map();
|
||||
std::vector<team> teams_ = *resources::teams;
|
||||
std::vector<team> teams_ = resources::gameboard->teams();
|
||||
const bool has_leader = leader != units_.end();
|
||||
|
||||
std::vector<target> targets;
|
||||
|
|
|
@ -677,7 +677,7 @@ double recruitment::get_average_defense(const std::string& u_type) const {
|
|||
*/
|
||||
const pathfind::full_cost_map recruitment::get_cost_map_of_side(int side) const {
|
||||
const unit_map& units = *resources::units;
|
||||
const team& team = (*resources::teams)[side - 1];
|
||||
const team& team = resources::gameboard->teams()[side - 1];
|
||||
|
||||
pathfind::full_cost_map cost_map(true, true, team, true, true);
|
||||
|
||||
|
@ -748,7 +748,7 @@ void recruitment::update_average_lawful_bonus() {
|
|||
void recruitment::update_average_local_cost() {
|
||||
average_local_cost_.clear();
|
||||
const gamemap& map = resources::gameboard->map();
|
||||
const team& team = (*resources::teams)[get_side() - 1];
|
||||
const team& team = resources::gameboard->teams()[get_side() - 1];
|
||||
|
||||
for(int x = 0; x < map.w(); ++x) {
|
||||
for (int y = 0; y < map.h(); ++y) {
|
||||
|
@ -810,7 +810,7 @@ void recruitment::update_important_hexes() {
|
|||
// The important hexes are those where my value on the cost map is
|
||||
// similar to a enemies one.
|
||||
const pathfind::full_cost_map my_cost_map = get_cost_map_of_side(get_side());
|
||||
for (const team& team : *resources::teams) {
|
||||
for (const team& team : resources::gameboard->teams()) {
|
||||
if (current_team().is_enemy(team.side())) {
|
||||
const pathfind::full_cost_map enemy_cost_map = get_cost_map_of_side(team.side());
|
||||
|
||||
|
@ -932,7 +932,7 @@ void recruitment::do_combat_analysis(std::vector<data>* leader_data) {
|
|||
}
|
||||
if (enemy_units.size() < UNIT_THRESHOLD) {
|
||||
// Use also enemies recruitment lists and insert units into enemy_units.
|
||||
for (const team& team : *resources::teams) {
|
||||
for (const team& team : resources::gameboard->teams()) {
|
||||
if (!current_team().is_enemy(team.side())) {
|
||||
continue;
|
||||
}
|
||||
|
@ -1411,7 +1411,7 @@ bool recruitment::remove_job_if_no_blocker(config* job) {
|
|||
* positive or negative.
|
||||
*/
|
||||
double recruitment::get_estimated_income(int turns) const {
|
||||
const team& team = (*resources::teams)[get_side() - 1];
|
||||
const team& team = resources::gameboard->teams()[get_side() - 1];
|
||||
const size_t own_villages = team.villages().size();
|
||||
const double village_gain = get_estimated_village_gain();
|
||||
const double unit_gain = get_estimated_unit_gain();
|
||||
|
@ -1447,7 +1447,7 @@ double recruitment::get_estimated_village_gain() const {
|
|||
++neutral_villages;
|
||||
}
|
||||
}
|
||||
return (neutral_villages / resources::teams->size()) / 4.;
|
||||
return (neutral_villages / resources::gameboard->teams().size()) / 4.;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1474,7 +1474,7 @@ double recruitment::get_unit_ratio() const {
|
|||
}
|
||||
}
|
||||
int allies_count = 0;
|
||||
for (const team& team : *resources::teams) {
|
||||
for (const team& team : resources::gameboard->teams()) {
|
||||
if (!current_team().is_enemy(team.side())) {
|
||||
++allies_count;
|
||||
}
|
||||
|
@ -1712,7 +1712,7 @@ void recruitment::update_scouts_wanted() {
|
|||
++neutral_villages;
|
||||
}
|
||||
}
|
||||
double our_share = static_cast<double>(neutral_villages) / resources::teams->size();
|
||||
double our_share = static_cast<double>(neutral_villages) / resources::gameboard->teams().size();
|
||||
|
||||
// The villages per scout is for a two-side battle,
|
||||
// accounting for all neutral villages on the map.
|
||||
|
|
|
@ -211,7 +211,7 @@ pathfind::plain_route formula_ai::shortest_path_calculator(const map_location &s
|
|||
map_location destination = dst;
|
||||
|
||||
unit_map &units_ = *resources::units;
|
||||
pathfind::shortest_path_calculator calc(*unit_it, current_team(), *resources::teams, resources::gameboard->map());
|
||||
pathfind::shortest_path_calculator calc(*unit_it, current_team(), resources::gameboard->teams(), resources::gameboard->map());
|
||||
|
||||
unit_map::const_iterator dst_un = units_.find(destination);
|
||||
|
||||
|
@ -660,7 +660,7 @@ variant formula_ai::get_value(const std::string& key) const
|
|||
|
||||
} else if(key == "my_side")
|
||||
{
|
||||
return variant(new team_callable((*resources::teams)[get_side()-1]));
|
||||
return variant(new team_callable(resources::gameboard->teams()[get_side()-1]));
|
||||
|
||||
} else if(key == "my_side_number")
|
||||
{
|
||||
|
@ -669,7 +669,7 @@ variant formula_ai::get_value(const std::string& key) const
|
|||
} else if(key == "teams")
|
||||
{
|
||||
std::vector<variant> vars;
|
||||
for(std::vector<team>::const_iterator i = resources::teams->begin(); i != resources::teams->end(); ++i) {
|
||||
for(std::vector<team>::const_iterator i = resources::gameboard->teams().begin(); i != resources::gameboard->teams().end(); ++i) {
|
||||
vars.push_back(variant(new team_callable(*i)));
|
||||
}
|
||||
return variant(&vars);
|
||||
|
@ -677,7 +677,7 @@ variant formula_ai::get_value(const std::string& key) const
|
|||
} else if(key == "allies")
|
||||
{
|
||||
std::vector<variant> vars;
|
||||
for( size_t i = 0; i < resources::teams->size(); ++i) {
|
||||
for( size_t i = 0; i < resources::gameboard->teams().size(); ++i) {
|
||||
if ( !current_team().is_enemy( i+1 ) )
|
||||
vars.push_back(variant( i ));
|
||||
}
|
||||
|
@ -686,7 +686,7 @@ variant formula_ai::get_value(const std::string& key) const
|
|||
} else if(key == "enemies")
|
||||
{
|
||||
std::vector<variant> vars;
|
||||
for( size_t i = 0; i < resources::teams->size(); ++i) {
|
||||
for( size_t i = 0; i < resources::gameboard->teams().size(); ++i) {
|
||||
if ( current_team().is_enemy( i+1 ) )
|
||||
vars.push_back(variant( i ));
|
||||
}
|
||||
|
@ -719,12 +719,12 @@ variant formula_ai::get_value(const std::string& key) const
|
|||
|
||||
unit_types.build_all(unit_type::FULL);
|
||||
|
||||
for( size_t i = 0; i<resources::teams->size(); ++i)
|
||||
for( size_t i = 0; i<resources::gameboard->teams().size(); ++i)
|
||||
{
|
||||
std::vector<variant> v;
|
||||
tmp.push_back( v );
|
||||
|
||||
const std::set<std::string>& recruits = (*resources::teams)[i].recruits();
|
||||
const std::set<std::string>& recruits = resources::gameboard->teams()[i].recruits();
|
||||
if(recruits.empty()) {
|
||||
continue;
|
||||
}
|
||||
|
@ -754,7 +754,7 @@ variant formula_ai::get_value(const std::string& key) const
|
|||
{
|
||||
std::vector<variant> vars;
|
||||
std::vector< std::vector< variant> > tmp;
|
||||
for( size_t i = 0; i<resources::teams->size(); ++i)
|
||||
for( size_t i = 0; i<resources::gameboard->teams().size(); ++i)
|
||||
{
|
||||
std::vector<variant> v;
|
||||
tmp.push_back( v );
|
||||
|
@ -832,13 +832,13 @@ variant formula_ai::get_value(const std::string& key) const
|
|||
} else if(key == "villages_of_side")
|
||||
{
|
||||
std::vector<variant> vars;
|
||||
for(size_t i = 0; i<resources::teams->size(); ++i)
|
||||
for(size_t i = 0; i<resources::gameboard->teams().size(); ++i)
|
||||
{
|
||||
vars.push_back( variant() );
|
||||
}
|
||||
for(size_t i = 0; i<vars.size(); ++i)
|
||||
{
|
||||
vars[i] = villages_from_set((*resources::teams)[i].villages());
|
||||
vars[i] = villages_from_set(resources::gameboard->teams()[i].villages());
|
||||
}
|
||||
return variant(&vars);
|
||||
|
||||
|
|
|
@ -280,7 +280,7 @@ private:
|
|||
// for(unit_map::const_iterator i = resources::units->begin(); i != resources::units->end(); ++i) {
|
||||
// unit_counter[i->second.side()-1]++;
|
||||
// unit_adapter unit(i->second);
|
||||
// find_movemap( resources::gameboard->map(), *resources::units, unit, i->first, scores[i->second.side()-1], ai_.*resources::teams , true );
|
||||
// find_movemap( resources::gameboard->map(), *resources::units, unit, i->first, scores[i->second.side()-1], ai_.resources::gameboard->teams() , true );
|
||||
// }
|
||||
|
||||
for(size_t side = 0 ; side < units_input.num_elements() ; ++side) {
|
||||
|
|
|
@ -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::teams)[side-1];
|
||||
team own_team = resources::gameboard->teams()[side-1];
|
||||
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::teams)[side-1].spend_gold(u->cost());
|
||||
resources::gameboard->teams()[side-1].spend_gold(u->cost());
|
||||
|
||||
LOG_AI_SIM_ACTIONS << "recruit " << u->type_name() << " at "
|
||||
<< recruit_location << " spend " << u->cost() << " gold" << std::endl;
|
||||
|
@ -178,7 +178,7 @@ bool simulated_synced_command(){
|
|||
|
||||
// Helper functions.
|
||||
void helper_check_village(const map_location& loc, int side){
|
||||
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;
|
||||
|
|
|
@ -45,7 +45,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::teams)[side-1];
|
||||
team& current_team = resources::gameboard->teams()[side-1];
|
||||
|
||||
int _turn_number = resources::tod_manager->turn();
|
||||
int _units = resources::gameboard->side_units(side);
|
||||
|
@ -89,8 +89,8 @@ void ai_testing::log_victory(std::set<unsigned int> winners)
|
|||
|
||||
void ai_testing::log_game_start()
|
||||
{
|
||||
for (std::vector<team>::const_iterator tm = resources::teams->begin(); tm != resources::teams->end(); ++tm) {
|
||||
int side = tm-resources::teams->begin()+1;
|
||||
for (std::vector<team>::const_iterator tm = resources::gameboard->teams().begin(); tm != resources::gameboard->teams().end(); ++tm) {
|
||||
int side = tm-resources::gameboard->teams().begin()+1;
|
||||
LOG_AI_TESTING << "AI_IDENTIFIER"<<side<<": " << ai::manager::get_active_ai_identifier_for_side(side) <<std::endl;
|
||||
LOG_AI_TESTING << "TEAM"<<side<<": " << tm->side() << std::endl;
|
||||
resources::recorder->add_log_data("ai_log","ai_id"+std::to_string(side),ai::manager::get_active_ai_identifier_for_side(side));
|
||||
|
@ -105,8 +105,8 @@ void ai_testing::log_game_end()
|
|||
LOG_AI_TESTING << "GAME_END_TURN: "<< resources::tod_manager->turn() <<std::endl;
|
||||
resources::recorder->add_log_data("ai_log","end_turn",
|
||||
std::to_string(resources::tod_manager->turn()));
|
||||
for (std::vector<team>::const_iterator tm = resources::teams->begin(); tm != resources::teams->end(); ++tm) {
|
||||
int side = tm-resources::teams->begin()+1;
|
||||
for (std::vector<team>::const_iterator tm = resources::gameboard->teams().begin(); tm != resources::gameboard->teams().end(); ++tm) {
|
||||
int side = tm-resources::gameboard->teams().begin()+1;
|
||||
resources::recorder->add_log_data("ai_log","end_gold"+std::to_string(side),std::to_string(tm->gold()));
|
||||
resources::recorder->add_log_data("ai_log","end_units"+std::to_string(side),std::to_string(resources::gameboard->side_units(side)));
|
||||
}
|
||||
|
|
|
@ -108,7 +108,7 @@ void editor_action_item_replace::perform_without_undo(map_context& /*mc*/) const
|
|||
//
|
||||
// /* @todo
|
||||
// if (mc.get_map().is_village(new_loc_)) {
|
||||
// (*(resources::teams))[u.side()].get_village(new_loc_);
|
||||
// (*(resources::gameboard->teams()))[u.side()].get_village(new_loc_);
|
||||
// }
|
||||
// */
|
||||
//
|
||||
|
|
|
@ -107,7 +107,7 @@ void editor_action_unit_replace::perform_without_undo(map_context& mc) const
|
|||
|
||||
/* @todo
|
||||
if (mc.get_map().is_village(new_loc_)) {
|
||||
(*(resources::teams))[u.side()].get_village(new_loc_);
|
||||
(*(resources::gameboard->teams()))[u.side()].get_village(new_loc_);
|
||||
}
|
||||
*/
|
||||
|
||||
|
|
|
@ -42,6 +42,7 @@
|
|||
#include "reports.hpp"
|
||||
|
||||
#include "desktop/clipboard.hpp"
|
||||
#include "game_board.hpp"
|
||||
#include "game_preferences.hpp"
|
||||
#include "gettext.hpp"
|
||||
#include "preferences_display.hpp"
|
||||
|
@ -161,7 +162,7 @@ editor_controller::~editor_controller()
|
|||
{
|
||||
resources::units = nullptr;
|
||||
resources::tod_manager = nullptr;
|
||||
resources::teams = nullptr;
|
||||
resources::gameboard = nullptr;
|
||||
|
||||
resources::classification = nullptr;
|
||||
resources::mp_settings = nullptr;
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#include "filesystem.hpp"
|
||||
#include "filechooser.hpp"
|
||||
#include "formula/string_utils.hpp"
|
||||
#include "game_board.hpp"
|
||||
#include "gettext.hpp"
|
||||
#include "generators/map_create.hpp"
|
||||
#include "generators/map_generator.hpp"
|
||||
|
@ -76,7 +77,7 @@ public:
|
|||
context_manager_.gui().change_display_context(&context_manager_.get_map_context());
|
||||
|
||||
resources::units = &context_manager_.get_map_context().get_units();
|
||||
resources::teams = &context_manager_.get_map_context().get_teams();
|
||||
resources::gameboard->teams() = context_manager_.get_map_context().get_teams();
|
||||
|
||||
// TODO register the tod_manager with the gui?
|
||||
resources::tod_manager = context_manager_.get_map_context().get_time_manager();
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include "config_assign.hpp"
|
||||
#include "display.hpp"
|
||||
#include "filesystem.hpp"
|
||||
#include "game_board.hpp"
|
||||
#include "gettext.hpp"
|
||||
#include "map/exception.hpp"
|
||||
#include "map/label.hpp"
|
||||
|
@ -302,7 +303,7 @@ void map_context::load_scenario(const config& game_config)
|
|||
music_tracks_.insert(std::pair<std::string, sound::music_track>(music["name"], sound::music_track(music)));
|
||||
}
|
||||
|
||||
resources::teams = &teams_;
|
||||
resources::gameboard->teams() = teams_;
|
||||
|
||||
int i = 1;
|
||||
for(config &side : scenario.child_range("side"))
|
||||
|
|
|
@ -93,6 +93,7 @@ public:
|
|||
virtual ~game_board();
|
||||
|
||||
virtual const std::vector<team> & teams() const { return teams_; }
|
||||
virtual std::vector<team> & teams() { return teams_; }
|
||||
virtual const gamemap & map() const { return *map_; }
|
||||
virtual const unit_map & units() const { return units_; }
|
||||
unit_map & units() { return units_; }
|
||||
|
|
|
@ -117,7 +117,7 @@ namespace { // Support functions
|
|||
std::string img_mods = cfg["image_mods"];
|
||||
|
||||
size_t side_num = cfg["side"].to_int(1);
|
||||
if ( side_num == 0 || side_num > resources::teams->size() )
|
||||
if ( side_num == 0 || side_num > resources::gameboard->teams().size() )
|
||||
side_num = 1;
|
||||
|
||||
unit_race::GENDER gender = string_gender(cfg["gender"]);
|
||||
|
@ -167,8 +167,8 @@ namespace { // Support functions
|
|||
continue;
|
||||
}
|
||||
pathfind::shortest_path_calculator calc(fake_unit,
|
||||
(*resources::teams)[fake_unit.side()-1],
|
||||
*resources::teams,
|
||||
resources::gameboard->teams()[fake_unit.side()-1],
|
||||
resources::gameboard->teams(),
|
||||
*game_map);
|
||||
|
||||
try {
|
||||
|
@ -442,17 +442,17 @@ WML_HANDLER_FUNCTION(recall,, cfg)
|
|||
vconfig unit_filter_cfg(temp_config);
|
||||
const vconfig & leader_filter = cfg.child("secondary_unit");
|
||||
|
||||
for(int index = 0; index < int(resources::teams->size()); ++index) {
|
||||
for(int index = 0; index < int(resources::gameboard->teams().size()); ++index) {
|
||||
LOG_NG << "for side " << index + 1 << "...\n";
|
||||
const std::string player_id = (*resources::teams)[index].save_id();
|
||||
const std::string player_id = resources::gameboard->teams()[index].save_id();
|
||||
|
||||
if((*resources::teams)[index].recall_list().size() < 1) {
|
||||
if(resources::gameboard->teams()[index].recall_list().size() < 1) {
|
||||
DBG_NG << "recall list is empty when trying to recall!\n"
|
||||
<< "player_id: " << player_id << " side: " << index+1 << "\n";
|
||||
continue;
|
||||
}
|
||||
|
||||
recall_list_manager & avail = (*resources::teams)[index].recall_list();
|
||||
recall_list_manager & avail = resources::gameboard->teams()[index].recall_list();
|
||||
std::vector<unit_map::unit_iterator> leaders = resources::units->find_leaders(index + 1);
|
||||
|
||||
const unit_filter ufilt(unit_filter_cfg, resources::filter_con);
|
||||
|
@ -901,12 +901,12 @@ WML_HANDLER_FUNCTION(unit,, cfg)
|
|||
int side = parsed_cfg["side"].to_int(1);
|
||||
|
||||
|
||||
if ((side<1)||(side > static_cast<int>(resources::teams->size()))) {
|
||||
ERR_NG << "wrong side in [unit] tag - no such side: "<<side<<" ( number of teams :"<<resources::teams->size()<<")"<<std::endl;
|
||||
if ((side<1)||(side > static_cast<int>(resources::gameboard->teams().size()))) {
|
||||
ERR_NG << "wrong side in [unit] tag - no such side: "<<side<<" ( number of teams :"<<resources::gameboard->teams().size()<<")"<<std::endl;
|
||||
DBG_NG << parsed_cfg.debug();
|
||||
return;
|
||||
}
|
||||
team &tm = resources::teams->at(side-1);
|
||||
team &tm = resources::gameboard->teams().at(side-1);
|
||||
|
||||
unit_creator uc(tm,resources::gameboard->map().starting_position(side));
|
||||
|
||||
|
|
|
@ -66,7 +66,7 @@ namespace builtin_conditions {
|
|||
}
|
||||
if(cfg["search_recall_list"].to_bool()) {
|
||||
const unit_filter ufilt(cfg, resources::filter_con);
|
||||
for(const team& team : *resources::teams) {
|
||||
for(const team& team : resources::gameboard->teams()) {
|
||||
if(counts == default_counts && match_count) {
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -120,12 +120,12 @@ void campaign_controller::report_victory(
|
|||
|
||||
void campaign_controller::show_carryover_message(playsingle_controller& playcontroller, const end_level_data& end_level, const LEVEL_RESULT res)
|
||||
{
|
||||
assert(resources::teams);
|
||||
assert(resources::gameboard);
|
||||
|
||||
bool has_next_scenario = !resources::gamedata->next_scenario().empty() &&
|
||||
resources::gamedata->next_scenario() != "null";
|
||||
//maybe this can be the case for scenario that only contain a story and end during the prestart event ?
|
||||
if(resources::teams->size() < 1){
|
||||
if(resources::gameboard->teams().size() < 1){
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -145,7 +145,7 @@ void campaign_controller::show_carryover_message(playsingle_controller& playcont
|
|||
}
|
||||
|
||||
//We need to write the carryover amount to the team thats why we need non const
|
||||
std::vector<team>& teams = *resources::teams;
|
||||
std::vector<team>& teams = resources::gameboard->teams();
|
||||
int persistent_teams = 0;
|
||||
for (const team &t : teams) {
|
||||
if (t.persistent()){
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
#include "game_events/manager.hpp"
|
||||
#include "serialization/parser.hpp" // for write()
|
||||
|
||||
#include "game_board.hpp"
|
||||
#include "game_data.hpp"
|
||||
#include "recall_list_manager.hpp"
|
||||
#include "resources.hpp"
|
||||
|
@ -559,8 +560,8 @@ public:
|
|||
}
|
||||
|
||||
if(selected == 0) {
|
||||
config c = resources::teams
|
||||
? resources::teams->at(side_ - 1).to_config()
|
||||
config c = resources::gameboard
|
||||
? resources::gameboard->teams().at(side_ - 1).to_config()
|
||||
: config();
|
||||
c.clear_children("ai", "village");
|
||||
model_.set_inspect_window_text(config_to_string(c));
|
||||
|
@ -595,8 +596,8 @@ public:
|
|||
|
||||
if(selected == 6) {
|
||||
std::stringstream s;
|
||||
if (resources::teams) {
|
||||
for(const auto & u : resources::teams->at(side_ - 1).recall_list())
|
||||
if (resources::gameboard) {
|
||||
for(const auto & u : resources::gameboard->teams().at(side_ - 1).recall_list())
|
||||
{
|
||||
s << "id=\"" << u->id() << "\" (" << u->type_id() << ")\nL"
|
||||
<< u->level() << "; " << u->experience() << "/"
|
||||
|
@ -615,8 +616,8 @@ public:
|
|||
|
||||
if(selected == 7) {
|
||||
config c;
|
||||
if (resources::teams) {
|
||||
for(const auto & u : resources::teams->at(side_ - 1).recall_list())
|
||||
if (resources::gameboard) {
|
||||
for(const auto & u : resources::gameboard->teams().at(side_ - 1).recall_list())
|
||||
{
|
||||
config c_unit;
|
||||
u->write(c_unit);
|
||||
|
@ -694,8 +695,8 @@ public:
|
|||
sm_controllers_.push_back(std::make_shared<unit_mode_controller>
|
||||
("units", model_));
|
||||
// BOOST_FOREACHteam
|
||||
int sides = resources::teams
|
||||
? static_cast<int>((*resources::teams).size())
|
||||
int sides = resources::gameboard
|
||||
? static_cast<int>(resources::gameboard->teams().size())
|
||||
: 0;
|
||||
for(int side = 1; side <= sides; ++side) {
|
||||
std::string side_str = std::to_string(side);
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
#include "gui/widgets/window.hpp"
|
||||
|
||||
#include "formula/string_utils.hpp"
|
||||
#include "game_board.hpp"
|
||||
#include "game_display.hpp"
|
||||
#include "game_preferences.hpp"
|
||||
#include "log.hpp"
|
||||
|
@ -172,8 +173,8 @@ public:
|
|||
model_.clear_nicks();
|
||||
|
||||
std::set<std::string> nicks;
|
||||
for(std::vector<team>::const_iterator it = resources::teams->begin();
|
||||
it != resources::teams->end();
|
||||
for(std::vector<team>::const_iterator it = resources::gameboard->teams().begin();
|
||||
it != resources::gameboard->teams().end();
|
||||
++it) {
|
||||
if(!it->is_local_ai() && !it->is_network_ai() && !it->is_idle()
|
||||
&& !it->is_empty() && !it->current_player().empty())
|
||||
|
@ -192,8 +193,8 @@ public:
|
|||
|
||||
for(const auto & nick : nicks)
|
||||
{
|
||||
if(side_number_ <= static_cast<int>(resources::teams->size())
|
||||
&& resources::teams->at(side_number_ - 1).current_player()
|
||||
if(side_number_ <= static_cast<int>(resources::gameboard->teams().size())
|
||||
&& resources::gameboard->teams().at(side_number_ - 1).current_player()
|
||||
== nick) {
|
||||
std::string label_str = "<b>" + nick + "</b>";
|
||||
model_.add_nick(nick, label_str);
|
||||
|
@ -239,11 +240,11 @@ public:
|
|||
{
|
||||
DBG_GUI << "Sides list: filling\n";
|
||||
model_.clear_sides();
|
||||
int sides = resources::teams
|
||||
? static_cast<int>((*resources::teams).size())
|
||||
int sides = resources::gameboard
|
||||
? static_cast<int>(resources::gameboard->teams().size())
|
||||
: 0;
|
||||
for(int side = 1; side <= sides; ++side) {
|
||||
if(!resources::teams->at(side - 1).hidden()) {
|
||||
if(!resources::gameboard->teams().at(side - 1).hidden()) {
|
||||
string_map symbols;
|
||||
symbols["side"] = std::to_string(side);
|
||||
std::string side_str = vgettext("Side $side", symbols);
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
#include "gui/widgets/window.hpp"
|
||||
#include "marked-up_text.hpp"
|
||||
#include "help/help.hpp"
|
||||
#include "game_board.hpp"
|
||||
#include "gettext.hpp"
|
||||
#include "replay_helper.hpp"
|
||||
#include "resources.hpp"
|
||||
|
@ -113,14 +114,14 @@ static std::string format_cost_string(int unit_recall_cost, const int team_recal
|
|||
|
||||
static std::string get_title_suffix(int side_num)
|
||||
{
|
||||
if(!resources::teams || !resources::units) {
|
||||
if(!resources::gameboard || !resources::units) {
|
||||
return "";
|
||||
}
|
||||
|
||||
unit_map& units = *resources::units;
|
||||
|
||||
int controlled_recruiters = 0;
|
||||
for(const auto& team : *resources::teams) {
|
||||
for(const auto& team : resources::gameboard->teams()) {
|
||||
if(team.is_local_human() && !team.recruits().empty() && units.find_leader(team.side()) !=units.end()) {
|
||||
++controlled_recruiters;
|
||||
}
|
||||
|
|
|
@ -298,7 +298,7 @@ const std::vector<std::string>& map_labels::all_categories() const {
|
|||
categories_dirty = false;
|
||||
categories.clear();
|
||||
categories.push_back("team");
|
||||
for(size_t i = 1; i <= resources::teams->size(); i++) {
|
||||
for(size_t i = 1; i <= resources::gameboard->teams().size(); i++) {
|
||||
categories.push_back("side:" + std::to_string(i));
|
||||
}
|
||||
std::set<std::string> unique_cats;
|
||||
|
|
|
@ -1450,8 +1450,8 @@ void console_handler::do_control() {
|
|||
try {
|
||||
side_num = lexical_cast<unsigned int>(side);
|
||||
} catch(bad_lexical_cast&) {
|
||||
std::vector<team>::const_iterator it_t = boost::find_if(*resources::teams, save_id_matches(side));
|
||||
if(it_t == resources::teams->end()) {
|
||||
std::vector<team>::const_iterator it_t = boost::find_if(resources::gameboard->teams(), save_id_matches(side));
|
||||
if(it_t == resources::gameboard->teams().end()) {
|
||||
utils::string_map symbols;
|
||||
symbols["side"] = side;
|
||||
command_failed(vgettext("Can't change control of invalid side: '$side'.", symbols));
|
||||
|
|
|
@ -121,7 +121,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::teams)[leader.side()-1]);
|
||||
nullptr, &resources::gameboard->teams()[leader.side()-1]);
|
||||
}
|
||||
|
||||
|
||||
|
@ -279,7 +279,7 @@ static void find_routes(
|
|||
// When see_all is true, the viewing team never matters, but we still
|
||||
// need to supply one to some functions.
|
||||
if ( viewing_team == nullptr )
|
||||
viewing_team = &resources::teams->front();
|
||||
viewing_team = &resources::gameboard->teams().front();
|
||||
|
||||
// Build a teleport map, if needed.
|
||||
const teleport_map teleports = teleporter ?
|
||||
|
@ -530,7 +530,7 @@ paths::paths(const unit& u, bool force_ignore_zoc,
|
|||
int additional_turns, bool see_all, bool ignore_units)
|
||||
: destinations()
|
||||
{
|
||||
std::vector<team> const &teams = *resources::teams;
|
||||
std::vector<team> const &teams = resources::gameboard->teams();
|
||||
if (u.side() < 1 || u.side() > int(teams.size())) {
|
||||
return;
|
||||
}
|
||||
|
@ -642,7 +642,7 @@ marked_route mark_route(const plain_route &rt)
|
|||
|
||||
int turns = 0;
|
||||
int movement = u.movement_left();
|
||||
const team& unit_team = (*resources::teams)[u.side()-1];
|
||||
const team& unit_team = resources::gameboard->teams()[u.side()-1];
|
||||
bool zoc = false;
|
||||
|
||||
std::vector<map_location>::const_iterator i = rt.steps.begin();
|
||||
|
@ -654,7 +654,7 @@ marked_route mark_route(const plain_route &rt)
|
|||
assert(last_step || resources::gameboard->map().on_board(*(i+1)));
|
||||
const int move_cost = last_step ? 0 : u.movement_cost((resources::gameboard->map())[*(i+1)]);
|
||||
|
||||
team const& viewing_team = (*resources::teams)[resources::screen->viewing_team()];
|
||||
team const& viewing_team = resources::gameboard->teams()[resources::screen->viewing_team()];
|
||||
|
||||
if (last_step || zoc || move_cost > movement) {
|
||||
// check if we stop an a village and so maybe capture it
|
||||
|
@ -878,7 +878,7 @@ full_cost_map::full_cost_map(bool force_ignore_zoc,
|
|||
*/
|
||||
void full_cost_map::add_unit(const unit& u, bool use_max_moves)
|
||||
{
|
||||
std::vector<team> const &teams = *resources::teams;
|
||||
std::vector<team> const &teams = resources::gameboard->teams();
|
||||
if (u.side() < 1 || u.side() > int(teams.size())) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -140,7 +140,7 @@ void verify_and_get_global_variable(const vconfig &pcfg)
|
|||
DBG_PERSIST << "verify_and_get_global_variable with from_global=" << pcfg["from_global"] << " from side " << pcfg["side"] << "\n";
|
||||
config::attribute_value pcfg_side = pcfg["side"];
|
||||
int side = (pcfg_side.str() == "global" || pcfg_side.empty()) ? resources::controller->current_side() : pcfg_side.to_int();
|
||||
if (unsigned (side - 1) >= resources::teams->size()) {
|
||||
if (unsigned (side - 1) >= resources::gameboard->teams().size()) {
|
||||
ERR_PERSIST << "[get_global_variable] attribute \"side\" specifies invalid side number." << "\n";
|
||||
valid = false;
|
||||
}
|
||||
|
@ -177,15 +177,15 @@ void verify_and_set_global_variable(const vconfig &pcfg)
|
|||
//Check side matching only if the side is not "global" or empty.
|
||||
if (pcfg_side.str() != "global" && !pcfg_side.empty()) {
|
||||
//Ensure that the side is valid.
|
||||
if (unsigned(side-1) > resources::teams->size()) {
|
||||
if (unsigned(side-1) > resources::gameboard->teams().size()) {
|
||||
ERR_PERSIST << "[set_global_variable] attribute \"side\" specifies invalid side number.";
|
||||
valid = false;
|
||||
} else if ((*resources::teams)[side - 1].is_empty()) {
|
||||
} else if (resources::gameboard->teams()[side - 1].is_empty()) {
|
||||
LOG_PERSIST << "[set_global_variable] attribute \"side\" specifies a null-controlled side number.";
|
||||
valid = false;
|
||||
} else {
|
||||
//Set the variable only if it is meant for a side we control
|
||||
valid = (*resources::teams)[side - 1].is_local();
|
||||
valid = resources::gameboard->teams()[side - 1].is_local();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -216,15 +216,15 @@ void verify_and_clear_global_variable(const vconfig &pcfg)
|
|||
//Check side matching only if the side is not "global" or empty.
|
||||
if (pcfg_side.str() != "global" && !pcfg_side.empty()) {
|
||||
//Ensure that the side is valid.
|
||||
if (unsigned(side-1) > resources::teams->size()) {
|
||||
if (unsigned(side-1) > resources::gameboard->teams().size()) {
|
||||
ERR_PERSIST << "[clear_global_variable] attribute \"side\" specifies invalid side number.";
|
||||
valid = false;
|
||||
} else if ((*resources::teams)[side - 1].is_empty()) {
|
||||
} else if (resources::gameboard->teams()[side - 1].is_empty()) {
|
||||
LOG_PERSIST << "[clear_global_variable] attribute \"side\" specifies a null-controlled side number.";
|
||||
valid = false;
|
||||
} else {
|
||||
//Clear the variable only if it is meant for a side we control
|
||||
valid = (*resources::teams)[side - 1].is_local();
|
||||
valid = resources::gameboard->teams()[side - 1].is_local();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -126,7 +126,6 @@ static void clear_resources()
|
|||
resources::persist = nullptr;
|
||||
resources::screen = nullptr;
|
||||
resources::soundsources = nullptr;
|
||||
resources::teams = nullptr;
|
||||
resources::tod_manager = nullptr;
|
||||
resources::tunnels = nullptr;
|
||||
resources::undo_stack = nullptr;
|
||||
|
@ -224,7 +223,6 @@ void play_controller::init(CVideo& video, const config& level)
|
|||
|
||||
resources::gameboard = &gamestate().board_;
|
||||
resources::gamedata = &gamestate().gamedata_;
|
||||
resources::teams = &gamestate().board_.teams_;
|
||||
resources::tod_manager = &gamestate().tod_manager_;
|
||||
resources::units = &gamestate().board_.units_;
|
||||
resources::filter_con = &gamestate();
|
||||
|
@ -308,7 +306,6 @@ void play_controller::reset_gamestate(const config& level, int replay_pos)
|
|||
{
|
||||
resources::gameboard = nullptr;
|
||||
resources::gamedata = nullptr;
|
||||
resources::teams = nullptr;
|
||||
resources::tod_manager = nullptr;
|
||||
resources::units = nullptr;
|
||||
resources::filter_con = nullptr;
|
||||
|
@ -320,7 +317,6 @@ void play_controller::reset_gamestate(const config& level, int replay_pos)
|
|||
gamestate_.reset(new game_state(level, *this, tdata_));
|
||||
resources::gameboard = &gamestate().board_;
|
||||
resources::gamedata = &gamestate().gamedata_;
|
||||
resources::teams = &gamestate().board_.teams_;
|
||||
resources::tod_manager = &gamestate().tod_manager_;
|
||||
resources::units = &gamestate().board_.units_;
|
||||
resources::filter_con = &gamestate();
|
||||
|
|
|
@ -197,7 +197,7 @@ void playsingle_controller::play_scenario_main_loop()
|
|||
}
|
||||
reset_gamestate(*ex.level, (*ex.level)["replay_pos"]);
|
||||
for(size_t i = 0; i < local_players.size(); ++i) {
|
||||
(*resources::teams)[i].set_local(local_players[i]);
|
||||
resources::gameboard->teams()[i].set_local(local_players[i]);
|
||||
}
|
||||
play_scenario_init();
|
||||
replay_.reset(new replay_controller(*this, false, ex.level));
|
||||
|
|
|
@ -213,7 +213,7 @@ turn_info::PROCESS_DATA_RESULT turn_info::process_network_data(const config& cfg
|
|||
|
||||
bool restart = side_drop == resources::screen->playing_side();
|
||||
|
||||
if (index >= resources::teams->size()) {
|
||||
if (index >= resources::gameboard->teams().size()) {
|
||||
ERR_NW << "unknown side " << side_drop << " is dropping game" << std::endl;
|
||||
throw ingame_wesnothd_error("");
|
||||
}
|
||||
|
|
|
@ -675,7 +675,7 @@ REPLAY_RETURN do_replay(bool one_move)
|
|||
REPLAY_RETURN do_replay_handle(bool one_move)
|
||||
{
|
||||
|
||||
//team ¤t_team = (*resources::teams)[side_num - 1];
|
||||
//team ¤t_team = resources::gameboard->teams()[side_num - 1];
|
||||
|
||||
const int side_num = resources::controller->current_side();
|
||||
while(true)
|
||||
|
@ -797,7 +797,7 @@ REPLAY_RETURN do_replay_handle(bool one_move)
|
|||
{
|
||||
int val = child["value"];
|
||||
int tval = child["team"];
|
||||
if (tval <= 0 || tval > int(resources::teams->size())) {
|
||||
if (tval <= 0 || tval > int(resources::gameboard->teams().size())) {
|
||||
std::stringstream errbuf;
|
||||
errbuf << "Illegal countdown update \n"
|
||||
<< "Received update for :" << tval << " Current user :"
|
||||
|
@ -805,7 +805,7 @@ REPLAY_RETURN do_replay_handle(bool one_move)
|
|||
|
||||
replay::process_error(errbuf.str());
|
||||
} else {
|
||||
(*resources::teams)[tval - 1].set_countdown_time(val);
|
||||
resources::gameboard->teams()[tval - 1].set_countdown_time(val);
|
||||
}
|
||||
}
|
||||
else if ((*cfg)["dependent"].to_bool(false))
|
||||
|
|
|
@ -26,7 +26,6 @@ namespace resources
|
|||
persist_manager *persist = nullptr;
|
||||
game_display *screen = nullptr;
|
||||
soundsource::manager *soundsources = nullptr;
|
||||
std::vector<team> *teams = nullptr;
|
||||
replay *recorder = nullptr;
|
||||
::tod_manager *tod_manager = nullptr;
|
||||
fake_unit_manager *fake_units = nullptr;
|
||||
|
|
|
@ -26,7 +26,6 @@ class game_data;
|
|||
class filter_context;
|
||||
class game_lua_kernel;
|
||||
class play_controller;
|
||||
class team;
|
||||
class fake_unit_manager;
|
||||
class tod_manager;
|
||||
class unit_map;
|
||||
|
@ -59,7 +58,6 @@ namespace resources
|
|||
extern filter_context *filter_con;
|
||||
extern const mp_game_settings *mp_settings;
|
||||
extern soundsource::manager *soundsources;
|
||||
extern std::vector<team> *teams;
|
||||
extern replay *recorder;
|
||||
extern fake_unit_manager *fake_units;
|
||||
extern ::tod_manager *tod_manager;
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include "chat_events.hpp" // for chat_handler, etc
|
||||
#include "config.hpp"
|
||||
#include "display_chat_manager.hpp"
|
||||
#include "game_board.hpp"
|
||||
#include "game_display.hpp"
|
||||
#include "log.hpp"
|
||||
#include "map/location.hpp" // for map_location
|
||||
|
@ -119,7 +120,7 @@ unit* lua_unit::get()
|
|||
if (ptr) return ptr.get();
|
||||
if (c_ptr) return c_ptr;
|
||||
if (side) {
|
||||
return (*resources::teams)[side - 1].recall_list().find_if_matches_underlying_id(uid).get();
|
||||
return resources::gameboard->teams()[side - 1].recall_list().find_if_matches_underlying_id(uid).get();
|
||||
}
|
||||
unit_map::unit_iterator ui = resources::units->find(uid);
|
||||
if (!ui.valid()) return nullptr;
|
||||
|
@ -129,7 +130,7 @@ unit_ptr lua_unit::get_shared()
|
|||
{
|
||||
if (ptr) return ptr;
|
||||
if (side) {
|
||||
return (*resources::teams)[side - 1].recall_list().find_if_matches_underlying_id(uid);
|
||||
return resources::gameboard->teams()[side - 1].recall_list().find_if_matches_underlying_id(uid);
|
||||
}
|
||||
unit_map::unit_iterator ui = resources::units->find(uid);
|
||||
if (!ui.valid()) return unit_ptr();
|
||||
|
@ -154,7 +155,7 @@ bool lua_unit::put_map(const map_location &loc)
|
|||
return false;
|
||||
}
|
||||
} else if (side) { // recall list
|
||||
unit_ptr it = (*resources::teams)[side - 1].recall_list().extract_if_matches_underlying_id(uid);
|
||||
unit_ptr it = resources::gameboard->teams()[side - 1].recall_list().extract_if_matches_underlying_id(uid);
|
||||
if (it) {
|
||||
side = 0;
|
||||
// uid may be changed by unit_map on insertion
|
||||
|
@ -216,4 +217,4 @@ lua_unit* luaW_pushlocalunit(lua_State *L, unit& u)
|
|||
lua_rawget(L, LUA_REGISTRYINDEX);
|
||||
lua_setmetatable(L, -2);
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
*/
|
||||
|
||||
#include "global.hpp"
|
||||
#include "game_board.hpp"
|
||||
#include "statistics.hpp"
|
||||
#include "log.hpp"
|
||||
#include "resources.hpp" // Needed for teams, to get team save_id for a unit
|
||||
|
@ -41,8 +42,8 @@ typedef std::map<std::string,stats> team_stats_t;
|
|||
|
||||
std::string get_team_save_id(const unit & u)
|
||||
{
|
||||
assert(resources::teams);
|
||||
return resources::teams->at(u.side()-1).save_id();
|
||||
assert(resources::gameboard);
|
||||
return resources::gameboard->teams().at(u.side()-1).save_id();
|
||||
}
|
||||
|
||||
struct scenario_stats
|
||||
|
|
|
@ -66,7 +66,7 @@ synced_command::map& synced_command::registry()
|
|||
SYNCED_COMMAND_HANDLER_FUNCTION(recruit, child, use_undo, show, error_handler)
|
||||
{
|
||||
int current_team_num = resources::controller->current_side();
|
||||
team ¤t_team = (*resources::teams)[current_team_num - 1];
|
||||
team ¤t_team = resources::gameboard->teams()[current_team_num - 1];
|
||||
|
||||
map_location loc(child, resources::gamedata);
|
||||
map_location from(child.child_or_empty("from"), resources::gamedata);
|
||||
|
@ -131,7 +131,7 @@ SYNCED_COMMAND_HANDLER_FUNCTION(recall, child, use_undo, show, error_handler)
|
|||
{
|
||||
|
||||
int current_team_num = resources::controller->current_side();
|
||||
team ¤t_team = (*resources::teams)[current_team_num - 1];
|
||||
team ¤t_team = resources::gameboard->teams()[current_team_num - 1];
|
||||
|
||||
const std::string& unit_id = child["value"];
|
||||
map_location loc(child, resources::gamedata);
|
||||
|
@ -230,7 +230,7 @@ SYNCED_COMMAND_HANDLER_FUNCTION(disband, child, /*use_undo*/, /*show*/, error_ha
|
|||
{
|
||||
|
||||
int current_team_num = resources::controller->current_side();
|
||||
team ¤t_team = (*resources::teams)[current_team_num - 1];
|
||||
team ¤t_team = resources::gameboard->teams()[current_team_num - 1];
|
||||
|
||||
const std::string& unit_id = child["value"];
|
||||
size_t old_size = current_team.recall_list().size();
|
||||
|
@ -253,7 +253,7 @@ SYNCED_COMMAND_HANDLER_FUNCTION(disband, child, /*use_undo*/, /*show*/, error_ha
|
|||
SYNCED_COMMAND_HANDLER_FUNCTION(move, child, use_undo, show, error_handler)
|
||||
{
|
||||
int current_team_num = resources::controller->current_side();
|
||||
team ¤t_team = (*resources::teams)[current_team_num - 1];
|
||||
team ¤t_team = resources::gameboard->teams()[current_team_num - 1];
|
||||
|
||||
std::vector<map_location> steps;
|
||||
|
||||
|
|
|
@ -103,7 +103,7 @@ std::map<int,config> mp_sync::get_user_choice_multiple_sides(const std::string &
|
|||
{
|
||||
//pass sides by copy because we need a copy.
|
||||
const bool is_synced = synced_context::is_synced();
|
||||
const int max_side = static_cast<int>(resources::teams->size());
|
||||
const int max_side = static_cast<int>(resources::gameboard->teams().size());
|
||||
//we currently don't check for too early because luas sync choice doesn't necessarily show screen dialogs.
|
||||
//It (currently) in the responsibility of the user of sync choice to not use dialogs during prestart events..
|
||||
if(!is_synced)
|
||||
|
@ -120,7 +120,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::teams)[side-1].is_empty())
|
||||
if( resources::gameboard->teams()[side-1].is_empty())
|
||||
{
|
||||
empty_sides.insert(side);
|
||||
}
|
||||
|
@ -150,7 +150,7 @@ config mp_sync::get_user_choice(const std::string &name, const mp_sync::user_cho
|
|||
const bool is_too_early = resources::gamedata->phase() != game_data::START && resources::gamedata->phase() != game_data::PLAY;
|
||||
const bool is_synced = synced_context::is_synced();
|
||||
const bool is_mp_game = resources::controller->is_networked_mp();//Only used in debugging output below
|
||||
const int max_side = static_cast<int>(resources::teams->size());
|
||||
const int max_side = static_cast<int>(resources::gameboard->teams().size());
|
||||
bool is_side_null_controlled;
|
||||
|
||||
if(!is_synced)
|
||||
|
@ -186,7 +186,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::teams)[side-1].is_empty();
|
||||
is_side_null_controlled = resources::gameboard->teams()[side-1].is_empty();
|
||||
|
||||
LOG_REPLAY << "get_user_choice_called with"
|
||||
<< " name=" << name
|
||||
|
@ -202,7 +202,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::teams)[side-1].is_empty() )
|
||||
while ( side <= max_side && resources::gameboard->teams()[side-1].is_empty() )
|
||||
side++;
|
||||
assert(side <= max_side);
|
||||
}
|
||||
|
@ -233,12 +233,12 @@ user_choice_manager::user_choice_manager(const std::string &name, const mp_sync:
|
|||
, changed_event_("user_choice_update")
|
||||
{
|
||||
update_local_choice();
|
||||
const int max_side = static_cast<int>(resources::teams->size());
|
||||
const int max_side = static_cast<int>(resources::gameboard->teams().size());
|
||||
|
||||
for(int side : required_)
|
||||
{
|
||||
assert(1 <= side && side <= max_side);
|
||||
const team& t = (*resources::teams)[side-1];
|
||||
const team& t = resources::gameboard->teams()[side-1];
|
||||
assert(!t.is_empty());
|
||||
if(side != current_side_)
|
||||
{
|
||||
|
@ -317,7 +317,7 @@ void user_choice_manager::update_local_choice()
|
|||
sides_str += " ";
|
||||
sides_str += std::to_string(side);
|
||||
//and it is local
|
||||
if((*resources::teams)[side-1].is_local() && !(*resources::teams)[side-1].is_idle())
|
||||
if(resources::gameboard->teams()[side-1].is_local() && !resources::gameboard->teams()[side-1].is_idle())
|
||||
{
|
||||
//then we have to make a local choice.
|
||||
local_choice_ = side;
|
||||
|
|
41
src/team.cpp
41
src/team.cpp
|
@ -46,9 +46,6 @@ static lg::log_domain log_engine_enemies("engine/enemies");
|
|||
#define LOG_NGE LOG_STREAM(info, log_engine_enemies)
|
||||
#define WRN_NGE LOG_STREAM(warn, log_engine_enemies)
|
||||
|
||||
|
||||
static std::vector<team> *&teams = resources::teams;
|
||||
|
||||
//static member initialization
|
||||
const int team::default_team_gold_ = 100;
|
||||
|
||||
|
@ -440,7 +437,7 @@ int team::minimum_recruit_price() const
|
|||
|
||||
bool team::calculate_enemies(size_t index) const
|
||||
{
|
||||
if(teams == nullptr || index >= teams->size()) {
|
||||
if(!resources::gameboard || index >= resources::gameboard->teams().size()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -454,15 +451,15 @@ bool team::calculate_enemies(size_t index) const
|
|||
bool team::calculate_is_enemy(size_t index) const
|
||||
{
|
||||
// We're not enemies of ourselves
|
||||
if(&(*teams)[index] == this) {
|
||||
if(&resources::gameboard->teams()[index] == this) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// We are friends with anyone who we share a teamname with
|
||||
std::vector<std::string> our_teams = utils::split(info_.team_name),
|
||||
their_teams = utils::split((*teams)[index].info_.team_name);
|
||||
their_teams = utils::split(resources::gameboard->teams()[index].info_.team_name);
|
||||
|
||||
LOG_NGE << "team " << info_.side << " calculates if it has enemy in team "<<index+1 << "; our team_name ["<<info_.team_name<<"], their team_name is ["<<(*teams)[index].info_.team_name<<"]"<< std::endl;
|
||||
LOG_NGE << "team " << info_.side << " calculates if it has enemy in team "<<index+1 << "; our team_name ["<<info_.team_name<<"], their team_name is ["<<resources::gameboard->teams()[index].info_.team_name<<"]"<< std::endl;
|
||||
for(std::vector<std::string>::const_iterator t = our_teams.begin(); t != our_teams.end(); ++t) {
|
||||
if(std::find(their_teams.begin(), their_teams.end(), *t) != their_teams.end())
|
||||
{
|
||||
|
@ -548,11 +545,11 @@ void team::change_team(const std::string &name, const t_string &user_name)
|
|||
|
||||
void team::clear_caches(){
|
||||
// Reset the cache of allies for all teams
|
||||
if(teams != nullptr) {
|
||||
for(std::vector<team>::const_iterator i = teams->begin(); i != teams->end(); ++i) {
|
||||
i->enemies_.clear();
|
||||
i->ally_shroud_.clear();
|
||||
i->ally_fog_.clear();
|
||||
if(!resources::gameboard->teams().empty()) {
|
||||
for(auto& t : resources::gameboard->teams()) {
|
||||
t.enemies_.clear();
|
||||
t.ally_shroud_.clear();
|
||||
t.ally_fog_.clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -566,10 +563,10 @@ void team::set_objectives(const t_string& new_objectives, bool silently)
|
|||
|
||||
bool team::shrouded(const map_location& loc) const
|
||||
{
|
||||
if(!teams)
|
||||
if(resources::gameboard->teams().empty())
|
||||
return shroud_.value(loc.x+1,loc.y+1);
|
||||
|
||||
return shroud_.shared_value(ally_shroud(*teams),loc.x+1,loc.y+1);
|
||||
return shroud_.shared_value(ally_shroud(resources::gameboard->teams()),loc.x+1,loc.y+1);
|
||||
}
|
||||
|
||||
bool team::fogged(const map_location& loc) const
|
||||
|
@ -580,10 +577,10 @@ bool team::fogged(const map_location& loc) const
|
|||
if ( fog_clearer_.count(loc) > 0 )
|
||||
return false;
|
||||
|
||||
if(!teams)
|
||||
if(resources::gameboard->teams().empty())
|
||||
return fog_.value(loc.x+1,loc.y+1);
|
||||
|
||||
return fog_.shared_value(ally_fog(*teams),loc.x+1,loc.y+1);
|
||||
return fog_.shared_value(ally_fog(resources::gameboard->teams()),loc.x+1,loc.y+1);
|
||||
}
|
||||
|
||||
const std::vector<const team::shroud_map*>& team::ally_shroud(const std::vector<team>& teams) const
|
||||
|
@ -614,7 +611,7 @@ const std::vector<const team::shroud_map*>& team::ally_fog(const std::vector<tea
|
|||
|
||||
bool team::knows_about_team(size_t index) const
|
||||
{
|
||||
const team& t = (*teams)[index];
|
||||
const team& t = resources::gameboard->teams()[index];
|
||||
|
||||
// We know about our own team
|
||||
if(this == &t) return true;
|
||||
|
@ -656,11 +653,11 @@ void team::remove_fog_override(const std::set<map_location> &hexes)
|
|||
|
||||
void validate_side(int side)
|
||||
{
|
||||
if(teams == nullptr) {
|
||||
if(resources::gameboard->teams().empty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(side < 1 || side > int(teams->size())) {
|
||||
if(side < 1 || side > int(resources::gameboard->teams().size())) {
|
||||
throw game::game_error("invalid side(" + std::to_string(side) + ") found in unit definition");
|
||||
}
|
||||
}
|
||||
|
@ -841,8 +838,8 @@ std::string team::get_side_color_index(int side)
|
|||
{
|
||||
size_t index = size_t(side-1);
|
||||
|
||||
if(teams != nullptr && index < teams->size()) {
|
||||
const std::string side_map = (*teams)[index].color();
|
||||
if(!resources::gameboard->teams().empty() && index < resources::gameboard->teams().size()) {
|
||||
const std::string side_map = resources::gameboard->teams()[index].color();
|
||||
if(!side_map.empty()) {
|
||||
return side_map;
|
||||
}
|
||||
|
@ -880,7 +877,7 @@ config team::to_config() const
|
|||
std::string team::allied_human_teams() const
|
||||
{
|
||||
std::vector<int> res;
|
||||
for(const team& t : *teams)
|
||||
for(const team& t : resources::gameboard->teams())
|
||||
{
|
||||
if(!t.is_enemy(this->side()) && t.is_human()) {
|
||||
res.push_back(t.side());
|
||||
|
|
|
@ -61,7 +61,7 @@ public:
|
|||
//find out the correct qty of gold and handle gold carryover.
|
||||
gold();
|
||||
|
||||
//create a new instance of team and push it to back of resources::teams vector
|
||||
//create a new instance of team and push it to back of resources::gameboard->teams() vector
|
||||
new_team();
|
||||
|
||||
assert(t_!=nullptr);
|
||||
|
|
|
@ -128,7 +128,7 @@ bool affects_side(const config& cfg, const std::vector<team>& teams, size_t side
|
|||
|
||||
bool unit::get_ability_bool(const std::string& tag_name, const map_location& loc) const
|
||||
{
|
||||
assert(resources::teams);
|
||||
assert(resources::gameboard);
|
||||
|
||||
for (const config &i : this->abilities_.child_range(tag_name)) {
|
||||
if (ability_active(tag_name, i, loc) &&
|
||||
|
@ -153,7 +153,7 @@ bool unit::get_ability_bool(const std::string& tag_name, const map_location& loc
|
|||
if ( &*it == this )
|
||||
continue;
|
||||
for (const config &j : it->abilities_.child_range(tag_name)) {
|
||||
if (affects_side(j, *resources::teams, side(), it->side()) &&
|
||||
if (affects_side(j, resources::gameboard->teams(), side(), it->side()) &&
|
||||
it->ability_active(tag_name, j, adjacent[i]) &&
|
||||
ability_affects_adjacent(tag_name, j, i, loc, *it))
|
||||
{
|
||||
|
@ -167,7 +167,7 @@ bool unit::get_ability_bool(const std::string& tag_name, const map_location& loc
|
|||
}
|
||||
unit_ability_list unit::get_abilities(const std::string& tag_name, const map_location& loc) const
|
||||
{
|
||||
assert(resources::teams);
|
||||
assert(resources::gameboard);
|
||||
|
||||
unit_ability_list res;
|
||||
|
||||
|
@ -194,7 +194,7 @@ unit_ability_list unit::get_abilities(const std::string& tag_name, const map_loc
|
|||
if ( &*it == this )
|
||||
continue;
|
||||
for (const config &j : it->abilities_.child_range(tag_name)) {
|
||||
if (affects_side(j, *resources::teams, side(), it->side()) &&
|
||||
if (affects_side(j, resources::gameboard->teams(), side(), it->side()) &&
|
||||
it->ability_active(tag_name, j, adjacent[i]) &&
|
||||
ability_affects_adjacent(tag_name, j, i, loc, *it))
|
||||
{
|
||||
|
@ -309,7 +309,7 @@ std::vector<std::tuple<t_string,t_string,t_string> > unit::ability_tooltips(std:
|
|||
bool unit::ability_active(const std::string& ability,const config& cfg,const map_location& loc) const
|
||||
{
|
||||
bool illuminates = ability == "illuminates";
|
||||
assert(resources::units && resources::gameboard && resources::teams && resources::tod_manager);
|
||||
assert(resources::units && resources::gameboard && resources::tod_manager);
|
||||
|
||||
if (const config &afilter = cfg.child("filter"))
|
||||
if ( !unit_filter(vconfig(afilter), resources::filter_con, illuminates).matches(*this, loc) )
|
||||
|
@ -823,14 +823,14 @@ namespace { // Helpers for attack_type::special_active()
|
|||
if ( !filter_child )
|
||||
// The special does not filter on this unit, so we pass.
|
||||
return true;
|
||||
|
||||
|
||||
// If the primary unit doesn't exist, there's nothing to match
|
||||
if (!un_it.valid()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
unit_filter ufilt(vconfig(filter_child), resources::filter_con);
|
||||
|
||||
|
||||
// If the other unit doesn't exist, try matching without it
|
||||
if (!u2.valid()) {
|
||||
return ufilt.matches(*un_it, loc);
|
||||
|
|
|
@ -217,7 +217,7 @@ void unit_mover::replace_temporary(unit_ptr u)
|
|||
u->set_hidden(true);
|
||||
|
||||
// Update cached data.
|
||||
is_enemy_ = (*resources::teams)[u->side()-1].is_enemy(disp_->viewing_side());
|
||||
is_enemy_ = resources::gameboard->teams()[u->side()-1].is_enemy(disp_->viewing_side());
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -2084,7 +2084,7 @@ void unit::apply_builtin_effect(std::string apply_to, const config& effect)
|
|||
} else if (apply_to == "recall_cost") {
|
||||
const std::string &increase = effect["increase"];
|
||||
const std::string &set = effect["set"];
|
||||
const int recall_cost = recall_cost_ < 0 ? resources::teams->at(side_).recall_cost() : recall_cost_;
|
||||
const int recall_cost = recall_cost_ < 0 ? resources::gameboard->teams().at(side_).recall_cost() : recall_cost_;
|
||||
|
||||
if(!set.empty()) {
|
||||
if(set[set.size()-1] == '%') {
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
|
||||
#include "config_assign.hpp"
|
||||
#include "formula/string_utils.hpp"
|
||||
#include "game_board.hpp"
|
||||
#include "game_data.hpp"
|
||||
#include "log.hpp"
|
||||
#include "resources.hpp"
|
||||
|
@ -482,9 +483,9 @@ void scoped_weapon_info::activate()
|
|||
|
||||
void scoped_recall_unit::activate()
|
||||
{
|
||||
assert(resources::teams);
|
||||
assert(resources::gameboard);
|
||||
|
||||
const std::vector<team>& teams = *resources::teams;
|
||||
const std::vector<team>& teams = resources::gameboard->teams();
|
||||
|
||||
std::vector<team>::const_iterator team_it;
|
||||
for (team_it = teams.begin(); team_it != teams.end(); ++team_it) {
|
||||
|
|
|
@ -105,7 +105,7 @@ action::action(config const& cfg, bool hidden)
|
|||
// Construct and validate team_index_
|
||||
int team_index_temp = cfg["team_index_"].to_int(-1); //default value: -1
|
||||
if(team_index_temp < 0
|
||||
|| team_index_temp >= static_cast<int>(resources::teams->size()))
|
||||
|| team_index_temp >= static_cast<int>(resources::gameboard->teams().size()))
|
||||
throw ctor_err("action: Invalid team_index_");
|
||||
team_index_ = team_index_temp;
|
||||
}
|
||||
|
|
|
@ -261,7 +261,7 @@ action::error attack::check_validity() const
|
|||
return NO_ATTACK_LEFT;
|
||||
}
|
||||
// Verify that the attacker and target are enemies
|
||||
if(!(*resources::teams)[get_unit()->side() - 1].is_enemy(resources::units->find(target_hex_)->side())){
|
||||
if(!resources::gameboard->teams()[get_unit()->side() - 1].is_enemy(resources::units->find(target_hex_)->side())){
|
||||
return NOT_AN_ENEMY;
|
||||
}
|
||||
//@todo: (maybe) verify that the target hex contains the same unit that before,
|
||||
|
|
|
@ -86,7 +86,7 @@ void highlighter::set_mouseover_hex(const map_location& hex)
|
|||
if(it != get_unit_map().end()) {
|
||||
selection_candidate_ = it.get_shared_ptr();
|
||||
|
||||
if(resources::teams->at(it->side()-1).get_side_actions()->unit_has_actions(*it)) {
|
||||
if(resources::gameboard->teams().at(it->side()-1).get_side_actions()->unit_has_actions(*it)) {
|
||||
owner_unit_ = it.get_shared_ptr();
|
||||
}
|
||||
|
||||
|
@ -189,7 +189,7 @@ void highlighter::last_action_redraw(move_ptr move)
|
|||
{
|
||||
//Last action with a fake unit always gets normal appearance
|
||||
if(move->get_fake_unit()) {
|
||||
side_actions& sa = *resources::teams->at(move->team_index()).get_side_actions();
|
||||
side_actions& sa = *resources::gameboard->teams().at(move->team_index()).get_side_actions().get();
|
||||
side_actions::iterator last_action = sa.find_last_action_of(*(move->get_unit()));
|
||||
side_actions::iterator second_to_last_action = last_action != sa.end() && last_action != sa.begin() ? last_action - 1 : sa.end();
|
||||
|
||||
|
|
|
@ -78,8 +78,8 @@ manager::manager():
|
|||
temp_move_unit_underlying_id_(0),
|
||||
key_poller_(new CKey),
|
||||
hidden_unit_hexes_(),
|
||||
net_buffer_(resources::teams->size()),
|
||||
team_plans_hidden_(resources::teams->size(),preferences::hide_whiteboard()),
|
||||
net_buffer_(resources::gameboard->teams().size()),
|
||||
team_plans_hidden_(resources::gameboard->teams().size(),preferences::hide_whiteboard()),
|
||||
units_owning_moves_()
|
||||
{
|
||||
LOG_WB << "Manager initialized.\n";
|
||||
|
@ -142,7 +142,7 @@ void manager::print_help_once()
|
|||
bool manager::can_modify_game_state() const
|
||||
{
|
||||
if(wait_for_side_init_
|
||||
|| resources::teams == nullptr
|
||||
|| resources::gameboard == nullptr
|
||||
|| executing_actions_
|
||||
|| resources::gameboard->is_observer()
|
||||
|| resources::controller->is_linger_mode())
|
||||
|
@ -326,7 +326,7 @@ void manager::post_delete_action(action_ptr action)
|
|||
// If the last remaining action of the unit that owned this move is a move as well,
|
||||
// adjust its appearance accordingly.
|
||||
|
||||
side_actions_ptr side_actions = resources::teams->at(action->team_index()).get_side_actions();
|
||||
side_actions_ptr side_actions = resources::gameboard->teams().at(action->team_index()).get_side_actions();
|
||||
|
||||
unit_ptr actor = action->get_unit();
|
||||
if(actor) { // The unit might have died following the execution of an attack
|
||||
|
@ -342,7 +342,7 @@ void manager::post_delete_action(action_ptr action)
|
|||
|
||||
static void hide_all_plans()
|
||||
{
|
||||
for(team& t : *resources::teams){
|
||||
for(team& t : resources::gameboard->teams()){
|
||||
t.get_side_actions()->hide();
|
||||
}
|
||||
}
|
||||
|
@ -351,11 +351,11 @@ static void hide_all_plans()
|
|||
void manager::update_plan_hiding(size_t team_index)
|
||||
{
|
||||
//We don't control the "viewing" side ... we're probably an observer
|
||||
if(!resources::teams->at(team_index).is_local_human())
|
||||
if(!resources::gameboard->teams().at(team_index).is_local_human())
|
||||
hide_all_plans();
|
||||
else // normal circumstance
|
||||
{
|
||||
for(team& t : *resources::teams)
|
||||
for(team& t : resources::gameboard->teams())
|
||||
{
|
||||
//make sure only appropriate teams are hidden
|
||||
if(!t.is_network_human())
|
||||
|
@ -397,10 +397,10 @@ void manager::on_change_controller(int side, const team& t)
|
|||
hide_all_plans(); // give up knowledge of everyone's plans, in case we became an observer
|
||||
|
||||
//tell them our plans -- they may not have received them up to this point
|
||||
size_t num_teams = resources::teams->size();
|
||||
size_t num_teams = resources::gameboard->teams().size();
|
||||
for(size_t i=0; i<num_teams; ++i)
|
||||
{
|
||||
team& local_team = resources::teams->at(i);
|
||||
team& local_team = resources::gameboard->teams().at(i);
|
||||
if(local_team.is_local_human() && !local_team.is_enemy(side))
|
||||
resources::whiteboard->queue_net_cmd(i,local_team.get_side_actions()->make_net_cmd_refresh());
|
||||
}
|
||||
|
@ -551,7 +551,7 @@ void manager::draw_hex(const map_location& hex)
|
|||
|
||||
//Info about the action numbers to be displayed on screen.
|
||||
side_actions::numbers_t numbers;
|
||||
for (team& t : *resources::teams)
|
||||
for (team& t : resources::gameboard->teams())
|
||||
{
|
||||
side_actions& sa = *t.get_side_actions();
|
||||
if(!sa.hidden())
|
||||
|
@ -607,7 +607,7 @@ void manager::send_network_data()
|
|||
config packet;
|
||||
config& wb_cfg = packet.add_child("whiteboard",buf_cfg);
|
||||
wb_cfg["side"] = static_cast<int>(team_index+1);
|
||||
wb_cfg["to_sides"] = resources::teams->at(team_index).allied_human_teams();
|
||||
wb_cfg["to_sides"] = resources::gameboard->teams().at(team_index).allied_human_teams();
|
||||
|
||||
buf_cfg = config();
|
||||
|
||||
|
@ -625,7 +625,7 @@ void manager::process_network_data(config const& cfg)
|
|||
size_t count = wb_cfg.child_count("net_cmd");
|
||||
LOG_WB << "Received wb data (" << count << ").\n";
|
||||
|
||||
team& team_from = resources::teams->at(wb_cfg["side"]-1);
|
||||
team& team_from = resources::gameboard->teams().at(wb_cfg["side"]-1);
|
||||
for(side_actions::net_cmd const& cmd : wb_cfg.child_range("net_cmd"))
|
||||
team_from.get_side_actions()->execute_net_cmd(cmd);
|
||||
}
|
||||
|
@ -1048,14 +1048,14 @@ void manager::contextual_bump_down_action()
|
|||
|
||||
bool manager::has_actions() const
|
||||
{
|
||||
assert(resources::teams);
|
||||
assert(resources::gameboard);
|
||||
return wb::has_actions();
|
||||
}
|
||||
|
||||
bool manager::unit_has_actions(unit const* unit) const
|
||||
{
|
||||
assert(unit != nullptr);
|
||||
assert(resources::teams);
|
||||
assert(resources::gameboard);
|
||||
return viewer_actions()->unit_has_actions(*unit);
|
||||
}
|
||||
|
||||
|
@ -1064,7 +1064,7 @@ int manager::get_spent_gold_for(int side)
|
|||
if(wait_for_side_init_)
|
||||
return 0;
|
||||
|
||||
return resources::teams->at(side - 1).get_side_actions()->get_gold_spent();
|
||||
return resources::gameboard->teams().at(side - 1).get_side_actions()->get_gold_spent();
|
||||
}
|
||||
|
||||
void manager::options_dlg()
|
||||
|
@ -1081,7 +1081,7 @@ void manager::options_dlg()
|
|||
options.push_back(_("HIDE ALL allies’ plans"));
|
||||
|
||||
//populate list of networked allies
|
||||
for(team &t : *resources::teams)
|
||||
for(team &t : resources::gameboard->teams())
|
||||
{
|
||||
//Exclude enemies, AIs, and local players
|
||||
if(t.is_enemy(v_side) || !t.is_network())
|
||||
|
|
|
@ -56,7 +56,7 @@ mapbuilder::~mapbuilder()
|
|||
|
||||
void mapbuilder::pre_build()
|
||||
{
|
||||
for (team& t : *resources::teams) {
|
||||
for (team& t : resources::gameboard->teams()) {
|
||||
//Reset spent gold to zero, it'll be recalculated during the map building
|
||||
t.get_side_actions()->reset_gold_spent();
|
||||
}
|
||||
|
@ -68,7 +68,7 @@ void mapbuilder::pre_build()
|
|||
//Remove any unit the current side cannot see to avoid their detection by planning
|
||||
//Units will be restored to the unit map by destruction of removers_
|
||||
|
||||
if(!on_current_side && !u.is_visible_to_team((*resources::teams)[viewer_team()], resources::gameboard->map(), false)) {
|
||||
if(!on_current_side && !u.is_visible_to_team(resources::gameboard->teams()[viewer_team()], resources::gameboard->map(), false)) {
|
||||
removers_.push_back(new temporary_unit_remover(*resources::units, u.get_location()));
|
||||
|
||||
//Don't do anything else to the removed unit!
|
||||
|
@ -96,7 +96,7 @@ void mapbuilder::build_map()
|
|||
bool end = false;
|
||||
for(size_t turn=0; !end; ++turn) {
|
||||
end = true;
|
||||
for (team &side : *resources::teams) {
|
||||
for (team &side : resources::gameboard->teams()) {
|
||||
side_actions &actions = *side.get_side_actions();
|
||||
if(turn < actions.num_turns() && team_has_visible_plan(side)) {
|
||||
end = false;
|
||||
|
|
|
@ -158,7 +158,7 @@ void move::init()
|
|||
{
|
||||
fake_unit_->anim_comp().set_ghosted(true);
|
||||
}
|
||||
side_actions_ptr side_actions = resources::teams->at(team_index()).get_side_actions();
|
||||
side_actions_ptr side_actions = resources::gameboard->teams().at(team_index()).get_side_actions();
|
||||
side_actions::iterator action = side_actions->find_last_action_of(*(get_unit()));
|
||||
if (action != side_actions->end())
|
||||
{
|
||||
|
@ -314,8 +314,8 @@ bool move::calculate_new_route(const map_location& source_hex, const map_locatio
|
|||
{
|
||||
pathfind::plain_route new_plain_route;
|
||||
pathfind::shortest_path_calculator path_calc(*get_unit(),
|
||||
resources::teams->at(team_index()),
|
||||
*resources::teams, resources::gameboard->map());
|
||||
resources::gameboard->teams().at(team_index()),
|
||||
resources::gameboard->teams(), resources::gameboard->map());
|
||||
new_plain_route = pathfind::a_star_search(source_hex,
|
||||
dest_hex, 10000, &path_calc, resources::gameboard->map().w(), resources::gameboard->map().h());
|
||||
if (new_plain_route.move_cost >= path_calc.getNoPathValue()) return false;
|
||||
|
@ -469,7 +469,7 @@ action::error move::check_validity() const
|
|||
}
|
||||
|
||||
//If the path has at least two hexes (it can have less with the attack subclass), ensure destination hex is free
|
||||
if(get_route().steps.size() >= 2 && resources::gameboard->get_visible_unit(get_dest_hex(),resources::teams->at(viewer_team())) != nullptr) {
|
||||
if(get_route().steps.size() >= 2 && resources::gameboard->get_visible_unit(get_dest_hex(),resources::gameboard->teams().at(viewer_team())) != nullptr) {
|
||||
return LOCATION_OCCUPIED;
|
||||
}
|
||||
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#include "actions/create.hpp"
|
||||
#include "fake_unit_manager.hpp"
|
||||
#include "fake_unit_ptr.hpp"
|
||||
#include "game_board.hpp"
|
||||
#include "game_display.hpp"
|
||||
#include "recall_list_manager.hpp"
|
||||
#include "resources.hpp"
|
||||
|
@ -73,7 +74,7 @@ recall::recall(config const& cfg, bool hidden)
|
|||
{
|
||||
// Construct and validate temp_unit_
|
||||
size_t underlying_id = cfg["temp_unit_"];
|
||||
for(const unit_const_ptr & recall_unit : resources::teams->at(team_index()).recall_list())
|
||||
for(const unit_const_ptr & recall_unit : resources::gameboard->teams().at(team_index()).recall_list())
|
||||
{
|
||||
if(recall_unit->underlying_id()==underlying_id)
|
||||
{
|
||||
|
@ -113,7 +114,7 @@ void recall::accept(visitor& v)
|
|||
|
||||
void recall::execute(bool& success, bool& complete)
|
||||
{
|
||||
team & current_team = resources::teams->at(team_index());
|
||||
team & current_team = resources::gameboard->teams().at(team_index());
|
||||
|
||||
assert(valid());
|
||||
assert(temp_unit_.get());
|
||||
|
@ -145,11 +146,11 @@ void recall::apply_temp_modifier(unit_map& unit_map)
|
|||
<< "] at position " << temp_unit_->get_location() << ".\n";
|
||||
|
||||
//temporarily remove unit from recall list
|
||||
unit_ptr it = resources::teams->at(team_index()).recall_list().extract_if_matches_id(temp_unit_->id());
|
||||
unit_ptr it = resources::gameboard->teams().at(team_index()).recall_list().extract_if_matches_id(temp_unit_->id());
|
||||
assert(it);
|
||||
|
||||
//Add cost to money spent on recruits.
|
||||
int cost = resources::teams->at(team_index()).recall_cost();
|
||||
int cost = resources::gameboard->teams().at(team_index()).recall_cost();
|
||||
if (it->recall_cost() > -1) {
|
||||
cost = it->recall_cost();
|
||||
}
|
||||
|
@ -158,7 +159,7 @@ void recall::apply_temp_modifier(unit_map& unit_map)
|
|||
//unit map takes ownership of temp_unit
|
||||
unit_map.insert(temp_unit_);
|
||||
|
||||
resources::teams->at(team_index()).get_side_actions()->change_gold_spent_by(cost);
|
||||
resources::gameboard->teams().at(team_index()).get_side_actions()->change_gold_spent_by(cost);
|
||||
// Update gold in top bar
|
||||
resources::screen->invalidate_game_status();
|
||||
}
|
||||
|
@ -169,7 +170,7 @@ void recall::remove_temp_modifier(unit_map& unit_map)
|
|||
assert(temp_unit_.get());
|
||||
|
||||
//Put unit back into recall list
|
||||
resources::teams->at(team_index()).recall_list().add(temp_unit_);
|
||||
resources::gameboard->teams().at(team_index()).recall_list().add(temp_unit_);
|
||||
}
|
||||
|
||||
void recall::draw_hex(map_location const& hex)
|
||||
|
@ -183,7 +184,7 @@ void recall::draw_hex(map_location const& hex)
|
|||
unit &it = *get_unit();
|
||||
int cost = statistics::un_recall_unit_cost(it);
|
||||
if (cost < 0) {
|
||||
number_text << utils::unicode_minus << resources::teams->at(team_index()).recall_cost();
|
||||
number_text << utils::unicode_minus << resources::gameboard->teams().at(team_index()).recall_cost();
|
||||
}
|
||||
else {
|
||||
number_text << utils::unicode_minus << cost;
|
||||
|
@ -207,11 +208,11 @@ action::error recall::check_validity() const
|
|||
return LOCATION_OCCUPIED;
|
||||
}
|
||||
//Check that unit to recall is still in side's recall list
|
||||
if( !(*resources::teams)[team_index()].recall_list().find_if_matches_id(temp_unit_->id()) ) {
|
||||
if( !resources::gameboard->teams()[team_index()].recall_list().find_if_matches_id(temp_unit_->id()) ) {
|
||||
return UNIT_UNAVAILABLE;
|
||||
}
|
||||
//Check that there is still enough gold to recall this unit
|
||||
if((*resources::teams)[team_index()].recall_cost() > (*resources::teams)[team_index()].gold()) {
|
||||
if(resources::gameboard->teams()[team_index()].recall_cost() > resources::gameboard->teams()[team_index()].gold()) {
|
||||
return NOT_ENOUGH_GOLD;
|
||||
}
|
||||
//Check that there is a leader available to recall this unit
|
||||
|
|
|
@ -109,11 +109,11 @@ void recruit::execute(bool& success, bool& complete)
|
|||
temporary_unit_hider const raii(*fake_unit_);
|
||||
int const side_num = team_index() + 1;
|
||||
//Give back the spent gold so we don't get "not enough gold" message
|
||||
resources::teams->at(team_index()).get_side_actions()->change_gold_spent_by(-cost_);
|
||||
resources::gameboard->teams().at(team_index()).get_side_actions()->change_gold_spent_by(-cost_);
|
||||
bool const result = resources::controller->get_menu_handler().do_recruit(unit_name_, side_num, recruit_hex_);
|
||||
//If it failed, take back the gold
|
||||
if (!result) {
|
||||
resources::teams->at(team_index()).get_side_actions()->change_gold_spent_by(cost_);
|
||||
resources::gameboard->teams().at(team_index()).get_side_actions()->change_gold_spent_by(cost_);
|
||||
}
|
||||
success = complete = result;
|
||||
}
|
||||
|
@ -127,7 +127,7 @@ void recruit::apply_temp_modifier(unit_map& unit_map)
|
|||
<< "] at position " << temp_unit_->get_location() << ".\n";
|
||||
|
||||
// Add cost to money spent on recruits.
|
||||
resources::teams->at(team_index()).get_side_actions()->change_gold_spent_by(cost_);
|
||||
resources::gameboard->teams().at(team_index()).get_side_actions()->change_gold_spent_by(cost_);
|
||||
|
||||
// Temporarily insert unit into unit_map
|
||||
// unit map takes ownership of temp_unit
|
||||
|
@ -187,12 +187,12 @@ action::error recruit::check_validity() const
|
|||
}
|
||||
//Check that unit to recruit is still in side's recruit list
|
||||
//FIXME: look at leaders extra_recruit too.
|
||||
const std::set<std::string>& recruits = (*resources::teams)[team_index()].recruits();
|
||||
const std::set<std::string>& recruits = resources::gameboard->teams()[team_index()].recruits();
|
||||
if(recruits.find(unit_name_) == recruits.end()) {
|
||||
return UNIT_UNAVAILABLE;
|
||||
}
|
||||
//Check that there is still enough gold to recruit this unit
|
||||
if(temp_unit_->cost() > (*resources::teams)[team_index()].gold()) {
|
||||
if(temp_unit_->cost() > resources::gameboard->teams()[team_index()].gold()) {
|
||||
return NOT_ENOUGH_GOLD;
|
||||
}
|
||||
//Check that there is a leader available to recruit this unit
|
||||
|
|
|
@ -49,14 +49,14 @@ int viewer_side()
|
|||
side_actions_ptr viewer_actions()
|
||||
{
|
||||
side_actions_ptr side_actions =
|
||||
(*resources::teams)[resources::screen->viewing_team()].get_side_actions();
|
||||
resources::gameboard->teams()[resources::screen->viewing_team()].get_side_actions();
|
||||
return side_actions;
|
||||
}
|
||||
|
||||
side_actions_ptr current_side_actions()
|
||||
{
|
||||
side_actions_ptr side_actions =
|
||||
(*resources::teams)[resources::controller->current_side() - 1].get_side_actions();
|
||||
resources::gameboard->teams()[resources::controller->current_side() - 1].get_side_actions();
|
||||
return side_actions;
|
||||
}
|
||||
|
||||
|
@ -97,7 +97,7 @@ unit* future_visible_unit(map_location hex, int viewer_side)
|
|||
return nullptr;
|
||||
}
|
||||
//use global method get_visible_unit
|
||||
return resources::gameboard->get_visible_unit(hex, resources::teams->at(viewer_side - 1), false);
|
||||
return resources::gameboard->get_visible_unit(hex, resources::gameboard->teams().at(viewer_side - 1), false);
|
||||
}
|
||||
|
||||
unit* future_visible_unit(int on_side, map_location hex, int viewer_side)
|
||||
|
@ -114,7 +114,7 @@ int path_cost(std::vector<map_location> const& path, unit const& u)
|
|||
if(path.size() < 2)
|
||||
return 0;
|
||||
|
||||
team const& u_team = resources::teams->at(u.side()-1);
|
||||
team const& u_team = resources::gameboard->teams().at(u.side()-1);
|
||||
map_location const& dest = path.back();
|
||||
if ( (resources::gameboard->map().is_village(dest) && !u_team.owns_village(dest))
|
||||
|| pathfind::enemy_zoc(u_team, dest, u_team) )
|
||||
|
@ -152,7 +152,7 @@ void unghost_owner_unit(unit* unit)
|
|||
|
||||
bool has_actions()
|
||||
{
|
||||
for (team& t : *resources::teams) {
|
||||
for (team& t : resources::gameboard->teams()) {
|
||||
if (!t.get_side_actions()->empty())
|
||||
return true;
|
||||
}
|
||||
|
@ -170,7 +170,7 @@ void for_each_action(std::function<void(action*)> function, team_filter team_fil
|
|||
bool end = false;
|
||||
for(size_t turn=0; !end; ++turn) {
|
||||
end = true;
|
||||
for(team &side : *resources::teams) {
|
||||
for(team &side : resources::gameboard->teams()) {
|
||||
side_actions &actions = *side.get_side_actions();
|
||||
if(turn < actions.num_turns() && team_filter(side)) {
|
||||
for(auto iter = actions.turn_begin(turn); iter != actions.turn_end(turn); ++iter) {
|
||||
|
@ -187,7 +187,7 @@ action_ptr find_action_at(map_location hex, team_filter team_filter)
|
|||
action_ptr result;
|
||||
size_t result_turn = std::numeric_limits<size_t>::max();
|
||||
|
||||
for(team &side : *resources::teams) {
|
||||
for(team &side : resources::gameboard->teams()) {
|
||||
side_actions &actions = *side.get_side_actions();
|
||||
if(team_filter(side)) {
|
||||
side_actions::iterator chall = actions.find_first_action_at(hex);
|
||||
|
@ -208,7 +208,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::teams)[target.side()-1].get_side_actions()->actions_of(target);
|
||||
return resources::gameboard->teams()[target.side()-1].get_side_actions()->actions_of(target);
|
||||
}
|
||||
|
||||
} //end namespace wb
|
||||
|
|
Loading…
Add table
Reference in a new issue