Angband
Macros | Functions | Variables
cave-map.c File Reference

Lighting and map management functions. More...

#include "angband.h"
#include "cave.h"
#include "init.h"
#include "monster.h"
#include "obj-ignore.h"
#include "obj-tval.h"
#include "obj-util.h"
#include "player-timed.h"
#include "trap.h"

Macros

#define FLOW_MAX   2048
 Size of the circular queue used by "update_flow()".

Functions

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'.
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.
static void cave_light (struct point_set *ps)
 This routine will Perma-Light all grids in the set passed in.
static void cave_unlight (struct point_set *ps)
 This routine will "darken" all grids in the set passed in.
static void cave_room_aux (struct point_set *seen, int y, int x)
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_forget_flow (struct chunk *c)
 Forget the "flow" information ready for a complete update.
void cave_update_flow (struct chunk *c)
void cave_known (void)

Variables

static int flow_save = 0

Detailed Description

Lighting and map management functions.

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 FLOW_MAX   2048

Size of the circular queue used by "update_flow()".

Referenced by cave_update_flow().

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_illuminate ( struct chunk c,
bool  daytime 
)
void cave_known ( void  )
static void cave_light ( struct point_set ps)
static

This routine will Perma-Light all grids in the set passed in.

This routine is used (only) by "light_room()"

Dark grids are illuminated.

Also, process all affected monsters.

SMART monsters always wake up when illuminated NORMAL monsters wake up 1/4 the time when illuminated STUPID monsters wake up 1/10 the time when illuminated

References cave, FALSE, monster_race::flags, i, square::info, monster::m_timed, square::mon, mon_clear_timed(), MON_TMD_FLG_NOTIFY, point_set::n, point_set::pts, PU_FORGET_VIEW, PU_MONSTERS, PU_UPDATE_VIEW, monster::race, randint0, rf_has, sqinfo_on, square_light_spot(), square_monster(), chunk::squares, player_upkeep::update, update_stuff(), player::upkeep, loc::x, and loc::y.

Referenced by light_room().

static void cave_room_aux ( struct point_set seen,
int  y,
int  x 
)
static
static void cave_unlight ( struct point_set ps)
static

This routine will "darken" all grids in the set passed in.

In addition, some of these grids will be "unmarked".

This routine is used (only) by "light_room()"

References cave, i, square::info, point_set::n, point_set::pts, PU_FORGET_VIEW, PU_MONSTERS, PU_UPDATE_VIEW, sqinfo_off, square_isinteresting(), square_light_spot(), chunk::squares, player_upkeep::update, update_stuff(), player::upkeep, loc::x, and loc::y.

Referenced by light_room().

void cave_update_flow ( struct chunk c)
void light_room ( int  y1,
int  x1,
bool  light 
)
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().

void square_light_spot ( struct chunk c,
int  y,
int  x 
)
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().

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

int flow_save = 0
static