revise m_at()

Get rid of some unnecessary code when ignoring unimplemented buried
monsters.  A smart compiler probably optimizes away the useless bits
even when not explicitly optimizing but a dumb one isn't likely to.

m_at(x,y) was
|  (levl.monsters[x][y] != 0
|   && (levl.monsters[x][y] ? levl.monsters[x][y] : 0))
when
|  levl.monsters[x][y]
accomplishes the same thing.
This commit is contained in:
PatR
2023-05-14 03:03:04 -07:00
parent 1851c7ca88
commit 910868cba8

View File

@@ -1,4 +1,4 @@
/* NetHack 3.7 rm.h $NHDT-Date: 1657918091 2022/07/15 20:48:11 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.96 $ */
/* NetHack 3.7 rm.h $NHDT-Date: 1684058570 2023/05/14 10:02:50 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.107 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Pasi Kallinen, 2017. */
/* NetHack may be freely redistributed. See license for details. */
@@ -438,14 +438,19 @@ typedef struct {
* Macros for encapsulation of level.monsters references.
*/
#if 0
/* these wouldn't allow buried monster and surface monster at same location */
#define MON_AT(x, y) \
(gl.level.monsters[x][y] != (struct monst *) 0 \
&& !(gl.level.monsters[x][y])->mburied)
(gl.level.monsters[x][y] && !gl.level.monsters[x][y]->mburied)
#define MON_BURIED_AT(x, y) \
(gl.level.monsters[x][y] != (struct monst *) 0 \
&& (gl.level.monsters[x][y])->mburied)
(gl.level.monsters[x][y] && gl.level.monsters[x][y]->mburied)
#define m_at(x, y) \
(MON_AT(x, y) ? gl.level.monsters[x][y] : (struct monst *) 0)
#define m_buried_at(x, y) \
(MON_BURIED_AT(x, y) ? gl.level.monsters[x][y] : (struct monst *) 0)
#else /* without 'mburied' */
#define MON_AT(x, y) (gl.level.monsters[x][y] != (struct monst *) 0)
#define m_at(x, y) (gl.level.monsters[x][y])
#define m_buried_at(x, y) ((struct monst *) 0)
#endif
#ifdef EXTRA_SANITY_CHECKS
#define place_worm_seg(m, x, y) \
@@ -464,9 +469,6 @@ typedef struct {
#define place_worm_seg(m, x, y) gl.level.monsters[x][y] = m
#define remove_monster(x, y) gl.level.monsters[x][y] = (struct monst *) 0
#endif
#define m_at(x, y) (MON_AT(x, y) ? gl.level.monsters[x][y] : (struct monst *) 0)
#define m_buried_at(x, y) \
(MON_BURIED_AT(x, y) ? gl.level.monsters[x][y] : (struct monst *) 0)
/* restricted movement, potential luck penalties */
#define Sokoban gl.level.flags.sokoban_rules