OpenTTD
gfxinit.cpp
Go to the documentation of this file.
1 /* $Id: gfxinit.cpp 27775 2017-03-11 13:05:54Z frosch $ */
2 
3 /*
4  * This file is part of OpenTTD.
5  * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
6  * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
7  * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
8  */
9 
12 #include "stdafx.h"
13 #include "fios.h"
14 #include "newgrf.h"
15 #include "3rdparty/md5/md5.h"
16 #include "fontcache.h"
17 #include "gfx_func.h"
18 #include "transparency.h"
19 #include "blitter/factory.hpp"
20 #include "video/video_driver.hpp"
21 #include "window_func.h"
22 
23 /* The type of set we're replacing */
24 #define SET_TYPE "graphics"
25 #include "base_media_func.h"
26 
27 #include "table/sprites.h"
28 
29 #include "safeguards.h"
30 
33 
34 #include "table/landscape_sprite.h"
35 
37 static const SpriteID * const _landscape_spriteindexes[] = {
38  _landscape_spriteindexes_arctic,
39  _landscape_spriteindexes_tropic,
40  _landscape_spriteindexes_toyland,
41 };
42 
50 static uint LoadGrfFile(const char *filename, uint load_index, int file_index)
51 {
52  uint load_index_org = load_index;
53  uint sprite_id = 0;
54 
55  FioOpenFile(file_index, filename, BASESET_DIR);
56 
57  DEBUG(sprite, 2, "Reading grf-file '%s'", filename);
58 
59  byte container_ver = GetGRFContainerVersion();
60  if (container_ver == 0) usererror("Base grf '%s' is corrupt", filename);
61  ReadGRFSpriteOffsets(container_ver);
62  if (container_ver >= 2) {
63  /* Read compression. */
64  byte compression = FioReadByte();
65  if (compression != 0) usererror("Unsupported compression format");
66  }
67 
68  while (LoadNextSprite(load_index, file_index, sprite_id, container_ver)) {
69  load_index++;
70  sprite_id++;
71  if (load_index >= MAX_SPRITES) {
72  usererror("Too many sprites. Recompile with higher MAX_SPRITES value or remove some custom GRF files.");
73  }
74  }
75  DEBUG(sprite, 2, "Currently %i sprites are loaded", load_index);
76 
77  return load_index - load_index_org;
78 }
79 
87 static void LoadGrfFileIndexed(const char *filename, const SpriteID *index_tbl, int file_index)
88 {
89  uint start;
90  uint sprite_id = 0;
91 
92  FioOpenFile(file_index, filename, BASESET_DIR);
93 
94  DEBUG(sprite, 2, "Reading indexed grf-file '%s'", filename);
95 
96  byte container_ver = GetGRFContainerVersion();
97  if (container_ver == 0) usererror("Base grf '%s' is corrupt", filename);
98  ReadGRFSpriteOffsets(container_ver);
99  if (container_ver >= 2) {
100  /* Read compression. */
101  byte compression = FioReadByte();
102  if (compression != 0) usererror("Unsupported compression format");
103  }
104 
105  while ((start = *index_tbl++) != END) {
106  uint end = *index_tbl++;
107 
108  do {
109  bool b = LoadNextSprite(start, file_index, sprite_id, container_ver);
110  assert(b);
111  sprite_id++;
112  } while (++start <= end);
113  }
114 }
115 
122 {
123  if (BaseGraphics::GetUsedSet() == NULL || BaseSounds::GetUsedSet() == NULL) return;
124 
125  const GraphicsSet *used_set = BaseGraphics::GetUsedSet();
126 
127  DEBUG(grf, 1, "Using the %s base graphics set", used_set->name);
128 
129  static const size_t ERROR_MESSAGE_LENGTH = 256;
130  static const size_t MISSING_FILE_MESSAGE_LENGTH = 128;
131 
132  /* Allocate for a message for each missing file and for one error
133  * message per set.
134  */
135  char error_msg[MISSING_FILE_MESSAGE_LENGTH * (GraphicsSet::NUM_FILES + SoundsSet::NUM_FILES) + 2 * ERROR_MESSAGE_LENGTH];
136  error_msg[0] = '\0';
137  char *add_pos = error_msg;
138  const char *last = lastof(error_msg);
139 
140  if (used_set->GetNumInvalid() != 0) {
141  /* Not all files were loaded successfully, see which ones */
142  add_pos += seprintf(add_pos, last, "Trying to load graphics set '%s', but it is incomplete. The game will probably not run correctly until you properly install this set or select another one. See section 4.1 of readme.txt.\n\nThe following files are corrupted or missing:\n", used_set->name);
143  for (uint i = 0; i < GraphicsSet::NUM_FILES; i++) {
145  if (res != MD5File::CR_MATCH) add_pos += seprintf(add_pos, last, "\t%s is %s (%s)\n", used_set->files[i].filename, res == MD5File::CR_MISMATCH ? "corrupt" : "missing", used_set->files[i].missing_warning);
146  }
147  add_pos += seprintf(add_pos, last, "\n");
148  }
149 
150  const SoundsSet *sounds_set = BaseSounds::GetUsedSet();
151  if (sounds_set->GetNumInvalid() != 0) {
152  add_pos += seprintf(add_pos, last, "Trying to load sound set '%s', but it is incomplete. The game will probably not run correctly until you properly install this set or select another one. See section 4.1 of readme.txt.\n\nThe following files are corrupted or missing:\n", sounds_set->name);
153 
154  assert_compile(SoundsSet::NUM_FILES == 1);
155  /* No need to loop each file, as long as there is only a single
156  * sound file. */
157  add_pos += seprintf(add_pos, last, "\t%s is %s (%s)\n", sounds_set->files->filename, SoundsSet::CheckMD5(sounds_set->files, BASESET_DIR) == MD5File::CR_MISMATCH ? "corrupt" : "missing", sounds_set->files->missing_warning);
158  }
159 
160  if (add_pos != error_msg) ShowInfoF("%s", error_msg);
161 }
162 
164 static void LoadSpriteTables()
165 {
166  memset(_palette_remap_grf, 0, sizeof(_palette_remap_grf));
167  uint i = FIRST_GRF_SLOT;
168  const GraphicsSet *used_set = BaseGraphics::GetUsedSet();
169 
170  _palette_remap_grf[i] = (PAL_DOS != used_set->palette);
171  LoadGrfFile(used_set->files[GFT_BASE].filename, 0, i++);
172 
173  /*
174  * The second basic file always starts at the given location and does
175  * contain a different amount of sprites depending on the "type"; DOS
176  * has a few sprites less. However, we do not care about those missing
177  * sprites as they are not shown anyway (logos in intro game).
178  */
179  _palette_remap_grf[i] = (PAL_DOS != used_set->palette);
180  LoadGrfFile(used_set->files[GFT_LOGOS].filename, 4793, i++);
181 
182  /*
183  * Load additional sprites for climates other than temperate.
184  * This overwrites some of the temperate sprites, such as foundations
185  * and the ground sprites.
186  */
187  if (_settings_game.game_creation.landscape != LT_TEMPERATE) {
188  _palette_remap_grf[i] = (PAL_DOS != used_set->palette);
192  i++
193  );
194  }
195 
196  /* Initialize the unicode to sprite mapping table */
198 
199  /*
200  * Load the base and extra NewGRF with OTTD required graphics as first NewGRF.
201  * However, we do not want it to show up in the list of used NewGRFs,
202  * so we have to manually add it, and then remove it later.
203  */
204  GRFConfig *top = _grfconfig;
205 
206  /* Default extra graphics */
207  GRFConfig *master = new GRFConfig("OPENTTD.GRF");
208  master->palette |= GRFP_GRF_DOS;
209  FillGRFDetails(master, false, BASESET_DIR);
210  ClrBit(master->flags, GCF_INIT_ONLY);
211 
212  /* Baseset extra graphics */
213  GRFConfig *extra = new GRFConfig(used_set->files[GFT_EXTRA].filename);
214 
215  /* We know the palette of the base set, so if the base NewGRF is not
216  * setting one, use the palette of the base set and not the global
217  * one which might be the wrong palette for this base NewGRF.
218  * The value set here might be overridden via action14 later. */
219  switch (used_set->palette) {
220  case PAL_DOS: extra->palette |= GRFP_GRF_DOS; break;
221  case PAL_WINDOWS: extra->palette |= GRFP_GRF_WINDOWS; break;
222  default: break;
223  }
224  FillGRFDetails(extra, false, BASESET_DIR);
225  ClrBit(extra->flags, GCF_INIT_ONLY);
226 
227  extra->next = top;
228  master->next = extra;
229  _grfconfig = master;
230 
231  LoadNewGRF(SPR_NEWGRFS_BASE, i, 2);
232 
233  uint total_extra_graphics = SPR_NEWGRFS_BASE - SPR_OPENTTD_BASE;
234  _missing_extra_graphics = GetSpriteCountForSlot(i, SPR_OPENTTD_BASE, SPR_NEWGRFS_BASE);
235  DEBUG(sprite, 1, "%u extra sprites, %u from baseset, %u from fallback", total_extra_graphics, total_extra_graphics - _missing_extra_graphics, _missing_extra_graphics);
236 
237  /* The original baseset extra graphics intentionally make use of the fallback graphics.
238  * Let's say everything which provides less than 500 sprites misses the rest intentionally. */
239  if (500 + _missing_extra_graphics > total_extra_graphics) _missing_extra_graphics = 0;
240 
241  /* Free and remove the top element. */
242  delete extra;
243  delete master;
244  _grfconfig = top;
245 }
246 
247 
252 static bool SwitchNewGRFBlitter()
253 {
254  /* Never switch if the blitter was specified by the user. */
255  if (!_blitter_autodetected) return false;
256 
257  /* Null driver => dedicated server => do nothing. */
258  if (BlitterFactory::GetCurrentBlitter()->GetScreenDepth() == 0) return false;
259 
260  /* Get preferred depth.
261  * - depth_wanted_by_base: Depth required by the baseset, i.e. the majority of the sprites.
262  * - depth_wanted_by_grf: Depth required by some NewGRF.
263  * Both can force using a 32bpp blitter. depth_wanted_by_base is used to select
264  * between multiple 32bpp blitters, which perform differently with 8bpp sprites.
265  */
266  uint depth_wanted_by_base = BaseGraphics::GetUsedSet()->blitter == BLT_32BPP ? 32 : 8;
267  uint depth_wanted_by_grf = _support8bpp == S8BPP_NONE ? 32 : 8;
268  for (GRFConfig *c = _grfconfig; c != NULL; c = c->next) {
269  if (c->status == GCS_DISABLED || c->status == GCS_NOT_FOUND || HasBit(c->flags, GCF_INIT_ONLY)) continue;
270  if (c->palette & GRFP_BLT_32BPP) depth_wanted_by_grf = 32;
271  }
272 
273  /* Search the best blitter. */
274  static const struct {
275  const char *name;
276  uint animation;
277  uint min_base_depth, max_base_depth, min_grf_depth, max_grf_depth;
278  } replacement_blitters[] = {
279 #ifdef WITH_SSE
280  { "32bpp-sse4", 0, 32, 32, 8, 32 },
281  { "32bpp-ssse3", 0, 32, 32, 8, 32 },
282  { "32bpp-sse2", 0, 32, 32, 8, 32 },
283  { "32bpp-sse4-anim", 1, 32, 32, 8, 32 },
284 #endif
285  { "8bpp-optimized", 2, 8, 8, 8, 8 },
286  { "32bpp-optimized", 0, 8, 32, 8, 32 },
287  { "32bpp-anim", 1, 8, 32, 8, 32 },
288  };
289 
290  const bool animation_wanted = HasBit(_display_opt, DO_FULL_ANIMATION);
291  const char *cur_blitter = BlitterFactory::GetCurrentBlitter()->GetName();
292 
294 
295  for (uint i = 0; i < lengthof(replacement_blitters); i++) {
296  if (animation_wanted && (replacement_blitters[i].animation == 0)) continue;
297  if (!animation_wanted && (replacement_blitters[i].animation == 1)) continue;
298 
299  if (!IsInsideMM(depth_wanted_by_base, replacement_blitters[i].min_base_depth, replacement_blitters[i].max_base_depth + 1)) continue;
300  if (!IsInsideMM(depth_wanted_by_grf, replacement_blitters[i].min_grf_depth, replacement_blitters[i].max_grf_depth + 1)) continue;
301  const char *repl_blitter = replacement_blitters[i].name;
302 
303  if (strcmp(repl_blitter, cur_blitter) == 0) {
305  return false;
306  }
307  if (BlitterFactory::GetBlitterFactory(repl_blitter) == NULL) continue;
308 
309  DEBUG(misc, 1, "Switching blitter from '%s' to '%s'... ", cur_blitter, repl_blitter);
310  Blitter *new_blitter = BlitterFactory::SelectBlitter(repl_blitter);
311  if (new_blitter == NULL) NOT_REACHED();
312  DEBUG(misc, 1, "Successfully switched to %s.", repl_blitter);
313  break;
314  }
315 
316  if (!VideoDriver::GetInstance()->AfterBlitterChange()) {
317  /* Failed to switch blitter, let's hope we can return to the old one. */
318  if (BlitterFactory::SelectBlitter(cur_blitter) == NULL || !VideoDriver::GetInstance()->AfterBlitterChange()) usererror("Failed to reinitialize video driver. Specify a fixed blitter in the config");
319  }
320 
322 
323  return true;
324 }
325 
328 {
329  if (!SwitchNewGRFBlitter()) return;
330 
331  ClearFontCache();
334 }
335 
338 {
339  DEBUG(sprite, 2, "Loading sprite set %d", _settings_game.game_creation.landscape);
340 
342  ClearFontCache();
343  GfxInitSpriteMem();
345  GfxInitPalettes();
346 
348 }
349 
350 bool GraphicsSet::FillSetDetails(IniFile *ini, const char *path, const char *full_filename)
351 {
352  bool ret = this->BaseSet<GraphicsSet, MAX_GFT, true>::FillSetDetails(ini, path, full_filename, false);
353  if (ret) {
354  IniGroup *metadata = ini->GetGroup("metadata");
355  IniItem *item;
356 
357  fetch_metadata("palette");
358  this->palette = (*item->value == 'D' || *item->value == 'd') ? PAL_DOS : PAL_WINDOWS;
359 
360  /* Get optional blitter information. */
361  item = metadata->GetItem("blitter", false);
362  this->blitter = (item != NULL && *item->value == '3') ? BLT_32BPP : BLT_8BPP;
363  }
364  return ret;
365 }
366 
377 {
378  size_t size = 0;
379  FILE *f = FioFOpenFile(file->filename, "rb", subdir, &size);
380  if (f == NULL) return MD5File::CR_NO_FILE;
381 
382  size_t max = GRFGetSizeOfDataSection(f);
383 
384  FioFCloseFile(f);
385 
386  return file->CheckMD5(subdir, max);
387 }
388 
389 
400 {
401  size_t size;
402  FILE *f = FioFOpenFile(this->filename, "rb", subdir, &size);
403 
404  if (f == NULL) return CR_NO_FILE;
405 
406  size = min(size, max_size);
407 
408  Md5 checksum;
409  uint8 buffer[1024];
410  uint8 digest[16];
411  size_t len;
412 
413  while ((len = fread(buffer, 1, (size > sizeof(buffer)) ? sizeof(buffer) : size, f)) != 0 && size != 0) {
414  size -= len;
415  checksum.Append(buffer, len);
416  }
417 
418  FioFCloseFile(f);
419 
420  checksum.Finish(digest);
421  return memcmp(this->hash, digest, sizeof(this->hash)) == 0 ? CR_MATCH : CR_MISMATCH;
422 }
423 
425 static const char * const _graphics_file_names[] = { "base", "logos", "arctic", "tropical", "toyland", "extra" };
426 
428 template <class T, size_t Tnum_files, bool Tsearch_in_tars>
430 
431 template <class Tbase_set>
433 {
434  if (BaseMedia<Tbase_set>::used_set != NULL) return true;
435 
436  const Tbase_set *best = NULL;
437  for (const Tbase_set *c = BaseMedia<Tbase_set>::available_sets; c != NULL; c = c->next) {
438  /* Skip unusable sets */
439  if (c->GetNumMissing() != 0) continue;
440 
441  if (best == NULL ||
442  (best->fallback && !c->fallback) ||
443  best->valid_files < c->valid_files ||
444  (best->valid_files == c->valid_files && (
445  (best->shortname == c->shortname && best->version < c->version) ||
446  (best->palette != PAL_DOS && c->palette == PAL_DOS)))) {
447  best = c;
448  }
449  }
450 
452  return BaseMedia<Tbase_set>::used_set != NULL;
453 }
454 
455 template <class Tbase_set>
456 /* static */ const char *BaseMedia<Tbase_set>::GetExtension()
457 {
458  return ".obg"; // OpenTTD Base Graphics
459 }
460 
First slot usable for (New)GRFs used during the game.
Definition: fios.h:92
A group within an ini file.
Definition: ini_type.h:38
GameSettings _settings_game
Game settings of a running game or the scenario editor.
Definition: settings.cpp:77
Base of all video drivers.
bool _blitter_autodetected
Was the blitter autodetected or specified by the user?
Definition: driver.cpp:32
GRFConfig * _grfconfig
First item in list of current GRF set up.
byte landscape
the landscape we&#39;re currently in
Subdirectory
The different kinds of subdirectories OpenTTD uses.
Definition: fileio_type.h:110
Generic function implementations for base data (graphics, sounds).
size_t GRFGetSizeOfDataSection(FILE *f)
Get the data section size of a GRF.
void FioFCloseFile(FILE *f)
Close a file in a safe way.
Definition: fileio.cpp:342
GRF file is processed up to GLS_INIT.
Definition: newgrf_config.h:29
byte _display_opt
What do we want to draw/do?
virtual void ReleaseBlitterLock()
Release any lock(s) required to be held when changing blitters.
static bool IsInsideMM(const T x, const uint min, const uint max)
Checks if a value is in an interval.
Definition: math_func.hpp:266
int CDECL seprintf(char *str, const char *last, const char *format,...)
Safer implementation of snprintf; same as snprintf except:
Definition: string.cpp:398
Structure holding filename and MD5 information about a single file.
int GetNumInvalid() const
Get the number of invalid files.
The file did not exist.
static const char * GetExtension()
Get the extension that is used to identify this set.
Definition: gfxinit.cpp:456
The NewGRF prefers a 32 bpp blitter.
Definition: newgrf_config.h:78
uint _missing_extra_graphics
Number of sprites provided by the fallback extra GRF, i.e. missing in the baseset.
static bool SwitchNewGRFBlitter()
Check blitter needed by NewGRF config and switch if needed.
Definition: gfxinit.cpp:252
void CheckExternalFiles()
Checks whether the MD5 checksums of the files are correct.
Definition: gfxinit.cpp:121
Use the Windows palette.
Definition: gfx_type.h:291
static void LoadSpriteTables()
Actually load the sprite tables.
Definition: gfxinit.cpp:164
Base set has both 8 bpp and 32 bpp sprites.
PaletteType palette
Palette of this graphics set.
Maximum number of slots.
Definition: fios.h:94
Use the DOS palette.
Definition: gfx_type.h:290
Maximum number of sprites that can be loaded at a given time.
Definition: sprites.h:1518
#define lastof(x)
Get the last element of an fixed size array.
Definition: depend.cpp:50
IniGroup * GetGroup(const char *name, size_t len=0, bool create_new=true)
Get the group with the given name.
Definition: ini_load.cpp:156
GRF file was not found in the local cache.
Definition: newgrf_config.h:38
MD5File files[NUM_FILES]
All files part of this set.
How all blitters should look like.
Definition: base.hpp:30
Base set has 8 bpp sprites only.
void LoadNewGRF(uint load_index, uint file_index, uint num_baseset)
Load all the NewGRFs.
Definition: newgrf.cpp:9228
Subdirectory for all base data (base sets, intro game)
Definition: fileio_type.h:118
static T max(const T a, const T b)
Returns the maximum of two values.
Definition: math_func.hpp:26
byte FioReadByte()
Read a byte from the file.
Definition: fileio.cpp:133
static void InitializeUnicodeGlyphMap()
Initialize the glyph map.
Definition: fontcache.h:161
virtual const char * GetName()=0
Get the name of the blitter, the same as the Factory-instance returns.
static const char *const _graphics_file_names[]
Names corresponding to the GraphicsFileType.
Definition: gfxinit.cpp:425
GRF file is disabled.
Definition: newgrf_config.h:37
struct GRFConfig * next
NOSAVE: Next item in the linked list.
Base sprites for all climates.
The file did exist, just the md5 checksum did not match.
A single "line" in an ini file.
Definition: ini_type.h:25
const char * missing_warning
warning when this file is missing
Landscape replacement sprites for arctic.
void CDECL ShowInfoF(const char *str,...)
Shows some information on the console/a popup box depending on the OS.
Definition: openttd.cpp:130
bool FillGRFDetails(GRFConfig *config, bool is_static, Subdirectory subdir)
Find the GRFID of a given grf, and calculate its md5sum.
Functions to read fonts from files and cache them.
void ReadGRFSpriteOffsets(byte container_version)
Parse the sprite section of GRFs.
const char * filename
filename
Information about GRF, used in the game and (part of it) in savegames.
static Blitter * SelectBlitter(const char *name)
Find the requested blitter and return his class.
Definition: factory.hpp:96
const char * name
The name of the base set.
Functions related to the gfx engine.
static uint LoadGrfFile(const char *filename, uint load_index, int file_index)
Load an old fashioned GRF file.
Definition: gfxinit.cpp:50
FILE * FioFOpenFile(const char *filename, const char *mode, Subdirectory subdir, size_t *filesize)
Opens a OpenTTD file somewhere in a personal or global directory.
Definition: fileio.cpp:474
Definition of base types and functions in a cross-platform compatible way.
Extra sprites that were not part of the original sprites.
void CDECL usererror(const char *s,...)
Error handling for fatal user errors.
Definition: openttd.cpp:90
A number of safeguards to prevent using unsafe methods.
Offsets of sprites to replace for non-temperate landscapes.
uint8 flags
NOSAVE: GCF_Flags, bitset.
char * value
The value of this item.
Definition: ini_type.h:28
virtual void AcquireBlitterLock()
Acquire any lock(s) required to be held when changing blitters.
#define lengthof(x)
Return the length of an fixed size array.
Definition: depend.cpp:42
void GfxClearSpriteCache()
Remove all encoded sprites from the sprite cache without discarding sprite location information...
static Blitter * GetCurrentBlitter()
Get the current active blitter (always set by calling SelectBlitter).
Definition: factory.hpp:147
#define fetch_metadata(name)
Try to read a single piece of metadata and return false if it doesn&#39;t exist.
static T min(const T a, const T b)
Returns the minimum of two values.
Definition: math_func.hpp:42
BlitterType blitter
Blitter of this graphics set.
Base for all base media (graphics, sounds)
ChecksumResult CheckMD5(Subdirectory subdir, size_t max_size) const
Calculate and check the MD5 hash of the supplied filename.
Definition: gfxinit.cpp:399
#define DEBUG(name, level,...)
Output a line of debugging information.
Definition: debug.h:39
void FioOpenFile(int slot, const char *filename, Subdirectory subdir)
Open a slotted file.
Definition: fileio.cpp:250
The NewGRF says the Windows palette can be used.
Definition: newgrf_config.h:73
No support for 8bpp by OS or hardware, force 32bpp blitters.
Definition: gfx_type.h:317
void ReInitAllWindows()
Re-initialize all windows.
Definition: window.cpp:3344
Ini file that supports both loading and saving.
Definition: ini_type.h:88
static T ClrBit(T &x, const uint8 y)
Clears a bit in a variable.
uint32 SpriteID
The number of a sprite, without mapping bits and colourtables.
Definition: gfx_type.h:19
void UpdateCursorSize()
Update cursor dimension.
Definition: gfx.cpp:1530
Declarations for savegames operations.
The file did exist and the md5 checksum did match.
uint8 palette
GRFPalette, bitset.
static VideoDriver * GetInstance()
Get the currently active instance of the video driver.
Functions related to transparency.
bool FillSetDetails(IniFile *ini, const char *path, const char *full_filename, bool allow_empty_filename=true)
Read the set information from a loaded ini.
All data of a sounds set.
#define INSTANTIATE_BASE_MEDIA_METHODS(repl_type, set_type)
Force instantiation of methods so we don&#39;t get linker errors.
All data of a graphics set.
ChecksumResult
The result of a checksum check.
IniItem * GetItem(const char *name, bool create)
Get the item with the given name, and if it doesn&#39;t exist and create is true it creates a new item...
Definition: ini_load.cpp:105
bool LoadNextSprite(int load_index, byte file_slot, uint file_sprite_id, byte container_version)
Load a real or recolour sprite.
static const SpriteID SPR_OPENTTD_BASE
Extra graphic spritenumbers.
Definition: sprites.h:58
static void LoadGrfFileIndexed(const char *filename, const SpriteID *index_tbl, int file_index)
Load an old fashioned GRF file to replace already loaded sprites.
Definition: gfxinit.cpp:87
Information about a single base set.
uint GetSpriteCountForSlot(uint file_slot, SpriteID begin, SpriteID end)
Count the sprites which originate from a specific file slot in a range of SpriteIDs.
The NewGRF says the DOS palette can be used.
Definition: newgrf_config.h:72
byte GetGRFContainerVersion()
Get the container version of the currently opened GRF file.
Definition: newgrf.cpp:8837
Perform palette animation.
Definition: openttd.h:46
static const SpriteID *const _landscape_spriteindexes[]
Offsets for loading the different "replacement" sprites in the files.
Definition: gfxinit.cpp:37
static BlitterFactory * GetBlitterFactory(const char *name)
Get the blitter factory with the given name.
Definition: factory.hpp:114
static bool HasBit(const T x, const uint8 y)
Checks if a bit in a value is set.
Logos, landscape icons and original terrain generator sprites.
static MD5File::ChecksumResult CheckMD5(const MD5File *file, Subdirectory subdir)
Calculate and check the MD5 hash of the supplied file.
GameCreationSettings game_creation
settings used during the creation of a game (map)
Window functions not directly related to making/drawing windows.
bool _palette_remap_grf[MAX_FILE_SLOTS]
Whether the given NewGRFs must get a palette remap from windows to DOS or not.
Definition: gfxinit.cpp:32
void CheckBlitter()
Check whether we still use the right blitter, or use another (better) one.
Definition: gfxinit.cpp:327
This file contains all sprite-related enums and defines.
Factory to &#39;query&#39; all available blitters.
static const GraphicsSet * GetUsedSet()
Return the used set.
static bool DetermineBestSet()
Determine the graphics pack that has to be used.
Definition: gfxinit.cpp:432
static MD5File::ChecksumResult CheckMD5(const MD5File *file, Subdirectory subdir)
Calculate and check the MD5 hash of the supplied GRF.
Definition: gfxinit.cpp:376
static const size_t NUM_FILES
Number of files in this set.
void GfxLoadSprites()
Initialise and load all the sprites.
Definition: gfxinit.cpp:337
Base for the NewGRF implementation.