From 55a56221b275df508b2701873fc70c0791082d9e Mon Sep 17 00:00:00 2001 From: meep-eep Date: Sat, 25 Nov 2006 20:59:06 +0000 Subject: [PATCH] Remove unused fast random stuff. git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@2544 8092fc87-c524-0410-9efc-e669fe64eaf9 --- sc2/src/sc2code/libs/math/Makeinfo | 2 +- sc2/src/sc2code/libs/math/fastrand.c | 125 --------------------------- sc2/src/sc2code/libs/math/random.h | 18 +--- sc2/src/sc2code/libs/mathlib.h | 3 +- 4 files changed, 4 insertions(+), 144 deletions(-) delete mode 100644 sc2/src/sc2code/libs/math/fastrand.c diff --git a/sc2/src/sc2code/libs/math/Makeinfo b/sc2/src/sc2code/libs/math/Makeinfo index de2311561..fc6d5aae7 100644 --- a/sc2/src/sc2code/libs/math/Makeinfo +++ b/sc2/src/sc2code/libs/math/Makeinfo @@ -1 +1 @@ -uqm_CFILES="fastrand.c random.c sqrt.c" +uqm_CFILES="random.c sqrt.c" diff --git a/sc2/src/sc2code/libs/math/fastrand.c b/sc2/src/sc2code/libs/math/fastrand.c deleted file mode 100644 index 7b2db2ae5..000000000 --- a/sc2/src/sc2code/libs/math/fastrand.c +++ /dev/null @@ -1,125 +0,0 @@ -//Copyright Paul Reiche, Fred Ford. 1992-2002 - -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#include "mthintrn.h" -#include "random.h" /* get the externs for error checking */ - -/* ----------------------------GLOBAL DATA-------------------------------- */ - -DWORD random_table[TABLE_SIZE]; -COUNT fast_index = 0; /* fast random cycling index */ - -/* ----------------------------PROTOTYPES--------------------------------- */ - -DWORD indexed_random_table(COUNT index); -void reseed_fast_random(void); -DWORD fast_random(void); -DWORD seed_fast_random(DWORD seed); - -/***************************************************************************** -* FUNC: DWORD seed_fast_random(DWORD seed) -* -* DESC:generate a small table of random numbers for later use by fast_random() -* -* NOTES: the table has a prime number of entries -* -* HISTORY: Created By Robert Leyland -* -*****************************************************************************/ - -DWORD -seed_fast_random(DWORD seed) -{ - DWORD retval; - COUNT index; - - retval = TFB_SeedRandom(seed); - - for( index = 0; index < TABLE_SIZE; index++ ) - random_table[index] = TFB_Random(); - - fast_index = 0; /* must be set to the start of the table for - repeatability... */ - - return (retval); -} - - -/***************************************************************************** -* FUNC: DWORD fast_random() -* -* DESC:return the next random number from the random number table -* -* NOTES: -* -* HISTORY: Created By Robert Leyland -* -*****************************************************************************/ - -DWORD -fast_random(void) -{ - fast_index++; - if( fast_index == TABLE_SIZE ) - fast_index = 0; - - return( random_table[fast_index] ); -} - -/***************************************************************************** -* FUNC: void reseed_fast_random() -* -* DESC:shifts the table pointer by calling the "real" random -* -* NOTES: -* -* HISTORY: Created By Robert Leyland -* -*****************************************************************************/ - -void -reseed_fast_random(void) -{ - fast_index = (COUNT)(TFB_Random() % TABLE_SIZE); - -} - - -/***************************************************************************** -* FUNC: DWORD indexed_random_table(COUNT index) -* -* DESC:return a "random" number from the random number table, as indexed -* for repeatability -* -* NOTES:used by texturing functions -* -* HISTORY: Created By Robert Leyland -* -*****************************************************************************/ - -DWORD -indexed_random_table(COUNT index) -{ - if( index > TABLE_SIZE ) /* only do % if really needed */ - index = index % TABLE_SIZE; - - return(random_table[index]); -} - - - diff --git a/sc2/src/sc2code/libs/math/random.h b/sc2/src/sc2code/libs/math/random.h index b54a392c4..b2ac4ec9f 100644 --- a/sc2/src/sc2code/libs/math/random.h +++ b/sc2/src/sc2code/libs/math/random.h @@ -28,27 +28,13 @@ /* ----------------------------DEFINES------------------------------------ */ -#ifndef SLOW_N_STUPID -#define TABLE_SIZE 1117 /* a "nice" prime number */ -#define _FAST_ fast_random() -#else /* FAST_N_UGLY */ -#define TABLE_SIZE ( (1 << 10) - 1 ) -#define _FAST_ ( random_table[ fast_index++ & TABLE_SIZE ] ) -#endif - - -#define FASTRAND(n) ( (int) ( (unsigned int)_FAST_ % (n) ) ) -#define SFASTRAND(n) ( (int)_FAST_ % (n) ) -#define AND_FASTRAND(n) ( (int)_FAST_ & (n) ) - #define RAND(n) ( (int) ( (unsigned int)TFB_Random() % (n) ) ) #define SRAND(n) ( (int)TFB_Random() % (n) ) #define AND_RAND(n) ( (int)TFB_Random() & (n) ) -#define INDEXED_RANDOM(x) (random_table[x]) /* ----------------------------GLOBALS/EXTERNS---------------------------- */ -extern DWORD random_table[TABLE_SIZE]; -extern COUNT fast_index; /* fast random cycling index */ +DWORD TFB_SeedRandom (DWORD seed); +DWORD TFB_Random (void); diff --git a/sc2/src/sc2code/libs/mathlib.h b/sc2/src/sc2code/libs/mathlib.h index 9edae67d4..ef11b166d 100644 --- a/sc2/src/sc2code/libs/mathlib.h +++ b/sc2/src/sc2code/libs/mathlib.h @@ -20,9 +20,8 @@ #define _MATHLIB_H #include "compiler.h" +#include "math/random.h" -extern DWORD TFB_SeedRandom (DWORD seed); -extern DWORD TFB_Random (void); extern COUNT square_root (DWORD value); #endif /* _MATHLIB_H */