aboutsummaryrefslogtreecommitdiff
path: root/games/rogue
diff options
context:
space:
mode:
authorSteve Price <steve@FreeBSD.org>1999-04-19 03:59:02 +0000
committerSteve Price <steve@FreeBSD.org>1999-04-19 03:59:02 +0000
commitaf71cfbb87e566f2b9f599f5c40481194f449a69 (patch)
tree579f8949d23c1c30971542889c96433deb74f034 /games/rogue
parentf1cb6ca39242b433b30c59db2895c3ac48406ab5 (diff)
downloadsrc-af71cfbb87e566f2b9f599f5c40481194f449a69.tar.gz
src-af71cfbb87e566f2b9f599f5c40481194f449a69.zip
Merge a bunch of cleanups from NetBSD.
PR: 8083 Submitted by: Stephen J. Roznowski <sjr@home.net> Obtained from: a whole slew of NetBSD PRs
Notes
Notes: svn path=/head/; revision=45801
Diffstat (limited to 'games/rogue')
-rw-r--r--games/rogue/hit.c18
-rw-r--r--games/rogue/init.c13
-rw-r--r--games/rogue/inventory.c22
-rw-r--r--games/rogue/level.c6
-rw-r--r--games/rogue/machdep.c19
-rw-r--r--games/rogue/message.c13
-rw-r--r--games/rogue/monster.c27
-rw-r--r--games/rogue/move.c2
-rw-r--r--games/rogue/object.c10
-rw-r--r--games/rogue/pack.c10
-rw-r--r--games/rogue/play.c2
-rw-r--r--games/rogue/ring.c4
-rw-r--r--games/rogue/rogue.h10
-rw-r--r--games/rogue/room.c7
-rw-r--r--games/rogue/save.c18
-rw-r--r--games/rogue/score.c18
-rw-r--r--games/rogue/throw.c2
-rw-r--r--games/rogue/trap.c4
-rw-r--r--games/rogue/use.c4
-rw-r--r--games/rogue/zap.c3
20 files changed, 118 insertions, 94 deletions
diff --git a/games/rogue/hit.c b/games/rogue/hit.c
index d2a6d75fa6f4..f9891539864e 100644
--- a/games/rogue/hit.c
+++ b/games/rogue/hit.c
@@ -63,7 +63,7 @@ mon_hit(monster)
register object *monster;
{
short damage, hit_chance;
- char *mn;
+ const char *mn;
float minus;
if (fight_monster && (monster != fight_monster)) {
@@ -175,7 +175,7 @@ short other;
}
get_damage(ds, r)
-char *ds;
+const char *ds;
boolean r;
{
register i = 0, j, n, d, total = 0;
@@ -201,7 +201,7 @@ boolean r;
}
get_w_damage(obj)
-object *obj;
+const object *obj;
{
char new_damage[12];
register to_hit, damage;
@@ -220,7 +220,7 @@ object *obj;
}
get_number(s)
-register char *s;
+const char *s;
{
register i = 0;
register total = 0;
@@ -234,7 +234,7 @@ register char *s;
long
lget_number(s)
-char *s;
+const char *s;
{
short i = 0;
long total = 0;
@@ -247,7 +247,7 @@ char *s;
}
to_hit(obj)
-object *obj;
+const object *obj;
{
if (!obj) {
return(1);
@@ -289,7 +289,7 @@ mon_damage(monster, damage)
object *monster;
short damage;
{
- char *mn;
+ const char *mn;
short row, col;
monster->hp_to_kill -= damage;
@@ -423,7 +423,7 @@ short allow_off_screen;
}
get_hit_chance(weapon)
-object *weapon;
+const object *weapon;
{
short hit_chance;
@@ -434,7 +434,7 @@ object *weapon;
}
get_weapon_damage(weapon)
-object *weapon;
+const object *weapon;
{
short damage;
diff --git a/games/rogue/init.c b/games/rogue/init.c
index d0b81f8dd7ac..fea5831baec8 100644
--- a/games/rogue/init.c
+++ b/games/rogue/init.c
@@ -65,8 +65,8 @@ boolean ask_quit = 1;
boolean no_skull = 0;
boolean passgo = 0;
boolean flush = 1;
-char *error_file = "rogue.esave";
-char *byebye_string = "Okay, bye bye!";
+const char *error_file = "rogue.esave";
+const char *byebye_string = "Okay, bye bye!";
extern char *fruit;
extern char *save_file;
@@ -77,7 +77,7 @@ init(argc, argv)
int argc;
char *argv[];
{
- char *pn;
+ const char *pn;
int seed;
pn = md_gln();
@@ -173,7 +173,7 @@ player_init()
}
clean_up(estr)
-char *estr;
+const char *estr;
{
if (save_is_interactive) {
if (init_curses) {
@@ -310,7 +310,7 @@ char **s, *e;
boolean add_blank;
{
short i = 0;
- char *t;
+ const char *t;
t = e;
@@ -332,7 +332,8 @@ boolean add_blank;
}
init_str(str, dflt)
-char **str, *dflt;
+char **str;
+const char *dflt;
{
if (!(*str)) {
*str = md_malloc(MAX_OPT_LEN + 2);
diff --git a/games/rogue/inventory.c b/games/rogue/inventory.c
index 5dd6f3da8ac3..da321de5ee9a 100644
--- a/games/rogue/inventory.c
+++ b/games/rogue/inventory.c
@@ -53,9 +53,9 @@ static char sccsid[] = "@(#)inventory.c 8.1 (Berkeley) 5/31/93";
#include "rogue.h"
boolean is_wood[WANDS];
-char *press_space = " --press space to continue--";
+const char *press_space = " --press space to continue--";
-char *wand_materials[WAND_MATERIALS] = {
+const char *const wand_materials[WAND_MATERIALS] = {
"steel ",
"bronze ",
"gold ",
@@ -89,7 +89,7 @@ char *wand_materials[WAND_MATERIALS] = {
"wooden "
};
-char *gems[GEMS] = {
+const char *const gems[GEMS] = {
"diamond ",
"stibotantalite ",
"lapi-lazuli ",
@@ -106,7 +106,7 @@ char *gems[GEMS] = {
"garnet "
};
-char *syllables[MAXSYLLABLES] = {
+const char *const syllables[MAXSYLLABLES] = {
"blech ",
"foo ",
"barf ",
@@ -153,10 +153,10 @@ char *syllables[MAXSYLLABLES] = {
struct id_com_s {
short com_char;
- char *com_desc;
+ const char *com_desc;
};
-struct id_com_s com_id_tab[COMS] = {
+const struct id_com_s com_id_tab[COMS] = {
'?', "? prints help",
'r', "r read scroll",
'/', "/ identify object",
@@ -211,7 +211,7 @@ extern boolean wizard;
extern char *m_names[], *more;
inventory(pack, mask)
-object *pack;
+const object *pack;
unsigned short mask;
{
object *obj;
@@ -441,10 +441,10 @@ make_scroll_titles()
}
get_desc(obj, desc)
-object *obj;
+const object *obj;
char *desc;
{
- char *item_name;
+ const char *item_name;
struct id *id_table;
char more_info[32];
short i;
@@ -657,7 +657,7 @@ short ichar;
struct id *
get_id_table(obj)
-object *obj;
+const object *obj;
{
switch(obj->what_is) {
case SCROL:
@@ -696,7 +696,7 @@ boolean is_weapon;
id_type()
{
- char *id;
+ const char *id;
int ch;
char buf[DCOLS];
diff --git a/games/rogue/level.c b/games/rogue/level.c
index 1e95f6db894f..7209ca8e4f3f 100644
--- a/games/rogue/level.c
+++ b/games/rogue/level.c
@@ -57,11 +57,11 @@ static char sccsid[] = "@(#)level.c 8.1 (Berkeley) 5/31/93";
short cur_level = 0;
short max_level = 1;
short cur_room;
-char *new_level_message = 0;
+const char *new_level_message = 0;
short party_room = NO_ROOM;
short r_de;
-long level_points[MAX_EXP_LEVEL] = {
+const long level_points[MAX_EXP_LEVEL] = {
10L,
20L,
40L,
@@ -572,7 +572,7 @@ boolean do_rec_de;
recursive_deadend(rn, offsets, srow, scol)
short rn;
-short *offsets;
+const short *offsets;
short srow, scol;
{
short i, de;
diff --git a/games/rogue/machdep.c b/games/rogue/machdep.c
index c7c89a6e4481..9e770fc71b44 100644
--- a/games/rogue/machdep.c
+++ b/games/rogue/machdep.c
@@ -254,7 +254,7 @@ md_ignore_signals()
int
md_get_file_id(fname)
-char *fname;
+const char *fname;
{
struct stat sbuf;
@@ -274,7 +274,7 @@ char *fname;
int
md_link_count(fname)
-char *fname;
+const char *fname;
{
struct stat sbuf;
@@ -330,7 +330,7 @@ struct rogue_time *rt_buf;
*/
md_gfmt(fname, rt_buf)
-char *fname;
+const char *fname;
struct rogue_time *rt_buf;
{
struct stat sbuf;
@@ -362,7 +362,7 @@ struct rogue_time *rt_buf;
boolean
md_df(fname)
-char *fname;
+const char *fname;
{
if (unlink(fname)) {
return(0);
@@ -379,7 +379,7 @@ char *fname;
* function, but then the score file would only have one name in it.
*/
-char *
+const char *
md_gln()
{
struct passwd *p;
@@ -446,7 +446,7 @@ int nsecs;
char *
md_getenv(name)
-char *name;
+const char *name;
{
char *value;
@@ -493,7 +493,10 @@ int n;
md_gseed()
{
- return(getpid());
+ time_t seconds;
+
+ time(&seconds);
+ return((int) seconds);
}
/* md_exit():
@@ -550,7 +553,7 @@ boolean l;
*/
md_shell(shell)
-char *shell;
+const char *shell;
{
long w[2];
diff --git a/games/rogue/message.c b/games/rogue/message.c
index 78958c3cf74d..08110169bf0d 100644
--- a/games/rogue/message.c
+++ b/games/rogue/message.c
@@ -57,14 +57,14 @@ char msgs[NMESSAGES][DCOLS] = {"", "", "", "", ""};
short msg_col = 0, imsg = -1;
boolean msg_cleared = 1, rmsg = 0;
char hunger_str[8] = "";
-char *more = "-more-";
+const char *more = "-more-";
extern boolean cant_int, did_int, interrupted, save_is_interactive, flush;
extern short add_strength;
extern short cur_level;
message(msg, intrpt)
-char *msg;
+const char *msg;
boolean intrpt;
{
cant_int = 1;
@@ -130,8 +130,9 @@ check_message()
}
get_input_line(prompt, insert, buf, if_cancelled, add_blank, do_echo)
-char *prompt, *buf, *insert;
-char *if_cancelled;
+const char *prompt, *insert;
+char *buf;
+const char *if_cancelled;
boolean add_blank;
boolean do_echo;
{
@@ -305,7 +306,7 @@ register stat_mask;
}
pad(s, n)
-char *s;
+const char *s;
short n;
{
short i;
@@ -357,7 +358,7 @@ short ch;
}
r_index(str, ch, last)
-char *str;
+const char *str;
int ch;
boolean last;
{
diff --git a/games/rogue/monster.c b/games/rogue/monster.c
index bd73414b8eb8..9a20837e9f08 100644
--- a/games/rogue/monster.c
+++ b/games/rogue/monster.c
@@ -55,7 +55,7 @@ static char sccsid[] = "@(#)monster.c 8.1 (Berkeley) 5/31/93";
object level_monsters;
boolean mon_disappeared;
-char *m_names[] = {
+const char *const m_names[] = {
"aquator",
"bat",
"centaur",
@@ -171,7 +171,7 @@ register mn;
mv_mons()
{
- register object *monster, *next_monster;
+ register object *monster, *next_monster, *test_mons;
boolean flew;
if (haste_self % 2) {
@@ -210,7 +210,17 @@ mv_mons()
if (!(flew && mon_can_go(monster, rogue.row, rogue.col))) {
mv_1_monster(monster, rogue.row, rogue.col);
}
-NM: monster = next_monster;
+NM: test_mons = level_monsters.next_monster;
+ monster = NULL;
+ while(test_mons)
+ {
+ if(next_monster == test_mons)
+ {
+ monster = next_monster;
+ break;
+ }
+ test_mons = test_mons->next_monster;
+ }
}
}
@@ -488,7 +498,7 @@ register short row, col;
}
mon_can_go(monster, row, col)
-register object *monster;
+const object *monster;
register short row, col;
{
object *obj;
@@ -572,9 +582,9 @@ short row, col;
}
}
-char *
+const char *
mon_name(monster)
-object *monster;
+const object *monster;
{
short ch;
@@ -790,7 +800,7 @@ object *monster;
gr_obj_char()
{
short r;
- char *rs = "%!?]=/):*";
+ const char *rs = "%!?]=/):*";
r = get_rand(0, 8);
@@ -832,7 +842,8 @@ aggravate()
boolean
mon_sees(monster, row, col)
-object *monster;
+const object *monster;
+int row, col;
{
short rn, rdif, cdif, retval;
diff --git a/games/rogue/move.c b/games/rogue/move.c
index dc05700b6fa0..d7659b3e5002 100644
--- a/games/rogue/move.c
+++ b/games/rogue/move.c
@@ -54,7 +54,7 @@ static char sccsid[] = "@(#)move.c 8.1 (Berkeley) 5/31/93";
short m_moves = 0;
boolean jump = 0;
-char *you_can_move_again = "you can move again";
+const char *you_can_move_again = "you can move again";
extern short cur_room, halluc, blind, levitate;
extern short cur_level, max_level;
diff --git a/games/rogue/object.c b/games/rogue/object.c
index 13dabe62ecf6..adc8c74e4677 100644
--- a/games/rogue/object.c
+++ b/games/rogue/object.c
@@ -228,6 +228,7 @@ boolean is_maze;
place_at(obj, row, col)
object *obj;
+int row, col;
{
obj->row = row;
obj->col = col;
@@ -257,6 +258,7 @@ short row, col;
object *
get_letter_object(ch)
+int ch;
{
object *obj;
@@ -281,11 +283,11 @@ object *objlist;
}
}
-char *
+const char *
name_of(obj)
-object *obj;
+const object *obj;
{
- char *retstring;
+ const char *retstring;
switch(obj->what_is) {
case SCROL:
@@ -602,7 +604,7 @@ put_stairs()
}
get_armor_class(obj)
-object *obj;
+const object *obj;
{
if (obj) {
return(obj->class + obj->d_enchant);
diff --git a/games/rogue/pack.c b/games/rogue/pack.c
index 3efcfa6cd187..daa78b19b686 100644
--- a/games/rogue/pack.c
+++ b/games/rogue/pack.c
@@ -52,13 +52,14 @@ static char sccsid[] = "@(#)pack.c 8.1 (Berkeley) 5/31/93";
#include "rogue.h"
-char *curse_message = "you can't, it appears to be cursed";
+const char *curse_message = "you can't, it appears to be cursed";
extern short levitate;
object *
add_to_pack(obj, pack, condense)
object *obj, *pack;
+int condense;
{
object *op;
@@ -99,6 +100,7 @@ object *obj, *pack;
object *
pick_up(row, col, status)
+int row, col;
short *status;
{
object *obj;
@@ -270,7 +272,7 @@ wait_for_ack()
}
pack_letter(prompt, mask)
-char *prompt;
+const char *prompt;
unsigned short mask;
{
short ch;
@@ -460,7 +462,7 @@ call_it()
}
pack_count(new_obj)
-object *new_obj;
+const object *new_obj;
{
object *obj;
short count = 0;
@@ -488,7 +490,7 @@ object *new_obj;
boolean
mask_pack(pack, mask)
-object *pack;
+const object *pack;
unsigned short mask;
{
while (pack->next_object) {
diff --git a/games/rogue/play.c b/games/rogue/play.c
index 5b890f93bacd..1eea292aa691 100644
--- a/games/rogue/play.c
+++ b/games/rogue/play.c
@@ -53,7 +53,7 @@ static char sccsid[] = "@(#)play.c 8.1 (Berkeley) 5/31/93";
#include "rogue.h"
boolean interrupted = 0;
-char *unknown_command = "unknown command";
+const char *unknown_command = "unknown command";
extern short party_room, bear_trap;
extern char hit_message[];
diff --git a/games/rogue/ring.c b/games/rogue/ring.c
index e343b2cb87c7..9516b5fe78ab 100644
--- a/games/rogue/ring.c
+++ b/games/rogue/ring.c
@@ -52,8 +52,8 @@ static char sccsid[] = "@(#)ring.c 8.1 (Berkeley) 5/31/93";
#include "rogue.h"
-char *left_or_right = "left or right hand?";
-char *no_ring = "there's no ring on that hand";
+const char *left_or_right = "left or right hand?";
+const char *no_ring = "there's no ring on that hand";
short stealthy;
short r_rings;
short add_strength;
diff --git a/games/rogue/rogue.h b/games/rogue/rogue.h
index b3009be1648f..2052e55f5608 100644
--- a/games/rogue/rogue.h
+++ b/games/rogue/rogue.h
@@ -221,7 +221,7 @@ struct id {
struct obj { /* comment is monster meaning */
unsigned long m_flags; /* monster flags */
- char *damage; /* damage it does */
+ const char *damage; /* damage it does */
short quantity; /* hit points to kill */
short ichar; /* 'A' is for aquatar */
short kill_exp; /* exp for killing it */
@@ -427,10 +427,10 @@ extern object level_monsters;
/* external routine declarations.
*/
-char *mon_name();
-char *get_ench_color();
-char *name_of();
-char *md_gln();
+const char *mon_name();
+const char *get_ench_color();
+const char *name_of();
+const char *md_gln();
char *md_getenv();
char *md_malloc();
boolean is_direction();
diff --git a/games/rogue/room.c b/games/rogue/room.c
index 1412fd10f9e1..c07f5e1377dd 100644
--- a/games/rogue/room.c
+++ b/games/rogue/room.c
@@ -62,7 +62,7 @@ extern char *nick_name, *fruit, *save_file, *press_space;
#define NOPTS 8
struct option {
- char *prompt;
+ const char *prompt;
boolean is_bool;
char **strval;
boolean *bval;
@@ -129,6 +129,7 @@ int rn;
}
light_passage(row, col)
+int row, col;
{
short i, j, i_end, j_end;
@@ -604,7 +605,7 @@ CH:
opt_show(i)
int i;
{
- char *s;
+ const char *s;
struct option *opt = &options[i];
opt_erase(i);
@@ -635,7 +636,7 @@ int i;
do_shell()
{
#ifdef UNIX
- char *sh;
+ const char *sh;
md_ignore_signals();
if (!(sh = md_getenv("SHELL"))) {
diff --git a/games/rogue/save.c b/games/rogue/save.c
index 46d7ef59ac58..04c9652e1caf 100644
--- a/games/rogue/save.c
+++ b/games/rogue/save.c
@@ -94,7 +94,7 @@ save_game()
}
save_into_file(sfile)
-char *sfile;
+const char *sfile;
{
FILE *fp;
int file_id;
@@ -176,7 +176,7 @@ static del_save_file()
}
restore(fname)
-char *fname;
+const char *fname;
{
FILE *fp;
struct rogue_time saved_time, mod_time;
@@ -257,16 +257,16 @@ char *fname;
}
write_pack(pack, fp)
-object *pack;
+const object *pack;
FILE *fp;
{
object t;
while (pack = pack->next_object) {
- r_write(fp, (char *) pack, sizeof(object));
+ r_write(fp, (const char *) pack, sizeof(object));
}
t.ichar = t.what_is = 0;
- r_write(fp, (char *) &t, sizeof(object));
+ r_write(fp, (const char *) &t, sizeof(object));
}
read_pack(pack, fp, is_rogue)
@@ -333,8 +333,8 @@ boolean wr;
for (i = 0; i < n; i++) {
if (wr) {
- r_write(fp, (char *) &(id_table[i].value), sizeof(short));
- r_write(fp, (char *) &(id_table[i].id_status),
+ r_write(fp, (const char *) &(id_table[i].value), sizeof(short));
+ r_write(fp, (const char *) &(id_table[i].id_status),
sizeof(unsigned short));
write_string(id_table[i].title, fp);
} else {
@@ -393,7 +393,7 @@ int n;
r_write(fp, buf, n)
FILE *fp;
-char *buf;
+const char *buf;
int n;
{
if (!write_failed) {
@@ -407,7 +407,7 @@ int n;
boolean
has_been_touched(saved_time, mod_time)
-struct rogue_time *saved_time, *mod_time;
+const struct rogue_time *saved_time, *mod_time;
{
if (saved_time->year < mod_time->year) {
return(1);
diff --git a/games/rogue/score.c b/games/rogue/score.c
index 06b10b70da36..73fdda4d1d2b 100644
--- a/games/rogue/score.c
+++ b/games/rogue/score.c
@@ -61,7 +61,7 @@ extern boolean score_only, no_skull, msg_cleared;
extern char *byebye_string, *nick_name;
killed_by(monster, other)
-object *monster;
+const object *monster;
short other;
{
char buf[128];
@@ -193,7 +193,7 @@ boolean from_intrpt;
}
put_scores(monster, other)
-object *monster;
+const object *monster;
short other;
{
short i, n, rank = 10, x, ne = 0, found_player = -1;
@@ -321,9 +321,9 @@ short other;
insert_score(scores, n_names, n_name, rank, n, monster, other)
char scores[][82];
char n_names[][30];
-char *n_name;
+const char *n_name;
short rank, n;
-object *monster;
+const object *monster;
{
short i;
char buf[128];
@@ -423,7 +423,7 @@ sell_pack()
}
get_value(obj)
-object *obj;
+const object *obj;
{
short wc;
int val;
@@ -491,7 +491,8 @@ id_all()
}
name_cmp(s1, s2)
-char *s1, *s2;
+char *s1;
+const char *s2;
{
short i = 0;
int r;
@@ -540,7 +541,8 @@ boolean st;
}
nickize(buf, score, n_name)
-char *buf, *score, *n_name;
+char *buf;
+const char *score, *n_name;
{
short i = 15, j;
@@ -566,7 +568,7 @@ char *buf, *score, *n_name;
center(row, buf)
short row;
-char *buf;
+const char *buf;
{
short margin;
diff --git a/games/rogue/throw.c b/games/rogue/throw.c
index 0af3117978d3..3a0205d2fb29 100644
--- a/games/rogue/throw.c
+++ b/games/rogue/throw.c
@@ -261,7 +261,7 @@ short row, col;
rand_around(i, r, c)
short i, *r, *c;
{
- static char* pos = "\010\007\001\003\004\005\002\006\0";
+ static char pos[] = "\010\007\001\003\004\005\002\006\0";
static short row, col;
short j;
diff --git a/games/rogue/trap.c b/games/rogue/trap.c
index 518a32132afe..e7fab20794a4 100644
--- a/games/rogue/trap.c
+++ b/games/rogue/trap.c
@@ -56,7 +56,7 @@ trap traps[MAX_TRAPS];
boolean trap_door = 0;
short bear_trap = 0;
-char *trap_strings[TRAPS * 2] = {
+const char *const trap_strings[TRAPS * 2] = {
"trap door",
"you fell down a trap",
"bear trap",
@@ -72,7 +72,7 @@ char *trap_strings[TRAPS * 2] = {
};
extern short cur_level, party_room;
-extern char *new_level_message;
+extern const char *new_level_message;
extern boolean interrupted;
extern short ring_exp;
extern boolean sustain_strength;
diff --git a/games/rogue/use.c b/games/rogue/use.c
index b340fe20eb70..62edc7143e68 100644
--- a/games/rogue/use.c
+++ b/games/rogue/use.c
@@ -61,7 +61,7 @@ boolean see_invisible = 0;
short extra_hp = 0;
boolean detect_monster = 0;
boolean con_mon = 0;
-char *strange_feeling = "you have a strange feeling for a moment, then it passes";
+const char *strange_feeling = "you have a strange feeling for a moment, then it passes";
extern short bear_trap;
extern char hunger_str[];
@@ -580,7 +580,7 @@ go_blind()
mvaddch(rogue.row, rogue.col, rogue.fchar);
}
-char *
+const char *
get_ench_color()
{
if (halluc) {
diff --git a/games/rogue/zap.c b/games/rogue/zap.c
index b82d188252ff..29bbbade5db8 100644
--- a/games/rogue/zap.c
+++ b/games/rogue/zap.c
@@ -275,7 +275,8 @@ bounce(ball, dir, row, col, r)
short ball, dir, row, col, r;
{
short orow, ocol;
- char buf[DCOLS], *s;
+ char buf[DCOLS];
+ const char *s;
short i, ch, new_dir = -1, damage;
static short btime;