From 4286b13a7932e1f260d21ffd5068b6ee4ad66e16 Mon Sep 17 00:00:00 2001 From: Chris Beck Date: Sun, 6 Jul 2014 18:45:30 -0400 Subject: [PATCH] team::build takes a pointer to the game_data obj we want to use This eliminates another use of resources:: in class team --- src/editor/map/map_context.cpp | 2 +- src/game_data.cpp | 4 ++-- src/team.cpp | 4 ++-- src/team.hpp | 2 +- src/teambuilder.hpp | 5 ++++- 5 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/editor/map/map_context.cpp b/src/editor/map/map_context.cpp index 86e6512bcff1..04e360140b1b 100644 --- a/src/editor/map/map_context.cpp +++ b/src/editor/map/map_context.cpp @@ -303,7 +303,7 @@ void map_context::load_scenario(const config& game_config) { team t; side["side"] = i; - t.build(side, map_); + t.build(side, map_, NULL); //It's okay to pass a NULL gamedata ptr here, it is only used ultimately in map_location ctor and checked for null. teams_.push_back(t); BOOST_FOREACH(config &a_unit, side.child_range("unit")) { diff --git a/src/game_data.cpp b/src/game_data.cpp index 66cd37154284..accb05301aa1 100644 --- a/src/game_data.cpp +++ b/src/game_data.cpp @@ -205,7 +205,7 @@ team_builder_ptr game_data::create_team_builder(const config& side_cfg, const config& level, gamemap& map, unit_map& units, const config& starting_pos) { - return team_builder_ptr(new team_builder(side_cfg, save_id, teams, level, map, units, starting_pos)); + return team_builder_ptr(new team_builder(side_cfg, save_id, teams, level, map, units, *this, starting_pos)); } void game_data::build_team_stage_one(team_builder_ptr tb_ptr) @@ -266,4 +266,4 @@ void game_data::activate_scope_variable(std::string var_name) const break; } } -} \ No newline at end of file +} diff --git a/src/team.cpp b/src/team.cpp index 2e12bbe89cef..6390090a4284 100644 --- a/src/team.cpp +++ b/src/team.cpp @@ -280,7 +280,7 @@ team::~team() { } -void team::build(const config &cfg, const gamemap& map, int gold) +void team::build(const config &cfg, const gamemap& map, const game_data * gamedata, int gold) { gold_ = gold; info_.read(cfg); @@ -314,7 +314,7 @@ void team::build(const config &cfg, const gamemap& map, int gold) // Load in the villages the side controls at the start BOOST_FOREACH(const config &v, cfg.child_range("village")) { - map_location loc(v, resources::gamedata); + map_location loc(v, gamedata); if (map.is_village(loc)) { villages_.insert(loc); } else { diff --git a/src/team.hpp b/src/team.hpp index 7c5b48d93bff..fa77e3d32a25 100644 --- a/src/team.hpp +++ b/src/team.hpp @@ -157,7 +157,7 @@ class team : public savegame::savegame_config /// from a side's config before using it to create the side's leader. static const std::set attributes; - void build(const config &cfg, const gamemap &map, int gold = default_team_gold_); + void build(const config &cfg, const gamemap &map, const game_data * gamedata, int gold = default_team_gold_); void write(config& cfg) const; diff --git a/src/teambuilder.hpp b/src/teambuilder.hpp index 8c39cb073da6..fe114fe57103 100644 --- a/src/teambuilder.hpp +++ b/src/teambuilder.hpp @@ -40,6 +40,7 @@ class team_builder { team_builder(const config& side_cfg, const std::string &save_id, std::vector& teams, const config& level, gamemap& map, unit_map& units, + game_data & gamedata, const config &starting_pos) : gold_info_ngold_(0) , leader_configs_() @@ -55,6 +56,7 @@ class team_builder { , teams_(teams) , unit_configs_() , units_(units) + , gamedata_(gamedata) { } @@ -110,6 +112,7 @@ class team_builder { std::vector &teams_; std::vector unit_configs_; unit_map &units_; + game_data & gamedata_; void log_step(const char *s) const @@ -167,7 +170,7 @@ class team_builder { void new_team() { log_step("new team"); - t_->build(side_cfg_, map_, gold_info_ngold_); + t_->build(side_cfg_, map_, &gamedata_, gold_info_ngold_); //t_->set_gold_add(gold_info_add_); }