RNDSTRAW.H 3.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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. // TiberianDawn.DLL and RedAlert.dll and corresponding source code is distributed
  9. // in the hope that it will be useful, but with permitted additional restrictions
  10. // under Section 7 of the GPL. See the GNU General Public License in LICENSE.TXT
  11. // distributed with this program. You should have received a copy of the
  12. // GNU General Public License along with permitted additional restrictions
  13. // with this program. If not, see https://github.com/electronicarts/CnC_Remastered_Collection
  14. /* $Header: /CounterStrike/RNDSTRAW.H 1 3/03/97 10:25a Joe_bostic $ */
  15. /***********************************************************************************************
  16. *** 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 ***
  17. ***********************************************************************************************
  18. * *
  19. * Project Name : Command & Conquer *
  20. * *
  21. * File Name : RNDSTRAW.H *
  22. * *
  23. * Programmer : Joe L. Bostic *
  24. * *
  25. * Start Date : 07/04/96 *
  26. * *
  27. * Last Update : July 4, 1996 [JLB] *
  28. * *
  29. *---------------------------------------------------------------------------------------------*
  30. * Functions: *
  31. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  32. #ifndef RNDSTRAW_H
  33. #define RNDSTRAW_H
  34. #include "straw.h"
  35. #include "random.h"
  36. /*
  37. ** This is a straw terminator class. It will generate random numbers to fill the data request.
  38. ** Unlike regular straw terminators, this class will never run out of "data".
  39. */
  40. class RandomStraw : public Straw
  41. {
  42. public:
  43. RandomStraw(void);
  44. virtual ~RandomStraw(void);
  45. virtual int Get(void * source, int slen);
  46. void Reset(void);
  47. void Seed_Bit(int seed);
  48. void Seed_Byte(char seed);
  49. void Seed_Short(short seed);
  50. void Seed_Long(long seed);
  51. int Seed_Bits_Needed(void) const;
  52. private:
  53. /*
  54. ** Counter of the number of seed bits stored to this random number
  55. ** generator.
  56. */
  57. int SeedBits;
  58. /*
  59. ** The current random generator to use when fetching the next random
  60. ** byte of data.
  61. */
  62. int Current;
  63. /*
  64. ** Array of generators. There must be at least 448 bits of random number seed
  65. ** in order to be reasonably secure, however, using 1024 bits would be best.
  66. */
  67. RandomClass Random[32];
  68. void Scramble_Seed(void);
  69. RandomStraw(RandomStraw & rvalue);
  70. RandomStraw & operator = (RandomStraw const & pipe);
  71. };
  72. #endif