diff options
author | frosch <frosch@openttd.org> | 2017-01-14 13:12:49 +0000 |
---|---|---|
committer | frosch <frosch@openttd.org> | 2017-01-14 13:12:49 +0000 |
commit | ec9a920aab1af1001abb216a89cdc13e0ba1c3ab (patch) | |
tree | 08b793017fae46a658fda51e8e2d5720867335b2 | |
parent | 6696e5c4e1aca4a928dc88656497c63b6ebda6fa (diff) | |
download | openttd-ec9a920aab1af1001abb216a89cdc13e0ba1c3ab.tar.xz |
(svn r27729) -Codechange: Do not count static NewGRF when checking for the maximum number of NewGRFs in a game.
-Codechange: Remove LAST_GRF_SLOT and MAX_NEWGRFS. Now NETWORK_MAX_GRF_COUNT is the only constant to specify the maximum number of non-static NewGRF.
-Codechange: Increase the number of file slots, effectively increasing the maximum number of static NewGRF and baseset GRFs.
-rw-r--r-- | src/fios.h | 11 | ||||
-rw-r--r-- | src/network/core/config.h | 3 | ||||
-rw-r--r-- | src/newgrf.cpp | 15 | ||||
-rw-r--r-- | src/newgrf_gui.cpp | 10 |
4 files changed, 21 insertions, 18 deletions
diff --git a/src/fios.h b/src/fios.h index 51e0c275a..5e17e8ee1 100644 --- a/src/fios.h +++ b/src/fios.h @@ -81,20 +81,17 @@ extern LoadCheckData _load_check_data; 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 files, which are continuously accessed during a game. */ CONFIG_SLOT = 0, /** Slot for the sound. */ 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 */ diff --git a/src/network/core/config.h b/src/network/core/config.h index 93f75e377..f5e73dd12 100644 --- a/src/network/core/config.h +++ b/src/network/core/config.h @@ -55,8 +55,7 @@ static const uint NETWORK_GRF_NAME_LENGTH = 80; ///< Maximum l /** * 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; diff --git a/src/newgrf.cpp b/src/newgrf.cpp index 8d85b383d..7b862149d 100644 --- a/src/newgrf.cpp +++ b/src/newgrf.cpp @@ -8860,8 +8860,8 @@ void LoadNewGRFFile(GRFConfig *config, uint file_index, GrfLoadingStage stage, S if (stage == GLS_ACTIVATION && !HasBit(config->flags, GCF_RESERVED)) return; } - if (file_index > LAST_GRF_SLOT) { - DEBUG(grf, 0, "'%s' is not loaded as the maximum number of GRFs has been reached", filename); + if (file_index >= MAX_FILE_SLOTS) { + DEBUG(grf, 0, "'%s' is not loaded as the maximum number of file slots has been reached", filename); config->status = GCS_DISABLED; config->error = new GRFError(STR_NEWGRF_ERROR_MSG_FATAL, STR_NEWGRF_ERROR_TOO_MANY_NEWGRFS_LOADED); return; @@ -9263,6 +9263,7 @@ void LoadNewGRF(uint load_index, uint file_index) } 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 @@ void LoadNewGRF(uint load_index, uint file_index) } 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 non-static 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); diff --git a/src/newgrf_gui.cpp b/src/newgrf_gui.cpp index eac36c3cf..c3007ac42 100644 --- a/src/newgrf_gui.cpp +++ b/src/newgrf_gui.cpp @@ -39,10 +39,6 @@ #include <map> #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 @@ private: { 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 */ @@ -1519,10 +1515,10 @@ private: ShowErrorMessage(STR_NEWGRF_DUPLICATE_GRFID, INVALID_STRING_ID, WL_INFO); return false; } - count++; + if (!HasBit((*list)->flags, GCF_STATIC)) 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; } |