author | rubidium |
Thu, 01 Feb 2007 15:49:12 +0000 | |
changeset 5893 | 7e431a4abebb |
parent 5764 | c30289780789 |
child 6012 | 065d7234a7a9 |
permissions | -rw-r--r-- |
2186 | 1 |
/* $Id$ */ |
2 |
||
0 | 3 |
#include "stdafx.h" |
1891
862800791170
(svn r2397) - CodeChange: rename all "ttd" files to "openttd" files.
Darkvater
parents:
1844
diff
changeset
|
4 |
#include "openttd.h" |
1299
39c06aba09aa
(svn r1803) Move debugging stuff into files of it's own
tron
parents:
1250
diff
changeset
|
5 |
#include "debug.h" |
2163
b17b313113a0
(svn r2673) Include functions.h directly, not globally via openttd.h
tron
parents:
2159
diff
changeset
|
6 |
#include "functions.h" |
0 | 7 |
#include "gfx.h" |
2340
e18ef06bc59a
(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
|
8 |
#include "gfxinit.h" |
1349
15979a2e9001
(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
|
9 |
#include "spritecache.h" |
1363
775a7ee52369
(svn r1867) Include tables/sprites.h only in files which need it
tron
parents:
1361
diff
changeset
|
10 |
#include "table/sprites.h" |
0 | 11 |
#include "fileio.h" |
4200
e6ba94085b81
(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
|
12 |
#include "string.h" |
463
97ec66c280f2
(svn r687) Export InitNewGRFFile() and DecodeSpecialSprite() properly.
pasky
parents:
452
diff
changeset
|
13 |
#include "newgrf.h" |
961 | 14 |
#include "md5.h" |
2159
f6284cf5fab0
(svn r2669) Shuffle some more stuff around to reduce dependencies
tron
parents:
2142
diff
changeset
|
15 |
#include "variables.h" |
5156
771ed0d9f836
(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
|
16 |
#include "fontcache.h" |
4472
93758d1da52d
(svn r6257) Use memcmp() to check the MD5 sum instead of using a home brewed loop
tron
parents:
4209
diff
changeset
|
17 |
#include <string.h> |
0 | 18 |
|
961 | 19 |
typedef struct MD5File { |
5587
167d9a91ef02
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5584
diff
changeset
|
20 |
const char * filename; // filename |
167d9a91ef02
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5584
diff
changeset
|
21 |
md5_byte_t hash[16]; // md5 sum of the file |
961 | 22 |
} MD5File; |
23 |
||
614
b96f987dbf80
(svn r1038) Feature: OpenTTD runs with the grf files of the DOS version
dominik
parents:
579
diff
changeset
|
24 |
typedef struct FileList { |
5587
167d9a91ef02
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5584
diff
changeset
|
25 |
MD5File basic[4]; // grf files that always have to be loaded |
167d9a91ef02
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5584
diff
changeset
|
26 |
MD5File landscape[3]; // landscape specific grf files |
614
b96f987dbf80
(svn r1038) Feature: OpenTTD runs with the grf files of the DOS version
dominik
parents:
579
diff
changeset
|
27 |
} FileList; |
0 | 28 |
|
2588
e719db837e8a
(svn r3125) Symbolic names for skiping sprites and the end of the sprite list
tron
parents:
2577
diff
changeset
|
29 |
enum { |
e719db837e8a
(svn r3125) Symbolic names for skiping sprites and the end of the sprite list
tron
parents:
2577
diff
changeset
|
30 |
SKIP = 0xFFFE, |
e719db837e8a
(svn r3125) Symbolic names for skiping sprites and the end of the sprite list
tron
parents:
2577
diff
changeset
|
31 |
END = 0xFFFF |
e719db837e8a
(svn r3125) Symbolic names for skiping sprites and the end of the sprite list
tron
parents:
2577
diff
changeset
|
32 |
}; |
e719db837e8a
(svn r3125) Symbolic names for skiping sprites and the end of the sprite list
tron
parents:
2577
diff
changeset
|
33 |
|
961 | 34 |
#include "table/files.h" |
0 | 35 |
#include "table/landscape_sprite.h" |
36 |
||
2187
a0e206ce9fbf
(svn r2702) -Codechange: Cleaned up the sprite code and replaced many magic numbers
celestar
parents:
2186
diff
changeset
|
37 |
static const SpriteID * const _landscape_spriteindexes[] = { |
0 | 38 |
_landscape_spriteindexes_1, |
39 |
_landscape_spriteindexes_2, |
|
40 |
_landscape_spriteindexes_3, |
|
41 |
}; |
|
42 |
||
2187
a0e206ce9fbf
(svn r2702) -Codechange: Cleaned up the sprite code and replaced many magic numbers
celestar
parents:
2186
diff
changeset
|
43 |
static const SpriteID * const _slopes_spriteindexes[] = { |
37
61bf1df68d82
(svn r38) Preliminary slopes graphics fix. Neighboring tile check not done yet
dominik
parents:
0
diff
changeset
|
44 |
_slopes_spriteindexes_0, |
61bf1df68d82
(svn r38) Preliminary slopes graphics fix. Neighboring tile check not done yet
dominik
parents:
0
diff
changeset
|
45 |
_slopes_spriteindexes_1, |
61bf1df68d82
(svn r38) Preliminary slopes graphics fix. Neighboring tile check not done yet
dominik
parents:
0
diff
changeset
|
46 |
_slopes_spriteindexes_2, |
61bf1df68d82
(svn r38) Preliminary slopes graphics fix. Neighboring tile check not done yet
dominik
parents:
0
diff
changeset
|
47 |
_slopes_spriteindexes_3, |
61bf1df68d82
(svn r38) Preliminary slopes graphics fix. Neighboring tile check not done yet
dominik
parents:
0
diff
changeset
|
48 |
}; |
61bf1df68d82
(svn r38) Preliminary slopes graphics fix. Neighboring tile check not done yet
dominik
parents:
0
diff
changeset
|
49 |
|
61bf1df68d82
(svn r38) Preliminary slopes graphics fix. Neighboring tile check not done yet
dominik
parents:
0
diff
changeset
|
50 |
|
2342
aae24c9661ba
(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
|
51 |
static uint LoadGrfFile(const char* filename, uint load_index, int file_index) |
0 | 52 |
{ |
2342
aae24c9661ba
(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
|
53 |
uint load_index_org = load_index; |
0 | 54 |
|
55 |
FioOpenFile(file_index, filename); |
|
365
957b98a0e1e8
(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
|
56 |
|
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5296
diff
changeset
|
57 |
DEBUG(sprite, 2, "Reading grf-file '%s'", filename); |
0 | 58 |
|
59 |
while (LoadNextSprite(load_index, file_index)) { |
|
60 |
load_index++; |
|
2187
a0e206ce9fbf
(svn r2702) -Codechange: Cleaned up the sprite code and replaced many magic numbers
celestar
parents:
2186
diff
changeset
|
61 |
if (load_index >= MAX_SPRITES) { |
a0e206ce9fbf
(svn r2702) -Codechange: Cleaned up the sprite code and replaced many magic numbers
celestar
parents:
2186
diff
changeset
|
62 |
error("Too many sprites. Recompile with higher MAX_SPRITES value or remove some custom GRF files."); |
0 | 63 |
} |
64 |
} |
|
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5296
diff
changeset
|
65 |
DEBUG(sprite, 2, "Currently %i sprites are loaded", load_index); |
0 | 66 |
|
365
957b98a0e1e8
(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
|
67 |
return load_index - load_index_org; |
957b98a0e1e8
(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
|
68 |
} |
957b98a0e1e8
(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
|
69 |
|
2342
aae24c9661ba
(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
|
70 |
|
aae24c9661ba
(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
|
71 |
static void LoadGrfIndexed(const char* filename, const SpriteID* index_tbl, int file_index) |
365
957b98a0e1e8
(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
|
72 |
{ |
2342
aae24c9661ba
(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
|
73 |
uint start; |
614
b96f987dbf80
(svn r1038) Feature: OpenTTD runs with the grf files of the DOS version
dominik
parents:
579
diff
changeset
|
74 |
|
365
957b98a0e1e8
(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
|
75 |
FioOpenFile(file_index, filename); |
957b98a0e1e8
(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
|
76 |
|
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5296
diff
changeset
|
77 |
DEBUG(sprite, 2, "Reading indexed grf-file '%s'", filename); |
0 | 78 |
|
2588
e719db837e8a
(svn r3125) Symbolic names for skiping sprites and the end of the sprite list
tron
parents:
2577
diff
changeset
|
79 |
while ((start = *index_tbl++) != END) { |
2342
aae24c9661ba
(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
|
80 |
uint end = *index_tbl++; |
aae24c9661ba
(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
|
81 |
|
2588
e719db837e8a
(svn r3125) Symbolic names for skiping sprites and the end of the sprite list
tron
parents:
2577
diff
changeset
|
82 |
if (start == SKIP) { // skip sprites (amount in second var) |
37
61bf1df68d82
(svn r38) Preliminary slopes graphics fix. Neighboring tile check not done yet
dominik
parents:
0
diff
changeset
|
83 |
SkipSprites(end); |
61bf1df68d82
(svn r38) Preliminary slopes graphics fix. Neighboring tile check not done yet
dominik
parents:
0
diff
changeset
|
84 |
} else { // load sprites and use indexes from start to end |
61bf1df68d82
(svn r38) Preliminary slopes graphics fix. Neighboring tile check not done yet
dominik
parents:
0
diff
changeset
|
85 |
do { |
1844
f1552d831ed5
(svn r2349) - Fix: remove warning from release build when assertions are no longer active
Darkvater
parents:
1725
diff
changeset
|
86 |
#ifdef NDEBUG |
f1552d831ed5
(svn r2349) - Fix: remove warning from release build when assertions are no longer active
Darkvater
parents:
1725
diff
changeset
|
87 |
LoadNextSprite(start, file_index); |
f1552d831ed5
(svn r2349) - Fix: remove warning from release build when assertions are no longer active
Darkvater
parents:
1725
diff
changeset
|
88 |
#else |
37
61bf1df68d82
(svn r38) Preliminary slopes graphics fix. Neighboring tile check not done yet
dominik
parents:
0
diff
changeset
|
89 |
bool b = LoadNextSprite(start, file_index); |
61bf1df68d82
(svn r38) Preliminary slopes graphics fix. Neighboring tile check not done yet
dominik
parents:
0
diff
changeset
|
90 |
assert(b); |
1844
f1552d831ed5
(svn r2349) - Fix: remove warning from release build when assertions are no longer active
Darkvater
parents:
1725
diff
changeset
|
91 |
#endif |
37
61bf1df68d82
(svn r38) Preliminary slopes graphics fix. Neighboring tile check not done yet
dominik
parents:
0
diff
changeset
|
92 |
} while (++start <= end); |
61bf1df68d82
(svn r38) Preliminary slopes graphics fix. Neighboring tile check not done yet
dominik
parents:
0
diff
changeset
|
93 |
} |
0 | 94 |
} |
184
dbeaaaf8b2bb
(svn r185) -Fix: [1016954] Cached_sprites does now work again
truelight
parents:
182
diff
changeset
|
95 |
} |
0 | 96 |
|
97 |
||
961 | 98 |
/* Check that the supplied MD5 hash matches that stored for the supplied filename */ |
99 |
static bool CheckMD5Digest(const MD5File file, md5_byte_t *digest, bool warn) |
|
100 |
{ |
|
4472
93758d1da52d
(svn r6257) Use memcmp() to check the MD5 sum instead of using a home brewed loop
tron
parents:
4209
diff
changeset
|
101 |
if (memcmp(file.hash, digest, sizeof(file.hash)) == 0) return true; |
93758d1da52d
(svn r6257) Use memcmp() to check the MD5 sum instead of using a home brewed loop
tron
parents:
4209
diff
changeset
|
102 |
if (warn) fprintf(stderr, "MD5 of %s is ****INCORRECT**** - File Corrupt.\n", file.filename); |
93758d1da52d
(svn r6257) Use memcmp() to check the MD5 sum instead of using a home brewed loop
tron
parents:
4209
diff
changeset
|
103 |
return false; |
961 | 104 |
} |
105 |
||
1019
6bae6c11e865
(svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents:
966
diff
changeset
|
106 |
/* Calculate and check the MD5 hash of the supplied filename. |
961 | 107 |
* returns true if the checksum is correct */ |
108 |
static bool FileMD5(const MD5File file, bool warn) |
|
614
b96f987dbf80
(svn r1038) Feature: OpenTTD runs with the grf files of the DOS version
dominik
parents:
579
diff
changeset
|
109 |
{ |
b96f987dbf80
(svn r1038) Feature: OpenTTD runs with the grf files of the DOS version
dominik
parents:
579
diff
changeset
|
110 |
FILE *f; |
961 | 111 |
char buf[MAX_PATH]; |
614
b96f987dbf80
(svn r1038) Feature: OpenTTD runs with the grf files of the DOS version
dominik
parents:
579
diff
changeset
|
112 |
|
961 | 113 |
// open file |
5296
e7acddfdd8a7
(svn r7449) -Codechange: Rename _path to _paths as it is technically more correct, but mainly because
Darkvater
parents:
5170
diff
changeset
|
114 |
snprintf(buf, lengthof(buf), "%s%s", _paths.data_dir, file.filename); |
961 | 115 |
f = fopen(buf, "rb"); |
116 |
||
117 |
#if !defined(WIN32) |
|
118 |
if (f == NULL) { |
|
5296
e7acddfdd8a7
(svn r7449) -Codechange: Rename _path to _paths as it is technically more correct, but mainly because
Darkvater
parents:
5170
diff
changeset
|
119 |
strtolower(buf + strlen(_paths.data_dir) - 1); |
961 | 120 |
f = fopen(buf, "rb"); |
614
b96f987dbf80
(svn r1038) Feature: OpenTTD runs with the grf files of the DOS version
dominik
parents:
579
diff
changeset
|
121 |
} |
961 | 122 |
#endif |
614
b96f987dbf80
(svn r1038) Feature: OpenTTD runs with the grf files of the DOS version
dominik
parents:
579
diff
changeset
|
123 |
|
5482
0528f1dfb732
(svn r7766) -Fix: [OSX] removed incorrect debug message about corrupted/missing grf files
bjarni
parents:
5475
diff
changeset
|
124 |
#if defined SECOND_DATA_DIR |
0528f1dfb732
(svn r7766) -Fix: [OSX] removed incorrect debug message about corrupted/missing grf files
bjarni
parents:
5475
diff
changeset
|
125 |
/* If we failed to find the file in the first data directory, we will try the other one */ |
0528f1dfb732
(svn r7766) -Fix: [OSX] removed incorrect debug message about corrupted/missing grf files
bjarni
parents:
5475
diff
changeset
|
126 |
|
0528f1dfb732
(svn r7766) -Fix: [OSX] removed incorrect debug message about corrupted/missing grf files
bjarni
parents:
5475
diff
changeset
|
127 |
if (f == NULL) { |
0528f1dfb732
(svn r7766) -Fix: [OSX] removed incorrect debug message about corrupted/missing grf files
bjarni
parents:
5475
diff
changeset
|
128 |
snprintf(buf, lengthof(buf), "%s%s", _paths.second_data_dir, file.filename); |
0528f1dfb732
(svn r7766) -Fix: [OSX] removed incorrect debug message about corrupted/missing grf files
bjarni
parents:
5475
diff
changeset
|
129 |
f = fopen(buf, "rb"); |
0528f1dfb732
(svn r7766) -Fix: [OSX] removed incorrect debug message about corrupted/missing grf files
bjarni
parents:
5475
diff
changeset
|
130 |
|
0528f1dfb732
(svn r7766) -Fix: [OSX] removed incorrect debug message about corrupted/missing grf files
bjarni
parents:
5475
diff
changeset
|
131 |
if (f == NULL) { |
0528f1dfb732
(svn r7766) -Fix: [OSX] removed incorrect debug message about corrupted/missing grf files
bjarni
parents:
5475
diff
changeset
|
132 |
strtolower(buf + strlen(_paths.second_data_dir) - 1); |
0528f1dfb732
(svn r7766) -Fix: [OSX] removed incorrect debug message about corrupted/missing grf files
bjarni
parents:
5475
diff
changeset
|
133 |
f = fopen(buf, "rb"); |
0528f1dfb732
(svn r7766) -Fix: [OSX] removed incorrect debug message about corrupted/missing grf files
bjarni
parents:
5475
diff
changeset
|
134 |
} |
0528f1dfb732
(svn r7766) -Fix: [OSX] removed incorrect debug message about corrupted/missing grf files
bjarni
parents:
5475
diff
changeset
|
135 |
} |
0528f1dfb732
(svn r7766) -Fix: [OSX] removed incorrect debug message about corrupted/missing grf files
bjarni
parents:
5475
diff
changeset
|
136 |
#endif |
0528f1dfb732
(svn r7766) -Fix: [OSX] removed incorrect debug message about corrupted/missing grf files
bjarni
parents:
5475
diff
changeset
|
137 |
|
862
9baf2b0cdb18
(svn r1343) -Fix: [Graphic] Autorail icon is now correct (Darkvater)
truelight
parents:
614
diff
changeset
|
138 |
if (f != NULL) { |
2028
fff064370a36
(svn r2537) Small changes, especially use fprintf to stderr for warnings and errors instead of plain printf
tron
parents:
2027
diff
changeset
|
139 |
md5_state_t filemd5state; |
fff064370a36
(svn r2537) Small changes, especially use fprintf to stderr for warnings and errors instead of plain printf
tron
parents:
2027
diff
changeset
|
140 |
md5_byte_t buffer[1024]; |
fff064370a36
(svn r2537) Small changes, especially use fprintf to stderr for warnings and errors instead of plain printf
tron
parents:
2027
diff
changeset
|
141 |
md5_byte_t digest[16]; |
fff064370a36
(svn r2537) Small changes, especially use fprintf to stderr for warnings and errors instead of plain printf
tron
parents:
2027
diff
changeset
|
142 |
size_t len; |
fff064370a36
(svn r2537) Small changes, especially use fprintf to stderr for warnings and errors instead of plain printf
tron
parents:
2027
diff
changeset
|
143 |
|
961 | 144 |
md5_init(&filemd5state); |
2028
fff064370a36
(svn r2537) Small changes, especially use fprintf to stderr for warnings and errors instead of plain printf
tron
parents:
2027
diff
changeset
|
145 |
while ((len = fread(buffer, 1, sizeof(buffer), f)) != 0) |
961 | 146 |
md5_append(&filemd5state, buffer, len); |
147 |
||
5764
c30289780789
(svn r8315) -Fix: use ShowInfo over fprintf(stderr, as Windows doesn't always have a stderr visible/available
truelight
parents:
5587
diff
changeset
|
148 |
if (ferror(f) && warn) ShowInfoF("Error Reading from %s \n", buf); |
961 | 149 |
fclose(f); |
1019
6bae6c11e865
(svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents:
966
diff
changeset
|
150 |
|
961 | 151 |
md5_finish(&filemd5state, digest); |
2639 | 152 |
return CheckMD5Digest(file, digest, warn); |
961 | 153 |
} else { // file not found |
154 |
return false; |
|
1019
6bae6c11e865
(svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents:
966
diff
changeset
|
155 |
} |
961 | 156 |
} |
157 |
||
158 |
/* Checks, if either the Windows files exist (TRG1R.GRF) or the DOS files (TRG1.GRF) |
|
159 |
* by comparing the MD5 checksums of the files. _use_dos_palette is set accordingly. |
|
1019
6bae6c11e865
(svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents:
966
diff
changeset
|
160 |
* If neither are found, Windows palette is assumed. |
961 | 161 |
* |
162 |
* (Note: Also checks sample.cat for corruption) */ |
|
1093
4fdc46eaf423
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1070
diff
changeset
|
163 |
void CheckExternalFiles(void) |
961 | 164 |
{ |
1355 | 165 |
uint i; |
166 |
// count of files from this version |
|
167 |
uint dos = 0; |
|
168 |
uint win = 0; |
|
961 | 169 |
|
2028
fff064370a36
(svn r2537) Small changes, especially use fprintf to stderr for warnings and errors instead of plain printf
tron
parents:
2027
diff
changeset
|
170 |
for (i = 0; i < 2; i++) if (FileMD5(files_dos.basic[i], true)) dos++; |
fff064370a36
(svn r2537) Small changes, especially use fprintf to stderr for warnings and errors instead of plain printf
tron
parents:
2027
diff
changeset
|
171 |
for (i = 0; i < 3; i++) if (FileMD5(files_dos.landscape[i], true)) dos++; |
961 | 172 |
|
2028
fff064370a36
(svn r2537) Small changes, especially use fprintf to stderr for warnings and errors instead of plain printf
tron
parents:
2027
diff
changeset
|
173 |
for (i = 0; i < 2; i++) if (FileMD5(files_win.basic[i], true)) win++; |
fff064370a36
(svn r2537) Small changes, especially use fprintf to stderr for warnings and errors instead of plain printf
tron
parents:
2027
diff
changeset
|
174 |
for (i = 0; i < 3; i++) if (FileMD5(files_win.landscape[i], true)) win++; |
961 | 175 |
|
1355 | 176 |
if (!FileMD5(sample_cat_win, false) && !FileMD5(sample_cat_dos, false)) |
5576
b19c640dfc37
(svn r8013) -Codechange (r6921, rUnknown): Show the error message of corrupt or missing (own) files
Darkvater
parents:
5482
diff
changeset
|
177 |
ShowInfo("Your 'sample.cat' file is corrupted or missing!"); |
961 | 178 |
|
4934
e62da41b70e3
(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
|
179 |
for (i = 0; i < lengthof(files_openttd); i++) { |
e62da41b70e3
(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
|
180 |
if (!FileMD5(files_openttd[i], false)) { |
5576
b19c640dfc37
(svn r8013) -Codechange (r6921, rUnknown): Show the error message of corrupt or missing (own) files
Darkvater
parents:
5482
diff
changeset
|
181 |
ShowInfoF("Your '%s' file is corrupted or missing!", files_openttd[i].filename); |
4934
e62da41b70e3
(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
|
182 |
} |
e62da41b70e3
(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
|
183 |
} |
e62da41b70e3
(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
|
184 |
|
1380
72aa0a5df4db
(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
|
185 |
/* |
1389 | 186 |
* forced DOS palette via command line -> leave it that way |
1380
72aa0a5df4db
(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
|
187 |
* all Windows files present -> Windows palette |
72aa0a5df4db
(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
|
188 |
* all DOS files present -> DOS palette |
72aa0a5df4db
(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
|
189 |
* no Windows files present and any DOS file present -> DOS palette |
72aa0a5df4db
(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
|
190 |
* otherwise -> Windows palette |
72aa0a5df4db
(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
|
191 |
*/ |
1389 | 192 |
if (_use_dos_palette) { |
193 |
return; |
|
194 |
} else if (win == 5) { |
|
961 | 195 |
_use_dos_palette = false; |
1381 | 196 |
} else if (dos == 5 || (win == 0 && dos > 0)) { |
614
b96f987dbf80
(svn r1038) Feature: OpenTTD runs with the grf files of the DOS version
dominik
parents:
579
diff
changeset
|
197 |
_use_dos_palette = true; |
1380
72aa0a5df4db
(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
|
198 |
} else { |
961 | 199 |
_use_dos_palette = false; |
614
b96f987dbf80
(svn r1038) Feature: OpenTTD runs with the grf files of the DOS version
dominik
parents:
579
diff
changeset
|
200 |
} |
b96f987dbf80
(svn r1038) Feature: OpenTTD runs with the grf files of the DOS version
dominik
parents:
579
diff
changeset
|
201 |
} |
b96f987dbf80
(svn r1038) Feature: OpenTTD runs with the grf files of the DOS version
dominik
parents:
579
diff
changeset
|
202 |
|
2342
aae24c9661ba
(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
|
203 |
|
2353 | 204 |
static const SpriteID trg1idx[] = { |
2588
e719db837e8a
(svn r3125) Symbolic names for skiping sprites and the end of the sprite list
tron
parents:
2577
diff
changeset
|
205 |
0, 1, // Mouse cursor, ZZZ |
2353 | 206 |
/* Medium font */ |
2588
e719db837e8a
(svn r3125) Symbolic names for skiping sprites and the end of the sprite list
tron
parents:
2577
diff
changeset
|
207 |
2, 92, // ' ' till 'z' |
e719db837e8a
(svn r3125) Symbolic names for skiping sprites and the end of the sprite list
tron
parents:
2577
diff
changeset
|
208 |
SKIP, 36, |
e719db837e8a
(svn r3125) Symbolic names for skiping sprites and the end of the sprite list
tron
parents:
2577
diff
changeset
|
209 |
160, 160, // Move ¾ to the correct position |
e719db837e8a
(svn r3125) Symbolic names for skiping sprites and the end of the sprite list
tron
parents:
2577
diff
changeset
|
210 |
98, 98, // Up arrow |
e719db837e8a
(svn r3125) Symbolic names for skiping sprites and the end of the sprite list
tron
parents:
2577
diff
changeset
|
211 |
131, 133, |
e719db837e8a
(svn r3125) Symbolic names for skiping sprites and the end of the sprite list
tron
parents:
2577
diff
changeset
|
212 |
SKIP, 1, // skip currency sign |
e719db837e8a
(svn r3125) Symbolic names for skiping sprites and the end of the sprite list
tron
parents:
2577
diff
changeset
|
213 |
135, 135, |
e719db837e8a
(svn r3125) Symbolic names for skiping sprites and the end of the sprite list
tron
parents:
2577
diff
changeset
|
214 |
SKIP, 1, |
e719db837e8a
(svn r3125) Symbolic names for skiping sprites and the end of the sprite list
tron
parents:
2577
diff
changeset
|
215 |
137, 137, |
e719db837e8a
(svn r3125) Symbolic names for skiping sprites and the end of the sprite list
tron
parents:
2577
diff
changeset
|
216 |
SKIP, 1, |
e719db837e8a
(svn r3125) Symbolic names for skiping sprites and the end of the sprite list
tron
parents:
2577
diff
changeset
|
217 |
139, 139, |
e719db837e8a
(svn r3125) Symbolic names for skiping sprites and the end of the sprite list
tron
parents:
2577
diff
changeset
|
218 |
140, 140, // TODO Down arrow |
e719db837e8a
(svn r3125) Symbolic names for skiping sprites and the end of the sprite list
tron
parents:
2577
diff
changeset
|
219 |
141, 141, |
e719db837e8a
(svn r3125) Symbolic names for skiping sprites and the end of the sprite list
tron
parents:
2577
diff
changeset
|
220 |
142, 142, // TODO Check mark |
e719db837e8a
(svn r3125) Symbolic names for skiping sprites and the end of the sprite list
tron
parents:
2577
diff
changeset
|
221 |
143, 143, // TODO Cross |
e719db837e8a
(svn r3125) Symbolic names for skiping sprites and the end of the sprite list
tron
parents:
2577
diff
changeset
|
222 |
144, 144, |
e719db837e8a
(svn r3125) Symbolic names for skiping sprites and the end of the sprite list
tron
parents:
2577
diff
changeset
|
223 |
145, 145, // TODO Right arrow |
e719db837e8a
(svn r3125) Symbolic names for skiping sprites and the end of the sprite list
tron
parents:
2577
diff
changeset
|
224 |
146, 149, |
e719db837e8a
(svn r3125) Symbolic names for skiping sprites and the end of the sprite list
tron
parents:
2577
diff
changeset
|
225 |
118, 122, // Transport markers |
e719db837e8a
(svn r3125) Symbolic names for skiping sprites and the end of the sprite list
tron
parents:
2577
diff
changeset
|
226 |
SKIP, 2, |
e719db837e8a
(svn r3125) Symbolic names for skiping sprites and the end of the sprite list
tron
parents:
2577
diff
changeset
|
227 |
157, 157, |
e719db837e8a
(svn r3125) Symbolic names for skiping sprites and the end of the sprite list
tron
parents:
2577
diff
changeset
|
228 |
114, 115, // Small up/down arrows |
e719db837e8a
(svn r3125) Symbolic names for skiping sprites and the end of the sprite list
tron
parents:
2577
diff
changeset
|
229 |
SKIP, 1, |
e719db837e8a
(svn r3125) Symbolic names for skiping sprites and the end of the sprite list
tron
parents:
2577
diff
changeset
|
230 |
161, 225, |
2353 | 231 |
/* Small font */ |
2588
e719db837e8a
(svn r3125) Symbolic names for skiping sprites and the end of the sprite list
tron
parents:
2577
diff
changeset
|
232 |
226, 316, // ' ' till 'z' |
e719db837e8a
(svn r3125) Symbolic names for skiping sprites and the end of the sprite list
tron
parents:
2577
diff
changeset
|
233 |
SKIP, 36, |
e719db837e8a
(svn r3125) Symbolic names for skiping sprites and the end of the sprite list
tron
parents:
2577
diff
changeset
|
234 |
384, 384, // Move ¾ to the correct position |
e719db837e8a
(svn r3125) Symbolic names for skiping sprites and the end of the sprite list
tron
parents:
2577
diff
changeset
|
235 |
322, 322, // Up arrow |
e719db837e8a
(svn r3125) Symbolic names for skiping sprites and the end of the sprite list
tron
parents:
2577
diff
changeset
|
236 |
355, 357, |
e719db837e8a
(svn r3125) Symbolic names for skiping sprites and the end of the sprite list
tron
parents:
2577
diff
changeset
|
237 |
SKIP, 1, // skip currency sign |
e719db837e8a
(svn r3125) Symbolic names for skiping sprites and the end of the sprite list
tron
parents:
2577
diff
changeset
|
238 |
359, 359, |
e719db837e8a
(svn r3125) Symbolic names for skiping sprites and the end of the sprite list
tron
parents:
2577
diff
changeset
|
239 |
SKIP, 1, |
e719db837e8a
(svn r3125) Symbolic names for skiping sprites and the end of the sprite list
tron
parents:
2577
diff
changeset
|
240 |
361, 361, |
e719db837e8a
(svn r3125) Symbolic names for skiping sprites and the end of the sprite list
tron
parents:
2577
diff
changeset
|
241 |
SKIP, 1, |
e719db837e8a
(svn r3125) Symbolic names for skiping sprites and the end of the sprite list
tron
parents:
2577
diff
changeset
|
242 |
363, 363, |
e719db837e8a
(svn r3125) Symbolic names for skiping sprites and the end of the sprite list
tron
parents:
2577
diff
changeset
|
243 |
364, 364, // TODO Down arrow |
e719db837e8a
(svn r3125) Symbolic names for skiping sprites and the end of the sprite list
tron
parents:
2577
diff
changeset
|
244 |
365, 366, |
e719db837e8a
(svn r3125) Symbolic names for skiping sprites and the end of the sprite list
tron
parents:
2577
diff
changeset
|
245 |
SKIP, 1, |
e719db837e8a
(svn r3125) Symbolic names for skiping sprites and the end of the sprite list
tron
parents:
2577
diff
changeset
|
246 |
368, 368, |
e719db837e8a
(svn r3125) Symbolic names for skiping sprites and the end of the sprite list
tron
parents:
2577
diff
changeset
|
247 |
369, 369, // TODO Right arrow |
e719db837e8a
(svn r3125) Symbolic names for skiping sprites and the end of the sprite list
tron
parents:
2577
diff
changeset
|
248 |
370, 373, |
e719db837e8a
(svn r3125) Symbolic names for skiping sprites and the end of the sprite list
tron
parents:
2577
diff
changeset
|
249 |
SKIP, 7, |
e719db837e8a
(svn r3125) Symbolic names for skiping sprites and the end of the sprite list
tron
parents:
2577
diff
changeset
|
250 |
381, 381, |
e719db837e8a
(svn r3125) Symbolic names for skiping sprites and the end of the sprite list
tron
parents:
2577
diff
changeset
|
251 |
SKIP, 3, |
e719db837e8a
(svn r3125) Symbolic names for skiping sprites and the end of the sprite list
tron
parents:
2577
diff
changeset
|
252 |
385, 449, |
2353 | 253 |
/* Big font */ |
2588
e719db837e8a
(svn r3125) Symbolic names for skiping sprites and the end of the sprite list
tron
parents:
2577
diff
changeset
|
254 |
450, 540, // ' ' till 'z' |
e719db837e8a
(svn r3125) Symbolic names for skiping sprites and the end of the sprite list
tron
parents:
2577
diff
changeset
|
255 |
SKIP, 36, |
e719db837e8a
(svn r3125) Symbolic names for skiping sprites and the end of the sprite list
tron
parents:
2577
diff
changeset
|
256 |
608, 608, // Move ¾ to the correct position |
e719db837e8a
(svn r3125) Symbolic names for skiping sprites and the end of the sprite list
tron
parents:
2577
diff
changeset
|
257 |
SKIP, 1, |
e719db837e8a
(svn r3125) Symbolic names for skiping sprites and the end of the sprite list
tron
parents:
2577
diff
changeset
|
258 |
579, 581, |
e719db837e8a
(svn r3125) Symbolic names for skiping sprites and the end of the sprite list
tron
parents:
2577
diff
changeset
|
259 |
SKIP, 1, |
e719db837e8a
(svn r3125) Symbolic names for skiping sprites and the end of the sprite list
tron
parents:
2577
diff
changeset
|
260 |
583, 583, |
e719db837e8a
(svn r3125) Symbolic names for skiping sprites and the end of the sprite list
tron
parents:
2577
diff
changeset
|
261 |
SKIP, 5, |
e719db837e8a
(svn r3125) Symbolic names for skiping sprites and the end of the sprite list
tron
parents:
2577
diff
changeset
|
262 |
589, 589, |
e719db837e8a
(svn r3125) Symbolic names for skiping sprites and the end of the sprite list
tron
parents:
2577
diff
changeset
|
263 |
SKIP, 15, |
e719db837e8a
(svn r3125) Symbolic names for skiping sprites and the end of the sprite list
tron
parents:
2577
diff
changeset
|
264 |
605, 605, |
e719db837e8a
(svn r3125) Symbolic names for skiping sprites and the end of the sprite list
tron
parents:
2577
diff
changeset
|
265 |
SKIP, 3, |
e719db837e8a
(svn r3125) Symbolic names for skiping sprites and the end of the sprite list
tron
parents:
2577
diff
changeset
|
266 |
609, 625, |
e719db837e8a
(svn r3125) Symbolic names for skiping sprites and the end of the sprite list
tron
parents:
2577
diff
changeset
|
267 |
SKIP, 1, |
e719db837e8a
(svn r3125) Symbolic names for skiping sprites and the end of the sprite list
tron
parents:
2577
diff
changeset
|
268 |
627, 632, |
e719db837e8a
(svn r3125) Symbolic names for skiping sprites and the end of the sprite list
tron
parents:
2577
diff
changeset
|
269 |
SKIP, 1, |
e719db837e8a
(svn r3125) Symbolic names for skiping sprites and the end of the sprite list
tron
parents:
2577
diff
changeset
|
270 |
634, 639, |
e719db837e8a
(svn r3125) Symbolic names for skiping sprites and the end of the sprite list
tron
parents:
2577
diff
changeset
|
271 |
SKIP, 1, |
e719db837e8a
(svn r3125) Symbolic names for skiping sprites and the end of the sprite list
tron
parents:
2577
diff
changeset
|
272 |
641, 657, |
e719db837e8a
(svn r3125) Symbolic names for skiping sprites and the end of the sprite list
tron
parents:
2577
diff
changeset
|
273 |
SKIP, 1, |
e719db837e8a
(svn r3125) Symbolic names for skiping sprites and the end of the sprite list
tron
parents:
2577
diff
changeset
|
274 |
659, 664, |
e719db837e8a
(svn r3125) Symbolic names for skiping sprites and the end of the sprite list
tron
parents:
2577
diff
changeset
|
275 |
SKIP, 2, |
e719db837e8a
(svn r3125) Symbolic names for skiping sprites and the end of the sprite list
tron
parents:
2577
diff
changeset
|
276 |
667, 671, |
e719db837e8a
(svn r3125) Symbolic names for skiping sprites and the end of the sprite list
tron
parents:
2577
diff
changeset
|
277 |
SKIP, 1, |
e719db837e8a
(svn r3125) Symbolic names for skiping sprites and the end of the sprite list
tron
parents:
2577
diff
changeset
|
278 |
673, 673, |
2353 | 279 |
/* Graphics */ |
2588
e719db837e8a
(svn r3125) Symbolic names for skiping sprites and the end of the sprite list
tron
parents:
2577
diff
changeset
|
280 |
674, 4792, |
e719db837e8a
(svn r3125) Symbolic names for skiping sprites and the end of the sprite list
tron
parents:
2577
diff
changeset
|
281 |
END |
2353 | 282 |
}; |
283 |
||
2565
de04ba1d3a5c
(svn r3102) - Fix (regression): Newly added sprite had problems when newgrf's where loaded. Thanks Tron for explaining what the problem was and how it should be solved.
Darkvater
parents:
2559
diff
changeset
|
284 |
/* NOTE: When adding a normal sprite, increase OPENTTD_SPRITES_COUNT with the |
de04ba1d3a5c
(svn r3102) - Fix (regression): Newly added sprite had problems when newgrf's where loaded. Thanks Tron for explaining what the problem was and how it should be solved.
Darkvater
parents:
2559
diff
changeset
|
285 |
* amount of sprites and add them to the end of the list, with the index of |
de04ba1d3a5c
(svn r3102) - Fix (regression): Newly added sprite had problems when newgrf's where loaded. Thanks Tron for explaining what the problem was and how it should be solved.
Darkvater
parents:
2559
diff
changeset
|
286 |
* the old sprite-count offset from SPR_OPENTTD_BASE. With this there is no |
de04ba1d3a5c
(svn r3102) - Fix (regression): Newly added sprite had problems when newgrf's where loaded. Thanks Tron for explaining what the problem was and how it should be solved.
Darkvater
parents:
2559
diff
changeset
|
287 |
* correspondence of any kind with the ID's in the grf file, but results in |
de04ba1d3a5c
(svn r3102) - Fix (regression): Newly added sprite had problems when newgrf's where loaded. Thanks Tron for explaining what the problem was and how it should be solved.
Darkvater
parents:
2559
diff
changeset
|
288 |
* a maximum use of sprite slots. */ |
2353 | 289 |
static const SpriteID _openttd_grf_indexes[] = { |
2571
550a7d323ced
(svn r3108) Confine the use of SPR_OPENTTD_BASE to table/sprites.h by adding/using some sprite enums
tron
parents:
2565
diff
changeset
|
290 |
SPR_IMG_AUTORAIL, SPR_CURSOR_WAYPOINT, // icons etc |
2353 | 291 |
134, 134, // euro symbol medium size |
292 |
582, 582, // euro symbol large size |
|
293 |
358, 358, // euro symbol tiny |
|
2571
550a7d323ced
(svn r3108) Confine the use of SPR_OPENTTD_BASE to table/sprites.h by adding/using some sprite enums
tron
parents:
2565
diff
changeset
|
294 |
SPR_CURSOR_CANAL, SPR_IMG_FASTFORWARD, // more icons |
2353 | 295 |
648, 648, // nordic char: æ |
296 |
616, 616, // nordic char: Æ |
|
297 |
666, 666, // nordic char: ø |
|
298 |
634, 634, // nordic char: Ø |
|
4935
1eeda247f1ea
(svn r6922) -Feature: Add proper cloning sprites and cursors, different for each vehicle. Big thanks
Darkvater
parents:
4934
diff
changeset
|
299 |
SPR_PIN_UP, SPR_CURSOR_CLONE_TRAIN, // more icons |
2353 | 300 |
382, 383, // ¼ ½ tiny |
301 |
158, 159, // ¼ ½ medium |
|
302 |
606, 607, // ¼ ½ large |
|
303 |
360, 360, // ¦ tiny |
|
304 |
362, 362, // ¨ tiny |
|
305 |
136, 136, // ¦ medium |
|
306 |
138, 138, // ¨ medium |
|
307 |
584, 584, // ¦ large |
|
308 |
586, 586, // ¨ large |
|
309 |
626, 626, // Ð large |
|
310 |
658, 658, // ð large |
|
311 |
374, 374, // ´ tiny |
|
312 |
378, 378, // ¸ tiny |
|
313 |
150, 150, // ´ medium |
|
314 |
154, 154, // ¸ medium |
|
315 |
598, 598, // ´ large |
|
316 |
602, 602, // ¸ large |
|
317 |
640, 640, // Þ large |
|
318 |
672, 672, // þ large |
|
319 |
380, 380, // º tiny |
|
320 |
156, 156, // º medium |
|
321 |
604, 604, // º large |
|
2411 | 322 |
317, 320, // { | } ~ tiny |
323 |
93, 96, // { | } ~ medium |
|
324 |
541, 544, // { | } ~ large |
|
2571
550a7d323ced
(svn r3108) Confine the use of SPR_OPENTTD_BASE to table/sprites.h by adding/using some sprite enums
tron
parents:
2565
diff
changeset
|
325 |
SPR_HOUSE_ICON, SPR_HOUSE_ICON, |
3252
7e4633d205b4
(svn r3940) - FS#56 [Crash] Missing glyph(s) in big-font. Added several missing glyphs for the big font.
Darkvater
parents:
3113
diff
changeset
|
326 |
585, 585, // § large |
7e4633d205b4
(svn r3940) - FS#56 [Crash] Missing glyph(s) in big-font. Added several missing glyphs for the big font.
Darkvater
parents:
3113
diff
changeset
|
327 |
587, 587, // © large |
7e4633d205b4
(svn r3940) - FS#56 [Crash] Missing glyph(s) in big-font. Added several missing glyphs for the big font.
Darkvater
parents:
3113
diff
changeset
|
328 |
592, 592, // ® large |
7e4633d205b4
(svn r3940) - FS#56 [Crash] Missing glyph(s) in big-font. Added several missing glyphs for the big font.
Darkvater
parents:
3113
diff
changeset
|
329 |
594, 597, // ° ± ² ³ large |
7e4633d205b4
(svn r3940) - FS#56 [Crash] Missing glyph(s) in big-font. Added several missing glyphs for the big font.
Darkvater
parents:
3113
diff
changeset
|
330 |
633, 633, // × large |
7e4633d205b4
(svn r3940) - FS#56 [Crash] Missing glyph(s) in big-font. Added several missing glyphs for the big font.
Darkvater
parents:
3113
diff
changeset
|
331 |
665, 665, // ÷ large |
4935
1eeda247f1ea
(svn r6922) -Feature: Add proper cloning sprites and cursors, different for each vehicle. Big thanks
Darkvater
parents:
4934
diff
changeset
|
332 |
SPR_SELL_TRAIN, SPR_SHARED_ORDERS_ICON, |
5000
340be626096e
(svn r7013) Add glyphs for the interpunct. This is mainly useful for the catalan translation
tron
parents:
4936
diff
changeset
|
333 |
377, 377, // · small |
340be626096e
(svn r7013) Add glyphs for the interpunct. This is mainly useful for the catalan translation
tron
parents:
4936
diff
changeset
|
334 |
153, 153, // · medium |
340be626096e
(svn r7013) Add glyphs for the interpunct. This is mainly useful for the catalan translation
tron
parents:
4936
diff
changeset
|
335 |
601, 601, // · large |
2588
e719db837e8a
(svn r3125) Symbolic names for skiping sprites and the end of the sprite list
tron
parents:
2577
diff
changeset
|
336 |
END |
2353 | 337 |
}; |
338 |
||
2342
aae24c9661ba
(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
|
339 |
|
1093
4fdc46eaf423
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1070
diff
changeset
|
340 |
static void LoadSpriteTables(void) |
0 | 341 |
{ |
2639 | 342 |
const FileList* files = _use_dos_palette ? &files_dos : &files_win; |
343 |
uint load_index; |
|
1355 | 344 |
uint i; |
614
b96f987dbf80
(svn r1038) Feature: OpenTTD runs with the grf files of the DOS version
dominik
parents:
579
diff
changeset
|
345 |
|
2353 | 346 |
LoadGrfIndexed(files->basic[0].filename, trg1idx, 0); |
2407 | 347 |
DupSprite( 2, 130); // non-breaking space medium |
348 |
DupSprite(226, 354); // non-breaking space tiny |
|
349 |
DupSprite(450, 578); // non-breaking space large |
|
2353 | 350 |
load_index = 4793; |
351 |
||
352 |
for (i = 1; files->basic[i].filename != NULL; i++) { |
|
2309 | 353 |
load_index += LoadGrfFile(files->basic[i].filename, load_index, i); |
354 |
} |
|
0 | 355 |
|
5151
23150e1b0660
(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
|
356 |
/* Load additional sprites for climates other than temperate */ |
23150e1b0660
(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
|
357 |
if (_opt.landscape != LT_NORMAL) { |
2309 | 358 |
LoadGrfIndexed( |
5151
23150e1b0660
(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 |
files->landscape[_opt.landscape - 1].filename, |
23150e1b0660
(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
|
360 |
_landscape_spriteindexes[_opt.landscape - 1], |
2309 | 361 |
i++ |
362 |
); |
|
363 |
} |
|
0 | 364 |
|
4936
ac3a8ba42785
(svn r6923) -Codechange: Load nsignalsw.grf in the same way as other mandatory additional grfs
Darkvater
parents:
4935
diff
changeset
|
365 |
assert(load_index == SPR_SIGNALS_BASE); |
ac3a8ba42785
(svn r6923) -Codechange: Load nsignalsw.grf in the same way as other mandatory additional grfs
Darkvater
parents:
4935
diff
changeset
|
366 |
load_index += LoadGrfFile("nsignalsw.grf", load_index, i++); |
ac3a8ba42785
(svn r6923) -Codechange: Load nsignalsw.grf in the same way as other mandatory additional grfs
Darkvater
parents:
4935
diff
changeset
|
367 |
|
2512
a66b16c61a69
(svn r3038) Reorder the loading of standard graphics files to reflect a bit where in the sprite array the sprites end up and assert, that the indices are equal to the corresponding sprite base enums, to guard against typos.
tron
parents:
2411
diff
changeset
|
368 |
assert(load_index == SPR_CANALS_BASE); |
a66b16c61a69
(svn r3038) Reorder the loading of standard graphics files to reflect a bit where in the sprite array the sprites end up and assert, that the indices are equal to the corresponding sprite base enums, to guard against typos.
tron
parents:
2411
diff
changeset
|
369 |
load_index += LoadGrfFile("canalsw.grf", load_index, i++); |
a66b16c61a69
(svn r3038) Reorder the loading of standard graphics files to reflect a bit where in the sprite array the sprites end up and assert, that the indices are equal to the corresponding sprite base enums, to guard against typos.
tron
parents:
2411
diff
changeset
|
370 |
|
a66b16c61a69
(svn r3038) Reorder the loading of standard graphics files to reflect a bit where in the sprite array the sprites end up and assert, that the indices are equal to the corresponding sprite base enums, to guard against typos.
tron
parents:
2411
diff
changeset
|
371 |
assert(load_index == SPR_SLOPES_BASE); |
2309 | 372 |
LoadGrfIndexed("trkfoundw.grf", _slopes_spriteindexes[_opt.landscape], i++); |
1070
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
1019
diff
changeset
|
373 |
|
2309 | 374 |
load_index = SPR_AUTORAIL_BASE; |
375 |
load_index += LoadGrfFile("autorail.grf", load_index, i++); |
|
142 | 376 |
|
3355
e414a0b104a6
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
3252
diff
changeset
|
377 |
assert(load_index == SPR_ELRAIL_BASE); |
e414a0b104a6
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
3252
diff
changeset
|
378 |
load_index += LoadGrfFile("elrailsw.grf", load_index, i++); |
e414a0b104a6
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
3252
diff
changeset
|
379 |
|
3113
d79500c648da
(svn r3717) - [2cc] Add 2cc colour maps and use for newgrf engines requiring them. Currently the second colour is fixed to be the player's colour.
peter1138
parents:
2639
diff
changeset
|
380 |
assert(load_index == SPR_2CCMAP_BASE); |
d79500c648da
(svn r3717) - [2cc] Add 2cc colour maps and use for newgrf engines requiring them. Currently the second colour is fixed to be the player's colour.
peter1138
parents:
2639
diff
changeset
|
381 |
load_index += LoadGrfFile("2ccmap.grf", load_index, i++); |
d79500c648da
(svn r3717) - [2cc] Add 2cc colour maps and use for newgrf engines requiring them. Currently the second colour is fixed to be the player's colour.
peter1138
parents:
2639
diff
changeset
|
382 |
|
2512
a66b16c61a69
(svn r3038) Reorder the loading of standard graphics files to reflect a bit where in the sprite array the sprites end up and assert, that the indices are equal to the corresponding sprite base enums, to guard against typos.
tron
parents:
2411
diff
changeset
|
383 |
assert(load_index == SPR_OPENTTD_BASE); |
a66b16c61a69
(svn r3038) Reorder the loading of standard graphics files to reflect a bit where in the sprite array the sprites end up and assert, that the indices are equal to the corresponding sprite base enums, to guard against typos.
tron
parents:
2411
diff
changeset
|
384 |
LoadGrfIndexed("openttd.grf", _openttd_grf_indexes, i++); |
2577
e2321aed315f
(svn r3114) Close two gaps in the sprite array when loading openttd.grf. That's seven more free sprite slots, yay!
tron
parents:
2571
diff
changeset
|
385 |
load_index = SPR_OPENTTD_BASE + OPENTTD_SPRITES_COUNT; |
142 | 386 |
|
4059
b1e1c1193f0a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
3355
diff
changeset
|
387 |
assert(load_index == SPR_AIRPORTX_BASE); |
b1e1c1193f0a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
3355
diff
changeset
|
388 |
load_index += LoadGrfFile("airports.grf", load_index, i++); |
b1e1c1193f0a
(svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents:
3355
diff
changeset
|
389 |
|
5156
771ed0d9f836
(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
|
390 |
/* Initialize the unicode to sprite mapping table */ |
771ed0d9f836
(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
|
391 |
InitializeUnicodeGlyphMap(); |
771ed0d9f836
(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
|
392 |
|
2342
aae24c9661ba
(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
|
393 |
LoadNewGRF(load_index, i); |
0 | 394 |
} |
395 |
||
396 |
||
1093
4fdc46eaf423
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1070
diff
changeset
|
397 |
void GfxLoadSprites(void) |
4fdc46eaf423
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1070
diff
changeset
|
398 |
{ |
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5296
diff
changeset
|
399 |
DEBUG(sprite, 2, "Loading sprite set %d", _opt.landscape); |
0 | 400 |
|
5151
23150e1b0660
(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
|
401 |
GfxInitSpriteMem(); |
23150e1b0660
(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
|
402 |
LoadSpriteTables(); |
23150e1b0660
(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
|
403 |
GfxInitPalettes(); |
0 | 404 |
} |