diff --git a/src/engine.cpp b/src/engine.cpp index 8e6c41ba00..ec09133113 100644 --- a/src/engine.cpp +++ b/src/engine.cpp @@ -808,6 +808,8 @@ bool IsEngineBuildable(EngineID engine, VehicleType type, CompanyID company) /* check if it's available */ if (!HasBit(e->company_avail, company)) return false; + if (e->info.string_id == STR_NEWGRF_INVALID_ENGINE) return false; + if (type == VEH_TRAIN) { /* Check if the rail type is available to this company */ const Company *c = Company::Get(company); diff --git a/src/group_gui.cpp b/src/group_gui.cpp index 3ce991bee9..94e5ac9426 100644 --- a/src/group_gui.cpp +++ b/src/group_gui.cpp @@ -381,12 +381,12 @@ public: { switch (widget) { case GRP_WIDGET_ALL_VEHICLES: - DrawString(r.left + WD_FRAMERECT_LEFT + 8, r.right - WD_FRAMERECT_RIGHT - 8, r.top + WD_MATRIX_TOP, + DrawString(r.left + WD_FRAMERECT_LEFT + 8, r.right - WD_FRAMERECT_RIGHT - 8, r.top + WD_FRAMERECT_TOP + 1, STR_GROUP_ALL_TRAINS + this->vehicle_type, IsAllGroupID(this->group_sel) ? TC_WHITE : TC_BLACK); break; case GRP_WIDGET_DEFAULT_VEHICLES: - DrawString(r.left + WD_FRAMERECT_LEFT + 8, r.right - WD_FRAMERECT_RIGHT - 8, r.top + WD_MATRIX_TOP, + DrawString(r.left + WD_FRAMERECT_LEFT + 8, r.right - WD_FRAMERECT_RIGHT - 8, r.top + WD_FRAMERECT_TOP + 1, STR_GROUP_DEFAULT_TRAINS + this->vehicle_type, IsDefaultGroupID(this->group_sel) ? TC_WHITE : TC_BLACK); break; diff --git a/src/lang/english.txt b/src/lang/english.txt index 44587b8595..7cd03f652d 100644 --- a/src/lang/english.txt +++ b/src/lang/english.txt @@ -2397,6 +2397,13 @@ STR_NEWGRF_BUGGY :{WHITE}NewGRF ' STR_NEWGRF_BUGGY_ARTICULATED_CARGO :{WHITE}Cargo/refit information for '{1:ENGINE}' differs from purchase list after construction. This might cause autorenew/-replace to fail refitting correctly. STR_NEWGRF_BUGGY_ENDLESS_PRODUCTION_CALLBACK :{WHITE}'{1:STRING}' caused an endless loop in the production callback. +# 'User removed essential NewGRFs'-placeholders for stuff without specs. +STR_NEWGRF_INVALID_CARGO : +STR_NEWGRF_INVALID_CARGO_ABBREV :?? +STR_NEWGRF_INVALID_CARGO_QUANTITY :{COMMA} of +STR_NEWGRF_INVALID_ENGINE : +STR_NEWGRF_INVALID_INDUSTRYTYPE : + # Sign list window STR_SIGN_LIST_CAPTION :{WHITE}Sign List - {COMMA} Sign{P "" s} diff --git a/src/newgrf.cpp b/src/newgrf.cpp index fa2686680c..21804428af 100644 --- a/src/newgrf.cpp +++ b/src/newgrf.cpp @@ -6131,6 +6131,34 @@ static void CalculateRefitMasks() } } +/** Check for invalid engines */ +static void FinaliseEngineArray() +{ + Engine *e; + + FOR_ALL_ENGINES(e) { + if (e->grffile == NULL) { + const EngineIDMapping &eid = _engine_mngr[e->index]; + if (eid.grfid != INVALID_GRFID || eid.internal_id != eid.substitute_id) { + e->info.string_id = STR_NEWGRF_INVALID_ENGINE; + } + } + } +} + +/** Check for invalid cargos */ +static void FinaliseCargoArray() +{ + for (CargoID c = 0; c < NUM_CARGO; c++) { + CargoSpec *cs = CargoSpec::Get(c); + if (!cs->IsValid()) { + cs->name = cs->name_single = cs->units_volume = STR_NEWGRF_INVALID_CARGO; + cs->quantifier = STR_NEWGRF_INVALID_CARGO_QUANTITY; + cs->abbrev = STR_NEWGRF_INVALID_CARGO_ABBREV; + } + } +} + /** Add all new houses to the house array. House properties can be set at any * time in the GRF file, so we can only add a house spec to the house array * after the file has finished loading. We also need to check the dates, due to @@ -6259,6 +6287,9 @@ static void FinaliseIndustriesArray() indsp->conflicting[i] = MapNewGRFIndustryType(indsp->conflicting[i], indsp->grf_prop.grffile->grfid); } } + if (!indsp->enabled) { + indsp->name = STR_NEWGRF_INVALID_INDUSTRYTYPE; + } } } @@ -6610,9 +6641,15 @@ static void AfterLoadGRFs() } _grf_line_to_action6_sprite_override.clear(); + /* Polish cargos */ + FinaliseCargoArray(); + /* Pre-calculate all refit masks after loading GRF files. */ CalculateRefitMasks(); + /* Polish engines */ + FinaliseEngineArray(); + /* Set the block size in the depot windows based on vehicle sprite sizes */ InitDepotWindowBlockSizes(); diff --git a/src/strings.cpp b/src/strings.cpp index f07139f0a0..834bb52719 100644 --- a/src/strings.cpp +++ b/src/strings.cpp @@ -964,7 +964,7 @@ static char *FormatString(char *buff, const char *str, int64 *argv, uint casei, assert(e != NULL); - if (e->name != NULL) { + if (e->name != NULL && e->info.string_id != STR_NEWGRF_INVALID_ENGINE) { buff = strecpy(buff, e->name, last); } else { buff = GetStringWithArgs(buff, e->info.string_id, NULL, last); diff --git a/src/vehicle_gui.h b/src/vehicle_gui.h index fab4b6bb6f..f84a80105d 100644 --- a/src/vehicle_gui.h +++ b/src/vehicle_gui.h @@ -59,7 +59,7 @@ enum { static inline bool ValidVLWFlags(uint16 flags) { - return (flags == VLW_STANDARD || flags == VLW_SHARED_ORDERS || flags == VLW_STATION_LIST || flags == VLW_DEPOT_LIST || flags == VLW_GROUP_LIST); + return (flags == VLW_STANDARD || flags == VLW_SHARED_ORDERS || flags == VLW_STATION_LIST || flags == VLW_DEPOT_LIST || flags == VLW_GROUP_LIST || flags == VLW_WAYPOINT_LIST); } int DrawVehiclePurchaseInfo(int left, int right, int y, EngineID engine_number);