arogue7: record completed games in a logfile.

This commit is contained in:
John "Elwin" Edwards 2015-05-12 09:55:05 -04:00
parent b6ab08176a
commit e4d23af7c5
3 changed files with 49 additions and 1 deletions

View file

@ -602,6 +602,7 @@ int sig;
clear();
move(lines-1, 0);
draw(stdscr);
writelog(pstats.s_exp + (long) purse, CHICKEN, 0);
score(pstats.s_exp + (long) purse, CHICKEN, 0);
#ifdef PC7300
endhardwin();

View file

@ -17,6 +17,8 @@
#define EDITSCORE 2 /* Edit the current score file */
#define ADDSCORE 3 /* Add a new score */
#define LOGFILE "arogue7.log"
#define NAMELEN 80
/*
@ -138,6 +140,7 @@ register short monst;
mvaddstr(18, 26, (sprintf(prbuf, "%4d", 1900+lt->tm_year), prbuf));
move(lines-1, 0);
refresh();
writelog(pstats.s_exp, KILLED, monst);
score(pstats.s_exp, KILLED, monst);
endwin();
#ifdef PC7300
@ -199,7 +202,49 @@ register short monst;
return (deaths[i].name);
}
/* Writes an entry in the log file */
void
writelog(unsigned long amount, int flags, short monst)
{
FILE *logwriter;
char had_quest = '0';
char fate[LINELEN];
struct linked_list *item;
struct object *obj;
#ifdef LOGFILE
if (waswizard)
return;
/* Check for quest item */
for (item = pack; item != NULL; item = next(item)) {
obj = OBJPTR(item);
if (obj->o_type == RELIC && obj->o_which == quest_item)
had_quest = '1';
}
/* Describe what happened */
if (flags == KILLED) {
snprintf(fate, LINELEN, "killed by %s", killname(monst));
}
else if (flags == CHICKEN) {
strcpy(fate, "quit");
}
else if (flags == WINNER) {
strcpy(fate, "escaped");
}
else
return;
/* Open and write */
logwriter = fopen(LOGFILE, "a");
if (logwriter == NULL)
return;
fprintf(logwriter, "%d %d %s %d %s %d %d %d %c %s\n", time(NULL), amount,
whoami, pstats.s_lvl, char_class[char_type].name, level, max_level,
quest_item, had_quest, fate);
fclose(logwriter);
#endif
return;
}
/*
* score -- figure score and post it.
*/
@ -823,6 +868,7 @@ total_winner()
}
mvprintw(c - 'a' + 1, 0," %5d Gold Pieces ", oldpurse);
refresh();
writelog(pstats.s_exp + (long) purse, WINNER, '\0');
score(pstats.s_exp + (long) purse, WINNER, '\0');
endwin();
#ifdef PC7300

View file

@ -1150,6 +1150,7 @@ void genmonsters(),
add_constitution(), add_charisma(), res_intelligence(), res_strength(int),
res_wisdom(), res_dexterity(), res_constitution(), res_charisma();
void writelog(unsigned long amount, int flags, short monst);
#ifdef CHECKTIME
int checkout();