Angband
Functions | Variables
cave.c File Reference

chunk allocation and utility functions More...

#include "angband.h"
#include "cave.h"
#include "cmds.h"
#include "cmd-core.h"
#include "game-event.h"
#include "game-world.h"
#include "init.h"
#include "monster.h"
#include "obj-ignore.h"
#include "obj-pile.h"
#include "obj-tval.h"
#include "obj-util.h"
#include "object.h"
#include "player-timed.h"
#include "trap.h"

Functions

static int lookup_feat (const char *name)
 Find a terrain feature index by name.
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 *c, int y, int x), bool under)
 Return the number of doors/traps around (or under) the character.

Variables

struct featuref_info
struct chunkcave = NULL
struct chunkcave_k = NULL
const s16b ddd [9]
 Global array for looping through the "keypad directions".
const s16b ddx [10]
 Global arrays for converting "keypad direction" into "offsets".
const s16b ddy [10]
const s16b ddx_ddd [9]
 Global arrays for optimizing "ddx[ddd[i]]" and "ddy[ddd[i]]".
const s16b ddy_ddd [9]

Detailed Description

chunk allocation and utility 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.

Function Documentation

void cave_free ( struct chunk c)
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
int count_feats ( int y,
int x,
bool(*)(struct chunk *c, int y, int x)  test,
bool  under 
)

Return the number of doors/traps around (or under) the character.

References ddx_ddd, ddy_ddd, player::px, player::py, square_in_bounds_fully(), and square_ismark().

Referenced by do_cmd_close(), do_cmd_disarm(), and do_cmd_open().

static int lookup_feat ( const char *  name)
static

Find a terrain feature index by name.

References angband_constants::f_max, i, feature::name, quit_fmt(), streq, and z_info.

Referenced by set_terrain().

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  )

Variable Documentation

struct chunk* cave = NULL

Referenced by acquirement(), autoinscribe_ground(), become_aware(), blow_after_effects(), build_quest_stairs(), call_monster(), can_call_monster(), cave_generate(), cave_known(), cave_light(), cave_room_aux(), cave_unlight(), chest_check(), chest_death(), chunk_write(), cleanup_angband(), compact_monsters(), compact_monsters_aux(), context_menu_cave(), context_menu_object(), context_menu_player(), delete_monster(), delete_monster_idx(), display_feeling(), display_map(), do_animation(), do_autopickup(), do_cmd_alter_aux(), do_cmd_autoinscribe(), do_cmd_buy(), do_cmd_close(), do_cmd_close_aux(), do_cmd_close_test(), do_cmd_disarm(), do_cmd_disarm_aux(), do_cmd_disarm_test(), do_cmd_go_down(), do_cmd_go_up(), do_cmd_hold(), do_cmd_lock_door(), do_cmd_open(), do_cmd_open_aux(), do_cmd_open_chest(), do_cmd_open_test(), do_cmd_pickup(), do_cmd_retrieve(), do_cmd_sell(), do_cmd_stash(), do_cmd_tunnel(), do_cmd_tunnel_aux(), do_cmd_tunnel_test(), do_cmd_walk_test(), do_cmd_wiz_bamf(), do_cmd_wiz_features(), do_cmd_wiz_hack_ben(), do_cmd_wiz_named(), do_cmd_wiz_query(), do_cmd_wiz_zap(), draw_path(), drop_near(), effect_handler_AGGRAVATE(), effect_handler_BALL(), effect_handler_BANISH(), effect_handler_BREATH(), effect_handler_CREATE_STAIRS(), effect_handler_DAMAGE(), effect_handler_DESTRUCTION(), effect_handler_DETECT_DOORS(), effect_handler_DETECT_EVIL(), effect_handler_DETECT_GOLD(), effect_handler_DETECT_INVISIBLE_MONSTERS(), effect_handler_DETECT_OBJECTS(), effect_handler_DETECT_STAIRS(), effect_handler_DETECT_TRAPS(), effect_handler_DETECT_VISIBLE_MONSTERS(), effect_handler_DRAIN_MANA(), effect_handler_EARTHQUAKE(), effect_handler_ENLIGHTENMENT(), effect_handler_MAP_AREA(), effect_handler_MASS_BANISH(), effect_handler_MON_HEAL_HP(), effect_handler_MON_TIMED_INC(), effect_handler_PROBE(), effect_handler_PROJECT_LOS(), effect_handler_RUNE(), effect_handler_SENSE_OBJECTS(), effect_handler_SUMMON(), effect_handler_TELEPORT(), effect_handler_TELEPORT_LEVEL(), effect_handler_TELEPORT_TO(), effect_handler_THRUST_AWAY(), effect_handler_TRAP_RUNE_SUMMON(), fill_terrain_info(), find_artifact(), find_hiding(), find_safety(), findpath(), floor_get_oldest_ignored(), floor_object_for_use(), get_debug_command(), get_moves(), grid_data_as_text(), hit_trap(), hp_colour_change(), inven_drop(), is_valid_pf(), light_room(), look_mon_desc(), make_attack_spell(), make_ranged_shot(), make_ranged_throw(), map_info(), melee_effect_handler_EAT_GOLD(), melee_effect_handler_EAT_ITEM(), modify_panel(), monster_death(), monster_list_collect(), monster_list_needs_update(), monster_list_new(), monster_list_reset(), monster_swap(), move_player(), multiply_monster(), near_permwall(), object_flavor_aware(), object_list_collect(), on_leave_level(), pack_overflow(), player_can_see_bold(), player_has_los_bold(), player_inc_timed(), player_pickup_aux(), player_pickup_gold(), player_pickup_item(), process_monsters(), process_player_cleanup(), process_world(), project(), project_aimed(), project_feature_handler_DARK_WEAK(), project_feature_handler_KILL_DOOR(), project_feature_handler_KILL_TRAP(), project_feature_handler_KILL_WALL(), project_feature_handler_LIGHT_WEAK(), project_feature_handler_MAKE_DOOR(), project_feature_handler_MAKE_TRAP(), project_m(), project_m_apply_side_effects(), project_o(), project_p(), project_path(), project_player_handler_NEXUS(), prt_dtrap(), prt_map(), prt_map_aux(), push_object(), py_attack(), py_attack_real(), ranged_helper(), rd_dungeon(), rd_monsters(), rd_objects(), rd_traps(), recharge_objects(), refill_lamp(), reset_monsters(), run_game_loop(), run_step(), run_test(), scan_floor(), search(), see_wall(), show_obj_list(), spell_value_base_monster_level(), square_light_spot(), start_game(), store_at(), store_will_buy_tester(), summon_possible(), summon_specific(), target_able(), target_accept(), target_get_monsters(), target_recall_loop_object(), target_set_closest(), target_set_interactive(), target_set_interactive_aux(), target_set_location(), test_drop_eat(), test_drop_pickup(), test_loadgame(), test_magic_missile(), test_newgame(), textui_enter_store(), textui_process_click(), twall(), update_minimap_subwindow(), update_monsters(), update_stuff(), use_aux(), wield_item(), wiz_create_item_subaction(), wiz_dark(), wiz_light(), wiz_statistics(), wiz_test_kind(), wr_dungeon(), wr_monsters(), wr_objects(), and wr_traps().

struct chunk* cave_k = NULL
const s16b ddd[9]
Initial value:
{ 2, 8, 6, 4, 3, 1, 9, 7, 5 }

Global array for looping through the "keypad directions".

Referenced by build_streamer(), player_confuse_dir(), and process_monster().

const s16b ddx[10]
const s16b ddx_ddd[9]
Initial value:
{ 0, 0, 1, -1, 1, -1, 1, -1, 0 }

Global arrays for optimizing "ddx[ddd[i]]" and "ddy[ddd[i]]".

This means that each entry in this array corresponds to the direction with the same array index in ddd[].

Referenced by build_room_of_chambers(), cave_illuminate(), cave_update_flow(), count_chests(), count_feats(), effect_handler_EARTHQUAKE(), effect_handler_MAP_AREA(), effect_handler_THRUST_AWAY(), generate_starburst_room(), get_moves(), get_moves_fear(), get_moves_flow(), hollow_out_room(), make_chamber(), next_to_corr(), place_new_monster_group(), project(), rand_dir(), and wiz_light().

const s16b ddy[10]
const s16b ddy_ddd[9]
struct feature* f_info