comparison xrogue/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 7c1cb43f346e
children
comparison
equal deleted inserted replaced
237:2236ef808bcb 238:e1cd27c5464f
34 { 34 {
35 register struct linked_list *ip, *lp = NULL, *ap; 35 register struct linked_list *ip, *lp = NULL, *ap;
36 register struct object *obj, *op = NULL; 36 register struct object *obj, *op = NULL;
37 register bool exact, from_floor; 37 register bool exact, from_floor;
38 bool giveflag = 0; 38 bool giveflag = 0;
39 static long cleric = C_CLERIC, 39 int newclass;
40 monk = C_MONK,
41 magician = C_MAGICIAN,
42 assassin = C_ASSASSIN,
43 druid = C_DRUID,
44 thief = C_THIEF,
45 fighter = C_FIGHTER,
46 ranger = C_RANGER,
47 paladin = C_PALADIN;
48 40
49 if (item == NULL) 41 if (item == NULL)
50 { 42 {
51 from_floor = TRUE; 43 from_floor = TRUE;
52 if ((item = find_obj(hero.y, hero.x)) == NULL) 44 if ((item = find_obj(hero.y, hero.x)) == NULL)
261 if (player.t_ctype != C_CLERIC && player.t_ctype != C_PALADIN) 253 if (player.t_ctype != C_CLERIC && player.t_ctype != C_PALADIN)
262 fuse(prayer_recovery, NULL, SPELLTIME, AFTER); 254 fuse(prayer_recovery, NULL, SPELLTIME, AFTER);
263 /* start a fuse to change player into a paladin */ 255 /* start a fuse to change player into a paladin */
264 if (quest_item != HEIL_ANKH) { 256 if (quest_item != HEIL_ANKH) {
265 msg("You hear a strange, distant hypnotic calling... "); 257 msg("You hear a strange, distant hypnotic calling... ");
266 if (player.t_ctype != C_PALADIN && obj->o_which ==HEIL_ANKH) 258 if (player.t_ctype != C_PALADIN && obj->o_which ==HEIL_ANKH) {
267 fuse(changeclass, &paladin, roll(8, 8), AFTER); 259 newclass = C_PALADIN;
260 fuse(changeclass, &newclass, roll(8, 8), AFTER);
261 }
268 } 262 }
269 263
270 /* A cloak must be worn. */ 264 /* A cloak must be worn. */
271 when EMORI_CLOAK: 265 when EMORI_CLOAK:
272 if (cur_armor != NULL || cur_misc[WEAR_CLOAK]) { 266 if (cur_armor != NULL || cur_misc[WEAR_CLOAK]) {
285 if (obj->o_charges == 0) 279 if (obj->o_charges == 0)
286 fuse(cloak_charge, obj, CLOAK_TIME, AFTER); 280 fuse(cloak_charge, obj, CLOAK_TIME, AFTER);
287 /* start a fuse to change player into a monk */ 281 /* start a fuse to change player into a monk */
288 if (quest_item != EMORI_CLOAK) { 282 if (quest_item != EMORI_CLOAK) {
289 msg("You suddenly become calm and quiet. "); 283 msg("You suddenly become calm and quiet. ");
290 if (player.t_ctype != C_MONK && obj->o_which == EMORI_CLOAK) 284 if (player.t_ctype != C_MONK && obj->o_which == EMORI_CLOAK) {
291 fuse(changeclass, &monk, roll(8, 8), AFTER); 285 newclass = C_MONK;
286 fuse(changeclass, &newclass, roll(8, 8), AFTER);
287 }
292 } 288 }
293 289
294 /* The amulet must be worn. */ 290 /* The amulet must be worn. */
295 when STONEBONES_AMULET: 291 when STONEBONES_AMULET:
296 case YENDOR_AMULET: 292 case YENDOR_AMULET:
310 /* start a fuse to change into a magician */ 306 /* start a fuse to change into a magician */
311 if (quest_item != STONEBONES_AMULET) { 307 if (quest_item != STONEBONES_AMULET) {
312 if (player.t_ctype != C_MAGICIAN && 308 if (player.t_ctype != C_MAGICIAN &&
313 obj->o_which == STONEBONES_AMULET) { 309 obj->o_which == STONEBONES_AMULET) {
314 msg("You sense approaching etheric forces... "); 310 msg("You sense approaching etheric forces... ");
315 fuse(changeclass, &magician, roll(8, 8), AFTER); 311 newclass = C_MAGICIAN;
312 fuse(changeclass, &newclass, roll(8, 8), AFTER);
316 } 313 }
317 } 314 }
318 315
319 /* The eye is now inserted in forehead */ 316 /* The eye is now inserted in forehead */
320 when EYE_VECNA: 317 when EYE_VECNA:
329 waste_time(); 326 waste_time();
330 msg("The excruciating pain slowly turns into a dull throb."); 327 msg("The excruciating pain slowly turns into a dull throb.");
331 /* start a fuse to change player into an assassin */ 328 /* start a fuse to change player into an assassin */
332 if (quest_item != EYE_VECNA) { 329 if (quest_item != EYE_VECNA) {
333 msg("Your blood rushes and you begin to sweat profusely... "); 330 msg("Your blood rushes and you begin to sweat profusely... ");
334 if (player.t_ctype != C_ASSASSIN && obj->o_which == EYE_VECNA) 331 if (player.t_ctype != C_ASSASSIN && obj->o_which == EYE_VECNA) {
335 fuse(changeclass, &assassin, roll(8, 8), AFTER); 332 newclass = C_ASSASSIN;
333 fuse(changeclass, &newclass, roll(8, 8), AFTER);
334 }
336 } 335 }
337 336
338 when QUILL_NAGROM: 337 when QUILL_NAGROM:
339 fuse(quill_charge, NULL, 8, AFTER); 338 fuse(quill_charge, NULL, 8, AFTER);
340 /* start a fuse to change player into a druid */ 339 /* start a fuse to change player into a druid */
341 if (quest_item != QUILL_NAGROM) { 340 if (quest_item != QUILL_NAGROM) {
342 msg("You begin to see things differently... "); 341 msg("You begin to see things differently... ");
343 if (player.t_ctype != C_DRUID && obj->o_which == QUILL_NAGROM) 342 if (player.t_ctype != C_DRUID && obj->o_which == QUILL_NAGROM) {
344 fuse(changeclass, &druid, roll(8, 8), AFTER); 343 newclass = C_DRUID;
344 fuse(changeclass, &newclass, roll(8, 8), AFTER);
345 }
345 } 346 }
346 347
347 /* Weapons will insist on being wielded. */ 348 /* Weapons will insist on being wielded. */
348 when MUSTY_DAGGER: 349 when MUSTY_DAGGER:
349 case HRUGGEK_MSTAR: 350 case HRUGGEK_MSTAR:
360 /* start a fuse to change player into a thief */ 361 /* start a fuse to change player into a thief */
361 if (quest_item != MUSTY_DAGGER) { 362 if (quest_item != MUSTY_DAGGER) {
362 if (player.t_ctype != C_THIEF && 363 if (player.t_ctype != C_THIEF &&
363 obj->o_which == MUSTY_DAGGER) { 364 obj->o_which == MUSTY_DAGGER) {
364 msg("You look about furtively. "); 365 msg("You look about furtively. ");
365 fuse(changeclass, &thief, roll(8, 8), AFTER); 366 newclass = C_THIEF;
367 fuse(changeclass, &newclass, roll(8, 8), AFTER);
366 } 368 }
367 } 369 }
368 /* start a fuse to change player into a fighter */ 370 /* start a fuse to change player into a fighter */
369 if (quest_item != AXE_AKLAD) { 371 if (quest_item != AXE_AKLAD) {
370 if (player.t_ctype != C_FIGHTER && 372 if (player.t_ctype != C_FIGHTER &&
371 obj->o_which == AXE_AKLAD) { 373 obj->o_which == AXE_AKLAD) {
372 msg("Your bones feel strengthened. "); 374 msg("Your bones feel strengthened. ");
373 fuse(changeclass, &fighter, roll(8, 8), AFTER); 375 newclass = C_FIGHTER;
376 fuse(changeclass, &newclass, roll(8, 8), AFTER);
374 } 377 }
375 } 378 }
376 if (cur_weapon != NULL) { 379 if (cur_weapon != NULL) {
377 msg("The artifact insists you release your current weapon!"); 380 msg("The artifact insists you release your current weapon!");
378 if (!dropcheck(cur_weapon)) { 381 if (!dropcheck(cur_weapon)) {
403 when BRIAN_MANDOLIN: 406 when BRIAN_MANDOLIN:
404 msg("You hear an ancient haunting sound... "); 407 msg("You hear an ancient haunting sound... ");
405 /* start a fuse to change player into a ranger */ 408 /* start a fuse to change player into a ranger */
406 if (quest_item != BRIAN_MANDOLIN) { 409 if (quest_item != BRIAN_MANDOLIN) {
407 msg("You are transfixed with empathy. "); 410 msg("You are transfixed with empathy. ");
408 if (player.t_ctype != C_RANGER && obj->o_which == BRIAN_MANDOLIN) 411 if (player.t_ctype != C_RANGER && obj->o_which == BRIAN_MANDOLIN) {
409 fuse(changeclass, &ranger, roll(8, 8), AFTER); 412 newclass = C_RANGER;
413 fuse(changeclass, &newclass, roll(8, 8), AFTER);
414 }
410 } 415 }
411 416
412 /* add to the music */ 417 /* add to the music */
413 when GERYON_HORN: 418 when GERYON_HORN:
414 msg("You begin to hear trumpets!"); 419 msg("You begin to hear trumpets!");
415 /* start a fuse to change player into a cleric */ 420 /* start a fuse to change player into a cleric */
416 if (quest_item != GERYON_HORN) { 421 if (quest_item != GERYON_HORN) {
417 msg("You follow their calling. "); 422 msg("You follow their calling. ");
418 if (player.t_ctype != C_CLERIC && obj->o_which == GERYON_HORN) 423 if (player.t_ctype != C_CLERIC && obj->o_which == GERYON_HORN) {
419 fuse(changeclass, &cleric, roll(8, 8), AFTER); 424 newclass = C_CLERIC;
425 fuse(changeclass, &newclass, roll(8, 8), AFTER);
426 }
420 } 427 }
421 428
422 /* the card can not be picked up, it must be traded for */ 429 /* the card can not be picked up, it must be traded for */
423 when ALTERAN_CARD: 430 when ALTERAN_CARD:
424 if (giveflag == FALSE) { 431 if (giveflag == FALSE) {