mail[Wesnoth-commits] r28489 - /trunk/src/unit.cpp


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

Header


Content

Posted by koraq on August 12, 2008 - 19:26:
Author: mordante
Date: Tue Aug 12 19:26:06 2008
New Revision: 28489

URL: http://svn.gna.org/viewcvs/wesnoth?rev=28489&view=rev
Log:
Initialize all members.

Modified:
    trunk/src/unit.cpp

Modified: trunk/src/unit.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/unit.cpp?rev=28489&r1=28488&r2=28489&view=diff
==============================================================================
--- trunk/src/unit.cpp (original)
+++ trunk/src/unit.cpp Tue Aug 12 19:26:06 2008
@@ -155,10 +155,11 @@
            animations_(o.animations_),
 
            anim_(NULL),
+                  next_idling_(0),
 
            frame_begin_time_(o.frame_begin_time_),
-           unit_halo_(o.unit_halo_),
-           unit_anim_halo_(o.unit_anim_halo_),
+           unit_halo_(halo::NO_HALO),
+           unit_anim_halo_(halo::NO_HALO),
            getsHit_(o.getsHit_),
            refreshing_(o.refreshing_),
            hidden_(o.hidden_),
@@ -168,34 +169,84 @@
            units_(o.units_),
            map_(o.map_),
            gamestatus_(o.gamestatus_),
-           teams_(o.teams_)
-{
-       next_idling_ = 0;
-       unit_halo_ = halo::NO_HALO;
-       unit_anim_halo_ = halo::NO_HALO;
-}
-
-unit::unit(unit_map* unitmap, const gamemap* map,
-       const gamestatus* game_status, const std::vector<team>* teams,const 
config& cfg,
-       bool use_traits, game_state* state) :
-               movement_(0),
-               hold_position_(false),
-               resting_(false),
-               state_(STATE_STANDING),
-               facing_(gamemap::location::SOUTH_EAST),
-               flying_(false),
-               anim_(NULL),
-               next_idling_(0),
-               frame_begin_time_(0),
-               unit_halo_(halo::NO_HALO),
-               unit_anim_halo_(halo::NO_HALO),
-               draw_bars_(false),
-               units_(unitmap),
-               map_(map),
-               gamestatus_(game_status),
-               teams_(teams)
+           teams_(o.teams_),
+                  invisibility_cache_()
+{
+}
+
+unit::unit(unit_map* unitmap, const gamemap* map, const gamestatus* 
game_status, 
+               const std::vector<team>* teams,const config& cfg, 
+               bool use_traits, game_state* state) :
+       cfg_(),
+       advances_to_(),
+       type_(),
+       race_(NULL),
+       id_(),
+       name_(),
+       underlying_id_(),
+       type_name_(),
+       undead_variation_(),
+       variation_(),
+       hit_points_(0),
+       max_hit_points_(0),
+       experience_(0),
+       max_experience_(0),
+       level_(0),
+       alignment_(),
+       flag_rgb_(),
+       image_mods_(),
+       unrenamable_(false),
+       side_(0),
+       gender_(),
+       alpha_(),
+       unit_formula_(),
+       formula_vars_(),
+       recruits_(),
+       movement_(0),
+       max_movement_(0),
+       movement_costs_(),
+       defense_mods_(),
+       hold_position_(false),
+       end_turn_(false),
+       resting_(false),
+       attacks_left_(0),
+       max_attacks_(0),
+       states_(),
+       variables_(),
+       emit_zoc_(0),
+       state_(STATE_STANDING),
+       overlays_(),
+       role_(),
+       ai_special_(),
+       attacks_(),
+       facing_(gamemap::location::SOUTH_EAST),
+       traits_description_(),
+       unit_value_(),
+       goto_(),
+       interrupted_move_(),
+       flying_(false),
+       is_fearless_(false),
+       is_healthy_(false),
+       modification_descriptions_(),
+       animations_(),
+       anim_(NULL),
+       next_idling_(0),
+       frame_begin_time_(0),
+       unit_halo_(halo::NO_HALO),
+       unit_anim_halo_(halo::NO_HALO),
+       getsHit_(0),
+       refreshing_(false),
+       hidden_(false),
+       draw_bars_(false),
+       modifications_(),
+       units_(unitmap),
+       map_(map),
+       gamestatus_(game_status),
+       teams_(teams),
+       invisibility_cache_()
 {
        read(cfg, use_traits, state);
+       /** @todo Are these modified by read? if not they can be removed. */
        getsHit_=0;
        end_turn_ = false;
        refreshing_  = false;
@@ -203,17 +254,80 @@
        game_config::add_color_info(cfg);
 }
 
-unit::unit(const config& cfg,bool use_traits) : movement_(0),
-           hold_position_(false), resting_(false), state_(STATE_STANDING),
-           facing_(gamemap::location::SOUTH_EAST),
-           flying_(false),anim_(NULL),next_idling_(0),frame_begin_time_(0),
-           
unit_halo_(halo::NO_HALO),unit_anim_halo_(halo::NO_HALO),draw_bars_(false),
-           units_(NULL),map_(NULL), gamestatus_(NULL)
+unit::unit(const config& cfg,bool use_traits) : 
+       cfg_(),
+       advances_to_(),
+       type_(),
+       race_(NULL),
+       id_(),
+       name_(),
+       underlying_id_(),
+       type_name_(),
+       undead_variation_(),
+       variation_(),
+       hit_points_(0),
+       max_hit_points_(0),
+       experience_(0),
+       max_experience_(0),
+       level_(0),
+       alignment_(),
+       flag_rgb_(),
+       image_mods_(),
+       unrenamable_(false),
+       side_(0),
+       gender_(),
+       alpha_(),
+       unit_formula_(),
+       formula_vars_(),
+       recruits_(),
+       movement_(0),
+       max_movement_(0),
+       movement_costs_(),
+       defense_mods_(),
+       hold_position_(false), 
+       end_turn_(false),
+       resting_(false), 
+       attacks_left_(0),
+       max_attacks_(0),
+       states_(),
+       variables_(),
+       emit_zoc_(0),
+       state_(STATE_STANDING), 
+       overlays_(),
+       role_(),
+       ai_special_(),
+       attacks_(),
+       facing_(gamemap::location::SOUTH_EAST), 
+       traits_description_(),
+       unit_value_(),
+       goto_(),
+       interrupted_move_(),
+       flying_(false),
+       is_fearless_(false),
+       is_healthy_(false),
+       modification_descriptions_(),
+       animations_(),
+       anim_(NULL),
+       next_idling_(0),
+       frame_begin_time_(0), 
+       unit_halo_(halo::NO_HALO),
+       unit_anim_halo_(halo::NO_HALO),
+       getsHit_(0),
+       refreshing_(false),
+       hidden_(false),
+       draw_bars_(false), 
+       modifications_(),
+       units_(NULL),
+       map_(NULL), 
+       gamestatus_(NULL),
+       teams_(NULL),
+       invisibility_cache_()
 {
        read(cfg,use_traits);
+       /** @todo Are these modified by read? if not they can be removed. */
        getsHit_=0;
        end_turn_ = false;
-       refreshing_  = false;
+       refreshing_ = false;
        hidden_ = false;
 }
 
@@ -244,18 +358,77 @@
        }
 }
 
-unit::unit(unit_map* unitmap, const gamemap* map,
-           const gamestatus* game_status, const std::vector<team>* teams, 
const unit_type* t,
-           int side, bool use_traits, bool dummy_unit, unit_race::GENDER 
gender, std::string variation) :
-           variation_(variation), gender_(dummy_unit ? gender : 
generate_gender(*t,use_traits)), resting_(false),
-           state_(STATE_STANDING), 
facing_(gamemap::location::SOUTH_EAST),draw_bars_(false),
-           units_(unitmap),map_(map),gamestatus_(game_status),teams_(teams)
-{
-       goto_ = gamemap::location();
-       side_ = side;
-       movement_ = 0;
-       attacks_left_ = 0;
-       experience_ = 0;
+unit::unit(unit_map* unitmap, const gamemap* map, const gamestatus* 
game_status, 
+               const std::vector<team>* teams, const unit_type* t, int side, 
+               bool use_traits, bool dummy_unit, unit_race::GENDER gender, 
std::string variation) :
+       cfg_(),
+       advances_to_(),
+       type_(),
+       race_(NULL),
+       id_(),
+       name_(),
+       underlying_id_(),
+       type_name_(),
+       undead_variation_(),
+       variation_(variation), 
+       hit_points_(0),
+       max_hit_points_(0),
+       experience_(0),
+       max_experience_(0),
+       level_(0),
+       alignment_(),
+       flag_rgb_(),
+       image_mods_(),
+       unrenamable_(false),
+       side_(side),
+       gender_(dummy_unit ? gender : generate_gender(*t,use_traits)), 
+       alpha_(),
+       unit_formula_(),
+       formula_vars_(),
+       recruits_(),
+       movement_(0),
+       max_movement_(0),
+       movement_costs_(),
+       defense_mods_(),
+       hold_position_(false),
+       end_turn_(false),
+       resting_(false), 
+       attacks_left_(0),
+       max_attacks_(0),
+       states_(),
+       variables_(),
+       emit_zoc_(0),
+       state_(STATE_STANDING), 
+       overlays_(),
+       role_(),
+       ai_special_(),
+       attacks_(),
+       facing_(gamemap::location::SOUTH_EAST),
+       traits_description_(),
+       unit_value_(),
+       goto_(),
+       interrupted_move_(),
+       flying_(false),
+       is_fearless_(false),
+       is_healthy_(false),
+       modification_descriptions_(),
+       animations_(),
+       anim_(NULL),
+       next_idling_(0),
+       frame_begin_time_(0),
+       unit_halo_(halo::NO_HALO),
+       unit_anim_halo_(halo::NO_HALO),
+       getsHit_(0),
+       refreshing_(false),
+       hidden_(false),
+       draw_bars_(false), 
+       modifications_(),
+       units_(unitmap),
+       map_(map),
+       gamestatus_(game_status),
+       teams_(teams),
+       invisibility_cache_()
+{
        cfg_["upkeep"]="full";
        advance_to(t);
        if(dummy_unit == false) validate_side(side_);
@@ -270,6 +443,10 @@
        apply_modifications();
        set_underlying_id();
 
+       /** 
+        * @todo Test whether the calls above modify these values if not they 
can
+        * removed, since already set in the initialization list.
+        */
        unrenamable_ = false;
        anim_ = NULL;
        getsHit_=0;
@@ -280,16 +457,77 @@
        unit_halo_ = halo::NO_HALO;
        unit_anim_halo_ = halo::NO_HALO;
 }
-unit::unit(const unit_type* t, int side, bool use_traits, bool dummy_unit, 
unit_race::GENDER gender, std::string variation) :
-           variation_(variation),gender_(dummy_unit ? gender : 
generate_gender(*t,use_traits)),
-           
state_(STATE_STANDING),facing_(gamemap::location::SOUTH_EAST),draw_bars_(false),
-           units_(NULL),map_(NULL),gamestatus_(NULL),teams_(NULL)
-{
-       goto_ = gamemap::location();
-       side_ = side;
-       movement_ = 0;
-       attacks_left_ = 0;
-       experience_ = 0;
+
+unit::unit(const unit_type* t, int side, bool use_traits, bool dummy_unit, 
+               unit_race::GENDER gender, std::string variation) :
+       cfg_(),
+       advances_to_(),
+       type_(),
+       race_(NULL),
+       id_(),
+       name_(),
+       underlying_id_(),
+       type_name_(),
+       undead_variation_(),
+       variation_(variation),
+       hit_points_(0),
+       max_hit_points_(0),
+       experience_(0),
+       max_experience_(0),
+       level_(0),
+       alignment_(),
+       flag_rgb_(),
+       image_mods_(),
+       unrenamable_(false),
+       side_(side),
+       gender_(dummy_unit ? gender : generate_gender(*t,use_traits)), 
+       alpha_(),
+       unit_formula_(),
+       formula_vars_(),
+       recruits_(),
+       movement_(0),
+       max_movement_(0),
+       movement_costs_(),
+       defense_mods_(),
+       hold_position_(false),
+       end_turn_(false),
+       resting_(false),
+       attacks_left_(0),
+       max_attacks_(0),
+       states_(),
+       variables_(),
+       emit_zoc_(0),
+       state_(STATE_STANDING),
+       overlays_(),
+       role_(),
+       ai_special_(),
+       attacks_(),
+       facing_(gamemap::location::SOUTH_EAST),
+       traits_description_(),
+       unit_value_(),
+       goto_(),
+       interrupted_move_(),
+       flying_(false),
+       is_fearless_(false),
+       is_healthy_(false),
+       modification_descriptions_(),
+       animations_(),
+       anim_(NULL),
+       next_idling_(0),
+       frame_begin_time_(0),
+       unit_halo_(halo::NO_HALO),
+       unit_anim_halo_(halo::NO_HALO),
+       getsHit_(0),
+       refreshing_(false),
+       hidden_(false),
+       draw_bars_(false), 
+       modifications_(),
+       units_(NULL),
+       map_(NULL),
+       gamestatus_(NULL),
+       teams_(NULL),
+       invisibility_cache_()
+{
        cfg_["upkeep"]="full";
        advance_to(t);
        if(dummy_unit == false) validate_side(side_);
@@ -303,7 +541,11 @@
        reset_modifications();
        apply_modifications();
        set_underlying_id();
-
+ 
+       /** 
+        * @todo Test whether the calls above modify these values if not they 
can
+        * removed, since already set in the initialization list.
+        */
        unrenamable_ = false;
        next_idling_ = 0;
        frame_begin_time_ = 0;




Related Messages


Powered by MHonArc, Updated Tue Aug 12 20:01:50 2008