X-Git-Url: https://git.cameronkatri.com/bsdgames-darwin.git/blobdiff_plain/6e013c6c7ff3bfb8c4653256f90718d32fd155b2..82159d673f616b12554c28d5ac54f515fec21e91:/larn/create.c

diff --git a/larn/create.c b/larn/create.c
index 941f8caa..440b9184 100644
--- a/larn/create.c
+++ b/larn/create.c
@@ -1,16 +1,26 @@
-/* $NetBSD: create.c,v 1.8 2005/02/25 15:04:43 simonb Exp $	 */
+/* $NetBSD: create.c,v 1.12 2012/06/19 05:30:43 dholland Exp $	 */
 
 /* create.c		Larn is copyrighted 1986 by Noah Morgan. */
 
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: create.c,v 1.8 2005/02/25 15:04:43 simonb Exp $");
+__RCSID("$NetBSD: create.c,v 1.12 2012/06/19 05:30:43 dholland Exp $");
 #endif				/* not lint */
 
 #include "header.h"
 #include "extern.h"
 #include <unistd.h>
+
+static void makemaze(int);
+static int cannedlevel(int);
+static void treasureroom(int);
+static void troom(int, int, int, int, int, int);
+static void makeobject(int);
+static void fillmroom(int, int, int);
+static void froom(int, int, int);
 static void fillroom(int, int);
+static void sethp(int);
+static void checkgen(void);
 
 /*
 	makeplayer()
@@ -19,7 +29,7 @@ static void fillroom(int, int);
 	this is called at the beginning of a game and at no other time
  */
 void
-makeplayer()
+makeplayer(void)
 {
 	int i;
 	scbr();
@@ -62,38 +72,38 @@ makeplayer()
 	Note that it is here we remove genocided monsters from the present level.
  */
 void
-newcavelevel(x)
-	int             x;
+newcavelevel(int x)
 {
 	int             i, j;
 	if (beenhere[level])
 		savelevel();	/* put the level back into storage	 */
 	level = x;		/* get the new level and put in working
 				 * storage */
-	if (beenhere[x] == 0)
-		for (i = 0; i < MAXY; i++)
-			for (j = 0; j < MAXX; j++)
-				know[j][i] = mitem[j][i] = 0;
-	else {
+	if (beenhere[x]) {
 		getlevel();
 		sethp(0);
-		goto chgn;
+		checkgen();
+		return;
 	}
+
+	/* fill in new level */
+	for (i = 0; i < MAXY; i++)
+		for (j = 0; j < MAXX; j++)
+			know[j][i] = mitem[j][i] = 0;
 	makemaze(x);
 	makeobject(x);
 	beenhere[x] = 1;
 	sethp(1);
+	checkgen();		/* wipe out any genocided monsters */
 
 #if WIZID
 	if (wizard || x == 0)
 #else
 	if (x == 0)
 #endif
-
 		for (j = 0; j < MAXY; j++)
 			for (i = 0; i < MAXX; i++)
 				know[i][j] = 1;
-chgn:	checkgen();		/* wipe out any genocided monsters */
 }
 
 /*
@@ -103,9 +113,9 @@ chgn:	checkgen();		/* wipe out any genocided monsters */
 	subroutine to make the caverns for a given level.  only walls are made.
  */
 static int      mx, mxl, mxh, my, myl, myh, tmp2;
-void
-makemaze(k)
-	int             k;
+
+static void
+makemaze(int k)
 {
 	int             i, j, tmp;
 	int             z;
@@ -165,8 +175,7 @@ makemaze(k)
 	function to eat away a filled in maze
  */
 void
-eat(xx, yy)
-	int             xx, yy;
+eat(int xx, int yy)
 {
 	int             dir, try;
 	dir = rnd(4);
@@ -228,9 +237,8 @@ eat(xx, yy)
  *		~	eye of larn		!	cure dianthroritis
  *		-	random object
  */
-int
-cannedlevel(k)
-	int             k;
+static int
+cannedlevel(int k)
 {
 	char           *row;
 	int             i, j;
@@ -305,9 +313,8 @@ cannedlevel(k)
 	level 10's treasure room has the eye in it and demon lords
 	level V3 has potion of cure dianthroritis and demon prince
  */
-void
-treasureroom(lv)
-	int             lv;
+static void
+treasureroom(int lv)
 {
 	int             tx, ty, xsize, ysize;
 
@@ -328,9 +335,8 @@ treasureroom(lv)
  *	room is filled with objects and monsters
  *	the coordinate given is that of the upper left corner of the room
  */
-void
-troom(lv, xsize, ysize, tx, ty, glyph)
-	int             lv, xsize, ysize, tx, ty, glyph;
+static void
+troom(int lv, int xsize, int ysize, int tx, int ty, int glyph)
 {
 	int             i, j;
 	int             tp1, tp2;
@@ -386,9 +392,8 @@ troom(lv, xsize, ysize, tx, ty, glyph)
 	***********
 	subroutine to create the objects in the maze for the given level
  */
-void
-makeobject(j)
-	int             j;
+static void
+makeobject(int j)
 {
 	int             i;
 	if (j == 0) {
@@ -480,22 +485,23 @@ makeobject(j)
 	subroutine to fill in a number of objects of the same kind
  */
 
-void
-fillmroom(n, what, arg)
-	int             n, arg;
-	char            what;
+static void
+fillmroom(int n, int what_i, int arg)
 {
 	int             i;
+	char            what;
+
+	/* truncate to char width (just in case it matters) */
+	what = (char)what_i;
 	for (i = 0; i < n; i++)
 		fillroom(what, arg);
 }
-void
-froom(n, itm, arg)
-	int             n, arg;
-	char            itm;
+
+static void
+froom(int n, int theitem, int arg)
 {
 	if (rnd(151) < n)
-		fillroom(itm, arg);
+		fillroom(theitem, arg);
 }
 
 /*
@@ -503,11 +509,13 @@ froom(n, itm, arg)
  *	uses a random walk
  */
 static void
-fillroom(what, arg)
-	int             arg;
-	char            what;
+fillroom(int what_i, int arg)
 {
 	int             x, y;
+	char            what;
+
+	/* truncate to char width (just in case it matters) */
+	what = (char)what_i;
 
 #ifdef EXTRA
 	c[FILLROOM]++;
@@ -541,8 +549,7 @@ fillroom(what, arg)
 	monsters
  */
 int
-fillmonst(what)
-	int            what;
+fillmonst(int what)
 {
 	int             x, y, trys;
 	for (trys = 5; trys > 0; --trys) {	/* max # of creation attempts */
@@ -563,9 +570,8 @@ fillmonst(what)
 	must be done when entering a new level
 	if sethp(1) then wipe out old monsters else leave them there
  */
-void
-sethp(flg)
-	int             flg;
+static void
+sethp(int flg)
 {
 	int             i, j;
 	if (flg)
@@ -589,8 +595,8 @@ sethp(flg)
 /*
  *	Function to destroy all genocided monsters on the present level
  */
-void
-checkgen()
+static void
+checkgen(void)
 {
 	int             x, y;
 	for (y = 0; y < MAXY; y++)