Mercurial > hg > openttd
annotate src/gfxinit.cpp @ 9470:47924a4b2ad4 draft
(svn r13390) -Codechange: introduce usererror() for fatal but not openttd related errors. Now all error() will 'crash' openttd after showing the message in win32 releases (MSVC), creating a crash.log and crash.dmp (like the '!' hack used before). On the other hand, usererror() will just close the game. So use error() only when it can be helpful to debugging, else use usererror().
author | glx <glx@openttd.org> |
---|---|
date | Thu, 05 Jun 2008 20:54:52 +0000 |
parents | b3969ef775ba |
children | 10fd2a3a4a1c |
rev | line source |
---|---|
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1 /* $Id$ */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2 |
9111
d48433370037
(svn r12971) -Documentation: add @file in files that missed them and add something more than whitespace as description of files that don't have a description.
rubidium <rubidium@openttd.org>
parents:
8432
diff
changeset
|
3 /** @file gfxinit.cpp Initializing of the (GRF) graphics. */ |
6179
e3e61b92574b
(svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas <belugas@openttd.org>
parents:
6103
diff
changeset
|
4 |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
5 #include "stdafx.h" |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
6 #include "openttd.h" |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
7 #include "debug.h" |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
8 #include "gfxinit.h" |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
9 #include "spritecache.h" |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
10 #include "fileio.h" |
7805
9a2371156469
(svn r11355) -Fix [FS#1377]: loading too many GRFs was not handled gracefully causing crashes and such.
rubidium <rubidium@openttd.org>
parents:
7800
diff
changeset
|
11 #include "fios.h" |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
12 #include "newgrf.h" |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
13 #include "md5.h" |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
14 #include "variables.h" |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
15 #include "fontcache.h" |
8123
c26c28875749
(svn r11684) -Codechange: split gfx.h in a type and functional header.
rubidium <rubidium@openttd.org>
parents:
8121
diff
changeset
|
16 #include "gfx_func.h" |
8213
87c85bb42d6f
(svn r11776) -Codechange: more header splittings to reduce the dependencies.
rubidium <rubidium@openttd.org>
parents:
8133
diff
changeset
|
17 #include "core/alloc_func.hpp" |
8236
d1191295967a
(svn r11800) -Codechange: move some functions to a more logical location + some type safety.
rubidium <rubidium@openttd.org>
parents:
8214
diff
changeset
|
18 #include "core/bitmath_func.hpp" |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
19 #include <string.h> |
8270
5613b863190d
(svn r11834) -Codechange: only include settings_type.h if needed.
rubidium <rubidium@openttd.org>
parents:
8264
diff
changeset
|
20 #include "settings_type.h" |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
21 |
8264
2495310e220f
(svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium <rubidium@openttd.org>
parents:
8236
diff
changeset
|
22 #include "table/sprites.h" |
2495310e220f
(svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium <rubidium@openttd.org>
parents:
8236
diff
changeset
|
23 |
6248
0789677a15a0
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium <rubidium@openttd.org>
parents:
6247
diff
changeset
|
24 struct MD5File { |
6179
e3e61b92574b
(svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas <belugas@openttd.org>
parents:
6103
diff
changeset
|
25 const char * filename; ///< filename |
8133
455889a24c77
(svn r11695) -Codechange: Converted the md5 algorithm to OOP
skidd13 <skidd13@openttd.org>
parents:
8131
diff
changeset
|
26 uint8 hash[16]; ///< md5 sum of the file |
6248
0789677a15a0
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium <rubidium@openttd.org>
parents:
6247
diff
changeset
|
27 }; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
28 |
6248
0789677a15a0
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium <rubidium@openttd.org>
parents:
6247
diff
changeset
|
29 struct FileList { |
7882
3cf133973d26
(svn r11433) -Fix: starting OpenTTD with DOS files made it look weird out of the box.
rubidium <rubidium@openttd.org>
parents:
7841
diff
changeset
|
30 MD5File basic[2]; ///< GRF files that always have to be loaded |
3cf133973d26
(svn r11433) -Fix: starting OpenTTD with DOS files made it look weird out of the box.
rubidium <rubidium@openttd.org>
parents:
7841
diff
changeset
|
31 MD5File landscape[3]; ///< Landscape specific grf files |
3cf133973d26
(svn r11433) -Fix: starting OpenTTD with DOS files made it look weird out of the box.
rubidium <rubidium@openttd.org>
parents:
7841
diff
changeset
|
32 MD5File sound; ///< Sound samples |
3cf133973d26
(svn r11433) -Fix: starting OpenTTD with DOS files made it look weird out of the box.
rubidium <rubidium@openttd.org>
parents:
7841
diff
changeset
|
33 MD5File openttd; ///< GRF File with OTTD specific graphics |
6248
0789677a15a0
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium <rubidium@openttd.org>
parents:
6247
diff
changeset
|
34 }; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
35 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
36 #include "table/files.h" |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
37 #include "table/landscape_sprite.h" |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
38 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
39 static const SpriteID * const _landscape_spriteindexes[] = { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
40 _landscape_spriteindexes_1, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
41 _landscape_spriteindexes_2, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
42 _landscape_spriteindexes_3, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
43 }; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
44 |
7841
076cd8a1d64c
(svn r11391) -Change: print all error messages related to missing/corrupted files in one message including the location where they can get said missing/corrupted files.
rubidium <rubidium@openttd.org>
parents:
7805
diff
changeset
|
45 static uint LoadGrfFile(const char *filename, uint load_index, int file_index) |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
46 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
47 uint load_index_org = load_index; |
6908
71da5dd33fa4
(svn r10157) -Fix: use as indentified for PNGs, the place of the image as it was in the grf, not the internal SpriteID
truelight <truelight@openttd.org>
parents:
6780
diff
changeset
|
48 uint sprite_id = 0; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
49 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
50 FioOpenFile(file_index, filename); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
51 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
52 DEBUG(sprite, 2, "Reading grf-file '%s'", filename); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
53 |
6908
71da5dd33fa4
(svn r10157) -Fix: use as indentified for PNGs, the place of the image as it was in the grf, not the internal SpriteID
truelight <truelight@openttd.org>
parents:
6780
diff
changeset
|
54 while (LoadNextSprite(load_index, file_index, sprite_id)) { |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
55 load_index++; |
6908
71da5dd33fa4
(svn r10157) -Fix: use as indentified for PNGs, the place of the image as it was in the grf, not the internal SpriteID
truelight <truelight@openttd.org>
parents:
6780
diff
changeset
|
56 sprite_id++; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
57 if (load_index >= MAX_SPRITES) { |
9470
47924a4b2ad4
(svn r13390) -Codechange: introduce usererror() for fatal but not openttd related errors. Now all error() will 'crash' openttd after showing the message in win32 releases (MSVC), creating a crash.log and crash.dmp (like the '!' hack used before). On the other hand, usererror() will just close the game. So use error() only when it can be helpful to debugging, else use usererror().
glx <glx@openttd.org>
parents:
9436
diff
changeset
|
58 usererror("Too many sprites. Recompile with higher MAX_SPRITES value or remove some custom GRF files."); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
59 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
60 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
61 DEBUG(sprite, 2, "Currently %i sprites are loaded", load_index); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
62 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
63 return load_index - load_index_org; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
64 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
65 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
66 |
7772
e14b246ba55c
(svn r11321) -Codechange: add support to load different graphics for halftile slopes using a NewGRF. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7767
diff
changeset
|
67 void LoadSpritesIndexed(int file_index, uint *sprite_id, const SpriteID *index_tbl) |
e14b246ba55c
(svn r11321) -Codechange: add support to load different graphics for halftile slopes using a NewGRF. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7767
diff
changeset
|
68 { |
e14b246ba55c
(svn r11321) -Codechange: add support to load different graphics for halftile slopes using a NewGRF. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7767
diff
changeset
|
69 uint start; |
e14b246ba55c
(svn r11321) -Codechange: add support to load different graphics for halftile slopes using a NewGRF. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7767
diff
changeset
|
70 while ((start = *index_tbl++) != END) { |
e14b246ba55c
(svn r11321) -Codechange: add support to load different graphics for halftile slopes using a NewGRF. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7767
diff
changeset
|
71 uint end = *index_tbl++; |
e14b246ba55c
(svn r11321) -Codechange: add support to load different graphics for halftile slopes using a NewGRF. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7767
diff
changeset
|
72 |
8432
e802c4a2fa5e
(svn r12002) -Cleanup (r11981): Remove obsolete code to skip sprites from indexed GRFs.
peter1138 <peter1138@openttd.org>
parents:
8411
diff
changeset
|
73 do { |
e802c4a2fa5e
(svn r12002) -Cleanup (r11981): Remove obsolete code to skip sprites from indexed GRFs.
peter1138 <peter1138@openttd.org>
parents:
8411
diff
changeset
|
74 bool b = LoadNextSprite(start, file_index, *sprite_id); |
e802c4a2fa5e
(svn r12002) -Cleanup (r11981): Remove obsolete code to skip sprites from indexed GRFs.
peter1138 <peter1138@openttd.org>
parents:
8411
diff
changeset
|
75 assert(b); |
e802c4a2fa5e
(svn r12002) -Cleanup (r11981): Remove obsolete code to skip sprites from indexed GRFs.
peter1138 <peter1138@openttd.org>
parents:
8411
diff
changeset
|
76 (*sprite_id)++; |
e802c4a2fa5e
(svn r12002) -Cleanup (r11981): Remove obsolete code to skip sprites from indexed GRFs.
peter1138 <peter1138@openttd.org>
parents:
8411
diff
changeset
|
77 } while (++start <= end); |
7772
e14b246ba55c
(svn r11321) -Codechange: add support to load different graphics for halftile slopes using a NewGRF. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7767
diff
changeset
|
78 } |
e14b246ba55c
(svn r11321) -Codechange: add support to load different graphics for halftile slopes using a NewGRF. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7767
diff
changeset
|
79 } |
e14b246ba55c
(svn r11321) -Codechange: add support to load different graphics for halftile slopes using a NewGRF. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7767
diff
changeset
|
80 |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
81 static void LoadGrfIndexed(const char* filename, const SpriteID* index_tbl, int file_index) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
82 { |
6908
71da5dd33fa4
(svn r10157) -Fix: use as indentified for PNGs, the place of the image as it was in the grf, not the internal SpriteID
truelight <truelight@openttd.org>
parents:
6780
diff
changeset
|
83 uint sprite_id = 0; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
84 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
85 FioOpenFile(file_index, filename); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
86 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
87 DEBUG(sprite, 2, "Reading indexed grf-file '%s'", filename); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
88 |
7772
e14b246ba55c
(svn r11321) -Codechange: add support to load different graphics for halftile slopes using a NewGRF. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7767
diff
changeset
|
89 LoadSpritesIndexed(file_index, &sprite_id, index_tbl); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
90 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
91 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
92 |
7841
076cd8a1d64c
(svn r11391) -Change: print all error messages related to missing/corrupted files in one message including the location where they can get said missing/corrupted files.
rubidium <rubidium@openttd.org>
parents:
7805
diff
changeset
|
93 /** |
076cd8a1d64c
(svn r11391) -Change: print all error messages related to missing/corrupted files in one message including the location where they can get said missing/corrupted files.
rubidium <rubidium@openttd.org>
parents:
7805
diff
changeset
|
94 * Calculate and check the MD5 hash of the supplied filename. |
076cd8a1d64c
(svn r11391) -Change: print all error messages related to missing/corrupted files in one message including the location where they can get said missing/corrupted files.
rubidium <rubidium@openttd.org>
parents:
7805
diff
changeset
|
95 * @param file filename and expected MD5 hash for the given filename. |
076cd8a1d64c
(svn r11391) -Change: print all error messages related to missing/corrupted files in one message including the location where they can get said missing/corrupted files.
rubidium <rubidium@openttd.org>
parents:
7805
diff
changeset
|
96 * @return true if the checksum is correct. |
076cd8a1d64c
(svn r11391) -Change: print all error messages related to missing/corrupted files in one message including the location where they can get said missing/corrupted files.
rubidium <rubidium@openttd.org>
parents:
7805
diff
changeset
|
97 */ |
076cd8a1d64c
(svn r11391) -Change: print all error messages related to missing/corrupted files in one message including the location where they can get said missing/corrupted files.
rubidium <rubidium@openttd.org>
parents:
7805
diff
changeset
|
98 static bool FileMD5(const MD5File file) |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
99 { |
7574
62a4ffc139c0
(svn r11099) -Codechange: allow on opening of a file via FioFOpenFile to request the size of the file, so we can keep that in mind
truelight <truelight@openttd.org>
parents:
6917
diff
changeset
|
100 size_t size; |
62a4ffc139c0
(svn r11099) -Codechange: allow on opening of a file via FioFOpenFile to request the size of the file, so we can keep that in mind
truelight <truelight@openttd.org>
parents:
6917
diff
changeset
|
101 FILE *f = FioFOpenFile(file.filename, "rb", DATA_DIR, &size); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
102 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
103 if (f != NULL) { |
8133
455889a24c77
(svn r11695) -Codechange: Converted the md5 algorithm to OOP
skidd13 <skidd13@openttd.org>
parents:
8131
diff
changeset
|
104 Md5 checksum; |
455889a24c77
(svn r11695) -Codechange: Converted the md5 algorithm to OOP
skidd13 <skidd13@openttd.org>
parents:
8131
diff
changeset
|
105 uint8 buffer[1024]; |
455889a24c77
(svn r11695) -Codechange: Converted the md5 algorithm to OOP
skidd13 <skidd13@openttd.org>
parents:
8131
diff
changeset
|
106 uint8 digest[16]; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
107 size_t len; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
108 |
7574
62a4ffc139c0
(svn r11099) -Codechange: allow on opening of a file via FioFOpenFile to request the size of the file, so we can keep that in mind
truelight <truelight@openttd.org>
parents:
6917
diff
changeset
|
109 while ((len = fread(buffer, 1, (size > sizeof(buffer)) ? sizeof(buffer) : size, f)) != 0 && size != 0) { |
62a4ffc139c0
(svn r11099) -Codechange: allow on opening of a file via FioFOpenFile to request the size of the file, so we can keep that in mind
truelight <truelight@openttd.org>
parents:
6917
diff
changeset
|
110 size -= len; |
8133
455889a24c77
(svn r11695) -Codechange: Converted the md5 algorithm to OOP
skidd13 <skidd13@openttd.org>
parents:
8131
diff
changeset
|
111 checksum.Append(buffer, len); |
7574
62a4ffc139c0
(svn r11099) -Codechange: allow on opening of a file via FioFOpenFile to request the size of the file, so we can keep that in mind
truelight <truelight@openttd.org>
parents:
6917
diff
changeset
|
112 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
113 |
7592
eb177cee0aa4
(svn r11119) -Codechange: analyze .tar files upon loading, remembering their files and offsets, which speeds up .tar handling with a big factor
truelight <truelight@openttd.org>
parents:
7574
diff
changeset
|
114 FioFCloseFile(f); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
115 |
8133
455889a24c77
(svn r11695) -Codechange: Converted the md5 algorithm to OOP
skidd13 <skidd13@openttd.org>
parents:
8131
diff
changeset
|
116 checksum.Finish(digest); |
7841
076cd8a1d64c
(svn r11391) -Change: print all error messages related to missing/corrupted files in one message including the location where they can get said missing/corrupted files.
rubidium <rubidium@openttd.org>
parents:
7805
diff
changeset
|
117 return memcmp(file.hash, digest, sizeof(file.hash)) == 0; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
118 } else { // file not found |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
119 return false; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
120 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
121 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
122 |
7841
076cd8a1d64c
(svn r11391) -Change: print all error messages related to missing/corrupted files in one message including the location where they can get said missing/corrupted files.
rubidium <rubidium@openttd.org>
parents:
7805
diff
changeset
|
123 /** |
076cd8a1d64c
(svn r11391) -Change: print all error messages related to missing/corrupted files in one message including the location where they can get said missing/corrupted files.
rubidium <rubidium@openttd.org>
parents:
7805
diff
changeset
|
124 * Determine the palette that has to be used. |
076cd8a1d64c
(svn r11391) -Change: print all error messages related to missing/corrupted files in one message including the location where they can get said missing/corrupted files.
rubidium <rubidium@openttd.org>
parents:
7805
diff
changeset
|
125 * - forced DOS palette via command line -> leave it that way |
076cd8a1d64c
(svn r11391) -Change: print all error messages related to missing/corrupted files in one message including the location where they can get said missing/corrupted files.
rubidium <rubidium@openttd.org>
parents:
7805
diff
changeset
|
126 * - all Windows files present -> Windows palette |
076cd8a1d64c
(svn r11391) -Change: print all error messages related to missing/corrupted files in one message including the location where they can get said missing/corrupted files.
rubidium <rubidium@openttd.org>
parents:
7805
diff
changeset
|
127 * - all DOS files present -> DOS palette |
076cd8a1d64c
(svn r11391) -Change: print all error messages related to missing/corrupted files in one message including the location where they can get said missing/corrupted files.
rubidium <rubidium@openttd.org>
parents:
7805
diff
changeset
|
128 * - no Windows files present and any DOS file present -> DOS palette |
076cd8a1d64c
(svn r11391) -Change: print all error messages related to missing/corrupted files in one message including the location where they can get said missing/corrupted files.
rubidium <rubidium@openttd.org>
parents:
7805
diff
changeset
|
129 * - otherwise -> Windows palette |
076cd8a1d64c
(svn r11391) -Change: print all error messages related to missing/corrupted files in one message including the location where they can get said missing/corrupted files.
rubidium <rubidium@openttd.org>
parents:
7805
diff
changeset
|
130 */ |
076cd8a1d64c
(svn r11391) -Change: print all error messages related to missing/corrupted files in one message including the location where they can get said missing/corrupted files.
rubidium <rubidium@openttd.org>
parents:
7805
diff
changeset
|
131 static void DeterminePalette() |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
132 { |
7841
076cd8a1d64c
(svn r11391) -Change: print all error messages related to missing/corrupted files in one message including the location where they can get said missing/corrupted files.
rubidium <rubidium@openttd.org>
parents:
7805
diff
changeset
|
133 if (_use_dos_palette) return; |
076cd8a1d64c
(svn r11391) -Change: print all error messages related to missing/corrupted files in one message including the location where they can get said missing/corrupted files.
rubidium <rubidium@openttd.org>
parents:
7805
diff
changeset
|
134 |
076cd8a1d64c
(svn r11391) -Change: print all error messages related to missing/corrupted files in one message including the location where they can get said missing/corrupted files.
rubidium <rubidium@openttd.org>
parents:
7805
diff
changeset
|
135 /* Count of files from the different versions. */ |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
136 uint dos = 0; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
137 uint win = 0; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
138 |
7841
076cd8a1d64c
(svn r11391) -Change: print all error messages related to missing/corrupted files in one message including the location where they can get said missing/corrupted files.
rubidium <rubidium@openttd.org>
parents:
7805
diff
changeset
|
139 for (uint i = 0; i < lengthof(files_dos.basic); i++) if (FioCheckFileExists(files_dos.basic[i].filename)) dos++; |
076cd8a1d64c
(svn r11391) -Change: print all error messages related to missing/corrupted files in one message including the location where they can get said missing/corrupted files.
rubidium <rubidium@openttd.org>
parents:
7805
diff
changeset
|
140 for (uint i = 0; i < lengthof(files_dos.landscape); i++) if (FioCheckFileExists(files_dos.landscape[i].filename)) dos++; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
141 |
7841
076cd8a1d64c
(svn r11391) -Change: print all error messages related to missing/corrupted files in one message including the location where they can get said missing/corrupted files.
rubidium <rubidium@openttd.org>
parents:
7805
diff
changeset
|
142 for (uint i = 0; i < lengthof(files_win.basic); i++) if (FioCheckFileExists(files_win.basic[i].filename)) win++; |
076cd8a1d64c
(svn r11391) -Change: print all error messages related to missing/corrupted files in one message including the location where they can get said missing/corrupted files.
rubidium <rubidium@openttd.org>
parents:
7805
diff
changeset
|
143 for (uint i = 0; i < lengthof(files_win.landscape); i++) if (FioCheckFileExists(files_win.landscape[i].filename)) win++; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
144 |
7841
076cd8a1d64c
(svn r11391) -Change: print all error messages related to missing/corrupted files in one message including the location where they can get said missing/corrupted files.
rubidium <rubidium@openttd.org>
parents:
7805
diff
changeset
|
145 if (win == 5) { |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
146 _use_dos_palette = false; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
147 } else if (dos == 5 || (win == 0 && dos > 0)) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
148 _use_dos_palette = true; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
149 } else { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
150 _use_dos_palette = false; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
151 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
152 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
153 |
7841
076cd8a1d64c
(svn r11391) -Change: print all error messages related to missing/corrupted files in one message including the location where they can get said missing/corrupted files.
rubidium <rubidium@openttd.org>
parents:
7805
diff
changeset
|
154 /** |
076cd8a1d64c
(svn r11391) -Change: print all error messages related to missing/corrupted files in one message including the location where they can get said missing/corrupted files.
rubidium <rubidium@openttd.org>
parents:
7805
diff
changeset
|
155 * Checks whether the MD5 checksums of the files are correct. |
076cd8a1d64c
(svn r11391) -Change: print all error messages related to missing/corrupted files in one message including the location where they can get said missing/corrupted files.
rubidium <rubidium@openttd.org>
parents:
7805
diff
changeset
|
156 * |
076cd8a1d64c
(svn r11391) -Change: print all error messages related to missing/corrupted files in one message including the location where they can get said missing/corrupted files.
rubidium <rubidium@openttd.org>
parents:
7805
diff
changeset
|
157 * @note Also checks sample.cat and other required non-NewGRF GRFs for corruption. |
076cd8a1d64c
(svn r11391) -Change: print all error messages related to missing/corrupted files in one message including the location where they can get said missing/corrupted files.
rubidium <rubidium@openttd.org>
parents:
7805
diff
changeset
|
158 */ |
076cd8a1d64c
(svn r11391) -Change: print all error messages related to missing/corrupted files in one message including the location where they can get said missing/corrupted files.
rubidium <rubidium@openttd.org>
parents:
7805
diff
changeset
|
159 void CheckExternalFiles() |
076cd8a1d64c
(svn r11391) -Change: print all error messages related to missing/corrupted files in one message including the location where they can get said missing/corrupted files.
rubidium <rubidium@openttd.org>
parents:
7805
diff
changeset
|
160 { |
076cd8a1d64c
(svn r11391) -Change: print all error messages related to missing/corrupted files in one message including the location where they can get said missing/corrupted files.
rubidium <rubidium@openttd.org>
parents:
7805
diff
changeset
|
161 DeterminePalette(); |
076cd8a1d64c
(svn r11391) -Change: print all error messages related to missing/corrupted files in one message including the location where they can get said missing/corrupted files.
rubidium <rubidium@openttd.org>
parents:
7805
diff
changeset
|
162 |
076cd8a1d64c
(svn r11391) -Change: print all error messages related to missing/corrupted files in one message including the location where they can get said missing/corrupted files.
rubidium <rubidium@openttd.org>
parents:
7805
diff
changeset
|
163 static const size_t ERROR_MESSAGE_LENGTH = 128; |
076cd8a1d64c
(svn r11391) -Change: print all error messages related to missing/corrupted files in one message including the location where they can get said missing/corrupted files.
rubidium <rubidium@openttd.org>
parents:
7805
diff
changeset
|
164 const FileList *files = _use_dos_palette ? &files_dos : &files_win; |
7882
3cf133973d26
(svn r11433) -Fix: starting OpenTTD with DOS files made it look weird out of the box.
rubidium <rubidium@openttd.org>
parents:
7841
diff
changeset
|
165 char error_msg[ERROR_MESSAGE_LENGTH * (lengthof(files->basic) + lengthof(files->landscape) + 3)]; |
7841
076cd8a1d64c
(svn r11391) -Change: print all error messages related to missing/corrupted files in one message including the location where they can get said missing/corrupted files.
rubidium <rubidium@openttd.org>
parents:
7805
diff
changeset
|
166 error_msg[0] = '\0'; |
076cd8a1d64c
(svn r11391) -Change: print all error messages related to missing/corrupted files in one message including the location where they can get said missing/corrupted files.
rubidium <rubidium@openttd.org>
parents:
7805
diff
changeset
|
167 char *add_pos = error_msg; |
076cd8a1d64c
(svn r11391) -Change: print all error messages related to missing/corrupted files in one message including the location where they can get said missing/corrupted files.
rubidium <rubidium@openttd.org>
parents:
7805
diff
changeset
|
168 |
076cd8a1d64c
(svn r11391) -Change: print all error messages related to missing/corrupted files in one message including the location where they can get said missing/corrupted files.
rubidium <rubidium@openttd.org>
parents:
7805
diff
changeset
|
169 for (uint i = 0; i < lengthof(files->basic); i++) { |
076cd8a1d64c
(svn r11391) -Change: print all error messages related to missing/corrupted files in one message including the location where they can get said missing/corrupted files.
rubidium <rubidium@openttd.org>
parents:
7805
diff
changeset
|
170 if (!FileMD5(files->basic[i])) { |
076cd8a1d64c
(svn r11391) -Change: print all error messages related to missing/corrupted files in one message including the location where they can get said missing/corrupted files.
rubidium <rubidium@openttd.org>
parents:
7805
diff
changeset
|
171 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); |
076cd8a1d64c
(svn r11391) -Change: print all error messages related to missing/corrupted files in one message including the location where they can get said missing/corrupted files.
rubidium <rubidium@openttd.org>
parents:
7805
diff
changeset
|
172 } |
076cd8a1d64c
(svn r11391) -Change: print all error messages related to missing/corrupted files in one message including the location where they can get said missing/corrupted files.
rubidium <rubidium@openttd.org>
parents:
7805
diff
changeset
|
173 } |
076cd8a1d64c
(svn r11391) -Change: print all error messages related to missing/corrupted files in one message including the location where they can get said missing/corrupted files.
rubidium <rubidium@openttd.org>
parents:
7805
diff
changeset
|
174 |
076cd8a1d64c
(svn r11391) -Change: print all error messages related to missing/corrupted files in one message including the location where they can get said missing/corrupted files.
rubidium <rubidium@openttd.org>
parents:
7805
diff
changeset
|
175 for (uint i = 0; i < lengthof(files->landscape); i++) { |
076cd8a1d64c
(svn r11391) -Change: print all error messages related to missing/corrupted files in one message including the location where they can get said missing/corrupted files.
rubidium <rubidium@openttd.org>
parents:
7805
diff
changeset
|
176 if (!FileMD5(files->landscape[i])) { |
076cd8a1d64c
(svn r11391) -Change: print all error messages related to missing/corrupted files in one message including the location where they can get said missing/corrupted files.
rubidium <rubidium@openttd.org>
parents:
7805
diff
changeset
|
177 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); |
076cd8a1d64c
(svn r11391) -Change: print all error messages related to missing/corrupted files in one message including the location where they can get said missing/corrupted files.
rubidium <rubidium@openttd.org>
parents:
7805
diff
changeset
|
178 } |
076cd8a1d64c
(svn r11391) -Change: print all error messages related to missing/corrupted files in one message including the location where they can get said missing/corrupted files.
rubidium <rubidium@openttd.org>
parents:
7805
diff
changeset
|
179 } |
076cd8a1d64c
(svn r11391) -Change: print all error messages related to missing/corrupted files in one message including the location where they can get said missing/corrupted files.
rubidium <rubidium@openttd.org>
parents:
7805
diff
changeset
|
180 |
7882
3cf133973d26
(svn r11433) -Fix: starting OpenTTD with DOS files made it look weird out of the box.
rubidium <rubidium@openttd.org>
parents:
7841
diff
changeset
|
181 if (!FileMD5(files_win.sound) && !FileMD5(files_dos.sound)) { |
7841
076cd8a1d64c
(svn r11391) -Change: print all error messages related to missing/corrupted files in one message including the location where they can get said missing/corrupted files.
rubidium <rubidium@openttd.org>
parents:
7805
diff
changeset
|
182 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"); |
076cd8a1d64c
(svn r11391) -Change: print all error messages related to missing/corrupted files in one message including the location where they can get said missing/corrupted files.
rubidium <rubidium@openttd.org>
parents:
7805
diff
changeset
|
183 } |
076cd8a1d64c
(svn r11391) -Change: print all error messages related to missing/corrupted files in one message including the location where they can get said missing/corrupted files.
rubidium <rubidium@openttd.org>
parents:
7805
diff
changeset
|
184 |
7882
3cf133973d26
(svn r11433) -Fix: starting OpenTTD with DOS files made it look weird out of the box.
rubidium <rubidium@openttd.org>
parents:
7841
diff
changeset
|
185 if (!FileMD5(files->openttd)) { |
3cf133973d26
(svn r11433) -Fix: starting OpenTTD with DOS files made it look weird out of the box.
rubidium <rubidium@openttd.org>
parents:
7841
diff
changeset
|
186 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); |
7841
076cd8a1d64c
(svn r11391) -Change: print all error messages related to missing/corrupted files in one message including the location where they can get said missing/corrupted files.
rubidium <rubidium@openttd.org>
parents:
7805
diff
changeset
|
187 } |
076cd8a1d64c
(svn r11391) -Change: print all error messages related to missing/corrupted files in one message including the location where they can get said missing/corrupted files.
rubidium <rubidium@openttd.org>
parents:
7805
diff
changeset
|
188 |
076cd8a1d64c
(svn r11391) -Change: print all error messages related to missing/corrupted files in one message including the location where they can get said missing/corrupted files.
rubidium <rubidium@openttd.org>
parents:
7805
diff
changeset
|
189 if (add_pos != error_msg) ShowInfoF(error_msg); |
076cd8a1d64c
(svn r11391) -Change: print all error messages related to missing/corrupted files in one message including the location where they can get said missing/corrupted files.
rubidium <rubidium@openttd.org>
parents:
7805
diff
changeset
|
190 } |
076cd8a1d64c
(svn r11391) -Change: print all error messages related to missing/corrupted files in one message including the location where they can get said missing/corrupted files.
rubidium <rubidium@openttd.org>
parents:
7805
diff
changeset
|
191 |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
192 |
6247
57363e064324
(svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents:
6179
diff
changeset
|
193 static void LoadSpriteTables() |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
194 { |
7841
076cd8a1d64c
(svn r11391) -Change: print all error messages related to missing/corrupted files in one message including the location where they can get said missing/corrupted files.
rubidium <rubidium@openttd.org>
parents:
7805
diff
changeset
|
195 const FileList *files = _use_dos_palette ? &files_dos : &files_win; |
7805
9a2371156469
(svn r11355) -Fix [FS#1377]: loading too many GRFs was not handled gracefully causing crashes and such.
rubidium <rubidium@openttd.org>
parents:
7800
diff
changeset
|
196 uint i = FIRST_GRF_SLOT; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
197 |
8411
e0420e29320d
(svn r11981) -Fix [FS#1698]: Use unicode glyph mapping to fix up missing/shuffled sprites in original data files instead of shuffling or skipping
peter1138 <peter1138@openttd.org>
parents:
8375
diff
changeset
|
198 LoadGrfFile(files->basic[0].filename, 0, i++); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
199 |
7841
076cd8a1d64c
(svn r11391) -Change: print all error messages related to missing/corrupted files in one message including the location where they can get said missing/corrupted files.
rubidium <rubidium@openttd.org>
parents:
7805
diff
changeset
|
200 /* |
076cd8a1d64c
(svn r11391) -Change: print all error messages related to missing/corrupted files in one message including the location where they can get said missing/corrupted files.
rubidium <rubidium@openttd.org>
parents:
7805
diff
changeset
|
201 * The second basic file always starts at the given location and does |
076cd8a1d64c
(svn r11391) -Change: print all error messages related to missing/corrupted files in one message including the location where they can get said missing/corrupted files.
rubidium <rubidium@openttd.org>
parents:
7805
diff
changeset
|
202 * contain a different amount of sprites depending on the "type"; DOS |
076cd8a1d64c
(svn r11391) -Change: print all error messages related to missing/corrupted files in one message including the location where they can get said missing/corrupted files.
rubidium <rubidium@openttd.org>
parents:
7805
diff
changeset
|
203 * has a few sprites less. However, we do not care about those missing |
076cd8a1d64c
(svn r11391) -Change: print all error messages related to missing/corrupted files in one message including the location where they can get said missing/corrupted files.
rubidium <rubidium@openttd.org>
parents:
7805
diff
changeset
|
204 * sprites as they are not shown anyway (logos in intro game). |
076cd8a1d64c
(svn r11391) -Change: print all error messages related to missing/corrupted files in one message including the location where they can get said missing/corrupted files.
rubidium <rubidium@openttd.org>
parents:
7805
diff
changeset
|
205 */ |
076cd8a1d64c
(svn r11391) -Change: print all error messages related to missing/corrupted files in one message including the location where they can get said missing/corrupted files.
rubidium <rubidium@openttd.org>
parents:
7805
diff
changeset
|
206 LoadGrfFile(files->basic[1].filename, 4793, i++); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
207 |
7841
076cd8a1d64c
(svn r11391) -Change: print all error messages related to missing/corrupted files in one message including the location where they can get said missing/corrupted files.
rubidium <rubidium@openttd.org>
parents:
7805
diff
changeset
|
208 /* |
076cd8a1d64c
(svn r11391) -Change: print all error messages related to missing/corrupted files in one message including the location where they can get said missing/corrupted files.
rubidium <rubidium@openttd.org>
parents:
7805
diff
changeset
|
209 * Load additional sprites for climates other than temperate. |
076cd8a1d64c
(svn r11391) -Change: print all error messages related to missing/corrupted files in one message including the location where they can get said missing/corrupted files.
rubidium <rubidium@openttd.org>
parents:
7805
diff
changeset
|
210 * This overwrites some of the temperate sprites, such as foundations |
076cd8a1d64c
(svn r11391) -Change: print all error messages related to missing/corrupted files in one message including the location where they can get said missing/corrupted files.
rubidium <rubidium@openttd.org>
parents:
7805
diff
changeset
|
211 * and the ground sprites. |
076cd8a1d64c
(svn r11391) -Change: print all error messages related to missing/corrupted files in one message including the location where they can get said missing/corrupted files.
rubidium <rubidium@openttd.org>
parents:
7805
diff
changeset
|
212 */ |
9413
512ea64da840
(svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium <rubidium@openttd.org>
parents:
9358
diff
changeset
|
213 if (_settings_game.game_creation.landscape != LT_TEMPERATE) { |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
214 LoadGrfIndexed( |
9413
512ea64da840
(svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium <rubidium@openttd.org>
parents:
9358
diff
changeset
|
215 files->landscape[_settings_game.game_creation.landscape - 1].filename, |
512ea64da840
(svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium <rubidium@openttd.org>
parents:
9358
diff
changeset
|
216 _landscape_spriteindexes[_settings_game.game_creation.landscape - 1], |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
217 i++ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
218 ); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
219 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
220 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
221 /* Initialize the unicode to sprite mapping table */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
222 InitializeUnicodeGlyphMap(); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
223 |
7882
3cf133973d26
(svn r11433) -Fix: starting OpenTTD with DOS files made it look weird out of the box.
rubidium <rubidium@openttd.org>
parents:
7841
diff
changeset
|
224 /* |
3cf133973d26
(svn r11433) -Fix: starting OpenTTD with DOS files made it look weird out of the box.
rubidium <rubidium@openttd.org>
parents:
7841
diff
changeset
|
225 * Load the base NewGRF with OTTD required graphics as first NewGRF. |
3cf133973d26
(svn r11433) -Fix: starting OpenTTD with DOS files made it look weird out of the box.
rubidium <rubidium@openttd.org>
parents:
7841
diff
changeset
|
226 * However, we do not want it to show up in the list of used NewGRFs, |
3cf133973d26
(svn r11433) -Fix: starting OpenTTD with DOS files made it look weird out of the box.
rubidium <rubidium@openttd.org>
parents:
7841
diff
changeset
|
227 * so we have to manually add it, and then remove it later. |
3cf133973d26
(svn r11433) -Fix: starting OpenTTD with DOS files made it look weird out of the box.
rubidium <rubidium@openttd.org>
parents:
7841
diff
changeset
|
228 */ |
3cf133973d26
(svn r11433) -Fix: starting OpenTTD with DOS files made it look weird out of the box.
rubidium <rubidium@openttd.org>
parents:
7841
diff
changeset
|
229 GRFConfig *top = _grfconfig; |
3cf133973d26
(svn r11433) -Fix: starting OpenTTD with DOS files made it look weird out of the box.
rubidium <rubidium@openttd.org>
parents:
7841
diff
changeset
|
230 GRFConfig *master = CallocT<GRFConfig>(1); |
3cf133973d26
(svn r11433) -Fix: starting OpenTTD with DOS files made it look weird out of the box.
rubidium <rubidium@openttd.org>
parents:
7841
diff
changeset
|
231 master->filename = strdup(files->openttd.filename); |
3cf133973d26
(svn r11433) -Fix: starting OpenTTD with DOS files made it look weird out of the box.
rubidium <rubidium@openttd.org>
parents:
7841
diff
changeset
|
232 FillGRFDetails(master, false); |
7929
4d13dbed828c
(svn r11482) -Codechange: Remove the doubled function ClrBitT and rename the remaining to fit with the naming style
skidd13 <skidd13@openttd.org>
parents:
7882
diff
changeset
|
233 ClrBit(master->flags, GCF_INIT_ONLY); |
7882
3cf133973d26
(svn r11433) -Fix: starting OpenTTD with DOS files made it look weird out of the box.
rubidium <rubidium@openttd.org>
parents:
7841
diff
changeset
|
234 master->next = top; |
3cf133973d26
(svn r11433) -Fix: starting OpenTTD with DOS files made it look weird out of the box.
rubidium <rubidium@openttd.org>
parents:
7841
diff
changeset
|
235 _grfconfig = master; |
3cf133973d26
(svn r11433) -Fix: starting OpenTTD with DOS files made it look weird out of the box.
rubidium <rubidium@openttd.org>
parents:
7841
diff
changeset
|
236 |
3cf133973d26
(svn r11433) -Fix: starting OpenTTD with DOS files made it look weird out of the box.
rubidium <rubidium@openttd.org>
parents:
7841
diff
changeset
|
237 LoadNewGRF(SPR_NEWGRFS_BASE, i); |
3cf133973d26
(svn r11433) -Fix: starting OpenTTD with DOS files made it look weird out of the box.
rubidium <rubidium@openttd.org>
parents:
7841
diff
changeset
|
238 |
3cf133973d26
(svn r11433) -Fix: starting OpenTTD with DOS files made it look weird out of the box.
rubidium <rubidium@openttd.org>
parents:
7841
diff
changeset
|
239 /* Free and remove the top element. */ |
3cf133973d26
(svn r11433) -Fix: starting OpenTTD with DOS files made it look weird out of the box.
rubidium <rubidium@openttd.org>
parents:
7841
diff
changeset
|
240 ClearGRFConfig(&master); |
3cf133973d26
(svn r11433) -Fix: starting OpenTTD with DOS files made it look weird out of the box.
rubidium <rubidium@openttd.org>
parents:
7841
diff
changeset
|
241 _grfconfig = top; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
242 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
243 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
244 |
6247
57363e064324
(svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents:
6179
diff
changeset
|
245 void GfxLoadSprites() |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
246 { |
9413
512ea64da840
(svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium <rubidium@openttd.org>
parents:
9358
diff
changeset
|
247 DEBUG(sprite, 2, "Loading sprite set %d", _settings_game.game_creation.landscape); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
248 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
249 GfxInitSpriteMem(); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
250 LoadSpriteTables(); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
251 GfxInitPalettes(); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
252 } |