more reformatting - label placement
Indent all labels one space. Having uniform placement makes spotting them much easier. (Having no indent at all would impact the change bars of 'git diff'. Those display the last unindented line--which doesn't start with punctuation--occuring before each band of changes, so usually the name of the function being changed now that we no longer have unindented K&R-style function argument declarations.) While in there, shorten or split various wide lines and replace a few tabs with spaces.
This commit is contained in:
+29
-13
@@ -575,7 +575,8 @@ const struct condmap condition_aliases[] = {
|
|||||||
{ "opt_in", BL_MASK_BAREH | BL_MASK_BUSY | BL_MASK_GLOWHANDS
|
{ "opt_in", BL_MASK_BAREH | BL_MASK_BUSY | BL_MASK_GLOWHANDS
|
||||||
| BL_MASK_HELD | BL_MASK_ICY | BL_MASK_PARLYZ
|
| BL_MASK_HELD | BL_MASK_ICY | BL_MASK_PARLYZ
|
||||||
| BL_MASK_SLEEPING | BL_MASK_SLIPPERY
|
| BL_MASK_SLEEPING | BL_MASK_SLIPPERY
|
||||||
| BL_MASK_SUBMERGED | BL_MASK_TETHERED | BL_MASK_TRAPPED
|
| BL_MASK_SUBMERGED | BL_MASK_TETHERED
|
||||||
|
| BL_MASK_TRAPPED
|
||||||
| BL_MASK_UNCONSC | BL_MASK_WOUNDEDL
|
| BL_MASK_UNCONSC | BL_MASK_WOUNDEDL
|
||||||
| BL_MASK_HOLDING },
|
| BL_MASK_HOLDING },
|
||||||
};
|
};
|
||||||
@@ -1298,7 +1299,9 @@ evaluate_and_notify_windowport(boolean *valsetlist, int idx)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
status_initialize(boolean reassessment) /* TRUE: just recheck fields w/o other initialization */
|
status_initialize(
|
||||||
|
boolean reassessment) /* TRUE: just recheck fields without other
|
||||||
|
* initialization */
|
||||||
{
|
{
|
||||||
enum statusfields fld;
|
enum statusfields fld;
|
||||||
boolean fldenabl;
|
boolean fldenabl;
|
||||||
@@ -1633,7 +1636,8 @@ percentage(struct istat_s *bl, struct istat_s *maxbl)
|
|||||||
from a non-zero input; note: if we ever change to something like
|
from a non-zero input; note: if we ever change to something like
|
||||||
((((1000 * val) / max) + 5) / 10) for a rounded result, we'll
|
((((1000 * val) / max) + 5) / 10) for a rounded result, we'll
|
||||||
also need to check for and convert false 100 to 99 */
|
also need to check for and convert false 100 to 99 */
|
||||||
if (result == 0 && (ival != 0 || lval != 0L || uval != 0U || ulval != 0UL))
|
if (result == 0
|
||||||
|
&& (ival != 0 || lval != 0L || uval != 0U || ulval != 0UL))
|
||||||
result = 1;
|
result = 1;
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
@@ -1863,12 +1867,13 @@ status_eval_next_unhilite(void)
|
|||||||
struct istat_s *curr;
|
struct istat_s *curr;
|
||||||
long next_unhilite, this_unhilite;
|
long next_unhilite, this_unhilite;
|
||||||
|
|
||||||
g.bl_hilite_moves = g.moves; /* simpllfied; used to try to encode fractional
|
g.bl_hilite_moves = g.moves; /* simpllfied; at one point we used to try
|
||||||
* amounts for multiple moves within same turn */
|
* to encode fractional amounts for multiple
|
||||||
|
* moves within same turn */
|
||||||
/* figure out whether an unhilight needs to be performed now */
|
/* figure out whether an unhilight needs to be performed now */
|
||||||
next_unhilite = 0L;
|
next_unhilite = 0L;
|
||||||
for (i = 0; i < MAXBLSTATS; ++i) {
|
for (i = 0; i < MAXBLSTATS; ++i) {
|
||||||
curr = &g.blstats[0][i]; /* g.blstats[0][*].time == g.blstats[1][*].time */
|
curr = &g.blstats[0][i]; /* blstats[0][*].time == blstats[1][*].time */
|
||||||
|
|
||||||
if (curr->chg) {
|
if (curr->chg) {
|
||||||
struct istat_s *prev = &g.blstats[1][i];
|
struct istat_s *prev = &g.blstats[1][i];
|
||||||
@@ -2282,8 +2287,11 @@ splitsubfields(char *str, char ***sfarr, int maxsf)
|
|||||||
#undef MAX_SUBFIELDS
|
#undef MAX_SUBFIELDS
|
||||||
|
|
||||||
static boolean
|
static boolean
|
||||||
is_fld_arrayvalues(const char *str, const char *const *arr,
|
is_fld_arrayvalues(
|
||||||
int arrmin, int arrmax, int *retidx)
|
const char *str,
|
||||||
|
const char *const *arr,
|
||||||
|
int arrmin, int arrmax,
|
||||||
|
int *retidx)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
@@ -2296,7 +2304,10 @@ is_fld_arrayvalues(const char *str, const char *const *arr,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
query_arrayvalue(const char *querystr, const char *const *arr, int arrmin, int arrmax)
|
query_arrayvalue(
|
||||||
|
const char *querystr,
|
||||||
|
const char *const *arr,
|
||||||
|
int arrmin, int arrmax)
|
||||||
{
|
{
|
||||||
int i, res, ret = arrmin - 1;
|
int i, res, ret = arrmin - 1;
|
||||||
winid tmpwin;
|
winid tmpwin;
|
||||||
@@ -3296,7 +3307,8 @@ status_hilite_menu_choose_behavior(int fld)
|
|||||||
nopts++;
|
nopts++;
|
||||||
}
|
}
|
||||||
|
|
||||||
Sprintf(buf, "Select %s field hilite behavior:", initblstats[fld].fldname);
|
Sprintf(buf, "Select %s field hilite behavior:",
|
||||||
|
initblstats[fld].fldname);
|
||||||
end_menu(tmpwin, buf);
|
end_menu(tmpwin, buf);
|
||||||
|
|
||||||
if (nopts > 1) {
|
if (nopts > 1) {
|
||||||
@@ -3642,7 +3654,9 @@ choose_value:
|
|||||||
hilite.rel = TXT_VALUE;
|
hilite.rel = TXT_VALUE;
|
||||||
Strcpy(hilite.textmatch, enc_stat[rv]);
|
Strcpy(hilite.textmatch, enc_stat[rv]);
|
||||||
} else if (fld == BL_ALIGN) {
|
} else if (fld == BL_ALIGN) {
|
||||||
static const char *aligntxt[] = { "chaotic", "neutral", "lawful" };
|
static const char *aligntxt[] = {
|
||||||
|
"chaotic", "neutral", "lawful"
|
||||||
|
};
|
||||||
int rv = query_arrayvalue(qry_buf,
|
int rv = query_arrayvalue(qry_buf,
|
||||||
aligntxt, 0, 2 + 1);
|
aligntxt, 0, 2 + 1);
|
||||||
|
|
||||||
@@ -3830,11 +3844,13 @@ status_hilite_remove(int id)
|
|||||||
hlprev->next = hl->next;
|
hlprev->next = hl->next;
|
||||||
} else {
|
} else {
|
||||||
g.blstats[0][fld].thresholds = hl->next;
|
g.blstats[0][fld].thresholds = hl->next;
|
||||||
g.blstats[1][fld].thresholds = g.blstats[0][fld].thresholds;
|
g.blstats[1][fld].thresholds
|
||||||
|
= g.blstats[0][fld].thresholds;
|
||||||
}
|
}
|
||||||
if (g.blstats[0][fld].hilite_rule == hl) {
|
if (g.blstats[0][fld].hilite_rule == hl) {
|
||||||
g.blstats[0][fld].hilite_rule
|
g.blstats[0][fld].hilite_rule
|
||||||
= g.blstats[1][fld].hilite_rule = (struct hilite_s *) 0;
|
= g.blstats[1][fld].hilite_rule
|
||||||
|
= (struct hilite_s *) 0;
|
||||||
g.blstats[0][fld].time = g.blstats[1][fld].time = 0L;
|
g.blstats[0][fld].time = g.blstats[1][fld].time = 0L;
|
||||||
}
|
}
|
||||||
free((genericptr_t) hl);
|
free((genericptr_t) hl);
|
||||||
|
|||||||
@@ -2074,7 +2074,8 @@ struct ext_func_tab extcmdlist[] = {
|
|||||||
doborn, IFBURIED | WIZMODECMD, NULL },
|
doborn, IFBURIED | WIZMODECMD, NULL },
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
{ '\0', "wizbury", "bury objs under and around you",
|
{ '\0', "wizbury", "bury objs under and around you",
|
||||||
wiz_debug_cmd_bury, IFBURIED | AUTOCOMPLETE | WIZMODECMD, NULL },
|
wiz_debug_cmd_bury, IFBURIED | AUTOCOMPLETE | WIZMODECMD,
|
||||||
|
NULL },
|
||||||
#endif
|
#endif
|
||||||
{ C('e'), "wizdetect", "reveal hidden things within a small radius",
|
{ C('e'), "wizdetect", "reveal hidden things within a small radius",
|
||||||
wiz_detect, IFBURIED | WIZMODECMD, NULL },
|
wiz_detect, IFBURIED | WIZMODECMD, NULL },
|
||||||
|
|||||||
@@ -230,9 +230,9 @@ dig_check(struct monst *madeby, boolean verbose, int x, int y)
|
|||||||
static int
|
static int
|
||||||
dig(void)
|
dig(void)
|
||||||
{
|
{
|
||||||
register struct rm *lev;
|
struct rm *lev;
|
||||||
register xchar dpx = g.context.digging.pos.x, dpy = g.context.digging.pos.y;
|
xchar dpx = g.context.digging.pos.x, dpy = g.context.digging.pos.y;
|
||||||
register boolean ispick = uwep && is_pick(uwep);
|
boolean ispick = uwep && is_pick(uwep);
|
||||||
const char *verb = (!uwep || is_pick(uwep)) ? "dig into" : "chop through";
|
const char *verb = (!uwep || is_pick(uwep)) ? "dig into" : "chop through";
|
||||||
|
|
||||||
lev = &levl[dpx][dpy];
|
lev = &levl[dpx][dpy];
|
||||||
@@ -1471,7 +1471,8 @@ zap_dig(void)
|
|||||||
coord cc;
|
coord cc;
|
||||||
struct trap *adjpit = t_at(zx, zy);
|
struct trap *adjpit = t_at(zx, zy);
|
||||||
|
|
||||||
if ((diridx != DIR_ERR) && !conjoined_pits(adjpit, trap_with_u, FALSE)) {
|
if (diridx != DIR_ERR
|
||||||
|
&& !conjoined_pits(adjpit, trap_with_u, FALSE)) {
|
||||||
digdepth = 0; /* limited to the adjacent location only */
|
digdepth = 0; /* limited to the adjacent location only */
|
||||||
if (!(adjpit && is_pit(adjpit->ttyp))) {
|
if (!(adjpit && is_pit(adjpit->ttyp))) {
|
||||||
char buf[BUFSZ];
|
char buf[BUFSZ];
|
||||||
|
|||||||
+23
-16
@@ -219,7 +219,7 @@ str_end_is(const char *str, const char *chkstr)
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* return the max line length from buffer comprising of newline-separated strings */
|
/* return max line length from buffer comprising newline-separated strings */
|
||||||
int
|
int
|
||||||
str_lines_maxlen(const char *str)
|
str_lines_maxlen(const char *str)
|
||||||
{
|
{
|
||||||
@@ -396,7 +396,8 @@ onlyspace(const char *s)
|
|||||||
|
|
||||||
/* expand tabs into proper number of spaces (in place) */
|
/* expand tabs into proper number of spaces (in place) */
|
||||||
char *
|
char *
|
||||||
tabexpand(char *sbuf) /* assumed to be [BUFSZ] but can be smaller provided that
|
tabexpand(
|
||||||
|
char *sbuf) /* assumed to be [BUFSZ] but can be smaller provided that
|
||||||
* expanded string fits; expansion bigger than BUFSZ-1
|
* expanded string fits; expansion bigger than BUFSZ-1
|
||||||
* will be truncated */
|
* will be truncated */
|
||||||
{
|
{
|
||||||
@@ -521,9 +522,10 @@ strsubst(char *bp, const char *orig, const char *replacement)
|
|||||||
if N is 0, substitute all occurrences; returns the number of subsitutions;
|
if N is 0, substitute all occurrences; returns the number of subsitutions;
|
||||||
maximum output length is BUFSZ (BUFSZ-1 chars + terminating '\0') */
|
maximum output length is BUFSZ (BUFSZ-1 chars + terminating '\0') */
|
||||||
int
|
int
|
||||||
strNsubst(char *inoutbuf, /* current string, and result buffer */
|
strNsubst(
|
||||||
const char *orig, /* old substring; if "" then insert in front of Nth char */
|
char *inoutbuf, /* current string, and result buffer */
|
||||||
const char *replacement, /* new substring; if "" then delete old substring */
|
const char *orig, /* old substring; if "", insert in front of Nth char */
|
||||||
|
const char *replacement, /* new substring; if "", delete old substring */
|
||||||
int n) /* which occurrence to replace; 0 => all */
|
int n) /* which occurrence to replace; 0 => all */
|
||||||
{
|
{
|
||||||
char *bp, *op, workbuf[BUFSZ];
|
char *bp, *op, workbuf[BUFSZ];
|
||||||
@@ -732,7 +734,9 @@ pmatchi(const char *patrn, const char *strng)
|
|||||||
return pmatch_internal(patrn, strng, TRUE, (const char *) 0);
|
return pmatch_internal(patrn, strng, TRUE, (const char *) 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* case-insensitive wildcard fuzzymatch */
|
#if 0
|
||||||
|
/* case-insensitive wildcard fuzzymatch;
|
||||||
|
NEVER WORKED AS INTENDED but fortunately isn't needed */
|
||||||
boolean
|
boolean
|
||||||
pmatchz(const char *patrn, const char *strng)
|
pmatchz(const char *patrn, const char *strng)
|
||||||
{
|
{
|
||||||
@@ -741,6 +745,7 @@ pmatchz(const char *patrn, const char *strng)
|
|||||||
|
|
||||||
return pmatch_internal(patrn, strng, TRUE, fuzzychars);
|
return pmatch_internal(patrn, strng, TRUE, fuzzychars);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef STRNCMPI
|
#ifndef STRNCMPI
|
||||||
/* case insensitive counted string comparison */
|
/* case insensitive counted string comparison */
|
||||||
@@ -884,14 +889,15 @@ static void
|
|||||||
set_random(unsigned long seed,
|
set_random(unsigned long seed,
|
||||||
int (*fn)(int) UNUSED)
|
int (*fn)(int) UNUSED)
|
||||||
{
|
{
|
||||||
/* the types are different enough here that sweeping the different
|
/*
|
||||||
* routine names into one via #defines is even more confusing
|
* The types are different enough here that sweeping the different
|
||||||
|
* routine names into one via #defines is even more confusing.
|
||||||
*/
|
*/
|
||||||
# ifdef RANDOM /* srandom() from sys/share/random.c */
|
# ifdef RANDOM /* srandom() from sys/share/random.c */
|
||||||
srandom((unsigned int) seed);
|
srandom((unsigned int) seed);
|
||||||
# else
|
# else
|
||||||
# if defined(__APPLE__) || defined(BSD) || defined(LINUX) || defined(ULTRIX) \
|
# if defined(__APPLE__) || defined(BSD) || defined(LINUX) \
|
||||||
|| defined(CYGWIN32) /* system srandom() */
|
|| defined(ULTRIX) || defined(CYGWIN32) /* system srandom() */
|
||||||
# if defined(BSD) && !defined(POSIX_TYPES) && defined(SUNOS4)
|
# if defined(BSD) && !defined(POSIX_TYPES) && defined(SUNOS4)
|
||||||
(void)
|
(void)
|
||||||
# endif
|
# endif
|
||||||
@@ -1265,14 +1271,16 @@ DISABLE_WARNING_FORMAT_NONLITERAL
|
|||||||
* Wrap reasons:
|
* Wrap reasons:
|
||||||
* 1. If there are any platform issues, we have one spot to fix them -
|
* 1. If there are any platform issues, we have one spot to fix them -
|
||||||
* snprintf is a routine with a troubling history of bad implementations.
|
* snprintf is a routine with a troubling history of bad implementations.
|
||||||
* 2. Add combersome error checking in one spot. Problems with text wrangling
|
* 2. Add combersome error checking in one spot. Problems with text
|
||||||
* do not have to be fatal.
|
* wrangling do not have to be fatal.
|
||||||
* 3. Gcc 9+ will issue a warning unless the return value is used.
|
* 3. Gcc 9+ will issue a warning unless the return value is used.
|
||||||
* Annoyingly, explicitly casting to void does not remove the error.
|
* Annoyingly, explicitly casting to void does not remove the error.
|
||||||
* So, use the result - see reason #2.
|
* So, use the result - see reason #2.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
nh_snprintf(const char *func, int line, char *str, size_t size,
|
nh_snprintf(
|
||||||
|
const char *func, int line,
|
||||||
|
char *str, size_t size,
|
||||||
const char *fmt, ...)
|
const char *fmt, ...)
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
@@ -1287,10 +1295,9 @@ nh_snprintf(const char *func, int line, char *str, size_t size,
|
|||||||
va_end(ap);
|
va_end(ap);
|
||||||
if (n < 0 || (size_t) n >= size) { /* is there a problem? */
|
if (n < 0 || (size_t) n >= size) { /* is there a problem? */
|
||||||
impossible("snprintf %s: func %s, file line %d",
|
impossible("snprintf %s: func %s, file line %d",
|
||||||
n < 0 ? "format error"
|
(n < 0) ? "format error" : "overflow",
|
||||||
: "overflow",
|
|
||||||
func, line);
|
func, line);
|
||||||
str[size-1] = 0; /* make sure it is nul terminated */
|
str[size - 1] = '\0'; /* make sure it is nul terminated */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+8
-5
@@ -57,8 +57,10 @@ get_map(int col, int row, schar bg_typ)
|
|||||||
return levl[col][row].typ;
|
return levl[col][row].typ;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const int dirs[16] = { -1, -1 /**/, -1, 0 /**/, -1, 1 /**/, 0, -1 /**/,
|
static const int dirs[16] = {
|
||||||
0, 1 /**/, 1, -1 /**/, 1, 0 /**/, 1, 1 };
|
-1, -1 /**/, -1, 0 /**/, -1, 1 /**/, 0, -1 /**/,
|
||||||
|
0, 1 /**/, 1, -1 /**/, 1, 0 /**/, 1, 1
|
||||||
|
};
|
||||||
|
|
||||||
static void
|
static void
|
||||||
pass_one(schar bg_typ, schar fg_typ)
|
pass_one(schar bg_typ, schar fg_typ)
|
||||||
@@ -257,8 +259,8 @@ join_map(schar bg_typ, schar fg_typ)
|
|||||||
g.n_loc_filled = 0;
|
g.n_loc_filled = 0;
|
||||||
flood_fill_rm(i, j, g.nroom + ROOMOFFSET, FALSE, FALSE);
|
flood_fill_rm(i, j, g.nroom + ROOMOFFSET, FALSE, FALSE);
|
||||||
if (g.n_loc_filled > 3) {
|
if (g.n_loc_filled > 3) {
|
||||||
add_room(g.min_rx, g.min_ry, g.max_rx, g.max_ry, FALSE, OROOM,
|
add_room(g.min_rx, g.min_ry, g.max_rx, g.max_ry,
|
||||||
TRUE);
|
FALSE, OROOM, TRUE);
|
||||||
g.rooms[g.nroom - 1].irregular = TRUE;
|
g.rooms[g.nroom - 1].irregular = TRUE;
|
||||||
if (g.nroom >= (MAXNROFROOMS * 2))
|
if (g.nroom >= (MAXNROFROOMS * 2))
|
||||||
goto joinm;
|
goto joinm;
|
||||||
@@ -285,7 +287,8 @@ joinm:
|
|||||||
* so don't call sort_rooms(), which can screw up the roomno's
|
* so don't call sort_rooms(), which can screw up the roomno's
|
||||||
* validity in the levl structure.
|
* validity in the levl structure.
|
||||||
*/
|
*/
|
||||||
for (croom = &g.rooms[0], croom2 = croom + 1; croom2 < &g.rooms[g.nroom];) {
|
for (croom = &g.rooms[0], croom2 = croom + 1;
|
||||||
|
croom2 < &g.rooms[g.nroom]; ) {
|
||||||
/* pick random starting and end locations for "corridor" */
|
/* pick random starting and end locations for "corridor" */
|
||||||
if (!somexy(croom, &sm) || !somexy(croom2, &em)) {
|
if (!somexy(croom, &sm) || !somexy(croom2, &em)) {
|
||||||
/* ack! -- the level is going to be busted */
|
/* ack! -- the level is going to be busted */
|
||||||
|
|||||||
+2
-1
@@ -526,7 +526,8 @@ mkswamp(void) /* Michiel Huisjes & Fred de Wilde */
|
|||||||
sroom->rtype = SWAMP;
|
sroom->rtype = SWAMP;
|
||||||
for (sx = sroom->lx; sx <= sroom->hx; sx++)
|
for (sx = sroom->lx; sx <= sroom->hx; sx++)
|
||||||
for (sy = sroom->ly; sy <= sroom->hy; sy++) {
|
for (sy = sroom->ly; sy <= sroom->hy; sy++) {
|
||||||
if (!IS_ROOM(levl[sx][sy].typ) || (int) levl[sx][sy].roomno != rmno)
|
if (!IS_ROOM(levl[sx][sy].typ)
|
||||||
|
|| (int) levl[sx][sy].roomno != rmno)
|
||||||
continue;
|
continue;
|
||||||
if (!OBJ_AT(sx, sy) && !MON_AT(sx, sy) && !t_at(sx, sy)
|
if (!OBJ_AT(sx, sy) && !MON_AT(sx, sy) && !t_at(sx, sy)
|
||||||
&& !nexttodoor(sx, sy)) {
|
&& !nexttodoor(sx, sy)) {
|
||||||
|
|||||||
+8
-3
@@ -213,14 +213,18 @@ pri_move(struct monst *priest)
|
|||||||
|
|
||||||
/* exclusively for mktemple() */
|
/* exclusively for mktemple() */
|
||||||
void
|
void
|
||||||
priestini(d_level *lvl, struct mkroom *sroom, int sx, int sy,
|
priestini(
|
||||||
|
d_level *lvl,
|
||||||
|
struct mkroom *sroom,
|
||||||
|
int sx, int sy,
|
||||||
boolean sanctum) /* is it the seat of the high priest? */
|
boolean sanctum) /* is it the seat of the high priest? */
|
||||||
{
|
{
|
||||||
struct monst *priest;
|
struct monst *priest;
|
||||||
struct obj *otmp;
|
struct obj *otmp;
|
||||||
int cnt;
|
int cnt;
|
||||||
int px = 0, py = 0, i, si = rn2(N_DIRS);
|
int px = 0, py = 0, i, si = rn2(N_DIRS);
|
||||||
struct permonst *prim = &mons[sanctum ? PM_HIGH_CLERIC : PM_ALIGNED_CLERIC];
|
struct permonst *prim = &mons[sanctum ? PM_HIGH_CLERIC
|
||||||
|
: PM_ALIGNED_CLERIC];
|
||||||
|
|
||||||
for (i = 0; i < N_DIRS; i++) {
|
for (i = 0; i < N_DIRS; i++) {
|
||||||
px = sx + xdir[DIR_CLAMP(i+si)];
|
px = sx + xdir[DIR_CLAMP(i+si)];
|
||||||
@@ -707,7 +711,8 @@ reset_hostility(struct monst *roamer)
|
|||||||
}
|
}
|
||||||
|
|
||||||
boolean
|
boolean
|
||||||
in_your_sanctuary(struct monst *mon, /* if non-null, <mx,my> overrides <x,y> */
|
in_your_sanctuary(
|
||||||
|
struct monst *mon, /* if non-null, <mx,my> overrides <x,y> */
|
||||||
xchar x, xchar y)
|
xchar x, xchar y)
|
||||||
{
|
{
|
||||||
register char roomno;
|
register char roomno;
|
||||||
|
|||||||
+71
-43
@@ -617,27 +617,32 @@ save_regions(NHFILE* nhfp)
|
|||||||
if (!perform_bwrite(nhfp))
|
if (!perform_bwrite(nhfp))
|
||||||
goto skip_lots;
|
goto skip_lots;
|
||||||
if (nhfp->structlevel) {
|
if (nhfp->structlevel) {
|
||||||
bwrite(nhfp->fd, (genericptr_t) &g.moves, sizeof (g.moves)); /* timestamp */
|
/* timestamp */
|
||||||
|
bwrite(nhfp->fd, (genericptr_t) &g.moves, sizeof (g.moves));
|
||||||
bwrite(nhfp->fd, (genericptr_t) &g.n_regions, sizeof (g.n_regions));
|
bwrite(nhfp->fd, (genericptr_t) &g.n_regions, sizeof (g.n_regions));
|
||||||
}
|
}
|
||||||
for (i = 0; i < g.n_regions; i++) {
|
for (i = 0; i < g.n_regions; i++) {
|
||||||
if (nhfp->structlevel) {
|
if (nhfp->structlevel) {
|
||||||
bwrite(nhfp->fd, (genericptr_t) &g.regions[i]->bounding_box, sizeof (NhRect));
|
bwrite(nhfp->fd, (genericptr_t) &g.regions[i]->bounding_box,
|
||||||
bwrite(nhfp->fd, (genericptr_t) &g.regions[i]->nrects, sizeof (short));
|
sizeof (NhRect));
|
||||||
|
bwrite(nhfp->fd, (genericptr_t) &g.regions[i]->nrects,
|
||||||
|
sizeof (short));
|
||||||
}
|
}
|
||||||
for (j = 0; j < g.regions[i]->nrects; j++) {
|
for (j = 0; j < g.regions[i]->nrects; j++) {
|
||||||
if (nhfp->structlevel)
|
if (nhfp->structlevel)
|
||||||
bwrite(nhfp->fd, (genericptr_t) &g.regions[i]->rects[j], sizeof (NhRect));
|
bwrite(nhfp->fd, (genericptr_t) &g.regions[i]->rects[j],
|
||||||
|
sizeof (NhRect));
|
||||||
}
|
}
|
||||||
if (nhfp->structlevel)
|
if (nhfp->structlevel)
|
||||||
bwrite(nhfp->fd, (genericptr_t) &g.regions[i]->attach_2_u, sizeof (boolean));
|
bwrite(nhfp->fd, (genericptr_t) &g.regions[i]->attach_2_u,
|
||||||
|
sizeof (boolean));
|
||||||
n = 0;
|
n = 0;
|
||||||
|
|
||||||
if (nhfp->structlevel)
|
if (nhfp->structlevel)
|
||||||
bwrite(nhfp->fd, (genericptr_t) &g.regions[i]->attach_2_m, sizeof (unsigned));
|
bwrite(nhfp->fd, (genericptr_t) &g.regions[i]->attach_2_m,
|
||||||
|
sizeof (unsigned));
|
||||||
|
|
||||||
n = g.regions[i]->enter_msg != (const char *)0 ?
|
n = !g.regions[i]->enter_msg ? 0 : strlen(g.regions[i]->enter_msg);
|
||||||
strlen(g.regions[i]->enter_msg) : 0;
|
|
||||||
if (nhfp->structlevel)
|
if (nhfp->structlevel)
|
||||||
bwrite(nhfp->fd, (genericptr_t) &n, sizeof n);
|
bwrite(nhfp->fd, (genericptr_t) &n, sizeof n);
|
||||||
|
|
||||||
@@ -645,8 +650,7 @@ save_regions(NHFILE* nhfp)
|
|||||||
if (nhfp->structlevel)
|
if (nhfp->structlevel)
|
||||||
bwrite(nhfp->fd, (genericptr_t) g.regions[i]->enter_msg, n);
|
bwrite(nhfp->fd, (genericptr_t) g.regions[i]->enter_msg, n);
|
||||||
}
|
}
|
||||||
n = g.regions[i]->leave_msg != (const char *)0 ?
|
n = !g.regions[i]->leave_msg ? 0 : strlen(g.regions[i]->leave_msg);
|
||||||
strlen(g.regions[i]->leave_msg) : 0;
|
|
||||||
if (nhfp->structlevel)
|
if (nhfp->structlevel)
|
||||||
bwrite(nhfp->fd, (genericptr_t) &n, sizeof n);
|
bwrite(nhfp->fd, (genericptr_t) &n, sizeof n);
|
||||||
|
|
||||||
@@ -656,15 +660,24 @@ save_regions(NHFILE* nhfp)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (nhfp->structlevel) {
|
if (nhfp->structlevel) {
|
||||||
bwrite(nhfp->fd, (genericptr_t) &g.regions[i]->ttl, sizeof (long));
|
bwrite(nhfp->fd, (genericptr_t) &g.regions[i]->ttl,
|
||||||
bwrite(nhfp->fd, (genericptr_t) &g.regions[i]->expire_f, sizeof (short));
|
sizeof (long));
|
||||||
bwrite(nhfp->fd, (genericptr_t) &g.regions[i]->can_enter_f, sizeof (short));
|
bwrite(nhfp->fd, (genericptr_t) &g.regions[i]->expire_f,
|
||||||
bwrite(nhfp->fd, (genericptr_t) &g.regions[i]->enter_f, sizeof (short));
|
sizeof (short));
|
||||||
bwrite(nhfp->fd, (genericptr_t) &g.regions[i]->can_leave_f, sizeof (short));
|
bwrite(nhfp->fd, (genericptr_t) &g.regions[i]->can_enter_f,
|
||||||
bwrite(nhfp->fd, (genericptr_t) &g.regions[i]->leave_f, sizeof (short));
|
sizeof (short));
|
||||||
bwrite(nhfp->fd, (genericptr_t) &g.regions[i]->inside_f, sizeof (short));
|
bwrite(nhfp->fd, (genericptr_t) &g.regions[i]->enter_f,
|
||||||
bwrite(nhfp->fd, (genericptr_t) &g.regions[i]->player_flags, sizeof (unsigned int));
|
sizeof (short));
|
||||||
bwrite(nhfp->fd, (genericptr_t) &g.regions[i]->n_monst, sizeof (short));
|
bwrite(nhfp->fd, (genericptr_t) &g.regions[i]->can_leave_f,
|
||||||
|
sizeof (short));
|
||||||
|
bwrite(nhfp->fd, (genericptr_t) &g.regions[i]->leave_f,
|
||||||
|
sizeof (short));
|
||||||
|
bwrite(nhfp->fd, (genericptr_t) &g.regions[i]->inside_f,
|
||||||
|
sizeof (short));
|
||||||
|
bwrite(nhfp->fd, (genericptr_t) &g.regions[i]->player_flags,
|
||||||
|
sizeof (unsigned int));
|
||||||
|
bwrite(nhfp->fd, (genericptr_t) &g.regions[i]->n_monst,
|
||||||
|
sizeof (short));
|
||||||
}
|
}
|
||||||
for (j = 0; j < g.regions[i]->n_monst; j++) {
|
for (j = 0; j < g.regions[i]->n_monst; j++) {
|
||||||
if (nhfp->structlevel)
|
if (nhfp->structlevel)
|
||||||
@@ -672,9 +685,12 @@ save_regions(NHFILE* nhfp)
|
|||||||
sizeof (unsigned));
|
sizeof (unsigned));
|
||||||
}
|
}
|
||||||
if (nhfp->structlevel) {
|
if (nhfp->structlevel) {
|
||||||
bwrite(nhfp->fd, (genericptr_t) &g.regions[i]->visible, sizeof (boolean));
|
bwrite(nhfp->fd, (genericptr_t) &g.regions[i]->visible,
|
||||||
bwrite(nhfp->fd, (genericptr_t) &g.regions[i]->glyph, sizeof (int));
|
sizeof (boolean));
|
||||||
bwrite(nhfp->fd, (genericptr_t) &g.regions[i]->arg, sizeof (anything));
|
bwrite(nhfp->fd, (genericptr_t) &g.regions[i]->glyph,
|
||||||
|
sizeof (int));
|
||||||
|
bwrite(nhfp->fd, (genericptr_t) &g.regions[i]->arg,
|
||||||
|
sizeof (anything));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -709,19 +725,24 @@ rest_regions(NHFILE* nhfp)
|
|||||||
for (i = 0; i < g.n_regions; i++) {
|
for (i = 0; i < g.n_regions; i++) {
|
||||||
g.regions[i] = (NhRegion *) alloc(sizeof (NhRegion));
|
g.regions[i] = (NhRegion *) alloc(sizeof (NhRegion));
|
||||||
if (nhfp->structlevel) {
|
if (nhfp->structlevel) {
|
||||||
mread(nhfp->fd, (genericptr_t) &g.regions[i]->bounding_box, sizeof (NhRect));
|
mread(nhfp->fd, (genericptr_t) &g.regions[i]->bounding_box,
|
||||||
mread(nhfp->fd, (genericptr_t) &g.regions[i]->nrects, sizeof (short));
|
sizeof (NhRect));
|
||||||
|
mread(nhfp->fd, (genericptr_t) &g.regions[i]->nrects,
|
||||||
|
sizeof (short));
|
||||||
}
|
}
|
||||||
if (g.regions[i]->nrects > 0)
|
if (g.regions[i]->nrects > 0)
|
||||||
g.regions[i]->rects = (NhRect *)
|
g.regions[i]->rects = (NhRect *) alloc(
|
||||||
alloc(sizeof (NhRect) * g.regions[i]->nrects);
|
sizeof (NhRect) * g.regions[i]->nrects);
|
||||||
for (j = 0; j < g.regions[i]->nrects; j++) {
|
for (j = 0; j < g.regions[i]->nrects; j++) {
|
||||||
if (nhfp->structlevel)
|
if (nhfp->structlevel)
|
||||||
mread(nhfp->fd, (genericptr_t) &g.regions[i]->rects[j], sizeof (NhRect));
|
mread(nhfp->fd, (genericptr_t) &g.regions[i]->rects[j],
|
||||||
|
sizeof (NhRect));
|
||||||
}
|
}
|
||||||
if (nhfp->structlevel) {
|
if (nhfp->structlevel) {
|
||||||
mread(nhfp->fd, (genericptr_t) &g.regions[i]->attach_2_u, sizeof (boolean));
|
mread(nhfp->fd, (genericptr_t) &g.regions[i]->attach_2_u,
|
||||||
mread(nhfp->fd, (genericptr_t) &g.regions[i]->attach_2_m, sizeof (unsigned));
|
sizeof (boolean));
|
||||||
|
mread(nhfp->fd, (genericptr_t) &g.regions[i]->attach_2_m,
|
||||||
|
sizeof (unsigned));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nhfp->structlevel)
|
if (nhfp->structlevel)
|
||||||
@@ -752,8 +773,9 @@ rest_regions(NHFILE* nhfp)
|
|||||||
mread(nhfp->fd, (genericptr_t) &g.regions[i]->ttl, sizeof (long));
|
mread(nhfp->fd, (genericptr_t) &g.regions[i]->ttl, sizeof (long));
|
||||||
/* check for expired region */
|
/* check for expired region */
|
||||||
if (g.regions[i]->ttl >= 0L)
|
if (g.regions[i]->ttl >= 0L)
|
||||||
g.regions[i]->ttl =
|
g.regions[i]->ttl = ((g.regions[i]->ttl > tmstamp)
|
||||||
(g.regions[i]->ttl > tmstamp) ? g.regions[i]->ttl - tmstamp : 0L;
|
? g.regions[i]->ttl - tmstamp
|
||||||
|
: 0L);
|
||||||
if (nhfp->structlevel) {
|
if (nhfp->structlevel) {
|
||||||
mread(nhfp->fd, (genericptr_t) &g.regions[i]->expire_f,
|
mread(nhfp->fd, (genericptr_t) &g.regions[i]->expire_f,
|
||||||
sizeof (short));
|
sizeof (short));
|
||||||
@@ -775,10 +797,11 @@ rest_regions(NHFILE* nhfp)
|
|||||||
clear_heros_fault(g.regions[i]);
|
clear_heros_fault(g.regions[i]);
|
||||||
}
|
}
|
||||||
if (nhfp->structlevel)
|
if (nhfp->structlevel)
|
||||||
mread(nhfp->fd, (genericptr_t) &g.regions[i]->n_monst, sizeof (short));
|
mread(nhfp->fd, (genericptr_t) &g.regions[i]->n_monst,
|
||||||
|
sizeof (short));
|
||||||
if (g.regions[i]->n_monst > 0)
|
if (g.regions[i]->n_monst > 0)
|
||||||
g.regions[i]->monsters =
|
g.regions[i]->monsters = (unsigned *) alloc(
|
||||||
(unsigned *) alloc(sizeof (unsigned) * g.regions[i]->n_monst);
|
sizeof (unsigned) * g.regions[i]->n_monst);
|
||||||
else
|
else
|
||||||
g.regions[i]->monsters = (unsigned int *)0;
|
g.regions[i]->monsters = (unsigned int *)0;
|
||||||
g.regions[i]->max_monst = g.regions[i]->n_monst;
|
g.regions[i]->max_monst = g.regions[i]->n_monst;
|
||||||
@@ -788,9 +811,11 @@ rest_regions(NHFILE* nhfp)
|
|||||||
sizeof (unsigned));
|
sizeof (unsigned));
|
||||||
}
|
}
|
||||||
if (nhfp->structlevel) {
|
if (nhfp->structlevel) {
|
||||||
mread(nhfp->fd, (genericptr_t) &g.regions[i]->visible, sizeof (boolean));
|
mread(nhfp->fd, (genericptr_t) &g.regions[i]->visible,
|
||||||
|
sizeof (boolean));
|
||||||
mread(nhfp->fd, (genericptr_t) &g.regions[i]->glyph, sizeof (int));
|
mread(nhfp->fd, (genericptr_t) &g.regions[i]->glyph, sizeof (int));
|
||||||
mread(nhfp->fd, (genericptr_t) &g.regions[i]->arg, sizeof (anything));
|
mread(nhfp->fd, (genericptr_t) &g.regions[i]->arg,
|
||||||
|
sizeof (anything));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* remove expired regions, do not trigger the expire_f callback (yet!);
|
/* remove expired regions, do not trigger the expire_f callback (yet!);
|
||||||
@@ -806,14 +831,18 @@ DISABLE_WARNING_FORMAT_NONLITERAL
|
|||||||
|
|
||||||
/* to support '#stats' wizard-mode command */
|
/* to support '#stats' wizard-mode command */
|
||||||
void
|
void
|
||||||
region_stats(const char* hdrfmt, char* hdrbuf, long* count, long* size)
|
region_stats(
|
||||||
|
const char *hdrfmt,
|
||||||
|
char *hdrbuf,
|
||||||
|
long *count,
|
||||||
|
long *size)
|
||||||
{
|
{
|
||||||
NhRegion *rg;
|
NhRegion *rg;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
/* other stats formats take one parameter; this takes two */
|
/* other stats formats take one parameter; this takes two */
|
||||||
Sprintf(hdrbuf, hdrfmt, (long) sizeof (NhRegion), (long) sizeof (NhRect));
|
Sprintf(hdrbuf, hdrfmt, (long) sizeof (NhRegion), (long) sizeof (NhRect));
|
||||||
*count = (long) g.n_regions; /* might be 0 even though g.max_regions isn't */
|
*count = (long) g.n_regions; /* might be 0 even though max_regions isn't */
|
||||||
*size = (long) g.max_regions * (long) sizeof (NhRegion);
|
*size = (long) g.max_regions * (long) sizeof (NhRegion);
|
||||||
for (i = 0; i < g.n_regions; ++i) {
|
for (i = 0; i < g.n_regions; ++i) {
|
||||||
rg = g.regions[i];
|
rg = g.regions[i];
|
||||||
@@ -1110,9 +1139,9 @@ create_gas_cloud(xchar x, xchar y, int cloudsize, int damage)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* we have now either filled up xcoord and ycoord entirely or run out of
|
/* We have now either filled up xcoord and ycoord entirely or run out
|
||||||
* space. In either case, newidx is the correct total number of coordinates
|
of space. In either case, newidx is the correct total number of
|
||||||
* inserted. */
|
coordinates inserted. */
|
||||||
cloud = create_region((NhRect *) 0, 0);
|
cloud = create_region((NhRect *) 0, 0);
|
||||||
for (i = 0; i < newidx; ++i) {
|
for (i = 0; i < newidx; ++i) {
|
||||||
tmprect.lx = tmprect.hx = xcoords[i];
|
tmprect.lx = tmprect.hx = xcoords[i];
|
||||||
@@ -1120,8 +1149,7 @@ create_gas_cloud(xchar x, xchar y, int cloudsize, int damage)
|
|||||||
add_rect_to_reg(cloud, &tmprect);
|
add_rect_to_reg(cloud, &tmprect);
|
||||||
}
|
}
|
||||||
cloud->ttl = rn1(3, 4);
|
cloud->ttl = rn1(3, 4);
|
||||||
/* If the cloud was constrained in a small space, give it more time to
|
/* If cloud was constrained in small space, give it more time to live. */
|
||||||
* live. */
|
|
||||||
cloud->ttl = (cloud->ttl * cloudsize) / newidx;
|
cloud->ttl = (cloud->ttl * cloudsize) / newidx;
|
||||||
|
|
||||||
if (!g.in_mklev && !g.context.mon_moving)
|
if (!g.in_mklev && !g.context.mon_moving)
|
||||||
|
|||||||
+1
-1
@@ -667,7 +667,7 @@ vision_recalc(int control)
|
|||||||
do_light_sources(next_array);
|
do_light_sources(next_array);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Make the g.viz_array the new array so that cansee() will work correctly.
|
* Make the viz_array the new array so that cansee() will work correctly.
|
||||||
*/
|
*/
|
||||||
temp_array = g.viz_array;
|
temp_array = g.viz_array;
|
||||||
g.viz_array = next_array;
|
g.viz_array = next_array;
|
||||||
|
|||||||
Reference in New Issue
Block a user