Defines | Functions | Variables

# 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 "base_media_func.h"`
`#include "table/sprites.h"`
`#include "table/landscape_sprite.h"`

Go to the source code of this file.

## Defines
#define | SET_TYPE "graphics"
## Functions
static uint | LoadGrfFile (const char *filename, uint load_index, int file_index)
| Load an old fashioned GRF file.
static void | LoadGrfFileIndexed (const char *filename, const SpriteID *index_tbl, int file_index)
| 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 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
bool | _palette_remap_grf [MAX_FILE_SLOTS]
| Whether the given NewGRFs must get a palette remap from windows to DOS or not.
static const SpriteID *const | _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.

## Function Documentation

void CheckBlitter | ( |  | ) |

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

Definition at line 294 of file gfxinit.cpp.

References GfxClearSpriteCache(), and SwitchNewGRFBlitter().

Referenced by MenuClickSettings().

void CheckExternalFiles | ( |  | ) |

Checks whether the MD5 checksums of the files are correct.

Note:
  Also checks sample.cat and other required non-NewGRF GRFs for corruption.

Definition at line 118 of file gfxinit.cpp.

References BASESET_DIR, BaseSet< SoundsSet, 1, true >::CheckMD5(), GraphicsSet::CheckMD5(), MD5File::CR_MATCH, MD5File::CR_MISMATCH, DEBUG, MD5File::filename, BaseSet< T, Tnum_files, Tsearch_in_tars >::files, BaseSet< T, Tnum_files, Tsearch_in_tars >::GetNumInvalid(), BaseMedia< SoundsSet >::GetUsedSet(), BaseMedia< GraphicsSet >::GetUsedSet(), lastof, MD5File::missing_warning, BaseSet< T, Tnum_files, Tsearch_in_tars >::name, BaseSet< SoundsSet, 1, true >::NUM_FILES, BaseSet< GraphicsSet, MAX_GFT, true >::NUM_FILES, seprintf(), and ShowInfoF().

Referenced by BaseMedia< Tbase_set >::SetSet().

void GfxLoadSprites | ( |  | ) |

Initialise and load all the sprites.

Definition at line 303 of file gfxinit.cpp.

References _settings_game, DEBUG, GameSettings::game_creation, GameCreationSettings::landscape, LoadSpriteTables(), SwitchNewGRFBlitter(), and UpdateCursorSize().

Referenced by AfterLoadGame(), GenerateWorld(), and ReloadNewGRFData().

static uint LoadGrfFile | ( | const char * | filename,
|  | uint | load_index,
|  | int | file_index |
| ) |  |  | `[static]`

Load an old fashioned GRF file.

Parameters:

  | filename | The name of the file to open.
  | load_index | The offset of the first sprite.
  | file_index | The Fio offset to load the file in.

Returns:
  The number of loaded sprites.

Definition at line 47 of file gfxinit.cpp.

References BASESET_DIR, DEBUG, FioOpenFile(), FioReadByte(), GetGRFContainerVersion(), LoadNextSprite(), MAX_SPRITES, ReadGRFSpriteOffsets(), and usererror().

Referenced by LoadSpriteTables().

static void LoadGrfFileIndexed | ( | const char * | filename,
|  | const SpriteID * | index_tbl,
|  | int | file_index |
| ) |  |  | `[static]`

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

Parameters:

  | filename | The name of the file to open.
  | index_tlb | The offsets of each of the sprites.
  | file_index | The Fio offset to load the file in.

Returns:
  The number of loaded sprites.

Definition at line 84 of file gfxinit.cpp.

References BASESET_DIR, DEBUG, FioOpenFile(), FioReadByte(), GetGRFContainerVersion(), LoadNextSprite(), ReadGRFSpriteOffsets(), and usererror().

Referenced by LoadSpriteTables().

static void LoadSpriteTables | ( |  | ) | `[static]`

Actually load the sprite tables.

Definition at line 161 of file gfxinit.cpp.

References _grfconfig, _landscape_spriteindexes, _palette_remap_grf, _settings_game, BASESET_DIR, ClrBit(), MD5File::filename, BaseSet< T, Tnum_files, Tsearch_in_tars >::files, FillGRFDetails(), GRFConfig::flags, GameSettings::game_creation, GCF_INIT_ONLY, BaseMedia< GraphicsSet >::GetUsedSet(), GFT_ARCTIC, GFT_BASE, GFT_EXTRA, GFT_LOGOS, InitializeUnicodeGlyphMap(), GameCreationSettings::landscape, LoadGrfFile(), LoadGrfFileIndexed(), LoadNewGRF(), GRFConfig::next, PAL_DOS, PAL_WINDOWS, GRFConfig::palette, and GraphicsSet::palette.

Referenced by GfxLoadSprites().

static bool SwitchNewGRFBlitter | ( |  | ) | `[static]`

Check blitter needed by NewGRF config and switch if needed.

Returns:
  False when nothing changed, true otherwise.

< 0: no support, 1: do support, 2: both

Definition at line 231 of file gfxinit.cpp.

References _blitter_autodetected, _display_opt, _grfconfig, GraphicsSet::blitter, BLT_32BPP, DEBUG, DO_FULL_ANIMATION, GCF_INIT_ONLY, GCS_DISABLED, GCS_NOT_FOUND, BlitterFactory::GetBlitterFactory(), BlitterFactory::GetCurrentBlitter(), VideoDriver::GetInstance(), Blitter::GetName(), BaseMedia< GraphicsSet >::GetUsedSet(), GRFP_BLT_32BPP, HasBit(), IsInsideMM(), lengthof, GRFConfig::next, BlitterFactory::SelectBlitter(), and usererror().

Referenced by CheckBlitter(), and GfxLoadSprites().

## Variable Documentation

const SpriteID* const _landscape_spriteindexes[]`[static]`

Initial value:

     {
      _landscape_spriteindexes_arctic,
      _landscape_spriteindexes_tropic,
      _landscape_spriteindexes_toyland,
    }

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

Definition at line 34 of file gfxinit.cpp.

Referenced by LoadSpriteTables().

bool _palette_remap_grf[MAX_FILE_SLOTS]

Whether the given NewGRFs must get a palette remap from windows to DOS or not.

Definition at line 29 of file gfxinit.cpp.

Referenced by DecodeSingleSprite(), LoadNewGRFFile(), LoadSpriteTables(), and ReadRecolourSprite().