summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2008-08-16 14:02:20 +0000
committerfrosch <frosch@openttd.org>2008-08-16 14:02:20 +0000
commit92f3c368b8685580353172e7979c7d7d816db21f (patch)
tree4c275596da6f577f47cea17f49ee3870846e07cb /src/core
parent302cdf69a4f697134b6495252f51a4d3b91b3f67 (diff)
downloadopenttd-92f3c368b8685580353172e7979c7d7d816db21f.tar.xz
(svn r14083) -Fix [FS#1264, FS#2037, FS#2038, FS#2110]: Rewrite the autoreplace kernel.
Diffstat (limited to 'src/core')
-rw-r--r--src/core/random_func.hpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/core/random_func.hpp b/src/core/random_func.hpp
index d77d38906..82f751003 100644
--- a/src/core/random_func.hpp
+++ b/src/core/random_func.hpp
@@ -52,6 +52,30 @@ struct Randomizer {
extern Randomizer _random; ///< Random used in the game state calculations
extern Randomizer _interactive_random; ///< Random used every else where is does not (directly) influence the game state
+/** Stores the state of all random number generators */
+struct SavedRandomSeeds {
+ Randomizer random;
+ Randomizer interactive_random;
+};
+
+/** Saves the current seeds
+ * @param storage Storage for saving
+ */
+static inline void SaveRandomSeeds(SavedRandomSeeds *storage)
+{
+ storage->random = _random;
+ storage->interactive_random = _interactive_random;
+}
+
+/** Restores previously saved seeds
+ * @param storage Storage where SaveRandomSeeds() stored th seeds
+ */
+static inline void RestoreRandomSeeds(const SavedRandomSeeds &storage)
+{
+ _random = storage.random;
+ _interactive_random = storage.interactive_random;
+}
+
void SetRandomSeed(uint32 seed);
#ifdef RANDOM_DEBUG
#define Random() DoRandom(__LINE__, __FILE__)