changeset 311:28e22fb35989

Fix one more batch of compiler warnings. A few of these were potential bugs.
author John "Elwin" Edwards
date Tue, 04 May 2021 21:03:47 -0400
parents 827441d05b3e
children 029c1f5c5588
files arogue5/monsters.c arogue5/rogue.h arogue5/weapons.c arogue7/monsters.c arogue7/move.c arogue7/rogue.h arogue7/weapons.c srogue/monsters.c srogue/rogue.ext srogue/sticks.c urogue/monsters.c xrogue/monsters.c xrogue/rogue.h xrogue/weapons.c
diffstat 14 files changed, 30 insertions(+), 27 deletions(-) [+]
line wrap: on
line diff
--- a/arogue5/monsters.c	Mon May 03 19:05:37 2021 -0400
+++ b/arogue5/monsters.c	Tue May 04 21:03:47 2021 -0400
@@ -770,12 +770,12 @@
     /*
      * Every time he sees mean monster, it might start chasing him
      */
-    if (on(*tp, ISMEAN)							&& 
+    if ((on(*tp, ISMEAN)						&& 
 	off(*tp, ISHELD)						&& 
 	off(*tp, ISRUN)							&& 
 	rnd(100) > 33							&& 
 	(!is_stealth(&player) || (on(*tp, ISUNIQUE) && rnd(100) > 95))	&&
-	(off(player, ISINVIS) || on(*tp, CANSEE))			||
+	(off(player, ISINVIS) || on(*tp, CANSEE)))			||
 	(trp != NULL && (trp->r_flags & ISTREAS))) {
 	tp->t_dest = &hero;
 	turn_on(*tp, ISRUN);
--- a/arogue5/rogue.h	Mon May 03 19:05:37 2021 -0400
+++ b/arogue5/rogue.h	Tue May 04 21:03:47 2021 -0400
@@ -1046,7 +1046,7 @@
 void    init_stones(void);
 void    init_terrain(void);
 void    init_things(void);
-void    init_weapon(struct object *weap, char type);
+void    init_weapon(struct object *weap, int type);
 char   *inv_name(struct object *obj, bool drop);
 bool    inventory(struct linked_list *list, int type);
 bool    is_current(struct object *obj);
--- a/arogue5/weapons.c	Mon May 03 19:05:37 2021 -0400
+++ b/arogue5/weapons.c	Tue May 04 21:03:47 2021 -0400
@@ -140,7 +140,7 @@
  */
 
 void
-init_weapon(struct object *weap, char type)
+init_weapon(struct object *weap, int type)
 {
 	register struct init_weps *iwp;
 
--- a/arogue7/monsters.c	Mon May 03 19:05:37 2021 -0400
+++ b/arogue7/monsters.c	Tue May 04 21:03:47 2021 -0400
@@ -594,12 +594,12 @@
     /*
      * Every time he sees mean monster, it might start chasing him
      */
-    if (on(*tp, ISMEAN)							&& 
+    if ((on(*tp, ISMEAN)						&& 
 	off(*tp, ISHELD)						&& 
 	off(*tp, ISRUN)							&& 
 	rnd(100) > 33							&& 
 	(!is_stealth(&player) || (on(*tp, ISUNIQUE) && rnd(100) > 50))	&&
-	(off(player, ISINVIS) || on(*tp, CANSEE))			||
+	(off(player, ISINVIS) || on(*tp, CANSEE)))			||
 	(trp != NULL && (trp->r_flags & ISTREAS))) {
 	runto(tp, &hero);
     }
--- a/arogue7/move.c	Mon May 03 19:05:37 2021 -0400
+++ b/arogue7/move.c	Tue May 04 21:03:47 2021 -0400
@@ -132,7 +132,8 @@
 
 		    /* Make sure we were not chasing a monster here */
 		    th->t_dest = &hero;
-		    if (on(*th, ISFRIENDLY), turn_off(*th, ISFLEE));
+		    if (on(*th, ISFRIENDLY))
+			turn_off(*th, ISFLEE);
 		}
 	    }
 	when BEARTRAP:
@@ -406,7 +407,8 @@
 
 		    /* Make sure we were not chasing a monster here */
 		    th->t_dest = &hero;
-		    if (on(*th, ISFRIENDLY), turn_off(*th, ISFLEE));
+		    if (on(*th, ISFRIENDLY))
+			turn_off(*th, ISFLEE);
 	    }
 	    else
 		    killed(mitem, FALSE, FALSE, FALSE);
--- a/arogue7/rogue.h	Mon May 03 19:05:37 2021 -0400
+++ b/arogue7/rogue.h	Tue May 04 21:03:47 2021 -0400
@@ -1249,7 +1249,7 @@
 void    init_stones(void);
 void    init_terrain(void);
 void    init_things(void);
-void    init_weapon(struct object *weap, char type);
+void    init_weapon(struct object *weap, int type);
 char   *inv_name(struct object *obj, bool drop);
 bool    inventory(struct linked_list *list, int type);
 bool    is_current(struct object *obj);
--- a/arogue7/weapons.c	Mon May 03 19:05:37 2021 -0400
+++ b/arogue7/weapons.c	Tue May 04 21:03:47 2021 -0400
@@ -197,7 +197,7 @@
  */
 
 void
-init_weapon(struct object *weap, char type)
+init_weapon(struct object *weap, int type)
 {
 	register struct init_weps *iwp;
 
--- a/srogue/monsters.c	Mon May 03 19:05:37 2021 -0400
+++ b/srogue/monsters.c	Tue May 04 21:03:47 2021 -0400
@@ -24,7 +24,7 @@
  *	Pick a monster to show up.  The lower the level,
  *	the meaner the monster.
  */
-char
+int
 rnd_mon(bool wander, bool baddie)
 {
 	/* baddie; TRUE when from a polymorph stick */
@@ -85,7 +85,7 @@
  *	Pick a new monster and add it to the list
  */
 struct linked_list *
-new_monster(char type, struct coord *cp, bool treas)
+new_monster(int indx, struct coord *cp, bool treas)
 {
 	reg struct linked_list *item;
 	reg struct thing *tp;
@@ -97,9 +97,9 @@
 	attach(mlist, item);
 	tp = THINGPTR(item);
 	st = &tp->t_stats;
-	mp = &monsters[type];		/* point to this monsters structure */
+	mp = &monsters[indx];		/* point to this monsters structure */
 	tp->t_type = mp->m_show;
-	tp->t_indx = type;
+	tp->t_indx = indx;
 	tp->t_pos = *cp;
 	tp->t_room = roomin(cp);
 	tp->t_oldch = mvwinch(cw, cp->y, cp->x) & A_CHARTEXT;
--- a/srogue/rogue.ext	Mon May 03 19:05:37 2021 -0400
+++ b/srogue/rogue.ext	Tue May 04 21:03:47 2021 -0400
@@ -154,7 +154,7 @@
 char   *new(int size);
 struct linked_list *new_item(int size);
 void    new_level(int ltype);
-struct linked_list *new_monster(char type, struct coord *cp, bool treas);
+struct linked_list *new_monster(int indx, struct coord *cp, bool treas);
 struct linked_list *new_thing(bool treas, int type, int which);
 void    nohaste(int fromfuse);
 void    noteth(int fromfuse);
@@ -193,7 +193,7 @@
 void    ringabil(void);
 int     ringex(int rtype);
 int     rnd(int range);
-char    rnd_mon(bool wander, bool baddie);
+int     rnd_mon(bool wander, bool baddie);
 struct coord *rnd_pos(struct room *rp);
 int     rnd_room(void);
 struct coord *rndmove(struct thing *who);
--- a/srogue/sticks.c	Mon May 03 19:05:37 2021 -0400
+++ b/srogue/sticks.c	Tue May 04 21:03:47 2021 -0400
@@ -230,19 +230,20 @@
 			tp = THINGPTR(item);
 			omonst = tp->t_indx;
 			if (wh == WS_POLYM && !curse) {
+				int newmonst;
 				detach(mlist, item);
 				discard(item);
 				oldch = tp->t_oldch;
 				delta.y = y;
 				delta.x = x;
-				monster = rnd_mon(FALSE, TRUE);
-				item = new_monster(monster, &delta, FALSE);
+				newmonst = rnd_mon(FALSE, TRUE);
+				item = new_monster(newmonst, &delta, FALSE);
 				if (!(tp->t_flags & ISRUN))
 					runto(&delta, &hero);
 				if (isalpha(mvwinch(cw, y, x)))
-					mvwaddch(cw, y, x, monsters[monster].m_show);
+					mvwaddch(cw, y, x, monsters[newmonst].m_show);
 				tp->t_oldch = oldch;
-				ws_know[WS_POLYM] |= (monster != omonst);
+				ws_know[WS_POLYM] |= (newmonst != omonst);
 			}
 			else if (wh == WS_MINVIS && !bless) {
 				tp->t_flags |= ISINVIS;
--- a/urogue/monsters.c	Mon May 03 19:05:37 2021 -0400
+++ b/urogue/monsters.c	Tue May 04 21:03:47 2021 -0400
@@ -955,9 +955,9 @@
      */
 
     if (off(player, CANTRUESEE) &&
-        on(*tp, ISINWALL) || on(*tp, CANSURPRISE) ||
-        (on(*tp, ISSHADOW) && rnd(100) < 80) ||
-        (on(*tp, ISINVIS) && off(player, CANSEE)))
+        (on(*tp, ISINWALL) || on(*tp, CANSURPRISE) ||
+         (on(*tp, ISSHADOW) && rnd(100) < 80) ||
+         (on(*tp, ISINVIS) && off(player, CANSEE))))
 	{
 	    /* 
 	    TODO: incomplete - need to finish logic
--- a/xrogue/monsters.c	Mon May 03 19:05:37 2021 -0400
+++ b/xrogue/monsters.c	Tue May 04 21:03:47 2021 -0400
@@ -630,12 +630,12 @@
     /*
      * Every time he sees mean monster, it might start chasing him
      */
-    if (on(*tp, ISMEAN)  && 
+    if ((on(*tp, ISMEAN) && 
         off(*tp, ISHELD) && 
         off(*tp, ISRUN)  && 
         rnd(100) > 35    && 
         (!is_stealth(&player) || (on(*tp, ISUNIQUE) && rnd(100) > 35)) &&
-        (off(player, ISINVIS) || on(*tp, CANSEE)) ||
+        (off(player, ISINVIS) || on(*tp, CANSEE))) ||
         (trp != NULL && (trp->r_flags & ISTREAS))) {
         runto(tp, &hero);
     }
--- a/xrogue/rogue.h	Mon May 03 19:05:37 2021 -0400
+++ b/xrogue/rogue.h	Tue May 04 21:03:47 2021 -0400
@@ -1347,7 +1347,7 @@
 void    init_stones(void);
 void    init_terrain(void);
 void    init_things(void);
-void    init_weapon(struct object *weap, char type);
+void    init_weapon(struct object *weap, int type);
 char   *inv_name(struct object *obj, bool drop);
 bool    inventory(struct linked_list *list, int type);
 bool    invisible(struct thing *monst);
--- a/xrogue/weapons.c	Mon May 03 19:05:37 2021 -0400
+++ b/xrogue/weapons.c	Tue May 04 21:03:47 2021 -0400
@@ -198,7 +198,7 @@
  */
 
 void
-init_weapon(struct object *weap, char type)
+init_weapon(struct object *weap, int type)
 {
         register struct init_weps *iwp;