Angband
Data Structures | Macros | Typedefs | Functions | Variables
message.c File Reference

Message handling. More...

#include "z-virt.h"
#include "z-color.h"
#include "z-util.h"
#include "message.h"
#include "game-event.h"
#include "option.h"
#include "init.h"
#include "player.h"
#include "list-message.h"

Data Structures

struct  _message_t
struct  _msgcolor_t
struct  _msgqueue_t

Macros

#define MSG(x, s)   #x,
#define MSG(x, s)   s,
#define MSG(x, s)   s,

Typedefs

typedef struct _message_t message_t
typedef struct _msgcolor_t msgcolor_t
typedef struct _msgqueue_t msgqueue_t

Functions

void messages_init (void)
 

Functions operating on the entire list


void messages_free (void)
 Free the message package.
u16b messages_num (void)
 Return the current number of messages stored.
void message_add (const char *str, u16b type)
 

Functions for individual messages


static message_tmessage_get (u16b age)
 Returns the message of age age.
const char * message_str (u16b age)
 Returns the text of the message of age age.
u16b message_count (u16b age)
 Returns the number of times the message of age age was saved.
u16b message_type (u16b age)
 Returns the type of the message of age age.
byte message_color (u16b age)
 Returns the display colour of the message memorised age messages ago.
void message_color_define (u16b type, byte color)
 

Message-color functions


byte message_type_color (u16b type)
 Returns the colour for the message type type.
void sound (int type)
 Make a noise, without a message.
void bell (const char *fmt,...)
 Clear everything, display a formatted message, ring the system bell.
void msg (const char *fmt,...)
 Display a formatted message.
void msgt (unsigned int type, const char *fmt,...)
 Display a formatted message with a given type, making a sound relevant to the message tyoe.

Variables

static msgqueue_tmessages = NULL
struct init_module messages_module

Detailed Description

Message handling.

Copyright (c) 2007 Elly, Andi Sidwell

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

Macro Definition Documentation

#define MSG (   x,
 
)    #x,
#define MSG (   x,
 
)    s,
#define MSG (   x,
 
)    s,

Typedef Documentation

typedef struct _message_t message_t
typedef struct _msgcolor_t msgcolor_t
typedef struct _msgqueue_t msgqueue_t

Function Documentation

void bell ( const char *  fmt,
  ... 
)
void message_add ( const char *  str,
u16b  type 
)


Functions for individual messages

Save a new message into the memory buffer, with text str and type type. The type should be one of the MSG_ constants defined in message.h.

The new message may not be saved if it is identical to the one saved before it, in which case the "count" of the message will be increased instead. This count can be fetched using the message_count() function.

References _message_t::count, _msgqueue_t::count, _msgqueue_t::head, _msgqueue_t::max, mem_free(), mem_zalloc(), _message_t::newer, _message_t::older, _message_t::str, string_make(), _msgqueue_t::tail, _message_t::type, and type.

Referenced by bell(), do_cmd_accept_character(), msg(), msgt(), and rd_messages().

byte message_color ( u16b  age)

Returns the display colour of the message memorised age messages ago.

(i.e. age = 0 represents the last memorised message, age = 1 is the one before that, etc).

References COLOUR_WHITE, message_get(), message_type_color(), and _message_t::type.

Referenced by do_cmd_message_one(), do_cmd_messages(), and update_messages_subwindow().

void message_color_define ( u16b  type,
byte  color 
)


Message-color functions

Defines the color color for the message type type.

References _msgcolor_t::color, _msgqueue_t::colors, mem_zalloc(), _msgcolor_t::next, _msgcolor_t::type, and type.

Referenced by parse_prefs_message().

u16b message_count ( u16b  age)

Returns the number of times the message of age age was saved.

The age of the most recently saved message is 0, the one before that is of age 1, etc.

In other words, if message_add() was called five times, one after the other, with the message "The orc sets your hair on fire.", then the text will only have one age (age = 0), but will have a count of 5.

References _message_t::count, and message_get().

Referenced by do_cmd_messages(), and update_messages_subwindow().

static message_t* message_get ( u16b  age)
static

Returns the message of age age.

References _msgqueue_t::head, and _message_t::older.

Referenced by message_color(), message_count(), message_str(), and message_type().

const char* message_str ( u16b  age)

Returns the text of the message of age age.

The age of the most recently saved message is 0, the one before that is of age 1, etc.

Returns the empty string if the no messages of the age specified are available.

References message_get(), and _message_t::str.

Referenced by do_cmd_message_one(), do_cmd_messages(), update_messages_subwindow(), wr_messages(), and write_character_dump().

u16b message_type ( u16b  age)

Returns the type of the message of age age.

The age of the most recently saved message is 0, the one before that is of age 1, etc.

The type is one of the MSG_ constants, defined in message.h.

References message_get(), and _message_t::type.

Referenced by effect_handler_SUMMON(), and wr_messages().

byte message_type_color ( u16b  type)

Returns the colour for the message type type.

References _msgcolor_t::color, _msgqueue_t::colors, COLOUR_DARK, COLOUR_WHITE, _msgcolor_t::next, and _msgcolor_t::type.

Referenced by display_message(), and message_color().

void messages_free ( void  )
void messages_init ( void  )


Functions operating on the entire list

Initialise the messages package. Should be called before using any other functions in the package.

References _msgqueue_t::max, and mem_zalloc().

u16b messages_num ( void  )

Return the current number of messages stored.

References _msgqueue_t::count.

Referenced by do_cmd_messages(), wr_messages(), and write_character_dump().

void msg ( const char *  fmt,
  ... 
)

Display a formatted message.

NB: Never call this function directly with a string read in from a file, because it may contain format characters and crash the game. Always use msg("%s", string) in those situations.

Parameters
fmtFormat string

References buf, EVENT_MESSAGE, event_signal_message(), message_add(), void(), and vstrnfmt().

void msgt ( unsigned int  type,
const char *  fmt,
  ... 
)
void sound ( int  type)

Make a noise, without a message.

Sound modules hook into this event.

Parameters
typeMSG_* constant for the sound type

References event_signal_message(), EVENT_SOUND, and OPT.

Referenced by do_cmd_close_aux(), do_cmd_open_aux(), drop_near(), effect_handler_SUMMON(), effect_handler_TELEPORT(), effect_handler_TELEPORT_TO(), msgt(), play_ambient_sound(), process_monster_multiply(), ranged_helper(), spell_cast(), twall(), and use_aux().

Variable Documentation

msgqueue_t* messages = NULL
static

Referenced by cleanup_pain().

struct init_module messages_module
Initial value:
{
.name = "messages",
.init = messages_init,
.cleanup = messages_free
}