Crossfire Server, Trunk  R20513
Functions
info.c File Reference

Basic client output functions. More...

#include "global.h"
#include <stdarg.h>
#include <string.h>
#include "skills.h"
#include "spells.h"
#include "sproto.h"
Include dependency graph for info.c:

Go to the source code of this file.

Functions

void draw_ext_info (int flags, int pri, const object *pl, uint8_t type, uint8_t subtype, const char *message)
 Sends message to player(s). More...
 
void draw_ext_info_format (int flags, int pri, const object *pl, uint8_t type, uint8_t subtype, const char *format,...)
 Sends message to player(s). More...
 
void draw_magic_map (object *pl)
 Creates and sends magic map to player. More...
 
void ext_info_map (int color, const mapstruct *map, uint8_t type, uint8_t subtype, const char *str1)
 Writes to everyone on the specified map. More...
 
void ext_info_map_except (int color, const mapstruct *map, const object *op, uint8_t type, uint8_t subtype, const char *str1)
 Writes to everyone on the map except *op. More...
 
void ext_info_map_except2 (int color, const mapstruct *map, const object *op1, const object *op2, int type, int subtype, const char *str1)
 Writes to everyone on the map except op1 and op2. More...
 
void magic_mapping_mark (object *pl, char *map_mark, int strength)
 Creates magic map for player. More...
 
static void magic_mapping_mark_recursive (object *pl, char *map_mark, int px, int py)
 Helper for magic map creation. More...
 
void print_ext_msg (socket_struct *ns, int color, uint8_t type, uint8_t subtype, const char *message)
 Draws an extended message on the client. More...
 
void rangetostring (const object *pl, char *obuf, size_t len)
 Get player's current range attack in obuf. More...
 
void set_title (const object *pl, char *buf, size_t len)
 Sets player title. More...
 

Detailed Description

Basic client output functions.

Date
2003-12-02

This file implements some of the simpler output functions to the client. Basically, things like sending text strings along

Definition in file info.c.

Function Documentation

void draw_ext_info ( int  flags,
int  pri,
const object pl,
uint8_t  type,
uint8_t  subtype,
const char *  message 
)

Sends message to player(s).

Parameters
flagsVarious flags - mostly color, plus a few specials. If NDI_ALL or NDI_ALL_DMS is set, pl is ignored and the message is resent to all players or all DMs individually.
priPriority. The lower the value, the more important it is. Thus, 0 gets sent no matter what. Otherwise, the value must be less than the listening level that the player has set. Unfortunately, there is no clear guideline on what each level does what.
plWho to send the message to. pl may be NULL, particularly if flags has NDI_ALL or NDI_DMS set since it is ignored in that case. If NDI_ALL and NDI_DMS are not set, when pl is NULL, nobody gets the message. This is sometimes useful when a function that can be invoked by a player is automatically called by some other mechanism. For example, if a player tries to put something in a container, they should get a message that tells them they cannot put it in an unsuitable container, but when auto-pickup is at work, all containers are tried, even unsuitable ones, and so messages should not be sent to the player.
typeThe type MSG_TYPE for the type of message.
subtypeThe subtype of the message.
messageThe message to send.

Definition at line 86 of file info.c.

References obj::contr, first_player, FLAG_WIZ, pl::listening, llevInfo, LOG(), NDI_ALL, NDI_ALL_DMS, NDI_COLOR_MASK, pl::next, pl::ob, PLAYER, print_ext_msg(), QUERY_FLAG, pl::socket, and obj::type.

Referenced by draw_ext_info_format(), ext_info_map(), ext_info_map_except(), and ext_info_map_except2().

Here is the call graph for this function:

Here is the caller graph for this function:

void draw_ext_info_format ( int  flags,
int  pri,
const object pl,
uint8_t  type,
uint8_t  subtype,
const char *  format,
  ... 
)

Sends message to player(s).

This function is the same as draw_ext_info, but takes varargs format. Otherwise, the meaning of all the fields is the same. This is perhaps not the most efficient as we do vsnprintf on both the old and newbuf, but it simplifies the code greatly since we can just call draw_ext_info.

Parameters
flagsVarious flags - mostly color, plus a few specials.
priPriority. It is a little odd - the lower the value, the more important it is. Thus, 0 gets sent no matter what. Otherwise, the value must be less than the listening level that the player has set. Unfortunately, there is no clear guideline on what each level does what.
plCan be passed as NULL - in fact, this will be done if NDI_ALL is set in the flags.
typeThe type MSG_TYPE for the type of message.
subtypeThe type MSG_TYPE for the subtype of message.
formatThe message to send, with optional format specifiers.

Definition at line 137 of file info.c.

References draw_ext_info(), HUGE_BUF, and vsnprintf.

Here is the call graph for this function:

void draw_magic_map ( object pl)

Creates and sends magic map to player.

@ param pl The player to send the magic map to

The following function is a lot messier than it really should be, but there is no real easy solution.

Mark Wedel

Definition at line 440 of file info.c.

References obj::contr, FACE_FLOOR, llevError, LOG(), MAGIC_MAP_HALF, MAGIC_MAP_SIZE, magic_mapping_mark(), MAX, MIN, PLAYER, Send_With_Handling(), pl::socket, SockList_AddChar(), SockList_AddPrintf(), SockList_Init(), SockList_Term(), and obj::type.

Referenced by cast_spell().

Here is the call graph for this function:

Here is the caller graph for this function:

void ext_info_map ( int  color,
const mapstruct map,
uint8_t  type,
uint8_t  subtype,
const char *  str1 
)

Writes to everyone on the specified map.

Parameters
colorThe color of the message
mapThe map where the players receiving the message are located
typeThe message type
subtypeThe message subtype
str1The message to be sent

Definition at line 161 of file info.c.

References draw_ext_info(), first_player, obj::map, pl::next, and pl::ob.

Here is the call graph for this function:

void ext_info_map_except ( int  color,
const mapstruct map,
const object op,
uint8_t  type,
uint8_t  subtype,
const char *  str1 
)

Writes to everyone on the map except *op.

This is useful for emotions.

Parameters
colorThe color of the message
mapThe map where the players receiving the message are located
opThe player object to skip sending the message to on the map
typeThe message type
subtypeThe message subtype
str1The message to be sent

Definition at line 185 of file info.c.

References draw_ext_info(), first_player, obj::map, pl::next, and pl::ob.

Referenced by basic_emote(), command_cointoss(), and monster_communicate().

Here is the call graph for this function:

Here is the caller graph for this function:

void ext_info_map_except2 ( int  color,
const mapstruct map,
const object op1,
const object op2,
int  type,
int  subtype,
const char *  str1 
)

Writes to everyone on the map except op1 and op2.

Parameters
colorThe message color
mapThe map where the players receiving the message are located
op1The first player object to skip sending the message to
op2The second player object to skip sending the message to
typeThe message type
subtypeThe message subtype
str1The message to be sent

Definition at line 211 of file info.c.

References draw_ext_info(), first_player, obj::map, pl::next, and pl::ob.

Referenced by basic_emote().

Here is the call graph for this function:

Here is the caller graph for this function:

void magic_mapping_mark ( object pl,
char *  map_mark,
int  strength 
)

Creates magic map for player.

Parameters
plThe player making the magic map
map_markHolds flags for each tile analyzed. Should have been initialized to zero before this function is called.
strengthAn initial strength*2 rectangular area that we automatically see in/penetrate through.

Note: For improved magic mapping display, the space that blocks the view is now marked with value 2. Any dependencies of map_mark being nonzero have been changed to check for 1. Also, since map_mark is a char value, putting 2 in should cause no problems.

This function examines the map the player is on, and determines what is visible. 2 is set for walls or objects that blocks view. 1 is for open spaces.

Definition at line 393 of file info.c.

References blank_face, obj::face, FACE_FLOOR, FACE_WALL, GET_MAP_FACE_OBJ, get_map_flags(), obj::invisible, MAGIC_MAP_HALF, MAGIC_MAP_SIZE, magic_mapping_mark_recursive(), new_face_struct::magicmap, obj::map, MAP_LAYERS, P_BLOCKSVIEW, P_OUT_OF_MAP, obj::x, and obj::y.

Referenced by draw_magic_map().

Here is the call graph for this function:

Here is the caller graph for this function:

static void magic_mapping_mark_recursive ( object pl,
char *  map_mark,
int  px,
int  py 
)
static

Helper for magic map creation.

Takes a player, the map_mark array and an x and y starting position.

Parameters
plThe player creating the magic map.
map_markHolds flags for each tile analyzed
pxThe x offset from the player to start calculations
pyThe y offset from the player to start calculations

This function examines all the adjacant spaces next to px, py. It updates the map_mark arrow with the color and high bits set for various code values.

Definition at line 325 of file info.c.

References blank_face, FABS, obj::face, FACE_FLOOR, FACE_WALL, GET_MAP_FACE_OBJ, get_map_flags(), obj::invisible, MAGIC_MAP_HALF, MAGIC_MAP_SIZE, new_face_struct::magicmap, obj::map, MAP_LAYERS, P_BLOCKSVIEW, P_OUT_OF_MAP, obj::x, and obj::y.

Referenced by magic_mapping_mark().

Here is the call graph for this function:

Here is the caller graph for this function:

void print_ext_msg ( socket_struct ns,
int  color,
uint8_t  type,
uint8_t  subtype,
const char *  message 
)

Draws an extended message on the client.

Parameters
nsThe socket to send message to
colorColor informations (used mainly if client does not support message type)
typeThe type of text message
subtypeThe subtype of text message
messageThe main message

make this non-static, so other files can use this to send messages to client before player has been added.

Definition at line 49 of file info.c.

References Send_With_Handling(), SockList_AddPrintf(), SockList_Init(), and SockList_Term().

Referenced by add_me_cmd(), and draw_ext_info().

Here is the call graph for this function:

Here is the caller graph for this function:

void rangetostring ( const object pl,
char *  obuf,
size_t  len 
)

Get player's current range attack in obuf.

Parameters
plThe player who is being evaluated
obufThe buffer for the range attack string
lenThe length of the buffer

Definition at line 230 of file info.c.

References obj::below, BOW, Settings::casting_time, obj::casting_time, obj::chosen_skill, obj::contr, FLAG_APPLIED, obj::inv, MAX_BUF, obj::name, query_base_name(), QUERY_FLAG, obj::race, range_bow, range_builder, range_golem, range_magic, range_misc, range_none, range_skill, pl::ranges, settings, pl::shoottype, snprintf, obj::spell, TRUE, and obj::type.

Referenced by esrv_update_stats().

Here is the call graph for this function:

Here is the caller graph for this function:

void set_title ( const object pl,
char *  buf,
size_t  len 
)

Sets player title.

Definition at line 300 of file info.c.

References obj::contr, obj::name, player_get_title(), and snprintf.

Referenced by esrv_update_stats().

Here is the call graph for this function:

Here is the caller graph for this function: