OSDN Git Service

Save damages dealt by player for each monster. (Do not use yet)
[hengband/hengband.git] / src / dungeon.c
index da2cf72..d984c7d 100644 (file)
@@ -313,6 +313,7 @@ static void sense_inventory1(void)
                }
 
                case CLASS_PALADIN:
+               case CLASS_SNIPER:
                {
                        /* Bad sensing */
                        if (0 != randint0(77777L / (plev * plev + 40))) return;
@@ -476,6 +477,7 @@ static void sense_inventory2(void)
                case CLASS_SAMURAI:
                case CLASS_CAVALRY:
                case CLASS_BERSERKER:
+               case CLASS_SNIPER:
                {
                        return;
                }
@@ -639,9 +641,8 @@ static void pattern_teleport(void)
 #else
        else if (get_check("Normal teleport? "))
 #endif
-
        {
-               teleport_player(200, FALSE);
+               teleport_player(200, 0L);
                return;
        }
        else
@@ -689,7 +690,7 @@ static void pattern_teleport(void)
 static void wreck_the_pattern(void)
 {
        int to_ruin = 0, r_y, r_x;
-       int pattern_type = f_info[cave[py][px].feat].power;
+       int pattern_type = f_info[cave[py][px].feat].subtype;
 
        if (pattern_type == PATTERN_TILE_WRECKED)
        {
@@ -719,13 +720,13 @@ static void wreck_the_pattern(void)
                scatter(&r_y, &r_x, py, px, 4, 0);
 
                if (pattern_tile(r_y, r_x) &&
-                   (f_info[cave[r_y][r_x].feat].power != PATTERN_TILE_WRECKED))
+                   (f_info[cave[r_y][r_x].feat].subtype != PATTERN_TILE_WRECKED))
                {
-                       cave_set_feat(r_y, r_x, FEAT_PATTERN_XTRA2);
+                       cave_set_feat(r_y, r_x, feat_pattern_corrupted);
                }
        }
 
-       cave_set_feat(py, px, FEAT_PATTERN_XTRA2);
+       cave_set_feat(py, px, feat_pattern_corrupted);
 }
 
 
@@ -742,7 +743,7 @@ static bool pattern_effect(void)
                wreck_the_pattern();
        }
 
-       pattern_type = f_info[cave[py][px].feat].power;
+       pattern_type = f_info[cave[py][px].feat].subtype;
 
        switch (pattern_type)
        {
@@ -762,7 +763,7 @@ static bool pattern_effect(void)
                (void)restore_level();
                (void)hp_player(1000);
 
-               cave_set_feat(py, px, FEAT_PATTERN_OLD);
+               cave_set_feat(py, px, feat_pattern_old);
 
 #ifdef JP
                msg_print("¡Ö¥Ñ¥¿¡¼¥ó¡×¤Î¤³¤ÎÉôʬ¤Ï¾¤ÎÉôʬ¤è¤ê¶¯ÎϤǤʤ¤¤è¤¦¤À¡£");
@@ -868,9 +869,10 @@ static void regenhp(int percent)
 /*
  * Regenerate mana points
  */
-static void regenmana(int percent)
+static void regenmana(int upkeep_factor, int regen_amount)
 {
        s32b old_csp = p_ptr->csp;
+       s32b regen_rate = regen_amount * 100 - upkeep_factor * PY_REGEN_NORMAL;
 
        /*
         * Excess mana will decay 32 times faster than normal
@@ -897,11 +899,11 @@ static void regenmana(int percent)
        }
 
        /* Regenerating mana (unless the player has excess mana) */
-       else if (percent > 0)
+       else if (regen_rate > 0)
        {
                /* (percent/100) is the Regen factor in unit (1/2^16) */
                s32b new_mana = 0;
-               u32b new_mana_frac = (p_ptr->msp * percent / 100 + PY_REGEN_MNBASE);
+               u32b new_mana_frac = (p_ptr->msp * regen_rate / 100 + PY_REGEN_MNBASE);
 
                /* Convert the unit (1/2^16) to (1/2^32) */
                s64b_LSHIFT(new_mana, new_mana_frac, 16);
@@ -919,11 +921,11 @@ static void regenmana(int percent)
 
 
        /* Reduce mana (even when the player has excess mana) */
-       if (percent < 0)
+       if (regen_rate < 0)
        {
                /* PY_REGEN_NORMAL is the Regen factor in unit (1/2^16) */
                s32b reduce_mana = 0;
-               u32b reduce_mana_frac = (p_ptr->msp * PY_REGEN_NORMAL + PY_REGEN_MNBASE);
+               u32b reduce_mana_frac = (p_ptr->msp * (-1) * regen_rate / 100 + PY_REGEN_MNBASE);
 
                /* Convert the unit (1/2^16) to (1/2^32) */
                s64b_LSHIFT(reduce_mana, reduce_mana_frac, 16);
@@ -958,17 +960,22 @@ static void regenmana(int percent)
 
 /*
  * Regenerate magic
+ * regen_amount: PY_REGEN_NORMAL * 2 (if resting) * 2 (if having regenarate)
  */
-static void regenmagic(int percent)
+static void regenmagic(int regen_amount)
 {
-       s32b        new_mana;
+       s32b new_mana;
        int i;
+       int dev = 30;
+       int mult = (dev + adj_mag_mana[p_ptr->stat_ind[A_INT]]); /* x1 to x2 speed bonus for recharging */
 
        for (i = 0; i < EATER_EXT*2; i++)
        {
                if (!p_ptr->magic_num2[i]) continue;
                if (p_ptr->magic_num1[i] == ((long)p_ptr->magic_num2[i] << 16)) continue;
-               new_mana = ((long)p_ptr->magic_num2[i]+adj_mag_mana[A_INT]+13) * percent / 8;
+
+               /* Increase remaining charge number like float value */
+               new_mana = (regen_amount * mult * ((long)p_ptr->magic_num2[i] + 13)) / (dev * 8);
                p_ptr->magic_num1[i] += new_mana;
 
                /* Check maximum charge */
@@ -982,7 +989,13 @@ static void regenmagic(int percent)
        {
                if (!p_ptr->magic_num1[i]) continue;
                if (!p_ptr->magic_num2[i]) continue;
-               p_ptr->magic_num1[i] -= (long)(p_ptr->magic_num2[i] * (adj_mag_mana[A_INT] + 10)) * EATER_ROD_CHARGE/16;
+
+               /* Decrease remaining period for charging */
+               new_mana = (regen_amount * mult * ((long)p_ptr->magic_num2[i] + 10) * EATER_ROD_CHARGE) 
+                                       / (dev * 16 * PY_REGEN_NORMAL); 
+               p_ptr->magic_num1[i] -= new_mana;
+
+               /* Check minimum remaining period for charging */
                if (p_ptr->magic_num1[i] < 0) p_ptr->magic_num1[i] = 0;
                wild_regen = 20;
        }
@@ -1097,349 +1110,6 @@ static void regen_captured_monsters(void)
 }
 
 
-/*
- * Process the counters of monsters (once per 10 game turns)
- *
- * This function is to process monsters' counters same as player's.
- */
-static void process_monsters_counters(void)
-{
-       int          m_idx;
-       monster_type *m_ptr;
-       monster_race *r_ptr;
-       bool         see_m;
-
-       u32b noise; /* Hack -- local "player stealth" value */
-
-       /* Handle "leaving" */
-       if (p_ptr->leaving) return;
-
-       /* Hack -- calculate the "player noise" */
-       noise = (1L << (30 - p_ptr->skill_stl));
-
-       /* Process the monsters (backwards) */
-       for (m_idx = m_max - 1; m_idx >= 1; m_idx--)
-       {
-               /* Access the monster */
-               m_ptr = &m_list[m_idx];
-               r_ptr = &r_info[m_ptr->r_idx];
-
-               /* Ignore "dead" monsters */
-               if (!m_ptr->r_idx) continue;
-
-               see_m = is_seen(m_ptr);
-
-               /* Handle Invulnerability */
-               if (m_ptr->invulner)
-               {
-                       /* Reduce by one, note if expires */
-                       m_ptr->invulner--;
-
-                       if (!m_ptr->invulner)
-                       {
-                               if (see_m)
-                               {
-                                       char m_name[80];
-
-                                       /* Acquire the monster name */
-                                       monster_desc(m_name, m_ptr, 0);
-
-                                       /* Dump a message */
-#ifdef JP
-                                       msg_format("%^s¤Ï¤â¤¦ÌµÅ¨¤Ç¤Ê¤¤¡£", m_name);
-#else
-                                       msg_format("%^s is no longer invulnerable.", m_name);
-#endif
-                               }
-                               if (m_ptr->ml)
-                               {
-                                       if (p_ptr->health_who == m_idx) p_ptr->redraw |= (PR_HEALTH);
-                                       if (p_ptr->riding == m_idx) p_ptr->redraw |= (PR_UHEALTH);
-                               }
-                               if (!p_ptr->wild_mode) m_ptr->energy_need += ENERGY_NEED();
-                       }
-               }
-
-               /* Handle fast */
-               if (m_ptr->fast)
-               {
-                       /* Reduce by one, note if expires */
-                       m_ptr->fast--;
-
-                       if (!m_ptr->fast)
-                       {
-                               if (see_m)
-                               {
-                                       char m_name[80];
-
-                                       /* Acquire the monster name */
-                                       monster_desc(m_name, m_ptr, 0);
-
-                                       /* Dump a message */
-#ifdef JP
-                                       msg_format("%^s¤Ï¤â¤¦²Ã®¤µ¤ì¤Æ¤¤¤Ê¤¤¡£", m_name);
-#else
-                                       msg_format("%^s is no longer fast.", m_name);
-#endif
-                               }
-                               if (p_ptr->riding == m_idx) p_ptr->update |= (PU_BONUS);
-                       }
-               }
-
-               /* Handle slow */
-               if (m_ptr->slow)
-               {
-                       /* Reduce by one, note if expires */
-                       m_ptr->slow--;
-
-                       if (!m_ptr->slow)
-                       {
-                               if (see_m)
-                               {
-                                       char m_name[80];
-
-                                       /* Acquire the monster name */
-                                       monster_desc(m_name, m_ptr, 0);
-
-                                       /* Dump a message */
-#ifdef JP
-                                       msg_format("%^s¤Ï¤â¤¦¸ºÂ®¤µ¤ì¤Æ¤¤¤Ê¤¤¡£", m_name);
-#else
-                                       msg_format("%^s is no longer slow.", m_name);
-#endif
-                               }
-                               if (p_ptr->riding == m_idx) p_ptr->update |= (PU_BONUS);
-                       }
-               }
-
-               /* Handle "sleep" */
-               if (m_ptr->csleep)
-               {
-                       /* Assume does not wake up */
-                       bool test = FALSE;
-
-                       /* Hack -- Require proximity */
-                       if (m_ptr->cdis < AAF_LIMIT)
-                       {
-                               /* Handle "sensing radius" */
-                               if (m_ptr->cdis <= (is_pet(m_ptr) ? ((r_ptr->aaf > MAX_SIGHT) ? MAX_SIGHT : r_ptr->aaf) : r_ptr->aaf))
-                               {
-                                       /* We may wake up */
-                                       test = TRUE;
-                               }
-
-                               /* Handle "sight" and "aggravation" */
-                               else if ((m_ptr->cdis <= MAX_SIGHT) && (player_has_los_bold(m_ptr->fy, m_ptr->fx)))
-                               {
-                                       /* We may wake up */
-                                       test = TRUE;
-                               }
-                       }
-
-                       if (test)
-                       {
-                               u32b notice = randint0(1024);
-
-                               /* Nightmare monsters are more alert */
-                               if (ironman_nightmare) notice /= 2;
-
-                               /* Hack -- See if monster "notices" player */
-                               if ((notice * notice * notice) <= noise)
-                               {
-                                       /* Hack -- amount of "waking" */
-                                       /* Wake up faster near the player */
-                                       int d = (m_ptr->cdis < AAF_LIMIT / 2) ? (AAF_LIMIT / m_ptr->cdis) : 1;
-
-                                       /* Hack -- amount of "waking" is affected by speed of player */
-                                       d = (d * SPEED_TO_ENERGY(p_ptr->pspeed)) / 10;
-                                       if (d < 0) d = 1;
-
-                                       /* Still asleep */
-                                       if (m_ptr->csleep > d)
-                                       {
-                                               /* Monster wakes up "a little bit" */
-                                               m_ptr->csleep -= d;
-
-                                               /* Notice the "not waking up" */
-                                               if (is_original_ap_and_seen(m_ptr))
-                                               {
-                                                       /* Hack -- Count the ignores */
-                                                       if (r_ptr->r_ignore < MAX_UCHAR) r_ptr->r_ignore++;
-                                               }
-                                       }
-
-                                       /* Just woke up */
-                                       else
-                                       {
-                                               /* Reset sleep counter */
-                                               m_ptr->csleep = 0;
-
-                                               if (r_ptr->flags7 & RF7_HAS_LD_MASK) p_ptr->update |= (PU_MON_LITE);
-
-                                               /* Notice the "waking up" */
-                                               if (see_m)
-                                               {
-                                                       char m_name[80];
-
-                                                       /* Acquire the monster name */
-                                                       monster_desc(m_name, m_ptr, 0);
-
-                                                       /* Dump a message */
-#ifdef JP
-                                                       msg_format("%^s¤¬Ìܤò³Ð¤Þ¤·¤¿¡£", m_name);
-#else
-                                                       msg_format("%^s wakes up.", m_name);
-#endif
-                                               }
-
-                                               if (m_ptr->ml)
-                                               {
-                                                       /* Redraw the health bar */
-                                                       if (p_ptr->health_who == m_idx) p_ptr->redraw |= (PR_HEALTH);
-                                                       if (p_ptr->riding == m_idx) p_ptr->redraw |= (PR_UHEALTH);
-
-                                                       /* Hack -- Count the wakings */
-                                                       if ((r_ptr->r_wake < MAX_UCHAR) && is_original_ap(m_ptr))
-                                                       {
-                                                               r_ptr->r_wake++;
-                                                       }
-                                               }
-                                       }
-                               }
-                       }
-               }
-
-               /* Handle "stun" */
-               if (m_ptr->stunned)
-               {
-                       int d = 1;
-
-                       /* Make a "saving throw" against stun */
-                       if (randint0(10000) <= r_ptr->level * r_ptr->level)
-                       {
-                               /* Recover fully */
-                               d = m_ptr->stunned;
-                       }
-
-                       /* Hack -- Recover from stun */
-                       if (m_ptr->stunned > d)
-                       {
-                               /* Recover somewhat */
-                               m_ptr->stunned -= d;
-                       }
-
-                       /* Fully recover */
-                       else
-                       {
-                               /* Recover fully */
-                               m_ptr->stunned = 0;
-
-                               /* Message if visible */
-                               if (see_m)
-                               {
-                                       char m_name[80];
-
-                                       /* Acquire the monster name */
-                                       monster_desc(m_name, m_ptr, 0);
-
-                                       /* Dump a message */
-#ifdef JP
-                                       msg_format("%^s¤ÏÛ¯Û°¾õÂÖ¤«¤éΩ¤Áľ¤Ã¤¿¡£", m_name);
-#else
-                                       msg_format("%^s is no longer stunned.", m_name);
-#endif
-                               }
-                       }
-               }
-
-               /* Handle confusion */
-               if (m_ptr->confused)
-               {
-                       /* Amount of "boldness" */
-                       int d = randint1(r_ptr->level / 20 + 1);
-
-                       /* Still confused */
-                       if (m_ptr->confused > d)
-                       {
-                               /* Reduce the confusion */
-                               m_ptr->confused -= d;
-                       }
-
-                       /* Recovered */
-                       else
-                       {
-                               /* No longer confused */
-                               m_ptr->confused = 0;
-
-                               /* Message if visible */
-                               if (see_m)
-                               {
-                                       char m_name[80];
-
-                                       /* Acquire the monster name */
-                                       monster_desc(m_name, m_ptr, 0);
-
-                                       /* Dump a message */
-#ifdef JP
-                                       msg_format("%^s¤Ïº®Í𤫤éΩ¤Áľ¤Ã¤¿¡£", m_name);
-#else
-                                       msg_format("%^s is no longer confused.", m_name);
-#endif
-                               }
-                       }
-               }
-
-               /* Handle "fear" */
-               if (m_ptr->monfear)
-               {
-                       /* Amount of "boldness" */
-                       int d = randint1(r_ptr->level / 20 + 1);
-
-                       /* Still afraid */
-                       if (m_ptr->monfear > d)
-                       {
-                               /* Reduce the fear */
-                               m_ptr->monfear -= d;
-                       }
-
-                       /* Recover from fear, take note if seen */
-                       else
-                       {
-                               /* No longer afraid */
-                               m_ptr->monfear = 0;
-
-                               /* Visual note */
-                               if (see_m)
-                               {
-                                       char m_name[80];
-#ifndef JP
-                                       char m_poss[80];
-
-                                       /* Acquire the monster possessive */
-                                       monster_desc(m_poss, m_ptr, MD_PRON_VISIBLE | MD_POSSESSIVE);
-#endif
-
-                                       /* Acquire the monster name */
-                                       monster_desc(m_name, m_ptr, 0);
-
-                                       /* Dump a message */
-#ifdef JP
-                                       msg_format("%^s¤Ïͦµ¤¤ò¼è¤êÌᤷ¤¿¡£", m_name);
-#else
-                                       msg_format("%^s recovers %s courage.", m_name, m_poss);
-#endif
-                               }
-                               if (m_ptr->ml)
-                               {
-                                       if (p_ptr->health_who == m_idx) p_ptr->redraw |= (PR_HEALTH);
-                                       if (p_ptr->riding == m_idx) p_ptr->redraw |= (PR_UHEALTH);
-                               }
-                       }
-               }
-       }
-}
-
-
 static void notice_lite_change(object_type *o_ptr)
 {
        /* Hack -- notice interesting fuel steps */
@@ -1459,7 +1129,7 @@ static void notice_lite_change(object_type *o_ptr)
        /* The light is now out */
        else if (o_ptr->xtra4 == 0)
        {
-               disturb(0, 0);
+               disturb(0, 1);
 #ifdef JP
 msg_print("ÌÀ¤«¤ê¤¬¾Ã¤¨¤Æ¤·¤Þ¤Ã¤¿¡ª");
 #else
@@ -1479,7 +1149,7 @@ msg_print("
                if ((o_ptr->xtra4 < 50) && (!(o_ptr->xtra4 % 5))
                    && (turn % (TURNS_PER_TICK*2)))
                {
-                       if (disturb_minor) disturb(0, 0);
+                       if (disturb_minor) disturb(0, 1);
 #ifdef JP
 msg_print("ÌÀ¤«¤ê¤¬Èù¤«¤Ë¤Ê¤Ã¤Æ¤­¤Æ¤¤¤ë¡£");
 #else
@@ -1492,7 +1162,7 @@ msg_print("
        /* The light is getting dim */
        else if ((o_ptr->xtra4 < 100) && (!(o_ptr->xtra4 % 10)))
        {
-               if (disturb_minor) disturb(0, 0);
+               if (disturb_minor) disturb(0, 1);
 #ifdef JP
 msg_print("ÌÀ¤«¤ê¤¬Èù¤«¤Ë¤Ê¤Ã¤Æ¤­¤Æ¤¤¤ë¡£");
 #else
@@ -1515,17 +1185,50 @@ void leave_quest_check(void)
        {
                quest[leaving_quest].status = QUEST_STATUS_FAILED;
                quest[leaving_quest].complev = (byte)p_ptr->lev;
-               if (quest[leaving_quest].type == QUEST_TYPE_RANDOM)
+
+               /* Additional settings */
+               switch (quest[leaving_quest].type)
                {
+               case QUEST_TYPE_TOWER:
+                       quest[QUEST_TOWER1].status = QUEST_STATUS_FAILED;
+                       quest[QUEST_TOWER1].complev = (byte)p_ptr->lev;
+                       break;
+               case QUEST_TYPE_FIND_ARTIFACT:
+                       a_info[quest[leaving_quest].k_idx].gen_flags &= ~(TRG_QUESTITEM);
+                       break;
+               case QUEST_TYPE_RANDOM:
                        r_info[quest[leaving_quest].r_idx].flags1 &= ~(RF1_QUESTOR);
-                       if (record_rand_quest)
-                               do_cmd_write_nikki(NIKKI_RAND_QUEST_F, leaving_quest, NULL);
 
                        /* Floor of random quest will be blocked */
                        prepare_change_floor_mode(CFM_NO_RETURN);
+                       break;
+               }
+
+               /* Record finishing a quest */
+               if (quest[leaving_quest].type == QUEST_TYPE_RANDOM)
+               {
+                       if (record_rand_quest) do_cmd_write_nikki(NIKKI_RAND_QUEST_F, leaving_quest, NULL);
+               }
+               else
+               {
+                       if (record_fix_quest) do_cmd_write_nikki(NIKKI_FIX_QUEST_F, leaving_quest, NULL);
+               }
+       }
+}
+
+void leave_tower_check(void)
+{
+       leaving_quest = p_ptr->inside_quest;
+       /* Check for Tower Quest */
+       if (leaving_quest &&
+               (quest[leaving_quest].type == QUEST_TYPE_TOWER) &&
+               (quest[QUEST_TOWER1].status != QUEST_STATUS_COMPLETED))
+       {
+               if(quest[leaving_quest].type == QUEST_TYPE_TOWER)
+               {
+                       quest[QUEST_TOWER1].status = QUEST_STATUS_FAILED;
+                       quest[QUEST_TOWER1].complev = (byte)p_ptr->lev;
                }
-               else if (record_fix_quest)
-                       do_cmd_write_nikki(NIKKI_FIX_QUEST_F, leaving_quest, NULL);
        }
 }
 
@@ -1621,6 +1324,9 @@ msg_format("%s
        /* "Inscribe" it */
        o_ptr->feeling = feel;
 
+       /* Player touches it */
+       o_ptr->marked |= OM_TOUCHED;
+
        /* Combine / Reorder the pack (later) */
        p_ptr->notice |= (PN_COMBINE | PN_REORDER);
 
@@ -1713,7 +1419,7 @@ static void recharged_notice(object_type *o_ptr)
 
 static void check_music(void)
 {
-       magic_type *s_ptr;
+       const magic_type *s_ptr;
        int spell;
        s32b need_mana;
        u32b need_mana_frac;
@@ -1805,6 +1511,17 @@ static object_type *choose_cursed_obj_name(u32b flag)
                        choices[number] = i;
                        number++;
                }
+               else if ((flag == TRC_ADD_L_CURSE) || (flag == TRC_ADD_H_CURSE))
+               {
+                       u32b cf = (flag == TRC_ADD_L_CURSE) ? TR_ADD_L_CURSE : TR_ADD_H_CURSE;
+                       u32b flgs[4];
+                       object_flags(o_ptr, flgs);
+                       if (have_flag(flgs, cf))
+                       {
+                               choices[number] = i;
+                               number++;
+                       }
+               }
        }
 
        /* Choice one of them */
@@ -1820,7 +1537,6 @@ static void process_world_aux_hp_and_sp(void)
        feature_type *f_ptr = &f_info[cave[py][px].feat];
        bool cave_no_regen = FALSE;
        int upkeep_factor = 0;
-       int upkeep_regen;
 
        /* Default regeneration */
        int regen_amount = PY_REGEN_NORMAL;
@@ -2159,8 +1875,7 @@ take_hit(DAMAGE_NOESCAPE, damage, "
        }
 
        /* Regenerate the mana */
-       upkeep_regen = (100 - upkeep_factor) * regen_amount;
-       regenmana(upkeep_regen);
+       regenmana(upkeep_factor, regen_amount);
 
 
        /* Recharge magic eater's power */
@@ -2565,7 +2280,7 @@ static void process_world_aux_mutation(void)
 
        if ((p_ptr->muta2 & MUT2_BERS_RAGE) && one_in_(3000))
        {
-               disturb(0, 0);
+               disturb(0, 1);
 #ifdef JP
                msg_print("¥¦¥¬¥¡¥¡¥¢¡ª");
                msg_print("·ãÅܤÎȯºî¤Ë½±¤ï¤ì¤¿¡ª");
@@ -2575,13 +2290,14 @@ static void process_world_aux_mutation(void)
 #endif
 
                (void)set_shero(10 + randint1(p_ptr->lev), FALSE);
+               (void)set_afraid(0);
        }
 
        if ((p_ptr->muta2 & MUT2_COWARDICE) && (randint1(3000) == 13))
        {
                if (!p_ptr->resist_fear)
                {
-                       disturb(0, 0);
+                       disturb(0, 1);
 #ifdef JP
                        msg_print("¤È¤Æ¤â°Å¤¤... ¤È¤Æ¤â¶²¤¤¡ª");
 #else
@@ -2597,7 +2313,7 @@ static void process_world_aux_mutation(void)
                if (!p_ptr->resist_nexus && !(p_ptr->muta1 & MUT1_VTELEPORT) &&
                    !p_ptr->anti_tele)
                {
-                       disturb(0, 0);
+                       disturb(0, 1);
 
                        /* Teleport player */
 #ifdef JP
@@ -2607,7 +2323,7 @@ static void process_world_aux_mutation(void)
 #endif
 
                        msg_print(NULL);
-                       teleport_player(40, TRUE);
+                       teleport_player(40, TELEPORT_PASSIVE);
                }
        }
 
@@ -2615,7 +2331,7 @@ static void process_world_aux_mutation(void)
        {
                if (!p_ptr->resist_conf && !p_ptr->resist_chaos)
                {
-                       disturb(0, 0);
+                       disturb(0, 1);
                        p_ptr->redraw |= PR_EXTRA;
 #ifdef JP
                        msg_print("¤¤¤Ò¤­¤¬¤â¡¼¤í¡¼¤È¤Ò¤Æ¤­¤¿¤­¤¬¤Õ¤ë...¥Ò¥Ã¥¯¡ª");
@@ -2637,7 +2353,7 @@ static void process_world_aux_mutation(void)
                                msg_print(NULL);
                                if (one_in_(3)) lose_all_info();
                                else wiz_dark();
-                               teleport_player(100, TRUE);
+                               (void)teleport_player_aux(100, TELEPORT_NONMAGICAL | TELEPORT_PASSIVE);
                                wiz_dark();
 #ifdef JP
                                msg_print("¤¢¤Ê¤¿¤Ï¸«ÃΤé¤Ì¾ì½ê¤ÇÌܤ¬Àä᤿...Ƭ¤¬Äˤ¤¡£");
@@ -2668,7 +2384,7 @@ static void process_world_aux_mutation(void)
        {
                if (!p_ptr->resist_chaos)
                {
-                       disturb(0, 0);
+                       disturb(0, 1);
                        p_ptr->redraw |= PR_EXTRA;
                        (void)set_image(p_ptr->image + randint0(50) + 20);
                }
@@ -2676,7 +2392,7 @@ static void process_world_aux_mutation(void)
 
        if ((p_ptr->muta2 & MUT2_FLATULENT) && (randint1(3000) == 13))
        {
-               disturb(0, 0);
+               disturb(0, 1);
 
 #ifdef JP
                msg_print("¥Ö¥¥¡¼¡¼¥Ã¡ª¤ª¤Ã¤È¡£");
@@ -2692,7 +2408,7 @@ static void process_world_aux_mutation(void)
            !p_ptr->anti_magic && one_in_(9000))
        {
                int dire = 0;
-               disturb(0, 0);
+               disturb(0, 1);
 #ifdef JP
                msg_print("ËâË¡¤Î¥¨¥Í¥ë¥®¡¼¤¬ÆÍÁ³¤¢¤Ê¤¿¤ÎÃæ¤Ëή¤ì¹þ¤ó¤Ç¤­¤¿¡ª¥¨¥Í¥ë¥®¡¼¤ò²òÊü¤·¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡ª");
 #else
@@ -2723,13 +2439,13 @@ static void process_world_aux_mutation(void)
                        msg_print("You have attracted a demon!");
 #endif
 
-                       disturb(0, 0);
+                       disturb(0, 1);
                }
        }
 
        if ((p_ptr->muta2 & MUT2_SPEED_FLUX) && one_in_(6000))
        {
-               disturb(0, 0);
+               disturb(0, 1);
                if (one_in_(2))
                {
 #ifdef JP
@@ -2768,7 +2484,7 @@ static void process_world_aux_mutation(void)
        }
        if ((p_ptr->muta2 & MUT2_BANISH_ALL) && one_in_(9000))
        {
-               disturb(0, 0);
+               disturb(0, 1);
 #ifdef JP
                msg_print("ÆÍÁ³¤Û¤È¤ó¤É¸ÉÆȤˤʤ俵¤¤¬¤¹¤ë¡£");
 #else
@@ -2866,14 +2582,14 @@ static void process_world_aux_mutation(void)
                        msg_print("You have attracted an animal!");
 #endif
 
-                       disturb(0, 0);
+                       disturb(0, 1);
                }
        }
 
        if ((p_ptr->muta2 & MUT2_RAW_CHAOS) &&
            !p_ptr->anti_magic && one_in_(8000))
        {
-               disturb(0, 0);
+               disturb(0, 1);
 #ifdef JP
                msg_print("¼þ¤ê¤Î¶õ´Ö¤¬ÏĤó¤Ç¤¤¤ëµ¤¤¬¤¹¤ë¡ª");
 #else
@@ -2895,7 +2611,7 @@ static void process_world_aux_mutation(void)
        }
        if ((p_ptr->muta2 & MUT2_WRAITH) && !p_ptr->anti_magic && one_in_(3000))
        {
-               disturb(0, 0);
+               disturb(0, 1);
 #ifdef JP
                msg_print("Èóʪ¼Á²½¤·¤¿¡ª");
 #else
@@ -2946,7 +2662,7 @@ static void process_world_aux_mutation(void)
 
                if (!sustained)
                {
-                       disturb(0, 0);
+                       disturb(0, 1);
 #ifdef JP
                        msg_print("¼«Ê¬¤¬¿ê¼å¤·¤Æ¤¤¤¯¤Î¤¬Ê¬¤«¤ë¡ª");
 #else
@@ -2974,7 +2690,7 @@ static void process_world_aux_mutation(void)
                        msg_print("You have attracted a dragon!");
 #endif
 
-                       disturb(0, 0);
+                       disturb(0, 1);
                }
        }
        if ((p_ptr->muta2 & MUT2_WEIRD_MIND) && !p_ptr->anti_magic &&
@@ -3004,7 +2720,7 @@ static void process_world_aux_mutation(void)
        if ((p_ptr->muta2 & MUT2_NAUSEA) && !p_ptr->slow_digest &&
            one_in_(9000))
        {
-               disturb(0, 0);
+               disturb(0, 1);
 #ifdef JP
                msg_print("°ß¤¬áÛÚ»¤·¡¢¿©»ö¤ò¼º¤Ã¤¿¡ª");
 #else
@@ -3013,6 +2729,8 @@ static void process_world_aux_mutation(void)
 
                msg_print(NULL);
                set_food(PY_FOOD_WEAK);
+               if (music_singing_any()) stop_singing();
+               if (hex_spelling_any()) stop_hex_spell_all();
        }
 
        if ((p_ptr->muta2 & MUT2_WALK_SHAD) &&
@@ -3086,7 +2804,7 @@ static void process_world_aux_mutation(void)
        if ((p_ptr->muta2 & MUT2_INVULN) && !p_ptr->anti_magic &&
            one_in_(5000))
        {
-               disturb(0, 0);
+               disturb(0, 1);
 #ifdef JP
                msg_print("̵Ũ¤Êµ¤¤¬¤¹¤ë¡ª");
 #else
@@ -3147,7 +2865,7 @@ static void process_world_aux_mutation(void)
                int slot = 0;
                object_type *o_ptr = NULL;
 
-               disturb(0, 0);
+               disturb(0, 1);
 #ifdef JP
                msg_print("­¤¬¤â¤Ä¤ì¤Æž¤ó¤À¡ª");
                take_hit(DAMAGE_NOESCAPE, randint1(p_ptr->wt / 6), "žÅÝ", -1);
@@ -3177,7 +2895,7 @@ static void process_world_aux_mutation(void)
                if (slot && !object_is_cursed(o_ptr))
                {
 #ifdef JP
-                       msg_print("Éð´ï¤òÍ¤Æ¤·¤Þ¤Ã¤¿¡ª");
+                       msg_print("Éð´ï¤òÍî¤Ȥ·¤Æ¤·¤Þ¤Ã¤¿¡ª");
 #else
                        msg_print("You drop your weapon!");
 #endif
@@ -3186,7 +2904,6 @@ static void process_world_aux_mutation(void)
        }
 }
 
-
 /*
  * Handle curse effects once every 10 game turns
  */
@@ -3202,23 +2919,32 @@ static void process_world_aux_curse(void)
                {
                        char o_name[MAX_NLEN];
                        object_type *o_ptr;
-                       int i;
+                       int i, i_keep = 0, count = 0;
 
                        /* Scan the equipment with random teleport ability */
                        for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
                        {
                                u32b flgs[TR_FLAG_SIZE];
                                o_ptr = &inventory[i];
-                               
+
                                /* Skip non-objects */
                                if (!o_ptr->k_idx) continue;
-                               
+
                                /* Extract the item flags */
                                object_flags(o_ptr, flgs);
-                               
-                               if (have_flag(flgs, TR_TELEPORT)) break;
+
+                               if (have_flag(flgs, TR_TELEPORT))
+                               {
+                                       /* {.} will stop random teleportation. */
+                                       if (!o_ptr->inscription || !my_strchr(quark_str(o_ptr->inscription), '.'))
+                                       {
+                                               count++;
+                                               if (one_in_(count)) i_keep = i;
+                                       }
+                               }
                        }
 
+                       o_ptr = &inventory[i_keep];
                        object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
 
 #ifdef JP
@@ -3233,8 +2959,8 @@ static void process_world_aux_curse(void)
                        if (get_check_strict("Teleport? ", CHECK_OKAY_CANCEL))
 #endif
                        {
-                               disturb(0, 0);
-                               teleport_player(50, FALSE);
+                               disturb(0, 1);
+                               teleport_player(50, 0L);
                        }
                        else
                        {
@@ -3243,7 +2969,7 @@ static void process_world_aux_curse(void)
 #else
                                msg_format("You can inscribe {.} on your %s to disable random teleportation. ", o_name);
 #endif
-                               disturb(1, 0);
+                               disturb(1, 1);
                        }
                }
                /* Make a chainsword noise */
@@ -3343,7 +3069,7 @@ static void process_world_aux_curse(void)
                                msg_format("Your %s have attracted an animal!", o_name);
 #endif
 
-                               disturb(0, 0);
+                               disturb(0, 1);
                        }
                }
                /* Call demon */
@@ -3360,7 +3086,7 @@ static void process_world_aux_curse(void)
                                msg_format("Your %s have attracted a demon!", o_name);
 #endif
 
-                               disturb(0, 0);
+                               disturb(0, 1);
                        }
                }
                /* Call dragon */
@@ -3378,14 +3104,14 @@ static void process_world_aux_curse(void)
                                msg_format("Your %s have attracted an animal!", o_name);
 #endif
 
-                               disturb(0, 0);
+                               disturb(0, 1);
                        }
                }
                if ((p_ptr->cursed & TRC_COWARDICE) && one_in_(1500))
                {
                        if (!p_ptr->resist_fear)
                        {
-                               disturb(0, 0);
+                               disturb(0, 1);
 #ifdef JP
                                msg_print("¤È¤Æ¤â°Å¤¤... ¤È¤Æ¤â¶²¤¤¡ª");
 #else
@@ -3398,10 +3124,10 @@ static void process_world_aux_curse(void)
                /* Teleport player */
                if ((p_ptr->cursed & TRC_TELEPORT) && one_in_(200) && !p_ptr->anti_tele)
                {
-                       disturb(0, 0);
+                       disturb(0, 1);
 
                        /* Teleport player */
-                       teleport_player(40, TRUE);
+                       teleport_player(40, TELEPORT_PASSIVE);
                }
                /* Handle HP draining */
                if ((p_ptr->cursed & TRC_DRAIN_HP) && one_in_(666))
@@ -3417,7 +3143,7 @@ static void process_world_aux_curse(void)
                        take_hit(DAMAGE_LOSELIFE, MIN(p_ptr->lev*2, 100), o_name, -1);
                }
                /* Handle mana draining */
-               if ((p_ptr->cursed & TRC_DRAIN_MANA) && one_in_(666))
+               if ((p_ptr->cursed & TRC_DRAIN_MANA) && p_ptr->csp && one_in_(666))
                {
                        char o_name[MAX_NLEN];
 
@@ -3598,18 +3324,15 @@ static void process_world_aux_movement(void)
                if (!p_ptr->word_recall)
                {
                        /* Disturbing! */
-                       disturb(0, 0);
+                       disturb(0, 1);
 
                        /* Determine the level */
-                       if (dun_level || p_ptr->inside_quest)
+                       if (dun_level || p_ptr->inside_quest || p_ptr->enter_dungeon)
                        {
-#ifdef JP
-msg_print("¾å¤Ë°ú¤ÃÄ¥¤ê¤¢¤²¤é¤ì¤ë´¶¤¸¤¬¤¹¤ë¡ª");
-#else
-                               msg_print("You feel yourself yanked upwards!");
-#endif
+                               msg_print(_("¾å¤Ë°ú¤ÃÄ¥¤ê¤¢¤²¤é¤ì¤ë´¶¤¸¤¬¤¹¤ë¡ª",
+                                                       "You feel yourself yanked upwards!"));
 
-                               p_ptr->recall_dungeon = dungeon_type;
+                               if (dungeon_type) p_ptr->recall_dungeon = dungeon_type;
                                if (record_stair)
                                        do_cmd_write_nikki(NIKKI_RECALL, dun_level, NULL);
 
@@ -3617,6 +3340,7 @@ msg_print("
                                dungeon_type = 0;
 
                                leave_quest_check();
+                               leave_tower_check();
 
                                p_ptr->inside_quest = 0;
 
@@ -3624,11 +3348,8 @@ msg_print("
                        }
                        else
                        {
-#ifdef JP
-msg_print("²¼¤Ë°ú¤­¤º¤ê¹ß¤í¤µ¤ì¤ë´¶¤¸¤¬¤¹¤ë¡ª");
-#else
-                               msg_print("You feel yourself yanked downwards!");
-#endif
+                               msg_print(_("²¼¤Ë°ú¤­¤º¤ê¹ß¤í¤µ¤ì¤ë´¶¤¸¤¬¤¹¤ë¡ª",
+                                                       "You feel yourself yanked downwards!"));
 
                                dungeon_type = p_ptr->recall_dungeon;
 
@@ -3678,72 +3399,312 @@ msg_print("
                                /* Leaving */
                                p_ptr->leaving = TRUE;
 
-                               if (dungeon_type == DUNGEON_ANGBAND)
-                               {
-                                       int i;
+                               if (dungeon_type == DUNGEON_ANGBAND)
+                               {
+                                       int i;
+
+                                       for (i = MIN_RANDOM_QUEST; i < MAX_RANDOM_QUEST + 1; i++)
+                                       {
+                                               if ((quest[i].type == QUEST_TYPE_RANDOM) &&
+                                                   (quest[i].status == QUEST_STATUS_TAKEN) &&
+                                                   (quest[i].level < dun_level))
+                                               {
+                                                       quest[i].status = QUEST_STATUS_FAILED;
+                                                       quest[i].complev = (byte)p_ptr->lev;
+                                                       r_info[quest[i].r_idx].flags1 &= ~(RF1_QUESTOR);
+                                               }
+                                       }
+                               }
+                       }
+
+                       /* Sound */
+                       sound(SOUND_TPLEVEL);
+               }
+       }
+
+
+       /* Delayed Alter reality */
+       if (p_ptr->alter_reality)
+       {
+               if (autosave_l && (p_ptr->alter_reality == 1) && !p_ptr->inside_battle)
+                       do_cmd_save_game(TRUE);
+
+               /* Count down towards alter */
+               p_ptr->alter_reality--;
+
+               p_ptr->redraw |= (PR_STATUS);
+
+               /* Activate the alter reality */
+               if (!p_ptr->alter_reality)
+               {
+                       /* Disturbing! */
+                       disturb(0, 1);
+
+                       /* Determine the level */
+                       if (!quest_number(dun_level) && dun_level)
+                       {
+#ifdef JP
+                               msg_print("À¤³¦¤¬ÊѤï¤Ã¤¿¡ª");
+#else
+                               msg_print("The world changes!");
+#endif
+
+                               /*
+                                * Clear all saved floors
+                                * and create a first saved floor
+                                */
+                               prepare_change_floor_mode(CFM_FIRST_FLOOR);
+
+                               /* Leaving */
+                               p_ptr->leaving = TRUE;
+                       }
+                       else
+                       {
+#ifdef JP
+                               msg_print("À¤³¦¤¬¾¯¤·¤Î´ÖÊѲ½¤·¤¿¤è¤¦¤À¡£");
+#else
+                               msg_print("The world seems to change for a moment!");
+#endif
+                       }
+
+                       /* Sound */
+                       sound(SOUND_TPLEVEL);
+               }
+       }
+}
+
+
+/*
+ * Count number of adjacent monsters
+ */
+static int get_monster_crowd_number(int m_idx)
+{
+       monster_type *m_ptr = &m_list[m_idx];
+       int my = m_ptr->fy;
+       int mx = m_ptr->fx;
+       int i;
+       int count = 0;
+
+       for (i = 0; i < 7; i++)
+       {
+               int ay = my + ddy_ddd[i];
+               int ax = mx + ddx_ddd[i];
+
+               if (!in_bounds(ay, ax)) continue;
+
+               /* Count number of monsters */
+               if (cave[ay][ax].m_idx > 0) count++;
+       }
+
+       return count;
+}
+
+
+
+/*
+ * Dungeon rating is no longer linear
+ */
+#define RATING_BOOST(delta) (delta * delta + 50 * delta)
+
+/*
+ * Examine all monsters and unidentified objects,
+ * and get the feeling of current dungeon floor
+ */
+static byte get_dungeon_feeling(void)
+{
+       const int base = 10;
+       int rating = 0;
+       int i;
+
+       /* Hack -- no feeling in the town */
+       if (!dun_level) return 0;
+
+       /* Examine each monster */
+       for (i = 1; i < m_max; i++)
+       {
+               monster_type *m_ptr = &m_list[i];
+               monster_race *r_ptr;
+               int delta = 0;
+
+               /* Skip dead monsters */
+               if (!m_ptr->r_idx) continue;
+
+               /* Ignore pet */
+               if (is_pet(m_ptr)) continue;
+
+               r_ptr = &r_info[m_ptr->r_idx];
+
+               /* Unique monsters */
+               if (r_ptr->flags1 & (RF1_UNIQUE))
+               {
+                       /* Nearly out-of-depth unique monsters */
+                       if (r_ptr->level + 10 > dun_level)
+                       {
+                               /* Boost rating by twice delta-depth */
+                               delta += (r_ptr->level + 10 - dun_level) * 2 * base;
+                       }
+               }
+               else
+               {
+                       /* Out-of-depth monsters */
+                       if (r_ptr->level > dun_level)
+                       {
+                               /* Boost rating by delta-depth */
+                               delta += (r_ptr->level - dun_level) * base;
+                       }
+               }
+
+               /* Unusually crowded monsters get a little bit of rating boost */
+               if (r_ptr->flags1 & RF1_FRIENDS)
+               {
+                       if (5 <= get_monster_crowd_number(i)) delta += 1;
+               }
+               else
+               {
+                       if (2 <= get_monster_crowd_number(i)) delta += 1;
+               }
+
+
+               rating += RATING_BOOST(delta);
+       }
+
+       /* Examine each unidentified object */
+       for (i = 1; i < o_max; i++)
+       {
+               object_type *o_ptr = &o_list[i];
+               object_kind *k_ptr = &k_info[o_ptr->k_idx];
+               int delta = 0;
+
+               /* Skip dead objects */
+               if (!o_ptr->k_idx) continue;
+
+               /* Skip known objects */
+               if (object_is_known(o_ptr))
+               {
+                       /* Touched? */
+                       if (o_ptr->marked & OM_TOUCHED) continue;
+               }
+
+               /* Skip pseudo-known objects */
+               if (o_ptr->ident & IDENT_SENSE) continue;
+
+               /* Ego objects */
+               if (object_is_ego(o_ptr))
+               {
+                       ego_item_type *e_ptr = &e_info[o_ptr->name2];
+
+                       delta += e_ptr->rating * base;
+               }
+
+               /* Artifacts */
+               if (object_is_artifact(o_ptr))
+               {
+                       s32b cost = object_value_real(o_ptr);
+
+                       delta += 10 * base;
+                       if (cost > 10000L) delta += 10 * base;
+                       if (cost > 50000L) delta += 10 * base;
+                       if (cost > 100000L) delta += 10 * base;
 
-                                       for (i = MIN_RANDOM_QUEST; i < MAX_RANDOM_QUEST + 1; i++)
-                                       {
-                                               if ((quest[i].type == QUEST_TYPE_RANDOM) &&
-                                                   (quest[i].status == QUEST_STATUS_TAKEN) &&
-                                                   (quest[i].level < dun_level))
-                                               {
-                                                       quest[i].status = QUEST_STATUS_FAILED;
-                                                       quest[i].complev = (byte)p_ptr->lev;
-                                                       r_info[quest[i].r_idx].flags1 &= ~(RF1_QUESTOR);
-                                               }
-                                       }
-                               }
-                       }
+                       /* Special feeling */
+                       if (!preserve_mode) return 1;
+               }
 
-                       /* Sound */
-                       sound(SOUND_TPLEVEL);
+               if (o_ptr->tval == TV_DRAG_ARMOR) delta += 30 * base;
+               if (o_ptr->tval == TV_SHIELD &&
+                   o_ptr->sval == SV_DRAGON_SHIELD) delta += 5 * base;
+               if (o_ptr->tval == TV_GLOVES &&
+                   o_ptr->sval == SV_SET_OF_DRAGON_GLOVES) delta += 5 * base;
+               if (o_ptr->tval == TV_BOOTS &&
+                   o_ptr->sval == SV_PAIR_OF_DRAGON_GREAVE) delta += 5 * base;
+               if (o_ptr->tval == TV_HELM &&
+                   o_ptr->sval == SV_DRAGON_HELM) delta += 5 * base;
+               if (o_ptr->tval == TV_RING &&
+                   o_ptr->sval == SV_RING_SPEED &&
+                   !object_is_cursed(o_ptr)) delta += 25 * base;
+               if (o_ptr->tval == TV_RING &&
+                   o_ptr->sval == SV_RING_LORDLY &&
+                   !object_is_cursed(o_ptr)) delta += 15 * base;
+               if (o_ptr->tval == TV_AMULET &&
+                   o_ptr->sval == SV_AMULET_THE_MAGI &&
+                   !object_is_cursed(o_ptr)) delta += 15 * base;
+
+               /* Out-of-depth objects */
+               if (!object_is_cursed(o_ptr) && !object_is_broken(o_ptr) &&
+                   k_ptr->level > dun_level)
+               {
+                       /* Rating increase */
+                       delta += (k_ptr->level - dun_level) * base;
                }
+
+               rating += RATING_BOOST(delta);
        }
 
 
-       /* Delayed Alter reality */
-       if (p_ptr->alter_reality)
-       {
-               if (autosave_l && (p_ptr->alter_reality == 1) && !p_ptr->inside_battle)
-                       do_cmd_save_game(TRUE);
+       if (rating > RATING_BOOST(1000)) return 2;
+       if (rating > RATING_BOOST(800)) return 3;
+       if (rating > RATING_BOOST(600)) return 4;
+       if (rating > RATING_BOOST(400)) return 5;
+       if (rating > RATING_BOOST(300)) return 6;
+       if (rating > RATING_BOOST(200)) return 7;
+       if (rating > RATING_BOOST(100)) return 8;
+       if (rating > RATING_BOOST(0)) return 9;
 
-               /* Count down towards alter */
-               p_ptr->alter_reality--;
+       return 10;
+}
 
-               p_ptr->redraw |= (PR_STATUS);
 
-               /* Activate the alter reality */
-               if (!p_ptr->alter_reality)
-               {
-                       /* Disturbing! */
-                       disturb(0, 0);
+/*
+ * Update dungeon feeling, and announce it if changed
+ */
+static void update_dungeon_feeling(void)
+{
+       byte new_feeling;
+       int quest_num;
+       int delay;
 
-                       /* Determine the level */
-                       if (!quest_number(dun_level) && dun_level)
-                       {
-#ifdef JP
-                               msg_print("À¤³¦¤¬ÊѤï¤Ã¤¿¡ª");
-#else
-                               msg_print("The world changes!");
-#endif
+       /* No feeling on the surface */
+       if (!dun_level) return;
 
-                               /* Leaving */
-                               p_ptr->leaving = TRUE;
-                       }
-                       else
-                       {
-#ifdef JP
-                               msg_print("À¤³¦¤¬¾¯¤·¤Î´ÖÊѲ½¤·¤¿¤è¤¦¤À¡£");
-#else
-                               msg_print("The world seems to change for a moment!");
-#endif
-                       }
+       /* No feeling in the arena */
+       if (p_ptr->inside_battle) return;
 
-                       /* Sound */
-                       sound(SOUND_TPLEVEL);
-               }
-       }
+       /* Extract delay time */
+       delay = MAX(10, 150 - p_ptr->skill_fos) * (150 - dun_level) * TURNS_PER_TICK / 100;
+
+       /* Not yet felt anything */
+       if (turn < p_ptr->feeling_turn + delay && !cheat_xtra) return;
+
+       /* Extract quest number (if any) */
+       quest_num = quest_number(dun_level);
+
+       /* No feeling in a quest */
+       if (quest_num &&
+           (is_fixed_quest_idx(quest_num) &&
+            !((quest_num == QUEST_OBERON) || (quest_num == QUEST_SERPENT) ||
+              !(quest[quest_num].flags & QUEST_FLAG_PRESET)))) return;
+
+
+       /* Get new dungeon feeling */
+       new_feeling = get_dungeon_feeling();
+
+       /* Remember last time updated */
+       p_ptr->feeling_turn = turn;
+
+       /* No change */
+       if (p_ptr->feeling == new_feeling) return;
+
+       /* Dungeon feeling is changed */
+       p_ptr->feeling = new_feeling;
+
+       /* Announce feeling */
+       do_cmd_feeling();
+
+       /* Update the level indicator */
+       p_ptr->redraw |= (PR_DEPTH);
+
+       /* Disturb */
+       if (disturb_minor) disturb(0, 0);
 }
 
 
@@ -3760,28 +3721,8 @@ static void process_world(void)
        
        extract_day_hour_min(&day, &hour, &min);
 
-
-       if ((turn - old_turn == (150 - dun_level) * TURNS_PER_TICK)
-           && dun_level && !p_ptr->inside_battle)
-       {
-               int quest_num = quest_number(dun_level);
-
-               /* Get dungeon level feeling */
-               if (!(quest_num &&
-                     (is_fixed_quest_idx(quest_num) &&
-                      !((quest_num == QUEST_OBERON) || (quest_num == QUEST_SERPENT) ||
-                        !(quest[quest_num].flags & QUEST_FLAG_PRESET)))))
-               {
-                       /* Announce feeling */
-                       do_cmd_feeling();
-
-                       /* Update the level indicator */
-                       p_ptr->redraw |= (PR_DEPTH);
-
-                       /* Disturb */
-                       if (disturb_minor) disturb(0, 0);
-               }
-       }
+       /* Update dungeon feeling, and announce it if changed */
+       update_dungeon_feeling();
 
        /*** Check monster arena ***/
        if (p_ptr->inside_battle && !p_ptr->leaving)
@@ -3855,7 +3796,7 @@ static void process_world(void)
                        p_ptr->energy_need = 0;
                        battle_monsters();
                }
-               else if(turn - old_turn == 150*TURNS_PER_TICK)
+               else if (turn - old_turn == 150*TURNS_PER_TICK)
                {
 #ifdef JP
                        msg_print("¿½¤·Ê¬¤±¤¢¤ê¤Þ¤»¤ó¤¬¡¢¤³¤Î¾¡Éé¤Ï°ú¤­Ê¬¤±¤È¤µ¤»¤Æ¤¤¤¿¤À¤­¤Þ¤¹¡£");
@@ -3883,7 +3824,7 @@ static void process_world(void)
                        if (closing_flag <= 2)
                        {
                                /* Disturb */
-                               disturb(0, 0);
+                               disturb(0, 1);
 
                                /* Count warnings */
                                closing_flag++;
@@ -4080,7 +4021,7 @@ msg_print("
                                        if (!have_flag(f_ptr->flags, FF_STORE)) continue;
 
                                        /* Verify store type */
-                                       if (f_ptr->power == n)
+                                       if (f_ptr->subtype == n)
                                        {
                                                /* Message */
 #ifdef JP
@@ -4114,8 +4055,16 @@ msg_print("
        if (!(turn % (TURNS_PER_TICK*10)) && !p_ptr->inside_battle) regen_monsters();
        if (!(turn % (TURNS_PER_TICK*3))) regen_captured_monsters();
 
-       /* Hack -- Process the counters of all monsters */
-       process_monsters_counters();
+       if (!p_ptr->leaving)
+       {
+               int i;
+
+               /* Hack -- Process the counters of monsters if needed */
+               for (i = 0; i < MAX_MTIMED; i++)
+               {
+                       if (mproc_max[i] > 0) process_monsters_mtimed(i);
+               }
+       }
 
 
        /* Date changes */
@@ -4139,7 +4088,7 @@ msg_print("
                if ((hour == 23) && !(min % 15))
                {
                        /* Disturbing */
-                       disturb(0, 0);
+                       disturb(0, 1);
 
                        switch (min / 15)
                        {
@@ -4177,12 +4126,12 @@ msg_print("
                        }
                }
 
-               /* TY_CURSE activates at mignight! */
+               /* TY_CURSE activates at midnight! */
                if (!hour && !min)
                {
                        int count = 0;
 
-                       disturb(1, 0);
+                       disturb(1, 1);
 #ifdef JP
                        msg_print("±ó¤¯¤Ç¾â¤¬²¿²ó¤âÌĤꡢ»à¤ó¤À¤è¤¦¤ÊÀŤ±¤µ¤ÎÃæ¤Ø¾Ã¤¨¤Æ¤¤¤Ã¤¿¡£");
 #else
@@ -4246,7 +4195,7 @@ msg_print("
                                msg_print("You faint from the lack of food.");
 #endif
 
-                               disturb(1, 0);
+                               disturb(1, 1);
 
                                /* Hack -- faint (bypass free action) */
                                (void)set_paralyzed(p_ptr->paralyzed + 1 + randint0(5));
@@ -4487,6 +4436,10 @@ static void process_command(void)
 
        now_message = 0;
 
+       /* Sniper */
+       if ((p_ptr->pclass == CLASS_SNIPER) && (p_ptr->concent))
+               reset_concent = TRUE;
+
        /* Parse the command */
        switch (command_cmd)
        {
@@ -4866,7 +4819,9 @@ msg_print("
                        else if (p_ptr->pclass == CLASS_SMITH)
                                do_cmd_kaji(TRUE);
                        else if (p_ptr->pclass == CLASS_MAGIC_EATER)
-                               do_cmd_magic_eater(TRUE);
+                               do_cmd_magic_eater(TRUE, FALSE);
+                       else if (p_ptr->pclass == CLASS_SNIPER)
+                               do_cmd_snipe_browse();
                        else do_cmd_browse();
                        break;
                }
@@ -4966,13 +4921,15 @@ msg_print("
                                        else if (p_ptr->pclass == CLASS_IMITATOR)
                                                do_cmd_mane(FALSE);
                                        else if (p_ptr->pclass == CLASS_MAGIC_EATER)
-                                               do_cmd_magic_eater(FALSE);
+                                               do_cmd_magic_eater(FALSE, FALSE);
                                        else if (p_ptr->pclass == CLASS_SAMURAI)
                                                do_cmd_hissatsu();
                                        else if (p_ptr->pclass == CLASS_BLUE_MAGE)
                                                do_cmd_cast_learned();
                                        else if (p_ptr->pclass == CLASS_SMITH)
                                                do_cmd_kaji(FALSE);
+                                       else if (p_ptr->pclass == CLASS_SNIPER)
+                                               do_cmd_snipe();
                                        else
                                                do_cmd_cast();
                                }
@@ -5289,6 +5246,7 @@ msg_print("
                case '=':
                {
                        do_cmd_options();
+                       (void)combine_and_reorder_home(STORE_HOME);
                        do_cmd_redraw();
                        break;
                }
@@ -5404,6 +5362,13 @@ msg_print("
                        break;
                }
 
+               /* Record/stop "Movie" */
+               case ']':
+               {
+                       prepare_movie_hooks();
+                       break;
+               }
+
                /* Make random artifact list */
                case KTRL('V'):
                {
@@ -5411,6 +5376,18 @@ msg_print("
                        break;
                }
 
+#ifdef TRAVEL
+               case '`':
+               {
+                       if (!p_ptr->wild_mode) do_cmd_travel();
+                       if (p_ptr->special_defense & KATA_MUSOU)
+                       {
+                               set_action(ACTION_NONE);
+                       }
+                       break;
+               }
+#endif
+
                /* Hack -- Unknown command */
                default:
                {
@@ -5455,6 +5432,86 @@ static bool monster_tsuri(int r_idx)
 }
 
 
+/* Hack -- Pack Overflow */
+static void pack_overflow(void)
+{
+       if (inventory[INVEN_PACK].k_idx)
+       {
+               char o_name[MAX_NLEN];
+               object_type *o_ptr;
+
+               /* Is auto-destroy done? */
+               notice_stuff();
+               if (!inventory[INVEN_PACK].k_idx) return;
+
+               /* Access the slot to be dropped */
+               o_ptr = &inventory[INVEN_PACK];
+
+               /* Disturbing */
+               disturb(0, 1);
+
+               /* Warning */
+#ifdef JP
+               msg_print("¥¶¥Ã¥¯¤«¤é¥¢¥¤¥Æ¥à¤¬¤¢¤Õ¤ì¤¿¡ª");
+#else
+               msg_print("Your pack overflows!");
+#endif
+
+               /* Describe */
+               object_desc(o_name, o_ptr, 0);
+
+               /* Message */
+#ifdef JP
+               msg_format("%s(%c)¤òÍî¤È¤·¤¿¡£", o_name, index_to_label(INVEN_PACK));
+#else
+               msg_format("You drop %s (%c).", o_name, index_to_label(INVEN_PACK));
+#endif
+
+               /* Drop it (carefully) near the player */
+               (void)drop_near(o_ptr, 0, py, px);
+
+               /* Modify, Describe, Optimize */
+               inven_item_increase(INVEN_PACK, -255);
+               inven_item_describe(INVEN_PACK);
+               inven_item_optimize(INVEN_PACK);
+
+               /* Handle "p_ptr->notice" */
+               notice_stuff();
+
+               /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
+               handle_stuff();
+       }
+}
+
+/*
+ * process the effects per 100 energy at player speed.
+ */
+static void process_upkeep_with_speed(void)
+{
+       /* Give the player some energy */
+       if (!load && p_ptr->enchant_energy_need > 0 && !p_ptr->leaving)
+       {
+               p_ptr->enchant_energy_need -= SPEED_TO_ENERGY(p_ptr->pspeed);
+       }
+       
+       /* No turn yet */
+       if (p_ptr->enchant_energy_need > 0) return;
+       
+       while (p_ptr->enchant_energy_need <= 0)
+       {
+               /* Handle the player song */
+               if (!load) check_music();
+
+               /* Hex - Handle the hex spells */
+               if (!load) check_hex();
+               if (!load) revenge_spell();
+               
+               /* There is some randomness of needed energy */
+               p_ptr->enchant_energy_need += ENERGY_NEED();
+       }
+}
+
+
 /*
  * Process the player
  *
@@ -5577,7 +5634,7 @@ msg_print("
                                msg_print("Damn!  The fish stole your bait!");
 #endif
                        }
-                       disturb(0, 0);
+                       disturb(0, 1);
                }
        }
 
@@ -5585,7 +5642,7 @@ msg_print("
        if (check_abort)
        {
                /* Check for "player abort" (semi-efficiently for resting) */
-               if (running || command_rep || (p_ptr->action == ACTION_REST) || (p_ptr->action == ACTION_FISH))
+               if (running || travel.run || command_rep || (p_ptr->action == ACTION_REST) || (p_ptr->action == ACTION_FISH))
                {
                        /* Do not wait */
                        inkey_scan = TRUE;
@@ -5597,7 +5654,7 @@ msg_print("
                                flush();
 
                                /* Disturb */
-                               disturb(0, 0);
+                               disturb(0, 1);
 
                                /* Hack -- Show a Message */
 #ifdef JP
@@ -5615,14 +5672,12 @@ msg_print("
                monster_type *m_ptr = &m_list[p_ptr->riding];
                monster_race *r_ptr = &r_info[m_ptr->r_idx];
 
-               if (m_ptr->csleep)
+               if (MON_CSLEEP(m_ptr))
                {
                        char m_name[80];
 
                        /* Recover fully */
-                       m_ptr->csleep = 0;
-
-                       if (r_ptr->flags7 & RF7_HAS_LD_MASK) p_ptr->update |= (PU_MON_LITE);
+                       (void)set_monster_csleep(p_ptr->riding, 0);
 
                        /* Acquire the monster name */
                        monster_desc(m_name, m_ptr, 0);
@@ -5631,35 +5686,16 @@ msg_print("
 #else
                        msg_format("You have waked %s up.", m_name);
 #endif
-                       p_ptr->redraw |= (PR_UHEALTH);
                }
 
-               if (m_ptr->stunned)
+               if (MON_STUNNED(m_ptr))
                {
-                       int d = 1;
-
-                       /* Make a "saving throw" against stun */
-                       if (randint0(r_ptr->level) < p_ptr->skill_exp[GINOU_RIDING])
-                       {
-                               /* Recover fully */
-                               d = m_ptr->stunned;
-                       }
-
                        /* Hack -- Recover from stun */
-                       if (m_ptr->stunned > d)
-                       {
-                               /* Recover somewhat */
-                               m_ptr->stunned -= d;
-                       }
-
-                       /* Fully recover */
-                       else
+                       if (set_monster_stunned(p_ptr->riding,
+                               (randint0(r_ptr->level) < p_ptr->skill_exp[GINOU_RIDING]) ? 0 : (MON_STUNNED(m_ptr) - 1)))
                        {
                                char m_name[80];
 
-                               /* Recover fully */
-                               m_ptr->stunned = 0;
-
                                /* Acquire the monster name */
                                monster_desc(m_name, m_ptr, 0);
 
@@ -5672,32 +5708,14 @@ msg_print("
                        }
                }
 
-               if (m_ptr->confused)
+               if (MON_CONFUSED(m_ptr))
                {
-                       int d = 1;
-
-                       /* Make a "saving throw" against stun */
-                       if (randint0(r_ptr->level) < p_ptr->skill_exp[GINOU_RIDING])
-                       {
-                               /* Recover fully */
-                               d = m_ptr->confused;
-                       }
-
-                       /* Hack -- Recover from stun */
-                       if (m_ptr->confused > d)
-                       {
-                               /* Recover somewhat */
-                               m_ptr->confused -= d;
-                       }
-
-                       /* Fully recover */
-                       else
+                       /* Hack -- Recover from confusion */
+                       if (set_monster_confused(p_ptr->riding,
+                               (randint0(r_ptr->level) < p_ptr->skill_exp[GINOU_RIDING]) ? 0 : (MON_CONFUSED(m_ptr) - 1)))
                        {
                                char m_name[80];
 
-                               /* Recover fully */
-                               m_ptr->confused = 0;
-
                                /* Acquire the monster name */
                                monster_desc(m_name, m_ptr, 0);
 
@@ -5710,32 +5728,14 @@ msg_print("
                        }
                }
 
-               if (m_ptr->monfear)
+               if (MON_MONFEAR(m_ptr))
                {
-                       int d = 1;
-
-                       /* Make a "saving throw" against stun */
-                       if (randint0(r_ptr->level) < p_ptr->skill_exp[GINOU_RIDING])
-                       {
-                               /* Recover fully */
-                               d = m_ptr->monfear;
-                       }
-
-                       /* Hack -- Recover from stun */
-                       if (m_ptr->monfear > d)
-                       {
-                               /* Recover somewhat */
-                               m_ptr->monfear -= d;
-                       }
-
-                       /* Fully recover */
-                       else
+                       /* Hack -- Recover from fear */
+                       if (set_monster_monfear(p_ptr->riding,
+                               (randint0(r_ptr->level) < p_ptr->skill_exp[GINOU_RIDING]) ? 0 : (MON_MONFEAR(m_ptr) - 1)))
                        {
                                char m_name[80];
 
-                               /* Recover fully */
-                               m_ptr->monfear = 0;
-
                                /* Acquire the monster name */
                                monster_desc(m_name, m_ptr, 0);
 
@@ -5745,17 +5745,13 @@ msg_print("
 #else
                                msg_format("%^s is no longer fear.", m_name);
 #endif
-                               p_ptr->redraw |= (PR_UHEALTH);
                        }
                }
 
                /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
                handle_stuff();
        }
-
-       /* Handle the player song */
-       if (!load) check_music();
-
+       
        load = FALSE;
 
        /* Fast */
@@ -5836,53 +5832,7 @@ msg_print("
 
 
                /* Hack -- Pack Overflow */
-               if (inventory[INVEN_PACK].k_idx)
-               {
-                       int item = INVEN_PACK;
-
-                       char o_name[MAX_NLEN];
-
-                       object_type *o_ptr;
-
-                       /* Access the slot to be dropped */
-                       o_ptr = &inventory[item];
-
-                       /* Disturbing */
-                       disturb(0, 0);
-
-                       /* Warning */
-#ifdef JP
-msg_print("¥¶¥Ã¥¯¤«¤é¥¢¥¤¥Æ¥à¤¬¤¢¤Õ¤ì¤¿¡ª");
-#else
-                       msg_print("Your pack overflows!");
-#endif
-
-
-                       /* Describe */
-                       object_desc(o_name, o_ptr, 0);
-
-                       /* Message */
-#ifdef JP
-msg_format("%s(%c)¤òÍî¤È¤·¤¿¡£", o_name, index_to_label(item));
-#else
-                       msg_format("You drop %s (%c).", o_name, index_to_label(item));
-#endif
-
-
-                       /* Drop it (carefully) near the player */
-                       (void)drop_near(o_ptr, 0, py, px);
-
-                       /* Modify, Describe, Optimize */
-                       inven_item_increase(item, -255);
-                       inven_item_describe(item);
-                       inven_item_optimize(item);
-
-                       /* Handle "p_ptr->notice" */
-                       notice_stuff();
-
-                       /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
-                       handle_stuff();
-               }
+               pack_overflow();
 
 
                /* Hack -- cancel "lurking browse mode" */
@@ -5944,6 +5894,15 @@ msg_format("%s(%c)
                        run_step(0);
                }
 
+#ifdef TRAVEL
+               /* Traveling */
+               else if (travel.run)
+               {
+                       /* Take a step */
+                       travel_step();
+               }
+#endif
+
                /* Repeated command */
                else if (command_rep)
                {
@@ -5982,6 +5941,10 @@ msg_format("%s(%c)
                }
 
 
+               /* Hack -- Pack Overflow */
+               pack_overflow();
+
+
                /*** Clean up ***/
 
                /* Significant */
@@ -6110,7 +6073,7 @@ msg_format("%s(%c)
                                        }
                                }
                                new_mane = FALSE;
-                               p_ptr->redraw |= (PR_MANE);
+                               p_ptr->redraw |= (PR_IMITATION);
                        }
                        if (p_ptr->action == ACTION_LEARN)
                        {
@@ -6150,6 +6113,9 @@ msg_format("%s(%c)
                        break;
                }
 
+               /* Sniper */
+               if (energy_use && reset_concent) reset_concentration(TRUE);
+
                /* Handle "leaving" */
                if (p_ptr->leaving) break;
        }
@@ -6207,7 +6173,7 @@ static void dungeon(bool load_game)
 
 
        /* Disturb */
-       disturb(1, 0);
+       disturb(1, 1);
 
        /* Get index of current quest (if any) */
        quest_num = quest_number(dun_level);
@@ -6233,6 +6199,8 @@ static void dungeon(bool load_game)
                if (record_maxdepth) do_cmd_write_nikki(NIKKI_MAXDEAPTH, dun_level, NULL);
        }
 
+       (void)calculate_upkeep();
+
        /* Validate the panel */
        panel_bounds_center();
 
@@ -6352,6 +6320,9 @@ msg_print("
        /* Not leaving dungeon */
        p_ptr->leaving_dungeon = FALSE;
 
+       /* Initialize monster process */
+       mproc_init();
+
        /* Main loop */
        while (TRUE)
        {
@@ -6368,9 +6339,11 @@ msg_print("
                /* Hack -- Compress the object list occasionally */
                if (o_cnt + 32 < o_max) compact_objects(0);
 
-
+               
                /* Process the player */
                process_player();
+               
+               process_upkeep_with_speed();
 
                /* Handle "p_ptr->notice" */
                notice_stuff();
@@ -6429,8 +6402,15 @@ msg_print("
 
                /* Count game turns */
                turn++;
-               if (!p_ptr->wild_mode || wild_regen) dungeon_turn++;
-               else if (p_ptr->wild_mode && !(turn % ((MAX_HGT + MAX_WID) / 2))) dungeon_turn++;
+
+               if (dungeon_turn < dungeon_turn_limit)
+               {
+                       if (!p_ptr->wild_mode || wild_regen) dungeon_turn++;
+                       else if (p_ptr->wild_mode && !(turn % ((MAX_HGT + MAX_WID) / 2))) dungeon_turn++;
+               }
+
+               prevent_turn_overflow();
+
                if (wild_regen) wild_regen--;
        }
 
@@ -6656,6 +6636,7 @@ void play_game(bool new_game)
 {
        int i;
        bool load_game = TRUE;
+       bool init_random_seed = FALSE;
 
 #ifdef CHUUKEI
        if (chuukei_client)
@@ -6671,6 +6652,13 @@ void play_game(bool new_game)
        }
 #endif
 
+       if (browsing_movie)
+       {
+               reset_visuals();
+               browse_movie();
+               return;
+       }
+
        hack_mutation = FALSE;
 
        /* Hack -- Character is "icky" */
@@ -6784,6 +6772,8 @@ quit("
                quit(0);
        }
 
+       creating_savefile = new_game;
+
        /* Nothing loaded */
        if (!character_loaded)
        {
@@ -6794,7 +6784,7 @@ quit("
                character_dungeon = FALSE;
 
                /* Prepare to init the RNG */
-               Rand_quick = TRUE;
+               init_random_seed = TRUE;
 
                /* Initialize the saved floors data */
                init_saved_floors(FALSE);
@@ -6815,7 +6805,7 @@ quit("
        }
 
        /* Init the RNG */
-       if (Rand_quick)
+       if (init_random_seed)
        {
                u32b seed;
 
@@ -6829,10 +6819,7 @@ quit("
 
 #endif
 
-               /* Use the complex RNG */
-               Rand_quick = FALSE;
-
-               /* Seed the "complex" RNG */
+               /* Seed the RNG */
                Rand_state_init(seed);
        }
 
@@ -6898,6 +6885,8 @@ quit("
                }
        }
 
+       creating_savefile = FALSE;
+
        p_ptr->teleport_town = FALSE;
        p_ptr->sutemi = FALSE;
        world_monster = FALSE;
@@ -7072,9 +7061,13 @@ prt("
                m_ptr->maxhp = r_ptr->hdice*(r_ptr->hside+1)/2;
                m_ptr->max_maxhp = m_ptr->maxhp;
                m_ptr->hp = r_ptr->hdice*(r_ptr->hside+1)/2;
+               m_ptr->dealt_damage = 0;
                m_ptr->energy_need = ENERGY_NEED() + ENERGY_NEED();
        }
 
+       (void)combine_and_reorder_home(STORE_HOME);
+       (void)combine_and_reorder_home(STORE_MUSEUM);
+
        /* Process */
        while (TRUE)
        {
@@ -7084,9 +7077,14 @@ prt("
                /* Handle "p_ptr->notice" */
                notice_stuff();
 
+               /* Hack -- prevent "icky" message */
+               character_xtra = TRUE;
+
                /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
                handle_stuff();
 
+               character_xtra = FALSE;
+
                /* Cancel the target */
                target_who = 0;
 
@@ -7236,7 +7234,7 @@ prt("
                                        p_ptr->inside_battle = FALSE;
                                        leaving_quest = 0;
                                        p_ptr->inside_quest = 0;
-                                       p_ptr->recall_dungeon = dungeon_type;
+                                       if (dungeon_type) p_ptr->recall_dungeon = dungeon_type;
                                        dungeon_type = 0;
                                        if (lite_town || vanilla_town)
                                        {
@@ -7305,3 +7303,47 @@ s32b turn_real(s32b hoge)
                return hoge;
        }
 }
+
+/*
+ * ¥¿¡¼¥ó¤Î¥ª¡¼¥Ð¡¼¥Õ¥í¡¼¤ËÂФ¹¤ëÂнè
+ * ¥¿¡¼¥óµÚ¤Ó¥¿¡¼¥ó¤òµ­Ï¿¤¹¤ëÊÑ¿ô¤ò¥¿¡¼¥ó¤Î¸Â³¦¤Î1ÆüÁ°¤Þ¤Ç´¬¤­Ì᤹.
+ */
+void prevent_turn_overflow(void)
+{
+       int rollback_days, i, j;
+       s32b rollback_turns;
+
+       if (turn < turn_limit) return;
+
+       rollback_days = 1 + (turn - turn_limit) / (TURNS_PER_TICK * TOWN_DAWN);
+       rollback_turns = TURNS_PER_TICK * TOWN_DAWN * rollback_days;
+
+       if (turn > rollback_turns) turn -= rollback_turns;
+       else turn = 1; /* Paranoia */
+       if (old_turn > rollback_turns) old_turn -= rollback_turns;
+       else old_turn = 1;
+       if (old_battle > rollback_turns) old_battle -= rollback_turns;
+       else old_battle = 1;
+       if (p_ptr->feeling_turn > rollback_turns) p_ptr->feeling_turn -= rollback_turns;
+       else p_ptr->feeling_turn = 1;
+
+       for (i = 1; i < max_towns; i++)
+       {
+               for (j = 0; j < MAX_STORES; j++)
+               {
+                       store_type *st_ptr = &town[i].store[j];
+
+                       if (st_ptr->last_visit > -10L * TURNS_PER_TICK * STORE_TICKS)
+                       {
+                               st_ptr->last_visit -= rollback_turns;
+                               if (st_ptr->last_visit < -10L * TURNS_PER_TICK * STORE_TICKS) st_ptr->last_visit = -10L * TURNS_PER_TICK * STORE_TICKS;
+                       }
+
+                       if (st_ptr->store_open)
+                       {
+                               st_ptr->store_open -= rollback_turns;
+                               if (st_ptr->store_open < 1) st_ptr->store_open = 1;
+                       }
+               }
+       }
+}