From: deskull Date: Tue, 30 Apr 2019 09:13:14 +0000 (+0900) Subject: [Refactor] #38993 o_cnt, o_max を floor_type 構造体に取り込み. X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=4fa211be70c9ca76b01a0d677e0e1da5695dfbbf;p=hengband%2Fhengband.git [Refactor] #38993 o_cnt, o_max を floor_type 構造体に取り込み. --- diff --git a/src/core.c b/src/core.c index 8b748251b..6272e6788 100644 --- a/src/core.c +++ b/src/core.c @@ -2849,7 +2849,7 @@ static void process_world_aux_recharge(void) } /* Process objects on floor */ - for (i = 1; i < o_max; i++) + for (i = 1; i < current_floor_ptr->o_max; i++) { object_type *o_ptr = ¤t_floor_ptr->o_list[i]; @@ -5085,10 +5085,10 @@ static void dungeon(bool load_game) /* Hack -- Compact the object list occasionally */ - if (o_cnt + 32 > current_floor_ptr->max_o_idx) compact_objects(64); + if (current_floor_ptr->o_cnt + 32 > current_floor_ptr->max_o_idx) compact_objects(64); /* Hack -- Compress the object list occasionally */ - if (o_cnt + 32 < o_max) compact_objects(0); + if (current_floor_ptr->o_cnt + 32 < current_floor_ptr->o_max) compact_objects(0); /* Process the player */ process_player(); diff --git a/src/externs.h b/src/externs.h index 8dbbfd7da..d2331f37c 100644 --- a/src/externs.h +++ b/src/externs.h @@ -159,8 +159,6 @@ extern bool shimmer_monsters; extern bool shimmer_objects; extern bool repair_monsters; extern bool repair_objects; -extern OBJECT_IDX o_max; -extern OBJECT_IDX o_cnt; extern MONSTER_IDX m_max; extern MONSTER_IDX m_cnt; extern MONSTER_IDX hack_m_idx; diff --git a/src/floor-events.c b/src/floor-events.c index 5e420b755..b4bca96bf 100644 --- a/src/floor-events.c +++ b/src/floor-events.c @@ -195,7 +195,7 @@ byte get_dungeon_feeling(void) } /* Examine each unidentified object */ - for (i = 1; i < o_max; i++) + for (i = 1; i < current_floor_ptr->o_max; i++) { object_type *o_ptr = ¤t_floor_ptr->o_list[i]; object_kind *k_ptr = &k_info[o_ptr->k_idx]; diff --git a/src/floor-generate.c b/src/floor-generate.c index 9f970d8c1..976020a16 100644 --- a/src/floor-generate.c +++ b/src/floor-generate.c @@ -1330,9 +1330,9 @@ void clear_cave(void) int i; /* Very simplified version of wipe_o_list() */ - (void)C_WIPE(current_floor_ptr->o_list, o_max, object_type); - o_max = 1; - o_cnt = 0; + (void)C_WIPE(current_floor_ptr->o_list, current_floor_ptr->o_max, object_type); + current_floor_ptr->o_max = 1; + current_floor_ptr->o_cnt = 0; /* Very simplified version of wipe_m_list() */ for (i = 1; i < max_r_idx; i++) @@ -1435,7 +1435,7 @@ void generate_random_floor(void) /* Prevent object over-flow */ - if (o_max >= current_floor_ptr->max_o_idx) + if (current_floor_ptr->o_max >= current_floor_ptr->max_o_idx) { why = _("アイテムが多すぎる", "too many objects"); okay = FALSE; diff --git a/src/floor-save.c b/src/floor-save.c index 9514205d9..d161d1846 100644 --- a/src/floor-save.c +++ b/src/floor-save.c @@ -658,7 +658,7 @@ static void update_unique_artifact(s16b cur_floor_id) } /* Maintain artifatcs */ - for (i = 1; i < o_max; i++) + for (i = 1; i < current_floor_ptr->o_max; i++) { object_type *o_ptr = ¤t_floor_ptr->o_list[i]; @@ -1235,7 +1235,7 @@ void change_floor(void) } /* Maintain artifatcs */ - for (i = 1; i < o_max; i++) + for (i = 1; i < current_floor_ptr->o_max; i++) { object_type *o_ptr = ¤t_floor_ptr->o_list[i]; diff --git a/src/floor.h b/src/floor.h index 0515ebb8f..a578254f5 100644 --- a/src/floor.h +++ b/src/floor.h @@ -16,6 +16,8 @@ typedef struct { object_type *o_list; /*!< The array of dungeon items [current_floor_ptr->max_o_idx] */ OBJECT_IDX max_o_idx; /*!< Maximum number of objects in the level */ + OBJECT_IDX o_max; /* Number of allocated objects */ + OBJECT_IDX o_cnt; /* Number of live objects */ monster_type *m_list; /*!< The array of dungeon monsters [current_floor_ptr->max_m_idx] */ MONSTER_IDX max_m_idx; /*!< Maximum number of monsters in the level */ diff --git a/src/object2.c b/src/object2.c index 7801cf0ff..98f5d987f 100644 --- a/src/object2.c +++ b/src/object2.c @@ -171,7 +171,7 @@ void delete_object_idx(OBJECT_IDX o_idx) object_wipe(j_ptr); /* Count objects */ - o_cnt--; + current_floor_ptr->o_cnt--; } @@ -201,7 +201,7 @@ void delete_object(POSITION y, POSITION x) object_wipe(o_ptr); /* Count objects */ - o_cnt--; + current_floor_ptr->o_cnt--; } /* Objects are gone */ @@ -228,7 +228,7 @@ static void compact_objects_aux(OBJECT_IDX i1, OBJECT_IDX i2) if (i1 == i2) return; /* Repair objects */ - for (i = 1; i < o_max; i++) + for (i = 1; i < current_floor_ptr->o_max; i++) { o_ptr = ¤t_floor_ptr->o_list[i]; @@ -330,7 +330,7 @@ void compact_objects(int size) cur_dis = 5 * (20 - cnt); /* Examine the objects */ - for (i = 1; i < o_max; i++) + for (i = 1; i < current_floor_ptr->o_max; i++) { o_ptr = ¤t_floor_ptr->o_list[i]; @@ -383,7 +383,7 @@ void compact_objects(int size) /* Excise dead objects (backwards!) */ - for (i = o_max - 1; i >= 1; i--) + for (i = current_floor_ptr->o_max - 1; i >= 1; i--) { o_ptr = ¤t_floor_ptr->o_list[i]; @@ -391,10 +391,10 @@ void compact_objects(int size) if (o_ptr->k_idx) continue; /* Move last object into open hole */ - compact_objects_aux(o_max - 1, i); + compact_objects_aux(current_floor_ptr->o_max - 1, i); - /* Compress "o_max" */ - o_max--; + /* Compress "current_floor_ptr->o_max" */ + current_floor_ptr->o_max--; } } @@ -416,7 +416,7 @@ void wipe_o_list(void) int i; /* Delete the existing objects */ - for (i = 1; i < o_max; i++) + for (i = 1; i < current_floor_ptr->o_max; i++) { object_type *o_ptr = ¤t_floor_ptr->o_list[i]; @@ -461,11 +461,11 @@ void wipe_o_list(void) object_wipe(o_ptr); } - /* Reset "o_max" */ - o_max = 1; + /* Reset "current_floor_ptr->o_max" */ + current_floor_ptr->o_max = 1; - /* Reset "o_cnt" */ - o_cnt = 0; + /* Reset "current_floor_ptr->o_cnt" */ + current_floor_ptr->o_cnt = 0; } @@ -482,16 +482,16 @@ OBJECT_IDX o_pop(void) OBJECT_IDX i; /* Initial allocation */ - if (o_max < current_floor_ptr->max_o_idx) + if (current_floor_ptr->o_max < current_floor_ptr->max_o_idx) { /* Get next space */ - i = o_max; + i = current_floor_ptr->o_max; /* Expand object array */ - o_max++; + current_floor_ptr->o_max++; /* Count objects */ - o_cnt++; + current_floor_ptr->o_cnt++; /* Use this object */ return (i); @@ -499,7 +499,7 @@ OBJECT_IDX o_pop(void) /* Recycle dead objects */ - for (i = 1; i < o_max; i++) + for (i = 1; i < current_floor_ptr->o_max; i++) { object_type *o_ptr; o_ptr = ¤t_floor_ptr->o_list[i]; @@ -508,7 +508,7 @@ OBJECT_IDX o_pop(void) if (o_ptr->k_idx) continue; /* Count objects */ - o_cnt++; + current_floor_ptr->o_cnt++; /* Use this object */ return (i); diff --git a/src/save.c b/src/save.c index 711cf1d23..b02a22ce6 100644 --- a/src/save.c +++ b/src/save.c @@ -1071,10 +1071,10 @@ static void wr_saved_floor(saved_floor_type *sf_ptr) /*** Dump objects ***/ /* Total objects */ - wr_u16b(o_max); + wr_u16b(current_floor_ptr->o_max); /* Dump the objects */ - for (i = 1; i < o_max; i++) + for (i = 1; i < current_floor_ptr->o_max; i++) { object_type *o_ptr = ¤t_floor_ptr->o_list[i]; diff --git a/src/spells-floor.c b/src/spells-floor.c index 4bc6bd9b2..4762c27c6 100644 --- a/src/spells-floor.c +++ b/src/spells-floor.c @@ -35,7 +35,7 @@ void wiz_lite(bool ninja) feature_type *f_ptr; /* Memorize objects */ - for (i = 1; i < o_max; i++) + for (i = 1; i < current_floor_ptr->o_max; i++) { object_type *o_ptr = ¤t_floor_ptr->o_list[i]; @@ -152,7 +152,7 @@ void wiz_dark(void) } /* Forget all objects */ - for (i = 1; i < o_max; i++) + for (i = 1; i < current_floor_ptr->o_max; i++) { object_type *o_ptr = ¤t_floor_ptr->o_list[i]; diff --git a/src/spells2.c b/src/spells2.c index 994b7ce77..296cd4770 100644 --- a/src/spells2.c +++ b/src/spells2.c @@ -192,7 +192,7 @@ bool detect_objects_gold(POSITION range) if (d_info[p_ptr->dungeon_idx].flags1 & DF1_DARKNESS) range2 /= 3; /* Scan objects */ - for (i = 1; i < o_max; i++) + for (i = 1; i < current_floor_ptr->o_max; i++) { object_type *o_ptr = ¤t_floor_ptr->o_list[i]; @@ -247,7 +247,7 @@ bool detect_objects_normal(POSITION range) if (d_info[p_ptr->dungeon_idx].flags1 & DF1_DARKNESS) range2 /= 3; /* Scan objects */ - for (i = 1; i < o_max; i++) + for (i = 1; i < current_floor_ptr->o_max; i++) { object_type *o_ptr = ¤t_floor_ptr->o_list[i]; @@ -310,7 +310,7 @@ bool detect_objects_magic(POSITION range) if (d_info[p_ptr->dungeon_idx].flags1 & DF1_DARKNESS) range /= 3; /* Scan all objects */ - for (i = 1; i < o_max; i++) + for (i = 1; i < current_floor_ptr->o_max; i++) { object_type *o_ptr = ¤t_floor_ptr->o_list[i]; diff --git a/src/variable.c b/src/variable.c index ccd8165b8..be3a7b6b4 100644 --- a/src/variable.c +++ b/src/variable.c @@ -141,8 +141,6 @@ bool repair_objects; /* Hack -- optimize detect objects */ bool is_loading_now; /*!< ロード直後にcalc_bonus()時の徳変化、及びsanity_blast()による異常を抑止する */ bool hack_mutation; -OBJECT_IDX o_max = 1; /* Number of allocated objects */ -OBJECT_IDX o_cnt = 0; /* Number of live objects */ MONSTER_IDX m_max = 1; /* Number of allocated monsters */ MONSTER_IDX m_cnt = 0; /* Number of live monsters */