~ubuntu-branches/ubuntu/trusty/grfcodec/trusty

« back to all changes in this revision

Viewing changes to debian/patches/fix-action-14-big-endian.patch

  • Committer: Package Import Robot
  • Author(s): Matthijs Kooijman
  • Date: 2011-12-06 14:43:46 UTC
  • mfrom: (1.1.4)
  • Revision ID: package-import@ubuntu.com-20111206144346-0mzy2iu6wdro48he
Tags: 5.1.2-1
* [36684f3] New upstream release 5.1.2.
* [14174a4] Remove fix-action-14-big-endian.patch, which is included upstream.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
Description: Fix action 14 palette checking on big endian machines
2
 
 This bug caused the openttd package to FTBFS on big endian platforms.
3
 
 .
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
7
 
--- a/src/act14.cpp
8
 
+++ b/src/act14.cpp
9
 
@@ -33,11 +33,15 @@
10
 
 
11
 
 static bool Check14(PseudoSprite&data, uint&offset, vector<uint>&idstack)
12
 
 {
13
 
-       /* Define IDs in an endian-independant manner */
14
 
-       static union {
15
 
-               char text[5];
16
 
-               uint id;
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)
27
 
 
28
 
        uint type = data.ExtractByte(offset++);
29
 
        while (type != 0) {
30
 
@@ -68,7 +72,7 @@
31
 
                                extern uint _act14_pal;
32
 
                                uint size = data.ExtractWord(offset);
33
 
                                offset += 2;
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')) {
38
 
                                                _act14_pal=pal;