Mercurial > hg > early-roguelike
diff arogue7/potions.c @ 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 | f9ef86cf22b2 |
children |
line wrap: on
line diff
--- a/arogue7/potions.c Tue Mar 08 20:47:57 2016 -0500 +++ b/arogue7/potions.c Fri Mar 11 17:40:00 2016 -0500 @@ -150,7 +150,7 @@ else { msg("You feel yourself moving %sfaster.", blessed ? "much " : ""); turn_on(player, ISHASTE); - fuse(nohaste, 0, roll(hasttime, hasttime), AFTER); + fuse(nohaste, NULL, roll(hasttime, hasttime), AFTER); } } @@ -206,7 +206,7 @@ lengthen(noslow, roll(HASTETIME,HASTETIME)); else { turn_on(player, ISSLOW); - fuse(noslow, 0, roll(HASTETIME,HASTETIME), AFTER); + fuse(noslow, NULL, roll(HASTETIME,HASTETIME), AFTER); } } } @@ -324,7 +324,7 @@ } else { /* Just light a fuse for how long player is safe */ if (off(player, ISCLEAR)) { - fuse(unclrhead, 0, CLRDURATION, AFTER); + fuse(unclrhead, NULL, CLRDURATION, AFTER); msg("A faint blue aura surrounds your head."); } else { /* If we have a fuse lengthen it, else we @@ -491,7 +491,7 @@ { msg("A cloak of darkness falls around you."); turn_on(player, ISBLIND); - fuse(sight, 0, SEEDURATION, AFTER); + fuse(sight, NULL, SEEDURATION, AFTER); light(&hero); } else @@ -501,7 +501,7 @@ if (off(player, CANSEE)) { turn_on(player, CANSEE); msg("Your eyes begin to tingle."); - fuse(unsee, 0, blessed ? SEEDURATION*3 :SEEDURATION, AFTER); + fuse(unsee, NULL, blessed ? SEEDURATION*3 :SEEDURATION, AFTER); light(&hero); } else if (find_slot(unsee) != 0) @@ -523,7 +523,7 @@ if (on(player, CANINWALL)) lengthen(unphase, duration*PHASEDURATION); else { - fuse(unphase, 0, duration*PHASEDURATION, AFTER); + fuse(unphase, NULL, duration*PHASEDURATION, AFTER); turn_on(player, CANINWALL); } msg("You feel %slight-headed!", @@ -547,7 +547,7 @@ } } else { - fuse(land, 0, duration*FLYTIME, AFTER); + fuse(land, NULL, duration*FLYTIME, AFTER); turn_on(player, ISFLY); } if (say_message) { @@ -610,7 +610,7 @@ if (off(player, ISINVIS)) { turn_on(player, ISINVIS); msg("You have a tingling feeling all over your body"); - fuse(appear, 0, blessed ? GONETIME*3 : GONETIME, AFTER); + fuse(appear, NULL, blessed ? GONETIME*3 : GONETIME, AFTER); PLAYER = IPLAYER; light(&hero); } @@ -675,7 +675,7 @@ if (!find_slot(unskill)) { /* No skill */ pstats.s_lvladj = -2; pstats.s_lvl += pstats.s_lvladj; - fuse(unskill, 0, SKILLDURATION, AFTER); + fuse(unskill, NULL, SKILLDURATION, AFTER); } else { /* Has an artifical skill */ /* Is the skill beneficial? */ @@ -714,7 +714,7 @@ if (!find_slot(unskill)) { pstats.s_lvladj = adjust; pstats.s_lvl += pstats.s_lvladj; - fuse(unskill, 0, + fuse(unskill, NULL, blessed ? SKILLDURATION*2 : SKILLDURATION, AFTER); } else { /* Has an artifical skill */ @@ -763,7 +763,7 @@ } } else { - fuse(nofire, 0, duration*FIRETIME, AFTER); + fuse(nofire, NULL, duration*FIRETIME, AFTER); turn_on(player, NOFIRE); } if (say_message) { @@ -789,7 +789,7 @@ } } else { - fuse(nocold, 0, duration*COLDTIME, AFTER); + fuse(nocold, NULL, duration*COLDTIME, AFTER); turn_on(player, NOCOLD); } if (say_message) { @@ -811,7 +811,7 @@ lengthen(nobolt, duration*BOLTTIME); } else { - fuse(nobolt, 0, duration*BOLTTIME, AFTER); + fuse(nobolt, NULL, duration*BOLTTIME, AFTER); turn_on(player, NOBOLT); } if (say_message)