#include "quest.h"
#include "wild.h"
#include "spells-floor.h"
+#include "monster-status.h"
static FLOOR_IDX new_floor_id; /*!<次のフロアのID / floor_id of the destination */
static void kill_saved_floor(saved_floor_type *sf_ptr)
{
char floor_savefile[1024];
-
- /* Paranoia */
if (!sf_ptr) return;
/* Already empty */
sf_ptr->visit_mark = latest_visit_mark++;
/* sf_ptr->dun_level may be changed later */
- sf_ptr->dun_level = dun_level;
+ sf_ptr->dun_level = current_floor_ptr->dun_level;
/* Increment number of floor_id */
{
POSITION x, y;
- /* Clear and empty the current_floor->grid_array */
+ /* Clear and empty the current_floor_ptr->grid_array */
clear_cave();
/* Fill the arrays of floors and walls in the good proportions */
set_floor_and_wall(0);
/* Smallest area */
- cur_hgt = SCREEN_HGT;
- cur_wid = SCREEN_WID;
+ current_floor_ptr->height = SCREEN_HGT;
+ current_floor_ptr->width = SCREEN_WID;
/* Filled with permanent walls */
for (y = 0; y < MAX_HGT; y++)
}
/* Place at center of the floor */
- p_ptr->y = cur_hgt / 2;
- p_ptr->x = cur_wid / 2;
+ p_ptr->y = current_floor_ptr->height / 2;
+ p_ptr->x = current_floor_ptr->width / 2;
/* Give one square */
place_floor_bold(p_ptr->y, p_ptr->x);
if (p_ptr->riding)
{
- monster_type *m_ptr = &m_list[p_ptr->riding];
+ monster_type *m_ptr = ¤t_floor_ptr->m_list[p_ptr->riding];
/* Pet of other pet don't follow. */
if (m_ptr->parent_m_idx)
{
for (i = m_max - 1, num = 1; (i >= 1 && num < MAX_PARTY_MON); i--)
{
- monster_type *m_ptr = &m_list[i];
+ monster_type *m_ptr = ¤t_floor_ptr->m_list[i];
- if (!m_ptr->r_idx) continue;
+ if (!monster_is_valid(m_ptr)) continue;
if (!is_pet(m_ptr)) continue;
if (i == p_ptr->riding) continue;
}
}
- (void)COPY(&party_mon[num], &m_list[i], monster_type);
+ (void)COPY(&party_mon[num], ¤t_floor_ptr->m_list[i], monster_type);
num++;
{
for (i = m_max - 1; i >=1; i--)
{
- monster_type *m_ptr = &m_list[i];
+ monster_type *m_ptr = ¤t_floor_ptr->m_list[i];
GAME_TEXT m_name[MAX_NLEN];
- if (!m_ptr->r_idx) continue;
+ if (!monster_is_valid(m_ptr)) continue;
if (!is_pet(m_ptr)) continue;
if (!m_ptr->nickname) continue;
if (p_ptr->riding == i) continue;
/* Pet of other pet may disappear. */
for (i = m_max - 1; i >=1; i--)
{
- monster_type *m_ptr = &m_list[i];
+ monster_type *m_ptr = ¤t_floor_ptr->m_list[i];
/* Are there its parent? */
- if (m_ptr->parent_m_idx && !m_list[m_ptr->parent_m_idx].r_idx)
+ if (m_ptr->parent_m_idx && !current_floor_ptr->m_list[m_ptr->parent_m_idx].r_idx)
{
/* Its parent have gone, it also goes away. */
m_ptr = &party_mon[i];
/* Skip empty monsters */
- if (!m_ptr->r_idx) continue;
+ if (!monster_is_valid(m_ptr)) continue;
/* Hack -- Increase the racial counter */
real_r_ptr(m_ptr)->cur_num++;
if (m_idx)
{
- monster_type *m_ptr = &m_list[m_idx];
+ monster_type *m_ptr = ¤t_floor_ptr->m_list[m_idx];
monster_race *r_ptr;
- current_floor->grid_array[cy][cx].m_idx = m_idx;
+ current_floor_ptr->grid_array[cy][cx].m_idx = m_idx;
m_ptr->r_idx = party_mon[i].r_idx;
m_ptr->fx = cx;
m_ptr->ml = TRUE;
m_ptr->mtimed[MTIMED_CSLEEP] = 0;
-
- /* Paranoia */
m_ptr->hold_o_idx = 0;
m_ptr->target_y = 0;
/* r_ptr->cur_num++; */
/* Hack -- Count the number of "reproducers" */
- if (r_ptr->flags2 & RF2_MULTIPLY) num_repro++;
+ if (r_ptr->flags2 & RF2_MULTIPLY) current_floor_ptr->num_repro++;
/* Hack -- Notice new multi-hued monsters */
{
for (i = 1; i < m_max; i++)
{
monster_race *r_ptr;
- monster_type *m_ptr = &m_list[i];
+ monster_type *m_ptr = ¤t_floor_ptr->m_list[i];
- /* Skip dead monsters */
- if (!m_ptr->r_idx) continue;
+ if (!monster_is_valid(m_ptr)) continue;
/* Extract real monster race */
r_ptr = real_r_ptr(m_ptr);
/* Maintain artifatcs */
for (i = 1; i < o_max; i++)
{
- object_type *o_ptr = &o_list[i];
+ object_type *o_ptr = ¤t_floor_ptr->o_list[i];
/* Skip dead objects */
if (!o_ptr->k_idx) continue;
POSITION dis = 1;
POSITION oy = p_ptr->y;
POSITION ox = p_ptr->x;
- MONSTER_IDX m_idx = current_floor->grid_array[oy][ox].m_idx;
+ MONSTER_IDX m_idx = current_floor_ptr->grid_array[oy][ox].m_idx;
/* Nothing to do if no monster */
if (!m_idx) return;
if (!cave_empty_bold(ny, nx)) continue;
/* Hack -- no teleport onto glyph of warding */
- if (is_glyph_grid(¤t_floor->grid_array[ny][nx])) continue;
- if (is_explosive_rune_grid(¤t_floor->grid_array[ny][nx])) continue;
+ if (is_glyph_grid(¤t_floor_ptr->grid_array[ny][nx])) continue;
+ if (is_explosive_rune_grid(¤t_floor_ptr->grid_array[ny][nx])) continue;
/* ...nor onto the Pattern */
if (pattern_tile(ny, nx)) continue;
/*** It's a good place ***/
- m_ptr = &m_list[m_idx];
+ m_ptr = ¤t_floor_ptr->m_list[m_idx];
/* Update the old location */
- current_floor->grid_array[oy][ox].m_idx = 0;
+ current_floor_ptr->grid_array[oy][ox].m_idx = 0;
/* Update the new location */
- current_floor->grid_array[ny][nx].m_idx = m_idx;
+ current_floor_ptr->grid_array[ny][nx].m_idx = m_idx;
/* Move the monster */
m_ptr->fy = ny;
int i;
/* Search usable stairs */
- for (y = 0; y < cur_hgt; y++)
+ for (y = 0; y < current_floor_ptr->height; y++)
{
- for (x = 0; x < cur_wid; x++)
+ for (x = 0; x < current_floor_ptr->width; x++)
{
- grid_type *g_ptr = ¤t_floor->grid_array[y][x];
+ grid_type *g_ptr = ¤t_floor_ptr->grid_array[y][x];
feature_type *f_ptr = &f_info[g_ptr->feat];
bool ok = FALSE;
prepare_change_floor_mode(CFM_RAND_PLACE | CFM_NO_RETURN);
/* Mega Hack -- It's not the stairs you enter. Disable it. */
- if (!feat_uses_special(current_floor->grid_array[p_ptr->y][p_ptr->x].feat)) current_floor->grid_array[p_ptr->y][p_ptr->x].special = 0;
+ if (!feat_uses_special(current_floor_ptr->grid_array[p_ptr->y][p_ptr->x].feat)) current_floor_ptr->grid_array[p_ptr->y][p_ptr->x].special = 0;
}
else
{
if ((quest[i].status == QUEST_STATUS_TAKEN) &&
((quest[i].type == QUEST_TYPE_KILL_LEVEL) ||
(quest[i].type == QUEST_TYPE_RANDOM)) &&
- (quest[i].level == dun_level) &&
+ (quest[i].level == current_floor_ptr->dun_level) &&
(p_ptr->dungeon_idx == quest[i].dungeon) &&
!(quest[i].flags & QUEST_FLAG_PRESET))
{
for (i = 1; i < m_max; i++)
{
monster_race *r_ptr;
- monster_type *m_ptr = &m_list[i];
+ monster_type *m_ptr = ¤t_floor_ptr->m_list[i];
- /* Skip dead monsters */
- if (!m_ptr->r_idx) continue;
+ if (!monster_is_valid(m_ptr)) continue;
/* Only maintain quest monsters */
if (quest_r_idx != m_ptr->r_idx) continue;
if (change_floor_mode & CFM_SAVE_FLOORS)
{
/* Extract stair position */
- g_ptr = ¤t_floor->grid_array[p_ptr->y][p_ptr->x];
+ g_ptr = ¤t_floor_ptr->grid_array[p_ptr->y][p_ptr->x];
f_ptr = &f_info[g_ptr->feat];
/* Get back to old saved floor? */
/* Get out from or Enter the dungeon */
if (change_floor_mode & CFM_DOWN)
{
- if (!dun_level)
+ if (!current_floor_ptr->dun_level)
move_num = d_info[p_ptr->dungeon_idx].mindepth;
}
else if (change_floor_mode & CFM_UP)
{
- if (dun_level + move_num < d_info[p_ptr->dungeon_idx].mindepth)
- move_num = -dun_level;
+ if (current_floor_ptr->dun_level + move_num < d_info[p_ptr->dungeon_idx].mindepth)
+ move_num = -current_floor_ptr->dun_level;
}
- dun_level += move_num;
+ current_floor_ptr->dun_level += move_num;
}
/* Leaving the dungeon to town */
- if (!dun_level && p_ptr->dungeon_idx)
+ if (!current_floor_ptr->dun_level && p_ptr->dungeon_idx)
{
p_ptr->leaving_dungeon = TRUE;
if (!vanilla_town && !lite_town)
/* Get out of the my way! */
get_out_monster();
- /* Record the last visit turn of current floor */
- sf_ptr->last_visit = turn;
+ /* Record the last visit current_world_ptr->game_turn of current floor */
+ sf_ptr->last_visit = current_world_ptr->game_turn;
forget_lite();
forget_view();
* @return なし
* @details
* If the floor is an old saved floor, it will be\n
- * restored from the temporal file. If the floor is new one, new current_floor->grid_array\n
+ * restored from the temporal file. If the floor is new one, new current_floor_ptr->grid_array\n
* will be generated.\n
*/
void change_floor(void)
panel_col_max = 0;
/* Mega-Hack -- not ambushed on the wildness? */
- ambush_flag = FALSE;
+ p_ptr->ambush_flag = FALSE;
/* No saved floors (On the surface etc.) */
if (!(change_floor_mode & CFM_SAVE_FLOORS) &&
!(change_floor_mode & CFM_FIRST_FLOOR))
{
- /* Create current_floor->grid_array */
+ /* Create current_floor_ptr->grid_array */
generate_random_floor();
/* Paranoia -- No new saved floor */
/* Forbid return stairs */
if (change_floor_mode & CFM_NO_RETURN)
{
- grid_type *g_ptr = ¤t_floor->grid_array[p_ptr->y][p_ptr->x];
+ grid_type *g_ptr = ¤t_floor_ptr->grid_array[p_ptr->y][p_ptr->x];
if (!feat_uses_special(g_ptr->feat))
{
int alloc_chance = d_info[p_ptr->dungeon_idx].max_m_alloc_chance;
GAME_TURN alloc_times;
- while (tmp_last_visit > turn) tmp_last_visit -= TURNS_PER_TICK * TOWN_DAWN;
- absence_ticks = (turn - tmp_last_visit) / TURNS_PER_TICK;
+ while (tmp_last_visit > current_world_ptr->game_turn) tmp_last_visit -= TURNS_PER_TICK * TOWN_DAWN;
+ absence_ticks = (current_world_ptr->game_turn - tmp_last_visit) / TURNS_PER_TICK;
/* Maintain monsters */
for (i = 1; i < m_max; i++)
{
monster_race *r_ptr;
- monster_type *m_ptr = &m_list[i];
+ monster_type *m_ptr = ¤t_floor_ptr->m_list[i];
- /* Skip dead monsters */
- if (!m_ptr->r_idx) continue;
+ if (!monster_is_valid(m_ptr)) continue;
if (!is_pet(m_ptr))
{
/* Maintain artifatcs */
for (i = 1; i < o_max; i++)
{
- object_type *o_ptr = &o_list[i];
+ object_type *o_ptr = ¤t_floor_ptr->o_list[i];
/* Skip dead objects */
if (!o_ptr->k_idx) continue;
}
else
{
- /* Newly create current_floor->grid_array */
+ /* Newly create current_floor_ptr->grid_array */
generate_random_floor();
}
- /* Record last visit turn */
- sf_ptr->last_visit = turn;
+ /* Record last visit current_world_ptr->game_turn */
+ sf_ptr->last_visit = current_world_ptr->game_turn;
- /* Set correct dun_level value */
- sf_ptr->dun_level = dun_level;
+ /* Set correct current_floor_ptr->dun_level value */
+ sf_ptr->dun_level = current_floor_ptr->dun_level;
/* Create connected stairs */
if (!(change_floor_mode & CFM_NO_RETURN))
{
/* Extract stair position */
- grid_type *g_ptr = ¤t_floor->grid_array[p_ptr->y][p_ptr->x];
+ grid_type *g_ptr = ¤t_floor_ptr->grid_array[p_ptr->y][p_ptr->x];
/*** Create connected stairs ***/
/* No stairs down from Quest */
- if ((change_floor_mode & CFM_UP) && !quest_number(dun_level))
+ if ((change_floor_mode & CFM_UP) && !quest_number(current_floor_ptr->dun_level))
{
g_ptr->feat = (change_floor_mode & CFM_SHAFT) ? feat_state(feat_down_stair, FF_SHAFT) : feat_down_stair;
}
/*
* Update visit mark
*
- * The "turn" is not always different number because
- * the level teleport doesn't take any turn. Use
- * visit mark instead of last visit turn to find the
+ * The "current_world_ptr->game_turn" is not always different number because
+ * the level teleport doesn't take any current_world_ptr->game_turn. Use
+ * visit mark instead of last visit current_world_ptr->game_turn to find the
* oldest saved floor.
*/
sf_ptr->visit_mark = latest_visit_mark++;
wiz_lite((bool)(p_ptr->pclass == CLASS_NINJA));
/* Remember when this level was "created" */
- old_turn = turn;
+ current_floor_ptr->generated_turn = current_world_ptr->game_turn;
/* No dungeon feeling yet */
- p_ptr->feeling_turn = old_turn;
+ p_ptr->feeling_turn = current_floor_ptr->generated_turn;
p_ptr->feeling = 0;
/* Clear all flags */
if (ironman_downward) up = FALSE;
/* Forbid down staircases on quest level */
- if (quest_number(dun_level) || (dun_level >= d_info[p_ptr->dungeon_idx].maxdepth)) down = FALSE;
+ if (quest_number(current_floor_ptr->dun_level) || (current_floor_ptr->dun_level >= d_info[p_ptr->dungeon_idx].maxdepth)) down = FALSE;
/* No effect out of standard dungeon floor */
- if (!dun_level || (!up && !down) ||
+ if (!current_floor_ptr->dun_level || (!up && !down) ||
(p_ptr->inside_quest && is_fixed_quest_idx(p_ptr->inside_quest)) ||
p_ptr->inside_arena || p_ptr->inside_battle)
{
/* Extract current floor data */
sf_ptr = get_sf_ptr(p_ptr->floor_id);
-
- /* Paranoia */
if (!sf_ptr)
{
/* No floor id? -- Create now! */
{
POSITION x, y;
- for (y = 0; y < cur_hgt; y++)
+ for (y = 0; y < current_floor_ptr->height; y++)
{
- for (x = 0; x < cur_wid; x++)
+ for (x = 0; x < current_floor_ptr->width; x++)
{
- grid_type *g_ptr = ¤t_floor->grid_array[y][x];
+ grid_type *g_ptr = ¤t_floor_ptr->grid_array[y][x];
if (!g_ptr->special) continue;
if (feat_uses_special(g_ptr->feat)) continue;
if (up)
{
cave_set_feat(p_ptr->y, p_ptr->x,
- (dest_sf_ptr->last_visit && (dest_sf_ptr->dun_level <= dun_level - 2)) ?
+ (dest_sf_ptr->last_visit && (dest_sf_ptr->dun_level <= current_floor_ptr->dun_level - 2)) ?
feat_state(feat_up_stair, FF_SHAFT) : feat_up_stair);
}
else
{
cave_set_feat(p_ptr->y, p_ptr->x,
- (dest_sf_ptr->last_visit && (dest_sf_ptr->dun_level >= dun_level + 2)) ?
+ (dest_sf_ptr->last_visit && (dest_sf_ptr->dun_level >= current_floor_ptr->dun_level + 2)) ?
feat_state(feat_down_stair, FF_SHAFT) : feat_down_stair);
}
/* Connect this stairs to the destination */
- current_floor->grid_array[p_ptr->y][p_ptr->x].special = dest_floor_id;
+ current_floor_ptr->grid_array[p_ptr->y][p_ptr->x].special = dest_floor_id;
}