-/* $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()
this is called at the beginning of a game and at no other time
*/
void
-makeplayer()
+makeplayer(void)
{
int i;
scbr();
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 */
}
/*
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;
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);
* ~ eye of larn ! cure dianthroritis
* - random object
*/
-int
-cannedlevel(k)
- int k;
+static int
+cannedlevel(int k)
{
char *row;
int i, j;
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;
* 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;
***********
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) {
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);
}
/*
* 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]++;
monsters
*/
int
-fillmonst(what)
- int what;
+fillmonst(int what)
{
int x, y, trys;
for (trys = 5; trys > 0; --trys) { /* max # of creation attempts */
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)
/*
* 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++)