summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2009-05-14 12:08:24 +0000
committerrubidium <rubidium@openttd.org>2009-05-14 12:08:24 +0000
commita5d6e23e9d2c3752e2a059325ed67026c0ebdfdb (patch)
tree89844a6b0a6dda4ea42c1e6697718394df916351 /src/core
parent9dff385c3841cbb894058de2ac018bfcb7e53fd9 (diff)
downloadopenttd-a5d6e23e9d2c3752e2a059325ed67026c0ebdfdb.tar.xz
(svn r16305) -Codechange: force-enable extra sync checking when random debugging is enable and give the calling location of Chance16(R) instead of the Random call within those functions.
Diffstat (limited to 'src/core')
-rw-r--r--src/core/random_func.hpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/core/random_func.hpp b/src/core/random_func.hpp
index 811c53b55..9d1d585ae 100644
--- a/src/core/random_func.hpp
+++ b/src/core/random_func.hpp
@@ -135,10 +135,14 @@ static FORCEINLINE bool Chance16I(const uint a, const uint b, const uint32 r)
* @param b The denominator of the fraction
* @return True with (a/b) probability
*/
+#ifdef RANDOM_DEBUG
+ #define Chance16(a, b) Chance16I(a, b, DoRandom(__LINE__, __FILE__))
+#else
static FORCEINLINE bool Chance16(const uint a, const uint b)
{
return Chance16I(a, b, Random());
}
+#endif /* RANDOM_DEBUG */
/**
* Flips a coin with a given probability and saves the randomize-number in a variable.
@@ -155,10 +159,14 @@ static FORCEINLINE bool Chance16(const uint a, const uint b)
* @param r The variable to save the randomize-number from Random()
* @return True in (a/b) percent
*/
+#ifdef RANDOM_DEBUG
+ #define Chance16R(a, b, r) (r = DoRandom(__LINE__, __FILE__), Chance16I(a, b, r))
+#else
static FORCEINLINE bool Chance16R(const uint a, const uint b, uint32 &r)
{
r = Random();
return Chance16I(a, b, r);
}
+#endif /* RANDOM_DEBUG */
#endif /* RANDOM_FUNC_HPP */