diff xrogue/misc.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
line wrap: on
line diff
--- a/xrogue/misc.c	Tue Mar 08 20:47:57 2016 -0500
+++ b/xrogue/misc.c	Fri Mar 11 17:40:00 2016 -0500
@@ -24,9 +24,9 @@
  */
 
 void
-changeclass(long *newclass)
+changeclass(int newclass)
 {
-    if (*newclass == player.t_ctype) {
+    if (newclass == player.t_ctype) {
         msg("You feel more skillful.");
         raise_level();
     }
@@ -38,19 +38,19 @@
          */
         long save;
 
-        msg("You are transformed into a %s! ", char_class[*newclass].name);
+        msg("You are transformed into a %s! ", char_class[newclass].name);
 
         /*
          * if he becomes a thief or an assassin give him studded leather armor
          */
-        if ((*newclass == C_THIEF || *newclass == C_ASSASSIN) &&
+        if ((newclass == C_THIEF || newclass == C_ASSASSIN) &&
             cur_armor != NULL && cur_armor->o_which != STUDDED_LEATHER)
                 cur_armor->o_which = STUDDED_LEATHER;
         /*
          * if he becomes a monk he can't wear any armor
      * so give him a cloak of protection
          */
-        if (*newclass == C_MONK && cur_armor != NULL) {
+        if (newclass == C_MONK && cur_armor != NULL) {
                 cur_armor->o_ac = armors[cur_armor->o_which].a_class - 
                                   cur_armor->o_ac;
                 cur_armor->o_type = MM;
@@ -62,8 +62,8 @@
     /*
      * otherwise give him plate armor
      */
-        if ((*newclass != C_THIEF ||
-         *newclass != C_ASSASSIN || *newclass != C_MONK) &&
+        if ((newclass != C_THIEF ||
+         newclass != C_ASSASSIN || newclass != C_MONK) &&
          cur_armor != NULL && cur_armor->o_which != PLATE_ARMOR) 
                 cur_armor->o_which = PLATE_ARMOR;
 
@@ -81,11 +81,11 @@
         /*
          * if he becomes a spell caster of some kind, give him a fuse
          */
-        if (*newclass == C_MAGICIAN || *newclass == C_RANGER)
+        if (newclass == C_MAGICIAN || newclass == C_RANGER)
                 fuse(spell_recovery, NULL, SPELLTIME, AFTER);
-        if (*newclass == C_DRUID || *newclass == C_MONK)
+        if (newclass == C_DRUID || newclass == C_MONK)
                 fuse(chant_recovery, NULL, SPELLTIME, AFTER);
-        if ((*newclass==C_CLERIC || *newclass==C_PALADIN) && !cur_misc[HEIL_ANKH])
+        if ((newclass==C_CLERIC || newclass==C_PALADIN) && !cur_misc[HEIL_ANKH])
                 fuse(prayer_recovery, NULL, SPELLTIME, AFTER);
         /*
          * if he's changing from a fighter, ranger, or paladin then we
@@ -98,8 +98,8 @@
         cur_weapon != NULL && cur_weapon->o_type == WEAPON &&
             (cur_weapon->o_which == BASWORD  ||
         cur_weapon->o_which == TWOSWORD) &&
-            !(*newclass == C_FIGHTER || *newclass == C_RANGER ||
-            *newclass == C_PALADIN)  &&
+            !(newclass == C_FIGHTER || newclass == C_RANGER ||
+            newclass == C_PALADIN)  &&
         cur_weapon->o_which == TWOSWORD)
                 cur_weapon->o_which = SWORD;
 
@@ -113,8 +113,8 @@
         cur_weapon != NULL && cur_weapon->o_type == WEAPON &&
             (cur_weapon->o_which == BASWORD  ||
             cur_weapon->o_which == TWOSWORD) &&
-            !(*newclass == C_THIEF || *newclass == C_ASSASSIN ||
-            *newclass == C_MONK)   &&
+            !(newclass == C_THIEF || newclass == C_ASSASSIN ||
+            newclass == C_MONK)   &&
         cur_weapon->o_which == BASWORD)
                 cur_weapon->o_which = SWORD;
 
@@ -130,12 +130,12 @@
          * if he becomes a thief, assassin, or monk then add 
      * the trap_look() daemon
          */
-        if (*newclass == C_THIEF || *newclass == C_ASSASSIN ||
-        *newclass == C_MONK)
+        if (newclass == C_THIEF || newclass == C_ASSASSIN ||
+        newclass == C_MONK)
                 start_daemon(trap_look, NULL, AFTER);
 
     /* adjust stats */
-        char_type = player.t_ctype = *newclass;
+        char_type = player.t_ctype = newclass;
         save = pstats.s_hpt;
         max_stats.s_hpt = pstats.s_hpt = 0;
         max_stats.s_lvl = pstats.s_lvl = 0; 
@@ -1103,7 +1103,7 @@
         when MM_SKILLS:
             detach (pack, item);
             inpack--;
-            changeclass(&obj->o_ac);
+            changeclass(obj->o_ac);
     when MM_CRYSTAL:
     {
         register char *str;