Mercurial > hg > openttd
changeset 10001:5f7a84c30cdf draft
(svn r14158) -Codechange: Initialization of rail type data from static source, so data can be changed.
author | peter1138 <peter1138@openttd.org> |
---|---|
date | Sun, 24 Aug 2008 23:00:11 +0000 |
parents | 4b2c65748b47 |
children | 139ef0c97e94 |
files | src/newgrf.cpp src/rail.h src/rail_cmd.cpp src/table/railtypes.h |
diffstat | 4 files changed, 22 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/src/newgrf.cpp +++ b/src/newgrf.cpp @@ -5422,6 +5422,9 @@ /* Copy/reset original bridge info data */ ResetBridges(); + /* Reset rail type information */ + ResetRailTypes(); + /* Allocate temporary refit/cargo class data */ _gted = CallocT<GRFTempEngineData>(GetEnginePoolSize());
--- a/src/rail.h +++ b/src/rail.h @@ -237,4 +237,9 @@ */ RailTypes GetPlayerRailtypes(const PlayerID p); +/** + * Reset all rail type information to its default values. + */ +void ResetRailTypes(); + #endif /* RAIL_H */
--- 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,
--- 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,