author | translators |
Mon, 01 Dec 2008 18:28:44 +0000 | |
changeset 10396 | 7f6f37c9dc67 |
parent 10355 | 8a930759b457 |
permissions | -rw-r--r-- |
6629
eba0ac353e4d
(svn r9850) -Codechange: Introduction of the Override/Substitute manager. Currently only used for newhouses.
belugas
parents:
diff
changeset
|
1 |
/* $Id$ */ |
eba0ac353e4d
(svn r9850) -Codechange: Introduction of the Override/Substitute manager. Currently only used for newhouses.
belugas
parents:
diff
changeset
|
2 |
|
eba0ac353e4d
(svn r9850) -Codechange: Introduction of the Override/Substitute manager. Currently only used for newhouses.
belugas
parents:
diff
changeset
|
3 |
/** @file newgrf_commons.h This file simplyfies and embeds a common mechanism of |
eba0ac353e4d
(svn r9850) -Codechange: Introduction of the Override/Substitute manager. Currently only used for newhouses.
belugas
parents:
diff
changeset
|
4 |
* loading/saving and mapping of grf entities. |
eba0ac353e4d
(svn r9850) -Codechange: Introduction of the Override/Substitute manager. Currently only used for newhouses.
belugas
parents:
diff
changeset
|
5 |
*/ |
eba0ac353e4d
(svn r9850) -Codechange: Introduction of the Override/Substitute manager. Currently only used for newhouses.
belugas
parents:
diff
changeset
|
6 |
|
eba0ac353e4d
(svn r9850) -Codechange: Introduction of the Override/Substitute manager. Currently only used for newhouses.
belugas
parents:
diff
changeset
|
7 |
#ifndef NEWGRF_COMMONS_H |
eba0ac353e4d
(svn r9850) -Codechange: Introduction of the Override/Substitute manager. Currently only used for newhouses.
belugas
parents:
diff
changeset
|
8 |
#define NEWGRF_COMMONS_H |
eba0ac353e4d
(svn r9850) -Codechange: Introduction of the Override/Substitute manager. Currently only used for newhouses.
belugas
parents:
diff
changeset
|
9 |
|
10355
8a930759b457
(svn r14606) -Codechange: Unify usage of PALETTE_MODIFIER_TRANSPARENT and PALETTE_MODIFIER_COLOR in spritelayout drawing.
frosch
parents:
8511
diff
changeset
|
10 |
#include "core/bitmath_func.hpp" |
8a930759b457
(svn r14606) -Codechange: Unify usage of PALETTE_MODIFIER_TRANSPARENT and PALETTE_MODIFIER_COLOR in spritelayout drawing.
frosch
parents:
8511
diff
changeset
|
11 |
|
8a930759b457
(svn r14606) -Codechange: Unify usage of PALETTE_MODIFIER_TRANSPARENT and PALETTE_MODIFIER_COLOR in spritelayout drawing.
frosch
parents:
8511
diff
changeset
|
12 |
#include "table/sprites.h" |
8a930759b457
(svn r14606) -Codechange: Unify usage of PALETTE_MODIFIER_TRANSPARENT and PALETTE_MODIFIER_COLOR in spritelayout drawing.
frosch
parents:
8511
diff
changeset
|
13 |
|
6629
eba0ac353e4d
(svn r9850) -Codechange: Introduction of the Override/Substitute manager. Currently only used for newhouses.
belugas
parents:
diff
changeset
|
14 |
/** |
eba0ac353e4d
(svn r9850) -Codechange: Introduction of the Override/Substitute manager. Currently only used for newhouses.
belugas
parents:
diff
changeset
|
15 |
* Maps an entity id stored on the map to a GRF file. |
eba0ac353e4d
(svn r9850) -Codechange: Introduction of the Override/Substitute manager. Currently only used for newhouses.
belugas
parents:
diff
changeset
|
16 |
* Entities are objects used ingame (houses, industries, industry tiles) for |
eba0ac353e4d
(svn r9850) -Codechange: Introduction of the Override/Substitute manager. Currently only used for newhouses.
belugas
parents:
diff
changeset
|
17 |
* which we need to correlate the ids from the grf files with the ones in the |
eba0ac353e4d
(svn r9850) -Codechange: Introduction of the Override/Substitute manager. Currently only used for newhouses.
belugas
parents:
diff
changeset
|
18 |
* the savegames themselves. |
eba0ac353e4d
(svn r9850) -Codechange: Introduction of the Override/Substitute manager. Currently only used for newhouses.
belugas
parents:
diff
changeset
|
19 |
* An array of EntityIDMapping structs is saved with the savegame so |
eba0ac353e4d
(svn r9850) -Codechange: Introduction of the Override/Substitute manager. Currently only used for newhouses.
belugas
parents:
diff
changeset
|
20 |
* that those GRFs can be loaded in a different order, or removed safely. The |
eba0ac353e4d
(svn r9850) -Codechange: Introduction of the Override/Substitute manager. Currently only used for newhouses.
belugas
parents:
diff
changeset
|
21 |
* index in the array is the entity's ID stored on the map. |
eba0ac353e4d
(svn r9850) -Codechange: Introduction of the Override/Substitute manager. Currently only used for newhouses.
belugas
parents:
diff
changeset
|
22 |
* |
eba0ac353e4d
(svn r9850) -Codechange: Introduction of the Override/Substitute manager. Currently only used for newhouses.
belugas
parents:
diff
changeset
|
23 |
* The substitute ID is the ID of an original entity that should be used instead |
eba0ac353e4d
(svn r9850) -Codechange: Introduction of the Override/Substitute manager. Currently only used for newhouses.
belugas
parents:
diff
changeset
|
24 |
* if the GRF containing the new entity is not available. |
eba0ac353e4d
(svn r9850) -Codechange: Introduction of the Override/Substitute manager. Currently only used for newhouses.
belugas
parents:
diff
changeset
|
25 |
*/ |
eba0ac353e4d
(svn r9850) -Codechange: Introduction of the Override/Substitute manager. Currently only used for newhouses.
belugas
parents:
diff
changeset
|
26 |
struct EntityIDMapping { |
eba0ac353e4d
(svn r9850) -Codechange: Introduction of the Override/Substitute manager. Currently only used for newhouses.
belugas
parents:
diff
changeset
|
27 |
uint32 grfid; ///< The GRF ID of the file the entity belongs to |
eba0ac353e4d
(svn r9850) -Codechange: Introduction of the Override/Substitute manager. Currently only used for newhouses.
belugas
parents:
diff
changeset
|
28 |
uint8 entity_id; ///< The entity ID within the GRF file |
eba0ac353e4d
(svn r9850) -Codechange: Introduction of the Override/Substitute manager. Currently only used for newhouses.
belugas
parents:
diff
changeset
|
29 |
uint8 substitute_id; ///< The (original) entity ID to use if this GRF is not available |
eba0ac353e4d
(svn r9850) -Codechange: Introduction of the Override/Substitute manager. Currently only used for newhouses.
belugas
parents:
diff
changeset
|
30 |
}; |
eba0ac353e4d
(svn r9850) -Codechange: Introduction of the Override/Substitute manager. Currently only used for newhouses.
belugas
parents:
diff
changeset
|
31 |
|
7325
1140f831f255
(svn r10688) -Cleanup: coding style cleanups missed in the last few cleanups.
rubidium
parents:
7000
diff
changeset
|
32 |
class OverrideManagerBase { |
6629
eba0ac353e4d
(svn r9850) -Codechange: Introduction of the Override/Substitute manager. Currently only used for newhouses.
belugas
parents:
diff
changeset
|
33 |
protected: |
eba0ac353e4d
(svn r9850) -Codechange: Introduction of the Override/Substitute manager. Currently only used for newhouses.
belugas
parents:
diff
changeset
|
34 |
uint16 *entity_overrides; |
7873
9bb5874c81df
(svn r11423) -Codechange: store grfid when adding an override
glx
parents:
7667
diff
changeset
|
35 |
uint32 *grfid_overrides; |
6629
eba0ac353e4d
(svn r9850) -Codechange: Introduction of the Override/Substitute manager. Currently only used for newhouses.
belugas
parents:
diff
changeset
|
36 |
|
eba0ac353e4d
(svn r9850) -Codechange: Introduction of the Override/Substitute manager. Currently only used for newhouses.
belugas
parents:
diff
changeset
|
37 |
uint16 max_offset; ///< what is the length of the original entity's array of specs |
eba0ac353e4d
(svn r9850) -Codechange: Introduction of the Override/Substitute manager. Currently only used for newhouses.
belugas
parents:
diff
changeset
|
38 |
uint16 max_new_entities; ///< what is the amount of entities, old and new summed |
eba0ac353e4d
(svn r9850) -Codechange: Introduction of the Override/Substitute manager. Currently only used for newhouses.
belugas
parents:
diff
changeset
|
39 |
|
eba0ac353e4d
(svn r9850) -Codechange: Introduction of the Override/Substitute manager. Currently only used for newhouses.
belugas
parents:
diff
changeset
|
40 |
uint16 invalid_ID; ///< ID used to dected invalid entities; |
7632
08e14d61a557
(svn r11163) -Codechange: Verify that the IndustryTileOverrideManager skip the magic value of 0xFF when assigning a new tileID. This is really important, since the value is reserved for water checking.
belugas
parents:
7325
diff
changeset
|
41 |
virtual bool CheckValidNewID(uint16 testid) { return true; } |
6629
eba0ac353e4d
(svn r9850) -Codechange: Introduction of the Override/Substitute manager. Currently only used for newhouses.
belugas
parents:
diff
changeset
|
42 |
|
eba0ac353e4d
(svn r9850) -Codechange: Introduction of the Override/Substitute manager. Currently only used for newhouses.
belugas
parents:
diff
changeset
|
43 |
public: |
eba0ac353e4d
(svn r9850) -Codechange: Introduction of the Override/Substitute manager. Currently only used for newhouses.
belugas
parents:
diff
changeset
|
44 |
EntityIDMapping *mapping_ID; ///< mapping of ids from grf files. Public out of convenience |
eba0ac353e4d
(svn r9850) -Codechange: Introduction of the Override/Substitute manager. Currently only used for newhouses.
belugas
parents:
diff
changeset
|
45 |
|
eba0ac353e4d
(svn r9850) -Codechange: Introduction of the Override/Substitute manager. Currently only used for newhouses.
belugas
parents:
diff
changeset
|
46 |
OverrideManagerBase(uint16 offset, uint16 maximum, uint16 invalid); |
eba0ac353e4d
(svn r9850) -Codechange: Introduction of the Override/Substitute manager. Currently only used for newhouses.
belugas
parents:
diff
changeset
|
47 |
virtual ~OverrideManagerBase(); |
eba0ac353e4d
(svn r9850) -Codechange: Introduction of the Override/Substitute manager. Currently only used for newhouses.
belugas
parents:
diff
changeset
|
48 |
|
eba0ac353e4d
(svn r9850) -Codechange: Introduction of the Override/Substitute manager. Currently only used for newhouses.
belugas
parents:
diff
changeset
|
49 |
void ResetOverride(); |
eba0ac353e4d
(svn r9850) -Codechange: Introduction of the Override/Substitute manager. Currently only used for newhouses.
belugas
parents:
diff
changeset
|
50 |
void ResetMapping(); |
eba0ac353e4d
(svn r9850) -Codechange: Introduction of the Override/Substitute manager. Currently only used for newhouses.
belugas
parents:
diff
changeset
|
51 |
|
7873
9bb5874c81df
(svn r11423) -Codechange: store grfid when adding an override
glx
parents:
7667
diff
changeset
|
52 |
void Add(uint8 local_id, uint32 grfid, uint entity_type); |
6835
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
6827
diff
changeset
|
53 |
virtual uint16 AddEntityID(byte grf_local_id, uint32 grfid, byte substitute_id); |
6629
eba0ac353e4d
(svn r9850) -Codechange: Introduction of the Override/Substitute manager. Currently only used for newhouses.
belugas
parents:
diff
changeset
|
54 |
|
eba0ac353e4d
(svn r9850) -Codechange: Introduction of the Override/Substitute manager. Currently only used for newhouses.
belugas
parents:
diff
changeset
|
55 |
uint16 GetSubstituteID(byte entity_id); |
8511
abb116ef8cd8
(svn r12086) -Fix [FS#1747] (r11425): check overrides only for industries when mapping newgrf entities to 'real' entities
glx
parents:
8458
diff
changeset
|
56 |
virtual uint16 GetID(uint8 grf_local_id, uint32 grfid); |
6629
eba0ac353e4d
(svn r9850) -Codechange: Introduction of the Override/Substitute manager. Currently only used for newhouses.
belugas
parents:
diff
changeset
|
57 |
|
7325
1140f831f255
(svn r10688) -Cleanup: coding style cleanups missed in the last few cleanups.
rubidium
parents:
7000
diff
changeset
|
58 |
inline uint16 GetMaxMapping() { return max_new_entities; } |
1140f831f255
(svn r10688) -Cleanup: coding style cleanups missed in the last few cleanups.
rubidium
parents:
7000
diff
changeset
|
59 |
inline uint16 GetMaxOffset() { return max_offset; } |
6629
eba0ac353e4d
(svn r9850) -Codechange: Introduction of the Override/Substitute manager. Currently only used for newhouses.
belugas
parents:
diff
changeset
|
60 |
}; |
eba0ac353e4d
(svn r9850) -Codechange: Introduction of the Override/Substitute manager. Currently only used for newhouses.
belugas
parents:
diff
changeset
|
61 |
|
eba0ac353e4d
(svn r9850) -Codechange: Introduction of the Override/Substitute manager. Currently only used for newhouses.
belugas
parents:
diff
changeset
|
62 |
|
eba0ac353e4d
(svn r9850) -Codechange: Introduction of the Override/Substitute manager. Currently only used for newhouses.
belugas
parents:
diff
changeset
|
63 |
struct HouseSpec; |
7325
1140f831f255
(svn r10688) -Cleanup: coding style cleanups missed in the last few cleanups.
rubidium
parents:
7000
diff
changeset
|
64 |
class HouseOverrideManager : public OverrideManagerBase { |
6629
eba0ac353e4d
(svn r9850) -Codechange: Introduction of the Override/Substitute manager. Currently only used for newhouses.
belugas
parents:
diff
changeset
|
65 |
public: |
6835
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
6827
diff
changeset
|
66 |
HouseOverrideManager(uint16 offset, uint16 maximum, uint16 invalid) : |
7325
1140f831f255
(svn r10688) -Cleanup: coding style cleanups missed in the last few cleanups.
rubidium
parents:
7000
diff
changeset
|
67 |
OverrideManagerBase(offset, maximum, invalid) {} |
6629
eba0ac353e4d
(svn r9850) -Codechange: Introduction of the Override/Substitute manager. Currently only used for newhouses.
belugas
parents:
diff
changeset
|
68 |
void SetEntitySpec(const HouseSpec *hs); |
eba0ac353e4d
(svn r9850) -Codechange: Introduction of the Override/Substitute manager. Currently only used for newhouses.
belugas
parents:
diff
changeset
|
69 |
}; |
eba0ac353e4d
(svn r9850) -Codechange: Introduction of the Override/Substitute manager. Currently only used for newhouses.
belugas
parents:
diff
changeset
|
70 |
|
eba0ac353e4d
(svn r9850) -Codechange: Introduction of the Override/Substitute manager. Currently only used for newhouses.
belugas
parents:
diff
changeset
|
71 |
|
6835
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
6827
diff
changeset
|
72 |
struct IndustrySpec; |
7325
1140f831f255
(svn r10688) -Cleanup: coding style cleanups missed in the last few cleanups.
rubidium
parents:
7000
diff
changeset
|
73 |
class IndustryOverrideManager : public OverrideManagerBase { |
1140f831f255
(svn r10688) -Cleanup: coding style cleanups missed in the last few cleanups.
rubidium
parents:
7000
diff
changeset
|
74 |
public: |
1140f831f255
(svn r10688) -Cleanup: coding style cleanups missed in the last few cleanups.
rubidium
parents:
7000
diff
changeset
|
75 |
IndustryOverrideManager(uint16 offset, uint16 maximum, uint16 invalid) : |
1140f831f255
(svn r10688) -Cleanup: coding style cleanups missed in the last few cleanups.
rubidium
parents:
7000
diff
changeset
|
76 |
OverrideManagerBase(offset, maximum, invalid) {} |
6835
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
6827
diff
changeset
|
77 |
|
7325
1140f831f255
(svn r10688) -Cleanup: coding style cleanups missed in the last few cleanups.
rubidium
parents:
7000
diff
changeset
|
78 |
virtual uint16 AddEntityID(byte grf_local_id, uint32 grfid, byte substitute_id); |
8511
abb116ef8cd8
(svn r12086) -Fix [FS#1747] (r11425): check overrides only for industries when mapping newgrf entities to 'real' entities
glx
parents:
8458
diff
changeset
|
79 |
virtual uint16 GetID(uint8 grf_local_id, uint32 grfid); |
7667
0355390b08d9
(svn r11198) -Fix: When industry override is not possible because it is already been overridden, mark the new candidate as not being an override
belugas
parents:
7632
diff
changeset
|
80 |
void SetEntitySpec(IndustrySpec *inds); |
6835
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
6827
diff
changeset
|
81 |
}; |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
6827
diff
changeset
|
82 |
|
7000
603a41cb93f8
(svn r10256) -Add: Addition of IndustryTileOverrideManager
belugas
parents:
6835
diff
changeset
|
83 |
|
603a41cb93f8
(svn r10256) -Add: Addition of IndustryTileOverrideManager
belugas
parents:
6835
diff
changeset
|
84 |
struct IndustryTileSpec; |
7325
1140f831f255
(svn r10688) -Cleanup: coding style cleanups missed in the last few cleanups.
rubidium
parents:
7000
diff
changeset
|
85 |
class IndustryTileOverrideManager : public OverrideManagerBase { |
7632
08e14d61a557
(svn r11163) -Codechange: Verify that the IndustryTileOverrideManager skip the magic value of 0xFF when assigning a new tileID. This is really important, since the value is reserved for water checking.
belugas
parents:
7325
diff
changeset
|
86 |
protected: |
08e14d61a557
(svn r11163) -Codechange: Verify that the IndustryTileOverrideManager skip the magic value of 0xFF when assigning a new tileID. This is really important, since the value is reserved for water checking.
belugas
parents:
7325
diff
changeset
|
87 |
virtual bool CheckValidNewID(uint16 testid) { return testid != 0xFF; } |
7325
1140f831f255
(svn r10688) -Cleanup: coding style cleanups missed in the last few cleanups.
rubidium
parents:
7000
diff
changeset
|
88 |
public: |
1140f831f255
(svn r10688) -Cleanup: coding style cleanups missed in the last few cleanups.
rubidium
parents:
7000
diff
changeset
|
89 |
IndustryTileOverrideManager(uint16 offset, uint16 maximum, uint16 invalid) : |
1140f831f255
(svn r10688) -Cleanup: coding style cleanups missed in the last few cleanups.
rubidium
parents:
7000
diff
changeset
|
90 |
OverrideManagerBase(offset, maximum, invalid) {} |
1140f831f255
(svn r10688) -Cleanup: coding style cleanups missed in the last few cleanups.
rubidium
parents:
7000
diff
changeset
|
91 |
|
1140f831f255
(svn r10688) -Cleanup: coding style cleanups missed in the last few cleanups.
rubidium
parents:
7000
diff
changeset
|
92 |
void SetEntitySpec(const IndustryTileSpec *indts); |
7000
603a41cb93f8
(svn r10256) -Add: Addition of IndustryTileOverrideManager
belugas
parents:
6835
diff
changeset
|
93 |
}; |
603a41cb93f8
(svn r10256) -Add: Addition of IndustryTileOverrideManager
belugas
parents:
6835
diff
changeset
|
94 |
|
6629
eba0ac353e4d
(svn r9850) -Codechange: Introduction of the Override/Substitute manager. Currently only used for newhouses.
belugas
parents:
diff
changeset
|
95 |
extern HouseOverrideManager _house_mngr; |
6835
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
6827
diff
changeset
|
96 |
extern IndustryOverrideManager _industry_mngr; |
7000
603a41cb93f8
(svn r10256) -Add: Addition of IndustryTileOverrideManager
belugas
parents:
6835
diff
changeset
|
97 |
extern IndustryTileOverrideManager _industile_mngr; |
6629
eba0ac353e4d
(svn r9850) -Codechange: Introduction of the Override/Substitute manager. Currently only used for newhouses.
belugas
parents:
diff
changeset
|
98 |
|
6801
9d82611443fd
(svn r10040) -Codechange: Make the function GetTerrainType public, as other functions require it
belugas
parents:
6629
diff
changeset
|
99 |
uint32 GetTerrainType(TileIndex tile); |
6827
e2450e25ad95
(svn r10066) -Codechange: Expose function GetNearbyTile by moving it to newgrf_commons.[cpp|h]. Will be used by industries in a few.
belugas
parents:
6801
diff
changeset
|
100 |
TileIndex GetNearbyTile(byte parameter, TileIndex tile); |
8458
38fe72ff1402
(svn r12028) -Codechange: Split common part of station var 0x67, house var 0x62, indtile var 0x60 and industry var 0x62 to 'newgrf_commons.cpp'.
frosch
parents:
7873
diff
changeset
|
101 |
uint32 GetNearbyTileInformation(TileIndex tile); |
6801
9d82611443fd
(svn r10040) -Codechange: Make the function GetTerrainType public, as other functions require it
belugas
parents:
6629
diff
changeset
|
102 |
|
10355
8a930759b457
(svn r14606) -Codechange: Unify usage of PALETTE_MODIFIER_TRANSPARENT and PALETTE_MODIFIER_COLOR in spritelayout drawing.
frosch
parents:
8511
diff
changeset
|
103 |
/** |
8a930759b457
(svn r14606) -Codechange: Unify usage of PALETTE_MODIFIER_TRANSPARENT and PALETTE_MODIFIER_COLOR in spritelayout drawing.
frosch
parents:
8511
diff
changeset
|
104 |
* Applies PALETTE_MODIFIER_TRANSPARENT and PALETTE_MODIFIER_COLOR to a palette entry of a sprite layout entry |
8a930759b457
(svn r14606) -Codechange: Unify usage of PALETTE_MODIFIER_TRANSPARENT and PALETTE_MODIFIER_COLOR in spritelayout drawing.
frosch
parents:
8511
diff
changeset
|
105 |
* @Note for ground sprites use #GroundSpritePaletteTransform |
8a930759b457
(svn r14606) -Codechange: Unify usage of PALETTE_MODIFIER_TRANSPARENT and PALETTE_MODIFIER_COLOR in spritelayout drawing.
frosch
parents:
8511
diff
changeset
|
106 |
* @Note Not useable for OTTD internal spritelayouts from table/xxx_land.h as PALETTE_MODIFIER_TRANSPARENT is only set |
8a930759b457
(svn r14606) -Codechange: Unify usage of PALETTE_MODIFIER_TRANSPARENT and PALETTE_MODIFIER_COLOR in spritelayout drawing.
frosch
parents:
8511
diff
changeset
|
107 |
* when to use the default palette. |
8a930759b457
(svn r14606) -Codechange: Unify usage of PALETTE_MODIFIER_TRANSPARENT and PALETTE_MODIFIER_COLOR in spritelayout drawing.
frosch
parents:
8511
diff
changeset
|
108 |
* |
8a930759b457
(svn r14606) -Codechange: Unify usage of PALETTE_MODIFIER_TRANSPARENT and PALETTE_MODIFIER_COLOR in spritelayout drawing.
frosch
parents:
8511
diff
changeset
|
109 |
* @param image The sprite to draw |
8a930759b457
(svn r14606) -Codechange: Unify usage of PALETTE_MODIFIER_TRANSPARENT and PALETTE_MODIFIER_COLOR in spritelayout drawing.
frosch
parents:
8511
diff
changeset
|
110 |
* @param pal The palette from the sprite layout |
8a930759b457
(svn r14606) -Codechange: Unify usage of PALETTE_MODIFIER_TRANSPARENT and PALETTE_MODIFIER_COLOR in spritelayout drawing.
frosch
parents:
8511
diff
changeset
|
111 |
* @param default_pal The default recolour sprite to use (typically company color resp. random industry/house color) |
8a930759b457
(svn r14606) -Codechange: Unify usage of PALETTE_MODIFIER_TRANSPARENT and PALETTE_MODIFIER_COLOR in spritelayout drawing.
frosch
parents:
8511
diff
changeset
|
112 |
* @return The palette to use |
8a930759b457
(svn r14606) -Codechange: Unify usage of PALETTE_MODIFIER_TRANSPARENT and PALETTE_MODIFIER_COLOR in spritelayout drawing.
frosch
parents:
8511
diff
changeset
|
113 |
*/ |
8a930759b457
(svn r14606) -Codechange: Unify usage of PALETTE_MODIFIER_TRANSPARENT and PALETTE_MODIFIER_COLOR in spritelayout drawing.
frosch
parents:
8511
diff
changeset
|
114 |
static inline SpriteID SpriteLayoutPaletteTransform(SpriteID image, SpriteID pal, SpriteID default_pal) |
8a930759b457
(svn r14606) -Codechange: Unify usage of PALETTE_MODIFIER_TRANSPARENT and PALETTE_MODIFIER_COLOR in spritelayout drawing.
frosch
parents:
8511
diff
changeset
|
115 |
{ |
8a930759b457
(svn r14606) -Codechange: Unify usage of PALETTE_MODIFIER_TRANSPARENT and PALETTE_MODIFIER_COLOR in spritelayout drawing.
frosch
parents:
8511
diff
changeset
|
116 |
if (HasBit(image, PALETTE_MODIFIER_TRANSPARENT) || HasBit(image, PALETTE_MODIFIER_COLOR)) { |
8a930759b457
(svn r14606) -Codechange: Unify usage of PALETTE_MODIFIER_TRANSPARENT and PALETTE_MODIFIER_COLOR in spritelayout drawing.
frosch
parents:
8511
diff
changeset
|
117 |
return (pal != 0 ? pal : default_pal); |
8a930759b457
(svn r14606) -Codechange: Unify usage of PALETTE_MODIFIER_TRANSPARENT and PALETTE_MODIFIER_COLOR in spritelayout drawing.
frosch
parents:
8511
diff
changeset
|
118 |
} else { |
8a930759b457
(svn r14606) -Codechange: Unify usage of PALETTE_MODIFIER_TRANSPARENT and PALETTE_MODIFIER_COLOR in spritelayout drawing.
frosch
parents:
8511
diff
changeset
|
119 |
return PAL_NONE; |
8a930759b457
(svn r14606) -Codechange: Unify usage of PALETTE_MODIFIER_TRANSPARENT and PALETTE_MODIFIER_COLOR in spritelayout drawing.
frosch
parents:
8511
diff
changeset
|
120 |
} |
8a930759b457
(svn r14606) -Codechange: Unify usage of PALETTE_MODIFIER_TRANSPARENT and PALETTE_MODIFIER_COLOR in spritelayout drawing.
frosch
parents:
8511
diff
changeset
|
121 |
} |
8a930759b457
(svn r14606) -Codechange: Unify usage of PALETTE_MODIFIER_TRANSPARENT and PALETTE_MODIFIER_COLOR in spritelayout drawing.
frosch
parents:
8511
diff
changeset
|
122 |
|
8a930759b457
(svn r14606) -Codechange: Unify usage of PALETTE_MODIFIER_TRANSPARENT and PALETTE_MODIFIER_COLOR in spritelayout drawing.
frosch
parents:
8511
diff
changeset
|
123 |
/** |
8a930759b457
(svn r14606) -Codechange: Unify usage of PALETTE_MODIFIER_TRANSPARENT and PALETTE_MODIFIER_COLOR in spritelayout drawing.
frosch
parents:
8511
diff
changeset
|
124 |
* Applies PALETTE_MODIFIER_COLOR to a palette entry of a ground sprite |
8a930759b457
(svn r14606) -Codechange: Unify usage of PALETTE_MODIFIER_TRANSPARENT and PALETTE_MODIFIER_COLOR in spritelayout drawing.
frosch
parents:
8511
diff
changeset
|
125 |
* @Note Not useable for OTTD internal spritelayouts from table/xxx_land.h as PALETTE_MODIFIER_TRANSPARENT is only set |
8a930759b457
(svn r14606) -Codechange: Unify usage of PALETTE_MODIFIER_TRANSPARENT and PALETTE_MODIFIER_COLOR in spritelayout drawing.
frosch
parents:
8511
diff
changeset
|
126 |
* when to use the default palette. |
8a930759b457
(svn r14606) -Codechange: Unify usage of PALETTE_MODIFIER_TRANSPARENT and PALETTE_MODIFIER_COLOR in spritelayout drawing.
frosch
parents:
8511
diff
changeset
|
127 |
* |
8a930759b457
(svn r14606) -Codechange: Unify usage of PALETTE_MODIFIER_TRANSPARENT and PALETTE_MODIFIER_COLOR in spritelayout drawing.
frosch
parents:
8511
diff
changeset
|
128 |
* @param image The sprite to draw |
8a930759b457
(svn r14606) -Codechange: Unify usage of PALETTE_MODIFIER_TRANSPARENT and PALETTE_MODIFIER_COLOR in spritelayout drawing.
frosch
parents:
8511
diff
changeset
|
129 |
* @param pal The palette from the sprite layout |
8a930759b457
(svn r14606) -Codechange: Unify usage of PALETTE_MODIFIER_TRANSPARENT and PALETTE_MODIFIER_COLOR in spritelayout drawing.
frosch
parents:
8511
diff
changeset
|
130 |
* @param default_pal The default recolour sprite to use (typically company color resp. random industry/house color) |
8a930759b457
(svn r14606) -Codechange: Unify usage of PALETTE_MODIFIER_TRANSPARENT and PALETTE_MODIFIER_COLOR in spritelayout drawing.
frosch
parents:
8511
diff
changeset
|
131 |
* @return The palette to use |
8a930759b457
(svn r14606) -Codechange: Unify usage of PALETTE_MODIFIER_TRANSPARENT and PALETTE_MODIFIER_COLOR in spritelayout drawing.
frosch
parents:
8511
diff
changeset
|
132 |
*/ |
8a930759b457
(svn r14606) -Codechange: Unify usage of PALETTE_MODIFIER_TRANSPARENT and PALETTE_MODIFIER_COLOR in spritelayout drawing.
frosch
parents:
8511
diff
changeset
|
133 |
static inline SpriteID GroundSpritePaletteTransform(SpriteID image, SpriteID pal, SpriteID default_pal) |
8a930759b457
(svn r14606) -Codechange: Unify usage of PALETTE_MODIFIER_TRANSPARENT and PALETTE_MODIFIER_COLOR in spritelayout drawing.
frosch
parents:
8511
diff
changeset
|
134 |
{ |
8a930759b457
(svn r14606) -Codechange: Unify usage of PALETTE_MODIFIER_TRANSPARENT and PALETTE_MODIFIER_COLOR in spritelayout drawing.
frosch
parents:
8511
diff
changeset
|
135 |
if (HasBit(image, PALETTE_MODIFIER_COLOR)) { |
8a930759b457
(svn r14606) -Codechange: Unify usage of PALETTE_MODIFIER_TRANSPARENT and PALETTE_MODIFIER_COLOR in spritelayout drawing.
frosch
parents:
8511
diff
changeset
|
136 |
return (pal != 0 ? pal : default_pal); |
8a930759b457
(svn r14606) -Codechange: Unify usage of PALETTE_MODIFIER_TRANSPARENT and PALETTE_MODIFIER_COLOR in spritelayout drawing.
frosch
parents:
8511
diff
changeset
|
137 |
} else { |
8a930759b457
(svn r14606) -Codechange: Unify usage of PALETTE_MODIFIER_TRANSPARENT and PALETTE_MODIFIER_COLOR in spritelayout drawing.
frosch
parents:
8511
diff
changeset
|
138 |
return PAL_NONE; |
8a930759b457
(svn r14606) -Codechange: Unify usage of PALETTE_MODIFIER_TRANSPARENT and PALETTE_MODIFIER_COLOR in spritelayout drawing.
frosch
parents:
8511
diff
changeset
|
139 |
} |
8a930759b457
(svn r14606) -Codechange: Unify usage of PALETTE_MODIFIER_TRANSPARENT and PALETTE_MODIFIER_COLOR in spritelayout drawing.
frosch
parents:
8511
diff
changeset
|
140 |
} |
8a930759b457
(svn r14606) -Codechange: Unify usage of PALETTE_MODIFIER_TRANSPARENT and PALETTE_MODIFIER_COLOR in spritelayout drawing.
frosch
parents:
8511
diff
changeset
|
141 |
|
6629
eba0ac353e4d
(svn r9850) -Codechange: Introduction of the Override/Substitute manager. Currently only used for newhouses.
belugas
parents:
diff
changeset
|
142 |
#endif /* NEWGRF_COMMONS_H */ |