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
commitf7826f8a372d3120cc9d56e4d1c11df3e2fd577c (patch)
tree4c275596da6f577f47cea17f49ee3870846e07cb /src/core
parent56459cab81f6a56d1fde29130670d001389ff7ce (diff)
downloadopenttd-f7826f8a372d3120cc9d56e4d1c11df3e2fd577c.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__)