From: Pasi Kallinen Date: Sun, 15 Nov 2020 17:56:35 +0000 (+0200) Subject: Avoid hard-coded bit twiddling X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ccb5bc4b55343f0f5e5f5a4a3bcba9b8afbae02c;p=nethack Avoid hard-coded bit twiddling --- diff --git a/src/sp_lev.c b/src/sp_lev.c index cb81076c6..348f023e0 100755 --- a/src/sp_lev.c +++ b/src/sp_lev.c @@ -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))]; } /*