# 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 "settings_type.h"`
`#include "base_media_func.h"`
`#include "table/sprites.h"`
`#include "table/palette_convert.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)
static void | LoadSpritesIndexed (int file_index, uint *sprite_id, const SpriteID *index_tbl)
static void | LoadGrfIndexed (const char *filename, const SpriteID *index_tbl, int file_index)
void | CheckExternalFiles ()
| Checks whether the MD5 checksums of the files are correct.
static void | LoadSpriteTables ()
void | GfxLoadSprites ()
void | UpdateNewGRFConfigPalette ()
| Update the palettes of the graphics from the config file.
## Variables
PaletteType | _use_palette = PAL_AUTODETECT
| The currently used palette.
bool | _palette_remap_grf [MAX_FILE_SLOTS]
| Whether the given NewGRFs must get a palette remap or not.
const byte * | _palette_remap = NULL
| Palette map to go from the !_use_palette to the _use_palette.
const byte * | _palette_reverse_remap = NULL
| Palette map to go from the _use_palette to the !_use_palette.
static const SpriteID *const | _landscape_spriteindexes []
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 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 96 of file gfxinit.cpp.

References _use_palette, assert_compile(), MD5File::CheckMD5(), MD5File::CR_MATCH, MD5File::CR_MISMATCH, DATA_DIR, BaseGraphics::DeterminePalette(), MD5File::filename, BaseSet< T, Tnum_files, Tsubdir >::files, BaseSet< T, Tnum_files, Tsubdir >::GetNumInvalid(), BaseMedia< SoundsSet >::GetUsedSet(), BaseMedia< GraphicsSet >::GetUsedSet(), lastof, MD5File::missing_warning, BaseSet< T, Tnum_files, Tsubdir >::name, BaseSet< SoundsSet, 1, DATA_DIR >::NUM_FILES, BaseSet< GraphicsSet, MAX_GFT, DATA_DIR >::NUM_FILES, PAL_DOS, seprintf(), and ShowInfoF().

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

void UpdateNewGRFConfigPalette | ( |  | ) |

Update the palettes of the graphics from the config file.

This is needed because the config file gets read and parsed before the palette is chosen (one can configure the base graphics set governing the palette in the config after all). As a result of this we update the settings from the config once we have determined the palette.

Definition at line 38 of file newgrf_config.cpp.

References _use_palette, GRFConfig::next, and PAL_WINDOWS.

Referenced by BaseGraphics::DeterminePalette().

## Variable Documentation

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

Initial value:

     {
      _landscape_spriteindexes_1,
      _landscape_spriteindexes_2,
      _landscape_spriteindexes_3,
    }

Definition at line 38 of file gfxinit.cpp.

bool _palette_remap_grf[MAX_FILE_SLOTS]

Whether the given NewGRFs must get a palette remap or not.

Definition at line 30 of file gfxinit.cpp.