2005-08-14 18:10:18 +00:00
|
|
|
|
/* $Id$ */
|
|
|
|
|
|
2007-03-01 01:24:44 +00:00
|
|
|
|
/** @file gfxinit.cpp */
|
|
|
|
|
|
2005-08-14 18:10:18 +00:00
|
|
|
|
#include "stdafx.h"
|
|
|
|
|
#include "openttd.h"
|
|
|
|
|
#include "debug.h"
|
|
|
|
|
#include "functions.h"
|
|
|
|
|
#include "gfx.h"
|
|
|
|
|
#include "gfxinit.h"
|
|
|
|
|
#include "spritecache.h"
|
|
|
|
|
#include "table/sprites.h"
|
|
|
|
|
#include "fileio.h"
|
2006-07-31 22:11:34 +00:00
|
|
|
|
#include "string.h"
|
2005-08-14 18:10:18 +00:00
|
|
|
|
#include "newgrf.h"
|
|
|
|
|
#include "md5.h"
|
|
|
|
|
#include "variables.h"
|
2006-11-24 20:47:29 +00:00
|
|
|
|
#include "fontcache.h"
|
2006-08-31 07:52:20 +00:00
|
|
|
|
#include <string.h>
|
2005-08-14 18:10:18 +00:00
|
|
|
|
|
2007-03-07 12:11:48 +00:00
|
|
|
|
struct MD5File {
|
2007-03-01 01:24:44 +00:00
|
|
|
|
const char * filename; ///< filename
|
|
|
|
|
md5_byte_t hash[16]; ///< md5 sum of the file
|
2007-03-07 12:11:48 +00:00
|
|
|
|
};
|
2005-08-14 18:10:18 +00:00
|
|
|
|
|
2007-03-07 12:11:48 +00:00
|
|
|
|
struct FileList {
|
2007-03-01 01:24:44 +00:00
|
|
|
|
MD5File basic[4]; ///< grf files that always have to be loaded
|
|
|
|
|
MD5File landscape[3]; ///< landscape specific grf files
|
2007-03-07 12:11:48 +00:00
|
|
|
|
};
|
2005-08-14 18:10:18 +00:00
|
|
|
|
|
2005-11-03 15:25:45 +00:00
|
|
|
|
enum {
|
|
|
|
|
SKIP = 0xFFFE,
|
|
|
|
|
END = 0xFFFF
|
|
|
|
|
};
|
|
|
|
|
|
2005-08-14 18:10:18 +00:00
|
|
|
|
#include "table/files.h"
|
|
|
|
|
#include "table/landscape_sprite.h"
|
|
|
|
|
|
|
|
|
|
static const SpriteID * const _landscape_spriteindexes[] = {
|
|
|
|
|
_landscape_spriteindexes_1,
|
|
|
|
|
_landscape_spriteindexes_2,
|
|
|
|
|
_landscape_spriteindexes_3,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static const SpriteID * const _slopes_spriteindexes[] = {
|
|
|
|
|
_slopes_spriteindexes_0,
|
|
|
|
|
_slopes_spriteindexes_1,
|
|
|
|
|
_slopes_spriteindexes_2,
|
|
|
|
|
_slopes_spriteindexes_3,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
2005-08-15 11:39:13 +00:00
|
|
|
|
static uint LoadGrfFile(const char* filename, uint load_index, int file_index)
|
2005-08-14 18:10:18 +00:00
|
|
|
|
{
|
2005-08-15 11:39:13 +00:00
|
|
|
|
uint load_index_org = load_index;
|
2005-08-14 18:10:18 +00:00
|
|
|
|
|
|
|
|
|
FioOpenFile(file_index, filename);
|
|
|
|
|
|
2006-12-26 17:36:18 +00:00
|
|
|
|
DEBUG(sprite, 2, "Reading grf-file '%s'", filename);
|
2005-08-14 18:10:18 +00:00
|
|
|
|
|
|
|
|
|
while (LoadNextSprite(load_index, file_index)) {
|
|
|
|
|
load_index++;
|
|
|
|
|
if (load_index >= MAX_SPRITES) {
|
|
|
|
|
error("Too many sprites. Recompile with higher MAX_SPRITES value or remove some custom GRF files.");
|
|
|
|
|
}
|
|
|
|
|
}
|
2006-12-26 17:36:18 +00:00
|
|
|
|
DEBUG(sprite, 2, "Currently %i sprites are loaded", load_index);
|
2005-08-14 18:10:18 +00:00
|
|
|
|
|
|
|
|
|
return load_index - load_index_org;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2005-08-15 11:39:13 +00:00
|
|
|
|
static void LoadGrfIndexed(const char* filename, const SpriteID* index_tbl, int file_index)
|
2005-08-14 18:10:18 +00:00
|
|
|
|
{
|
2005-08-15 11:39:13 +00:00
|
|
|
|
uint start;
|
2005-08-14 18:10:18 +00:00
|
|
|
|
|
|
|
|
|
FioOpenFile(file_index, filename);
|
|
|
|
|
|
2006-12-26 17:36:18 +00:00
|
|
|
|
DEBUG(sprite, 2, "Reading indexed grf-file '%s'", filename);
|
2005-08-14 18:10:18 +00:00
|
|
|
|
|
2005-11-03 15:25:45 +00:00
|
|
|
|
while ((start = *index_tbl++) != END) {
|
2005-08-15 11:39:13 +00:00
|
|
|
|
uint end = *index_tbl++;
|
|
|
|
|
|
2005-11-03 15:25:45 +00:00
|
|
|
|
if (start == SKIP) { // skip sprites (amount in second var)
|
2005-08-14 18:10:18 +00:00
|
|
|
|
SkipSprites(end);
|
|
|
|
|
} else { // load sprites and use indexes from start to end
|
|
|
|
|
do {
|
|
|
|
|
#ifdef NDEBUG
|
|
|
|
|
LoadNextSprite(start, file_index);
|
|
|
|
|
#else
|
|
|
|
|
bool b = LoadNextSprite(start, file_index);
|
|
|
|
|
assert(b);
|
|
|
|
|
#endif
|
|
|
|
|
} while (++start <= end);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Check that the supplied MD5 hash matches that stored for the supplied filename */
|
|
|
|
|
static bool CheckMD5Digest(const MD5File file, md5_byte_t *digest, bool warn)
|
|
|
|
|
{
|
2006-08-31 07:52:20 +00:00
|
|
|
|
if (memcmp(file.hash, digest, sizeof(file.hash)) == 0) return true;
|
|
|
|
|
if (warn) fprintf(stderr, "MD5 of %s is ****INCORRECT**** - File Corrupt.\n", file.filename);
|
|
|
|
|
return false;
|
2005-08-14 18:10:18 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Calculate and check the MD5 hash of the supplied filename.
|
|
|
|
|
* returns true if the checksum is correct */
|
|
|
|
|
static bool FileMD5(const MD5File file, bool warn)
|
|
|
|
|
{
|
|
|
|
|
FILE *f;
|
|
|
|
|
char buf[MAX_PATH];
|
|
|
|
|
|
2007-03-01 01:24:44 +00:00
|
|
|
|
/* open file */
|
2006-12-09 10:56:12 +00:00
|
|
|
|
snprintf(buf, lengthof(buf), "%s%s", _paths.data_dir, file.filename);
|
2005-08-14 18:10:18 +00:00
|
|
|
|
f = fopen(buf, "rb");
|
|
|
|
|
|
|
|
|
|
#if !defined(WIN32)
|
|
|
|
|
if (f == NULL) {
|
2006-12-09 10:56:12 +00:00
|
|
|
|
strtolower(buf + strlen(_paths.data_dir) - 1);
|
2005-08-14 18:10:18 +00:00
|
|
|
|
f = fopen(buf, "rb");
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
2007-01-02 20:39:07 +00:00
|
|
|
|
#if defined SECOND_DATA_DIR
|
|
|
|
|
/* If we failed to find the file in the first data directory, we will try the other one */
|
|
|
|
|
|
|
|
|
|
if (f == NULL) {
|
|
|
|
|
snprintf(buf, lengthof(buf), "%s%s", _paths.second_data_dir, file.filename);
|
|
|
|
|
f = fopen(buf, "rb");
|
|
|
|
|
|
|
|
|
|
if (f == NULL) {
|
|
|
|
|
strtolower(buf + strlen(_paths.second_data_dir) - 1);
|
|
|
|
|
f = fopen(buf, "rb");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
2005-08-14 18:10:18 +00:00
|
|
|
|
if (f != NULL) {
|
|
|
|
|
md5_state_t filemd5state;
|
|
|
|
|
md5_byte_t buffer[1024];
|
|
|
|
|
md5_byte_t digest[16];
|
|
|
|
|
size_t len;
|
|
|
|
|
|
|
|
|
|
md5_init(&filemd5state);
|
|
|
|
|
while ((len = fread(buffer, 1, sizeof(buffer), f)) != 0)
|
|
|
|
|
md5_append(&filemd5state, buffer, len);
|
|
|
|
|
|
2007-01-21 17:09:32 +00:00
|
|
|
|
if (ferror(f) && warn) ShowInfoF("Error Reading from %s \n", buf);
|
2005-08-14 18:10:18 +00:00
|
|
|
|
fclose(f);
|
|
|
|
|
|
|
|
|
|
md5_finish(&filemd5state, digest);
|
2005-11-14 19:48:04 +00:00
|
|
|
|
return CheckMD5Digest(file, digest, warn);
|
2005-08-14 18:10:18 +00:00
|
|
|
|
} else { // file not found
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Checks, if either the Windows files exist (TRG1R.GRF) or the DOS files (TRG1.GRF)
|
|
|
|
|
* by comparing the MD5 checksums of the files. _use_dos_palette is set accordingly.
|
|
|
|
|
* If neither are found, Windows palette is assumed.
|
|
|
|
|
*
|
|
|
|
|
* (Note: Also checks sample.cat for corruption) */
|
2007-03-07 11:47:46 +00:00
|
|
|
|
void CheckExternalFiles()
|
2005-08-14 18:10:18 +00:00
|
|
|
|
{
|
|
|
|
|
uint i;
|
2007-03-01 01:24:44 +00:00
|
|
|
|
/* count of files from this version */
|
2005-08-14 18:10:18 +00:00
|
|
|
|
uint dos = 0;
|
|
|
|
|
uint win = 0;
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < 2; i++) if (FileMD5(files_dos.basic[i], true)) dos++;
|
|
|
|
|
for (i = 0; i < 3; i++) if (FileMD5(files_dos.landscape[i], true)) dos++;
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < 2; i++) if (FileMD5(files_win.basic[i], true)) win++;
|
|
|
|
|
for (i = 0; i < 3; i++) if (FileMD5(files_win.landscape[i], true)) win++;
|
|
|
|
|
|
|
|
|
|
if (!FileMD5(sample_cat_win, false) && !FileMD5(sample_cat_dos, false))
|
2007-01-09 21:25:13 +00:00
|
|
|
|
ShowInfo("Your 'sample.cat' file is corrupted or missing!");
|
2005-08-14 18:10:18 +00:00
|
|
|
|
|
2006-10-24 10:15:56 +00:00
|
|
|
|
for (i = 0; i < lengthof(files_openttd); i++) {
|
|
|
|
|
if (!FileMD5(files_openttd[i], false)) {
|
2007-01-09 21:25:13 +00:00
|
|
|
|
ShowInfoF("Your '%s' file is corrupted or missing!", files_openttd[i].filename);
|
2006-10-24 10:15:56 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2005-08-14 18:10:18 +00:00
|
|
|
|
/*
|
|
|
|
|
* 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
|
|
|
|
|
*/
|
|
|
|
|
if (_use_dos_palette) {
|
|
|
|
|
return;
|
|
|
|
|
} else if (win == 5) {
|
|
|
|
|
_use_dos_palette = false;
|
|
|
|
|
} else if (dos == 5 || (win == 0 && dos > 0)) {
|
|
|
|
|
_use_dos_palette = true;
|
|
|
|
|
} else {
|
|
|
|
|
_use_dos_palette = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2005-08-15 11:39:13 +00:00
|
|
|
|
|
2005-08-20 18:14:32 +00:00
|
|
|
|
static const SpriteID trg1idx[] = {
|
2007-03-01 01:24:44 +00:00
|
|
|
|
0, 1, ///< Mouse cursor, ZZZ
|
2005-08-20 18:14:32 +00:00
|
|
|
|
/* Medium font */
|
2007-03-01 01:24:44 +00:00
|
|
|
|
2, 92, ///< ' ' till 'z'
|
2005-11-03 15:25:45 +00:00
|
|
|
|
SKIP, 36,
|
2007-05-28 04:15:32 +00:00
|
|
|
|
160, 160, ///< Move Ÿ to the correct position
|
2007-03-01 01:24:44 +00:00
|
|
|
|
98, 98, ///< Up arrow
|
2005-11-03 15:25:45 +00:00
|
|
|
|
131, 133,
|
2007-03-01 01:24:44 +00:00
|
|
|
|
SKIP, 1, ///< skip currency sign
|
2005-11-03 15:25:45 +00:00
|
|
|
|
135, 135,
|
|
|
|
|
SKIP, 1,
|
|
|
|
|
137, 137,
|
|
|
|
|
SKIP, 1,
|
|
|
|
|
139, 139,
|
2007-03-01 01:24:44 +00:00
|
|
|
|
140, 140, ///< @todo Down arrow
|
2005-11-03 15:25:45 +00:00
|
|
|
|
141, 141,
|
2007-03-01 01:24:44 +00:00
|
|
|
|
142, 142, ///< @todo Check mark
|
|
|
|
|
143, 143, ///< @todo Cross
|
2005-11-03 15:25:45 +00:00
|
|
|
|
144, 144,
|
2007-03-01 01:24:44 +00:00
|
|
|
|
145, 145, ///< @todo Right arrow
|
2005-11-03 15:25:45 +00:00
|
|
|
|
146, 149,
|
2007-03-01 01:24:44 +00:00
|
|
|
|
118, 122, ///< Transport markers
|
2005-11-03 15:25:45 +00:00
|
|
|
|
SKIP, 2,
|
|
|
|
|
157, 157,
|
2007-03-01 01:24:44 +00:00
|
|
|
|
114, 115, ///< Small up/down arrows
|
2005-11-03 15:25:45 +00:00
|
|
|
|
SKIP, 1,
|
|
|
|
|
161, 225,
|
2005-08-20 18:14:32 +00:00
|
|
|
|
/* Small font */
|
2007-03-01 01:24:44 +00:00
|
|
|
|
226, 316, ///< ' ' till 'z'
|
2005-11-03 15:25:45 +00:00
|
|
|
|
SKIP, 36,
|
2007-05-28 04:15:32 +00:00
|
|
|
|
384, 384, ///< Move Ÿ to the correct position
|
2007-03-01 01:24:44 +00:00
|
|
|
|
322, 322, ///< Up arrow
|
2005-11-03 15:25:45 +00:00
|
|
|
|
355, 357,
|
2007-03-01 01:24:44 +00:00
|
|
|
|
SKIP, 1, ///< skip currency sign
|
2005-11-03 15:25:45 +00:00
|
|
|
|
359, 359,
|
|
|
|
|
SKIP, 1,
|
|
|
|
|
361, 361,
|
|
|
|
|
SKIP, 1,
|
|
|
|
|
363, 363,
|
2007-03-01 01:24:44 +00:00
|
|
|
|
364, 364, ////< @todo Down arrow
|
2005-11-03 15:25:45 +00:00
|
|
|
|
365, 366,
|
|
|
|
|
SKIP, 1,
|
|
|
|
|
368, 368,
|
2007-03-01 01:24:44 +00:00
|
|
|
|
369, 369, ///< @todo Right arrow
|
2005-11-03 15:25:45 +00:00
|
|
|
|
370, 373,
|
|
|
|
|
SKIP, 7,
|
|
|
|
|
381, 381,
|
|
|
|
|
SKIP, 3,
|
|
|
|
|
385, 449,
|
2005-08-20 18:14:32 +00:00
|
|
|
|
/* Big font */
|
2007-03-01 01:24:44 +00:00
|
|
|
|
450, 540, ///< ' ' till 'z'
|
2005-11-03 15:25:45 +00:00
|
|
|
|
SKIP, 36,
|
2007-05-28 04:15:32 +00:00
|
|
|
|
608, 608, ///< Move Ÿ to the correct position
|
2005-11-03 15:25:45 +00:00
|
|
|
|
SKIP, 1,
|
|
|
|
|
579, 581,
|
|
|
|
|
SKIP, 1,
|
|
|
|
|
583, 583,
|
|
|
|
|
SKIP, 5,
|
|
|
|
|
589, 589,
|
|
|
|
|
SKIP, 15,
|
|
|
|
|
605, 605,
|
|
|
|
|
SKIP, 3,
|
|
|
|
|
609, 625,
|
|
|
|
|
SKIP, 1,
|
|
|
|
|
627, 632,
|
|
|
|
|
SKIP, 1,
|
|
|
|
|
634, 639,
|
|
|
|
|
SKIP, 1,
|
|
|
|
|
641, 657,
|
|
|
|
|
SKIP, 1,
|
|
|
|
|
659, 664,
|
|
|
|
|
SKIP, 2,
|
|
|
|
|
667, 671,
|
|
|
|
|
SKIP, 1,
|
|
|
|
|
673, 673,
|
2005-08-20 18:14:32 +00:00
|
|
|
|
/* Graphics */
|
2005-11-03 15:25:45 +00:00
|
|
|
|
674, 4792,
|
|
|
|
|
END
|
2005-08-20 18:14:32 +00:00
|
|
|
|
};
|
|
|
|
|
|
2005-10-29 22:27:34 +00:00
|
|
|
|
/* NOTE: When adding a normal sprite, increase OPENTTD_SPRITES_COUNT with the
|
|
|
|
|
* amount of sprites and add them to the end of the list, with the index of
|
|
|
|
|
* the old sprite-count offset from SPR_OPENTTD_BASE. With this there is no
|
|
|
|
|
* correspondence of any kind with the ID's in the grf file, but results in
|
|
|
|
|
* a maximum use of sprite slots. */
|
2005-08-20 18:14:32 +00:00
|
|
|
|
static const SpriteID _openttd_grf_indexes[] = {
|
2005-10-31 10:23:58 +00:00
|
|
|
|
SPR_IMG_AUTORAIL, SPR_CURSOR_WAYPOINT, // icons etc
|
2007-03-01 01:24:44 +00:00
|
|
|
|
134, 134, ///< euro symbol medium size
|
|
|
|
|
582, 582, ///< euro symbol large size
|
|
|
|
|
358, 358, ///< euro symbol tiny
|
2005-10-31 10:23:58 +00:00
|
|
|
|
SPR_CURSOR_CANAL, SPR_IMG_FASTFORWARD, // more icons
|
2007-05-28 04:15:32 +00:00
|
|
|
|
648, 648, ///< nordic char: æ
|
|
|
|
|
616, 616, ///< nordic char: Æ
|
|
|
|
|
666, 666, ///< nordic char: ø
|
|
|
|
|
634, 634, ///< nordic char: Ø
|
2006-10-24 12:56:14 +00:00
|
|
|
|
SPR_PIN_UP, SPR_CURSOR_CLONE_TRAIN, // more icons
|
2007-05-28 04:15:32 +00:00
|
|
|
|
382, 383, ///< Œ œ tiny
|
|
|
|
|
158, 159, ///< Œ œ medium
|
|
|
|
|
606, 607, ///< Œ œ large
|
|
|
|
|
360, 360, ///< Š tiny
|
|
|
|
|
362, 362, ///< š tiny
|
|
|
|
|
136, 136, ///< Š medium
|
|
|
|
|
138, 138, ///< š medium
|
|
|
|
|
584, 584, ///< Š large
|
|
|
|
|
586, 586, ///< š large
|
|
|
|
|
626, 626, ///< Ð large
|
|
|
|
|
658, 658, ///< ð large
|
|
|
|
|
374, 374, ///< Ž tiny
|
|
|
|
|
378, 378, ///< ž tiny
|
|
|
|
|
150, 150, ///< Ž medium
|
|
|
|
|
154, 154, ///< ž medium
|
|
|
|
|
598, 598, ///< Ž large
|
|
|
|
|
602, 602, ///< ž large
|
|
|
|
|
640, 640, ///< Þ large
|
|
|
|
|
672, 672, ///< þ large
|
|
|
|
|
380, 380, ///< º tiny
|
|
|
|
|
156, 156, ///< º medium
|
|
|
|
|
604, 604, ///< º large
|
2007-03-01 01:24:44 +00:00
|
|
|
|
317, 320, ///< { | } ~ tiny
|
|
|
|
|
93, 96, ///< { | } ~ medium
|
|
|
|
|
541, 544, ///< { | } ~ large
|
2005-10-31 10:23:58 +00:00
|
|
|
|
SPR_HOUSE_ICON, SPR_HOUSE_ICON,
|
2007-05-28 04:15:32 +00:00
|
|
|
|
585, 585, ///< § large
|
|
|
|
|
587, 587, ///< © large
|
|
|
|
|
592, 592, ///< ® large
|
|
|
|
|
594, 597, ///< ° ± ² ³ large
|
|
|
|
|
633, 633, ///< × large
|
|
|
|
|
665, 665, ///< ÷ large
|
2006-10-24 12:56:14 +00:00
|
|
|
|
SPR_SELL_TRAIN, SPR_SHARED_ORDERS_ICON,
|
2007-05-28 04:15:32 +00:00
|
|
|
|
377, 377, ///< · small
|
|
|
|
|
153, 153, ///< · medium
|
|
|
|
|
601, 601, ///< · large
|
2007-02-21 23:18:08 +00:00
|
|
|
|
SPR_WARNING_SIGN, SPR_WARNING_SIGN,
|
2005-11-03 15:25:45 +00:00
|
|
|
|
END
|
2005-08-20 18:14:32 +00:00
|
|
|
|
};
|
|
|
|
|
|
2005-08-15 11:39:13 +00:00
|
|
|
|
|
2007-03-07 11:47:46 +00:00
|
|
|
|
static void LoadSpriteTables()
|
2005-08-14 18:10:18 +00:00
|
|
|
|
{
|
2005-11-14 19:48:04 +00:00
|
|
|
|
const FileList* files = _use_dos_palette ? &files_dos : &files_win;
|
|
|
|
|
uint load_index;
|
2005-08-14 18:10:18 +00:00
|
|
|
|
uint i;
|
|
|
|
|
|
2005-08-20 18:14:32 +00:00
|
|
|
|
LoadGrfIndexed(files->basic[0].filename, trg1idx, 0);
|
2005-09-10 08:17:30 +00:00
|
|
|
|
DupSprite( 2, 130); // non-breaking space medium
|
|
|
|
|
DupSprite(226, 354); // non-breaking space tiny
|
|
|
|
|
DupSprite(450, 578); // non-breaking space large
|
2005-08-20 18:14:32 +00:00
|
|
|
|
load_index = 4793;
|
|
|
|
|
|
|
|
|
|
for (i = 1; files->basic[i].filename != NULL; i++) {
|
2005-08-14 18:10:18 +00:00
|
|
|
|
load_index += LoadGrfFile(files->basic[i].filename, load_index, i);
|
|
|
|
|
}
|
|
|
|
|
|
2006-11-24 12:39:13 +00:00
|
|
|
|
/* Load additional sprites for climates other than temperate */
|
2007-03-22 03:42:43 +00:00
|
|
|
|
if (_opt.landscape != LT_TEMPERATE) {
|
2005-08-14 18:10:18 +00:00
|
|
|
|
LoadGrfIndexed(
|
2006-11-24 12:39:13 +00:00
|
|
|
|
files->landscape[_opt.landscape - 1].filename,
|
|
|
|
|
_landscape_spriteindexes[_opt.landscape - 1],
|
2005-08-14 18:10:18 +00:00
|
|
|
|
i++
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2006-10-24 13:08:52 +00:00
|
|
|
|
assert(load_index == SPR_SIGNALS_BASE);
|
|
|
|
|
load_index += LoadGrfFile("nsignalsw.grf", load_index, i++);
|
|
|
|
|
|
2005-10-14 07:59:16 +00:00
|
|
|
|
assert(load_index == SPR_CANALS_BASE);
|
|
|
|
|
load_index += LoadGrfFile("canalsw.grf", load_index, i++);
|
|
|
|
|
|
|
|
|
|
assert(load_index == SPR_SLOPES_BASE);
|
2005-08-14 18:10:18 +00:00
|
|
|
|
LoadGrfIndexed("trkfoundw.grf", _slopes_spriteindexes[_opt.landscape], i++);
|
|
|
|
|
|
|
|
|
|
load_index = SPR_AUTORAIL_BASE;
|
|
|
|
|
load_index += LoadGrfFile("autorail.grf", load_index, i++);
|
|
|
|
|
|
2006-03-29 16:30:26 +00:00
|
|
|
|
assert(load_index == SPR_ELRAIL_BASE);
|
|
|
|
|
load_index += LoadGrfFile("elrailsw.grf", load_index, i++);
|
|
|
|
|
|
2006-03-01 23:14:03 +00:00
|
|
|
|
assert(load_index == SPR_2CCMAP_BASE);
|
|
|
|
|
load_index += LoadGrfFile("2ccmap.grf", load_index, i++);
|
|
|
|
|
|
2005-10-14 07:59:16 +00:00
|
|
|
|
assert(load_index == SPR_OPENTTD_BASE);
|
|
|
|
|
LoadGrfIndexed("openttd.grf", _openttd_grf_indexes, i++);
|
2005-11-01 06:38:23 +00:00
|
|
|
|
load_index = SPR_OPENTTD_BASE + OPENTTD_SPRITES_COUNT;
|
2005-08-14 18:10:18 +00:00
|
|
|
|
|
2006-06-23 22:05:40 +00:00
|
|
|
|
assert(load_index == SPR_AIRPORTX_BASE);
|
|
|
|
|
load_index += LoadGrfFile("airports.grf", load_index, i++);
|
|
|
|
|
|
2007-02-14 16:37:16 +00:00
|
|
|
|
assert(load_index == SPR_ROADSTOP_BASE);
|
|
|
|
|
load_index += LoadGrfFile("roadstops.grf", load_index, i++);
|
|
|
|
|
|
2007-05-19 09:40:18 +00:00
|
|
|
|
assert(load_index == SPR_GROUP_BASE);
|
|
|
|
|
load_index += LoadGrfFile("group.grf", load_index, i++);
|
|
|
|
|
|
2007-05-25 22:07:40 +00:00
|
|
|
|
assert(load_index == SPR_TRAMWAY_BASE);
|
|
|
|
|
load_index += LoadGrfFile("tramtrkw.grf", load_index, i++);
|
|
|
|
|
|
2007-05-31 15:15:00 +00:00
|
|
|
|
assert(load_index == SPR_ONEWAY_BASE);
|
|
|
|
|
load_index += LoadGrfFile("oneway.grf", load_index, i++);
|
|
|
|
|
|
2006-11-24 20:47:29 +00:00
|
|
|
|
/* Initialize the unicode to sprite mapping table */
|
|
|
|
|
InitializeUnicodeGlyphMap();
|
|
|
|
|
|
2005-08-15 11:39:13 +00:00
|
|
|
|
LoadNewGRF(load_index, i);
|
2005-08-14 18:10:18 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-03-07 11:47:46 +00:00
|
|
|
|
void GfxLoadSprites()
|
2005-08-14 18:10:18 +00:00
|
|
|
|
{
|
2006-12-26 17:36:18 +00:00
|
|
|
|
DEBUG(sprite, 2, "Loading sprite set %d", _opt.landscape);
|
2005-08-14 18:10:18 +00:00
|
|
|
|
|
2006-11-24 12:39:13 +00:00
|
|
|
|
GfxInitSpriteMem();
|
|
|
|
|
LoadSpriteTables();
|
|
|
|
|
GfxInitPalettes();
|
2005-08-14 18:10:18 +00:00
|
|
|
|
}
|