botl.c cleanup
Mainly miscellaneous source formatting, plus some expanded comments and #undef of macros when done with them.
This commit is contained in:
+15
-11
@@ -44,9 +44,11 @@ enum statusfields {
|
|||||||
MAXBLSTATS /* [23] */
|
MAXBLSTATS /* [23] */
|
||||||
};
|
};
|
||||||
|
|
||||||
enum relationships { NO_LTEQGT = -1,
|
enum relationships {
|
||||||
EQ_VALUE, LT_VALUE, LE_VALUE,
|
NO_LTEQGT = -1,
|
||||||
GE_VALUE, GT_VALUE, TXT_VALUE };
|
EQ_VALUE, LT_VALUE, LE_VALUE,
|
||||||
|
GE_VALUE, GT_VALUE, TXT_VALUE
|
||||||
|
};
|
||||||
|
|
||||||
enum blconditions {
|
enum blconditions {
|
||||||
bl_bareh,
|
bl_bareh,
|
||||||
@@ -219,16 +221,18 @@ extern int cond_idx[CONDITION_COUNT];
|
|||||||
#define HL_ATTCLR_BOLD CLR_MAX + 4
|
#define HL_ATTCLR_BOLD CLR_MAX + 4
|
||||||
#define BL_ATTCLR_MAX CLR_MAX + 5
|
#define BL_ATTCLR_MAX CLR_MAX + 5
|
||||||
|
|
||||||
enum hlattribs { HL_UNDEF = 0x00,
|
enum hlattribs {
|
||||||
HL_NONE = 0x01,
|
HL_UNDEF = 0x00,
|
||||||
HL_BOLD = 0x02,
|
HL_NONE = 0x01,
|
||||||
HL_INVERSE = 0x04,
|
HL_BOLD = 0x02,
|
||||||
HL_ULINE = 0x08,
|
HL_INVERSE = 0x04,
|
||||||
HL_BLINK = 0x10,
|
HL_ULINE = 0x08,
|
||||||
HL_DIM = 0x20 };
|
HL_BLINK = 0x10,
|
||||||
|
HL_DIM = 0x20
|
||||||
|
};
|
||||||
|
|
||||||
#define MAXVALWIDTH 80 /* actually less, but was using 80 to allocate title
|
#define MAXVALWIDTH 80 /* actually less, but was using 80 to allocate title
|
||||||
* and leveldesc then using QBUFSZ everywhere else */
|
* and leveldesc then using QBUFSZ everywhere else */
|
||||||
#ifdef STATUS_HILITES
|
#ifdef STATUS_HILITES
|
||||||
struct hilite_s {
|
struct hilite_s {
|
||||||
enum statusfields fld;
|
enum statusfields fld;
|
||||||
|
|||||||
+113
-85
@@ -18,12 +18,6 @@ const char *const enc_stat[] = {
|
|||||||
static const char *rank(void);
|
static const char *rank(void);
|
||||||
static void bot_via_windowport(void);
|
static void bot_via_windowport(void);
|
||||||
static void stat_update_time(void);
|
static void stat_update_time(void);
|
||||||
#ifdef STATUS_HILITES
|
|
||||||
static unsigned long query_conditions(void);
|
|
||||||
static boolean status_hilite_remove(int);
|
|
||||||
static boolean status_hilite_menu_fld(int);
|
|
||||||
static void status_hilites_viewall(void);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static char *
|
static char *
|
||||||
get_strength_str(void)
|
get_strength_str(void)
|
||||||
@@ -80,8 +74,9 @@ do_statusline1(void)
|
|||||||
k++;
|
k++;
|
||||||
}
|
}
|
||||||
Strcpy(nb = eos(nb), mbot);
|
Strcpy(nb = eos(nb), mbot);
|
||||||
} else
|
} else {
|
||||||
Strcpy(nb = eos(nb), rank());
|
Strcpy(nb = eos(nb), rank());
|
||||||
|
}
|
||||||
|
|
||||||
Sprintf(nb = eos(nb), " ");
|
Sprintf(nb = eos(nb), " ");
|
||||||
i = gm.mrank_sz + 15;
|
i = gm.mrank_sz + 15;
|
||||||
@@ -94,9 +89,9 @@ do_statusline1(void)
|
|||||||
ACURR(A_DEX), ACURR(A_CON), ACURR(A_INT), ACURR(A_WIS),
|
ACURR(A_DEX), ACURR(A_CON), ACURR(A_INT), ACURR(A_WIS),
|
||||||
ACURR(A_CHA));
|
ACURR(A_CHA));
|
||||||
Sprintf(nb = eos(nb), "%s",
|
Sprintf(nb = eos(nb), "%s",
|
||||||
(u.ualign.type == A_CHAOTIC)
|
(u.ualign.type == A_CHAOTIC) ? " Chaotic"
|
||||||
? " Chaotic"
|
: (u.ualign.type == A_NEUTRAL) ? " Neutral"
|
||||||
: (u.ualign.type == A_NEUTRAL) ? " Neutral" : " Lawful");
|
: " Lawful");
|
||||||
#ifdef SCORE_ON_BOTL
|
#ifdef SCORE_ON_BOTL
|
||||||
if (flags.showscore)
|
if (flags.showscore)
|
||||||
Sprintf(nb = eos(nb), " S:%ld", botl_score());
|
Sprintf(nb = eos(nb), " S:%ld", botl_score());
|
||||||
@@ -157,7 +152,7 @@ do_statusline2(void)
|
|||||||
else if (flags.showexp)
|
else if (flags.showexp)
|
||||||
Sprintf(expr, "Xp:%d/%-1ld", u.ulevel, u.uexp);
|
Sprintf(expr, "Xp:%d/%-1ld", u.ulevel, u.uexp);
|
||||||
else
|
else
|
||||||
Sprintf(expr, "Exp:%d", u.ulevel);
|
Sprintf(expr, "Xp:%d", u.ulevel);
|
||||||
xln = strlen(expr);
|
xln = strlen(expr);
|
||||||
|
|
||||||
/* time/move counter */
|
/* time/move counter */
|
||||||
@@ -224,20 +219,21 @@ do_statusline2(void)
|
|||||||
* interface supports that.
|
* interface supports that.
|
||||||
*/
|
*/
|
||||||
if ((dln - dx) + 1 + hln + 1 + xln + 1 + tln + 1 + cln <= COLNO) {
|
if ((dln - dx) + 1 + hln + 1 + xln + 1 + tln + 1 + cln <= COLNO) {
|
||||||
Snprintf(newbot2, sizeof(newbot2), "%s %s %s %s %s", dloc, hlth, expr,
|
Snprintf(newbot2, sizeof newbot2, "%s %s %s %s %s", dloc, hlth, expr,
|
||||||
tmmv, cond);
|
tmmv, cond);
|
||||||
} else {
|
} else {
|
||||||
if (dln + 1 + hln + 1 + xln + 1 + tln + 1 + cln + 1 > MAXCO) {
|
if (dln + 1 + hln + 1 + xln + 1 + tln + 1 + cln + 1 > MAXCO) {
|
||||||
panic("bot2: second status line exceeds MAXCO (%u > %d)",
|
panic("bot2: second status line exceeds MAXCO (%u > %d)",
|
||||||
(unsigned)(dln + 1 + hln + 1 + xln + 1 + tln + 1 + cln + 1), MAXCO);
|
(unsigned)(dln + 1 + hln + 1 + xln + 1 + tln + 1 + cln + 1),
|
||||||
|
MAXCO);
|
||||||
} else if ((dln - dx) + 1 + hln + 1 + xln + 1 + cln <= COLNO) {
|
} else if ((dln - dx) + 1 + hln + 1 + xln + 1 + cln <= COLNO) {
|
||||||
Snprintf(newbot2, sizeof(newbot2), "%s %s %s %s %s", dloc, hlth,
|
Snprintf(newbot2, sizeof newbot2, "%s %s %s %s %s", dloc, hlth,
|
||||||
expr, cond, tmmv);
|
expr, cond, tmmv);
|
||||||
} else if ((dln - dx) + 1 + hln + 1 + cln <= COLNO) {
|
} else if ((dln - dx) + 1 + hln + 1 + cln <= COLNO) {
|
||||||
Snprintf(newbot2, sizeof(newbot2), "%s %s %s %s %s", dloc, hlth,
|
Snprintf(newbot2, sizeof newbot2, "%s %s %s %s %s", dloc, hlth,
|
||||||
cond, expr, tmmv);
|
cond, expr, tmmv);
|
||||||
} else {
|
} else {
|
||||||
Snprintf(newbot2, sizeof(newbot2), "%s %s %s %s %s", hlth, cond,
|
Snprintf(newbot2, sizeof newbot2, "%s %s %s %s %s", hlth, cond,
|
||||||
dloc, expr, tmmv);
|
dloc, expr, tmmv);
|
||||||
}
|
}
|
||||||
/* only two or three consecutive spaces available to squeeze out */
|
/* only two or three consecutive spaces available to squeeze out */
|
||||||
@@ -357,9 +353,12 @@ rank(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
title_to_mon(const char *str, int *rank_indx, int *title_length)
|
title_to_mon(
|
||||||
|
const char *str,
|
||||||
|
int *rank_indx,
|
||||||
|
int *title_length)
|
||||||
{
|
{
|
||||||
register int i, j;
|
int i, j;
|
||||||
|
|
||||||
/* Loop through each of the roles */
|
/* Loop through each of the roles */
|
||||||
for (i = 0; roles[i].name.m; i++) {
|
for (i = 0; roles[i].name.m; i++) {
|
||||||
@@ -391,8 +390,9 @@ title_to_mon(const char *str, int *rank_indx, int *title_length)
|
|||||||
void
|
void
|
||||||
max_rank_sz(void)
|
max_rank_sz(void)
|
||||||
{
|
{
|
||||||
register int i;
|
int i;
|
||||||
size_t r, maxr = 0;
|
size_t r, maxr = 0;
|
||||||
|
|
||||||
for (i = 0; i < 9; i++) {
|
for (i = 0; i < 9; i++) {
|
||||||
if (gu.urole.rank[i].m && (r = strlen(gu.urole.rank[i].m)) > maxr)
|
if (gu.urole.rank[i].m && (r = strlen(gu.urole.rank[i].m)) > maxr)
|
||||||
maxr = r;
|
maxr = r;
|
||||||
@@ -495,6 +495,7 @@ static boolean is_fld_arrayvalues(const char *, const char *const *, int, int,
|
|||||||
static int query_arrayvalue(const char *, const char *const *, int, int);
|
static int query_arrayvalue(const char *, const char *const *, int, int);
|
||||||
static void status_hilite_add_threshold(int, struct hilite_s *);
|
static void status_hilite_add_threshold(int, struct hilite_s *);
|
||||||
static boolean parse_status_hl2(char (*)[QBUFSZ], boolean);
|
static boolean parse_status_hl2(char (*)[QBUFSZ], boolean);
|
||||||
|
static unsigned long query_conditions(void);
|
||||||
static char *conditionbitmask2str(unsigned long);
|
static char *conditionbitmask2str(unsigned long);
|
||||||
static unsigned long match_str2conditionbitmask(const char *);
|
static unsigned long match_str2conditionbitmask(const char *);
|
||||||
static unsigned long str2conditionbitmask(char *);
|
static unsigned long str2conditionbitmask(char *);
|
||||||
@@ -512,6 +513,10 @@ static int status_hilite_menu_choose_behavior(int);
|
|||||||
static int status_hilite_menu_choose_updownboth(int, const char *, boolean,
|
static int status_hilite_menu_choose_updownboth(int, const char *, boolean,
|
||||||
boolean);
|
boolean);
|
||||||
static boolean status_hilite_menu_add(int);
|
static boolean status_hilite_menu_add(int);
|
||||||
|
static boolean status_hilite_remove(int);
|
||||||
|
static boolean status_hilite_menu_fld(int);
|
||||||
|
static void status_hilites_viewall(void);
|
||||||
|
|
||||||
#define has_hilite(i) (gb.blstats[0][(i)].thresholds)
|
#define has_hilite(i) (gb.blstats[0][(i)].thresholds)
|
||||||
/* TH_UPDOWN encompasses specific 'up' and 'down' also general 'changed' */
|
/* TH_UPDOWN encompasses specific 'up' and 'down' also general 'changed' */
|
||||||
#define Is_Temp_Hilite(rule) ((rule) && (rule)->behavior == BL_TH_UPDOWN)
|
#define Is_Temp_Hilite(rule) ((rule) && (rule)->behavior == BL_TH_UPDOWN)
|
||||||
@@ -598,6 +603,7 @@ const struct condmap condition_aliases[] = {
|
|||||||
|
|
||||||
#endif /* STATUS_HILITES */
|
#endif /* STATUS_HILITES */
|
||||||
|
|
||||||
|
/* condition names and their abbreviations are used by windowport code */
|
||||||
const struct conditions_t conditions[] = {
|
const struct conditions_t conditions[] = {
|
||||||
/* ranking, mask, identifier, txt1, txt2, txt3 */
|
/* ranking, mask, identifier, txt1, txt2, txt3 */
|
||||||
{ 20, BL_MASK_BAREH, bl_bareh, { "Bare", "Bar", "Bh" } },
|
{ 20, BL_MASK_BAREH, bl_bareh, { "Bare", "Bar", "Bh" } },
|
||||||
@@ -633,7 +639,8 @@ const struct conditions_t conditions[] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct condtests_t condtests[CONDITION_COUNT] = {
|
struct condtests_t condtests[CONDITION_COUNT] = {
|
||||||
/* id, useropt, opt_in or out, enabled, configchoice, testresult */
|
/* id, useropt, opt_in or out, enabled, configchoice, testresult;
|
||||||
|
default value for enabled is !opt_in but can get changed via options */
|
||||||
{ bl_bareh, "barehanded", opt_in, FALSE, FALSE, FALSE },
|
{ bl_bareh, "barehanded", opt_in, FALSE, FALSE, FALSE },
|
||||||
{ bl_blind, "blind", opt_out, TRUE, FALSE, FALSE },
|
{ bl_blind, "blind", opt_out, TRUE, FALSE, FALSE },
|
||||||
{ bl_busy, "busy", opt_in, FALSE, FALSE, FALSE },
|
{ bl_busy, "busy", opt_in, FALSE, FALSE, FALSE },
|
||||||
@@ -673,7 +680,7 @@ static boolean cache_avail[3] = { FALSE, FALSE, FALSE };
|
|||||||
static boolean cache_reslt[3] = { FALSE, FALSE, FALSE };
|
static boolean cache_reslt[3] = { FALSE, FALSE, FALSE };
|
||||||
static const char *cache_nomovemsg = NULL, *cache_multi_reason = NULL;
|
static const char *cache_nomovemsg = NULL, *cache_multi_reason = NULL;
|
||||||
|
|
||||||
#define cond_cache_prepA() \
|
#define cond_cache_prepA() \
|
||||||
do { \
|
do { \
|
||||||
boolean clear_cache = FALSE, refresh_cache = FALSE; \
|
boolean clear_cache = FALSE, refresh_cache = FALSE; \
|
||||||
\
|
\
|
||||||
@@ -861,16 +868,24 @@ bot_via_windowport(void)
|
|||||||
|
|
||||||
gb.blstats[idx][BL_CONDITION].a.a_ulong = 0L;
|
gb.blstats[idx][BL_CONDITION].a.a_ulong = 0L;
|
||||||
|
|
||||||
/* avoid anything that does string comparisons in here because this
|
/*
|
||||||
is called *extremely* often, for every screen update and the same
|
* Avoid anything that does string comparisons in here because this
|
||||||
string comparisons would be repeated, thus contributing toward
|
* is called *extremely* often, for every screen update and the same
|
||||||
performance degradation. If it is essential that string comparisons
|
* string comparisons would be repeated, thus contributing toward
|
||||||
are needed for a particular condition, consider adding a caching
|
* performance degradation. If it is essential that string comparisons
|
||||||
mechanism to limit the string comparisons to the first occurrence
|
* are needed for a particular condition, consider adding a caching
|
||||||
for that cache lifetime. There is caching of that nature done for
|
* mechanism to limit the string comparisons to the first occurrence
|
||||||
unconsc (1) and parlyz (2) because the suggested way of being able
|
* for that cache lifetime. There is caching of that nature done for
|
||||||
to distinguish unconsc, parlyz, sleeping, and busy involves multiple
|
* unconsc (1) and parlyz (2) because the suggested way of being able
|
||||||
string comparisons. */
|
* to distinguish unconsc, parlyz, sleeping, and busy involves multiple
|
||||||
|
* string comparisons.
|
||||||
|
*
|
||||||
|
* [Rebuttal: it's called a lot for Windows and MS-DOS because their
|
||||||
|
* sample run-time configuration file enables 'time' (move counter).
|
||||||
|
* The optimization to bypass full status update when only 'time'
|
||||||
|
* has changed (via timebot(), only effective for VIA_WINDOWPORT()
|
||||||
|
* configurations) should ameliorate that.]
|
||||||
|
*/
|
||||||
|
|
||||||
#define test_if_enabled(c) if (condtests[(c)].enabled) condtests[(c)].test
|
#define test_if_enabled(c) if (condtests[(c)].enabled) condtests[(c)].test
|
||||||
|
|
||||||
@@ -962,18 +977,22 @@ bot_via_windowport(void)
|
|||||||
condtests[bl_sleeping].test = condtests[bl_busy].test = FALSE;
|
condtests[bl_sleeping].test = condtests[bl_busy].test = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define cond_bitset(c) \
|
#define cond_setbit(c) \
|
||||||
gb.blstats[idx][BL_CONDITION].a.a_ulong |= conditions[(c)].mask;
|
gb.blstats[idx][BL_CONDITION].a.a_ulong |= conditions[(c)].mask
|
||||||
|
|
||||||
for (i = 0; i < CONDITION_COUNT; ++i) {
|
for (i = 0; i < CONDITION_COUNT; ++i) {
|
||||||
if (condtests[i].enabled
|
if (condtests[i].enabled
|
||||||
/* && i != bl_holding */ /* uncomment to suppress UHold */
|
/* && i != bl_holding */ /* uncomment to suppress UHold */
|
||||||
&& condtests[i].test)
|
&& condtests[i].test)
|
||||||
cond_bitset(i);
|
cond_setbit(i);
|
||||||
}
|
}
|
||||||
|
#undef cond_bitset
|
||||||
|
|
||||||
evaluate_and_notify_windowport(gv.valset, idx);
|
evaluate_and_notify_windowport(gv.valset, idx);
|
||||||
|
#undef test_if_enabled
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#undef cond_cache_prepA
|
||||||
|
|
||||||
/* update just the status lines' 'time' field */
|
/* update just the status lines' 'time' field */
|
||||||
static void
|
static void
|
||||||
@@ -1069,7 +1088,9 @@ parse_cond_option(boolean negated, char *opts)
|
|||||||
void
|
void
|
||||||
cond_menu(void)
|
cond_menu(void)
|
||||||
{
|
{
|
||||||
static const char *const menutitle[2] = { "alphabetically", "by ranking"};
|
static const char *const menutitle[2] = {
|
||||||
|
"alphabetically", "by ranking"
|
||||||
|
};
|
||||||
int i, res, idx = 0;
|
int i, res, idx = 0;
|
||||||
int sequence[CONDITION_COUNT];
|
int sequence[CONDITION_COUNT];
|
||||||
winid tmpwin;
|
winid tmpwin;
|
||||||
@@ -1107,8 +1128,7 @@ cond_menu(void)
|
|||||||
any = cg.zeroany;
|
any = cg.zeroany;
|
||||||
any.a_int = idx + 2; /* avoid zero and the sort change pick */
|
any.a_int = idx + 2; /* avoid zero and the sort change pick */
|
||||||
condtests[idx].choice = FALSE;
|
condtests[idx].choice = FALSE;
|
||||||
add_menu(tmpwin, &nul_glyphinfo, &any, 0, 0, ATR_NONE,
|
add_menu(tmpwin, &nul_glyphinfo, &any, 0, 0, ATR_NONE, clr, mbuf,
|
||||||
clr, mbuf,
|
|
||||||
condtests[idx].enabled
|
condtests[idx].enabled
|
||||||
? MENU_ITEMFLAGS_SELECTED : MENU_ITEMFLAGS_NONE);
|
? MENU_ITEMFLAGS_SELECTED : MENU_ITEMFLAGS_NONE);
|
||||||
}
|
}
|
||||||
@@ -1178,7 +1198,10 @@ opt_next_cond(int indx, char *outbuf)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static boolean
|
static boolean
|
||||||
eval_notify_windowport_field(int fld, boolean *valsetlist, int idx)
|
eval_notify_windowport_field(
|
||||||
|
int fld,
|
||||||
|
boolean *valsetlist,
|
||||||
|
int idx)
|
||||||
{
|
{
|
||||||
static int oldrndencode = 0;
|
static int oldrndencode = 0;
|
||||||
static nhsym oldgoldsym = 0;
|
static nhsym oldgoldsym = 0;
|
||||||
@@ -1300,7 +1323,9 @@ eval_notify_windowport_field(int fld, boolean *valsetlist, int idx)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
evaluate_and_notify_windowport(boolean *valsetlist, int idx)
|
evaluate_and_notify_windowport(
|
||||||
|
boolean *valsetlist,
|
||||||
|
int idx)
|
||||||
{
|
{
|
||||||
int i, updated = 0, notpresent UNUSED = 0;
|
int i, updated = 0, notpresent UNUSED = 0;
|
||||||
|
|
||||||
@@ -1356,8 +1381,7 @@ evaluate_and_notify_windowport(boolean *valsetlist, int idx)
|
|||||||
|
|
||||||
void
|
void
|
||||||
status_initialize(
|
status_initialize(
|
||||||
boolean reassessment) /* TRUE: just recheck fields without other
|
boolean reassessment) /* True: just recheck fields without other init */
|
||||||
* initialization */
|
|
||||||
{
|
{
|
||||||
enum statusfields fld;
|
enum statusfields fld;
|
||||||
boolean fldenabl;
|
boolean fldenabl;
|
||||||
@@ -1403,9 +1427,11 @@ status_finish(void)
|
|||||||
/* free memory that we alloc'd now */
|
/* free memory that we alloc'd now */
|
||||||
for (i = 0; i < MAXBLSTATS; ++i) {
|
for (i = 0; i < MAXBLSTATS; ++i) {
|
||||||
if (gb.blstats[0][i].val)
|
if (gb.blstats[0][i].val)
|
||||||
free((genericptr_t) gb.blstats[0][i].val), gb.blstats[0][i].val = 0;
|
free((genericptr_t) gb.blstats[0][i].val),
|
||||||
|
gb.blstats[0][i].val = (char *) NULL;
|
||||||
if (gb.blstats[1][i].val)
|
if (gb.blstats[1][i].val)
|
||||||
free((genericptr_t) gb.blstats[1][i].val), gb.blstats[1][i].val = 0;
|
free((genericptr_t) gb.blstats[1][i].val),
|
||||||
|
gb.blstats[1][i].val = (char *) NULL;
|
||||||
#ifdef STATUS_HILITES
|
#ifdef STATUS_HILITES
|
||||||
/* pointer to an entry in thresholds list; Null it out since
|
/* pointer to an entry in thresholds list; Null it out since
|
||||||
that list is about to go away */
|
that list is about to go away */
|
||||||
@@ -1417,7 +1443,9 @@ status_finish(void)
|
|||||||
next = temp->next;
|
next = temp->next;
|
||||||
free((genericptr_t) temp);
|
free((genericptr_t) temp);
|
||||||
}
|
}
|
||||||
gb.blstats[0][i].thresholds = gb.blstats[1][i].thresholds = 0;
|
gb.blstats[0][i].thresholds
|
||||||
|
= gb.blstats[1][i].thresholds
|
||||||
|
= (struct hilite_s *) NULL;
|
||||||
}
|
}
|
||||||
#endif /* STATUS_HILITES */
|
#endif /* STATUS_HILITES */
|
||||||
}
|
}
|
||||||
@@ -1442,7 +1470,8 @@ init_blstats(void)
|
|||||||
gb.blstats[i][j] = initblstats[j];
|
gb.blstats[i][j] = initblstats[j];
|
||||||
gb.blstats[i][j].a = cg.zeroany;
|
gb.blstats[i][j].a = cg.zeroany;
|
||||||
if (gb.blstats[i][j].valwidth) {
|
if (gb.blstats[i][j].valwidth) {
|
||||||
gb.blstats[i][j].val = (char *) alloc(gb.blstats[i][j].valwidth);
|
gb.blstats[i][j].val
|
||||||
|
= (char *) alloc(gb.blstats[i][j].valwidth);
|
||||||
gb.blstats[i][j].val[0] = '\0';
|
gb.blstats[i][j].val[0] = '\0';
|
||||||
} else
|
} else
|
||||||
gb.blstats[i][j].val = (char *) 0;
|
gb.blstats[i][j].val = (char *) 0;
|
||||||
@@ -1493,43 +1522,35 @@ compare_blstats(struct istat_s *bl1, struct istat_s *bl2)
|
|||||||
|
|
||||||
switch (anytype) {
|
switch (anytype) {
|
||||||
case ANY_INT:
|
case ANY_INT:
|
||||||
result = (bl1->a.a_int < bl2->a.a_int)
|
result = (bl1->a.a_int < bl2->a.a_int) ? 1
|
||||||
? 1
|
|
||||||
: (bl1->a.a_int > bl2->a.a_int) ? -1 : 0;
|
: (bl1->a.a_int > bl2->a.a_int) ? -1 : 0;
|
||||||
break;
|
break;
|
||||||
case ANY_IPTR:
|
case ANY_IPTR:
|
||||||
result = (*bl1->a.a_iptr < *bl2->a.a_iptr)
|
result = (*bl1->a.a_iptr < *bl2->a.a_iptr) ? 1
|
||||||
? 1
|
|
||||||
: (*bl1->a.a_iptr > *bl2->a.a_iptr) ? -1 : 0;
|
: (*bl1->a.a_iptr > *bl2->a.a_iptr) ? -1 : 0;
|
||||||
break;
|
break;
|
||||||
case ANY_LONG:
|
case ANY_LONG:
|
||||||
result = (bl1->a.a_long < bl2->a.a_long)
|
result = (bl1->a.a_long < bl2->a.a_long) ? 1
|
||||||
? 1
|
|
||||||
: (bl1->a.a_long > bl2->a.a_long) ? -1 : 0;
|
: (bl1->a.a_long > bl2->a.a_long) ? -1 : 0;
|
||||||
break;
|
break;
|
||||||
case ANY_LPTR:
|
case ANY_LPTR:
|
||||||
result = (*bl1->a.a_lptr < *bl2->a.a_lptr)
|
result = (*bl1->a.a_lptr < *bl2->a.a_lptr) ? 1
|
||||||
? 1
|
|
||||||
: (*bl1->a.a_lptr > *bl2->a.a_lptr) ? -1 : 0;
|
: (*bl1->a.a_lptr > *bl2->a.a_lptr) ? -1 : 0;
|
||||||
break;
|
break;
|
||||||
case ANY_UINT:
|
case ANY_UINT:
|
||||||
result = (bl1->a.a_uint < bl2->a.a_uint)
|
result = (bl1->a.a_uint < bl2->a.a_uint) ? 1
|
||||||
? 1
|
|
||||||
: (bl1->a.a_uint > bl2->a.a_uint) ? -1 : 0;
|
: (bl1->a.a_uint > bl2->a.a_uint) ? -1 : 0;
|
||||||
break;
|
break;
|
||||||
case ANY_UPTR:
|
case ANY_UPTR:
|
||||||
result = (*bl1->a.a_uptr < *bl2->a.a_uptr)
|
result = (*bl1->a.a_uptr < *bl2->a.a_uptr) ? 1
|
||||||
? 1
|
|
||||||
: (*bl1->a.a_uptr > *bl2->a.a_uptr) ? -1 : 0;
|
: (*bl1->a.a_uptr > *bl2->a.a_uptr) ? -1 : 0;
|
||||||
break;
|
break;
|
||||||
case ANY_ULONG:
|
case ANY_ULONG:
|
||||||
result = (bl1->a.a_ulong < bl2->a.a_ulong)
|
result = (bl1->a.a_ulong < bl2->a.a_ulong) ? 1
|
||||||
? 1
|
|
||||||
: (bl1->a.a_ulong > bl2->a.a_ulong) ? -1 : 0;
|
: (bl1->a.a_ulong > bl2->a.a_ulong) ? -1 : 0;
|
||||||
break;
|
break;
|
||||||
case ANY_ULPTR:
|
case ANY_ULPTR:
|
||||||
result = (*bl1->a.a_ulptr < *bl2->a.a_ulptr)
|
result = (*bl1->a.a_ulptr < *bl2->a.a_ulptr) ? 1
|
||||||
? 1
|
|
||||||
: (*bl1->a.a_ulptr > *bl2->a.a_ulptr) ? -1 : 0;
|
: (*bl1->a.a_ulptr > *bl2->a.a_ulptr) ? -1 : 0;
|
||||||
break;
|
break;
|
||||||
case ANY_STR:
|
case ANY_STR:
|
||||||
@@ -1822,7 +1843,7 @@ bl_idx_to_fldname(int idx)
|
|||||||
/* Core status hiliting support */
|
/* Core status hiliting support */
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
|
|
||||||
static struct fieldid_t {
|
static const struct fieldid_t {
|
||||||
const char *fieldname;
|
const char *fieldname;
|
||||||
enum statusfields fldid;
|
enum statusfields fldid;
|
||||||
} fieldids_alias[] = {
|
} fieldids_alias[] = {
|
||||||
@@ -1868,7 +1889,6 @@ fldname_to_bl_indx(const char *name)
|
|||||||
fld = initblstats[i].fld;
|
fld = initblstats[i].fld;
|
||||||
nmatches++;
|
nmatches++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!nmatches) {
|
if (!nmatches) {
|
||||||
/* check aliases */
|
/* check aliases */
|
||||||
for (i = 0; fieldids_alias[i].fieldname; i++)
|
for (i = 0; fieldids_alias[i].fieldname; i++)
|
||||||
@@ -1878,7 +1898,6 @@ fldname_to_bl_indx(const char *name)
|
|||||||
nmatches++;
|
nmatches++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!nmatches) {
|
if (!nmatches) {
|
||||||
/* check partial matches to canonical names */
|
/* check partial matches to canonical names */
|
||||||
int len = (int) strlen(name);
|
int len = (int) strlen(name);
|
||||||
@@ -1935,10 +1954,10 @@ status_eval_next_unhilite(void)
|
|||||||
struct istat_s *prev = &gb.blstats[1][i];
|
struct istat_s *prev = &gb.blstats[1][i];
|
||||||
|
|
||||||
if (Is_Temp_Hilite(curr->hilite_rule))
|
if (Is_Temp_Hilite(curr->hilite_rule))
|
||||||
curr->time = prev->time = (gb.bl_hilite_moves
|
curr->time = (gb.bl_hilite_moves + iflags.hilite_delta);
|
||||||
+ iflags.hilite_delta);
|
|
||||||
else
|
else
|
||||||
curr->time = prev->time = 0L;
|
curr->time = 0L;
|
||||||
|
prev->time = curr->time;
|
||||||
|
|
||||||
curr->chg = prev->chg = FALSE;
|
curr->chg = prev->chg = FALSE;
|
||||||
gc.context.botl = TRUE;
|
gc.context.botl = TRUE;
|
||||||
@@ -2210,6 +2229,9 @@ get_hilite(
|
|||||||
return rule;
|
return rule;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#undef has_hilite
|
||||||
|
#undef Is_Temp_Hilite
|
||||||
|
|
||||||
static void
|
static void
|
||||||
split_clridx(int idx, int *coloridx, int *attrib)
|
split_clridx(int idx, int *coloridx, int *attrib)
|
||||||
{
|
{
|
||||||
@@ -2278,9 +2300,11 @@ parse_status_hl1(char *op, boolean from_configfile)
|
|||||||
}
|
}
|
||||||
if (badopt)
|
if (badopt)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
else if (!iflags.hilite_delta)
|
/* make sure highlighting is On; use short duration for temp highlights */
|
||||||
|
if (!iflags.hilite_delta)
|
||||||
iflags.hilite_delta = 3L;
|
iflags.hilite_delta = 3L;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
#undef MAX_THRESH
|
||||||
}
|
}
|
||||||
|
|
||||||
/* is str in the format of "[<>]?=?[-+]?[0-9]+%?" regex */
|
/* is str in the format of "[<>]?=?[-+]?[0-9]+%?" regex */
|
||||||
@@ -2321,10 +2345,10 @@ has_ltgt_percentnumber(const char *str)
|
|||||||
/* splitsubfields(): splits str in place into '+' or '&' separated strings.
|
/* splitsubfields(): splits str in place into '+' or '&' separated strings.
|
||||||
* returns number of strings, or -1 if more than maxsf or MAX_SUBFIELDS
|
* returns number of strings, or -1 if more than maxsf or MAX_SUBFIELDS
|
||||||
*/
|
*/
|
||||||
#define MAX_SUBFIELDS 16
|
|
||||||
static int
|
static int
|
||||||
splitsubfields(char *str, char ***sfarr, int maxsf)
|
splitsubfields(char *str, char ***sfarr, int maxsf)
|
||||||
{
|
{
|
||||||
|
#define MAX_SUBFIELDS 16
|
||||||
static char *subfields[MAX_SUBFIELDS];
|
static char *subfields[MAX_SUBFIELDS];
|
||||||
char *st = (char *) 0;
|
char *st = (char *) 0;
|
||||||
int sf = 0;
|
int sf = 0;
|
||||||
@@ -2360,8 +2384,8 @@ splitsubfields(char *str, char ***sfarr, int maxsf)
|
|||||||
}
|
}
|
||||||
*sfarr = subfields;
|
*sfarr = subfields;
|
||||||
return sf;
|
return sf;
|
||||||
}
|
|
||||||
#undef MAX_SUBFIELDS
|
#undef MAX_SUBFIELDS
|
||||||
|
}
|
||||||
|
|
||||||
static boolean
|
static boolean
|
||||||
is_fld_arrayvalues(
|
is_fld_arrayvalues(
|
||||||
@@ -2445,10 +2469,15 @@ status_hilite_add_threshold(int fld, struct hilite_s *hilite)
|
|||||||
gb.blstats[1][fld].thresholds = gb.blstats[0][fld].thresholds;
|
gb.blstats[1][fld].thresholds = gb.blstats[0][fld].thresholds;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static boolean
|
static boolean
|
||||||
parse_status_hl2(char (*s)[QBUFSZ], boolean from_configfile)
|
parse_status_hl2(char (*s)[QBUFSZ], boolean from_configfile)
|
||||||
{
|
{
|
||||||
|
static const char *const aligntxt[] = { "chaotic", "neutral", "lawful" };
|
||||||
|
/* hu_stat[] from eat.c has trailing spaces which foul up comparisons;
|
||||||
|
for the "not hungry" case, there's no text hence no way to highlight */
|
||||||
|
static const char *const hutxt[] = {
|
||||||
|
"Satiated", "", "Hungry", "Weak", "Fainting", "Fainted", "Starved"
|
||||||
|
};
|
||||||
char *tmp, *how;
|
char *tmp, *how;
|
||||||
int sidx = 0, i = -1, dt = -1;
|
int sidx = 0, i = -1, dt = -1;
|
||||||
int coloridx = -1, successes = 0;
|
int coloridx = -1, successes = 0;
|
||||||
@@ -2459,10 +2488,6 @@ parse_status_hl2(char (*s)[QBUFSZ], boolean from_configfile)
|
|||||||
enum statusfields fld = BL_FLUSH;
|
enum statusfields fld = BL_FLUSH;
|
||||||
struct hilite_s hilite;
|
struct hilite_s hilite;
|
||||||
char tmpbuf[BUFSZ];
|
char tmpbuf[BUFSZ];
|
||||||
static const char *const aligntxt[] = { "chaotic", "neutral", "lawful" };
|
|
||||||
/* hu_stat[] from eat.c has trailing spaces which foul up comparisons */
|
|
||||||
static const char *const hutxt[] = { "Satiated", "", "Hungry", "Weak",
|
|
||||||
"Fainting", "Fainted", "Starved" };
|
|
||||||
|
|
||||||
/* Examples:
|
/* Examples:
|
||||||
3.6.1:
|
3.6.1:
|
||||||
@@ -2502,7 +2527,7 @@ parse_status_hl2(char (*s)[QBUFSZ], boolean from_configfile)
|
|||||||
int sf = 0; /* subfield count */
|
int sf = 0; /* subfield count */
|
||||||
int kidx;
|
int kidx;
|
||||||
|
|
||||||
txt = (const char *)0;
|
txt = (const char *) 0;
|
||||||
percent = numeric = always = FALSE;
|
percent = numeric = always = FALSE;
|
||||||
down = up = changed = FALSE;
|
down = up = changed = FALSE;
|
||||||
criticalhp = FALSE;
|
criticalhp = FALSE;
|
||||||
@@ -2736,9 +2761,6 @@ parse_status_hl2(char (*s)[QBUFSZ], boolean from_configfile)
|
|||||||
|
|
||||||
return (successes > 0);
|
return (successes > 0);
|
||||||
}
|
}
|
||||||
#endif /* STATUS_HILITES */
|
|
||||||
|
|
||||||
#ifdef STATUS_HILITES
|
|
||||||
|
|
||||||
static unsigned long
|
static unsigned long
|
||||||
query_conditions(void)
|
query_conditions(void)
|
||||||
@@ -3036,7 +3058,6 @@ hlattr2attrname(int attrib, char *buf, size_t bufsz)
|
|||||||
return (char *) 0;
|
return (char *) 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
struct _status_hilite_line_str {
|
struct _status_hilite_line_str {
|
||||||
int id;
|
int id;
|
||||||
int fld;
|
int fld;
|
||||||
@@ -3046,12 +3067,16 @@ struct _status_hilite_line_str {
|
|||||||
struct _status_hilite_line_str *next;
|
struct _status_hilite_line_str *next;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* these don't need to be in 'struct g' */
|
||||||
static struct _status_hilite_line_str *status_hilite_str = 0;
|
static struct _status_hilite_line_str *status_hilite_str = 0;
|
||||||
static int status_hilite_str_id = 0;
|
static int status_hilite_str_id = 0;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
status_hilite_linestr_add(int fld, struct hilite_s *hl,
|
status_hilite_linestr_add(
|
||||||
unsigned long mask, const char *str)
|
int fld,
|
||||||
|
struct hilite_s *hl,
|
||||||
|
unsigned long mask,
|
||||||
|
const char *str)
|
||||||
{
|
{
|
||||||
struct _status_hilite_line_str *tmp, *nxt;
|
struct _status_hilite_line_str *tmp, *nxt;
|
||||||
|
|
||||||
@@ -3426,8 +3451,9 @@ status_hilite_menu_choose_behavior(int fld)
|
|||||||
beh = BL_TH_NONE;
|
beh = BL_TH_NONE;
|
||||||
else if (res == -1) /* menu cancelled */
|
else if (res == -1) /* menu cancelled */
|
||||||
beh = (BL_TH_NONE - 1);
|
beh = (BL_TH_NONE - 1);
|
||||||
} else if (onlybeh != BL_TH_NONE)
|
} else if (onlybeh != BL_TH_NONE) {
|
||||||
beh = onlybeh;
|
beh = onlybeh;
|
||||||
|
}
|
||||||
destroy_nhwindow(tmpwin);
|
destroy_nhwindow(tmpwin);
|
||||||
if (res > 0) {
|
if (res > 0) {
|
||||||
beh = picks->item.a_int;
|
beh = picks->item.a_int;
|
||||||
@@ -3437,8 +3463,10 @@ status_hilite_menu_choose_behavior(int fld)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
status_hilite_menu_choose_updownboth(int fld, const char *str,
|
status_hilite_menu_choose_updownboth(
|
||||||
boolean ltok, boolean gtok)
|
int fld,
|
||||||
|
const char *str,
|
||||||
|
boolean ltok, boolean gtok)
|
||||||
{
|
{
|
||||||
int res, ret = NO_LTEQGT;
|
int res, ret = NO_LTEQGT;
|
||||||
winid tmpwin;
|
winid tmpwin;
|
||||||
|
|||||||
Reference in New Issue
Block a user