mail[Wesnoth-commits] r36976 - in /trunk/src: ./ ai/ ai/default/


Others Months | Index by Date | Thread Index
>>   [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Header


Content

Posted by guillaume . melquiond on July 18, 2009 - 14:06:
Author: silene
Date: Sat Jul 18 14:06:00 2009
New Revision: 36976

URL: http://svn.gna.org/viewcvs/wesnoth?rev=36976&view=rev
Log:
Removed redundant field tod_manager_ from class unit.

Modified:
    trunk/src/actions.cpp
    trunk/src/ai/actions.cpp
    trunk/src/ai/contexts.cpp
    trunk/src/ai/default/ai.cpp
    trunk/src/game_events.cpp
    trunk/src/gamestatus.cpp
    trunk/src/menu_events.cpp
    trunk/src/replay.cpp
    trunk/src/unit.cpp
    trunk/src/unit.hpp
    trunk/src/unit_abilities.cpp

Modified: trunk/src/actions.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/actions.cpp?rev=36976&r1=36975&r2=36976&view=diff
==============================================================================
--- trunk/src/actions.cpp (original)
+++ trunk/src/actions.cpp Sat Jul 18 14:06:00 2009
@@ -1298,7 +1298,7 @@
                                        reanimitor = 
unit_type_data::types().find_unit_type(a_stats_->plague_type);
                                        LOG_NG << "found unit type:" << 
reanimitor->second.id() << std::endl;
                                        if(reanimitor != 
unit_type_data::types().end()) {
-                                               unit newunit(&units_, 
&tod_manager_, &reanimitor->second,
+                                               unit newunit(&units_, 
&reanimitor->second,
                                                             
a_.get_unit().side(), true, true);
                                                newunit.set_attacks(0);
                                                // Apply variation
@@ -1569,7 +1569,7 @@
                                        reanimitor = 
unit_type_data::types().find_unit_type(d_stats_->plague_type);
                                        LOG_NG << "found unit type:" << 
reanimitor->second.id() << std::endl;
                                        if(reanimitor != 
unit_type_data::types().end()) {
-                                               unit newunit(&units_, 
&tod_manager_, &reanimitor->second,
+                                               unit newunit(&units_, 
&reanimitor->second,
                                                             
d_.get_unit().side(), true, true);
                                                // Apply variation
                                                
if(strcmp(undead_variation.c_str(),"null")){

Modified: trunk/src/ai/actions.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/ai/actions.cpp?rev=36976&r1=36975&r2=36976&view=diff
==============================================================================
--- trunk/src/ai/actions.cpp (original)
+++ trunk/src/ai/actions.cpp Sat Jul 18 14:06:00 2009
@@ -665,7 +665,7 @@
        recorder.add_recruit(num_,recruit_location_);
        replay_undo replay_guard(recorder);
        unit_type_data::unit_type_map::const_iterator u = 
unit_type_data::types().find_unit_type(unit_name_);
-       unit new_unit(&info.units, &info.tod_manager_, &u->second, 
get_side(), true);
+       unit new_unit(&info.units, &u->second, get_side(), true);
        std::string recruit_err = 
recruit_unit(info.map,get_side(),info.units,new_unit,recruit_location_,false,preferences::show_ai_moves());
        if(recruit_err.empty()) {
                statistics::recruit_unit(new_unit);

Modified: trunk/src/ai/contexts.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/ai/contexts.cpp?rev=36976&r1=36975&r2=36976&view=diff
==============================================================================
--- trunk/src/ai/contexts.cpp (original)
+++ trunk/src/ai/contexts.cpp Sat Jul 18 14:06:00 2009
@@ -182,7 +182,7 @@
            " gold=" << (current_team().gold()) <<
            " (-> " << (current_team().gold()-u->second.cost()) << ")\n";
 
-       unit new_unit(&get_info().units, &get_info().tod_manager_, 
&u->second, get_side(), true);
+       unit new_unit(&get_info().units, &u->second, get_side(), true);
 
        // See if we can actually recruit (i.e. have enough room etc.)
        std::string recruit_err = 
recruit_unit(get_info().map,get_side(),get_info().units,new_unit,loc,false,preferences::show_ai_moves());

Modified: trunk/src/ai/default/ai.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/ai/default/ai.cpp?rev=36976&r1=36975&r2=36976&view=diff
==============================================================================
--- trunk/src/ai/default/ai.cpp (original)
+++ trunk/src/ai/default/ai.cpp Sat Jul 18 14:06:00 2009
@@ -1400,8 +1400,7 @@
                        continue;
                }
 
-               const unit temp_unit(&get_info().units,
-                       &get_info().tod_manager_, &info->second, get_side());
+               const unit temp_unit(&get_info().units, &info->second, 
get_side());
                // since we now use the ignore_units switch, no need to use a 
empty unit_map
                // unit_map units;
                // const temporary_unit_placer placer(units,start,temp_unit);

Modified: trunk/src/game_events.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/game_events.cpp?rev=36976&r1=36975&r2=36976&view=diff
==============================================================================
--- trunk/src/game_events.cpp (original)
+++ trunk/src/game_events.cpp Sat Jul 18 14:06:00 2009
@@ -1048,7 +1048,7 @@
                const unit_race::GENDER gender = string_gender(cfg["gender"]);
                const unit_type_data::unit_type_map::const_iterator itor = 
unit_type_data::types().find_unit_type(type);
                if(itor != unit_type_data::types().end()) {
-                       unit dummy_unit(resources::units, 
resources::tod_manager, &itor->second, side_num + 1, false, true, gender, 
variation);
+                       unit dummy_unit(resources::units, &itor->second, 
side_num + 1, false, true, gender, variation);
                        const std::vector<std::string> xvals = 
utils::split(x);
                        const std::vector<std::string> yvals = 
utils::split(y);
                        std::vector<map_location> path;
@@ -1765,7 +1765,7 @@
                                        // Iterate over the player's recall 
list to find a match
                                        for(size_t i=0; i < 
pi->recall_list().size(); ++i) {
                                                unit& u = 
pi->recall_list()[i];
-                                               
u.set_game_context(resources::units, resources::tod_manager);
+                                               
u.set_game_context(resources::units);
                                                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"]);
@@ -1959,7 +1959,7 @@
 WML_HANDLER_FUNCTION(unit, /*event_info*/, cfg)
 {
                const config& parsed_cfg = cfg.get_parsed_config();
-               unit new_unit(resources::units, resources::tod_manager, 
parsed_cfg, true, resources::state_of_game);
+               unit new_unit(resources::units, parsed_cfg, true, 
resources::state_of_game);
                if(cfg.has_attribute("to_variable")) {
                        config &var = 
resources::state_of_game->get_variable_cfg(parsed_cfg["to_variable"]);
                        new_unit.write(var);
@@ -2032,7 +2032,7 @@
 
                        for(std::vector<unit>::iterator u = avail.begin(); u 
!= avail.end(); ++u) {
                                DBG_NG << "checking unit against filter...\n";
-                               u->set_game_context(resources::units, 
resources::tod_manager);
+                               u->set_game_context(resources::units);
                                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);
@@ -2266,7 +2266,7 @@
                        {
                                std::vector<unit>& avail_units = 
pi->recall_list();
                                for(std::vector<unit>::iterator j = 
avail_units.begin(); j != avail_units.end();) {
-                                       j->set_game_context(resources::units, 
resources::tod_manager);
+                                       j->set_game_context(resources::units);
                                        scoped_recall_unit 
auto_store("this_unit", pi->save_id(), j - avail_units.begin());
                                        
if(game_events::unit_matches_filter(*j, cfg,map_location())) {
                                                j = avail_units.erase(j);
@@ -2414,7 +2414,7 @@
                                        pi != resources::teams->end(); ++pi) {
                                std::vector<unit>& avail_units = 
pi->recall_list();
                                for(std::vector<unit>::iterator j = 
avail_units.begin(); j != avail_units.end();) {
-                                       j->set_game_context(resources::units, 
resources::tod_manager);
+                                       j->set_game_context(resources::units);
                                        scoped_recall_unit 
auto_store("this_unit", pi->save_id(), j - avail_units.begin());
                                        
if(game_events::unit_matches_filter(*j, filter,map_location()) == false) {
                                                ++j;
@@ -2444,7 +2444,7 @@
        const config &var = 
resources::state_of_game->get_variable_cfg(cfg["variable"]);
 
        try {
-               const unit u(resources::units, resources::tod_manager, var, 
false);
+               const unit u(resources::units, var, false);
 
                        preferences::encountered_units().insert(u.type_id());
                        map_location loc = cfg_to_loc(

Modified: trunk/src/gamestatus.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gamestatus.cpp?rev=36976&r1=36975&r2=36976&view=diff
==============================================================================
--- trunk/src/gamestatus.cpp (original)
+++ trunk/src/gamestatus.cpp Sat Jul 18 14:06:00 2009
@@ -773,7 +773,7 @@
 
        // If this side tag describes the leader of the side
        if(!utils::string_bool(side_cfg["no_leader"]) && 
side_cfg["controller"] != "null") {
-               unit new_unit(&units, &tod_mng, side_cfg, true);
+               unit new_unit(&units, side_cfg, true);
 
                // Search the recall list for leader units, and if there is 
one,
                // use it in place of the config-described unit
@@ -792,7 +792,7 @@
                                it != teams.back().recall_list().end(); ++it) 
{
                                if(it->can_recruit()) {
                                        new_unit = *it;
-                                       new_unit.set_game_context(&units, 
&tod_mng);
+                                       new_unit.set_game_context(&units);
                                        teams.back().recall_list().erase(it);
                                        break;
                                }
@@ -852,7 +852,7 @@
                teams.back().recall_list().clear();
        }
        for(config::child_list::const_iterator su = starting_units.begin(); 
su != starting_units.end(); ++su) {
-               unit new_unit(&units, &tod_mng, **su, true);
+               unit new_unit(&units, **su, true);
 
                new_unit.set_side(side);
 

Modified: trunk/src/menu_events.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/menu_events.cpp?rev=36976&r1=36975&r2=36976&view=diff
==============================================================================
--- trunk/src/menu_events.cpp (original)
+++ trunk/src/menu_events.cpp Sat Jul 18 14:06:00 2009
@@ -781,7 +781,7 @@
 
                        //create a unit with traits
                        recorder.add_recruit(recruit_num, last_hex);
-                       unit new_unit(&units_, &tod_manager_, 
&u_type->second, side_num, true);
+                       unit new_unit(&units_, &u_type->second, side_num, 
true);
                        map_location loc = last_hex;
                        const std::string &msg = recruit_unit(map_, side_num, 
units_,
                                new_unit, loc, false, gui_ != NULL);
@@ -939,7 +939,7 @@
                                        unit& un = recall_list_team[res];
                                        map_location loc = last_hex;
                                        recorder.add_recall(res,loc);
-                                       un.set_game_context(&units_, 
&tod_manager_);
+                                       un.set_game_context(&units_);
                                        const std::string &err = 
recruit_unit(map_, side_num, units_,
                                                un, loc, true, gui_ != NULL);
                                        if(!err.empty()) {
@@ -1109,7 +1109,7 @@
                                unit un = 
current_team.recall_list()[action.recall_pos];
 
                                
recorder.add_recall(action.recall_pos,action.recall_loc);
-                               un.set_game_context(&units_, &tod_manager_);
+                               un.set_game_context(&units_);
                                const std::string &msg = recruit_unit(map_, 
side_num,
                                        units_, un, action.recall_loc, true, 
gui_ != NULL);
                                if(msg.empty()) {
@@ -1433,7 +1433,7 @@
                        const unit_race::GENDER gender =
                                (!genders.empty() ? 
genders[gamestate_.rng().get_random() % genders.size()] : unit_race::MALE);
 
-                       unit chosen(&units_, &tod_manager_, 
unit_choices[choice], 1, false, false, gender, "", random_gender);
+                       unit chosen(&units_, unit_choices[choice], 1, false, 
false, gender, "", random_gender);
                        chosen.new_turn();
 
                        const map_location& loc = mousehandler.get_last_hex();
@@ -3059,8 +3059,7 @@
 
                        menu_handler_.units_.erase(loc);
                        menu_handler_.units_.add(loc,
-                               unit(&menu_handler_.units_, 
&menu_handler_.tod_manager_,
-                                    &i->second, 1, false));
+                               unit(&menu_handler_.units_, &i->second, 1, 
false));
                        menu_handler_.gui_->invalidate(loc);
                        menu_handler_.gui_->invalidate_unit();
                } else {

Modified: trunk/src/replay.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/replay.cpp?rev=36976&r1=36975&r2=36976&view=diff
==============================================================================
--- trunk/src/replay.cpp (original)
+++ trunk/src/replay.cpp Sat Jul 18 14:06:00 2009
@@ -930,7 +930,7 @@
                                replay::throw_error(errbuf.str());
                        }
 
-                       unit new_unit(&units, &tod_mng, &u_type->second, 
team_num, true, false);
+                       unit new_unit(&units, &u_type->second, team_num, 
true, false);
                        const std::string& res = 
recruit_unit(map,team_num,units,new_unit,loc,false,!get_replay_source().is_skipping());
                        if(!res.empty()) {
                                std::stringstream errbuf;
@@ -971,7 +971,7 @@
 
                        if(val >= 0 && val < 
int(current_team.recall_list().size())) {
                                
statistics::recall_unit(current_team.recall_list()[val]);
-                               
current_team.recall_list()[val].set_game_context(&units, &tod_mng);
+                               
current_team.recall_list()[val].set_game_context(&units);
                                
recruit_unit(map,team_num,units,current_team.recall_list()[val],loc,true,!get_replay_source().is_skipping());
                                
current_team.recall_list().erase(current_team.recall_list().begin()+val);
                                
current_team.spend_gold(game_config::recall_cost);

Modified: trunk/src/unit.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/unit.cpp?rev=36976&r1=36975&r2=36976&view=diff
==============================================================================
--- trunk/src/unit.cpp (original)
+++ trunk/src/unit.cpp Sat Jul 18 14:06:00 2009
@@ -163,12 +163,11 @@
 
            modifications_(o.modifications_),
            units_(o.units_),
-           tod_manager_(o.tod_manager_),
                   invisibility_cache_()
 {
 }
 
-unit::unit(unit_map* unitmap, const tod_manager* tod_mng, const config& cfg,
+unit::unit(unit_map* unitmap, const config& cfg,
                bool use_traits, game_state* state) :
        cfg_(),
        advances_to_(),
@@ -236,7 +235,6 @@
        draw_bars_(false),
        modifications_(),
        units_(unitmap),
-       tod_manager_(tod_mng),
        invisibility_cache_()
 {
        read(cfg, use_traits, state);
@@ -315,7 +313,6 @@
        draw_bars_(false),
        modifications_(),
        units_(NULL),
-       tod_manager_(NULL),
        invisibility_cache_()
 {
        read(cfg,use_traits);
@@ -353,7 +350,7 @@
        }
 }
 
-unit::unit(unit_map *unitmap, const tod_manager *tod_mng, const unit_type 
*t, int side,
+unit::unit(unit_map *unitmap, const unit_type *t, int side,
                bool use_traits, bool dummy_unit, unit_race::GENDER gender, 
std::string variation, bool force_gender) :
        cfg_(),
        advances_to_(),
@@ -421,7 +418,6 @@
        draw_bars_(false),
        modifications_(),
        units_(unitmap),
-       tod_manager_(tod_mng),
        invisibility_cache_()
 {
        cfg_["upkeep"]="full";
@@ -520,7 +516,6 @@
        draw_bars_(false),
        modifications_(),
        units_(NULL),
-       tod_manager_(NULL),
        invisibility_cache_()
 {
        cfg_["upkeep"]="full";
@@ -579,10 +574,9 @@
 
 
 
-void unit::set_game_context(unit_map *unitmap, const tod_manager *tod_mng)
+void unit::set_game_context(unit_map *unitmap)
 {
        units_ = unitmap;
-       tod_manager_ = tod_mng;
 
        // In case the unit carries EventWML, apply it now
        game_events::add_events(cfg_.child_range("event"), type_);
@@ -1125,7 +1119,7 @@
        if(cfg.has_child("filter_location")) {
                assert(resources::game_map != NULL);
                assert(resources::teams != NULL);
-               assert(tod_manager_ != NULL);
+               assert(resources::tod_manager != NULL);
                assert(units_ != NULL);
                const vconfig& t_cfg = cfg.child("filter_location");
                terrain_filter t_filter(t_cfg, *units_, use_flat_tod);

Modified: trunk/src/unit.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/unit.hpp?rev=36976&r1=36975&r2=36976&view=diff
==============================================================================
--- trunk/src/unit.hpp (original)
+++ trunk/src/unit.hpp Sat Jul 18 14:06:00 2009
@@ -26,7 +26,6 @@
 #include "unit_map.hpp"
 
 class config_writer;
-class tod_manager;
 class game_display;
 class game_state;
 class vconfig;
@@ -69,15 +68,14 @@
        /** Initilizes a unit from a config */
        unit(const config& cfg, bool use_traits=false);
        unit(unit_map* unitmap,
-               const tod_manager* tod_mng,
                const config& cfg, bool use_traits=false, game_state* state = 
0);
        /** Initializes a unit from a unit type */
        unit(const unit_type* t, int side, bool use_traits=false, bool 
dummy_unit=false, unit_race::GENDER gender=unit_race::MALE, std::string 
variation="");
-       unit(unit_map* unitmap, const tod_manager* tod_mng, const unit_type* 
t, int side, bool use_traits=false, bool dummy_unit=false, unit_race::GENDER 
gender=unit_race::MALE, std::string variation="", bool force_gender=false);
+       unit(unit_map* unitmap, const unit_type* t, int side, bool 
use_traits=false, bool dummy_unit=false, unit_race::GENDER 
gender=unit_race::MALE, std::string variation="", bool force_gender=false);
        virtual ~unit();
        unit& operator=(const unit&);
 
-       void set_game_context(unit_map* unitmap, const tod_manager* tod_mng);
+       void set_game_context(unit_map* unitmap);
 
        /** Advances this unit to another type */
        void advance_to(const unit_type* t, bool use_traits=false, 
game_state* state = 0);
@@ -457,7 +455,6 @@
 
        friend void attack_type::set_specials_context(const map_location& 
loc, const map_location&, const unit& un, bool) const;
        const unit_map* units_;
-       const tod_manager* tod_manager_;
 
        /** Hold the visibility status cache for a unit, mutable since it's a 
cache. */
        mutable std::map<map_location, bool> invisibility_cache_;

Modified: trunk/src/unit_abilities.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/unit_abilities.cpp?rev=36976&r1=36975&r2=36976&view=diff
==============================================================================
--- trunk/src/unit_abilities.cpp (original)
+++ trunk/src/unit_abilities.cpp Sat Jul 18 14:06:00 2009
@@ -245,7 +245,7 @@
 bool unit::ability_active(const std::string& ability,const config& cfg,const 
map_location& loc) const
 {
        int illuminates = -1;
-       assert(units_ && resources::game_map && resources::teams && 
tod_manager_);
+       assert(units_ && resources::game_map && resources::teams && 
resources::tod_manager);
 
        if (const config &afilter = cfg.child("filter"))
                if (!matches_filter(vconfig(afilter), loc, 
cache_illuminates(illuminates, ability)))
@@ -761,7 +761,6 @@
        dloc_ = dloc;
        unitmap_ = un.units_;
        map_ = resources::game_map;
-       tod_manager_ = un.tod_manager_;
        teams_ = resources::teams;
        attacker_ = attacker;
        other_attack_ = NULL;




Related Messages


Powered by MHonArc, Updated Sat Jul 18 14:21:05 2009