OSDN Git Service

Weird Weapon must have slay_human
[hengband/hengband.git] / src / load.c
index 618ddb4..9b731e8 100644 (file)
@@ -703,6 +703,15 @@ static void rd_monster_old(monster_type *m_ptr)
        {
                rd_s16b(&m_ptr->max_maxhp);
        }
+       if(h_older_than(2, 1, 2, 1))
+       {
+               m_ptr->dealt_damage = 0;
+       }
+       else
+       {
+               rd_u32b(&m_ptr->dealt_damage); 
+       }
+       
        rd_s16b(&m_ptr->mtimed[MTIMED_CSLEEP]);
        rd_byte(&m_ptr->mspeed);
        if (z_older_than(10, 4, 2))
@@ -825,6 +834,14 @@ static void rd_monster(monster_type *m_ptr)
        rd_s16b(&m_ptr->hp);
        rd_s16b(&m_ptr->maxhp);
        rd_s16b(&m_ptr->max_maxhp);
+       if(h_older_than(2, 1, 2, 1))
+       {
+               m_ptr->dealt_damage = 0;
+       }
+       else
+       {
+               rd_u32b(&m_ptr->dealt_damage); 
+       }
 
        /* Monster race index of its appearance */
        if (flags & SAVE_MON_AP_R_IDX) rd_s16b(&m_ptr->ap_r_idx);
@@ -1077,7 +1094,7 @@ static void rd_lore(int r_idx)
 static void home_carry(store_type *st_ptr, object_type *o_ptr)
 {
        int                             slot;
-       s32b                       value, j_value;
+       s32b                       value;
        int     i;
        object_type *j_ptr;
 
@@ -1110,45 +1127,7 @@ static void home_carry(store_type *st_ptr, object_type *o_ptr)
        /* Check existing slots to see if we must "slide" */
        for (slot = 0; slot < st_ptr->stock_num; slot++)
        {
-               /* Get that item */
-               j_ptr = &st_ptr->stock[slot];
-
-               /* Hack -- readable books always come first */
-               if ((o_ptr->tval == mp_ptr->spell_book) &&
-                       (j_ptr->tval != mp_ptr->spell_book)) break;
-               if ((j_ptr->tval == mp_ptr->spell_book) &&
-                       (o_ptr->tval != mp_ptr->spell_book)) continue;
-
-               /* Objects sort by decreasing type */
-               if (o_ptr->tval > j_ptr->tval) break;
-               if (o_ptr->tval < j_ptr->tval) continue;
-
-               /* Can happen in the home */
-               if (!object_is_aware(o_ptr)) continue;
-               if (!object_is_aware(j_ptr)) break;
-
-               /* Objects sort by increasing sval */
-               if (o_ptr->sval < j_ptr->sval) break;
-               if (o_ptr->sval > j_ptr->sval) continue;
-
-               /* Objects in the home can be unknown */
-               if (!object_is_known(o_ptr)) continue;
-               if (!object_is_known(j_ptr)) break;
-
-               /*
-                * Hack:  otherwise identical rods sort by
-                * increasing recharge time --dsb
-                */
-               if (o_ptr->tval == TV_ROD)
-               {
-                       if (o_ptr->pval < j_ptr->pval) break;
-                       if (o_ptr->pval > j_ptr->pval) continue;
-               }
-
-               /* Objects sort by decreasing value */
-               j_value = object_value(j_ptr);
-               if (value > j_value) break;
-               if (value < j_value) continue;
+               if (object_sort_comp(o_ptr, value, &st_ptr->stock[slot])) break;
        }
 
        /* Slide the others up */
@@ -1276,9 +1255,6 @@ static void rd_randomizer(void)
        {
                rd_u32b(&Rand_state[i]);
        }
-
-       /* Accept */
-       Rand_quick = FALSE;
 }
 
 
@@ -1821,7 +1797,7 @@ static void rd_extra(void)
        /* More info */
        strip_bytes(8);
        rd_s16b(&p_ptr->sc);
-       strip_bytes(2);
+       rd_s16b(&p_ptr->concent);
 
        /* Read the flags */
        strip_bytes(2); /* Old "rest" */
@@ -1834,6 +1810,10 @@ static void rd_extra(void)
        rd_s16b(&p_ptr->energy_need);
        if (z_older_than(11, 0, 13))
                p_ptr->energy_need = 100 - p_ptr->energy_need;
+       if (h_older_than(2, 1, 2, 0))
+               p_ptr->enchant_energy_need = 0;
+       else
+               rd_s16b(&p_ptr->enchant_energy_need);
 
        rd_s16b(&p_ptr->fast);
        rd_s16b(&p_ptr->slow);
@@ -2219,6 +2199,9 @@ static errr rd_inventory(void)
                /* Wield equipment */
                if (n >= INVEN_RARM)
                {
+                       /* Player touches it */
+                       q_ptr->marked |= OM_TOUCHED;
+
                        /* Copy object */
                        object_copy(&inventory[n], q_ptr);
 
@@ -2250,6 +2233,9 @@ note("
                        /* Get a slot */
                        n = slot++;
 
+                       /* Player touches it */
+                       q_ptr->marked |= OM_TOUCHED;
+
                        /* Copy object */
                        object_copy(&inventory[n], q_ptr);
 
@@ -2299,9 +2285,19 @@ static void rd_messages(void)
 /*** Terrain Feature Indexes (see "lib/edit/f_info.txt") ***/
 #define OLD_FEAT_INVIS              0x02
 #define OLD_FEAT_GLYPH              0x03
+#define OLD_FEAT_QUEST_ENTER        0x08
+#define OLD_FEAT_QUEST_EXIT         0x09
 #define OLD_FEAT_MINOR_GLYPH        0x40
+#define OLD_FEAT_BLDG_1             0x81
 #define OLD_FEAT_MIRROR             0xc3
 
+/* Old quests */
+#define OLD_QUEST_WATER_CAVE 18
+
+/* Quest constants */
+#define QUEST_OLD_CASTLE  27
+#define QUEST_ROYAL_CRYPT 28
+
 /*
  * Read the dungeon (old method)
  *
@@ -2557,6 +2553,35 @@ static errr rd_dungeon_old(void)
                }
        }
 
+       /* Quest 18 was removed */
+       if (h_older_than(1, 7, 0, 6) && !vanilla_town)
+       {
+               for (y = 0; y < ymax; y++) for (x = 0; x < xmax; x++)
+               {
+                       /* Access the cave */
+                       c_ptr = &cave[y][x];
+
+                       if ((c_ptr->special == OLD_QUEST_WATER_CAVE) && !dun_level)
+                       {
+                               if (c_ptr->feat == OLD_FEAT_QUEST_ENTER)
+                               {
+                                       c_ptr->feat = feat_tree;
+                                       c_ptr->special = 0;
+                               }
+                               else if (c_ptr->feat == OLD_FEAT_BLDG_1)
+                               {
+                                       c_ptr->special = lite_town ? QUEST_OLD_CASTLE : QUEST_ROYAL_CRYPT;
+                               }
+                       }
+                       else if ((c_ptr->feat == OLD_FEAT_QUEST_EXIT) &&
+                                (p_ptr->inside_quest == OLD_QUEST_WATER_CAVE))
+                       {
+                               c_ptr->feat = feat_up_stair;
+                               c_ptr->special = 0;
+                       }
+               }
+       }
+
        /*** Objects ***/
 
        /* Read the item count */
@@ -2725,7 +2750,7 @@ static errr rd_saved_floor(saved_floor_type *sf_ptr)
        u32b tmp32u;
        u16b limit;
 
-       cave_template_type *template;
+       cave_template_type *templates;
 
 
        /*** Wipe all cave ***/
@@ -2792,12 +2817,12 @@ static errr rd_saved_floor(saved_floor_type *sf_ptr)
        rd_u16b(&limit);
 
        /* Allocate the "template" array */
-       C_MAKE(template, limit, cave_template_type);
+       C_MAKE(templates, limit, cave_template_type);
 
        /* Read the templates */
        for (i = 0; i < limit; i++)
        {
-               cave_template_type *ct_ptr = &template[i];
+               cave_template_type *ct_ptr = &templates[i];
 
                /* Read it */
                rd_u16b(&ct_ptr->info);
@@ -2845,10 +2870,10 @@ static errr rd_saved_floor(saved_floor_type *sf_ptr)
                        cave_type *c_ptr = &cave[y][x];
 
                        /* Extract cave data */
-                       c_ptr->info = template[id].info;
-                       c_ptr->feat = template[id].feat;
-                       c_ptr->mimic = template[id].mimic;
-                       c_ptr->special = template[id].special;
+                       c_ptr->info = templates[id].info;
+                       c_ptr->feat = templates[id].feat;
+                       c_ptr->mimic = templates[id].mimic;
+                       c_ptr->special = templates[id].special;
 
                        /* Advance/Wrap */
                        if (++x >= xmax)
@@ -2862,8 +2887,37 @@ static errr rd_saved_floor(saved_floor_type *sf_ptr)
                }
        }
 
+       /* Quest 18 was removed */
+       if (h_older_than(1, 7, 0, 6) && !vanilla_town)
+       {
+               for (y = 0; y < ymax; y++) for (x = 0; x < xmax; x++)
+               {
+                       /* Access the cave */
+                       cave_type *c_ptr = &cave[y][x];
+
+                       if ((c_ptr->special == OLD_QUEST_WATER_CAVE) && !dun_level)
+                       {
+                               if (c_ptr->feat == OLD_FEAT_QUEST_ENTER)
+                               {
+                                       c_ptr->feat = feat_tree;
+                                       c_ptr->special = 0;
+                               }
+                               else if (c_ptr->feat == OLD_FEAT_BLDG_1)
+                               {
+                                       c_ptr->special = lite_town ? QUEST_OLD_CASTLE : QUEST_ROYAL_CRYPT;
+                               }
+                       }
+                       else if ((c_ptr->feat == OLD_FEAT_QUEST_EXIT) &&
+                                (p_ptr->inside_quest == OLD_QUEST_WATER_CAVE))
+                       {
+                               c_ptr->feat = feat_up_stair;
+                               c_ptr->special = 0;
+                       }
+               }
+       }
+
        /* Free the "template" array */
-       C_FREE(template, limit, cave_template_type);
+       C_KILL(templates, limit, cave_template_type);
 
 
        /*** Objects ***/
@@ -3378,46 +3432,58 @@ note(format("
                {
                        if (i < max_quests)
                        {
-                               rd_s16b(&quest[i].status);
-                               rd_s16b(&quest[i].level);
+                               quest_type* const q_ptr = &quest[i];
+                               
+                               rd_s16b(&q_ptr->status);
+                               rd_s16b(&q_ptr->level);
 
                                if (z_older_than(11, 0, 6))
                                {
-                                       quest[i].complev = 0;
+                                       q_ptr->complev = 0;
+                               }
+                               else
+                               {
+                                       rd_byte(&q_ptr->complev);
+                               }
+                               if(h_older_than(2, 1, 2, 2))
+                               {
+                                       q_ptr->comptime = 0;
                                }
                                else
                                {
-                                       rd_byte(&quest[i].complev);
+                                       rd_u32b(&q_ptr->comptime);
                                }
 
                                /* Load quest status if quest is running */
-                               if (quest[i].status == QUEST_STATUS_TAKEN || (!z_older_than(10, 3, 14) && (quest[i].status == QUEST_STATUS_COMPLETED)) || (!z_older_than(11, 0, 7) && (i >= MIN_RANDOM_QUEST) && (i <= (MIN_RANDOM_QUEST+max_rquests_load))))
+                               if ((q_ptr->status == QUEST_STATUS_TAKEN) ||
+                                   (!z_older_than(10, 3, 14) && (q_ptr->status == QUEST_STATUS_COMPLETED)) ||
+                                   (!z_older_than(11, 0, 7) && (i >= MIN_RANDOM_QUEST) && (i <= (MIN_RANDOM_QUEST + max_rquests_load))))
                                {
-                                       rd_s16b(&quest[i].cur_num);
-                                       rd_s16b(&quest[i].max_num);
-                                       rd_s16b(&quest[i].type);
+                                       rd_s16b(&q_ptr->cur_num);
+                                       rd_s16b(&q_ptr->max_num);
+                                       rd_s16b(&q_ptr->type);
 
                                        /* Load quest monster index */
-                                       rd_s16b(&quest[i].r_idx);
+                                       rd_s16b(&q_ptr->r_idx);
 
-                                       if ((quest[i].type == QUEST_TYPE_RANDOM) && (!quest[i].r_idx))
+                                       if ((q_ptr->type == QUEST_TYPE_RANDOM) && (!q_ptr->r_idx))
                                        {
                                                determine_random_questor(&quest[i]);
                                        }
 
                                        /* Load quest item index */
-                                       rd_s16b(&quest[i].k_idx);
+                                       rd_s16b(&q_ptr->k_idx);
 
-                                       if (quest[i].k_idx)
-                                               a_info[quest[i].k_idx].gen_flags |= TRG_QUESTITEM;
+                                       if (q_ptr->k_idx)
+                                               a_info[q_ptr->k_idx].gen_flags |= TRG_QUESTITEM;
 
-                                       rd_byte(&quest[i].flags);
+                                       rd_byte(&q_ptr->flags);
 
                                        if (z_older_than(10, 3, 11))
                                        {
-                                               if (quest[i].flags & QUEST_FLAG_PRESET)
+                                               if (q_ptr->flags & QUEST_FLAG_PRESET)
                                                {
-                                                       quest[i].dungeon = 0;
+                                                       q_ptr->dungeon = 0;
                                                }
                                                else
                                                {
@@ -3430,12 +3496,12 @@ note(format("
                                        }
                                        else
                                        {
-                                               rd_byte(&quest[i].dungeon);
+                                               rd_byte(&q_ptr->dungeon);
                                        }
                                        /* Mark uniques */
-                                       if (quest[i].status == QUEST_STATUS_TAKEN || quest[i].status == QUEST_STATUS_UNTAKEN)
-                                               if (r_info[quest[i].r_idx].flags1 & RF1_UNIQUE)
-                                                       r_info[quest[i].r_idx].flags1 |= RF1_QUESTOR;
+                                       if (q_ptr->status == QUEST_STATUS_TAKEN || q_ptr->status == QUEST_STATUS_UNTAKEN)
+                                               if (r_info[q_ptr->r_idx].flags1 & RF1_UNIQUE)
+                                                       r_info[q_ptr->r_idx].flags1 |= RF1_QUESTOR;
                                }
                        }
                        /* Ignore the empty quests from old versions */
@@ -3454,6 +3520,13 @@ note(format("
                        }
                }
 
+               /* Quest 18 was removed */
+               if (h_older_than(1, 7, 0, 6))
+               {
+                       (void)WIPE(&quest[OLD_QUEST_WATER_CAVE], quest_type);
+                       quest[OLD_QUEST_WATER_CAVE].status = QUEST_STATUS_UNTAKEN;
+               }
+
                /* Position in the wilderness */
                rd_s32b(&p_ptr->wilderness_x);
                rd_s32b(&p_ptr->wilderness_y);
@@ -3761,6 +3834,17 @@ note("
                }
        }
 
+       /* Quest 18 was removed */
+       if (h_older_than(1, 7, 0, 6))
+       {
+               if (p_ptr->inside_quest == OLD_QUEST_WATER_CAVE)
+               {
+                       dungeon_type = lite_town ? DUNGEON_ANGBAND : DUNGEON_GALGALS;
+                       dun_level = 1;
+                       p_ptr->inside_quest = 0;
+               }
+       }
+
 
 #ifdef VERIFY_CHECKSUMS