finish removing resources::game_map

The remaining uses are just, checking whether or not the pointer
is null, or resets to its value, or simply storing it in a local
variable.

It might be appropriate to add resources::game_map back as a
function taking no parameters, at least this is flexible
enough to be changed later easily.
This commit is contained in:
Chris Beck 2014-06-10 21:26:41 -04:00
parent aab7edd88c
commit 22cc827d71
11 changed files with 13 additions and 18 deletions

View file

@ -844,7 +844,7 @@ namespace { // Helpers for place_recruit()
const map_location &recruit_loc, const map_location &leader_loc)
{
// Find closest enemy and turn towards it (level 2s count more than level 1s, etc.)
const gamemap *map = resources::game_map;
const gamemap *map = & resources::gameboard->map();
const unit_map & units = *resources::units;
unit_map::const_iterator unit_itor;
map_location min_loc;
@ -852,7 +852,7 @@ namespace { // Helpers for place_recruit()
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], resources::gameboard->map(), false)) {
unit_itor->is_visible_to_team((*resources::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;

View file

@ -152,7 +152,6 @@ void editor_controller::init_music(const config& game_config)
editor_controller::~editor_controller()
{
resources::game_map = NULL;
resources::units = NULL;
resources::tod_manager = NULL;
resources::teams = NULL;

View file

@ -75,7 +75,6 @@ public:
void refresh() {
context_manager_.gui().change_display_context(&context_manager_.get_map_context());
resources::game_map = &context_manager_.get_map();
resources::units = &context_manager_.get_map_context().get_units();
resources::teams = &context_manager_.get_map_context().get_teams();

View file

@ -288,7 +288,7 @@ namespace { // Support functions
std::vector<map_location> fake_unit_path(const unit& fake_unit, const std::vector<std::string>& xvals, const std::vector<std::string>& yvals)
{
const gamemap *game_map = resources::game_map;
const gamemap *game_map = & resources::gameboard->map();
std::vector<map_location> path;
map_location src;
map_location dst;
@ -1680,7 +1680,7 @@ WML_HANDLER_FUNCTION(replace_map, /*event_info*/, cfg)
* easier to do this as wanted by the author in WML.
*/
const gamemap * game_map = resources::game_map;
const gamemap * game_map = & resources::gameboard->map();
gamemap map(*game_map);
try {

View file

@ -1662,7 +1662,7 @@ public:
}
ss << generate_table(resistance_table);
if (resources::game_map != NULL) {
if (resources::gameboard != NULL) {
// Print the terrain modifier table of the unit.
ss << "\n\n<header>text='" << escape(_("Terrain Modifiers"))
<< "'</header>\n\n";
@ -1900,7 +1900,7 @@ void generate_races_sections(const config *help_cfg, section &sec, int level)
void generate_terrain_sections(const config* /*help_cfg*/, section& sec, int /*level*/)
{
if (resources::game_map == NULL) return;
if (resources::gameboard == NULL) return;
std::map<std::string, section> base_map;

View file

@ -25,6 +25,7 @@
#include "config.hpp"
#include "formula_string_utils.hpp"
#include "game_board.hpp"
#include "map.hpp"
#include "resources.hpp"
#include "gettext.hpp"
@ -317,7 +318,7 @@ std::vector<map_location> parse_location_range(const std::string &x, const std::
std::vector<map_location> res;
const std::vector<std::string> xvals = utils::split(x);
const std::vector<std::string> yvals = utils::split(y);
const gamemap *map = resources::game_map;
const gamemap *map = & resources::gameboard->map();
assert(map);
int xmin = 1, xmax = map->w(), ymin = 1, ymax = map->h();
if (with_border) {

View file

@ -75,7 +75,6 @@ static void clear_resources()
resources::controller = NULL;
resources::gameboard = NULL;
resources::gamedata = NULL;
resources::game_map = NULL;
resources::persist = NULL;
resources::screen = NULL;
resources::soundsources = NULL;
@ -143,7 +142,6 @@ play_controller::play_controller(const config& level, game_state& state_of_game,
resources::controller = this;
resources::gameboard = &gameboard_;
resources::gamedata = &gamedata_;
resources::game_map = &gameboard_.map_;
resources::persist = &persist_;
resources::teams = &gameboard_.teams_;
resources::tod_manager = &tod_manager_;

View file

@ -21,7 +21,6 @@ namespace resources
game_config_manager *config_manager = NULL;
play_controller *controller = NULL;
game_data *gamedata = NULL;
const gamemap *game_map = NULL;
LuaKernel *lua_kernel = NULL;
persist_manager *persist = NULL;
game_display *screen = NULL;

View file

@ -44,7 +44,6 @@ namespace resources
extern play_controller *controller;
extern game_board *gameboard;
extern game_data *gamedata;
extern const gamemap *game_map;
extern LuaKernel *lua_kernel; // Set by game_events::manager.
extern persist_manager *persist;
extern game_classification *classification;

View file

@ -1323,7 +1323,7 @@ bool unit::internal_matches_filter(const vconfig& cfg, const map_location& loc,
}
if(cfg.has_child("filter_location")) {
assert(resources::game_map != NULL);
assert(resources::gameboard != NULL);
assert(resources::teams != NULL);
assert(resources::tod_manager != NULL);
assert(resources::units != NULL);
@ -1347,8 +1347,8 @@ bool unit::internal_matches_filter(const vconfig& cfg, const map_location& loc,
if (!cfg_x.blank() || !cfg_y.blank()){
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::gameboard->map().on_board(loc)))
if ((!resources::gameboard && loc.valid()) ||
(resources::gameboard && resources::gameboard->map().on_board(loc)))
{
return false;
}
@ -1590,7 +1590,7 @@ bool unit::internal_matches_filter(const vconfig& cfg, const map_location& loc,
}
if (cfg.has_child("filter_adjacent")) {
assert(resources::units && resources::game_map);
assert(resources::units && resources::gameboard);
const unit_map& units = *resources::units;
map_location adjacent[6];
get_adjacent_tiles(loc, adjacent);

View file

@ -292,7 +292,7 @@ std::vector<boost::tuple<t_string,t_string,t_string> > unit::ability_tooltips(st
bool unit::ability_active(const std::string& ability,const config& cfg,const map_location& loc) const
{
bool illuminates = ability == "illuminates";
assert(resources::units && resources::game_map && resources::teams && resources::tod_manager);
assert(resources::units && resources::gameboard && resources::teams && resources::tod_manager);
if (const config &afilter = cfg.child("filter"))
if ( !matches_filter(vconfig(afilter), loc, illuminates) )