RNDSTRAW.H (3713B)
1 // 2 // Copyright 2020 Electronic Arts Inc. 3 // 4 // TiberianDawn.DLL and RedAlert.dll and corresponding source code is free 5 // software: you can redistribute it and/or modify it under the terms of 6 // the GNU General Public License as published by the Free Software Foundation, 7 // either version 3 of the License, or (at your option) any later version. 8 9 // TiberianDawn.DLL and RedAlert.dll and corresponding source code is distributed 10 // in the hope that it will be useful, but with permitted additional restrictions 11 // under Section 7 of the GPL. See the GNU General Public License in LICENSE.TXT 12 // distributed with this program. You should have received a copy of the 13 // GNU General Public License along with permitted additional restrictions 14 // with this program. If not, see https://github.com/electronicarts/CnC_Remastered_Collection 15 16 /* $Header: /CounterStrike/RNDSTRAW.H 1 3/03/97 10:25a Joe_bostic $ */ 17 /*********************************************************************************************** 18 *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** 19 *********************************************************************************************** 20 * * 21 * Project Name : Command & Conquer * 22 * * 23 * File Name : RNDSTRAW.H * 24 * * 25 * Programmer : Joe L. Bostic * 26 * * 27 * Start Date : 07/04/96 * 28 * * 29 * Last Update : July 4, 1996 [JLB] * 30 * * 31 *---------------------------------------------------------------------------------------------* 32 * Functions: * 33 * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ 34 35 36 #ifndef RNDSTRAW_H 37 #define RNDSTRAW_H 38 39 40 #include "straw.h" 41 #include "random.h" 42 43 /* 44 ** This is a straw terminator class. It will generate random numbers to fill the data request. 45 ** Unlike regular straw terminators, this class will never run out of "data". 46 */ 47 class RandomStraw : public Straw 48 { 49 public: 50 RandomStraw(void); 51 virtual ~RandomStraw(void); 52 53 virtual int Get(void * source, int slen); 54 55 void Reset(void); 56 void Seed_Bit(int seed); 57 void Seed_Byte(char seed); 58 void Seed_Short(short seed); 59 void Seed_Long(long seed); 60 61 int Seed_Bits_Needed(void) const; 62 63 private: 64 /* 65 ** Counter of the number of seed bits stored to this random number 66 ** generator. 67 */ 68 int SeedBits; 69 70 /* 71 ** The current random generator to use when fetching the next random 72 ** byte of data. 73 */ 74 int Current; 75 76 /* 77 ** Array of generators. There must be at least 448 bits of random number seed 78 ** in order to be reasonably secure, however, using 1024 bits would be best. 79 */ 80 RandomClass Random[32]; 81 82 void Scramble_Seed(void); 83 84 RandomStraw(RandomStraw & rvalue); 85 RandomStraw & operator = (RandomStraw const & pipe); 86 }; 87 88 89 #endif