]> granicus.if.org Git - nethack/commitdiff
Avoid hard-coded bit twiddling
authorPasi Kallinen <paxed@alt.org>
Sun, 15 Nov 2020 17:56:35 +0000 (19:56 +0200)
committerPasi Kallinen <paxed@alt.org>
Sun, 15 Nov 2020 17:56:35 +0000 (19:56 +0200)
src/sp_lev.c

index cb81076c629f8ae6b84fad0f589e0baa906ac12b..348f023e01aadd2b9ac420c1c4540153bcac9dfb 100755 (executable)
@@ -1025,10 +1025,9 @@ link_doors_rooms()
 static int
 rnddoor()
 {
-    int i = 1 << rn2(5);
+    static int state[] = { D_NODOOR, D_BROKEN, D_ISOPEN, D_CLOSED, D_LOCKED };
 
-    i >>= 1;
-    return i;
+    return state[rn2(SIZE(state))];
 }
 
 /*