Angband
Macros | Functions | Variables
player-history.c File Reference

Character auto-history creation, management, and display. More...

#include "angband.h"
#include "cave.h"
#include "game-world.h"
#include "obj-desc.h"
#include "obj-make.h"
#include "obj-pile.h"
#include "obj-util.h"
#include "player-history.h"

Macros

#define HISTORY_BIRTH_SIZE   10
 Number of slots available at birth in the player history list.
#define HISTORY_MAX   5000

Functions

static void history_init (size_t entries)
 Initialise an empty history list.
void history_clear (void)
 Clear any existing history.
static bool history_set_num (size_t num)
 Set the number of history items.
size_t history_get_num (void)
 Return the number of history entries.
static bool history_know_artifact (struct artifact *artifact)
 Mark artifact number id as known.
bool history_lose_artifact (struct artifact *artifact)
 Mark artifact number id as lost forever, either due to leaving it on a level, or due to a store purging its inventory after the player sold it.
bool history_add_full (bitflag *type, struct artifact *artifact, s16b dlev, s16b clev, s32b turnno, const char *text)
 Add an entry with text event to the history list, with type type ("HIST_xxx" in player-history.h), and artifact number id (0 for everything else).
bool history_add (const char *event, int type, struct artifact *artifact)
 Add an entry with text event to the history list, with type type ("HIST_xxx" in player-history.h), and artifact number id (0 for everything else).
bool history_is_artifact_known (struct artifact *artifact)
 Returns TRUE if the artifact is KNOWN in the history log.
static bool history_is_artifact_logged (struct artifact *artifact)
 Returns TRUE if the artifact denoted by a_idx is an active entry in the history log (i.e.
bool history_add_artifact (struct artifact *artifact, bool known, bool found)
 Adding artifacts to the history list is trickier than other operations.
void history_unmask_unknown (void)
 Convert all ARTIFACT_UNKNOWN history items to HIST_ARTIFACT_KNOWN.
size_t history_get_list (struct history_info **list)
 Present a copy of the history fot UI use.

Variables

struct history_infohistory_list
static size_t history_ctr
static size_t history_size

Detailed Description

Character auto-history creation, management, and display.

Copyright (c) 2007 J.D. White

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 HISTORY_BIRTH_SIZE   10

Number of slots available at birth in the player history list.

Defaults to 10 and will expand automatically as new history entries are added, up the the maximum defined value.

Referenced by history_add_full().

#define HISTORY_MAX   5000

Referenced by history_set_num().

Function Documentation

bool history_add ( const char *  event,
int  type,
struct artifact artifact 
)

Add an entry with text event to the history list, with type type ("HIST_xxx" in player-history.h), and artifact number id (0 for everything else).

Return TRUE on success.

References player::depth, h, hist_on, HIST_SIZE, hist_wipe, history_add_full(), player::lev, and turn.

Referenced by adjust_level(), do_cmd_accept_character(), do_cmd_note(), history_add_artifact(), and mon_take_hit().

bool history_add_artifact ( struct artifact artifact,
bool  known,
bool  found 
)

Adding artifacts to the history list is trickier than other operations.

This is a wrapper function that gets some of the logic out of places where it really doesn't belong. Call this to add an artifact to the history list or make the history entry visible–history_add_artifact will make that determination depending on what object_is_known returns for the artifact.

References buf, player::depth, FALSE, hist_on, HIST_SIZE, hist_wipe, history_add(), history_add_full(), history_is_artifact_logged(), history_know_artifact(), player::lev, make_fake_artifact(), object_desc(), object_wipe(), ODESC_BASE, ODESC_PREFIX, ODESC_SPOIL, strnfmt(), TRUE, turn, and type.

Referenced by do_cmd_sell(), do_ident_item(), history_lose_artifact(), object_notice_everything(), object_notice_on_wield(), and player_pickup_aux().

bool history_add_full ( bitflag type,
struct artifact artifact,
s16b  dlev,
s16b  clev,
s32b  turnno,
const char *  text 
)

Add an entry with text event to the history list, with type type ("HIST_xxx" in player-history.h), and artifact number id (0 for everything else).

Return TRUE on success.

References history_info::a_idx, artifact::aidx, history_info::clev, history_info::dlev, history_info::event, FALSE, hist_copy, HISTORY_BIRTH_SIZE, history_ctr, history_init(), history_set_num(), history_size, my_strcpy(), player::total_energy, TRUE, and history_info::turn.

Referenced by history_add(), history_add_artifact(), and rd_history().

void history_clear ( void  )

Clear any existing history.

References history_ctr, history_size, and mem_free().

Referenced by cleanup_angband(), do_cmd_accept_character(), and rd_history().

size_t history_get_list ( struct history_info **  list)

Present a copy of the history fot UI use.

References history_ctr, and history_list.

Referenced by dump_history(), and history_display().

size_t history_get_num ( void  )

Return the number of history entries.

References history_ctr.

Referenced by wr_history().

static void history_init ( size_t  entries)
static

Initialise an empty history list.

References entries, history_ctr, history_size, and mem_zalloc().

Referenced by history_add_full().

bool history_is_artifact_known ( struct artifact artifact)

Returns TRUE if the artifact is KNOWN in the history log.

References history_info::a_idx, artifact::aidx, FALSE, hist_has, history_ctr, i, TRUE, and type.

Referenced by desc_art_fake().

static bool history_is_artifact_logged ( struct artifact artifact)
static

Returns TRUE if the artifact denoted by a_idx is an active entry in the history log (i.e.

is not marked HIST_ARTIFACT_LOST). This permits proper handling of the case where the player loses an artifact but (in preserve mode) finds it again later.

References history_info::a_idx, artifact::aidx, FALSE, hist_has, history_ctr, i, TRUE, and type.

Referenced by history_add_artifact().

static bool history_know_artifact ( struct artifact artifact)
static

Mark artifact number id as known.

References history_info::a_idx, artifact::aidx, FALSE, hist_on, hist_wipe, history_ctr, i, TRUE, and type.

Referenced by history_add_artifact().

bool history_lose_artifact ( struct artifact artifact)

Mark artifact number id as lost forever, either due to leaving it on a level, or due to a store purging its inventory after the player sold it.

References history_info::a_idx, artifact::aidx, FALSE, hist_on, history_add_artifact(), history_ctr, i, TRUE, and type.

Referenced by store_delete_random().

static bool history_set_num ( size_t  num)
static

Set the number of history items.

References FALSE, HISTORY_MAX, history_size, mem_realloc(), num, and TRUE.

Referenced by history_add_full().

void history_unmask_unknown ( void  )

Convert all ARTIFACT_UNKNOWN history items to HIST_ARTIFACT_KNOWN.

Use only after player retirement/death for the final character dump.

References hist_has, hist_off, hist_on, history_ctr, i, and type.

Referenced by death_knowledge().

Variable Documentation

size_t history_ctr
static
struct history_info* history_list
size_t history_size
static