(svn r9145) [NoAI] -Fix: allow compiling with RANDOM_DEBUG enabled (tnx Rubidium)
--- a/src/ai/core/ai_base.hpp Tue Mar 13 18:36:29 2007 +0000
+++ b/src/ai/core/ai_base.hpp Tue Mar 13 18:43:10 2007 +0000
@@ -13,14 +13,22 @@
* Get a random value.
* @return A random value between 0 and MAX(uint32)
*/
+#if defined(RANDOM_DEBUG)
+ uint32 DoRandom(int line, const char *file);
+#else
uint32 Random();
+#endif
/**
* Get a random value in a range.
* @param max The maximum value it will return.
* @return A random value between 0 .. max.
*/
- uint32 RandomRange(uint max);
+#if defined(RANDOM_DEBUG)
+ uint DoRandomRange(uint max, int line, const char *file);
+#else
+ uint RandomRange(uint max);
+#endif
/**
* Take a chance of 'out' out of 'max'.
--- a/src/ai/core/base/random.cpp Tue Mar 13 18:36:29 2007 +0000
+++ b/src/ai/core/base/random.cpp Tue Mar 13 18:43:10 2007 +0000
@@ -4,20 +4,36 @@
#include "../ai_base.hpp"
+#if defined(RANDOM_DEBUG)
+uint32 AIBase::DoRandom(int line, const char *file)
+#else
uint32 AIBase::Random()
+#endif
{
/* We pick RandomRange if we are in SP (so when saved, we do the same over and over)
* but we pick InteractiveRandomRange if we are a network_server or network-client. */
if (_networking) return InteractiveRandom();
+#if defined(RANDOM_DEBUG)
+ return ::DoRandom(line, file);
+#else
return ::Random();
+#endif
}
-uint32 AIBase::RandomRange(uint max)
+#if defined(RANDOM_DEBUG)
+uint AIBase::DoRandomRange(uint max, int line, const char *file)
+#else
+uint AIBase::RandomRange(uint max)
+#endif
{
/* We pick RandomRange if we are in SP (so when saved, we do the same over and over)
* but we pick InteractiveRandomRange if we are a network_server or network-client. */
if (_networking) return InteractiveRandomRange(max);
+#if defined(RANDOM_DEBUG)
+ return ::DoRandomRange(max, line, file);
+#else
return ::RandomRange(max);
+#endif
}
bool AIBase::Chance(uint out, uint max)