(svn r11355) -Fix [FS#1377]: loading too many GRFs was not handled gracefully causing crashes and such.

This commit is contained in:
rubidium
2007-10-29 23:02:31 +00:00
parent 24956ab71b
commit b14c94867a
7 changed files with 45 additions and 18 deletions

View File

@@ -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