示例#1
0
static void
fill_topten_entry(struct toptenentry *newtt, int how)
{
    int uid = getuid();

    memset(newtt, 0, sizeof (struct toptenentry));

    /* deepest_lev_reached() is in terms of depth(), and reporting the deepest
       level reached in the dungeon death occurred in doesn't seem right, so we 
       have to report the death level in depth() terms as well (which also
       seems reasonable since that's all the player sees on the screen anyway) */
    newtt->ver_major = VERSION_MAJOR;
    newtt->ver_minor = VERSION_MINOR;
    newtt->patchlevel = PATCHLEVEL;
    newtt->points = u.urexp > -1 ?      /* u.urexp stores score once invent is
                                           invalid */
        u.urexp : calc_score(how, FALSE, money_cnt(invent) + hidden_gold());
    newtt->deathdnum = u.uz.dnum;
    newtt->deathlev = depth(&u.uz);
    newtt->maxlvl = deepest_lev_reached(TRUE);
    newtt->hp = u.uhp;
    newtt->maxhp = u.uhpmax;
    newtt->deaths = u.umortality;
    newtt->uid = uid;
    newtt->moves = moves;
    newtt->how = how;
    strncpy(newtt->plrole, urole.filecode, ROLESZ);
    newtt->plrole[ROLESZ] = '\0';
    strncpy(newtt->plrace, urace.filecode, ROLESZ);
    newtt->plrace[ROLESZ] = '\0';
    strncpy(newtt->plgend, genders[flags.female].filecode, ROLESZ);
    newtt->plgend[ROLESZ] = '\0';
    strncpy(newtt->plalign, aligns[1 - u.ualign.type].filecode, ROLESZ);
    newtt->plalign[ROLESZ] = '\0';
    strncpy(newtt->name, plname, NAMSZ);
    newtt->name[NAMSZ] = '\0';
    newtt->death[0] = '\0';
    switch (killer_format) {
    default:
        impossible("bad killer format?");
    case KILLED_BY_AN:
        strcat(newtt->death, killed_by_prefix[how]);
        strncat(newtt->death, an(killer), DTHSZ - strlen(newtt->death));
        break;
    case KILLED_BY:
        strcat(newtt->death, killed_by_prefix[how]);
        strncat(newtt->death, killer, DTHSZ - strlen(newtt->death));
        break;
    case NO_KILLER_PREFIX:
        strncat(newtt->death, killer, DTHSZ);
        break;
    }
    newtt->birthdate = yyyymmdd(u.ubirthday);
    newtt->deathdate = yyyymmdd((time_t) 0L);
    time(&deathtime_internal);
}
示例#2
0
文件: files.c 项目: DanielT/NitroHack
/*ARGSUSED*/
void paniclog(const char *type,   /* panic, impossible, trickery */
	      const char *reason) /* explanation */
{
#ifdef PANICLOG
	FILE *lfile;
	char buf[BUFSZ];

	if (!program_state.in_paniclog) {
		program_state.in_paniclog = 1;
		lfile = fopen_datafile(PANICLOG, "a", TROUBLEPREFIX);
		if (lfile) {
		    fprintf(lfile, "%s %08ld: %s %s\n",
				   version_string(buf), yyyymmdd((time_t)0L),
				   type, reason);
		    fclose(lfile);
		}
		program_state.in_paniclog = 0;
	}
#endif /* PANICLOG */
	return;
}