RandSync.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /*
  2. * Copyright (c) 2014, Oculus VR, Inc.
  3. * All rights reserved.
  4. *
  5. * This source code is licensed under the BSD-style license found in the
  6. * LICENSE file in the root directory of this source tree. An additional grant
  7. * of patent rights can be found in the PATENTS file in the same directory.
  8. *
  9. */
  10. /// \file
  11. /// \brief \b [Internal] Random number generator
  12. ///
  13. #ifndef __RAND_SYNC_H
  14. #define __RAND_SYNC_H
  15. #include "Export.h"
  16. #include "Rand.h"
  17. #include "DS_Queue.h"
  18. #include "NativeTypes.h"
  19. namespace RakNet {
  20. class BitStream;
  21. class RAK_DLL_EXPORT RakNetRandomSync
  22. {
  23. public:
  24. RakNetRandomSync();
  25. virtual ~RakNetRandomSync();
  26. void SeedMT( uint32_t _seed );
  27. void SeedMT( uint32_t _seed, uint32_t skipValues );
  28. float FrandomMT( void );
  29. unsigned int RandomMT( void );
  30. uint32_t GetSeed( void ) const;
  31. uint32_t GetCallCount( void ) const;
  32. void SetCallCount( uint32_t i );
  33. virtual void SerializeConstruction(RakNet::BitStream *constructionBitstream);
  34. virtual bool DeserializeConstruction(RakNet::BitStream *constructionBitstream);
  35. virtual void Serialize(RakNet::BitStream *outputBitstream);
  36. virtual void Deserialize(RakNet::BitStream *outputBitstream);
  37. protected:
  38. void Skip( uint32_t count );
  39. DataStructures::Queue<unsigned int> usedValues;
  40. uint32_t seed;
  41. uint32_t callCount;
  42. uint32_t usedValueBufferCount;
  43. RakNetRandom rnr;
  44. };
  45. } // namespace RakNet
  46. #endif
粤ICP备19079148号