Mercurial > hg > early-roguelike
comparison xrogue/command.c @ 220:f54901b9c39b
XRogue: convert to ANSI-style function declarations.
| author | John "Elwin" Edwards |
|---|---|
| date | Wed, 02 Mar 2016 21:13:26 -0500 |
| parents | a0a57cf42810 |
| children | 7c1cb43f346e |
comparison
equal
deleted
inserted
replaced
| 219:f9ef86cf22b2 | 220:f54901b9c39b |
|---|---|
| 22 #include <stdlib.h> | 22 #include <stdlib.h> |
| 23 #include <string.h> | 23 #include <string.h> |
| 24 #include "mach_dep.h" | 24 #include "mach_dep.h" |
| 25 #include "rogue.h" | 25 #include "rogue.h" |
| 26 | 26 |
| 27 void display(void); | |
| 28 void d_level(void); | |
| 29 void u_level(void); | |
| 30 void shell(void); | |
| 31 void nameit(void); | |
| 32 void namemonst(void); | |
| 33 void count_gold(void); | |
| 34 | |
| 27 /* | 35 /* |
| 28 * command: | 36 * command: |
| 29 * Process the user commands | 37 * Process the user commands |
| 30 */ | 38 */ |
| 31 | 39 |
| 32 command() | 40 void |
| 41 command(void) | |
| 33 { | 42 { |
| 34 unsigned int ch; | 43 unsigned int ch; |
| 35 struct linked_list *item; | 44 struct linked_list *item; |
| 36 unsigned int countch = 0, direction = 0, newcount = FALSE; | 45 unsigned int countch = 0, direction = 0, newcount = FALSE; |
| 37 int segment = 1; | 46 int segment = 1; |
| 286 player.t_no_move = 2*movement(&player); | 295 player.t_no_move = 2*movement(&player); |
| 287 } | 296 } |
| 288 else { | 297 else { |
| 289 after = FALSE; | 298 after = FALSE; |
| 290 player.t_action = A_NIL; | 299 player.t_action = A_NIL; |
| 291 fright(); | 300 fright(NULL); |
| 292 } | 301 } |
| 293 when 'g' : /* Give command: give slime-molds to monsters */ | 302 when 'g' : /* Give command: give slime-molds to monsters */ |
| 294 if (player.t_action == A_NIL) { | 303 if (player.t_action == A_NIL) { |
| 295 player.t_action = 'g'; | 304 player.t_action = 'g'; |
| 296 player.t_no_move = 2*movement(&player); | 305 player.t_no_move = 2*movement(&player); |
| 297 } | 306 } |
| 298 else { | 307 else { |
| 299 after = FALSE; | 308 after = FALSE; |
| 300 player.t_action = A_NIL; | 309 player.t_action = A_NIL; |
| 301 give(); | 310 give(NULL); |
| 302 } | 311 } |
| 303 when 'G' : | 312 when 'G' : |
| 304 if (player.t_action == A_NIL) { | 313 if (player.t_action == A_NIL) { |
| 305 player.t_action = 'G'; | 314 player.t_action = 'G'; |
| 306 player.t_no_move = movement(&player); | 315 player.t_no_move = movement(&player); |
| 355 | 364 |
| 356 /* no character descriptions yet until updated (help.c) */ | 365 /* no character descriptions yet until updated (help.c) */ |
| 357 /* when '\\' : after = FALSE; ident_hero(); */ | 366 /* when '\\' : after = FALSE; ident_hero(); */ |
| 358 when '\\' : msg("Charon (the Boatman) looks at you... "); | 367 when '\\' : msg("Charon (the Boatman) looks at you... "); |
| 359 | 368 |
| 360 when '/' : after = FALSE; identify(NULL); | 369 when '/' : after = FALSE; identify('\0'); |
| 361 when C_COUNT : count_gold(); | 370 when C_COUNT : count_gold(); |
| 362 when C_DIP : dip_it(); | 371 when C_DIP : dip_it(); |
| 363 when C_DROP : player.t_action = C_DROP; | 372 when C_DROP : player.t_action = C_DROP; |
| 364 drop((struct linked_list *)NULL); | 373 drop((struct linked_list *)NULL); |
| 365 when C_EAT : eat(); | 374 when C_EAT : eat(); |
| 366 when C_QUAFF : quaff(-1, NULL, NULL, TRUE); | 375 when C_QUAFF : quaff(-1, 0, 0, TRUE); |
| 367 when C_READ : read_scroll(-1, NULL, TRUE); | 376 when C_READ : read_scroll(-1, 0, TRUE); |
| 368 when C_SETTRAP : set_trap(&player, hero.y, hero.x); | 377 when C_SETTRAP : set_trap(&player, hero.y, hero.x); |
| 369 when C_SEARCH : | 378 when C_SEARCH : |
| 370 if (player.t_action == A_NIL) { | 379 if (player.t_action == A_NIL) { |
| 371 player.t_action = C_SEARCH; | 380 player.t_action = C_SEARCH; |
| 372 player.t_no_move = 2 + movement(&player); | 381 player.t_no_move = 2 + movement(&player); |
| 377 } | 386 } |
| 378 when C_TAKEOFF : take_off(); | 387 when C_TAKEOFF : take_off(); |
| 379 when C_USE : use_mm(-1); | 388 when C_USE : use_mm(-1); |
| 380 when C_WEAR : wear(); | 389 when C_WEAR : wear(); |
| 381 when C_WIELD : wield(); | 390 when C_WIELD : wield(); |
| 382 when C_ZAP : if (!player_zap(NULL, FALSE)) after=FALSE; | 391 when C_ZAP : if (!player_zap(0, FALSE)) after=FALSE; |
| 383 when C_CAST : cast(); | 392 when C_CAST : cast(); |
| 384 when C_CHANT : chant(); | 393 when C_CHANT : chant(); |
| 385 when C_PRAY : pray(); | 394 when C_PRAY : pray(); |
| 386 when CTRL('B') : msg("Current score: %d", | 395 when CTRL('B') : msg("Current score: %d", |
| 387 pstats.s_exp + (long) purse); | 396 pstats.s_exp + (long) purse); |
| 636 /* | 645 /* |
| 637 * display | 646 * display |
| 638 * tell the player what is at a certain coordinates assuming | 647 * tell the player what is at a certain coordinates assuming |
| 639 * it can be seen. | 648 * it can be seen. |
| 640 */ | 649 */ |
| 641 display() | 650 void |
| 651 display(void) | |
| 642 { | 652 { |
| 643 coord c; | 653 coord c; |
| 644 struct linked_list *item; | 654 struct linked_list *item; |
| 645 struct thing *tp; | 655 struct thing *tp; |
| 646 int what; | 656 int what; |
| 671 * Have player make certain, then exit. | 681 * Have player make certain, then exit. |
| 672 */ | 682 */ |
| 673 | 683 |
| 674 /*UNUSED*/ | 684 /*UNUSED*/ |
| 675 void | 685 void |
| 676 quit(sig) | 686 quit(int sig) |
| 677 int sig; | |
| 678 { | 687 { |
| 679 register int oy, ox; | 688 register int oy, ox; |
| 680 | 689 |
| 681 NOOP(sig); | 690 NOOP(sig); |
| 682 | 691 |
| 725 /* | 734 /* |
| 726 * bugkill: | 735 * bugkill: |
| 727 * killed by a program bug instead of voluntarily. | 736 * killed by a program bug instead of voluntarily. |
| 728 */ | 737 */ |
| 729 | 738 |
| 730 bugkill(sig) | 739 void |
| 731 int sig; | 740 bugkill(int sig) |
| 732 { | 741 { |
| 733 signal(sig, quit); /* If we get it again, give up */ | 742 signal(sig, quit); /* If we get it again, give up */ |
| 734 if (levtype == OUTSIDE) { | 743 if (levtype == OUTSIDE) { |
| 735 msg("Oh no! You walk right into a flying swarm of nasty little bugs!! "); | 744 msg("Oh no! You walk right into a flying swarm of nasty little bugs!! "); |
| 736 msg("One of them penetrates your brain!!! --More--"); | 745 msg("One of them penetrates your brain!!! --More--"); |
| 746 /* | 755 /* |
| 747 * search: | 756 * search: |
| 748 * Player gropes about him to find hidden things. | 757 * Player gropes about him to find hidden things. |
| 749 */ | 758 */ |
| 750 | 759 |
| 751 search(is_thief, door_chime) | 760 void |
| 752 register bool is_thief, door_chime; | 761 search(bool is_thief, bool door_chime) |
| 753 { | 762 { |
| 754 register int x, y; | 763 register int x, y; |
| 755 register char ch, /* The trap or door character */ | 764 register char ch, /* The trap or door character */ |
| 756 sch; /* Trap or door character (as seen on screen) */ | 765 sch; /* Trap or door character (as seen on screen) */ |
| 757 register unsigned char mch; /* Monster, if a monster is on the trap or door */ | 766 register unsigned char mch; /* Monster, if a monster is on the trap or door */ |
| 859 /* | 868 /* |
| 860 * d_level: | 869 * d_level: |
| 861 * He wants to go down a level | 870 * He wants to go down a level |
| 862 */ | 871 */ |
| 863 | 872 |
| 864 d_level() | 873 void |
| 874 d_level(void) | |
| 865 { | 875 { |
| 866 bool no_phase=FALSE; | 876 bool no_phase=FALSE; |
| 867 char position = winat(hero.y, hero.x); | 877 char position = winat(hero.y, hero.x); |
| 868 int au; | 878 int au; |
| 869 | 879 |
| 960 /* | 970 /* |
| 961 * u_level: | 971 * u_level: |
| 962 * He wants to go up a level | 972 * He wants to go up a level |
| 963 */ | 973 */ |
| 964 | 974 |
| 965 u_level() | 975 void |
| 976 u_level(void) | |
| 966 { | 977 { |
| 967 bool no_phase = FALSE; | 978 bool no_phase = FALSE; |
| 968 register struct linked_list *item; | 979 register struct linked_list *item; |
| 969 char position = winat(hero.y, hero.x); | 980 char position = winat(hero.y, hero.x); |
| 970 struct thing *tp; | 981 struct thing *tp; |
| 1051 | 1062 |
| 1052 /* | 1063 /* |
| 1053 * Let him escape for a while | 1064 * Let him escape for a while |
| 1054 */ | 1065 */ |
| 1055 | 1066 |
| 1056 shell() | 1067 void |
| 1068 shell(void) | |
| 1057 { | 1069 { |
| 1058 /* | 1070 /* |
| 1059 * Set the terminal back to original mode | 1071 * Set the terminal back to original mode |
| 1060 */ | 1072 */ |
| 1061 wclear(hw); | 1073 wclear(hw); |
| 1077 } | 1089 } |
| 1078 | 1090 |
| 1079 /* | 1091 /* |
| 1080 * see what we want to name -- an item or a monster. | 1092 * see what we want to name -- an item or a monster. |
| 1081 */ | 1093 */ |
| 1082 nameit() | 1094 void |
| 1095 nameit(void) | |
| 1083 { | 1096 { |
| 1084 char answer; | 1097 char answer; |
| 1085 | 1098 |
| 1086 msg("Name monster or item (m or i)? "); | 1099 msg("Name monster or item (m or i)? "); |
| 1087 answer = wgetch(cw); | 1100 answer = wgetch(cw); |
| 1101 | 1114 |
| 1102 /* | 1115 /* |
| 1103 * allow a user to call a potion, scroll, or ring something | 1116 * allow a user to call a potion, scroll, or ring something |
| 1104 */ | 1117 */ |
| 1105 | 1118 |
| 1106 nameitem(item, mark) | 1119 void |
| 1107 struct linked_list *item; | 1120 nameitem(struct linked_list *item, bool mark) |
| 1108 bool mark; | |
| 1109 { | 1121 { |
| 1110 register struct object *obj; | 1122 register struct object *obj; |
| 1111 register char **guess = NULL, *elsewise = NULL; | 1123 register char **guess = NULL, *elsewise = NULL; |
| 1112 register bool *know; | 1124 register bool *know; |
| 1113 | 1125 |
| 1189 } | 1201 } |
| 1190 } | 1202 } |
| 1191 | 1203 |
| 1192 /* Name a monster */ | 1204 /* Name a monster */ |
| 1193 | 1205 |
| 1194 namemonst() | 1206 void |
| 1207 namemonst(void) | |
| 1195 { | 1208 { |
| 1196 register struct thing *tp; | 1209 register struct thing *tp; |
| 1197 struct linked_list *item; | 1210 struct linked_list *item; |
| 1198 coord c; | 1211 coord c; |
| 1199 | 1212 |
| 1234 } | 1247 } |
| 1235 | 1248 |
| 1236 msg("There is no monster there to name."); | 1249 msg("There is no monster there to name."); |
| 1237 } | 1250 } |
| 1238 | 1251 |
| 1239 count_gold() | 1252 void |
| 1253 count_gold(void) | |
| 1240 { | 1254 { |
| 1241 if (player.t_action != C_COUNT) { | 1255 if (player.t_action != C_COUNT) { |
| 1242 msg("You take a break to count your money.. "); | 1256 msg("You take a break to count your money.. "); |
| 1243 player.t_using = NULL; | 1257 player.t_using = NULL; |
| 1244 player.t_action = C_COUNT; /* We are counting */ | 1258 player.t_action = C_COUNT; /* We are counting */ |
| 1257 | 1271 |
| 1258 /* | 1272 /* |
| 1259 * Teleport somewhere, anywhere... | 1273 * Teleport somewhere, anywhere... |
| 1260 */ | 1274 */ |
| 1261 | 1275 |
| 1262 do_teleport() | 1276 void |
| 1277 do_teleport(void) | |
| 1263 { | 1278 { |
| 1264 int tlev; | 1279 int tlev; |
| 1265 prbuf[0] = '\0'; | 1280 prbuf[0] = '\0'; |
| 1266 msg("To which level do you wish to teleport? "); | 1281 msg("To which level do you wish to teleport? "); |
| 1267 if(get_str(prbuf,msgw) == NORM) { | 1282 if(get_str(prbuf,msgw) == NORM) { |
