Index: src/fios.h =================================================================== --- src/fios.h (revision 27726) +++ src/fios.h (working copy) @@ -81,10 +81,9 @@ enum FileSlots { /** - * Slot used for the GRF scanning and such. This slot cannot be reused - * as it will otherwise cause issues when pressing "rescan directories". - * It can furthermore not be larger than LAST_GRF_SLOT as that complicates - * the testing for "too much NewGRFs". + * Slot used for the GRF scanning and such. + * This slot is used for all temporary accesses to files when scanning/testing files, + * and thus cannot be used for any long-term usage. */ CONFIG_SLOT = 0, /** Slot for the sound. */ @@ -91,10 +90,8 @@ SOUND_SLOT = 1, /** First slot usable for (New)GRFs used during the game. */ FIRST_GRF_SLOT = 2, - /** Last slot usable for (New)GRFs used during the game. */ - LAST_GRF_SLOT = 63, /** Maximum number of slots. */ - MAX_FILE_SLOTS = 64 + MAX_FILE_SLOTS = 128, }; /** Deals with finding savegames */ Index: src/network/core/config.h =================================================================== --- src/network/core/config.h (revision 27726) +++ src/network/core/config.h (working copy) @@ -55,8 +55,7 @@ /** * Maximum number of GRFs that can be sent. - * This value is related to number of handles (files) OpenTTD can open. - * This is currently 64. Two are used for configuration and sound. + * This limit is reached when PACKET_UDP_SERVER_RESPONSE reaches the maximum size of SEND_MTU bytes. */ static const uint NETWORK_MAX_GRF_COUNT = 62; Index: src/newgrf.cpp =================================================================== --- src/newgrf.cpp (revision 27726) +++ src/newgrf.cpp (working copy) @@ -8860,7 +8860,7 @@ if (stage == GLS_ACTIVATION && !HasBit(config->flags, GCF_RESERVED)) return; } - if (file_index > LAST_GRF_SLOT) { + if (file_index >= MAX_FILE_SLOTS) { DEBUG(grf, 0, "'%s' is not loaded as the maximum number of GRFs has been reached", filename); config->status = GCS_DISABLED; config->error = new GRFError(STR_NEWGRF_ERROR_MSG_FATAL, STR_NEWGRF_ERROR_TOO_MANY_NEWGRFS_LOADED); @@ -9263,6 +9263,7 @@ } uint slot = file_index; + uint num_non_static = 0; _cur.stage = stage; for (GRFConfig *c = _grfconfig; c != NULL; c = c->next) { @@ -9277,6 +9278,16 @@ } if (stage == GLS_LABELSCAN) InitNewGRFFile(c); + + if (!HasBit(c->flags, GCF_STATIC) && !HasBit(c->flags, GCF_SYSTEM)) { + if (num_non_static == NETWORK_MAX_GRF_COUNT) { + DEBUG(grf, 0, "'%s' is not loaded as the maximum number of GRFs has been reached", c->filename); + c->status = GCS_DISABLED; + c->error = new GRFError(STR_NEWGRF_ERROR_MSG_FATAL, STR_NEWGRF_ERROR_TOO_MANY_NEWGRFS_LOADED); + continue; + } + num_non_static++; + } LoadNewGRFFile(c, slot++, stage, subdir); if (stage == GLS_RESERVE) { SetBit(c->flags, GCF_RESERVED); Index: src/newgrf_gui.cpp =================================================================== --- src/newgrf_gui.cpp (revision 27726) +++ src/newgrf_gui.cpp (working copy) @@ -39,10 +39,6 @@ #include #include "safeguards.h" -/* Maximum number of NewGRFs that may be loaded. Six reserved slots are: - * 0 - config, 1 - sound, 2 - base, 3 - logos, 4 - climate, 5 - extra */ -static const int MAX_NEWGRFS = MAX_FILE_SLOTS - 6; - /** * Show the first NewGRF error we can find. */ @@ -1509,7 +1505,7 @@ { if (this->avail_sel == NULL || !this->editable || HasBit(this->avail_sel->flags, GCF_INVALID)) return false; - int count = 0; + uint count = 0; GRFConfig **entry = NULL; GRFConfig **list; /* Find last entry in the list, checking for duplicate grfid on the way */ @@ -1522,7 +1518,7 @@ count++; } if (entry == NULL) entry = list; - if (count >= MAX_NEWGRFS) { + if (count >= NETWORK_MAX_GRF_COUNT) { ShowErrorMessage(STR_NEWGRF_TOO_MANY_NEWGRFS, INVALID_STRING_ID, WL_INFO); return false; }