author | rubidium |
Wed, 09 Jan 2008 18:11:12 +0000 | |
branch | noai |
changeset 9723 | eee46cb39750 |
parent 9722 | ebf0ece7d8f6 |
child 9724 | b39bc69bb2f2 |
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" |
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
|
8 |
#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
|
9 |
#include "spritecache.h" |
1363
01d3de5d8039
(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" |
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9703
diff
changeset
|
12 |
#include "fios.h" |
463
91bcad840bcd
(svn r687) Export InitNewGRFFile() and DecodeSpecialSprite() properly.
pasky
parents:
452
diff
changeset
|
13 |
#include "newgrf.h" |
961 | 14 |
#include "md5.h" |
2159
3b634157c3b2
(svn r2669) Shuffle some more stuff around to reduce dependencies
tron
parents:
2142
diff
changeset
|
15 |
#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
|
16 |
#include "fontcache.h" |
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
17 |
#include "gfx_func.h" |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
18 |
#include "core/alloc_func.hpp" |
4472
745f9ebe2216
(svn r6257) Use memcmp() to check the MD5 sum instead of using a home brewed loop
tron
parents:
4209
diff
changeset
|
19 |
#include <string.h> |
0 | 20 |
|
6574
e1d1a12faaf7
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6573
diff
changeset
|
21 |
struct MD5File { |
6505
abcb0580d976
(svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents:
6429
diff
changeset
|
22 |
const char * filename; ///< filename |
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
23 |
uint8 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
|
24 |
}; |
961 | 25 |
|
6574
e1d1a12faaf7
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6573
diff
changeset
|
26 |
struct FileList { |
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9703
diff
changeset
|
27 |
MD5File basic[2]; ///< GRF files that always have to be loaded |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9703
diff
changeset
|
28 |
MD5File landscape[3]; ///< Landscape specific grf files |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9703
diff
changeset
|
29 |
MD5File sound; ///< Sound samples |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9703
diff
changeset
|
30 |
MD5File chars; ///< GRF File with character replacements |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9703
diff
changeset
|
31 |
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
|
32 |
}; |
40d7dba79fc7
(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
2a51f8925eeb
(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 |
||
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9703
diff
changeset
|
43 |
static uint LoadGrfFile(const char *filename, uint load_index, int file_index) |
0 | 44 |
{ |
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
|
45 |
uint load_index_org = load_index; |
9628
b5c2449616b5
(svn r10195) [NoAI] -Sync: with trunk r10119:10194.
rubidium
parents:
9626
diff
changeset
|
46 |
uint sprite_id = 0; |
0 | 47 |
|
48 |
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
|
49 |
|
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5296
diff
changeset
|
50 |
DEBUG(sprite, 2, "Reading grf-file '%s'", filename); |
0 | 51 |
|
9628
b5c2449616b5
(svn r10195) [NoAI] -Sync: with trunk r10119:10194.
rubidium
parents:
9626
diff
changeset
|
52 |
while (LoadNextSprite(load_index, file_index, sprite_id)) { |
0 | 53 |
load_index++; |
9628
b5c2449616b5
(svn r10195) [NoAI] -Sync: with trunk r10119:10194.
rubidium
parents:
9626
diff
changeset
|
54 |
sprite_id++; |
2187
2a51f8925eeb
(svn r2702) -Codechange: Cleaned up the sprite code and replaced many magic numbers
celestar
parents:
2186
diff
changeset
|
55 |
if (load_index >= MAX_SPRITES) { |
2a51f8925eeb
(svn r2702) -Codechange: Cleaned up the sprite code and replaced many magic numbers
celestar
parents:
2186
diff
changeset
|
56 |
error("Too many sprites. Recompile with higher MAX_SPRITES value or remove some custom GRF files."); |
0 | 57 |
} |
58 |
} |
|
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5296
diff
changeset
|
59 |
DEBUG(sprite, 2, "Currently %i sprites are loaded", load_index); |
0 | 60 |
|
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
|
61 |
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
|
62 |
} |
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 |
|
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
|
64 |
|
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9703
diff
changeset
|
65 |
void LoadSpritesIndexed(int file_index, uint *sprite_id, const SpriteID *index_tbl) |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9703
diff
changeset
|
66 |
{ |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9703
diff
changeset
|
67 |
uint start; |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9703
diff
changeset
|
68 |
while ((start = *index_tbl++) != END) { |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9703
diff
changeset
|
69 |
uint end = *index_tbl++; |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9703
diff
changeset
|
70 |
|
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9703
diff
changeset
|
71 |
if (start == SKIP) { // skip sprites (amount in second var) |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9703
diff
changeset
|
72 |
SkipSprites(end); |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9703
diff
changeset
|
73 |
(*sprite_id) += end; |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9703
diff
changeset
|
74 |
} else { // load sprites and use indexes from start to end |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9703
diff
changeset
|
75 |
do { |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9703
diff
changeset
|
76 |
#ifdef NDEBUG |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9703
diff
changeset
|
77 |
LoadNextSprite(start, file_index, *sprite_id); |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9703
diff
changeset
|
78 |
#else |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9703
diff
changeset
|
79 |
bool b = LoadNextSprite(start, file_index, *sprite_id); |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9703
diff
changeset
|
80 |
assert(b); |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9703
diff
changeset
|
81 |
#endif |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9703
diff
changeset
|
82 |
(*sprite_id)++; |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9703
diff
changeset
|
83 |
} while (++start <= end); |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9703
diff
changeset
|
84 |
} |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9703
diff
changeset
|
85 |
} |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9703
diff
changeset
|
86 |
} |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9703
diff
changeset
|
87 |
|
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
|
88 |
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
|
89 |
{ |
9628
b5c2449616b5
(svn r10195) [NoAI] -Sync: with trunk r10119:10194.
rubidium
parents:
9626
diff
changeset
|
90 |
uint sprite_id = 0; |
614
e016770cb781
(svn r1038) Feature: OpenTTD runs with the grf files of the DOS version
dominik
parents:
579
diff
changeset
|
91 |
|
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
|
92 |
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
|
93 |
|
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5296
diff
changeset
|
94 |
DEBUG(sprite, 2, "Reading indexed grf-file '%s'", filename); |
0 | 95 |
|
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9703
diff
changeset
|
96 |
LoadSpritesIndexed(file_index, &sprite_id, index_tbl); |
184
dbeaaaf8b2bb
(svn r185) -Fix: [1016954] Cached_sprites does now work again
truelight
parents:
182
diff
changeset
|
97 |
} |
0 | 98 |
|
99 |
||
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9703
diff
changeset
|
100 |
/** |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9703
diff
changeset
|
101 |
* Calculate and check the MD5 hash of the supplied filename. |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9703
diff
changeset
|
102 |
* @param file filename and expected MD5 hash for the given filename. |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9703
diff
changeset
|
103 |
* @return true if the checksum is correct. |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9703
diff
changeset
|
104 |
*/ |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9703
diff
changeset
|
105 |
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
|
106 |
{ |
9703
d2a6acdbd665
(svn r11146) [NoAI] -Sync: with trunk r11035:11045.
rubidium
parents:
9628
diff
changeset
|
107 |
size_t size; |
d2a6acdbd665
(svn r11146) [NoAI] -Sync: with trunk r11035:11045.
rubidium
parents:
9628
diff
changeset
|
108 |
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
|
109 |
|
862
d7e52ef99f42
(svn r1343) -Fix: [Graphic] Autorail icon is now correct (Darkvater)
truelight
parents:
614
diff
changeset
|
110 |
if (f != NULL) { |
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
111 |
Md5 checksum; |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
112 |
uint8 buffer[1024]; |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
113 |
uint8 digest[16]; |
2028
d7686f53adf2
(svn r2537) Small changes, especially use fprintf to stderr for warnings and errors instead of plain printf
tron
parents:
2027
diff
changeset
|
114 |
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
|
115 |
|
9703
d2a6acdbd665
(svn r11146) [NoAI] -Sync: with trunk r11035:11045.
rubidium
parents:
9628
diff
changeset
|
116 |
while ((len = fread(buffer, 1, (size > sizeof(buffer)) ? sizeof(buffer) : size, f)) != 0 && size != 0) { |
d2a6acdbd665
(svn r11146) [NoAI] -Sync: with trunk r11035:11045.
rubidium
parents:
9628
diff
changeset
|
117 |
size -= len; |
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
118 |
checksum.Append(buffer, len); |
9703
d2a6acdbd665
(svn r11146) [NoAI] -Sync: with trunk r11035:11045.
rubidium
parents:
9628
diff
changeset
|
119 |
} |
961 | 120 |
|
9703
d2a6acdbd665
(svn r11146) [NoAI] -Sync: with trunk r11035:11045.
rubidium
parents:
9628
diff
changeset
|
121 |
FioFCloseFile(f); |
1019
6363b8a4273e
(svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents:
966
diff
changeset
|
122 |
|
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
123 |
checksum.Finish(digest); |
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9703
diff
changeset
|
124 |
return memcmp(file.hash, digest, sizeof(file.hash)) == 0; |
961 | 125 |
} else { // file not found |
126 |
return false; |
|
1019
6363b8a4273e
(svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents:
966
diff
changeset
|
127 |
} |
961 | 128 |
} |
129 |
||
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9703
diff
changeset
|
130 |
/** |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9703
diff
changeset
|
131 |
* Determine the palette that has to be used. |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9703
diff
changeset
|
132 |
* - forced DOS palette via command line -> leave it that way |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9703
diff
changeset
|
133 |
* - all Windows files present -> Windows palette |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9703
diff
changeset
|
134 |
* - all DOS files present -> DOS palette |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9703
diff
changeset
|
135 |
* - no Windows files present and any DOS file present -> DOS palette |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9703
diff
changeset
|
136 |
* - otherwise -> Windows palette |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9703
diff
changeset
|
137 |
*/ |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9703
diff
changeset
|
138 |
static void DeterminePalette() |
961 | 139 |
{ |
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9703
diff
changeset
|
140 |
if (_use_dos_palette) return; |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9703
diff
changeset
|
141 |
|
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9703
diff
changeset
|
142 |
/* Count of files from the different versions. */ |
1355 | 143 |
uint dos = 0; |
144 |
uint win = 0; |
|
961 | 145 |
|
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9703
diff
changeset
|
146 |
for (uint i = 0; i < lengthof(files_dos.basic); i++) if (FioCheckFileExists(files_dos.basic[i].filename)) dos++; |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9703
diff
changeset
|
147 |
for (uint i = 0; i < lengthof(files_dos.landscape); i++) if (FioCheckFileExists(files_dos.landscape[i].filename)) dos++; |
961 | 148 |
|
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9703
diff
changeset
|
149 |
for (uint i = 0; i < lengthof(files_win.basic); i++) if (FioCheckFileExists(files_win.basic[i].filename)) win++; |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9703
diff
changeset
|
150 |
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
|
151 |
|
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9703
diff
changeset
|
152 |
if (win == 5) { |
961 | 153 |
_use_dos_palette = false; |
1381 | 154 |
} 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
|
155 |
_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
|
156 |
} else { |
961 | 157 |
_use_dos_palette = false; |
614
e016770cb781
(svn r1038) Feature: OpenTTD runs with the grf files of the DOS version
dominik
parents:
579
diff
changeset
|
158 |
} |
e016770cb781
(svn r1038) Feature: OpenTTD runs with the grf files of the DOS version
dominik
parents:
579
diff
changeset
|
159 |
} |
e016770cb781
(svn r1038) Feature: OpenTTD runs with the grf files of the DOS version
dominik
parents:
579
diff
changeset
|
160 |
|
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9703
diff
changeset
|
161 |
/** |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9703
diff
changeset
|
162 |
* Checks whether the MD5 checksums of the files are correct. |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9703
diff
changeset
|
163 |
* |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9703
diff
changeset
|
164 |
* @note Also checks sample.cat and other required non-NewGRF GRFs for corruption. |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9703
diff
changeset
|
165 |
*/ |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9703
diff
changeset
|
166 |
void CheckExternalFiles() |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9703
diff
changeset
|
167 |
{ |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9703
diff
changeset
|
168 |
DeterminePalette(); |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9703
diff
changeset
|
169 |
|
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9703
diff
changeset
|
170 |
static const size_t ERROR_MESSAGE_LENGTH = 128; |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9703
diff
changeset
|
171 |
const FileList *files = _use_dos_palette ? &files_dos : &files_win; |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9703
diff
changeset
|
172 |
char error_msg[ERROR_MESSAGE_LENGTH * (lengthof(files->basic) + lengthof(files->landscape) + 3)]; |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9703
diff
changeset
|
173 |
error_msg[0] = '\0'; |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9703
diff
changeset
|
174 |
char *add_pos = error_msg; |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9703
diff
changeset
|
175 |
|
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9703
diff
changeset
|
176 |
for (uint i = 0; i < lengthof(files->basic); i++) { |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9703
diff
changeset
|
177 |
if (!FileMD5(files->basic[i])) { |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9703
diff
changeset
|
178 |
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); |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9703
diff
changeset
|
179 |
} |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9703
diff
changeset
|
180 |
} |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9703
diff
changeset
|
181 |
|
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9703
diff
changeset
|
182 |
for (uint i = 0; i < lengthof(files->landscape); i++) { |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9703
diff
changeset
|
183 |
if (!FileMD5(files->landscape[i])) { |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9703
diff
changeset
|
184 |
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); |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9703
diff
changeset
|
185 |
} |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9703
diff
changeset
|
186 |
} |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9703
diff
changeset
|
187 |
|
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9703
diff
changeset
|
188 |
if (!FileMD5(files_win.sound) && !FileMD5(files_dos.sound)) { |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9703
diff
changeset
|
189 |
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"); |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9703
diff
changeset
|
190 |
} |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9703
diff
changeset
|
191 |
|
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9703
diff
changeset
|
192 |
if (!FileMD5(files->chars)) { |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9703
diff
changeset
|
193 |
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); |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9703
diff
changeset
|
194 |
} |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9703
diff
changeset
|
195 |
|
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9703
diff
changeset
|
196 |
if (!FileMD5(files->openttd)) { |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9703
diff
changeset
|
197 |
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); |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9703
diff
changeset
|
198 |
} |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9703
diff
changeset
|
199 |
|
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9703
diff
changeset
|
200 |
if (add_pos != error_msg) ShowInfoF(error_msg); |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9703
diff
changeset
|
201 |
} |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9703
diff
changeset
|
202 |
|
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
|
203 |
|
2353 | 204 |
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
|
205 |
0, 1, ///< Mouse cursor, ZZZ |
2353 | 206 |
/* Medium font */ |
6505
abcb0580d976
(svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents:
6429
diff
changeset
|
207 |
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
|
208 |
SKIP, 36, |
9625
3301b1b3889c
(svn r10016) [NoAI] -Sync with trunk r9914:r10015.
rubidium
parents:
9624
diff
changeset
|
209 |
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
|
210 |
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
|
211 |
131, 133, |
6505
abcb0580d976
(svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents:
6429
diff
changeset
|
212 |
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
|
213 |
135, 135, |
40d7dba79fc7
(svn r3125) Symbolic names for skiping sprites and the end of the sprite list
tron
parents:
2577
diff
changeset
|
214 |
SKIP, 1, |
40d7dba79fc7
(svn r3125) Symbolic names for skiping sprites and the end of the sprite list
tron
parents:
2577
diff
changeset
|
215 |
137, 137, |
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 |
139, 139, |
6505
abcb0580d976
(svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents:
6429
diff
changeset
|
218 |
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
|
219 |
141, 141, |
6505
abcb0580d976
(svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents:
6429
diff
changeset
|
220 |
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
|
221 |
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
|
222 |
144, 144, |
6505
abcb0580d976
(svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents:
6429
diff
changeset
|
223 |
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
|
224 |
146, 149, |
6505
abcb0580d976
(svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents:
6429
diff
changeset
|
225 |
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
|
226 |
SKIP, 2, |
40d7dba79fc7
(svn r3125) Symbolic names for skiping sprites and the end of the sprite list
tron
parents:
2577
diff
changeset
|
227 |
157, 157, |
6505
abcb0580d976
(svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents:
6429
diff
changeset
|
228 |
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
|
229 |
SKIP, 1, |
40d7dba79fc7
(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 */ |
6505
abcb0580d976
(svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents:
6429
diff
changeset
|
232 |
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
|
233 |
SKIP, 36, |
9625
3301b1b3889c
(svn r10016) [NoAI] -Sync with trunk r9914:r10015.
rubidium
parents:
9624
diff
changeset
|
234 |
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
|
235 |
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
|
236 |
355, 357, |
6505
abcb0580d976
(svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents:
6429
diff
changeset
|
237 |
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
|
238 |
359, 359, |
40d7dba79fc7
(svn r3125) Symbolic names for skiping sprites and the end of the sprite list
tron
parents:
2577
diff
changeset
|
239 |
SKIP, 1, |
40d7dba79fc7
(svn r3125) Symbolic names for skiping sprites and the end of the sprite list
tron
parents:
2577
diff
changeset
|
240 |
361, 361, |
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 |
363, 363, |
6505
abcb0580d976
(svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents:
6429
diff
changeset
|
243 |
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
|
244 |
365, 366, |
40d7dba79fc7
(svn r3125) Symbolic names for skiping sprites and the end of the sprite list
tron
parents:
2577
diff
changeset
|
245 |
SKIP, 1, |
40d7dba79fc7
(svn r3125) Symbolic names for skiping sprites and the end of the sprite list
tron
parents:
2577
diff
changeset
|
246 |
368, 368, |
6505
abcb0580d976
(svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents:
6429
diff
changeset
|
247 |
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
|
248 |
370, 373, |
40d7dba79fc7
(svn r3125) Symbolic names for skiping sprites and the end of the sprite list
tron
parents:
2577
diff
changeset
|
249 |
SKIP, 7, |
40d7dba79fc7
(svn r3125) Symbolic names for skiping sprites and the end of the sprite list
tron
parents:
2577
diff
changeset
|
250 |
381, 381, |
40d7dba79fc7
(svn r3125) Symbolic names for skiping sprites and the end of the sprite list
tron
parents:
2577
diff
changeset
|
251 |
SKIP, 3, |
40d7dba79fc7
(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 */ |
6505
abcb0580d976
(svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents:
6429
diff
changeset
|
254 |
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
|
255 |
SKIP, 36, |
9625
3301b1b3889c
(svn r10016) [NoAI] -Sync with trunk r9914:r10015.
rubidium
parents:
9624
diff
changeset
|
256 |
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
|
257 |
SKIP, 1, |
40d7dba79fc7
(svn r3125) Symbolic names for skiping sprites and the end of the sprite list
tron
parents:
2577
diff
changeset
|
258 |
579, 581, |
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 |
583, 583, |
40d7dba79fc7
(svn r3125) Symbolic names for skiping sprites and the end of the sprite list
tron
parents:
2577
diff
changeset
|
261 |
SKIP, 5, |
40d7dba79fc7
(svn r3125) Symbolic names for skiping sprites and the end of the sprite list
tron
parents:
2577
diff
changeset
|
262 |
589, 589, |
40d7dba79fc7
(svn r3125) Symbolic names for skiping sprites and the end of the sprite list
tron
parents:
2577
diff
changeset
|
263 |
SKIP, 15, |
40d7dba79fc7
(svn r3125) Symbolic names for skiping sprites and the end of the sprite list
tron
parents:
2577
diff
changeset
|
264 |
605, 605, |
40d7dba79fc7
(svn r3125) Symbolic names for skiping sprites and the end of the sprite list
tron
parents:
2577
diff
changeset
|
265 |
SKIP, 3, |
40d7dba79fc7
(svn r3125) Symbolic names for skiping sprites and the end of the sprite list
tron
parents:
2577
diff
changeset
|
266 |
609, 625, |
40d7dba79fc7
(svn r3125) Symbolic names for skiping sprites and the end of the sprite list
tron
parents:
2577
diff
changeset
|
267 |
SKIP, 1, |
40d7dba79fc7
(svn r3125) Symbolic names for skiping sprites and the end of the sprite list
tron
parents:
2577
diff
changeset
|
268 |
627, 632, |
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 |
634, 639, |
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 |
641, 657, |
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 |
659, 664, |
40d7dba79fc7
(svn r3125) Symbolic names for skiping sprites and the end of the sprite list
tron
parents:
2577
diff
changeset
|
275 |
SKIP, 2, |
40d7dba79fc7
(svn r3125) Symbolic names for skiping sprites and the end of the sprite list
tron
parents:
2577
diff
changeset
|
276 |
667, 671, |
40d7dba79fc7
(svn r3125) Symbolic names for skiping sprites and the end of the sprite list
tron
parents:
2577
diff
changeset
|
277 |
SKIP, 1, |
40d7dba79fc7
(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
40d7dba79fc7
(svn r3125) Symbolic names for skiping sprites and the end of the sprite list
tron
parents:
2577
diff
changeset
|
280 |
674, 4792, |
40d7dba79fc7
(svn r3125) Symbolic names for skiping sprites and the end of the sprite list
tron
parents:
2577
diff
changeset
|
281 |
END |
2353 | 282 |
}; |
283 |
||
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9703
diff
changeset
|
284 |
/** Replace some letter sprites with some other letters */ |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9703
diff
changeset
|
285 |
static const SpriteID _chars_grf_indexes[] = { |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9703
diff
changeset
|
286 |
134, 134, ///< euro symbol medium size |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9703
diff
changeset
|
287 |
582, 582, ///< euro symbol large size |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9703
diff
changeset
|
288 |
358, 358, ///< euro symbol tiny |
9625
3301b1b3889c
(svn r10016) [NoAI] -Sync with trunk r9914:r10015.
rubidium
parents:
9624
diff
changeset
|
289 |
648, 648, ///< nordic char: æ |
3301b1b3889c
(svn r10016) [NoAI] -Sync with trunk r9914:r10015.
rubidium
parents:
9624
diff
changeset
|
290 |
616, 616, ///< nordic char: Æ |
3301b1b3889c
(svn r10016) [NoAI] -Sync with trunk r9914:r10015.
rubidium
parents:
9624
diff
changeset
|
291 |
666, 666, ///< nordic char: ø |
3301b1b3889c
(svn r10016) [NoAI] -Sync with trunk r9914:r10015.
rubidium
parents:
9624
diff
changeset
|
292 |
634, 634, ///< nordic char: Ø |
3301b1b3889c
(svn r10016) [NoAI] -Sync with trunk r9914:r10015.
rubidium
parents:
9624
diff
changeset
|
293 |
382, 383, ///< Œ œ tiny |
3301b1b3889c
(svn r10016) [NoAI] -Sync with trunk r9914:r10015.
rubidium
parents:
9624
diff
changeset
|
294 |
158, 159, ///< Œ œ medium |
3301b1b3889c
(svn r10016) [NoAI] -Sync with trunk r9914:r10015.
rubidium
parents:
9624
diff
changeset
|
295 |
606, 607, ///< Œ œ large |
3301b1b3889c
(svn r10016) [NoAI] -Sync with trunk r9914:r10015.
rubidium
parents:
9624
diff
changeset
|
296 |
360, 360, ///< Š tiny |
3301b1b3889c
(svn r10016) [NoAI] -Sync with trunk r9914:r10015.
rubidium
parents:
9624
diff
changeset
|
297 |
362, 362, ///< š tiny |
3301b1b3889c
(svn r10016) [NoAI] -Sync with trunk r9914:r10015.
rubidium
parents:
9624
diff
changeset
|
298 |
136, 136, ///< Š medium |
3301b1b3889c
(svn r10016) [NoAI] -Sync with trunk r9914:r10015.
rubidium
parents:
9624
diff
changeset
|
299 |
138, 138, ///< š medium |
3301b1b3889c
(svn r10016) [NoAI] -Sync with trunk r9914:r10015.
rubidium
parents:
9624
diff
changeset
|
300 |
584, 584, ///< Š large |
3301b1b3889c
(svn r10016) [NoAI] -Sync with trunk r9914:r10015.
rubidium
parents:
9624
diff
changeset
|
301 |
586, 586, ///< š large |
3301b1b3889c
(svn r10016) [NoAI] -Sync with trunk r9914:r10015.
rubidium
parents:
9624
diff
changeset
|
302 |
626, 626, ///< Ð large |
3301b1b3889c
(svn r10016) [NoAI] -Sync with trunk r9914:r10015.
rubidium
parents:
9624
diff
changeset
|
303 |
658, 658, ///< ð large |
3301b1b3889c
(svn r10016) [NoAI] -Sync with trunk r9914:r10015.
rubidium
parents:
9624
diff
changeset
|
304 |
374, 374, ///< Ž tiny |
3301b1b3889c
(svn r10016) [NoAI] -Sync with trunk r9914:r10015.
rubidium
parents:
9624
diff
changeset
|
305 |
378, 378, ///< ž tiny |
3301b1b3889c
(svn r10016) [NoAI] -Sync with trunk r9914:r10015.
rubidium
parents:
9624
diff
changeset
|
306 |
150, 150, ///< Ž medium |
3301b1b3889c
(svn r10016) [NoAI] -Sync with trunk r9914:r10015.
rubidium
parents:
9624
diff
changeset
|
307 |
154, 154, ///< ž medium |
3301b1b3889c
(svn r10016) [NoAI] -Sync with trunk r9914:r10015.
rubidium
parents:
9624
diff
changeset
|
308 |
598, 598, ///< Ž large |
3301b1b3889c
(svn r10016) [NoAI] -Sync with trunk r9914:r10015.
rubidium
parents:
9624
diff
changeset
|
309 |
602, 602, ///< ž large |
3301b1b3889c
(svn r10016) [NoAI] -Sync with trunk r9914:r10015.
rubidium
parents:
9624
diff
changeset
|
310 |
640, 640, ///< Þ large |
3301b1b3889c
(svn r10016) [NoAI] -Sync with trunk r9914:r10015.
rubidium
parents:
9624
diff
changeset
|
311 |
672, 672, ///< þ large |
3301b1b3889c
(svn r10016) [NoAI] -Sync with trunk r9914:r10015.
rubidium
parents:
9624
diff
changeset
|
312 |
380, 380, ///< º tiny |
3301b1b3889c
(svn r10016) [NoAI] -Sync with trunk r9914:r10015.
rubidium
parents:
9624
diff
changeset
|
313 |
156, 156, ///< º medium |
3301b1b3889c
(svn r10016) [NoAI] -Sync with trunk r9914:r10015.
rubidium
parents:
9624
diff
changeset
|
314 |
604, 604, ///< º large |
6505
abcb0580d976
(svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents:
6429
diff
changeset
|
315 |
317, 320, ///< { | } ~ tiny |
abcb0580d976
(svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents:
6429
diff
changeset
|
316 |
93, 96, ///< { | } ~ medium |
abcb0580d976
(svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents:
6429
diff
changeset
|
317 |
541, 544, ///< { | } ~ large |
9625
3301b1b3889c
(svn r10016) [NoAI] -Sync with trunk r9914:r10015.
rubidium
parents:
9624
diff
changeset
|
318 |
585, 585, ///< § large |
3301b1b3889c
(svn r10016) [NoAI] -Sync with trunk r9914:r10015.
rubidium
parents:
9624
diff
changeset
|
319 |
587, 587, ///< © large |
3301b1b3889c
(svn r10016) [NoAI] -Sync with trunk r9914:r10015.
rubidium
parents:
9624
diff
changeset
|
320 |
592, 592, ///< ® large |
3301b1b3889c
(svn r10016) [NoAI] -Sync with trunk r9914:r10015.
rubidium
parents:
9624
diff
changeset
|
321 |
594, 597, ///< ° ± ² ³ large |
3301b1b3889c
(svn r10016) [NoAI] -Sync with trunk r9914:r10015.
rubidium
parents:
9624
diff
changeset
|
322 |
633, 633, ///< × large |
3301b1b3889c
(svn r10016) [NoAI] -Sync with trunk r9914:r10015.
rubidium
parents:
9624
diff
changeset
|
323 |
665, 665, ///< ÷ large |
3301b1b3889c
(svn r10016) [NoAI] -Sync with trunk r9914:r10015.
rubidium
parents:
9624
diff
changeset
|
324 |
377, 377, ///< · small |
3301b1b3889c
(svn r10016) [NoAI] -Sync with trunk r9914:r10015.
rubidium
parents:
9624
diff
changeset
|
325 |
153, 153, ///< · medium |
3301b1b3889c
(svn r10016) [NoAI] -Sync with trunk r9914:r10015.
rubidium
parents:
9624
diff
changeset
|
326 |
601, 601, ///< · large |
2588
40d7dba79fc7
(svn r3125) Symbolic names for skiping sprites and the end of the sprite list
tron
parents:
2577
diff
changeset
|
327 |
END |
2353 | 328 |
}; |
329 |
||
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
|
330 |
|
6573 | 331 |
static void LoadSpriteTables() |
0 | 332 |
{ |
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9703
diff
changeset
|
333 |
const FileList *files = _use_dos_palette ? &files_dos : &files_win; |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9703
diff
changeset
|
334 |
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
|
335 |
|
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9703
diff
changeset
|
336 |
LoadGrfIndexed(files->basic[0].filename, trg1idx, i++); |
2407 | 337 |
DupSprite( 2, 130); // non-breaking space medium |
338 |
DupSprite(226, 354); // non-breaking space tiny |
|
339 |
DupSprite(450, 578); // non-breaking space large |
|
2353 | 340 |
|
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9703
diff
changeset
|
341 |
/* |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9703
diff
changeset
|
342 |
* The second basic file always starts at the given location and does |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9703
diff
changeset
|
343 |
* contain a different amount of sprites depending on the "type"; DOS |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9703
diff
changeset
|
344 |
* has a few sprites less. However, we do not care about those missing |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9703
diff
changeset
|
345 |
* sprites as they are not shown anyway (logos in intro game). |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9703
diff
changeset
|
346 |
*/ |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9703
diff
changeset
|
347 |
LoadGrfFile(files->basic[1].filename, 4793, i++); |
0 | 348 |
|
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9703
diff
changeset
|
349 |
/* |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9703
diff
changeset
|
350 |
* Load additional sprites for climates other than temperate. |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9703
diff
changeset
|
351 |
* This overwrites some of the temperate sprites, such as foundations |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9703
diff
changeset
|
352 |
* and the ground sprites. |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9703
diff
changeset
|
353 |
*/ |
9517 | 354 |
if (_opt.landscape != LT_TEMPERATE) { |
2309 | 355 |
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
|
356 |
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
|
357 |
_landscape_spriteindexes[_opt.landscape - 1], |
2309 | 358 |
i++ |
359 |
); |
|
360 |
} |
|
0 | 361 |
|
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9703
diff
changeset
|
362 |
LoadGrfIndexed(files->chars.filename, _chars_grf_indexes, i++); |
9626 | 363 |
|
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
|
364 |
/* 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
|
365 |
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
|
366 |
|
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9703
diff
changeset
|
367 |
/* |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9703
diff
changeset
|
368 |
* Load the base NewGRF with OTTD required graphics as first NewGRF. |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9703
diff
changeset
|
369 |
* However, we do not want it to show up in the list of used NewGRFs, |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9703
diff
changeset
|
370 |
* so we have to manually add it, and then remove it later. |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9703
diff
changeset
|
371 |
*/ |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9703
diff
changeset
|
372 |
GRFConfig *top = _grfconfig; |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9703
diff
changeset
|
373 |
GRFConfig *master = CallocT<GRFConfig>(1); |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9703
diff
changeset
|
374 |
master->filename = strdup(files->openttd.filename); |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9703
diff
changeset
|
375 |
FillGRFDetails(master, false); |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9703
diff
changeset
|
376 |
ClrBit(master->flags, GCF_INIT_ONLY); |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9703
diff
changeset
|
377 |
master->next = top; |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9703
diff
changeset
|
378 |
_grfconfig = master; |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9703
diff
changeset
|
379 |
|
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9703
diff
changeset
|
380 |
LoadNewGRF(SPR_NEWGRFS_BASE, i); |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9703
diff
changeset
|
381 |
|
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9703
diff
changeset
|
382 |
/* Free and remove the top element. */ |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9703
diff
changeset
|
383 |
ClearGRFConfig(&master); |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9703
diff
changeset
|
384 |
_grfconfig = top; |
0 | 385 |
} |
386 |
||
387 |
||
6573 | 388 |
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
|
389 |
{ |
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5296
diff
changeset
|
390 |
DEBUG(sprite, 2, "Loading sprite set %d", _opt.landscape); |
0 | 391 |
|
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
|
392 |
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
|
393 |
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
|
394 |
GfxInitPalettes(); |
0 | 395 |
} |