Merge branch 'master' into nhmall-booktribute

Conflicts:
	sys/winnt/Makefile.msc
This commit is contained in:
nhmall
2015-03-21 10:59:49 -04:00
21 changed files with 945 additions and 218 deletions

View File

@@ -535,11 +535,11 @@ newgame()
#endif
program_state.something_worth_saving++; /* useful data now exists */
u.urealtime.realtime = (time_t)0L;
urealtime.realtime = (time_t)0L;
#if defined(BSD) && !defined(POSIX_TYPES)
(void) time((long *)&u.urealtime.restored);
(void) time((long *)&urealtime.restored);
#else
(void) time(&u.urealtime.restored);
(void) time(&urealtime.restored);
#endif
/* Success! */

View File

@@ -136,6 +136,7 @@ NEARDATA struct sysflag sysflags = DUMMY;
NEARDATA struct instance_flags iflags = DUMMY;
NEARDATA struct you u = DUMMY;
NEARDATA time_t ubirthday = DUMMY;
NEARDATA struct u_realtime urealtime = DUMMY;
schar lastseentyp[COLNO][ROWNO] = {DUMMY}; /* last seen/touched dungeon typ */

View File

@@ -391,7 +391,7 @@ Helmet_on(VOID_ARGS)
properties, including levitation; uarmh could get
dropped or destroyed here */
uchangealign((u.ualign.type != A_NEUTRAL) ? -u.ualign.type :
rn2(2) ? A_CHAOTIC : A_LAWFUL, 1);
(uarmh->o_id % 2) ? A_CHAOTIC : A_LAWFUL, 1);
/* makeknown(uarmh->otyp); -- moved below, after xname() */
/*FALLTHRU*/
case DUNCE_CAP:

View File

@@ -911,7 +911,7 @@ die:
topten figure it out separately and possibly getting different
time or even day if player is slow responding to --More-- */
endtime = getnow();
u.urealtime.realtime += (endtime - u.urealtime.restored);
urealtime.realtime += (endtime - urealtime.restored);
/* Sometimes you die on the first move. Life's not fair.
* On those rare occasions you get hosed immediately, go out

View File

@@ -26,6 +26,7 @@ NetHack, except that rounddiv may call panic().
char chrcasecpy (int,int)
char * strcasecpy (char *,const char *)
char * s_suffix (const char *)
char * ing_suffix (const char *)
char * xcrypt (const char *, char *)
boolean onlyspace (const char *)
char * tabexpand (char *)
@@ -235,6 +236,39 @@ s_suffix(s) /* return a name converted to possessive */
return buf;
}
char *
ing_suffix(s)
const char *s;
{
const char *vowel = "aeiouy";
static char buf[BUFSZ];
char onoff[10];
char *p;
Strcpy(buf, s);
p = eos(buf);
onoff[0] = *p = *(p+1) = '\0';
if ((strlen(buf) > 4) &&
(!strcmpi(p-3, " on") ||
!strcmpi(p-4, " off") ||
!strcmpi(p-5, " with"))) {
p = strrchr(buf, ' ');
Strcpy(onoff, p);
}
if (!index(vowel, *(p-1)) && index(vowel, *(p-2)) && !index(vowel, *(p-3))) {
/* tip -> tipp + ing */
*p = *(p-1);
*(p+1) = '\0';
} else if (!strcmpi(p-2, "ie")) { /* vie -> vy + ing */
*(p-2) = 'y';
*(p-1) = '\0';
} else if (*(p-1) == 'e') /* grease -> greas + ing */
*(p-1) = '\0';
Strcat(buf, "ing");
if (onoff[0]) Strcat(buf, onoff);
return buf;
}
char *
xcrypt(str, buf) /* trivial text encryption routine (see makedefs) */
const char *str;

View File

@@ -972,7 +972,21 @@ register const char *let,*word;
return((struct obj *)0);
}
if(ilet == '-') {
return(allownone ? &zeroobj : (struct obj *) 0);
if (!allownone) {
char *suf = NULL;
strcpy(buf, word);
if ((bp = strstr(buf, " on the ")) != NULL) { /* rub on the stone[s] */
*bp = '\0';
suf = (bp + 1);
}
if ((bp = strstr(buf, " or ")) != NULL) {
*bp = '\0';
bp = (rn2(2) ? buf : (bp + 4));
} else bp = buf;
You("mime %s something%s%s.", ing_suffix(bp),
suf ? " " : "", suf ? suf : "");
}
return(allownone ? &zeroobj : (struct obj *) 0);
}
if(ilet == def_oc_syms[COIN_CLASS].sym) {
if (!usegold) {

View File

@@ -551,13 +551,18 @@ unsigned int *stuckid, *steedid;
amii_setpens(amii_numcolors); /* use colors from save file */
#endif
mread(fd, (genericptr_t) &u, sizeof(struct you));
mread(fd, (genericptr_t) timebuf, 14);
timebuf[14] = '\0';
ubirthday = time_from_yyyymmddhhmmss(timebuf);
#define ReadTimebuf(foo) mread(fd, (genericptr_t) timebuf, 14); \
timebuf[14] = '\0'; \
foo = time_from_yyyymmddhhmmss(timebuf);
ReadTimebuf(ubirthday);
ReadTimebuf(urealtime.realtime);
ReadTimebuf(urealtime.restored);
#if defined(BSD) && !defined(POSIX_TYPES)
(void) time((long *)&u.urealtime.restored);
(void) time((long *)&urealtime.restored);
#else
(void) time(&u.urealtime.restored);
(void) time(&urealtime.restored);
#endif

View File

@@ -307,9 +307,11 @@ register int fd, mode;
#ifdef SYSFLAGS
bwrite(fd, (genericptr_t) &sysflags, sizeof(struct sysflag));
#endif
u.urealtime.realtime += (getnow() - u.urealtime.restored);
urealtime.realtime += (getnow() - urealtime.restored);
bwrite(fd, (genericptr_t) &u, sizeof(struct you));
bwrite(fd, yyyymmddhhmmss(ubirthday), 14);
bwrite(fd, yyyymmddhhmmss(urealtime.realtime), 14);
bwrite(fd, yyyymmddhhmmss(urealtime.restored), 14);
save_killers(fd, mode);
/* must come before migrating_objs and migrating_mons are freed */

View File

@@ -1,4 +1,4 @@
/* NetHack 3.5 topten.c $NHDT-Date$ $NHDT-Branch$:$NHDT-Revision$ */
/* NetHack 3.5 topten.c $NHDT-Date: 1426731079 2015/03/19 02:11:19 $ $NHDT-Branch: harder_d8 $:$NHDT-Revision: 1.25 $ */
/* NetHack 3.5 topten.c $Date: 2012/01/24 04:26:15 $ $Revision: 1.23 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
@@ -66,8 +66,8 @@ STATIC_DCL void FDECL(discardexcess, (FILE *));
STATIC_DCL void FDECL(readentry, (FILE *,struct toptenentry *));
STATIC_DCL void FDECL(writeentry, (FILE *,struct toptenentry *));
STATIC_DCL void FDECL(writexlentry, (FILE*, struct toptenentry *));
STATIC_DCL long FDECL(encodeconduct, (void));
STATIC_DCL long FDECL(encodeachieve, (void));
STATIC_DCL long NDECL(encodeconduct);
STATIC_DCL long NDECL(encodeachieve);
STATIC_DCL void FDECL(free_ttlist, (struct toptenentry *));
STATIC_DCL int FDECL(classmon, (char *,BOOLEAN_P));
STATIC_DCL int FDECL(score_wanted,
@@ -295,53 +295,58 @@ struct toptenentry *tt;
#endif
}
#define XLOG_SEP "\t" /* xlogfile field separator. */
/* as tab is never used in eg. plname or death, no need to mangle those. */
STATIC_OVL void
writexlentry(rfile,tt)
FILE *rfile;
struct toptenentry *tt;
{
char buf[DTHSZ+1];
(void)fprintf(rfile,
"version=%d.%d.%d"
XLOG_SEP "points=%ld"
XLOG_SEP "deathdnum=%d"
XLOG_SEP "deathlev=%d"
XLOG_SEP "maxlvl=%d"
XLOG_SEP "hp=%d"
XLOG_SEP "maxhp=%d"
XLOG_SEP "deaths=%d"
XLOG_SEP "deathdate=%d"
XLOG_SEP "birthdate=%d"
XLOG_SEP "uid=%d",
tt->ver_major, tt->ver_minor, tt->patchlevel,
tt->points, tt->deathdnum, tt->deathlev,
tt->maxlvl, tt->hp, tt->maxhp, tt->deaths,
tt->deathdate, tt->birthdate, tt->uid);
(void)fprintf(rfile,
XLOG_SEP "role=%s"
XLOG_SEP "race=%s"
XLOG_SEP "gender=%s"
XLOG_SEP "align=%s",
tt->plrole, tt->plrace, tt->plgend, tt->plalign);
(void)fprintf(rfile, XLOG_SEP "name=%s", plname);
(void)fprintf(rfile, XLOG_SEP "death=%s", tt->death);
(void)fprintf(rfile, XLOG_SEP "conduct=0x%lx", encodeconduct());
(void)fprintf(rfile, XLOG_SEP "turns=%ld", moves);
(void)fprintf(rfile, XLOG_SEP "achieve=0x%lx", encodeachieve());
(void)fprintf(rfile, XLOG_SEP "realtime=%ld", (long)u.urealtime.realtime);
(void)fprintf(rfile, XLOG_SEP "starttime=%ld", (long)ubirthday);
(void)fprintf(rfile, XLOG_SEP "endtime=%ld", (long)u.urealtime.endtime);
(void)fprintf(rfile, XLOG_SEP "gender0=%s", genders[flags.initgend].filecode);
(void)fprintf(rfile, XLOG_SEP "align0=%s",
aligns[1 - u.ualignbase[A_ORIGINAL]].filecode);
fprintf(rfile, "\n");
}
#undef XLOG_SEP
#define Fprintf (void)fprintf
#define XLOG_SEP '\t' /* xlogfile field separator. */
char buf[BUFSZ];
long
encodeconduct(void)
Sprintf(buf, "version=%d.%d.%d",
tt->ver_major, tt->ver_minor, tt->patchlevel);
Sprintf(eos(buf), "%cpoints=%ld%cdeathdnum=%d%cdeathlev=%d",
XLOG_SEP, tt->points,
XLOG_SEP, tt->deathdnum,
XLOG_SEP, tt->deathlev);
Sprintf(eos(buf), "%cmaxlvl=%d%chp=%d%cmaxhp=%d",
XLOG_SEP, tt->maxlvl,
XLOG_SEP, tt->hp,
XLOG_SEP, tt->maxhp);
Sprintf(eos(buf), "%cdeaths=%d%cdeathdate=%ld%cbirthdate=%ld%cuid=%d",
XLOG_SEP, tt->deaths,
XLOG_SEP, tt->deathdate,
XLOG_SEP, tt->birthdate,
XLOG_SEP, tt->uid);
Fprintf(rfile, "%s", buf);
Sprintf(buf, "%crole=%s%crace=%s%cgender=%s%calign=%s",
XLOG_SEP, tt->plrole,
XLOG_SEP, tt->plrace,
XLOG_SEP, tt->plgend,
XLOG_SEP, tt->plalign);
Fprintf(rfile, "%s%cname=%s%cdeath=%s",
buf, /* (already includes separator) */
XLOG_SEP, plname,
XLOG_SEP, tt->death);
Fprintf(rfile, "%cconduct=0x%lx%cturns=%ld%cachieve=0x%lx",
XLOG_SEP, encodeconduct(),
XLOG_SEP, moves,
XLOG_SEP, encodeachieve());
Fprintf(rfile, "%crealtime=%ld%cstarttime=%ld%cendtime=%ld",
XLOG_SEP, (long)urealtime.realtime,
XLOG_SEP, (long)ubirthday,
XLOG_SEP, (long)urealtime.endtime);
Fprintf(rfile, "%cgender0=%s%calign0=%s",
XLOG_SEP, genders[flags.initgend].filecode,
XLOG_SEP, aligns[1 - u.ualignbase[A_ORIGINAL]].filecode);
Fprintf(rfile, "\n");
#undef XLOG_SEP
}
STATIC_OVL long
encodeconduct()
{
long e = 0L;
@@ -361,8 +366,8 @@ encodeconduct(void)
return e;
}
long
encodeachieve(void)
STATIC_OVL long
encodeachieve()
{
long r = 0L;
@@ -475,7 +480,7 @@ time_t when;
t0->birthdate = yyyymmdd(ubirthday);
t0->deathdate = yyyymmdd(when);
t0->tt_next = 0;
u.urealtime.endtime = when;
urealtime.endtime = when;
#ifdef UPDATE_RECORD_IN_PLACE
t0->fpos = -1L;
#endif

View File

@@ -1,4 +1,4 @@
/* NetHack 3.5 trap.c $NHDT-Date: 1426558928 2015/03/17 02:22:08 $ $NHDT-Branch: master $:$NHDT-Revision: 1.195 $ */
/* NetHack 3.5 trap.c $NHDT-Date: 1426805491 2015/03/19 22:51:31 $ $NHDT-Branch: water_damage $:$NHDT-Revision: 1.198 $ */
/* NetHack 3.5 trap.c $Date: 2013/03/14 01:58:21 $ $Revision: 1.179 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
@@ -3145,6 +3145,14 @@ struct obj *obj;
erode_obj(obj, NULL, ERODE_CORRODE, EF_GREASE | EF_VERBOSE);
}
/* context for water_damage(), managed by water_damage_chain();
when more than one stack of potions of acid explode while processing
a chain of objects, use alternate phrasing after the first message */
static struct h2o_ctx {
int dkn_boom, unk_boom; /* track dknown, !dknown separately */
boolean ctx_valid;
} acid_ctx = { 0, 0, FALSE };
/* Get an object wet and damage it appropriately.
* "ostr", if present, is used instead of the object name in some
* messages.
@@ -3157,8 +3165,6 @@ struct obj *obj;
const char *ostr;
boolean force;
{
boolean exploded = FALSE;
if (!obj) return ER_NOTHING;
if (snuff_lit(obj))
@@ -3203,18 +3209,36 @@ boolean force;
return ER_DAMAGED;
} else if (obj->oclass == POTION_CLASS) {
if (obj->otyp == POT_ACID) {
char *bufp, buf[BUFSZ];
boolean one = (obj->quan == 1L);
boolean update = carried(obj);
char *bufp;
boolean one = (obj->quan == 1L),
update = carried(obj),
exploded = FALSE;
bufp = strcpy(buf, "potion");
if (!one) bufp = makeplural(bufp);
/* [should we damage player/monster?] */
if (Blind && !carried(obj)) obj->dknown = 0;
if (acid_ctx.ctx_valid)
exploded = ((obj->dknown ? acid_ctx.dkn_boom
: acid_ctx.unk_boom) > 0);
/* First message is
* "a [potion|<color> potion|potion of acid] explodes"
* depending on obj->dknown (potion has been seen) and
* objects[POT_ACID].oc_name_known (fully discovered),
* or "some {plural version} explode" when relevant.
* Second and subsequent messages for same chain and
* matching dknown status are
* "another [potion|<color> &c] explodes" or plural
* variant.
*/
bufp = simpleonames(obj);
pline("%s %s %s!", /* "A potion explodes!" */
!exploded ? (one ? "A" : "Some") :
(one ? "Another" : "More"),
(one ? "Another" : "More"),
bufp, vtense(bufp, "explode"));
exploded = TRUE;
if (acid_ctx.ctx_valid) {
if (obj->dknown)
acid_ctx.dkn_boom++;
else
acid_ctx.unk_boom++;
}
setnotworn(obj);
delobj(obj);
if (update)
@@ -3246,10 +3270,20 @@ struct obj *obj;
boolean here;
{
struct obj *otmp;
/* initialize acid context: so far, neither seen (dknown) potions of
acid nor unseen have exploded during this water damage sequence */
acid_ctx.dkn_boom = acid_ctx.unk_boom = 0;
acid_ctx.ctx_valid = TRUE;
for (; obj; obj = otmp) {
otmp = here ? obj->nexthere : obj->nobj;
water_damage(obj, NULL, FALSE);
}
/* reset acid context */
acid_ctx.dkn_boom = acid_ctx.unk_boom = 0;
acid_ctx.ctx_valid = FALSE;
}
/*

View File

@@ -500,6 +500,7 @@ u_init()
(void) memset((genericptr_t)&u, 0, sizeof(u));
u.ustuck = (struct monst *)0;
(void) memset((genericptr_t)&ubirthday, 0, sizeof(ubirthday));
(void) memset((genericptr_t)&urealtime, 0, sizeof(urealtime));
#if 0 /* documentation of more zero values as desirable */
u.usick_cause[0] = 0;