@@ -21,25 +21,24 @@
/*************************************************/
/* FILE IO ROUTINES ******************************/
#define FIO_BUFFER_SIZE 512
#define MAX_HANDLES 64
struct Fio {
byte *buffer, *buffer_end; ///< position pointer in local buffer and last valid byte of buffer
uint32 pos; ///< current (system) position in file
FILE *cur_fh; ///< current file handle
const char *filename; ///< current filename
FILE *handles[MAX_HANDLES]; ///< array of file handles we can have open
byte buffer_start[FIO_BUFFER_SIZE]; ///< local buffer when read from file
const char *filenames[MAX_HANDLES]; ///< array of filenames we (should) have open
FILE *handles[MAX_FILE_SLOTS]; ///< array of file handles we can have open
const char *filenames[MAX_FILE_SLOTS]; ///< array of filenames we (should) have open
#if defined(LIMITED_FDS)
uint open_handles; ///< current amount of open handles
uint usage_count[MAX_HANDLES]; ///< count how many times this file has been opened
uint usage_count[MAX_FILE_SLOTS]; ///< count how many times this file has been opened
#endif /* LIMITED_FDS */
};
static Fio _fio;
/* Get current position in file */
@@ -2,12 +2,30 @@
/** @file fios.h Declarations for savegames operations */
#ifndef FIOS_H
#define FIOS_H
enum {
/**
* 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".
*/
CONFIG_SLOT = 0,
/** Slot for the sound. */
SOUND_SLOT = 1,
/** First slot useable for (New)GRFs used during the game. */
FIRST_GRF_SLOT = 2,
/** Last slot useable for (New)GRFs used during the game. */
LAST_GRF_SLOT = 63,
/** Maximum number of slots. */
MAX_FILE_SLOTS = 64
/* Deals with finding savegames */
struct FiosItem {
byte type;
uint64 mtime;
char title[64];
char name[256 - 12 - 64];
@@ -8,12 +8,13 @@
#include "functions.h"
#include "gfx.h"
#include "gfxinit.h"
#include "spritecache.h"
#include "table/sprites.h"
#include "fileio.h"
#include "fios.h"
#include "string.h"
#include "newgrf.h"
#include "md5.h"
#include "variables.h"
#include "fontcache.h"
#include <string.h>
@@ -330,22 +331,22 @@ static const SpriteID _openttd_grf_index
static void LoadSpriteTables()
{
const FileList* files = _use_dos_palette ? &files_dos : &files_win;
uint load_index;
uint i;
uint i = FIRST_GRF_SLOT;
LoadGrfIndexed(files->basic[0].filename, trg1idx, 0);
LoadGrfIndexed(files->basic[0].filename, trg1idx, i++);
DupSprite( 2, 130); // non-breaking space medium
DupSprite(226, 354); // non-breaking space tiny
DupSprite(450, 578); // non-breaking space large
load_index = 4793;
for (i = 1; files->basic[i].filename != NULL; i++) {
load_index += LoadGrfFile(files->basic[i].filename, load_index, i);
for (uint j = 1; files->basic[j].filename != NULL; j++) {
load_index += LoadGrfFile(files->basic[j].filename, load_index, i++);
}
/* Load additional sprites for climates other than temperate */
if (_opt.landscape != LT_TEMPERATE) {
LoadGrfIndexed(
files->landscape[_opt.landscape - 1].filename,
@@ -3074,12 +3074,13 @@ STR_NEWGRF_ERROR_DOS_OR_WINDOWS
STR_NEWGRF_ERROR_UNSET_SWITCH :{STRING} is designed to be used with {STRING}
STR_NEWGRF_ERROR_INVALID_PARAMETER :Invalid parameter for {STRING}: parameter {STRING} ({NUM})
STR_NEWGRF_ERROR_LOAD_BEFORE :{STRING} must be loaded before {STRING}.
STR_NEWGRF_ERROR_LOAD_AFTER :{STRING} must be loaded after {STRING}.
STR_NEWGRF_ERROR_OTTD_VERSION_NUMBER :{STRING} requires OpenTTD version {STRING} or better.
STR_NEWGRF_ERROR_AFTER_TRANSLATED_FILE :the GRF file it was designed to translate
STR_NEWGRF_ERROR_TOO_MANY_NEWGRFS_LOADED :Too many NewGRFs are loaded.
STR_NEWGRF_ADD :{BLACK}Add
STR_NEWGRF_ADD_TIP :{BLACK}Add a NewGRF file to the list
STR_NEWGRF_REMOVE :{BLACK}Remove
STR_NEWGRF_REMOVE_TIP :{BLACK}Remove the selected NewGRF file from the list
STR_NEWGRF_MOVEUP :{BLACK}Move Up
@@ -44,12 +44,13 @@
#include "table/build_industry.h"
#include "newgrf_commons.h"
#include "newgrf_townname.h"
#include "newgrf_industries.h"
#include "table/landscape_sprite.h"
/* TTDPatch extended GRF format codec
* (c) Petr Baudis 2004 (GPL'd)
* Changes by Florian octo Forster are (c) by the OpenTTD development team.
*
* Contains portions of documentation by TTDPatch team.
@@ -5418,12 +5419,21 @@ void LoadNewGRFFile(GRFConfig *config, u
_cur_grffile = GetFileByFilename(filename);
if (_cur_grffile == NULL) error("File '%s' lost in cache.\n", filename);
if (stage == GLS_RESERVE && config->status != GCS_INITIALISED) return;
if (stage == GLS_ACTIVATION && config->status != GCS_INITIALISED) return;
if (file_index > LAST_GRF_SLOT) {
DEBUG(grf, 0, "'%s' is not loaded as the maximum number of GRFs has been reached", filename);
config->status = GCS_DISABLED;
config->error = CallocT<GRFError>(1);
config->error->severity = STR_NEWGRF_ERROR_MSG_FATAL;
config->error->message = STR_NEWGRF_ERROR_TOO_MANY_NEWGRFS_LOADED;
return;
FioOpenFile(file_index, filename);
_file_index = file_index; // XXX
_cur_grfconfig = config;
DEBUG(grf, 2, "LoadNewGRFFile: Reading NewGRF-file '%s'", filename);
@@ -63,15 +63,13 @@ bool FillGRFDetails(GRFConfig *config, b
if (!FioCheckFileExists(config->filename)) {
config->status = GCS_NOT_FOUND;
return false;
/* Find and load the Action 8 information */
/* 62 is the last file slot before sample.cat.
* Should perhaps be some "don't care" value */
LoadNewGRFFile(config, 62, GLS_FILESCAN);
LoadNewGRFFile(config, CONFIG_SLOT, GLS_FILESCAN);
/* Skip if the grfid is 0 (not read) or 0xFFFFFFFF (ttdp system grf) */
if (config->grfid == 0 || config->grfid == 0xFFFFFFFF) return false;
if (is_static) {
/* Perform a 'safety scan' for static GRFs */
@@ -12,17 +12,17 @@
#include "vehicle.h"
#include "window.h"
#include "viewport.h"
#include "newgrf_sound.h"
#include "helpers.hpp"
static uint _file_count;
static FileEntry *_files;
#define SOUND_SLOT 63
// Number of levels of panning per side
#define PANNING_LEVELS 16
static void OpenBankFile(const char *filename)
Status change: