robustness of #timeout and #wizintrinsic
Remove the assumption of property index values from the list of property names. Move the properties that can't have timed values in normal play to after those which can. (Mainly only matters for the #wizintrinsic command.) Bug fix: #wizintrinsic variable 'any' wasn't initialized properly if 'a_int' is smaller than a long or a pointer. The separator line I've added was ending up as a menu choice.
This commit is contained in:
@@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
/*** What the properties are ***
|
/*** What the properties are ***
|
||||||
*
|
*
|
||||||
* note: propertynames[] array in timeout.c must be kept in synch with these.
|
* note: propertynames[] array in timeout.c has string values for these.
|
||||||
* Property #0 is not used.
|
* Property #0 is not used.
|
||||||
*/
|
*/
|
||||||
/* Resistances to troubles */
|
/* Resistances to troubles */
|
||||||
|
|||||||
31
src/cmd.c
31
src/cmd.c
@@ -135,6 +135,7 @@ STATIC_PTR int NDECL(wiz_level_change);
|
|||||||
STATIC_PTR int NDECL(wiz_show_seenv);
|
STATIC_PTR int NDECL(wiz_show_seenv);
|
||||||
STATIC_PTR int NDECL(wiz_show_vision);
|
STATIC_PTR int NDECL(wiz_show_vision);
|
||||||
STATIC_PTR int NDECL(wiz_smell);
|
STATIC_PTR int NDECL(wiz_smell);
|
||||||
|
STATIC_PTR int NDECL(wiz_intrinsic);
|
||||||
STATIC_PTR int NDECL(wiz_mon_polycontrol);
|
STATIC_PTR int NDECL(wiz_mon_polycontrol);
|
||||||
STATIC_PTR int NDECL(wiz_show_wmodes);
|
STATIC_PTR int NDECL(wiz_show_wmodes);
|
||||||
STATIC_DCL void NDECL(wiz_map_levltyp);
|
STATIC_DCL void NDECL(wiz_map_levltyp);
|
||||||
@@ -1157,29 +1158,37 @@ STATIC_PTR int
|
|||||||
wiz_intrinsic(VOID_ARGS)
|
wiz_intrinsic(VOID_ARGS)
|
||||||
{
|
{
|
||||||
if (wizard) {
|
if (wizard) {
|
||||||
extern const char *const propertynames[]; /* timeout.c */
|
extern const struct propname {
|
||||||
|
int prop_num;
|
||||||
|
const char *prop_name;
|
||||||
|
} propertynames[]; /* timeout.c */
|
||||||
static const char wizintrinsic[] = "#wizintrinsic";
|
static const char wizintrinsic[] = "#wizintrinsic";
|
||||||
static const char fmt[] = "You are%s %s.";
|
static const char fmt[] = "You are%s %s.";
|
||||||
winid win;
|
winid win;
|
||||||
anything any;
|
anything any;
|
||||||
char buf[BUFSZ];
|
char buf[BUFSZ];
|
||||||
int i, n, p, amt, typ;
|
int i, j, n, p, amt, typ;
|
||||||
long oldtimeout, newtimeout;
|
long oldtimeout, newtimeout;
|
||||||
const char *propname;
|
const char *propname;
|
||||||
menu_item *pick_list = (menu_item *) 0;
|
menu_item *pick_list = (menu_item *) 0;
|
||||||
|
|
||||||
|
any = zeroany;
|
||||||
win = create_nhwindow(NHW_MENU);
|
win = create_nhwindow(NHW_MENU);
|
||||||
start_menu(win);
|
start_menu(win);
|
||||||
|
for (i = 0; (propname = propertynames[i].prop_name) != 0; ++i) {
|
||||||
for (i = 1; (propname = propertynames[i]) != 0; ++i) {
|
p = propertynames[i].prop_num;
|
||||||
if (i == HALLUC_RES) {
|
if (p == HALLUC_RES) {
|
||||||
/* Grayswandir vs hallucination; ought to be redone to
|
/* Grayswandir vs hallucination; ought to be redone to
|
||||||
use u.uprops[HALLUC].blocked instead of being treated
|
use u.uprops[HALLUC].blocked instead of being treated
|
||||||
as a separate property; letting in be manually toggled
|
as a separate property; letting in be manually toggled
|
||||||
even only in wizard mode would be asking for trouble... */
|
even only in wizard mode would be asking for trouble... */
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
any.a_int = i;
|
if (p == FIRE_RES) {
|
||||||
|
any.a_int = 0;
|
||||||
|
add_menu(win, NO_GLYPH, &any, 0, 0, ATR_NONE, "--", FALSE);
|
||||||
|
}
|
||||||
|
any.a_int = i + 1; /* +1: avoid 0 */
|
||||||
add_menu(win, NO_GLYPH, &any, 0, 0, ATR_NONE, propname, FALSE);
|
add_menu(win, NO_GLYPH, &any, 0, 0, ATR_NONE, propname, FALSE);
|
||||||
}
|
}
|
||||||
end_menu(win, "Which intrinsics?");
|
end_menu(win, "Which intrinsics?");
|
||||||
@@ -1187,8 +1196,9 @@ wiz_intrinsic(VOID_ARGS)
|
|||||||
destroy_nhwindow(win);
|
destroy_nhwindow(win);
|
||||||
|
|
||||||
amt = 30; /* TODO: prompt for duration */
|
amt = 30; /* TODO: prompt for duration */
|
||||||
for (i = 0; i < n; ++i) {
|
for (j = 0; j < n; ++j) {
|
||||||
p = pick_list[i].item.a_int;
|
i = pick_list[j].item.a_int - 1; /* -1: reverse +1 above */
|
||||||
|
p = propertynames[i].prop_num;
|
||||||
oldtimeout = u.uprops[p].intrinsic & TIMEOUT;
|
oldtimeout = u.uprops[p].intrinsic & TIMEOUT;
|
||||||
newtimeout = oldtimeout + (long) amt;
|
newtimeout = oldtimeout + (long) amt;
|
||||||
switch (p) {
|
switch (p) {
|
||||||
@@ -1204,9 +1214,12 @@ wiz_intrinsic(VOID_ARGS)
|
|||||||
case BLINDED:
|
case BLINDED:
|
||||||
make_blinded(newtimeout, TRUE);
|
make_blinded(newtimeout, TRUE);
|
||||||
break;
|
break;
|
||||||
|
#if 0 /* make_confused() only gives feedback when confusion is
|
||||||
|
* ending so use the 'default' case for it instead */
|
||||||
case CONFUSION:
|
case CONFUSION:
|
||||||
make_confused(newtimeout, TRUE);
|
make_confused(newtimeout, TRUE);
|
||||||
break;
|
break;
|
||||||
|
#endif /*0*/
|
||||||
case DEAF:
|
case DEAF:
|
||||||
make_deaf(newtimeout, TRUE);
|
make_deaf(newtimeout, TRUE);
|
||||||
break;
|
break;
|
||||||
@@ -1236,7 +1249,7 @@ wiz_intrinsic(VOID_ARGS)
|
|||||||
pline1(buf);
|
pline1(buf);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
pline("Timeout for %s %s %d.", propertynames[p],
|
pline("Timeout for %s %s %d.", propertynames[i].prop_name,
|
||||||
oldtimeout ? "increased by" : "set to", amt);
|
oldtimeout ? "increased by" : "set to", amt);
|
||||||
incr_itimeout(&u.uprops[p].intrinsic, amt);
|
incr_itimeout(&u.uprops[p].intrinsic, amt);
|
||||||
break;
|
break;
|
||||||
|
|||||||
132
src/timeout.c
132
src/timeout.c
@@ -15,43 +15,83 @@ STATIC_DCL void FDECL(see_lamp_flicker, (struct obj *, const char *));
|
|||||||
STATIC_DCL void FDECL(lantern_message, (struct obj *));
|
STATIC_DCL void FDECL(lantern_message, (struct obj *));
|
||||||
STATIC_DCL void FDECL(cleanup_burn, (ANY_P *, long));
|
STATIC_DCL void FDECL(cleanup_burn, (ANY_P *, long));
|
||||||
|
|
||||||
/* the order of these must match their numerical sequence in prop.h
|
/* used by wizard mode #timeout and #wizintrinsic; order by 'interest'
|
||||||
because the property number is inferred from the array index;
|
for timeout countdown, where most won't occur in normal play */
|
||||||
used by wizard mode #timeout and #wizintrinsic */
|
const struct propname {
|
||||||
const char *const propertynames[] = {
|
int prop_num;
|
||||||
"0: not used",
|
const char *prop_name;
|
||||||
/* Resistances */
|
} propertynames[] = {
|
||||||
/* 1..2 */ "fire resistance", "cold resistance",
|
{ INVULNERABLE, "invulnerable" },
|
||||||
/* 3..4 */ "sleep resistance", "disintegration resistance",
|
{ STONED, "petrifying" },
|
||||||
/* 5..6 */ "shock resistance", "poison resistance",
|
{ SLIMED, "becoming slime" },
|
||||||
/* 7..8 */ "acid resistance", "stoning resistance",
|
{ STRANGLED, "strangling" },
|
||||||
/* 9..10 */ "drain resistance", "sickness resistance",
|
{ SICK, "fatally sick" },
|
||||||
/* 11..12 */ "invulnerable", "magic resistance",
|
{ STUNNED, "stunned" },
|
||||||
/* Troubles */
|
{ CONFUSION, "confused" },
|
||||||
/* 13..16 */ "stunned", "confused", "blinded", "deafness",
|
{ HALLUC, "hallucinating" },
|
||||||
/* 17..20 */ "fatally sick", "petrifying", "strangling", "vomiting",
|
{ BLINDED, "blinded" },
|
||||||
/* 21..22 */ "slippery fingers", "becoming slime",
|
{ DEAF, "deafness" },
|
||||||
/* 23..24 */ "hallucinating", "halluicination resistance",
|
{ VOMITING, "vomiting" },
|
||||||
/* 25..28 */ "fumbling", "wounded legs", "sleepy", "voracious hunger",
|
{ GLIB, "slippery fingers" },
|
||||||
/* Vision and senses */
|
{ WOUNDED_LEGS, "wounded legs" },
|
||||||
/* 29..30 */ "see invisible", "telepathic",
|
{ SLEEPY, "sleepy" },
|
||||||
/* 31..33 */ "warning", "warn:monster", "warn:undead",
|
{ TELEPORT, "teleporting" },
|
||||||
/* 34..37 */ "searching", "clairvoyant", "infravision", "monster detection",
|
{ POLYMORPH, "polymorphing" },
|
||||||
/* Appearance and behavior */
|
{ LEVITATION, "levitating" },
|
||||||
/* 38..41 */ "adorned (+/-Cha)", "invisible", "displaced", "stealthy",
|
{ FAST, "very fast" }, /* timed 'FAST' is very fast */
|
||||||
/* 42..43 */ "monster aggrevation", "conflict",
|
{ CLAIRVOYANT, "clairvoyant" },
|
||||||
/* Transportation */
|
{ DETECT_MONSTERS, "monster detection" },
|
||||||
/* 44..46 */ "jumping", "teleporting", "teleport control",
|
{ SEE_INVIS, "see invisible" },
|
||||||
/* 47..49 */ "levitating", "flying", "water walking",
|
{ INVIS, "invisible" },
|
||||||
/* 50..52 */ "swimming", "magical breathing", "pass thru walls",
|
/* properties beyond here don't have timed values during normal play,
|
||||||
/* Physical attributes */
|
so there's no much point in trying to order them sensibly;
|
||||||
/* 53..55 */ "slow digestion", "half spell damage", "half physical damage",
|
they're either on or off based on equipment, role, actions, &c */
|
||||||
/* 56..58 */ "HP regeneration", "energy regeneration", "extra protection",
|
{ FIRE_RES, "fire resistance" },
|
||||||
/* 59 */ "protection from shape changers",
|
{ COLD_RES, "cold resistance" },
|
||||||
/* 60..62 */ "polymorphing", "polymorph control", "unchanging",
|
{ SLEEP_RES, "sleep resistance" },
|
||||||
/* 63..66 */ "fast", "reflecting", "free action", "fixed abilites",
|
{ DISINT_RES, "disintegration resistance" },
|
||||||
/* 67 */ "life will be saved",
|
{ SHOCK_RES, "shock resistance" },
|
||||||
0 /* sentinel */
|
{ POISON_RES, "poison resistance" },
|
||||||
|
{ ACID_RES, "acid resistance" },
|
||||||
|
{ STONE_RES, "stoning resistance" },
|
||||||
|
{ DRAIN_RES, "drain resistance" },
|
||||||
|
{ SICK_RES, "sickness resistance" },
|
||||||
|
{ ANTIMAGIC, "magic resistance" },
|
||||||
|
{ HALLUC_RES, "hallucination resistance" },
|
||||||
|
{ FUMBLING, "fumbling" },
|
||||||
|
{ HUNGER, "voracious hunger" },
|
||||||
|
{ TELEPAT, "telepathic" },
|
||||||
|
{ WARNING, "warning" },
|
||||||
|
{ WARN_OF_MON, "warn: monster type or class" },
|
||||||
|
{ WARN_UNDEAD, "warn: undead" },
|
||||||
|
{ SEARCHING, "searching" },
|
||||||
|
{ INFRAVISION, "infravision" },
|
||||||
|
{ ADORNED, "adorned (+/- Cha)" },
|
||||||
|
{ DISPLACED, "displaced" },
|
||||||
|
{ STEALTH, "stealthy" },
|
||||||
|
{ AGGRAVATE_MONSTER, "monster aggravation" },
|
||||||
|
{ CONFLICT, "conflict" },
|
||||||
|
{ JUMPING, "jumping" },
|
||||||
|
{ TELEPORT_CONTROL, "teleport control" },
|
||||||
|
{ FLYING, "flying" },
|
||||||
|
{ WWALKING, "water walking" },
|
||||||
|
{ SWIMMING, "swimming" },
|
||||||
|
{ MAGICAL_BREATHING, "magical breathing" },
|
||||||
|
{ PASSES_WALLS, "pass thru walls" },
|
||||||
|
{ SLOW_DIGESTION, "slow digestion" },
|
||||||
|
{ HALF_SPDAM, "half spell damage" },
|
||||||
|
{ HALF_PHDAM, "half physical damage" },
|
||||||
|
{ REGENERATION, "HP regeneration" },
|
||||||
|
{ ENERGY_REGENERATION, "energy regeneration" },
|
||||||
|
{ PROTECTION, "extra protection" },
|
||||||
|
{ PROT_FROM_SHAPE_CHANGERS, "protection from shape changers" },
|
||||||
|
{ POLYMORPH_CONTROL, "polymorph control" },
|
||||||
|
{ UNCHANGING, "unchanging" },
|
||||||
|
{ REFLECTING, "reflecting" },
|
||||||
|
{ FREE_ACTION, "free action" },
|
||||||
|
{ FIXED_ABIL, "fixed abilites" },
|
||||||
|
{ LIFESAVED, "life will be saved" },
|
||||||
|
{ 0, 0 },
|
||||||
};
|
};
|
||||||
|
|
||||||
/* He is being petrified - dialogue by inmet!tower */
|
/* He is being petrified - dialogue by inmet!tower */
|
||||||
@@ -1544,7 +1584,7 @@ wiz_timeout_queue()
|
|||||||
char buf[BUFSZ];
|
char buf[BUFSZ];
|
||||||
const char *propname;
|
const char *propname;
|
||||||
long intrinsic;
|
long intrinsic;
|
||||||
int i, count, longestlen, ln;
|
int i, p, count, longestlen, ln, specindx = 0;
|
||||||
|
|
||||||
win = create_nhwindow(NHW_MENU); /* corner text window */
|
win = create_nhwindow(NHW_MENU); /* corner text window */
|
||||||
if (win == WIN_ERR)
|
if (win == WIN_ERR)
|
||||||
@@ -1562,13 +1602,16 @@ wiz_timeout_queue()
|
|||||||
* normal play but those can be forced via the #wizintrinsic command.
|
* normal play but those can be forced via the #wizintrinsic command.
|
||||||
*/
|
*/
|
||||||
count = longestlen = 0;
|
count = longestlen = 0;
|
||||||
for (i = 1; (propname = propertynames[i]) != 0; ++i) { /* [0] not used */
|
for (i = 0; (propname = propertynames[i].prop_name) != 0; ++i) {
|
||||||
intrinsic = u.uprops[i].intrinsic;
|
p = propertynames[i].prop_num;
|
||||||
|
intrinsic = u.uprops[p].intrinsic;
|
||||||
if (intrinsic & TIMEOUT) {
|
if (intrinsic & TIMEOUT) {
|
||||||
++count;
|
++count;
|
||||||
if ((ln = (int) strlen(propname)) > longestlen)
|
if ((ln = (int) strlen(propname)) > longestlen)
|
||||||
longestlen = ln;
|
longestlen = ln;
|
||||||
}
|
}
|
||||||
|
if (specindx == 0 && p == FIRE_RES)
|
||||||
|
specindx = i;
|
||||||
}
|
}
|
||||||
putstr(win, 0, "");
|
putstr(win, 0, "");
|
||||||
if (!count) {
|
if (!count) {
|
||||||
@@ -1576,9 +1619,14 @@ wiz_timeout_queue()
|
|||||||
} else {
|
} else {
|
||||||
putstr(win, 0, "Timed properties:");
|
putstr(win, 0, "Timed properties:");
|
||||||
putstr(win, 0, "");
|
putstr(win, 0, "");
|
||||||
for (i = 1; (propname = propertynames[i]) != 0; ++i) {
|
for (i = 0; (propname = propertynames[i].prop_name) != 0; ++i) {
|
||||||
intrinsic = u.uprops[i].intrinsic;
|
p = propertynames[i].prop_num;
|
||||||
|
intrinsic = u.uprops[p].intrinsic;
|
||||||
if (intrinsic & TIMEOUT) {
|
if (intrinsic & TIMEOUT) {
|
||||||
|
if (specindx > 0 && i >= specindx) {
|
||||||
|
putstr(win, 0, " -- settable via #wizinstrinc only --");
|
||||||
|
specindx = 0;
|
||||||
|
}
|
||||||
/* timeout value can be up to 16777215 (0x00ffffff) but
|
/* timeout value can be up to 16777215 (0x00ffffff) but
|
||||||
width of 4 digits should result in values lining up
|
width of 4 digits should result in values lining up
|
||||||
almost all the time (if/when they don't, it won't
|
almost all the time (if/when they don't, it won't
|
||||||
|
|||||||
Reference in New Issue
Block a user