mirror of
https://github.com/wesnoth/wesnoth
synced 2025-05-18 17:28:17 +00:00
Added a modulo for set_variable wml,
...it uses the new itoa function of my previous commit. Also the int(atof(string)) which other similar code uses is not required so didn't use that either. Might be nice to convert the existing code as well.
This commit is contained in:
parent
090ad8ba82
commit
075432e75f
@ -69,7 +69,7 @@ Version 1.3-svn:
|
||||
* units can now have victory animations, usable with the WML tag 'victory_anim'
|
||||
* [event]s can now be written also inside [era]s (the [event]s are included
|
||||
in every scenario played using that era)
|
||||
* new operation for set_variable : divide
|
||||
* new operations for set_variable : divide and modulo
|
||||
* Animations now use duration= tag instead of begin= and end= (backward
|
||||
* Animations now have a frequency= filter to allow to tweak realtive rarety
|
||||
compatible)
|
||||
|
@ -1,5 +1,4 @@
|
||||
/* $Id$ */
|
||||
/* $Id$ */
|
||||
/*
|
||||
Copyright (C) 2003 by David White <davidnwhite@verizon.net>
|
||||
Part of the Battle for Wesnoth Project http://www.wesnoth.org/
|
||||
@ -887,6 +886,19 @@ bool event_handler::handle_event_command(const queued_event& event_info,
|
||||
}
|
||||
}
|
||||
|
||||
const std::string& modulo = cfg["modulo"];
|
||||
if(modulo.empty() == false) {
|
||||
int value = atoi(var.c_str());
|
||||
int divider = atoi(modulo.c_str());
|
||||
if (divider == 0) {
|
||||
ERR_NG << "division by zero on variable " << name << "\n";
|
||||
return rval;
|
||||
} else {
|
||||
value %= divider;
|
||||
var = utils::itoa(value);
|
||||
}
|
||||
}
|
||||
|
||||
// random generation works as follows:
|
||||
// random=[comma delimited list]
|
||||
// Each element in the list will be considered a separate choice,
|
||||
|
Loading…
x
Reference in New Issue
Block a user