OpenTTD Source: SpriteFile Class Reference

OpenTTD Source 14.0-beta3

Public Member Functions | Private Attributes
SpriteFile Class Reference

RandomAccessFile with some extra information specific for sprite files. More...

`#include <sprite_file_type.hpp>`

Inheritance diagram for SpriteFile:

## Public Member Functions
| SpriteFile (const std::string &filename, Subdirectory subdir, bool palette_remap)
| Create the SpriteFile. More...
| SpriteFile (const SpriteFile &)=delete
void | operator= (const SpriteFile &)=delete
bool | NeedsPaletteRemap () const
| Whether a palette remap is needed when loading sprites from this file. More...
byte | GetContainerVersion () const
| Get the version number of container type used by the file. More...
void | SeekToBegin ()
| Seek to the begin of the content, i.e. More...
Public Member Functions inherited from RandomAccessFile
| RandomAccessFile (const std::string &filename, Subdirectory subdir)
| Create the RandomAccesFile. More...
| RandomAccessFile (const RandomAccessFile &)=delete
void | operator= (const RandomAccessFile &)=delete
virtual | ~RandomAccessFile ()
| Close the file's file handle.
const std::string & | GetFilename () const
| Get the filename of the opened file with the path from the SubDirectory and the extension. More...
const std::string & | GetSimplifiedFilename () const
| Get the simplified filename of the opened file. More...
size_t | GetPos () const
| Get position in the file. More...
void | SeekTo (size_t pos, int mode)
| Seek in the current file. More...
byte | ReadByte ()
| Read a byte from the file. More...
uint16_t | ReadWord ()
| Read a word (16 bits) from the file (in low endian format). More...
uint32_t | ReadDword ()
| Read a double word (32 bits) from the file (in low endian format). More...
void | ReadBlock (void *ptr, size_t size)
| Read a block. More...
void | SkipBytes (size_t n)
| Skip n bytes ahead in the file. More...

## Private Attributes
bool | palette_remap
| Whether or not a remap of the palette is required for this file.
byte | container_version
| Container format of the sprite file.
size_t | content_begin
| The begin of the content of the sprite file, i.e. after the container metadata.

## Detailed Description

RandomAccessFile with some extra information specific for sprite files.

It automatically detects and stores the container version upload opening the file.

Definition at line 19 of file sprite_file_type.hpp.

## Constructor & Destructor Documentation

## ◆ SpriteFile()

SpriteFile::SpriteFile | ( | const std::string & | filename,
|  | Subdirectory | subdir,
|  | bool | palette_remap
| ) |  |

Create the SpriteFile.

Parameters

  filename | Name of the file at the disk.
  subdir | The sub directory to search this file in.
  palette_remap | Whether a palette remap needs to be performed for this file.

Definition at line 45 of file sprite_file.cpp.

References container_version, content_begin, GetGRFContainerVersion(), and RandomAccessFile::GetPos().

## Member Function Documentation

## ◆ GetContainerVersion()

byte SpriteFile::GetContainerVersion | ( |  | ) | const
| inline

Get the version number of container type used by the file.

Returns
  The version.

Definition at line 38 of file sprite_file_type.hpp.

References container_version.

Referenced by LoadGrfFile(), LoadGrfFileIndexed(), LoadNextSprite(), and ReadGRFSpriteOffsets().

## ◆ NeedsPaletteRemap()

bool SpriteFile::NeedsPaletteRemap | ( |  | ) | const
| inline

Whether a palette remap is needed when loading sprites from this file.

Returns
  True when needed, otherwise false.

Definition at line 32 of file sprite_file_type.hpp.

References palette_remap.

## ◆ SeekToBegin()

void SpriteFile::SeekToBegin | ( |  | ) |
| inline

Seek to the begin of the content, i.e.

the position just after the container version has been determined.

Definition at line 43 of file sprite_file_type.hpp.

References RandomAccessFile::SeekTo().

The documentation for this class was generated from the following files:

- src/spriteloader/sprite_file_type.hpp
- src/spriteloader/sprite_file.cpp