# gfxinit.cpp File Reference

`#include "stdafx.h"`
`#include "openttd.h"`
`#include "debug.h"`
`#include "gfxinit.h"`
`#include "spritecache.h"`
`#include "fileio.h"`
`#include "fios.h"`
`#include "newgrf.h"`
`#include "md5.h"`
`#include "variables.h"`
`#include "fontcache.h"`
`#include "gfx_func.h"`
`#include "core/alloc_func.hpp"`
`#include "core/bitmath_func.hpp"`
`#include <string.h>`
`#include "settings_type.h"`
`#include "table/sprites.h"`
`#include "table/files.h"`
`#include "table/landscape_sprite.h"`

Go to the source code of this file.

## Data Structures

struct | MD5File
struct | FileList

## Functions

static uint | LoadGrfFile (const char *filename, uint load_index, int file_index)
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)
static bool | FileMD5 (const MD5File file)
| Calculate and check the MD5 hash of the supplied filename.
static void | DeterminePalette ()
| Determine the palette that has to be used.
void | CheckExternalFiles ()
| Checks whether the MD5 checksums of the files are correct.
static void | LoadSpriteTables ()
void | GfxLoadSprites ()

## Variables

static const SpriteID *const | _landscape_spriteindexes []

## Detailed Description

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 163 of file gfxinit.cpp.

References DeterminePalette(), and FileMD5().

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

Determine the palette that has to be used.

- forced DOS palette via command line -> leave it that way
- all Windows files present -> Windows palette
- all DOS files present -> DOS palette
- no Windows files present and any DOS file present -> DOS palette
- otherwise -> Windows palette

Definition at line 135 of file gfxinit.cpp.

References FioCheckFileExists().

Referenced by CheckExternalFiles().

static bool FileMD5 | ( | const MD5File | file | ) | `[static]`

Calculate and check the MD5 hash of the supplied filename.

Parameters:

  | file | filename and expected MD5 hash for the given filename.

Returns:
  true if the checksum is correct.

Definition at line 102 of file gfxinit.cpp.

References DATA_DIR, FioFCloseFile(), and FioFOpenFile().

Referenced by CheckExternalFiles().

## Variable Documentation

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

Initial value:

     {
      _landscape_spriteindexes_1,
      _landscape_spriteindexes_2,
      _landscape_spriteindexes_3,
    }

Definition at line 39 of file gfxinit.cpp.