Angband
Macros | Functions
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_LEN_INIT   20
 Memory allocation constants. More...
 
#define HISTORY_LEN_INCR   20
 

Functions

static void history_init (struct player_history *h)
 Initialise an empty history list. More...
 
static void history_realloc (struct player_history *h)
 Increase the history array size. More...
 
void history_clear (struct player *p)
 Clear any existing history. More...
 
bool history_add_full (struct player *p, bitflag *type, int aidx, int dlev, int clev, int turnno, const char *text)
 Add an entry with text text to the history list, with type type ("HIST_xxx" in player-history.h), and artifact number id (0 for everything else). More...
 
static bool history_add_with_flags (struct player *p, const char *text, bitflag flags[HIST_SIZE], const struct artifact *artifact)
 Add an entry to the history ledger with specified bitflags. More...
 
bool history_add (struct player *p, const char *text, int type)
 Adds an entry to the history ledger. More...
 
bool history_is_artifact_known (struct player *p, const struct artifact *artifact)
 Returns true if the artifact is KNOWN in the history log. More...
 
static bool history_mark_artifact_known (struct player_history *h, const struct artifact *artifact)
 Mark artifact as known. More...
 
static bool history_mark_artifact_lost (struct player_history *h, const struct artifact *artifact)
 Mark artifact as lost. More...
 
static void get_artifact_name (char *buf, size_t len, const struct artifact *artifact)
 Utility function for history_add_artifact(): get artifact name. More...
 
void history_find_artifact (struct player *p, const struct artifact *artifact)
 Add an artifact to the history log. More...
 
void history_lose_artifact (struct player *p, const struct artifact *artifact)
 Mark artifact number id as lost forever. More...
 
void history_unmask_unknown (struct player *p)
 Convert all ARTIFACT_UNKNOWN history items to HIST_ARTIFACT_KNOWN. More...
 
size_t history_get_list (struct player *p, struct history_info **list)
 Present a copy of the history fot UI use. More...
 

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

◆ HISTORY_LEN_INCR

#define HISTORY_LEN_INCR   20

Referenced by history_realloc().

◆ HISTORY_LEN_INIT

#define HISTORY_LEN_INIT   20

Memory allocation constants.

Referenced by history_init().

Function Documentation

◆ get_artifact_name()

static void get_artifact_name ( char *  buf,
size_t  len,
const struct artifact artifact 
)
static

Utility function for history_add_artifact(): get artifact name.

References object::known, make_fake_artifact(), object_copy(), object_desc(), OBJECT_NULL, object_wipe(), ODESC_BASE, ODESC_PREFIX, and ODESC_SPOIL.

Referenced by history_find_artifact(), and history_lose_artifact().

◆ history_add()

bool history_add ( struct player p,
const char *  text,
int  type 
)

Adds an entry to the history ledger.

References flags, hist_on, HIST_SIZE, hist_wipe, history_add_with_flags(), and NULL.

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

◆ history_add_full()

bool history_add_full ( struct player p,
bitflag type,
int  aidx,
int  dlev,
int  clev,
int  turnno,
const char *  text 
)

Add an entry with text text 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, history_info::clev, history_info::dlev, player_history::entries, history_info::event, h, player::hist, hist_copy, history_init(), history_realloc(), player_history::length, my_strcpy(), player_history::next, history_info::turn, and history_info::type.

Referenced by history_add_with_flags(), and rd_history().

◆ history_add_with_flags()

static bool history_add_with_flags ( struct player p,
const char *  text,
bitflag  flags[HIST_SIZE],
const struct artifact artifact 
)
static

Add an entry to the history ledger with specified bitflags.

References artifact::aidx, player::depth, flags, history_add_full(), player::lev, and player::total_energy.

Referenced by history_add(), history_find_artifact(), and history_lose_artifact().

◆ history_clear()

void history_clear ( struct player p)

◆ history_find_artifact()

void history_find_artifact ( struct player p,
const struct artifact artifact 
)

Add an artifact to the history log.

Call this to add an artifact to the history list or make the history entry visible.

References flags, get_artifact_name(), player::hist, hist_on, HIST_SIZE, hist_wipe, history_add_with_flags(), history_mark_artifact_known(), NULL, and strnfmt().

Referenced by do_cmd_sell(), and object_touch().

◆ history_get_list()

size_t history_get_list ( struct player p,
struct history_info **  list 
)

Present a copy of the history fot UI use.

References player_history::entries, h, player::hist, and player_history::next.

Referenced by dump_history(), history_display(), and wr_history().

◆ history_init()

static void history_init ( struct player_history h)
static

Initialise an empty history list.

References player_history::entries, HISTORY_LEN_INIT, player_history::length, mem_zalloc(), and player_history::next.

Referenced by history_add_full().

◆ history_is_artifact_known()

bool history_is_artifact_known ( struct player p,
const struct artifact artifact 
)

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

References history_info::a_idx, artifact::aidx, player_history::entries, h, player::hist, hist_has, i, player_history::next, and history_info::type.

Referenced by desc_art_fake().

◆ history_lose_artifact()

void history_lose_artifact ( struct player p,
const struct artifact artifact 
)

◆ history_mark_artifact_known()

static bool history_mark_artifact_known ( struct player_history h,
const struct artifact artifact 
)
static

◆ history_mark_artifact_lost()

static bool history_mark_artifact_lost ( struct player_history h,
const struct artifact artifact 
)
static

◆ history_realloc()

static void history_realloc ( struct player_history h)
static

Increase the history array size.

References player_history::entries, HISTORY_LEN_INCR, player_history::length, and mem_realloc().

Referenced by history_add_full().

◆ history_unmask_unknown()

void history_unmask_unknown ( struct player p)

Convert all ARTIFACT_UNKNOWN history items to HIST_ARTIFACT_KNOWN.

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

References player_history::entries, h, player::hist, hist_has, hist_off, hist_on, i, player_history::next, and history_info::type.

Referenced by death_knowledge().