mirror of
https://github.com/JGRennison/OpenTTD-patches.git
synced 2024-11-09 19:10:38 +00:00
(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.
This commit is contained in:
parent
9f858cefd1
commit
8bd3a8a991
11
src/fios.h
11
src/fios.h
@ -81,20 +81,17 @@ extern LoadCheckData _load_check_data;
|
|||||||
|
|
||||||
enum FileSlots {
|
enum FileSlots {
|
||||||
/**
|
/**
|
||||||
* Slot used for the GRF scanning and such. This slot cannot be reused
|
* Slot used for the GRF scanning and such.
|
||||||
* as it will otherwise cause issues when pressing "rescan directories".
|
* This slot is used for all temporary accesses to files when scanning/testing files,
|
||||||
* It can furthermore not be larger than LAST_GRF_SLOT as that complicates
|
* and thus cannot be used for files, which are continuously accessed during a game.
|
||||||
* the testing for "too much NewGRFs".
|
|
||||||
*/
|
*/
|
||||||
CONFIG_SLOT = 0,
|
CONFIG_SLOT = 0,
|
||||||
/** Slot for the sound. */
|
/** Slot for the sound. */
|
||||||
SOUND_SLOT = 1,
|
SOUND_SLOT = 1,
|
||||||
/** First slot usable for (New)GRFs used during the game. */
|
/** First slot usable for (New)GRFs used during the game. */
|
||||||
FIRST_GRF_SLOT = 2,
|
FIRST_GRF_SLOT = 2,
|
||||||
/** Last slot usable for (New)GRFs used during the game. */
|
|
||||||
LAST_GRF_SLOT = 63,
|
|
||||||
/** Maximum number of slots. */
|
/** Maximum number of slots. */
|
||||||
MAX_FILE_SLOTS = 64
|
MAX_FILE_SLOTS = 128,
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Deals with finding savegames */
|
/** Deals with finding savegames */
|
||||||
|
@ -55,8 +55,7 @@ static const uint NETWORK_GRF_NAME_LENGTH = 80; ///< Maximum l
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Maximum number of GRFs that can be sent.
|
* Maximum number of GRFs that can be sent.
|
||||||
* This value is related to number of handles (files) OpenTTD can open.
|
* This limit is reached when PACKET_UDP_SERVER_RESPONSE reaches the maximum size of SEND_MTU bytes.
|
||||||
* This is currently 64. Two are used for configuration and sound.
|
|
||||||
*/
|
*/
|
||||||
static const uint NETWORK_MAX_GRF_COUNT = 62;
|
static const uint NETWORK_MAX_GRF_COUNT = 62;
|
||||||
|
|
||||||
|
@ -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 (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);
|
DEBUG(grf, 0, "'%s' is not loaded as the maximum number of file slots has been reached", filename);
|
||||||
config->status = GCS_DISABLED;
|
config->status = GCS_DISABLED;
|
||||||
config->error = new GRFError(STR_NEWGRF_ERROR_MSG_FATAL, STR_NEWGRF_ERROR_TOO_MANY_NEWGRFS_LOADED);
|
config->error = new GRFError(STR_NEWGRF_ERROR_MSG_FATAL, STR_NEWGRF_ERROR_TOO_MANY_NEWGRFS_LOADED);
|
||||||
return;
|
return;
|
||||||
@ -9263,6 +9263,7 @@ void LoadNewGRF(uint load_index, uint file_index)
|
|||||||
}
|
}
|
||||||
|
|
||||||
uint slot = file_index;
|
uint slot = file_index;
|
||||||
|
uint num_non_static = 0;
|
||||||
|
|
||||||
_cur.stage = stage;
|
_cur.stage = stage;
|
||||||
for (GRFConfig *c = _grfconfig; c != NULL; c = c->next) {
|
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 (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);
|
LoadNewGRFFile(c, slot++, stage, subdir);
|
||||||
if (stage == GLS_RESERVE) {
|
if (stage == GLS_RESERVE) {
|
||||||
SetBit(c->flags, GCF_RESERVED);
|
SetBit(c->flags, GCF_RESERVED);
|
||||||
|
@ -39,10 +39,6 @@
|
|||||||
#include <map>
|
#include <map>
|
||||||
#include "safeguards.h"
|
#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.
|
* 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;
|
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 **entry = NULL;
|
||||||
GRFConfig **list;
|
GRFConfig **list;
|
||||||
/* Find last entry in the list, checking for duplicate grfid on the way */
|
/* 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);
|
ShowErrorMessage(STR_NEWGRF_DUPLICATE_GRFID, INVALID_STRING_ID, WL_INFO);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
count++;
|
if (!HasBit((*list)->flags, GCF_STATIC)) count++;
|
||||||
}
|
}
|
||||||
if (entry == NULL) entry = list;
|
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);
|
ShowErrorMessage(STR_NEWGRF_TOO_MANY_NEWGRFS, INVALID_STRING_ID, WL_INFO);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user