mirror of
https://github.com/wesnoth/wesnoth
synced 2025-05-08 06:23:18 +00:00
Increase of WML random values.
This commit is contained in:
parent
7c0090b77f
commit
af2ad24e4e
@ -15,6 +15,7 @@ Version 1.11.0-svn:
|
||||
* new key: [set_menu_item][command]delayed_variable_substitution=yes|no
|
||||
* Removed support for the deprecated "colour=", "debug_border_colour=",
|
||||
and [colour_adjust]
|
||||
* Fixed bug #18996: Increase random number generation range.
|
||||
* Miscellaneous and bug fixes:
|
||||
* Fix wrong preferences path suffix (1.1 instead of 1.10) on Linux and other
|
||||
platforms using XDG layout (no compiled-in preferences path override,
|
||||
|
@ -1411,7 +1411,24 @@ WML_HANDLER_FUNCTION(set_variable, /*event_info*/, cfg)
|
||||
}
|
||||
}
|
||||
|
||||
int choice = state_of_game->rng().get_next_random() % num_choices;
|
||||
/*
|
||||
* Choice gets a value in the range [0..32768).
|
||||
* So need to add a second set of random values when a value
|
||||
* outside the range is requested.
|
||||
*/
|
||||
if(num_choices > 0x3fffffff) {
|
||||
WRN_NG << "Requested random number with an upper bound of "
|
||||
<< num_choices
|
||||
<< " however the maximum number generated will be "
|
||||
<< 0x3fffffff
|
||||
<< ".\n";
|
||||
}
|
||||
int choice = state_of_game->rng().get_next_random();
|
||||
if(num_choices >= 32768) {
|
||||
choice <<= 15;
|
||||
choice += state_of_game->rng().get_next_random();
|
||||
}
|
||||
choice %= num_choices;
|
||||
int tmp = 0;
|
||||
for(size_t i = 0; i < ranges.size(); ++i) {
|
||||
tmp += (ranges[i].second - ranges[i].first) + 1;
|
||||
|
Loading…
x
Reference in New Issue
Block a user