mail[Wesnoth-commits] r28990 - in /trunk: changelog src/unit.cpp src/unit.hpp


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

Header


Content

Posted by patrick_X99 on August 26, 2008 - 09:28:
Author: sapient
Date: Tue Aug 26 09:28:06 2008
New Revision: 28990

URL: http://svn.gna.org/viewcvs/wesnoth?rev=28990&view=rev
Log:
   * fix bug where max_experience of stored units was not the true max when 
playing with under 100% exp. settings
   * prevent some negative/nonsense values in direct WML unit modifications

Modified:
    trunk/changelog
    trunk/src/unit.cpp
    trunk/src/unit.hpp

Modified: trunk/changelog
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/changelog?rev=28990&r1=28989&r2=28990&view=diff
==============================================================================
--- trunk/changelog (original)
+++ trunk/changelog Tue Aug 26 09:28:06 2008
@@ -27,6 +27,9 @@
        [secondary_unit] weapon= deprecated too; use [primary_attack] and
        [secondary_attack] blocks instead.
    * fix various minor bugs with attack filtering
+   * fix bug where max_experience of stored units was not the true max when
+     playing with under 100% exp. settings
+   * prevent some negative/nonsense values in direct WML unit modifications
  * Miscellaneous and bug fixes:
    * Changed side_drop handling not to automaticaly assign AI for side if
      leader is dead (bug #12186)

Modified: trunk/src/unit.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/unit.cpp?rev=28990&r1=28989&r2=28990&view=diff
==============================================================================
--- trunk/src/unit.cpp (original)
+++ trunk/src/unit.cpp Tue Aug 26 09:28:06 2008
@@ -1468,9 +1468,9 @@
                undead_variation_ = cfg["undead_variation"];
        }
        if(cfg["max_attacks"] != "") {
-               max_attacks_ = 
lexical_cast_default<int>(cfg["max_attacks"],1);
-       }
-       attacks_left_ = lexical_cast_default<int>(cfg["attacks_left"], 
max_attacks_);
+               max_attacks_ = 
std::max<int>(0,lexical_cast_default<int>(cfg["max_attacks"],1));
+       }
+       attacks_left_ = 
std::max<int>(0,lexical_cast_default<int>(cfg["attacks_left"], max_attacks_));
 
        if(cfg["alpha"] != "") {
                alpha_ = lexical_cast_default<fixed_t>(cfg["alpha"]);
@@ -1491,9 +1491,9 @@
        if(cfg["profile"] != "") {
                cfg_["profile"] = cfg["profile"];
        }
-       max_hit_points_ = lexical_cast_default<int>(cfg["max_hitpoints"], 
max_hit_points_);
-       max_movement_ = lexical_cast_default<int>(cfg["max_moves"], 
max_movement_);
-       max_experience_ = lexical_cast_default<int>(cfg["max_experience"], 
max_experience_);
+       max_hit_points_ = 
std::max<int>(1,lexical_cast_default<int>(cfg["max_hitpoints"], 
max_hit_points_));
+       max_movement_ = 
std::max<int>(0,lexical_cast_default<int>(cfg["max_moves"], max_movement_));
+       max_experience_ = 
std::max<int>(1,lexical_cast_default<int>(cfg["max_experience"], 
max_experience_));
 
        std::vector<std::string> temp_advances = 
utils::split(cfg["advances_to"]);
        if(temp_advances.size() == 1 && temp_advances.front() == "null") {
@@ -2468,7 +2468,7 @@
        is_fearless_ = false;
        is_healthy_ = false;
        max_hit_points_ = t->hitpoints();
-       max_experience_ = t->experience_needed();
+       max_experience_ = t->experience_needed(false);
        max_movement_ = t->movement();
        attacks_ = t->attacks();
 
@@ -2994,6 +2994,10 @@
                        traits_description_ += ", ";
                }
        }
+
+       //apply the experience acceleration last
+       int exp_accel = unit_type::experience_accelerator::get_acceleration();
+       max_experience_ = std::max<int>(1, (max_experience_ * exp_accel + 
50)/100);
 }
 
 bool unit::invisible(const gamemap::location& loc,

Modified: trunk/src/unit.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/unit.hpp?rev=28990&r1=28989&r2=28990&view=diff
==============================================================================
--- trunk/src/unit.hpp (original)
+++ trunk/src/unit.hpp Tue Aug 26 09:28:06 2008
@@ -105,7 +105,7 @@
        int hitpoints() const { return hit_points_; }
        int max_hitpoints() const { return max_hit_points_; }
        int experience() const { return experience_; }
-       int max_experience() const { return 
std::max<int>(1,(max_experience_*unit_type::experience_accelerator::get_acceleration()
 + 50) / 100); }
+       int max_experience() const { return max_experience_; }
        int level() const { return level_; }
        /**
         * Adds 'xp' points to the units experience; returns true if 
advancement




Related Messages


Powered by MHonArc, Updated Tue Aug 26 11:41:25 2008