diff arogue7/effects.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/effects.c	Tue Mar 08 20:47:57 2016 -0500
+++ b/arogue7/effects.c	Fri Mar 11 17:40:00 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 {
 		    int odor_str = -(rnd(6)+1);
-
+		    int fuse_arg2 = 0;
 		    msg("You are overcome by a foul odor.");
 		    if (lost_str == 0) {
 			chg_str(odor_str);
-			fuse(res_strength, 0, SMELLTIME, AFTER);
+			fuse(res_strength, &fuse_arg2, SMELLTIME, AFTER);
 			lost_str -= odor_str;
 		    }
 		    else lengthen(res_strength, SMELLTIME);