Mercurial > hg > early-roguelike
comparison 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 |
comparison
equal
deleted
inserted
replaced
237:2236ef808bcb | 238:e1cd27c5464f |
---|---|
247 msg("%s (%c)", inv_name(obj, !terse), pack_char(pack, obj)); | 247 msg("%s (%c)", inv_name(obj, !terse), pack_char(pack, obj)); |
248 } | 248 } |
249 | 249 |
250 /* Relics can do strange things when you pick them up */ | 250 /* Relics can do strange things when you pick them up */ |
251 if (obj->o_type == RELIC) { | 251 if (obj->o_type == RELIC) { |
252 int newclass; | |
252 switch (obj->o_which) { | 253 switch (obj->o_which) { |
253 /* the ankh of Heil gives you prayers */ | 254 /* the ankh of Heil gives you prayers */ |
254 case HEIL_ANKH: | 255 case HEIL_ANKH: |
255 msg("The ankh welds itself into your hand."); | 256 msg("The ankh welds itself into your hand."); |
256 if (player.t_ctype != C_CLERIC && player.t_ctype != C_PALADIN) | 257 if (player.t_ctype != C_CLERIC && player.t_ctype != C_PALADIN) |
257 fuse(prayer_recovery, 0, SPELLTIME, AFTER); | 258 fuse(prayer_recovery, NULL, SPELLTIME, AFTER); |
258 | 259 |
259 /* A cloak must be worn. */ | 260 /* A cloak must be worn. */ |
260 when EMORI_CLOAK: | 261 when EMORI_CLOAK: |
261 if (cur_armor != NULL || cur_misc[WEAR_CLOAK]) { | 262 if (cur_armor != NULL || cur_misc[WEAR_CLOAK]) { |
262 msg("The cloak insists you remove your current garments."); | 263 msg("The cloak insists you remove your current garments."); |
304 } | 305 } |
305 waste_time(); | 306 waste_time(); |
306 msg("The excrutiating pain slowly turns into a dull throb."); | 307 msg("The excrutiating pain slowly turns into a dull throb."); |
307 | 308 |
308 when QUILL_NAGROM: | 309 when QUILL_NAGROM: |
309 fuse(quill_charge,0,player.t_ctype==C_MAGICIAN ? 4 : 8,AFTER); | 310 fuse(quill_charge,NULL,player.t_ctype==C_MAGICIAN ? 4 : 8,AFTER); |
310 | 311 |
311 /* Weapons will insist on being wielded. */ | 312 /* Weapons will insist on being wielded. */ |
312 when MUSTY_DAGGER: | 313 when MUSTY_DAGGER: |
313 case HRUGGEK_MSTAR: | 314 case HRUGGEK_MSTAR: |
314 case YEENOGHU_FLAIL: | 315 case YEENOGHU_FLAIL: |
315 case AXE_AKLAD: | 316 case AXE_AKLAD: |
316 /* For the daggers start a fuse to change player to a thief. */ | 317 /* For the daggers start a fuse to change player to a thief. */ |
317 /* and set a daemon to eat gold. */ | 318 /* and set a daemon to eat gold. */ |
318 if (obj->o_which == MUSTY_DAGGER) { | 319 if (obj->o_which == MUSTY_DAGGER) { |
319 fuse(changeclass, C_THIEF, roll(20, 20), AFTER); | 320 newclass = C_THIEF; |
321 fuse(changeclass, &newclass, roll(20, 20), AFTER); | |
320 if (purse > 0) | 322 if (purse > 0) |
321 msg("Your purse feels lighter"); | 323 msg("Your purse feels lighter"); |
322 else | 324 else |
323 purse = 1; /* fudge to get right msg from eat_gold() */ | 325 purse = 1; /* fudge to get right msg from eat_gold() */ |
324 eat_gold(obj); | 326 eat_gold(obj); |
325 start_daemon(eat_gold, obj, AFTER); | 327 start_daemon(eat_gold, obj, AFTER); |
326 } | 328 } |
327 /* For the axe start a fuse to change player to a fighter. */ | 329 /* For the axe start a fuse to change player to a fighter. */ |
328 if (obj->o_which == AXE_AKLAD) | 330 if (obj->o_which == AXE_AKLAD) |
329 fuse(changeclass, C_FIGHTER, roll(20, 20), AFTER); | 331 newclass = C_FIGHTER; |
332 fuse(changeclass, &newclass, roll(20, 20), AFTER); | |
330 if (cur_weapon != NULL) { | 333 if (cur_weapon != NULL) { |
331 msg("The artifact insists you release your current weapon."); | 334 msg("The artifact insists you release your current weapon."); |
332 if (!dropcheck(cur_weapon)) { | 335 if (!dropcheck(cur_weapon)) { |
333 pstats.s_hpt = -1; | 336 pstats.s_hpt = -1; |
334 msg("The artifact forces your weapon into your heart."); | 337 msg("The artifact forces your weapon into your heart."); |