summaryrefslogtreecommitdiff
path: root/src/generate.cc
diff options
context:
space:
mode:
authorBardur Arantsson <bardur@scientician.net>2018-03-25 20:07:30 +0200
committerBardur Arantsson <bardur@scientician.net>2018-03-25 20:07:30 +0200
commit45651c61e35ee203c434601ace5e95ccd5474375 (patch)
treec52f30588611a72deebd8f7f83199d1b0a644b5e /src/generate.cc
parent73238d2c617be1600bbb067e0d0bd388488f68d3 (diff)
Add object_type->k_ptr to point directly to the object_kind
The idea is to eventually migrate off k_idx completely, but there are still a couple of uses left.
Diffstat (limited to 'src/generate.cc')
-rw-r--r--src/generate.cc71
1 files changed, 36 insertions, 35 deletions
diff --git a/src/generate.cc b/src/generate.cc
index 1da96bb9..331f79a6 100644
--- a/src/generate.cc
+++ b/src/generate.cc
@@ -832,7 +832,7 @@ static void place_fountain(int y, int x)
/* List of usable svals */
for (auto const &k_entry: k_info)
{
- auto k_ptr = &k_entry.second;
+ auto const &k_ptr = k_entry.second;
if (((k_ptr->tval == TV_POTION) || (k_ptr->tval == TV_POTION2)) &&
(k_ptr->level <= dun_level) && (k_ptr->flags & TR_FOUNTAIN))
@@ -7970,53 +7970,54 @@ static bool_ cave_gen()
}
}
- if (m_idx && d_ptr->final_object &&
- (k_info.at(d_ptr->final_object).artifact == FALSE))
+ if (m_idx && d_ptr->final_object)
{
- object_type *q_ptr, forge, *o_ptr;
- int o_idx;
-
- /* Get new object */
- o_idx = o_pop();
+ auto k_ptr = k_info.at(d_ptr->final_object);
- /* Proceed only if there's an object slot available */
- if (o_idx)
+ if (k_ptr->artifact == FALSE)
{
- /* Get local object */
- q_ptr = &forge;
+ /* Get new object */
+ int o_idx = o_pop();
- k_info[d_ptr->final_object].allow_special = TRUE;
+ /* Proceed only if there's an object slot available */
+ if (o_idx)
+ {
+ /* Get local object */
+ object_type forge;
+ object_type *q_ptr = &forge;
- /* Wipe the object */
- object_wipe(q_ptr);
+ k_info[d_ptr->final_object]->allow_special = TRUE;
- /* Create the final object */
- object_prep(q_ptr, d_ptr->final_object);
- apply_magic(q_ptr, 1, FALSE, FALSE, FALSE);
+ /* Wipe the object */
+ object_wipe(q_ptr);
- /* Where it is found ? */
- q_ptr->found = OBJ_FOUND_MONSTER;
- q_ptr->found_aux1 = d_ptr->final_guardian;
- q_ptr->found_aux2 = 0;
- q_ptr->found_aux3 = dungeon_type;
- q_ptr->found_aux4 = level_or_feat(dungeon_type, dun_level);
+ /* Create the final object */
+ object_prep(q_ptr, d_ptr->final_object);
+ apply_magic(q_ptr, 1, FALSE, FALSE, FALSE);
- k_info[d_ptr->final_object].allow_special = FALSE;
+ /* Where it is found ? */
+ q_ptr->found = OBJ_FOUND_MONSTER;
+ q_ptr->found_aux1 = d_ptr->final_guardian;
+ q_ptr->found_aux2 = 0;
+ q_ptr->found_aux3 = dungeon_type;
+ q_ptr->found_aux4 = level_or_feat(dungeon_type, dun_level);
- k_info.at(d_ptr->final_object).artifact = TRUE;
+ k_ptr->allow_special = FALSE;
+ k_ptr->artifact = TRUE;
- /* Get the item */
- o_ptr = &o_list[o_idx];
+ /* Get the item */
+ object_type *o_ptr = &o_list[o_idx];
- /* Structure copy */
- object_copy(o_ptr, q_ptr);
+ /* Structure copy */
+ object_copy(o_ptr, q_ptr);
- /* Build a stack */
- o_ptr->held_m_idx = m_idx;
- o_ptr->ix = 0;
- o_ptr->iy = 0;
+ /* Build a stack */
+ o_ptr->held_m_idx = m_idx;
+ o_ptr->ix = 0;
+ o_ptr->iy = 0;
- m_list[m_idx].hold_o_idxs.push_back(o_idx);
+ m_list[m_idx].hold_o_idxs.push_back(o_idx);
+ }
}
}
}