ranking of new status conditions
This commit is contained in:
+2
-1
@@ -118,7 +118,7 @@ enum blconditions {
|
|||||||
/* clang-format on */
|
/* clang-format on */
|
||||||
|
|
||||||
struct conditions_t {
|
struct conditions_t {
|
||||||
int priority;
|
int ranking;
|
||||||
long mask;
|
long mask;
|
||||||
enum blconditions c;
|
enum blconditions c;
|
||||||
const char *text[3];
|
const char *text[3];
|
||||||
@@ -135,6 +135,7 @@ struct condtests_t {
|
|||||||
};
|
};
|
||||||
|
|
||||||
extern struct condtests_t condtests[CONDITION_COUNT];
|
extern struct condtests_t condtests[CONDITION_COUNT];
|
||||||
|
extern int cond_idx[CONDITION_COUNT];
|
||||||
|
|
||||||
#define BEFORE 0
|
#define BEFORE 0
|
||||||
#define NOW 1
|
#define NOW 1
|
||||||
|
|||||||
+76
-52
@@ -421,6 +421,7 @@ static int FDECL(compare_blstats, (struct istat_s *, struct istat_s *));
|
|||||||
static char *FDECL(anything_to_s, (char *, anything *, int));
|
static char *FDECL(anything_to_s, (char *, anything *, int));
|
||||||
static int FDECL(percentage, (struct istat_s *, struct istat_s *));
|
static int FDECL(percentage, (struct istat_s *, struct istat_s *));
|
||||||
static int NDECL(exp_percentage);
|
static int NDECL(exp_percentage);
|
||||||
|
static int FDECL(CFDECLSPEC cond_cmp, (const genericptr, const genericptr));
|
||||||
|
|
||||||
#ifdef STATUS_HILITES
|
#ifdef STATUS_HILITES
|
||||||
static void FDECL(s_to_anything, (anything *, char *, int));
|
static void FDECL(s_to_anything, (anything *, char *, int));
|
||||||
@@ -542,36 +543,36 @@ const struct condmap condition_aliases[] = {
|
|||||||
#endif /* STATUS_HILITES */
|
#endif /* STATUS_HILITES */
|
||||||
|
|
||||||
const struct conditions_t conditions[] = {
|
const struct conditions_t conditions[] = {
|
||||||
/* priority, mask, identifier, txt1, txt2, txt3 */
|
/* ranking, mask, identifier, txt1, txt2, txt3 */
|
||||||
{ 3, BL_MASK_BAREH, bl_bareh, { "Bare", "Bar", "Bh" } },
|
{ 20, BL_MASK_BAREH, bl_bareh, { "Bare", "Bar", "Bh" } },
|
||||||
{ 2, BL_MASK_BLIND, bl_blind, { "Blind", "Blnd", "Bl" } },
|
{ 10, BL_MASK_BLIND, bl_blind, { "Blind", "Blnd", "Bl" } },
|
||||||
{ 3, BL_MASK_BUSY, bl_busy, { "Busy", "Bsy", "By" } },
|
{ 20, BL_MASK_BUSY, bl_busy, { "Busy", "Bsy", "By" } },
|
||||||
{ 2, BL_MASK_CONF, bl_conf, { "Conf", "Cnf", "Cf" } },
|
{ 10, BL_MASK_CONF, bl_conf, { "Conf", "Cnf", "Cf" } },
|
||||||
{ 2, BL_MASK_DEAF, bl_deaf, { "Deaf", "Def", "Df" } },
|
{ 10, BL_MASK_DEAF, bl_deaf, { "Deaf", "Def", "Df" } },
|
||||||
{ 3, BL_MASK_ELF_IRON, bl_elf_iron, { "Iron", "Irn", "Fe" } },
|
{ 15, BL_MASK_ELF_IRON, bl_elf_iron, { "Iron", "Irn", "Fe" } },
|
||||||
{ 2, BL_MASK_FLY, bl_fly, { "Fly", "Fly", "Fl" } },
|
{ 10, BL_MASK_FLY, bl_fly, { "Fly", "Fly", "Fl" } },
|
||||||
{ 2, BL_MASK_FOODPOIS, bl_foodpois, { "FoodPois", "Fpois", "Poi" } },
|
{ 6, BL_MASK_FOODPOIS, bl_foodpois, { "FoodPois", "Fpois", "Poi" } },
|
||||||
{ 3, BL_MASK_GLOWHANDS, bl_glowhands, { "Glow", "Glo", "Gl" } },
|
{ 20, BL_MASK_GLOWHANDS, bl_glowhands, { "Glow", "Glo", "Gl" } },
|
||||||
{ 2, BL_MASK_GRAB, bl_grab, { "Grab", "Grb", "Gr" } },
|
{ 2, BL_MASK_GRAB, bl_grab, { "Grab", "Grb", "Gr" } },
|
||||||
{ 2, BL_MASK_HALLU, bl_hallu, { "Hallu", "Hal", "Hl" } },
|
{ 10, BL_MASK_HALLU, bl_hallu, { "Hallu", "Hal", "Hl" } },
|
||||||
{ 3, BL_MASK_HELD, bl_held, { "Held", "Hld", "Hd" } },
|
{ 20, BL_MASK_HELD, bl_held, { "Held", "Hld", "Hd" } },
|
||||||
{ 3, BL_MASK_ICY, bl_icy, { "Icy", "Icy", "Ic" } },
|
{ 20, BL_MASK_ICY, bl_icy, { "Icy", "Icy", "Ic" } },
|
||||||
{ 2, BL_MASK_INLAVA, bl_inlava, { "Lava", "Lav", "La" } },
|
{ 8, BL_MASK_INLAVA, bl_inlava, { "Lava", "Lav", "La" } },
|
||||||
{ 2, BL_MASK_LEV, bl_lev, { "Lev", "Lev", "Lv" } },
|
{ 10, BL_MASK_LEV, bl_lev, { "Lev", "Lev", "Lv" } },
|
||||||
{ 3, BL_MASK_PARLYZ, bl_parlyz, { "Parlyz", "Para", "Par" } },
|
{ 20, BL_MASK_PARLYZ, bl_parlyz, { "Parlyz", "Para", "Par" } },
|
||||||
{ 2, BL_MASK_RIDE, bl_ride, { "Ride", "Rid", "Rd" } },
|
{ 10, BL_MASK_RIDE, bl_ride, { "Ride", "Rid", "Rd" } },
|
||||||
{ 3, BL_MASK_SLEEPING, bl_sleeping, { "Zzz", "Zzz", "Zz" } },
|
{ 20, BL_MASK_SLEEPING, bl_sleeping, { "Zzz", "Zzz", "Zz" } },
|
||||||
{ 2, BL_MASK_SLIME, bl_slime, { "Slime", "Slim", "Slm" } },
|
{ 6, BL_MASK_SLIME, bl_slime, { "Slime", "Slim", "Slm" } },
|
||||||
{ 3, BL_MASK_SLIPPERY, bl_slippery, { "Slip", "Sli", "Sl" } },
|
{ 20, BL_MASK_SLIPPERY, bl_slippery, { "Slip", "Sli", "Sl" } },
|
||||||
{ 2, BL_MASK_STONE, bl_stone, { "Stone", "Ston", "Sto" } },
|
{ 6, BL_MASK_STONE, bl_stone, { "Stone", "Ston", "Sto" } },
|
||||||
{ 2, BL_MASK_STRNGL, bl_strngl, { "Strngl", "Stngl", "Str" } },
|
{ 4, BL_MASK_STRNGL, bl_strngl, { "Strngl", "Stngl", "Str" } },
|
||||||
{ 2, BL_MASK_STUN, bl_stun, { "Stun", "Stun", "St" } },
|
{ 10, BL_MASK_STUN, bl_stun, { "Stun", "Stun", "St" } },
|
||||||
{ 3, BL_MASK_SUBMERGED, bl_submerged, { "Sub", "Sub", "Sw" } },
|
{ 15, BL_MASK_SUBMERGED, bl_submerged, { "Sub", "Sub", "Sw" } },
|
||||||
{ 2, BL_MASK_TERMILL, bl_termill, { "TermIll", "Ill", "Ill" } },
|
{ 6, BL_MASK_TERMILL, bl_termill, { "TermIll", "Ill", "Ill" } },
|
||||||
{ 3, BL_MASK_TETHERED, bl_tethered, { "Teth", "Tth", "Te" } },
|
{ 20, BL_MASK_TETHERED, bl_tethered, { "Teth", "Tth", "Te" } },
|
||||||
{ 3, BL_MASK_TRAPPED, bl_trapped, { "Trap", "Trp", "Tr" } },
|
{ 20, BL_MASK_TRAPPED, bl_trapped, { "Trap", "Trp", "Tr" } },
|
||||||
{ 3, BL_MASK_UNCONSC, bl_unconsc, { "Out", "Out", "KO" } },
|
{ 20, BL_MASK_UNCONSC, bl_unconsc, { "Out", "Out", "KO" } },
|
||||||
{ 3, BL_MASK_WOUNDEDL, bl_woundedl, { "Legs", "Leg", "Lg" } },
|
{ 20, BL_MASK_WOUNDEDL, bl_woundedl, { "Legs", "Leg", "Lg" } },
|
||||||
};
|
};
|
||||||
|
|
||||||
struct condtests_t condtests[CONDITION_COUNT] = {
|
struct condtests_t condtests[CONDITION_COUNT] = {
|
||||||
@@ -606,6 +607,8 @@ struct condtests_t condtests[CONDITION_COUNT] = {
|
|||||||
{ bl_unconsc, opt_in, FALSE, FALSE, FALSE },
|
{ bl_unconsc, opt_in, FALSE, FALSE, FALSE },
|
||||||
{ bl_woundedl, opt_in, FALSE, FALSE, FALSE },
|
{ bl_woundedl, opt_in, FALSE, FALSE, FALSE },
|
||||||
};
|
};
|
||||||
|
/* condition indexing */
|
||||||
|
int cond_idx[CONDITION_COUNT] = { 0 };
|
||||||
|
|
||||||
/* cache-related */
|
/* cache-related */
|
||||||
static boolean cache_avail[3] = { FALSE, FALSE, FALSE };
|
static boolean cache_avail[3] = { FALSE, FALSE, FALSE };
|
||||||
@@ -938,6 +941,49 @@ stat_update_time()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* deal with player's choice to change processing of a condition */
|
||||||
|
void
|
||||||
|
condopt(addr, negated)
|
||||||
|
boolean *addr;
|
||||||
|
boolean negated;
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
boolean is_init = FALSE;
|
||||||
|
|
||||||
|
for (i = 0; i < CONDITION_COUNT; ++i) {
|
||||||
|
if (!addr) {
|
||||||
|
/* special: indicates a request to init so
|
||||||
|
set the choice values to match the defaults */
|
||||||
|
is_init = TRUE;
|
||||||
|
cond_idx[i] = i;
|
||||||
|
condtests[i].choice = condtests[i].enabled;
|
||||||
|
} else if (addr == &condtests[i].choice) {
|
||||||
|
condtests[i].enabled = negated ? FALSE : TRUE;
|
||||||
|
}
|
||||||
|
/* avoid lingering false positives if test is no longer run */
|
||||||
|
if (!condtests[i].enabled)
|
||||||
|
condtests[i].test = FALSE;
|
||||||
|
}
|
||||||
|
if (is_init)
|
||||||
|
qsort((genericptr_t) cond_idx, CONDITION_COUNT,
|
||||||
|
sizeof cond_idx[0], cond_cmp);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* qsort callback routine for sorting the condition index */
|
||||||
|
static int CFDECLSPEC
|
||||||
|
cond_cmp(vptr1, vptr2)
|
||||||
|
const genericptr vptr1;
|
||||||
|
const genericptr vptr2;
|
||||||
|
{
|
||||||
|
int indx1 = *(int *) vptr1, indx2 = *(int *) vptr2,
|
||||||
|
c1 = conditions[indx1].ranking, c2 = conditions[indx2].ranking;
|
||||||
|
|
||||||
|
if (c1 != c2)
|
||||||
|
return c1 - c2;
|
||||||
|
/* tie-breaker - visible alpha by name */
|
||||||
|
return strcmpi(conditions[indx1].text[0], conditions[indx2].text[0]);
|
||||||
|
}
|
||||||
|
|
||||||
static boolean
|
static boolean
|
||||||
eval_notify_windowport_field(fld, valsetlist, idx)
|
eval_notify_windowport_field(fld, valsetlist, idx)
|
||||||
int fld, idx;
|
int fld, idx;
|
||||||
@@ -1587,28 +1633,6 @@ int idx;
|
|||||||
return (const char *) 0;
|
return (const char *) 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* deal with player's choice to change processing of a condition */
|
|
||||||
void
|
|
||||||
condopt(addr, negated)
|
|
||||||
boolean *addr;
|
|
||||||
boolean negated;
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
|
|
||||||
for (i = 0; i < CONDITION_COUNT; ++i) {
|
|
||||||
if (!addr) {
|
|
||||||
/* special: indicates a request to init so
|
|
||||||
set the choice values to match the defaults */
|
|
||||||
condtests[i].choice = condtests[i].enabled;
|
|
||||||
} else if (addr == &condtests[i].choice) {
|
|
||||||
condtests[i].enabled = negated ? FALSE : TRUE;
|
|
||||||
}
|
|
||||||
/* avoid lingering false positives if test is no longer run */
|
|
||||||
if (!condtests[i].enabled)
|
|
||||||
condtests[i].test = FALSE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef STATUS_HILITES
|
#ifdef STATUS_HILITES
|
||||||
|
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
|
|||||||
@@ -975,6 +975,7 @@ curs_HPbar(char *text, /* pre-padded with trailing spaces if short */
|
|||||||
/* conditions[] is used primarily for parsing hilite_status rules, but
|
/* conditions[] is used primarily for parsing hilite_status rules, but
|
||||||
we can use it for condition names and mask bits, avoiding duplication */
|
we can use it for condition names and mask bits, avoiding duplication */
|
||||||
extern const struct conditions_t conditions[]; /* botl.c */
|
extern const struct conditions_t conditions[]; /* botl.c */
|
||||||
|
extern int cond_idx[CONDITION_COUNT];
|
||||||
|
|
||||||
static void
|
static void
|
||||||
curs_stat_conds(int vert_cond, /* 0 => horizontal, 1 => vertical */
|
curs_stat_conds(int vert_cond, /* 0 => horizontal, 1 => vertical */
|
||||||
@@ -983,7 +984,7 @@ curs_stat_conds(int vert_cond, /* 0 => horizontal, 1 => vertical */
|
|||||||
boolean *nohilite) /* optional output; indicates whether -*/
|
boolean *nohilite) /* optional output; indicates whether -*/
|
||||||
{ /*+ condbuf[] could be used as-is */
|
{ /*+ condbuf[] could be used as-is */
|
||||||
char condnam[20];
|
char condnam[20];
|
||||||
int i;
|
int i, ci;
|
||||||
long bitmsk;
|
long bitmsk;
|
||||||
|
|
||||||
if (condbuf) {
|
if (condbuf) {
|
||||||
@@ -996,9 +997,10 @@ curs_stat_conds(int vert_cond, /* 0 => horizontal, 1 => vertical */
|
|||||||
if (nohilite)
|
if (nohilite)
|
||||||
*nohilite = TRUE; /* assume ok */
|
*nohilite = TRUE; /* assume ok */
|
||||||
for (i = 0; i < BL_MASK_BITS; ++i) {
|
for (i = 0; i < BL_MASK_BITS; ++i) {
|
||||||
bitmsk = conditions[i].mask;
|
ci = cond_idx[i];
|
||||||
|
bitmsk = conditions[ci].mask;
|
||||||
if (curses_condition_bits & bitmsk) {
|
if (curses_condition_bits & bitmsk) {
|
||||||
Strcpy(condnam, conditions[i].text[0]);
|
Strcpy(condnam, conditions[ci].text[0]);
|
||||||
Strcat(strcat(condbuf, " "), upstart(condnam));
|
Strcat(strcat(condbuf, " "), upstart(condnam));
|
||||||
#ifdef STATUS_HILITES
|
#ifdef STATUS_HILITES
|
||||||
if (nohilite && *nohilite
|
if (nohilite && *nohilite
|
||||||
@@ -1024,9 +1026,10 @@ curs_stat_conds(int vert_cond, /* 0 => horizontal, 1 => vertical */
|
|||||||
cond_bits = curses_condition_bits;
|
cond_bits = curses_condition_bits;
|
||||||
/* show active conditions directly; for vertical, three per line */
|
/* show active conditions directly; for vertical, three per line */
|
||||||
for (i = 0; i < BL_MASK_BITS; ++i) {
|
for (i = 0; i < BL_MASK_BITS; ++i) {
|
||||||
bitmsk = conditions[i].mask;
|
ci = cond_idx[i];
|
||||||
|
bitmsk = conditions[ci].mask;
|
||||||
if (cond_bits & bitmsk) {
|
if (cond_bits & bitmsk) {
|
||||||
Strcpy(condnam, conditions[i].text[0]);
|
Strcpy(condnam, conditions[ci].text[0]);
|
||||||
cndlen = 1 + (int) strlen(condnam); /* count leading space */
|
cndlen = 1 + (int) strlen(condnam); /* count leading space */
|
||||||
if (!do_vert) {
|
if (!do_vert) {
|
||||||
getyx(win, cy, cx);
|
getyx(win, cy, cx);
|
||||||
|
|||||||
+4
-3
@@ -4409,7 +4409,7 @@ static void
|
|||||||
render_status(VOID_ARGS)
|
render_status(VOID_ARGS)
|
||||||
{
|
{
|
||||||
long mask, bits;
|
long mask, bits;
|
||||||
int i, x, y, idx, c, row, tlth, num_rows, coloridx = 0, attrmask = 0;
|
int i, x, y, idx, c, ci, row, tlth, num_rows, coloridx = 0, attrmask = 0;
|
||||||
char *text;
|
char *text;
|
||||||
struct WinDesc *cw = 0;
|
struct WinDesc *cw = 0;
|
||||||
|
|
||||||
@@ -4473,7 +4473,8 @@ render_status(VOID_ARGS)
|
|||||||
tty_curs(WIN_STATUS, x, y);
|
tty_curs(WIN_STATUS, x, y);
|
||||||
}
|
}
|
||||||
for (c = 0; c < SIZE(conditions) && bits != 0L; ++c) {
|
for (c = 0; c < SIZE(conditions) && bits != 0L; ++c) {
|
||||||
mask = conditions[c].mask;
|
ci = cond_idx[c];
|
||||||
|
mask = conditions[ci].mask;
|
||||||
if (bits & mask) {
|
if (bits & mask) {
|
||||||
const char *condtext;
|
const char *condtext;
|
||||||
|
|
||||||
@@ -4485,7 +4486,7 @@ render_status(VOID_ARGS)
|
|||||||
if (coloridx != NO_COLOR)
|
if (coloridx != NO_COLOR)
|
||||||
term_start_color(coloridx);
|
term_start_color(coloridx);
|
||||||
}
|
}
|
||||||
condtext = conditions[c].text[cond_shrinklvl];
|
condtext = conditions[ci].text[cond_shrinklvl];
|
||||||
if (x >= cw->cols && !truncation_expected) {
|
if (x >= cw->cols && !truncation_expected) {
|
||||||
impossible(
|
impossible(
|
||||||
"Unexpected condition placement overflow for \"%s\"",
|
"Unexpected condition placement overflow for \"%s\"",
|
||||||
|
|||||||
Reference in New Issue
Block a user