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.
This commit is contained in:
John "Elwin" Edwards 2016-03-11 17:40:00 -05:00
parent dafa5cc722
commit 758c6b1bf0
21 changed files with 147 additions and 124 deletions

View file

@ -249,12 +249,13 @@ picked_up:
/* Relics can do strange things when you pick them up */
if (obj->o_type == RELIC) {
int newclass;
switch (obj->o_which) {
/* the ankh of Heil gives you prayers */
case HEIL_ANKH:
msg("The ankh welds itself into your hand.");
if (player.t_ctype != C_CLERIC && player.t_ctype != C_PALADIN)
fuse(prayer_recovery, 0, SPELLTIME, AFTER);
fuse(prayer_recovery, NULL, SPELLTIME, AFTER);
/* A cloak must be worn. */
when EMORI_CLOAK:
@ -306,7 +307,7 @@ picked_up:
msg("The excrutiating pain slowly turns into a dull throb.");
when QUILL_NAGROM:
fuse(quill_charge,0,player.t_ctype==C_MAGICIAN ? 4 : 8,AFTER);
fuse(quill_charge,NULL,player.t_ctype==C_MAGICIAN ? 4 : 8,AFTER);
/* Weapons will insist on being wielded. */
when MUSTY_DAGGER:
@ -316,7 +317,8 @@ picked_up:
/* For the daggers start a fuse to change player to a thief. */
/* and set a daemon to eat gold. */
if (obj->o_which == MUSTY_DAGGER) {
fuse(changeclass, C_THIEF, roll(20, 20), AFTER);
newclass = C_THIEF;
fuse(changeclass, &newclass, roll(20, 20), AFTER);
if (purse > 0)
msg("Your purse feels lighter");
else
@ -326,7 +328,8 @@ picked_up:
}
/* For the axe start a fuse to change player to a fighter. */
if (obj->o_which == AXE_AKLAD)
fuse(changeclass, C_FIGHTER, roll(20, 20), AFTER);
newclass = C_FIGHTER;
fuse(changeclass, &newclass, roll(20, 20), AFTER);
if (cur_weapon != NULL) {
msg("The artifact insists you release your current weapon.");
if (!dropcheck(cur_weapon)) {