diff --git a/docs/newgrf-additions.html b/docs/newgrf-additions.html index d235c3ac93..ea1b5612bd 100644 --- a/docs/newgrf-additions.html +++ b/docs/newgrf-additions.html @@ -250,6 +250,36 @@
This is indicated by the feature name: action0_roadtype_extra_flags, version 1
This adds extra station names for use when all the avilable station names for a given town have been used.
+ The string should have the same format and use the same ID range as
+ industry - default name for nearby station.
+ The Action 0 ID field is ignored. This property always adds a new station name string instead of overwriting an existing one.
+ The property length is 4 bytes. The format is:
+
Size | Field | Description |
---|---|---|
W | String ID | String to use for the station name |
W | Flags | See table below |
Bit | Value | Meaning |
---|---|---|
0 | 1 | May be used for rail stations |
1 | 2 | May be used for road stations |
2 | 4 | May be used for airport stations |
3 | 8 | May be used for oil rig stations |
4 | 10 | May be used for dock stations |
5 | 20 | May be used for heliport stations |
8 | 100 | May only be used for stations near the town centre |
9 | 200 | May not be used for stations near the town centre |
10 | 400 | May only be used for stations near water |
11 | 800 | May not be used for stations near water |
This is indicated by the feature name: action0_global_extra_station_names, version 1
+This is indicated by the feature name: varaction2_station_var42, version 1
diff --git a/src/gfxinit.cpp b/src/gfxinit.cpp index 1c4ee94f8b..92c3c1051e 100644 --- a/src/gfxinit.cpp +++ b/src/gfxinit.cpp @@ -214,6 +214,9 @@ static void LoadSpriteTables() /* Initialize the unicode to sprite mapping table */ InitializeUnicodeGlyphMap(); + extern uint _extra_station_names_used; + _extra_station_names_used = 0; + /* * Load the base and extra NewGRF with OTTD required graphics as first NewGRF. * However, we do not want it to show up in the list of used NewGRFs, diff --git a/src/misc.cpp b/src/misc.cpp index 279df3f8cf..249eaaad9e 100644 --- a/src/misc.cpp +++ b/src/misc.cpp @@ -94,6 +94,7 @@ void InitializeGame(uint size_x, uint size_y, bool reset_date, bool reset_settin _game_load_date_fract = 0; _game_load_tick_skip_counter = 0; _game_load_time = 0; + _extra_station_names_used = 0; _loadgame_DBGL_data.clear(); if (reset_settings) MakeNewgameSettingsLive(); diff --git a/src/newgrf.cpp b/src/newgrf.cpp index cea70af355..43d14584a3 100644 --- a/src/newgrf.cpp +++ b/src/newgrf.cpp @@ -2886,6 +2886,19 @@ static ChangeInfoResult GlobalVarChangeInfo(uint gvid, int numinfo, int prop, co break; } + case A0RPI_GLOBALVAR_EXTRA_STATION_NAMES: { + if (MappedPropertyLengthMismatch(buf, 4, mapping_entry)) break; + uint16 str = buf->ReadWord(); + uint16 flags = buf->ReadWord(); + if (_extra_station_names_used < MAX_EXTRA_STATION_NAMES) { + ExtraStationNameInfo &info = _extra_station_names[_extra_station_names_used]; + AddStringForMapping(str, &info.str); + info.flags = flags; + _extra_station_names_used++; + } + break; + } + default: ret = HandleAction0PropertyDefault(buf, prop); break; @@ -2954,6 +2967,10 @@ static ChangeInfoResult GlobalVarReserveInfo(uint gvid, int numinfo, int prop, c } break; + case A0RPI_GLOBALVAR_EXTRA_STATION_NAMES: + buf->Skip(buf->ReadExtendedByte()); + break; + default: ret = HandleAction0PropertyDefault(buf, prop); break; @@ -8380,6 +8397,7 @@ static const GRFFeatureInfo _grf_feature_list[] = { GRFFeatureInfo("action0_railtype_restricted_signals", 1), GRFFeatureInfo("action0_railtype_disable_realistic_braking", 1), GRFFeatureInfo("action0_roadtype_extra_flags", 1), + GRFFeatureInfo("action0_global_extra_station_names", 1), GRFFeatureInfo(), }; @@ -8501,6 +8519,7 @@ static const GRFPropertyMapDefinition _grf_action0_remappable_properties[] = { GRFPropertyMapDefinition(GSF_RAILTYPES, A0RPI_RAILTYPE_DISABLE_REALISTIC_BRAKING, "railtype_disable_realistic_braking"), GRFPropertyMapDefinition(GSF_ROADTYPES, A0RPI_ROADTYPE_EXTRA_FLAGS, "roadtype_extra_flags"), GRFPropertyMapDefinition(GSF_TRAMTYPES, A0RPI_ROADTYPE_EXTRA_FLAGS, "roadtype_extra_flags"), + GRFPropertyMapDefinition(GSF_GLOBALVAR, A0RPI_GLOBALVAR_EXTRA_STATION_NAMES, "global_extra_station_names"), GRFPropertyMapDefinition(), }; diff --git a/src/newgrf.h b/src/newgrf.h index d19ec636b8..1bf44d8c54 100644 --- a/src/newgrf.h +++ b/src/newgrf.h @@ -119,6 +119,7 @@ enum Action0RemapPropertyIds { A0RPI_RAILTYPE_ENABLE_RESTRICTED_SIGNALS, A0RPI_RAILTYPE_DISABLE_REALISTIC_BRAKING, A0RPI_ROADTYPE_EXTRA_FLAGS, + A0RPI_GLOBALVAR_EXTRA_STATION_NAMES, }; enum GRFPropertyMapFallbackMode { diff --git a/src/openttd.cpp b/src/openttd.cpp index 8495833a19..4ea16b2907 100644 --- a/src/openttd.cpp +++ b/src/openttd.cpp @@ -464,6 +464,7 @@ static void ShutdownGame() _game_load_date_fract = 0; _game_load_tick_skip_counter = 0; _game_load_time = 0; + _extra_station_names_used = 0; _loadgame_DBGL_data.clear(); _loadgame_DBGC_data.clear(); } diff --git a/src/saveload/extended_ver_sl.cpp b/src/saveload/extended_ver_sl.cpp index ddf2fa57cd..136b12606c 100644 --- a/src/saveload/extended_ver_sl.cpp +++ b/src/saveload/extended_ver_sl.cpp @@ -153,6 +153,7 @@ const SlxiSubChunkInfo _sl_xv_sub_chunk_infos[] = { { XSLFI_CUSTOM_TOWN_ZONE, XSCF_IGNORABLE_UNKNOWN, 1, 1, "custom_town_zone", nullptr, nullptr, nullptr }, { XSLFI_STATION_CARGO_HISTORY, XSCF_NULL, 1, 1, "station_cargo_history", nullptr, nullptr, nullptr }, { XSLFI_TRAIN_SPEED_ADAPTATION, XSCF_NULL, 1, 1, "train_speed_adaptation", nullptr, nullptr, "TSAS" }, + { XSLFI_EXTRA_STATION_NAMES, XSCF_NULL, 1, 1, "extra_station_names", nullptr, nullptr, nullptr }, { XSLFI_NULL, XSCF_NULL, 0, 0, nullptr, nullptr, nullptr, nullptr },// This is the end marker }; diff --git a/src/saveload/extended_ver_sl.h b/src/saveload/extended_ver_sl.h index 54921e8dd4..b22e064202 100644 --- a/src/saveload/extended_ver_sl.h +++ b/src/saveload/extended_ver_sl.h @@ -107,6 +107,7 @@ enum SlXvFeatureIndex { XSLFI_CUSTOM_TOWN_ZONE, ///< Custom town zones XSLFI_STATION_CARGO_HISTORY, ///< Station waiting cargo history XSLFI_TRAIN_SPEED_ADAPTATION, ///< Train speed adaptation + XSLFI_EXTRA_STATION_NAMES, ///< Extra station names XSLFI_RIFF_HEADER_60_BIT, ///< Size field in RIFF chunk header is 60 bit XSLFI_HEIGHT_8_BIT, ///< Map tile height is 8 bit instead of 4 bit, but savegame version may be before this became true in trunk diff --git a/src/saveload/station_sl.cpp b/src/saveload/station_sl.cpp index 0572d55ba0..223fd5e880 100644 --- a/src/saveload/station_sl.cpp +++ b/src/saveload/station_sl.cpp @@ -449,6 +449,7 @@ static const SaveLoad _station_desc[] = { SLE_CONDREF(Station, airport.psa, REF_STORAGE, SLV_161, SL_MAX_VERSION), SLE_VAR(Station, indtype, SLE_UINT8), + SLE_CONDVAR_X(Station, extra_name_index, SLE_UINT16, SL_MIN_VERSION, SL_MAX_VERSION, SlXvFeatureTest(XSLFTO_AND, XSLFI_EXTRA_STATION_NAMES)), SLE_VAR(Station, time_since_load, SLE_UINT8), SLE_VAR(Station, time_since_unload, SLE_UINT8), diff --git a/src/station.cpp b/src/station.cpp index effc2c898d..419098254c 100644 --- a/src/station.cpp +++ b/src/station.cpp @@ -38,6 +38,9 @@ StationPool _station_pool("Station"); INSTANTIATE_POOL_METHODS(Station) +std::array