OSDN Git Service

realmを表わす変数が0をLIFEとするときと、1をLIFEとするときの2種類あって
authormogami <mogami@0568b783-4c39-0410-ac80-bf13821ea2a2>
Sun, 16 Jun 2002 00:25:27 +0000 (00:25 +0000)
committermogami <mogami@0568b783-4c39-0410-ac80-bf13821ea2a2>
Sun, 16 Jun 2002 00:25:27 +0000 (00:25 +0000)
まぎらわしいので、1をLIFEとするように統一。
その過程でサブウィンドウの呪文リストの表示でバグを2個所発見、修正。
1つはis_magic()にわたす値が1ずれていた。もう1つはMIN_TECHNICHを引くときに括弧が不足。

src/cmd4.c
src/cmd5.c
src/defines.h
src/dungeon.c
src/hissatsu.c
src/object2.c
src/spells3.c
src/xtra1.c

index b767495..52ff2b1 100644 (file)
@@ -6066,7 +6066,7 @@ static void do_cmd_knowledge_spell_exp(void)
                {
                        if (!is_magic(p_ptr->realm1))
                        {
-                               s_ptr = &technic_info[p_ptr->realm1 - MIN_TECHNIC - 1][i];
+                               s_ptr = &technic_info[p_ptr->realm1 - MIN_TECHNIC][i];
                        }
                        else
                        {
@@ -6099,7 +6099,7 @@ static void do_cmd_knowledge_spell_exp(void)
                {
                        if (!is_magic(p_ptr->realm1))
                        {
-                               s_ptr = &technic_info[p_ptr->realm2 - MIN_TECHNIC - 1][i];
+                               s_ptr = &technic_info[p_ptr->realm2 - MIN_TECHNIC][i];
                        }
                        else
                        {
index 4eb658b..263cf5b 100644 (file)
@@ -78,7 +78,7 @@ static int get_spell(int *sn, cptr prompt, int sval, bool learned, int use_realm
        if (repeat_pull(sn))
        {
                /* Verify the spell */
-               if (spell_okay(*sn, learned, FALSE, use_realm - 1))
+               if (spell_okay(*sn, learned, FALSE, use_realm))
                {
                        /* Success */
                        return (TRUE);
@@ -110,7 +110,7 @@ static int get_spell(int *sn, cptr prompt, int sval, bool learned, int use_realm
        for (i = 0; i < num; i++)
        {
                /* Look for "okay" spells */
-               if (spell_okay(spells[i], learned, FALSE, use_realm - 1)) okay = TRUE;
+               if (spell_okay(spells[i], learned, FALSE, use_realm)) okay = TRUE;
        }
 
        /* No "okay" spells */
@@ -195,7 +195,7 @@ static int get_spell(int *sn, cptr prompt, int sval, bool learned, int use_realm
                        }
                        if (menu_line > num) menu_line -= num;
                        /* Display a list of spells */
-                       print_spells(menu_line, spells, num, 1, 15, use_realm - 1);
+                       print_spells(menu_line, spells, num, 1, 15, use_realm);
                        if (ask) continue;
                }
                else
@@ -213,7 +213,7 @@ static int get_spell(int *sn, cptr prompt, int sval, bool learned, int use_realm
                                        screen_save();
 
                                        /* Display a list of spells */
-                                       print_spells(menu_line, spells, num, 1, 15, use_realm - 1);
+                                       print_spells(menu_line, spells, num, 1, 15, use_realm);
                                }
 
                                /* Hide the list */
@@ -254,7 +254,7 @@ static int get_spell(int *sn, cptr prompt, int sval, bool learned, int use_realm
                spell = spells[i];
 
                /* Require "okay" spells */
-               if (!spell_okay(spell, learned, FALSE, use_realm - 1))
+               if (!spell_okay(spell, learned, FALSE, use_realm))
                {
                        bell();
 #ifdef JP
@@ -274,7 +274,7 @@ static int get_spell(int *sn, cptr prompt, int sval, bool learned, int use_realm
                        /* Access the spell */
                        if (!is_magic(use_realm))
                        {
-                               s_ptr = &technic_info[use_realm - MIN_TECHNIC - 1][spell];
+                               s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
                        }
                        else
                        {
@@ -288,7 +288,7 @@ static int get_spell(int *sn, cptr prompt, int sval, bool learned, int use_realm
                        else
                        {
                                /* Extract mana consumption rate */
-                               shouhimana = s_ptr->smana*(3800 - experience_of_spell(spell, use_realm-1)) + 2399;
+                               shouhimana = s_ptr->smana*(3800 - experience_of_spell(spell, use_realm)) + 2399;
                                if(p_ptr->dec_mana)
                                        shouhimana *= 3;
                                else shouhimana *= 4;
@@ -302,11 +302,11 @@ static int get_spell(int *sn, cptr prompt, int sval, bool learned, int use_realm
                         /* ±ÑÆüÀÚ¤êÂؤ¨µ¡Ç½¤ËÂбþ */
                         (void) strnfmt(tmp_val, 78, "%s(MP%d, ¼ºÇÔΨ%d%%)¤ò%s¤Þ¤¹¤«? ",
                                 spell_names[technic2magic(use_realm)-1][spell % 32], shouhimana,
-                                      spell_chance(spell, use_realm -1),jverb_buf);
+                                      spell_chance(spell, use_realm),jverb_buf);
 #else
                        (void)strnfmt(tmp_val, 78, "%^s %s (%d mana, %d%% fail)? ",
                                prompt, spell_names[technic2magic(use_realm)-1][spell % 32], shouhimana,
-                               spell_chance(spell, use_realm - 1));
+                               spell_chance(spell, use_realm));
 #endif
 
 
@@ -509,7 +509,7 @@ s = "
                        if (spell == -1) break;
 
                        /* Display a list of spells */
-                       print_spells(0, spells, num, 1, 15, use_realm - 1);
+                       print_spells(0, spells, num, 1, 15, use_realm);
 
                        /* Notify that there's nothing to see, and wait. */
                        if (use_realm == REALM_HISSATSU)
@@ -542,7 +542,7 @@ s = "
                /* Access the spell */
                if (!is_magic(use_realm))
                {
-                       s_ptr = &technic_info[use_realm - MIN_TECHNIC - 1][spell];
+                       s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
                }
                else
                {
@@ -764,7 +764,7 @@ s = "
                        {
                                /* Skip non "okay" prayers */
                                if (!spell_okay(spell, FALSE, TRUE,
-                                       (increment ? p_ptr->realm2 - 1 : p_ptr->realm1 - 1))) continue;
+                                       (increment ? p_ptr->realm2 : p_ptr->realm1))) continue;
 
                                /* Hack -- Prepare the randomizer */
                                k++;
@@ -4833,7 +4833,7 @@ s = "
 
        if (!is_magic(use_realm))
        {
-               s_ptr = &technic_info[use_realm - MIN_TECHNIC - 1][spell];
+               s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
        }
        else
        {
@@ -4841,7 +4841,7 @@ s = "
        }
 
        /* Extract mana consumption rate */
-       shouhimana = s_ptr->smana*(3800 - experience_of_spell(spell, realm-1)) + 2399;
+       shouhimana = s_ptr->smana*(3800 - experience_of_spell(spell, realm)) + 2399;
        if(p_ptr->dec_mana)
                shouhimana *= 3;
        else shouhimana *= 4;
@@ -4875,7 +4875,7 @@ msg_format("
 
 
        /* Spell failure chance */
-       chance = spell_chance(spell, use_realm - 1);
+       chance = spell_chance(spell, use_realm);
 
        /* Failed spell */
        if (randint0(100) < chance)
index 7e9c255..80949ef 100644 (file)
 #define REALM_DAEMON       9
 #define REALM_CRUSADE      10
 #define MAX_MAGIC          10
-#define MIN_TECHNIC        15
+#define MIN_TECHNIC        16
 #define REALM_MUSIC        16
 #define REALM_HISSATSU     17
 #define MAX_REALM          17
 
-#define VALID_REALM        (MAX_REALM + MAX_MAGIC - MIN_TECHNIC)
-#define NUM_TECHNIC        (MAX_REALM - MIN_TECHNIC)
+#define VALID_REALM        (MAX_REALM + MAX_MAGIC - MIN_TECHNIC + 1)
+#define NUM_TECHNIC        (MAX_REALM - MIN_TECHNIC + 1)
 
 #define is_magic(A) ((A) < MAX_MAGIC + 1 ? TRUE : FALSE)
 #define tval2realm(A) ((A) - TV_LIFE_BOOK + 1)
-#define technic2magic(A)      (is_magic(A) ? (A) : (A) - MIN_TECHNIC + MAX_MAGIC)
+#define technic2magic(A)      (is_magic(A) ? (A) : (A) - MIN_TECHNIC + 1 + MAX_MAGIC)
 #define is_good_realm(REALM)   ((REALM) == REALM_LIFE || (REALM) == REALM_CRUSADE)
 
 /*
index 7fb5c4f..ed19b88 100644 (file)
@@ -1394,7 +1394,7 @@ static void check_music(void)
         if(p_ptr->pclass != CLASS_BARD) return;
         if(!p_ptr->magic_num1[0] && !p_ptr->magic_num1[1]) return;
 
-        s_ptr = &technic_info[REALM_MUSIC - MIN_TECHNIC - 1][p_ptr->magic_num2[0]];
+        s_ptr = &technic_info[REALM_MUSIC - MIN_TECHNIC][p_ptr->magic_num2[0]];
 
        shouhimana = (s_ptr->smana*(3800-p_ptr->spell_exp[p_ptr->magic_num2[0]])+2399);
        if(p_ptr->dec_mana)
index ada37db..1958d33 100644 (file)
@@ -12,7 +12,7 @@
 
 #include "angband.h"
 
-#define TECHNIC_HISSATSU (REALM_HISSATSU - MIN_TECHNIC - 1)
+#define TECHNIC_HISSATSU (REALM_HISSATSU - MIN_TECHNIC)
 
 /*
  * Allow user to choose a mindcrafter power.
index 6f5fa37..fee5f94 100644 (file)
@@ -6152,7 +6152,7 @@ void display_koff(int k_idx)
 
                /* Print spells */
                print_spells(0, spells, num, 2, 0,
-                   (q_ptr->tval == REALM1_BOOK ? p_ptr->realm1 - 1 : p_ptr->realm2 - 1));
+                   (q_ptr->tval == REALM1_BOOK ? p_ptr->realm1 : p_ptr->realm2));
        }
 }
 
index d6cc262..f9bde69 100644 (file)
@@ -3713,8 +3713,6 @@ void display_spell_list(void)
 {
        int             i, j;
        int             y, x;
-       int             use_realm1 = p_ptr->realm1 - 1;
-       int             use_realm2 = p_ptr->realm2 - 1;
        int             m[9];
        magic_type      *s_ptr;
        char            name[80];
@@ -3814,7 +3812,7 @@ put_str("Lv   MP 
        /* Normal spellcaster with books */
 
        /* Scan books */
-       for (j = 0; j < ((use_realm2 > -1) ? 2 : 1); j++)
+       for (j = 0; j < ((p_ptr->realm2 > REALM_NONE) ? 2 : 1); j++)
        {
                int n = 0;
 
@@ -3833,16 +3831,16 @@ put_str("Lv   MP 
                        byte a = TERM_WHITE;
 
                        /* Access the spell */
-                       if (!is_magic((j < 1) ? use_realm1 : use_realm2))
+                       if (!is_magic((j < 1) ? p_ptr->realm1 : p_ptr->realm2))
                        {
-                               s_ptr = &technic_info[(j < 1) ? use_realm1 : use_realm2 - MIN_TECHNIC][i % 32];
+                               s_ptr = &technic_info[((j < 1) ? p_ptr->realm1 : p_ptr->realm2) - MIN_TECHNIC][i % 32];
                        }
                        else
                        {
-                               s_ptr = &mp_ptr->info[(j < 1) ? use_realm1 : use_realm2][i % 32];
+                               s_ptr = &mp_ptr->info[((j < 1) ? p_ptr->realm1 : p_ptr->realm2) - 1][i % 32];
                        }
 
-                       strcpy(name, spell_names[technic2magic((j < 1) ? use_realm1+1 : use_realm2+1)-1][i % 32]);
+                       strcpy(name, spell_names[technic2magic((j < 1) ? p_ptr->realm1 : p_ptr->realm2)-1][i % 32]);
 
                        /* Illegible */
                        if (s_ptr->slevel >= 99)
@@ -3906,12 +3904,12 @@ strcpy(name, "(Ƚ
 /*
  * Returns experience of a spell
  */
-s16b experience_of_spell(int spell, int realm)
+s16b experience_of_spell(int spell, int use_realm)
 {
        if (p_ptr->pclass == CLASS_SORCERER) return 1600;
        else if (p_ptr->pclass == CLASS_RED_MAGE) return 1200;
-       else if (realm+1 == p_ptr->realm1) return p_ptr->spell_exp[spell];
-       else if (realm+1 == p_ptr->realm2) return p_ptr->spell_exp[spell + 32];
+       else if (use_realm == p_ptr->realm1) return p_ptr->spell_exp[spell];
+       else if (use_realm == p_ptr->realm2) return p_ptr->spell_exp[spell + 32];
        else return 0;
 }
 
@@ -3919,7 +3917,7 @@ s16b experience_of_spell(int spell, int realm)
 /*
  * Returns spell chance of failure for spell -RAK-
  */
-s16b spell_chance(int spell, int realm)
+s16b spell_chance(int spell, int use_realm)
 {
        int             chance, minfail;
        magic_type      *s_ptr;
@@ -3930,16 +3928,16 @@ s16b spell_chance(int spell, int realm)
        /* Paranoia -- must be literate */
        if (!mp_ptr->spell_book) return (100);
 
-       if (realm+1 == REALM_HISSATSU) return 0;
+       if (use_realm == REALM_HISSATSU) return 0;
 
        /* Access the spell */
-       if (!is_magic(realm+1))
+       if (!is_magic(use_realm))
        {
-               s_ptr = &technic_info[realm - MIN_TECHNIC][spell];
+               s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
        }
        else
        {
-               s_ptr = &mp_ptr->info[realm][spell];
+               s_ptr = &mp_ptr->info[use_realm - 1][spell];
        }
 
        /* Extract the base spell failure rate */
@@ -3955,7 +3953,7 @@ s16b spell_chance(int spell, int realm)
                chance += (MAX(r_info[m_list[p_ptr->riding].r_idx].level-p_ptr->skill_exp[GINOU_RIDING]/100-10,0));
 
        /* Extract mana consumption rate */
-       shouhimana = s_ptr->smana*(3800 - experience_of_spell(spell, realm)) + 2399;
+       shouhimana = s_ptr->smana*(3800 - experience_of_spell(spell, use_realm)) + 2399;
 
        if(p_ptr->dec_mana) shouhimana *= 3;
        else shouhimana *= 4;
@@ -3970,7 +3968,7 @@ s16b spell_chance(int spell, int realm)
        }
 
        chance += p_ptr->to_m_chance;
-       if (((realm + 1) != p_ptr->realm1) && ((p_ptr->pclass == CLASS_MAGE) || (p_ptr->pclass == CLASS_PRIEST))) chance += 5;
+       if ((use_realm != p_ptr->realm1) && ((p_ptr->pclass == CLASS_MAGE) || (p_ptr->pclass == CLASS_PRIEST))) chance += 5;
 
        /* Extract the minimum failure rate */
        minfail = adj_mag_fail[p_ptr->stat_ind[mp_ptr->spell_stat]];
@@ -3993,9 +3991,9 @@ s16b spell_chance(int spell, int realm)
        else if (p_ptr->easy_spell) chance-=3;
        else if (p_ptr->dec_mana) chance-=2;
 
-       if ((realm+1 == REALM_NATURE) && ((p_ptr->align > 50) || (p_ptr->align < -50))) chance += penalty;
-       if (((realm+1 == REALM_LIFE) || (realm+1 == REALM_CRUSADE)) && (p_ptr->align < -20)) chance += penalty;
-       if (((realm+1 == REALM_DEATH) || (realm+1 == REALM_DAEMON)) && (p_ptr->align > 20)) chance += penalty;
+       if ((use_realm == REALM_NATURE) && ((p_ptr->align > 50) || (p_ptr->align < -50))) chance += penalty;
+       if (((use_realm == REALM_LIFE) || (use_realm == REALM_CRUSADE)) && (p_ptr->align < -20)) chance += penalty;
+       if (((use_realm == REALM_DEATH) || (use_realm == REALM_DAEMON)) && (p_ptr->align > 20)) chance += penalty;
 
        /* Minimum failure rate */
        if (chance < minfail) chance = minfail;
@@ -4007,9 +4005,9 @@ s16b spell_chance(int spell, int realm)
        /* Always a 5 percent chance of working */
        if (chance > 95) chance = 95;
 
-       if ((realm+1 == p_ptr->realm1) || (realm+1 == p_ptr->realm2))
+       if ((use_realm == p_ptr->realm1) || (use_realm == p_ptr->realm2))
        {
-               s16b exp = experience_of_spell(spell, realm);
+               s16b exp = experience_of_spell(spell, use_realm);
                if(exp > 1399) chance--;
                if(exp > 1599) chance--;
        }
@@ -4029,25 +4027,25 @@ s16b spell_chance(int spell, int realm)
  * The spell must be legible, not forgotten, and also, to cast,
  * it must be known, and to study, it must not be known.
  */
-bool spell_okay(int spell, bool learned, bool study_pray, int realm)
+bool spell_okay(int spell, bool learned, bool study_pray, int use_realm)
 {
        magic_type *s_ptr;
 
        /* Access the spell */
-       if (!is_magic(realm+1))
+       if (!is_magic(use_realm))
        {
-               s_ptr = &technic_info[realm - MIN_TECHNIC][spell];
+               s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
        }
        else
        {
-               s_ptr = &mp_ptr->info[realm][spell];
+               s_ptr = &mp_ptr->info[use_realm - 1][spell];
        }
 
        /* Spell is illegal */
        if (s_ptr->slevel > p_ptr->lev) return (FALSE);
 
        /* Spell is forgotten */
-       if ((realm == p_ptr->realm2 - 1) ?
+       if ((use_realm == p_ptr->realm2) ?
            (p_ptr->spell_forgotten2 & (1L << spell)) :
            (p_ptr->spell_forgotten1 & (1L << spell)))
        {
@@ -4059,7 +4057,7 @@ bool spell_okay(int spell, bool learned, bool study_pray, int realm)
        if (p_ptr->pclass == CLASS_RED_MAGE) return (TRUE);
 
        /* Spell is learned */
-       if ((realm == p_ptr->realm2 - 1) ?
+       if ((use_realm == p_ptr->realm2) ?
            (p_ptr->spell_learned2 & (1L << spell)) :
            (p_ptr->spell_learned1 & (1L << spell)))
        {
@@ -4081,7 +4079,7 @@ bool spell_okay(int spell, bool learned, bool study_pray, int realm)
  * The strings in this function were extracted from the code in the
  * functions "do_cmd_cast()" and "do_cmd_pray()" and may be dated.
  */
-static void spell_info(char *p, int spell, int realm)
+static void spell_info(char *p, int spell, int use_realm)
 {
        int plev = p_ptr->lev;
 
@@ -4112,9 +4110,9 @@ static void spell_info(char *p, int spell, int realm)
        strcpy(p, "");
 
        /* Analyze the spell */
-       switch (realm)
+       switch (use_realm)
        {
-       case 0: /* Life */
+       case REALM_LIFE: /* Life */
                switch (spell)
                {
                case  0: sprintf(p, " %s2d10", s_heal); break;
@@ -4134,7 +4132,7 @@ static void spell_info(char *p, int spell, int realm)
                }
                break;
                
-       case 1: /* Sorcery */
+       case REALM_SORCERY: /* Sorcery */
                switch (spell)
                {
                case  1: sprintf(p, " %s10", s_range); break;
@@ -4155,7 +4153,7 @@ static void spell_info(char *p, int spell, int realm)
                }
                break;
                
-       case 2: /* Nature */
+       case REALM_NATURE: /* Nature */
                switch (spell)
                {
 #ifdef JP
@@ -4185,7 +4183,7 @@ static void spell_info(char *p, int spell, int realm)
                }
                break;
                
-       case 3: /* Chaos */
+       case REALM_CHAOS: /* Chaos */
                switch (spell)
                {
                case  0: sprintf(p, " %s%dd4", s_dam, 3 + ((plev - 1) / 5)); break;
@@ -4217,7 +4215,7 @@ static void spell_info(char *p, int spell, int realm)
                }
                break;
                
-       case 4: /* Death */
+       case REALM_DEATH: /* Death */
                switch (spell)
                {
                case  1: sprintf(p, " %s%dd3", s_dam, (3 + ((plev - 1) / 5))); break;
@@ -4244,7 +4242,7 @@ static void spell_info(char *p, int spell, int realm)
                }
                break;
                
-       case 5: /* Trump */
+       case REALM_TRUMP: /* Trump */
                switch (spell)
                {
                case  0: sprintf(p, " %s10", s_range); break;
@@ -4267,7 +4265,7 @@ static void spell_info(char *p, int spell, int realm)
                }
                break;
                
-       case 6: /* Arcane */
+       case REALM_ARCANE: /* Arcane */
                switch (spell)
                {
                case  0: sprintf(p, " %s%dd3", s_dam, 3 + ((plev - 1) / 5)); break;
@@ -4288,7 +4286,7 @@ static void spell_info(char *p, int spell, int realm)
                }
                break;
                
-       case 7: /* Craft */
+       case REALM_ENCHANT: /* Craft */
                switch (spell)
                {
                case 0: sprintf(p, " %s100+d100", s_dur); break;
@@ -4313,7 +4311,7 @@ static void spell_info(char *p, int spell, int realm)
                }
                break;
                
-       case 8: /* Daemon */
+       case REALM_DAEMON: /* Daemon */
                switch (spell)
                {
                case  0: sprintf(p, " %s%dd4", s_dam, 3 + ((plev - 1) / 5)); break;
@@ -4341,7 +4339,7 @@ static void spell_info(char *p, int spell, int realm)
                }
                break;
                
-       case 9: /* Crusade */
+       case REALM_CRUSADE: /* Crusade */
                switch (spell)
                {
                case  0: sprintf(p, " %s%dd4", s_dam, 3 + ((plev - 1) / 5)); break;
@@ -4380,7 +4378,7 @@ static void spell_info(char *p, int spell, int realm)
                }
                break;
 
-       case 15: /* Music */
+       case REALM_MUSIC: /* Music */
                switch (spell)
                {
                case 2 : sprintf(p, " %s%dd4", s_dam, 4 + ((plev - 1) / 5)); break;
@@ -4396,9 +4394,9 @@ static void spell_info(char *p, int spell, int realm)
                break;
        default:
 #ifdef JP
-               sprintf(p, "̤ÃΤΥ¿¥¤¥×: %d", realm);
+               sprintf(p, "̤ÃΤΥ¿¥¤¥×: %d", use_realm);
 #else
-               sprintf(p, "Unknown type: %d.", realm);
+               sprintf(p, "Unknown type: %d.", use_realm);
 #endif
        }
 }
@@ -4407,7 +4405,7 @@ static void spell_info(char *p, int spell, int realm)
 /*
  * Print a list of spells (for browsing or casting or viewing)
  */
-void print_spells(int target_spell, byte *spells, int num, int y, int x, int realm)
+void print_spells(int target_spell, byte *spells, int num, int y, int x, int use_realm)
 {
        int             i, spell, shougou, increment = 64;
        magic_type      *s_ptr;
@@ -4421,7 +4419,7 @@ void print_spells(int target_spell, byte *spells, int num, int y, int x, int rea
        bool max = FALSE;
 
 
-       if (((realm < 0) || (realm > MAX_REALM - 1)) && p_ptr->wizard)
+       if (((use_realm <= REALM_NONE) || (use_realm > MAX_REALM)) && p_ptr->wizard)
 #ifdef JP
 msg_print("·Ù¹ð¡ª print_spell ¤¬Îΰè¤Ê¤·¤Ë¸Æ¤Ð¤ì¤¿");
 #else
@@ -4431,7 +4429,7 @@ msg_print("
 
        /* Title the list */
        prt("", y, x);
-       if (realm+1 == REALM_HISSATSU)
+       if (use_realm == REALM_HISSATSU)
 #ifdef JP
                strcpy(buf,"  Lv   MP");
 #else
@@ -4453,8 +4451,8 @@ put_str(buf, y, x + 29);
 #endif
 
        if ((p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE)) increment = 0;
-       else if ((realm + 1) == p_ptr->realm1) increment = 0;
-       else if ((realm + 1) == p_ptr->realm2) increment = 32;
+       else if (use_realm == p_ptr->realm1) increment = 0;
+       else if (use_realm == p_ptr->realm2) increment = 32;
 
        /* Dump the spells */
        for (i = 0; i < num; i++)
@@ -4463,20 +4461,20 @@ put_str(buf, y, x + 29);
                spell = spells[i];
 
                /* Access the spell */
-               if (!is_magic(realm+1))
+               if (!is_magic(use_realm))
                {
-                       s_ptr = &technic_info[realm - MIN_TECHNIC][spell];
+                       s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
                }
                else
                {
-                       s_ptr = &mp_ptr->info[realm][spell];
+                       s_ptr = &mp_ptr->info[use_realm - 1][spell];
                }
 
-               if (realm+1 == REALM_HISSATSU)
+               if (use_realm == REALM_HISSATSU)
                        shouhimana = s_ptr->smana;
                else
                {
-                       s16b exp = experience_of_spell(spell, realm);
+                       s16b exp = experience_of_spell(spell, use_realm);
 
                        /* Extract mana consumption rate */
                        shouhimana = s_ptr->smana*(3800 - exp) + 2399;
@@ -4533,7 +4531,7 @@ strcat(out_val, format("%-30s", "(Ƚ
                /* XXX XXX Could label spells above the players level */
 
                /* Get extra info */
-               spell_info(info, spell, realm);
+               spell_info(info, spell, use_realm);
 
                /* Use that info */
                comment = info;
@@ -4565,7 +4563,7 @@ comment = " ˺
                                line_attr = TERM_YELLOW;
                        }
                }
-               else if ((realm+1 != p_ptr->realm1) && (realm+1 != p_ptr->realm2))
+               else if ((use_realm != p_ptr->realm1) && (use_realm != p_ptr->realm2))
                {
 #ifdef JP
 comment = " Ì¤ÃÎ";
@@ -4575,7 +4573,7 @@ comment = " ̤
 
                        line_attr = TERM_L_BLUE;
                }
-               else if ((realm + 1 == p_ptr->realm1) ?
+               else if ((use_realm == p_ptr->realm1) ?
                    ((p_ptr->spell_forgotten1 & (1L << spell))) :
                    ((p_ptr->spell_forgotten2 & (1L << spell))))
                {
@@ -4587,7 +4585,7 @@ comment = " ˺
 
                        line_attr = TERM_YELLOW;
                }
-               else if (!((realm + 1 == p_ptr->realm1) ?
+               else if (!((use_realm == p_ptr->realm1) ?
                    (p_ptr->spell_learned1 & (1L << spell)) :
                    (p_ptr->spell_learned2 & (1L << spell))))
                {
@@ -4599,7 +4597,7 @@ comment = " ̤
 
                        line_attr = TERM_L_BLUE;
                }
-               else if (!((realm + 1 == p_ptr->realm1) ?
+               else if (!((use_realm == p_ptr->realm1) ?
                    (p_ptr->spell_worked1 & (1L << spell)) :
                    (p_ptr->spell_worked2 & (1L << spell))))
                {
@@ -4613,18 +4611,18 @@ comment = " ̤
                }
 
                /* Dump the spell --(-- */
-               if (realm+1 == REALM_HISSATSU)
+               if (use_realm == REALM_HISSATSU)
                {
                        strcat(out_val, format("%-25s %2d %4d",
-                           spell_names[technic2magic(realm+1)-1][spell], /* realm, spell */
+                           spell_names[technic2magic(use_realm)-1][spell], /* realm, spell */
                            s_ptr->slevel, shouhimana));
                }
                else
                {
                        strcat(out_val, format("%-25s%c%-4s %2d %4d %3d%%%s",
-                           spell_names[technic2magic(realm+1)-1][spell], /* realm, spell */
+                           spell_names[technic2magic(use_realm)-1][spell], /* realm, spell */
                            (max ? '!' : ' '), ryakuji,
-                           s_ptr->slevel, shouhimana, spell_chance(spell, realm), comment));
+                           s_ptr->slevel, shouhimana, spell_chance(spell, use_realm), comment));
                }
                c_prt(line_attr, out_val, y + i + 1, x);
        }
index 8e27d2c..076cc6a 100644 (file)
@@ -2062,8 +2062,6 @@ static void calc_spells(void)
        int                     num_boukyaku = 0;
 
        magic_type              *s_ptr;
-       int use_realm1 = p_ptr->realm1 - 1;
-       int use_realm2 = p_ptr->realm2 - 1;
        int which;
        int bonus = 0;
 
@@ -2147,17 +2145,17 @@ static void calc_spells(void)
 
 
                /* Get the spell */
-               if (!is_magic(((j < 32) ? use_realm1 : use_realm2)+1))
+               if (!is_magic((j < 32) ? p_ptr->realm1 : p_ptr->realm2))
                {
                        if (j < 32)
-                               s_ptr = &technic_info[use_realm1 - MIN_TECHNIC][j];
+                               s_ptr = &technic_info[p_ptr->realm1 - MIN_TECHNIC][j];
                        else
-                               s_ptr = &technic_info[use_realm2 - MIN_TECHNIC][j%32];
+                               s_ptr = &technic_info[p_ptr->realm2 - MIN_TECHNIC][j%32];
                }
                else if (j < 32)
-                       s_ptr = &mp_ptr->info[use_realm1][j];
+                       s_ptr = &mp_ptr->info[p_ptr->realm1-1][j];
                else
-                       s_ptr = &mp_ptr->info[use_realm2][j%32];
+                       s_ptr = &mp_ptr->info[p_ptr->realm2-1][j%32];
 
                /* Skip spells we are allowed to know */
                if (s_ptr->slevel <= p_ptr->lev) continue;
@@ -2171,33 +2169,33 @@ static void calc_spells(void)
                        if (j < 32)
                        {
                                p_ptr->spell_forgotten1 |= (1L << j);
-                               which = use_realm1;
+                               which = p_ptr->realm1;
                        }
                        else
                        {
                                p_ptr->spell_forgotten2 |= (1L << (j - 32));
-                               which = use_realm2;
+                               which = p_ptr->realm2;
                        }
 
                        /* No longer known */
                        if (j < 32)
                        {
                                p_ptr->spell_learned1 &= ~(1L << j);
-                               which = use_realm1;
+                               which = p_ptr->realm1;
                        }
                        else
                        {
                                p_ptr->spell_learned2 &= ~(1L << (j - 32));
-                               which = use_realm2;
+                               which = p_ptr->realm2;
                        }
 
                        /* Message */
 #ifdef JP
                         msg_format("%s¤Î%s¤ò˺¤ì¤Æ¤·¤Þ¤Ã¤¿¡£",
-                                  spell_names[technic2magic(which+1)-1][j%32], p );
+                                  spell_names[technic2magic(which)-1][j%32], p );
 #else
                        msg_format("You have forgotten the %s of %s.", p,
-                       spell_names[technic2magic(which+1)-1][j%32]);
+                       spell_names[technic2magic(which)-1][j%32]);
 #endif
 
 
@@ -2231,33 +2229,33 @@ static void calc_spells(void)
                        if (j < 32)
                        {
                                p_ptr->spell_forgotten1 |= (1L << j);
-                               which = use_realm1;
+                               which = p_ptr->realm1;
                        }
                        else
                        {
                                p_ptr->spell_forgotten2 |= (1L << (j - 32));
-                               which = use_realm2;
+                               which = p_ptr->realm2;
                        }
 
                        /* No longer known */
                        if (j < 32)
                        {
                                p_ptr->spell_learned1 &= ~(1L << j);
-                               which = use_realm1;
+                               which = p_ptr->realm1;
                        }
                        else
                        {
                                p_ptr->spell_learned2 &= ~(1L << (j - 32));
-                               which = use_realm2;
+                               which = p_ptr->realm2;
                        }
 
                        /* Message */
 #ifdef JP
                         msg_format("%s¤Î%s¤ò˺¤ì¤Æ¤·¤Þ¤Ã¤¿¡£",
-                                  spell_names[technic2magic(which+1)-1][j%32], p );
+                                  spell_names[technic2magic(which)-1][j%32], p );
 #else
                        msg_format("You have forgotten the %s of %s.", p,
-                                  spell_names[technic2magic(which+1)-1][j%32]);
+                                  spell_names[technic2magic(which)-1][j%32]);
 #endif
 
 
@@ -2283,17 +2281,17 @@ static void calc_spells(void)
                if (j >= 99) break;
 
                /* Access the spell */
-               if (!is_magic(((j < 32) ? use_realm1 : use_realm2)+1))
+               if (!is_magic((j < 32) ? p_ptr->realm1 : p_ptr->realm2))
                {
                        if (j < 32)
-                               s_ptr = &technic_info[use_realm1 - MIN_TECHNIC][j];
+                               s_ptr = &technic_info[p_ptr->realm1 - MIN_TECHNIC][j];
                        else
-                               s_ptr = &technic_info[use_realm2 - MIN_TECHNIC][j%32];
+                               s_ptr = &technic_info[p_ptr->realm2 - MIN_TECHNIC][j%32];
                }
                else if (j<32)
-                       s_ptr = &mp_ptr->info[use_realm1][j];
+                       s_ptr = &mp_ptr->info[p_ptr->realm1-1][j];
                else
-                       s_ptr = &mp_ptr->info[use_realm2][j%32];
+                       s_ptr = &mp_ptr->info[p_ptr->realm2-1][j%32];
 
                /* Skip spells we cannot remember */
                if (s_ptr->slevel > p_ptr->lev) continue;
@@ -2307,33 +2305,33 @@ static void calc_spells(void)
                        if (j < 32)
                        {
                                p_ptr->spell_forgotten1 &= ~(1L << j);
-                               which = use_realm1;
+                               which = p_ptr->realm1;
                        }
                        else
                        {
                                p_ptr->spell_forgotten2 &= ~(1L << (j - 32));
-                               which = use_realm2;
+                               which = p_ptr->realm2;
                        }
 
                        /* Known once more */
                        if (j < 32)
                        {
                                p_ptr->spell_learned1 |= (1L << j);
-                               which = use_realm1;
+                               which = p_ptr->realm1;
                        }
                        else
                        {
                                p_ptr->spell_learned2 |= (1L << (j - 32));
-                               which = use_realm2;
+                               which = p_ptr->realm2;
                        }
 
                        /* Message */
 #ifdef JP
                         msg_format("%s¤Î%s¤ò»×¤¤½Ð¤·¤¿¡£",
-                                  spell_names[technic2magic(which+1)-1][j%32], p );
+                                  spell_names[technic2magic(which)-1][j%32], p );
 #else
                        msg_format("You have remembered the %s of %s.",
-                                  p, spell_names[technic2magic(which+1)-1][j%32]);
+                                  p, spell_names[technic2magic(which)-1][j%32]);
 #endif
 
 
@@ -2349,8 +2347,8 @@ static void calc_spells(void)
                /* Count spells that can be learned */
                for (j = 0; j < 32; j++)
                {
-                       if (!is_magic(use_realm1+1)) s_ptr = &technic_info[use_realm1-MIN_TECHNIC][j];
-                       else s_ptr = &mp_ptr->info[use_realm1][j];
+                       if (!is_magic(p_ptr->realm1)) s_ptr = &technic_info[p_ptr->realm1-MIN_TECHNIC][j];
+                       else s_ptr = &mp_ptr->info[p_ptr->realm1-1][j];
 
                        /* Skip spells we cannot remember */
                        if (s_ptr->slevel > p_ptr->lev) continue;