Crossfire Server, Trunk  R20513
Macros | Functions
requestinfo.c File Reference

requestinfo protocol handling. More...

#include "global.h"
#include <assert.h>
#include <fcntl.h>
#include <stdlib.h>
#include <string.h>
#include <sys/time.h>
#include <unistd.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
#include <netdb.h>
#include "commands.h"
#include "living.h"
#include "newserver.h"
#include "shared/newclient.h"
#include "sounds.h"
#include "sproto.h"
Include dependency graph for requestinfo.c:

Go to the source code of this file.

Macros

#define AddShortAttr(New, Type)
 

Functions

static void build_class_list_reply (SockList *sl)
 Creates the appropriate reply to the 'class_list' request info. More...
 
static void build_race_list_reply (SockList *sl)
 Creates the appropriate reply to the 'race_list' request info. More...
 
static void send_arch_info (SockList *sl, const object *op)
 This sends information about object op to client - used in response to requestinfo. More...
 
void send_class_info (socket_struct *ns, char *params)
 Send information on the specified class. More...
 
void send_class_list (socket_struct *ns, char *params)
 Sends the list of classes to the client. More...
 
void send_exp_table (socket_struct *ns, char *params)
 This sends the experience table the sever is using. More...
 
void send_file (socket_struct *ns, const char *file)
 Sends the desired file to the client. More...
 
void send_map_info (socket_struct *ns)
 Send information on the specified class. More...
 
void send_new_char_info (socket_struct *ns)
 Sends information related to creating a new character to the client. More...
 
void send_race_info (socket_struct *ns, char *params)
 Sends information on specified race to the client. More...
 
void send_race_list (socket_struct *ns, char *params)
 Send the list of player races to the client. More...
 
void send_skill_info (socket_struct *ns, char *params)
 This sends the skill number to name mapping. More...
 
void send_spell_paths (socket_struct *ns, char *params)
 This sends the spell path to name mapping. More...
 

Detailed Description

requestinfo protocol handling.

Date
2010-07-04

This file implements all of requestinfo protocol commands/responses. This was broken from request.c as that file as getting quite large and throwing everything into that file was making it fairly unmanageable.

Definition in file requestinfo.c.

Macro Definition Documentation

#define AddShortAttr (   New,
  Type 
)
Value:
if (New) { \
SockList_AddChar(sl, Type); \
SockList_AddShort(sl, New); \
}
void SockList_AddShort(SockList *sl, uint16_t data)
Adds a 16 bit value.
Definition: lowlevel.c:108
void SockList_AddChar(SockList *sl, char c)
Adds an 8 bit value.
Definition: lowlevel.c:98

Definition at line 144 of file requestinfo.c.

Referenced by send_arch_info().

Function Documentation

static void build_class_list_reply ( SockList sl)
static

Creates the appropriate reply to the 'class_list' request info.

Parameters
slreply.

Definition at line 337 of file requestinfo.c.

References CLASS, archt::clone, first_archetype, archt::name, archt::next, SockList_AddPrintf(), SockList_AddString(), SockList_Reset(), and obj::type.

Referenced by send_class_list().

Here is the call graph for this function:

Here is the caller graph for this function:

static void build_race_list_reply ( SockList sl)
static

Creates the appropriate reply to the 'race_list' request info.

Parameters
slsuitable reply.

Definition at line 271 of file requestinfo.c.

References archt::clone, first_archetype, archt::name, archt::next, PLAYER, SockList_AddPrintf(), SockList_AddString(), and obj::type.

Referenced by send_race_list().

Here is the call graph for this function:

Here is the caller graph for this function:

static void send_arch_info ( SockList sl,
const object op 
)
static

This sends information about object op to client - used in response to requestinfo.

This function is used by both race & class transmissions, and could perhaps be used by future requestinfo types.

Parameters
slsocketlist to add data to
opObject to extract data from.

Definition at line 160 of file requestinfo.c.

References AddShortAttr, liv::Cha, CLASS, archt::clone, liv::Con, CS_STAT_CHA, CS_STAT_CON, CS_STAT_DEX, CS_STAT_INT, CS_STAT_POW, CS_STAT_STR, CS_STAT_WIS, liv::Dex, liv::Int, llevError, LOG(), MAX_BUF, obj::msg, obj::name, object_get_value(), PLAYER, liv::Pow, snprintf, SockList_AddChar(), SockList_AddData(), SockList_AddLen8Data(), SockList_AddShort(), SockList_AddString(), obj::stats, liv::Str, strdup_local, strtok_r, try_find_archetype(), obj::type, and liv::Wis.

Referenced by send_class_info(), and send_race_info().

Here is the call graph for this function:

Here is the caller graph for this function:

void send_class_info ( socket_struct ns,
char *  params 
)

Send information on the specified class.

Parameters
nswhere to send.
paramsclass name to send.

Definition at line 380 of file requestinfo.c.

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

Referenced by request_info_cmd().

Here is the call graph for this function:

Here is the caller graph for this function:

void send_class_list ( socket_struct ns,
char *  params 
)

Sends the list of classes to the client.

The reply is kept in a static buffer, as it won't change during server run.

Parameters
nsclient to send to.
paramsignored.

Definition at line 359 of file requestinfo.c.

References build_class_list_reply(), Send_With_Handling(), and SockList_Init().

Referenced by request_info_cmd().

Here is the call graph for this function:

Here is the caller graph for this function:

void send_exp_table ( socket_struct ns,
char *  params 
)

This sends the experience table the sever is using.

Definition at line 121 of file requestinfo.c.

References levels, llevError, LOG(), Settings::max_level, Send_With_Handling(), settings, SockList_AddInt64(), SockList_AddShort(), SockList_AddString(), SockList_Avail(), SockList_Init(), and SockList_Term().

Referenced by request_info_cmd().

Here is the call graph for this function:

Here is the caller graph for this function:

void send_file ( socket_struct ns,
const char *  file 
)

Sends the desired file to the client.

In all three cases, we are basically just dumping file contents to the client - nothing more.

Parameters
nssocket to send to
fileWhich file to send - string of either motd, news, rules

Definition at line 443 of file requestinfo.c.

References Settings::confdir, llevError, LOG(), MAX_BUF, Settings::motd, Settings::news, Settings::rules, Send_With_Handling(), settings, snprintf, SockList_AddChar(), SockList_AddString(), SockList_Init(), and SockList_Term().

Referenced by request_info_cmd().

Here is the call graph for this function:

Here is the caller graph for this function:

void send_map_info ( socket_struct ns)

Send information on the specified class.

Parameters
nswhere to send.

Definition at line 404 of file requestinfo.c.

References archt::clone, first_archetype, INFO_MAP_ARCH_NAME, INFO_MAP_DESCRIPTION, INFO_MAP_NAME, MAP, MAP_TYPE_CHOICE, obj::msg, obj::name, archt::name, archt::next, Send_With_Handling(), SockList_AddChar(), SockList_AddLen16Data(), SockList_AddPrintf(), SockList_Init(), SockList_Term(), obj::subtype, and obj::type.

Referenced by request_info_cmd().

Here is the call graph for this function:

Here is the caller graph for this function:

void send_new_char_info ( socket_struct ns)

Sends information related to creating a new character to the client.

Parameters
nssocket to send to

Definition at line 484 of file requestinfo.c.

References MAX_BUF, NUM_STATS, safe_strcat(), Send_With_Handling(), settings, short_stat_name, snprintf, SockList_AddLen8Data(), SockList_AddString(), SockList_Init(), SockList_Term(), Settings::starting_stat_max, Settings::starting_stat_min, and Settings::starting_stat_points.

Referenced by request_info_cmd().

Here is the call graph for this function:

Here is the caller graph for this function:

void send_race_info ( socket_struct ns,
char *  params 
)

Sends information on specified race to the client.

Parameters
nswhere to send.
paramsrace name to send.

Definition at line 313 of file requestinfo.c.

References archt::clone, PLAYER, send_arch_info(), Send_With_Handling(), SockList_AddPrintf(), SockList_Init(), SockList_Term(), try_find_archetype(), and obj::type.

Referenced by request_info_cmd().

Here is the call graph for this function:

Here is the caller graph for this function:

void send_race_list ( socket_struct ns,
char *  params 
)

Send the list of player races to the client.

The reply is kept in a static buffer, as it won't change during server run.

Parameters
nswhere to send.
paramsignored.

Definition at line 292 of file requestinfo.c.

References build_race_list_reply(), Send_With_Handling(), and SockList_Init().

Referenced by request_info_cmd().

Here is the call graph for this function:

Here is the caller graph for this function:

void send_skill_info ( socket_struct ns,
char *  params 
)

This sends the skill number to name mapping.

We ignore the params - we always send the same info no matter what.

Definition at line 67 of file requestinfo.c.

References CS_STAT_SKILLINFO, esrv_send_face(), socket_struct::faces_sent, llevError, LOG(), NS_FACESENT_FACE, NUM_SKILLS, Send_With_Handling(), skill_faces, skill_names, SockList_AddPrintf(), SockList_AddString(), SockList_Avail(), SockList_Init(), and SockList_Term().

Referenced by request_info_cmd().

Here is the call graph for this function:

Here is the caller graph for this function:

void send_spell_paths ( socket_struct ns,
char *  params 
)

This sends the spell path to name mapping.

We ignore the params - we always send the same info no matter what.

Definition at line 97 of file requestinfo.c.

References llevError, LOG(), NRSPELLPATHS, Send_With_Handling(), SockList_AddPrintf(), SockList_AddString(), SockList_Avail(), SockList_Init(), SockList_Term(), and spellpathnames.

Referenced by request_info_cmd().

Here is the call graph for this function:

Here is the caller graph for this function: