Angband
Data Structures | Macros | Typedefs | Functions
obj-list.h File Reference

Object list construction. More...

Go to the source code of this file.

Data Structures

struct  object_list_entry_s
struct  object_list_s

Macros

#define MAX_ITEMLIST   2560

Typedefs

typedef struct object_list_entry_s object_list_entry_t
typedef struct object_list_s object_list_t

Functions

object_list_tobject_list_new (void)
 Allocate a new object list.
void object_list_free (object_list_t *list)
 Free an object list.
void object_list_init (void)
 Initialize the object list module.
void object_list_finalize (void)
 Tear down the object list module.
object_list_tobject_list_shared_instance (void)
 Return a common object list instance.
void object_list_reset (object_list_t *list)
 Zero out the contents of an object list.
void object_list_collect (object_list_t *list)
 Collect object information from the current cave.
int object_list_standard_compare (const void *a, const void *b)
 Standard comparison function for the object list.
void object_list_sort (object_list_t *list, int(*compare)(const void *, const void *))
 Sort the object list with the given sort function.
byte object_list_entry_line_attribute (const object_list_entry_t *entry)
 Return an attribute to display a particular list entry with.
void object_list_format_name (const object_list_entry_t *entry, char *line_buffer, size_t size, size_t full_width)
 Format the object name so that the prefix is right aligned to a common column.

Detailed Description

Object list construction.

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.

Macro Definition Documentation

#define MAX_ITEMLIST   2560

Referenced by object_list_new().

Typedef Documentation

typedef struct object_list_s object_list_t

Function Documentation

void object_list_collect ( object_list_t list)
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, COLOUR_L_RED, COLOUR_RED, COLOUR_SLATE, COLOUR_VIOLET, COLOUR_WHITE, object_kind::cost, is_unknown(), object::kind, object_list_entry_s::object, object_flavor_is_aware(), and object_is_known().

Referenced by object_list_format_section().

void object_list_finalize ( void  )

Tear down the object list module.

References object_list_free().

Referenced by cleanup_angband().

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

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.
full_widthis the maximum formatted width allowed.

References object::artifact, chunk, object_list_entry_s::count, FALSE, object::kind, lookup_sval(), MARK_AWARE, object::marked, MIN, my_strcat(), name, object::number, object_list_entry_s::object, object_desc(), object_is_known(), object_name_is_visible(), ODESC_FULL, ODESC_PREFIX, strnfmt(), object_kind::sval, TRUE, and object_kind::tval.

Referenced by object_list_format_section().

void object_list_free ( object_list_t list)

Free an object list.

References object_list_s::entries, and mem_free().

Referenced by object_list_finalize(), and object_list_show_interactive().

void object_list_init ( void  )

Initialize the object list module.

Referenced by init_angband().

object_list_t* object_list_new ( void  )
void object_list_reset ( object_list_t list)
object_list_t* object_list_shared_instance ( void  )

Return a common object list instance.

References object_list_new(), and object_list_subwindow.

Referenced by object_list_show_subwindow().

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

Sort the object list with the given sort function.

References elements, object_list_s::entries, sort(), object_list_s::sorted, object_list_s::total_entries, and TRUE.

Referenced by object_list_show_interactive(), and object_list_show_subwindow().

int object_list_standard_compare ( const void a,
const void b 
)

Standard comparison function for the object list.

Uses compare_items().

References compare_items(), and object_list_distance_compare().

Referenced by object_list_show_interactive(), and object_list_show_subwindow().