r6605 - packages/trunk/biniax2/debian/patches

Miriam Ruiz baby-guest at alioth.debian.org
Thu Apr 17 12:07:22 UTC 2008


Author: baby-guest
Date: 2008-04-17 12:07:21 +0000 (Thu, 17 Apr 2008)
New Revision: 6605

Modified:
   packages/trunk/biniax2/debian/patches/fixes.patch
Log:
Put autosave file in user home



Modified: packages/trunk/biniax2/debian/patches/fixes.patch
===================================================================
--- packages/trunk/biniax2/debian/patches/fixes.patch	2008-04-17 12:00:37 UTC (rev 6604)
+++ packages/trunk/biniax2/debian/patches/fixes.patch	2008-04-17 12:07:21 UTC (rev 6605)
@@ -3,9 +3,28 @@
 
 Index: biniax2/biniax.c
 ===================================================================
---- biniax2.orig/biniax.c	2008-04-17 11:57:46.000000000 +0000
-+++ biniax2/biniax.c	2008-04-17 11:57:46.000000000 +0000
-@@ -100,13 +100,27 @@
+--- biniax2.orig/biniax.c	2008-04-17 12:03:55.000000000 +0000
++++ biniax2/biniax.c	2008-04-17 12:06:57.000000000 +0000
+@@ -51,6 +51,18 @@
+ #include "lev.h"
+ #include "inc.h"
+ 
++#ifndef _WIN32
++#include <stdlib.h>
++#include <stdio.h>
++#include <string.h>
++#include <unistd.h>
++#include <limits.h>
++#include <pwd.h>
++#include <fcntl.h>
++#include <sys/stat.h>
++#include <sys/types.h>
++#endif
++
+ /* Global instance of GAME structure */
+ BNX_GAME Game;
+ 
+@@ -100,13 +112,27 @@
  	cfgInit();
  	hofInit();
  	if ( gfxInit() == BNX_FALSE )
@@ -34,10 +53,64 @@
  	
  	/******************************************************************
  	SHOW INITIAL WELCOME SCREEN                                                
+@@ -1161,11 +1187,43 @@
+ GAME AND HISCORE SAVE / RESTORE
+ ******************************************************************************/
+ 
++static const char *saveFileName()
++{
++#ifndef _WIN32
++        static char filename[PATH_MAX] = "";
++        char *home;
++        struct passwd *passwd;
++        if (*filename)
++                return filename;
++        if (!getuid() || !(home = getenv("HOME")))
++        {
++                passwd = getpwuid (getuid());
++                home=passwd->pw_dir;
++                if (!home)
++                {
++                        fprintf(stderr, "$HOME is not defined.n");
++                        return "./autosave.bnx2";
++                }
++        }
++        if (strlen(home) > PATH_MAX - sizeof("/.biniax2/autosave"))
++        {
++                fprintf(stderr, "$HOME is excessively long.n");
++                return "./autosave.bnx2";
++        }
++        snprintf(filename, sizeof(filename), "%s/.biniax2", home);
++        mkdir(filename, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
++        strncat(filename, "/autosave", sizeof(filename)-1);
++        return filename;
++#else
++        return "./autosave.bnx2";
++#endif
++}
++
+ BNX_BOOL saveGame( BNX_GAME *game )
+ {
+ 	FILE		*file;
+ 
+-	file = fopen( "autosave.bnx2", "wb" );
++	file = fopen( saveFileName(), "wb" );
+ 
+ 	if ( file == (FILE *) NULL )
+ 		return BNX_FALSE;
+@@ -1181,7 +1239,7 @@
+ {
+ 	FILE		*file;
+ 
+-	file = fopen( "autosave.bnx2", "rb" );
++	file = fopen( saveFileName(), "rb" );
+ 
+ 	if ( file == (FILE *) NULL )
+ 		return BNX_FALSE;
 Index: biniax2/desktop/cfg.c
 ===================================================================
---- biniax2.orig/desktop/cfg.c	2008-04-17 11:57:46.000000000 +0000
-+++ biniax2/desktop/cfg.c	2008-04-17 11:59:09.000000000 +0000
+--- biniax2.orig/desktop/cfg.c	2008-04-17 12:03:55.000000000 +0000
++++ biniax2/desktop/cfg.c	2008-04-17 12:03:57.000000000 +0000
 @@ -30,6 +30,17 @@
  
  #include "inc.h"
@@ -140,8 +213,8 @@
 +}
 Index: biniax2/desktop/cfg.h
 ===================================================================
---- biniax2.orig/desktop/cfg.h	2008-04-17 11:57:46.000000000 +0000
-+++ biniax2/desktop/cfg.h	2008-04-17 11:57:46.000000000 +0000
+--- biniax2.orig/desktop/cfg.h	2008-04-17 12:03:55.000000000 +0000
++++ biniax2/desktop/cfg.h	2008-04-17 12:03:57.000000000 +0000
 @@ -43,4 +43,8 @@
  BNX_BOOL cfgGetMusic();
  BNX_BOOL cfgGetFullscreen();
@@ -153,8 +226,8 @@
  #endif
 Index: biniax2/hof.c
 ===================================================================
---- biniax2.orig/hof.c	2008-04-17 11:57:46.000000000 +0000
-+++ biniax2/hof.c	2008-04-17 11:59:17.000000000 +0000
+--- biniax2.orig/hof.c	2008-04-17 12:03:55.000000000 +0000
++++ biniax2/hof.c	2008-04-17 12:07:28.000000000 +0000
 @@ -31,6 +31,18 @@
  
  #include "inc.h"
@@ -193,13 +266,13 @@
 +		if (!home)
 +		{
 +			fprintf(stderr, "$HOME is not defined.n");
-+			return BNX_FALSE;
++			return "./hof.bnx2";
 +		}
 +	}
-+	if (strlen(home) > PATH_MAX - sizeof("/.biniax2/config"))
++	if (strlen(home) > PATH_MAX - sizeof("/.biniax2/hof"))
 +	{
 +		fprintf(stderr, "$HOME is excessively long.n");
-+		return BNX_FALSE;
++		return "./hof.bnx2";
 +	}
 +	snprintf(filename, sizeof(filename), "%s/.biniax2", home);
 +	mkdir(filename, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);




More information about the Pkg-games-commits mailing list