[Wesnoth-commits] r10231 - in /trunk: changelog src/unit_types.cpp (February 21, 2006 - 05:32)

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

 

Author: noyga
Date: Tue Feb 21 05:31:42 2006
New Revision: 10231

URL: http://svn.gna.org/viewcvs/wesnoth?rev=10231&view=rev
Log:
[effect] can modify attack/defense weight

Modified:
    trunk/changelog
    trunk/src/unit_types.cpp

Modified: trunk/changelog
URL: http://svn.gna.org/viewcvs/wesnoth/trunk/changelog?rev=10231&r1=10230&r2=10231&view=diff
==============================================================================
--- trunk/changelog (original)
+++ trunk/changelog Tue Feb 21 05:31:42 2006
@@ -35,6 +35,7 @@
    * added 'profile' key to [unit] variables
    * added [label] inside [event]
    * attack animations can now be filtered on hit an miss
+   * [effect] can modify attack/defense weight
  * miscellaneous
    * added a --load FILE command-line option, where FILE is a saved game
      in the standard save game directory.

Modified: trunk/src/unit_types.cpp
URL: http://svn.gna.org/viewcvs/wesnoth/trunk/src/unit_types.cpp?rev=10231&r1=10230&r2=10231&view=diff
==============================================================================
--- trunk/src/unit_types.cpp (original)
+++ trunk/src/unit_types.cpp Tue Feb 21 05:31:42 2006
@@ -67,22 +67,8 @@
 	damage_ = atol(cfg["damage"].c_str());
 	num_attacks_ = atol(cfg["number"].c_str());
 
-	const std::string& attack_weight_string=cfg["attack_weight"];
-	char *aptr;
-	double res = strtod(attack_weight_string.c_str(),&aptr);
-	if (attack_weight_string.empty() || *aptr != '\0') {
-		attack_weight_ = 1.0;
-	} else {
-		attack_weight_ = res;
-	}
-	const std::string& defense_weight_string=cfg["defense_weight"];
-	char *dptr;
-	res = strtod(defense_weight_string.c_str(),&dptr);
-	if (defense_weight_string.empty() || *dptr != '\0') {
-		defense_weight_ = 1.0;
-	} else {
-		defense_weight_ = res;
-	}
+	attack_weight_ = lexical_cast_default<double>(cfg["attack_weight"],1.0);
+	defense_weight_ = lexical_cast_default<double>(cfg["defense_weight"],1.0);
 }
 
 const t_string& attack_type::name() const
@@ -250,6 +236,8 @@
 	const std::string& set_special = cfg["set_special"];
 	const std::string& increase_damage = cfg["increase_damage"];
 	const std::string& increase_attacks = cfg["increase_attacks"];
+	const std::string& set_attack_weight = cfg["attack_weight"];
+	const std::string& set_defense_weight = cfg["defense_weight"];
 
 	std::stringstream desc;
 
@@ -280,6 +268,14 @@
 		if(description != NULL) {
 			desc << (increase_attacks[0] == '-' ? "" : "+") << increase_attacks << " " << _("strikes");
 		}
+	}
+
+	if(set_attack_weight.empty() == false) {
+		attack_weight_ = lexical_cast_default<double>(set_attack_weight,1.0);
+	}
+
+	if(set_defense_weight.empty() == false) {
+		defense_weight_ = lexical_cast_default<double>(set_defense_weight,1.0);
 	}
 
 	if(description != NULL) {



Related Mails




Powered by MHonArc, Updated Tue Feb 21 07:00:32 2006