summaryrefslogtreecommitdiff
path: root/src/newgrf.cpp
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2010-05-21 20:51:00 +0000
committerfrosch <frosch@openttd.org>2010-05-21 20:51:00 +0000
commit393134ed6962b4297e0ac78c24b2f30872c52997 (patch)
treeada4caf20df75cf564787a68b5195020ffb5245a /src/newgrf.cpp
parent0040e88b7f2f833774fdbf73b618a06ac6bdb8f3 (diff)
downloadopenttd-393134ed6962b4297e0ac78c24b2f30872c52997.tar.xz
(svn r19877) -Change: Name invalid engines, cargos and industries 'invalid', if the player removed the supplying NewGRFs.
Diffstat (limited to 'src/newgrf.cpp')
-rw-r--r--src/newgrf.cpp37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/newgrf.cpp b/src/newgrf.cpp
index 4f6b88bf8..3e4e95b5b 100644
--- a/src/newgrf.cpp
+++ b/src/newgrf.cpp
@@ -6455,6 +6455,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
@@ -6583,6 +6611,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;
+ }
}
}
@@ -6963,9 +6994,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();