static void write_xlentry(FILE * rfile, const struct toptenentry *tt) { char buf[DTHSZ + 1]; char *uname; /* regular logfile data */ fprintf(rfile, "version=%d.%d.%d" SEP "points=%d" SEP "deathdnum=%d" SEP "deathlev=%d" SEP "maxlvl=%d" SEP "hp=%d" SEP "maxhp=%d" SEP "deaths=%d" SEP "deathdate=%ld" SEP "birthdate=%ld" 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, (unsigned long)tt->deathdate, (unsigned long)tt->birthdate, tt->uid); fprintf(rfile, SEP "role=%s" SEP "race=%s" SEP "gender=%s" SEP "align=%s", tt->plrole, tt->plrace, tt->plgend, tt->plalign); uname = nh_getenv("NH4SERVERUSER"); if (!uname) uname = nh_getenv("USER"); if (!uname) uname = ""; munge_xlstring(buf, uname, DTHSZ + 1); fprintf(rfile, SEP "name=%s", buf); munge_xlstring(buf, plname, DTHSZ + 1); fprintf(rfile, SEP "charname=%s", buf); munge_xlstring(buf, tt->death, DTHSZ + 1); fprintf(rfile, SEP "death=%s", buf); fprintf(rfile, SEP "conduct=%ld", encode_conduct()); fprintf(rfile, SEP "turns=%u", moves); /* AceHack's equivalent of achieve has rather different semantics from vanilla's. So give it a different name. */ fprintf(rfile, SEP "event=%ld", encode_uevent()); fprintf(rfile, SEP "carried=%ld", encode_carried()); fprintf(rfile, SEP "starttime=%ld" SEP "endtime=%ld", (long)u.ubirthday, (long)deathtime_internal); fprintf(rfile, SEP "gender0=%s", genders[u.initgend].filecode); fprintf(rfile, SEP "align0=%s", aligns[1 - u.ualignbase[A_ORIGINAL]].filecode); fprintf(rfile, SEP "xplevel=%d", u.ulevel); fprintf(rfile, SEP "exp=%d", u.uexp); fprintf(rfile, SEP "mode=%s", (flags.debug ? "debug" : flags.explore ? "explore" : "normal")); fprintf(rfile, "\n"); }
void getmailstatus() { if(!mailbox && !(mailbox = nh_getenv("MAIL"))) { # ifdef MAILPATH # ifdef AMS struct passwd ppasswd; (void) memcpy(&ppasswd, getpwuid(getuid()), sizeof(struct passwd)); if (ppasswd.pw_dir) { mailbox = (char *) alloc((unsigned) strlen(ppasswd.pw_dir)+sizeof(AMS_MAILBOX)); Strcpy(mailbox, ppasswd.pw_dir); Strcat(mailbox, AMS_MAILBOX); } else return; # else const char *pw_name = getpwuid(getuid())->pw_name; mailbox = (char *) alloc(sizeof(MAILPATH)+strlen(pw_name)); Strcpy(mailbox, MAILPATH); Strcat(mailbox, pw_name); # endif /* AMS */ # else return; # endif } if(stat(mailbox, &omstat)){ # ifdef PERMANENT_MAILBOX pline("Cannot get status of MAIL=\"%s\".", mailbox); mailbox = 0; # else omstat.st_mtime = 0; # endif } }
void pfa_setrandom(void) { char * seed_s = nh_getenv("NH_SEED"); int seed; if (seed_s == NULL) { #ifdef RANDOM /* srandom() from sys/share/random.c */ seed = time((time_t *)0); } else { seed = atoi(seed_s); } srandom((unsigned int) seed); #else # if defined(__APPLE__) || defined(BSD) || defined(LINUX) || defined(ULTRIX) || defined(CYGWIN32) /* system srandom() */ # if defined(BSD) && !defined(POSIX_TYPES) # if defined(SUNOS4) (void) # endif seed = time((long *)0); # else struct timeval tv; gettimeofday(&tv, NULL); seed = (int) tv.tv_sec + (tv.tv_usec/10000)*1000000; # endif }
const char *roguename(void) /* Name of a Rogue player */ { char *i, *opts; if ((opts = nh_getenv("ROGUEOPTS")) != 0) { for (i = opts; *i; i++) if (!strncmp("name=",i,5)) { char *j; if ((j = strchr(i+5,',')) != 0) *j = (char)0; return i+5; } } return rn2(3) ? (rn2(2) ? "Michael Toy" : "Kenneth Arnold") : "Glenn Wichman"; }
void interject_assistance( int num, int interjection_type, genericptr_t ptr1, genericptr_t ptr2) { switch (num) { case 1: { char *panicmsg = (char *)ptr1; char *datadir = (char *)ptr2; char *tempdir = nh_getenv("TEMP"); interjection_type = INTERJECT_PANIC; interjection[INTERJECT_PANIC] = 1; /* * ptr1 = the panic message about to be delivered. * ptr2 = the directory prefix of the dungeon file * that failed to open. * Check to see if datadir matches tempdir or a * common windows temp location. If it does, inform * the user that they are probably trying to run the * game from within their unzip utility, so the required * files really don't exist at the location. Instruct * them to unpack them first. */ if (panicmsg && datadir) { if (!strncmpi(datadir, "C:\\WINDOWS\\TEMP", 15) || strstri(datadir, "TEMP") || (tempdir && strstri(datadir, tempdir))) { (void)strncpy(interjection_buf[INTERJECT_PANIC], "\nOne common cause of this error is attempting to execute\n" "the game by double-clicking on it while it is displayed\n" "inside an unzip utility.\n\n" "You have to unzip the contents of the zip file into a\n" "folder on your system, and then run \"NetHack.exe\" or \n" "\"NetHackW.exe\" from there.\n\n" "If that is not the situation, you are encouraged to\n" "report the error as shown above.\n\n", 1023); } } } break; } }