From: Pasi Kallinen Date: Sun, 9 Feb 2020 12:30:11 +0000 (+0200) Subject: Unify lua setting wallprop X-Git-Tag: NetHack-3.7.0_WIP-2020-02-14~33 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e182ff428b328ff13f6c8bd90b0151d63ac034e1;p=nethack Unify lua setting wallprop --- diff --git a/src/sp_lev.c b/src/sp_lev.c index efe71d17b..7317130d6 100644 --- a/src/sp_lev.c +++ b/src/sp_lev.c @@ -92,6 +92,7 @@ static void FDECL(sel_set_feature, (int, int, genericptr_t)); static int FDECL(get_coord, (lua_State *, int, int *, int *)); static int FDECL(get_table_region, (lua_State *, const char *, int *, int *, int *, int *, BOOLEAN_P)); +static void FDECL(set_wallprop_in_selection, (lua_State *, int)); /* lua_CFunction prototypes */ int FDECL(lspo_altar, (lua_State *)); @@ -5169,13 +5170,11 @@ lua_State *L; return 0; } -/* non_diggable(selection); */ -/* non_diggable(); */ -int -lspo_non_diggable(L) +static void +set_wallprop_in_selection(L, prop) lua_State *L; +int prop; { - int prop = W_NONDIGGABLE; int argc = lua_gettop(L); boolean freesel = FALSE; struct selectionvar *sel = (struct selectionvar *) 0; @@ -5197,7 +5196,15 @@ lua_State *L; free(sel); } } +} +/* non_diggable(selection); */ +/* non_diggable(); */ +int +lspo_non_diggable(L) +lua_State *L; +{ + set_wallprop_in_selection(L, W_NONDIGGABLE); return 0; } @@ -5207,29 +5214,7 @@ int lspo_non_passwall(L) lua_State *L; { - int prop = W_NONPASSWALL; - int argc = lua_gettop(L); - boolean freesel = FALSE; - struct selectionvar *sel = (struct selectionvar *) 0; - - create_des_coder(); - - if (argc == 1) - sel = l_selection_check(L, -1); - else if (argc == 0) { - freesel = TRUE; - sel = selection_new(); - selection_not(sel); - } - - if (sel) { - selection_iterate(sel, sel_set_wall_property, (genericptr_t) &prop); - if (freesel) { - selection_free(sel); - free(sel); - } - } - + set_wallprop_in_selection(L, W_NONPASSWALL); return 0; }