|
@@ -8073,13 +8073,20 @@ static void DecodeSpecialSprite(byte *bu
|
|
|
grfmsg(1, "DecodeSpecialSprite: Tried to read past end of pseudo-sprite data");
|
|
|
DisableGrf(STR_NEWGRF_ERROR_READ_BOUNDS);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
void LoadNewGRFFile(GRFConfig *config, uint file_index, GrfLoadingStage stage)
|
|
|
/**
|
|
|
* Load a particular NewGRF.
|
|
|
* @param config The configuration of the to be loaded NewGRF.
|
|
|
* @param file_index The Fio index of the first NewGRF to load.
|
|
|
* @param stage The loading stage of the NewGRF.
|
|
|
* @param subdir The sub directory to find the NewGRF in.
|
|
|
*/
|
|
|
void LoadNewGRFFile(GRFConfig *config, uint file_index, GrfLoadingStage stage, Subdirectory subdir)
|
|
|
{
|
|
|
const char *filename = config->filename;
|
|
|
uint16 num;
|
|
|
|
|
|
/* A .grf file is activated only if it was active when the game was
|
|
|
* started. If a game is loaded, only its active .grfs will be
|
|
@@ -8102,13 +8109,13 @@ void LoadNewGRFFile(GRFConfig *config, u
|
|
|
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);
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
FioOpenFile(file_index, filename, NEWGRF_DIR);
|
|
|
FioOpenFile(file_index, filename, subdir);
|
|
|
_cur.file_index = file_index; // XXX
|
|
|
_palette_remap_grf[_cur.file_index] = (config->palette & GRFP_USE_MASK);
|
|
|
|
|
|
_cur.grfconfig = config;
|
|
|
|
|
|
DEBUG(grf, 2, "LoadNewGRFFile: Reading NewGRF-file '%s'", filename);
|
|
@@ -8401,12 +8408,17 @@ static void AfterLoadGRFs()
|
|
|
|
|
|
/* Deallocate temporary loading data */
|
|
|
free(_gted);
|
|
|
_grm_sprites.clear();
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Load all the NewGRFs.
|
|
|
* @param load_index The offset for the first sprite to add.
|
|
|
* @param file_index The Fio index of the first NewGRF to load.
|
|
|
*/
|
|
|
void LoadNewGRF(uint load_index, uint file_index)
|
|
|
{
|
|
|
/* In case of networking we need to "sync" the start values
|
|
|
* so all NewGRFs are loaded equally. For this we use the
|
|
|
* start date of the game and we set the counters, etc. to
|
|
|
* 0 so they're the same too. */
|
|
@@ -8455,20 +8467,21 @@ void LoadNewGRF(uint load_index, uint fi
|
|
|
|
|
|
_cur.stage = stage;
|
|
|
for (GRFConfig *c = _grfconfig; c != NULL; c = c->next) {
|
|
|
if (c->status == GCS_DISABLED || c->status == GCS_NOT_FOUND) continue;
|
|
|
if (stage > GLS_INIT && HasBit(c->flags, GCF_INIT_ONLY)) continue;
|
|
|
|
|
|
if (!FioCheckFileExists(c->filename)) {
|
|
|
Subdirectory subdir = slot == file_index ? BASESET_DIR : NEWGRF_DIR;
|
|
|
if (!FioCheckFileExists(c->filename, subdir)) {
|
|
|
DEBUG(grf, 0, "NewGRF file is missing '%s'; disabling", c->filename);
|
|
|
c->status = GCS_NOT_FOUND;
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
if (stage == GLS_LABELSCAN) InitNewGRFFile(c);
|
|
|
LoadNewGRFFile(c, slot++, stage);
|
|
|
LoadNewGRFFile(c, slot++, stage, subdir);
|
|
|
if (stage == GLS_RESERVE) {
|
|
|
SetBit(c->flags, GCF_RESERVED);
|
|
|
} else if (stage == GLS_ACTIVATION) {
|
|
|
ClrBit(c->flags, GCF_RESERVED);
|
|
|
assert(GetFileByGRFID(c->ident.grfid) == _cur.grffile);
|
|
|
ClearTemporaryNewGRFData(_cur.grffile);
|