Angband
Functions | Variables
game-world.c File Reference

Game core management of the game world. More...

#include "angband.h"
#include "cmds.h"
#include "game-world.h"
#include "init.h"
#include "mon-make.h"
#include "mon-move.h"
#include "mon-util.h"
#include "obj-desc.h"
#include "obj-gear.h"
#include "obj-identify.h"
#include "obj-tval.h"
#include "obj-util.h"
#include "player-timed.h"
#include "player-util.h"
#include "target.h"

Functions

bool is_daytime (void)
 Say whether it's daytime or not.
int turn_energy (int speed)
 The amount of energy gained in a turn by a player or monster.
static void recharged_notice (const object_type *obj, bool all)
 If player has inscribed the object with "!!", let him know when it's recharged.
static void recharge_objects (void)
 Recharge activatable objects in the player's equipment and rods in the inventory and on the ground.
void play_ambient_sound (void)
 Play an ambient sound dependent on dungeon level, and day or night in town.
static void decrease_timeouts (void)
 Helper for process_world – decrement player->timed[] fields.
void process_world (struct chunk *c)
 Handle things that need updating once every 10 game turns.
static void process_player_cleanup (void)
 Housekeeping after the processing of a player command.
void process_player (void)
 Process player commands from the command queue, finishing when there is a command using energy (any regular game command), or we run out of commands and need another from the user, or the character changes level or dies, or the game is stopped.
void on_new_level (void)
 Housekeeping on arriving on a new level.
static void on_leave_level (void)
 Housekeeping on leaving a level.
void run_game_loop (void)
 The main game loop.

Variables

u16b daycount = 0
u32b seed_randart
u32b seed_flavor
s32b turn
bool character_generated
bool character_dungeon
bool character_saved
const byte extract_energy [200]
 This table allows quick conversion from "speed" to "energy" The basic function WAS ((S>=110) ? (S-110) : (100 / (120-S))) Note that table access is much quicker than computation.

Detailed Description

Game core management of the game world.

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

static void decrease_timeouts ( void  )
static

Helper for process_world – decrement player->timed[] fields.

References adj_con_fix, FALSE, i, player_dec_timed(), player_state::stat_ind, player::state, player::timed, and TMD_MAX.

Referenced by process_world().

bool is_daytime ( void  )
static void on_leave_level ( void  )
static

Housekeeping on leaving a level.

References cave, EVENT_MESSAGE_FLUSH, event_signal(), forget_view(), notice_stuff(), redraw_stuff(), update_stuff(), and player::upkeep.

Referenced by run_game_loop().

void on_new_level ( void  )
void play_ambient_sound ( void  )

Play an ambient sound dependent on dungeon level, and day or night in town.

References player::depth, is_daytime(), and sound().

Referenced by on_new_level(), and process_world().

void process_player ( void  )

Process player commands from the command queue, finishing when there is a command using energy (any regular game command), or we run out of commands and need another from the user, or the character changes level or dies, or the game is stopped.

Notice the annoying code to handle "pack overflow", which must come first just in case somebody manages to corrupt the savefiles by clever use of menu commands or something. (Can go? NRM)

Notice the annoying code to handle "monster memory" changes, which allows us to avoid having to update the window flags every time we change any internal monster memory field, and also reduces the number of times that the recall window must be redrawn.

References CMD_GAME, cmd_get_nrepeats(), CMD_SLEEP, cmdq_pop(), cmdq_push(), effect_simple(), player_upkeep::energy_use, EVENT_CHECK_INTERRUPT, EVENT_COMMAND_REPEAT, EVENT_REFRESH, event_signal(), player_upkeep::generate_level, handle_stuff(), player::is_dead, player_upkeep::monster_race, notice_stuff(), pack_overflow(), player_has, player_resting_complete_special(), player_upkeep::playing, PR_MONSTER, process_player_cleanup(), player_upkeep::redraw, player::timed, and player::upkeep.

Referenced by run_game_loop().

static void process_player_cleanup ( void  )
static
void process_world ( struct chunk c)
static void recharge_objects ( void  )
static
static void recharged_notice ( const object_type obj,
bool  all 
)
static

If player has inscribed the object with "!!", let him know when it's recharged.

-LM- Also inform player when first item of a stack has recharged. -HK- Notify all recharges w/o inscription if notify_recharge option set -WP-

References object::artifact, disturb(), FALSE, msg, object::note, object::number, object_desc(), ODESC_BASE, OPT, quark_str(), and TRUE.

Referenced by recharge_objects().

void run_game_loop ( void  )
int turn_energy ( int  speed)

The amount of energy gained in a turn by a player or monster.

References extract_energy, angband_constants::move_energy, and z_info.

Referenced by adj_energy(), describe_effect(), describe_food(), process_monsters(), process_world(), and run_game_loop().

Variable Documentation

bool character_dungeon
bool character_generated
bool character_saved
u16b daycount = 0
const byte extract_energy[200]
Initial value:
{
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 3, 3, 3,
3, 3, 3, 3, 3, 4, 4, 4, 4, 4,
5, 5, 5, 5, 6, 6, 7, 7, 8, 9,
10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
20, 21, 22, 23, 24, 25, 26, 27, 28, 29,
30, 31, 32, 33, 34, 35, 36, 36, 37, 37,
38, 38, 39, 39, 40, 40, 40, 41, 41, 41,
42, 42, 42, 43, 43, 43, 44, 44, 44, 44,
45, 45, 45, 45, 45, 46, 46, 46, 46, 46,
47, 47, 47, 47, 47, 48, 48, 48, 48, 48,
49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
}

This table allows quick conversion from "speed" to "energy" The basic function WAS ((S>=110) ? (S-110) : (100 / (120-S))) Note that table access is much quicker than computation.

Note that the table has been changed at high speeds. From "Slow (-40)" to "Fast (+30)" is pretty much unchanged, but at speeds above "Fast (+30)", one approaches an asymptotic effective limit of 50 energy per turn. This means that it is relatively easy to reach "Fast (+30)" and get about 40 energy per turn, but then speed becomes very "expensive", and you must get all the way to "Fast (+50)" to reach the point of getting 45 energy per turn. After that point, furthur increases in speed are more or less pointless, except to balance out heavy inventory.

Note that currently the fastest monster is "Fast (+30)".

Referenced by adj_energy(), and turn_energy().

u32b seed_flavor
u32b seed_randart
s32b turn