Mercurial > hg > openttd
annotate src/gfxinit.cpp @ 11875:86fca539ec7a draft
(svn r16269) -Codechange: use gcc's ability to check parameters sent to printf-like functions
-Fix: wrong number of parameters or wrong parameter types sent to printf-like functions at several places
author | smatz <smatz@openttd.org> |
---|---|
date | Sun, 10 May 2009 17:27:25 +0000 |
parents | 699a0f6a1407 |
children | 577d93a5e10d |
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 "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
|
7 #include "spritecache.h" |
10039
6301378f3e0f
(svn r14199) -Codechange: split fileio.h into fileio_type.h and fileio_func.h so not everything that includes saveload.h needs to include everything else too.
rubidium <rubidium@openttd.org>
parents:
10037
diff
changeset
|
8 #include "fileio_func.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
|
9 #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
|
10 #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
|
11 #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
|
12 #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
|
13 #include "gfx_func.h" |
8270
5613b863190d
(svn r11834) -Codechange: only include settings_type.h if needed.
rubidium <rubidium@openttd.org>
parents:
8264
diff
changeset
|
14 #include "settings_type.h" |
9994
4687a554c837
(svn r14151) -Codechange: make it possible to choose between the DOS and Windows graphics packs while retaining the possibility to override the palette.
rubidium <rubidium@openttd.org>
parents:
9989
diff
changeset
|
15 #include "string_func.h" |
10037
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
16 #include "ini_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
|
17 |
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
|
18 #include "table/sprites.h" |
10062
fdd9ed12cdc1
(svn r14229) -Feature: allow overriding the palette of the base GRFs. This way you can play with NewGRFs made for the Windows palette with the DOS palettes base GRFs (and vice versa). Note that for this to work correctly ALL NewGRFs must use the same palette; mix and match is not yet supported.
rubidium <rubidium@openttd.org>
parents:
10048
diff
changeset
|
19 #include "table/palette_convert.h" |
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
|
20 |
10037
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
21 /** The currently used palette */ |
9995
a5aaa00e55ae
(svn r14152) -Fix (r14146): Apple decided to use a name I wanted to use... thus making compilation fail on OSX (planetmaker)
rubidium <rubidium@openttd.org>
parents:
9994
diff
changeset
|
22 PaletteType _use_palette = PAL_AUTODETECT; |
10062
fdd9ed12cdc1
(svn r14229) -Feature: allow overriding the palette of the base GRFs. This way you can play with NewGRFs made for the Windows palette with the DOS palettes base GRFs (and vice versa). Note that for this to work correctly ALL NewGRFs must use the same palette; mix and match is not yet supported.
rubidium <rubidium@openttd.org>
parents:
10048
diff
changeset
|
23 /** Whether the given NewGRFs must get a palette remap or not. */ |
fdd9ed12cdc1
(svn r14229) -Feature: allow overriding the palette of the base GRFs. This way you can play with NewGRFs made for the Windows palette with the DOS palettes base GRFs (and vice versa). Note that for this to work correctly ALL NewGRFs must use the same palette; mix and match is not yet supported.
rubidium <rubidium@openttd.org>
parents:
10048
diff
changeset
|
24 bool _palette_remap_grf[MAX_FILE_SLOTS]; |
fdd9ed12cdc1
(svn r14229) -Feature: allow overriding the palette of the base GRFs. This way you can play with NewGRFs made for the Windows palette with the DOS palettes base GRFs (and vice versa). Note that for this to work correctly ALL NewGRFs must use the same palette; mix and match is not yet supported.
rubidium <rubidium@openttd.org>
parents:
10048
diff
changeset
|
25 /** Palette map to go from the !_use_palette to the _use_palette */ |
fdd9ed12cdc1
(svn r14229) -Feature: allow overriding the palette of the base GRFs. This way you can play with NewGRFs made for the Windows palette with the DOS palettes base GRFs (and vice versa). Note that for this to work correctly ALL NewGRFs must use the same palette; mix and match is not yet supported.
rubidium <rubidium@openttd.org>
parents:
10048
diff
changeset
|
26 const byte *_palette_remap = NULL; |
fdd9ed12cdc1
(svn r14229) -Feature: allow overriding the palette of the base GRFs. This way you can play with NewGRFs made for the Windows palette with the DOS palettes base GRFs (and vice versa). Note that for this to work correctly ALL NewGRFs must use the same palette; mix and match is not yet supported.
rubidium <rubidium@openttd.org>
parents:
10048
diff
changeset
|
27 /** Palette map to go from the _use_palette to the !_use_palette */ |
fdd9ed12cdc1
(svn r14229) -Feature: allow overriding the palette of the base GRFs. This way you can play with NewGRFs made for the Windows palette with the DOS palettes base GRFs (and vice versa). Note that for this to work correctly ALL NewGRFs must use the same palette; mix and match is not yet supported.
rubidium <rubidium@openttd.org>
parents:
10048
diff
changeset
|
28 const byte *_palette_reverse_remap = NULL; |
fdd9ed12cdc1
(svn r14229) -Feature: allow overriding the palette of the base GRFs. This way you can play with NewGRFs made for the Windows palette with the DOS palettes base GRFs (and vice versa). Note that for this to work correctly ALL NewGRFs must use the same palette; mix and match is not yet supported.
rubidium <rubidium@openttd.org>
parents:
10048
diff
changeset
|
29 |
10615
a7c0533f0263
(svn r14907) -Codechange: Remove 32 character limit from driver/blitter selection and parameters.
peter1138 <peter1138@openttd.org>
parents:
10299
diff
changeset
|
30 char *_ini_graphics_set; |
9989
10fd2a3a4a1c
(svn r14146) -Codechange: allow palette override in both ways and remove some unneeded '(x == 0) ? 0 : 1' constructs.
rubidium <rubidium@openttd.org>
parents:
9470
diff
changeset
|
31 |
10037
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
32 /** Structure holding filename and MD5 information about a single file */ |
6248
0789677a15a0
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium <rubidium@openttd.org>
parents:
6247
diff
changeset
|
33 struct MD5File { |
10037
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
34 const char *filename; ///< filename |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
35 uint8 hash[16]; ///< md5 sum of the file |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
36 const char *missing_warning; ///< warning when this file is missing |
6248
0789677a15a0
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium <rubidium@openttd.org>
parents:
6247
diff
changeset
|
37 }; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
38 |
10037
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
39 /** Types of graphics in the base graphics set */ |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
40 enum GraphicsFileType { |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
41 GFT_BASE, ///< Base sprites for all climates |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
42 GFT_LOGOS, ///< Logos, landscape icons and original terrain generator sprites |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
43 GFT_ARCTIC, ///< Landscape replacement sprites for arctic |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
44 GFT_TROPICAL, ///< Landscape replacement sprites for tropical |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
45 GFT_TOYLAND, ///< Landscape replacement sprites for toyland |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
46 GFT_EXTRA, ///< Extra sprites that were not part of the original sprites |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
47 MAX_GFT ///< We are looking for this amount of GRFs |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
48 }; |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
49 |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
50 /** Information about a single graphics set. */ |
9994
4687a554c837
(svn r14151) -Codechange: make it possible to choose between the DOS and Windows graphics packs while retaining the possibility to override the palette.
rubidium <rubidium@openttd.org>
parents:
9989
diff
changeset
|
51 struct GraphicsSet { |
4687a554c837
(svn r14151) -Codechange: make it possible to choose between the DOS and Windows graphics packs while retaining the possibility to override the palette.
rubidium <rubidium@openttd.org>
parents:
9989
diff
changeset
|
52 const char *name; ///< The name of the graphics set |
4687a554c837
(svn r14151) -Codechange: make it possible to choose between the DOS and Windows graphics packs while retaining the possibility to override the palette.
rubidium <rubidium@openttd.org>
parents:
9989
diff
changeset
|
53 const char *description; ///< Description of the graphics set |
10037
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
54 uint32 shortname; ///< Four letter short variant of the name |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
55 uint32 version; ///< The version of this graphics set |
9995
a5aaa00e55ae
(svn r14152) -Fix (r14146): Apple decided to use a name I wanted to use... thus making compilation fail on OSX (planetmaker)
rubidium <rubidium@openttd.org>
parents:
9994
diff
changeset
|
56 PaletteType palette; ///< Palette of this graphics set |
10037
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
57 |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
58 MD5File files[MAX_GFT]; ///< All GRF files part of this set |
9994
4687a554c837
(svn r14151) -Codechange: make it possible to choose between the DOS and Windows graphics packs while retaining the possibility to override the palette.
rubidium <rubidium@openttd.org>
parents:
9989
diff
changeset
|
59 uint found_grfs; ///< Number of the GRFs that could be found |
10037
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
60 |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
61 GraphicsSet *next; ///< The next graphics set in this list |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
62 |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
63 /** Free everything we allocated */ |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
64 ~GraphicsSet() |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
65 { |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
66 free((void*)this->name); |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
67 free((void*)this->description); |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
68 for (uint i = 0; i < MAX_GFT; i++) { |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
69 free((void*)this->files[i].filename); |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
70 free((void*)this->files[i].missing_warning); |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
71 } |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
72 |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
73 delete this->next; |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
74 } |
6248
0789677a15a0
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium <rubidium@openttd.org>
parents:
6247
diff
changeset
|
75 }; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
76 |
10037
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
77 /** All graphics sets currently available */ |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
78 static GraphicsSet *_available_graphics_sets = NULL; |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
79 /** The one and only graphics set that is currently being used. */ |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
80 static const GraphicsSet *_used_graphics_set = NULL; |
9994
4687a554c837
(svn r14151) -Codechange: make it possible to choose between the DOS and Windows graphics packs while retaining the possibility to override the palette.
rubidium <rubidium@openttd.org>
parents:
9989
diff
changeset
|
81 |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
82 #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
|
83 #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
|
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 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
|
86 _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
|
87 _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
|
88 _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
|
89 }; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
90 |
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
|
91 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
|
92 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
93 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
|
94 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
|
95 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
96 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
|
97 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
98 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
|
99 |
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
|
100 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
|
101 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
|
102 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
|
103 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
|
104 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
|
105 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
106 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
107 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
|
108 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
109 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
|
110 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
111 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
112 |
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
|
113 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
|
114 { |
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
|
115 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
|
116 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
|
117 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
|
118 |
8432
e802c4a2fa5e
(svn r12002) -Cleanup (r11981): Remove obsolete code to skip sprites from indexed GRFs.
peter1138 <peter1138@openttd.org>
parents:
8411
diff
changeset
|
119 do { |
e802c4a2fa5e
(svn r12002) -Cleanup (r11981): Remove obsolete code to skip sprites from indexed GRFs.
peter1138 <peter1138@openttd.org>
parents:
8411
diff
changeset
|
120 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
|
121 assert(b); |
e802c4a2fa5e
(svn r12002) -Cleanup (r11981): Remove obsolete code to skip sprites from indexed GRFs.
peter1138 <peter1138@openttd.org>
parents:
8411
diff
changeset
|
122 (*sprite_id)++; |
e802c4a2fa5e
(svn r12002) -Cleanup (r11981): Remove obsolete code to skip sprites from indexed GRFs.
peter1138 <peter1138@openttd.org>
parents:
8411
diff
changeset
|
123 } 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
|
124 } |
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
|
125 } |
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
|
126 |
10647
592ae9307430
(svn r14949) -Cleanup: pointer coding style
rubidium <rubidium@openttd.org>
parents:
10615
diff
changeset
|
127 static void LoadGrfIndexed(const char *filename, const SpriteID *index_tbl, 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
|
128 { |
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
|
129 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
|
130 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
131 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
|
132 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
133 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
|
134 |
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
|
135 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
|
136 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
137 |
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 /** |
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 * 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
|
141 * @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
|
142 * @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
|
143 */ |
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
|
144 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
|
145 { |
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
|
146 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
|
147 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
|
148 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
149 if (f != NULL) { |
8133
455889a24c77
(svn r11695) -Codechange: Converted the md5 algorithm to OOP
skidd13 <skidd13@openttd.org>
parents:
8131
diff
changeset
|
150 Md5 checksum; |
455889a24c77
(svn r11695) -Codechange: Converted the md5 algorithm to OOP
skidd13 <skidd13@openttd.org>
parents:
8131
diff
changeset
|
151 uint8 buffer[1024]; |
455889a24c77
(svn r11695) -Codechange: Converted the md5 algorithm to OOP
skidd13 <skidd13@openttd.org>
parents:
8131
diff
changeset
|
152 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
|
153 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
|
154 |
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
|
155 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
|
156 size -= len; |
8133
455889a24c77
(svn r11695) -Codechange: Converted the md5 algorithm to OOP
skidd13 <skidd13@openttd.org>
parents:
8131
diff
changeset
|
157 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
|
158 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
159 |
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
|
160 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
|
161 |
8133
455889a24c77
(svn r11695) -Codechange: Converted the md5 algorithm to OOP
skidd13 <skidd13@openttd.org>
parents:
8131
diff
changeset
|
162 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
|
163 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
|
164 } 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
|
165 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
|
166 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
167 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
168 |
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
|
169 /** |
9994
4687a554c837
(svn r14151) -Codechange: make it possible to choose between the DOS and Windows graphics packs while retaining the possibility to override the palette.
rubidium <rubidium@openttd.org>
parents:
9989
diff
changeset
|
170 * Determine the graphics pack that has to be used. |
4687a554c837
(svn r14151) -Codechange: make it possible to choose between the DOS and Windows graphics packs while retaining the possibility to override the palette.
rubidium <rubidium@openttd.org>
parents:
9989
diff
changeset
|
171 * The one with the most correct files wins. |
4687a554c837
(svn r14151) -Codechange: make it possible to choose between the DOS and Windows graphics packs while retaining the possibility to override the palette.
rubidium <rubidium@openttd.org>
parents:
9989
diff
changeset
|
172 */ |
10048
d9459f6eb49e
(svn r14208) -Fix (r14197): Crash if no .obg files are found.
peter1138 <peter1138@openttd.org>
parents:
10039
diff
changeset
|
173 static bool DetermineGraphicsPack() |
9994
4687a554c837
(svn r14151) -Codechange: make it possible to choose between the DOS and Windows graphics packs while retaining the possibility to override the palette.
rubidium <rubidium@openttd.org>
parents:
9989
diff
changeset
|
174 { |
10048
d9459f6eb49e
(svn r14208) -Fix (r14197): Crash if no .obg files are found.
peter1138 <peter1138@openttd.org>
parents:
10039
diff
changeset
|
175 if (_used_graphics_set != NULL) return true; |
9994
4687a554c837
(svn r14151) -Codechange: make it possible to choose between the DOS and Windows graphics packs while retaining the possibility to override the palette.
rubidium <rubidium@openttd.org>
parents:
9989
diff
changeset
|
176 |
10037
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
177 const GraphicsSet *best = _available_graphics_sets; |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
178 for (const GraphicsSet *c = _available_graphics_sets; c != NULL; c = c->next) { |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
179 if (best->found_grfs < c->found_grfs || |
10062
fdd9ed12cdc1
(svn r14229) -Feature: allow overriding the palette of the base GRFs. This way you can play with NewGRFs made for the Windows palette with the DOS palettes base GRFs (and vice versa). Note that for this to work correctly ALL NewGRFs must use the same palette; mix and match is not yet supported.
rubidium <rubidium@openttd.org>
parents:
10048
diff
changeset
|
180 (best->found_grfs == c->found_grfs && ( |
fdd9ed12cdc1
(svn r14229) -Feature: allow overriding the palette of the base GRFs. This way you can play with NewGRFs made for the Windows palette with the DOS palettes base GRFs (and vice versa). Note that for this to work correctly ALL NewGRFs must use the same palette; mix and match is not yet supported.
rubidium <rubidium@openttd.org>
parents:
10048
diff
changeset
|
181 (best->shortname == c->shortname && best->version < c->version) || |
fdd9ed12cdc1
(svn r14229) -Feature: allow overriding the palette of the base GRFs. This way you can play with NewGRFs made for the Windows palette with the DOS palettes base GRFs (and vice versa). Note that for this to work correctly ALL NewGRFs must use the same palette; mix and match is not yet supported.
rubidium <rubidium@openttd.org>
parents:
10048
diff
changeset
|
182 (best->palette != _use_palette && c->palette == _use_palette)))) { |
10037
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
183 best = c; |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
184 } |
9994
4687a554c837
(svn r14151) -Codechange: make it possible to choose between the DOS and Windows graphics packs while retaining the possibility to override the palette.
rubidium <rubidium@openttd.org>
parents:
9989
diff
changeset
|
185 } |
4687a554c837
(svn r14151) -Codechange: make it possible to choose between the DOS and Windows graphics packs while retaining the possibility to override the palette.
rubidium <rubidium@openttd.org>
parents:
9989
diff
changeset
|
186 |
10037
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
187 _used_graphics_set = best; |
10048
d9459f6eb49e
(svn r14208) -Fix (r14197): Crash if no .obg files are found.
peter1138 <peter1138@openttd.org>
parents:
10039
diff
changeset
|
188 return _used_graphics_set != NULL; |
9994
4687a554c837
(svn r14151) -Codechange: make it possible to choose between the DOS and Windows graphics packs while retaining the possibility to override the palette.
rubidium <rubidium@openttd.org>
parents:
9989
diff
changeset
|
189 } |
4687a554c837
(svn r14151) -Codechange: make it possible to choose between the DOS and Windows graphics packs while retaining the possibility to override the palette.
rubidium <rubidium@openttd.org>
parents:
9989
diff
changeset
|
190 |
10077
7737958e76ad
(svn r14245) -Fix: NewGRF configs loaded from the config file would always default to the DOS palette instead of the "default" palette.
rubidium <rubidium@openttd.org>
parents:
10066
diff
changeset
|
191 extern void UpdateNewGRFConfigPalette(); |
7737958e76ad
(svn r14245) -Fix: NewGRF configs loaded from the config file would always default to the DOS palette instead of the "default" palette.
rubidium <rubidium@openttd.org>
parents:
10066
diff
changeset
|
192 |
9994
4687a554c837
(svn r14151) -Codechange: make it possible to choose between the DOS and Windows graphics packs while retaining the possibility to override the palette.
rubidium <rubidium@openttd.org>
parents:
9989
diff
changeset
|
193 /** |
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
|
194 * Determine the palette that has to be used. |
9994
4687a554c837
(svn r14151) -Codechange: make it possible to choose between the DOS and Windows graphics packs while retaining the possibility to override the palette.
rubidium <rubidium@openttd.org>
parents:
9989
diff
changeset
|
195 * - forced palette via command line -> leave it that way |
4687a554c837
(svn r14151) -Codechange: make it possible to choose between the DOS and Windows graphics packs while retaining the possibility to override the palette.
rubidium <rubidium@openttd.org>
parents:
9989
diff
changeset
|
196 * - otherwise -> palette based on the graphics pack |
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
|
197 */ |
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
|
198 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
|
199 { |
10048
d9459f6eb49e
(svn r14208) -Fix (r14197): Crash if no .obg files are found.
peter1138 <peter1138@openttd.org>
parents:
10039
diff
changeset
|
200 assert(_used_graphics_set != NULL); |
10062
fdd9ed12cdc1
(svn r14229) -Feature: allow overriding the palette of the base GRFs. This way you can play with NewGRFs made for the Windows palette with the DOS palettes base GRFs (and vice versa). Note that for this to work correctly ALL NewGRFs must use the same palette; mix and match is not yet supported.
rubidium <rubidium@openttd.org>
parents:
10048
diff
changeset
|
201 if (_use_palette >= MAX_PAL) _use_palette = _used_graphics_set->palette; |
fdd9ed12cdc1
(svn r14229) -Feature: allow overriding the palette of the base GRFs. This way you can play with NewGRFs made for the Windows palette with the DOS palettes base GRFs (and vice versa). Note that for this to work correctly ALL NewGRFs must use the same palette; mix and match is not yet supported.
rubidium <rubidium@openttd.org>
parents:
10048
diff
changeset
|
202 |
fdd9ed12cdc1
(svn r14229) -Feature: allow overriding the palette of the base GRFs. This way you can play with NewGRFs made for the Windows palette with the DOS palettes base GRFs (and vice versa). Note that for this to work correctly ALL NewGRFs must use the same palette; mix and match is not yet supported.
rubidium <rubidium@openttd.org>
parents:
10048
diff
changeset
|
203 switch (_use_palette) { |
fdd9ed12cdc1
(svn r14229) -Feature: allow overriding the palette of the base GRFs. This way you can play with NewGRFs made for the Windows palette with the DOS palettes base GRFs (and vice versa). Note that for this to work correctly ALL NewGRFs must use the same palette; mix and match is not yet supported.
rubidium <rubidium@openttd.org>
parents:
10048
diff
changeset
|
204 case PAL_DOS: |
fdd9ed12cdc1
(svn r14229) -Feature: allow overriding the palette of the base GRFs. This way you can play with NewGRFs made for the Windows palette with the DOS palettes base GRFs (and vice versa). Note that for this to work correctly ALL NewGRFs must use the same palette; mix and match is not yet supported.
rubidium <rubidium@openttd.org>
parents:
10048
diff
changeset
|
205 _palette_remap = _palmap_w2d; |
fdd9ed12cdc1
(svn r14229) -Feature: allow overriding the palette of the base GRFs. This way you can play with NewGRFs made for the Windows palette with the DOS palettes base GRFs (and vice versa). Note that for this to work correctly ALL NewGRFs must use the same palette; mix and match is not yet supported.
rubidium <rubidium@openttd.org>
parents:
10048
diff
changeset
|
206 _palette_reverse_remap = _palmap_d2w; |
fdd9ed12cdc1
(svn r14229) -Feature: allow overriding the palette of the base GRFs. This way you can play with NewGRFs made for the Windows palette with the DOS palettes base GRFs (and vice versa). Note that for this to work correctly ALL NewGRFs must use the same palette; mix and match is not yet supported.
rubidium <rubidium@openttd.org>
parents:
10048
diff
changeset
|
207 break; |
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 |
10062
fdd9ed12cdc1
(svn r14229) -Feature: allow overriding the palette of the base GRFs. This way you can play with NewGRFs made for the Windows palette with the DOS palettes base GRFs (and vice versa). Note that for this to work correctly ALL NewGRFs must use the same palette; mix and match is not yet supported.
rubidium <rubidium@openttd.org>
parents:
10048
diff
changeset
|
209 case PAL_WINDOWS: |
fdd9ed12cdc1
(svn r14229) -Feature: allow overriding the palette of the base GRFs. This way you can play with NewGRFs made for the Windows palette with the DOS palettes base GRFs (and vice versa). Note that for this to work correctly ALL NewGRFs must use the same palette; mix and match is not yet supported.
rubidium <rubidium@openttd.org>
parents:
10048
diff
changeset
|
210 _palette_remap = _palmap_d2w; |
fdd9ed12cdc1
(svn r14229) -Feature: allow overriding the palette of the base GRFs. This way you can play with NewGRFs made for the Windows palette with the DOS palettes base GRFs (and vice versa). Note that for this to work correctly ALL NewGRFs must use the same palette; mix and match is not yet supported.
rubidium <rubidium@openttd.org>
parents:
10048
diff
changeset
|
211 _palette_reverse_remap = _palmap_w2d; |
fdd9ed12cdc1
(svn r14229) -Feature: allow overriding the palette of the base GRFs. This way you can play with NewGRFs made for the Windows palette with the DOS palettes base GRFs (and vice versa). Note that for this to work correctly ALL NewGRFs must use the same palette; mix and match is not yet supported.
rubidium <rubidium@openttd.org>
parents:
10048
diff
changeset
|
212 break; |
fdd9ed12cdc1
(svn r14229) -Feature: allow overriding the palette of the base GRFs. This way you can play with NewGRFs made for the Windows palette with the DOS palettes base GRFs (and vice versa). Note that for this to work correctly ALL NewGRFs must use the same palette; mix and match is not yet supported.
rubidium <rubidium@openttd.org>
parents:
10048
diff
changeset
|
213 |
fdd9ed12cdc1
(svn r14229) -Feature: allow overriding the palette of the base GRFs. This way you can play with NewGRFs made for the Windows palette with the DOS palettes base GRFs (and vice versa). Note that for this to work correctly ALL NewGRFs must use the same palette; mix and match is not yet supported.
rubidium <rubidium@openttd.org>
parents:
10048
diff
changeset
|
214 default: |
fdd9ed12cdc1
(svn r14229) -Feature: allow overriding the palette of the base GRFs. This way you can play with NewGRFs made for the Windows palette with the DOS palettes base GRFs (and vice versa). Note that for this to work correctly ALL NewGRFs must use the same palette; mix and match is not yet supported.
rubidium <rubidium@openttd.org>
parents:
10048
diff
changeset
|
215 NOT_REACHED(); |
fdd9ed12cdc1
(svn r14229) -Feature: allow overriding the palette of the base GRFs. This way you can play with NewGRFs made for the Windows palette with the DOS palettes base GRFs (and vice versa). Note that for this to work correctly ALL NewGRFs must use the same palette; mix and match is not yet supported.
rubidium <rubidium@openttd.org>
parents:
10048
diff
changeset
|
216 } |
10077
7737958e76ad
(svn r14245) -Fix: NewGRF configs loaded from the config file would always default to the DOS palette instead of the "default" palette.
rubidium <rubidium@openttd.org>
parents:
10066
diff
changeset
|
217 |
7737958e76ad
(svn r14245) -Fix: NewGRF configs loaded from the config file would always default to the DOS palette instead of the "default" palette.
rubidium <rubidium@openttd.org>
parents:
10066
diff
changeset
|
218 UpdateNewGRFConfigPalette(); |
5584
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 |
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
|
221 /** |
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
|
222 * 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
|
223 * |
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
|
224 * @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
|
225 */ |
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
|
226 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
|
227 { |
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
|
228 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
|
229 |
10062
fdd9ed12cdc1
(svn r14229) -Feature: allow overriding the palette of the base GRFs. This way you can play with NewGRFs made for the Windows palette with the DOS palettes base GRFs (and vice versa). Note that for this to work correctly ALL NewGRFs must use the same palette; mix and match is not yet supported.
rubidium <rubidium@openttd.org>
parents:
10048
diff
changeset
|
230 DEBUG(grf, 1, "Using the %s base graphics set with the %s palette", _used_graphics_set->name, _use_palette == PAL_DOS ? "DOS" : "Windows"); |
fdd9ed12cdc1
(svn r14229) -Feature: allow overriding the palette of the base GRFs. This way you can play with NewGRFs made for the Windows palette with the DOS palettes base GRFs (and vice versa). Note that for this to work correctly ALL NewGRFs must use the same palette; mix and match is not yet supported.
rubidium <rubidium@openttd.org>
parents:
10048
diff
changeset
|
231 |
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
|
232 static const size_t ERROR_MESSAGE_LENGTH = 128; |
10037
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
233 char error_msg[ERROR_MESSAGE_LENGTH * (MAX_GFT + 1)]; |
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
|
234 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
|
235 char *add_pos = error_msg; |
10299
26fd53f1fd8d
(svn r14540) -Codechange: introduce [v]seprintf which are like [v]snprintf but do return the number of characters written instead of the number of characters that would be written; as size_t is unsigned substraction can cause integer underflows quite quickly.
rubidium <rubidium@openttd.org>
parents:
10077
diff
changeset
|
236 const char *last = lastof(error_msg); |
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
|
237 |
10037
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
238 for (uint i = 0; i < lengthof(_used_graphics_set->files); i++) { |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
239 if (!FileMD5(_used_graphics_set->files[i])) { |
10299
26fd53f1fd8d
(svn r14540) -Codechange: introduce [v]seprintf which are like [v]snprintf but do return the number of characters written instead of the number of characters that would be written; as size_t is unsigned substraction can cause integer underflows quite quickly.
rubidium <rubidium@openttd.org>
parents:
10077
diff
changeset
|
240 add_pos += seprintf(add_pos, last, "Your '%s' file is corrupted or missing! %s\n", _used_graphics_set->files[i].filename, _used_graphics_set->files[i].missing_warning); |
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
|
241 } |
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
|
242 } |
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
|
243 |
9994
4687a554c837
(svn r14151) -Codechange: make it possible to choose between the DOS and Windows graphics packs while retaining the possibility to override the palette.
rubidium <rubidium@openttd.org>
parents:
9989
diff
changeset
|
244 bool sound = false; |
4687a554c837
(svn r14151) -Codechange: make it possible to choose between the DOS and Windows graphics packs while retaining the possibility to override the palette.
rubidium <rubidium@openttd.org>
parents:
9989
diff
changeset
|
245 for (uint i = 0; !sound && i < lengthof(_sound_sets); i++) { |
4687a554c837
(svn r14151) -Codechange: make it possible to choose between the DOS and Windows graphics packs while retaining the possibility to override the palette.
rubidium <rubidium@openttd.org>
parents:
9989
diff
changeset
|
246 sound = FileMD5(_sound_sets[i]); |
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
|
247 } |
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
|
248 |
9994
4687a554c837
(svn r14151) -Codechange: make it possible to choose between the DOS and Windows graphics packs while retaining the possibility to override the palette.
rubidium <rubidium@openttd.org>
parents:
9989
diff
changeset
|
249 if (!sound) { |
10299
26fd53f1fd8d
(svn r14540) -Codechange: introduce [v]seprintf which are like [v]snprintf but do return the number of characters written instead of the number of characters that would be written; as size_t is unsigned substraction can cause integer underflows quite quickly.
rubidium <rubidium@openttd.org>
parents:
10077
diff
changeset
|
250 add_pos += seprintf(add_pos, last, "Your 'sample.cat' file is corrupted or missing! You can find 'sample.cat' on your Transport Tycoon Deluxe CD-ROM.\n"); |
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
|
251 } |
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
|
252 |
11875
86fca539ec7a
(svn r16269) -Codechange: use gcc's ability to check parameters sent to printf-like functions
smatz <smatz@openttd.org>
parents:
11344
diff
changeset
|
253 if (add_pos != error_msg) ShowInfoF("%s", error_msg); |
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
|
254 } |
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
|
255 |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
256 |
6247
57363e064324
(svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents:
6179
diff
changeset
|
257 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
|
258 { |
10062
fdd9ed12cdc1
(svn r14229) -Feature: allow overriding the palette of the base GRFs. This way you can play with NewGRFs made for the Windows palette with the DOS palettes base GRFs (and vice versa). Note that for this to work correctly ALL NewGRFs must use the same palette; mix and match is not yet supported.
rubidium <rubidium@openttd.org>
parents:
10048
diff
changeset
|
259 memset(_palette_remap_grf, 0, sizeof(_palette_remap_grf)); |
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
|
260 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
|
261 |
10062
fdd9ed12cdc1
(svn r14229) -Feature: allow overriding the palette of the base GRFs. This way you can play with NewGRFs made for the Windows palette with the DOS palettes base GRFs (and vice versa). Note that for this to work correctly ALL NewGRFs must use the same palette; mix and match is not yet supported.
rubidium <rubidium@openttd.org>
parents:
10048
diff
changeset
|
262 _palette_remap_grf[i] = (_use_palette != _used_graphics_set->palette); |
10037
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
263 LoadGrfFile(_used_graphics_set->files[GFT_BASE].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
|
264 |
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
|
265 /* |
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
|
266 * 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
|
267 * 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
|
268 * 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
|
269 * 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
|
270 */ |
10062
fdd9ed12cdc1
(svn r14229) -Feature: allow overriding the palette of the base GRFs. This way you can play with NewGRFs made for the Windows palette with the DOS palettes base GRFs (and vice versa). Note that for this to work correctly ALL NewGRFs must use the same palette; mix and match is not yet supported.
rubidium <rubidium@openttd.org>
parents:
10048
diff
changeset
|
271 _palette_remap_grf[i] = (_use_palette != _used_graphics_set->palette); |
10037
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
272 LoadGrfFile(_used_graphics_set->files[GFT_LOGOS].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
|
273 |
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
|
274 /* |
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
|
275 * 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
|
276 * 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
|
277 * 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
|
278 */ |
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
|
279 if (_settings_game.game_creation.landscape != LT_TEMPERATE) { |
10062
fdd9ed12cdc1
(svn r14229) -Feature: allow overriding the palette of the base GRFs. This way you can play with NewGRFs made for the Windows palette with the DOS palettes base GRFs (and vice versa). Note that for this to work correctly ALL NewGRFs must use the same palette; mix and match is not yet supported.
rubidium <rubidium@openttd.org>
parents:
10048
diff
changeset
|
280 _palette_remap_grf[i] = (_use_palette != _used_graphics_set->palette); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
281 LoadGrfIndexed( |
10037
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
282 _used_graphics_set->files[GFT_ARCTIC + _settings_game.game_creation.landscape - 1].filename, |
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
|
283 _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
|
284 i++ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
285 ); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
286 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
287 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
288 /* 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
|
289 InitializeUnicodeGlyphMap(); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
290 |
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
|
291 /* |
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
|
292 * 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
|
293 * 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
|
294 * 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
|
295 */ |
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
|
296 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
|
297 GRFConfig *master = CallocT<GRFConfig>(1); |
10037
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
298 master->filename = strdup(_used_graphics_set->files[GFT_EXTRA].filename); |
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
|
299 FillGRFDetails(master, false); |
10066
42653fe231a2
(svn r14233) -Feature/Fix [FS#2172]: save the palette of the loaded NewGRFs in the savegame, so joining with a server using Windows palette will make a client with the DOS palette do palette conversion and (thus) not cause a desync due to the different palettes disabling different NewGRFs.
rubidium <rubidium@openttd.org>
parents:
10062
diff
changeset
|
300 master->windows_paletted = (_used_graphics_set->palette == PAL_WINDOWS); |
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
|
301 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
|
302 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
|
303 _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
|
304 |
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
|
305 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
|
306 |
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
|
307 /* 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
|
308 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
|
309 _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
|
310 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
311 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
312 |
6247
57363e064324
(svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents:
6179
diff
changeset
|
313 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
|
314 { |
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
|
315 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
|
316 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
317 GfxInitSpriteMem(); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
318 LoadSpriteTables(); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
319 GfxInitPalettes(); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
320 } |
9994
4687a554c837
(svn r14151) -Codechange: make it possible to choose between the DOS and Windows graphics packs while retaining the possibility to override the palette.
rubidium <rubidium@openttd.org>
parents:
9989
diff
changeset
|
321 |
4687a554c837
(svn r14151) -Codechange: make it possible to choose between the DOS and Windows graphics packs while retaining the possibility to override the palette.
rubidium <rubidium@openttd.org>
parents:
9989
diff
changeset
|
322 /** |
10037
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
323 * Try to read a single piece of metadata and return false if it doesn't exist. |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
324 * @param name the name of the item to fetch. |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
325 */ |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
326 #define fetch_metadata(name) \ |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
327 item = metadata->GetItem(name, false); \ |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
328 if (item == NULL || strlen(item->value) == 0) { \ |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
329 DEBUG(grf, 0, "Base graphics set detail loading: %s field missing", name); \ |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
330 return false; \ |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
331 } |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
332 |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
333 /** Names corresponding to the GraphicsFileType */ |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
334 static const char *_gft_names[MAX_GFT] = { "base", "logos", "arctic", "tropical", "toyland", "extra" }; |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
335 |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
336 /** |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
337 * Read the graphics set information from a loaded ini. |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
338 * @param graphics the graphics set to write to |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
339 * @param ini the ini to read from |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
340 * @param path the path to this ini file (for filenames) |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
341 * @return true if loading was successful. |
9994
4687a554c837
(svn r14151) -Codechange: make it possible to choose between the DOS and Windows graphics packs while retaining the possibility to override the palette.
rubidium <rubidium@openttd.org>
parents:
9989
diff
changeset
|
342 */ |
10037
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
343 static bool FillGraphicsSetDetails(GraphicsSet *graphics, IniFile *ini, const char *path) |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
344 { |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
345 memset(graphics, 0, sizeof(*graphics)); |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
346 |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
347 IniGroup *metadata = ini->GetGroup("metadata"); |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
348 IniItem *item; |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
349 |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
350 fetch_metadata("name"); |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
351 graphics->name = strdup(item->value); |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
352 |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
353 fetch_metadata("description"); |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
354 graphics->description = strdup(item->value); |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
355 |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
356 fetch_metadata("shortname"); |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
357 for (uint i = 0; item->value[i] != '\0' && i < 4; i++) { |
10777
9afa402bfb6f
(svn r15110) -Fix: reading the shortname of graphicssets always missed the first character.
rubidium <rubidium@openttd.org>
parents:
10647
diff
changeset
|
358 graphics->shortname |= ((uint8)item->value[i]) << (i * 8); |
10037
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
359 } |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
360 |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
361 fetch_metadata("version"); |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
362 graphics->version = atoi(item->value); |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
363 |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
364 fetch_metadata("palette"); |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
365 graphics->palette = (*item->value == 'D' || *item->value == 'd') ? PAL_DOS : PAL_WINDOWS; |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
366 |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
367 /* For each of the graphics file types we want to find the file, MD5 checksums and warning messages. */ |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
368 IniGroup *files = ini->GetGroup("files"); |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
369 IniGroup *md5s = ini->GetGroup("md5s"); |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
370 IniGroup *origin = ini->GetGroup("origin"); |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
371 for (uint i = 0; i < MAX_GFT; i++) { |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
372 MD5File *file = &graphics->files[i]; |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
373 /* Find the filename first. */ |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
374 item = files->GetItem(_gft_names[i], false); |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
375 if (item == NULL) { |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
376 DEBUG(grf, 0, "No graphics file for: %s", _gft_names[i]); |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
377 return false; |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
378 } |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
379 |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
380 const char *filename = item->value; |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
381 file->filename = MallocT<char>(strlen(filename) + strlen(path) + 1); |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
382 sprintf((char*)file->filename, "%s%s", path, filename); |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
383 |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
384 /* Then find the MD5 checksum */ |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
385 item = md5s->GetItem(filename, false); |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
386 if (item == NULL) { |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
387 DEBUG(grf, 0, "No MD5 checksum specified for: %s", filename); |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
388 return false; |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
389 } |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
390 char *c = item->value; |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
391 for (uint i = 0; i < sizeof(file->hash) * 2; i++, c++) { |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
392 uint j; |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
393 if ('0' <= *c && *c <= '9') { |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
394 j = *c - '0'; |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
395 } else if ('a' <= *c && *c <= 'f') { |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
396 j = *c - 'a' + 10; |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
397 } else if ('A' <= *c && *c <= 'F') { |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
398 j = *c - 'A' + 10; |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
399 } else { |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
400 DEBUG(grf, 0, "Malformed MD5 checksum specified for: %s", filename); |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
401 return false; |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
402 } |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
403 if (i % 2 == 0) { |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
404 file->hash[i / 2] = j << 4; |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
405 } else { |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
406 file->hash[i / 2] |= j; |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
407 } |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
408 } |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
409 |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
410 /* Then find the warning message when the file's missing */ |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
411 item = origin->GetItem(filename, false); |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
412 if (item == NULL) item = origin->GetItem("default", false); |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
413 if (item == NULL) { |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
414 DEBUG(grf, 1, "No origin warning message specified for: %s", filename); |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
415 file->missing_warning = strdup(""); |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
416 } else { |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
417 file->missing_warning = strdup(item->value); |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
418 } |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
419 |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
420 if (FileMD5(*file)) graphics->found_grfs++; |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
421 } |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
422 |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
423 return true; |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
424 } |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
425 |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
426 /** Helper for scanning for files with GRF as extension */ |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
427 class OBGFileScanner : FileScanner { |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
428 public: |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
429 /* virtual */ bool AddFile(const char *filename, size_t basepath_length); |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
430 |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
431 /** Do the scan for OBGs. */ |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
432 static uint DoScan() |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
433 { |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
434 OBGFileScanner fs; |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
435 return fs.Scan(".obg", DATA_DIR); |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
436 } |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
437 }; |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
438 |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
439 /** |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
440 * Try to add a graphics set with the given filename. |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
441 * @param filename the full path to the file to read |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
442 * @param basepath_length amount of characters to chop of before to get a relative DATA_DIR filename |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
443 * @return true if the file is added. |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
444 */ |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
445 bool OBGFileScanner::AddFile(const char *filename, size_t basepath_length) |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
446 { |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
447 bool ret = false; |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
448 DEBUG(grf, 1, "Found %s as base graphics set", filename); |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
449 |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
450 GraphicsSet *graphics = new GraphicsSet();; |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
451 IniFile *ini = new IniFile(); |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
452 ini->LoadFromDisk(filename); |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
453 |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
454 char *path = strdup(filename + basepath_length); |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
455 char *psep = strrchr(path, PATHSEPCHAR); |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
456 if (psep != NULL) { |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
457 psep[1] = '\0'; |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
458 } else { |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
459 *path = '\0'; |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
460 } |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
461 |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
462 if (FillGraphicsSetDetails(graphics, ini, path)) { |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
463 bool duplicate = false; |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
464 for (const GraphicsSet *c = _available_graphics_sets; !duplicate && c != NULL; c = c->next) { |
10883
e043c7d591cf
(svn r15218) -Fix: base graphics detection did mark too much as duplicate
rubidium <rubidium@openttd.org>
parents:
10793
diff
changeset
|
465 duplicate = (strcmp(c->name, graphics->name) == 0 || c->shortname == graphics->shortname) && c->version == graphics->version; |
10037
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
466 } |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
467 if (duplicate) { |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
468 delete graphics; |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
469 } else { |
11344
699a0f6a1407
(svn r15694) -Codechange/feature/fix: invert the order in which base graphics sets are queried making it fairly unlikely that downloaded graphics sets override the original graphics.
rubidium <rubidium@openttd.org>
parents:
11130
diff
changeset
|
470 GraphicsSet **last = &_available_graphics_sets; |
699a0f6a1407
(svn r15694) -Codechange/feature/fix: invert the order in which base graphics sets are queried making it fairly unlikely that downloaded graphics sets override the original graphics.
rubidium <rubidium@openttd.org>
parents:
11130
diff
changeset
|
471 while (*last != NULL) last = &(*last)->next; |
699a0f6a1407
(svn r15694) -Codechange/feature/fix: invert the order in which base graphics sets are queried making it fairly unlikely that downloaded graphics sets override the original graphics.
rubidium <rubidium@openttd.org>
parents:
11130
diff
changeset
|
472 |
699a0f6a1407
(svn r15694) -Codechange/feature/fix: invert the order in which base graphics sets are queried making it fairly unlikely that downloaded graphics sets override the original graphics.
rubidium <rubidium@openttd.org>
parents:
11130
diff
changeset
|
473 *last = graphics; |
10037
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
474 ret = true; |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
475 } |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
476 } else { |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
477 delete graphics; |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
478 } |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
479 free(path); |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
480 |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
481 delete ini; |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
482 return ret; |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
483 } |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
484 |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
485 |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
486 |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
487 /** Scan for all Grahpics sets */ |
9994
4687a554c837
(svn r14151) -Codechange: make it possible to choose between the DOS and Windows graphics packs while retaining the possibility to override the palette.
rubidium <rubidium@openttd.org>
parents:
9989
diff
changeset
|
488 void FindGraphicsSets() |
4687a554c837
(svn r14151) -Codechange: make it possible to choose between the DOS and Windows graphics packs while retaining the possibility to override the palette.
rubidium <rubidium@openttd.org>
parents:
9989
diff
changeset
|
489 { |
10037
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
490 DEBUG(grf, 1, "Scanning for Graphics sets"); |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
491 OBGFileScanner::DoScan(); |
9994
4687a554c837
(svn r14151) -Codechange: make it possible to choose between the DOS and Windows graphics packs while retaining the possibility to override the palette.
rubidium <rubidium@openttd.org>
parents:
9989
diff
changeset
|
492 } |
4687a554c837
(svn r14151) -Codechange: make it possible to choose between the DOS and Windows graphics packs while retaining the possibility to override the palette.
rubidium <rubidium@openttd.org>
parents:
9989
diff
changeset
|
493 |
4687a554c837
(svn r14151) -Codechange: make it possible to choose between the DOS and Windows graphics packs while retaining the possibility to override the palette.
rubidium <rubidium@openttd.org>
parents:
9989
diff
changeset
|
494 /** |
4687a554c837
(svn r14151) -Codechange: make it possible to choose between the DOS and Windows graphics packs while retaining the possibility to override the palette.
rubidium <rubidium@openttd.org>
parents:
9989
diff
changeset
|
495 * Set the graphics set to be used. |
4687a554c837
(svn r14151) -Codechange: make it possible to choose between the DOS and Windows graphics packs while retaining the possibility to override the palette.
rubidium <rubidium@openttd.org>
parents:
9989
diff
changeset
|
496 * @param name of the graphics set to use |
4687a554c837
(svn r14151) -Codechange: make it possible to choose between the DOS and Windows graphics packs while retaining the possibility to override the palette.
rubidium <rubidium@openttd.org>
parents:
9989
diff
changeset
|
497 * @return true if it could be loaded |
4687a554c837
(svn r14151) -Codechange: make it possible to choose between the DOS and Windows graphics packs while retaining the possibility to override the palette.
rubidium <rubidium@openttd.org>
parents:
9989
diff
changeset
|
498 */ |
4687a554c837
(svn r14151) -Codechange: make it possible to choose between the DOS and Windows graphics packs while retaining the possibility to override the palette.
rubidium <rubidium@openttd.org>
parents:
9989
diff
changeset
|
499 bool SetGraphicsSet(const char *name) |
4687a554c837
(svn r14151) -Codechange: make it possible to choose between the DOS and Windows graphics packs while retaining the possibility to override the palette.
rubidium <rubidium@openttd.org>
parents:
9989
diff
changeset
|
500 { |
4687a554c837
(svn r14151) -Codechange: make it possible to choose between the DOS and Windows graphics packs while retaining the possibility to override the palette.
rubidium <rubidium@openttd.org>
parents:
9989
diff
changeset
|
501 if (StrEmpty(name)) { |
10048
d9459f6eb49e
(svn r14208) -Fix (r14197): Crash if no .obg files are found.
peter1138 <peter1138@openttd.org>
parents:
10039
diff
changeset
|
502 if (!DetermineGraphicsPack()) return false; |
9994
4687a554c837
(svn r14151) -Codechange: make it possible to choose between the DOS and Windows graphics packs while retaining the possibility to override the palette.
rubidium <rubidium@openttd.org>
parents:
9989
diff
changeset
|
503 CheckExternalFiles(); |
4687a554c837
(svn r14151) -Codechange: make it possible to choose between the DOS and Windows graphics packs while retaining the possibility to override the palette.
rubidium <rubidium@openttd.org>
parents:
9989
diff
changeset
|
504 return true; |
4687a554c837
(svn r14151) -Codechange: make it possible to choose between the DOS and Windows graphics packs while retaining the possibility to override the palette.
rubidium <rubidium@openttd.org>
parents:
9989
diff
changeset
|
505 } |
4687a554c837
(svn r14151) -Codechange: make it possible to choose between the DOS and Windows graphics packs while retaining the possibility to override the palette.
rubidium <rubidium@openttd.org>
parents:
9989
diff
changeset
|
506 |
10037
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
507 for (const GraphicsSet *g = _available_graphics_sets; g != NULL; g = g->next) { |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
508 if (strcmp(name, g->name) == 0) { |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
509 _used_graphics_set = g; |
9994
4687a554c837
(svn r14151) -Codechange: make it possible to choose between the DOS and Windows graphics packs while retaining the possibility to override the palette.
rubidium <rubidium@openttd.org>
parents:
9989
diff
changeset
|
510 CheckExternalFiles(); |
4687a554c837
(svn r14151) -Codechange: make it possible to choose between the DOS and Windows graphics packs while retaining the possibility to override the palette.
rubidium <rubidium@openttd.org>
parents:
9989
diff
changeset
|
511 return true; |
4687a554c837
(svn r14151) -Codechange: make it possible to choose between the DOS and Windows graphics packs while retaining the possibility to override the palette.
rubidium <rubidium@openttd.org>
parents:
9989
diff
changeset
|
512 } |
4687a554c837
(svn r14151) -Codechange: make it possible to choose between the DOS and Windows graphics packs while retaining the possibility to override the palette.
rubidium <rubidium@openttd.org>
parents:
9989
diff
changeset
|
513 } |
4687a554c837
(svn r14151) -Codechange: make it possible to choose between the DOS and Windows graphics packs while retaining the possibility to override the palette.
rubidium <rubidium@openttd.org>
parents:
9989
diff
changeset
|
514 return false; |
4687a554c837
(svn r14151) -Codechange: make it possible to choose between the DOS and Windows graphics packs while retaining the possibility to override the palette.
rubidium <rubidium@openttd.org>
parents:
9989
diff
changeset
|
515 } |
4687a554c837
(svn r14151) -Codechange: make it possible to choose between the DOS and Windows graphics packs while retaining the possibility to override the palette.
rubidium <rubidium@openttd.org>
parents:
9989
diff
changeset
|
516 |
4687a554c837
(svn r14151) -Codechange: make it possible to choose between the DOS and Windows graphics packs while retaining the possibility to override the palette.
rubidium <rubidium@openttd.org>
parents:
9989
diff
changeset
|
517 /** |
4687a554c837
(svn r14151) -Codechange: make it possible to choose between the DOS and Windows graphics packs while retaining the possibility to override the palette.
rubidium <rubidium@openttd.org>
parents:
9989
diff
changeset
|
518 * Returns a list with the graphics sets. |
4687a554c837
(svn r14151) -Codechange: make it possible to choose between the DOS and Windows graphics packs while retaining the possibility to override the palette.
rubidium <rubidium@openttd.org>
parents:
9989
diff
changeset
|
519 * @param p where to print to |
4687a554c837
(svn r14151) -Codechange: make it possible to choose between the DOS and Windows graphics packs while retaining the possibility to override the palette.
rubidium <rubidium@openttd.org>
parents:
9989
diff
changeset
|
520 * @param last the last character to print to |
4687a554c837
(svn r14151) -Codechange: make it possible to choose between the DOS and Windows graphics packs while retaining the possibility to override the palette.
rubidium <rubidium@openttd.org>
parents:
9989
diff
changeset
|
521 * @return the last printed character |
4687a554c837
(svn r14151) -Codechange: make it possible to choose between the DOS and Windows graphics packs while retaining the possibility to override the palette.
rubidium <rubidium@openttd.org>
parents:
9989
diff
changeset
|
522 */ |
4687a554c837
(svn r14151) -Codechange: make it possible to choose between the DOS and Windows graphics packs while retaining the possibility to override the palette.
rubidium <rubidium@openttd.org>
parents:
9989
diff
changeset
|
523 char *GetGraphicsSetsList(char *p, const char *last) |
4687a554c837
(svn r14151) -Codechange: make it possible to choose between the DOS and Windows graphics packs while retaining the possibility to override the palette.
rubidium <rubidium@openttd.org>
parents:
9989
diff
changeset
|
524 { |
10299
26fd53f1fd8d
(svn r14540) -Codechange: introduce [v]seprintf which are like [v]snprintf but do return the number of characters written instead of the number of characters that would be written; as size_t is unsigned substraction can cause integer underflows quite quickly.
rubidium <rubidium@openttd.org>
parents:
10077
diff
changeset
|
525 p += seprintf(p, last, "List of graphics sets:\n"); |
10037
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
526 for (const GraphicsSet *g = _available_graphics_sets; g != NULL; g = g->next) { |
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
527 if (g->found_grfs <= 1) continue; |
9994
4687a554c837
(svn r14151) -Codechange: make it possible to choose between the DOS and Windows graphics packs while retaining the possibility to override the palette.
rubidium <rubidium@openttd.org>
parents:
9989
diff
changeset
|
528 |
10299
26fd53f1fd8d
(svn r14540) -Codechange: introduce [v]seprintf which are like [v]snprintf but do return the number of characters written instead of the number of characters that would be written; as size_t is unsigned substraction can cause integer underflows quite quickly.
rubidium <rubidium@openttd.org>
parents:
10077
diff
changeset
|
529 p += seprintf(p, last, "%18s: %s", g->name, g->description); |
10037
83d0016c127e
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents:
9995
diff
changeset
|
530 int difference = MAX_GFT - g->found_grfs; |
9994
4687a554c837
(svn r14151) -Codechange: make it possible to choose between the DOS and Windows graphics packs while retaining the possibility to override the palette.
rubidium <rubidium@openttd.org>
parents:
9989
diff
changeset
|
531 if (difference != 0) { |
10299
26fd53f1fd8d
(svn r14540) -Codechange: introduce [v]seprintf which are like [v]snprintf but do return the number of characters written instead of the number of characters that would be written; as size_t is unsigned substraction can cause integer underflows quite quickly.
rubidium <rubidium@openttd.org>
parents:
10077
diff
changeset
|
532 p += seprintf(p, last, " (missing %i file%s)\n", difference, difference == 1 ? "" : "s"); |
9994
4687a554c837
(svn r14151) -Codechange: make it possible to choose between the DOS and Windows graphics packs while retaining the possibility to override the palette.
rubidium <rubidium@openttd.org>
parents:
9989
diff
changeset
|
533 } else { |
10299
26fd53f1fd8d
(svn r14540) -Codechange: introduce [v]seprintf which are like [v]snprintf but do return the number of characters written instead of the number of characters that would be written; as size_t is unsigned substraction can cause integer underflows quite quickly.
rubidium <rubidium@openttd.org>
parents:
10077
diff
changeset
|
534 p += seprintf(p, last, "\n"); |
9994
4687a554c837
(svn r14151) -Codechange: make it possible to choose between the DOS and Windows graphics packs while retaining the possibility to override the palette.
rubidium <rubidium@openttd.org>
parents:
9989
diff
changeset
|
535 } |
4687a554c837
(svn r14151) -Codechange: make it possible to choose between the DOS and Windows graphics packs while retaining the possibility to override the palette.
rubidium <rubidium@openttd.org>
parents:
9989
diff
changeset
|
536 } |
10299
26fd53f1fd8d
(svn r14540) -Codechange: introduce [v]seprintf which are like [v]snprintf but do return the number of characters written instead of the number of characters that would be written; as size_t is unsigned substraction can cause integer underflows quite quickly.
rubidium <rubidium@openttd.org>
parents:
10077
diff
changeset
|
537 p += seprintf(p, last, "\n"); |
9994
4687a554c837
(svn r14151) -Codechange: make it possible to choose between the DOS and Windows graphics packs while retaining the possibility to override the palette.
rubidium <rubidium@openttd.org>
parents:
9989
diff
changeset
|
538 |
4687a554c837
(svn r14151) -Codechange: make it possible to choose between the DOS and Windows graphics packs while retaining the possibility to override the palette.
rubidium <rubidium@openttd.org>
parents:
9989
diff
changeset
|
539 return p; |
4687a554c837
(svn r14151) -Codechange: make it possible to choose between the DOS and Windows graphics packs while retaining the possibility to override the palette.
rubidium <rubidium@openttd.org>
parents:
9989
diff
changeset
|
540 } |
10793
0744d383a56b
(svn r15126) -Feature: downloading content from a central server (content.openttd.org) where authors can upload they NewGRFS/AI etc. This should make joining servers that use only NewGRFs that are distributed via this system easier as the players can download the NewGRFs from in the game. It should also make it easier to see whether there are updates for NewGRFs and make the necessary updates.
rubidium <rubidium@openttd.org>
parents:
10777
diff
changeset
|
541 |
0744d383a56b
(svn r15126) -Feature: downloading content from a central server (content.openttd.org) where authors can upload they NewGRFS/AI etc. This should make joining servers that use only NewGRFs that are distributed via this system easier as the players can download the NewGRFs from in the game. It should also make it easier to see whether there are updates for NewGRFs and make the necessary updates.
rubidium <rubidium@openttd.org>
parents:
10777
diff
changeset
|
542 #if defined(ENABLE_NETWORK) |
0744d383a56b
(svn r15126) -Feature: downloading content from a central server (content.openttd.org) where authors can upload they NewGRFS/AI etc. This should make joining servers that use only NewGRFs that are distributed via this system easier as the players can download the NewGRFs from in the game. It should also make it easier to see whether there are updates for NewGRFs and make the necessary updates.
rubidium <rubidium@openttd.org>
parents:
10777
diff
changeset
|
543 #include "network/network_content.h" |
0744d383a56b
(svn r15126) -Feature: downloading content from a central server (content.openttd.org) where authors can upload they NewGRFS/AI etc. This should make joining servers that use only NewGRFs that are distributed via this system easier as the players can download the NewGRFs from in the game. It should also make it easier to see whether there are updates for NewGRFs and make the necessary updates.
rubidium <rubidium@openttd.org>
parents:
10777
diff
changeset
|
544 |
0744d383a56b
(svn r15126) -Feature: downloading content from a central server (content.openttd.org) where authors can upload they NewGRFS/AI etc. This should make joining servers that use only NewGRFs that are distributed via this system easier as the players can download the NewGRFs from in the game. It should also make it easier to see whether there are updates for NewGRFs and make the necessary updates.
rubidium <rubidium@openttd.org>
parents:
10777
diff
changeset
|
545 /** |
0744d383a56b
(svn r15126) -Feature: downloading content from a central server (content.openttd.org) where authors can upload they NewGRFS/AI etc. This should make joining servers that use only NewGRFs that are distributed via this system easier as the players can download the NewGRFs from in the game. It should also make it easier to see whether there are updates for NewGRFs and make the necessary updates.
rubidium <rubidium@openttd.org>
parents:
10777
diff
changeset
|
546 * Check whether we have an graphics with the exact characteristics as ci. |
0744d383a56b
(svn r15126) -Feature: downloading content from a central server (content.openttd.org) where authors can upload they NewGRFS/AI etc. This should make joining servers that use only NewGRFs that are distributed via this system easier as the players can download the NewGRFs from in the game. It should also make it easier to see whether there are updates for NewGRFs and make the necessary updates.
rubidium <rubidium@openttd.org>
parents:
10777
diff
changeset
|
547 * @param ci the characteristics to search on (shortname and md5sum) |
0744d383a56b
(svn r15126) -Feature: downloading content from a central server (content.openttd.org) where authors can upload they NewGRFS/AI etc. This should make joining servers that use only NewGRFs that are distributed via this system easier as the players can download the NewGRFs from in the game. It should also make it easier to see whether there are updates for NewGRFs and make the necessary updates.
rubidium <rubidium@openttd.org>
parents:
10777
diff
changeset
|
548 * @param md5sum whether to check the MD5 checksum |
0744d383a56b
(svn r15126) -Feature: downloading content from a central server (content.openttd.org) where authors can upload they NewGRFS/AI etc. This should make joining servers that use only NewGRFs that are distributed via this system easier as the players can download the NewGRFs from in the game. It should also make it easier to see whether there are updates for NewGRFs and make the necessary updates.
rubidium <rubidium@openttd.org>
parents:
10777
diff
changeset
|
549 * @return true iff we have an graphics set matching. |
0744d383a56b
(svn r15126) -Feature: downloading content from a central server (content.openttd.org) where authors can upload they NewGRFS/AI etc. This should make joining servers that use only NewGRFs that are distributed via this system easier as the players can download the NewGRFs from in the game. It should also make it easier to see whether there are updates for NewGRFs and make the necessary updates.
rubidium <rubidium@openttd.org>
parents:
10777
diff
changeset
|
550 */ |
0744d383a56b
(svn r15126) -Feature: downloading content from a central server (content.openttd.org) where authors can upload they NewGRFS/AI etc. This should make joining servers that use only NewGRFs that are distributed via this system easier as the players can download the NewGRFs from in the game. It should also make it easier to see whether there are updates for NewGRFs and make the necessary updates.
rubidium <rubidium@openttd.org>
parents:
10777
diff
changeset
|
551 bool HasGraphicsSet(const ContentInfo *ci, bool md5sum) |
0744d383a56b
(svn r15126) -Feature: downloading content from a central server (content.openttd.org) where authors can upload they NewGRFS/AI etc. This should make joining servers that use only NewGRFs that are distributed via this system easier as the players can download the NewGRFs from in the game. It should also make it easier to see whether there are updates for NewGRFs and make the necessary updates.
rubidium <rubidium@openttd.org>
parents:
10777
diff
changeset
|
552 { |
0744d383a56b
(svn r15126) -Feature: downloading content from a central server (content.openttd.org) where authors can upload they NewGRFS/AI etc. This should make joining servers that use only NewGRFs that are distributed via this system easier as the players can download the NewGRFs from in the game. It should also make it easier to see whether there are updates for NewGRFs and make the necessary updates.
rubidium <rubidium@openttd.org>
parents:
10777
diff
changeset
|
553 assert(ci->type == CONTENT_TYPE_BASE_GRAPHICS); |
0744d383a56b
(svn r15126) -Feature: downloading content from a central server (content.openttd.org) where authors can upload they NewGRFS/AI etc. This should make joining servers that use only NewGRFs that are distributed via this system easier as the players can download the NewGRFs from in the game. It should also make it easier to see whether there are updates for NewGRFs and make the necessary updates.
rubidium <rubidium@openttd.org>
parents:
10777
diff
changeset
|
554 for (const GraphicsSet *g = _available_graphics_sets; g != NULL; g = g->next) { |
0744d383a56b
(svn r15126) -Feature: downloading content from a central server (content.openttd.org) where authors can upload they NewGRFS/AI etc. This should make joining servers that use only NewGRFs that are distributed via this system easier as the players can download the NewGRFs from in the game. It should also make it easier to see whether there are updates for NewGRFs and make the necessary updates.
rubidium <rubidium@openttd.org>
parents:
10777
diff
changeset
|
555 if (g->found_grfs <= 1) continue; |
0744d383a56b
(svn r15126) -Feature: downloading content from a central server (content.openttd.org) where authors can upload they NewGRFS/AI etc. This should make joining servers that use only NewGRFs that are distributed via this system easier as the players can download the NewGRFs from in the game. It should also make it easier to see whether there are updates for NewGRFs and make the necessary updates.
rubidium <rubidium@openttd.org>
parents:
10777
diff
changeset
|
556 |
0744d383a56b
(svn r15126) -Feature: downloading content from a central server (content.openttd.org) where authors can upload they NewGRFS/AI etc. This should make joining servers that use only NewGRFs that are distributed via this system easier as the players can download the NewGRFs from in the game. It should also make it easier to see whether there are updates for NewGRFs and make the necessary updates.
rubidium <rubidium@openttd.org>
parents:
10777
diff
changeset
|
557 if (g->shortname != ci->unique_id) continue; |
0744d383a56b
(svn r15126) -Feature: downloading content from a central server (content.openttd.org) where authors can upload they NewGRFS/AI etc. This should make joining servers that use only NewGRFs that are distributed via this system easier as the players can download the NewGRFs from in the game. It should also make it easier to see whether there are updates for NewGRFs and make the necessary updates.
rubidium <rubidium@openttd.org>
parents:
10777
diff
changeset
|
558 if (!md5sum) return true; |
0744d383a56b
(svn r15126) -Feature: downloading content from a central server (content.openttd.org) where authors can upload they NewGRFS/AI etc. This should make joining servers that use only NewGRFs that are distributed via this system easier as the players can download the NewGRFs from in the game. It should also make it easier to see whether there are updates for NewGRFs and make the necessary updates.
rubidium <rubidium@openttd.org>
parents:
10777
diff
changeset
|
559 |
0744d383a56b
(svn r15126) -Feature: downloading content from a central server (content.openttd.org) where authors can upload they NewGRFS/AI etc. This should make joining servers that use only NewGRFs that are distributed via this system easier as the players can download the NewGRFs from in the game. It should also make it easier to see whether there are updates for NewGRFs and make the necessary updates.
rubidium <rubidium@openttd.org>
parents:
10777
diff
changeset
|
560 byte md5[16]; |
0744d383a56b
(svn r15126) -Feature: downloading content from a central server (content.openttd.org) where authors can upload they NewGRFS/AI etc. This should make joining servers that use only NewGRFs that are distributed via this system easier as the players can download the NewGRFs from in the game. It should also make it easier to see whether there are updates for NewGRFs and make the necessary updates.
rubidium <rubidium@openttd.org>
parents:
10777
diff
changeset
|
561 memset(md5, 0, sizeof(md5)); |
0744d383a56b
(svn r15126) -Feature: downloading content from a central server (content.openttd.org) where authors can upload they NewGRFS/AI etc. This should make joining servers that use only NewGRFs that are distributed via this system easier as the players can download the NewGRFs from in the game. It should also make it easier to see whether there are updates for NewGRFs and make the necessary updates.
rubidium <rubidium@openttd.org>
parents:
10777
diff
changeset
|
562 for (uint i = 0; i < MAX_GFT; i++) { |
0744d383a56b
(svn r15126) -Feature: downloading content from a central server (content.openttd.org) where authors can upload they NewGRFS/AI etc. This should make joining servers that use only NewGRFs that are distributed via this system easier as the players can download the NewGRFs from in the game. It should also make it easier to see whether there are updates for NewGRFs and make the necessary updates.
rubidium <rubidium@openttd.org>
parents:
10777
diff
changeset
|
563 for (uint j = 0; j < sizeof(md5); j++) { |
0744d383a56b
(svn r15126) -Feature: downloading content from a central server (content.openttd.org) where authors can upload they NewGRFS/AI etc. This should make joining servers that use only NewGRFs that are distributed via this system easier as the players can download the NewGRFs from in the game. It should also make it easier to see whether there are updates for NewGRFs and make the necessary updates.
rubidium <rubidium@openttd.org>
parents:
10777
diff
changeset
|
564 md5[j] ^= g->files[i].hash[j]; |
0744d383a56b
(svn r15126) -Feature: downloading content from a central server (content.openttd.org) where authors can upload they NewGRFS/AI etc. This should make joining servers that use only NewGRFs that are distributed via this system easier as the players can download the NewGRFs from in the game. It should also make it easier to see whether there are updates for NewGRFs and make the necessary updates.
rubidium <rubidium@openttd.org>
parents:
10777
diff
changeset
|
565 } |
0744d383a56b
(svn r15126) -Feature: downloading content from a central server (content.openttd.org) where authors can upload they NewGRFS/AI etc. This should make joining servers that use only NewGRFs that are distributed via this system easier as the players can download the NewGRFs from in the game. It should also make it easier to see whether there are updates for NewGRFs and make the necessary updates.
rubidium <rubidium@openttd.org>
parents:
10777
diff
changeset
|
566 } |
0744d383a56b
(svn r15126) -Feature: downloading content from a central server (content.openttd.org) where authors can upload they NewGRFS/AI etc. This should make joining servers that use only NewGRFs that are distributed via this system easier as the players can download the NewGRFs from in the game. It should also make it easier to see whether there are updates for NewGRFs and make the necessary updates.
rubidium <rubidium@openttd.org>
parents:
10777
diff
changeset
|
567 if (memcmp(md5, ci->md5sum, sizeof(md5)) == 0) return true; |
0744d383a56b
(svn r15126) -Feature: downloading content from a central server (content.openttd.org) where authors can upload they NewGRFS/AI etc. This should make joining servers that use only NewGRFs that are distributed via this system easier as the players can download the NewGRFs from in the game. It should also make it easier to see whether there are updates for NewGRFs and make the necessary updates.
rubidium <rubidium@openttd.org>
parents:
10777
diff
changeset
|
568 } |
0744d383a56b
(svn r15126) -Feature: downloading content from a central server (content.openttd.org) where authors can upload they NewGRFS/AI etc. This should make joining servers that use only NewGRFs that are distributed via this system easier as the players can download the NewGRFs from in the game. It should also make it easier to see whether there are updates for NewGRFs and make the necessary updates.
rubidium <rubidium@openttd.org>
parents:
10777
diff
changeset
|
569 |
0744d383a56b
(svn r15126) -Feature: downloading content from a central server (content.openttd.org) where authors can upload they NewGRFS/AI etc. This should make joining servers that use only NewGRFs that are distributed via this system easier as the players can download the NewGRFs from in the game. It should also make it easier to see whether there are updates for NewGRFs and make the necessary updates.
rubidium <rubidium@openttd.org>
parents:
10777
diff
changeset
|
570 return false; |
0744d383a56b
(svn r15126) -Feature: downloading content from a central server (content.openttd.org) where authors can upload they NewGRFS/AI etc. This should make joining servers that use only NewGRFs that are distributed via this system easier as the players can download the NewGRFs from in the game. It should also make it easier to see whether there are updates for NewGRFs and make the necessary updates.
rubidium <rubidium@openttd.org>
parents:
10777
diff
changeset
|
571 } |
0744d383a56b
(svn r15126) -Feature: downloading content from a central server (content.openttd.org) where authors can upload they NewGRFS/AI etc. This should make joining servers that use only NewGRFs that are distributed via this system easier as the players can download the NewGRFs from in the game. It should also make it easier to see whether there are updates for NewGRFs and make the necessary updates.
rubidium <rubidium@openttd.org>
parents:
10777
diff
changeset
|
572 |
0744d383a56b
(svn r15126) -Feature: downloading content from a central server (content.openttd.org) where authors can upload they NewGRFS/AI etc. This should make joining servers that use only NewGRFs that are distributed via this system easier as the players can download the NewGRFs from in the game. It should also make it easier to see whether there are updates for NewGRFs and make the necessary updates.
rubidium <rubidium@openttd.org>
parents:
10777
diff
changeset
|
573 #endif /* ENABLE_NETWORK */ |
11049
ed93627e213f
(svn r15389) -Feature: Add ability to select which base graphics set is used from the Game Options window. The change takes effect when the window is closed. This option can only be used from the intro menu, as reloading graphics during a game may cause issues.
peter1138 <peter1138@openttd.org>
parents:
10960
diff
changeset
|
574 |
ed93627e213f
(svn r15389) -Feature: Add ability to select which base graphics set is used from the Game Options window. The change takes effect when the window is closed. This option can only be used from the intro menu, as reloading graphics during a game may cause issues.
peter1138 <peter1138@openttd.org>
parents:
10960
diff
changeset
|
575 /** |
ed93627e213f
(svn r15389) -Feature: Add ability to select which base graphics set is used from the Game Options window. The change takes effect when the window is closed. This option can only be used from the intro menu, as reloading graphics during a game may cause issues.
peter1138 <peter1138@openttd.org>
parents:
10960
diff
changeset
|
576 * Count the number of available graphics sets. |
ed93627e213f
(svn r15389) -Feature: Add ability to select which base graphics set is used from the Game Options window. The change takes effect when the window is closed. This option can only be used from the intro menu, as reloading graphics during a game may cause issues.
peter1138 <peter1138@openttd.org>
parents:
10960
diff
changeset
|
577 */ |
ed93627e213f
(svn r15389) -Feature: Add ability to select which base graphics set is used from the Game Options window. The change takes effect when the window is closed. This option can only be used from the intro menu, as reloading graphics during a game may cause issues.
peter1138 <peter1138@openttd.org>
parents:
10960
diff
changeset
|
578 int GetNumGraphicsSets() |
ed93627e213f
(svn r15389) -Feature: Add ability to select which base graphics set is used from the Game Options window. The change takes effect when the window is closed. This option can only be used from the intro menu, as reloading graphics during a game may cause issues.
peter1138 <peter1138@openttd.org>
parents:
10960
diff
changeset
|
579 { |
ed93627e213f
(svn r15389) -Feature: Add ability to select which base graphics set is used from the Game Options window. The change takes effect when the window is closed. This option can only be used from the intro menu, as reloading graphics during a game may cause issues.
peter1138 <peter1138@openttd.org>
parents:
10960
diff
changeset
|
580 int n = 0; |
ed93627e213f
(svn r15389) -Feature: Add ability to select which base graphics set is used from the Game Options window. The change takes effect when the window is closed. This option can only be used from the intro menu, as reloading graphics during a game may cause issues.
peter1138 <peter1138@openttd.org>
parents:
10960
diff
changeset
|
581 for (const GraphicsSet *g = _available_graphics_sets; g != NULL; g = g->next) { |
11130
2770c4f89a05
(svn r15476) -Fix [FS#2630]: crash when opening the game options when the currently loaded base graphics pack has less than 2 valid graphics files. For example when someone replaces all his/her original base graphics with custom work (but keeps the name) or renames the dos ones to windows or vice versa.
rubidium <rubidium@openttd.org>
parents:
11054
diff
changeset
|
582 if (g != _used_graphics_set && g->found_grfs <= 1) continue; |
11049
ed93627e213f
(svn r15389) -Feature: Add ability to select which base graphics set is used from the Game Options window. The change takes effect when the window is closed. This option can only be used from the intro menu, as reloading graphics during a game may cause issues.
peter1138 <peter1138@openttd.org>
parents:
10960
diff
changeset
|
583 n++; |
ed93627e213f
(svn r15389) -Feature: Add ability to select which base graphics set is used from the Game Options window. The change takes effect when the window is closed. This option can only be used from the intro menu, as reloading graphics during a game may cause issues.
peter1138 <peter1138@openttd.org>
parents:
10960
diff
changeset
|
584 } |
ed93627e213f
(svn r15389) -Feature: Add ability to select which base graphics set is used from the Game Options window. The change takes effect when the window is closed. This option can only be used from the intro menu, as reloading graphics during a game may cause issues.
peter1138 <peter1138@openttd.org>
parents:
10960
diff
changeset
|
585 return n; |
ed93627e213f
(svn r15389) -Feature: Add ability to select which base graphics set is used from the Game Options window. The change takes effect when the window is closed. This option can only be used from the intro menu, as reloading graphics during a game may cause issues.
peter1138 <peter1138@openttd.org>
parents:
10960
diff
changeset
|
586 } |
ed93627e213f
(svn r15389) -Feature: Add ability to select which base graphics set is used from the Game Options window. The change takes effect when the window is closed. This option can only be used from the intro menu, as reloading graphics during a game may cause issues.
peter1138 <peter1138@openttd.org>
parents:
10960
diff
changeset
|
587 |
ed93627e213f
(svn r15389) -Feature: Add ability to select which base graphics set is used from the Game Options window. The change takes effect when the window is closed. This option can only be used from the intro menu, as reloading graphics during a game may cause issues.
peter1138 <peter1138@openttd.org>
parents:
10960
diff
changeset
|
588 /** |
ed93627e213f
(svn r15389) -Feature: Add ability to select which base graphics set is used from the Game Options window. The change takes effect when the window is closed. This option can only be used from the intro menu, as reloading graphics during a game may cause issues.
peter1138 <peter1138@openttd.org>
parents:
10960
diff
changeset
|
589 * Get the index of the currently active graphics set |
ed93627e213f
(svn r15389) -Feature: Add ability to select which base graphics set is used from the Game Options window. The change takes effect when the window is closed. This option can only be used from the intro menu, as reloading graphics during a game may cause issues.
peter1138 <peter1138@openttd.org>
parents:
10960
diff
changeset
|
590 */ |
ed93627e213f
(svn r15389) -Feature: Add ability to select which base graphics set is used from the Game Options window. The change takes effect when the window is closed. This option can only be used from the intro menu, as reloading graphics during a game may cause issues.
peter1138 <peter1138@openttd.org>
parents:
10960
diff
changeset
|
591 int GetIndexOfCurrentGraphicsSet() |
ed93627e213f
(svn r15389) -Feature: Add ability to select which base graphics set is used from the Game Options window. The change takes effect when the window is closed. This option can only be used from the intro menu, as reloading graphics during a game may cause issues.
peter1138 <peter1138@openttd.org>
parents:
10960
diff
changeset
|
592 { |
ed93627e213f
(svn r15389) -Feature: Add ability to select which base graphics set is used from the Game Options window. The change takes effect when the window is closed. This option can only be used from the intro menu, as reloading graphics during a game may cause issues.
peter1138 <peter1138@openttd.org>
parents:
10960
diff
changeset
|
593 int n = 0; |
ed93627e213f
(svn r15389) -Feature: Add ability to select which base graphics set is used from the Game Options window. The change takes effect when the window is closed. This option can only be used from the intro menu, as reloading graphics during a game may cause issues.
peter1138 <peter1138@openttd.org>
parents:
10960
diff
changeset
|
594 for (const GraphicsSet *g = _available_graphics_sets; g != NULL; g = g->next) { |
11130
2770c4f89a05
(svn r15476) -Fix [FS#2630]: crash when opening the game options when the currently loaded base graphics pack has less than 2 valid graphics files. For example when someone replaces all his/her original base graphics with custom work (but keeps the name) or renames the dos ones to windows or vice versa.
rubidium <rubidium@openttd.org>
parents:
11054
diff
changeset
|
595 if (g == _used_graphics_set) return n; |
11049
ed93627e213f
(svn r15389) -Feature: Add ability to select which base graphics set is used from the Game Options window. The change takes effect when the window is closed. This option can only be used from the intro menu, as reloading graphics during a game may cause issues.
peter1138 <peter1138@openttd.org>
parents:
10960
diff
changeset
|
596 if (g->found_grfs <= 1) continue; |
ed93627e213f
(svn r15389) -Feature: Add ability to select which base graphics set is used from the Game Options window. The change takes effect when the window is closed. This option can only be used from the intro menu, as reloading graphics during a game may cause issues.
peter1138 <peter1138@openttd.org>
parents:
10960
diff
changeset
|
597 n++; |
ed93627e213f
(svn r15389) -Feature: Add ability to select which base graphics set is used from the Game Options window. The change takes effect when the window is closed. This option can only be used from the intro menu, as reloading graphics during a game may cause issues.
peter1138 <peter1138@openttd.org>
parents:
10960
diff
changeset
|
598 } |
ed93627e213f
(svn r15389) -Feature: Add ability to select which base graphics set is used from the Game Options window. The change takes effect when the window is closed. This option can only be used from the intro menu, as reloading graphics during a game may cause issues.
peter1138 <peter1138@openttd.org>
parents:
10960
diff
changeset
|
599 return -1; |
ed93627e213f
(svn r15389) -Feature: Add ability to select which base graphics set is used from the Game Options window. The change takes effect when the window is closed. This option can only be used from the intro menu, as reloading graphics during a game may cause issues.
peter1138 <peter1138@openttd.org>
parents:
10960
diff
changeset
|
600 } |
ed93627e213f
(svn r15389) -Feature: Add ability to select which base graphics set is used from the Game Options window. The change takes effect when the window is closed. This option can only be used from the intro menu, as reloading graphics during a game may cause issues.
peter1138 <peter1138@openttd.org>
parents:
10960
diff
changeset
|
601 |
ed93627e213f
(svn r15389) -Feature: Add ability to select which base graphics set is used from the Game Options window. The change takes effect when the window is closed. This option can only be used from the intro menu, as reloading graphics during a game may cause issues.
peter1138 <peter1138@openttd.org>
parents:
10960
diff
changeset
|
602 /** |
ed93627e213f
(svn r15389) -Feature: Add ability to select which base graphics set is used from the Game Options window. The change takes effect when the window is closed. This option can only be used from the intro menu, as reloading graphics during a game may cause issues.
peter1138 <peter1138@openttd.org>
parents:
10960
diff
changeset
|
603 * Get the name of the graphics set at the specified index |
ed93627e213f
(svn r15389) -Feature: Add ability to select which base graphics set is used from the Game Options window. The change takes effect when the window is closed. This option can only be used from the intro menu, as reloading graphics during a game may cause issues.
peter1138 <peter1138@openttd.org>
parents:
10960
diff
changeset
|
604 */ |
ed93627e213f
(svn r15389) -Feature: Add ability to select which base graphics set is used from the Game Options window. The change takes effect when the window is closed. This option can only be used from the intro menu, as reloading graphics during a game may cause issues.
peter1138 <peter1138@openttd.org>
parents:
10960
diff
changeset
|
605 const char *GetGraphicsSetName(int index) |
ed93627e213f
(svn r15389) -Feature: Add ability to select which base graphics set is used from the Game Options window. The change takes effect when the window is closed. This option can only be used from the intro menu, as reloading graphics during a game may cause issues.
peter1138 <peter1138@openttd.org>
parents:
10960
diff
changeset
|
606 { |
ed93627e213f
(svn r15389) -Feature: Add ability to select which base graphics set is used from the Game Options window. The change takes effect when the window is closed. This option can only be used from the intro menu, as reloading graphics during a game may cause issues.
peter1138 <peter1138@openttd.org>
parents:
10960
diff
changeset
|
607 for (const GraphicsSet *g = _available_graphics_sets; g != NULL; g = g->next) { |
11130
2770c4f89a05
(svn r15476) -Fix [FS#2630]: crash when opening the game options when the currently loaded base graphics pack has less than 2 valid graphics files. For example when someone replaces all his/her original base graphics with custom work (but keeps the name) or renames the dos ones to windows or vice versa.
rubidium <rubidium@openttd.org>
parents:
11054
diff
changeset
|
608 if (g != _used_graphics_set && g->found_grfs <= 1) continue; |
11049
ed93627e213f
(svn r15389) -Feature: Add ability to select which base graphics set is used from the Game Options window. The change takes effect when the window is closed. This option can only be used from the intro menu, as reloading graphics during a game may cause issues.
peter1138 <peter1138@openttd.org>
parents:
10960
diff
changeset
|
609 if (index == 0) return g->name; |
ed93627e213f
(svn r15389) -Feature: Add ability to select which base graphics set is used from the Game Options window. The change takes effect when the window is closed. This option can only be used from the intro menu, as reloading graphics during a game may cause issues.
peter1138 <peter1138@openttd.org>
parents:
10960
diff
changeset
|
610 index--; |
ed93627e213f
(svn r15389) -Feature: Add ability to select which base graphics set is used from the Game Options window. The change takes effect when the window is closed. This option can only be used from the intro menu, as reloading graphics during a game may cause issues.
peter1138 <peter1138@openttd.org>
parents:
10960
diff
changeset
|
611 } |
ed93627e213f
(svn r15389) -Feature: Add ability to select which base graphics set is used from the Game Options window. The change takes effect when the window is closed. This option can only be used from the intro menu, as reloading graphics during a game may cause issues.
peter1138 <peter1138@openttd.org>
parents:
10960
diff
changeset
|
612 error("GetGraphicsSetName: index %d out of range", index); |
11054
da73fac03cd6
(svn r15394) -Fix (r15389): no new line at end of line warning
glx <glx@openttd.org>
parents:
11049
diff
changeset
|
613 } |