diff --git a/cmake/CompileFlags.cmake b/cmake/CompileFlags.cmake index 691feaed0d..440c4751e0 100644 --- a/cmake/CompileFlags.cmake +++ b/cmake/CompileFlags.cmake @@ -49,8 +49,8 @@ macro(compile_flags) "$<$>:-fstack-protector>" # Prevent undefined references when _FORTIFY_SOURCE > 0 ) if(CMAKE_SIZEOF_VOID_P EQUAL 8) - add_link_options( - "$<$:-Wl,--disable-dynamicbase,--disable-high-entropy-va,--default-image-base-low>" # ASLR somehow breaks linking for x64 Debug builds + add_compile_options( + "$<$:-Wa,-mbig-obj>" # Switch to pe-bigobj-x86-64 as x64 Debug builds push pe-x86-64 to the limits (linking errors with ASLR, ...) ) endif() endif() diff --git a/src/base_station_base.h b/src/base_station_base.h index c12ac2b525..f6653b4973 100644 --- a/src/base_station_base.h +++ b/src/base_station_base.h @@ -71,10 +71,8 @@ struct BaseStation : StationPool::PoolItem<&_station_pool> { Owner owner; ///< The owner of this station StationFacility facilities; ///< The facilities that this station has - uint8 num_specs; ///< Number of specs in the speclist - uint8 num_roadstop_specs; ///< Number of road stop specs in the roadstop_speclist - StationSpecList *speclist; ///< List of station specs of this station - RoadStopSpecList *roadstop_speclist; ///< List of road stop specs of this station + std::vector speclist; ///< List of rail station specs of this station. + std::vector roadstop_speclist; ///< List of road stop specs of this station Date build_date; ///< Date of construction diff --git a/src/lang/german.txt b/src/lang/german.txt index 6dd0f53882..ba54fbe37c 100644 --- a/src/lang/german.txt +++ b/src/lang/german.txt @@ -2971,15 +2971,15 @@ STR_NETWORK_SERVER_MESSAGE_GAME_REASON_LINK_GRAPH :Warten auf Neub STR_NETWORK_MESSAGE_CLIENT_LEAVING :geht STR_NETWORK_MESSAGE_CLIENT_JOINED :*** {STRING} ist dem Spiel beigetreten -STR_NETWORK_MESSAGE_CLIENT_JOINED_ID :*** {STRING} ist dem Spiel beigetreten (Teilnehmer #{2:NUM}) -STR_NETWORK_MESSAGE_CLIENT_COMPANY_JOIN :*** {STRING} ist der Firma #{2:NUM} beigetreten +STR_NETWORK_MESSAGE_CLIENT_JOINED_ID :*** {0:STRING} ist dem Spiel beigetreten (Teilnehmer #{2:NUM}) +STR_NETWORK_MESSAGE_CLIENT_COMPANY_JOIN :*** {0:STRING} ist der Firma #{2:NUM} beigetreten STR_NETWORK_MESSAGE_CLIENT_COMPANY_SPECTATE :*** {STRING} ist den Zuschauern beigetreten -STR_NETWORK_MESSAGE_CLIENT_COMPANY_NEW :*** {STRING} hat eine neue Firma gegründet (#{2:NUM}) -STR_NETWORK_MESSAGE_CLIENT_LEFT :*** {STRING} hat das Spiel verlassen ({2:STRING}) +STR_NETWORK_MESSAGE_CLIENT_COMPANY_NEW :*** {0:STRING} hat eine neue Firma gegründet (#{2:NUM}) +STR_NETWORK_MESSAGE_CLIENT_LEFT :*** {0:STRING} hat das Spiel verlassen ({2:STRING}) STR_NETWORK_MESSAGE_NAME_CHANGE :*** {STRING} hat den eigenen Namen zu {STRING} geändert STR_NETWORK_MESSAGE_GIVE_MONEY_RECEIVE :*** {STRING} gab der eigenen Firma {2:CURRENCY_LONG} STR_NETWORK_MESSAGE_GAVE_MONEY_AWAY :*** Die eigene Firma übergab {1:STRING} {2:CURRENCY_LONG} -STR_NETWORK_MESSAGE_GIVE_MONEY :*** {STRING} gab {2:CURRENCY_LONG} an {1:STRING} +STR_NETWORK_MESSAGE_GIVE_MONEY :*** {0:STRING} gab {2:CURRENCY_LONG} an {1:STRING} STR_NETWORK_MESSAGE_MONEY_GIVE_SRC_DESCRIPTION :{STRING} ({COMPANY}) STR_NETWORK_MESSAGE_SERVER_SHUTDOWN :{WHITE}Der Server hat das Spiel beendet STR_NETWORK_MESSAGE_SERVER_REBOOT :{WHITE}Der Server startet neu...{}Bitte warten... @@ -4295,15 +4295,15 @@ STR_NEWGRF_ERROR_MSG_FATAL :{RED}Schwerer F STR_NEWGRF_ERROR_FATAL_POPUP :{WHITE}Ein schwerer NewGRF-Fehler ist aufgetreten:{}{STRING} STR_NEWGRF_ERROR_POPUP :{WHITE}Ein NewGRF-Fehler ist aufgetreten:{}{STRING} STR_NEWGRF_ERROR_VERSION_NUMBER :{1:STRING} funktioniert nicht im Zusammenhang mit der von OpenTTD ermittelten TTDPatch-Version -STR_NEWGRF_ERROR_DOS_OR_WINDOWS :{1:STRING} ist für die {STRING}-Version von TTD -STR_NEWGRF_ERROR_UNSET_SWITCH :{1:STRING} ist für die Nutzung mit {STRING} vorgesehen -STR_NEWGRF_ERROR_INVALID_PARAMETER :Falscher Parameter für {1:STRING}: Parameter {STRING} ({NUM}) -STR_NEWGRF_ERROR_LOAD_BEFORE :{1:STRING} muss vor {STRING} geladen werden -STR_NEWGRF_ERROR_LOAD_AFTER :{1:STRING} muss nach {STRING} geladen werden -STR_NEWGRF_ERROR_OTTD_VERSION_NUMBER :{1:STRING} Benötigt OpenTTD-Version {STRING} oder höher +STR_NEWGRF_ERROR_DOS_OR_WINDOWS :{1:STRING} ist für die {2:STRING}-Version von TTD +STR_NEWGRF_ERROR_UNSET_SWITCH :{1:STRING} ist für die Nutzung mit {2:STRING} vorgesehen +STR_NEWGRF_ERROR_INVALID_PARAMETER :Ungültiger Parameter für {1:STRING}: Parameter {2:STRING} ({3:NUM}) +STR_NEWGRF_ERROR_LOAD_BEFORE :{1:STRING} muss vor {2:STRING} geladen werden +STR_NEWGRF_ERROR_LOAD_AFTER :{1:STRING} muss nach {2:STRING} geladen werden +STR_NEWGRF_ERROR_OTTD_VERSION_NUMBER :{1:STRING} benötigt OpenTTD-Version {2:STRING} oder höher STR_NEWGRF_ERROR_AFTER_TRANSLATED_FILE :der NewGRF-Datei, die es übersetzen soll, STR_NEWGRF_ERROR_TOO_MANY_NEWGRFS_LOADED :Zu viele NewGRFs geladen -STR_NEWGRF_ERROR_STATIC_GRF_CAUSES_DESYNC :Das Laden von {1:STRING} als statisches NewGRF mit {STRING} könnte Synchronisationsfehler hervorrufen +STR_NEWGRF_ERROR_STATIC_GRF_CAUSES_DESYNC :Das Laden von {1:STRING} als statisches NewGRF mit {2:STRING} könnte Synchronisationsfehler hervorrufen STR_NEWGRF_ERROR_UNEXPECTED_SPRITE :Unerwartetes Sprite (Sprite {3:NUM}) STR_NEWGRF_ERROR_UNKNOWN_PROPERTY :Unbekannte Action-0-Eigenschaft {4:HEX} (Sprite {3:NUM}) STR_NEWGRF_ERROR_INVALID_ID :Zugriff auf eine ungültige ID (Sprite {3:NUM}) @@ -4843,7 +4843,7 @@ STR_INDUSTRY_VIEW_TRANSPORTED_TOOLTIP :{BLACK}{STRING} STR_INDUSTRY_VIEW_TRANSPORTED_TOOLTIP_EXTENSION :{}{BLACK}{CARGO_LONG} ({COMMA}%) STR_INDUSTRY_VIEW_REQUIRES :{BLACK}Benötigt: -STR_INDUSTRY_VIEW_ACCEPT_CARGO :{YELLOW}{STRING}{BLACK}{3:STRING} +STR_INDUSTRY_VIEW_ACCEPT_CARGO :{YELLOW}{0:STRING}{BLACK}{3:STRING} STR_INDUSTRY_VIEW_ACCEPT_CARGO_AMOUNT :{YELLOW}{STRING}{BLACK}: {CARGO_SHORT} wartend{STRING} # Town tooltip @@ -5193,7 +5193,7 @@ STR_ENGINE_PREVIEW_AIRCRAFT :{G=n}Flugzeug STR_ENGINE_PREVIEW_SHIP :{G=n}Schiff STR_ENGINE_PREVIEW_COST_WEIGHT_SPEED_POWER :{BLACK}Kosten: {CURRENCY_LONG} Gewicht: {WEIGHT_SHORT}{}Geschwindigk.: {VELOCITY} Leistung: {POWER}{}Betriebskosten: {CURRENCY_LONG} pro Jahr{}Kapazität: {CARGO_LONG} -STR_ENGINE_PREVIEW_COST_WEIGHT_SPEED_POWER_MAX_TE :{BLACK}Preis: {CURRENCY_LONG} Gewicht: {WEIGHT_SHORT}{}Max. Geschwindigkeit: {VELOCITY} Leistung: {POWER} Max. Zugkraft: {6:FORCE}{}Betriebskosten: {4:CURRENCY_LONG}/Jahr{}Kapazität: {5:CARGO_LONG} +STR_ENGINE_PREVIEW_COST_WEIGHT_SPEED_POWER_MAX_TE :{BLACK}Preis: {0:CURRENCY_LONG} Gewicht: {1:WEIGHT_SHORT}{}Max. Geschwindigkeit: {2:VELOCITY} Leistung: {3:POWER} Max. Zugkraft: {6:FORCE}{}Betriebskosten: {4:CURRENCY_LONG}/Jahr{}Kapazität: {5:CARGO_LONG} STR_ENGINE_PREVIEW_COST_MAX_SPEED_CAP_RUNCOST :{BLACK}Preis: {CURRENCY_LONG} Höchstgeschw.: {VELOCITY}{}Kapazität: {CARGO_LONG}{}Betriebskosten: {CURRENCY_LONG}/Jahr STR_ENGINE_PREVIEW_COST_MAX_SPEED_TYPE_CAP_CAP_RUNCOST :{BLACK}Kosten: {CURRENCY_LONG} Max. Geschw.: {VELOCITY}{}Flugzeugtyp: {STRING}{}Kapazität: {CARGO_LONG}, {CARGO_LONG}{}Betriebskosten: {CURRENCY_LONG}/Jahr STR_ENGINE_PREVIEW_COST_MAX_SPEED_TYPE_CAP_RUNCOST :{BLACK}Kosten: {CURRENCY_LONG} Max. Geschw.: {VELOCITY}{}Flugzeugtyp: {STRING}{}Kapazität: {CARGO_LONG}{}Betriebskosten: {CURRENCY_LONG}/Jahr @@ -5400,8 +5400,8 @@ STR_VEHICLE_AUTO_GROUP_CARGO_LIST : ({CARGO_LIST}) STR_VEHICLE_INFO_BUILT_VALUE :{LTBLUE}{ENGINE} {BLACK}Gebaut: {LTBLUE}{NUM}{BLACK} Wert: {LTBLUE}{CURRENCY_LONG} STR_VEHICLE_INFO_NO_CAPACITY :{BLACK}Kapazität: {LTBLUE}Keine{STRING} -STR_VEHICLE_INFO_CAPACITY :{BLACK}Kapazität: {LTBLUE}{CARGO_LONG}{3:STRING} -STR_VEHICLE_INFO_CAPACITY_MULT :{BLACK}Kapazität: {LTBLUE}{CARGO_LONG}{3:STRING} (x{4:NUM}) +STR_VEHICLE_INFO_CAPACITY :{BLACK}Kapazität: {LTBLUE}{0:CARGO_LONG}{3:STRING} +STR_VEHICLE_INFO_CAPACITY_MULT :{BLACK}Kapazität: {LTBLUE}{0:CARGO_LONG}{3:STRING} (x{4:NUM}) STR_VEHICLE_INFO_CAPACITY_CAPACITY :{BLACK}Kapazität: {LTBLUE}{CARGO_LONG}, {CARGO_LONG}{STRING} STR_VEHICLE_INFO_FEEDER_CARGO_VALUE :{BLACK}Transfer-Einnahmen: {LTBLUE}{CURRENCY_LONG} diff --git a/src/lang/tamil.txt b/src/lang/tamil.txt index a84aef12c3..ed9a36c021 100644 --- a/src/lang/tamil.txt +++ b/src/lang/tamil.txt @@ -1836,6 +1836,7 @@ STR_CONFIG_ERROR_OUT_OF_MEMORY :{WHITE}நி # Video initalization errors STR_VIDEO_DRIVER_ERROR :{WHITE}வீடியோ அமைப்புகளில் பிழை... +STR_VIDEO_DRIVER_ERROR_NO_HARDWARE_ACCELERATION :{WHITE}... இணைவொத்த GPU கிடைக்கவில்லை. வன்பொருள் முடுக்கம் செயலிழக்கப்பட்டுள்ளது # Intro window STR_INTRO_CAPTION :{WHITE}OpenTTD {REV} @@ -2095,6 +2096,7 @@ STR_NETWORK_CLIENT_LIST_SERVER_CONNECTION_TYPE :{BLACK}தொ STR_NETWORK_CLIENT_LIST_SERVER_CONNECTION_TYPE_TOOLTIP :{BLACK}உங்கள் சேவையகத்தை மற்றவர்கள் எப்படி அணுகலாம் STR_NETWORK_CLIENT_LIST_PLAYER_NAME_TOOLTIP :{BLACK}உங்கள் வீரரின் பெயர் STR_NETWORK_CLIENT_LIST_ADMIN_COMPANY_TOOLTIP :{BLACK}இந்த நிறுவனத்திற்கான நிர்வாக நடவடிக்கைகள் +STR_NETWORK_CLIENT_LIST_JOIN_TOOLTIP :இந்த நிறுவனத்தில் சேரு STR_NETWORK_CLIENT_LIST_CHAT_CLIENT_TOOLTIP :{BLACK}இந்த விளையாட்டாளருக்கு ஒரு செய்தியை அனுப்பவும் STR_NETWORK_CLIENT_LIST_CHAT_SPECTATOR_TOOLTIP :{BLACK}அனைத்து பார்வையாளர்களுக்கும் ஒரு செய்தியை அனுப்பவும் STR_NETWORK_CLIENT_LIST_NEW_COMPANY :(புதிய நிறுவனம்) @@ -3443,6 +3445,7 @@ STR_BUY_VEHICLE_SHIP_CAPTION :புது STR_BUY_VEHICLE_AIRCRAFT_CAPTION :புது விமானம் STR_PURCHASE_INFO_COST_WEIGHT :{BLACK}செலவு: {GOLD}{CURRENCY_LONG}{BLACK} எடை: {GOLD}{WEIGHT_SHORT} +STR_PURCHASE_INFO_COST_REFIT_WEIGHT :{BLACK} செலவு: {GOLD}{CURRENCY_LONG}{BLACK} (சரக்கு திருத்தல் விலை: {GOLD}{CURRENCY_LONG}{BLACK}) கனம்: {GOLD}{WEIGHT_SHORT} STR_PURCHASE_INFO_SPEED_POWER :{BLACK}வேகம்: {GOLD}{VELOCITY}{BLACK} திறன்: {GOLD}{POWER} STR_PURCHASE_INFO_SPEED :{BLACK}வேகம்: {GOLD}{VELOCITY} STR_PURCHASE_INFO_SPEED_OCEAN :{BLACK}கடலில் வேகம்: {GOLD}{VELOCITY} diff --git a/src/newgrf_roadstop.cpp b/src/newgrf_roadstop.cpp index 7299fe7cf4..696179d5ec 100644 --- a/src/newgrf_roadstop.cpp +++ b/src/newgrf_roadstop.cpp @@ -531,7 +531,7 @@ const RoadStopSpec *GetRoadStopSpec(TileIndex t) const BaseStation *st = BaseStation::GetByTile(t); uint specindex = GetCustomRoadStopSpecIndex(t); - return specindex < st->num_roadstop_specs ? st->roadstop_speclist[specindex].spec : nullptr; + return specindex < st->roadstop_speclist.size() ? st->roadstop_speclist[specindex].spec : nullptr; } int AllocateRoadStopSpecToStation(const RoadStopSpec *statspec, BaseStation *st, bool exec) @@ -541,12 +541,12 @@ int AllocateRoadStopSpecToStation(const RoadStopSpec *statspec, BaseStation *st, if (statspec == nullptr || st == nullptr) return 0; /* Try to find the same spec and return that one */ - for (i = 1; i < st->num_roadstop_specs && i < NUM_ROADSTOPSPECS_PER_STATION; i++) { + for (i = 1; i < st->roadstop_speclist.size() && i < NUM_ROADSTOPSPECS_PER_STATION; i++) { if (st->roadstop_speclist[i].spec == statspec) return i; } /* Try to find an unused spec slot */ - for (i = 1; i < st->num_roadstop_specs && i < NUM_ROADSTOPSPECS_PER_STATION; i++) { + for (i = 1; i < st->roadstop_speclist.size() && i < NUM_ROADSTOPSPECS_PER_STATION; i++) { if (st->roadstop_speclist[i].spec == nullptr && st->roadstop_speclist[i].grfid == 0) break; } @@ -556,18 +556,7 @@ int AllocateRoadStopSpecToStation(const RoadStopSpec *statspec, BaseStation *st, } if (exec) { - if (i >= st->num_roadstop_specs) { - st->num_roadstop_specs = i + 1; - st->roadstop_speclist = ReallocT(st->roadstop_speclist, st->num_roadstop_specs); - - if (st->num_roadstop_specs == 2) { - /* Initial allocation */ - st->roadstop_speclist[0].spec = nullptr; - st->roadstop_speclist[0].grfid = 0; - st->roadstop_speclist[0].localidx = 0; - } - } - + if (i >= st->roadstop_speclist.size()) st->roadstop_speclist.resize(i + 1); st->roadstop_speclist[i].spec = statspec; st->roadstop_speclist[i].grfid = statspec->grf_prop.grffile->grfid; st->roadstop_speclist[i].localidx = statspec->grf_prop.local_id; @@ -596,15 +585,16 @@ void DeallocateRoadStopSpecFromStation(BaseStation *st, byte specindex) st->roadstop_speclist[specindex].localidx = 0; /* If this was the highest spec index, reallocate */ - if (specindex == st->num_roadstop_specs - 1) { - for (; st->roadstop_speclist[st->num_roadstop_specs - 1].grfid == 0 && st->num_roadstop_specs > 1; st->num_roadstop_specs--) {} + if (specindex == st->roadstop_speclist.size() - 1) { + size_t num_specs; + for (num_specs = st->roadstop_speclist.size() - 1; num_specs > 0; num_specs--) { + if (st->roadstop_speclist[num_specs].grfid != 0) break; + } - if (st->num_roadstop_specs > 1) { - st->roadstop_speclist = ReallocT(st->roadstop_speclist, st->num_roadstop_specs); + if (num_specs > 0) { + st->roadstop_speclist.resize(num_specs + 1); } else { - free(st->roadstop_speclist); - st->num_roadstop_specs = 0; - st->roadstop_speclist = nullptr; + st->roadstop_speclist.clear(); st->cached_roadstop_anim_triggers = 0; st->cached_roadstop_cargo_triggers = 0; return; @@ -625,7 +615,7 @@ void StationUpdateRoadStopCachedTriggers(BaseStation *st) /* Combine animation trigger bitmask for all road stop specs * of this station. */ - for (uint i = 0; i < st->num_roadstop_specs; i++) { + for (uint i = 0; i < st->roadstop_speclist.size(); i++) { const RoadStopSpec *ss = st->roadstop_speclist[i].spec; if (ss != nullptr) { st->cached_roadstop_anim_triggers |= ss->animation.triggers; diff --git a/src/newgrf_station.cpp b/src/newgrf_station.cpp index 6ff654cf8b..a82deee68f 100644 --- a/src/newgrf_station.cpp +++ b/src/newgrf_station.cpp @@ -689,7 +689,7 @@ int AllocateSpecToStation(const StationSpec *statspec, BaseStation *st, bool exe if (statspec == nullptr || st == nullptr) return 0; - for (i = 1; i < st->num_specs && i < NUM_STATIONSSPECS_PER_STATION; i++) { + for (i = 1; i < st->speclist.size() && i < NUM_STATIONSSPECS_PER_STATION; i++) { if (st->speclist[i].spec == nullptr && st->speclist[i].grfid == 0) break; } @@ -699,7 +699,7 @@ int AllocateSpecToStation(const StationSpec *statspec, BaseStation *st, bool exe * result in slightly "wrong" (as per specs) looking stations, * but it's fairly unlikely that one reaches the limit anyways. */ - for (i = 1; i < st->num_specs && i < NUM_STATIONSSPECS_PER_STATION; i++) { + for (i = 1; i < st->speclist.size() && i < NUM_STATIONSSPECS_PER_STATION; i++) { if (st->speclist[i].spec == statspec) return i; } @@ -707,18 +707,7 @@ int AllocateSpecToStation(const StationSpec *statspec, BaseStation *st, bool exe } if (exec) { - if (i >= st->num_specs) { - st->num_specs = i + 1; - st->speclist = ReallocT(st->speclist, st->num_specs); - - if (st->num_specs == 2) { - /* Initial allocation */ - st->speclist[0].spec = nullptr; - st->speclist[0].grfid = 0; - st->speclist[0].localidx = 0; - } - } - + if (i >= st->speclist.size()) st->speclist.resize(i + 1); st->speclist[i].spec = statspec; st->speclist[i].grfid = statspec->grf_prop.grffile->grfid; st->speclist[i].localidx = statspec->grf_prop.local_id; @@ -755,15 +744,16 @@ void DeallocateSpecFromStation(BaseStation *st, byte specindex) st->speclist[specindex].localidx = 0; /* If this was the highest spec index, reallocate */ - if (specindex == st->num_specs - 1) { - for (; st->speclist[st->num_specs - 1].grfid == 0 && st->num_specs > 1; st->num_specs--) {} + if (specindex == st->speclist.size() - 1) { + size_t num_specs; + for (num_specs = st->speclist.size() - 1; num_specs > 0; num_specs--) { + if (st->speclist[num_specs].grfid != 0) break; + } - if (st->num_specs > 1) { - st->speclist = ReallocT(st->speclist, st->num_specs); + if (num_specs > 0) { + st->speclist.resize(num_specs + 1); } else { - free(st->speclist); - st->num_specs = 0; - st->speclist = nullptr; + st->speclist.clear(); st->cached_anim_triggers = 0; st->cached_cargo_triggers = 0; return; @@ -860,7 +850,7 @@ const StationSpec *GetStationSpec(TileIndex t) const BaseStation *st = BaseStation::GetByTile(t); uint specindex = GetCustomStationSpecIndex(t); - return specindex < st->num_specs ? st->speclist[specindex].spec : nullptr; + return specindex < st->speclist.size() ? st->speclist[specindex].spec : nullptr; } @@ -1064,7 +1054,7 @@ void StationUpdateCachedTriggers(BaseStation *st) /* Combine animation trigger bitmask for all station specs * of this station. */ - for (uint i = 0; i < st->num_specs; i++) { + for (uint i = 0; i < st->speclist.size(); i++) { const StationSpec *ss = st->speclist[i].spec; if (ss != nullptr) { st->cached_anim_triggers |= ss->animation.triggers; diff --git a/src/saveload/station_sl.cpp b/src/saveload/station_sl.cpp index dbbdf70ba8..30b9e34163 100644 --- a/src/saveload/station_sl.cpp +++ b/src/saveload/station_sl.cpp @@ -23,6 +23,8 @@ #include "../safeguards.h" static byte _old_last_vehicle_type; +static uint8 _num_specs; +static uint8 _num_roadstop_specs; /** * Update the buoy orders to be waypoint orders. @@ -111,12 +113,12 @@ void AfterLoadStations() { /* Update the speclists of all stations to point to the currently loaded custom stations. */ for (BaseStation *st : BaseStation::Iterate()) { - for (uint i = 0; i < st->num_specs; i++) { + for (uint i = 0; i < st->speclist.size(); i++) { if (st->speclist[i].grfid == 0) continue; st->speclist[i].spec = StationClass::GetByGrf(st->speclist[i].grfid, st->speclist[i].localidx, nullptr); } - for (uint i = 0; i < st->num_roadstop_specs; i++) { + for (uint i = 0; i < st->roadstop_speclist.size(); i++) { if (st->roadstop_speclist[i].grfid == 0) continue; st->roadstop_speclist[i].spec = RoadStopClass::GetByGrf(st->roadstop_speclist[i].grfid, st->roadstop_speclist[i].localidx, nullptr); @@ -218,7 +220,7 @@ static const SaveLoad _old_station_desc[] = { /* Used by newstations for graphic variations */ SLE_CONDVAR(Station, random_bits, SLE_UINT16, SLV_27, SL_MAX_VERSION), SLE_CONDVAR(Station, waiting_triggers, SLE_UINT8, SLV_27, SL_MAX_VERSION), - SLE_CONDVAR(Station, num_specs, SLE_UINT8, SLV_27, SL_MAX_VERSION), + SLEG_CONDVAR(_num_specs, SLE_UINT8, SLV_27, SL_MAX_VERSION), SLE_CONDVEC(Station, loading_vehicles, REF_VEHICLE, SLV_57, SL_MAX_VERSION), @@ -329,6 +331,7 @@ static void Load_STNS() _cargo_source_xy = 0; _cargo_days = 0; _cargo_feeder_share = 0; + _num_specs = 0; uint num_cargo = IsSavegameVersionBefore(SLV_55) ? 12 : IsSavegameVersionBefore(SLV_EXTEND_CARGOTYPES) ? 32 : NUM_CARGO; int index; @@ -364,10 +367,10 @@ static void Load_STNS() if (SlXvIsFeatureMissing(XSLFI_ST_LAST_VEH_TYPE)) ge->last_vehicle_type = _old_last_vehicle_type; } - if (st->num_specs != 0) { + if (_num_specs != 0) { /* Allocate speclist memory when loading a game */ - st->speclist = CallocT(st->num_specs); - for (uint i = 0; i < st->num_specs; i++) { + st->speclist.resize(_num_specs); + for (uint i = 0; i < st->speclist.size(); i++) { SlObject(&st->speclist[i], _station_speclist_desc); } } @@ -409,8 +412,8 @@ static const SaveLoad _base_station_desc[] = { /* Used by newstations for graphic variations */ SLE_VAR(BaseStation, random_bits, SLE_UINT16), SLE_VAR(BaseStation, waiting_triggers, SLE_UINT8), - SLE_VAR(BaseStation, num_specs, SLE_UINT8), - SLE_CONDVAR_X(BaseStation, num_roadstop_specs, SLE_UINT8, SL_MIN_VERSION, SL_MAX_VERSION, SlXvFeatureTest(XSLFTO_AND, XSLFI_GRF_ROADSTOPS)), + SLEG_VAR(_num_specs, SLE_UINT8), + SLEG_CONDVAR_X(_num_roadstop_specs, SLE_UINT8, SL_MIN_VERSION, SL_MAX_VERSION, SlXvFeatureTest(XSLFTO_AND, XSLFI_GRF_ROADSTOPS)), SLE_CONDVARVEC_X(BaseStation, custom_road_stop_tiles, SLE_UINT32, SL_MIN_VERSION, SL_MAX_VERSION, SlXvFeatureTest(XSLFTO_AND, XSLFI_GRF_ROADSTOPS)), SLE_CONDVARVEC_X(BaseStation, custom_road_stop_data, SLE_UINT16, SL_MIN_VERSION, SL_MAX_VERSION, SlXvFeatureTest(XSLFTO_AND, XSLFI_GRF_ROADSTOPS)), }; @@ -510,6 +513,9 @@ static void SetupDescs_ROADSTOP() static void RealSave_STNN(BaseStation *bst) { + _num_specs = (uint8)bst->speclist.size(); + _num_roadstop_specs = (uint8)bst->roadstop_speclist.size(); + bool waypoint = (bst->facilities & FACIL_WAYPOINT) != 0; SlObjectSaveFiltered(bst, waypoint ? SaveLoadTable(_filtered_waypoint_desc) : SaveLoadTable(_filtered_station_desc)); @@ -562,11 +568,11 @@ static void RealSave_STNN(BaseStation *bst) } } - for (uint i = 0; i < bst->num_specs; i++) { + for (uint i = 0; i < bst->speclist.size(); i++) { SlObjectSaveFiltered(&bst->speclist[i], _filtered_station_speclist_desc); } - for (uint i = 0; i < bst->num_roadstop_specs; i++) { + for (uint i = 0; i < bst->roadstop_speclist.size(); i++) { SlObjectSaveFiltered(&bst->roadstop_speclist[i], _filtered_station_speclist_desc); } } @@ -587,6 +593,8 @@ static void Load_STNN() SetupDescs_STNN(); _num_flows = 0; + _num_specs = 0; + _num_roadstop_specs = 0; const uint num_cargo = IsSavegameVersionBefore(SLV_EXTEND_CARGOTYPES) ? 32 : NUM_CARGO; ReadBuffer *buffer = ReadBuffer::GetCurrent(); @@ -691,18 +699,18 @@ static void Load_STNN() st->station_cargo_history_offset = 0; } - if (bst->num_specs != 0) { + if (_num_specs != 0) { /* Allocate speclist memory when loading a game */ - bst->speclist = CallocT(bst->num_specs); - for (uint i = 0; i < bst->num_specs; i++) { + bst->speclist.resize(_num_specs); + for (uint i = 0; i < bst->speclist.size(); i++) { SlObjectLoadFiltered(&bst->speclist[i], _filtered_station_speclist_desc); } } - if (bst->num_roadstop_specs != 0) { + if (_num_roadstop_specs != 0) { /* Allocate speclist memory when loading a game */ - bst->roadstop_speclist = CallocT(bst->num_roadstop_specs); - for (uint i = 0; i < bst->num_roadstop_specs; i++) { + bst->roadstop_speclist.resize(_num_roadstop_specs); + for (uint i = 0; i < bst->roadstop_speclist.size(); i++) { SlObjectLoadFiltered(&bst->roadstop_speclist[i], _filtered_station_speclist_desc); } } diff --git a/src/saveload/upstream/station_sl.cpp b/src/saveload/upstream/station_sl.cpp index e8154ed9cf..e5ce580ed0 100644 --- a/src/saveload/upstream/station_sl.cpp +++ b/src/saveload/upstream/station_sl.cpp @@ -85,24 +85,19 @@ public: void Save(BaseStation *bst) const override { - SlSetStructListLength(bst->num_specs); - for (uint i = 0; i < bst->num_specs; i++) { + SlSetStructListLength(bst->speclist.size()); + for (uint i = 0; i < bst->speclist.size(); i++) { SlObject(&bst->speclist[i], this->GetDescription()); } } void Load(BaseStation *bst) const override { - if (!IsSavegameVersionBefore(SLV_SAVELOAD_LIST_LENGTH)) { - bst->num_specs = (uint8)SlGetStructListLength(UINT8_MAX); - } + uint8 num_specs = (uint8)SlGetStructListLength(UINT8_MAX); - if (bst->num_specs != 0) { - /* Allocate speclist memory when loading a game */ - bst->speclist = CallocT(bst->num_specs); - for (uint i = 0; i < bst->num_specs; i++) { - SlObject(&bst->speclist[i], this->GetLoadDescription()); - } + bst->speclist.resize(num_specs); + for (uint i = 0; i < num_specs; i++) { + SlObject(&bst->speclist[i], this->GetLoadDescription()); } } }; @@ -319,7 +314,6 @@ public: /* Used by newstations for graphic variations */ SLE_VAR(BaseStation, random_bits, SLE_UINT16), SLE_VAR(BaseStation, waiting_triggers, SLE_UINT8), - SLE_CONDVAR(BaseStation, num_specs, SLE_UINT8, SL_MIN_VERSION, SLV_SAVELOAD_LIST_LENGTH), }; inline const static SaveLoadCompatTable compat_description = _station_base_sl_compat; diff --git a/src/station.cpp b/src/station.cpp index 3fd94a47ef..6f73e6db49 100644 --- a/src/station.cpp +++ b/src/station.cpp @@ -57,9 +57,6 @@ void RebuildStationKdtree() BaseStation::~BaseStation() { - free(this->speclist); - free(this->roadstop_speclist); - if (CleaningPool()) return; DeleteWindowById(WC_TRAINS_LIST, VehicleListIdentifier(VL_STATION_LIST, VEH_TRAIN, this->owner, this->index).Pack()); @@ -266,7 +263,7 @@ void Station::MarkTilesDirty(bool cargo_change) const /* Don't waste time updating if there are no custom station graphics * that might change. Even if there are custom graphics, they might * not change. Unfortunately we have no way of telling. */ - if (this->num_specs == 0) return; + if (this->speclist.size() == 0) return; } for (h = 0; h < train_station.h; h++) { diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp index 7615b71df3..641c429f5f 100644 --- a/src/station_cmd.cpp +++ b/src/station_cmd.cpp @@ -2235,7 +2235,6 @@ CommandCost CmdBuildRoadStop(TileIndex tile, DoCommandFlag flags, uint32 p1, uin } else { if (road_rt == INVALID_ROADTYPE && RoadTypeIsRoad(rt)) road_rt = rt; if (tram_rt == INVALID_ROADTYPE && RoadTypeIsTram(rt)) tram_rt = rt; - /* Non-drive-through stop never overbuild and always count as two road bits. */ MakeRoadStop(cur_tile, st->owner, st->index, rs_type, road_rt, tram_rt, ddir); } UpdateCompanyRoadInfrastructure(road_rt, road_owner, ROAD_STOP_TRACKBIT_FACTOR);