OpenTTD Source 20241224-master-gf74b0cf984
gfxinit.cpp File Reference

Initializing of the (GRF) graphics. More...

#include "stdafx.h"
#include "fios.h"
#include "newgrf.h"
#include "3rdparty/md5/md5.h"
#include "fontcache.h"
#include "gfx_func.h"
#include "transparency.h"
#include "blitter/factory.hpp"
#include "video/video_driver.hpp"
#include "window_func.h"
#include "palette_func.h"
#include "base_media_func.h"
#include "table/sprites.h"
#include "safeguards.h"
#include "table/landscape_sprite.h"

Go to the source code of this file.

Macros

#define SET_TYPE   "graphics"
 

Functions

static uint LoadGrfFile (const std::string &filename, SpriteID load_index, bool needs_palette_remap)
 Load an old fashioned GRF file.
 
static void LoadGrfFileIndexed (const std::string &filename, std::span< const std::pair< SpriteID, SpriteID > > index_tbl, bool needs_palette_remap)
 Load an old fashioned GRF file to replace already loaded sprites.
 
void CheckExternalFiles ()
 Checks whether the MD5 checksums of the files are correct.
 
static void LoadSpriteTables ()
 Actually load the sprite tables.
 
static void RealChangeBlitter (const std::string_view repl_blitter)
 
static bool SwitchNewGRFBlitter ()
 Check blitter needed by NewGRF config and switch if needed.
 
void CheckBlitter ()
 Check whether we still use the right blitter, or use another (better) one.
 
void GfxLoadSprites ()
 Initialise and load all the sprites.
 

Variables

static constexpr std::span< const std::pair< SpriteID, SpriteID > > _landscape_spriteindexes []
 Offsets for loading the different "replacement" sprites in the files.
 
static const char *const _graphics_file_names [] = { "base", "logos", "arctic", "tropical", "toyland", "extra" }
 Names corresponding to the GraphicsFileType.
 

Detailed Description

Initializing of the (GRF) graphics.

Definition in file gfxinit.cpp.

Macro Definition Documentation

◆ SET_TYPE

#define SET_TYPE   "graphics"

Definition at line 23 of file gfxinit.cpp.

Function Documentation

◆ CheckBlitter()

void CheckBlitter ( )

Check whether we still use the right blitter, or use another (better) one.

Definition at line 313 of file gfxinit.cpp.

References GfxClearSpriteCache(), ReInitAllWindows(), and SwitchNewGRFBlitter().

Referenced by MenuClickSettings(), and GameOptionsWindow::OnDropdownSelect().

◆ CheckExternalFiles()

◆ GfxLoadSprites()

◆ LoadGrfFile()

static uint LoadGrfFile ( const std::string &  filename,
SpriteID  load_index,
bool  needs_palette_remap 
)
static

Load an old fashioned GRF file.

Parameters
filenameThe name of the file to open.
load_indexThe offset of the first sprite.
needs_palette_remapWhether the colours in the GRF file need a palette remap.
Returns
The number of loaded sprites.

Definition at line 46 of file gfxinit.cpp.

References BASESET_DIR, Debug, SpriteFile::GetContainerVersion(), LoadNextSprite(), MAX_SPRITES, OpenCachedSpriteFile(), RandomAccessFile::ReadByte(), and ReadGRFSpriteOffsets().

Referenced by LoadSpriteTables().

◆ LoadGrfFileIndexed()

static void LoadGrfFileIndexed ( const std::string &  filename,
std::span< const std::pair< SpriteID, SpriteID > >  index_tbl,
bool  needs_palette_remap 
)
static

Load an old fashioned GRF file to replace already loaded sprites.

Parameters
filenameThe name of the file to open.
index_tblThe offsets of each of the sprites.
needs_palette_remapWhether the colours in the GRF file need a palette remap.
Returns
The number of loaded sprites.

Definition at line 83 of file gfxinit.cpp.

References BASESET_DIR, Debug, SpriteFile::GetContainerVersion(), LoadNextSprite(), OpenCachedSpriteFile(), RandomAccessFile::ReadByte(), and ReadGRFSpriteOffsets().

Referenced by LoadSpriteTables().

◆ LoadSpriteTables()

◆ RealChangeBlitter()

static void RealChangeBlitter ( const std::string_view  repl_blitter)
static

Definition at line 219 of file gfxinit.cpp.

◆ SwitchNewGRFBlitter()

static bool SwitchNewGRFBlitter ( )
static

Variable Documentation

◆ _graphics_file_names

const char* const _graphics_file_names[] = { "base", "logos", "arctic", "tropical", "toyland", "extra" }
static

Names corresponding to the GraphicsFileType.

Definition at line 459 of file gfxinit.cpp.

◆ _landscape_spriteindexes

constexpr std::span<const std::pair<SpriteID, SpriteID> > _landscape_spriteindexes[]
staticconstexpr
Initial value:
= {
_landscape_spriteindexes_arctic,
_landscape_spriteindexes_tropic,
_landscape_spriteindexes_toyland,
}

Offsets for loading the different "replacement" sprites in the files.

Definition at line 33 of file gfxinit.cpp.

Referenced by LoadSpriteTables().