diff options
author | alberth <alberth@openttd.org> | 2012-09-18 19:29:29 +0000 |
---|---|---|
committer | alberth <alberth@openttd.org> | 2012-09-18 19:29:29 +0000 |
commit | 461fc1e268cb5db0394221f1b61383b453e6fc0a (patch) | |
tree | 09e47a7d2107524293c09567eafdf5a88a26aa92 /src/script/api/script_base.cpp | |
parent | 72639deb84b7b4ca61a10f87ac2dc4841f4c8cdb (diff) | |
download | openttd-461fc1e268cb5db0394221f1b61383b453e6fc0a.tar.xz |
(svn r24531) -Fix: Max script chance was too big.
Diffstat (limited to 'src/script/api/script_base.cpp')
-rw-r--r-- | src/script/api/script_base.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/script/api/script_base.cpp b/src/script/api/script_base.cpp index 5be6dd9a5..2472fe1c7 100644 --- a/src/script/api/script_base.cpp +++ b/src/script/api/script_base.cpp @@ -11,6 +11,7 @@ #include "../../stdafx.h" #include "script_base.hpp" +#include "script_error.hpp" #include "../../network/network.h" #include "../../core/random_func.hpp" @@ -42,7 +43,8 @@ /* static */ bool ScriptBase::Chance(uint out, uint max) { - return (uint16)Rand() <= (uint16)((65536 * out) / max); + EnforcePrecondition(false, out <= max); + return (uint16)Rand() <= (uint16)((65535 * out) / max); } /* static */ bool ScriptBase::ChanceItem(int unused_param, uint out, uint max) |