bones tracking (trunk only)

[See cvs log for include/rm.h or doc/window.doc for more complete description.]

Attach hero info, death reason, and date+time to a level that's being saved
as bones.  Read such data back when loading a bones file, then treat it as
part of that level for the rest of the game.  Dying on a loaded bones file
will chain the new hero+death+date to previous one(s) if new bones get saved.

outrip() now takes an extra argument of type time_t, and interface-specific
implementations of this routine need to be updated to handle that.
This commit is contained in:
nethack.rankin
2012-01-23 10:45:31 +00:00
parent b88c51deae
commit 9721470635
15 changed files with 152 additions and 64 deletions

View File

@@ -273,7 +273,9 @@ can_make_bones()
/* save bones and possessions of a deceased adventurer */
void
savebones(corpse)
savebones(how, when, corpse)
int how;
time_t when;
struct obj *corpse;
{
int fd, x, y;
@@ -281,6 +283,7 @@ struct obj *corpse;
struct monst *mtmp;
struct permonst *mptr;
struct fruit *f;
struct cemetery *newbones;
char c, *bonesid;
char whynot[BUFSZ];
@@ -407,6 +410,29 @@ struct obj *corpse;
#endif
}
/* Attach bones info to the current level before saving. */
newbones = (struct cemetery *)alloc(sizeof *newbones);
/* entries are '\0' terminated but have fixed length allocations,
so pre-fill with spaces to initialize any excess room */
(void)memset((genericptr_t)newbones, ' ', sizeof *newbones);
/* format name+role,&c, death reason, and date+time;
gender and alignment reflect final values rather than what the
character started out as, same as topten and logfile entries */
Sprintf(newbones->who, "%s-%.3s-%.3s-%.3s-%.3s",
plname, urole.filecode, urace.filecode,
genders[flags.female].filecode,
aligns[1 - u.ualign.type].filecode);
formatkiller(newbones->how, sizeof newbones->how, how);
Strcpy(newbones->when, yyyymmddhhmmss(when));
/* if current character died on a bones level, the cememtery list
will have multiple entries, most recent (this dead hero) first */
newbones->next = level.bonesinfo;
level.bonesinfo = newbones;
/* flag these bones if they are being created in wizard mode;
they might already be flagged as such, even when we're playing
in normal mode, if this level came from a previous bones file */
if (wizard) level.flags.wizard_bones = 1;
fd = create_bonesfile(&u.uz, &bonesid, whynot);
if(fd < 0) {
#ifdef WIZARD