• R/O
  • HTTP
  • SSH
  • HTTPS

hengband: Commit

変愚蛮怒のメインリポジトリです


Commit MetaInfo

Revision2675eb8841e88b3e6cbbe47dfe6ba81dea1228c5 (tree)
Time2019-06-12 08:06:34
Authordeskull <deskull@user...>
Commiterdeskull

Log Message

[Refactor] #39076 冗長なコメントを削除しつつ、 OBJECT_IS_HELD_MONSTER() マクロに置換。

Change Summary

Incremental Difference

--- a/src/load.c
+++ b/src/load.c
@@ -2896,9 +2896,7 @@ static errr rd_dungeon_old(void)
28962896 rd_item(o_ptr);
28972897
28982898
2899- /* XXX XXX */
2900-
2901- if (o_ptr->held_m_idx)
2899+ if (OBJECT_IS_HELD_MONSTER(o_ptr))
29022900 {
29032901 monster_type *m_ptr;
29042902 m_ptr = &current_floor_ptr->m_list[o_ptr->held_m_idx];
@@ -2950,8 +2948,6 @@ static errr rd_dungeon_old(void)
29502948 return (162);
29512949 }
29522950
2953-
2954- /* Acquire monster */
29552951 m_ptr = &current_floor_ptr->m_list[m_idx];
29562952
29572953 /* Read the monster */
@@ -3210,7 +3206,7 @@ static errr rd_saved_floor(saved_floor_type *sf_ptr)
32103206 /* Read the item */
32113207 rd_item(o_ptr);
32123208
3213- if (o_ptr->held_m_idx)
3209+ if (OBJECT_IS_HELD_MONSTER(o_ptr))
32143210 {
32153211 monster_type *m_ptr;
32163212 m_ptr = &current_floor_ptr->m_list[o_ptr->held_m_idx];
@@ -3255,8 +3251,6 @@ static errr rd_saved_floor(saved_floor_type *sf_ptr)
32553251
32563252 if (i != m_idx) return 162;
32573253
3258-
3259- /* Acquire monster */
32603254 m_ptr = &current_floor_ptr->m_list[m_idx];
32613255
32623256 /* Read the monster */
--- a/src/monster2.c
+++ b/src/monster2.c
@@ -473,8 +473,6 @@ MONSTER_IDX m_pop(void)
473473 for (i = 1; i < current_floor_ptr->m_max; i++)
474474 {
475475 monster_type *m_ptr;
476-
477- /* Acquire monster */
478476 m_ptr = &current_floor_ptr->m_list[i];
479477
480478 /* Skip live monsters */
--- a/src/object-hook.h
+++ b/src/object-hook.h
@@ -70,6 +70,8 @@ extern bool object_is_quest_target(object_type *o_ptr);
7070
7171 #define OBJECT_IS_VALID(T) ((T)->k_idx != 0)
7272
73+#define OBJECT_IS_HELD_MONSTER(T) ((T)->held_m_idx != 0)
74+
7375 /*
7476 * Artifacts use the "name1" field
7577 */
--- a/src/object.h
+++ b/src/object.h
@@ -386,7 +386,7 @@ struct object_type
386386 BIT_FLAGS curse_flags; /* Flags for curse */
387387
388388 OBJECT_IDX next_o_idx; /* Next object in stack (if any) */
389- MONSTER_IDX held_m_idx; /* Monster holding us (if any) */
389+ MONSTER_IDX held_m_idx; /*!< アイテムを所持しているモンスターID (いないなら 0) / Monster holding us (if any) */
390390
391391 ARTIFACT_BIAS_IDX artifact_bias; /*!< ランダムアーティファクト生成時のバイアスID */
392392 };
--- a/src/object2.c
+++ b/src/object2.c
@@ -58,7 +58,7 @@ void excise_object_idx(OBJECT_IDX o_idx)
5858 /* Object */
5959 j_ptr = &current_floor_ptr->o_list[o_idx];
6060
61- if (j_ptr->held_m_idx)
61+ if (OBJECT_IS_HELD_MONSTER(j_ptr))
6262 {
6363 monster_type *m_ptr;
6464 m_ptr = &current_floor_ptr->m_list[j_ptr->held_m_idx];
@@ -171,7 +171,7 @@ void delete_object_idx(OBJECT_IDX o_idx)
171171 j_ptr = &current_floor_ptr->o_list[o_idx];
172172
173173 /* Dungeon floor */
174- if (!(j_ptr->held_m_idx))
174+ if (!OBJECT_IS_HELD_MONSTER(j_ptr))
175175 {
176176 POSITION y, x;
177177 y = j_ptr->iy;
@@ -254,11 +254,9 @@ static void compact_objects_aux(OBJECT_IDX i1, OBJECT_IDX i2)
254254 }
255255 o_ptr = &current_floor_ptr->o_list[i1];
256256
257- if (o_ptr->held_m_idx)
257+ if (OBJECT_IS_HELD_MONSTER(o_ptr))
258258 {
259259 monster_type *m_ptr;
260-
261- /* Acquire monster */
262260 m_ptr = &current_floor_ptr->m_list[o_ptr->held_m_idx];
263261
264262 /* Repair monster */
@@ -349,11 +347,9 @@ void compact_objects(int size)
349347 /* Hack -- High level objects start out "immune" */
350348 if (k_info[o_ptr->k_idx].level > cur_lev) continue;
351349
352- if (o_ptr->held_m_idx)
350+ if (OBJECT_IS_HELD_MONSTER(o_ptr))
353351 {
354352 monster_type *m_ptr;
355-
356- /* Acquire monster */
357353 m_ptr = &current_floor_ptr->m_list[o_ptr->held_m_idx];
358354
359355 y = m_ptr->fy;
@@ -442,7 +438,7 @@ void wipe_o_list(void)
442438 }
443439 }
444440
445- if (o_ptr->held_m_idx)
441+ if (OBJECT_IS_HELD_MONSTER(o_ptr))
446442 {
447443 monster_type *m_ptr;
448444 m_ptr = &current_floor_ptr->m_list[o_ptr->held_m_idx];
--- a/src/spells-floor.c
+++ b/src/spells-floor.c
@@ -42,9 +42,7 @@ void wiz_lite(bool ninja)
4242 object_type *o_ptr = &current_floor_ptr->o_list[i];
4343
4444 if (!OBJECT_IS_VALID(o_ptr)) continue;
45-
46- /* Skip held objects */
47- if (o_ptr->held_m_idx) continue;
45+ if (OBJECT_IS_HELD_MONSTER(o_ptr)) continue;
4846
4947 /* Memorize */
5048 o_ptr->marked |= OM_FOUND;
@@ -158,9 +156,7 @@ void wiz_dark(void)
158156 object_type *o_ptr = &current_floor_ptr->o_list[i];
159157
160158 if (!OBJECT_IS_VALID(o_ptr)) continue;
161-
162- /* Skip held objects */
163- if (o_ptr->held_m_idx) continue;
159+ if (OBJECT_IS_HELD_MONSTER(o_ptr)) continue;
164160
165161 /* Forget the object */
166162 o_ptr->marked &= OM_TOUCHED;
--- a/src/spells2.c
+++ b/src/spells2.c
@@ -208,9 +208,7 @@ bool detect_objects_gold(POSITION range)
208208 object_type *o_ptr = &current_floor_ptr->o_list[i];
209209
210210 if (!OBJECT_IS_VALID(o_ptr)) continue;
211-
212- /* Skip held objects */
213- if (o_ptr->held_m_idx) continue;
211+ if (OBJECT_IS_HELD_MONSTER(o_ptr)) continue;
214212
215213 y = o_ptr->iy;
216214 x = o_ptr->ix;
@@ -262,9 +260,7 @@ bool detect_objects_normal(POSITION range)
262260 object_type *o_ptr = &current_floor_ptr->o_list[i];
263261
264262 if (!OBJECT_IS_VALID(o_ptr)) continue;
265-
266- /* Skip held objects */
267- if (o_ptr->held_m_idx) continue;
263+ if (OBJECT_IS_HELD_MONSTER(o_ptr)) continue;
268264
269265 y = o_ptr->iy;
270266 x = o_ptr->ix;
@@ -324,9 +320,7 @@ bool detect_objects_magic(POSITION range)
324320 object_type *o_ptr = &current_floor_ptr->o_list[i];
325321
326322 if (!OBJECT_IS_VALID(o_ptr)) continue;
327-
328- /* Skip held objects */
329- if (o_ptr->held_m_idx) continue;
323+ if (OBJECT_IS_HELD_MONSTER(o_ptr)) continue;
330324
331325 y = o_ptr->iy;
332326 x = o_ptr->ix;
Show on old repository browser