comparison arogue7/move.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 1cd604c827a3
children e52a8a7ad4c5
comparison
equal deleted inserted replaced
218:56e748983fa8 219:f9ef86cf22b2
17 * 17 *
18 */ 18 */
19 19
20 #include "curses.h" 20 #include "curses.h"
21 #include <ctype.h> 21 #include <ctype.h>
22 #include <string.h>
22 #include "rogue.h" 23 #include "rogue.h"
23 #ifdef PC7300 24 #ifdef PC7300
24 #include "menu.h" 25 #include "menu.h"
25 #endif 26 #endif
26 27
39 /* 40 /*
40 * be_trapped: 41 * be_trapped:
41 * The guy stepped on a trap.... Make him pay. 42 * The guy stepped on a trap.... Make him pay.
42 */ 43 */
43 44
44 be_trapped(th, tc) 45 char
45 register struct thing *th; 46 be_trapped(struct thing *th, coord *tc)
46 register coord *tc;
47 { 47 {
48 register struct trap *tp; 48 register struct trap *tp;
49 register char ch, *mname = ""; 49 register char ch, *mname = "";
50 register bool is_player = (th == &player), 50 register bool is_player = (th == &player),
51 can_see; 51 can_see;
424 * blue_light: 424 * blue_light:
425 * magically light up a room (or level or make it dark) 425 * magically light up a room (or level or make it dark)
426 */ 426 */
427 427
428 bool 428 bool
429 blue_light(blessed, cursed) 429 blue_light(bool blessed, bool cursed)
430 bool blessed, cursed;
431 { 430 {
432 register struct room *rp; 431 register struct room *rp;
433 bool ret_val=FALSE; /* Whether or not affect is known */ 432 bool ret_val=FALSE; /* Whether or not affect is known */
434 433
435 rp = roomin(&hero); /* What room is hero in? */ 434 rp = roomin(&hero); /* What room is hero in? */
484 * corr_move: 483 * corr_move:
485 * Check to see that a move is legal. If so, return correct character. 484 * Check to see that a move is legal. If so, return correct character.
486 * If not, if player came from a legal place, then try to turn him. 485 * If not, if player came from a legal place, then try to turn him.
487 */ 486 */
488 487
489 corr_move(dy, dx) 488 void
490 int dy, dx; 489 corr_move(int dy, int dx)
491 { 490 {
492 int legal=0; /* Number of legal alternatives */ 491 int legal=0; /* Number of legal alternatives */
493 register int y, x, /* Indexes though possible positions */ 492 register int y, x, /* Indexes though possible positions */
494 locy, locx; /* Hold delta of chosen location */ 493 locy, locx; /* Hold delta of chosen location */
495 494
562 561
563 /* 562 /*
564 * dip_it: 563 * dip_it:
565 * Dip an object into a magic pool 564 * Dip an object into a magic pool
566 */ 565 */
567 dip_it() 566 void
567 dip_it(void)
568 { 568 {
569 reg struct linked_list *what; 569 reg struct linked_list *what;
570 reg struct object *ob; 570 reg struct object *ob;
571 reg struct trap *tp; 571 reg struct trap *tp;
572 reg int wh, i; 572 reg int wh, i;
756 * do_move: 756 * do_move:
757 * Check to see that a move is legal. If it is handle the 757 * Check to see that a move is legal. If it is handle the
758 * consequences (fighting, picking up, etc.) 758 * consequences (fighting, picking up, etc.)
759 */ 759 */
760 760
761 do_move(dy, dx) 761 void
762 int dy, dx; 762 do_move(int dy, int dx)
763 { 763 {
764 register struct room *rp, *orp; 764 register struct room *rp, *orp;
765 register char ch; 765 register char ch;
766 struct linked_list *item; 766 struct linked_list *item;
767 register struct thing *tp = NULL; 767 register struct thing *tp = NULL;
1101 /* 1101 /*
1102 * do_run: 1102 * do_run:
1103 * Start the hero running 1103 * Start the hero running
1104 */ 1104 */
1105 1105
1106 do_run(ch) 1106 void
1107 char ch; 1107 do_run(char ch)
1108 { 1108 {
1109 firstmove = TRUE; 1109 firstmove = TRUE;
1110 running = TRUE; 1110 running = TRUE;
1111 after = FALSE; 1111 after = FALSE;
1112 runch = ch; 1112 runch = ch;
1117 * Takes a movement character (eg. h, j, k, l) and returns the 1117 * Takes a movement character (eg. h, j, k, l) and returns the
1118 * y and x delta corresponding to it in the remaining arguments. 1118 * y and x delta corresponding to it in the remaining arguments.
1119 * Returns TRUE if it could find it, FALSE otherwise. 1119 * Returns TRUE if it could find it, FALSE otherwise.
1120 */ 1120 */
1121 bool 1121 bool
1122 getdelta(match, dy, dx) 1122 getdelta(char match, int *dy, int *dx)
1123 char match;
1124 int *dy, *dx;
1125 { 1123 {
1126 register y, x; 1124 int y, x;
1127 1125
1128 for (y = 0; y < 3; y++) 1126 for (y = 0; y < 3; y++)
1129 for (x = 0; x < 3; x++) 1127 for (x = 0; x < 3; x++)
1130 if (Moves[y][x] == match) { 1128 if (Moves[y][x] == match) {
1131 *dy = y - 1; 1129 *dy = y - 1;
1138 1136
1139 /* 1137 /*
1140 * isatrap: 1138 * isatrap:
1141 * Returns TRUE if this character is some kind of trap 1139 * Returns TRUE if this character is some kind of trap
1142 */ 1140 */
1143 isatrap(ch) 1141 bool
1144 reg char ch; 1142 isatrap(char ch)
1145 { 1143 {
1146 switch(ch) { 1144 switch(ch) {
1147 case DARTTRAP: 1145 case DARTTRAP:
1148 case TELTRAP: 1146 case TELTRAP:
1149 case TRAPDOOR: 1147 case TRAPDOOR:
1159 /* 1157 /*
1160 * Called to illuminate a room. 1158 * Called to illuminate a room.
1161 * If it is dark, remove anything that might move. 1159 * If it is dark, remove anything that might move.
1162 */ 1160 */
1163 1161
1164 light(cp) 1162 void
1165 coord *cp; 1163 light(coord *cp)
1166 { 1164 {
1167 register struct room *rp; 1165 register struct room *rp;
1168 register int j, k, x, y; 1166 register int j, k, x, y;
1169 register char ch, rch, sch; 1167 register char ch, rch, sch;
1170 register struct linked_list *item; 1168 register struct linked_list *item;
1336 * lit_room: 1334 * lit_room:
1337 * Called to see if the specified room is lit up or not. 1335 * Called to see if the specified room is lit up or not.
1338 */ 1336 */
1339 1337
1340 bool 1338 bool
1341 lit_room(rp) 1339 lit_room(struct room *rp)
1342 register struct room *rp;
1343 { 1340 {
1344 register struct linked_list *fire_item; 1341 register struct linked_list *fire_item;
1345 register struct thing *fire_creature; 1342 register struct thing *fire_creature;
1346 1343
1347 if (!(rp->r_flags & ISDARK)) return(TRUE); /* A definitely lit room */ 1344 if (!(rp->r_flags & ISDARK)) return(TRUE); /* A definitely lit room */
1374 * Given a pointer to a player/monster structure, calculate the 1371 * Given a pointer to a player/monster structure, calculate the
1375 * movement rate for that character. 1372 * movement rate for that character.
1376 */ 1373 */
1377 1374
1378 short 1375 short
1379 movement(tp) 1376 movement(struct thing *tp)
1380 register struct thing *tp;
1381 { 1377 {
1382 register int result; 1378 register int result;
1383 register int carry; /* Percentage carried */ 1379 register int carry; /* Percentage carried */
1384 1380
1385 result = 0; 1381 result = 0;
1439 * rndmove: 1435 * rndmove:
1440 * move in a random direction if the monster/person is confused 1436 * move in a random direction if the monster/person is confused
1441 */ 1437 */
1442 1438
1443 coord * 1439 coord *
1444 rndmove(who) 1440 rndmove(struct thing *who)
1445 struct thing *who;
1446 { 1441 {
1447 register int x, y; 1442 register int x, y;
1448 register int ex, ey, nopen = 0; 1443 register int ex, ey, nopen = 0;
1449 static coord ret; /* what we will be returning */ 1444 static coord ret; /* what we will be returning */
1450 static coord dest; 1445 static coord dest;
1504 /* 1499 /*
1505 * set_trap: 1500 * set_trap:
1506 * set a trap at (y, x) on screen. 1501 * set a trap at (y, x) on screen.
1507 */ 1502 */
1508 1503
1509 set_trap(tp, y, x) 1504 void
1510 register struct thing *tp; 1505 set_trap(struct thing *tp, int y, int x)
1511 register int y, x;
1512 { 1506 {
1513 register bool is_player = (tp == &player); 1507 register bool is_player = (tp == &player);
1514 register int selection = rnd(TRAPTYPES-WIZARDTRAPS) + '1'; 1508 register int selection = rnd(TRAPTYPES-WIZARDTRAPS) + '1';
1515 register int i, num_traps; 1509 register int i, num_traps;
1516 register char ch, och; 1510 register char ch, och;
1611 if (menu_overlay) 1605 if (menu_overlay)
1612 /* 1606 /*
1613 * Put out the selection. The longest line is 1607 * Put out the selection. The longest line is
1614 * the prompt line (39 characters long). 1608 * the prompt line (39 characters long).
1615 */ 1609 */
1616 over_win(cw, hw, num_traps + 3, 41, 0, 39, NULL); 1610 over_win(cw, hw, num_traps + 3, 41, 0, 39, '\0');
1617 else 1611 else
1618 draw(hw); 1612 draw(hw);
1619 state = 1; /* Now in prompt window */ 1613 state = 1; /* Now in prompt window */
1620 } 1614 }
1621 break; 1615 break;
1671 if (menu_overlay) 1665 if (menu_overlay)
1672 /* 1666 /*
1673 * Put out the selection. The longest line is 1667 * Put out the selection. The longest line is
1674 * the prompt line (43 characters long). 1668 * the prompt line (43 characters long).
1675 */ 1669 */
1676 over_win(cw, hw, num_traps+3, 45, 0, 43, NULL); 1670 over_win(cw, hw, num_traps+3, 45, 0, 43, '\0');
1677 else 1671 else
1678 draw(hw); 1672 draw(hw);
1679 } 1673 }
1680 else { /* Normal window */ 1674 else { /* Normal window */
1681 mpos = 0; 1675 mpos = 0;
1741 /* 1735 /*
1742 * show: 1736 * show:
1743 * returns what a certain thing will display as to the un-initiated 1737 * returns what a certain thing will display as to the un-initiated
1744 */ 1738 */
1745 1739
1746 show(y, x) 1740 char
1747 register int y, x; 1741 show(int y, int x)
1748 { 1742 {
1749 register char ch = CCHAR( winat(y, x) ); 1743 register char ch = CCHAR( winat(y, x) );
1750 register struct linked_list *it; 1744 register struct linked_list *it;
1751 register struct thing *tp; 1745 register struct thing *tp;
1752 1746
1782 * trap_at: 1776 * trap_at:
1783 * find the trap at (y,x) on screen. 1777 * find the trap at (y,x) on screen.
1784 */ 1778 */
1785 1779
1786 struct trap * 1780 struct trap *
1787 trap_at(y, x) 1781 trap_at(int y, int x)
1788 register int y, x;
1789 { 1782 {
1790 register struct trap *tp, *ep; 1783 register struct trap *tp, *ep;
1791 1784
1792 ep = &traps[ntraps]; 1785 ep = &traps[ntraps];
1793 for (tp = traps; tp < ep; tp++) 1786 for (tp = traps; tp < ep; tp++)
1801 /* 1794 /*
1802 * weap_move: 1795 * weap_move:
1803 * Calculate how many segments it will take to swing the given 1796 * Calculate how many segments it will take to swing the given
1804 * weapon (note that the weapon may actually be a stick or 1797 * weapon (note that the weapon may actually be a stick or
1805 * even something else). 1798 * even something else).
1799 * wielder: Who's wielding the weapon
1800 * weap: The weapon
1806 */ 1801 */
1807 1802
1808 weap_move(wielder, weap) 1803 int
1809 register struct thing *wielder; /* Who's wielding the weapon */ 1804 weap_move(struct thing *wielder, struct object *weap)
1810 register struct object *weap; /* The weapon */
1811 { 1805 {
1812 register int weap_rate; 1806 register int weap_rate;
1813 int dexterity; 1807 int dexterity;
1814 int strength; 1808 int strength;
1815 1809