OSDN Git Service

branch-hexの変更をコミット。
[hengband/hengband.git] / src / bldg.c
index 129ce2e..fc703ff 100644 (file)
@@ -16,9 +16,6 @@
 /* hack as in leave_store in store.c */
 static bool leave_bldg = FALSE;
 
-/* remember building location */
-static int building_loc = 0;
-
 static bool is_owner(building_type *bldg)
 {
        if (bldg->member_class[p_ptr->pclass] == BUILDING_OWNER)
@@ -285,10 +282,13 @@ msg_print("
                                        if (get_check("Do you fight? "))
 #endif
                                        {
-                                               p_ptr->leftbldg = TRUE;
-                                               p_ptr->inside_arena = TRUE;
                                                p_ptr->exit_bldg = FALSE;
                                                reset_tim_flags();
+
+                                               /* Save the surface floor as saved floor */
+                                               prepare_change_floor_mode(CFM_SAVE_FLOORS);
+
+                                               p_ptr->inside_arena = TRUE;
                                                p_ptr->leaving = TRUE;
                                                leave_bldg = TRUE;
                                        }
@@ -324,10 +324,13 @@ msg_print("
                        }
                        else
                        {
-                               p_ptr->leftbldg = TRUE;
-                               p_ptr->inside_arena = TRUE;
                                p_ptr->exit_bldg = FALSE;
                                reset_tim_flags();
+
+                               /* Save the surface floor as saved floor */
+                               prepare_change_floor_mode(CFM_SAVE_FLOORS);
+
+                               p_ptr->inside_arena = TRUE;
                                p_ptr->leaving = TRUE;
                                leave_bldg = TRUE;
                        }
@@ -2054,10 +2057,14 @@ msg_print("
                        battle_odds = MAX(wager+1, wager * battle_odds / 100);
                        kakekin = wager;
                        p_ptr->au -= wager;
-                       p_ptr->leftbldg = TRUE;
-                       p_ptr->inside_battle = TRUE;
                        reset_tim_flags();
+
+                       /* Save the surface floor as saved floor */
+                       prepare_change_floor_mode(CFM_SAVE_FLOORS);
+
+                       p_ptr->inside_battle = TRUE;
                        p_ptr->leaving = TRUE;
+
                        leave_bldg = TRUE;
                        screen_load();
 
@@ -2222,7 +2229,7 @@ static bool kankin(void)
                if ((o_ptr->tval == TV_CAPTURE) && (o_ptr->pval == MON_TSUCHINOKO))
                {
                        char buf[MAX_NLEN+20];
-                       object_desc(o_name, o_ptr, TRUE, 3);
+                       object_desc(o_name, o_ptr, 0);
 #ifdef JP
                        sprintf(buf, "%s ¤ò´¹¶â¤·¤Þ¤¹¤«¡©",o_name);
 #else
@@ -2253,7 +2260,7 @@ static bool kankin(void)
                if ((o_ptr->tval == TV_CORPSE) && (o_ptr->sval == SV_CORPSE) && (o_ptr->pval == MON_TSUCHINOKO))
                {
                        char buf[MAX_NLEN+20];
-                       object_desc(o_name, o_ptr, TRUE, 3);
+                       object_desc(o_name, o_ptr, 0);
 #ifdef JP
                        sprintf(buf, "%s ¤ò´¹¶â¤·¤Þ¤¹¤«¡©",o_name);
 #else
@@ -2284,7 +2291,7 @@ static bool kankin(void)
                if ((o_ptr->tval == TV_CORPSE) && (o_ptr->sval == SV_SKELETON) && (o_ptr->pval == MON_TSUCHINOKO))
                {
                        char buf[MAX_NLEN+20];
-                       object_desc(o_name, o_ptr, TRUE, 3);
+                       object_desc(o_name, o_ptr, 0);
 #ifdef JP
                        sprintf(buf, "%s ¤ò´¹¶â¤·¤Þ¤¹¤«¡©",o_name);
 #else
@@ -2313,7 +2320,7 @@ static bool kankin(void)
                if ((o_ptr->tval == TV_CORPSE) && (o_ptr->sval == SV_CORPSE) && (streq(r_name + r_info[o_ptr->pval].name, r_name + r_info[today_mon].name)))
                {
                        char buf[MAX_NLEN+20];
-                       object_desc(o_name, o_ptr, TRUE, 3);
+                       object_desc(o_name, o_ptr, 0);
 #ifdef JP
                        sprintf(buf, "%s ¤ò´¹¶â¤·¤Þ¤¹¤«¡©",o_name);
 #else
@@ -2343,7 +2350,7 @@ static bool kankin(void)
                if ((o_ptr->tval == TV_CORPSE) && (o_ptr->sval == SV_SKELETON) && (streq(r_name + r_info[o_ptr->pval].name, r_name + r_info[today_mon].name)))
                {
                        char buf[MAX_NLEN+20];
-                       object_desc(o_name, o_ptr, TRUE, 3);
+                       object_desc(o_name, o_ptr, 0);
 #ifdef JP
                        sprintf(buf, "%s ¤ò´¹¶â¤·¤Þ¤¹¤«¡©",o_name);
 #else
@@ -2375,10 +2382,10 @@ static bool kankin(void)
                        if ((o_ptr->tval == TV_CORPSE) && (o_ptr->pval == kubi_r_idx[j]))
                        {
                                char buf[MAX_NLEN+20];
-                               int num, k;
+                               int num, k, item_new;
                                object_type forge;
 
-                               object_desc(o_name, o_ptr, TRUE, 3);
+                               object_desc(o_name, o_ptr, 0);
 #ifdef JP
                                sprintf(buf, "%s¤òÅϤ·¤Þ¤¹¤«¡©",o_name);
 #else
@@ -2386,7 +2393,7 @@ static bool kankin(void)
 #endif
                                if (!get_check(buf)) continue;
 
-#if 0 /* Obsorated */
+#if 0 /* Obsoleted */
 #ifdef JP
                                msg_format("¾Þ¶â %ld¡ð¤ò¼ê¤ËÆþ¤ì¤¿¡£", (r_info[kubi_r_idx[j]].level + 1) * 300 * o_ptr->number);
 #else
@@ -2401,7 +2408,7 @@ static bool kankin(void)
                                kubi_r_idx[j] += 10000;
 
                                change = TRUE;
-#endif /* Obsorated */
+#endif /* Obsoleted */
 
                                /* Hand it first */
                                inven_item_increase(i, -o_ptr->number);
@@ -2436,16 +2443,22 @@ static bool kankin(void)
                                 * Since a corpse is handed at first,
                                 * there is at least one empty slot.
                                 */
-                               (void)inven_carry(&forge);
+                               item_new = inven_carry(&forge);
 
                                /* Describe the object */
-                               object_desc(o_name, &forge, TRUE, 3);
+                               object_desc(o_name, &forge, 0);
 #ifdef JP
-                               msg_format("%s ¤òÌã¤Ã¤¿¡£",o_name);
+                               msg_format("%s(%c)¤òÌã¤Ã¤¿¡£", o_name, index_to_label(item_new));
 #else
-                               msg_format("You get %s. ",o_name);
+                               msg_format("You get %s (%c). ", o_name, index_to_label(item_new));
 #endif
 
+                               /* Auto-inscription */
+                               autopick_alter_item(item_new, FALSE);
+
+                               /* Handle stuff */
+                               handle_stuff();
+
                                change = TRUE;
                        }
                }
@@ -2790,120 +2803,119 @@ msg_print("
                        break;
 
                case BACT_REST: /* Rest for the night */
-                       if (!is_daytime()) /* Nighttime only */
+                       if ((p_ptr->poisoned) || (p_ptr->cut))
                        {
-                               if ((p_ptr->poisoned) || (p_ptr->cut))
-                               {
 #ifdef JP
-msg_print("¤¢¤Ê¤¿¤ËɬÍפʤΤÏÉô²°¤Ç¤Ï¤Ê¤¯¡¢¼£ÎżԤǤ¹¡£");
+                               msg_print("¤¢¤Ê¤¿¤ËɬÍפʤΤÏÉô²°¤Ç¤Ï¤Ê¤¯¡¢¼£ÎżԤǤ¹¡£");
 #else
-                                       msg_print("You need a healer, not a room.");
+                               msg_print("You need a healer, not a room.");
 #endif
 
-                                       msg_print(NULL);
+                               msg_print(NULL);
 #ifdef JP
-msg_print("¤¹¤ß¤Þ¤»¤ó¡¢¤Ç¤â¤¦¤Á¤Ç狼¤Ë»à¤Ê¤ì¤Á¤ãº¤¤ê¤Þ¤¹¤ó¤Ç¡£");
+                               msg_print("¤¹¤ß¤Þ¤»¤ó¡¢¤Ç¤â¤¦¤Á¤Ç狼¤Ë»à¤Ê¤ì¤Á¤ãº¤¤ê¤Þ¤¹¤ó¤Ç¡£");
 #else
-                                       msg_print("Sorry, but don't want anyone dying in here.");
+                               msg_print("Sorry, but don't want anyone dying in here.");
 #endif
+                       }
+                       else
+                       {
+                               s32b oldturn = turn;
+                               int prev_day, prev_hour, prev_min;
 
-                               }
-                               else
-                               {
-                                       int oldturn = turn;
+                               extract_day_hour_min(&prev_day, &prev_hour, &prev_min);
 #ifdef JP
-                                       do_cmd_write_nikki(NIKKI_BUNSHOU, 0, "½É²°¤ËÇñ¤Þ¤Ã¤¿¡£");
+                               do_cmd_write_nikki(NIKKI_BUNSHOU, 0, "½É²°¤ËÇñ¤Þ¤Ã¤¿¡£");
 #else
-                                       do_cmd_write_nikki(NIKKI_BUNSHOU, 0, "stay over night at the inn");
+                               if ((prev_hour >= 6) && (prev_hour <= 17)) do_cmd_write_nikki(NIKKI_BUNSHOU, 0, "stay over daytime at the inn.");
+                               else do_cmd_write_nikki(NIKKI_BUNSHOU, 0, "stay over night at the inn.");
 #endif
-                                       turn = (turn / (TURNS_PER_TICK*TOWN_DAWN/2) + 1) * (TURNS_PER_TICK*TOWN_DAWN/2);
-                                       if (((oldturn + TURNS_PER_TICK * TOWN_DAWN / 4) % (TURNS_PER_TICK * TOWN_DAWN)) > TURNS_PER_TICK * TOWN_DAWN/4) do_cmd_write_nikki(NIKKI_HIGAWARI, 0, NULL);
-                                       p_ptr->chp = p_ptr->mhp;
-
+                               turn = (turn / (TURNS_PER_TICK*TOWN_DAWN/2) + 1) * (TURNS_PER_TICK*TOWN_DAWN/2);
+                               if (dungeon_turn < dungeon_turn_limit)
+                               {
                                        dungeon_turn += MIN(turn - oldturn, TURNS_PER_TICK*250);
+                                       if (dungeon_turn > dungeon_turn_limit) dungeon_turn = dungeon_turn_limit;
+                               }
 
-                                       if (ironman_nightmare)
-                                       {
+                               prevent_turn_overflow();
+
+                               if ((prev_hour >= 18) && (prev_hour <= 23)) do_cmd_write_nikki(NIKKI_HIGAWARI, 0, NULL);
+                               p_ptr->chp = p_ptr->mhp;
+
+                               if (ironman_nightmare)
+                               {
 #ifdef JP
-msg_print("̲¤ê¤Ë½¢¤¯¤È¶²¤í¤·¤¤¸÷·Ê¤¬¿´¤ò¤è¤®¤Ã¤¿¡£");
+                                       msg_print("̲¤ê¤Ë½¢¤¯¤È¶²¤í¤·¤¤¸÷·Ê¤¬¿´¤ò¤è¤®¤Ã¤¿¡£");
 #else
-                                               msg_print("Horrible visions flit through your mind as you sleep.");
+                                       msg_print("Horrible visions flit through your mind as you sleep.");
 #endif
 
+                                       /* Pick a nightmare */
+                                       get_mon_num_prep(get_nightmare, NULL);
 
-                                               /* Pick a nightmare */
-                                               get_mon_num_prep(get_nightmare, NULL);
-
-                                               /* Have some nightmares */
-                                               while(1)
-                                               {
-                                                       have_nightmare(get_mon_num(MAX_DEPTH));
+                                       /* Have some nightmares */
+                                       while(1)
+                                       {
+                                               have_nightmare(get_mon_num(MAX_DEPTH));
 
-                                                       if (!one_in_(3)) break;
-                                               }
+                                               if (!one_in_(3)) break;
+                                       }
 
-                                               /* Remove the monster restriction */
-                                               get_mon_num_prep(NULL, NULL);
+                                       /* Remove the monster restriction */
+                                       get_mon_num_prep(NULL, NULL);
 
 #ifdef JP
-msg_print("¤¢¤Ê¤¿¤ÏÀ䶫¤·¤ÆÌܤò³Ð¤Þ¤·¤¿¡£");
+                                       msg_print("¤¢¤Ê¤¿¤ÏÀ䶫¤·¤ÆÌܤò³Ð¤Þ¤·¤¿¡£");
+                                       do_cmd_write_nikki(NIKKI_BUNSHOU, 0, "°­Ì´¤Ë¤¦¤Ê¤µ¤ì¤Æ¤è¤¯Ì²¤ì¤Ê¤«¤Ã¤¿¡£");
 #else
-                                               msg_print("You awake screaming.");
+                                       msg_print("You awake screaming.");
+                                       do_cmd_write_nikki(NIKKI_BUNSHOU, 0, "be troubled by a nightmare.");
 #endif
+                               }
+                               else
+                               {
+                                       set_blind(0);
+                                       set_confused(0);
+                                       p_ptr->stun = 0;
+                                       p_ptr->chp = p_ptr->mhp;
+                                       p_ptr->csp = p_ptr->msp;
+                                       if (p_ptr->pclass == CLASS_MAGIC_EATER)
+                                       {
+                                               int i;
+                                               for (i = 0; i < 72; i++)
+                                               {
+                                                       p_ptr->magic_num1[i] = p_ptr->magic_num2[i]*EATER_CHARGE;
+                                               }
+                                               for (; i < 108; i++)
+                                               {
+                                                       p_ptr->magic_num1[i] = 0;
+                                               }
+                                       }
 
+                                       if ((prev_hour >= 6) && (prev_hour <= 17))
+                                       {
 #ifdef JP
-                                               do_cmd_write_nikki(NIKKI_BUNSHOU, 0, "°­Ì´¤Ë¤¦¤Ê¤µ¤ì¤Æ¤è¤¯Ì²¤ì¤Ê¤«¤Ã¤¿¡£");
+                                               msg_print("¤¢¤Ê¤¿¤Ï¥ê¥Õ¥ì¥Ã¥·¥å¤·¤ÆÌܳФᡢͼÊý¤ò·Þ¤¨¤¿¡£");
+                                               do_cmd_write_nikki(NIKKI_BUNSHOU, 0, "ͼÊý¤ò·Þ¤¨¤¿¡£");
 #else
-                                               do_cmd_write_nikki(NIKKI_BUNSHOU, 0, "be troubled by a nightmare.");
+                                               msg_print("You awake refreshed for the evening.");
+                                               do_cmd_write_nikki(NIKKI_BUNSHOU, 0, "awake refreshed.");
 #endif
                                        }
                                        else
                                        {
-                                               set_blind(0);
-                                               set_confused(0);
-                                               p_ptr->stun = 0;
-                                               p_ptr->chp = p_ptr->mhp;
-                                               p_ptr->csp = p_ptr->msp;
-                                               if (p_ptr->pclass == CLASS_MAGIC_EATER)
-                                               {
-                                                       int i;
-                                                       for (i = 0; i < 72; i++)
-                                                       {
-                                                               p_ptr->magic_num1[i] = p_ptr->magic_num2[i]*EATER_CHARGE;
-                                                       }
-                                                       for (; i < 108; i++)
-                                                       {
-                                                               p_ptr->magic_num1[i] = 0;
-                                                       }
-                                               }
-
 #ifdef JP
-msg_print("¤¢¤Ê¤¿¤Ï¥ê¥Õ¥ì¥Ã¥·¥å¤·¤ÆÌܳФᡢ¿·¤¿¤ÊÆü¤ò·Þ¤¨¤¿¡£");
+                                               msg_print("¤¢¤Ê¤¿¤Ï¥ê¥Õ¥ì¥Ã¥·¥å¤·¤ÆÌܳФᡢ¿·¤¿¤ÊÆü¤ò·Þ¤¨¤¿¡£");
+                                               do_cmd_write_nikki(NIKKI_BUNSHOU, 0, "¤¹¤¬¤¹¤¬¤·¤¤Ä«¤ò·Þ¤¨¤¿¡£");
 #else
                                                msg_print("You awake refreshed for the new day.");
-#endif
-
-#ifdef JP
-                                               do_cmd_write_nikki(NIKKI_BUNSHOU, 0, "¤¹¤¬¤¹¤¬¤·¤¤Ä«¤ò¤à¤«¤¨¤¿¡£");
-#else
                                                do_cmd_write_nikki(NIKKI_BUNSHOU, 0, "awake refreshed.");
 #endif
                                        }
-
-                                       p_ptr->leftbldg = TRUE;
                                }
                        }
-                       else
-                       {
-#ifdef JP
-msg_print("Éô²°¤ÏÌë¤À¤±»ÈÍѲÄǽ¤Ç¤¹¡£");
-#else
-                               msg_print("The rooms are available only at night.");
-#endif
-
-                               return (FALSE);
-                       }
                        break;
+
                case BACT_RUMORS: /* Listen for rumors */
                        {
                                char Rumor[1024];
@@ -2924,22 +2936,6 @@ msg_print("
 
 
 /*
- * Share gold for thieves
- */
-static void share_gold(void)
-{
-       int i = (p_ptr->lev * 2) * 10;
-#ifdef JP
-msg_format("¡ð%d ¤ò¼ê¤ËÆþ¤ì¤¿¡£", i);
-#else
-       msg_format("You collect %d gold pieces", i);
-#endif
-
-       p_ptr->au += i;
-}
-
-
-/*
  * Display quest information
  */
 static void get_questinfo(int questnum)
@@ -3274,7 +3270,7 @@ static void list_weapon(object_type *o_ptr, int row, int col)
        int eff_ds = o_ptr->ds + p_ptr->to_ds[0];
 
        /* Print the weapon name */
-       object_desc(o_name, o_ptr, TRUE, 0);
+       object_desc(o_name, o_ptr, OD_NAME_ONLY);
        c_put_str(TERM_YELLOW, o_name, row, col);
 
        /* Print the player's number of blows */
@@ -3628,11 +3624,10 @@ static bool enchant_item(int cost, int to_hit, int to_dam, int to_ac)
        int         maxenchant = (p_ptr->lev / 5);
        char        tmp_str[MAX_NLEN];
 
-
        clear_bldg(4, 18);
 #ifdef JP
-prt(format("¸½ºß¤Î¤¢¤Ê¤¿¤Îµ»Î̤À¤È¡¢+%d ¤Þ¤Ç²þÎɤǤ­¤Þ¤¹¡£", maxenchant), 5, 0);
-prt(format(" ²þÎɤÎÎÁ¶â¤Ï°ì¸Ä¤Ë¤Ä¤­¡ð%d ¤Ç¤¹¡£", cost), 7, 0);
+       prt(format("¸½ºß¤Î¤¢¤Ê¤¿¤Îµ»Î̤À¤È¡¢+%d ¤Þ¤Ç²þÎɤǤ­¤Þ¤¹¡£", maxenchant), 5, 0);
+       prt(format(" ²þÎɤÎÎÁ¶â¤Ï°ì¸Ä¤Ë¤Ä¤­¡ð%d ¤Ç¤¹¡£", cost), 7, 0);
 #else
        prt(format("  Based on your skill, we can improve up to +%d.", maxenchant), 5, 0);
        prt(format("  The price for the service is %d gold per item.", cost), 7, 0);
@@ -3642,8 +3637,8 @@ prt(format(" 
 
        /* Get an item */
 #ifdef JP
-q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò²þÎɤ·¤Þ¤¹¤«¡©";
-s = "²þÎɤǤ­¤ë¤â¤Î¤¬¤¢¤ê¤Þ¤»¤ó¡£";
+       q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò²þÎɤ·¤Þ¤¹¤«¡©";
+       s = "²þÎɤǤ­¤ë¤â¤Î¤¬¤¢¤ê¤Þ¤»¤ó¡£";
 #else
        q = "Improve which item? ";
        s = "You have nothing to improve.";
@@ -3657,9 +3652,9 @@ s = "
        /* Check if the player has enough money */
        if (p_ptr->au < (cost * o_ptr->number))
        {
-               object_desc(tmp_str, o_ptr, TRUE, 0);
+               object_desc(tmp_str, o_ptr, OD_NAME_ONLY);
 #ifdef JP
-msg_format("%s¤ò²þÎɤ¹¤ë¤À¤±¤Î¥´¡¼¥ë¥É¤¬¤¢¤ê¤Þ¤»¤ó¡ª", tmp_str);
+               msg_format("%s¤ò²þÎɤ¹¤ë¤À¤±¤Î¥´¡¼¥ë¥É¤¬¤¢¤ê¤Þ¤»¤ó¡ª", tmp_str);
 #else
                msg_format("You do not have the gold to improve %s!", tmp_str);
 #endif
@@ -3714,21 +3709,20 @@ msg_format("%s
 
                /* Message */
 #ifdef JP
-msg_print("²þÎɤ˼ºÇÔ¤·¤¿¡£");
+               msg_print("²þÎɤ˼ºÇÔ¤·¤¿¡£");
 #else
                msg_print("The improvement failed.");
 #endif
 
-
                return (FALSE);
        }
        else
        {
-               object_desc(tmp_str, o_ptr, TRUE, 1);
+               object_desc(tmp_str, o_ptr, OD_NAME_AND_ENCHANT);
 #ifdef JP
-msg_format("¡ð%d ¤Ç%s¤ò²þÎɤ·¤Þ¤·¤¿¡£", cost * o_ptr->number, tmp_str );
+               msg_format("¡ð%d¤Ç%s¤Ë²þÎɤ·¤Þ¤·¤¿¡£", cost * o_ptr->number, tmp_str);
 #else
-               msg_format("Improved %s for %d gold.", tmp_str, cost * o_ptr->number);
+               msg_format("Improved into %s for %d gold.", tmp_str, cost * o_ptr->number);
 #endif
 
                /* Charge the money */
@@ -3807,7 +3801,7 @@ s = "
         * the level of the item or the number of charges.
         */
        /* The item must be "known" */
-       if (!object_known_p(o_ptr))
+       if (!object_is_known(o_ptr))
        {
 #ifdef JP
 msg_format("½¼Å¶¤¹¤ëÁ°¤Ë´ÕÄꤵ¤ì¤Æ¤¤¤ëɬÍפ¬¤¢¤ê¤Þ¤¹¡ª");
@@ -3832,7 +3826,7 @@ get_check("
                        identify_item(o_ptr);
 
                        /* Description */
-                       object_desc(tmp_str, o_ptr, TRUE, 3);
+                       object_desc(tmp_str, o_ptr, 0);
 
 #ifdef JP
 msg_format("%s ¤Ç¤¹¡£", tmp_str);
@@ -3841,7 +3835,7 @@ msg_format("%s 
 #endif
 
                        /* Auto-inscription */
-                       auto_inscribe_item(item, is_autopick(o_ptr));
+                       autopick_alter_item(item, FALSE);
 
                        /* Update the gold display */
                        building_prt_gold();
@@ -3853,7 +3847,7 @@ msg_format("%s 
        }
 
        /* Extract the object "level" */
-       lev = get_object_level(o_ptr);
+       lev = k_info[o_ptr->k_idx].level;
 
        /* Price for a rod */
        if (o_ptr->tval == TV_ROD)
@@ -3879,7 +3873,7 @@ msg_format("
        else if (o_ptr->tval == TV_STAFF)
        {
                /* Price per charge ( = double the price paid by shopkeepers for the charge) */
-               price = (get_object_cost(o_ptr) / 10) * o_ptr->number;
+               price = (k_info[o_ptr->k_idx].cost / 10) * o_ptr->number;
 
                /* Pay at least 10 gold per charge */
                price = MAX(10, price);
@@ -3887,7 +3881,7 @@ msg_format("
        else
        {
                /* Price per charge ( = double the price paid by shopkeepers for the charge) */
-               price = (get_object_cost(o_ptr) / 10);
+               price = (k_info[o_ptr->k_idx].cost / 10);
 
                /* Pay at least 10 gold per charge */
                price = MAX(10, price);
@@ -3939,7 +3933,7 @@ msg_print("
        /* Check if the player has enough money */
        if (p_ptr->au < price)
        {
-               object_desc(tmp_str, o_ptr, TRUE, 0);
+               object_desc(tmp_str, o_ptr, OD_NAME_ONLY);
 #ifdef JP
 msg_format("%s¤òºÆ½¼Å¶¤¹¤ë¤Ë¤Ï¡ð%d É¬ÍפǤ¹¡ª", tmp_str,price );
 #else
@@ -3998,7 +3992,7 @@ charges = get_quantity(format("
        }
 
        /* Give feedback */
-       object_desc(tmp_str, o_ptr, TRUE, 3);
+       object_desc(tmp_str, o_ptr, 0);
 #ifdef JP
 msg_format("%s¤ò¡ð%d ¤ÇºÆ½¼Å¶¤·¤Þ¤·¤¿¡£", tmp_str, price);
 #else
@@ -4057,10 +4051,10 @@ static void building_recharge_all(void)
                if (o_ptr->tval < TV_STAFF || o_ptr->tval > TV_ROD) continue;
 
                /* need identified */
-               if (!object_known_p(o_ptr)) total_cost += 50;
+               if (!object_is_known(o_ptr)) total_cost += 50;
 
                /* Extract the object "level" */
-               lev = get_object_level(o_ptr);
+               lev = k_info[o_ptr->k_idx].level;
 
                k_ptr = &k_info[o_ptr->k_idx];
 
@@ -4072,7 +4066,7 @@ static void building_recharge_all(void)
 
                case TV_STAFF:
                        /* Price per charge ( = double the price paid by shopkeepers for the charge) */
-                       price = (get_object_cost(o_ptr) / 10) * o_ptr->number;
+                       price = (k_info[o_ptr->k_idx].cost / 10) * o_ptr->number;
 
                        /* Pay at least 10 gold per charge */
                        price = MAX(10, price);
@@ -4083,7 +4077,7 @@ static void building_recharge_all(void)
 
                case TV_WAND:
                        /* Price per charge ( = double the price paid by shopkeepers for the charge) */
-                       price = (get_object_cost(o_ptr) / 10);
+                       price = (k_info[o_ptr->k_idx].cost / 10);
 
                        /* Pay at least 10 gold per charge */
                        price = MAX(10, price);
@@ -4137,12 +4131,12 @@ static void building_recharge_all(void)
                if (o_ptr->tval < TV_STAFF || o_ptr->tval > TV_ROD) continue;
 
                /* Identify it */
-               if (!object_known_p(o_ptr))
+               if (!object_is_known(o_ptr))
                {
                        identify_item(o_ptr);
 
                        /* Auto-inscription */
-                       auto_inscribe_item(i, is_autopick(o_ptr));
+                       autopick_alter_item(i, FALSE);
                }
 
                /* Recharge */
@@ -4270,7 +4264,7 @@ bool tele_town(void)
                        }
                }
        }
-       p_ptr->leftbldg = TRUE;
+
        p_ptr->leaving = TRUE;
        leave_bldg = TRUE;
        p_ptr->teleport_town = TRUE;
@@ -4444,9 +4438,9 @@ sprintf(buf, "%c - %s", sym, "̵
                                if (isupper(temp2[xx])) temp2[xx] = tolower(temp2[xx]);
 
 #ifdef JP
-                       if (strstr(temp2, temp) || strstr_j(r_name + r_ptr->name, temp))
+                       if (my_strstr(temp2, temp) || my_strstr(r_name + r_ptr->name, temp))
 #else
-                       if (strstr(temp2, temp))
+                       if (my_strstr(temp2, temp))
 #endif
                                who[n++] = i;
                }
@@ -4670,11 +4664,11 @@ msg_print("
                paid = compare_weapons();
                break;
        case BACT_ENCHANT_WEAPON:
-               item_tester_hook = item_tester_hook_melee_weapon;
+               item_tester_hook = object_allow_enchant_melee_weapon;
                enchant_item(bcost, 1, 1, 0);
                break;
        case BACT_ENCHANT_ARMOR:
-               item_tester_hook = item_tester_hook_armour;
+               item_tester_hook = object_is_armour;
                enchant_item(bcost, 0, 0, 1);
                break;
        case BACT_RECHARGE:
@@ -4719,21 +4713,6 @@ msg_print("
                if (do_res_stat(A_CON)) paid = TRUE;
                if (do_res_stat(A_CHR)) paid = TRUE;
                break;
-       case BACT_GOLD: /* set timed reward flag */
-               if (!p_ptr->rewards[BACT_GOLD])
-               {
-                       share_gold();
-                       p_ptr->rewards[BACT_GOLD] = TRUE;
-               }
-               else
-               {
-#ifdef JP
-                       msg_print("º£Æü¤Îʬ¤±Á°¤Ï¤¹¤Ç¤Ë»Ùʧ¤Ã¤¿¤¾¡ª");
-#else
-                       msg_print("You just had your daily allowance!");
-#endif
-               }
-               break;
        case BACT_ENCHANT_ARROWS:
                item_tester_hook = item_tester_hook_ammo;
                enchant_item(bcost, 1, 1, 0);
@@ -4779,7 +4758,7 @@ msg_print("
                        p_ptr->word_recall = 1;
                        p_ptr->recall_dungeon = select_dungeon;
                        max_dlv[p_ptr->recall_dungeon] = ((amt > d_info[select_dungeon].maxdepth) ? d_info[select_dungeon].maxdepth : ((amt < d_info[select_dungeon].mindepth) ? d_info[select_dungeon].mindepth : amt));
-                       if (record_maxdeapth)
+                       if (record_maxdepth)
 #ifdef JP
                                do_cmd_write_nikki(NIKKI_TRUMP, select_dungeon, "¥È¥é¥ó¥×¥¿¥ï¡¼¤Ç");
 #else
@@ -4797,7 +4776,10 @@ msg_print("
                break;
        }
        case BACT_LOSE_MUTATION:
-               if (p_ptr->muta1 || p_ptr->muta2 || p_ptr->muta3)
+               if (p_ptr->muta1 || p_ptr->muta2 ||
+                   (p_ptr->muta3 & ~MUT3_GOOD_LUCK) ||
+                   (p_ptr->pseikaku != SEIKAKU_LUCKY &&
+                    (p_ptr->muta3 & MUT3_GOOD_LUCK)))
                {
                        while(!lose_mutation(0));
                        paid = TRUE;
@@ -4876,7 +4858,7 @@ void do_cmd_quest(void)
 {
        energy_use = 100;
 
-       if (cave[py][px].feat != FEAT_QUEST_ENTER)
+       if (!cave_have_flag_bold(py, px, FF_QUEST_ENTER))
        {
 #ifdef JP
 msg_print("¤³¤³¤Ë¤Ï¥¯¥¨¥¹¥È¤ÎÆþ¸ý¤Ï¤Ê¤¤¡£");
@@ -4904,9 +4886,9 @@ msg_print("
 
                leave_quest_check();
 
+               if (quest[p_ptr->inside_quest].type != QUEST_TYPE_RANDOM) dun_level = 1;
                p_ptr->inside_quest = cave[py][px].special;
-               if(quest[leaving_quest].type != QUEST_TYPE_RANDOM) dun_level = 1;
-               p_ptr->leftbldg = TRUE;
+
                p_ptr->leaving = TRUE;
        }
 }
@@ -4925,11 +4907,10 @@ void do_cmd_bldg(void)
 
        energy_use = 100;
 
-       if (!((cave[py][px].feat >= FEAT_BLDG_HEAD) &&
-                 (cave[py][px].feat <= FEAT_BLDG_TAIL)))
+       if (!cave_have_flag_bold(py, px, FF_BLDG))
        {
 #ifdef JP
-msg_print("¤³¤³¤Ë¤Ï·úʪ¤Ï¤Ê¤¤¡£");
+               msg_print("¤³¤³¤Ë¤Ï·úʪ¤Ï¤Ê¤¤¡£");
 #else
                msg_print("You see no building here.");
 #endif
@@ -4937,8 +4918,7 @@ msg_print("
                return;
        }
 
-       which = (cave[py][px].feat - FEAT_BLDG_HEAD);
-       building_loc = which;
+       which = f_info[cave[py][px].feat].subtype;
 
        bldg = &building[which];
 
@@ -4948,31 +4928,54 @@ msg_print("
        if ((which == 2) && (p_ptr->arena_number < 0))
        {
 #ifdef JP
-msg_print("¡ÖÇÔ¼Ô¤ËÍѤϤʤ¤¡£¡×");
+               msg_print("¡ÖÇÔ¼Ô¤ËÍѤϤʤ¤¡£¡×");
 #else
                msg_print("'There's no place here for a LOSER like you!'");
 #endif
                return;
        }
-       else if ((which == 2) && p_ptr->inside_arena && !p_ptr->exit_bldg)
+       else if ((which == 2) && p_ptr->inside_arena)
        {
+               if (!p_ptr->exit_bldg)
+               {
 #ifdef JP
-prt("¥²¡¼¥È¤ÏÊĤޤäƤ¤¤ë¡£¥â¥ó¥¹¥¿¡¼¤¬¤¢¤Ê¤¿¤òÂԤäƤ¤¤ë¡ª",0,0);
+                       prt("¥²¡¼¥È¤ÏÊĤޤäƤ¤¤ë¡£¥â¥ó¥¹¥¿¡¼¤¬¤¢¤Ê¤¿¤òÂԤäƤ¤¤ë¡ª", 0, 0);
 #else
-               prt("The gates are closed.  The monster awaits!", 0, 0);
+                       prt("The gates are closed.  The monster awaits!", 0, 0);
 #endif
+               }
+               else
+               {
+                       /* Don't save the arena as saved floor */
+                       prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_NO_RETURN);
+
+                       p_ptr->inside_arena = FALSE;
+                       p_ptr->leaving = TRUE;
+
+                       /* Re-enter the arena */
+                       command_new = SPECIAL_KEY_BUILDING;
+
+                       /* No energy needed to re-enter the arena */
+                       energy_use = 0;
+               }
 
                return;
        }
-       else if ((which == 2) && p_ptr->inside_arena)
-       {
-               p_ptr->leaving = TRUE;
-               p_ptr->inside_arena = FALSE;
-       }
        else if (p_ptr->inside_battle)
        {
+               /* Don't save the arena as saved floor */
+               prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_NO_RETURN);
+
                p_ptr->leaving = TRUE;
                p_ptr->inside_battle = FALSE;
+
+               /* Re-enter the monster arena */
+               command_new = SPECIAL_KEY_BUILDING;
+
+               /* No energy needed to re-enter the arena */
+               energy_use = 0;
+
+               return;
        }
        else
        {
@@ -5041,7 +5044,9 @@ prt("
 
        /* Reinit wilderness to activate quests ... */
        if (reinit_wilderness)
+       {
                p_ptr->leaving = TRUE;
+       }
 
        /* Hack -- Decrease "icky" depth */
        character_icky--;