OpenTTD Source: src/base_media_base.h File Reference

OpenTTD Source 14.0-beta1

Data Structures | Enumerations | Functions | Variables
base_media_base.h File Reference
`#include "fileio_func.h"`
`#include "gfx_type.h"`
`#include "textfile_type.h"`
`#include "textfile_gui.h"`
`#include "3rdparty/md5/md5.h"`
`#include <unordered_map>`

Go to the source code of this file.

## Data Structures
struct | MD5File
| Structure holding filename and MD5 information about a single file. More...
struct | BaseSet< T, Tnum_files, Tsearch_in_tars >
| Information about a single base set. More...
class | BaseMedia< Tbase_set >
| Base for all base media (graphics, sounds) More...
struct | GraphicsSet
| All data of a graphics set. More...
class | BaseGraphics
| All data/functions related with replacing the base graphics. More...
struct | BaseGraphics::Ini
| Values loaded from config file. More...
struct | SoundsSet
| All data of a sounds set. More...
class | BaseSounds
| All data/functions related with replacing the base sounds. More...
struct | MusicSongInfo
| Metadata about a music track. More...
struct | MusicSet
| All data of a music set. More...
class | BaseMusic
| All data/functions related with replacing the base music. More...

## Enumerations
enum | GraphicsFileType { GFT_BASE, GFT_LOGOS, GFT_ARCTIC, GFT_TROPICAL, GFT_TOYLAND, GFT_EXTRA, MAX_GFT }
| Types of graphics in the base graphics set. More...
enum | BlitterType { BLT_8BPP, BLT_32BPP }
| Blitter type for base graphics sets. More...
enum | MusicTrackType { MTT_STANDARDMIDI, MTT_MPSMIDI }

## Functions
template<class Tbase_set >
const char * | TryGetBaseSetFile (const ContentInfo *ci, bool md5sum, const Tbase_set *s)
| Check whether there's a base set matching some information. More...
char * | GetMusicCatEntryName (const std::string &filename, size_t entrynum)
| Read the name of a music CAT file entry. More...
byte * | GetMusicCatEntryData (const std::string &filename, size_t entrynum, size_t &entrylen)
| Read the full data of a music CAT file entry. More...

## Variables
static const uint | NUM_SONGS_CLASS = 10
| Maximum number of songs in the 'class' playlists.
static const uint | NUM_SONG_CLASSES = 3
| Number of classes for songs.
static const uint | NUM_SONGS_AVAILABLE = 1 + NUM_SONG_CLASSES * NUM_SONGS_CLASS
| Maximum number of songs in the full playlist; theme song + the classes.
static const uint | NUM_SONGS_PLAYLIST = 32
| Maximum number of songs in the (custom) playlist.

## Detailed Description

Generic functions for replacing base data (graphics, sounds).

Definition in file base_media_base.h.

## Enumeration Type Documentation

## ◆ BlitterType

enum BlitterType

Blitter type for base graphics sets.

Enumerator
BLT_8BPP | Base set has 8 bpp sprites only.
BLT_32BPP | Base set has both 8 bpp and 32 bpp sprites.

Definition at line 252 of file base_media_base.h.

## ◆ GraphicsFileType

enum GraphicsFileType

Types of graphics in the base graphics set.

Enumerator
GFT_BASE | Base sprites for all climates.
GFT_LOGOS | Logos, landscape icons and original terrain generator sprites.
GFT_ARCTIC | Landscape replacement sprites for arctic.
GFT_TROPICAL | Landscape replacement sprites for tropical.
GFT_TOYLAND | Landscape replacement sprites for toyland.
GFT_EXTRA | Extra sprites that were not part of the original sprites.
MAX_GFT | We are looking for this amount of GRFs.

Definition at line 241 of file base_media_base.h.

## ◆ MusicTrackType

enum MusicTrackType

Enumerator
MTT_STANDARDMIDI | Standard MIDI file.
MTT_MPSMIDI | MPS GM driver MIDI format (contained in a CAT file)

Definition at line 319 of file base_media_base.h.

## Function Documentation

## ◆ GetMusicCatEntryData()

byte* GetMusicCatEntryData | ( | const std::string & | filename,
|  | size_t | entrynum,
|  | size_t & | entrylen
| ) |  |

Read the full data of a music CAT file entry.

Parameters

  | filename | Name of CAT file to read from.
  | entrynum | Index of entry to read
  [out] | entrylen | Receives length of data read

Returns
  Pointer to buffer with data read, caller is responsible for freeind memory, nullptr if entrynum does not exist.

Definition at line 55 of file music.cpp.

References BASESET_DIR, FioCheckFileExists(), RandomAccessFile::ReadBlock(), RandomAccessFile::ReadByte(), RandomAccessFile::ReadDword(), RandomAccessFile::SeekTo(), and RandomAccessFile::SkipBytes().

## ◆ GetMusicCatEntryName()

char* GetMusicCatEntryName | ( | const std::string & | filename,
|  | size_t | entrynum
| ) |  |

Read the name of a music CAT file entry.

Parameters

  filename | Name of CAT file to read from
  entrynum | Index of entry whose name to read

Returns
  Pointer to string, caller is responsible for freeing memory, nullptr if entrynum does not exist.

Definition at line 28 of file music.cpp.

References BASESET_DIR, FioCheckFileExists(), RandomAccessFile::ReadBlock(), RandomAccessFile::ReadByte(), RandomAccessFile::ReadDword(), and RandomAccessFile::SeekTo().

## ◆ TryGetBaseSetFile()

template<class Tbase_set >

const char* TryGetBaseSetFile | ( | const ContentInfo * | ci,
|  | bool | md5sum,
|  | const Tbase_set * | s
| ) |  |

Check whether there's a base set matching some information.

Parameters

  ci | The content info to compare it to.
  md5sum | Should the MD5 checksum be tested as well?
  s | The list with sets.

Returns
  The filename of the first file of the base set, or `nullptr` if there is no match.

Definition at line 319 of file base_media_func.h.

References ContentInfo::md5sum, and ContentInfo::unique_id.

Referenced by BaseMedia< GraphicsSet >::HasSet().