OSDN Git Service

[Refactor] #38844 inven_cnt, equip_cnt を player_type 構造体に取り込み.
authordeskull <deskull@users.sourceforge.jp>
Tue, 30 Apr 2019 09:07:41 +0000 (18:07 +0900)
committerdeskull <deskull@users.sourceforge.jp>
Tue, 30 Apr 2019 10:36:17 +0000 (19:36 +0900)
src/birth.c
src/cmd-basic.c
src/cmd-item.c
src/externs.h
src/files.c
src/load.c
src/object2.c
src/types.h
src/variable.c

index 63d9eda..1bc2080 100644 (file)
@@ -1683,8 +1683,8 @@ static void player_wipe_without_name(void)
        p_ptr->total_weight = 0;
 
        /* No items */
-       inven_cnt = 0;
-       equip_cnt = 0;
+       p_ptr->inven_cnt = 0;
+       p_ptr->equip_cnt = 0;
 
        /* Clear the p_ptr->inventory_list */
        for (i = 0; i < INVEN_TOTAL; i++)
@@ -1973,7 +1973,7 @@ static void wield_all(void)
                p_ptr->total_weight += i_ptr->weight; 
  
                /* Increment the equip counter by hand */ 
-               equip_cnt++;
+               p_ptr->equip_cnt++;
 
        } 
        return; 
index a45c4be..e930af8 100644 (file)
@@ -2821,7 +2821,7 @@ bool do_cmd_throw(int mult, bool boomerang, OBJECT_IDX shuriken)
                        p_ptr->total_weight += q_ptr->weight;
 
                        /* Increment the equip counter by hand */
-                       equip_cnt++;
+                       p_ptr->equip_cnt++;
 
                        p_ptr->update |= (PU_BONUS | PU_TORCH | PU_MANA);
                        p_ptr->window |= (PW_EQUIP);
index 201d935..4e22192 100644 (file)
@@ -387,7 +387,7 @@ void do_cmd_wield(void)
        p_ptr->total_weight += q_ptr->weight;
 
        /* Increment the equip counter by hand */
-       equip_cnt++;
+       p_ptr->equip_cnt++;
 
 #define STR_WIELD_RARM _("%s(%c)を右手に装備した。", "You are wielding %s (%c) in your right hand.")
 #define STR_WIELD_LARM _("%s(%c)を左手に装備した。", "You are wielding %s (%c) in your left hand.")
index 445f6a5..8dbbfd7 100644 (file)
@@ -159,8 +159,6 @@ extern bool shimmer_monsters;
 extern bool shimmer_objects;
 extern bool repair_monsters;
 extern bool repair_objects;
-extern s16b inven_cnt;
-extern s16b equip_cnt;
 extern OBJECT_IDX o_max;
 extern OBJECT_IDX o_cnt;
 extern MONSTER_IDX m_max;
index 7ddb94a..62fc3f3 100644 (file)
@@ -4856,7 +4856,7 @@ static void dump_aux_equipment_inventory(FILE *fff)
        GAME_TEXT o_name[MAX_NLEN];
 
        /* Dump the equipment */
-       if (equip_cnt)
+       if (p_ptr->equip_cnt)
        {
                fprintf(fff, _("  [キャラクタの装備]\n\n", "  [Character Equipment]\n\n"));
                for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
@@ -6455,7 +6455,7 @@ void show_info(void)
        /* Show equipment and p_ptr->inventory_list */
 
        /* Equipment -- if any */
-       if (equip_cnt)
+       if (p_ptr->equip_cnt)
        {
                Term_clear();
                (void)show_equip(0, USE_FULL);
@@ -6465,7 +6465,7 @@ void show_info(void)
        }
 
        /* Inventory -- if any */
-       if (inven_cnt)
+       if (p_ptr->inven_cnt)
        {
                Term_clear();
                (void)show_inven(0, USE_FULL);
index c9b84cf..1aa74e6 100644 (file)
@@ -2413,8 +2413,8 @@ static errr rd_inventory(void)
        p_ptr->total_weight = 0;
 
        /* No items */
-       inven_cnt = 0;
-       equip_cnt = 0;
+       p_ptr->inven_cnt = 0;
+       p_ptr->equip_cnt = 0;
 
        /* Read until done */
        while (1)
@@ -2445,11 +2445,11 @@ static errr rd_inventory(void)
                        p_ptr->total_weight += (q_ptr->number * q_ptr->weight);
 
                        /* One more item */
-                       equip_cnt++;
+                       p_ptr->equip_cnt++;
                }
 
                /* Warning -- backpack is full */
-               else if (inven_cnt == INVEN_PACK)
+               else if (p_ptr->inven_cnt == INVEN_PACK)
                {
                        note(_("持ち物の中のアイテムが多すぎる!", "Too many items in the p_ptr->inventory_list!"));
 
@@ -2470,7 +2470,7 @@ static errr rd_inventory(void)
                        p_ptr->total_weight += (q_ptr->number * q_ptr->weight);
 
                        /* One more item */
-                       inven_cnt++;
+                       p_ptr->inven_cnt++;
                }
        }
 
index 453d629..7801cf0 100644 (file)
@@ -5013,7 +5013,7 @@ void inven_item_optimize(INVENTORY_IDX item)
                int i;
 
                /* One less item */
-               inven_cnt--;
+               p_ptr->inven_cnt--;
 
                /* Slide everything down */
                for (i = item; i < INVEN_PACK; i++)
@@ -5032,7 +5032,7 @@ void inven_item_optimize(INVENTORY_IDX item)
        else
        {
                /* One less item */
-               equip_cnt--;
+               p_ptr->equip_cnt--;
 
                /* Erase the empty slot */
                object_wipe(&p_ptr->inventory_list[item]);
@@ -5174,7 +5174,7 @@ bool inven_carry_okay(object_type *o_ptr)
        int j;
 
        /* Empty slot? */
-       if (inven_cnt < INVEN_PACK) return (TRUE);
+       if (p_ptr->inven_cnt < INVEN_PACK) return (TRUE);
 
        /* Similar slot? */
        for (j = 0; j < INVEN_PACK; j++)
@@ -5329,7 +5329,7 @@ s16b inven_carry(object_type *o_ptr)
                }
        }
 
-       if (inven_cnt > INVEN_PACK) return (-1);
+       if (p_ptr->inven_cnt > INVEN_PACK) return (-1);
 
        /* Find an empty slot */
        for (j = 0; j <= INVEN_PACK; j++)
@@ -5392,7 +5392,7 @@ s16b inven_carry(object_type *o_ptr)
        p_ptr->total_weight += (j_ptr->number * j_ptr->weight);
 
        /* Count the items */
-       inven_cnt++;
+       p_ptr->inven_cnt++;
        p_ptr->update |= (PU_BONUS | PU_COMBINE | PU_REORDER);
        p_ptr->window |= (PW_INVEN);
 
@@ -5603,7 +5603,7 @@ void combine_pack(void)
                                                object_absorb(j_ptr, o_ptr);
 
                                                /* One object is gone */
-                                               inven_cnt--;
+                                               p_ptr->inven_cnt--;
 
                                                /* Slide everything down */
                                                for (k = i; k < INVEN_PACK; k++)
@@ -5677,7 +5677,7 @@ void reorder_pack(void)
        for (i = 0; i < INVEN_PACK; i++)
        {
                /* Mega-Hack -- allow "proper" over-flow */
-               if ((i == INVEN_PACK) && (inven_cnt == INVEN_PACK)) break;
+               if ((i == INVEN_PACK) && (p_ptr->inven_cnt == INVEN_PACK)) break;
 
                o_ptr = &p_ptr->inventory_list[i];
 
index c6216b6..02fa395 100644 (file)
@@ -1460,6 +1460,8 @@ struct player_type
        s32b feeling_turn;      /* The current_world_ptr->game_turn of the last dungeon feeling */
 
        object_type *inventory_list; /* The player's p_ptr->inventory_list [INVEN_TOTAL] */
+       s16b inven_cnt; /* Number of items in inventory */
+       s16b equip_cnt; /* Number of items in equipment */
 
                                                        /*** Temporary fields ***/
 
index 5feb21c..ccd8165 100644 (file)
@@ -141,9 +141,6 @@ bool repair_objects;        /* Hack -- optimize detect objects */
 bool is_loading_now;   /*!< ロード直後にcalc_bonus()時の徳変化、及びsanity_blast()による異常を抑止する */
 bool hack_mutation;
 
-s16b inven_cnt; /* Number of items in p_ptr->inventory_list */
-s16b equip_cnt; /* Number of items in equipment */
-
 OBJECT_IDX o_max = 1; /* Number of allocated objects */
 OBJECT_IDX o_cnt = 0; /* Number of live objects */