UltraRogue: add logging.
The log file's name is temporarily defined in main.c.
This commit is contained in:
parent
92d1275f42
commit
8eebfc0c85
3 changed files with 37 additions and 0 deletions
|
|
@ -28,8 +28,10 @@
|
||||||
|
|
||||||
#define SAVEDIR "."
|
#define SAVEDIR "."
|
||||||
#define SCOREFILE "/var/local/games/roguelike/urogue.scr"
|
#define SCOREFILE "/var/local/games/roguelike/urogue.scr"
|
||||||
|
#define LOGFILE "/var/local/games/roguelike/urogue.log"
|
||||||
|
|
||||||
FILE *fd_score = NULL;
|
FILE *fd_score = NULL;
|
||||||
|
FILE *file_log = NULL;
|
||||||
|
|
||||||
/* Command line options */
|
/* Command line options */
|
||||||
|
|
||||||
|
|
@ -107,6 +109,10 @@ main(int argc, char *argv[])
|
||||||
if (fd_score == NULL)
|
if (fd_score == NULL)
|
||||||
fd_score = fopen(score_file, "a+");
|
fd_score = fopen(score_file, "a+");
|
||||||
|
|
||||||
|
#ifdef LOGFILE
|
||||||
|
file_log = fopen(LOGFILE, "a+");
|
||||||
|
#endif
|
||||||
|
|
||||||
if (!use_savedir)
|
if (!use_savedir)
|
||||||
md_normaluser();
|
md_normaluser();
|
||||||
|
|
||||||
|
|
|
||||||
30
urogue/rip.c
30
urogue/rip.c
|
|
@ -53,6 +53,8 @@ static const char *rip[] =
|
||||||
0
|
0
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void writelog(long amount, int lvl, int flags, int monst);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
death()
|
death()
|
||||||
Do something really fun when he dies
|
Do something really fun when he dies
|
||||||
|
|
@ -205,6 +207,9 @@ score(long amount, int lvl, int flags, int monst) /*ARGSUSED*/
|
||||||
|
|
||||||
char *packend;
|
char *packend;
|
||||||
|
|
||||||
|
if (flags != SCOREIT)
|
||||||
|
writelog(amount, lvl, flags, monst);
|
||||||
|
|
||||||
if (flags != WINNER && flags != TOTAL && flags != SCOREIT)
|
if (flags != WINNER && flags != TOTAL && flags != SCOREIT)
|
||||||
{
|
{
|
||||||
if (flags == CHICKEN)
|
if (flags == CHICKEN)
|
||||||
|
|
@ -385,6 +390,31 @@ score(long amount, int lvl, int flags, int monst) /*ARGSUSED*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
writelog(long amount, int lvl, int flags, int monst)
|
||||||
|
{
|
||||||
|
char fate[80];
|
||||||
|
if (file_log == NULL)
|
||||||
|
return;
|
||||||
|
if (flags == KILLED) {
|
||||||
|
strcpy(fate, "killed by ");
|
||||||
|
killname(monst, fate + 10);
|
||||||
|
}
|
||||||
|
else if (flags == CHICKEN) {
|
||||||
|
strcpy(fate, "quit");
|
||||||
|
}
|
||||||
|
else if (flags == WINNER || flags == TOTAL) {
|
||||||
|
strcpy(fate, "escaped");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return;
|
||||||
|
fprintf(file_log, "%d %d %s %d %s %d %d %d %s\n", time(NULL), amount,
|
||||||
|
whoami, lvl, which_class(player.t_ctype), level, max_level,
|
||||||
|
has_artifact, fate);
|
||||||
|
fclose(file_log);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
total_winner(void)
|
total_winner(void)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1380,6 +1380,7 @@ extern char *ws_made[]; /* What sticks are made of */
|
||||||
/* main.c */
|
/* main.c */
|
||||||
|
|
||||||
extern FILE *fd_score;
|
extern FILE *fd_score;
|
||||||
|
extern FILE *file_log;
|
||||||
extern int summoned;
|
extern int summoned;
|
||||||
extern coord dta;
|
extern coord dta;
|
||||||
extern int main(int argc, char *argv[]);
|
extern int main(int argc, char *argv[]);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue