mirror of
https://github.com/wesnoth/wesnoth
synced 2025-04-28 22:04:24 +00:00
removed gamestatus member from class unit...
...(unused ctor parameter to be removed soon)
This commit is contained in:
parent
c0c779968b
commit
793bda65bf
@ -1785,7 +1785,7 @@ WML_HANDLER_FUNCTION(role, /*event_info*/, cfg)
|
||||
// Iterate over the player's recall list to find a match
|
||||
for(size_t i=0; i < p_info.available_units.size(); ++i) {
|
||||
unit& u = p_info.available_units[i];
|
||||
u.set_game_context(rsrc.units, rsrc.game_map, rsrc.status_ptr, &rsrc.controller->get_tod_manager(), rsrc.teams);
|
||||
u.set_game_context(rsrc.units, rsrc.game_map, &rsrc.controller->get_tod_manager(), rsrc.teams);
|
||||
scoped_recall_unit auto_store("this_unit", player_id, i);
|
||||
if(game_events::unit_matches_filter(u, filter, map_location())) {
|
||||
u.set_role(cfg["role"]);
|
||||
@ -2074,7 +2074,7 @@ WML_HANDLER_FUNCTION(recall, /*event_info*/, cfg)
|
||||
|
||||
for(std::vector<unit>::iterator u = avail.begin(); u != avail.end(); ++u) {
|
||||
DBG_NG << "checking unit against filter...\n";
|
||||
u->set_game_context(rsrc.units, rsrc.game_map, rsrc.status_ptr, &rsrc.controller->get_tod_manager(), rsrc.teams);
|
||||
u->set_game_context(rsrc.units, rsrc.game_map, &rsrc.controller->get_tod_manager(), rsrc.teams);
|
||||
scoped_recall_unit auto_store("this_unit", player_id, u - avail.begin());
|
||||
if(game_events::unit_matches_filter(*u, unit_filter, map_location())) {
|
||||
map_location loc = cfg_to_loc(cfg);
|
||||
@ -2313,7 +2313,7 @@ WML_HANDLER_FUNCTION(kill, event_info, cfg)
|
||||
{
|
||||
std::vector<unit>& avail_units = pi->second.available_units;
|
||||
for(std::vector<unit>::iterator j = avail_units.begin(); j != avail_units.end();) {
|
||||
j->set_game_context(rsrc.units, rsrc.game_map, rsrc.status_ptr, &rsrc.controller->get_tod_manager(), rsrc.teams);
|
||||
j->set_game_context(rsrc.units, rsrc.game_map, &rsrc.controller->get_tod_manager(), rsrc.teams);
|
||||
scoped_recall_unit auto_store("this_unit", pi->first, j - avail_units.begin());
|
||||
if(game_events::unit_matches_filter(*j, cfg,map_location())) {
|
||||
j = avail_units.erase(j);
|
||||
@ -2465,7 +2465,7 @@ WML_HANDLER_FUNCTION(store_unit, /*event_info*/, cfg)
|
||||
pi!=players.end(); ++pi) {
|
||||
std::vector<unit>& avail_units = pi->second.available_units;
|
||||
for(std::vector<unit>::iterator j = avail_units.begin(); j != avail_units.end();) {
|
||||
j->set_game_context(rsrc.units, rsrc.game_map, rsrc.status_ptr, &rsrc.controller->get_tod_manager(), rsrc.teams);
|
||||
j->set_game_context(rsrc.units, rsrc.game_map, &rsrc.controller->get_tod_manager(), rsrc.teams);
|
||||
scoped_recall_unit auto_store("this_unit", pi->first, j - avail_units.begin());
|
||||
if(game_events::unit_matches_filter(*j, filter,map_location()) == false) {
|
||||
++j;
|
||||
|
@ -962,7 +962,7 @@ void game_state::get_player_info(const config& cfg,
|
||||
it != player->available_units.end(); ++it) {
|
||||
if(it->can_recruit()) {
|
||||
new_unit = *it;
|
||||
new_unit.set_game_context(&units, &map, &game_status, &tod_mng, &teams);
|
||||
new_unit.set_game_context(&units, &map, &tod_mng, &teams);
|
||||
player->available_units.erase(it);
|
||||
break;
|
||||
}
|
||||
|
@ -939,7 +939,7 @@ private:
|
||||
unit& un = recall_list[res];
|
||||
map_location loc = last_hex;
|
||||
recorder.add_recall(res,loc);
|
||||
un.set_game_context(&units_,&map_,&status_,&tod_manager_,&teams_);
|
||||
un.set_game_context(&units_,&map_,&tod_manager_,&teams_);
|
||||
const std::string &err = recruit_unit(map_, side_num, units_,
|
||||
un, loc, true, gui_);
|
||||
if(!err.empty()) {
|
||||
@ -1117,7 +1117,7 @@ private:
|
||||
unit un = recall_list[action.recall_pos];
|
||||
|
||||
recorder.add_recall(action.recall_pos,action.recall_loc);
|
||||
un.set_game_context(&units_,&map_,&status_,&tod_manager_,&teams_);
|
||||
un.set_game_context(&units_,&map_,&tod_manager_,&teams_);
|
||||
const std::string &msg = recruit_unit(map_, side_num,
|
||||
units_, un, action.recall_loc, true, gui_);
|
||||
if(msg.empty()) {
|
||||
|
@ -971,7 +971,7 @@ bool do_replay_handle(game_display& disp, const gamemap& map,
|
||||
|
||||
if(val >= 0 && val < int(player->available_units.size())) {
|
||||
statistics::recall_unit(player->available_units[val]);
|
||||
player->available_units[val].set_game_context(&units,&map,&state,&tod_mng,&teams);
|
||||
player->available_units[val].set_game_context(&units,&map,&tod_mng,&teams);
|
||||
recruit_unit(map,team_num,units,player->available_units[val],loc,true,!get_replay_source().is_skipping());
|
||||
player->available_units.erase(player->available_units.begin()+val);
|
||||
current_team.spend_gold(game_config::recall_cost);
|
||||
|
12
src/unit.cpp
12
src/unit.cpp
@ -162,7 +162,6 @@ unit::unit(const unit& o):
|
||||
modifications_(o.modifications_),
|
||||
units_(o.units_),
|
||||
map_(o.map_),
|
||||
gamestatus_(o.gamestatus_),
|
||||
tod_manager_(o.tod_manager_),
|
||||
teams_(o.teams_),
|
||||
invisibility_cache_()
|
||||
@ -239,7 +238,6 @@ unit::unit(unit_map* unitmap, const gamemap* map, const gamestatus* game_status,
|
||||
modifications_(),
|
||||
units_(unitmap),
|
||||
map_(map),
|
||||
gamestatus_(game_status),
|
||||
tod_manager_(tod_mng),
|
||||
teams_(teams),
|
||||
invisibility_cache_()
|
||||
@ -321,7 +319,6 @@ unit::unit(const config& cfg,bool use_traits) :
|
||||
modifications_(),
|
||||
units_(NULL),
|
||||
map_(NULL),
|
||||
gamestatus_(NULL),
|
||||
tod_manager_(NULL),
|
||||
teams_(NULL),
|
||||
invisibility_cache_()
|
||||
@ -431,7 +428,6 @@ unit::unit(unit_map* unitmap, const gamemap* map, const gamestatus* game_status,
|
||||
modifications_(),
|
||||
units_(unitmap),
|
||||
map_(map),
|
||||
gamestatus_(game_status),
|
||||
tod_manager_(tod_mng),
|
||||
teams_(teams),
|
||||
invisibility_cache_()
|
||||
@ -533,7 +529,6 @@ unit::unit(const unit_type* t, int side, bool use_traits, bool dummy_unit,
|
||||
modifications_(),
|
||||
units_(NULL),
|
||||
map_(NULL),
|
||||
gamestatus_(NULL),
|
||||
tod_manager_(NULL),
|
||||
invisibility_cache_()
|
||||
{
|
||||
@ -593,11 +588,10 @@ unit& unit::operator=(const unit& u)
|
||||
|
||||
|
||||
|
||||
void unit::set_game_context(unit_map* unitmap, const gamemap* map, const gamestatus* game_status, const tod_manager* tod_mng, const std::vector<team>* teams)
|
||||
void unit::set_game_context(unit_map* unitmap, const gamemap* map, const tod_manager* tod_mng, const std::vector<team>* teams)
|
||||
{
|
||||
units_ = unitmap;
|
||||
map_ = map;
|
||||
gamestatus_ = game_status;
|
||||
tod_manager_ = tod_mng;
|
||||
teams_ = teams;
|
||||
|
||||
@ -1137,7 +1131,6 @@ bool unit::internal_matches_filter(const vconfig& cfg, const map_location& loc,
|
||||
|
||||
if(cfg.has_child("filter_location")) {
|
||||
assert(map_ != NULL);
|
||||
assert(gamestatus_ != NULL);
|
||||
assert(teams_ != NULL);
|
||||
assert(tod_manager_ != NULL);
|
||||
assert(units_ != NULL);
|
||||
@ -1333,7 +1326,7 @@ bool unit::internal_matches_filter(const vconfig& cfg, const map_location& loc,
|
||||
}
|
||||
|
||||
if (cfg.has_child("filter_adjacent")) {
|
||||
assert(units_ && map_ && gamestatus_);
|
||||
assert(units_ && map_);
|
||||
map_location adjacent[6];
|
||||
get_adjacent_tiles(loc, adjacent);
|
||||
vconfig::child_list::const_iterator i, i_end;
|
||||
@ -1367,7 +1360,6 @@ bool unit::internal_matches_filter(const vconfig& cfg, const map_location& loc,
|
||||
|
||||
if(cfg.has_attribute("find_in")) {
|
||||
// Allow filtering by searching a stored variable of units
|
||||
assert(gamestatus_ != NULL);
|
||||
variable_info vi(cfg["find_in"], false, variable_info::TYPE_CONTAINER);
|
||||
if(!vi.is_valid) return false;
|
||||
if(vi.explicit_index) {
|
||||
|
@ -77,7 +77,7 @@ public:
|
||||
virtual ~unit();
|
||||
unit& operator=(const unit&);
|
||||
|
||||
void set_game_context(unit_map* unitmap, const gamemap* map, const gamestatus* game_status, const tod_manager* tod_mng, const std::vector<team>* teams);
|
||||
void set_game_context(unit_map* unitmap, const gamemap* map, const tod_manager* tod_mng, const std::vector<team>* teams);
|
||||
|
||||
/** Advances this unit to another type */
|
||||
void advance_to(const unit_type* t, bool use_traits=false, game_state* state = 0);
|
||||
@ -458,7 +458,6 @@ private:
|
||||
friend void attack_type::set_specials_context(const map_location& loc, const map_location&, const unit& un, bool) const;
|
||||
const unit_map* units_;
|
||||
const gamemap* map_;
|
||||
const gamestatus* gamestatus_;
|
||||
const tod_manager* tod_manager_;
|
||||
const std::vector<team>* teams_;
|
||||
|
||||
|
@ -244,7 +244,7 @@ static bool cache_illuminates(int &cache, std::string const &ability)
|
||||
bool unit::ability_active(const std::string& ability,const config& cfg,const map_location& loc) const
|
||||
{
|
||||
int illuminates = -1;
|
||||
assert(units_ && map_ && gamestatus_ && teams_ && tod_manager_);
|
||||
assert(units_ && map_ && teams_ && tod_manager_);
|
||||
|
||||
if (const config &afilter = cfg.child("filter"))
|
||||
if (!matches_filter(vconfig(afilter), loc, cache_illuminates(illuminates, ability)))
|
||||
|
Loading…
x
Reference in New Issue
Block a user