Mercurial > hg > early-roguelike
comparison arogue5/main.c @ 218:56e748983fa8
Advanced Rogue 5: convert to ANSI function declarations.
This still leaves over a thousand lines of warning messages, mostly
related to the return types of daemons and fuses.
| author | John "Elwin" Edwards |
|---|---|
| date | Sun, 07 Feb 2016 14:39:21 -0500 |
| parents | aac28331e71d |
| children | 3d4252fa2ed3 |
comparison
equal
deleted
inserted
replaced
| 217:94a0d9dd5ce1 | 218:56e748983fa8 |
|---|---|
| 41 "peach", "banana" | 41 "peach", "banana" |
| 42 }; | 42 }; |
| 43 #define NFRUIT (sizeof(funfruit) / sizeof (char *)) | 43 #define NFRUIT (sizeof(funfruit) / sizeof (char *)) |
| 44 | 44 |
| 45 void open_records(void); | 45 void open_records(void); |
| 46 | 46 bool holiday(void); |
| 47 main(argc, argv, envp) | 47 |
| 48 char **argv; | 48 int |
| 49 char **envp; | 49 main(int argc, char *argv[], char *envp[]) |
| 50 { | 50 { |
| 51 register char *env; | 51 register char *env; |
| 52 int lowtime; | 52 int lowtime; |
| 53 time_t now; | 53 time_t now; |
| 54 char *roguedir; | 54 char *roguedir; |
| 121 #ifdef NUMNET | 121 #ifdef NUMNET |
| 122 /* | 122 /* |
| 123 * Check for a network update | 123 * Check for a network update |
| 124 */ | 124 */ |
| 125 if (argc == 2 && strcmp(argv[1], "-u") == 0) { | 125 if (argc == 2 && strcmp(argv[1], "-u") == 0) { |
| 126 unsigned long netread(); | |
| 127 int errcheck, errors = 0; | 126 int errcheck, errors = 0; |
| 128 unsigned long amount; | 127 unsigned long amount; |
| 129 short monster; | 128 short monster; |
| 130 | 129 |
| 131 /* Read in the amount and monster values to pass to score */ | 130 /* Read in the amount and monster values to pass to score */ |
| 275 /* | 274 /* |
| 276 * fatal: | 275 * fatal: |
| 277 * Exit the program, printing a message. | 276 * Exit the program, printing a message. |
| 278 */ | 277 */ |
| 279 | 278 |
| 280 fatal(s) | 279 void |
| 281 char *s; | 280 fatal(char *s) |
| 282 { | 281 { |
| 283 clear(); | 282 clear(); |
| 284 move(LINES-2, 0); | 283 move(LINES-2, 0); |
| 285 printw("%s", s); | 284 printw("%s", s); |
| 286 draw(stdscr); | 285 draw(stdscr); |
| 292 /* | 291 /* |
| 293 * rnd: | 292 * rnd: |
| 294 * Pick a very random number. | 293 * Pick a very random number. |
| 295 */ | 294 */ |
| 296 | 295 |
| 297 rnd(range) | 296 int |
| 298 register int range; | 297 rnd(int range) |
| 299 { | 298 { |
| 300 return(range == 0 ? 0 : md_rand() % range); | 299 return(range == 0 ? 0 : md_rand() % range); |
| 301 } | 300 } |
| 302 | 301 |
| 303 /* | 302 /* |
| 304 * roll: | 303 * roll: |
| 305 * roll a number of dice | 304 * roll a number of dice |
| 306 */ | 305 */ |
| 307 | 306 |
| 308 roll(number, sides) | 307 int |
| 309 register int number, sides; | 308 roll(int number, int sides) |
| 310 { | 309 { |
| 311 register int dtotal = 0; | 310 register int dtotal = 0; |
| 312 | 311 |
| 313 while(number--) | 312 while(number--) |
| 314 dtotal += rnd(sides)+1; | 313 dtotal += rnd(sides)+1; |
| 334 draw(cw); | 333 draw(cw); |
| 335 md_flushinp(); | 334 md_flushinp(); |
| 336 } | 335 } |
| 337 # endif | 336 # endif |
| 338 | 337 |
| 339 setup() | 338 void |
| 339 setup(void) | |
| 340 { | 340 { |
| 341 #ifdef CHECKTIME | 341 #ifdef CHECKTIME |
| 342 int checkout(); | 342 void checkout(); |
| 343 #endif | 343 #endif |
| 344 | 344 |
| 345 #ifndef DUMP | 345 #ifndef DUMP |
| 346 #ifdef SIGHUP | 346 #ifdef SIGHUP |
| 347 signal(SIGHUP, auto_save); | 347 signal(SIGHUP, auto_save); |
| 390 * playit: | 390 * playit: |
| 391 * The main loop of the program. Loop until the game is over, | 391 * The main loop of the program. Loop until the game is over, |
| 392 * refreshing things and looking at the proper times. | 392 * refreshing things and looking at the proper times. |
| 393 */ | 393 */ |
| 394 | 394 |
| 395 playit() | 395 void |
| 396 playit(void) | |
| 396 { | 397 { |
| 397 register char *opts; | 398 register char *opts; |
| 398 | 399 |
| 399 | 400 |
| 400 /* | 401 /* |
| 414 | 415 |
| 415 #if MAXLOAD|MAXUSERS | 416 #if MAXLOAD|MAXUSERS |
| 416 /* | 417 /* |
| 417 * see if the system is being used too much for this game | 418 * see if the system is being used too much for this game |
| 418 */ | 419 */ |
| 419 too_much() | 420 bool |
| 421 too_much(void) | |
| 420 { | 422 { |
| 421 #ifdef MAXLOAD | 423 #ifdef MAXLOAD |
| 422 double avec[3]; | 424 double avec[3]; |
| 423 #endif | 425 #endif |
| 424 | 426 |
| 433 | 435 |
| 434 /* | 436 /* |
| 435 * author: | 437 * author: |
| 436 * See if a user is an author of the program | 438 * See if a user is an author of the program |
| 437 */ | 439 */ |
| 438 author() | 440 bool |
| 441 author(void) | |
| 439 { | 442 { |
| 440 switch (md_getuid()) { | 443 switch (md_getuid()) { |
| 441 #if AUTHOR | 444 #if AUTHOR |
| 442 case AUTHOR: | 445 case AUTHOR: |
| 443 #endif | 446 #endif |
| 448 } | 451 } |
| 449 } | 452 } |
| 450 | 453 |
| 451 | 454 |
| 452 #ifdef CHECKTIME | 455 #ifdef CHECKTIME |
| 453 checkout() | 456 /* |
| 457 * checkout()'s version of msg. If we are in the middle of a shell, do a | |
| 458 * printf instead of a msg to avoid the refresh. | |
| 459 */ | |
| 460 void | |
| 461 chmsg(char *fmt, int arg) | |
| 462 { | |
| 463 if (in_shell) { | |
| 464 printf(fmt, arg); | |
| 465 putchar('\n'); | |
| 466 fflush(stdout); | |
| 467 } | |
| 468 else | |
| 469 msg(fmt, arg); | |
| 470 } | |
| 471 | |
| 472 void | |
| 473 checkout(void) | |
| 454 { | 474 { |
| 455 static char *msgs[] = { | 475 static char *msgs[] = { |
| 456 "The system is too loaded for games. Please leave in %d minutes", | 476 "The system is too loaded for games. Please leave in %d minutes", |
| 457 "Please save your game. You have %d minutes", | 477 "Please save your game. You have %d minutes", |
| 458 "This is your last chance. You had better leave in %d minutes", | 478 "This is your last chance. You had better leave in %d minutes", |
| 480 num_checks = 0; | 500 num_checks = 0; |
| 481 } | 501 } |
| 482 alarm(CHECKTIME * 60); | 502 alarm(CHECKTIME * 60); |
| 483 } | 503 } |
| 484 } | 504 } |
| 485 | |
| 486 /* | |
| 487 * checkout()'s version of msg. If we are in the middle of a shell, do a | |
| 488 * printf instead of a msg to avoid the refresh. | |
| 489 */ | |
| 490 chmsg(fmt, arg) | |
| 491 char *fmt; | |
| 492 int arg; | |
| 493 { | |
| 494 if (in_shell) { | |
| 495 printf(fmt, arg); | |
| 496 putchar('\n'); | |
| 497 fflush(stdout); | |
| 498 } | |
| 499 else | |
| 500 msg(fmt, arg); | |
| 501 } | |
| 502 #endif | 505 #endif |
| 503 | 506 |
| 504 #ifdef LOADAV | 507 #ifdef LOADAV |
| 505 | 508 |
| 506 #include <nlist.h> | 509 #include <nlist.h> |
| 508 struct nlist avenrun = | 511 struct nlist avenrun = |
| 509 { | 512 { |
| 510 "_avenrun" | 513 "_avenrun" |
| 511 }; | 514 }; |
| 512 | 515 |
| 513 loadav(avg) | 516 void |
| 514 reg double *avg; | 517 loadav(double *avg) |
| 515 { | 518 { |
| 516 reg int kmem; | 519 reg int kmem; |
| 517 | 520 |
| 518 if ((kmem = open("/dev/kmem", 0)) < 0) | 521 if ((kmem = open("/dev/kmem", 0)) < 0) |
| 519 goto bad; | 522 goto bad; |
| 534 * Count the number of people on the system | 537 * Count the number of people on the system |
| 535 */ | 538 */ |
| 536 #include <sys/types.h> | 539 #include <sys/types.h> |
| 537 #include <utmp.h> | 540 #include <utmp.h> |
| 538 struct utmp buf; | 541 struct utmp buf; |
| 539 ucount() | 542 int |
| 543 ucount(void) | |
| 540 { | 544 { |
| 541 reg struct utmp *up; | 545 reg struct utmp *up; |
| 542 reg FILE *utmp; | 546 reg FILE *utmp; |
| 543 reg int count; | 547 reg int count; |
| 544 | 548 |
| 557 | 561 |
| 558 /* | 562 /* |
| 559 * holiday: | 563 * holiday: |
| 560 * Returns TRUE when it is a good time to play rogue | 564 * Returns TRUE when it is a good time to play rogue |
| 561 */ | 565 */ |
| 562 holiday() | 566 bool |
| 567 holiday(void) | |
| 563 { | 568 { |
| 564 time_t now; | 569 time_t now; |
| 565 struct tm *localtime(); | 570 struct tm *localtime(); |
| 566 reg struct tm *ntime; | 571 reg struct tm *ntime; |
| 567 | 572 |
