diff arogue7/pack.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 0250220d8cdd
line wrap: on
line diff
--- a/arogue7/pack.c	Tue Mar 08 20:47:57 2016 -0500
+++ b/arogue7/pack.c	Fri Mar 11 17:40:00 2016 -0500
@@ -249,12 +249,13 @@
 
     /* 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 @@
 		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 @@
 		/* 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 @@
 		}
 		/* 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)) {