Mercurial > hg > early-roguelike
changeset 220:f54901b9c39b
XRogue: convert to ANSI-style function declarations.
author | John "Elwin" Edwards |
---|---|
date | Wed, 02 Mar 2016 21:13:26 -0500 |
parents | f9ef86cf22b2 |
children | 4f6e056438eb |
files | xrogue/actions.c xrogue/bolt.c xrogue/chase.c xrogue/command.c xrogue/daemon.c xrogue/daemons.c xrogue/eat.c xrogue/effects.c xrogue/encumb.c xrogue/fight.c xrogue/help.c xrogue/init.c xrogue/io.c xrogue/list.c xrogue/main.c xrogue/maze.c xrogue/misc.c xrogue/monsters.c xrogue/move.c xrogue/n_level.c xrogue/network.h xrogue/options.c xrogue/outside.c xrogue/pack.c xrogue/passages.c xrogue/player.c xrogue/potions.c xrogue/rings.c xrogue/rip.c xrogue/rogue.h xrogue/rooms.c xrogue/save.c xrogue/scrolls.c xrogue/state.c xrogue/sticks.c xrogue/things.c xrogue/trader.c xrogue/util.c xrogue/weapons.c xrogue/wear.c xrogue/wizard.c |
diffstat | 41 files changed, 1282 insertions(+), 909 deletions(-) [+] |
line wrap: on
line diff
--- a/xrogue/actions.c Fri Feb 19 21:02:28 2016 -0500 +++ b/xrogue/actions.c Wed Mar 02 21:13:26 2016 -0500 @@ -24,12 +24,20 @@ int mf_count = 0; /* move_free counter - see actions.c(m_act()) */ int mf_jmpcnt = 0; /* move_free counter for # of jumps */ +void m_breathe(struct thing *tp); +void m_select(struct thing *th, bool flee); +void m_sonic(struct thing *tp); +void m_spell(struct thing *tp); +void m_summon(struct thing *tp); +bool m_use_it(struct thing *tp, bool flee, struct room *rer, struct room *ree); +bool m_use_pack(struct thing *monster, coord *defend_pos, int dist, + coord *shoot_dir); + /* * Did we disrupt a spell? */ -dsrpt_monster(tp, always, see_him) -register struct thing *tp; -bool always, see_him; +void +dsrpt_monster(struct thing *tp, bool always, bool see_him) { switch (tp->t_action) { case A_SUMMON: @@ -58,7 +66,8 @@ } } -dsrpt_player() +void +dsrpt_player(void) { int which, action; struct linked_list *item; @@ -87,7 +96,7 @@ if (purse > 0) { msg("Your gold goes flying everywhere!"); do { - item = spec_item(GOLD, NULL, NULL, NULL); + item = spec_item(GOLD, 0, 0, 0); obj = OBJPTR(item); obj->o_count = min(purse, rnd(20)+1); purse -= obj->o_count; @@ -125,8 +134,8 @@ * Otherwise, let it perform its chosen action. */ -m_act(tp) -register struct thing *tp; +void +m_act(struct thing *tp) { struct object *obj; bool flee; /* Are we scared? */ @@ -290,8 +299,8 @@ * Breathe in the chosen direction. */ -m_breathe(tp) -register struct thing *tp; +void +m_breathe(struct thing *tp) { register int damage; register char *breath = NULL; @@ -399,11 +408,11 @@ /* * m_select: * Select an action for the monster. + * flee: True if running away or player is inaccessible in wall */ -m_select(th, flee) -register struct thing *th; -register bool flee; /* True if running away or player is inaccessible in wall */ +void +m_select(struct thing *th, bool flee) { register struct room *rer, *ree; /* room of chaser, room of chasee */ int dist = INT_MIN; @@ -541,8 +550,8 @@ * The monster is sounding a sonic blast. */ -m_sonic(tp) -register struct thing *tp; +void +m_sonic(struct thing *tp) { register int damage; struct object blast = @@ -571,8 +580,8 @@ * The monster casts a spell. Currently this is limited to * magic missile. */ -m_spell(tp) -register struct thing *tp; +void +m_spell(struct thing *tp) { struct object missile = { @@ -594,8 +603,8 @@ * Summon aid. */ -m_summon(tp) -register struct thing *tp; +void +m_summon(struct thing *tp) { register char *helpname, *mname; int fail, numsum; @@ -668,10 +677,7 @@ */ bool -m_use_it(tp, flee, rer, ree) -register struct thing *tp; -bool flee; -register struct room *rer, *ree; +m_use_it(struct thing *tp, bool flee, struct room *rer, struct room *ree) { int dist; register coord *ee = tp->t_dest, *er = &tp->t_pos; @@ -836,7 +842,8 @@ } -reap() +void +reap(void) { _t_free_list(&rlist); } @@ -844,10 +851,11 @@ /* * runners: * Make all the awake monsters try to do something. + * segments: Number of segments since last called */ -runners(segments) -int segments; /* Number of segments since last called */ +int +runners(int segments) { register struct linked_list *item; register struct thing *tp = NULL; @@ -961,11 +969,7 @@ * Only care about relics and wands for now. */ bool -m_use_pack(monster, defend_pos, dist, shoot_dir) -register struct thing *monster; -coord *defend_pos; -register int dist; -register coord *shoot_dir; +m_use_pack(struct thing *monster, coord *defend_pos, int dist, coord *shoot_dir) { register struct object *obj; register struct linked_list *pitem, *relic, *stick;
--- a/xrogue/bolt.c Fri Feb 19 21:02:28 2016 -0500 +++ b/xrogue/bolt.c Wed Mar 02 21:13:26 2016 -0500 @@ -18,6 +18,7 @@ #include <curses.h> #include <ctype.h> +#include <string.h> #include "rogue.h" /* @@ -25,13 +26,9 @@ * given direction */ -shoot_bolt(shooter, start, dir, get_points, reason, name, damage) -struct thing *shooter; -coord start, dir; -bool get_points; -short reason; -char *name; -int damage; +void +shoot_bolt(struct thing *shooter, coord start, coord dir, bool get_points, + short reason, char *name, int damage) { unsigned char dirch = 0, ch; bool used, change, see_him;
--- a/xrogue/chase.c Fri Feb 19 21:02:28 2016 -0500 +++ b/xrogue/chase.c Wed Mar 02 21:13:26 2016 -0500 @@ -19,16 +19,18 @@ #include <ctype.h> #include <curses.h> #include <limits.h> +#include <stdlib.h> #include "rogue.h" +bool straight_shot(int ery, int erx, int eey, int eex, coord *shooting); + /* * Canblink checks if the monster can teleport (blink). If so, it will * try to blink the monster next to the player. */ bool -can_blink(tp) -register struct thing *tp; +can_blink(struct thing *tp) { register int y, x, index=9; coord tryp; /* To hold the coordinates for use in diag_ok */ @@ -123,8 +125,7 @@ */ int -can_shoot(er, ee, shoot_dir) -register coord *er, *ee, *shoot_dir; +can_shoot(coord *er, coord *ee, coord *shoot_dir) { /* * They must be in the same room or very close (at door) @@ -150,15 +151,13 @@ * Find the spot for the chaser(er) to move closer to the * chasee(ee). Rer is the room of the chaser, and ree is the * room of the creature being chased (chasee). + * flee: True if destination (ee) is player and monster is running away + * or the player is in a wall and the monster can't get to it */ -chase(tp, ee, rer, ree, flee) -register struct thing *tp; -register coord *ee; -register struct room *rer, *ree; -bool flee; /* True if destination (ee) is player and monster is running away - * or the player is in a wall and the monster can't get to it - */ +void +chase(struct thing *tp, coord *ee, struct room *rer, struct room *ree, + bool flee) { int dist, thisdist, monst_dist = INT_MAX; register coord *er = &tp->t_pos; @@ -495,8 +494,8 @@ * Make one thing chase another. */ -do_chase(th) -register struct thing *th; +void +do_chase(struct thing *th) { register struct room *orig_rer, /* Original room of chaser */ *new_room; /* new room of monster */ @@ -812,8 +811,7 @@ */ struct linked_list * -get_hurl(tp) -register struct thing *tp; +get_hurl(struct thing *tp) { struct linked_list *arrow=NULL, *bolt=NULL, *rock=NULL, *spear = NULL, *dagger=NULL, *dart=NULL, *aklad=NULL; @@ -860,9 +858,8 @@ * Set a monster running after something */ -runto(runner, spot) -register struct thing *runner; -coord *spot; +void +runto(struct thing *runner, coord *spot) { if (on(*runner, ISSTONE)) return; @@ -888,9 +885,7 @@ */ bool -straight_shot(ery, erx, eey, eex, shooting) -register int ery, erx, eey, eex; -register coord *shooting; +straight_shot(int ery, int erx, int eey, int eex, coord *shooting) { register int dy, dx; /* Deltas */ unsigned char ch;
--- a/xrogue/command.c Fri Feb 19 21:02:28 2016 -0500 +++ b/xrogue/command.c Wed Mar 02 21:13:26 2016 -0500 @@ -24,12 +24,21 @@ #include "mach_dep.h" #include "rogue.h" +void display(void); +void d_level(void); +void u_level(void); +void shell(void); +void nameit(void); +void namemonst(void); +void count_gold(void); + /* * command: * Process the user commands */ -command() +void +command(void) { unsigned int ch; struct linked_list *item; @@ -288,7 +297,7 @@ else { after = FALSE; player.t_action = A_NIL; - fright(); + fright(NULL); } when 'g' : /* Give command: give slime-molds to monsters */ if (player.t_action == A_NIL) { @@ -298,7 +307,7 @@ else { after = FALSE; player.t_action = A_NIL; - give(); + give(NULL); } when 'G' : if (player.t_action == A_NIL) { @@ -357,14 +366,14 @@ /* when '\\' : after = FALSE; ident_hero(); */ when '\\' : msg("Charon (the Boatman) looks at you... "); - when '/' : after = FALSE; identify(NULL); + when '/' : after = FALSE; identify('\0'); when C_COUNT : count_gold(); when C_DIP : dip_it(); when C_DROP : player.t_action = C_DROP; drop((struct linked_list *)NULL); when C_EAT : eat(); - when C_QUAFF : quaff(-1, NULL, NULL, TRUE); - when C_READ : read_scroll(-1, NULL, TRUE); + when C_QUAFF : quaff(-1, 0, 0, TRUE); + when C_READ : read_scroll(-1, 0, TRUE); when C_SETTRAP : set_trap(&player, hero.y, hero.x); when C_SEARCH : if (player.t_action == A_NIL) { @@ -379,7 +388,7 @@ when C_USE : use_mm(-1); when C_WEAR : wear(); when C_WIELD : wield(); - when C_ZAP : if (!player_zap(NULL, FALSE)) after=FALSE; + when C_ZAP : if (!player_zap(0, FALSE)) after=FALSE; when C_CAST : cast(); when C_CHANT : chant(); when C_PRAY : pray(); @@ -638,7 +647,8 @@ * tell the player what is at a certain coordinates assuming * it can be seen. */ -display() +void +display(void) { coord c; struct linked_list *item; @@ -673,8 +683,7 @@ /*UNUSED*/ void -quit(sig) -int sig; +quit(int sig) { register int oy, ox; @@ -727,8 +736,8 @@ * killed by a program bug instead of voluntarily. */ -bugkill(sig) -int sig; +void +bugkill(int sig) { signal(sig, quit); /* If we get it again, give up */ if (levtype == OUTSIDE) { @@ -748,8 +757,8 @@ * Player gropes about him to find hidden things. */ -search(is_thief, door_chime) -register bool is_thief, door_chime; +void +search(bool is_thief, bool door_chime) { register int x, y; register char ch, /* The trap or door character */ @@ -861,7 +870,8 @@ * He wants to go down a level */ -d_level() +void +d_level(void) { bool no_phase=FALSE; char position = winat(hero.y, hero.x); @@ -962,7 +972,8 @@ * He wants to go up a level */ -u_level() +void +u_level(void) { bool no_phase = FALSE; register struct linked_list *item; @@ -1053,7 +1064,8 @@ * Let him escape for a while */ -shell() +void +shell(void) { /* * Set the terminal back to original mode @@ -1079,7 +1091,8 @@ /* * see what we want to name -- an item or a monster. */ -nameit() +void +nameit(void) { char answer; @@ -1103,9 +1116,8 @@ * allow a user to call a potion, scroll, or ring something */ -nameitem(item, mark) -struct linked_list *item; -bool mark; +void +nameitem(struct linked_list *item, bool mark) { register struct object *obj; register char **guess = NULL, *elsewise = NULL; @@ -1191,7 +1203,8 @@ /* Name a monster */ -namemonst() +void +namemonst(void) { register struct thing *tp; struct linked_list *item; @@ -1236,7 +1249,8 @@ msg("There is no monster there to name."); } -count_gold() +void +count_gold(void) { if (player.t_action != C_COUNT) { msg("You take a break to count your money.. "); @@ -1259,7 +1273,8 @@ * Teleport somewhere, anywhere... */ -do_teleport() +void +do_teleport(void) { int tlev; prbuf[0] = '\0';
--- a/xrogue/daemon.c Fri Feb 19 21:02:28 2016 -0500 +++ b/xrogue/daemon.c Wed Mar 02 21:13:26 2016 -0500 @@ -41,7 +41,7 @@ * Find an empty slot in the daemon list */ struct delayed_action * -d_slot() +d_slot(void) { reg int i; reg struct delayed_action *dev; @@ -57,7 +57,7 @@ * Find an empty slot in the fuses list */ struct delayed_action * -f_slot() +f_slot(void) { reg int i; reg struct delayed_action *dev; @@ -74,8 +74,7 @@ */ struct delayed_action * -find_slot(func) -reg int (*func)(); +find_slot(int (*func)()) { reg int i; reg struct delayed_action *dev; @@ -91,9 +90,8 @@ * Start a daemon, takes a function. */ -start_daemon(dfunc, arg, type) -reg VOID *arg; -reg int type, (*dfunc)(); +void +start_daemon(int (*dfunc)(), VOID *arg, int type) { reg struct delayed_action *dev; @@ -112,8 +110,8 @@ * Remove a daemon from the list */ -kill_daemon(dfunc) -reg int (*dfunc)(); +void +kill_daemon(int (*dfunc)()) { reg struct delayed_action *dev; reg int i; @@ -140,8 +138,8 @@ * passing the argument to the function. */ -do_daemons(flag) -reg int flag; +void +do_daemons(int flag) { struct delayed_action *dev; int i; @@ -165,9 +163,8 @@ * Start a fuse to go off in a certain number of turns */ -fuse(dfunc, arg, time, type) -VOID *arg; -reg int (*dfunc)(), time, type; +void +fuse(int (*dfunc)(), VOID *arg, int time, int type) { reg struct delayed_action *wire; @@ -186,8 +183,8 @@ * Increase the time until a fuse goes off