Crossfire Server, Trunk
requestinfo.cpp 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 "AssetsManager.h"
+ Include dependency graph for requestinfo.cpp:

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 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_extra (socket_struct *ns, char *params)
 
void send_skill_info (socket_struct *ns, char *params)
 
void send_spell_paths (socket_struct *ns)
 

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.cpp.

Macro Definition Documentation

◆ AddShortAttr

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

Definition at line 181 of file requestinfo.cpp.

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 375 of file requestinfo.cpp.

References AssetsManager::archetypes(), CLASS, archetype::clone, AssetsCollection< T, Key >::each(), getManager(), SockList_AddString(), SockList_Reset(), and object::type.

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 309 of file requestinfo.cpp.

References AssetsManager::archetypes(), archetype::clone, AssetsCollection< T, Key >::each(), getManager(), PLAYER, SockList_AddString(), and object::type.

Referenced by send_race_list().

+ 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 198 of file requestinfo.cpp.

References AddShortAttr, archininventory::arch, buf, CLASS, 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, PLAYER, 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 413 of file requestinfo.cpp.

References CLASS, archetype::clone, socket_struct::host, llevError, LOG(), roll-o-matic::params, send_arch_info(), Send_With_Handling(), SockList_AddPrintf(), SockList_Init(), SockList_Term(), try_find_archetype(), and object::type.

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

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 158 of file requestinfo.cpp.

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 479 of file requestinfo.cpp.

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 441 of file requestinfo.cpp.

References AssetsManager::archetypes(), AssetsCollection< T, Key >::each(), getManager(), m, MAP, MAP_TYPE_CHOICE, SockList_AddPrintf(), 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_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 520 of file requestinfo.cpp.

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 347 of file requestinfo.cpp.

References archetype::clone, socket_struct::host, llevError, LOG(), roll-o-matic::params, PLAYER, send_arch_info(), Send_With_Handling(), SockList_AddPrintf(), SockList_Init(), SockList_Term(), try_find_archetype(), and object::type.

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

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_extra()

void send_skill_extra ( socket_struct ns,
char *  params 
)

Send extra skill information.

Parameters
nswhere to write the information.
paramsignored.

Definition at line 102 of file requestinfo.cpp.

References CS_STAT_SKILLINFO, llevError, LOG(), MAX_SKILLS, roll-o-matic::params, Send_With_Handling(), skill_messages, skill_names, SockList_AddLen16Data(), SockList_AddShort(), SockList_AddString(), SockList_Avail(), SockList_Init(), SockList_Term(), and nlohmann::detail::void().

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 71 of file requestinfo.cpp.

References CS_STAT_SKILLINFO, esrv_send_face(), socket_struct::faces_sent, llevError, LOG(), MAX_SKILLS, NS_FACESENT_FACE, Face::number, roll-o-matic::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 132 of file requestinfo.cpp.

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: