OpenTTD Source: src/gfxinit.cpp Source File

OpenTTD Source 1.11.0-RC1

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