Module Name:    src
Committed By:   dholland
Date:           Sat Mar 29 20:44:20 UTC 2014

Modified Files:
        src/games/hunt/huntd: makemaze.c

Log Message:
tsort contents of file


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/games/hunt/huntd/makemaze.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/games/hunt/huntd/makemaze.c
diff -u src/games/hunt/huntd/makemaze.c:1.10 src/games/hunt/huntd/makemaze.c:1.11
--- src/games/hunt/huntd/makemaze.c:1.10	Sat Mar 29 20:41:57 2014
+++ src/games/hunt/huntd/makemaze.c	Sat Mar 29 20:44:20 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: makemaze.c,v 1.10 2014/03/29 20:41:57 dholland Exp $	*/
+/*	$NetBSD: makemaze.c,v 1.11 2014/03/29 20:44:20 dholland Exp $	*/
 /*
  * Copyright (c) 1983-2003, Regents of the University of California.
  * All rights reserved.
@@ -32,7 +32,7 @@
 
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: makemaze.c,v 1.10 2014/03/29 20:41:57 dholland Exp $");
+__RCSID("$NetBSD: makemaze.c,v 1.11 2014/03/29 20:44:20 dholland Exp $");
 #endif /* not lint */
 
 #include "hunt.h"
@@ -41,35 +41,10 @@ __RCSID("$NetBSD: makemaze.c,v 1.10 2014
 #define ODD(n)		((n) & 01)
 
 #if 0
-static bool candig(int, int);
-static void dig(int, int);
-#endif
-static void dig_maze(int, int);
-static void remap(void);
-
-void
-makemaze(void)
-{
-	char *sp;
-	int y, x;
-
-	/*
-	 * fill maze with walls
-	 */
-	sp = &Maze[0][0];
-	while (sp < &Maze[HEIGHT - 1][WIDTH])
-		*sp++ = DOOR;
-
-	x = rand_num(WIDTH / 2) * 2 + 1;
-	y = rand_num(HEIGHT / 2) * 2 + 1;
-	dig_maze(x, y);
-	remap();
-}
 
 #define NPERM	24
 #define NDIR	4
 
-#if 0
 static const int dirs[NPERM][NDIR] = {
 	{0,1,2,3},	{3,0,1,2},	{0,2,3,1},	{0,3,2,1},
 	{1,0,2,3},	{2,3,0,1},	{0,2,1,3},	{2,3,1,0},
@@ -84,26 +59,6 @@ static const int incr[NDIR][2] = {
 };
 
 
-static void
-dig(int y, int x)
-{
-	const int *dp;
-	const int *ip;
-	int ny, nx;
-	const int *endp;
-
-	Maze[y][x] = SPACE;			/* Clear this spot */
-	dp = dirs[rand_num(NPERM)];
-	endp = &dp[NDIR];
-	while (dp < endp) {
-		ip = &incr[*dp++][0];
-		ny = y + *ip++;
-		nx = x + *ip;
-		if (candig(ny, nx))
-			dig(ny, nx);
-	}
-}
-
 /*
  * candig:
  *	Is it legal to clear this spot?
@@ -137,9 +92,29 @@ candig(int y, int x)
 
 	return true;			/* OK */
 }
+
+static void
+dig(int y, int x)
+{
+	const int *dp;
+	const int *ip;
+	int ny, nx;
+	const int *endp;
+
+	Maze[y][x] = SPACE;			/* Clear this spot */
+	dp = dirs[rand_num(NPERM)];
+	endp = &dp[NDIR];
+	while (dp < endp) {
+		ip = &incr[*dp++][0];
+		ny = y + *ip++;
+		nx = x + *ip;
+		if (candig(ny, nx))
+			dig(ny, nx);
+	}
+}
 #endif
 
-void
+static void
 dig_maze(int x, int y)
 {
 	int tx, ty;
@@ -186,7 +161,7 @@ dig_maze(int x, int y)
 	}
 }
 
-void
+static void
 remap(void)
 {
 	int y, x;
@@ -233,3 +208,22 @@ remap(void)
 		}
 	memcpy(Orig_maze, Maze, sizeof Maze);
 }
+
+void
+makemaze(void)
+{
+	char *sp;
+	int y, x;
+
+	/*
+	 * fill maze with walls
+	 */
+	sp = &Maze[0][0];
+	while (sp < &Maze[HEIGHT - 1][WIDTH])
+		*sp++ = DOOR;
+
+	x = rand_num(WIDTH / 2) * 2 + 1;
+	y = rand_num(HEIGHT / 2) * 2 + 1;
+	dig_maze(x, y);
+	remap();
+}

Reply via email to