]> granicus.if.org Git - nethack/commitdiff
Oselect() for monster's weapon
authorPatR <rankin@nethack.org>
Tue, 17 Aug 2021 23:31:14 +0000 (16:31 -0700)
committerPatR <rankin@nethack.org>
Tue, 17 Aug 2021 23:31:14 +0000 (16:31 -0700)
Make the Oselect() macro less likely to accidentally interfere with
caller's if-then-else usage.

src/weapon.c

index 62539aafa850db7d4cc73605c83e52975cf957de..0be11a51c7d687f2ec1eea2f5c0463e3c286deed 100644 (file)
@@ -1,4 +1,4 @@
-/* NetHack 3.7 weapon.c        $NHDT-Date: 1607811730 2020/12/12 22:22:10 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.89 $ */
+/* NetHack 3.7 weapon.c        $NHDT-Date: 1629243070 2021/08/17 23:31:10 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.95 $ */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /*-Copyright (c) Robert Patrick Rankin, 2011. */
 /* NetHack may be freely redistributed.  See license for details. */
@@ -465,9 +465,11 @@ silver_sears(struct monst *magr UNUSED, struct monst *mdef,
 }
 
 static struct obj *oselect(struct monst *, int);
-#define Oselect(x)                      \
-    if ((otmp = oselect(mtmp, x)) != 0) \
-        return otmp;
+#define Oselect(x) \
+    do {                                        \
+        if ((otmp = oselect(mtmp, x)) != 0)     \
+            return otmp;                        \
+    } while (0)
 
 static struct obj *
 oselect(struct monst *mtmp, int x)