]> granicus.if.org Git - nethack/commitdiff
Qt c++ function name shadow warnings
authornhmall <nhmall@nethack.org>
Wed, 3 Feb 2021 15:55:07 +0000 (10:55 -0500)
committernhmall <nhmall@nethack.org>
Wed, 3 Feb 2021 15:55:07 +0000 (10:55 -0500)
We have a struct called mkroom and a function called mkroom()
so c++ complains about the mkroom() function hiding the
initializer for the struct.

Similarly, we have a struct called attack and a function
called attack().

There may be a more elegant way of eliminating those two
warnings, but renaming mkroom() to do_mkroom() and
attack() to do_attack() was straightforward enough.

include/extern.h
src/apply.c
src/dig.c
src/hack.c
src/mhitm.c
src/mklev.c
src/mkroom.c
src/uhitm.c

index ff3b7450314fd790caa71d1d33d3502a9e1876d7..290eedf7ea234f436442cc0b4b5c53d9e54de8a1 100644 (file)
@@ -1347,7 +1347,7 @@ extern struct obj *init_dummyobj(struct obj *, short, long);
 
 /* ### mkroom.c ### */
 
-extern void mkroom(int);
+extern void do_mkroom(int);
 extern void fill_zoo(struct mkroom *);
 extern struct permonst *antholemon(void);
 extern boolean nexttodoor(int, int);
@@ -2630,7 +2630,7 @@ extern void erode_armor(struct monst *, int);
 extern boolean attack_checks(struct monst *, struct obj *);
 extern void check_caitiff(struct monst *);
 extern int find_roll_to_hit(struct monst *, uchar, struct obj *, int *, int *);
-extern boolean attack(struct monst *);
+extern boolean do_attack(struct monst *);
 extern boolean hmon(struct monst *, struct obj *, int, int);
 extern boolean shade_miss(struct monst *, struct monst *, struct obj *,
                           boolean, boolean);
index a82d4aa159a8ba536a7d2dceceacfa68c21c6e22..495fc00a47743cafae9876ce4a689d130605700c 100644 (file)
@@ -2732,7 +2732,7 @@ use_whip(struct obj *obj)
     if (proficient < 0)
         proficient = 0;
 
-    if (u.uswallow && attack(u.ustuck)) {
+    if (u.uswallow && do_attack(u.ustuck)) {
         There("is not enough room to flick your bullwhip.");
 
     } else if (Underwater) {
@@ -2806,7 +2806,7 @@ use_whip(struct obj *obj)
             if (bigmonst(mtmp->data)) {
                 wrapped_what = strcpy(buf, mon_nam(mtmp));
             } else if (proficient) {
-                if (attack(mtmp))
+                if (do_attack(mtmp))
                     return 1;
                 else
                     pline1(msg_snap);
@@ -2936,7 +2936,7 @@ use_whip(struct obj *obj)
             else
                 You("flick your bullwhip towards %s.", mon_nam(mtmp));
             if (proficient) {
-                if (attack(mtmp))
+                if (do_attack(mtmp))
                     return 1;
                 else
                     pline1(msg_snap);
index 63f51b5a48e8f3350a2756f3d0cb6532ffe223b0..71034427953903e0ed1bd071d1062a69efc5539d 100644 (file)
--- a/src/dig.c
+++ b/src/dig.c
@@ -1029,7 +1029,7 @@ use_pick_axe2(struct obj *obj)
     boolean ispick = is_pick(obj);
     const char *verbing = ispick ? "digging" : "chopping";
 
-    if (u.uswallow && attack(u.ustuck)) {
+    if (u.uswallow && do_attack(u.ustuck)) {
         ; /* return 1 */
     } else if (Underwater) {
         pline("Turbulence torpedoes your %s attempts.", verbing);
@@ -1060,7 +1060,7 @@ use_pick_axe2(struct obj *obj)
             return 1;
         }
         lev = &levl[rx][ry];
-        if (MON_AT(rx, ry) && attack(m_at(rx, ry)))
+        if (MON_AT(rx, ry) && do_attack(m_at(rx, ry)))
             return 1;
         dig_target = dig_typ(obj, rx, ry);
         if (dig_target == DIGTYP_UNDIGGABLE) {
index 554027b65e9c71f582853c2ae4afdb1c1b2a6af8..abf492d89a5ff84c8b5c97bb2f44de28b300995f 100644 (file)
@@ -1612,22 +1612,22 @@ domove_core(void)
     /* attack monster */
     if (mtmp) {
         /* don't stop travel when displacing pets; if the
-           displace fails for some reason, attack() in uhitm.c
+           displace fails for some reason, do_attack() in uhitm.c
            will stop travel rather than domove */
         if (!is_safemon(mtmp) || g.context.forcefight)
             nomul(0);
         /* only attack if we know it's there */
         /* or if we used the 'F' command to fight blindly */
-        /* or if it hides_under, in which case we call attack() to print
+        /* or if it hides_under, in which case we call do_attack() to print
          * the Wait! message.
          * This is different from ceiling hiders, who aren't handled in
-         * attack().
+         * do_attack().
          */
 
         /* If they used a 'm' command, trying to move onto a monster
          * prints the below message and wastes a turn.  The exception is
          * if the monster is unseen and the player doesn't remember an
-         * invisible monster--then, we fall through to attack() and
+         * invisible monster--then, we fall through to do_attack() and
          * attack_check(), which still wastes a turn, but prints a
          * different message and makes the player remember the monster.
          */
@@ -1663,7 +1663,7 @@ domove_core(void)
 
             /* try to attack; note that it might evade;
                also, we don't attack tame when _safepet_ */
-            else if (attack(mtmp))
+            else if (do_attack(mtmp))
                 return;
         }
     }
@@ -1826,7 +1826,7 @@ domove_core(void)
 
     /*
      * If safepet at destination then move the pet to the hero's
-     * previous location using the same conditions as in attack().
+     * previous location using the same conditions as in do_attack().
      * there are special extenuating circumstances:
      * (1) if the pet dies then your god angers,
      * (2) if the pet gets trapped then your god may disapprove.
@@ -2062,7 +2062,7 @@ boolean
 overexertion(void)
 {
     /* this used to be part of domove() when moving to a monster's
-       position, but is now called by attack() so that it doesn't
+       position, but is now called by do_attack() so that it doesn't
        execute if you decline to attack a peaceful monster */
     gethungry();
     if ((g.moves % 3L) != 0L && near_capacity() >= HVY_ENCUMBER) {
index e818ad97d4632fedeae2ed3a74d9ffae22ea6042..87d67d038f747b505656e31a5e33b9cea6d7338f 100644 (file)
@@ -197,7 +197,7 @@ mdisplacem(register struct monst *magr, register struct monst *mdef,
     if (m_at(fx, fy) != magr || m_at(tx, ty) != mdef)
         return MM_MISS;
 
-    /* The 1 in 7 failure below matches the chance in attack()
+    /* The 1 in 7 failure below matches the chance in do_attack()
      * for pet displacement.
      */
     if (!rn2(7))
index 7061fae22af0cf98ff400d02b4173c7614ac2b01..a3d53cdff0cb78daf5493030944af4f31ba5a097 100644 (file)
@@ -923,34 +923,34 @@ makelevel(void)
          * note that mkroom doesn't guarantee a room gets created, and that this
          * step only sets the room's rtype - it doesn't fill it yet. */
         if (wizard && nh_getenv("SHOPTYPE"))
-            mkroom(SHOPBASE);
+            do_mkroom(SHOPBASE);
         else if (u_depth > 1 && u_depth < depth(&medusa_level)
                  && g.nroom >= room_threshold && rn2(u_depth) < 3)
-            mkroom(SHOPBASE);
+            do_mkroom(SHOPBASE);
         else if (u_depth > 4 && !rn2(6))
-            mkroom(COURT);
+            do_mkroom(COURT);
         else if (u_depth > 5 && !rn2(8)
                  && !(g.mvitals[PM_LEPRECHAUN].mvflags & G_GONE))
-            mkroom(LEPREHALL);
+            do_mkroom(LEPREHALL);
         else if (u_depth > 6 && !rn2(7))
-            mkroom(ZOO);
+            do_mkroom(ZOO);
         else if (u_depth > 8 && !rn2(5))
-            mkroom(TEMPLE);
+            do_mkroom(TEMPLE);
         else if (u_depth > 9 && !rn2(5)
                  && !(g.mvitals[PM_KILLER_BEE].mvflags & G_GONE))
-            mkroom(BEEHIVE);
+            do_mkroom(BEEHIVE);
         else if (u_depth > 11 && !rn2(6))
-            mkroom(MORGUE);
+            do_mkroom(MORGUE);
         else if (u_depth > 12 && !rn2(8) && antholemon())
-            mkroom(ANTHOLE);
+            do_mkroom(ANTHOLE);
         else if (u_depth > 14 && !rn2(4)
                  && !(g.mvitals[PM_SOLDIER].mvflags & G_GONE))
-            mkroom(BARRACKS);
+            do_mkroom(BARRACKS);
         else if (u_depth > 15 && !rn2(6))
-            mkroom(SWAMP);
+            do_mkroom(SWAMP);
         else if (u_depth > 16 && !rn2(8)
                  && !(g.mvitals[PM_COCKATRICE].mvflags & G_GONE))
-            mkroom(COCKNEST);
+            do_mkroom(COCKNEST);
 
  skip0:
         /* Place multi-dungeon branch. */
index f2e613e9e79ddb973f71418dac8eb548559486a4..fdbb55513f71ed89553bf6486472ee670b6bf347 100644 (file)
@@ -5,7 +5,7 @@
 
 /*
  * Entry points:
- *      mkroom() -- make and stock a room of a given type
+ *      do_mkroom() -- make and stock a room of a given type
  *      nexttodoor() -- return TRUE if adjacent to a door
  *      has_dnstairs() -- return TRUE if given room has a down staircase
  *      has_upstairs() -- return TRUE if given room has an up staircase
@@ -43,7 +43,7 @@ isbig(struct mkroom* sroom)
 
 /* make and stock a room of a given type */
 void
-mkroom(int roomtype)
+do_mkroom(int roomtype)
 {
     if (roomtype >= SHOPBASE)
         mkshop(); /* someday, we should be able to specify shop type */
index 756929f24d55be4bc96ad2f781f585be057d3747..f644735c39ba514c158387ac6ab26edbb30bd923 100644 (file)
@@ -93,7 +93,7 @@ erode_armor(struct monst *mdef, int hurt)
 /* FALSE means it's OK to attack */
 boolean
 attack_checks(struct monst *mtmp,
-              struct obj *wep) /* uwep for attack(), null for kick_monster() */
+              struct obj *wep) /* uwep for do_attack(), null for kick_monster() */
 {
     int glyph;
 
@@ -319,7 +319,7 @@ find_roll_to_hit(struct monst *mtmp,
 /* try to attack; return False if monster evaded;
    u.dx and u.dy must be set */
 boolean
-attack(struct monst *mtmp)
+do_attack(struct monst *mtmp)
 {
     register struct permonst *mdat = mtmp->data;
 
@@ -571,7 +571,8 @@ hitum_cleave(struct monst *target, /* non-Null; forcefight at nothing doesn't
                                &attknum, &armorpenalty);
         dieroll = rnd(20);
         mhit = (tmp > dieroll);
-        g.bhitpos.x = tx, g.bhitpos.y = ty; /* normally set up by attack() */
+        g.bhitpos.x = tx, g.bhitpos.y = ty; /* normally set up by
+                                              do_attack() */
         (void) known_hitum(mtmp, uwep, &mhit, tmp, armorpenalty,
                            uattk, dieroll);
         (void) passive(mtmp, uwep, mhit, !DEADMONSTER(mtmp), AT_WEAP, !uwep);