Angband
Functions | Variables
obj-list.c File Reference

Object list construction. More...

#include "angband.h"
#include "game-world.h"
#include "obj-desc.h"
#include "obj-ignore.h"
#include "obj-knowledge.h"
#include "obj-list.h"
#include "obj-pile.h"
#include "obj-tval.h"
#include "obj-util.h"
#include "project.h"

Functions

object_list_tobject_list_new (void)
 Allocate a new object list. More...
 
void object_list_free (object_list_t *list)
 Free an object list. More...
 
void object_list_init (void)
 Initialize the object list module. More...
 
void object_list_finalize (void)
 Tear down the object list module. More...
 
object_list_tobject_list_shared_instance (void)
 Return a common object list instance. More...
 
static bool object_list_needs_update (const object_list_t *list)
 Return true if the list needs to be updated. More...
 
void object_list_reset (object_list_t *list)
 Zero out the contents of an object list. More...
 
static bool object_list_should_ignore_object (const struct object *obj)
 Return true if the object should be omitted from the object list. More...
 
void object_list_collect (object_list_t *list)
 Collect object information from the current cave. More...
 
static int object_list_distance_compare (const void *a, const void *b)
 Object distance comparator: nearest to farthest. More...
 
int object_list_standard_compare (const void *a, const void *b)
 Standard comparison function for the object list. More...
 
void object_list_sort (object_list_t *list, int(*compare)(const void *, const void *))
 Sort the object list with the given sort function. More...
 
byte object_list_entry_line_attribute (const object_list_entry_t *entry)
 Return an attribute to display a particular list entry with. More...
 
void object_list_format_name (const object_list_entry_t *entry, char *line_buffer, size_t size)
 Format the object name so that the prefix is right aligned to a common column. More...
 

Variables

static object_list_tobject_list_subwindow = NULL
 Share object list instance. More...
 

Detailed Description

Object list construction.

Copyright (c) 1997-2007 Ben Harrison, James E. Wilson, Robert A. Koeneke Copyright (c) 2013 Ben Semmler

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

◆ object_list_collect()

void object_list_collect ( object_list_t list)

◆ object_list_distance_compare()

static int object_list_distance_compare ( const void a,
const void b 
)
static

Object distance comparator: nearest to farthest.

References object_list_entry_s::dx, and object_list_entry_s::dy.

Referenced by object_list_standard_compare().

◆ object_list_entry_line_attribute()

byte object_list_entry_line_attribute ( const object_list_entry_t entry)

Return an attribute to display a particular list entry with.

Parameters
entryis the object list entry to display.
Returns
a term attribute for the object entry.

References object::artifact, cave, COLOUR_L_RED, COLOUR_RED, COLOUR_SLATE, COLOUR_VIOLET, COLOUR_WHITE, object_kind::cost, is_unknown(), object::kind, object::known, NULL, object_list_entry_s::object, object_flavor_is_aware(), chunk::objects, and object::oidx.

Referenced by object_list_format_section().

◆ object_list_finalize()

void object_list_finalize ( void  )

Tear down the object list module.

References object_list_free().

Referenced by cleanup_angband().

◆ object_list_format_name()

void object_list_format_name ( const object_list_entry_t entry,
char *  line_buffer,
size_t  size 
)

Format the object name so that the prefix is right aligned to a common column.

This uses the default logic of object_desc() in order to handle flavors, artifacts, vowels and so on. It was easier to do this and then use strtok() to break it up than to do anything else.

Parameters
entryis the object list entry that has a name to be formatted.
line_bufferis the buffer to format into.
sizeis the size of line_buffer.

References cave, chunk, object_list_entry_s::count, object::ix, object::iy, object::kind, lookup_sval(), los(), my_strcat(), name, NULL, object::number, object_list_entry_s::object, object_desc(), object_is_known_artifact(), OBJECT_LIST_SECTION_LOS, OBJECT_LIST_SECTION_NO_LOS, chunk::objects, ODESC_FULL, ODESC_PREFIX, object::oidx, PROJECT_NONE, projectable(), player::px, player::py, strnfmt(), object_kind::sval, and object_kind::tval.

Referenced by object_list_format_section().

◆ object_list_free()

void object_list_free ( object_list_t list)

Free an object list.

References object_list_s::entries, mem_free(), and NULL.

Referenced by object_list_finalize(), and object_list_show_interactive().

◆ object_list_init()

void object_list_init ( void  )

Initialize the object list module.

References NULL.

Referenced by init_angband().

◆ object_list_needs_update()

static bool object_list_needs_update ( const object_list_t list)
static

Return true if the list needs to be updated.

Usually this is each turn.

References object_list_s::entries, and NULL.

Referenced by object_list_collect(), and object_list_reset().

◆ object_list_new()

object_list_t* object_list_new ( void  )

◆ object_list_reset()

void object_list_reset ( object_list_t list)

◆ object_list_shared_instance()

object_list_t* object_list_shared_instance ( void  )

Return a common object list instance.

References NULL, object_list_new(), and object_list_subwindow.

Referenced by object_list_show_subwindow().

◆ object_list_should_ignore_object()

static bool object_list_should_ignore_object ( const struct object obj)
static

Return true if the object should be omitted from the object list.

References cave, ignore_known_item_ok(), is_unknown(), object::kind, chunk::objects, object::oidx, and tval_is_money().

Referenced by object_list_collect().

◆ object_list_sort()

void object_list_sort ( object_list_t list,
int(*)(const void *, const void *)  compare 
)

Sort the object list with the given sort function.

References object_list_s::distinct_entries, object_list_s::entries, NULL, sort(), and object_list_s::sorted.

Referenced by object_list_show_interactive(), and object_list_show_subwindow().

◆ object_list_standard_compare()

int object_list_standard_compare ( const void a,
const void b 
)

Standard comparison function for the object list.

Uses compare_items().

References cave, compare_items(), NULL, object_list_distance_compare(), chunk::objects, and object::oidx.

Referenced by object_list_show_interactive(), and object_list_show_subwindow().

Variable Documentation

◆ object_list_subwindow

object_list_t* object_list_subwindow = NULL
static

Share object list instance.

Referenced by object_list_shared_instance().