summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDarkvater <darkvater@openttd.org>2005-07-15 21:28:26 +0000
committerDarkvater <darkvater@openttd.org>2005-07-15 21:28:26 +0000
commit95463428c806c83e9383c413a04452274ee716fa (patch)
treee6a8586269965e4d359c151af3826423098a1046
parentc496d92c3e2d19c276a1d9ede104a7a86575693d (diff)
downloadopenttd-95463428c806c83e9383c413a04452274ee716fa.tar.xz
(svn r2585) - Fix [Makefile]: some small cleanups, remove warnings, and add mersenne to makefile (Luca)
-rw-r--r--Makefile1
-rw-r--r--functions.h2
-rw-r--r--mersenne.c145
-rw-r--r--npf.c2
-rw-r--r--openttd.h6
-rw-r--r--strings.c3
6 files changed, 82 insertions, 77 deletions
diff --git a/Makefile b/Makefile
index 00fbb13c2..8339749d1 100644
--- a/Makefile
+++ b/Makefile
@@ -639,6 +639,7 @@ C_SOURCES += landscape.c
C_SOURCES += main_gui.c
C_SOURCES += map.c
C_SOURCES += md5.c
+C_SOURCES += mersenne.c
C_SOURCES += minilzo.c
C_SOURCES += misc.c
C_SOURCES += misc_cmd.c
diff --git a/functions.h b/functions.h
index 1ea2c9a8e..0b62da095 100644
--- a/functions.h
+++ b/functions.h
@@ -79,7 +79,7 @@ void ShowInfo(const char *str);
void CDECL ShowInfoF(const char *str, ...);
void NORETURN CDECL error(const char *str, ...);
-/* ttd.c */
+/* openttd.c */
// **************
// * Warning: DO NOT enable this unless you understand what it does
diff --git a/mersenne.c b/mersenne.c
index 98170084f..a30bc0cf5 100644
--- a/mersenne.c
+++ b/mersenne.c
@@ -1,72 +1,73 @@
-#include "stdafx.h"
-#include "openttd.h"
-
-#ifdef MERSENNE_TWISTER
-
-// Source code for Mersenne Twister.
-// A Random number generator with much higher quality random numbers.
-
-#define N (624) // length of _mt_state vector
-#define M (397) // a period parameter
-#define K (0x9908B0DFU) // a magic constant
-#define hiBit(u) ((u) & 0x80000000U) // mask all but highest bit of u
-#define loBit(u) ((u) & 0x00000001U) // mask all but lowest bit of u
-#define loBits(u) ((u) & 0x7FFFFFFFU) // mask the highest bit of u
-#define mixBits(u, v) (hiBit(u)|loBits(v)) // move hi bit of u to hi bit of v
-
-static uint32 _mt_state[N+1]; // _mt_state vector + 1 extra to not violate ANSI C
-static uint32 *_mt_next; // _mt_next random value is computed from here
-static int _mt_left = -1; // can *_mt_next++ this many times before reloading
-
-void SeedMT(uint32 seed)
-{
- register uint32 x = (seed | 1U) & 0xFFFFFFFFU, *s = _mt_state;
- register int j;
-
- for(_mt_left=0, *s++=x, j=N; --j;
- *s++ = (x*=69069U) & 0xFFFFFFFFU);
- }
-
-
-static uint32 ReloadMT(void)
- {
- register uint32 *p0=_mt_state, *p2=_mt_state+2, *pM=_mt_state+M, s0, s1;
- register int j;
-
- if(_mt_left < -1)
- SeedMT(4357U);
-
- _mt_left=N-1, _mt_next=_mt_state+1;
-
- for(s0=_mt_state[0], s1=_mt_state[1], j=N-M+1; --j; s0=s1, s1=*p2++)
- *p0++ = *pM++ ^ (mixBits(s0, s1) >> 1) ^ (loBit(s1) ? K : 0U);
-
- for(pM=_mt_state, j=M; --j; s0=s1, s1=*p2++)
- *p0++ = *pM++ ^ (mixBits(s0, s1) >> 1) ^ (loBit(s1) ? K : 0U);
-
- s1=_mt_state[0], *p0 = *pM ^ (mixBits(s0, s1) >> 1) ^ (loBit(s1) ? K : 0U);
- s1 ^= (s1 >> 11);
- s1 ^= (s1 << 7) & 0x9D2C5680U;
- s1 ^= (s1 << 15) & 0xEFC60000U;
- return(s1 ^ (s1 >> 18));
- }
-
-
-uint32 RandomMT(void)
-{
- uint32 y;
-
- if(--_mt_left < 0)
- return ReloadMT();
-
- y = *_mt_next++;
- y ^= (y >> 11);
- y ^= (y << 7) & 0x9D2C5680U;
- y ^= (y << 15) & 0xEFC60000U;
- return y ^ (y >> 18);
-}
-#else
-
-void SeedMT(uint32 seed) {}
-
-#endif \ No newline at end of file
+#include "stdafx.h"
+#include "openttd.h"
+
+#ifdef MERSENNE_TWISTER
+
+// Source code for Mersenne Twister.
+// A Random number generator with much higher quality random numbers.
+
+#define N (624) // length of _mt_state vector
+#define M (397) // a period parameter
+#define K (0x9908B0DFU) // a magic constant
+#define hiBit(u) ((u) & 0x80000000U) // mask all but highest bit of u
+#define loBit(u) ((u) & 0x00000001U) // mask all but lowest bit of u
+#define loBits(u) ((u) & 0x7FFFFFFFU) // mask the highest bit of u
+#define mixBits(u, v) (hiBit(u)|loBits(v)) // move hi bit of u to hi bit of v
+
+static uint32 _mt_state[N+1]; // _mt_state vector + 1 extra to not violate ANSI C
+static uint32 *_mt_next; // _mt_next random value is computed from here
+static int _mt_left = -1; // can *_mt_next++ this many times before reloading
+
+void SeedMT(uint32 seed)
+{
+ register uint32 x = (seed | 1U) & 0xFFFFFFFFU, *s = _mt_state;
+ register int j;
+
+ for(_mt_left=0, *s++=x, j=N; --j;
+ *s++ = (x*=69069U) & 0xFFFFFFFFU);
+ }
+
+
+static uint32 ReloadMT(void)
+ {
+ register uint32 *p0=_mt_state, *p2=_mt_state+2, *pM=_mt_state+M, s0, s1;
+ register int j;
+
+ if(_mt_left < -1)
+ SeedMT(4357U);
+
+ _mt_left=N-1, _mt_next=_mt_state+1;
+
+ for(s0=_mt_state[0], s1=_mt_state[1], j=N-M+1; --j; s0=s1, s1=*p2++)
+ *p0++ = *pM++ ^ (mixBits(s0, s1) >> 1) ^ (loBit(s1) ? K : 0U);
+
+ for(pM=_mt_state, j=M; --j; s0=s1, s1=*p2++)
+ *p0++ = *pM++ ^ (mixBits(s0, s1) >> 1) ^ (loBit(s1) ? K : 0U);
+
+ s1=_mt_state[0], *p0 = *pM ^ (mixBits(s0, s1) >> 1) ^ (loBit(s1) ? K : 0U);
+ s1 ^= (s1 >> 11);
+ s1 ^= (s1 << 7) & 0x9D2C5680U;
+ s1 ^= (s1 << 15) & 0xEFC60000U;
+ return(s1 ^ (s1 >> 18));
+ }
+
+
+uint32 RandomMT(void)
+{
+ uint32 y;
+
+ if(--_mt_left < 0)
+ return ReloadMT();
+
+ y = *_mt_next++;
+ y ^= (y >> 11);
+ y ^= (y << 7) & 0x9D2C5680U;
+ y ^= (y << 15) & 0xEFC60000U;
+ return y ^ (y >> 18);
+}
+#else
+
+void SeedMT(uint32 seed) {}
+
+#endif /* MERSENNE_TWISTER */
+
diff --git a/npf.c b/npf.c
index 67eb2b830..81601cb97 100644
--- a/npf.c
+++ b/npf.c
@@ -71,11 +71,13 @@ bool IsEndOfLine(TileIndex tile, Trackdir trackdir, RailType enginetype)
}
};
+#if 0
static uint NTPHash(uint key1, uint key2)
{
/* This function uses the old hash, which is fixed on 10 bits (1024 buckets) */
return PATHFIND_HASH_TILE(key1);
}
+#endif
/**
* Calculates a hash value for use in the NPF.
diff --git a/openttd.h b/openttd.h
index 317acd03f..1936a13aa 100644
--- a/openttd.h
+++ b/openttd.h
@@ -1,5 +1,5 @@
-#ifndef TTD_H
-#define TTD_H
+#ifndef OPENTTD_H
+#define OPENTTD_H
#ifndef VARDEF
#define VARDEF extern
@@ -548,4 +548,4 @@ VARDEF byte _no_scroll;
#include "functions.h"
#include "variables.h"
-#endif /* TTD_H */
+#endif /* OPENTTD_H */
diff --git a/strings.c b/strings.c
index 9e1db8a55..ceae490c3 100644
--- a/strings.c
+++ b/strings.c
@@ -983,4 +983,5 @@ void InitializeLanguagePacks(void)
if (!ReadLanguagePack(def))
error("can't read language pack '%s'", dl->ent[def].file);
-} \ No newline at end of file
+}
+