comparison arogue7/things.c @ 219:f9ef86cf22b2

Advanced Rogue 7: convert to ANSI-style function declarations. Almost 1500 lines of compiler warnings remain, and the GCC developers are already working on a new version with even more warnings turned on by default.
author John "Elwin" Edwards
date Fri, 19 Feb 2016 21:02:28 -0500
parents b786053d2f37
children
comparison
equal deleted inserted replaced
218:56e748983fa8 219:f9ef86cf22b2
21 #include "curses.h" 21 #include "curses.h"
22 #include <ctype.h> 22 #include <ctype.h>
23 #include <string.h> 23 #include <string.h>
24 #include "rogue.h" 24 #include "rogue.h"
25 25
26 int pick_one(struct magic_item *magic, int nitems);
27 char *blesscurse(int flags);
28 char *p_kind(struct object *obj);
29 int extras(void);
30
26 /* 31 /*
27 * print out the number of charges on a stick 32 * print out the number of charges on a stick
28 */ 33 */
29 char * 34 char *
30 charge_str(obj) 35 charge_str(struct object *obj)
31 register struct object *obj;
32 { 36 {
33 static char buf[20]; 37 static char buf[20];
34 38
35 if (!(obj->o_flags & ISKNOW)) 39 if (!(obj->o_flags & ISKNOW))
36 buf[0] = '\0'; 40 buf[0] = '\0';
44 * inv_name: 48 * inv_name:
45 * return the name of something as it would appear in an 49 * return the name of something as it would appear in an
46 * inventory. 50 * inventory.
47 */ 51 */
48 char * 52 char *
49 inv_name(obj, drop) 53 inv_name(struct object *obj, bool drop)
50 register struct object *obj;
51 bool drop;
52 { 54 {
53 register char *pb; 55 register char *pb;
54 56
55 pb = prbuf; 57 pb = prbuf;
56 pb[0] = '\0'; 58 pb[0] = '\0';
322 /* 324 /*
323 * weap_name: 325 * weap_name:
324 * Return the name of a weapon. 326 * Return the name of a weapon.
325 */ 327 */
326 char * 328 char *
327 weap_name(obj) 329 weap_name(struct object *obj)
328 register struct object *obj;
329 { 330 {
330 switch (obj->o_type) { 331 switch (obj->o_type) {
331 case WEAPON: 332 case WEAPON:
332 return(weaps[obj->o_which].w_name); 333 return(weaps[obj->o_which].w_name);
333 when MISSILE: 334 when MISSILE:
355 356
356 /* 357 /*
357 * drop: 358 * drop:
358 * put something down 359 * put something down
359 */ 360 */
360 drop(item) 361 bool
361 struct linked_list *item; 362 drop(struct linked_list *item)
362 { 363 {
363 register char ch; 364 register char ch;
364 register struct linked_list *obj, *nobj; 365 register struct linked_list *obj, *nobj;
365 register struct object *op; 366 register struct object *op;
366 367
462 } 463 }
463 464
464 /* 465 /*
465 * do special checks for dropping or unweilding|unwearing|unringing 466 * do special checks for dropping or unweilding|unwearing|unringing
466 */ 467 */
467 dropcheck(op) 468 bool
468 register struct object *op; 469 dropcheck(struct object *op)
469 { 470 {
470 int save_max; 471 int save_max;
471 472
472 if (op == NULL) 473 if (op == NULL)
473 return TRUE; 474 return TRUE;
564 565
565 /* 566 /*
566 * return a new thing 567 * return a new thing
567 */ 568 */
568 struct linked_list * 569 struct linked_list *
569 new_thing(thing_type, allow_curse) 570 new_thing(int thing_type, bool allow_curse)
570 int thing_type;
571 bool allow_curse;
572 { 571 {
573 register struct linked_list *item; 572 register struct linked_list *item;
574 register struct object *cur; 573 register struct object *cur;
575 register int j; 574 register int j;
576 register int blesschance, cursechance; 575 register int blesschance, cursechance;
777 776
778 /* 777 /*
779 * provide a new item tailored to specification 778 * provide a new item tailored to specification
780 */ 779 */
781 struct linked_list * 780 struct linked_list *
782 spec_item(type, which, hit, damage) 781 spec_item(int type, int which, int hit, int damage)
783 int type, which, hit, damage;
784 { 782 {
785 register struct linked_list *item; 783 register struct linked_list *item;
786 register struct object *obj; 784 register struct object *obj;
787 785
788 item = new_item(sizeof *obj); 786 item = new_item(sizeof *obj);
856 } 854 }
857 855
858 /* 856 /*
859 * pick an item out of a list of nitems possible magic items 857 * pick an item out of a list of nitems possible magic items
860 */ 858 */
861 pick_one(magic, nitems) 859 int
862 register struct magic_item *magic; 860 pick_one(struct magic_item *magic, int nitems)
863 int nitems;
864 { 861 {
865 register struct magic_item *end; 862 register struct magic_item *end;
866 register int i; 863 register int i;
867 register struct magic_item *start; 864 register struct magic_item *start;
868 865
887 /* blesscurse returns whether, according to the flag, the object is 884 /* blesscurse returns whether, according to the flag, the object is
888 * blessed, cursed, or neither 885 * blessed, cursed, or neither
889 */ 886 */
890 887
891 char * 888 char *
892 blesscurse(flags) 889 blesscurse(int flags)
893 int flags;
894 { 890 {
895 if (flags & ISKNOW) { 891 if (flags & ISKNOW) {
896 if (flags & ISCURSED) return("cursed "); 892 if (flags & ISCURSED) return("cursed ");
897 if (flags & ISBLESSED) return("blessed "); 893 if (flags & ISBLESSED) return("blessed ");
898 return("normal "); 894 return("normal ");
901 } 897 }
902 898
903 /* 899 /*
904 * p_kind returns the type of potion for some types of identified potions; 900 * p_kind returns the type of potion for some types of identified potions;
905 * otherwise, it returns the color. 901 * otherwise, it returns the color.
902 * We assume that obj points to a potion
906 */ 903 */
907 904
908 char * 905 char *
909 p_kind(obj) 906 p_kind(struct object *obj)
910 struct object *obj; /* We assume that obj points to a potion */
911 { 907 {
912 if (obj->o_which == P_ABIL) return(abilities[obj->o_kind]); 908 if (obj->o_which == P_ABIL) return(abilities[obj->o_kind]);
913 else return(p_colors[obj->o_which]); 909 else return(p_colors[obj->o_which]);
914 } 910 }
915 911
916 /* 912 /*
917 * extras: 913 * extras:
918 * Return the number of extra items to be created 914 * Return the number of extra items to be created
919 */ 915 */
920 extras() 916 int
917 extras(void)
921 { 918 {
922 reg int i; 919 reg int i;
923 920
924 i = rnd(100); 921 i = rnd(100);
925 if (i < 4) /* 4% for 2 more */ 922 if (i < 4) /* 4% for 2 more */