Changeset - r22522:211f98bf45cf
[Not reviewed]
master
0 4 0
frosch - 7 years ago 2017-01-14 13:12:49
frosch@openttd.org
(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.
4 files changed with 21 insertions and 18 deletions:
0 comments (0 inline, 0 general)
src/fios.h
Show inline comments
 
@@ -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 */
src/network/core/config.h
Show inline comments
 
@@ -55,8 +55,7 @@ static const uint NETWORK_GRF_NAME_LENGT
 

	
 
/**
 
 * 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;
 

	
src/newgrf.cpp
Show inline comments
 
@@ -8860,8 +8860,8 @@ void LoadNewGRFFile(GRFConfig *config, u
 
		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 fi
 
		}
 

	
 
		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 fi
 
			}
 

	
 
			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);
src/newgrf_gui.cpp
Show inline comments
 
@@ -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;
 
		}
0 comments (0 inline, 0 general)