Mercurial > hg > early-roguelike
changeset 239:837044d2c362
Merge the GCC5 and build fix branches.
This fixes all warnings produced by GCC 5, except the ones related to
system functions. Those could be fixed by including the proper headers,
but it would be better to replace the system-dependent code with
functions from mdport.c.
author | John "Elwin" Edwards |
---|---|
date | Fri, 11 Mar 2016 19:47:52 -0500 |
parents | bac2c81fec78 (current diff) e1cd27c5464f (diff) |
children | 163bd1fd4766 |
files | |
diffstat | 52 files changed, 416 insertions(+), 392 deletions(-) [+] |
line wrap: on
line diff
--- a/arogue5/daemon.c Tue Mar 08 19:45:41 2016 -0500 +++ b/arogue5/daemon.c Fri Mar 11 19:47:52 2016 -0500 @@ -70,7 +70,7 @@ * Find a particular slot in the table */ struct delayed_action * -find_slot(int (*func)()) +find_slot(void (*func)()) { reg int i; reg struct delayed_action *dev; @@ -87,7 +87,7 @@ * Start a daemon, takes a function. */ void -start_daemon(int (*func)(), void *arg, int type) +start_daemon(void (*func)(), void *arg, int type) { reg struct delayed_action *dev; @@ -107,7 +107,7 @@ * Remove a daemon from the list */ void -kill_daemon(int (*func)()) +kill_daemon(void (*func)()) { reg struct delayed_action *dev; reg int i; @@ -155,7 +155,7 @@ * Start a fuse to go off in a certain number of turns */ void -fuse(int (*func)(), void *arg, int time, int type) +fuse(void (*func)(), void *arg, int time, int type) { reg struct delayed_action *wire; @@ -175,7 +175,7 @@ * Increase the time until a fuse goes off */ void -lengthen(int (*func)(), int xtime) +lengthen(void (*func)(), int xtime) { reg struct delayed_action *wire; @@ -190,7 +190,7 @@ * Put out a fuse */ void -extinguish(int (*func)()) +extinguish(void (*func)()) { reg struct delayed_action *wire;
--- a/arogue5/fight.c Tue Mar 08 19:45:41 2016 -0500 +++ b/arogue5/fight.c Fri Mar 11 19:47:52 2016 -0500 @@ -20,17 +20,18 @@ bool roll_em(struct thing *att_er, struct thing *def_er, struct object *weap, bool hurl, struct object *cur_weapon, bool back_stab); -void hit(struct object *weapon, struct thing *tp, char *er, char *ee, - bool back_stab); -void miss(struct object *weapon, struct thing *tp, char *er, char *ee); +void hit(struct object *weapon, struct thing *tp, const char *er, + const char *ee, bool back_stab); +void miss(struct object *weapon, struct thing *tp, const char *er, + const char *ee); int dext_plus(int dexterity); int str_plus(short str); int add_dam(short str); int hung_dam(void); -void thunk(struct object *weap, struct thing *tp, char *mname); -void m_thunk(struct object *weap, struct thing *tp, char *mname); -void bounce(struct object *weap, struct thing *tp, char *mname); -void m_bounce(struct object *weap, struct thing *tp, char *mname); +void thunk(struct object *weap, struct thing *tp, const char *mname); +void m_thunk(struct object *weap, struct thing *tp, const char *mname); +void bounce(struct object *weap, struct thing *tp, const char *mname); +void m_bounce(struct object *weap, struct thing *tp, const char *mname); struct object *wield_weap(struct object *thrown, struct thing *mp); void explode(struct thing *tp); @@ -1037,7 +1038,7 @@ */ char * -prname(char *who, bool upper) +prname(const char *who, bool upper) { static char tbuf[LINELEN]; @@ -1062,7 +1063,8 @@ */ void -hit(struct object *weapon, struct thing *tp, char *er, char *ee, bool back_stab) +hit(struct object *weapon, struct thing *tp, const char *er, const char *ee, + bool back_stab) { register char *s = NULL; char @@ -1119,7 +1121,7 @@ */ void -miss(struct object *weapon, struct thing *tp, char *er, char *ee) +miss(struct object *weapon, struct thing *tp, const char *er, const char *ee) { register char *s = NULL; char @@ -1226,7 +1228,7 @@ */ void -thunk(struct object *weap, struct thing *tp, char *mname) +thunk(struct object *weap, struct thing *tp, const char *mname) { /* tp: Defender */ char *def_name; /* Name of defender */ @@ -1254,7 +1256,7 @@ */ void -m_thunk(struct object *weap, struct thing *tp, char *mname) +m_thunk(struct object *weap, struct thing *tp, const char *mname) { char *att_name; /* Name of attacker */ @@ -1281,7 +1283,7 @@ */ void -bounce(struct object *weap, struct thing *tp, char *mname) +bounce(struct object *weap, struct thing *tp, const char *mname) { /* tp: Defender */ char *def_name; /* Name of defender */ @@ -1309,7 +1311,7 @@ */ void -m_bounce(struct object *weap, struct thing *tp, char *mname) +m_bounce(struct object *weap, struct thing *tp, const char *mname) { char *att_name; /* Name of attacker */
--- a/arogue5/options.c Tue Mar 08 19:45:41 2016 -0500 +++ b/arogue5/options.c Fri Mar 11 19:47:52 2016 -0500 @@ -28,8 +28,8 @@ struct optstruct { char *o_name; /* option name */ char *o_prompt; /* prompt for interactive entry */ - int *o_opt; /* pointer to thing to set */ - int (*o_putfunc)(); /* function to print value */ + void *o_opt; /* pointer to thing to set */ + void (*o_putfunc)(); /* function to print value */ int (*o_getfunc)(); /* function to get value interactively */ }; @@ -39,38 +39,38 @@ int get_restr(char *optstr, WINDOW *win); int get_score(char *optstr, WINDOW *win); void put_abil(int *ability, WINDOW *win); -void get_abil(int *abil, WINDOW *win); +int get_abil(int *abil, WINDOW *win); void put_quest(int *quest, WINDOW *win); -void get_quest(int *quest, WINDOW *win); +int get_quest(int *quest, WINDOW *win); void put_bool(bool *b, WINDOW *win); int get_bool(bool *bp, WINDOW *win); void put_str(char *str, WINDOW *win); OPTION optlist[] = { {"terse", "Terse output: ", - (int *) &terse, put_bool, get_bool }, + (void *) &terse, put_bool, get_bool }, {"flush", "Flush typeahead during battle: ", - (int *) &fight_flush, put_bool, get_bool }, + (void *) &fight_flush, put_bool, get_bool }, {"jump", "Show position only at end of run: ", - (int *) &jump, put_bool, get_bool }, + (void *) &jump, put_bool, get_bool }, {"step", "Do inventories one line at a time: ", - (int *) &slow_invent, put_bool, get_bool }, + (void *) &slow_invent, put_bool, get_bool }, {"askme", "Ask me about unidentified things: ", - (int *) &askme, put_bool, get_bool }, + (void *) &askme, put_bool, get_bool }, {"pickup", "Pick things up automatically: ", - (int *) &auto_pickup, put_bool, get_bool }, + (void *) &auto_pickup, put_bool, get_bool }, {"name", "Name: ", - (int *) whoami, put_str, get_restr }, + (void *) whoami, put_str, get_restr }, {"fruit", "Fruit: ", - (int *) fruit, put_str, get_str }, + (void *) fruit, put_str, get_str }, {"file", "Save file: ", - (int *) file_name, put_str, get_restr }, + (void *) file_name, put_str, get_restr }, {"score", "Score file: ", - (int *) score_file, put_str, get_score }, + (void *) score_file, put_str, get_score }, {"class", "Character class: ", - (int *)&char_type, put_abil, get_abil }, + (void *)&char_type, put_abil, get_abil }, {"quest", "Quest item: ", - (int *) &quest_item, put_quest, get_quest } + (void *) &quest_item, put_quest, get_quest } }; /* For fields that would be restricted if use_savedir is set. */ @@ -111,27 +111,27 @@ /* * The ability field is read-only */ -void +int get_abil(int *abil, WINDOW *win) { register int oy, ox; getyx(win, oy, ox); put_abil(abil, win); - get_ro(win, oy, ox); + return get_ro(win, oy, ox); } /* * The quest field is read-only */ -void +int get_quest(int *quest, WINDOW *win) { register int oy, ox; getyx(win, oy, ox); waddstr(win, rel_magic[*quest].mi_name); - get_ro(win, oy, ox); + return get_ro(win, oy, ox); } /* @@ -416,18 +416,19 @@ if (op->o_putfunc != put_abil) strcpy((char *)op->o_opt, value); - else if (*op->o_opt == -1) { /* Only init ability once */ + else if (*(int *)op->o_opt == -1) { + /* Only init ability once */ register int len = strlen(value); if (isupper(value[0])) value[0] = tolower(value[0]); if (EQSTR(value, "fighter", len)) - *op->o_opt = C_FIGHTER; + *(int *)op->o_opt = C_FIGHTER; else if (EQSTR(value, "magic", min(len, 5))) - *op->o_opt = C_MAGICIAN; + *(int *)op->o_opt = C_MAGICIAN; else if (EQSTR(value, "cleric", len)) - *op->o_opt = C_CLERIC; + *(int *)op->o_opt = C_CLERIC; else if (EQSTR(value, "thief", len)) - *op->o_opt = C_THIEF; + *(int *)op->o_opt = C_THIEF; } } break;
--- a/arogue5/rogue.h Tue Mar 08 19:45:41 2016 -0500 +++ b/arogue5/rogue.h Fri Mar 11 19:47:52 2016 -0500 @@ -724,7 +724,7 @@ struct delayed_action { int d_type; - int (*d_func)(); + void (*d_func)(); void *d_arg; int d_time; }; @@ -1013,17 +1013,17 @@ int encwrite(char *start, unsigned int size, FILE *outf); void endit(int sig); void endmsg(void); -void extinguish(int (*func)()); +void extinguish(void (*func)()); void fall(struct linked_list *item, bool pr); coord *fallpos(coord *pos, bool be_clear, int range); void fatal(char *s); bool fight(coord *mp, struct object *weap, bool thrown); struct linked_list *find_mons(int y, int x); struct linked_list *find_obj(int y, int x); -struct delayed_action *find_slot(int (*func)()); +struct delayed_action *find_slot(void (*func)()); void fix_stick(struct object *cur); void fumble(void); -void fuse(int (*func)(), void *arg, int time, int type); +void fuse(void (*func)(), void *arg, int time, int type); void genmonsters(int least, bool treas); bool get_dir(void); struct linked_list *get_item(struct linked_list *list, char *purpose, int type); @@ -1053,11 +1053,11 @@ bool is_magic(struct object *obj); bool isatrap(char ch); int itemweight(struct object *wh); -void kill_daemon(int (*func)()); +void kill_daemon(void (*func)()); void killed(struct linked_list *item, bool pr, bool points); void lake_check(coord *place); void land(void); -void lengthen(int (*func)(), int xtime); +void lengthen(void (*func)(), int xtime); void light(coord *cp); bool lit_room(struct room *rp); void look(bool wakeup, bool runend); @@ -1133,7 +1133,7 @@ char show(int y, int x); void sight(void); struct linked_list *spec_item(int type, int which, int hit, int damage); -void start_daemon(int (*func)(), void *arg, int type); +void start_daemon(void (*func)(), void *arg, int type); void status(bool display); void steal(void); bool step_ok(int y, int x, int can_on_monst, struct thing *flgptr); @@ -1165,6 +1165,7 @@ char *vowelstr(char *str); void wait_for(WINDOW *win, char ch); struct linked_list *wake_monster(int y, int x); +void wanderer(void); void waste_time(void); char *weap_name(struct object *obj); void wear(void);
--- a/arogue7/daemon.c Tue Mar 08 19:45:41 2016 -0500 +++ b/arogue7/daemon.c Fri Mar 11 19:47:52 2016 -0500 @@ -78,7 +78,7 @@ * Find a particular slot in the table */ struct delayed_action * -find_slot(int (*func)()) +find_slot(void (*func)()) { reg int i; reg struct delayed_action *dev; @@ -95,7 +95,7 @@ * Start a daemon, takes a function. */ void -start_daemon(int (*func)(), int arg, int type) +start_daemon(void (*func)(), void *arg, int type) { reg struct delayed_action *dev; @@ -103,7 +103,7 @@ if (dev != NULL) { dev->d_type = type; dev->d_func = func; - dev->d_.arg = arg; + dev->d_.varg = arg; dev->d_time = DAEMON; demoncnt += 1; /* update count */ } @@ -115,7 +115,7 @@ * Remove a daemon from the list */ void -kill_daemon(int (*func)()) +kill_daemon(void (*func)()) { reg struct delayed_action *dev; reg int i; @@ -154,7 +154,7 @@ * Executing each one, giving it the proper arguments */ if (dev->d_type == flag && dev->d_time == DAEMON) - (*dev->d_func)(dev->d_.arg); + (*dev->d_func)(dev->d_.varg); } @@ -163,7 +163,7 @@ * Start a fuse to go off in a certain number of turns */ void -fuse(int (*func)(), int arg, int time, int type) +fuse(void (*func)(), void *arg, int time, int type) { reg struct delayed_action *wire; @@ -171,7 +171,10 @@ if (wire != NULL) { wire->d_type = type; wire->d_func = func; - wire->d_.arg = arg; + if (func == changeclass || func == res_strength) + wire->d_.arg = *(int *) arg; + else + wire->d_.varg = arg; wire->d_time = time; fusecnt += 1; /* update count */ } @@ -183,7 +186,7 @@ * Increase the time until a fuse goes off */ void -lengthen(int (*func)(), int xtime) +lengthen(void (*func)(), int xtime) { reg struct delayed_action *wire; @@ -198,7 +201,7 @@ * Put out a fuse */ void -extinguish(int (*func)()) +extinguish(void (*func)()) { reg struct delayed_action *wire; @@ -232,8 +235,10 @@ if(flag == wire->d_type && wire->d_time > 0 && --wire->d_time == 0) { wire->d_type = EMPTY; - if (wire->d_func != NULL) + if (wire->d_func == changeclass || wire->d_func == res_strength) (*wire->d_func)(wire->d_.arg); + else if (wire->d_func != NULL) + (*wire->d_func)(wire->d_.varg); fusecnt -= 1; } }
--- a/arogue7/daemons.c Tue Mar 08 19:45:41 2016 -0500 +++ b/arogue7/daemons.c Fri Mar 11 19:47:52 2016 -0500 @@ -111,7 +111,7 @@ void swander(void) { - start_daemon(rollwand, 0, BEFORE); + start_daemon(rollwand, NULL, BEFORE); } /* @@ -134,7 +134,7 @@ if (levtype != POSTLEV) wanderer(); kill_daemon(rollwand); - fuse(swander, 0, WANDERTIME, BEFORE); + fuse(swander, NULL, WANDERTIME, BEFORE); } between = 0; } @@ -663,7 +663,7 @@ time = SPELLTIME - max(17-pstats.s_intel, 0); time = max(time, 5); if (spell_power > 0) spell_power--; - fuse(spell_recovery, 0, time, AFTER); + fuse(spell_recovery, NULL, time, AFTER); } /* * give the hero back some prayer points @@ -676,7 +676,7 @@ time = SPELLTIME - max(17-pstats.s_wisdom, 0); time = max(time, 5); if (pray_time > 0) pray_time--; - fuse(prayer_recovery, 0, time, AFTER); + fuse(prayer_recovery, NULL, time, AFTER); } /* * give the hero back some chant points @@ -689,5 +689,5 @@ time = SPELLTIME - max(17-pstats.s_wisdom, 0); time = max(time, 5); if (chant_time > 0) chant_time--; - fuse(chant_recovery, 0, time, AFTER); + fuse(chant_recovery, NULL, time, AFTER); }
--- a/arogue7/effects.c Tue Mar 08 19:45:41 2016 -0500 +++ b/arogue7/effects.c Fri Mar 11 19:47:52 2016 -0500 @@ -294,7 +294,7 @@ if (on(player, HASSTINK)) lengthen(unstink, STINKTIME); else { turn_on(player, HASSTINK); - fuse(unstink, 0, STINKTIME, AFTER); + fuse(unstink, NULL, STINKTIME, AFTER); } } } @@ -308,8 +308,10 @@ msg("You cringe at %s's chilling touch.", prname(attname, FALSE)); chg_str(-1); - if (lost_str++ == 0) - fuse(res_strength, 0, CHILLTIME, AFTER); + if (lost_str++ == 0) { + int fuse_arg = 0; + fuse(res_strength, &fuse_arg, CHILLTIME, AFTER); + } else lengthen(res_strength, CHILLTIME); } } @@ -344,7 +346,7 @@ } else { turn_on(*def, HASDISEASE); - fuse(cure_disease, 0, roll(HEALTIME,SICKTIME), AFTER); + fuse(cure_disease, NULL, roll(HEALTIME,SICKTIME), AFTER); msg(terse ? "You have been diseased." : "You have contracted a disease!"); } @@ -478,7 +480,7 @@ turn_off(*att, CANDANCE); turn_on(*def, ISDANCE); msg("You begin to dance uncontrollably!"); - fuse(undance, 0, roll(2,4), AFTER); + fuse(undance, NULL, roll(2,4), AFTER); } /* @@ -491,7 +493,7 @@ (find_slot(suffocate) == 0)) { turn_on(*att, DIDSUFFOCATE); msg("%s is beginning to suffocate you.", prname(attname, TRUE)); - fuse(suffocate, 0, roll(9,3), AFTER); + fuse(suffocate, NULL, roll(9,3), AFTER); } /* @@ -530,11 +532,11 @@ msg("You smell an unpleasant odor."); else {