Qt c++ function name shadow warnings

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.
This commit is contained in:
nhmall
2021-02-03 10:55:07 -05:00
parent 24c829ecf7
commit 7900632b50
8 changed files with 33 additions and 32 deletions
+2 -2
View File
@@ -1347,7 +1347,7 @@ extern struct obj *init_dummyobj(struct obj *, short, long);
/* ### mkroom.c ### */ /* ### mkroom.c ### */
extern void mkroom(int); extern void do_mkroom(int);
extern void fill_zoo(struct mkroom *); extern void fill_zoo(struct mkroom *);
extern struct permonst *antholemon(void); extern struct permonst *antholemon(void);
extern boolean nexttodoor(int, int); 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 boolean attack_checks(struct monst *, struct obj *);
extern void check_caitiff(struct monst *); extern void check_caitiff(struct monst *);
extern int find_roll_to_hit(struct monst *, uchar, struct obj *, int *, int *); 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 hmon(struct monst *, struct obj *, int, int);
extern boolean shade_miss(struct monst *, struct monst *, struct obj *, extern boolean shade_miss(struct monst *, struct monst *, struct obj *,
boolean, boolean); boolean, boolean);
+3 -3
View File
@@ -2732,7 +2732,7 @@ use_whip(struct obj *obj)
if (proficient < 0) if (proficient < 0)
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."); There("is not enough room to flick your bullwhip.");
} else if (Underwater) { } else if (Underwater) {
@@ -2806,7 +2806,7 @@ use_whip(struct obj *obj)
if (bigmonst(mtmp->data)) { if (bigmonst(mtmp->data)) {
wrapped_what = strcpy(buf, mon_nam(mtmp)); wrapped_what = strcpy(buf, mon_nam(mtmp));
} else if (proficient) { } else if (proficient) {
if (attack(mtmp)) if (do_attack(mtmp))
return 1; return 1;
else else
pline1(msg_snap); pline1(msg_snap);
@@ -2936,7 +2936,7 @@ use_whip(struct obj *obj)
else else
You("flick your bullwhip towards %s.", mon_nam(mtmp)); You("flick your bullwhip towards %s.", mon_nam(mtmp));
if (proficient) { if (proficient) {
if (attack(mtmp)) if (do_attack(mtmp))
return 1; return 1;
else else
pline1(msg_snap); pline1(msg_snap);
+2 -2
View File
@@ -1029,7 +1029,7 @@ use_pick_axe2(struct obj *obj)
boolean ispick = is_pick(obj); boolean ispick = is_pick(obj);
const char *verbing = ispick ? "digging" : "chopping"; const char *verbing = ispick ? "digging" : "chopping";
if (u.uswallow && attack(u.ustuck)) { if (u.uswallow && do_attack(u.ustuck)) {
; /* return 1 */ ; /* return 1 */
} else if (Underwater) { } else if (Underwater) {
pline("Turbulence torpedoes your %s attempts.", verbing); pline("Turbulence torpedoes your %s attempts.", verbing);
@@ -1060,7 +1060,7 @@ use_pick_axe2(struct obj *obj)
return 1; return 1;
} }
lev = &levl[rx][ry]; 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; return 1;
dig_target = dig_typ(obj, rx, ry); dig_target = dig_typ(obj, rx, ry);
if (dig_target == DIGTYP_UNDIGGABLE) { if (dig_target == DIGTYP_UNDIGGABLE) {
+7 -7
View File
@@ -1612,22 +1612,22 @@ domove_core(void)
/* attack monster */ /* attack monster */
if (mtmp) { if (mtmp) {
/* don't stop travel when displacing pets; if the /* 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 */ will stop travel rather than domove */
if (!is_safemon(mtmp) || g.context.forcefight) if (!is_safemon(mtmp) || g.context.forcefight)
nomul(0); nomul(0);
/* only attack if we know it's there */ /* only attack if we know it's there */
/* or if we used the 'F' command to fight blindly */ /* 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. * the Wait! message.
* This is different from ceiling hiders, who aren't handled in * 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 /* If they used a 'm' command, trying to move onto a monster
* prints the below message and wastes a turn. The exception is * prints the below message and wastes a turn. The exception is
* if the monster is unseen and the player doesn't remember an * 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 * attack_check(), which still wastes a turn, but prints a
* different message and makes the player remember the monster. * different message and makes the player remember the monster.
*/ */
@@ -1663,7 +1663,7 @@ domove_core(void)
/* try to attack; note that it might evade; /* try to attack; note that it might evade;
also, we don't attack tame when _safepet_ */ also, we don't attack tame when _safepet_ */
else if (attack(mtmp)) else if (do_attack(mtmp))
return; return;
} }
} }
@@ -1826,7 +1826,7 @@ domove_core(void)
/* /*
* If safepet at destination then move the pet to the hero's * 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: * there are special extenuating circumstances:
* (1) if the pet dies then your god angers, * (1) if the pet dies then your god angers,
* (2) if the pet gets trapped then your god may disapprove. * (2) if the pet gets trapped then your god may disapprove.
@@ -2062,7 +2062,7 @@ boolean
overexertion(void) overexertion(void)
{ {
/* this used to be part of domove() when moving to a monster's /* 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 */ execute if you decline to attack a peaceful monster */
gethungry(); gethungry();
if ((g.moves % 3L) != 0L && near_capacity() >= HVY_ENCUMBER) { if ((g.moves % 3L) != 0L && near_capacity() >= HVY_ENCUMBER) {
+1 -1
View 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) if (m_at(fx, fy) != magr || m_at(tx, ty) != mdef)
return MM_MISS; 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. * for pet displacement.
*/ */
if (!rn2(7)) if (!rn2(7))
+12 -12
View File
@@ -923,34 +923,34 @@ makelevel(void)
* note that mkroom doesn't guarantee a room gets created, and that this * 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. */ * step only sets the room's rtype - it doesn't fill it yet. */
if (wizard && nh_getenv("SHOPTYPE")) if (wizard && nh_getenv("SHOPTYPE"))
mkroom(SHOPBASE); do_mkroom(SHOPBASE);
else if (u_depth > 1 && u_depth < depth(&medusa_level) else if (u_depth > 1 && u_depth < depth(&medusa_level)
&& g.nroom >= room_threshold && rn2(u_depth) < 3) && g.nroom >= room_threshold && rn2(u_depth) < 3)
mkroom(SHOPBASE); do_mkroom(SHOPBASE);
else if (u_depth > 4 && !rn2(6)) else if (u_depth > 4 && !rn2(6))
mkroom(COURT); do_mkroom(COURT);
else if (u_depth > 5 && !rn2(8) else if (u_depth > 5 && !rn2(8)
&& !(g.mvitals[PM_LEPRECHAUN].mvflags & G_GONE)) && !(g.mvitals[PM_LEPRECHAUN].mvflags & G_GONE))
mkroom(LEPREHALL); do_mkroom(LEPREHALL);
else if (u_depth > 6 && !rn2(7)) else if (u_depth > 6 && !rn2(7))
mkroom(ZOO); do_mkroom(ZOO);
else if (u_depth > 8 && !rn2(5)) else if (u_depth > 8 && !rn2(5))
mkroom(TEMPLE); do_mkroom(TEMPLE);
else if (u_depth > 9 && !rn2(5) else if (u_depth > 9 && !rn2(5)
&& !(g.mvitals[PM_KILLER_BEE].mvflags & G_GONE)) && !(g.mvitals[PM_KILLER_BEE].mvflags & G_GONE))
mkroom(BEEHIVE); do_mkroom(BEEHIVE);
else if (u_depth > 11 && !rn2(6)) else if (u_depth > 11 && !rn2(6))
mkroom(MORGUE); do_mkroom(MORGUE);
else if (u_depth > 12 && !rn2(8) && antholemon()) else if (u_depth > 12 && !rn2(8) && antholemon())
mkroom(ANTHOLE); do_mkroom(ANTHOLE);
else if (u_depth > 14 && !rn2(4) else if (u_depth > 14 && !rn2(4)
&& !(g.mvitals[PM_SOLDIER].mvflags & G_GONE)) && !(g.mvitals[PM_SOLDIER].mvflags & G_GONE))
mkroom(BARRACKS); do_mkroom(BARRACKS);
else if (u_depth > 15 && !rn2(6)) else if (u_depth > 15 && !rn2(6))
mkroom(SWAMP); do_mkroom(SWAMP);
else if (u_depth > 16 && !rn2(8) else if (u_depth > 16 && !rn2(8)
&& !(g.mvitals[PM_COCKATRICE].mvflags & G_GONE)) && !(g.mvitals[PM_COCKATRICE].mvflags & G_GONE))
mkroom(COCKNEST); do_mkroom(COCKNEST);
skip0: skip0:
/* Place multi-dungeon branch. */ /* Place multi-dungeon branch. */
+2 -2
View File
@@ -5,7 +5,7 @@
/* /*
* Entry points: * 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 * nexttodoor() -- return TRUE if adjacent to a door
* has_dnstairs() -- return TRUE if given room has a down staircase * has_dnstairs() -- return TRUE if given room has a down staircase
* has_upstairs() -- return TRUE if given room has an up 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 */ /* make and stock a room of a given type */
void void
mkroom(int roomtype) do_mkroom(int roomtype)
{ {
if (roomtype >= SHOPBASE) if (roomtype >= SHOPBASE)
mkshop(); /* someday, we should be able to specify shop type */ mkshop(); /* someday, we should be able to specify shop type */
+4 -3
View File
@@ -93,7 +93,7 @@ erode_armor(struct monst *mdef, int hurt)
/* FALSE means it's OK to attack */ /* FALSE means it's OK to attack */
boolean boolean
attack_checks(struct monst *mtmp, 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; int glyph;
@@ -319,7 +319,7 @@ find_roll_to_hit(struct monst *mtmp,
/* try to attack; return False if monster evaded; /* try to attack; return False if monster evaded;
u.dx and u.dy must be set */ u.dx and u.dy must be set */
boolean boolean
attack(struct monst *mtmp) do_attack(struct monst *mtmp)
{ {
register struct permonst *mdat = mtmp->data; register struct permonst *mdat = mtmp->data;
@@ -571,7 +571,8 @@ hitum_cleave(struct monst *target, /* non-Null; forcefight at nothing doesn't
&attknum, &armorpenalty); &attknum, &armorpenalty);
dieroll = rnd(20); dieroll = rnd(20);
mhit = (tmp > dieroll); 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, (void) known_hitum(mtmp, uwep, &mhit, tmp, armorpenalty,
uattk, dieroll); uattk, dieroll);
(void) passive(mtmp, uwep, mhit, !DEADMONSTER(mtmp), AT_WEAP, !uwep); (void) passive(mtmp, uwep, mhit, !DEADMONSTER(mtmp), AT_WEAP, !uwep);