Changeset - r25415:8ce980a6ac29
[Not reviewed]
master
0 4 0
Rubidium - 3 years ago 2021-04-21 16:40:37
rubidium@openttd.org
Cleanup: remove the old FIO slot functions
4 files changed with 0 insertions and 154 deletions:
0 comments (0 inline, 0 general)
src/fileio.cpp
Show inline comments
 
@@ -30,136 +30,12 @@
 

	
 
#include "safeguards.h"
 

	
 
static SpriteFile *_fio_current_file;                       ///< current file handle for the Fio functions
 
static std::array<SpriteFile *, MAX_FILE_SLOTS> _fio_files; ///< array of random access files we can have open
 

	
 
/** Whether the working directory should be scanned. */
 
static bool _do_scan_working_directory = true;
 

	
 
extern std::string _config_file;
 
extern std::string _highscore_file;
 

	
 
/**
 
 * Transition helper to get the SpriteFile associated with a given slot.
 
 */
 
SpriteFile *FioGetSpriteFile(int slot)
 
{
 
	return _fio_files[slot];
 
}
 

	
 
/**
 
 * Get position in the current file.
 
 * @return Position in the file.
 
 */
 
size_t FioGetPos()
 
{
 
	return _fio_current_file->GetPos();
 
}
 

	
 
/**
 
 * Get the filename associated with a slot.
 
 * @param slot Index of queried file.
 
 * @return Name of the file.
 
 */
 
const char *FioGetFilename(uint8 slot)
 
{
 
	return _fio_current_file->GetSimplifiedFilename().c_str();
 
}
 

	
 
/**
 
 * Seek in the current file.
 
 * @param pos New position.
 
 * @param mode Type of seek (\c SEEK_CUR means \a pos is relative to current position, \c SEEK_SET means \a pos is absolute).
 
 */
 
void FioSeekTo(size_t pos, int mode)
 
{
 
	_fio_current_file->SeekTo(pos, mode);
 
}
 

	
 
/**
 
 * Switch to a different file and seek to a position.
 
 * @param slot Slot number of the new file.
 
 * @param pos New absolute position in the new file.
 
 */
 
void FioSeekToFile(uint8 slot, size_t pos)
 
{
 
	SpriteFile *file = _fio_files[slot];
 
	assert(file != nullptr);
 
	_fio_current_file = file;
 
	_fio_current_file->SeekTo(pos, SEEK_SET);
 
}
 

	
 
/**
 
 * Read a byte from the file.
 
 * @return Read byte.
 
 */
 
byte FioReadByte()
 
{
 
	return _fio_current_file->ReadByte();
 
}
 

	
 
/**
 
 * Skip \a n bytes ahead in the file.
 
 * @param n Number of bytes to skip reading.
 
 */
 
void FioSkipBytes(int n)
 
{
 
	return _fio_current_file->SkipBytes(n);
 
}
 

	
 
/**
 
 * Read a word (16 bits) from the file (in low endian format).
 
 * @return Read word.
 
 */
 
uint16 FioReadWord()
 
{
 
	return _fio_current_file->ReadWord();
 
}
 

	
 
/**
 
 * Read a double word (32 bits) from the file (in low endian format).
 
 * @return Read word.
 
 */
 
uint32 FioReadDword()
 
{
 
	return _fio_current_file->ReadDword();
 
}
 

	
 
/**
 
 * Read a block.
 
 * @param ptr Destination buffer.
 
 * @param size Number of bytes to read.
 
 */
 
void FioReadBlock(void *ptr, size_t size)
 
{
 
	_fio_current_file->ReadBlock(ptr, size);
 
}
 

	
 
/** Close all slotted open files. */
 
void FioCloseAll()
 
{
 
	for (int i = 0; i != lengthof(_fio_files); i++) {
 
		delete _fio_files[i];
 
		_fio_files[i] = nullptr;
 
	}
 
}
 

	
 
/**
 
 * Open a slotted file.
 
 * @param slot Index to assign.
 
 * @param filename Name of the file at the disk.
 
 * @param subdir The sub directory to search this file in.
 
 * @param palette_remap Whether palette remapping needs to take place.
 
 */
 
SpriteFile &FioOpenFile(int slot, const std::string &filename, Subdirectory subdir, bool palette_remap)
 
{
 
	SpriteFile *file = new SpriteFile(filename, subdir, palette_remap);
 
	delete _fio_files[slot];
 
	_fio_files[slot] = file;
 
	_fio_current_file = file;
 
	return *file;
 
}
 

	
 
static const char * const _subdirs[] = {
 
	"",
 
	"save" PATHSEP,
src/fileio_func.h
Show inline comments
 
@@ -15,19 +15,6 @@
 
#include <string>
 
#include <vector>
 

	
 
void FioSeekTo(size_t pos, int mode);
 
void FioSeekToFile(uint8 slot, size_t pos);
 
size_t FioGetPos();
 
const char *FioGetFilename(uint8 slot);
 
byte FioReadByte();
 
uint16 FioReadWord();
 
uint32 FioReadDword();
 
void FioCloseAll();
 
class SpriteFile &FioOpenFile(int slot, const std::string &filename, Subdirectory subdir, bool palette_remap = false);
 
void FioReadBlock(void *ptr, size_t size);
 
void FioSkipBytes(int n);
 
class SpriteFile *FioGetSpriteFile(int slot);
 

	
 
void FioFCloseFile(FILE *f);
 
FILE *FioFOpenFile(const std::string &filename, const char *mode, Subdirectory subdir, size_t *filesize = nullptr);
 
bool FioCheckFileExists(const std::string &filename, Subdirectory subdir);
src/fios.h
Show inline comments
 
@@ -83,20 +83,6 @@ struct LoadCheckData {
 

	
 
extern LoadCheckData _load_check_data;
 

	
 

	
 
enum FileSlots {
 
	/**
 
	 * 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,
 
	/** First slot usable for (New)GRFs used during the game. */
 
	FIRST_GRF_SLOT =  2,
 
	/** Maximum number of slots. */
 
	MAX_FILE_SLOTS = 128,
 
};
 

	
 
/** Deals with finding savegames */
 
struct FiosItem {
 
	FiosType type;
src/openttd.cpp
Show inline comments
 
@@ -324,9 +324,6 @@ static void ShutdownGame()
 
	/* No NewGRFs were loaded when it was still bootstrapping. */
 
	if (_game_mode != GM_BOOTSTRAP) ResetNewGRFData();
 

	
 
	/* Close all and any open filehandles */
 
	FioCloseAll();
 

	
 
	UninitFreeType();
 
}
 

	
0 comments (0 inline, 0 general)