Mercurial > hg > early-roguelike
comparison arogue7/misc.c @ 225:4f6e056438eb
Merge the GCC5 and build fix branches.
| author | John "Elwin" Edwards |
|---|---|
| date | Wed, 02 Mar 2016 21:28:34 -0500 |
| parents | f9ef86cf22b2 |
| children | e1cd27c5464f |
comparison
equal
deleted
inserted
replaced
| 224:4d0f53998e8a | 225:4f6e056438eb |
|---|---|
| 13 */ | 13 */ |
| 14 | 14 |
| 15 #include "curses.h" | 15 #include "curses.h" |
| 16 #include <stdlib.h> | 16 #include <stdlib.h> |
| 17 #include <ctype.h> | 17 #include <ctype.h> |
| 18 #include <string.h> | |
| 18 #include "rogue.h" | 19 #include "rogue.h" |
| 19 #ifdef PC7300 | 20 #ifdef PC7300 |
| 20 #include "menu.h" | 21 #include "menu.h" |
| 21 #endif | 22 #endif |
| 22 | 23 |
| 27 /* | 28 /* |
| 28 * changeclass: | 29 * changeclass: |
| 29 * Change the player's class to the specified one. | 30 * Change the player's class to the specified one. |
| 30 */ | 31 */ |
| 31 | 32 |
| 32 changeclass(newclass) | 33 void |
| 33 int newclass; | 34 changeclass(int newclass) |
| 34 { | 35 { |
| 35 if (newclass == player.t_ctype) { | 36 if (newclass == player.t_ctype) { |
| 36 msg("You feel more skillful."); | 37 msg("You feel more skillful."); |
| 37 raise_level(); | 38 raise_level(); |
| 38 } | 39 } |
| 130 } | 131 } |
| 131 | 132 |
| 132 /* | 133 /* |
| 133 * Use the relic that our monster is wielding. | 134 * Use the relic that our monster is wielding. |
| 134 */ | 135 */ |
| 135 m_use_relic(monster) | 136 void |
| 136 register struct thing *monster; | 137 m_use_relic(struct thing *monster) |
| 137 { | 138 { |
| 138 register struct object *obj; | 139 register struct object *obj; |
| 139 | 140 |
| 140 /* Make sure we really have it */ | 141 /* Make sure we really have it */ |
| 141 if (monster->t_using) obj = OBJPTR(monster->t_using); | 142 if (monster->t_using) obj = OBJPTR(monster->t_using); |
| 159 hit_monster(unc(missile.o_pos), &missile, monster); | 160 hit_monster(unc(missile.o_pos), &missile, monster); |
| 160 monster->t_artifact = monster->t_artifact * 4 / 5; | 161 monster->t_artifact = monster->t_artifact * 4 / 5; |
| 161 } | 162 } |
| 162 when EMORI_CLOAK: | 163 when EMORI_CLOAK: |
| 163 debug("stunning with Emori's cloak"); | 164 debug("stunning with Emori's cloak"); |
| 164 do_zap(monster, obj, &monster->t_newpos, WS_PARALYZE, NULL); | 165 do_zap(monster, obj, &monster->t_newpos, WS_PARALYZE, 0); |
| 165 obj->o_charges = 0; | 166 obj->o_charges = 0; |
| 166 | 167 |
| 167 when ASMO_ROD: { | 168 when ASMO_ROD: { |
| 168 char *name; | 169 char *name; |
| 169 | 170 |
| 226 monster->t_using = NULL; | 227 monster->t_using = NULL; |
| 227 } | 228 } |
| 228 | 229 |
| 229 /* | 230 /* |
| 230 * add something to the contents of something else | 231 * add something to the contents of something else |
| 232 * bag: the holder of the items | |
| 233 * item: the item to put inside | |
| 231 */ | 234 */ |
| 232 put_contents(bag, item) | 235 void |
| 233 register struct object *bag; /* the holder of the items */ | 236 put_contents(struct object *bag, struct linked_list *item) |
| 234 register struct linked_list *item; /* the item to put inside */ | |
| 235 { | 237 { |
| 236 register struct linked_list *titem; | 238 register struct linked_list *titem; |
| 237 register struct object *tobj; | 239 register struct object *tobj; |
| 238 | 240 |
| 239 bag->o_ac++; | 241 bag->o_ac++; |
| 254 } | 256 } |
| 255 } | 257 } |
| 256 | 258 |
| 257 /* | 259 /* |
| 258 * remove something from something else | 260 * remove something from something else |
| 261 * bag: the holder of the items | |
| 259 */ | 262 */ |
| 260 take_contents(bag, item) | 263 void |
| 261 register struct object *bag; /* the holder of the items */ | 264 take_contents(struct object *bag, struct linked_list *item) |
| 262 register struct linked_list *item; | |
| 263 { | 265 { |
| 264 | 266 |
| 265 if (bag->o_ac <= 0) { | 267 if (bag->o_ac <= 0) { |
| 266 msg("Nothing to take out"); | 268 msg("Nothing to take out"); |
| 267 return; | 269 return; |
| 271 if (!add_pack(item, FALSE, NULL)) | 273 if (!add_pack(item, FALSE, NULL)) |
| 272 put_contents(bag, item); | 274 put_contents(bag, item); |
| 273 } | 275 } |
| 274 | 276 |
| 275 | 277 |
| 276 do_bag(item) | 278 void |
| 277 register struct linked_list *item; | 279 do_bag(struct linked_list *item) |
| 278 { | 280 { |
| 279 | 281 |
| 280 register struct linked_list *titem = NULL; | 282 register struct linked_list *titem = NULL; |
| 281 register struct object *obj, *tobj; | 283 register struct object *obj, *tobj; |
| 282 bool doit = TRUE; | 284 bool doit = TRUE; |
| 393 touchwin(cw); | 395 touchwin(cw); |
| 394 } | 396 } |
| 395 } | 397 } |
| 396 } | 398 } |
| 397 | 399 |
| 398 do_panic(who) | 400 /* who: Kind of monster to panic (all if who is NULL) */ |
| 399 int who; /* Kind of monster to panic (all if who is NULL) */ | 401 void |
| 402 do_panic(int who) | |
| 400 { | 403 { |
| 401 register int x,y; | 404 register int x,y; |
| 402 register struct linked_list *mon, *item; | 405 register struct linked_list *mon, *item; |
| 403 register struct thing *th; | 406 register struct thing *th; |
| 404 | 407 |
| 458 | 461 |
| 459 /* | 462 /* |
| 460 * print miscellaneous magic bonuses | 463 * print miscellaneous magic bonuses |
| 461 */ | 464 */ |
| 462 char * | 465 char * |
| 463 misc_name(obj) | 466 misc_name(struct object *obj) |
| 464 register struct object *obj; | |
| 465 { | 467 { |
| 466 static char buf[LINELEN]; | 468 static char buf[LINELEN]; |
| 467 char buf1[LINELEN]; | 469 char buf1[LINELEN]; |
| 468 | 470 |
| 469 buf[0] = '\0'; | 471 buf[0] = '\0'; |
| 521 } | 523 } |
| 522 strcat (buf, buf1); | 524 strcat (buf, buf1); |
| 523 return buf; | 525 return buf; |
| 524 } | 526 } |
| 525 | 527 |
| 526 use_emori() | 528 void |
| 529 use_emori(void) | |
| 527 { | 530 { |
| 528 char selection; /* Cloak function */ | 531 char selection; /* Cloak function */ |
| 529 int state = 0; /* Menu state */ | 532 int state = 0; /* Menu state */ |
| 530 | 533 |
| 531 msg("What do you want to do? (* for a list): "); | 534 msg("What do you want to do? (* for a list): "); |
| 631 static char Displines[MAXQUILL+1][LINELEN+1]; /* The lines themselves */ | 634 static char Displines[MAXQUILL+1][LINELEN+1]; /* The lines themselves */ |
| 632 #endif | 635 #endif |
| 633 /* | 636 /* |
| 634 * try to write a scroll with the quill of Nagrom | 637 * try to write a scroll with the quill of Nagrom |
| 635 */ | 638 */ |
| 636 use_quill(obj) | 639 void |
| 637 struct object *obj; | 640 use_quill(struct object *obj) |
| 638 { | 641 { |
| 639 struct linked_list *item; | 642 struct linked_list *item; |
| 640 register int i, | 643 register int i, |
| 641 scroll_ability; | 644 scroll_ability; |
| 642 int which_scroll, | 645 int which_scroll, |
| 764 goto got_scroll; | 767 goto got_scroll; |
| 765 } | 768 } |
| 766 #endif | 769 #endif |
| 767 /* Should we overlay? */ | 770 /* Should we overlay? */ |
| 768 if (menu_overlay && MAXQUILL + 3 < lines / 2) { | 771 if (menu_overlay && MAXQUILL + 3 < lines / 2) { |
| 769 over_win(cw, hw, MAXQUILL + 5, maxlen + 3, 0, curlen, NULL); | 772 over_win(cw, hw, MAXQUILL + 5, maxlen + 3, 0, curlen, '\0'); |
| 770 } | 773 } |
| 771 else draw(hw); | 774 else draw(hw); |
| 772 } | 775 } |
| 773 | 776 |
| 774 if (!nohw) { | 777 if (!nohw) { |
| 793 if (maxlen < curlen) maxlen = curlen; | 796 if (maxlen < curlen) maxlen = curlen; |
| 794 | 797 |
| 795 /* Should we overlay? */ | 798 /* Should we overlay? */ |
| 796 if (menu_overlay && MAXQUILL + 3 < lines / 2) { | 799 if (menu_overlay && MAXQUILL + 3 < lines / 2) { |
| 797 over_win(cw, hw, MAXQUILL + 5, maxlen + 3, | 800 over_win(cw, hw, MAXQUILL + 5, maxlen + 3, |
| 798 0, curlen, NULL); | 801 0, curlen, '\0'); |
| 799 } | 802 } |
| 800 else draw(hw); | 803 else draw(hw); |
| 801 | 804 |
| 802 which_scroll = (int) (readchar() - 'a'); | 805 which_scroll = (int) (readchar() - 'a'); |
| 803 } | 806 } |
| 833 (OBJPTR(item))->o_pos = hero; | 836 (OBJPTR(item))->o_pos = hero; |
| 834 fall(item, TRUE); | 837 fall(item, TRUE); |
| 835 } | 838 } |
| 836 } | 839 } |
| 837 | 840 |
| 838 use_mm(which) | 841 void |
| 839 int which; | 842 use_mm(int which) |
| 840 { | 843 { |
| 841 register struct object *obj = NULL; | 844 register struct object *obj = NULL; |
| 842 register struct linked_list *item = NULL; | 845 register struct linked_list *item = NULL; |
| 843 bool cursed, blessed, is_mm; | 846 bool cursed, blessed, is_mm; |
| 844 | 847 |
| 913 /* Put monsters around us to sleep */ | 916 /* Put monsters around us to sleep */ |
| 914 read_scroll(S_HOLD, 0, FALSE); | 917 read_scroll(S_HOLD, 0, FALSE); |
| 915 when GERYON_HORN: | 918 when GERYON_HORN: |
| 916 /* Chase close monsters away */ | 919 /* Chase close monsters away */ |
| 917 msg("The horn blasts a shrill tone."); | 920 msg("The horn blasts a shrill tone."); |
| 918 do_panic(NULL); | 921 do_panic(0); |
| 919 when HEIL_ANKH: | 922 when HEIL_ANKH: |
| 920 case YENDOR_AMULET: | 923 case YENDOR_AMULET: |
| 921 case STONEBONES_AMULET: | 924 case STONEBONES_AMULET: |
| 922 /* Nothing happens by this mode */ | 925 /* Nothing happens by this mode */ |
| 923 msg("Nothing happens."); | 926 msg("Nothing happens."); |
| 936 case MM_JUG: | 939 case MM_JUG: |
| 937 if (obj->o_ac == JUG_EMPTY) { | 940 if (obj->o_ac == JUG_EMPTY) { |
| 938 msg("The jug is empty"); | 941 msg("The jug is empty"); |
| 939 break; | 942 break; |
| 940 } | 943 } |
| 941 quaff (obj->o_ac, NULL, NULL, FALSE); | 944 quaff (obj->o_ac, 0, 0, FALSE); |
| 942 obj->o_ac = JUG_EMPTY; | 945 obj->o_ac = JUG_EMPTY; |
| 943 fuse (alchemy, obj, ALCHEMYTIME, AFTER); | 946 fuse (alchemy, obj, ALCHEMYTIME, AFTER); |
| 944 if (!(obj->o_flags & ISKNOW)) | 947 if (!(obj->o_flags & ISKNOW)) |
| 945 whatis(item); | 948 whatis(item); |
| 946 | 949 |
| 1006 if (obj->o_charges <= 0) { | 1009 if (obj->o_charges <= 0) { |
| 1007 msg("The drum is broken!"); | 1010 msg("The drum is broken!"); |
| 1008 break; | 1011 break; |
| 1009 } | 1012 } |
| 1010 obj->o_charges--; | 1013 obj->o_charges--; |
| 1011 do_panic(NULL); | 1014 do_panic(0); |
| 1012 /* | 1015 /* |
| 1013 * dust of disappearance makes the player invisible for a while | 1016 * dust of disappearance makes the player invisible for a while |
| 1014 */ | 1017 */ |
| 1015 when MM_DISAPPEAR: | 1018 when MM_DISAPPEAR: |
| 1016 m_know[MM_DISAPPEAR] = TRUE; | 1019 m_know[MM_DISAPPEAR] = TRUE; |
| 1122 * Return how long it takes to use an item. For now we only give time | 1125 * Return how long it takes to use an item. For now we only give time |
| 1123 * for MM, RELIC, SCROLL, and POTION items. | 1126 * for MM, RELIC, SCROLL, and POTION items. |
| 1124 */ | 1127 */ |
| 1125 | 1128 |
| 1126 int | 1129 int |
| 1127 usage_time(item) | 1130 usage_time(struct linked_list *item) |
| 1128 struct linked_list *item; | |
| 1129 { | 1131 { |
| 1130 register struct object *obj; | 1132 register struct object *obj; |
| 1131 register int units = -1; | 1133 register int units = -1; |
| 1132 | 1134 |
| 1133 obj = OBJPTR(item); | 1135 obj = OBJPTR(item); |
