Mercurial > hg > early-roguelike
comparison rogue4/fight.c @ 215:1b73a8641b37
rogue4: fix most GCC5 warnings.
Converting all function definitions to ANSI style accounts for most of
the change. This has exposed other problems, such as daemons not
actually being their stated type, that will require more careful
solutions.
author | John "Elwin" Edwards |
---|---|
date | Wed, 27 Jan 2016 19:41:05 -0500 |
parents | 9535a08ddc39 |
children | 0990adf580ee |
comparison
equal
deleted
inserted
replaced
214:e5a15b09ce1d | 215:1b73a8641b37 |
---|---|
8 * All rights reserved. | 8 * All rights reserved. |
9 * | 9 * |
10 * See the file LICENSE.TXT for full copyright and licensing information. | 10 * See the file LICENSE.TXT for full copyright and licensing information. |
11 */ | 11 */ |
12 | 12 |
13 #include <stdlib.h> | |
13 #include <curses.h> | 14 #include <curses.h> |
14 #include <ctype.h> | 15 #include <ctype.h> |
15 #include <string.h> | 16 #include <string.h> |
16 #include "rogue.h" | 17 #include "rogue.h" |
17 | 18 |
18 long e_levels[] = { | 19 long e_levels[] = { |
19 10L,20L,40L,80L,160L,320L,640L,1280L,2560L,5120L,10240L,20480L, | 20 10L,20L,40L,80L,160L,320L,640L,1280L,2560L,5120L,10240L,20480L, |
20 40920L, 81920L, 163840L, 327680L, 655360L, 1310720L, 2621440L, 0L | 21 40920L, 81920L, 163840L, 327680L, 655360L, 1310720L, 2621440L, 0L |
21 }; | 22 }; |
22 | 23 |
24 bool roll_em(THING *thatt, THING *thdef, THING *weap, bool hurl); | |
25 void hit(char *er, char *ee); | |
26 void miss(char *er, char *ee); | |
27 int str_plus(str_t str); | |
28 int add_dam(str_t str); | |
29 void thunk(THING *weap, const char *mname); | |
30 void bounce(THING *weap, const char *mname); | |
31 | |
23 /* | 32 /* |
24 * fight: | 33 * fight: |
25 * The player attacks the monster. | 34 * The player attacks the monster. |
26 */ | 35 */ |
27 fight(mp, mn, weap, thrown) | 36 bool |
28 register coord *mp; | 37 fight(coord *mp, char mn, THING *weap, bool thrown) |
29 char mn; | |
30 register THING *weap; | |
31 bool thrown; | |
32 { | 38 { |
33 register THING *tp; | 39 register THING *tp; |
34 register bool did_hit = TRUE; | 40 register bool did_hit = TRUE; |
35 register const char *mname; | 41 register const char *mname; |
36 | 42 |
94 | 100 |
95 /* | 101 /* |
96 * attack: | 102 * attack: |
97 * The monster attacks the player | 103 * The monster attacks the player |
98 */ | 104 */ |
99 attack(mp) | 105 int |
100 register THING *mp; | 106 attack(THING *mp) |
101 { | 107 { |
102 register const char *mname; | 108 register const char *mname; |
103 | 109 |
104 /* | 110 /* |
105 * Since this is an attack, stop running and any healing that was | 111 * Since this is an attack, stop running and any healing that was |
293 | 299 |
294 /* | 300 /* |
295 * swing: | 301 * swing: |
296 * Returns true if the swing hits | 302 * Returns true if the swing hits |
297 */ | 303 */ |
298 swing(at_lvl, op_arm, wplus) | 304 bool |
299 int at_lvl, op_arm, wplus; | 305 swing(int at_lvl, int op_arm, int wplus) |
300 { | 306 { |
301 register int res = rnd(20); | 307 register int res = rnd(20); |
302 register int need = (20 - at_lvl) - op_arm; | 308 register int need = (20 - at_lvl) - op_arm; |
303 | 309 |
304 return (res + wplus >= need); | 310 return (res + wplus >= need); |
306 | 312 |
307 /* | 313 /* |
308 * check_level: | 314 * check_level: |
309 * Check to see if the guy has gone up a level. | 315 * Check to see if the guy has gone up a level. |
310 */ | 316 */ |
311 check_level() | 317 void |
318 check_level(void) | |
312 { | 319 { |
313 register int i, add, olevel; | 320 register int i, add, olevel; |
314 | 321 |
315 for (i = 0; e_levels[i] != 0; i++) | 322 for (i = 0; e_levels[i] != 0; i++) |
316 if (e_levels[i] > pstats.s_exp) | 323 if (e_levels[i] > pstats.s_exp) |
330 | 337 |
331 /* | 338 /* |
332 * roll_em: | 339 * roll_em: |
333 * Roll several attacks | 340 * Roll several attacks |
334 */ | 341 */ |
335 roll_em(thatt, thdef, weap, hurl) | 342 bool |
336 THING *thatt, *thdef, *weap; | 343 roll_em(THING *thatt, THING *thdef, THING *weap, bool hurl) |
337 bool hurl; | |
338 { | 344 { |
339 register struct stats *att, *def; | 345 register struct stats *att, *def; |
340 register char *cp; | 346 register char *cp; |
341 register int ndice, nsides, def_arm; | 347 register int ndice, nsides, def_arm; |
342 register bool did_hit = FALSE; | 348 register bool did_hit = FALSE; |
438 /* | 444 /* |
439 * prname: | 445 * prname: |
440 * The print name of a combatant | 446 * The print name of a combatant |
441 */ | 447 */ |
442 char * | 448 char * |
443 prname(who, upper) | 449 prname(char *who, bool upper) |
444 register char *who; | |
445 bool upper; | |
446 { | 450 { |
447 static char tbuf[MAXSTR]; | 451 static char tbuf[MAXSTR]; |
448 | 452 |
449 *tbuf = '\0'; | 453 *tbuf = '\0'; |
450 if (who == 0) | 454 if (who == 0) |
463 | 467 |
464 /* | 468 /* |
465 * hit: | 469 * hit: |
466 * Print a message to indicate a succesful hit | 470 * Print a message to indicate a succesful hit |
467 */ | 471 */ |
468 hit(er, ee) | 472 void |
469 register char *er, *ee; | 473 hit(char *er, char *ee) |
470 { | 474 { |
471 register char *s = ""; | 475 register char *s = ""; |
472 | 476 |
473 addmsg(prname(er, TRUE)); | 477 addmsg(prname(er, TRUE)); |
474 if (terse) | 478 if (terse) |
489 | 493 |
490 /* | 494 /* |
491 * miss: | 495 * miss: |
492 * Print a message to indicate a poor swing | 496 * Print a message to indicate a poor swing |
493 */ | 497 */ |
494 miss(er, ee) | 498 void |
495 register char *er, *ee; | 499 miss(char *er, char *ee) |
496 { | 500 { |
497 register char *s = ""; | 501 register char *s = ""; |
498 | 502 |
499 addmsg(prname(er, TRUE)); | 503 addmsg(prname(er, TRUE)); |
500 switch (terse ? 0 : rnd(4)) | 504 switch (terse ? 0 : rnd(4)) |
512 | 516 |
513 /* | 517 /* |
514 * save_throw: | 518 * save_throw: |
515 * See if a creature save against something | 519 * See if a creature save against something |
516 */ | 520 */ |
517 save_throw(which, tp) | 521 bool |
518 int which; | 522 save_throw(int which, THING *tp) |
519 THING *tp; | |
520 { | 523 { |
521 register int need; | 524 register int need; |
522 | 525 |
523 need = 14 + which - tp->t_stats.s_lvl / 2; | 526 need = 14 + which - tp->t_stats.s_lvl / 2; |
524 return (roll(1, 20) >= need); | 527 return (roll(1, 20) >= need); |
526 | 529 |
527 /* | 530 /* |
528 * save: | 531 * save: |
529 * See if he saves against various nasty things | 532 * See if he saves against various nasty things |
530 */ | 533 */ |
531 save(which) | 534 bool |
532 register int which; | 535 save(int which) |
533 { | 536 { |
534 if (which == VS_MAGIC) | 537 if (which == VS_MAGIC) |
535 { | 538 { |
536 if (ISRING(LEFT, R_PROTECT)) | 539 if (ISRING(LEFT, R_PROTECT)) |
537 which -= cur_ring[LEFT]->o_ac; | 540 which -= cur_ring[LEFT]->o_ac; |
543 | 546 |
544 /* | 547 /* |
545 * str_plus: | 548 * str_plus: |
546 * Compute bonus/penalties for strength on the "to hit" roll | 549 * Compute bonus/penalties for strength on the "to hit" roll |
547 */ | 550 */ |
548 str_plus(str) | 551 int |
549 register str_t str; | 552 str_plus(str_t str) |
550 { | 553 { |
551 if (str == 31) | 554 if (str == 31) |
552 return 3; | 555 return 3; |
553 if (str > 20) | 556 if (str > 20) |
554 return 2; | 557 return 2; |
561 | 564 |
562 /* | 565 /* |
563 * add_dam: | 566 * add_dam: |
564 * Compute additional damage done for exceptionally high or low strength | 567 * Compute additional damage done for exceptionally high or low strength |
565 */ | 568 */ |
566 add_dam(str) | 569 int |
567 register str_t str; | 570 add_dam(str_t str) |
568 { | 571 { |
569 if (str == 31) | 572 if (str == 31) |
570 return 6; | 573 return 6; |
571 if (str > 21) | 574 if (str > 21) |
572 return 5; | 575 return 5; |
573 if (str == 21) | 576 if (str == 21) |
585 | 588 |
586 /* | 589 /* |
587 * raise_level: | 590 * raise_level: |
588 * The guy just magically went up a level. | 591 * The guy just magically went up a level. |
589 */ | 592 */ |
590 raise_level() | 593 void |
594 raise_level(void) | |
591 { | 595 { |
592 pstats.s_exp = e_levels[pstats.s_lvl-1] + 1L; | 596 pstats.s_exp = e_levels[pstats.s_lvl-1] + 1L; |
593 check_level(); | 597 check_level(); |
594 } | 598 } |
595 | 599 |
596 /* | 600 /* |
597 * thunk: | 601 * thunk: |
598 * A missile hits a monster | 602 * A missile hits a monster |
599 */ | 603 */ |
600 thunk(weap, mname) | 604 void |
601 register THING *weap; | 605 thunk(THING *weap, const char *mname) |
602 register const char *mname; | |
603 { | 606 { |
604 if (weap->o_type == WEAPON) | 607 if (weap->o_type == WEAPON) |
605 addmsg("the %s hits ", w_names[weap->o_which]); | 608 addmsg("the %s hits ", w_names[weap->o_which]); |
606 else | 609 else |
607 addmsg("you hit "); | 610 addmsg("you hit "); |
613 | 616 |
614 /* | 617 /* |
615 * bounce: | 618 * bounce: |
616 * A missile misses a monster | 619 * A missile misses a monster |
617 */ | 620 */ |
618 bounce(weap, mname) | 621 void |
619 register THING *weap; | 622 bounce(THING *weap, const char *mname) |
620 register const char *mname; | |
621 { | 623 { |
622 if (weap->o_type == WEAPON) | 624 if (weap->o_type == WEAPON) |
623 addmsg("the %s misses ", w_names[weap->o_which]); | 625 addmsg("the %s misses ", w_names[weap->o_which]); |
624 else | 626 else |
625 addmsg("you missed "); | 627 addmsg("you missed "); |
631 | 633 |
632 /* | 634 /* |
633 * remove: | 635 * remove: |
634 * Remove a monster from the screen | 636 * Remove a monster from the screen |
635 */ | 637 */ |
636 remove_monster(mp, tp, waskill) | 638 void |
637 register coord *mp; | 639 remove_monster(coord *mp, THING *tp, bool waskill) |
638 register THING *tp; | |
639 bool waskill; | |
640 { | 640 { |
641 register THING *obj, *nexti; | 641 register THING *obj, *nexti; |
642 | 642 |
643 for (obj = tp->t_pack; obj != NULL; obj = nexti) | 643 for (obj = tp->t_pack; obj != NULL; obj = nexti) |
644 { | 644 { |
658 | 658 |
659 /* | 659 /* |
660 * is_magic: | 660 * is_magic: |
661 * Returns true if an object radiates magic | 661 * Returns true if an object radiates magic |
662 */ | 662 */ |
663 is_magic(obj) | 663 bool |
664 register THING *obj; | 664 is_magic(THING *obj) |
665 { | 665 { |
666 switch (obj->o_type) | 666 switch (obj->o_type) |
667 { | 667 { |
668 case ARMOR: | 668 case ARMOR: |
669 return obj->o_ac != a_class[obj->o_which]; | 669 return obj->o_ac != a_class[obj->o_which]; |
681 | 681 |
682 /* | 682 /* |
683 * killed: | 683 * killed: |
684 * Called to put a monster to death | 684 * Called to put a monster to death |
685 */ | 685 */ |
686 killed(tp, pr) | 686 void |
687 register THING *tp; | 687 killed(THING *tp, bool pr) |
688 bool pr; | |
689 { | 688 { |
690 pstats.s_exp += tp->t_stats.s_exp; | 689 pstats.s_exp += tp->t_stats.s_exp; |
691 /* | 690 /* |
692 * If the monster was a violet fungi, un-hold him | 691 * If the monster was a violet fungi, un-hold him |
693 */ | 692 */ |