* included in all such copies. \n
* 2014 Deskull rearranged comment for Doxygen. \n
*/
+#pragma once
#include "angband.h"
#include "bldg.h"
#include "artifact.h"
#include "dungeon.h"
#include "floor.h"
+#include "floor-save.h"
#include "floor-events.h"
#include "floor-generate.h"
#include "feature.h"
+#include "geometry.h"
#include "grid.h"
#include "monster.h"
#include "quest.h"
clear_cave(floor_ptr);
+ /* Mega-Hack -- no player yet */
+ p_ptr->x = p_ptr->y = 0;
+
+
/* Fill the arrays of floors and walls in the good proportions */
set_floor_and_wall(0);
for (x = 0; x < MAX_WID; x++)
{
/* Create "solid" perma-wall */
- place_solid_perm_bold(y, x);
+ place_solid_perm_bold(floor_ptr, y, x);
}
}
p_ptr->x = floor_ptr->width / 2;
/* Give one square */
- place_floor_bold(p_ptr->y, p_ptr->x);
+ place_floor_bold(floor_ptr, p_ptr->y, p_ptr->x);
wipe_generate_random_floor_flags(floor_ptr);
}
* @brief フロア移動時のペット保存処理 / Preserve_pets
* @return なし
*/
-static void preserve_pet(void)
+static void preserve_pet(player_type *master_ptr)
{
int num;
MONSTER_IDX i;
party_mon[num].r_idx = 0;
}
- if (p_ptr->riding)
+ if (master_ptr->riding)
{
- monster_type *m_ptr = &p_ptr->current_floor_ptr->m_list[p_ptr->riding];
+ monster_type *m_ptr = &master_ptr->current_floor_ptr->m_list[master_ptr->riding];
/* Pet of other pet don't follow. */
if (m_ptr->parent_m_idx)
{
- p_ptr->riding = 0;
- p_ptr->pet_extra_flags &= ~(PF_RYOUTE);
- p_ptr->riding_ryoute = p_ptr->old_riding_ryoute = FALSE;
+ master_ptr->riding = 0;
+ master_ptr->pet_extra_flags &= ~(PF_RYOUTE);
+ master_ptr->riding_ryoute = master_ptr->old_riding_ryoute = FALSE;
}
else
{
(void)COPY(&party_mon[0], m_ptr, monster_type);
/* Delete from this floor */
- delete_monster_idx(p_ptr->riding);
+ delete_monster_idx(master_ptr->riding);
}
}
* If player is in wild mode, no pets are preserved
* except a monster whom player riding
*/
- if (!p_ptr->wild_mode && !p_ptr->inside_arena && !p_ptr->phase_out)
+ if (!master_ptr->wild_mode && !master_ptr->current_floor_ptr->inside_arena && !master_ptr->phase_out)
{
- for (i = p_ptr->current_floor_ptr->m_max - 1, num = 1; (i >= 1 && num < MAX_PARTY_MON); i--)
+ for (i = master_ptr->current_floor_ptr->m_max - 1, num = 1; (i >= 1 && num < MAX_PARTY_MON); i--)
{
- monster_type *m_ptr = &p_ptr->current_floor_ptr->m_list[i];
+ monster_type *m_ptr = &master_ptr->current_floor_ptr->m_list[i];
if (!monster_is_valid(m_ptr)) continue;
if (!is_pet(m_ptr)) continue;
- if (i == p_ptr->riding) continue;
+ if (i == master_ptr->riding) continue;
if (reinit_wilderness)
{
}
else
{
- POSITION dis = distance(p_ptr->y, p_ptr->x, m_ptr->fy, m_ptr->fx);
+ POSITION dis = distance(master_ptr->y, master_ptr->x, m_ptr->fy, m_ptr->fx);
/* Confused (etc.) monsters don't follow. */
if (MON_CONFUSED(m_ptr) || MON_STUNNED(m_ptr) || MON_CSLEEP(m_ptr)) continue;
* when you or the pet can see the other.
*/
if (m_ptr->nickname &&
- ((player_has_los_bold(m_ptr->fy, m_ptr->fx) && projectable(p_ptr->y, p_ptr->x, m_ptr->fy, m_ptr->fx)) ||
- (los(m_ptr->fy, m_ptr->fx, p_ptr->y, p_ptr->x) && projectable(m_ptr->fy, m_ptr->fx, p_ptr->y, p_ptr->x))))
+ ((player_has_los_bold(master_ptr, m_ptr->fy, m_ptr->fx) && projectable(master_ptr->current_floor_ptr, master_ptr->y, master_ptr->x, m_ptr->fy, m_ptr->fx)) ||
+ (los(master_ptr->current_floor_ptr, m_ptr->fy, m_ptr->fx, master_ptr->y, master_ptr->x) && projectable(master_ptr->current_floor_ptr, m_ptr->fy, m_ptr->fx, master_ptr->y, master_ptr->x))))
{
if (dis > 3) continue;
}
}
}
- (void)COPY(&party_mon[num], &p_ptr->current_floor_ptr->m_list[i], monster_type);
+ (void)COPY(&party_mon[num], &master_ptr->current_floor_ptr->m_list[i], monster_type);
num++;
if (record_named_pet)
{
- for (i = p_ptr->current_floor_ptr->m_max - 1; i >=1; i--)
+ for (i = master_ptr->current_floor_ptr->m_max - 1; i >=1; i--)
{
- monster_type *m_ptr = &p_ptr->current_floor_ptr->m_list[i];
+ monster_type *m_ptr = &master_ptr->current_floor_ptr->m_list[i];
GAME_TEXT m_name[MAX_NLEN];
if (!monster_is_valid(m_ptr)) continue;
if (!is_pet(m_ptr)) continue;
if (!m_ptr->nickname) continue;
- if (p_ptr->riding == i) continue;
+ if (master_ptr->riding == i) continue;
monster_desc(m_name, m_ptr, MD_ASSUME_VISIBLE | MD_INDEF_VISIBLE);
- exe_write_diary(p_ptr, NIKKI_NAMED_PET, RECORD_NAMED_PET_MOVED, m_name);
+ exe_write_diary(master_ptr, NIKKI_NAMED_PET, RECORD_NAMED_PET_MOVED, m_name);
}
}
/* Pet of other pet may disappear. */
- for (i = p_ptr->current_floor_ptr->m_max - 1; i >=1; i--)
+ for (i = master_ptr->current_floor_ptr->m_max - 1; i >=1; i--)
{
- monster_type *m_ptr = &p_ptr->current_floor_ptr->m_list[i];
+ monster_type *m_ptr = &master_ptr->current_floor_ptr->m_list[i];
/* Are there its parent? */
- if (m_ptr->parent_m_idx && !p_ptr->current_floor_ptr->m_list[m_ptr->parent_m_idx].r_idx)
+ if (m_ptr->parent_m_idx && !master_ptr->current_floor_ptr->m_list[m_ptr->parent_m_idx].r_idx)
{
/* Its parent have gone, it also goes away. */
m_ptr->fy = cy;
m_ptr->fx = cx;
+ m_ptr->current_floor_ptr = master_ptr->current_floor_ptr;
m_ptr->ml = TRUE;
m_ptr->mtimed[MTIMED_CSLEEP] = 0;
m_ptr->hold_o_idx = 0;
/* Must repair monsters */
repair_monsters = TRUE;
}
- update_monster(m_idx, TRUE);
+ update_monster(master_ptr, m_idx, TRUE);
lite_spot(cy, cx);
/* Pre-calculated in precalc_cur_num_of_pet() */
* while new floor creation since dungeons may be re-created by\n
* auto-scum option.\n
*/
-static void update_unique_artifact(s16b cur_floor_id)
+static void update_unique_artifact(floor_type *floor_ptr, s16b cur_floor_id)
{
int i;
/* Maintain unique monsters */
- for (i = 1; i < p_ptr->current_floor_ptr->m_max; i++)
+ for (i = 1; i < floor_ptr->m_max; i++)
{
monster_race *r_ptr;
- monster_type *m_ptr = &p_ptr->current_floor_ptr->m_list[i];
+ monster_type *m_ptr = &floor_ptr->m_list[i];
if (!monster_is_valid(m_ptr)) continue;
}
/* Maintain artifatcs */
- for (i = 1; i < p_ptr->current_floor_ptr->o_max; i++)
+ for (i = 1; i < floor_ptr->o_max; i++)
{
- object_type *o_ptr = &p_ptr->current_floor_ptr->o_list[i];
+ object_type *o_ptr = &floor_ptr->o_list[i];
if (!OBJECT_IS_VALID(o_ptr)) continue;
if (!in_bounds(floor_ptr, ny, nx)) continue;
/* Require "empty" floor space */
- if (!cave_empty_bold(ny, nx)) continue;
+ if (!cave_empty_bold(p_ptr->current_floor_ptr, ny, nx)) continue;
/* Hack -- no teleport onto glyph of warding */
if (is_glyph_grid(&floor_ptr->grid_array[ny][nx])) continue;
* @param sf_ptr 移動元の保存フロア構造体参照ポインタ
* @return なし
*/
-static void locate_connected_stairs(saved_floor_type *sf_ptr, BIT_FLAGS floor_mode)
+static void locate_connected_stairs(player_type *creature_ptr, floor_type *floor_ptr, saved_floor_type *sf_ptr, BIT_FLAGS floor_mode)
{
POSITION x, y, sx = 0, sy = 0;
POSITION x_table[20];
int i;
/* Search usable stairs */
- for (y = 0; y < p_ptr->current_floor_ptr->height; y++)
+ for (y = 0; y < floor_ptr->height; y++)
{
- for (x = 0; x < p_ptr->current_floor_ptr->width; x++)
+ for (x = 0; x < floor_ptr->width; x++)
{
- grid_type *g_ptr = &p_ptr->current_floor_ptr->grid_array[y][x];
+ grid_type *g_ptr = &floor_ptr->grid_array[y][x];
feature_type *f_ptr = &f_info[g_ptr->feat];
bool ok = FALSE;
if (sx)
{
/* Already fixed */
- p_ptr->y = sy;
- p_ptr->x = sx;
+ creature_ptr->y = sy;
+ creature_ptr->x = sx;
}
else if (!num)
{
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(p_ptr->current_floor_ptr->grid_array[p_ptr->y][p_ptr->x].feat)) p_ptr->current_floor_ptr->grid_array[p_ptr->y][p_ptr->x].special = 0;
+ if (!feat_uses_special(floor_ptr->grid_array[creature_ptr->y][creature_ptr->x].feat)) floor_ptr->grid_array[creature_ptr->y][creature_ptr->x].special = 0;
}
else
{
i = randint0(num);
/* Point stair location */
- p_ptr->y = y_table[i];
- p_ptr->x = x_table[i];
+ creature_ptr->y = y_table[i];
+ creature_ptr->x = x_table[i];
}
}
FLOOR_IDX tmp_floor_idx = 0;
/* Preserve pets and prepare to take these to next floor */
- preserve_pet();
+ preserve_pet(creature_ptr);
/* Remove all mirrors without explosion */
- remove_all_mirrors(FALSE);
+ remove_all_mirrors(creature_ptr, FALSE);
if (creature_ptr->special_defense & NINJA_S_STEALTH) set_superstealth(creature_ptr, FALSE);
/* Choose random stairs */
if ((creature_ptr->change_floor_mode & CFM_RAND_CONNECT) && tmp_floor_idx)
{
- locate_connected_stairs(sf_ptr, creature_ptr->change_floor_mode);
+ locate_connected_stairs(creature_ptr, creature_ptr->current_floor_ptr, sf_ptr, creature_ptr->change_floor_mode);
}
/* Extract new dungeon level */
/* Get out of the my way! */
get_out_monster(p_ptr->current_floor_ptr, creature_ptr);
- /* Record the last visit current_world_ptr->game_turn of current floor */
+ /* Record the last visit turn of current floor */
sf_ptr->last_visit = current_world_ptr->game_turn;
forget_lite(p_ptr->current_floor_ptr);
- forget_view();
+ forget_view(p_ptr->current_floor_ptr);
clear_mon_lite(p_ptr->current_floor_ptr);
/* Save current floor */
* @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 p_ptr->current_floor_ptr->grid_array\n
+ * restored from the temporal file. If the floor is new one, new floor\n
* will be generated.\n
*/
void change_floor(player_type *creature_ptr)
if (!(creature_ptr->change_floor_mode & CFM_SAVE_FLOORS) &&
!(creature_ptr->change_floor_mode & CFM_FIRST_FLOOR))
{
- /* Create creature_ptr->current_floor_ptr->grid_array */
- generate_random_floor(creature_ptr->current_floor_ptr);
+ generate_floor(creature_ptr->current_floor_ptr);
/* Paranoia -- No new saved floor */
new_floor_id = 0;
}
}
- (void)place_quest_monsters(creature_ptr->current_floor_ptr);
+ (void)place_quest_monsters(creature_ptr->current_floor_ptr, creature_ptr);
/* Place some random monsters */
alloc_times = absence_ticks / alloc_chance;
}
else
{
- /* Newly create creature_ptr->current_floor_ptr->grid_array */
- generate_random_floor(creature_ptr->current_floor_ptr);
+ generate_floor(creature_ptr->current_floor_ptr);
}
- /* Record last visit current_world_ptr->game_turn */
+ /* Record last visit turn */
sf_ptr->last_visit = current_world_ptr->game_turn;
- /* Set correct creature_ptr->current_floor_ptr->dun_level value */
+ /* Set correct dun_level value */
sf_ptr->dun_level = creature_ptr->current_floor_ptr->dun_level;
/* Create connected stairs */
/* Arrive at random grid */
if (creature_ptr->change_floor_mode & (CFM_RAND_PLACE))
{
- (void)new_player_spot();
+ (void)new_player_spot(creature_ptr);
}
/* You see stairs blocked */
/*
* Update visit mark
*
- * 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
+ * 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
* oldest saved floor.
*/
sf_ptr->visit_mark = latest_visit_mark++;
place_pet(creature_ptr);
/* Reset travel target place */
- forget_travel_flow();
+ forget_travel_flow(creature_ptr->current_floor_ptr);
/* Hack -- maintain unique and artifacts */
- update_unique_artifact(new_floor_id);
+ update_unique_artifact(creature_ptr->current_floor_ptr, new_floor_id);
/* Now the player is in new floor */
creature_ptr->floor_id = new_floor_id;