Author: soliton
Date: Thu Apr 30 17:35:47 2009
New Revision: 35349

URL: http://svn.gna.org/viewcvs/wesnoth?rev=35349&view=rev
Log:
* Added the 'sub' key to [set_variable] to subtract from the variable.

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

Modified: trunk/changelog
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/changelog?rev=35349&r1=35348&r2=35349&view=diff
==============================================================================
--- trunk/changelog (original)
+++ trunk/changelog Thu Apr 30 17:35:47 2009
@@ -118,6 +118,7 @@
      also allow to use sub-tag [not] (to hide a race but not a specific type)
    * [stone] and [unstone] have been replaced with [petrify] and [unpetrify];
      the units' "stoned" status variable has been renamed to "petrified"
+   * Added the 'sub' key to [set_variable] to subtract from the variable.
  * Miscellaneous and bugfixes:
    * Added --ignore-fatal-errors option to wmlunits
    * Added --rng-seed command line option to specify a value to seed the random

Modified: trunk/src/game_events.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/game_events.cpp?rev=35349&r1=35348&r2=35349&view=diff
==============================================================================
--- trunk/src/game_events.cpp (original)
+++ trunk/src/game_events.cpp Thu Apr 30 17:35:47 2009
@@ -1276,6 +1276,15 @@
                        }
                }
 
+               const std::string sub = cfg["sub"];
+               if(sub.empty() == false) {
+                       if(isint(var.str()) && isint(sub)) {
+                               var = str_cast( std::atoi(var.c_str()) - 
std::atoi(sub.c_str()) );
+                       } else {
+                               var = str_cast( std::atof(var.c_str()) - 
std::atof(sub.c_str()) );
+                       }
+               }
+
                const std::string multiply = cfg["multiply"];
                if(multiply.empty() == false) {
                        if(isint(var) && isint(multiply)) {


_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits

Reply via email to