summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpeter1138 <peter1138@openttd.org>2008-08-24 23:00:11 +0000
committerpeter1138 <peter1138@openttd.org>2008-08-24 23:00:11 +0000
commit2f80a277eb88271f2f0534b85bb3fbe97b036e12 (patch)
tree0bb45167329807ec747b24cc185e85fc2dee3a18
parentff07598ce23d2126e6dbdf6eb4db2bb346e4de11 (diff)
downloadopenttd-2f80a277eb88271f2f0534b85bb3fbe97b036e12.tar.xz
(svn r14158) -Codechange: Initialization of rail type data from static source, so data can be changed.
-rw-r--r--src/newgrf.cpp3
-rw-r--r--src/rail.h5
-rw-r--r--src/rail_cmd.cpp13
-rw-r--r--src/table/railtypes.h2
4 files changed, 22 insertions, 1 deletions
diff --git a/src/newgrf.cpp b/src/newgrf.cpp
index 44892df0b..cf3e53a52 100644
--- a/src/newgrf.cpp
+++ b/src/newgrf.cpp
@@ -5422,6 +5422,9 @@ static void ResetNewGRFData()
/* Copy/reset original bridge info data */
ResetBridges();
+ /* Reset rail type information */
+ ResetRailTypes();
+
/* Allocate temporary refit/cargo class data */
_gted = CallocT<GRFTempEngineData>(GetEnginePoolSize());
diff --git a/src/rail.h b/src/rail.h
index e7d8f293c..8fa3164c2 100644
--- a/src/rail.h
+++ b/src/rail.h
@@ -237,4 +237,9 @@ RailType GetBestRailtype(const PlayerID p);
*/
RailTypes GetPlayerRailtypes(const PlayerID p);
+/**
+ * Reset all rail type information to its default values.
+ */
+void ResetRailTypes();
+
#endif /* RAIL_H */
diff --git a/src/rail_cmd.cpp b/src/rail_cmd.cpp
index 121512b8e..88112966d 100644
--- a/src/rail_cmd.cpp
+++ b/src/rail_cmd.cpp
@@ -54,6 +54,19 @@
#include "table/railtypes.h"
#include "table/track_land.h"
+RailtypeInfo _railtypes[RAILTYPE_END];
+
+assert_compile(sizeof(_original_railtypes) <= sizeof(_railtypes));
+
+/**
+ * Initialize rail type information.
+ */
+void ResetRailTypes()
+{
+ memset(_railtypes, 0, sizeof(_railtypes));
+ memcpy(_railtypes, _original_railtypes, sizeof(_original_railtypes));
+}
+
const byte _track_sloped_sprites[14] = {
14, 15, 22, 13,
0, 21, 17, 12,
diff --git a/src/table/railtypes.h b/src/table/railtypes.h
index 8bfa65645..3a5467cb0 100644
--- a/src/table/railtypes.h
+++ b/src/table/railtypes.h
@@ -9,7 +9,7 @@
/** Global Railtype definition
*/
-RailtypeInfo _railtypes[] = {
+static const RailtypeInfo _original_railtypes[] = {
/** Railway */
{ /* Main Sprites */
{ SPR_RAIL_TRACK_Y, SPR_RAIL_TRACK_N_S, SPR_RAIL_TRACK_BASE, SPR_RAIL_SINGLE_Y, SPR_RAIL_SINGLE_X,