comparison urogue/rip.c @ 268:4ab49e42dd6a

UltraRogue: add logging. The log file's name is temporarily defined in main.c.
author John "Elwin" Edwards
date Sun, 26 Feb 2017 16:51:29 -0500
parents 911f0aa6e758
children 1bbdd13ec585
comparison
equal deleted inserted replaced
267:911f0aa6e758 268:4ab49e42dd6a
51 " *| * * * | *", 51 " *| * * * | *",
52 " ________)/\\\\_//(\\/(/\\)/\\//\\/|_)_______", 52 " ________)/\\\\_//(\\/(/\\)/\\//\\/|_)_______",
53 0 53 0
54 }; 54 };
55 55
56 void writelog(long amount, int lvl, int flags, int monst);
57
56 /* 58 /*
57 death() 59 death()
58 Do something really fun when he dies 60 Do something really fun when he dies
59 */ 61 */
60 62
202 "a winner", 204 "a winner",
203 "a total winner" 205 "a total winner"
204 }; 206 };
205 207
206 char *packend; 208 char *packend;
209
210 if (flags != SCOREIT)
211 writelog(amount, lvl, flags, monst);
207 212
208 if (flags != WINNER && flags != TOTAL && flags != SCOREIT) 213 if (flags != WINNER && flags != TOTAL && flags != SCOREIT)
209 { 214 {
210 if (flags == CHICKEN) 215 if (flags == CHICKEN)
211 packend = "when you quit"; 216 packend = "when you quit";
381 if (flags != SCOREIT) { 386 if (flags != SCOREIT) {
382 printf("[Press RETURN to exit]\n"); 387 printf("[Press RETURN to exit]\n");
383 fflush(stdout); 388 fflush(stdout);
384 getchar(); 389 getchar();
385 } 390 }
391 }
392
393 void
394 writelog(long amount, int lvl, int flags, int monst)
395 {
396 char fate[80];
397 if (file_log == NULL)
398 return;
399 if (flags == KILLED) {
400 strcpy(fate, "killed by ");
401 killname(monst, fate + 10);
402 }
403 else if (flags == CHICKEN) {
404 strcpy(fate, "quit");
405 }
406 else if (flags == WINNER || flags == TOTAL) {
407 strcpy(fate, "escaped");
408 }
409 else
410 return;
411 fprintf(file_log, "%d %d %s %d %s %d %d %d %s\n", time(NULL), amount,
412 whoami, lvl, which_class(player.t_ctype), level, max_level,
413 has_artifact, fate);
414 fclose(file_log);
415 return;
386 } 416 }
387 417
388 void 418 void
389 total_winner(void) 419 total_winner(void)
390 { 420 {