comparison rogue5/rip.c @ 34:655c317b6237

rogue5: add savedir, logfile, bugfixes
author elwin
date Mon, 24 May 2010 20:16:15 +0000
parents f502bf60e6e4
children 24e6beb9e7aa
comparison
equal deleted inserted replaced
33:f502bf60e6e4 34:655c317b6237
221 signal(SIGINT, fp); 221 signal(SIGINT, fp);
222 } 222 }
223 } 223 }
224 } 224 }
225 225
226 void writelog(int amount, int flags, int monst)
227 {
228 #ifdef LOGFILE
229 char logmessage[160], ltemp[80];
230
231 if (logfi == NULL)
232 return;
233 #ifdef MASTER
234 if (wizard)
235 {
236 fclose(logfi);
237 return;
238 }
239 #endif
240 sprintf(logmessage, "%d %d %.20s %d ", time(NULL), amount, whoami,
241 pstats.s_lvl);
242 if (flags == 0) /* dead */
243 {
244 sprintf(ltemp, "killed by %s on level %d\n", killname(monst, TRUE),
245 level);
246 strcat(logmessage, ltemp);
247 }
248 else if (flags == 1) /* quit */
249 {
250 if (amulet)
251 sprintf(ltemp, "quit on level %d [max %d] with the Amulet\n",
252 level, max_level);
253 else
254 sprintf(ltemp, "quit on level %d\n", level);
255 strcat(logmessage, ltemp);
256 }
257 else if (flags == 2) /* won */
258 {
259 sprintf(ltemp, "escaped with the Amulet [deepest level: %d]\n",
260 max_level);
261 strcat(logmessage, ltemp);
262 }
263 else if (flags == 3) /* killed with Amulet */
264 {
265 strcat(logmessage, "killed by ");
266 strcat(logmessage, killname(monst, TRUE));
267 sprintf(ltemp, " on level %d [max %d] with the Amulet\n",
268 level, max_level);
269 strcat(logmessage, ltemp);
270 }
271 else
272 {
273 fclose(logfi);
274 return;
275 }
276 fprintf(logfi, "%s", logmessage);
277 fclose(logfi);
278 #endif
279 return;
280 }
281
226 /* 282 /*
227 * death: 283 * death:
228 * Do something really fun when he dies 284 * Do something really fun when he dies
229 */ 285 */
230 286
269 sprintf(prbuf, "%4d", 1900+lt->tm_year); 325 sprintf(prbuf, "%4d", 1900+lt->tm_year);
270 mvaddstr(18, 26, prbuf); 326 mvaddstr(18, 26, prbuf);
271 } 327 }
272 move(LINES - 1, 0); 328 move(LINES - 1, 0);
273 refresh(); 329 refresh();
330 writelog(purse, amulet ? 3 : 0, monst);
274 score(purse, amulet ? 3 : 0, monst); 331 score(purse, amulet ? 3 : 0, monst);
332 /* Make sure the output gets through. */
333 printf("[Press return to exit]\n");
334 fflush(NULL);
335 getchar();
275 my_exit(0); 336 my_exit(0);
276 } 337 }
277 338
278 /* 339 /*
279 * center: 340 * center:
380 printw("%c) %5d %s\n", obj->o_packch, worth, inv_name(obj, FALSE)); 441 printw("%c) %5d %s\n", obj->o_packch, worth, inv_name(obj, FALSE));
381 purse += worth; 442 purse += worth;
382 } 443 }
383 printw(" %5d Gold Pieces ", oldpurse); 444 printw(" %5d Gold Pieces ", oldpurse);
384 refresh(); 445 refresh();
446 writelog(purse, 2, ' ');
385 score(purse, 2, ' '); 447 score(purse, 2, ' ');
386 my_exit(0); 448 my_exit(0);
387 } 449 }
388 450
389 /* 451 /*