Angband
Data Structures | Macros | Typedefs | Enumerations | Functions | Variables
cave.h File Reference

Matters relating to the current dungeon level. More...

#include "z-type.h"
#include "z-bitflag.h"
#include "list-square-flags.h"
#include "list-terrain-flags.h"

Go to the source code of this file.

Data Structures

struct  feature
 Information about terrain features. More...
struct  grid_data
struct  square
struct  chunk

Macros

#define SQUARE(a, b)   SQUARE_##a,
#define SQUARE_SIZE   FLAG_SIZE(SQUARE_MAX)
#define sqinfo_has(f, flag)   flag_has_dbg(f, SQUARE_SIZE, flag, #f, #flag)
#define sqinfo_next(f, flag)   flag_next(f, SQUARE_SIZE, flag)
#define sqinfo_is_empty(f)   flag_is_empty(f, SQUARE_SIZE)
#define sqinfo_is_full(f)   flag_is_full(f, SQUARE_SIZE)
#define sqinfo_is_inter(f1, f2)   flag_is_inter(f1, f2, SQUARE_SIZE)
#define sqinfo_is_subset(f1, f2)   flag_is_subset(f1, f2, SQUARE_SIZE)
#define sqinfo_is_equal(f1, f2)   flag_is_equal(f1, f2, SQUARE_SIZE)
#define sqinfo_on(f, flag)   flag_on_dbg(f, SQUARE_SIZE, flag, #f, #flag)
#define sqinfo_off(f, flag)   flag_off(f, SQUARE_SIZE, flag)
#define sqinfo_wipe(f)   flag_wipe(f, SQUARE_SIZE)
#define sqinfo_setall(f)   flag_setall(f, SQUARE_SIZE)
#define sqinfo_negate(f)   flag_negate(f, SQUARE_SIZE)
#define sqinfo_copy(f1, f2)   flag_copy(f1, f2, SQUARE_SIZE)
#define sqinfo_union(f1, f2)   flag_union(f1, f2, SQUARE_SIZE)
#define sqinfo_comp_union(f1, f2)   flag_comp_union(f1, f2, SQUARE_SIZE)
#define sqinfo_inter(f1, f2)   flag_inter(f1, f2, SQUARE_SIZE)
#define sqinfo_diff(f1, f2)   flag_diff(f1, f2, SQUARE_SIZE)
#define TF(a, b)   TF_##a,
#define TF_SIZE   FLAG_SIZE(TF_MAX)
#define tf_has(f, flag)   flag_has_dbg(f, TF_SIZE, flag, #f, #flag)

Typedefs

typedef struct feature feature_type
 Information about terrain features.
typedef bool(* square_predicate )(struct chunk *c, int y, int x)
 square_predicate is a function pointer which tests a given square to see if the predicate in question is true.

Enumerations

enum  { SQUARE_MAX }
 Square flags. More...
enum  { TF_MAX }
 Terrain flags. More...
enum  grid_light_level {
  LIGHTING_LOS = 0, LIGHTING_TORCH, LIGHTING_LIT, LIGHTING_DARK,
  LIGHTING_MAX
}

Functions

int distance (int y1, int x1, int y2, int x2)
 Approximate distance between two points.
bool los (struct chunk *c, int y1, int x1, int y2, int x2)
 A simple, fast, integer-based line-of-sight algorithm.
void forget_view (struct chunk *c)
 The comments below are still predominantly true, and have been left (slightly modified for accuracy) for historical and nostalgic reasons.
void update_view (struct chunk *c, struct player *p)
 update the player's current view
bool player_has_los_bold (int y, int x)
 Determine if a "legal" grid is within "los" of the player.
bool player_can_see_bold (int y, int x)
 Determine if a "legal" grid can be "seen" by the player.
bool no_light (void)
 Returns true if the player's grid is dark.
void map_info (unsigned x, unsigned y, grid_data *g)
 This function takes a grid location (x, y) and extracts information the player is allowed to know about it, filling in the grid_data structure passed in 'g'.
void square_note_spot (struct chunk *c, int y, int x)
 Memorize interesting viewable object/features in the given grid.
void square_light_spot (struct chunk *c, int y, int x)
 Tell the UI that a given map location has been updated.
void light_room (int y1, int x1, bool light)
 Illuminate or darken any room containing the given location.
void wiz_light (struct chunk *c, bool full)
 Light up the dungeon using "claravoyance".
void wiz_dark (void)
 Forget the dungeon map (ala "Thinking of Maud...").
void cave_illuminate (struct chunk *c, bool daytime)
 Light or Darken the town.
void cave_update_flow (struct chunk *c)
void cave_forget_flow (struct chunk *c)
 Forget the "flow" information ready for a complete update.
bool feat_is_magma (int feat)
 FEATURE PREDICATES.
bool feat_is_quartz (int feat)
 True if the square is a quartz wall.
bool feat_is_treasure (int feat)
 True if the square is a mineral wall with treasure (magma/quartz).
bool feat_is_wall (int feat)
 True is the feature is a solid wall (not rubble).
bool feat_is_monster_walkable (int feat)
 True if a monster can walk through the feature.
bool feat_is_shop (int feat)
 True if the feature is a shop entrance.
bool feat_is_passable (int feat)
 True if the feature is passable by the player.
bool feat_is_projectable (int feat)
 True if any projectable can pass through the feature.
bool feat_isboring (feature_type *f_ptr)
bool square_isfloor (struct chunk *c, int y, int x)
 SQUARE FEATURE PREDICATES.
bool square_isrock (struct chunk *c, int y, int x)
 True if the square is a normal granite rock wall.
bool square_isperm (struct chunk *c, int y, int x)
 True if the square is a permanent wall.
bool square_ismagma (struct chunk *c, int y, int x)
 True if the square is a magma wall.
bool square_isquartz (struct chunk *c, int y, int x)
 True if the square is a quartz wall.
bool square_ismineral (struct chunk *c, int y, int x)
 True if the square is a mineral wall (magma/quartz).
bool square_hasgoldvein (struct chunk *c, int y, int x)
bool square_isrubble (struct chunk *c, int y, int x)
 True if the square is rubble.
bool square_issecretdoor (struct chunk *c, int y, int x)
 True if the square is a hidden secret door.
bool square_isopendoor (struct chunk *c, int y, int x)
 True if the square is an open door.
bool square_iscloseddoor (struct chunk *c, int y, int x)
 True if the square is a closed door (possibly locked or jammed).
bool square_islockeddoor (struct chunk *c, int y, int x)
 True if the square is a closed, locked door.
bool square_isbrokendoor (struct chunk *c, int y, int x)
bool square_isdoor (struct chunk *c, int y, int x)
 True if the square is a door.
bool square_isstairs (struct chunk *c, int y, int x)
 True if square is any stair.
bool square_isupstairs (struct chunk *c, int y, int x)
 True if square is an up stair.
bool square_isdownstairs (struct chunk *c, int y, int x)
 True if square is a down stair.
bool square_isshop (struct chunk *c, int y, int x)
 True if the square is a shop entrance.
bool square_noticeable (struct chunk *c, int y, int x)
bool square_isplayer (struct chunk *c, int y, int x)
 True if the square contains the player.
bool square_ismark (struct chunk *c, int y, int x)
 SQUARE INFO PREDICATES.
bool square_isglow (struct chunk *c, int y, int x)
 True if the square is lit.
bool square_isvault (struct chunk *c, int y, int x)
 True if the square is part of a vault.
bool square_isroom (struct chunk *c, int y, int x)
 True if the square is part of a room.
bool square_isseen (struct chunk *c, int y, int x)
 True if the square has been seen by the player.
bool square_isview (struct chunk *c, int y, int x)
 True if the cave square is currently viewable by the player.
bool square_wasseen (struct chunk *c, int y, int x)
 True if the cave square was seen before the current update.
bool square_isdtrap (struct chunk *c, int y, int x)
 True if the square has been detected for traps.
bool square_isfeel (struct chunk *c, int y, int x)
 True if cave square is a feeling trigger square.
bool square_isdedge (struct chunk *c, int y, int x)
 True if the square is on the trap detection edge.
bool square_istrap (struct chunk *c, int y, int x)
 True if the square has a known trap.
bool square_isinvis (struct chunk *c, int y, int x)
 True if the square has an unknown trap.
bool square_iswall_inner (struct chunk *c, int y, int x)
 True if cave square is an inner wall (generation)
bool square_iswall_outer (struct chunk *c, int y, int x)
 True if cave square is an outer wall (generation)
bool square_iswall_solid (struct chunk *c, int y, int x)
 True if cave square is a solid wall (generation)
bool square_ismon_restrict (struct chunk *c, int y, int x)
 True if cave square has monster restrictions (generation)
bool square_isno_teleport (struct chunk *c, int y, int x)
 True if cave square can't be teleported from by the player.
bool square_isno_map (struct chunk *c, int y, int x)
 True if cave square can't be magically mapped by the player.
bool square_isno_esp (struct chunk *c, int y, int x)
 True if cave square can't be detected by player ESP.
bool square_isproject (struct chunk *c, int y, int x)
 True if cave square is marked for projection processing.
bool square_isopen (struct chunk *c, int y, int x)
 SQUARE BEHAVIOR PREDICATES.
bool square_isempty (struct chunk *c, int y, int x)
 True if the square is empty (an open square without any items).
bool square_canputitem (struct chunk *c, int y, int x)
 True if the square is a floor square without items.
bool square_isdiggable (struct chunk *c, int y, int x)
 True if the square can be dug: this includes rubble and non-permanent walls.
bool square_is_monster_walkable (struct chunk *c, int y, int x)
 True if a monster can walk through the tile.
bool square_ispassable (struct chunk *c, int y, int x)
 True if the square is passable by the player.
bool square_isprojectable (struct chunk *c, int y, int x)
 True if any projectable can pass through the square.
bool square_iswall (struct chunk *c, int y, int x)
 True if the square is a wall square (impedes the player).
bool square_isstrongwall (struct chunk *c, int y, int x)
 True if the square is a permanent wall or one of the "stronger" walls.
bool square_isboring (struct chunk *c, int y, int x)
 True if the cave square is "boring".
bool square_iswarded (struct chunk *c, int y, int x)
bool square_canward (struct chunk *c, int y, int x)
bool square_seemslikewall (struct chunk *c, int y, int x)
bool square_isinteresting (struct chunk *c, int y, int x)
bool square_isplayertrap (struct chunk *c, int y, int x)
 True if there is a player trap (known or unknown) in this square.
bool square_isvisibletrap (struct chunk *c, int y, int x)
 True if there is a visible trap in this square.
bool square_issecrettrap (struct chunk *c, int y, int x)
 True if the square is an unknown player trap (it will appear as a floor tile)
bool square_isknowntrap (struct chunk *c, int y, int x)
 True if the square is a known player trap.
bool square_changeable (struct chunk *c, int y, int x)
 Determine if a given location may be "destroyed".
bool square_dtrap_edge (struct chunk *c, int y, int x)
 Checks if a square is at the (inner) edge of a trap detect area.
bool square_in_bounds (struct chunk *c, int y, int x)
bool square_in_bounds_fully (struct chunk *c, int y, int x)
struct featuresquare_feat (struct chunk *c, int y, int x)
 OTHER SQUARE FUNCTIONS.
struct monstersquare_monster (struct chunk *c, int y, int x)
 Get a monster on the current level by its position.
struct objectsquare_object (struct chunk *c, int y, int x)
 Get the top object of a pile on the current level by its position.
bool square_holds_object (struct chunk *c, int y, int x, struct object *obj)
 Return TRUE if the given object is on the floor at this grid.
void square_excise_object (struct chunk *c, int y, int x, struct object *obj)
 Excise an object from a floor pile, leaving it orphaned.
void square_set_feat (struct chunk *c, int y, int x, int feat)
void square_add_trap (struct chunk *c, int y, int x)
void square_add_ward (struct chunk *c, int y, int x)
void square_add_stairs (struct chunk *c, int y, int x, int depth)
void square_add_door (struct chunk *c, int y, int x, bool closed)
void square_open_door (struct chunk *c, int y, int x)
void square_close_door (struct chunk *c, int y, int x)
void square_smash_door (struct chunk *c, int y, int x)
void square_lock_door (struct chunk *c, int y, int x, int power)
void square_unlock_door (struct chunk *c, int y, int x)
void square_destroy_door (struct chunk *c, int y, int x)
void square_show_trap (struct chunk *c, int y, int x, int type)
void square_destroy_trap (struct chunk *c, int y, int x)
void square_tunnel_wall (struct chunk *c, int y, int x)
void square_destroy_wall (struct chunk *c, int y, int x)
void square_destroy (struct chunk *c, int y, int x)
void square_earthquake (struct chunk *c, int y, int x)
void square_remove_ward (struct chunk *c, int y, int x)
void square_upgrade_mineral (struct chunk *c, int y, int x)
 Add visible treasure to a mineral square.
void square_destroy_rubble (struct chunk *c, int y, int x)
void square_force_floor (struct chunk *c, int y, int x)
int square_shopnum (struct chunk *c, int y, int x)
int square_digging (struct chunk *c, int y, int x)
const char * square_apparent_name (struct chunk *c, struct player *p, int y, int x)
void set_terrain (void)
 Set terrain constants to the indices from terrain.txt.
struct chunkcave_new (int height, int width)
 Allocate a new chunk of the world.
void cave_free (struct chunk *c)
 Free a chunk.
void scatter (struct chunk *c, int *yp, int *xp, int y, int x, int d, bool need_los)
 Standard "find me a location" function.
struct monstercave_monster (struct chunk *c, int idx)
 Get a monster on the current level by its index.
int cave_monster_max (struct chunk *c)
 The maximum number of monsters allowed in the level.
int cave_monster_count (struct chunk *c)
 The current number of monsters present on the level.
int count_feats (int *y, int *x, bool(*test)(struct chunk *cave, int y, int x), bool under)
void cave_generate (struct chunk **c, struct player *p)
 Generate a random level.
bool is_quest (int level)
 Check if the given level is a quest level.
void cave_known (void)

Variables

const s16b ddd [9]
const s16b ddx [10]
const s16b ddy [10]
const s16b ddx_ddd [9]
const s16b ddy_ddd [9]
feature_typef_info
int FEAT_NONE
int FEAT_FLOOR
int FEAT_CLOSED
int FEAT_OPEN
int FEAT_BROKEN
int FEAT_LESS
int FEAT_MORE
int FEAT_SECRET
int FEAT_RUBBLE
int FEAT_MAGMA
int FEAT_QUARTZ
int FEAT_MAGMA_K
int FEAT_QUARTZ_K
int FEAT_GRANITE
int FEAT_PERM
int FEAT_DTRAP_FLOOR
int FEAT_DTRAP_WALL
struct chunkcave
struct chunkcave_k
struct chunk ** chunk_list
u16b chunk_list_max

Detailed Description

Matters relating to the current dungeon level.

Copyright (c) 1997 Ben Harrison, James E. Wilson, Robert A. Koeneke

This work is free software; you can redistribute it and/or modify it under the terms of either:

a) the GNU General Public License as published by the Free Software Foundation, version 2, or

b) the "Angband licence": This software may be copied and distributed for educational, research, and not for profit purposes provided that this copyright and statement are included in all such copies. Other copyrights may also apply.

Macro Definition Documentation

#define sqinfo_comp_union (   f1,
  f2 
)    flag_comp_union(f1, f2, SQUARE_SIZE)
#define sqinfo_copy (   f1,
  f2 
)    flag_copy(f1, f2, SQUARE_SIZE)

Referenced by chunk_copy(), and chunk_write().

#define sqinfo_diff (   f1,
  f2 
)    flag_diff(f1, f2, SQUARE_SIZE)
#define sqinfo_has (   f,
  flag 
)    flag_has_dbg(f, SQUARE_SIZE, flag, #f, #flag)
#define sqinfo_inter (   f1,
  f2 
)    flag_inter(f1, f2, SQUARE_SIZE)
#define sqinfo_is_empty (   f)    flag_is_empty(f, SQUARE_SIZE)
#define sqinfo_is_equal (   f1,
  f2 
)    flag_is_equal(f1, f2, SQUARE_SIZE)
#define sqinfo_is_full (   f)    flag_is_full(f, SQUARE_SIZE)
#define sqinfo_is_inter (   f1,
  f2 
)    flag_is_inter(f1, f2, SQUARE_SIZE)
#define sqinfo_is_subset (   f1,
  f2 
)    flag_is_subset(f1, f2, SQUARE_SIZE)
#define sqinfo_negate (   f)    flag_negate(f, SQUARE_SIZE)
#define sqinfo_next (   f,
  flag 
)    flag_next(f, SQUARE_SIZE, flag)
#define sqinfo_off (   f,
  flag 
)    flag_off(f, SQUARE_SIZE, flag)
#define sqinfo_on (   f,
  flag 
)    flag_on_dbg(f, SQUARE_SIZE, flag, #f, #flag)
#define sqinfo_setall (   f)    flag_setall(f, SQUARE_SIZE)
#define sqinfo_union (   f1,
  f2 
)    flag_union(f1, f2, SQUARE_SIZE)
#define sqinfo_wipe (   f)    flag_wipe(f, SQUARE_SIZE)
#define SQUARE (   a,
 
)    SQUARE_##a,
#define SQUARE_SIZE   FLAG_SIZE(SQUARE_MAX)
#define TF (   a,
 
)    TF_##a,
#define tf_has (   f,
  flag 
)    flag_has_dbg(f, TF_SIZE, flag, #f, #flag)
#define TF_SIZE   FLAG_SIZE(TF_MAX)

Referenced by parse_feat_flags().

Typedef Documentation

typedef struct feature feature_type

Information about terrain features.

At the moment this isn't very much, but eventually a primitive flag-based information system will be used here.

typedef bool(* square_predicate)(struct chunk *c, int y, int x)

square_predicate is a function pointer which tests a given square to see if the predicate in question is true.

Enumeration Type Documentation

anonymous enum

Square flags.

Enumerator:
SQUARE_MAX 
anonymous enum

Terrain flags.

Enumerator:
TF_MAX 
Enumerator:
LIGHTING_LOS 
LIGHTING_TORCH 
LIGHTING_LIT 
LIGHTING_DARK 
LIGHTING_MAX 

Function Documentation

void cave_forget_flow ( struct chunk c)

Forget the "flow" information ready for a complete update.

References square::cost, flow_save, chunk::height, chunk::squares, square::when, and chunk::width.

Referenced by update_stuff().

void cave_free ( struct chunk c)
void cave_generate ( struct chunk **  c,
struct player p 
)
void cave_illuminate ( struct chunk c,
bool  daytime 
)
void cave_known ( void  )
struct monster* cave_monster ( struct chunk c,
int  idx 
)
read
int cave_monster_count ( struct chunk c)

The current number of monsters present on the level.

References chunk::mon_cnt.

Referenced by process_world().

int cave_monster_max ( struct chunk c)
struct chunk* cave_new ( int  height,
int  width 
)
read
void cave_update_flow ( struct chunk c)
int count_feats ( int y,
int x,
bool(*)(struct chunk *cave, int y, int x)  test,
bool  under 
)
int distance ( int  y1,
int  x1,
int  y2,
int  x2 
)

Approximate distance between two points.

When either the X or Y component dwarfs the other component, this function is almost perfect, and otherwise, it tends to over-estimate about one grid per fifteen grids of distance.

Algorithm: hypot(dy,dx) = max(dy,dx) + min(dy,dx) / 2

References abs.

Referenced by add_monster_lights(), chance_of_missile_hit(), effect_handler_DESTRUCTION(), effect_handler_EARTHQUAKE(), effect_handler_TELEPORT(), find_hiding(), find_safety(), generate_starburst_room(), get_moves_fear(), pick_and_place_distant_monster(), project(), ranged_helper(), scatter(), summon_possible(), target_set_interactive(), and update_view_one().

bool feat_is_magma ( int  feat)

FEATURE PREDICATES.

These functions test a terrain feature index for the obviously described type. They are used in the square feature predicates below, and occasionally on their own True if the square is a magma wall.

References f_info, flags, and tf_has.

Referenced by grid_get_attr(), and square_ismagma().

bool feat_is_monster_walkable ( int  feat)

True if a monster can walk through the feature.

References f_info, flags, and tf_has.

Referenced by square_is_monster_walkable().

bool feat_is_passable ( int  feat)

True if the feature is passable by the player.

References f_info, flags, and tf_has.

Referenced by square_ispassable().

bool feat_is_projectable ( int  feat)

True if any projectable can pass through the feature.

References f_info, flags, and tf_has.

Referenced by square_isprojectable().

bool feat_is_quartz ( int  feat)

True if the square is a quartz wall.

References f_info, flags, and tf_has.

Referenced by grid_get_attr(), and square_isquartz().

bool feat_is_shop ( int  feat)

True if the feature is a shop entrance.

References f_info, flags, and tf_has.

Referenced by build_store(), and square_isshop().

bool feat_is_treasure ( int  feat)

True if the square is a mineral wall with treasure (magma/quartz).

References f_info, flags, and tf_has.

Referenced by grid_get_attr().

bool feat_is_wall ( int  feat)

True is the feature is a solid wall (not rubble).

References f_info, flags, and tf_has.

Referenced by grid_get_attr().

bool feat_isboring ( feature_type f_ptr)
void forget_view ( struct chunk c)

The comments below are still predominantly true, and have been left (slightly modified for accuracy) for historical and nostalgic reasons.

Some comments on the dungeon related data structures and functions...

Angband is primarily a dungeon exploration game, and it should come as no surprise that the internal representation of the dungeon has evolved over time in much the same way as the game itself, to provide semantic changes to the game itself, to make the code simpler to understand, and to make the executable itself faster or more efficient in various ways.

There are a variety of dungeon related data structures, and associated functions, which store information about the dungeon, and provide methods by which this information can be accessed or modified.

Some of this information applies to the dungeon as a whole, such as the list of unique monsters which are still alive. Some of this information only applies to the current dungeon level, such as the current depth, or the list of monsters currently inhabiting the level. And some of the information only applies to a single grid of the current dungeon level, such as whether the grid is illuminated, or whether the grid contains a monster, or whether the grid can be seen by the player. If Angband was to be turned into a multi-player game, some of the information currently associated with the dungeon should really be associated with the player, such as whether a given grid is viewable by a given player.

Currently, a lot of the information about the dungeon is stored in ways that make it very efficient to access or modify the information, while still attempting to be relatively conservative about memory usage, even if this means that some information is stored in multiple places, or in ways which require the use of special code idioms. For example, each monster record in the monster array contains the location of the monster, and each cave grid has an index into the monster array, or a zero if no monster is in the grid. This allows the monster code to efficiently see where the monster is located, while allowing the dungeon code to quickly determine not only if a monster is present in a given grid, but also to find out which monster. The extra space used to store the information twice is inconsequential compared to the speed increase.

Several pieces of information about each cave grid are stored in the info field of the "cave->squares" array, which is a special array of bitflags.

The "SQUARE_ROOM" flag is used to determine which grids are part of "rooms", and thus which grids are affected by "illumination" spells.

The "SQUARE_VAULT" flag is used to determine which grids are part of "vaults", and thus which grids cannot serve as the destinations of player teleportation.

The "SQUARE_MARK" flag is used to determine which grids have been memorized by the player. This flag is used by the "map_info()" function to determine if a grid should be displayed. This flag is used in a few other places to determine if the player can * "know" about a given grid.

The "SQUARE_GLOW" flag is used to determine which grids are "permanently illuminated". This flag is used by the update_view() function to help determine which viewable flags may be "seen" by the player. This flag is used by the "map_info" function to determine if a grid is only lit by the player's torch. This flag has special semantics for wall grids (see "update_view()").

The "SQUARE_VIEW" flag is used to determine which grids are currently in line of sight of the player. This flag is set by (and used by) the "update_view()" function. This flag is used by any code which needs to know if the player can "view" a given grid. This flag is used by the "map_info()" function for some optional special lighting effects. The "player_has_los_bold()" macro wraps an abstraction around this flag, but certain code idioms are much more efficient. This flag is used to check if a modification to a terrain feature might affect the player's field of view. This flag is used to see if certain monsters are "visible" to the player. This flag is used to allow any monster in the player's field of view to "sense" the presence of the player.

The "SQUARE_SEEN" flag is used to determine which grids are currently in line of sight of the player and also illuminated in some way. This flag is set by the "update_view()" function, using computations based on the "SQUARE_VIEW" and "SQUARE_GLOW" flags and terrain of various grids. This flag is used by any code which needs to know if the player can "see" a given grid. This flag is used by the "map_info()" function both to see if a given "boring" grid can be seen by the player, and for some optional special lighting effects. The "player_can_see_bold()" macro wraps an abstraction around this flag, but certain code idioms are much more efficient. This flag is used to see if certain monsters are "visible" to the player. This flag is never set for a grid unless "SQUARE_VIEW" is also set for the grid. Whenever the terrain or "SQUARE_GLOW" flag changes for a grid which has the "SQUARE_VIEW" flag set, the "SQUARE_SEEN" flag must be recalculated. The simplest way to do this is to call "forget_view()" and "update_view()" whenever the terrain or "SQUARE_GLOW" flag changes for a grid which has "SQUARE_VIEW" set.

The "SQUARE_WASSEEN" flag is used for a variety of temporary purposes. This flag is used to determine if the "SQUARE_SEEN" flag for a grid has changed during the "update_view()" function. This flag is used to "spread" light or darkness through a room. This flag is used by the "monster flow code". This flag must always be cleared by any code which sets it.

Note that the "SQUARE_MARK" flag is used for many reasons, some of which are strictly for optimization purposes. The "SQUARE_MARK" flag means that even if the player cannot "see" the grid, he "knows" about the terrain in that grid. This is used to "memorize" grids when they are first "seen" by the player, and to allow certain grids to be "detected" by certain magic.

Objects are "memorized" in a different way, using a special "marked" flag on the object itself, which is set when an object is observed or detected. This allows objects to be "memorized" independant of the terrain features.

The "update_view()" function is an extremely important function. It is called only when the player moves, significant terrain changes, or the player's blindness or torch radius changes. Note that when the player is resting, or performing any repeated actions (like digging, disarming, farming, etc), there is no need to call the "update_view()" function, so even if it was not very efficient, this would really only matter when the player was "running" through the dungeon. It sets the "SQUARE_VIEW" flag on every cave grid in the player's field of view. It also checks the torch radius of the player, and sets the "SQUARE_SEEN" flag for every grid which is in the "field of view" of the player and which is also "illuminated", either by the players torch (if any) or by any permanent light source. It could use and help maintain information about multiple light sources, which would be helpful in a multi-player version of Angband.

Note that the "update_view()" function allows, among other things, a room to be "partially" seen as the player approaches it, with a growing cone of floor appearing as the player gets closer to the door. Also, by not turning on the "memorize perma-lit grids" option, the player will only "see" those floor grids which are actually in line of sight. And best of all, you can now activate the special lighting effects to indicate which grids are actually in the player's field of view by using dimmer colors for grids which are not in the player's field of view, and/or to indicate which grids are illuminated only by the player's torch by using the color yellow for those grids.

It seems as though slight modifications to the "update_view()" functions would allow us to determine "reverse" line-of-sight as well as "normal" line-of-sight", which would allow monsters to have a more "correct" way to determine if they can "see" the player, since right now, they "cheat" somewhat and assume that if the player has "line of sight" to them, then they can "pretend" that they have "line of sight" to the player. But if such a change was attempted, the monsters would actually start to exhibit some undesirable behavior, such as "freezing" near the entrances to long hallways containing the player, and code would have to be added to make the monsters move around even if the player was not detectable, and to "remember" where the player was last seen, to avoid looking stupid.

Note that the "SQUARE_GLOW" flag means that a grid is permanently lit in some way. However, for the player to "see" the grid, as determined by the "SQUARE_SEEN" flag, the player must not be blind, the grid must have the "SQUARE_VIEW" flag set, and if the grid is a "wall" grid, and it is not lit by the player's torch, then it must touch a projectable grid which has both the "SQUARE_GLOW" and "SQUARE_VIEW" flags set. This last part about wall grids is induced by the semantics of "SQUARE_GLOW" as applied to wall grids, and checking the technical requirements can be very expensive, especially since the grid may be touching some "illegal" grids. Luckily, it is more or less correct to restrict the "touching" grids from the eight "possible" grids to the (at most) three grids which are touching the grid, and which are closer to the player than the grid itself, which eliminates more than half of the work, including all of the potentially "illegal" grids, if at most one of the three grids is a "diagonal" grid. In addition, in almost every situation, it is possible to ignore the "SQUARE_VIEW" flag on these three "touching" grids, for a variety of technical reasons. Finally, note that in most situations, it is only necessary to check a single "touching" grid, in fact, the grid which is strictly closest to the player of all the touching grids, and in fact, it is normally only necessary to check the "SQUARE_GLOW" flag of that grid, again, for various technical reasons. However, one of the situations which does not work with this last reduction is the very common one in which the player approaches an illuminated room from a dark hallway, in which the two wall grids which form the "entrance" to the room would not be marked as "SQUARE_SEEN", since of the three "touching" grids nearer to the player than each wall grid, only the farthest of these grids is itself marked "SQUARE_GLOW".

Here are some pictures of the legal "light source" radius values, in which the numbers indicate the "order" in which the grids could have been calculated, if desired. Note that the code will work with larger radiuses, though currently yields such a radius, and the game would become slower in some situations if it did.

  Rad=0     Rad=1      Rad=2        Rad=3
 No-Light Torch,etc   Lantern     Artifacts

                                     333
                        333         43334
             212       32123       3321233
    @        1@1       31@13       331@133
             212       32123       3321233
                        333         43334
                                     333

Forget the "SQUARE_VIEW" grids, redrawing as needed

References chunk::height, square::info, sqinfo_off, square_isview(), square_light_spot(), chunk::squares, and chunk::width.

Referenced by on_leave_level(), textui_enter_store(), and update_stuff().

bool is_quest ( int  level)
void light_room ( int  y1,
int  x1,
bool  light 
)
bool los ( struct chunk c,
int  y1,
int  x1,
int  y2,
int  x2 
)

A simple, fast, integer-based line-of-sight algorithm.

By Joseph Hall, 4116 Brewster Drive, Raleigh NC 27606. Email to jnh@e.nosp@m.cemw.nosp@m.l.ncs.nosp@m.u.ed.nosp@m.u.

This function returns TRUE if a "line of sight" can be traced from the center of the grid (x1,y1) to the center of the grid (x2,y2), with all of the grids along this path (except for the endpoints) being non-wall grids. Actually, the "chess knight move" situation is handled by some special case code which allows the grid diagonally next to the player to be obstructed, because this yields better gameplay semantics. This algorithm is totally reflexive, except for "knight move" situations.

Because this function uses (short) ints for all calculations, overflow may occur if dx and dy exceed 90.

Once all the degenerate cases are eliminated, we determine the "slope" ("m"), and we use special "fixed point" mathematics in which we use a special "fractional component" for one of the two location components ("qy" or "qx"), which, along with the slope itself, are "scaled" by a scale factor equal to "abs(dy*dx*2)" to keep the math simple. Then we simply travel from start to finish along the longer axis, starting at the border between the first and second tiles (where the y offset is thus half the slope), using slope and the fractional component to see when motion along the shorter axis is necessary. Since we assume that vision is not blocked by "brushing" the corner of any grid, we must do some special checks to avoid testing grids which are "brushed" but not actually "entered".

Angband three different "line of sight" type concepts, including this function (which is used almost nowhere), the "project()" method (which is used for determining the paths of projectables and spells and such), and the "update_view()" concept (which is used to determine which grids are "viewable" by the player, which is used for many things, such as determining which grids are illuminated by the player's torch, and which grids and monsters can be "seen" by the player, etc).

References ABS, FALSE, square_isprojectable(), and TRUE.

Referenced by add_monster_lights(), can_call_monster(), drop_near(), monster_list_collect(), project(), scatter(), summon_possible(), and update_view_one().

void map_info ( unsigned  y,
unsigned  x,
grid_data g 
)

This function takes a grid location (x, y) and extracts information the player is allowed to know about it, filling in the grid_data structure passed in 'g'.

The information filled in is as follows:

  • g->f_idx is filled in with the terrain's feature type, or FEAT_NONE if the player doesn't know anything about the grid. The function makes use of the "mimic" field in terrain in order to allow one feature to look like another (hiding secret doors, invisible traps, etc). This will return the terrain type the player "Knows" about, not necessarily the real terrain.
  • g->m_idx is set to the monster index, or 0 if there is none (or the player doesn't know it).
  • g->first_kind is set to the object_kind of the first object in a grid that the player knows about, or NULL for no objects.
  • g->muliple_objects is TRUE if there is more than one object in the grid that the player knows and cares about (to facilitate any special floor stack symbol that might be used).
  • g->in_view is TRUE if the player can currently see the grid - this can be used to indicate field-of-view, such as through the OPT(view_bright_light) option.
  • g->lighting is set to indicate the lighting level for the grid: LIGHTING_DARK for unlit grids, LIGHTING_LIT for inherently light grids (lit rooms, etc), LIGHTING_TORCH for grids lit by the player's light source, and LIGHTING_LOS for grids in the player's line of sight. Note that lighting is always LIGHTING_LIT for known "interesting" grids like walls.
  • g->is_player is TRUE if the player is on the given grid.
  • g->hallucinate is TRUE if the player is hallucinating something "strange" for this grid - this should pick a random monster to show if the m_idx is non-zero, and a random object if first_kind is non-zero.

NOTES: This is called pretty frequently, whenever a grid on the map display needs updating, so don't overcomplicate it.

Terrain is remembered separately from objects and monsters, so can be shown even when the player can't "see" it. This leads to things like doors out of the player's view still change from closed to open and so on.

TODO: Hallucination is currently disabled (it was a display-level hack before, and we need it to be a knowledge-level hack). The idea is that objects may turn into different objects, monsters into different monsters, and terrain may be objects, monsters, or stay the same.

References cave, cave_k, cave_monster(), grid_data::f_idx, f_info, FALSE, square::feat, FEAT_NONE, FEAT_PERM, grid_data::first_kind, trap::flags, grid_data::hallucinate, chunk::height, ignore_item_ok(), grid_data::in_view, grid_data::is_player, k_info, object::kind, grid_data::lighting, LIGHTING_DARK, LIGHTING_LIT, LIGHTING_LOS, LIGHTING_TORCH, grid_data::m_idx, MARK_AWARE, MARK_SEEN, object::marked, monster::mflag, mflag_has, feature::mimic, square::mon, chunk::mon_max, grid_data::multiple_objects, trap::next, object::next, one_in_, OPT, square_isdedge(), square_isglow(), square_ismark(), square_isseen(), square_istrap(), square_object(), chunk::squares, player::timed, grid_data::trap, square::trap, grid_data::trapborder, trf_has, TRUE, tval_is_money(), grid_data::unseen_money, grid_data::unseen_object, and chunk::width.

Referenced by display_map(), is_unknown(), prt_map(), prt_map_aux(), and update_maps().

bool no_light ( void  )
bool player_can_see_bold ( int  y,
int  x 
)
bool player_has_los_bold ( int  y,
int  x 
)
void scatter ( struct chunk c,
int yp,
int xp,
int  y,
int  x,
int  d,
bool  need_los 
)

Standard "find me a location" function.

Obtains a legal location within the given distance of the initial location, and with "los()" from the source to destination location.

This function is often called from inside a loop which searches for locations while increasing the "d" distance.

need_los determines whether line of sight is needed

References distance(), los(), rand_spread, square_in_bounds_fully(), and TRUE.

Referenced by build_quest_stairs(), do_cmd_wiz_named(), multiply_monster(), place_friends(), summon_specific(), and vault_monsters().

void set_terrain ( void  )
void square_add_door ( struct chunk c,
int  y,
int  x,
bool  closed 
)
void square_add_stairs ( struct chunk c,
int  y,
int  x,
int  depth 
)
void square_add_trap ( struct chunk c,
int  y,
int  x 
)

References chunk::depth, and place_trap().

Referenced by get_debug_command().

void square_add_ward ( struct chunk c,
int  y,
int  x 
)
const char* square_apparent_name ( struct chunk c,
struct player p,
int  y,
int  x 
)
bool square_canputitem ( struct chunk c,
int  y,
int  x 
)

True if the square is a floor square without items.

References square_isfloor(), and square_object().

Referenced by drop_near(), place_gold(), place_object(), place_random_stairs(), and vault_objects().

bool square_canward ( struct chunk c,
int  y,
int  x 
)

References square_isfloor().

Referenced by effect_handler_RUNE().

bool square_changeable ( struct chunk c,
int  y,
int  x 
)

Determine if a given location may be "destroyed".

Used by destruction spells, and for placing stairs, etc.

References object::artifact, FALSE, object::next, square_isperm(), square_isshop(), square_isstairs(), square_object(), and TRUE.

Referenced by build_quest_stairs(), and effect_handler_EARTHQUAKE().

void square_close_door ( struct chunk c,
int  y,
int  x 
)

References FEAT_CLOSED, and square_set_feat().

Referenced by do_cmd_close_aux().

void square_destroy ( struct chunk c,
int  y,
int  x 
)
void square_destroy_door ( struct chunk c,
int  y,
int  x 
)
void square_destroy_rubble ( struct chunk c,
int  y,
int  x 
)
void square_destroy_trap ( struct chunk c,
int  y,
int  x 
)
void square_destroy_wall ( struct chunk c,
int  y,
int  x 
)
int square_digging ( struct chunk c,
int  y,
int  x 
)
bool square_dtrap_edge ( struct chunk c,
int  y,
int  x 
)

Checks if a square is at the (inner) edge of a trap detect area.

References FALSE, square_in_bounds_fully(), square_isdtrap(), and TRUE.

Referenced by effect_handler_DETECT_TRAPS().

void square_earthquake ( struct chunk c,
int  y,
int  x 
)
void square_excise_object ( struct chunk c,
int  y,
int  x,
struct object obj 
)

Excise an object from a floor pile, leaving it orphaned.

References square::obj, pile_excise(), and chunk::squares.

Referenced by floor_carry(), floor_object_for_use(), player_pickup_aux(), player_pickup_gold(), process_monster_grab_objects(), project_o(), and wield_item().

struct feature* square_feat ( struct chunk c,
int  y,
int  x 
)
read

OTHER SQUARE FUNCTIONS.

Below are various square-specific functions which are not predicates

References f_info, square::feat, height, chunk::squares, and width.

Referenced by push_object().

void square_force_floor ( struct chunk c,
int  y,
int  x 
)

References FEAT_FLOOR, and square_set_feat().

Referenced by push_object().

bool square_hasgoldvein ( struct chunk c,
int  y,
int  x 
)
bool square_holds_object ( struct chunk c,
int  y,
int  x,
struct object obj 
)

Return TRUE if the given object is on the floor at this grid.

References pile_contains(), and square_object().

Referenced by player_pickup_item(), and wield_item().

bool square_in_bounds ( struct chunk c,
int  y,
int  x 
)
bool square_in_bounds_fully ( struct chunk c,
int  y,
int  x 
)
bool square_is_monster_walkable ( struct chunk c,
int  y,
int  x 
)

True if a monster can walk through the tile.

This is needed for polymorphing. A monster may be on a feature that isn't an empty space, causing problems when it is replaced with a new monster.

References square::feat, feat_is_monster_walkable(), square_in_bounds(), and chunk::squares.

Referenced by place_new_monster_one().

bool square_isboring ( struct chunk c,
int  y,
int  x 
)

True if the cave square is "boring".

References square::feat, feat_is_boring(), square_in_bounds(), and chunk::squares.

Referenced by target_accept().

bool square_isbrokendoor ( struct chunk c,
int  y,
int  x 
)
bool square_iscloseddoor ( struct chunk c,
int  y,
int  x 
)
bool square_isdedge ( struct chunk c,
int  y,
int  x 
)

True if the square is on the trap detection edge.

References square::info, sqinfo_has, square_in_bounds(), and chunk::squares.

Referenced by map_info(), and prt_dtrap().

bool square_isdiggable ( struct chunk c,
int  y,
int  x 
)

True if the square can be dug: this includes rubble and non-permanent walls.

References square_ismineral(), square_isrubble(), and square_issecretdoor().

Referenced by context_menu_cave(), do_cmd_alter_aux(), do_cmd_tunnel_test(), square_digging(), and twall().

bool square_isdoor ( struct chunk c,
int  y,
int  x 
)
bool square_isdownstairs ( struct chunk c,
int  y,
int  x 
)

True if square is a down stair.

References f_info, square::feat, flags, chunk::squares, and tf_has.

Referenced by context_menu_player(), do_cmd_go_down(), labyrinth_gen(), and textui_process_click().

bool square_isdtrap ( struct chunk c,
int  y,
int  x 
)

True if the square has been detected for traps.

References square::info, sqinfo_has, square_in_bounds(), and chunk::squares.

Referenced by move_player(), prt_dtrap(), and square_dtrap_edge().

bool square_isempty ( struct chunk c,
int  y,
int  x 
)
bool square_isfeel ( struct chunk c,
int  y,
int  x 
)

True if cave square is a feeling trigger square.

References square::info, sqinfo_has, square_in_bounds(), and chunk::squares.

Referenced by place_feeling(), and update_one().

bool square_isfloor ( struct chunk c,
int  y,
int  x 
)

SQUARE FEATURE PREDICATES.

These functions are used to figure out what kind of square something is, via c->squares[y][x].feat. All direct testing of c->squares[y][x].feat should be rewritten in terms of these functions.

It's often better to use square behavior predicates (written in terms of these functions) instead of these functions directly. For instance, square_isrock() will return false for a secret door, even though it will behave like a rock wall until the player determines it's a door.

Use functions like square_isdiggable, square_iswall, etc. in these cases. True if the square is normal open floor.

References f_info, square::feat, feature::flags, chunk::squares, and tf_has.

Referenced by count_adj_walls(), drop_near(), effect_handler_CREATE_STAIRS(), get_debug_command(), next_to_corr(), project_feature_handler_MAKE_DOOR(), square_canputitem(), square_canward(), square_isopen(), and wiz_light().

bool square_isglow ( struct chunk c,
int  y,
int  x 
)

True if the square is lit.

References square::info, sqinfo_has, square_in_bounds(), and chunk::squares.

Referenced by become_viewable(), map_info(), and update_view().

bool square_isinteresting ( struct chunk c,
int  y,
int  x 
)
bool square_isinvis ( struct chunk c,
int  y,
int  x 
)

True if the square has an unknown trap.

References square::info, sqinfo_has, square_in_bounds(), and chunk::squares.

bool square_isknowntrap ( struct chunk c,
int  y,
int  x 
)

True if the square is a known player trap.

References square_isplayertrap(), and square_isvisibletrap().

Referenced by context_menu_cave(), do_cmd_alter_aux(), do_cmd_disarm(), do_cmd_disarm_test(), and move_player().

bool square_islockeddoor ( struct chunk c,
int  y,
int  x 
)
bool square_ismagma ( struct chunk c,
int  y,
int  x 
)

True if the square is a magma wall.

References square::feat, feat_is_magma(), and chunk::squares.

Referenced by project_feature_handler_KILL_WALL(), and square_ismineral().

bool square_ismark ( struct chunk c,
int  y,
int  x 
)

SQUARE INFO PREDICATES.

These functions tell whether a square is marked with one of the SQUARE_* flags. These flags are mostly used to mark a square with some information about its location or status. True if a square's terrain is memorized by the player

References square::info, sqinfo_has, square_in_bounds(), and chunk::squares.

Referenced by count_feats(), do_cmd_close_test(), do_cmd_disarm_test(), do_cmd_open_test(), do_cmd_tunnel_test(), do_cmd_walk_test(), do_cmd_wiz_query(), draw_path(), is_valid_pf(), map_info(), move_player(), process_monster_glyph(), run_step(), run_test(), see_wall(), square_apparent_name(), square_note_spot(), and target_accept().

bool square_ismineral ( struct chunk c,
int  y,
int  x 
)

True if the square is a mineral wall (magma/quartz).

References square_ismagma(), square_isquartz(), and square_isrock().

Referenced by square_isdiggable(), and square_isstrongwall().

bool square_ismon_restrict ( struct chunk c,
int  y,
int  x 
)

True if cave square has monster restrictions (generation)

References square::info, sqinfo_has, square_in_bounds(), and chunk::squares.

Referenced by pick_and_place_distant_monster().

bool square_isno_esp ( struct chunk c,
int  y,
int  x 
)

True if cave square can't be detected by player ESP.

References square::info, sqinfo_has, square_in_bounds(), and chunk::squares.

Referenced by update_mon().

bool square_isno_map ( struct chunk c,
int  y,
int  x 
)

True if cave square can't be magically mapped by the player.

References square::info, sqinfo_has, square_in_bounds(), and chunk::squares.

Referenced by effect_handler_MAP_AREA().

bool square_isno_teleport ( struct chunk c,
int  y,
int  x 
)

True if cave square can't be teleported from by the player.

References square::info, sqinfo_has, square_in_bounds(), and chunk::squares.

Referenced by effect_handler_TELEPORT().

bool square_isopen ( struct chunk c,
int  y,
int  x 
)

SQUARE BEHAVIOR PREDICATES.

These functions define how a given square behaves, e.g. whether it is passable by the player, whether it is diggable, contains items, etc.

These functions use the SQUARE FEATURE PREDICATES (among other info) to make the determination. True if the square is open (a floor square not occupied by a monster).

References square::mon, square_isfloor(), and chunk::squares.

Referenced by lab_is_tunnel(), place_friends(), and square_isempty().

bool square_isopendoor ( struct chunk c,
int  y,
int  x 
)

True if the square is an open door.

References f_info, square::feat, feature::flags, chunk::squares, and tf_has.

Referenced by context_menu_cave(), do_cmd_close(), and do_cmd_close_test().

bool square_ispassable ( struct chunk c,
int  y,
int  x 
)
bool square_isperm ( struct chunk c,
int  y,
int  x 
)
bool square_isplayer ( struct chunk c,
int  y,
int  x 
)

True if the square contains the player.

References FALSE, square::mon, chunk::squares, and TRUE.

Referenced by process_monster().

bool square_isplayertrap ( struct chunk c,
int  y,
int  x 
)

True if there is a player trap (known or unknown) in this square.

References square_trap_flag().

Referenced by effect_handler_DETECT_TRAPS(), project_feature_handler_KILL_DOOR(), square_isknowntrap(), square_issecrettrap(), and square_reveal_trap().

bool square_isproject ( struct chunk c,
int  y,
int  x 
)

True if cave square is marked for projection processing.

References square::info, sqinfo_has, square_in_bounds(), and chunk::squares.

Referenced by project().

bool square_isprojectable ( struct chunk c,
int  y,
int  x 
)

True if any projectable can pass through the square.

This function is the logical negation of square_iswall().

References square::feat, feat_is_projectable(), square_in_bounds(), and chunk::squares.

Referenced by add_monster_lights(), draw_path(), effect_handler_THRUST_AWAY(), light_room(), los(), project(), project_m(), project_path(), ranged_helper(), and square_iswall().

bool square_isquartz ( struct chunk c,
int  y,
int  x 
)

True if the square is a quartz wall.

References square::feat, feat_is_quartz(), and chunk::squares.

Referenced by project_feature_handler_KILL_WALL(), and square_ismineral().

bool square_isrock ( struct chunk c,
int  y,
int  x 
)

True if the square is a normal granite rock wall.

References f_info, square::feat, feature::flags, chunk::squares, and tf_has.

Referenced by build_streamer(), init_cavern(), and square_ismineral().

bool square_isroom ( struct chunk c,
int  y,
int  x 
)

True if the square is part of a room.

References square::info, sqinfo_has, square_in_bounds(), and chunk::squares.

Referenced by alloc_object(), build_tunnel(), cave_room_aux(), get_moves(), next_to_corr(), and try_door().

bool square_isrubble ( struct chunk c,
int  y,
int  x 
)
bool square_issecretdoor ( struct chunk c,
int  y,
int  x 
)

True if the square is a hidden secret door.

These squares appear as if they were granite–when detected a secret door is replaced by a closed door.

References f_info, square::feat, feature::flags, chunk::squares, and tf_has.

Referenced by do_cmd_tunnel_aux(), effect_handler_DETECT_DOORS(), process_monster_can_move(), project_feature_handler_KILL_TRAP(), search(), and square_isdiggable().

bool square_issecrettrap ( struct chunk c,
int  y,
int  x 
)

True if the square is an unknown player trap (it will appear as a floor tile)

References square_isplayertrap(), and square_isvisibletrap().

Referenced by move_player(), and search().

bool square_isseen ( struct chunk c,
int  y,
int  x 
)

True if the square has been seen by the player.

References square::info, sqinfo_has, square_in_bounds(), and chunk::squares.

Referenced by map_info(), mark_wasseen(), square_note_spot(), update_mon(), and update_one().

bool square_isshop ( struct chunk c,
int  y,
int  x 
)
bool square_isstairs ( struct chunk c,
int  y,
int  x 
)
bool square_isstrongwall ( struct chunk c,
int  y,
int  x 
)

True if the square is a permanent wall or one of the "stronger" walls.

The stronger walls are granite, magma and quartz. This excludes things like secret doors and rubble.

References square_in_bounds(), square_ismineral(), and square_isperm().

Referenced by possible_doorway(), and try_door().

bool square_istrap ( struct chunk c,
int  y,
int  x 
)
bool square_isupstairs ( struct chunk c,
int  y,
int  x 
)

True if square is an up stair.

References f_info, square::feat, flags, chunk::squares, and tf_has.

Referenced by context_menu_player(), do_cmd_go_up(), labyrinth_gen(), and textui_process_click().

bool square_isvault ( struct chunk c,
int  y,
int  x 
)

True if the square is part of a vault.

This doesn't say what kind of square it is, just that it is part of a vault.

References square::info, sqinfo_has, square_in_bounds(), and chunk::squares.

Referenced by effect_handler_TELEPORT(), generate_starburst_room(), join_region(), and square_isstart().

bool square_isview ( struct chunk c,
int  y,
int  x 
)

True if the cave square is currently viewable by the player.

References square::info, sqinfo_has, square_in_bounds(), and chunk::squares.

Referenced by become_viewable(), forget_view(), and update_mon().

bool square_isvisibletrap ( struct chunk c,
int  y,
int  x 
)

True if there is a visible trap in this square.

References square_trap_flag().

Referenced by square_isknowntrap(), square_issecrettrap(), target_accept(), target_set_interactive_aux(), and wiz_light().

bool square_iswall ( struct chunk c,
int  y,
int  x 
)

True if the square is a wall square (impedes the player).

This function is the logical negation of square_isprojectable().

References square_in_bounds(), and square_isprojectable().

Referenced by become_viewable(), build_quest_stairs(), next_to_walls(), place_feeling(), process_monster_can_move(), project_feature_handler_KILL_WALL(), and update_view_one().

bool square_iswall_inner ( struct chunk c,
int  y,
int  x 
)

True if cave square is an inner wall (generation)

References square::info, sqinfo_has, square_in_bounds(), and chunk::squares.

Referenced by build_room_of_chambers(), and make_chamber().

bool square_iswall_outer ( struct chunk c,
int  y,
int  x 
)

True if cave square is an outer wall (generation)

References square::info, sqinfo_has, square_in_bounds(), and chunk::squares.

Referenced by build_room_of_chambers(), and make_inner_chamber_wall().

bool square_iswall_solid ( struct chunk c,
int  y,
int  x 
)

True if cave square is a solid wall (generation)

References square::info, sqinfo_has, square_in_bounds(), and chunk::squares.

Referenced by build_room_of_chambers(), and make_inner_chamber_wall().

bool square_iswarded ( struct chunk c,
int  y,
int  x 
)
void square_light_spot ( struct chunk c,
int  y,
int  x 
)
void square_lock_door ( struct chunk c,
int  y,
int  x,
int  power 
)
struct monster* square_monster ( struct chunk c,
int  y,
int  x 
)
read
void square_note_spot ( struct chunk c,
int  y,
int  x 
)

Memorize interesting viewable object/features in the given grid.

This function should only be called on "legal" grids.

This function will memorize the object and/or feature in the given grid, if they are (1) see-able and (2) interesting. Note that all objects are interesting, all terrain features except floors (and invisible traps) are interesting, and floors (and invisible traps) are interesting sometimes (depending on various options involving the illumination of floor grids).

The automatic memorization of all objects and non-floor terrain features as soon as they are displayed allows incredible amounts of optimization in various places, especially "map_info()" and this function itself.

Note that the memorization of objects is completely separate from the memorization of terrain features, preventing annoying floor memorization when a detected object is picked up from a dark floor, and object memorization when an object is dropped into a floor grid which is memorized but out-of-sight.

This function should be called every time the "memorization" of a grid (or the object in a grid) is called into question, such as when an object is created in a grid, when a terrain feature "changes" from "floor" to "non-floor", and when any grid becomes "see-able" for any reason.

This function is called primarily from the "update_view()" function, for each grid which becomes newly "see-able".

References square::info, MARK_SEEN, object::marked, object::next, sqinfo_on, square_ismark(), square_isseen(), square_object(), and chunk::squares.

Referenced by floor_carry(), square_set_feat(), square_verify_trap(), and update_one().

bool square_noticeable ( struct chunk c,
int  y,
int  x 
)

References f_info, square::feat, feature::flags, chunk::squares, and tf_has.

Referenced by run_test().

struct object* square_object ( struct chunk c,
int  y,
int  x 
)
read
void square_open_door ( struct chunk c,
int  y,
int  x 
)
void square_remove_ward ( struct chunk c,
int  y,
int  x 
)
bool square_seemslikewall ( struct chunk c,
int  y,
int  x 
)
void square_set_feat ( struct chunk c,
int  y,
int  x,
int  feat 
)
int square_shopnum ( struct chunk c,
int  y,
int  x 
)
void square_show_trap ( struct chunk c,
int  y,
int  x,
int  type 
)
void square_smash_door ( struct chunk c,
int  y,
int  x 
)
void square_tunnel_wall ( struct chunk c,
int  y,
int  x 
)

References FEAT_FLOOR, and square_set_feat().

Referenced by twall().

void square_unlock_door ( struct chunk c,
int  y,
int  x 
)
void square_upgrade_mineral ( struct chunk c,
int  y,
int  x 
)

Add visible treasure to a mineral square.

References square::feat, FEAT_MAGMA, FEAT_MAGMA_K, FEAT_QUARTZ, FEAT_QUARTZ_K, square_set_feat(), and chunk::squares.

Referenced by build_streamer().

bool square_wasseen ( struct chunk c,
int  y,
int  x 
)

True if the cave square was seen before the current update.

References square::info, sqinfo_has, square_in_bounds(), and chunk::squares.

Referenced by update_one().

void update_view ( struct chunk c,
struct player p 
)
void wiz_dark ( void  )
void wiz_light ( struct chunk c,
bool  full 
)

Light up the dungeon using "claravoyance".

This function "illuminates" every grid in the dungeon, memorizes all "objects" (or notes the existence of an object "if" full is TRUE), and memorizes all grids as with magic mapping.

References cave, cave_k, ddx_ddd, ddy_ddd, square::feat, chunk::height, i, square::info, object::kind, MARK_AWARE, MARK_SEEN, object::marked, object::next, PR_ITEMLIST, PR_MAP, PR_MONLIST, PU_FORGET_VIEW, PU_MONSTERS, PU_UPDATE_VIEW, player_upkeep::redraw, sqinfo_on, square_isfloor(), square_isvisibletrap(), square_object(), square_seemslikewall(), chunk::squares, player_upkeep::update, player::upkeep, and chunk::width.

Referenced by effect_handler_ENLIGHTENMENT(), get_debug_command(), and labyrinth_gen().

Variable Documentation

struct chunk* cave
struct chunk* cave_k
struct chunk** chunk_list

Referenced by cleanup_angband(), and wr_chunks().

u16b chunk_list_max
const s16b ddd[9]
const s16b ddx[10]
const s16b ddx_ddd[9]
const s16b ddy[10]
const s16b ddy_ddd[9]
feature_type* f_info
int FEAT_BROKEN
int FEAT_CLOSED
int FEAT_DTRAP_FLOOR

Referenced by grid_data_as_text(), and set_terrain().

int FEAT_DTRAP_WALL

Referenced by grid_data_as_text(), and set_terrain().

int FEAT_FLOOR
int FEAT_GRANITE
int FEAT_LESS
int FEAT_MAGMA
int FEAT_MAGMA_K
int FEAT_MORE
int FEAT_NONE

Referenced by map_info(), and set_terrain().

int FEAT_OPEN
int FEAT_PERM
int FEAT_QUARTZ
int FEAT_QUARTZ_K
int FEAT_RUBBLE
int FEAT_SECRET