dslinux/user/games/bsdgames/hack config.h hack.end.c hack.main.c hack.unix.c

pepsiman dslinux_pepsiman at user.in-berlin.de
Thu Nov 2 19:41:37 CET 2006


Update of /cvsroot/dslinux/dslinux/user/games/bsdgames/hack
In directory antilope:/tmp/cvs-serv32189/user/games/bsdgames/hack

Modified Files:
	config.h hack.end.c hack.main.c hack.unix.c 
Log Message:
Patch from Bradley Remedios <bremedios at gmail.com> to fix hack, boggle and wump

Index: config.h
===================================================================
RCS file: /cvsroot/dslinux/dslinux/user/games/bsdgames/hack/config.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- config.h	14 Oct 2006 14:15:35 -0000	1.2
+++ config.h	2 Nov 2006 18:41:35 -0000	1.3
@@ -62,7 +62,8 @@
  */
 
 #include "pathnames.h"
-
+#include <linux/autoconf.h>	// Bradley Remedios<bremedios at gmail.com> for
+				// Font Size defines
 #ifndef CONFIG	/* make sure the compiler doesnt see the typedefs twice */
 
 #define	CONFIG
@@ -160,8 +161,19 @@
 #endif /* CHDIR */
 
 /* size of terminal screen is (at least) (ROWNO+2) by COLNO */
-#define	COLNO	64
-#define	ROWNO	30
+#if defined(CONFIG_FONT_MINI_4x9)
+	#define	COLNO	64
+	#define	ROWNO	19
+#elif defined(CONFIG_FONT_MINI_6x6)
+	#define	COLNO	42
+	#define	ROWNO	30
+#elif defined(CONFIG_FONT_MINI_4x6)
+	#define	COLNO	64
+	#define	ROWNO	30
+#else
+	#define	COLNO	64
+	#define	ROWNO	30
+#endif // FONT SIZE
 
 /*
  * small signed integers (8 bits suffice)

Index: hack.main.c
===================================================================
RCS file: /cvsroot/dslinux/dslinux/user/games/bsdgames/hack/hack.main.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- hack.main.c	22 Oct 2005 20:04:41 -0000	1.1
+++ hack.main.c	2 Nov 2006 18:41:35 -0000	1.2
@@ -69,6 +69,8 @@
 #include <signal.h>
 #include <stdlib.h>
 #include <unistd.h>
+#include <sys/types.h>
+#include <sys/stat.h>
 #include <fcntl.h>
 #include "hack.h"
 #include "extern.h"
@@ -105,6 +107,67 @@
 	char           *dir;
 #endif
 
+	{
+		// We will create the full directory required for the record file if it
+		// does not exist already.
+		const char*	full_path	= _PATH_HACK;
+		char		path[256]	= {0};
+		int			path_index	= 0;
+
+		for (;path_index < 255; path_index++)
+		{
+			if (((full_path[path_index] == '/') && (path_index > 0)) ||
+				(full_path[path_index] == '\0'))
+			{
+				path[path_index] = '\0';
+
+				struct stat	stat_data;
+
+				int ret = stat (path, &stat_data);
+
+				// If we cannot stat it, then it does not exist and we cannot
+				// continue.
+				if (ret < 0)
+				{
+					int ret = mkdir (path, 0x777);
+
+					if (ret < 0)
+					{
+						printf ("Failed to Create Directory %s\n", path);
+						return -1;
+					}
+				}
+
+				// If we are not a directory, then nothing will work.
+				if (!S_ISDIR (stat_data.st_mode))
+				{
+					printf ("%s is not a directory\n", path);
+					return -1;
+				}
+
+				if (full_path[path_index] == '\0')
+					break;
+
+			}
+
+			path[path_index] = full_path[path_index];
+		}
+
+		// We will create the file if it needs to be created.
+		int temp_fd = open (	_PATH_HACK"/record",
+								O_RDWR | O_CREAT,
+								S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | \
+								S_IROTH | S_IWOTH);
+
+		if (temp_fd < 0)
+		{
+			printf ("Failed to Create or Write RecordFile (%d)", temp_fd);
+			return -1;
+		}
+
+		close (temp_fd);
+	}
+
 	/* Check for dirty tricks with closed fds 0, 1, 2 */
 	fd = open("/dev/null", O_RDONLY);
 	if (fd < 3)

Index: hack.end.c
===================================================================
RCS file: /cvsroot/dslinux/dslinux/user/games/bsdgames/hack/hack.end.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- hack.end.c	22 Oct 2005 20:04:43 -0000	1.1
+++ hack.end.c	2 Nov 2006 18:41:35 -0000	1.2
@@ -328,6 +328,10 @@
 	FILE           *rfile;
 	int 		flg = 0;
 #define	HUP	if(!done_hup)
+
+// Bradley Remedios<bremedios at gmail.com>
+// link will not work with FAT32, so we disable locking here too.
+#if 0
 	while (link(recfile, reclock) == -1) {
 		HUP             perror(reclock);
 		if (!sleepct--) {
@@ -340,6 +344,7 @@
 		HUP(void) fflush(stdout);
 		sleep(1);
 	}
+#endif
 	if (!(rfile = fopen(recfile, "r"))) {
 		HUP             puts("Cannot open record file!");
 		goto unlock;

Index: hack.unix.c
===================================================================
RCS file: /cvsroot/dslinux/dslinux/user/games/bsdgames/hack/hack.unix.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- hack.unix.c	22 Oct 2005 20:04:47 -0000	1.1
+++ hack.unix.c	2 Nov 2006 18:41:35 -0000	1.2
@@ -272,6 +272,11 @@
 
 	(void) fflush(stdout);
 
+	// Bradley Remedios<bremedios at gmail.com>
+	// We disable the link call with locking so that hack will work.
+	// link will not work on FAT.
+	return;
+	
 	/* we ignore QUIT and INT at this point */
 	if (link(HLOCK, LLOCK) == -1) {
 		int             errnosv = errno;




More information about the dslinux-commit mailing list