srogue: add logging.
This commit is contained in:
parent
7aa541b5a8
commit
07b5ea7c50
2 changed files with 44 additions and 0 deletions
|
|
@ -372,6 +372,7 @@ quit(int a)
|
||||||
clear();
|
clear();
|
||||||
move(LINES-1, 0);
|
move(LINES-1, 0);
|
||||||
refresh();
|
refresh();
|
||||||
|
writelog(purse, CHICKEN, 0);
|
||||||
score(purse, CHICKEN, 0);
|
score(purse, CHICKEN, 0);
|
||||||
byebye(0);
|
byebye(0);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
43
srogue/rip.c
43
srogue/rip.c
|
|
@ -22,6 +22,8 @@
|
||||||
#include "rogue.h"
|
#include "rogue.h"
|
||||||
#include "rogue.ext"
|
#include "rogue.ext"
|
||||||
|
|
||||||
|
#define LOGFILE "/usr/local/games/roguelike/srogue.log"
|
||||||
|
|
||||||
static char scoreline[100];
|
static char scoreline[100];
|
||||||
|
|
||||||
static char *rip[] = {
|
static char *rip[] = {
|
||||||
|
|
@ -82,6 +84,7 @@ char monst;
|
||||||
mvaddstr(18, 32, prbuf);
|
mvaddstr(18, 32, prbuf);
|
||||||
move(LINES-1, 0);
|
move(LINES-1, 0);
|
||||||
refresh();
|
refresh();
|
||||||
|
writelog(purse, KILLED, monst);
|
||||||
score(purse, KILLED, monst);
|
score(purse, KILLED, monst);
|
||||||
byebye(0);
|
byebye(0);
|
||||||
}
|
}
|
||||||
|
|
@ -215,6 +218,45 @@ int amount, aflag;
|
||||||
showtop(prflags); /* print top ten list */
|
showtop(prflags); /* print top ten list */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void writelog(int amount, int aflag, char monst)
|
||||||
|
{
|
||||||
|
char logmessage[160], ltemp[80], mlev[40];
|
||||||
|
char *killer;
|
||||||
|
FILE *logfi;
|
||||||
|
|
||||||
|
if (waswizard)
|
||||||
|
return;
|
||||||
|
#ifdef LOGFILE
|
||||||
|
sprintf(logmessage, "%d %d %.20s %d ", time(NULL), amount, whoami,
|
||||||
|
him->s_lvl);
|
||||||
|
if (amulet)
|
||||||
|
sprintf(mlev, " [max %d] with the Amulet", max_level);
|
||||||
|
else
|
||||||
|
mlev[0] = '\0';
|
||||||
|
if (aflag == KILLED) {
|
||||||
|
killer = killname(monst);
|
||||||
|
sprintf(ltemp, "killed by a%s %s on level %d%s\n",
|
||||||
|
vowelstr(killer), killer, level, mlev);
|
||||||
|
}
|
||||||
|
else if (aflag == CHICKEN) {
|
||||||
|
sprintf(ltemp, "quit on level %d%s\n", level, mlev);
|
||||||
|
}
|
||||||
|
else if (aflag == WINNER) {
|
||||||
|
sprintf(ltemp, "escaped with the Amulet [deepest level: %d]\n",
|
||||||
|
max_level);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return;
|
||||||
|
strcat(logmessage, ltemp);
|
||||||
|
logfi = fopen(LOGFILE, "a");
|
||||||
|
if (logfi == NULL)
|
||||||
|
return;
|
||||||
|
fprintf(logfi, "%s", logmessage);
|
||||||
|
fclose(logfi);
|
||||||
|
#endif
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* showtop:
|
* showtop:
|
||||||
* Display the top ten on the screen
|
* Display the top ten on the screen
|
||||||
|
|
@ -296,6 +338,7 @@ addstr("a great profit and are admitted to the fighters guild.\n");
|
||||||
clear();
|
clear();
|
||||||
oldpurse = purse;
|
oldpurse = purse;
|
||||||
showpack(TRUE, NULL);
|
showpack(TRUE, NULL);
|
||||||
|
writelog(purse, WINNER, 0);
|
||||||
score(purse, WINNER, 0);
|
score(purse, WINNER, 0);
|
||||||
byebye(0);
|
byebye(0);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue