mirror of
https://github.com/JGRennison/OpenTTD-patches.git
synced 2024-11-02 09:40:35 +00:00
Fix increased number of NewGRFs support.
Improve error handling if multiplayer limit is exceeded.
This commit is contained in:
parent
7e89b9789f
commit
f89e8b76d6
@ -75,7 +75,7 @@ size_t FioGetPos()
|
|||||||
* @param slot Index of queried file.
|
* @param slot Index of queried file.
|
||||||
* @return Name of the file.
|
* @return Name of the file.
|
||||||
*/
|
*/
|
||||||
const char *FioGetFilename(uint8 slot)
|
const char *FioGetFilename(uint slot)
|
||||||
{
|
{
|
||||||
return _fio.shortnames[slot];
|
return _fio.shortnames[slot];
|
||||||
}
|
}
|
||||||
@ -112,7 +112,7 @@ static void FioRestoreFile(int slot)
|
|||||||
* @param slot Slot number of the new file.
|
* @param slot Slot number of the new file.
|
||||||
* @param pos New absolute position in the new file.
|
* @param pos New absolute position in the new file.
|
||||||
*/
|
*/
|
||||||
void FioSeekToFile(uint8 slot, size_t pos)
|
void FioSeekToFile(uint slot, size_t pos)
|
||||||
{
|
{
|
||||||
FILE *f;
|
FILE *f;
|
||||||
#if defined(LIMITED_FDS)
|
#if defined(LIMITED_FDS)
|
||||||
@ -247,7 +247,7 @@ static void FioFreeHandle()
|
|||||||
* @param filename Name of the file at the disk.
|
* @param filename Name of the file at the disk.
|
||||||
* @param subdir The sub directory to search this file in.
|
* @param subdir The sub directory to search this file in.
|
||||||
*/
|
*/
|
||||||
void FioOpenFile(int slot, const char *filename, Subdirectory subdir)
|
void FioOpenFile(uint slot, const char *filename, Subdirectory subdir)
|
||||||
{
|
{
|
||||||
FILE *f;
|
FILE *f;
|
||||||
|
|
||||||
|
@ -16,14 +16,14 @@
|
|||||||
#include "fileio_type.h"
|
#include "fileio_type.h"
|
||||||
|
|
||||||
void FioSeekTo(size_t pos, int mode);
|
void FioSeekTo(size_t pos, int mode);
|
||||||
void FioSeekToFile(uint8 slot, size_t pos);
|
void FioSeekToFile(uint slot, size_t pos);
|
||||||
size_t FioGetPos();
|
size_t FioGetPos();
|
||||||
const char *FioGetFilename(uint8 slot);
|
const char *FioGetFilename(uint slot);
|
||||||
byte FioReadByte();
|
byte FioReadByte();
|
||||||
uint16 FioReadWord();
|
uint16 FioReadWord();
|
||||||
uint32 FioReadDword();
|
uint32 FioReadDword();
|
||||||
void FioCloseAll();
|
void FioCloseAll();
|
||||||
void FioOpenFile(int slot, const char *filename, Subdirectory subdir);
|
void FioOpenFile(uint slot, const char *filename, Subdirectory subdir);
|
||||||
void FioReadBlock(void *ptr, size_t size);
|
void FioReadBlock(void *ptr, size_t size);
|
||||||
void FioSkipBytes(int n);
|
void FioSkipBytes(int n);
|
||||||
|
|
||||||
|
@ -90,8 +90,10 @@ enum FileSlots {
|
|||||||
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,
|
||||||
|
/** Maximum number of GRFs in single-player */
|
||||||
|
MAX_NEWGRFS = 256,
|
||||||
/** Maximum number of slots. */
|
/** Maximum number of slots. */
|
||||||
MAX_FILE_SLOTS = 256,
|
MAX_FILE_SLOTS = 300,
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Deals with finding savegames */
|
/** Deals with finding savegames */
|
||||||
|
@ -1179,7 +1179,7 @@ struct NetworkStartServerWindow : public Window {
|
|||||||
}
|
}
|
||||||
|
|
||||||
case WID_NSS_GENERATE_GAME: // Start game
|
case WID_NSS_GENERATE_GAME: // Start game
|
||||||
if ((uint) CountSelectedGRFs (_grfconfig_newgame) > NETWORK_MAX_GRF_COUNT) {
|
if (CountSelectedGRFs(_grfconfig_newgame) > NETWORK_MAX_GRF_COUNT) {
|
||||||
ShowErrorMessage(STR_NEWGRF_ERROR_TOO_MANY_NEWGRFS_LOADED, INVALID_STRING_ID, WL_ERROR);
|
ShowErrorMessage(STR_NEWGRF_ERROR_TOO_MANY_NEWGRFS_LOADED, INVALID_STRING_ID, WL_ERROR);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -9271,7 +9271,7 @@ void LoadNewGRF(uint load_index, uint file_index, uint num_baseset)
|
|||||||
if (stage == GLS_LABELSCAN) InitNewGRFFile(c);
|
if (stage == GLS_LABELSCAN) InitNewGRFFile(c);
|
||||||
|
|
||||||
if (!HasBit(c->flags, GCF_STATIC) && !HasBit(c->flags, GCF_SYSTEM)) {
|
if (!HasBit(c->flags, GCF_STATIC) && !HasBit(c->flags, GCF_SYSTEM)) {
|
||||||
if (num_non_static == NETWORK_MAX_GRF_COUNT) {
|
if ((_networking && num_non_static == NETWORK_MAX_GRF_COUNT) || slot == MAX_FILE_SLOTS) {
|
||||||
DEBUG(grf, 0, "'%s' is not loaded as the maximum number of non-static GRFs has been reached", c->filename);
|
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->status = GCS_DISABLED;
|
||||||
c->error = new GRFError(STR_NEWGRF_ERROR_MSG_FATAL, STR_NEWGRF_ERROR_TOO_MANY_NEWGRFS_LOADED);
|
c->error = new GRFError(STR_NEWGRF_ERROR_MSG_FATAL, STR_NEWGRF_ERROR_TOO_MANY_NEWGRFS_LOADED);
|
||||||
@ -9314,12 +9314,13 @@ void LoadNewGRF(uint load_index, uint file_index, uint num_baseset)
|
|||||||
/**
|
/**
|
||||||
* Returns amount of user selected NewGRFs files.
|
* Returns amount of user selected NewGRFs files.
|
||||||
*/
|
*/
|
||||||
int CountSelectedGRFs(GRFConfig *grfconf)
|
uint CountSelectedGRFs(GRFConfig *grfconf)
|
||||||
{
|
{
|
||||||
int i = 0;
|
uint i = 0;
|
||||||
|
|
||||||
/* Find last entry in the list */
|
/* Find last entry in the list */
|
||||||
for (const GRFConfig *list = grfconf; list != NULL; list = list->next, i++) {
|
for (const GRFConfig *list = grfconf; list != NULL; list = list->next) {
|
||||||
|
if (!HasBit(list->flags, GCF_STATIC) && !HasBit(list->flags, GCF_SYSTEM)) i++;
|
||||||
}
|
}
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
@ -194,7 +194,7 @@ bool GetGlobalVariable(byte param, uint32 *value, const GRFFile *grffile);
|
|||||||
|
|
||||||
StringID MapGRFStringID(uint32 grfid, StringID str);
|
StringID MapGRFStringID(uint32 grfid, StringID str);
|
||||||
void ShowNewGRFError();
|
void ShowNewGRFError();
|
||||||
int CountSelectedGRFs(GRFConfig *grfconf);
|
uint CountSelectedGRFs(GRFConfig *grfconf);
|
||||||
|
|
||||||
struct TemplateVehicle;
|
struct TemplateVehicle;
|
||||||
|
|
||||||
|
@ -1521,7 +1521,7 @@ private:
|
|||||||
if (!HasBit((*list)->flags, GCF_STATIC)) count++;
|
if (!HasBit((*list)->flags, GCF_STATIC)) count++;
|
||||||
}
|
}
|
||||||
if (entry == NULL) entry = list;
|
if (entry == NULL) entry = list;
|
||||||
if (count >= NETWORK_MAX_GRF_COUNT) {
|
if (count >= MAX_NEWGRFS) {
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
@ -741,6 +741,13 @@ bool AfterLoadGame()
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (_networking && CountSelectedGRFs(_grfconfig) > NETWORK_MAX_GRF_COUNT) {
|
||||||
|
SetSaveLoadError(STR_NEWGRF_ERROR_TOO_MANY_NEWGRFS_LOADED);
|
||||||
|
/* Restore the signals */
|
||||||
|
ResetSignalHandlers();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/* The value of _date_fract got divided, so make sure that old games are converted correctly. */
|
/* The value of _date_fract got divided, so make sure that old games are converted correctly. */
|
||||||
if (IsSavegameVersionBefore(11, 1) || (IsSavegameVersionBefore(147) && _date_fract > DAY_TICKS)) _date_fract /= 885;
|
if (IsSavegameVersionBefore(11, 1) || (IsSavegameVersionBefore(147) && _date_fract > DAY_TICKS)) _date_fract /= 885;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user