Crossfire Server, Trunk
requestinfo.c File Reference
#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 "assets.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)
 
static void build_race_list_reply (SockList *sl)
 
static void do_class_list (archetype *cl)
 
static void do_map_info (archetype *m)
 
static void do_race_list (archetype *race)
 
static void send_arch_info (SockList *sl, const object *op)
 
void send_class_info (socket_struct *ns, char *params)
 
void send_class_list (socket_struct *ns)
 
void send_exp_table (socket_struct *ns)
 
void send_file (socket_struct *ns, const char *file)
 
void send_map_info (socket_struct *ns)
 
void send_new_char_info (socket_struct *ns)
 
void send_race_info (socket_struct *ns, char *params)
 
void send_race_list (socket_struct *ns)
 
void send_skill_info (socket_struct *ns, char *params)
 
void send_spell_paths (socket_struct *ns)
 

Variables

static SockListugly
 

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

◆ AddShortAttr

#define AddShortAttr (   New,
  Type 
)
Value:
if (New) { \
SockList_AddChar(sl, Type); \
SockList_AddShort(sl, New); \
}

Definition at line 150 of file requestinfo.c.

Function Documentation

◆ build_class_list_reply()

static void build_class_list_reply ( SockList sl)
static

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

Parameters
slreply.

Definition at line 356 of file requestinfo.c.

References archetypes_for_each(), do_class_list(), SockList_AddString(), SockList_Reset(), and ugly.

Referenced by send_class_list().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ build_race_list_reply()

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 291 of file requestinfo.c.

References archetypes_for_each(), do_race_list(), SockList_AddString(), and ugly.

Referenced by send_race_list().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ do_class_list()

static void do_class_list ( archetype *  cl)
static

Definition at line 344 of file requestinfo.c.

References SockList_AddPrintf(), and ugly.

Referenced by build_class_list_reply().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ do_map_info()

static void do_map_info ( archetype *  m)
static

Callback function sending start map information, used by send_map_info().

Parameters
marchetype.

Definition at line 415 of file requestinfo.c.

References INFO_MAP_ARCH_NAME, INFO_MAP_DESCRIPTION, INFO_MAP_NAME, m, MAP_TYPE_CHOICE, SockList_AddChar(), SockList_AddLen16Data(), and ugly.

Referenced by send_map_info().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ do_race_list()

static void do_race_list ( archetype *  race)
static

Callback used to write race archetypes to the socket.

Parameters
racearchetype to process.

Definition at line 279 of file requestinfo.c.

References SockList_AddPrintf(), and ugly.

Referenced by build_race_list_reply().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ send_arch_info()

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 167 of file requestinfo.c.

References AddShortAttr, archininventory::arch, spell_arrow::archetype, buf, CS_STAT_CHA, CS_STAT_CON, CS_STAT_DEX, CS_STAT_INT, CS_STAT_POW, CS_STAT_STR, CS_STAT_WIS, llevError, LOG(), MAX_BUF, object_get_value(), give::op, SockList_AddChar(), SockList_AddData(), SockList_AddLen8Data(), SockList_AddShort(), SockList_AddString(), strdup_local, try_find_archetype(), and autojail::value.

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:

◆ send_class_info()

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 392 of file requestinfo.c.

References spell_arrow::archetype, manor::params, 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:

◆ send_class_list()

void send_class_list ( socket_struct ns)

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.

Definition at line 371 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:

◆ send_exp_table()

void send_exp_table ( socket_struct ns)

This sends the experience table the sever is using.

Parameters
nswhere to write the information.

Definition at line 127 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:

◆ send_file()

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 462 of file requestinfo.c.

References buf, Settings::confdir, mad_mage_user::file, llevError, LOG(), MAX_BUF, Settings::motd, Settings::news, Settings::rules, Send_With_Handling(), settings, 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:

◆ send_map_info()

void send_map_info ( socket_struct ns)

Send information on available start maps.

Parameters
nswhere to send.

Definition at line 439 of file requestinfo.c.

References archetypes_for_each(), do_map_info(), Send_With_Handling(), SockList_AddPrintf(), SockList_Init(), SockList_Term(), and ugly.

Referenced by request_info_cmd().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ send_new_char_info()

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 503 of file requestinfo.c.

References buf, MAX_BUF, NUM_STATS, safe_strcat(), Send_With_Handling(), settings, short_stat_name, 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:

◆ send_race_info()

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 326 of file requestinfo.c.

References spell_arrow::archetype, manor::params, send_arch_info(), Send_With_Handling(), SockList_AddPrintf(), SockList_Init(), SockList_Term(), and try_find_archetype().

Referenced by request_info_cmd().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ send_race_list()

void send_race_list ( socket_struct ns)

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.

Definition at line 305 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:

◆ send_skill_info()

void send_skill_info ( socket_struct ns,
char *  params 
)

This sends the skill number to name mapping.

Parameters
nswhere to write the information.
paramsif '1', then send the face along the skill, else just send the skill name.

Definition at line 70 of file requestinfo.c.

References CS_STAT_SKILLINFO, esrv_send_face(), socket_struct::faces_sent, llevError, LOG(), MAX_SKILLS, NS_FACESENT_FACE, Face::number, manor::params, 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:

◆ send_spell_paths()

void send_spell_paths ( socket_struct ns)

This sends the spell path to name mapping.

Parameters
nswhere to write the information.

Definition at line 101 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:

Variable Documentation

◆ ugly

SockList* ugly
static
Todo:
remove when C++ and lambdas...

Definition at line 273 of file requestinfo.c.

Referenced by build_class_list_reply(), build_race_list_reply(), do_class_list(), do_map_info(), do_race_list(), and send_map_info().