r4104 - packages/trunk/hex-a-hop/debian/patches
Jens Seidel
jseidel-guest at alioth.debian.org
Thu Sep 6 19:12:26 UTC 2007
Author: jseidel-guest
Date: 2007-09-06 19:12:26 +0000 (Thu, 06 Sep 2007)
New Revision: 4104
Modified:
packages/trunk/hex-a-hop/debian/patches/endianess.patch
packages/trunk/hex-a-hop/debian/patches/pango_fonts.patch
Log:
Do no longer use byteswap.h as this is an unportable GNU extension!
Instead lets use SDL/SDL_endian.h together with some macros which
also simplify the code.
Modified: packages/trunk/hex-a-hop/debian/patches/endianess.patch
===================================================================
--- packages/trunk/hex-a-hop/debian/patches/endianess.patch 2007-09-06 19:06:27 UTC (rev 4103)
+++ packages/trunk/hex-a-hop/debian/patches/endianess.patch 2007-09-06 19:12:26 UTC (rev 4104)
@@ -4,15 +4,22 @@
Index: hex-a-hop.svn/packfile.h
===================================================================
---- hex-a-hop.svn.orig/packfile.h 2007-09-05 23:51:42.000000000 +0200
-+++ hex-a-hop.svn/packfile.h 2007-09-06 02:05:59.000000000 +0200
-@@ -16,11 +16,16 @@
+--- hex-a-hop.svn.orig/packfile.h 2007-09-06 20:37:51.000000000 +0200
++++ hex-a-hop.svn/packfile.h 2007-09-06 20:44:29.000000000 +0200
+@@ -16,11 +16,23 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+#include <stdint.h>
-+#include <endian.h>
-+#include <byteswap.h>
++#include <SDL/SDL_endian.h>
++
++#if SDL_BYTEORDER == SDL_LIL_ENDIAN
++#define SWAP16(X) (X)
++#define SWAP32(X) (X)
++#else
++#define SWAP16(X) SDL_Swap16(X)
++#define SWAP32(X) SDL_Swap32(X)
++#endif
struct PackFile1
{
@@ -24,7 +31,7 @@
public:
char name[1];
-@@ -73,10 +78,13 @@
+@@ -73,10 +85,11 @@
if (numfiles || e || data)
FATAL("Calling Packfile1::Read when already initialised.");
@@ -33,27 +40,23 @@
fseek(f, -(int)sizeof(size), SEEK_END);
int end_offset = ftell(f);
fread(&size, sizeof(size), 1, f);
-+#if __BYTE_ORDER == __BIG_ENDIAN
-+ size = bswap_32(size);
-+#endif
++ size = SWAP32(size);
fseek(f, end_offset - size, SEEK_SET);
data = malloc(size);
-@@ -88,6 +96,10 @@
+@@ -88,6 +101,8 @@
while ((void*)i < data_end)
{
numfiles++;
-+#if __BYTE_ORDER == __BIG_ENDIAN
+ int32_t *data_length = (int32_t*)i;
-+ *data_length = bswap_32(*data_length);
-+#endif
++ *data_length = SWAP32(*data_length);
i = i->GetNext();
}
Index: hex-a-hop.svn/hex_puzzzle.cpp
===================================================================
---- hex-a-hop.svn.orig/hex_puzzzle.cpp 2007-09-05 23:51:42.000000000 +0200
-+++ hex-a-hop.svn/hex_puzzzle.cpp 2007-09-06 02:14:52.000000000 +0200
+--- hex-a-hop.svn.orig/hex_puzzzle.cpp 2007-09-06 20:37:51.000000000 +0200
++++ hex-a-hop.svn/hex_puzzzle.cpp 2007-09-06 20:48:40.000000000 +0200
@@ -444,10 +444,10 @@
}
@@ -76,7 +79,7 @@
int turboAnim;
Pos player;
int player_items[2];
-@@ -1565,14 +1565,26 @@
+@@ -1565,14 +1565,20 @@
fgetc(f); // Remove '\n' character
@@ -86,27 +89,21 @@
Pos playerStart;
fread(&par, sizeof(par), 1, f);
- if (version >= 4)
-+#if __BYTE_ORDER == __BIG_ENDIAN
-+ par = bswap_32(par);
-+#endif
++ par = SWAP32(par);
+
+ if (version >= 4) {
fread(&diff, sizeof(diff), 1, f);
-+#if __BYTE_ORDER == __BIG_ENDIAN
-+ diff = bswap_32(diff);
-+#endif
++ diff = SWAP32(diff);
+ }
fread(bounds, sizeof(bounds), 1, f);
- fread(&playerStart, sizeof(player), 1, f);
+ fread(&playerStart, sizeof(playerStart), 1, f);
-+#if __BYTE_ORDER == __BIG_ENDIAN
-+ playerStart.x = bswap_32(playerStart.x);
-+ playerStart.y = bswap_32(playerStart.y);
-+#endif
++ playerStart.x = SWAP32(playerStart.x);
++ playerStart.y = SWAP32(playerStart.y);
int highval=0;
-@@ -1884,7 +1896,7 @@
+@@ -1884,7 +1890,7 @@
if (!save)
{
@@ -115,29 +112,25 @@
_LoadSave(f, save);
delete [] data;
loadPtr = endLoad = 0;
-@@ -1935,10 +1947,20 @@
+@@ -1935,10 +1941,16 @@
if (version==1)
{
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
++ map[i][j] = SWAP32(map[i][j]);
+ }
fn(&player, sizeof(player), 1, f);
+ if (!save) {
-+#if __BYTE_ORDER == __BIG_ENDIAN
-+ player.x = bswap_32(player.x);
-+ player.y = bswap_32(player.y);
-+#endif
++ player.x = SWAP32(player.x);
++ player.y = SWAP32(player.y);
+ }
if (fn(map_item, sizeof(map_item), 1, f) == 0)
memset(map_item, 0, sizeof(map_item));
-@@ -1966,18 +1988,34 @@
+@@ -1966,18 +1978,28 @@
memset(map_item, 0, sizeof(map_item));
}
@@ -146,9 +139,7 @@
+ if (version>=3) {
+ fn(&levelPar, sizeof(levelPar), 1, f);
+ if (!save) {
-+#if __BYTE_ORDER == __BIG_ENDIAN
-+ levelPar = bswap_32(levelPar);
-+#endif
++ levelPar = SWAP32(levelPar);
+ }
+ }
else if (!save)
@@ -159,9 +150,7 @@
+ if (version>=4) {
+ fn(&levelDiff, sizeof(levelDiff), 1, f);
+ if (!save) {
-+#if __BYTE_ORDER == __BIG_ENDIAN
-+ levelDiff = bswap_32(levelDiff);
-+#endif
++ levelDiff = SWAP32(levelDiff);
+ }
+ }
else if (!save)
@@ -170,14 +159,12 @@
- fn(bounds, sizeof(bounds), 1, f);
+ fn(bounds, sizeof(bounds), 1, f); // CHECKME
fn(&player, sizeof(player), 1, f);
-+#if __BYTE_ORDER == __BIG_ENDIAN
-+ player.x = bswap_32(player.x);
-+ player.y = bswap_32(player.y);
-+#endif
++ player.x = SWAP32(player.x);
++ player.y = SWAP32(player.y);
int offsetx=0, offsety=0;
-@@ -2027,13 +2065,16 @@
+@@ -2027,13 +2049,14 @@
else
{
while(1){
@@ -189,13 +176,11 @@
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
++ len = SWAP16(len);
if (len<0) break;
char* tmp = new char[len+1];
tmp[len] = 0;
-@@ -2398,10 +2439,14 @@
+@@ -2398,10 +2421,12 @@
FILE* f = file_open(bmp, "rb");
if (!f) FATAL("Unable to open file", bmp);
@@ -204,28 +189,22 @@
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
++ w = SWAP16(w);
++ h = SWAP16(h);
+ if (w>1500 || h>1500 || w<=0 || h<=0) FATAL("Invalid file", bmp);
tmp = new uint32[(int)w*h];
-@@ -2414,9 +2459,16 @@
+@@ -2414,9 +2439,12 @@
else
{
fread(&c, sizeof(c), 1, f);
-+#if __BYTE_ORDER == __BIG_ENDIAN
-+ c = bswap_32(c);
-+#endif
++ c = SWAP32(c);
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
++ cnt = SWAP32(cnt);
+ }
}
tmp[p] = c | 0xff000000;
Modified: packages/trunk/hex-a-hop/debian/patches/pango_fonts.patch
===================================================================
--- packages/trunk/hex-a-hop/debian/patches/pango_fonts.patch 2007-09-06 19:06:27 UTC (rev 4103)
+++ packages/trunk/hex-a-hop/debian/patches/pango_fonts.patch 2007-09-06 19:12:26 UTC (rev 4104)
@@ -3,8 +3,8 @@
Index: hex-a-hop.svn/gfx.cpp
===================================================================
---- hex-a-hop.svn.orig/gfx.cpp 2007-08-28 23:27:39.000000000 +0200
-+++ hex-a-hop.svn/gfx.cpp 2007-08-28 23:31:02.000000000 +0200
+--- hex-a-hop.svn.orig/gfx.cpp 2007-09-06 21:00:16.000000000 +0200
++++ hex-a-hop.svn/gfx.cpp 2007-09-06 21:00:27.000000000 +0200
@@ -19,6 +19,7 @@
#include "i18n.h"
@@ -36,15 +36,7 @@
extern State* MakeWorld();
-@@ -143,6 +153,7 @@
- SDL_Surface* tempscreen = SDL_CreateRGBSurface(
- SDL_SWSURFACE,
- SCREEN_W, SCREEN_H,
-+ // CHECKME: Respect Endianess (see man page)?!
- 16, 0xf800, 0x07e0, 0x001f, 0);
-
- screen = SDL_DisplayFormat(tempscreen);
-@@ -157,6 +168,78 @@
+@@ -157,6 +167,78 @@
}
String base_path;
@@ -123,7 +115,7 @@
int TickTimer()
{
static int time = SDL_GetTicks();
-@@ -204,6 +287,10 @@
+@@ -204,6 +286,10 @@
*/
SDL_Init(SDL_INIT_VIDEO | SDL_INIT_NOPARACHUTE);
@@ -134,7 +126,7 @@
SDL_Surface* icon = SDL_LoadBMP("graphics/icon.bmp");
if (icon)
-@@ -378,7 +465,7 @@
+@@ -378,7 +464,7 @@
if (!td.isValid())
printf("No tablet/driver found\n");
#endif
@@ -143,7 +135,7 @@
if (m->msg == WM_DROPFILES)
{
HDROP h = (HDROP)m->wParam;
-@@ -476,6 +563,7 @@
+@@ -476,6 +562,7 @@
}
}
@@ -153,8 +145,8 @@
}
Index: hex-a-hop.svn/hex_puzzzle.cpp
===================================================================
---- hex-a-hop.svn.orig/hex_puzzzle.cpp 2007-08-28 23:27:39.000000000 +0200
-+++ hex-a-hop.svn/hex_puzzzle.cpp 2007-08-28 23:30:49.000000000 +0200
+--- hex-a-hop.svn.orig/hex_puzzzle.cpp 2007-09-06 21:00:16.000000000 +0200
++++ hex-a-hop.svn/hex_puzzzle.cpp 2007-09-06 21:00:17.000000000 +0200
@@ -17,6 +17,11 @@
*/
@@ -289,8 +281,8 @@
#include "menus.h"
Index: hex-a-hop.svn/Makefile
===================================================================
---- hex-a-hop.svn.orig/Makefile 2007-08-28 23:27:39.000000000 +0200
-+++ hex-a-hop.svn/Makefile 2007-08-28 23:30:44.000000000 +0200
+--- hex-a-hop.svn.orig/Makefile 2007-09-06 21:00:16.000000000 +0200
++++ hex-a-hop.svn/Makefile 2007-09-06 21:00:17.000000000 +0200
@@ -19,7 +19,7 @@
$(GCC) $(CXXFLAGS) -D_VERSION=\"$(VERSION)\" -DDATA_DIR=\"$(DATA_DIR)\" `sdl-config --cflags` -c -o $@ $<
@@ -302,8 +294,8 @@
clean :
Index: hex-a-hop.svn/menus.h
===================================================================
---- hex-a-hop.svn.orig/menus.h 2007-08-28 23:27:39.000000000 +0200
-+++ hex-a-hop.svn/menus.h 2007-08-28 23:30:49.000000000 +0200
+--- hex-a-hop.svn.orig/menus.h 2007-09-06 21:00:16.000000000 +0200
++++ hex-a-hop.svn/menus.h 2007-09-06 21:00:17.000000000 +0200
@@ -16,11 +16,14 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
More information about the Pkg-games-commits
mailing list