Bug#550585: hex-a-hop: patch to make it build with -D_DEBUG (to allow editing)
root
russell at coker.com.au
Sun Oct 11 11:17:45 UTC 2009
Package: hex-a-hop
Version: 0.0.20070315-7
Severity: normal
The following patch makes it not SEGV when it can't load a bmp file, makes the
SWAP16 and SWAP32 macros available from savestate.h, and makes the = operator
on the String class behave correctly when assigning the value of "".
This makes it all compile correctly for editing.
diff -ru hex-a-hop-0.0.20070315.new/hex_puzzzle.cpp hex-a-hop-0.0.20070315/hex_puzzzle.cpp
--- hex-a-hop-0.0.20070315.new/hex_puzzzle.cpp 2009-10-11 22:01:42.000000000 +1100
+++ hex-a-hop-0.0.20070315/hex_puzzzle.cpp 2009-10-11 21:10:02.000000000 +1100
@@ -2416,6 +2417,7 @@
if (strstr(bmp, ".bmp"))
{
g = SDL_LoadBMP(bmp);
+ if (!g) FATAL("Unable to SDL_LoadBMP file", bmp);
char out[1024];
strcpy(out, bmp);
diff -ru hex-a-hop-0.0.20070315.new/savestate.h hex-a-hop-0.0.20070315/savestate.h
--- hex-a-hop-0.0.20070315.new/savestate.h 2009-10-11 18:01:54.000000000 +1100
+++ hex-a-hop-0.0.20070315/savestate.h 2009-10-11 18:28:52.000000000 +1100
@@ -18,6 +18,16 @@
struct HexPuzzle;
+
+#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
class LevelSave
{
diff -ru hex-a-hop-0.0.20070315.new/state.h hex-a-hop-0.0.20070315/state.h
--- hex-a-hop-0.0.20070315.new/state.h 2009-10-11 18:01:54.000000000 +1100
+++ hex-a-hop-0.0.20070315/state.h 2009-10-11 21:50:45.000000000 +1100
@@ -63,16 +63,51 @@
int len;
char* data;
public:
- void reserve(int i) { if (i<0) FATAL("-ve string length."); if (i<=len) return; len=i; data=(char*)realloc(data, (len+1)*sizeof(char)); }
+ void reserve(int i)
+ {
+ if (i < 0)
+ FATAL("-ve string length.");
+ if (i <= len)
+ return;
+ data = (char*)realloc(data, (i+1)*sizeof(char));
+ if(!len)
+ data[0] = '\0';
+ len = i;
+ }
String() : len(0), data(NULL) {}
String(String const & s) : len(0), data(NULL) { reserve(s.len); strcpy(data, s.data); }
~String() { free(data); }
operator const char* () const {return data ? data : "";}
void operator = (String const & a) { *this = (const char*)a; }
- void operator = (const char * a) { reserve(strlen(a)); strcpy(data, a); }
+ void operator = (const char * a)
+ {
+ if(!a || !a[0])
+ {
+ truncate(0);
+ return;
+ }
+ reserve(strlen(a)); strcpy(data, a);
+ }
void operator += (const char * a) { reserve(strlen(a)+len); strcat(data, a); }
- void truncate (int pos) { data[pos] = '\0'; }
- void fix_backslashes() { if(data) for (int i=0; data[i]; i++) if (data[i]=='\\') data[i]='/'; }
+ void truncate (int pos)
+ {
+ if(data && pos < len)
+ {
+ data[pos] = '\0';
+ len = 0;
+ }
+ }
+ void fix_backslashes()
+ {
+ if(data)
+ {
+ for (int i=0; data[i]; i++)
+ {
+ if (data[i]=='\\')
+ data[i]='/';
+ }
+ }
+ }
};
class State
-- System Information:
Debian Release: squeeze/sid
APT prefers unstable
APT policy: (500, 'unstable'), (1, 'experimental')
Architecture: amd64 (x86_64)
Kernel: Linux 2.6.31-trunk-amd64 (SMP w/2 CPU cores)
Locale: LANG=en_AU.UTF-8, LC_CTYPE=en_AU.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Versions of packages hex-a-hop depends on:
ii libc6 2.9-27 GNU C Library: Shared libraries
ii libgcc1 1:4.4.1-6 GCC support library
ii libsdl-pango1 0.1.2-4 text rendering with Pango in SDL a
ii libsdl1.2debian 1.2.13-5 Simple DirectMedia Layer
ii libstdc++6 4.4.1-6 The GNU Standard C++ Library v3
hex-a-hop recommends no packages.
hex-a-hop suggests no packages.
-- no debconf information
More information about the Pkg-games-devel
mailing list