Mercurial > hg > early-roguelike
changeset 238:e1cd27c5464f
arogue7, xrogue: improve the handling of the arguments to fuses.
fuse() now expects a pointer as the argument to a fuse function.  If
this is one of the functions that takes int, fuse() follows the pointer
and stores that value in the f_list slot, in the integer field of the
argument union.  When the fuse goes off, do_fuses() recognizes the
function and passes it the integer field instead of the pointer.
This has the disadvantage of hard-coding the functions that require int
in daemon.c, but since the int is copied into f_list, it no longer has
to be in static or global memory, which simplifies several files.
| author | John "Elwin" Edwards | 
|---|---|
| date | Fri, 11 Mar 2016 17:40:00 -0500 | 
| parents | 2236ef808bcb | 
| children | 837044d2c362 | 
| files | arogue7/daemon.c arogue7/daemons.c arogue7/effects.c arogue7/encumb.c arogue7/fight.c arogue7/main.c arogue7/misc.c arogue7/monsters.c arogue7/pack.c arogue7/potions.c arogue7/rings.c arogue7/rogue.h arogue7/sticks.c arogue7/util.c arogue7/wear.c xrogue/daemon.c xrogue/effects.c xrogue/fight.c xrogue/misc.c xrogue/pack.c xrogue/rogue.h | 
| diffstat | 21 files changed, 147 insertions(+), 124 deletions(-) [+] | 
line wrap: on
 line diff
--- a/arogue7/daemon.c Tue Mar 08 20:47:57 2016 -0500 +++ b/arogue7/daemon.c Fri Mar 11 17:40:00 2016 -0500 @@ -95,7 +95,7 @@ * Start a daemon, takes a function. */ void -start_daemon(void (*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 */ } @@ -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(void (*func)(), int arg, int time, int type) +fuse(void (*func)(), void *arg, int time, int type)
