r4058 - in packages/trunk/hex-a-hop/debian: . patches

Jens Seidel jseidel-guest at alioth.debian.org
Mon Sep 3 23:58:13 UTC 2007


Author: jseidel-guest
Date: 2007-09-03 23:58:13 +0000 (Mon, 03 Sep 2007)
New Revision: 4058

Modified:
   packages/trunk/hex-a-hop/debian/changelog
   packages/trunk/hex-a-hop/debian/patches/endianess.patch
Log:
* Code is now (more or less) big endian clean. 
  Closes: #438857


Modified: packages/trunk/hex-a-hop/debian/changelog
===================================================================
--- packages/trunk/hex-a-hop/debian/changelog	2007-09-03 21:58:19 UTC (rev 4057)
+++ packages/trunk/hex-a-hop/debian/changelog	2007-09-03 23:58:13 UTC (rev 4058)
@@ -5,6 +5,11 @@
   * Reduced the CPU load a little bit. Thanks to Joey Hess
     <joeyh at debian.org> for the patch. Closes: #440377
     There is more to do to get it properly fixed.
+  * Code is now (more or less) big endian clean.
+    Closes: #438857
+  * Use an ordinary (ASCII) dash instead of a UTF-8
+    encoded one in the Vietnamese translation which is
+    invalid in the generated man page.
 
  -- Jens Seidel <jensseidel at users.sf.net>  Sun, 02 Sep 2007 23:45:00 +0200
 

Modified: packages/trunk/hex-a-hop/debian/patches/endianess.patch
===================================================================
--- packages/trunk/hex-a-hop/debian/patches/endianess.patch	2007-09-03 21:58:19 UTC (rev 4057)
+++ packages/trunk/hex-a-hop/debian/patches/endianess.patch	2007-09-03 23:58:13 UTC (rev 4058)
@@ -1,9 +1,12 @@
 # Copyright (C) 2007  Miriam Ruiz <little_miry at yahoo.es>
+# Copyright (C) 2007  Jens Seidel <jensseidel at users.sf.net>
 # Licensed under the GPL, see /usr/share/common-licenses/GPL
 
+Index: hex-a-hop-0.0.20070315/packfile.h
+===================================================================
 --- hex-a-hop-0.0.20070315.orig/packfile.h
 +++ hex-a-hop-0.0.20070315/packfile.h
-@@ -16,6 +16,9 @@
+@@ -16,11 +16,14 @@
      Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  */
  
@@ -13,7 +16,13 @@
  
  struct PackFile1
  {
-@@ -73,10 +76,13 @@
+ 	class Entry {
+-		int len;
++		int32_t len;
+ 	public:
+ 		char name[1];
+ 
+@@ -73,10 +76,13 @@ struct PackFile1
  		if (numfiles || e || data)
  			FATAL("Calling Packfile1::Read when already initialised.");
  
@@ -28,3 +37,154 @@
  		fseek(f, end_offset - size, SEEK_SET);
  
  		data = malloc(size);
+@@ -88,6 +94,10 @@ struct PackFile1
+ 		while ((void*)i < data_end)
+ 		{
+ 			numfiles++;
++			int32_t *data_length = (int32_t*)i;
++#if __BYTE_ORDER == __BIG_ENDIAN
++			*data_length = bswap_32(*data_length);
++#endif
+ 			i = i->GetNext();
+ 		}
+ 		
+Index: hex-a-hop-0.0.20070315/hex_puzzzle.cpp
+===================================================================
+--- hex-a-hop-0.0.20070315.orig/hex_puzzzle.cpp
++++ hex-a-hop-0.0.20070315/hex_puzzzle.cpp
+@@ -444,10 +444,10 @@ void SaveState::ApplyStuff()
+ }
+ 
+ 
+-typedef int Tile;
++typedef int32_t Tile;
+ typedef int Dir;
+ struct Pos{
+-	int x,y;
++	int32_t x,y;
+ 	Pos() : x(0), y(0) {}
+ 	Pos(int a, int b) : x(a), y(b) {}
+ 	bool operator == (Pos const & p) const 
+@@ -1579,6 +1579,7 @@ struct HexPuzzle : public State
+ 			for (int i=bounds[0]; i<=bounds[1]; i++)
+ 				for (int j=bounds[2]; j<=bounds[3]; j++)
+ 				{
++					unused code
+ 					unsigned char comp = map[i][j] | (map_item[i][j]<<5);
+ 					fread(&comp, sizeof(comp), 1, f);
+ 					int t = comp & 0x1f;
+@@ -1884,7 +1885,7 @@ struct HexPuzzle : public State
+ 
+ 				if (!save)
+ 				{
+-					char* data = ReadAll(f);
++					char* data = ReadAll(f); //??
+ 					_LoadSave(f, save);
+ 					delete [] data;
+ 					loadPtr = endLoad = 0;
+@@ -1934,9 +1935,14 @@ struct HexPuzzle : public State
+ 
+ 		if (version==1)
+ 		{
++			printf("Reading version 1 file format ...\n");
+ 			for (int i=0; i<MAP_SIZE; i++)
+-				for (int j=0; j<MAP_SIZE; j++)
++				for (int j=0; j<MAP_SIZE; j++) {
+ 					fn(&map[i][j], sizeof(map[i][j]), 1, f);
++#if __BYTE_ORDER == __BIG_ENDIAN
++					map[i][j] = bswap_32(map[i][j]);
++#endif
++					}
+ 
+ 			fn(&player, sizeof(player), 1, f);
+ 
+@@ -1966,18 +1972,34 @@ struct HexPuzzle : public State
+ 				memset(map_item, 0, sizeof(map_item));
+ 			}
+ 
+-			if (version>=3)
++			if (version>=3) {
+ 				fn(&levelPar, 1, sizeof(levelPar), f);
++				if (!save) {
++#if __BYTE_ORDER == __BIG_ENDIAN
++					levelPar = bswap_32(levelPar);
++#endif
++				}
++			}
+ 			else if (!save)
+ 				levelPar = 0;
+ 
+-			if (version>=4)
++			if (version>=4) {
+ 				fn(&levelDiff, 1, sizeof(levelDiff), f);
++				if (!save) {
++#if __BYTE_ORDER == __BIG_ENDIAN
++					levelDiff = bswap_32(levelDiff);
++#endif
++				}
++			}
+ 			else if (!save)
+ 				levelDiff = 0;
+ 
+ 			fn(bounds, sizeof(bounds), 1, f);
+ 			fn(&player, sizeof(player), 1, f);
++#if __BYTE_ORDER == __BIG_ENDIAN
++					player.x = bswap_32(player.x);
++					player.y = bswap_32(player.y);
++#endif
+ 
+ 			int offsetx=0, offsety=0;
+ 
+@@ -2027,13 +2049,16 @@ struct HexPuzzle : public State
+ 			else
+ 			{
+ 				while(1){
+-					short len;
++					int16_t len;
+ 					unsigned char x, y;
+ 					if (!fn(&x, sizeof(x), 1, f))
+ 						break;
+ 					fn(&y, sizeof(y), 1, f);
+ 					x += offsetx; y += offsety;
+ 					fn(&len, sizeof(len), 1, f);
++#if __BYTE_ORDER == __BIG_ENDIAN
++					len = bswap_16(len);
++#endif
+ 					if (len<0) break;
+ 					char* tmp = new char[len+1];
+ 					tmp[len] = 0;
+@@ -2398,10 +2423,14 @@ struct HexPuzzle : public State
+ 		FILE* f = file_open(bmp, "rb");
+ 		if (!f) FATAL("Unable to open file", bmp);
+ 
+-		short w,h;
++		int16_t w,h;
+ 		fread(&w, sizeof(w), 1, f);
+ 		fread(&h, sizeof(h), 1, f);
+-		if (w>1500 || h>1500) FATAL("Invalid file", bmp);
++#if __BYTE_ORDER == __BIG_ENDIAN
++		w = bswap_16(w);
++		h = bswap_16(h);
++#endif
++		if (w>1500 || h>1500 || w<=0 || h<=0) FATAL("Invalid file", bmp);
+ 
+ 		tmp = new uint32[(int)w*h];
+ 		
+@@ -2414,9 +2443,16 @@ struct HexPuzzle : public State
+ 			else
+ 			{
+ 				fread(&c, sizeof(c), 1, f);
++#if __BYTE_ORDER == __BIG_ENDIAN
++                		c = bswap_32(c);
++#endif
+ 				cnt = c >> 24;
+-				if (cnt==255)
++				if (cnt==255) {
+ 					fread(&cnt, sizeof(cnt), 1, f);
++#if __BYTE_ORDER == __BIG_ENDIAN
++	                		cnt = bswap_32(cnt);
++#endif
++				}
+ 			}
+ 			tmp[p] = c | 0xff000000;
+ 		}




More information about the Pkg-games-commits mailing list