Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions 10 include/botl.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ enum statusfields {
BL_TITLE = 0,
BL_STR, BL_DX, BL_CO, BL_IN, BL_WI, BL_CH, /* 1..6 */
BL_ALIGN, BL_SCORE, BL_CAP, BL_GOLD, BL_ENE, BL_ENEMAX, /* 7..12 */
BL_XP, BL_AC, BL_HD, BL_TIME, BL_HUNGER, BL_HP, /* 13..18 */
BL_HPMAX, BL_LEVELDESC, BL_EXP, BL_CONDITION, /* 19..22 */
MAXBLSTATS /* [23] */
BL_XP, BL_AC, BL_HD, BL_TIME, BL_REALTIME, BL_HUNGER, /* 13..18 */
BL_HP, BL_HPMAX, BL_LEVELDESC, BL_EXP, BL_CONDITION, /* 19..23 */
MAXBLSTATS /* [24] */
};

enum relationships { NO_LTEQGT = -1,
Expand Down Expand Up @@ -265,4 +265,8 @@ struct istat_s {

extern const char *status_fieldnames[]; /* in botl.c */

#ifdef REALTIME_ON_BOTL
void stat_update_time(void);
#endif

#endif /* BOTL_H */
3 changes: 3 additions & 0 deletions 3 include/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,9 @@ typedef unsigned char uchar;
/* #define SCORE_ON_BOTL */ /* enable the 'showscore' option to
show estimated score on status line */

#define REALTIME_ON_BOTL /* enable the 'showrealtime' option to
show elapsed time */

/* FREE_ALL_MEMORY is neither experimental nor inadequately tested,
but it isn't necessary for successful operation of the program */
#define FREE_ALL_MEMORY /* free all memory at exit */
Expand Down
3 changes: 3 additions & 0 deletions 3 include/extern.h
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,9 @@ extern void max_rank_sz(void);
#ifdef SCORE_ON_BOTL
extern long botl_score(void);
#endif
#ifdef REALTIME_ON_BOTL
extern const char *botl_realtime(void);
#endif
extern int describe_level(char *);
extern void status_initialize(boolean);
extern void status_finish(void);
Expand Down
4 changes: 4 additions & 0 deletions 4 include/flag.h
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,10 @@ struct instance_flags {
uchar bouldersym; /* symbol for boulder display */
char prevmsg_window; /* type of old message window to use */
boolean extmenu; /* extended commands use menu interface */
#ifdef REALTIME_ON_BOTL
char show_realtime; /* type of time to show in status display */
char realtime_format; /* format of time shown */
#endif
#ifdef MICRO
boolean BIOS; /* use IBM or ST BIOS calls when appropriate */
#endif
Expand Down
6 changes: 6 additions & 0 deletions 6 include/optlist.h
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,12 @@ opt_##a,
#else
NHOPTB(rawio, 0, opt_in, set_in_config, Off, No, No, No, NoAlias,
(boolean *) 0)
#endif
#ifdef REALTIME_ON_BOTL
NHOPTC(realtime, 5, opt_in, set_in_game, Yes, Yes, No, Yes, NoAlias,
"show realtime in status line")
NHOPTC(realtime_format, 5, opt_in, set_in_game, No, Yes, No, Yes, NoAlias,
"format of realtime in status line")
#endif
NHOPTB(rest_on_space, 0, opt_in, set_in_game, Off, Yes, No, No, NoAlias,
&flags.rest_on_space)
Expand Down
68 changes: 65 additions & 3 deletions 68 src/botl.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ const char *const enc_stat[] = { "", "Burdened", "Stressed",

static const char *rank(void);
static void bot_via_windowport(void);
#ifndef REALTIME_ON_BOTL
static void stat_update_time(void);
#endif
#ifdef STATUS_HILITES
static unsigned long query_conditions(void);
static boolean status_hilite_remove(int);
Expand Down Expand Up @@ -409,6 +411,48 @@ botl_score(void)
}
#endif /* SCORE_ON_BOTL */

#ifdef REALTIME_ON_BOTL
const char *
botl_realtime(void)
{
time_t currenttime;

if (iflags.show_realtime == 'p') {
/* play time */
currenttime = urealtime.realtime + (getnow() - urealtime.start_timing);
} else if (iflags.show_realtime == 'w') {
/* wallclock time */
currenttime = getnow() - ubirthday;
} else {
return "";
}

static char buf[BUFSZ] = { 0 };
switch (iflags.realtime_format) {
case 's':
Sprintf(buf, "%ld", currenttime);
break;

case 'c':
Sprintf(buf, "%ld:%2.2ld", currenttime / 3600, (currenttime % 3600) / 60);
break;

case 'u':
default: {
long ss, mm, hh;
ss = currenttime % 60;
currenttime /= 60;
mm = currenttime % 60;
currenttime /= 60;
hh = currenttime;
Sprintf(buf, "%02ld:%02ld:%02ld", hh, mm, ss);
}
}
return buf;
}

#endif

/* provide the name of the current level for display by various ports */
int
describe_level(char *buf)
Expand Down Expand Up @@ -524,6 +568,7 @@ static struct istat_s initblstats[MAXBLSTATS] = {
INIT_BLSTAT("armor-class", " AC:%s", ANY_INT, 10, BL_AC),
INIT_BLSTAT("HD", " HD:%s", ANY_INT, 10, BL_HD),
INIT_BLSTAT("time", " T:%s", ANY_LONG, 20, BL_TIME),
INIT_BLSTAT("realtime", " %s", ANY_STR, 10, BL_REALTIME),
/* hunger used to be 'ANY_UINT'; see note below in bot_via_windowport() */
INIT_BLSTAT("hunger", " %s", ANY_INT, 40, BL_HUNGER),
INIT_BLSTATP("hitpoints", " HP:%s", ANY_INT, 10, BL_HPMAX, BL_HP),
Expand Down Expand Up @@ -811,6 +856,9 @@ bot_via_windowport(void)
/* Time (moves) */
g.blstats[idx][BL_TIME].a.a_long = g.moves;

/* Realtime */
Strcpy(g.blstats[idx][BL_REALTIME].val, botl_realtime());

/* Hunger */
/* note: u.uhs is unsigned, and 3.6.1's STATUS_HILITE defined
BL_HUNGER to be ANY_UINT, but that was the only non-int/non-long
Expand Down Expand Up @@ -939,18 +987,29 @@ bot_via_windowport(void)
}


/* update just the status lines' 'time' field */
/* update just the status lines' 'time' and 'realtime' fields */
#ifdef REALTIME_ON_BOTL
void
#else
static void
#endif
stat_update_time(void)
{
int idx = g.now_or_before_idx; /* no 0/1 toggle */
int fld = BL_TIME;
int fld;

/* Time (moves) */
fld = BL_TIME;
g.blstats[idx][fld].a.a_long = g.moves;
g.valset[fld] = FALSE;
eval_notify_windowport_field(fld, g.valset, idx);

/* Realtime */
fld = BL_REALTIME;
Strcpy(g.blstats[idx][fld].val, botl_realtime());
g.valset[fld] = FALSE;
eval_notify_windowport_field(fld, g.valset, idx);

if ((windowprocs.wincap2 & WC2_FLUSH_STATUS) != 0L)
status_update(BL_FLUSH, (genericptr_t) 0, 0, 0,
NO_COLOR, (unsigned long *) 0);
Expand Down Expand Up @@ -1241,6 +1300,7 @@ evaluate_and_notify_windowport(boolean *valsetlist, int idx)
if (((i == BL_SCORE) && !flags.showscore)
|| ((i == BL_EXP) && !flags.showexp)
|| ((i == BL_TIME) && !flags.time)
|| ((i == BL_REALTIME) && !iflags.show_realtime)
|| ((i == BL_HD) && !Upolyd)
|| ((i == BL_XP || i == BL_EXP) && Upolyd)) {
notpresent++;
Expand Down Expand Up @@ -1308,7 +1368,8 @@ status_initialize(boolean reassessment) /* TRUE: just recheck fields w/o other i
: (fld == BL_EXP) ? (boolean) (flags.showexp && !Upolyd)
: (fld == BL_XP) ? (boolean) !Upolyd
: (fld == BL_HD) ? (boolean) Upolyd
: TRUE;
: (fld == BL_REALTIME) ? (boolean) iflags.show_realtime
: TRUE;

fieldname = initblstats[i].fldname;
fieldfmt = (fld == BL_TITLE && iflags.wc2_hitpointbar) ? "%-30.30s"
Expand Down Expand Up @@ -1768,6 +1829,7 @@ static struct fieldid_t {
{ "ac", BL_AC },
{ "hit-dice", BL_HD },
{ "turns", BL_TIME },
{ "realtime", BL_REALTIME },
{ "hp", BL_HP },
{ "hp-max", BL_HPMAX },
{ "dgn", BL_LEVELDESC },
Expand Down
157 changes: 157 additions & 0 deletions 157 src/options.c
Original file line number Diff line number Diff line change
Expand Up @@ -2603,6 +2603,163 @@ optfn_race(int optidx, int req, boolean negated, char *opts, char *op)
return optn_ok;
}

#ifdef REALTIME_ON_BOTL
static int
optfn_realtime(int optidx, int req, boolean negated, char *opts, char *op)
{
int retval = optn_ok;
int tmp;

if (req == do_init) {
return optn_ok;
}
if (req == do_set) {
/* '\0': disabled
'p': play time
'w': wallclock time
*/

if (op == empty_optstr) {
tmp = negated ? '\0' : 'p';
} else {
if (negated) {
bad_negation(allopt[optidx].name, TRUE);
return optn_err;
}
tmp = lowc(*op);
}
switch (tmp) {
case 'd':
tmp = '\0';
/*FALLTHRU*/
case '\0':
case 'p':
case 'w':
iflags.show_realtime = (char) tmp;
break;
default:
config_error_add("Unknown %s parameter '%s'", allopt[optidx].name,
op);
retval = optn_err;
}
return retval;
}
if (req == get_val) {
if (!opts)
return optn_err;
opts[0] = '\0';
tmp = iflags.show_realtime;
Sprintf(opts, "%s", (tmp == 'p') ? "play time"
: (tmp == 'w') ? "wallclock time"
: "disabled");
return optn_ok;
}
if (req == do_handler) {
winid tmpwin;
anything any;
menu_item *window_pick = (menu_item *) 0;

tmpwin = create_nhwindow(NHW_MENU);
start_menu(tmpwin, MENU_BEHAVE_STANDARD);
any = cg.zeroany;
any.a_char = 'd';
add_menu(tmpwin, &nul_glyphinfo, &any, 'd',
0, ATR_NONE, "disabled", MENU_ITEMFLAGS_NONE);
any.a_char = 'p';
add_menu(tmpwin, &nul_glyphinfo, &any, 'p',
0, ATR_NONE, "play time", MENU_ITEMFLAGS_NONE);
any.a_char = 'w';
add_menu(tmpwin, &nul_glyphinfo, &any, 'w',
0, ATR_NONE, "wallclock time", MENU_ITEMFLAGS_NONE);
end_menu(tmpwin, "Type of time to show on status bar:");
if (select_menu(tmpwin, PICK_ONE, &window_pick) > 0) {
tmp = window_pick->item.a_char;
iflags.show_realtime = tmp == 'd' ? '\0' : tmp;
free((genericptr_t) window_pick);

status_initialize(REASSESS_ONLY);
}
destroy_nhwindow(tmpwin);
return optn_ok;
}
return optn_ok;
}

static int
optfn_realtime_format(int optidx, int req, boolean negated, char *opts, char *op)
{
int retval = optn_ok;
int tmp;

if (req == do_init) {
return optn_ok;
}
if (req == do_set) {
/* realtime_format:seconds, condensed, units */

if (op == empty_optstr) {
config_error_add("%s must take a parameter", allopt[optidx].name);
return optn_err;
}
if (negated) {
bad_negation(allopt[optidx].name, TRUE);
return optn_err;
}
tmp = lowc(*op);
switch (tmp) {
case 's':
case 'c':
case 'u':
iflags.realtime_format = (char) tmp;
break;
default:
config_error_add("Unknown %s parameter '%s'", allopt[optidx].name,
op);
retval = optn_err;
}
return retval;
}
if (req == get_val) {
if (!opts)
return optn_err;
opts[0] = '\0';
tmp = iflags.realtime_format;
Sprintf(opts, "%s", (tmp == 's') ? "seconds"
: (tmp == 'c') ? "condensed"
: "units");
return optn_ok;
}
if (req == do_handler) {
winid tmpwin;
anything any;
menu_item *window_pick = (menu_item *) 0;

tmpwin = create_nhwindow(NHW_MENU);
start_menu(tmpwin, MENU_BEHAVE_STANDARD);
any = cg.zeroany;
any.a_char = 's';
add_menu(tmpwin, &nul_glyphinfo, &any, 's',
0, ATR_NONE, "seconds (s)", MENU_ITEMFLAGS_NONE);
any.a_char = 'c';
add_menu(tmpwin, &nul_glyphinfo, &any, 'c',
0, ATR_NONE, "condensed (h:mm)", MENU_ITEMFLAGS_NONE);
any.a_char = 'u';
add_menu(tmpwin, &nul_glyphinfo, &any, 'u',
0, ATR_NONE, "units (hh:mm:ss)", MENU_ITEMFLAGS_NONE);
end_menu(tmpwin, "Format used by realtime display:");
if (select_menu(tmpwin, PICK_ONE, &window_pick) > 0) {
iflags.realtime_format = window_pick->item.a_char;
free((genericptr_t) window_pick);

status_initialize(REASSESS_ONLY);
}
destroy_nhwindow(tmpwin);
return optn_ok;
}
return optn_ok;
}
#endif

static int
optfn_roguesymset(int optidx, int req, boolean negated UNUSED,
char *opts, char *op)
Expand Down
Loading
Morty Proxy This is a proxified and sanitized view of the page, visit original site.