add gamemap argument to tod_manager::add_time_area(config &c)

This is needed to properly parse a list of locations from strings,
to have the dimensions available.

This allows to refactor tod_manager and not use resources:: ptrs
in its implementation, instead using the objects from the relevant
context.
This commit is contained in:
Chris Beck 2014-06-13 01:17:55 -04:00
parent fe00d72dd2
commit 8531ddeae5
4 changed files with 8 additions and 8 deletions

View File

@ -281,7 +281,7 @@ void map_context::load_scenario(const config& game_config)
tod_manager_.reset(new tod_manager(scenario));
BOOST_FOREACH(const config &time_area, scenario.child_range("time_area")) {
tod_manager_->add_time_area(time_area);
tod_manager_->add_time_area(map_,time_area);
}
BOOST_FOREACH(const config& item, scenario.child_range("item")) {

View File

@ -195,7 +195,7 @@ void play_controller::init(CVideo& video){
}
BOOST_FOREACH(const config &t, level_.child_range("time_area")) {
tod_manager_.add_time_area(t);
tod_manager_.add_time_area(gameboard_.map(),t);
}
LOG_NG << "initialized teams... " << (SDL_GetTicks() - ticks_) << std::endl;

View File

@ -13,18 +13,18 @@
*/
#include "tod_manager.hpp"
#include "wml_exception.hpp"
#include "gettext.hpp"
#include "display_context.hpp"
#include "formula_string_utils.hpp"
#include "gamestatus.hpp"
#include "gettext.hpp"
#include "log.hpp"
#include "map.hpp"
#include "play_controller.hpp"
#include "random_new.hpp"
#include "resources.hpp"
#include "unit.hpp"
#include "unit_abilities.hpp"
#include "wml_exception.hpp"
#include <boost/foreach.hpp>
#include <boost/range/adaptors.hpp>
@ -316,7 +316,7 @@ const std::set<map_location>& tod_manager::get_area_by_index(int index) const
return areas_[index].hexes;
}
void tod_manager::add_time_area(const config& cfg)
void tod_manager::add_time_area(const gamemap & map, const config& cfg)
{
areas_.push_back(area_time_of_day());
area_time_of_day &area = areas_.back();
@ -324,7 +324,7 @@ void tod_manager::add_time_area(const config& cfg)
area.xsrc = cfg["x"].str();
area.ysrc = cfg["y"].str();
area.currentTime = cfg["current_time"].to_int(0);
std::vector<map_location> const& locs (resources::disp_context->map().parse_location_range(area.xsrc, area.ysrc, true));
std::vector<map_location> const& locs (map.parse_location_range(area.xsrc, area.ysrc, true));
area.hexes.insert(locs.begin(), locs.end());
time_of_day::parse_times(cfg, area.times);
}

View File

@ -117,7 +117,7 @@ class tod_manager : public savegame::savegame_config
* @param cfg Config object containing x,y range/list of
* locations and desired [time] information.
*/
void add_time_area(const config& cfg);
void add_time_area(const gamemap & map, const config& cfg);
/**
* Adds a new local time area from a set of locations, making those