partially remove resources::game_map (part 1)
This is the result of running, in src/ directory, the following: find . -type f -exec sed -i 's/resources::game_map->/resources::gameboard->map()./g' '{}' \; and carefully inspecting the result, and adding "game_board.hpp"
This commit is contained in:
parent
3c93463b3c
commit
4830b8ee3c
29 changed files with 169 additions and 158 deletions
|
@ -134,7 +134,7 @@ battle_context_unit_stats::battle_context_unit_stats(const unit &u,
|
|||
// Handle plague.
|
||||
unit_ability_list plague_specials = weapon->get_specials("plague");
|
||||
plagues = !opp.get_state("unplagueable") && !plague_specials.empty() &&
|
||||
strcmp(opp.undead_variation().c_str(), "null") && !resources::game_map->is_village(opp_loc);
|
||||
strcmp(opp.undead_variation().c_str(), "null") && !resources::gameboard->map().is_village(opp_loc);
|
||||
|
||||
if (plagues) {
|
||||
plague_type = (*plague_specials.front().first)["type"].str();
|
||||
|
@ -144,7 +144,7 @@ battle_context_unit_stats::battle_context_unit_stats(const unit &u,
|
|||
|
||||
// Compute chance to hit.
|
||||
chance_to_hit = opp.defense_modifier(
|
||||
resources::game_map->get_terrain(opp_loc)) + weapon->accuracy() -
|
||||
resources::gameboard->map().get_terrain(opp_loc)) + weapon->accuracy() -
|
||||
(opp_weapon ? opp_weapon->parry() : 0);
|
||||
if(chance_to_hit > 100) {
|
||||
chance_to_hit = 100;
|
||||
|
|
|
@ -161,13 +161,13 @@ map_location unit_creator::find_location(const config &cfg, const unit* pass_che
|
|||
loc = map_location(cfg,resources::gamedata);
|
||||
}
|
||||
|
||||
if(loc.valid() && resources::game_map->on_board(loc)) {
|
||||
if(loc.valid() && resources::gameboard->map().on_board(loc)) {
|
||||
const bool pass((place == "leader_passable") || (place == "map_passable"));
|
||||
if ( place != "map_overwrite" ) {
|
||||
loc = find_vacant_tile(loc, pathfind::VACANT_ANY,
|
||||
pass ? pass_check : NULL);
|
||||
}
|
||||
if(loc.valid() && resources::game_map->on_board(loc)) {
|
||||
if(loc.valid() && resources::gameboard->map().on_board(loc)) {
|
||||
return loc;
|
||||
}
|
||||
}
|
||||
|
@ -239,7 +239,7 @@ void unit_creator::post_create(const map_location &loc, const unit &new_unit, bo
|
|||
bool animate = show && anim;
|
||||
|
||||
if (get_village_) {
|
||||
if (resources::game_map->is_village(loc)) {
|
||||
if (resources::gameboard->map().is_village(loc)) {
|
||||
actions::get_village(loc, new_unit.side());
|
||||
}
|
||||
}
|
||||
|
@ -344,7 +344,7 @@ const std::set<std::string> get_recruits(int side, const map_location &recruit_l
|
|||
u_end = resources::units->end();
|
||||
|
||||
bool leader_in_place = false;
|
||||
bool allow_local = resources::game_map->is_castle(recruit_loc);
|
||||
bool allow_local = resources::gameboard->map().is_castle(recruit_loc);
|
||||
|
||||
|
||||
// Check for a leader at recruit_loc (means we are recruiting from there,
|
||||
|
@ -352,7 +352,7 @@ const std::set<std::string> get_recruits(int side, const map_location &recruit_l
|
|||
unit_map::const_iterator find_it = resources::units->find(recruit_loc);
|
||||
if ( find_it != u_end ) {
|
||||
if ( find_it->can_recruit() && find_it->side() == side &&
|
||||
resources::game_map->is_keep(recruit_loc) )
|
||||
resources::gameboard->map().is_keep(recruit_loc) )
|
||||
{
|
||||
// We have been requested to get the recruit list for this
|
||||
// particular leader.
|
||||
|
@ -444,7 +444,7 @@ const std::vector<const unit*> get_recalls(int side, const map_location &recall_
|
|||
*/
|
||||
|
||||
bool leader_in_place = false;
|
||||
bool allow_local = resources::game_map->is_castle(recall_loc);
|
||||
bool allow_local = resources::gameboard->map().is_castle(recall_loc);
|
||||
|
||||
|
||||
// Check for a leader at recall_loc (means we are recalling from there,
|
||||
|
@ -452,7 +452,7 @@ const std::vector<const unit*> get_recalls(int side, const map_location &recall_
|
|||
unit_map::const_iterator find_it = resources::units->find(recall_loc);
|
||||
if ( find_it != resources::units->end() ) {
|
||||
if ( find_it->can_recruit() && find_it->side() == side &&
|
||||
resources::game_map->is_keep(recall_loc) )
|
||||
resources::gameboard->map().is_keep(recall_loc) )
|
||||
{
|
||||
// We have been requested to get the recalls for this
|
||||
// particular leader.
|
||||
|
@ -523,7 +523,7 @@ namespace { // Helpers for check_recall_location()
|
|||
return RECRUIT_NO_ABLE_LEADER;
|
||||
|
||||
// Make sure the unit is on a keep.
|
||||
if ( !resources::game_map->is_keep(recaller.get_location()) )
|
||||
if ( !resources::gameboard->map().is_keep(recaller.get_location()) )
|
||||
return RECRUIT_NO_KEEP_LEADER;
|
||||
|
||||
// Make sure there is a permissible location to which to recruit.
|
||||
|
@ -653,7 +653,7 @@ namespace { // Helpers for check_recruit_location()
|
|||
}
|
||||
|
||||
// Make sure the unit is on a keep.
|
||||
if ( !resources::game_map->is_keep(recruiter.get_location()) )
|
||||
if ( !resources::gameboard->map().is_keep(recruiter.get_location()) )
|
||||
return RECRUIT_NO_KEEP_LEADER;
|
||||
|
||||
// Make sure there is a permissible location to which to recruit.
|
||||
|
@ -932,7 +932,7 @@ bool place_recruit(const unit &u, const map_location &recruit_location, const ma
|
|||
}
|
||||
|
||||
// Village capturing.
|
||||
if ( resources::game_map->is_village(current_loc) ) {
|
||||
if ( resources::gameboard->map().is_village(current_loc) ) {
|
||||
mutated |= actions::get_village(current_loc, new_unit_itor->side());
|
||||
if ( !validate_recruit_iterator(new_unit_itor, current_loc) )
|
||||
return true;
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
|
||||
#include "heal.hpp"
|
||||
|
||||
#include "../game_board.hpp"
|
||||
#include "../game_display.hpp"
|
||||
#include "../gettext.hpp"
|
||||
#include "../log.hpp"
|
||||
|
@ -93,7 +94,7 @@ namespace {
|
|||
if ( patient.side() == side )
|
||||
{
|
||||
// Village healing?
|
||||
if ( resources::game_map->gives_healing(patient.get_location()) )
|
||||
if ( resources::gameboard->map().gives_healing(patient.get_location()) )
|
||||
return POISON_CURE;
|
||||
|
||||
// Regeneration?
|
||||
|
@ -191,7 +192,7 @@ namespace {
|
|||
{
|
||||
// Village healing?
|
||||
update_healing(healing, harming,
|
||||
resources::game_map->gives_healing(patient.get_location()));
|
||||
resources::gameboard->map().gives_healing(patient.get_location()));
|
||||
|
||||
// Regeneration?
|
||||
unit_ability_list regen_list = patient.get_abilities("regenerate");
|
||||
|
|
|
@ -564,7 +564,7 @@ namespace { // Private helpers for move_unit()
|
|||
return false;
|
||||
|
||||
// We can reasonably stop if the hex is not an unowned village.
|
||||
return !resources::game_map->is_village(hex) ||
|
||||
return !resources::gameboard->map().is_village(hex) ||
|
||||
current_team_->owns_village(hex);
|
||||
}
|
||||
|
||||
|
@ -1048,7 +1048,7 @@ namespace { // Private helpers for move_unit()
|
|||
move_it_->set_movement(0, true);
|
||||
|
||||
// Village capturing.
|
||||
if ( resources::game_map->is_village(final_loc) ) {
|
||||
if ( resources::gameboard->map().is_village(final_loc) ) {
|
||||
// Is this a capture?
|
||||
orig_village_owner = village_owner(final_loc);
|
||||
if ( orig_village_owner != current_side_-1 ) {
|
||||
|
@ -1304,7 +1304,7 @@ bool unit_can_move(const unit &u)
|
|||
map_location locs[6];
|
||||
get_adjacent_tiles(u.get_location(), locs);
|
||||
for(int n = 0; n != 6; ++n) {
|
||||
if (resources::game_map->on_board(locs[n])) {
|
||||
if (resources::gameboard->map().on_board(locs[n])) {
|
||||
const unit_map::const_iterator i = resources::units->find(locs[n]);
|
||||
if (i.valid() && !i->incapacitated() &&
|
||||
current_team.is_enemy(i->side())) {
|
||||
|
|
|
@ -720,7 +720,7 @@ bool undo_list::move_action::undo(int side, undo_list & /*undos*/)
|
|||
return false;
|
||||
}
|
||||
|
||||
if ( resources::game_map->is_village(rev_route.front()) ) {
|
||||
if ( resources::gameboard->map().is_village(rev_route.front()) ) {
|
||||
get_village(rev_route.front(), original_village_owner + 1);
|
||||
//MP_COUNTDOWN take away capture bonus
|
||||
if ( countdown_time_bonus )
|
||||
|
@ -964,7 +964,7 @@ bool undo_list::move_action::redo(int side)
|
|||
u->set_movement(saved_moves, true);
|
||||
u->set_standing();
|
||||
|
||||
if ( resources::game_map->is_village(route.back()) ) {
|
||||
if ( resources::gameboard->map().is_village(route.back()) ) {
|
||||
get_village(route.back(), u->side());
|
||||
//MP_COUNTDOWN restore capture bonus
|
||||
if ( countdown_time_bonus )
|
||||
|
|
|
@ -370,7 +370,7 @@ bool move_result::test_route(const unit &un)
|
|||
pathfind::teleport_map allowed_teleports = pathfind::get_teleport_locations(un, my_team, true);///@todo 1.9: see_all -> false
|
||||
|
||||
//do an A*-search
|
||||
route_ = boost::shared_ptr<pathfind::plain_route>( new pathfind::plain_route(pathfind::a_star_search(un.get_location(), to_, 10000.0, &calc, resources::game_map->w(), resources::game_map->h(), &allowed_teleports)));
|
||||
route_ = boost::shared_ptr<pathfind::plain_route>( new pathfind::plain_route(pathfind::a_star_search(un.get_location(), to_, 10000.0, &calc, resources::gameboard->map().w(), resources::gameboard->map().h(), &allowed_teleports)));
|
||||
if (route_->steps.empty()) {
|
||||
set_error(E_NO_ROUTE);
|
||||
return false;
|
||||
|
@ -565,7 +565,7 @@ void recall_result::do_check_before()
|
|||
|
||||
void recall_result::do_check_after()
|
||||
{
|
||||
if (!resources::game_map->on_board(recall_location_)){
|
||||
if (!resources::gameboard->map().on_board(recall_location_)){
|
||||
set_error(AI_ACTION_FAILURE);
|
||||
return;
|
||||
}
|
||||
|
@ -709,7 +709,7 @@ void recruit_result::do_check_before()
|
|||
|
||||
void recruit_result::do_check_after()
|
||||
{
|
||||
if (!resources::game_map->on_board(recruit_location_)) {
|
||||
if (!resources::gameboard->map().on_board(recruit_location_)) {
|
||||
set_error(AI_ACTION_FAILURE);
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
|
||||
#include "../../actions/attack.hpp"
|
||||
#include "../../attack_prediction.hpp"
|
||||
#include "../../game_board.hpp"
|
||||
#include "../../resources.hpp"
|
||||
#include "../../log.hpp"
|
||||
#include "../../map.hpp"
|
||||
|
@ -60,11 +61,11 @@ field_couple::field_couple(const map_location& first, const map_location& second
|
|||
number(1) {
|
||||
first_location.first = first.x;
|
||||
first_location.second = first.y;
|
||||
first_field_type = resources::game_map->get_terrain_string(first);
|
||||
first_field_type = resources::gameboard->map().get_terrain_string(first);
|
||||
|
||||
second_location.first = second.x;
|
||||
second_location.second = second.y;
|
||||
second_field_type = resources::game_map->get_terrain_string(second);
|
||||
second_field_type = resources::gameboard->map().get_terrain_string(second);
|
||||
|
||||
}
|
||||
|
||||
|
@ -82,11 +83,11 @@ void terrain_analyze::analyze() {
|
|||
}
|
||||
|
||||
void terrain_analyze::search() {
|
||||
for (int x = 0; x < resources::game_map->w(); x++) {
|
||||
for(int y = 0; y < resources::game_map->h(); y++) {
|
||||
for (int x = 0; x < resources::gameboard->map().w(); x++) {
|
||||
for(int y = 0; y < resources::gameboard->map().h(); y++) {
|
||||
const map_location loc(x,y);
|
||||
if (resources::game_map->is_keep(loc)) {
|
||||
} else if (resources::game_map->is_village(loc)) {
|
||||
if (resources::gameboard->map().is_keep(loc)) {
|
||||
} else if (resources::gameboard->map().is_village(loc)) {
|
||||
village_location_.push_back(loc);
|
||||
}
|
||||
}
|
||||
|
@ -123,8 +124,8 @@ void terrain_analyze::add_terrain(const std::string& terrain) {
|
|||
|
||||
void terrain_analyze::add_village_battle(const map_location& village, const map_location& adj) {
|
||||
// If the battle is already stored, increment the number
|
||||
std::string village_field = resources::game_map->get_terrain_string(village);
|
||||
std::string adj_field = resources::game_map->get_terrain_string(adj);
|
||||
std::string village_field = resources::gameboard->map().get_terrain_string(village);
|
||||
std::string adj_field = resources::gameboard->map().get_terrain_string(adj);
|
||||
|
||||
BOOST_FOREACH(field_couple &couple, couple_field_list_) {
|
||||
if (compareFieldCouple(couple, village_field, adj_field)) {
|
||||
|
@ -380,7 +381,7 @@ double recruitment::evaluate()
|
|||
const map_location &keep = leader->get_location();
|
||||
checked_hexes.insert(keep);
|
||||
|
||||
if (resources::game_map->is_keep(leader->get_location()) && count_free_hexes_in_castle(leader->get_location(), checked_hexes) != 0) {
|
||||
if (resources::gameboard->map().is_keep(leader->get_location()) && count_free_hexes_in_castle(leader->get_location(), checked_hexes) != 0) {
|
||||
return get_score();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -414,7 +414,7 @@ void readonly_context_impl::calculate_moves(const unit_map& units, std::map<map_
|
|||
bool friend_owns = false;
|
||||
|
||||
// Don't take friendly villages
|
||||
if(!enemy && resources::game_map->is_village(dst)) {
|
||||
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)) {
|
||||
int side = n + 1;
|
||||
|
@ -489,7 +489,7 @@ const defensive_position& readonly_context_impl::best_defensive_position(const m
|
|||
typedef move_map::const_iterator Itor;
|
||||
const std::pair<Itor,Itor> itors = srcdst.equal_range(loc);
|
||||
for(Itor i = itors.first; i != itors.second; ++i) {
|
||||
const int defense = itor->defense_modifier(resources::game_map->get_terrain(i->second));
|
||||
const int defense = itor->defense_modifier(resources::gameboard->map().get_terrain(i->second));
|
||||
if(defense > pos.chance_to_hit) {
|
||||
continue;
|
||||
}
|
||||
|
@ -1260,7 +1260,7 @@ void readonly_context_impl::set_src_dst_enemy_valid_lua()
|
|||
}
|
||||
|
||||
const map_location& readonly_context_impl::suitable_keep(const map_location& leader_location, const pathfind::paths& leader_paths){
|
||||
if (resources::game_map->is_keep(leader_location)) {
|
||||
if (resources::gameboard->map().is_keep(leader_location)) {
|
||||
return leader_location; //if leader already on keep, then return leader_location
|
||||
}
|
||||
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
|
||||
#include "../../array.hpp"
|
||||
#include "../../dialogs.hpp"
|
||||
#include "../../game_board.hpp"
|
||||
#include "../../game_events/pump.hpp"
|
||||
#include "../../gamestatus.hpp"
|
||||
#include "../../log.hpp"
|
||||
|
@ -320,7 +321,7 @@ int ai_default_recruitment_stage::average_resistance_against(const unit_type& a,
|
|||
{
|
||||
int weighting_sum = 0, defense = 0;
|
||||
const std::map<t_translation::t_terrain, size_t>& terrain =
|
||||
resources::game_map->get_weighted_terrain_frequencies();
|
||||
resources::gameboard->map().get_weighted_terrain_frequencies();
|
||||
|
||||
for (std::map<t_translation::t_terrain, size_t>::const_iterator j = terrain.begin(),
|
||||
j_end = terrain.end(); j != j_end; ++j)
|
||||
|
@ -584,7 +585,7 @@ void ai_default_recruitment_stage::analyze_potential_recruit_movements()
|
|||
for(std::vector<target>::const_iterator t = targets.begin(); t != targets.end(); ++t) {
|
||||
LOG_AI << "analyzing '" << *i << "' getting to target...\n";
|
||||
pathfind::plain_route route = a_star_search(start, t->loc, 100.0, &calc,
|
||||
resources::game_map->w(), resources::game_map->h());
|
||||
resources::gameboard->map().w(), resources::gameboard->map().h());
|
||||
|
||||
if (!route.steps.empty()) {
|
||||
LOG_AI << "made it: " << route.move_cost << "\n";
|
||||
|
@ -826,7 +827,7 @@ bool ai_default_recruitment_stage::do_play_stage()
|
|||
// We recruit the initial allocation of scouts
|
||||
// based on how many neutral villages there are
|
||||
// that are closer to us than to other keeps.
|
||||
const std::vector<map_location>& villages = resources::game_map->villages();
|
||||
const std::vector<map_location>& villages = resources::gameboard->map().villages();
|
||||
for(std::vector<map_location>::const_iterator v = villages.begin(); v != villages.end(); ++v) {
|
||||
const int owner = village_owner(*v);
|
||||
if(owner == -1) {
|
||||
|
@ -835,7 +836,7 @@ bool ai_default_recruitment_stage::do_play_stage()
|
|||
bool closest = true;
|
||||
for(std::vector<team>::const_iterator i = resources::teams->begin(); i != resources::teams->end(); ++i) {
|
||||
const int index = i - resources::teams->begin() + 1;
|
||||
const map_location& loc = resources::game_map->starting_position(index);
|
||||
const map_location& loc = resources::gameboard->map().starting_position(index);
|
||||
if(loc != start_pos && distance_between(loc,*v) < distance) {
|
||||
closest = false;
|
||||
break;
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
|
||||
#include "contexts.hpp"
|
||||
|
||||
#include "../../game_board.hpp"
|
||||
#include "../../log.hpp"
|
||||
#include "../../map.hpp"
|
||||
#include "../../resources.hpp"
|
||||
|
@ -74,7 +75,7 @@ int default_ai_context_impl::count_free_hexes_in_castle(const map_location &loc,
|
|||
if (checked_hexes.find(adj[n]) != checked_hexes.end())
|
||||
continue;
|
||||
checked_hexes.insert(adj[n]);
|
||||
if (resources::game_map->is_castle(adj[n])) {
|
||||
if (resources::gameboard->map().is_castle(adj[n])) {
|
||||
const unit_map::const_iterator u = units_.find(adj[n]);
|
||||
ret += count_free_hexes_in_castle(adj[n], checked_hexes);
|
||||
if (u == units_.end()
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
#include "../manager.hpp"
|
||||
|
||||
#include "../../callable_objects.hpp"
|
||||
#include "../../game_board.hpp"
|
||||
#include "../../game_display.hpp"
|
||||
#include "../../formula_debugger.hpp"
|
||||
#include "../../log.hpp"
|
||||
|
@ -193,7 +194,7 @@ pathfind::plain_route formula_ai::shortest_path_calculator(const map_location &s
|
|||
get_adjacent_tiles(destination,adj);
|
||||
|
||||
for(size_t n = 0; n != 6; ++n) {
|
||||
if(resources::game_map->on_board(adj[n]) == false) {
|
||||
if(resources::gameboard->map().on_board(adj[n]) == false) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -220,7 +221,7 @@ pathfind::plain_route formula_ai::shortest_path_calculator(const map_location &s
|
|||
}
|
||||
|
||||
pathfind::plain_route route = pathfind::a_star_search(src, destination, 1000.0, &calc,
|
||||
resources::game_map->w(), resources::game_map->h(), &allowed_teleports);
|
||||
resources::gameboard->map().w(), resources::gameboard->map().h(), &allowed_teleports);
|
||||
|
||||
return route;
|
||||
}
|
||||
|
@ -824,7 +825,7 @@ variant formula_ai::get_value(const std::string& key) const
|
|||
return variant(new gamemap_callable(*resources::game_map));
|
||||
} else if(key == "villages")
|
||||
{
|
||||
return villages_from_set(resources::game_map->villages());
|
||||
return villages_from_set(resources::gameboard->map().villages());
|
||||
} else if(key == "villages_of_side")
|
||||
{
|
||||
std::vector<variant> vars;
|
||||
|
@ -844,7 +845,7 @@ variant formula_ai::get_value(const std::string& key) const
|
|||
|
||||
} else if(key == "enemy_and_unowned_villages")
|
||||
{
|
||||
return villages_from_set(resources::game_map->villages(), ¤t_team().villages());
|
||||
return villages_from_set(resources::gameboard->map().villages(), ¤t_team().villages());
|
||||
}
|
||||
|
||||
return variant();
|
||||
|
@ -886,14 +887,14 @@ variant formula_ai::get_keeps() const
|
|||
{
|
||||
if(keeps_cache_.is_null()) {
|
||||
std::vector<variant> vars;
|
||||
for(size_t x = 0; x != size_t(resources::game_map->w()); ++x) {
|
||||
for(size_t y = 0; y != size_t(resources::game_map->h()); ++y) {
|
||||
for(size_t x = 0; x != size_t(resources::gameboard->map().w()); ++x) {
|
||||
for(size_t y = 0; y != size_t(resources::gameboard->map().h()); ++y) {
|
||||
const map_location loc(x,y);
|
||||
if(resources::game_map->is_keep(loc)) {
|
||||
if(resources::gameboard->map().is_keep(loc)) {
|
||||
map_location adj[6];
|
||||
get_adjacent_tiles(loc,adj);
|
||||
for(size_t n = 0; n != 6; ++n) {
|
||||
if(resources::game_map->is_castle(adj[n])) {
|
||||
if(resources::gameboard->map().is_castle(adj[n])) {
|
||||
vars.push_back(variant(new location_callable(loc)));
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
|
||||
#include "ai.hpp"
|
||||
#include "../../attack_prediction.hpp"
|
||||
#include "../../game_board.hpp"
|
||||
#include "callable_objects.hpp"
|
||||
#include "../../resources.hpp"
|
||||
|
||||
|
@ -200,7 +201,7 @@ void attack_map_callable::collect_possible_attacks(std::vector<variant>& vars, m
|
|||
|
||||
for(int n = 0; n != 6; ++n) {
|
||||
/* if adjacent tile is outside the board */
|
||||
if (! resources::game_map->on_board(adj[n]))
|
||||
if (! resources::gameboard->map().on_board(adj[n]))
|
||||
continue;
|
||||
unit_map::const_iterator unit = units_.find(adj[n]);
|
||||
/* if tile is empty */
|
||||
|
|
|
@ -121,7 +121,7 @@ private:
|
|||
variant execute(const formula_callable& variables, formula_debugger *fdb) const {
|
||||
const map_location loc = convert_variant<location_callable>(args()[0]->evaluate(variables,add_debug_info(fdb,0,"distance_to_nearest_unowned_village:location")))->loc();
|
||||
int best = 1000000;
|
||||
const std::vector<map_location>& villages = resources::game_map->villages();
|
||||
const std::vector<map_location>& villages = resources::gameboard->map().villages();
|
||||
const std::set<map_location>& my_villages = ai_.current_team().villages();
|
||||
for(std::vector<map_location>::const_iterator i = villages.begin(); i != villages.end(); ++i) {
|
||||
int distance = distance_between(loc, *i);
|
||||
|
@ -265,8 +265,8 @@ private:
|
|||
}
|
||||
|
||||
variant execute(const formula_callable& variables, formula_debugger *fdb) const {
|
||||
int w = resources::game_map->w();
|
||||
int h = resources::game_map->h();
|
||||
int w = resources::gameboard->map().w();
|
||||
int h = resources::gameboard->map().h();
|
||||
|
||||
const variant units_input = args()[0]->evaluate(variables,fdb);
|
||||
const variant leaders_input = args()[1]->evaluate(variables,fdb);
|
||||
|
@ -438,7 +438,7 @@ private:
|
|||
|
||||
std::vector<variant> v;
|
||||
for(int n = 0; n != 6; ++n) {
|
||||
if (resources::game_map->on_board(adj[n]) )
|
||||
if (resources::gameboard->map().on_board(adj[n]) )
|
||||
v.push_back(variant(new location_callable(adj[n])));
|
||||
}
|
||||
|
||||
|
@ -475,7 +475,7 @@ private:
|
|||
v.push_back(variant(new location_callable(loc)));
|
||||
|
||||
for(size_t n = 0; n != res.size(); ++n) {
|
||||
if (resources::game_map->on_board(res[n]) )
|
||||
if (resources::gameboard->map().on_board(res[n]) )
|
||||
v.push_back(variant(new location_callable(res[n])));
|
||||
}
|
||||
|
||||
|
@ -549,17 +549,17 @@ private:
|
|||
get_adjacent_tiles(loc, adj);
|
||||
|
||||
for(int n = 0; n != 6; ++n) {
|
||||
if (resources::game_map->on_board(adj[n]) && visited_locs.find( adj[n] ) == visited_locs.end() ) {
|
||||
if (resources::game_map->get_terrain_info(adj[n]).is_keep() ||
|
||||
resources::game_map->get_terrain_info(adj[n]).is_castle() ) {
|
||||
if (resources::gameboard->map().on_board(adj[n]) && visited_locs.find( adj[n] ) == visited_locs.end() ) {
|
||||
if (resources::gameboard->map().get_terrain_info(adj[n]).is_keep() ||
|
||||
resources::gameboard->map().get_terrain_info(adj[n]).is_castle() ) {
|
||||
queued_locs.push(adj[n]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( !resources::game_map->get_terrain_info(starting_loc).is_keep() &&
|
||||
!resources::game_map->get_terrain_info(starting_loc).is_castle() )
|
||||
if ( !resources::gameboard->map().get_terrain_info(starting_loc).is_keep() &&
|
||||
!resources::gameboard->map().get_terrain_info(starting_loc).is_castle() )
|
||||
visited_locs.erase(starting_loc);
|
||||
|
||||
std::vector<variant> res;
|
||||
|
@ -692,8 +692,8 @@ private:
|
|||
w = m.w();
|
||||
h = m.h();
|
||||
} else {
|
||||
w = resources::game_map->w();
|
||||
h = resources::game_map->h();
|
||||
w = resources::gameboard->map().w();
|
||||
h = resources::gameboard->map().h();
|
||||
}
|
||||
|
||||
for(int i = 0; i < w; ++i)
|
||||
|
@ -758,8 +758,8 @@ private:
|
|||
map_location att_loc = convert_variant<location_callable>(args()[0]->evaluate(variables,add_debug_info(fdb,0,"aki_eval:attacker_current_location")))->loc();
|
||||
map_location def_loc = convert_variant<location_callable>(args()[1]->evaluate(variables,add_debug_info(fdb,1,"aki_eval:defender_current_location")))->loc();
|
||||
|
||||
terrain.push_back(variant(resources::game_map->get_terrain_string(att_loc)));
|
||||
terrain.push_back(variant(resources::game_map->get_terrain_string(def_loc)));
|
||||
terrain.push_back(variant(resources::gameboard->map().get_terrain_string(att_loc)));
|
||||
terrain.push_back(variant(resources::gameboard->map().get_terrain_string(def_loc)));
|
||||
|
||||
std::string att = args()[2]->evaluate(variables,add_debug_info(fdb,2,"aki_eval:atta_type")).as_string();
|
||||
std::string def = args()[3]->evaluate(variables,add_debug_info(fdb,3,"aki_eval:def_type")).as_string();
|
||||
|
@ -1147,7 +1147,7 @@ private:
|
|||
|
||||
pathfind::emergency_path_calculator em_calc(*unit_it, *resources::game_map);
|
||||
|
||||
pathfind::plain_route route = pathfind::a_star_search(src, dst, 1000.0, &em_calc, resources::game_map->w(), resources::game_map->h(), &allowed_teleports);
|
||||
pathfind::plain_route route = pathfind::a_star_search(src, dst, 1000.0, &em_calc, resources::gameboard->map().w(), resources::gameboard->map().h(), &allowed_teleports);
|
||||
|
||||
if( route.steps.size() < 2 ) {
|
||||
return variant(&locations);
|
||||
|
@ -1526,7 +1526,7 @@ private:
|
|||
if( un.total_movement() < un.movement_cost( (*resources::game_map)[loc]) )
|
||||
return variant();
|
||||
|
||||
if(!resources::game_map->on_board(loc)) {
|
||||
if(!resources::gameboard->map().on_board(loc)) {
|
||||
return variant();
|
||||
}
|
||||
|
||||
|
@ -1540,7 +1540,7 @@ private:
|
|||
if( un.movement() < un.movement_type().movement_cost((*resources::game_map)[loc]) )
|
||||
return variant();
|
||||
|
||||
if(!resources::game_map->on_board(loc)) {
|
||||
if(!resources::gameboard->map().on_board(loc)) {
|
||||
return variant();
|
||||
}
|
||||
|
||||
|
@ -1573,7 +1573,7 @@ private:
|
|||
{
|
||||
const unit& un = u_call->get_unit();
|
||||
|
||||
if(!resources::game_map->on_board(loc)) {
|
||||
if(!resources::gameboard->map().on_board(loc)) {
|
||||
return variant();
|
||||
}
|
||||
|
||||
|
@ -1584,7 +1584,7 @@ private:
|
|||
{
|
||||
const unit_type& un = u_type->get_unit_type();
|
||||
|
||||
if(!resources::game_map->on_board(loc)) {
|
||||
if(!resources::gameboard->map().on_board(loc)) {
|
||||
return variant();
|
||||
}
|
||||
|
||||
|
@ -1617,7 +1617,7 @@ private:
|
|||
{
|
||||
const unit& un = u_call->get_unit();
|
||||
|
||||
if(!resources::game_map->on_board(loc)) {
|
||||
if(!resources::gameboard->map().on_board(loc)) {
|
||||
return variant();
|
||||
}
|
||||
|
||||
|
@ -1628,7 +1628,7 @@ private:
|
|||
{
|
||||
const unit_type& un = u_type->get_unit_type();
|
||||
|
||||
if(!resources::game_map->on_board(loc)) {
|
||||
if(!resources::gameboard->map().on_board(loc)) {
|
||||
return variant();
|
||||
}
|
||||
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#include "../manager.hpp"
|
||||
#include "../../actions/attack.hpp"
|
||||
#include "../../attack_prediction.hpp"
|
||||
#include "../../game_board.hpp"
|
||||
#include "../../game_display.hpp"
|
||||
#include "../../log.hpp"
|
||||
#include "../../map.hpp"
|
||||
|
@ -177,7 +178,7 @@ double recruitment::evaluate() {
|
|||
}
|
||||
|
||||
const map_location& loc = leader->get_location();
|
||||
if (resources::game_map->is_keep(loc) &&
|
||||
if (resources::gameboard->map().is_keep(loc) &&
|
||||
pathfind::find_vacant_castle(*leader) != map_location::null_location()) {
|
||||
return get_score();
|
||||
}
|
||||
|
@ -206,7 +207,7 @@ void recruitment::execute() {
|
|||
|
||||
BOOST_FOREACH(const unit_map::const_iterator& leader, leaders) {
|
||||
const map_location& keep = leader->get_location();
|
||||
if (!resources::game_map->is_keep(keep)) {
|
||||
if (!resources::gameboard->map().is_keep(keep)) {
|
||||
LOG_AI_RECRUITMENT << "Leader " << leader->name() << " is not on keep. \n";
|
||||
continue;
|
||||
}
|
||||
|
@ -1708,7 +1709,7 @@ void recruitment::update_scouts_wanted() {
|
|||
int neutral_villages = 0;
|
||||
// We recruit the initial allocation of scouts
|
||||
// based on how many neutral villages there are.
|
||||
BOOST_FOREACH(const map_location& village, resources::game_map->villages()) {
|
||||
BOOST_FOREACH(const map_location& village, resources::gameboard->map().villages()) {
|
||||
if (village_owner(village) == -1) {
|
||||
++neutral_villages;
|
||||
}
|
||||
|
|
|
@ -153,12 +153,12 @@ double aspect_recruitment_phase::evaluate()
|
|||
if(leader == resources::units->end()) {
|
||||
return BAD_SCORE;
|
||||
}
|
||||
if (!resources::game_map->is_keep(leader->get_location())) {
|
||||
if (!resources::gameboard->map().is_keep(leader->get_location())) {
|
||||
return BAD_SCORE;
|
||||
}
|
||||
|
||||
map_location recruit_loc = pathfind::find_vacant_castle(*leader);
|
||||
if (!resources::game_map->on_board(recruit_loc)) {
|
||||
if (!resources::gameboard->map().on_board(recruit_loc)) {
|
||||
return BAD_SCORE;
|
||||
}
|
||||
|
||||
|
@ -200,7 +200,7 @@ double recruitment_phase::evaluate()
|
|||
if(leader == resources::units->end()) {
|
||||
return BAD_SCORE;
|
||||
}
|
||||
if (!resources::game_map->is_keep(leader->get_location())) {
|
||||
if (!resources::gameboard->map().is_keep(leader->get_location())) {
|
||||
return BAD_SCORE;
|
||||
}
|
||||
|
||||
|
@ -385,7 +385,7 @@ int recruitment_phase::average_resistance_against(const unit_type& a, const unit
|
|||
{
|
||||
int weighting_sum = 0, defense = 0;
|
||||
const std::map<t_translation::t_terrain, size_t>& terrain =
|
||||
resources::game_map->get_weighted_terrain_frequencies();
|
||||
resources::gameboard->map().get_weighted_terrain_frequencies();
|
||||
|
||||
for (std::map<t_translation::t_terrain, size_t>::const_iterator j = terrain.begin(),
|
||||
j_end = terrain.end(); j != j_end; ++j)
|
||||
|
@ -690,7 +690,7 @@ double move_leader_to_goals_phase::evaluate()
|
|||
|
||||
pathfind::shortest_path_calculator calc(*leader, current_team(), *resources::teams, *resources::game_map);
|
||||
pathfind::plain_route route = a_star_search(leader->get_location(), dst_, 1000.0, &calc,
|
||||
resources::game_map->w(), resources::game_map->h());
|
||||
resources::gameboard->map().w(), resources::gameboard->map().h());
|
||||
if(route.steps.empty()) {
|
||||
LOG_AI_TESTING_AI_DEFAULT << "route empty";
|
||||
return BAD_SCORE;
|
||||
|
@ -808,7 +808,7 @@ double move_leader_to_keep_phase::evaluate()
|
|||
const pathfind::teleport_map allowed_teleports = pathfind::get_teleport_locations(*leader, current_team());
|
||||
|
||||
pathfind::plain_route route;
|
||||
route = pathfind::a_star_search(leader->get_location(), keep, 10000.0, &calc, resources::game_map->w(), resources::game_map->h(), &allowed_teleports);
|
||||
route = pathfind::a_star_search(leader->get_location(), keep, 10000.0, &calc, resources::gameboard->map().w(), resources::gameboard->map().h(), &allowed_teleports);
|
||||
|
||||
if (!route.steps.empty() || route.move_cost < shortest_distance) {
|
||||
best_leader = &(*leader);
|
||||
|
@ -844,7 +844,7 @@ double move_leader_to_keep_phase::evaluate()
|
|||
ordered_locations moves_toward_keep;
|
||||
|
||||
pathfind::plain_route route;
|
||||
route = pathfind::a_star_search(leader->get_location(), keep, 10000.0, &calc, resources::game_map->w(), resources::game_map->h(), &allowed_teleports);
|
||||
route = pathfind::a_star_search(leader->get_location(), keep, 10000.0, &calc, resources::gameboard->map().w(), resources::gameboard->map().h(), &allowed_teleports);
|
||||
|
||||
// find next hop
|
||||
map_location next_hop = map_location::null_location();
|
||||
|
@ -852,7 +852,7 @@ double move_leader_to_keep_phase::evaluate()
|
|||
BOOST_FOREACH(const map_location& step, route.steps) {
|
||||
if (leader_paths.destinations.contains(step)) {
|
||||
next_hop = step;
|
||||
next_hop_cost += leader->movement_cost(resources::game_map->get_terrain(step));
|
||||
next_hop_cost += leader->movement_cost(resources::gameboard->map().get_terrain(step));
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
|
@ -866,7 +866,7 @@ double move_leader_to_keep_phase::evaluate()
|
|||
BOOST_FOREACH(const pathfind::paths::step &dest, leader_paths.destinations) {
|
||||
if (!units_.find(dest.curr).valid()) {
|
||||
route = pathfind::a_star_search(dest.curr, next_hop, 10000.0, &calc,
|
||||
resources::game_map->w(), resources::game_map->h(), &allowed_teleports);
|
||||
resources::gameboard->map().w(), resources::gameboard->map().h(), &allowed_teleports);
|
||||
if (route.move_cost < next_hop_cost) {
|
||||
moves_toward_keep.insert(std::make_pair(route.move_cost, dest.curr));
|
||||
}
|
||||
|
@ -963,7 +963,7 @@ void get_villages_phase::execute()
|
|||
|
||||
if(leader_move.second.valid()) {
|
||||
if((resources::gameboard->find_visible_unit(leader_move.first , current_team()) == units_.end())
|
||||
&& resources::game_map->is_village(leader_move.first)) {
|
||||
&& resources::gameboard->map().is_village(leader_move.first)) {
|
||||
move_result_ptr move_res = execute_move_action(leader_move.second,leader_move.first,true);
|
||||
if (!move_res->is_ok()) {
|
||||
return;
|
||||
|
@ -1741,7 +1741,7 @@ double get_healing_phase::evaluate()
|
|||
Itor best_loc = it.second;
|
||||
while(it.first != it.second) {
|
||||
const map_location& dst = it.first->second;
|
||||
if (resources::game_map->gives_healing(dst) && (units_.find(dst) == units_.end() || dst == u_it->get_location())) {
|
||||
if (resources::gameboard->map().gives_healing(dst) && (units_.find(dst) == units_.end() || dst == u_it->get_location())) {
|
||||
const double vuln = power_projection(dst, get_enemy_dstsrc());
|
||||
DBG_AI_TESTING_AI_DEFAULT << "found village with vulnerability: " << vuln << "\n";
|
||||
if(vuln < best_vulnerability) {
|
||||
|
@ -1852,8 +1852,8 @@ double retreat_phase::evaluate()
|
|||
map_location best_pos, best_defensive(i->get_location());
|
||||
|
||||
double best_rating = -1000.0;
|
||||
int best_defensive_rating = i->defense_modifier(resources::game_map->get_terrain(i->get_location()))
|
||||
- (resources::game_map->is_village(i->get_location()) ? 10 : 0);
|
||||
int best_defensive_rating = i->defense_modifier(resources::gameboard->map().get_terrain(i->get_location()))
|
||||
- (resources::gameboard->map().is_village(i->get_location()) ? 10 : 0);
|
||||
while(itors.first != itors.second) {
|
||||
|
||||
//if(leader != units_.end() && std::count(leader_adj,
|
||||
|
@ -1868,7 +1868,7 @@ double retreat_phase::evaluate()
|
|||
// compared to theirs, multiplying their power projection by their
|
||||
// chance to hit us on the hex we're planning to flee to.
|
||||
const map_location& hex = itors.first->second;
|
||||
const int defense = i->defense_modifier(resources::game_map->get_terrain(hex));
|
||||
const int defense = i->defense_modifier(resources::gameboard->map().get_terrain(hex));
|
||||
const double our_power = power_projection(hex,get_dstsrc());
|
||||
const double their_power = power_projection(hex,get_enemy_dstsrc()) * double(defense)/100.0;
|
||||
const double rating = our_power - their_power;
|
||||
|
@ -1878,7 +1878,7 @@ double retreat_phase::evaluate()
|
|||
}
|
||||
|
||||
// Give a bonus for getting to a village.
|
||||
const int modified_defense = defense - (resources::game_map->is_village(hex) ? 10 : 0);
|
||||
const int modified_defense = defense - (resources::gameboard->map().is_village(hex) ? 10 : 0);
|
||||
|
||||
if(modified_defense < best_defensive_rating) {
|
||||
best_defensive_rating = modified_defense;
|
||||
|
@ -1932,7 +1932,7 @@ bool retreat_phase::should_retreat(const map_location& loc, const unit_map::cons
|
|||
double optimal_terrain = best_defensive_position(un->get_location(), dstsrc,
|
||||
srcdst, enemy_dstsrc).chance_to_hit/100.0;
|
||||
const double proposed_terrain =
|
||||
un->defense_modifier(resources::game_map->get_terrain(loc)) / 100.0;
|
||||
un->defense_modifier(resources::gameboard->map().get_terrain(loc)) / 100.0;
|
||||
|
||||
// The 'exposure' is the additional % chance to hit
|
||||
// this unit receives from being on a sub-optimal defensive terrain.
|
||||
|
@ -2087,11 +2087,11 @@ void leader_shares_keep_phase::execute()
|
|||
BOOST_FOREACH(unit_map::unit_iterator &ai_leader, ai_leaders){
|
||||
//only if leader is on a keep
|
||||
const map_location &keep = ai_leader->get_location();
|
||||
if ( !resources::game_map->is_keep(keep) ) {
|
||||
if ( !resources::gameboard->map().is_keep(keep) ) {
|
||||
continue;
|
||||
}
|
||||
map_location recruit_loc = pathfind::find_vacant_castle(*ai_leader);
|
||||
if(!resources::game_map->on_board(recruit_loc)){
|
||||
if(!resources::gameboard->map().on_board(recruit_loc)){
|
||||
continue;
|
||||
}
|
||||
bool friend_can_reach_keep = false;
|
||||
|
@ -2121,7 +2121,7 @@ void leader_shares_keep_phase::execute()
|
|||
if(distance_between(i->curr, keep) <= 3
|
||||
&& static_cast<int>(distance_between(i->curr, keep)) <= ai_leader->movement_left()){
|
||||
|
||||
int tmp_def_mod = ai_leader->defense_modifier(resources::game_map->get_terrain(i->curr));
|
||||
int tmp_def_mod = ai_leader->defense_modifier(resources::gameboard->map().get_terrain(i->curr));
|
||||
if(tmp_def_mod < defense_modifier){
|
||||
defense_modifier = tmp_def_mod;
|
||||
best_move = i->curr;
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
|
||||
#include "../composite/ai.hpp"
|
||||
#include "../actions.hpp"
|
||||
#include "../../game_board.hpp"
|
||||
#include "../../log.hpp"
|
||||
#include "../../map.hpp"
|
||||
#include "../../resources.hpp"
|
||||
|
@ -161,15 +162,15 @@ void testing_move_to_targets_phase::execute()
|
|||
|
||||
for(std::vector<target>::const_iterator ittg = targets.begin();
|
||||
ittg != targets.end(); ++ittg) {
|
||||
assert(resources::game_map->on_board(ittg->loc));
|
||||
assert(resources::gameboard->map().on_board(ittg->loc));
|
||||
}
|
||||
|
||||
if(move.first.valid() == false || move.second.valid() == false) {
|
||||
break;
|
||||
}
|
||||
|
||||
assert (resources::game_map->on_board(move.first)
|
||||
&& resources::game_map->on_board(move.second));
|
||||
assert (resources::gameboard->map().on_board(move.first)
|
||||
&& resources::gameboard->map().on_board(move.second));
|
||||
|
||||
LOG_AI << "move: " << move.first << " -> " << move.second << '\n';
|
||||
|
||||
|
@ -858,7 +859,7 @@ bool testing_move_to_targets_phase::should_retreat(const map_location& loc, cons
|
|||
double optimal_terrain = best_defensive_position(un->get_location(), dstsrc,
|
||||
srcdst, enemy_dstsrc).chance_to_hit/100.0;
|
||||
const double proposed_terrain =
|
||||
un->defense_modifier(resources::game_map->get_terrain(loc))/100.0;
|
||||
un->defense_modifier(resources::gameboard->map().get_terrain(loc))/100.0;
|
||||
|
||||
// The 'exposure' is the additional % chance to hit
|
||||
// this unit receives from being on a sub-optimal defensive terrain.
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
#include "../composite/engine.hpp"
|
||||
#include "../composite/rca.hpp"
|
||||
#include "../composite/stage.hpp"
|
||||
#include "../../game_board.hpp"
|
||||
#include "../../gamestatus.hpp"
|
||||
#include "../../log.hpp"
|
||||
#include "../../map.hpp"
|
||||
|
@ -73,7 +74,7 @@ double testing_recruitment_phase::evaluate()
|
|||
if(leader == resources::units->end()) {
|
||||
return BAD_SCORE;
|
||||
}
|
||||
if (!resources::game_map->is_keep(leader->get_location())) {
|
||||
if (!resources::gameboard->map().is_keep(leader->get_location())) {
|
||||
return BAD_SCORE;
|
||||
}
|
||||
|
||||
|
@ -255,7 +256,7 @@ static int average_resistance_against(const unit_type& a, const unit_type& b)
|
|||
{
|
||||
int weighting_sum = 0, defense = 0;
|
||||
const std::map<t_translation::t_terrain, size_t>& terrain =
|
||||
resources::game_map->get_weighted_terrain_frequencies();
|
||||
resources::gameboard->map().get_weighted_terrain_frequencies();
|
||||
|
||||
for (std::map<t_translation::t_terrain, size_t>::const_iterator j = terrain.begin(),
|
||||
j_end = terrain.end(); j != j_end; ++j)
|
||||
|
|
|
@ -1594,11 +1594,11 @@ WML_HANDLER_FUNCTION(recall, /*event_info*/, cfg)
|
|||
if ( (leader_filter.null() || leader->matches_filter(leader_filter)) &&
|
||||
u->matches_filter(vconfig(leader->recall_filter()), map_location()) ) {
|
||||
DBG_NG << "...matched the leader filter and is able to recall the unit.\n";
|
||||
if(!resources::game_map->on_board(loc))
|
||||
if(!resources::gameboard->map().on_board(loc))
|
||||
loc = leader->get_location();
|
||||
if(pass_check || (resources::units->count(loc) > 0))
|
||||
loc = pathfind::find_vacant_tile(loc, pathfind::VACANT_ANY, pass_check);
|
||||
if(resources::game_map->on_board(loc)) {
|
||||
if(resources::gameboard->map().on_board(loc)) {
|
||||
DBG_NG << "...valid location for the recall found. Recalling.\n";
|
||||
avail.erase(u); // Erase before recruiting, since recruiting can fire more events
|
||||
actions::place_recruit(to_recruit, loc, leader->get_location(), 0, true,
|
||||
|
@ -1608,12 +1608,12 @@ WML_HANDLER_FUNCTION(recall, /*event_info*/, cfg)
|
|||
}
|
||||
}
|
||||
}
|
||||
if (resources::game_map->on_board(cfg_loc)) {
|
||||
if (resources::gameboard->map().on_board(cfg_loc)) {
|
||||
map_location loc = cfg_loc;
|
||||
if(pass_check || (resources::units->count(loc) > 0))
|
||||
loc = pathfind::find_vacant_tile(loc, pathfind::VACANT_ANY, pass_check);
|
||||
// Check if we still have a valid location
|
||||
if (resources::game_map->on_board(loc)) {
|
||||
if (resources::gameboard->map().on_board(loc)) {
|
||||
DBG_NG << "No usable leader found, but found usable location. Recalling.\n";
|
||||
avail.erase(u); // Erase before recruiting, since recruiting can fire more events
|
||||
map_location null_location = map_location::null_location();
|
||||
|
@ -2330,13 +2330,13 @@ WML_HANDLER_FUNCTION(teleport, event_info, cfg)
|
|||
|
||||
// We have found a unit that matches the filter
|
||||
const map_location dst = cfg_to_loc(cfg);
|
||||
if (dst == u->get_location() || !resources::game_map->on_board(dst)) return;
|
||||
if (dst == u->get_location() || !resources::gameboard->map().on_board(dst)) return;
|
||||
|
||||
const unit* pass_check = NULL;
|
||||
if (cfg["check_passability"].to_bool(true))
|
||||
pass_check = &*u;
|
||||
const map_location vacant_dst = find_vacant_tile(dst, pathfind::VACANT_ANY, pass_check);
|
||||
if (!resources::game_map->on_board(vacant_dst)) return;
|
||||
if (!resources::gameboard->map().on_board(vacant_dst)) return;
|
||||
|
||||
// Clear the destination hex before the move (so the animation can be seen).
|
||||
bool clear_shroud = cfg["clear_shroud"].to_bool(true);
|
||||
|
@ -2364,7 +2364,7 @@ WML_HANDLER_FUNCTION(teleport, event_info, cfg)
|
|||
clearer.clear_unit(vacant_dst, *u);
|
||||
}
|
||||
|
||||
if (resources::game_map->is_village(vacant_dst)) {
|
||||
if (resources::gameboard->map().is_village(vacant_dst)) {
|
||||
actions::get_village(vacant_dst, u->side());
|
||||
}
|
||||
|
||||
|
@ -2492,7 +2492,7 @@ WML_HANDLER_FUNCTION(unit, /*event_info*/, cfg)
|
|||
}
|
||||
team &tm = resources::teams->at(side-1);
|
||||
|
||||
unit_creator uc(tm,resources::game_map->starting_position(side));
|
||||
unit_creator uc(tm,resources::gameboard->map().starting_position(side));
|
||||
|
||||
uc
|
||||
.allow_add_to_recall(true)
|
||||
|
@ -2519,7 +2519,7 @@ WML_HANDLER_FUNCTION(unstore_unit, /*event_info*/, cfg)
|
|||
map_location loc = cfg_to_loc(
|
||||
(cfg.has_attribute("x") && cfg.has_attribute("y")) ? cfg : vconfig(var));
|
||||
const bool advance = cfg["advance"].to_bool(true);
|
||||
if(resources::game_map->on_board(loc)) {
|
||||
if(resources::gameboard->map().on_board(loc)) {
|
||||
if (cfg["find_vacant"].to_bool()) {
|
||||
const unit* pass_check = NULL;
|
||||
if (cfg["check_passability"].to_bool(true)) pass_check = &u;
|
||||
|
|
15
src/help.cpp
15
src/help.cpp
|
@ -26,6 +26,7 @@
|
|||
#include "about.hpp"
|
||||
#include "display.hpp"
|
||||
#include "exceptions.hpp"
|
||||
#include "game_board.hpp"
|
||||
#include "game_preferences.hpp"
|
||||
#include "gettext.hpp"
|
||||
#include "gui/dialogs/transient_message.hpp"
|
||||
|
@ -1321,13 +1322,13 @@ public:
|
|||
|
||||
if (!(type_.union_type().size() == 1 && type_.union_type()[0] == type_.number() && type_.is_nonnull())) {
|
||||
|
||||
const t_translation::t_list& underlying_terrains = resources::game_map->underlying_mvt_terrain(type_.number());
|
||||
const t_translation::t_list& underlying_terrains = resources::gameboard->map().underlying_mvt_terrain(type_.number());
|
||||
|
||||
ss << "\n" << N_("Base Terrain: ");
|
||||
|
||||
bool first = true;
|
||||
BOOST_FOREACH(const t_translation::t_terrain& underlying_terrain, underlying_terrains) {
|
||||
const terrain_type& mvt_base = resources::game_map->get_terrain_info(underlying_terrain);
|
||||
const terrain_type& mvt_base = resources::gameboard->map().get_terrain_info(underlying_terrain);
|
||||
|
||||
if (mvt_base.editor_name().empty()) continue;
|
||||
if (!first) ss << ",";
|
||||
|
@ -1688,7 +1689,7 @@ public:
|
|||
const t_translation::t_terrain terrain = *terrain_it;
|
||||
if (terrain == t_translation::FOGGED || terrain == t_translation::VOID_TERRAIN || terrain == t_translation::OFF_MAP_USER)
|
||||
continue;
|
||||
const terrain_type& info = resources::game_map->get_terrain_info(terrain);
|
||||
const terrain_type& info = resources::gameboard->map().get_terrain_info(terrain);
|
||||
|
||||
if (info.union_type().size() == 1 && info.union_type()[0] == info.number() && info.is_nonnull()) {
|
||||
std::vector<item> row;
|
||||
|
@ -1903,11 +1904,11 @@ void generate_terrain_sections(const config* /*help_cfg*/, section& sec, int /*l
|
|||
|
||||
std::map<std::string, section> base_map;
|
||||
|
||||
const t_translation::t_list& t_listi = resources::game_map->get_terrain_list();
|
||||
const t_translation::t_list& t_listi = resources::gameboard->map().get_terrain_list();
|
||||
|
||||
BOOST_FOREACH(const t_translation::t_terrain& t, t_listi) {
|
||||
|
||||
const terrain_type& info = resources::game_map->get_terrain_info(t);
|
||||
const terrain_type& info = resources::gameboard->map().get_terrain_info(t);
|
||||
|
||||
bool hidden = info.is_combined() || info.hide_help();
|
||||
|
||||
|
@ -1920,10 +1921,10 @@ void generate_terrain_sections(const config* /*help_cfg*/, section& sec, int /*l
|
|||
terrain_topic.id = hidden_symbol(hidden) + terrain_prefix + info.id();
|
||||
terrain_topic.text = new terrain_topic_generator(info);
|
||||
|
||||
t_translation::t_list base_terrains = resources::game_map->underlying_union_terrain(t);
|
||||
t_translation::t_list base_terrains = resources::gameboard->map().underlying_union_terrain(t);
|
||||
BOOST_FOREACH(const t_translation::t_terrain& base, base_terrains) {
|
||||
|
||||
const terrain_type& base_info = resources::game_map->get_terrain_info(base);
|
||||
const terrain_type& base_info = resources::gameboard->map().get_terrain_info(base);
|
||||
|
||||
if (!base_info.is_nonnull() || base_info.hide_help())
|
||||
continue;
|
||||
|
|
|
@ -904,7 +904,7 @@ void menu_handler::terrain_description(mouse_handler& mousehandler)
|
|||
}
|
||||
|
||||
const terrain_type& type = map_.get_terrain_info(loc);
|
||||
//const terrain_type& info = resources::game_map->get_terrain_info(terrain);
|
||||
//const terrain_type& info = resources::gameboard->map().get_terrain_info(terrain);
|
||||
dialogs::show_terrain_description(type);
|
||||
}
|
||||
|
||||
|
|
|
@ -104,7 +104,7 @@ void mouse_handler::mouse_motion(int x, int y, const bool browse, bool update, m
|
|||
|
||||
if(new_hex != last_hex_) {
|
||||
update = true;
|
||||
if ( resources::game_map->on_board(last_hex_) ) {
|
||||
if ( resources::gameboard->map().on_board(last_hex_) ) {
|
||||
// we store the previous hexes used to propose attack direction
|
||||
previous_hex_ = last_hex_;
|
||||
// the hex of the selected unit is also "free"
|
||||
|
@ -140,7 +140,7 @@ void mouse_handler::mouse_motion(int x, int y, const bool browse, bool update, m
|
|||
|
||||
// reset current_route_ and current_paths if not valid anymore
|
||||
// we do it before cursor selection, because it uses current_paths_
|
||||
if( !resources::game_map->on_board(new_hex) ) {
|
||||
if( !resources::gameboard->map().on_board(new_hex) ) {
|
||||
current_route_.steps.clear();
|
||||
gui().set_route(NULL);
|
||||
resources::whiteboard->erase_temp_move();
|
||||
|
@ -492,7 +492,7 @@ void mouse_handler::mouse_wheel_right(int /*x*/, int /*y*/, const bool /*browse*
|
|||
|
||||
void mouse_handler::select_or_action(bool browse)
|
||||
{
|
||||
if (!resources::game_map->on_board(last_hex_))
|
||||
if (!resources::gameboard->map().on_board(last_hex_))
|
||||
return;
|
||||
|
||||
unit_map::iterator clicked_u = find_unit(last_hex_);
|
||||
|
@ -523,7 +523,7 @@ void mouse_handler::move_action(bool browse)
|
|||
// TODO
|
||||
// // Clicks on border hexes mean to deselect.
|
||||
// // (Check this before doing processing that might not be needed.)
|
||||
// if ( !resources::game_map->on_board(hex) ) {
|
||||
// if ( !resources::gameboard->map().on_board(hex) ) {
|
||||
// deselect_hex();
|
||||
// return false;
|
||||
// }
|
||||
|
@ -843,7 +843,7 @@ size_t mouse_handler::move_unit_along_route(const std::vector<map_location> & st
|
|||
|
||||
//If this is a leader on a keep, ask permission to the whiteboard to move it
|
||||
//since otherwise it may cause planned recruits to be erased.
|
||||
if ( resources::game_map->is_keep(steps.front()) )
|
||||
if ( resources::gameboard->map().is_keep(steps.front()) )
|
||||
{
|
||||
unit_map::const_iterator const u = board_.units().find(steps.front());
|
||||
|
||||
|
|
|
@ -649,7 +649,7 @@ marked_route mark_route(const plain_route &rt)
|
|||
bool last_step = (i+1 == rt.steps.end());
|
||||
|
||||
// move_cost of the next step is irrelevant for the last step
|
||||
assert(last_step || resources::game_map->on_board(*(i+1)));
|
||||
assert(last_step || resources::gameboard->map().on_board(*(i+1)));
|
||||
const int move_cost = last_step ? 0 : u.movement_cost((*resources::game_map)[*(i+1)]);
|
||||
|
||||
team const& viewing_team = (*resources::teams)[resources::screen->viewing_team()];
|
||||
|
@ -659,7 +659,7 @@ marked_route mark_route(const plain_route &rt)
|
|||
// if it's an enemy unit and a fogged village, we assume a capture
|
||||
// (if he already owns it, we can't know that)
|
||||
// if it's not an enemy, we can always know if he owns the village
|
||||
bool capture = resources::game_map->is_village(*i) && ( !unit_team.owns_village(*i)
|
||||
bool capture = resources::gameboard->map().is_village(*i) && ( !unit_team.owns_village(*i)
|
||||
|| (viewing_team.is_enemy(u.side()) && viewing_team.fogged(*i)) );
|
||||
|
||||
++turns;
|
||||
|
|
|
@ -1290,8 +1290,8 @@ bool play_controller::in_context_menu(hotkey::HOTKEY_COMMAND command) const
|
|||
|
||||
// A quick check to save us having to create the future map and
|
||||
// possibly loop through all units.
|
||||
if ( !resources::game_map->is_keep(last_hex) &&
|
||||
!resources::game_map->is_castle(last_hex) )
|
||||
if ( !resources::gameboard->map().is_keep(last_hex) &&
|
||||
!resources::gameboard->map().is_castle(last_hex) )
|
||||
return false;
|
||||
|
||||
wb::future_map future; /* lasts until method returns. */
|
||||
|
|
|
@ -318,7 +318,7 @@ static config unit_status(const unit* u)
|
|||
if (!u) return report();
|
||||
config res;
|
||||
map_location displayed_unit_hex = resources::screen->displayed_unit_hex();
|
||||
if (resources::game_map->on_board(displayed_unit_hex) && u->invisible(displayed_unit_hex)) {
|
||||
if (resources::gameboard->map().on_board(displayed_unit_hex) && u->invisible(displayed_unit_hex)) {
|
||||
add_status(res, "misc/invisible.png", N_("invisible: "),
|
||||
N_("This unit is invisible. It cannot be seen or attacked by enemy units."));
|
||||
}
|
||||
|
@ -529,7 +529,7 @@ static config unit_defense(const unit* u, const map_location& displayed_unit_hex
|
|||
|
||||
std::ostringstream str, tooltip;
|
||||
const gamemap &map = *resources::game_map;
|
||||
if(!resources::game_map->on_board(displayed_unit_hex)) {
|
||||
if(!resources::gameboard->map().on_board(displayed_unit_hex)) {
|
||||
return report();
|
||||
}
|
||||
|
||||
|
@ -617,7 +617,7 @@ static config unit_moves(const unit* u)
|
|||
if (terrain == t_translation::FOGGED || terrain == t_translation::VOID_TERRAIN || terrain == t_translation::OFF_MAP_USER)
|
||||
continue;
|
||||
|
||||
const terrain_type& info = resources::game_map->get_terrain_info(terrain);
|
||||
const terrain_type& info = resources::gameboard->map().get_terrain_info(terrain);
|
||||
|
||||
if (info.union_type().size() == 1 && info.union_type()[0] == info.number() && info.is_nonnull()) {
|
||||
|
||||
|
@ -1278,13 +1278,13 @@ REPORT_GENERATOR(villages)
|
|||
str << td.villages << '/';
|
||||
if (viewing_team.uses_shroud()) {
|
||||
int unshrouded_villages = 0;
|
||||
BOOST_FOREACH(const map_location &loc, resources::game_map->villages()) {
|
||||
BOOST_FOREACH(const map_location &loc, resources::gameboard->map().villages()) {
|
||||
if (!viewing_team.shrouded(loc))
|
||||
++unshrouded_villages;
|
||||
}
|
||||
str << unshrouded_villages;
|
||||
} else {
|
||||
str << resources::game_map->villages().size();
|
||||
str << resources::gameboard->map().villages().size();
|
||||
}
|
||||
return gray_inactive(str.str());
|
||||
}
|
||||
|
|
|
@ -1254,7 +1254,7 @@ static int intf_get_terrain(lua_State *L)
|
|||
int x = luaL_checkint(L, 1);
|
||||
int y = luaL_checkint(L, 2);
|
||||
|
||||
t_translation::t_terrain const &t = resources::game_map->
|
||||
t_translation::t_terrain const &t = resources::gameboard->map().
|
||||
get_terrain(map_location(x - 1, y - 1));
|
||||
lua_pushstring(L, t_translation::write_terrain_code(t).c_str());
|
||||
return 1;
|
||||
|
@ -1307,7 +1307,7 @@ static int intf_get_terrain_info(lua_State *L)
|
|||
char const *m = luaL_checkstring(L, 1);
|
||||
t_translation::t_terrain t = t_translation::read_terrain_code(m);
|
||||
if (t == t_translation::NONE_TERRAIN) return 0;
|
||||
terrain_type const &info = resources::game_map->get_terrain_info(t);
|
||||
terrain_type const &info = resources::gameboard->map().get_terrain_info(t);
|
||||
|
||||
lua_newtable(L);
|
||||
lua_pushstring(L, info.id().c_str());
|
||||
|
@ -1358,7 +1358,7 @@ static int intf_get_time_of_day(lua_State *L)
|
|||
lua_rawgeti(L, arg, 1);
|
||||
lua_rawgeti(L, arg, 2);
|
||||
loc = map_location(luaL_checkinteger(L, -2) - 1, luaL_checkinteger(L, -1) - 1);
|
||||
if(!resources::game_map->on_board(loc)) return luaL_argerror(L, arg, "coordinates are not on board");
|
||||
if(!resources::gameboard->map().on_board(loc)) return luaL_argerror(L, arg, "coordinates are not on board");
|
||||
lua_pop(L, 2);
|
||||
|
||||
lua_rawgeti(L, arg, 3);
|
||||
|
@ -1403,7 +1403,7 @@ static int intf_get_village_owner(lua_State *L)
|
|||
int y = luaL_checkint(L, 2);
|
||||
|
||||
map_location loc(x - 1, y - 1);
|
||||
if (!resources::game_map->is_village(loc))
|
||||
if (!resources::gameboard->map().is_village(loc))
|
||||
return 0;
|
||||
|
||||
int side = village_owner(loc) + 1;
|
||||
|
@ -1425,7 +1425,7 @@ static int intf_set_village_owner(lua_State *L)
|
|||
|
||||
std::vector<team> &teams = *resources::teams;
|
||||
map_location loc(x - 1, y - 1);
|
||||
if (!resources::game_map->is_village(loc))
|
||||
if (!resources::gameboard->map().is_village(loc))
|
||||
return 0;
|
||||
|
||||
int old_side = village_owner(loc) + 1;
|
||||
|
@ -1464,7 +1464,7 @@ static int intf_get_map_size(lua_State *L)
|
|||
static int intf_get_mouseover_tile(lua_State *L)
|
||||
{
|
||||
const map_location &loc = resources::screen->mouseover_hex();
|
||||
if (!resources::game_map->on_board(loc)) return 0;
|
||||
if (!resources::gameboard->map().on_board(loc)) return 0;
|
||||
lua_pushinteger(L, loc.x + 1);
|
||||
lua_pushinteger(L, loc.y + 1);
|
||||
return 2;
|
||||
|
@ -1478,7 +1478,7 @@ static int intf_get_mouseover_tile(lua_State *L)
|
|||
static int intf_get_selected_tile(lua_State *L)
|
||||
{
|
||||
const map_location &loc = resources::screen->selected_hex();
|
||||
if (!resources::game_map->on_board(loc)) return 0;
|
||||
if (!resources::gameboard->map().on_board(loc)) return 0;
|
||||
lua_pushinteger(L, loc.x + 1);
|
||||
lua_pushinteger(L, loc.y + 1);
|
||||
return 2;
|
||||
|
@ -1494,8 +1494,8 @@ static int intf_get_starting_location(lua_State* L)
|
|||
const int side = luaL_checkint(L, 1);
|
||||
if(side < 1 || static_cast<int>(resources::teams->size()) < side)
|
||||
return luaL_argerror(L, 1, "out of bounds");
|
||||
const map_location& starting_pos = resources::game_map->starting_position(side);
|
||||
if(!resources::game_map->on_board(starting_pos)) return 0;
|
||||
const map_location& starting_pos = resources::gameboard->map().starting_position(side);
|
||||
if(!resources::gameboard->map().on_board(starting_pos)) return 0;
|
||||
|
||||
lua_createtable(L, 2, 0);
|
||||
lua_pushinteger(L, starting_pos.x + 1);
|
||||
|
@ -1775,9 +1775,9 @@ static int intf_find_path(lua_State *L)
|
|||
dst.y = luaL_checkinteger(L, arg) - 1;
|
||||
++arg;
|
||||
|
||||
if (!resources::game_map->on_board(src))
|
||||
if (!resources::gameboard->map().on_board(src))
|
||||
return luaL_argerror(L, 1, "invalid location");
|
||||
if (!resources::game_map->on_board(dst))
|
||||
if (!resources::gameboard->map().on_board(dst))
|
||||
return luaL_argerror(L, arg - 2, "invalid location");
|
||||
|
||||
std::vector<team> &teams = *resources::teams;
|
||||
|
@ -2156,7 +2156,7 @@ static int intf_put_unit(lua_State *L)
|
|||
unit_arg = 3;
|
||||
loc.x = lua_tointeger(L, 1) - 1;
|
||||
loc.y = luaL_checkinteger(L, 2) - 1;
|
||||
if (!resources::game_map->on_board(loc))
|
||||
if (!resources::gameboard->map().on_board(loc))
|
||||
return luaL_argerror(L, 1, "invalid location");
|
||||
}
|
||||
|
||||
|
@ -2170,7 +2170,7 @@ static int intf_put_unit(lua_State *L)
|
|||
}
|
||||
if (unit_arg == 1) {
|
||||
loc = u->get_location();
|
||||
if (!resources::game_map->on_board(loc))
|
||||
if (!resources::gameboard->map().on_board(loc))
|
||||
return luaL_argerror(L, 1, "invalid location");
|
||||
}
|
||||
}
|
||||
|
@ -2180,7 +2180,7 @@ static int intf_put_unit(lua_State *L)
|
|||
if (unit_arg == 1) {
|
||||
loc.x = cfg["x"] - 1;
|
||||
loc.y = cfg["y"] - 1;
|
||||
if (!resources::game_map->on_board(loc))
|
||||
if (!resources::gameboard->map().on_board(loc))
|
||||
return luaL_argerror(L, 1, "invalid location");
|
||||
}
|
||||
u = new unit(cfg, true);
|
||||
|
@ -2655,7 +2655,7 @@ static int intf_select_hex(lua_State *L)
|
|||
const int y = luaL_checkinteger(L, 2) - 1;
|
||||
|
||||
const map_location loc(x, y);
|
||||
if(!resources::game_map->on_board(loc)) return luaL_argerror(L, 1, "not on board");
|
||||
if(!resources::gameboard->map().on_board(loc)) return luaL_argerror(L, 1, "not on board");
|
||||
bool highlight = true;
|
||||
if(!lua_isnoneornil(L, 3))
|
||||
highlight = luaW_toboolean(L, 3);
|
||||
|
@ -3164,7 +3164,7 @@ static int intf_get_locations(lua_State *L)
|
|||
*/
|
||||
static int intf_get_villages(lua_State *L)
|
||||
{
|
||||
std::vector<map_location> locs = resources::game_map->villages();
|
||||
std::vector<map_location> locs = resources::gameboard->map().villages();
|
||||
lua_newtable(L);
|
||||
int i = 1;
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
#include "global.hpp"
|
||||
|
||||
#include "config.hpp"
|
||||
#include "game_board.hpp"
|
||||
#include "log.hpp"
|
||||
#include "map.hpp"
|
||||
#include "resources.hpp"
|
||||
|
@ -114,7 +115,7 @@ bool terrain_filter::match_internal(const map_location& loc, const bool ignore_x
|
|||
cache_.parsed_terrain = new t_translation::t_match(cfg_["terrain"]);
|
||||
}
|
||||
if(!cache_.parsed_terrain->is_empty) {
|
||||
const t_translation::t_terrain letter = resources::game_map->get_terrain_info(loc).number();
|
||||
const t_translation::t_terrain letter = resources::gameboard->map().get_terrain_info(loc).number();
|
||||
if(!t_translation::terrain_matches(letter, *cache_.parsed_terrain)) {
|
||||
return false;
|
||||
}
|
||||
|
@ -190,7 +191,7 @@ bool terrain_filter::match_internal(const map_location& loc, const bool ignore_x
|
|||
std::vector<map_location::DIRECTION>::const_iterator j, j_end = dirs.end();
|
||||
for (j = dirs.begin(); j != j_end; ++j) {
|
||||
map_location &adj = adjacent[*j];
|
||||
if (resources::game_map->on_board(adj)) {
|
||||
if (resources::gameboard->map().on_board(adj)) {
|
||||
if(cache_.adjacent_matches == NULL) {
|
||||
while(index >= std::distance(cache_.adjacent_match_cache.begin(), cache_.adjacent_match_cache.end())) {
|
||||
const vconfig& adj_cfg = adj_cfgs[cache_.adjacent_match_cache.size()];
|
||||
|
@ -282,7 +283,7 @@ bool terrain_filter::match_internal(const map_location& loc, const bool ignore_x
|
|||
if(!owner_side.empty()) {
|
||||
WRN_NG << "duplicate side information in a SLF, ignoring inline owner_side=" << std::endl;
|
||||
}
|
||||
if(!resources::game_map->is_village(loc))
|
||||
if(!resources::gameboard->map().is_village(loc))
|
||||
return false;
|
||||
side_filter ssf(filter_owner);
|
||||
const std::vector<int>& sides = ssf.get_teams();
|
||||
|
@ -311,7 +312,7 @@ bool terrain_filter::match_internal(const map_location& loc, const bool ignore_x
|
|||
bool terrain_filter::match(const map_location& loc) const
|
||||
{
|
||||
if(cfg_["x"] == "recall" && cfg_["y"] == "recall") {
|
||||
return !resources::game_map->on_board(loc);
|
||||
return !resources::gameboard->map().on_board(loc);
|
||||
}
|
||||
std::set<map_location> hexes;
|
||||
std::vector<map_location> loc_vec(1, loc);
|
||||
|
@ -387,9 +388,9 @@ void terrain_filter::get_locations(std::set<map_location>& locs, bool with_borde
|
|||
&& !cfg_.has_attribute("area") ) {
|
||||
|
||||
//consider all locations on the map
|
||||
int bs = resources::game_map->border_size();
|
||||
int w = with_border ? resources::game_map->w() + bs : resources::game_map->w();
|
||||
int h = with_border ? resources::game_map->h() + bs : resources::game_map->h();
|
||||
int bs = resources::gameboard->map().border_size();
|
||||
int w = with_border ? resources::gameboard->map().w() + bs : resources::gameboard->map().w();
|
||||
int h = with_border ? resources::gameboard->map().h() + bs : resources::gameboard->map().h();
|
||||
for (int x = with_border ? 0 - bs : 0; x < w; ++x) {
|
||||
for (int y = with_border ? 0 - bs : 0; y < h; ++y) {
|
||||
match_set.insert(map_location(x,y));
|
||||
|
|
|
@ -1348,7 +1348,7 @@ bool unit::internal_matches_filter(const vconfig& cfg, const map_location& loc,
|
|||
if(cfg_x == "recall" && cfg_y == "recall") {
|
||||
//locations on the map are considered to not be on a recall list
|
||||
if ((!resources::game_map && loc.valid()) ||
|
||||
(resources::game_map && resources::game_map->on_board(loc)))
|
||||
(resources::game_map && resources::gameboard->map().on_board(loc)))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -1529,12 +1529,12 @@ bool unit::internal_matches_filter(const vconfig& cfg, const map_location& loc,
|
|||
}
|
||||
|
||||
config::attribute_value cfg_defense = cfg["defense"];
|
||||
if (!cfg_defense.blank() && cfg_defense.to_int(-1) != defense_modifier(resources::game_map->get_terrain(loc))) {
|
||||
if (!cfg_defense.blank() && cfg_defense.to_int(-1) != defense_modifier(resources::gameboard->map().get_terrain(loc))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
config::attribute_value cfg_movement = cfg["movement_cost"];
|
||||
if (!cfg_movement.blank() && cfg_movement.to_int(-1) != movement_cost(resources::game_map->get_terrain(loc))) {
|
||||
if (!cfg_movement.blank() && cfg_movement.to_int(-1) != movement_cost(resources::gameboard->map().get_terrain(loc))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -310,7 +310,7 @@ bool move::calculate_new_route(const map_location& source_hex, const map_locatio
|
|||
resources::teams->at(team_index()),
|
||||
*resources::teams, *resources::game_map);
|
||||
new_plain_route = pathfind::a_star_search(source_hex,
|
||||
dest_hex, 10000, &path_calc, resources::game_map->w(), resources::game_map->h());
|
||||
dest_hex, 10000, &path_calc, resources::gameboard->map().w(), resources::gameboard->map().h());
|
||||
if (new_plain_route.move_cost >= path_calc.getNoPathValue()) return false;
|
||||
route_.reset(new pathfind::marked_route(pathfind::mark_route(new_plain_route)));
|
||||
calculate_move_cost();
|
||||
|
|
|
@ -64,7 +64,7 @@ side_actions_ptr current_side_actions()
|
|||
unit const* find_backup_leader(unit const& leader)
|
||||
{
|
||||
assert(leader.can_recruit());
|
||||
assert(resources::game_map->is_keep(leader.get_location()));
|
||||
assert(resources::gameboard->map().is_keep(leader.get_location()));
|
||||
BOOST_FOREACH(unit const& unit, *resources::units)
|
||||
{
|
||||
if (unit.can_recruit() && unit.id() != leader.id())
|
||||
|
@ -78,7 +78,7 @@ unit const* find_backup_leader(unit const& leader)
|
|||
|
||||
unit* find_recruiter(size_t team_index, map_location const& hex)
|
||||
{
|
||||
if ( !resources::game_map->is_castle(hex) )
|
||||
if ( !resources::gameboard->map().is_castle(hex) )
|
||||
return NULL;
|
||||
|
||||
BOOST_FOREACH(unit& u, *resources::units)
|
||||
|
@ -117,7 +117,7 @@ int path_cost(std::vector<map_location> const& path, unit const& u)
|
|||
|
||||
team const& u_team = resources::teams->at(u.side()-1);
|
||||
map_location const& dest = path.back();
|
||||
if ( (resources::game_map->is_village(dest) && !u_team.owns_village(dest))
|
||||
if ( (resources::gameboard->map().is_village(dest) && !u_team.owns_village(dest))
|
||||
|| pathfind::enemy_zoc(u_team, dest, u_team) )
|
||||
return u.total_movement();
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue