diff options
author | peter1138 <peter1138@openttd.org> | 2008-08-24 23:00:11 +0000 |
---|---|---|
committer | peter1138 <peter1138@openttd.org> | 2008-08-24 23:00:11 +0000 |
commit | e999f189e6641fc09f2522b44f81a757feccde34 (patch) | |
tree | 0bb45167329807ec747b24cc185e85fc2dee3a18 | |
parent | 6261063689a738338e1c37b183a8c6509ebd0b8d (diff) | |
download | openttd-e999f189e6641fc09f2522b44f81a757feccde34.tar.xz |
(svn r14158) -Codechange: Initialization of rail type data from static source, so data can be changed.
-rw-r--r-- | src/newgrf.cpp | 3 | ||||
-rw-r--r-- | src/rail.h | 5 | ||||
-rw-r--r-- | src/rail_cmd.cpp | 13 | ||||
-rw-r--r-- | src/table/railtypes.h | 2 |
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, |