1
Description: Fix action 14 palette checking on big endian machines
2
This bug caused the openttd package to FTBFS on big endian platforms.
4
Cherry-picked from upstream. Changes to the changelog are left out.
5
Origin: upstream, http://dev.openttdcoop.org/projects/grfcodec/repository/revisions/423c64a32ec9
6
diff -r 08511c778a07 -r 423c64a32ec9 src/act14.cpp
11
static bool Check14(PseudoSprite&data, uint&offset, vector<uint>&idstack)
13
- /* Define IDs in an endian-independant manner */
17
- } ID_INFO = {"INFO"}, ID_PALS = {"PALS"};
18
+ /* NFORenum reads the NFO, which is a text file. As per definition the
19
+ * NFO is LE ordered. If characters are interpreted as bytes they will
20
+ * therefore be read in LE order. ExtractDword does interpret the
21
+ * characters as bytes and construct a host endian ordered integer.
22
+ * Consequently, there is no need to swap endian for the read data; it
23
+ * will always be in the host order, or the constant below as long as
24
+ * they have the expected integer value, thus reverse due to LE. */
25
+ static const uint ID_INFO = 0x4F464E49; // INFO in reverse order (LE)
26
+ static const uint ID_PALS = 0x534C4150; // PALS in reverse order (LE)
28
uint type = data.ExtractByte(offset++);
31
extern uint _act14_pal;
32
uint size = data.ExtractWord(offset);
34
- if (idstack.size()==2 && idstack[0]==ID_INFO.id && idstack[1]==ID_PALS.id) {
35
+ if (idstack.size()==2 && idstack[0]==ID_INFO && idstack[1]==ID_PALS) {
36
uint pal=data.ExtractByte(offset);
37
if (size==1 && (pal=='D' || pal=='W' || pal=='A')) {