wiz_intrinsic(void)
{
if (wizard) {
- extern const struct propname {
- int prop_num;
- const char *prop_name;
- } propertynames[]; /* timeout.c */
static const char wizintrinsic[] = "#wizintrinsic";
static const char fmt[] = "You are%s %s.";
winid win;
anything any;
char buf[BUFSZ];
- int i, j, n, p, amt, typ;
+ int i, j, n, amt, typ, p = 0;
long oldtimeout, newtimeout;
const char *propname;
menu_item *pick_list = (menu_item *) 0;
add_menu(win, &nul_glyphinfo, &any, 0, 0, ATR_NONE, clr, buf,
MENU_ITEMFLAGS_NONE);
}
- for (i = 0; (propname = propertynames[i].prop_name) != 0; ++i) {
- p = propertynames[i].prop_num;
+ for (i = 0; (propname = property_by_index(i, &p)) != 0; ++i) {
if (p == HALLUC_RES) {
/* Grayswandir vs hallucination; ought to be redone to
use u.uprops[HALLUC].blocked instead of being treated
for (j = 0; j < n; ++j) {
i = pick_list[j].item.a_int - 1; /* -1: reverse +1 above */
- p = propertynames[i].prop_num;
+ propname = property_by_index(i, &p);
oldtimeout = u.uprops[p].intrinsic & TIMEOUT;
amt = (pick_list[j].count == -1L) ? DEFAULT_TIMEOUT_INCR
: (int) pick_list[j].count;
if (p != GLIB)
incr_itimeout(&u.uprops[p].intrinsic, amt);
g.context.botl = 1; /* have pline() do a status update */
- pline("Timeout for %s %s %d.", propertynames[i].prop_name,
+ pline("Timeout for %s %s %d.", propname,
oldtimeout ? "increased by" : "set to", amt);
break;
}
/* used by wizard mode #timeout and #wizintrinsic; order by 'interest'
for timeout countdown, where most won't occur in normal play */
-const struct propname {
+static const struct propname {
int prop_num;
const char *prop_name;
} propertynames[] = {
{ 0, 0 },
};
+const char *
+property_by_index(int idx, int *propertynum)
+{
+ if (!(idx >= 0 && idx < SIZE(propertynames) - 1))
+ idx = SIZE(propertynames) - 1;
+
+ if (propertynum)
+ *propertynum = propertynames[idx].prop_num;
+ return propertynames[idx].prop_name;
+}
+
/* He is being petrified - dialogue by inmet!tower */
static NEARDATA const char *const stoned_texts[] = {
"You are slowing down.", /* 5 */