comparison rogue3/main.c @ 212:12e070d1a780

rogue3: replace alarm() calls with a portable function. Calls to alarm() in main.c are replaced with md_start_checkout_timer(), so the #ifdefs around nonportable code can be confined to mdport.c.
author John "Elwin" Edwards
date Fri, 22 Jan 2016 19:19:48 -0500
parents ee250e3646fd
children e5a15b09ce1d
comparison
equal deleted inserted replaced
211:382ff498acdd 212:12e070d1a780
372 signal(SIGTSTP, tstp); 372 signal(SIGTSTP, tstp);
373 #endif 373 #endif
374 374
375 if (!author()) 375 if (!author())
376 { 376 {
377 #ifdef SIGALRM 377 md_start_checkout_timer(CHECKTIME * 60);
378 signal(SIGALRM, checkout);
379 alarm(CHECKTIME * 60);
380 #endif
381 num_checks = 0; 378 num_checks = 0;
382 } 379 }
383 380
384 nonl(); 381 nonl();
385 crmode(); /* Cbreak mode */ 382 crmode(); /* Cbreak mode */
462 "The load is too high to be playing. Please leave in %d minutes", 459 "The load is too high to be playing. Please leave in %d minutes",
463 "Please save your game. You have %d minutes", 460 "Please save your game. You have %d minutes",
464 "Last warning. You have %d minutes to leave", 461 "Last warning. You have %d minutes to leave",
465 }; 462 };
466 int checktime; 463 int checktime;
467 #ifdef SIGALRM
468 signal(SIGALRM, checkout);
469 #endif
470 if (too_much()) 464 if (too_much())
471 { 465 {
472 if (num_checks >= 3) 466 if (num_checks >= 3)
473 fatal("Sorry. You took to long. You are dead\n"); 467 fatal("Sorry. You took to long. You are dead\n");
474 checktime = CHECKTIME / (num_checks + 1); 468 checktime = CHECKTIME / (num_checks + 1);
475 if (num_checks < 3) 469 if (num_checks < 3)
476 chmsg(msgs[num_checks++], checktime); 470 chmsg(msgs[num_checks++], checktime);
477 #ifdef SIGALRM 471 md_start_checkout_timer(checktime * 60);
478 alarm(checktime * 60);
479 #endif
480 } 472 }
481 else 473 else
482 { 474 {
483 if (num_checks) 475 if (num_checks)
484 { 476 {
485 chmsg("The load has dropped back down. You have a reprieve."); 477 chmsg("The load has dropped back down. You have a reprieve.");
486 num_checks = 0; 478 num_checks = 0;
487 } 479 }
488 #ifdef SIGALRM 480 md_start_checkout_timer(CHECKTIME * 60);
489 alarm(CHECKTIME * 60);
490 #endif
491 } 481 }
492 } 482 }
493 483
494 /* 484 /*
495 * checkout()'s version of msg. If we are in the middle of a shell, do a 485 * checkout()'s version of msg. If we are in the middle of a shell, do a