author | rubidium |
Mon, 03 Dec 2007 23:39:38 +0000 | |
branch | NewGRF_ports |
changeset 6871 | 5a9dc001e1ad |
parent 6870 | ca3fd1fbe311 |
child 6872 | 1c4a4a609f85 |
permissions | -rw-r--r-- |
2186 | 1 |
/* $Id$ */ |
2 |
||
6505
abcb0580d976
(svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents:
6429
diff
changeset
|
3 |
/** @file gfxinit.cpp */ |
abcb0580d976
(svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents:
6429
diff
changeset
|
4 |
|
0 | 5 |
#include "stdafx.h" |
1891
92a3b0aa0946
(svn r2397) - CodeChange: rename all "ttd" files to "openttd" files.
Darkvater
parents:
1844
diff
changeset
|
6 |
#include "openttd.h" |
1299
0a6510cc889b
(svn r1803) Move debugging stuff into files of it's own
tron
parents:
1250
diff
changeset
|
7 |
#include "debug.h" |
2163
637ec3c361f5
(svn r2673) Include functions.h directly, not globally via openttd.h
tron
parents:
2159
diff
changeset
|
8 |
#include "functions.h" |
0 | 9 |
#include "gfx.h" |
2340
0a9f3eeccb96
(svn r2866) Move all functions and tables which aren't directly involved in managing the sprite heap to a new file gfxinit.c.
tron
parents:
2339
diff
changeset
|
10 |
#include "gfxinit.h" |
1349
07514c2cc6d1
(svn r1853) Move spritecache function declarations into a header of their own and use SpriteID as parameter type where appropriate
tron
parents:
1348
diff
changeset
|
11 |
#include "spritecache.h" |
1363
01d3de5d8039
(svn r1867) Include tables/sprites.h only in files which need it
tron
parents:
1361
diff
changeset
|
12 |
#include "table/sprites.h" |
0 | 13 |
#include "fileio.h" |
6871
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
14 |
#include "fios.h" |
4200
a45420ba0c23
(svn r5684) - Codechange: create an strtolower() function that uses tolower() on a whole string and apply it in the places this was used.
Darkvater
parents:
4059
diff
changeset
|
15 |
#include "string.h" |
463
91bcad840bcd
(svn r687) Export InitNewGRFFile() and DecodeSpecialSprite() properly.
pasky
parents:
452
diff
changeset
|
16 |
#include "newgrf.h" |
961 | 17 |
#include "md5.h" |
2159
3b634157c3b2
(svn r2669) Shuffle some more stuff around to reduce dependencies
tron
parents:
2142
diff
changeset
|
18 |
#include "variables.h" |
5156
5edaa8f9b295
(svn r7254) -Fix (r7250): move unicode glyph map initialisation to just before newgrf files are loaded, else newgrf glyphs will be cleared out too. (thanks Hadez)
peter1138
parents:
5151
diff
changeset
|
19 |
#include "fontcache.h" |
4472
745f9ebe2216
(svn r6257) Use memcmp() to check the MD5 sum instead of using a home brewed loop
tron
parents:
4209
diff
changeset
|
20 |
#include <string.h> |
0 | 21 |
|
6574
e1d1a12faaf7
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6573
diff
changeset
|
22 |
struct MD5File { |
6505
abcb0580d976
(svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents:
6429
diff
changeset
|
23 |
const char * filename; ///< filename |
abcb0580d976
(svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents:
6429
diff
changeset
|
24 |
md5_byte_t hash[16]; ///< md5 sum of the file |
6574
e1d1a12faaf7
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6573
diff
changeset
|
25 |
}; |
961 | 26 |
|
6574
e1d1a12faaf7
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6573
diff
changeset
|
27 |
struct FileList { |
6871
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
28 |
MD5File basic[2]; ///< GRF files that always have to be loaded |
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
29 |
MD5File landscape[3]; ///< Landscape specific grf files |
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
30 |
MD5File sound; ///< Sound samples |
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
31 |
MD5File chars; ///< GRF File with character replacements |
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
32 |
MD5File openttd; ///< GRF File with OTTD specific graphics |
2588
40d7dba79fc7
(svn r3125) Symbolic names for skiping sprites and the end of the sprite list
tron
parents:
2577
diff
changeset
|
33 |
}; |
40d7dba79fc7
(svn r3125) Symbolic names for skiping sprites and the end of the sprite list
tron
parents:
2577
diff
changeset
|
34 |
|
961 | 35 |
#include "table/files.h" |
0 | 36 |
#include "table/landscape_sprite.h" |
37 |
||
2187
2a51f8925eeb
(svn r2702) -Codechange: Cleaned up the sprite code and replaced many magic numbers
celestar
parents:
2186
diff
changeset
|
38 |
static const SpriteID * const _landscape_spriteindexes[] = { |
0 | 39 |
_landscape_spriteindexes_1, |
40 |
_landscape_spriteindexes_2, |
|
41 |
_landscape_spriteindexes_3, |
|
42 |
}; |
|
43 |
||
6871
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
44 |
static uint LoadGrfFile(const char *filename, uint load_index, int file_index) |
0 | 45 |
{ |
2342
c19fb4f2df30
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
46 |
uint load_index_org = load_index; |
6720
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
47 |
uint sprite_id = 0; |
0 | 48 |
|
49 |
FioOpenFile(file_index, filename); |
|
365
5752af05ed75
(svn r553) -newgrf: Special routine for loading newgrf files. LoadNewGrfFile() introduced; will get more handy when loading stages will be introduced (octo and pasky).
darkvater
parents:
364
diff
changeset
|
50 |
|
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5296
diff
changeset
|
51 |
DEBUG(sprite, 2, "Reading grf-file '%s'", filename); |
0 | 52 |
|
6720
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
53 |
while (LoadNextSprite(load_index, file_index, sprite_id)) { |
0 | 54 |
load_index++; |
6720
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
55 |
sprite_id++; |
2187
2a51f8925eeb
(svn r2702) -Codechange: Cleaned up the sprite code and replaced many magic numbers
celestar
parents:
2186
diff
changeset
|
56 |
if (load_index >= MAX_SPRITES) { |
2a51f8925eeb
(svn r2702) -Codechange: Cleaned up the sprite code and replaced many magic numbers
celestar
parents:
2186
diff
changeset
|
57 |
error("Too many sprites. Recompile with higher MAX_SPRITES value or remove some custom GRF files."); |
0 | 58 |
} |
59 |
} |
|
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5296
diff
changeset
|
60 |
DEBUG(sprite, 2, "Currently %i sprites are loaded", load_index); |
0 | 61 |
|
365
5752af05ed75
(svn r553) -newgrf: Special routine for loading newgrf files. LoadNewGrfFile() introduced; will get more handy when loading stages will be introduced (octo and pasky).
darkvater
parents:
364
diff
changeset
|
62 |
return load_index - load_index_org; |
5752af05ed75
(svn r553) -newgrf: Special routine for loading newgrf files. LoadNewGrfFile() introduced; will get more handy when loading stages will be introduced (octo and pasky).
darkvater
parents:
364
diff
changeset
|
63 |
} |
5752af05ed75
(svn r553) -newgrf: Special routine for loading newgrf files. LoadNewGrfFile() introduced; will get more handy when loading stages will be introduced (octo and pasky).
darkvater
parents:
364
diff
changeset
|
64 |
|
2342
c19fb4f2df30
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
65 |
|
6871
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
66 |
void LoadSpritesIndexed(int file_index, uint *sprite_id, const SpriteID *index_tbl) |
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
67 |
{ |
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
68 |
uint start; |
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
69 |
while ((start = *index_tbl++) != END) { |
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
70 |
uint end = *index_tbl++; |
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
71 |
|
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
72 |
if (start == SKIP) { // skip sprites (amount in second var) |
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
73 |
SkipSprites(end); |
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
74 |
(*sprite_id) += end; |
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
75 |
} else { // load sprites and use indexes from start to end |
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
76 |
do { |
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
77 |
#ifdef NDEBUG |
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
78 |
LoadNextSprite(start, file_index, *sprite_id); |
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
79 |
#else |
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
80 |
bool b = LoadNextSprite(start, file_index, *sprite_id); |
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
81 |
assert(b); |
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
82 |
#endif |
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
83 |
(*sprite_id)++; |
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
84 |
} while (++start <= end); |
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
85 |
} |
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
86 |
} |
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
87 |
} |
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
88 |
|
2342
c19fb4f2df30
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
89 |
static void LoadGrfIndexed(const char* filename, const SpriteID* index_tbl, int file_index) |
365
5752af05ed75
(svn r553) -newgrf: Special routine for loading newgrf files. LoadNewGrfFile() introduced; will get more handy when loading stages will be introduced (octo and pasky).
darkvater
parents:
364
diff
changeset
|
90 |
{ |
6720
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
91 |
uint sprite_id = 0; |
614
e016770cb781
(svn r1038) Feature: OpenTTD runs with the grf files of the DOS version
dominik
parents:
579
diff
changeset
|
92 |
|
365
5752af05ed75
(svn r553) -newgrf: Special routine for loading newgrf files. LoadNewGrfFile() introduced; will get more handy when loading stages will be introduced (octo and pasky).
darkvater
parents:
364
diff
changeset
|
93 |
FioOpenFile(file_index, filename); |
5752af05ed75
(svn r553) -newgrf: Special routine for loading newgrf files. LoadNewGrfFile() introduced; will get more handy when loading stages will be introduced (octo and pasky).
darkvater
parents:
364
diff
changeset
|
94 |
|
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5296
diff
changeset
|
95 |
DEBUG(sprite, 2, "Reading indexed grf-file '%s'", filename); |
0 | 96 |
|
6871
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
97 |
LoadSpritesIndexed(file_index, &sprite_id, index_tbl); |
184
dbeaaaf8b2bb
(svn r185) -Fix: [1016954] Cached_sprites does now work again
truelight
parents:
182
diff
changeset
|
98 |
} |
0 | 99 |
|
100 |
||
6871
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
101 |
/** |
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
102 |
* Calculate and check the MD5 hash of the supplied filename. |
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
103 |
* @param file filename and expected MD5 hash for the given filename. |
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
104 |
* @return true if the checksum is correct. |
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
105 |
*/ |
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
106 |
static bool FileMD5(const MD5File file) |
614
e016770cb781
(svn r1038) Feature: OpenTTD runs with the grf files of the DOS version
dominik
parents:
579
diff
changeset
|
107 |
{ |
6870
ca3fd1fbe311
(svn r11219) [NewGRF_ports] -Sync: with trunk r11035:11218.
rubidium
parents:
6720
diff
changeset
|
108 |
size_t size; |
ca3fd1fbe311
(svn r11219) [NewGRF_ports] -Sync: with trunk r11035:11218.
rubidium
parents:
6720
diff
changeset
|
109 |
FILE *f = FioFOpenFile(file.filename, "rb", DATA_DIR, &size); |
5733
8b3c5398687f
(svn r7766) -Fix: [OSX] removed incorrect debug message about corrupted/missing grf files
bjarni
parents:
5726
diff
changeset
|
110 |
|
862
d7e52ef99f42
(svn r1343) -Fix: [Graphic] Autorail icon is now correct (Darkvater)
truelight
parents:
614
diff
changeset
|
111 |
if (f != NULL) { |
2028
d7686f53adf2
(svn r2537) Small changes, especially use fprintf to stderr for warnings and errors instead of plain printf
tron
parents:
2027
diff
changeset
|
112 |
md5_state_t filemd5state; |
d7686f53adf2
(svn r2537) Small changes, especially use fprintf to stderr for warnings and errors instead of plain printf
tron
parents:
2027
diff
changeset
|
113 |
md5_byte_t buffer[1024]; |
d7686f53adf2
(svn r2537) Small changes, especially use fprintf to stderr for warnings and errors instead of plain printf
tron
parents:
2027
diff
changeset
|
114 |
md5_byte_t digest[16]; |
d7686f53adf2
(svn r2537) Small changes, especially use fprintf to stderr for warnings and errors instead of plain printf
tron
parents:
2027
diff
changeset
|
115 |
size_t len; |
d7686f53adf2
(svn r2537) Small changes, especially use fprintf to stderr for warnings and errors instead of plain printf
tron
parents:
2027
diff
changeset
|
116 |
|
961 | 117 |
md5_init(&filemd5state); |
6870
ca3fd1fbe311
(svn r11219) [NewGRF_ports] -Sync: with trunk r11035:11218.
rubidium
parents:
6720
diff
changeset
|
118 |
while ((len = fread(buffer, 1, (size > sizeof(buffer)) ? sizeof(buffer) : size, f)) != 0 && size != 0) { |
ca3fd1fbe311
(svn r11219) [NewGRF_ports] -Sync: with trunk r11035:11218.
rubidium
parents:
6720
diff
changeset
|
119 |
size -= len; |
961 | 120 |
md5_append(&filemd5state, buffer, len); |
6870
ca3fd1fbe311
(svn r11219) [NewGRF_ports] -Sync: with trunk r11035:11218.
rubidium
parents:
6720
diff
changeset
|
121 |
} |
961 | 122 |
|
6870
ca3fd1fbe311
(svn r11219) [NewGRF_ports] -Sync: with trunk r11035:11218.
rubidium
parents:
6720
diff
changeset
|
123 |
FioFCloseFile(f); |
1019
6363b8a4273e
(svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents:
966
diff
changeset
|
124 |
|
961 | 125 |
md5_finish(&filemd5state, digest); |
6871
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
126 |
return memcmp(file.hash, digest, sizeof(file.hash)) == 0; |
961 | 127 |
} else { // file not found |
128 |
return false; |
|
1019
6363b8a4273e
(svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents:
966
diff
changeset
|
129 |
} |
961 | 130 |
} |
131 |
||
6871
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
132 |
/** |
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
133 |
* Determine the palette that has to be used. |
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
134 |
* - forced DOS palette via command line -> leave it that way |
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
135 |
* - all Windows files present -> Windows palette |
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
136 |
* - all DOS files present -> DOS palette |
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
137 |
* - no Windows files present and any DOS file present -> DOS palette |
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
138 |
* - otherwise -> Windows palette |
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
139 |
*/ |
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
140 |
static void DeterminePalette() |
961 | 141 |
{ |
6871
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
142 |
if (_use_dos_palette) return; |
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
143 |
|
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
144 |
/* Count of files from the different versions. */ |
1355 | 145 |
uint dos = 0; |
146 |
uint win = 0; |
|
961 | 147 |
|
6871
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
148 |
for (uint i = 0; i < lengthof(files_dos.basic); i++) if (FioCheckFileExists(files_dos.basic[i].filename)) dos++; |
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
149 |
for (uint i = 0; i < lengthof(files_dos.landscape); i++) if (FioCheckFileExists(files_dos.landscape[i].filename)) dos++; |
961 | 150 |
|
6871
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
151 |
for (uint i = 0; i < lengthof(files_win.basic); i++) if (FioCheckFileExists(files_win.basic[i].filename)) win++; |
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
152 |
for (uint i = 0; i < lengthof(files_win.landscape); i++) if (FioCheckFileExists(files_win.landscape[i].filename)) win++; |
4934
5f937d83f3eb
(svn r6921) - PEBKAC: Add an MD5 sum check of our own data files, and warn if they don't match.
peter1138
parents:
4795
diff
changeset
|
153 |
|
6871
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
154 |
if (win == 5) { |
961 | 155 |
_use_dos_palette = false; |
1381 | 156 |
} else if (dos == 5 || (win == 0 && dos > 0)) { |
614
e016770cb781
(svn r1038) Feature: OpenTTD runs with the grf files of the DOS version
dominik
parents:
579
diff
changeset
|
157 |
_use_dos_palette = true; |
1380
7faf03f67dc3
(svn r1884) Change palette detection algorithm: Use the DOS palette if there are no Windows .grfs but at least one DOS .grf
tron
parents:
1378
diff
changeset
|
158 |
} else { |
961 | 159 |
_use_dos_palette = false; |
614
e016770cb781
(svn r1038) Feature: OpenTTD runs with the grf files of the DOS version
dominik
parents:
579
diff
changeset
|
160 |
} |
e016770cb781
(svn r1038) Feature: OpenTTD runs with the grf files of the DOS version
dominik
parents:
579
diff
changeset
|
161 |
} |
e016770cb781
(svn r1038) Feature: OpenTTD runs with the grf files of the DOS version
dominik
parents:
579
diff
changeset
|
162 |
|
6871
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
163 |
/** |
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
164 |
* Checks whether the MD5 checksums of the files are correct. |
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
165 |
* |
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
166 |
* @note Also checks sample.cat and other required non-NewGRF GRFs for corruption. |
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
167 |
*/ |
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
168 |
void CheckExternalFiles() |
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
169 |
{ |
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
170 |
DeterminePalette(); |
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
171 |
|
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
172 |
static const size_t ERROR_MESSAGE_LENGTH = 128; |
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
173 |
const FileList *files = _use_dos_palette ? &files_dos : &files_win; |
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
174 |
char error_msg[ERROR_MESSAGE_LENGTH * (lengthof(files->basic) + lengthof(files->landscape) + 3)]; |
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
175 |
error_msg[0] = '\0'; |
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
176 |
char *add_pos = error_msg; |
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
177 |
|
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
178 |
for (uint i = 0; i < lengthof(files->basic); i++) { |
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
179 |
if (!FileMD5(files->basic[i])) { |
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
180 |
add_pos += snprintf(add_pos, ERROR_MESSAGE_LENGTH, "Your '%s' file is corrupted or missing! You can find '%s' on your Transport Tycoon Deluxe CD-ROM.\n", files->basic[i].filename, files->basic[i].filename); |
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
181 |
} |
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
182 |
} |
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
183 |
|
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
184 |
for (uint i = 0; i < lengthof(files->landscape); i++) { |
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
185 |
if (!FileMD5(files->landscape[i])) { |
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
186 |
add_pos += snprintf(add_pos, ERROR_MESSAGE_LENGTH, "Your '%s' file is corrupted or missing! You can find '%s' on your Transport Tycoon Deluxe CD-ROM.\n", files->landscape[i].filename, files->landscape[i].filename); |
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
187 |
} |
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
188 |
} |
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
189 |
|
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
190 |
if (!FileMD5(files_win.sound) && !FileMD5(files_dos.sound)) { |
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
191 |
add_pos += snprintf(add_pos, ERROR_MESSAGE_LENGTH, "Your 'sample.cat' file is corrupted or missing! You can find 'sample.cat' on your Transport Tycoon Deluxe CD-ROM.\n"); |
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
192 |
} |
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
193 |
|
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
194 |
if (!FileMD5(files->chars)) { |
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
195 |
add_pos += snprintf(add_pos, ERROR_MESSAGE_LENGTH, "Your '%s' file is corrupted or missing! The file was part of your installation.\n", files->chars.filename); |
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
196 |
} |
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
197 |
|
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
198 |
if (!FileMD5(files->openttd)) { |
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
199 |
add_pos += snprintf(add_pos, ERROR_MESSAGE_LENGTH, "Your '%s' file is corrupted or missing! The file was part of your installation.\n", files->openttd.filename); |
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
200 |
} |
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
201 |
|
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
202 |
if (add_pos != error_msg) ShowInfoF(error_msg); |
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
203 |
} |
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
204 |
|
2342
c19fb4f2df30
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
205 |
|
2353 | 206 |
static const SpriteID trg1idx[] = { |
6505
abcb0580d976
(svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents:
6429
diff
changeset
|
207 |
0, 1, ///< Mouse cursor, ZZZ |
2353 | 208 |
/* Medium font */ |
6505
abcb0580d976
(svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents:
6429
diff
changeset
|
209 |
2, 92, ///< ' ' till 'z' |
2588
40d7dba79fc7
(svn r3125) Symbolic names for skiping sprites and the end of the sprite list
tron
parents:
2577
diff
changeset
|
210 |
SKIP, 36, |
6719
4cc327ad39d5
(svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents:
6683
diff
changeset
|
211 |
160, 160, ///< Move Ÿ to the correct position |
6505
abcb0580d976
(svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents:
6429
diff
changeset
|
212 |
98, 98, ///< Up arrow |
2588
40d7dba79fc7
(svn r3125) Symbolic names for skiping sprites and the end of the sprite list
tron
parents:
2577
diff
changeset
|
213 |
131, 133, |
6505
abcb0580d976
(svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents:
6429
diff
changeset
|
214 |
SKIP, 1, ///< skip currency sign |
2588
40d7dba79fc7
(svn r3125) Symbolic names for skiping sprites and the end of the sprite list
tron
parents:
2577
diff
changeset
|
215 |
135, 135, |
40d7dba79fc7
(svn r3125) Symbolic names for skiping sprites and the end of the sprite list
tron
parents:
2577
diff
changeset
|
216 |
SKIP, 1, |
40d7dba79fc7
(svn r3125) Symbolic names for skiping sprites and the end of the sprite list
tron
parents:
2577
diff
changeset
|
217 |
137, 137, |
40d7dba79fc7
(svn r3125) Symbolic names for skiping sprites and the end of the sprite list
tron
parents:
2577
diff
changeset
|
218 |
SKIP, 1, |
40d7dba79fc7
(svn r3125) Symbolic names for skiping sprites and the end of the sprite list
tron
parents:
2577
diff
changeset
|
219 |
139, 139, |
6505
abcb0580d976
(svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents:
6429
diff
changeset
|
220 |
140, 140, ///< @todo Down arrow |
2588
40d7dba79fc7
(svn r3125) Symbolic names for skiping sprites and the end of the sprite list
tron
parents:
2577
diff
changeset
|
221 |
141, 141, |
6505
abcb0580d976
(svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents:
6429
diff
changeset
|
222 |
142, 142, ///< @todo Check mark |
abcb0580d976
(svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents:
6429
diff
changeset
|
223 |
143, 143, ///< @todo Cross |
2588
40d7dba79fc7
(svn r3125) Symbolic names for skiping sprites and the end of the sprite list
tron
parents:
2577
diff
changeset
|
224 |
144, 144, |
6505
abcb0580d976
(svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents:
6429
diff
changeset
|
225 |
145, 145, ///< @todo Right arrow |
2588
40d7dba79fc7
(svn r3125) Symbolic names for skiping sprites and the end of the sprite list
tron
parents:
2577
diff
changeset
|
226 |
146, 149, |
6505
abcb0580d976
(svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents:
6429
diff
changeset
|
227 |
118, 122, ///< Transport markers |
2588
40d7dba79fc7
(svn r3125) Symbolic names for skiping sprites and the end of the sprite list
tron
parents:
2577
diff
changeset
|
228 |
SKIP, 2, |
40d7dba79fc7
(svn r3125) Symbolic names for skiping sprites and the end of the sprite list
tron
parents:
2577
diff
changeset
|
229 |
157, 157, |
6505
abcb0580d976
(svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents:
6429
diff
changeset
|
230 |
114, 115, ///< Small up/down arrows |
2588
40d7dba79fc7
(svn r3125) Symbolic names for skiping sprites and the end of the sprite list
tron
parents:
2577
diff
changeset
|
231 |
SKIP, 1, |
40d7dba79fc7
(svn r3125) Symbolic names for skiping sprites and the end of the sprite list
tron
parents:
2577
diff
changeset
|
232 |
161, 225, |
2353 | 233 |
/* Small font */ |
6505
abcb0580d976
(svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents:
6429
diff
changeset
|
234 |
226, 316, ///< ' ' till 'z' |
2588
40d7dba79fc7
(svn r3125) Symbolic names for skiping sprites and the end of the sprite list
tron
parents:
2577
diff
changeset
|
235 |
SKIP, 36, |
6719
4cc327ad39d5
(svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents:
6683
diff
changeset
|
236 |
384, 384, ///< Move Ÿ to the correct position |
6505
abcb0580d976
(svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents:
6429
diff
changeset
|
237 |
322, 322, ///< Up arrow |
2588
40d7dba79fc7
(svn r3125) Symbolic names for skiping sprites and the end of the sprite list
tron
parents:
2577
diff
changeset
|
238 |
355, 357, |
6505
abcb0580d976
(svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents:
6429
diff
changeset
|
239 |
SKIP, 1, ///< skip currency sign |
2588
40d7dba79fc7
(svn r3125) Symbolic names for skiping sprites and the end of the sprite list
tron
parents:
2577
diff
changeset
|
240 |
359, 359, |
40d7dba79fc7
(svn r3125) Symbolic names for skiping sprites and the end of the sprite list
tron
parents:
2577
diff
changeset
|
241 |
SKIP, 1, |
40d7dba79fc7
(svn r3125) Symbolic names for skiping sprites and the end of the sprite list
tron
parents:
2577
diff
changeset
|
242 |
361, 361, |
40d7dba79fc7
(svn r3125) Symbolic names for skiping sprites and the end of the sprite list
tron
parents:
2577
diff
changeset
|
243 |
SKIP, 1, |
40d7dba79fc7
(svn r3125) Symbolic names for skiping sprites and the end of the sprite list
tron
parents:
2577
diff
changeset
|
244 |
363, 363, |
6505
abcb0580d976
(svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents:
6429
diff
changeset
|
245 |
364, 364, ////< @todo Down arrow |
2588
40d7dba79fc7
(svn r3125) Symbolic names for skiping sprites and the end of the sprite list
tron
parents:
2577
diff
changeset
|
246 |
365, 366, |
40d7dba79fc7
(svn r3125) Symbolic names for skiping sprites and the end of the sprite list
tron
parents:
2577
diff
changeset
|
247 |
SKIP, 1, |
40d7dba79fc7
(svn r3125) Symbolic names for skiping sprites and the end of the sprite list
tron
parents:
2577
diff
changeset
|
248 |
368, 368, |
6505
abcb0580d976
(svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents:
6429
diff
changeset
|
249 |
369, 369, ///< @todo Right arrow |
2588
40d7dba79fc7
(svn r3125) Symbolic names for skiping sprites and the end of the sprite list
tron
parents:
2577
diff
changeset
|
250 |
370, 373, |
40d7dba79fc7
(svn r3125) Symbolic names for skiping sprites and the end of the sprite list
tron
parents:
2577
diff
changeset
|
251 |
SKIP, 7, |
40d7dba79fc7
(svn r3125) Symbolic names for skiping sprites and the end of the sprite list
tron
parents:
2577
diff
changeset
|
252 |
381, 381, |
40d7dba79fc7
(svn r3125) Symbolic names for skiping sprites and the end of the sprite list
tron
parents:
2577
diff
changeset
|
253 |
SKIP, 3, |
40d7dba79fc7
(svn r3125) Symbolic names for skiping sprites and the end of the sprite list
tron
parents:
2577
diff
changeset
|
254 |
385, 449, |
2353 | 255 |
/* Big font */ |
6505
abcb0580d976
(svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents:
6429
diff
changeset
|
256 |
450, 540, ///< ' ' till 'z' |
2588
40d7dba79fc7
(svn r3125) Symbolic names for skiping sprites and the end of the sprite list
tron
parents:
2577
diff
changeset
|
257 |
SKIP, 36, |
6719
4cc327ad39d5
(svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents:
6683
diff
changeset
|
258 |
608, 608, ///< Move Ÿ to the correct position |
2588
40d7dba79fc7
(svn r3125) Symbolic names for skiping sprites and the end of the sprite list
tron
parents:
2577
diff
changeset
|
259 |
SKIP, 1, |
40d7dba79fc7
(svn r3125) Symbolic names for skiping sprites and the end of the sprite list
tron
parents:
2577
diff
changeset
|
260 |
579, 581, |
40d7dba79fc7
(svn r3125) Symbolic names for skiping sprites and the end of the sprite list
tron
parents:
2577
diff
changeset
|
261 |
SKIP, 1, |
40d7dba79fc7
(svn r3125) Symbolic names for skiping sprites and the end of the sprite list
tron
parents:
2577
diff
changeset
|
262 |
583, 583, |
40d7dba79fc7
(svn r3125) Symbolic names for skiping sprites and the end of the sprite list
tron
parents:
2577
diff
changeset
|
263 |
SKIP, 5, |
40d7dba79fc7
(svn r3125) Symbolic names for skiping sprites and the end of the sprite list
tron
parents:
2577
diff
changeset
|
264 |
589, 589, |
40d7dba79fc7
(svn r3125) Symbolic names for skiping sprites and the end of the sprite list
tron
parents:
2577
diff
changeset
|
265 |
SKIP, 15, |
40d7dba79fc7
(svn r3125) Symbolic names for skiping sprites and the end of the sprite list
tron
parents:
2577
diff
changeset
|
266 |
605, 605, |
40d7dba79fc7
(svn r3125) Symbolic names for skiping sprites and the end of the sprite list
tron
parents:
2577
diff
changeset
|
267 |
SKIP, 3, |
40d7dba79fc7
(svn r3125) Symbolic names for skiping sprites and the end of the sprite list
tron
parents:
2577
diff
changeset
|
268 |
609, 625, |
40d7dba79fc7
(svn r3125) Symbolic names for skiping sprites and the end of the sprite list
tron
parents:
2577
diff
changeset
|
269 |
SKIP, 1, |
40d7dba79fc7
(svn r3125) Symbolic names for skiping sprites and the end of the sprite list
tron
parents:
2577
diff
changeset
|
270 |
627, 632, |
40d7dba79fc7
(svn r3125) Symbolic names for skiping sprites and the end of the sprite list
tron
parents:
2577
diff
changeset
|
271 |
SKIP, 1, |
40d7dba79fc7
(svn r3125) Symbolic names for skiping sprites and the end of the sprite list
tron
parents:
2577
diff
changeset
|
272 |
634, 639, |
40d7dba79fc7
(svn r3125) Symbolic names for skiping sprites and the end of the sprite list
tron
parents:
2577
diff
changeset
|
273 |
SKIP, 1, |
40d7dba79fc7
(svn r3125) Symbolic names for skiping sprites and the end of the sprite list
tron
parents:
2577
diff
changeset
|
274 |
641, 657, |
40d7dba79fc7
(svn r3125) Symbolic names for skiping sprites and the end of the sprite list
tron
parents:
2577
diff
changeset
|
275 |
SKIP, 1, |
40d7dba79fc7
(svn r3125) Symbolic names for skiping sprites and the end of the sprite list
tron
parents:
2577
diff
changeset
|
276 |
659, 664, |
40d7dba79fc7
(svn r3125) Symbolic names for skiping sprites and the end of the sprite list
tron
parents:
2577
diff
changeset
|
277 |
SKIP, 2, |
40d7dba79fc7
(svn r3125) Symbolic names for skiping sprites and the end of the sprite list
tron
parents:
2577
diff
changeset
|
278 |
667, 671, |
40d7dba79fc7
(svn r3125) Symbolic names for skiping sprites and the end of the sprite list
tron
parents:
2577
diff
changeset
|
279 |
SKIP, 1, |
40d7dba79fc7
(svn r3125) Symbolic names for skiping sprites and the end of the sprite list
tron
parents:
2577
diff
changeset
|
280 |
673, 673, |
2353 | 281 |
/* Graphics */ |
2588
40d7dba79fc7
(svn r3125) Symbolic names for skiping sprites and the end of the sprite list
tron
parents:
2577
diff
changeset
|
282 |
674, 4792, |
40d7dba79fc7
(svn r3125) Symbolic names for skiping sprites and the end of the sprite list
tron
parents:
2577
diff
changeset
|
283 |
END |
2353 | 284 |
}; |
285 |
||
6871
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
286 |
/** Replace some letter sprites with some other letters */ |
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
287 |
static const SpriteID _chars_grf_indexes[] = { |
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
288 |
134, 134, ///< euro symbol medium size |
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
289 |
582, 582, ///< euro symbol large size |
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
290 |
358, 358, ///< euro symbol tiny |
6719
4cc327ad39d5
(svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents:
6683
diff
changeset
|
291 |
648, 648, ///< nordic char: æ |
4cc327ad39d5
(svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents:
6683
diff
changeset
|
292 |
616, 616, ///< nordic char: Æ |
4cc327ad39d5
(svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents:
6683
diff
changeset
|
293 |
666, 666, ///< nordic char: ø |
4cc327ad39d5
(svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents:
6683
diff
changeset
|
294 |
634, 634, ///< nordic char: Ø |
4cc327ad39d5
(svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents:
6683
diff
changeset
|
295 |
382, 383, ///< Œ œ tiny |
4cc327ad39d5
(svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents:
6683
diff
changeset
|
296 |
158, 159, ///< Œ œ medium |
4cc327ad39d5
(svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents:
6683
diff
changeset
|
297 |
606, 607, ///< Œ œ large |
4cc327ad39d5
(svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents:
6683
diff
changeset
|
298 |
360, 360, ///< Š tiny |
4cc327ad39d5
(svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents:
6683
diff
changeset
|
299 |
362, 362, ///< š tiny |
4cc327ad39d5
(svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents:
6683
diff
changeset
|
300 |
136, 136, ///< Š medium |
4cc327ad39d5
(svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents:
6683
diff
changeset
|
301 |
138, 138, ///< š medium |
4cc327ad39d5
(svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents:
6683
diff
changeset
|
302 |
584, 584, ///< Š large |
4cc327ad39d5
(svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents:
6683
diff
changeset
|
303 |
586, 586, ///< š large |
4cc327ad39d5
(svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents:
6683
diff
changeset
|
304 |
626, 626, ///< Ð large |
4cc327ad39d5
(svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents:
6683
diff
changeset
|
305 |
658, 658, ///< ð large |
4cc327ad39d5
(svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents:
6683
diff
changeset
|
306 |
374, 374, ///< Ž tiny |
4cc327ad39d5
(svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents:
6683
diff
changeset
|
307 |
378, 378, ///< ž tiny |
4cc327ad39d5
(svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents:
6683
diff
changeset
|
308 |
150, 150, ///< Ž medium |
4cc327ad39d5
(svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents:
6683
diff
changeset
|
309 |
154, 154, ///< ž medium |
4cc327ad39d5
(svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents:
6683
diff
changeset
|
310 |
598, 598, ///< Ž large |
4cc327ad39d5
(svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents:
6683
diff
changeset
|
311 |
602, 602, ///< ž large |
4cc327ad39d5
(svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents:
6683
diff
changeset
|
312 |
640, 640, ///< Þ large |
4cc327ad39d5
(svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents:
6683
diff
changeset
|
313 |
672, 672, ///< þ large |
4cc327ad39d5
(svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents:
6683
diff
changeset
|
314 |
380, 380, ///< º tiny |
4cc327ad39d5
(svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents:
6683
diff
changeset
|
315 |
156, 156, ///< º medium |
4cc327ad39d5
(svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents:
6683
diff
changeset
|
316 |
604, 604, ///< º large |
6505
abcb0580d976
(svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents:
6429
diff
changeset
|
317 |
317, 320, ///< { | } ~ tiny |
abcb0580d976
(svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents:
6429
diff
changeset
|
318 |
93, 96, ///< { | } ~ medium |
abcb0580d976
(svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents:
6429
diff
changeset
|
319 |
541, 544, ///< { | } ~ large |
6719
4cc327ad39d5
(svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents:
6683
diff
changeset
|
320 |
585, 585, ///< § large |
4cc327ad39d5
(svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents:
6683
diff
changeset
|
321 |
587, 587, ///< © large |
4cc327ad39d5
(svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents:
6683
diff
changeset
|
322 |
592, 592, ///< ® large |
4cc327ad39d5
(svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents:
6683
diff
changeset
|
323 |
594, 597, ///< ° ± ² ³ large |
4cc327ad39d5
(svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents:
6683
diff
changeset
|
324 |
633, 633, ///< × large |
4cc327ad39d5
(svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents:
6683
diff
changeset
|
325 |
665, 665, ///< ÷ large |
4cc327ad39d5
(svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents:
6683
diff
changeset
|
326 |
377, 377, ///< · small |
4cc327ad39d5
(svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents:
6683
diff
changeset
|
327 |
153, 153, ///< · medium |
4cc327ad39d5
(svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents:
6683
diff
changeset
|
328 |
601, 601, ///< · large |
2588
40d7dba79fc7
(svn r3125) Symbolic names for skiping sprites and the end of the sprite list
tron
parents:
2577
diff
changeset
|
329 |
END |
2353 | 330 |
}; |
331 |
||
2342
c19fb4f2df30
(svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents:
2340
diff
changeset
|
332 |
|
6573 | 333 |
static void LoadSpriteTables() |
0 | 334 |
{ |
6871
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
335 |
const FileList *files = _use_dos_palette ? &files_dos : &files_win; |
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
336 |
uint i = FIRST_GRF_SLOT; |
614
e016770cb781
(svn r1038) Feature: OpenTTD runs with the grf files of the DOS version
dominik
parents:
579
diff
changeset
|
337 |
|
6871
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
338 |
LoadGrfIndexed(files->basic[0].filename, trg1idx, i++); |
2407 | 339 |
DupSprite( 2, 130); // non-breaking space medium |
340 |
DupSprite(226, 354); // non-breaking space tiny |
|
341 |
DupSprite(450, 578); // non-breaking space large |
|
2353 | 342 |
|
6871
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
343 |
/* |
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
344 |
* The second basic file always starts at the given location and does |
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
345 |
* contain a different amount of sprites depending on the "type"; DOS |
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
346 |
* has a few sprites less. However, we do not care about those missing |
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
347 |
* sprites as they are not shown anyway (logos in intro game). |
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
348 |
*/ |
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
349 |
LoadGrfFile(files->basic[1].filename, 4793, i++); |
0 | 350 |
|
6871
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
351 |
/* |
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
352 |
* Load additional sprites for climates other than temperate. |
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
353 |
* This overwrites some of the temperate sprites, such as foundations |
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
354 |
* and the ground sprites. |
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
355 |
*/ |
6683
7ec558346172
(svn r9400) -Codechange: Use some more representative enum names for landscape types.
belugas
parents:
6574
diff
changeset
|
356 |
if (_opt.landscape != LT_TEMPERATE) { |
2309 | 357 |
LoadGrfIndexed( |
5151
0f939d1c0896
(svn r7246) -Codechange: Always reload sprite and NewGRF data when loading or starting a game, instead of only when the climate type is different.
peter1138
parents:
5000
diff
changeset
|
358 |
files->landscape[_opt.landscape - 1].filename, |
0f939d1c0896
(svn r7246) -Codechange: Always reload sprite and NewGRF data when loading or starting a game, instead of only when the climate type is different.
peter1138
parents:
5000
diff
changeset
|
359 |
_landscape_spriteindexes[_opt.landscape - 1], |
2309 | 360 |
i++ |
361 |
); |
|
362 |
} |
|
0 | 363 |
|
6871
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
364 |
LoadGrfIndexed(files->chars.filename, _chars_grf_indexes, i++); |
6719
4cc327ad39d5
(svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents:
6683
diff
changeset
|
365 |
|
5156
5edaa8f9b295
(svn r7254) -Fix (r7250): move unicode glyph map initialisation to just before newgrf files are loaded, else newgrf glyphs will be cleared out too. (thanks Hadez)
peter1138
parents:
5151
diff
changeset
|
366 |
/* Initialize the unicode to sprite mapping table */ |
5edaa8f9b295
(svn r7254) -Fix (r7250): move unicode glyph map initialisation to just before newgrf files are loaded, else newgrf glyphs will be cleared out too. (thanks Hadez)
peter1138
parents:
5151
diff
changeset
|
367 |
InitializeUnicodeGlyphMap(); |
5edaa8f9b295
(svn r7254) -Fix (r7250): move unicode glyph map initialisation to just before newgrf files are loaded, else newgrf glyphs will be cleared out too. (thanks Hadez)
peter1138
parents:
5151
diff
changeset
|
368 |
|
6871
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
369 |
/* |
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
370 |
* Load the base NewGRF with OTTD required graphics as first NewGRF. |
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
371 |
* However, we do not want it to show up in the list of used NewGRFs, |
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
372 |
* so we have to manually add it, and then remove it later. |
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
373 |
*/ |
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
374 |
GRFConfig *top = _grfconfig; |
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
375 |
GRFConfig *master = CallocT<GRFConfig>(1); |
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
376 |
master->filename = strdup(files->openttd.filename); |
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
377 |
FillGRFDetails(master, false); |
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
378 |
ClrBit(master->flags, GCF_INIT_ONLY); |
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
379 |
master->next = top; |
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
380 |
_grfconfig = master; |
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
381 |
|
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
382 |
LoadNewGRF(SPR_NEWGRFS_BASE, i); |
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
383 |
|
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
384 |
/* Free and remove the top element. */ |
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
385 |
ClearGRFConfig(&master); |
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
386 |
_grfconfig = top; |
0 | 387 |
} |
388 |
||
389 |
||
6573 | 390 |
void GfxLoadSprites() |
1093
e8d26c7dc42f
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1070
diff
changeset
|
391 |
{ |
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5296
diff
changeset
|
392 |
DEBUG(sprite, 2, "Loading sprite set %d", _opt.landscape); |
0 | 393 |
|
5151
0f939d1c0896
(svn r7246) -Codechange: Always reload sprite and NewGRF data when loading or starting a game, instead of only when the climate type is different.
peter1138
parents:
5000
diff
changeset
|
394 |
GfxInitSpriteMem(); |
0f939d1c0896
(svn r7246) -Codechange: Always reload sprite and NewGRF data when loading or starting a game, instead of only when the climate type is different.
peter1138
parents:
5000
diff
changeset
|
395 |
LoadSpriteTables(); |
0f939d1c0896
(svn r7246) -Codechange: Always reload sprite and NewGRF data when loading or starting a game, instead of only when the climate type is different.
peter1138
parents:
5000
diff
changeset
|
396 |
GfxInitPalettes(); |
0 | 397 |
} |