-/* $NetBSD: level.c,v 1.7 2003/08/07 09:37:38 agc Exp $ */
+/* $NetBSD: level.c,v 1.10 2008/01/14 03:50:01 dholland Exp $ */
/*
* Copyright (c) 1988, 1993
#if 0
static char sccsid[] = "@(#)level.c 8.1 (Berkeley) 5/31/93";
#else
-__RCSID("$NetBSD: level.c,v 1.7 2003/08/07 09:37:38 agc Exp $");
+__RCSID("$NetBSD: level.c,v 1.10 2008/01/14 03:50:01 dholland Exp $");
#endif
#endif /* not lint */
#include "rogue.h"
-#define swap(x,y) {t = x; x = y; y = t;}
+#define SWAP(x,y) (t = (x), (x) = (y), (y) = t)
+
+static void add_mazes(void);
+static int connect_rooms(short, short);
+static void draw_simple_passage(short, short, short, short, short);
+static void fill_it(int, boolean);
+static void fill_out_level(void);
+static int get_exp_level(long);
+static void hide_boxed_passage(short, short, short, short, short);
+static void make_maze(short, short, short, short, short, short);
+static void make_room(short, short, short, short);
+static boolean mask_room(short, short *, short *, unsigned short);
+static void mix_random_rooms(void);
+static void put_door(room *, short, short *, short *);
+static void recursive_deadend(short, const short *, short, short);
+static int same_col(int, int);
+static int same_row(int, int);
short cur_level = 0;
short max_level = 1;
short cur_room;
-const char *new_level_message = 0;
+const char *new_level_message = NULL;
short party_room = NO_ROOM;
-short r_de;
+
+static short r_de;
const long level_points[MAX_EXP_LEVEL] = {
10L,
99900000L
};
-short random_rooms[MAXROOMS] = {3, 7, 5, 2, 0, 6, 1, 4, 8};
+static short random_rooms[MAXROOMS] = {3, 7, 5, 2, 0, 6, 1, 4, 8};
void
-make_level()
+make_level(void)
{
short i, j;
short must_1, must_2, must_3;
i = random_rooms[j];
if (i < (MAXROOMS-1)) {
- (void) connect_rooms(i, i+1);
+ (void)connect_rooms(i, i+1);
}
if (i < (MAXROOMS-3)) {
- (void) connect_rooms(i, i+3);
+ (void)connect_rooms(i, i+3);
}
if (i < (MAXROOMS-2)) {
if (rooms[i+1].is_room & R_NOTHING) {
}
}
-void
-make_room(rn, r1, r2, r3)
- short rn, r1, r2, r3;
+static void
+make_room(short rn, short r1, short r2, short r3)
{
short left_col, right_col, top_row, bottom_row;
short width, height;
rooms[rn].right_col = right_col;
}
-int
-connect_rooms(room1, room2)
- short room1, room2;
+static int
+connect_rooms(short room1, short room2)
{
short row1, col1, row2, col2, dir;
}
void
-clear_level()
+clear_level(void)
{
short i, j;
clear();
}
-void
-put_door(rm, dir, row, col)
- room *rm;
- short dir;
- short *row, *col;
+static void
+put_door(room *rm, short dir, short *row, short *col)
{
short wall_width;
rm->doors[dir/2].door_col = *col;
}
-void
-draw_simple_passage(row1, col1, row2, col2, dir)
- short row1, col1, row2, col2, dir;
+static void
+draw_simple_passage(short row1, short col1, short row2, short col2, short dir)
{
short i, middle, t;
if ((dir == LEFT) || (dir == RIGHT)) {
if (col1 > col2) {
- swap(row1, row2);
- swap(col1, col2);
+ SWAP(row1, row2);
+ SWAP(col1, col2);
}
middle = get_rand(col1+1, col2-1);
for (i = col1+1; i != middle; i++) {
}
} else {
if (row1 > row2) {
- swap(row1, row2);
- swap(col1, col2);
+ SWAP(row1, row2);
+ SWAP(col1, col2);
}
middle = get_rand(row1+1, row2-1);
for (i = row1+1; i != middle; i++) {
}
}
-int
-same_row(room1, room2)
- int room1, room2;
+static int
+same_row(int room1, int room2)
{
return((room1 / 3) == (room2 / 3));
}
-int
-same_col(room1, room2)
- int room1, room2;
+static int
+same_col(int room1, int room2)
{
return((room1 % 3) == (room2 % 3));
}
-void
-add_mazes()
+static void
+add_mazes(void)
{
short i, j;
short start;
}
}
-void
-fill_out_level()
+static void
+fill_out_level(void)
{
short i, rn;
}
}
-void
-fill_it(rn, do_rec_de)
- int rn;
- boolean do_rec_de;
+static void
+fill_it(int rn, boolean do_rec_de)
{
short i, tunnel_dir, door_dir, drow, dcol;
short target_room, rooms_found = 0;
}
}
-void
-recursive_deadend(rn, offsets, srow, scol)
- short rn;
- const short *offsets;
- short srow, scol;
+static void
+recursive_deadend(short rn, const short *offsets, short srow, short scol)
{
short i, de;
short drow, dcol, tunnel_dir;
}
}
-boolean
-mask_room(rn, row, col, mask)
- short rn;
- short *row, *col;
- unsigned short mask;
+static boolean
+mask_room(short rn, short *row, short *col, unsigned short mask)
{
short i, j;
return(0);
}
-void
-make_maze(r, c, tr, br, lc, rc)
- short r, c, tr, br, lc, rc;
+static void
+make_maze(short r, short c, short tr, short br, short lc, short rc)
{
char dirs[4];
short i, t;
t1 = get_rand(0, 3);
t2 = get_rand(0, 3);
- swap(dirs[t1], dirs[t2]);
+ SWAP(dirs[t1], dirs[t2]);
}
}
for (i = 0; i < 4; i++) {
}
}
-void
-hide_boxed_passage(row1, col1, row2, col2, n)
- short row1, col1, row2, col2, n;
+static void
+hide_boxed_passage(short row1, short col1, short row2, short col2, short n)
{
short i, j, t;
short row, col, row_cut, col_cut;
if (cur_level > 2) {
if (row1 > row2) {
- swap(row1, row2);
+ SWAP(row1, row2);
}
if (col1 > col2) {
- swap(col1, col2);
+ SWAP(col1, col2);
}
h = row2 - row1;
w = col2 - col1;
}
}
+/*
+ * try not to put in room NR
+ */
void
-put_player(nr)
- short nr; /* try not to put in this room */
+put_player(short nr)
{
short rn = nr, misses;
short row, col;
rn = get_room_number(rogue.row, rogue.col);
wake_room(rn, 1, rogue.row, rogue.col);
if (new_level_message) {
- message(new_level_message, 0);
- new_level_message = 0;
+ messagef(0, "%s", new_level_message);
+ new_level_message = NULL;
}
mvaddch(rogue.row, rogue.col, rogue.fchar);
}
int
-drop_check()
+drop_check(void)
{
if (wizard) {
return(1);
}
if (dungeon[rogue.row][rogue.col] & STAIRS) {
if (levitate) {
- message("you're floating in the air!", 0);
+ messagef(0, "you're floating in the air!");
return(0);
}
return(1);
}
- message("I see no way down", 0);
+ messagef(0, "I see no way down");
return(0);
}
int
-check_up()
+check_up(void)
{
if (!wizard) {
if (!(dungeon[rogue.row][rogue.col] & STAIRS)) {
- message("I see no way up", 0);
+ messagef(0, "I see no way up");
return(0);
}
if (!has_amulet()) {
- message("your way is magically blocked", 0);
+ messagef(0, "your way is magically blocked");
return(0);
}
}
}
void
-add_exp(e, promotion)
- int e;
- boolean promotion;
+add_exp(int e, boolean promotion)
{
- char mbuf[40];
short new_exp;
short i, hp;
rogue.exp_points = MAX_EXP + 1;
}
for (i = rogue.exp+1; i <= new_exp; i++) {
- sprintf(mbuf, "welcome to level %d", i);
- message(mbuf, 0);
+ messagef(0, "welcome to level %d", i);
if (promotion) {
hp = hp_raise();
rogue.hp_current += hp;
}
}
-int
-get_exp_level(e)
- long e;
+static int
+get_exp_level(long e)
{
short i;
}
int
-hp_raise()
+hp_raise(void)
{
int hp;
}
void
-show_average_hp()
+show_average_hp(void)
{
- char mbuf[80];
float real_average;
float effective_average;
} else {
real_average = (float)
((rogue.hp_max - extra_hp - INIT_HP) + less_hp) / (rogue.exp - 1);
- effective_average = (float) (rogue.hp_max - INIT_HP) / (rogue.exp - 1);
+ effective_average = (float)(rogue.hp_max - INIT_HP) / (rogue.exp - 1);
}
- sprintf(mbuf, "R-Hp: %.2f, E-Hp: %.2f (!: %d, V: %d)", real_average,
+ messagef(0, "R-Hp: %.2f, E-Hp: %.2f (!: %d, V: %d)", real_average,
effective_average, extra_hp, less_hp);
- message(mbuf, 0);
}
-void
-mix_random_rooms()
+static void
+mix_random_rooms(void)
{
short i, t;
short x, y;
x = get_rand(0, (MAXROOMS-1));
y = get_rand(0, (MAXROOMS-1));
} while (x == y);
- swap(random_rooms[x], random_rooms[y]);
+ SWAP(random_rooms[x], random_rooms[y]);
}
}