summaryrefslogtreecommitdiff
path: root/src/saveload/industry_sl.cpp
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2015-05-09 10:04:50 +0000
committerfrosch <frosch@openttd.org>2015-05-09 10:04:50 +0000
commit3f55e5364e69c0ce4d0011371afbad4153fc073e (patch)
tree2fbced55b3c246e37692d41321b0fa0fef63d514 /src/saveload/industry_sl.cpp
parent5e47c27550efca4c318cfe4b9bdfe51a28bc2984 (diff)
downloadopenttd-3f55e5364e69c0ce4d0011371afbad4153fc073e.tar.xz
(svn r27278) -Fix: Handle savegames with an unexpected amount of industry-builder or NewGRF entity-mapping more gracefully.
Diffstat (limited to 'src/saveload/industry_sl.cpp')
-rw-r--r--src/saveload/industry_sl.cpp10
1 files changed, 4 insertions, 6 deletions
diff --git a/src/saveload/industry_sl.cpp b/src/saveload/industry_sl.cpp
index 658cfd2bd..34e857c6f 100644
--- a/src/saveload/industry_sl.cpp
+++ b/src/saveload/industry_sl.cpp
@@ -160,14 +160,12 @@ static void Save_ITBL()
/** Load industry-type build data. */
static void Load_ITBL()
{
+ _industry_builder.Reset();
int index;
- for (int i = 0; i < NUM_INDUSTRYTYPES; i++) {
- index = SlIterateArray();
- assert(index == i);
- SlObject(_industry_builder.builddata + i, _industrytype_builder_desc);
+ while ((index = SlIterateArray()) != -1) {
+ if ((uint)index >= NUM_INDUSTRYTYPES) SlErrorCorrupt("Too many industry builder datas");
+ SlObject(_industry_builder.builddata + index, _industrytype_builder_desc);
}
- index = SlIterateArray();
- assert(index == -1);
}
extern const ChunkHandler _industry_chunk_handlers[] = {