(svn r9145) [NoAI] -Fix: allow compiling with RANDOM_DEBUG enabled (tnx Rubidium) noai
authortruelight
Tue, 13 Mar 2007 18:43:10 +0000
branchnoai
changeset 9362 3aebc515446a
parent 9361 7bb2bd22b16e
child 9363 56b5886b5cfc
(svn r9145) [NoAI] -Fix: allow compiling with RANDOM_DEBUG enabled (tnx Rubidium)
src/ai/core/ai_base.hpp
src/ai/core/base/random.cpp
--- 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)