OSDN Git Service

[Add] #40514 calc_inventory_weight() を実装. / Implement calc_inventory_weight().
authordeskull <deskull@users.sourceforge.jp>
Sun, 8 Nov 2020 05:20:37 +0000 (14:20 +0900)
committerdeskull <deskull@users.sourceforge.jp>
Sun, 8 Nov 2020 05:20:37 +0000 (14:20 +0900)
src/player/player-status.c
src/player/player-status.h

index 6b9d588..2ea7fee 100644 (file)
@@ -270,6 +270,25 @@ static bool is_heavy_shoot(player_type *creature_ptr, object_type *o_ptr)
 }
 
 /*!
+ * @brief 所持品総重量を計算する
+ * @param creature_ptr 計算対象となるクリーチャーの参照ポインタ
+ * @return 総重量
+ */
+WEIGHT calc_inventory_weight(player_type *creature_ptr)
+{
+    WEIGHT weight = 0;
+
+    object_type *o_ptr;
+    BIT_FLAGS flgs[TR_FLAG_SIZE];
+    for (inventory_slot_type i = 0; i < INVEN_TOTAL; i++) {
+        o_ptr = &creature_ptr->inventory_list[i];
+        if (!o_ptr->k_idx)
+            continue;
+        weight += o_ptr->weight;
+    }
+    return weight;
+}
+/*!
  * @brief プレイヤーの全ステータスを更新する /
  * Calculate the players current "state", taking into account
  * not only race/class intrinsics, but also objects being worn
index 18fc3b4..2e340de 100644 (file)
@@ -506,6 +506,7 @@ extern int riding_exp_level(int riding_exp);
 extern int spell_exp_level(int spell_exp);
 
 extern int calc_weapon_weight_limit(player_type *creature_ptr);
+extern WEIGHT calc_inventory_weight(player_type *creature_ptr);
 
 extern s16b calc_num_fire(player_type *creature_ptr, object_type *o_ptr);
 extern void calc_bonuses(player_type *creature_ptr);