summaryrefslogtreecommitdiff
path: root/src/newgrf.cpp
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2007-10-29 23:02:31 +0000
committerrubidium <rubidium@openttd.org>2007-10-29 23:02:31 +0000
commitb14c94867a121a5c6b9b69340953368aee8a8876 (patch)
treef4608f438da95909157f41aa78f5a878e7152382 /src/newgrf.cpp
parent24956ab71ba1dd9ed1734ae262229f098662b275 (diff)
downloadopenttd-b14c94867a121a5c6b9b69340953368aee8a8876.tar.xz
(svn r11355) -Fix [FS#1377]: loading too many GRFs was not handled gracefully causing crashes and such.
Diffstat (limited to 'src/newgrf.cpp')
-rw-r--r--src/newgrf.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/newgrf.cpp b/src/newgrf.cpp
index 9052adb63..d706417b7 100644
--- a/src/newgrf.cpp
+++ b/src/newgrf.cpp
@@ -47,6 +47,7 @@
#include "newgrf_industries.h"
#include "table/landscape_sprite.h"
#include "gfxinit.h"
+#include "fios.h"
/* TTDPatch extended GRF format codec
* (c) Petr Baudis 2004 (GPL'd)
@@ -5421,6 +5422,15 @@ void LoadNewGRFFile(GRFConfig *config, uint file_index, GrfLoadingStage stage)
if (stage == GLS_ACTIVATION && config->status != GCS_INITIALISED) return;
}
+ if (file_index > LAST_GRF_SLOT) {
+ DEBUG(grf, 0, "'%s' is not loaded as the maximum number of GRFs has been reached", filename);
+ config->status = GCS_DISABLED;
+ config->error = CallocT<GRFError>(1);
+ config->error->severity = STR_NEWGRF_ERROR_MSG_FATAL;
+ config->error->message = STR_NEWGRF_ERROR_TOO_MANY_NEWGRFS_LOADED;
+ return;
+ }
+
FioOpenFile(file_index, filename);
_file_index = file_index; // XXX