From 039570342d9c77650d88835c82aef4e6c801a1a0 Mon Sep 17 00:00:00 2001 From: skidd13 Date: Wed, 21 Nov 2007 19:13:38 +0000 Subject: (svn r11488) -Codechange: Spilt the random functions out to seperate file -Codechange: Make the mersenne twister more readable -Codechange: Unify the seeding process of random --- src/misc.cpp | 51 --------------------------------------------------- 1 file changed, 51 deletions(-) (limited to 'src/misc.cpp') diff --git a/src/misc.cpp b/src/misc.cpp index 10fd76ecf..52cd764e8 100644 --- a/src/misc.cpp +++ b/src/misc.cpp @@ -27,57 +27,6 @@ char _name_array[512][32]; -#ifndef MERSENNE_TWISTER - -#ifdef RANDOM_DEBUG -#include "network/network_data.h" -uint32 DoRandom(int line, const char *file) -#else // RANDOM_DEBUG -uint32 Random() -#endif // RANDOM_DEBUG -{ - -uint32 s; -uint32 t; - -#ifdef RANDOM_DEBUG - if (_networking && (DEREF_CLIENT(0)->status != STATUS_INACTIVE || !_network_server)) - printf("Random [%d/%d] %s:%d\n",_frame_counter, (byte)_current_player, file, line); -#endif - - s = _random_seeds[0][0]; - t = _random_seeds[0][1]; - _random_seeds[0][0] = s + ROR(t ^ 0x1234567F, 7) + 1; - return _random_seeds[0][1] = ROR(s, 3) - 1; -} -#endif // MERSENNE_TWISTER - -#if defined(RANDOM_DEBUG) && !defined(MERSENNE_TWISTER) -uint DoRandomRange(uint max, int line, const char *file) -{ - return GB(DoRandom(line, file), 0, 16) * max >> 16; -} -#else -uint RandomRange(uint max) -{ - return GB(Random(), 0, 16) * max >> 16; -} -#endif - - -uint32 InteractiveRandom() -{ - uint32 t = _random_seeds[1][1]; - uint32 s = _random_seeds[1][0]; - _random_seeds[1][0] = s + ROR(t ^ 0x1234567F, 7) + 1; - return _random_seeds[1][1] = ROR(s, 3) - 1; -} - -uint InteractiveRandomRange(uint max) -{ - return GB(InteractiveRandom(), 0, 16) * max >> 16; -} - void InitializeVehicles(); void InitializeWaypoints(); void InitializeDepots(); -- cgit v1.2.3-70-g09d2