39 #include <sys/types.h> 41 #include <netinet/in.h> 42 #include <netinet/tcp.h> 80 len = 16+strlen(skill_names[i]);
82 LOG(
llevError,
"Buffer overflow in send_skill_info, not sending all skill information\n");
86 if (params != NULL && *params ==
'1') {
115 LOG(
llevError,
"Buffer overflow in send_skill_extra, not sending all skill information\n");
143 LOG(
llevError,
"Buffer overflow in send_spell_paths, not sending all spell information\n");
168 LOG(
llevError,
"Buffer overflow in send_exp_table, not sending all information\n");
181 #define AddShortAttr(New, Type) \ 183 SockList_AddChar(sl, Type); \ 184 SockList_AddShort(sl, New); \ 237 const char *value, *value1;
238 char *lasts, *mychoices, *token;
242 snprintf(buf,
MAX_BUF,
"race_choice_description_%d", i);
244 snprintf(buf,
MAX_BUF,
"race_choice_%d", i);
247 snprintf(buf,
MAX_BUF,
"class_choice_description_%d", i);
249 snprintf(buf,
MAX_BUF,
"class_choice_%d", i);
253 if (value && value1) {
268 token = strtok_r(mychoices,
" ", &lasts);
278 LOG(
llevError,
"send_arch_info: Unable to find archetype %s\n", token);
280 token = strtok_r(NULL,
" ", &lasts);
314 SockList_AddPrintf(sl,
"|%s", race->name);
328 static int sl_initialized = 0;
330 if (!sl_initialized) {
348 if (params == NULL) {
349 LOG(
llevError,
"send_race_info: IP '%s' sent bogus race_info command.\n", ns->
host);
380 SockList_AddPrintf(sl,
"|%s", cl->name);
394 static int sl_initialized = 0;
396 if (!sl_initialized) {
414 if (params == NULL) {
415 LOG(
llevError,
"send_class_info: IP '%s' sent bogus class_info request.\n", ns->
host);
449 SockList_AddChar(&sl, INFO_MAP_ARCH_NAME);
450 SockList_AddLen16Data(&sl, m->name, strlen(m->name));
452 SockList_AddChar(&sl, INFO_MAP_NAME);
453 SockList_AddLen16Data(&sl, m->clone.name, strlen(m->clone.name));
459 SockList_AddChar(&sl, INFO_MAP_DESCRIPTION);
460 SockList_AddLen16Data(&sl, m->clone.msg, strlen(m->clone.msg));
484 if (!strcmp(file,
"motd"))
486 else if (!strcmp(file,
"rules"))
488 else if (!strcmp(file,
"news"))
491 LOG(
llevError,
"send_file requested to send unknown file: %s\n", file);
494 fp = fopen(buf,
"r");
502 while (fgets(buf,
MAX_BUF, fp) != NULL) {
535 snprintf(buf,
MAX_BUF,
"V statrange %d %d",
539 snprintf(buf,
MAX_BUF,
"V statname");
548 snprintf(buf,
MAX_BUF,
"R race requestinfo");
551 snprintf(buf,
MAX_BUF,
"R class requestinfo");
554 snprintf(buf,
MAX_BUF,
"O startingmap requestinfo");
static void build_race_list_reply(SockList *sl)
Creates the appropriate reply to the 'race_list' request info.
void SockList_AddPrintf(SockList *sl, const char *format,...)
Adds a printf like formatted string.
const char * rules
Name of rules file.
void send_skill_extra(socket_struct *ns, char *params)
Send extra skill information.
const char * skill_names[MAX_SKILLS]
Will contain a number-name mapping for skills, initialized by init_skills().
void send_race_list(socket_struct *ns)
Send the list of player races to the client.
void SockList_Reset(SockList *sl)
Resets the length of the stored data for writing.
const char *const short_stat_name[NUM_STATS]
Short name of stats.
#define NS_FACESENT_FACE
Bitmask for the faces_sent[] array - what portion of the face have we sent?
void SockList_Init(SockList *sl)
Initializes the SockList instance.
uint8_t starting_stat_min
Minimum value of a starting stat.
void LOG(LogLevel logLevel, const char *format,...)
Logs a message to stderr, or to file.
Defines various flags that both the new client and new server use.
const char * motd
Name of the motd file.
int16_t max_level
This is read out of exp_table.
const Face * skill_faces[MAX_SKILLS]
Will contain the face numbers for the skills, initialized by init_skill().
sstring skill_messages[MAX_SKILLS]
Will contain the message for the skills, initialized by init_skill().
void SockList_AddShort(SockList *sl, uint16_t data)
Adds a 16 bit value.
Socket structure, represents a client-server connection.
void send_file(socket_struct *ns, const char *file)
Sends the desired file to the client.
void SockList_AddLen16Data(SockList *sl, const void *data, size_t len)
Adds a data block prepended with an 16 bit length field.
Object for applying character class modifications to someone.
static void send_arch_info(SockList *sl, const object *op)
This sends information about object op to client - used in response to requestinfo.
static void build_class_list_reply(SockList *sl)
Creates the appropriate reply to the 'class_list' request info.
uint8_t starting_stat_max
Maximum value of a starting stat.
void send_new_char_info(socket_struct *ns)
Sends information related to creating a new character to the client.
void send_race_info(socket_struct *ns, char *params)
Sends information on specified race to the client.
Global type definitions and header inclusions.
char * host
Which host it is connected from (ip address).
archetype * try_find_archetype(const char *name)
#define MAP_TYPE_CHOICE
Choice of maps presented to player.
AssetsManager * getManager()
const char * news
Name of news file.
const char *const spellpathnames[NRSPELLPATHS]
Perhaps not the best place for this, but needs to be in some file in the common area so that standalo...
void SockList_AddData(SockList *sl, const void *data, size_t len)
Adds a data block.
The archetype structure is a set of rules on how to generate and manipulate objects which point to ar...
void safe_strcat(char *dest, const char *orig, size_t *curlen, size_t maxlen)
Simple function we use below to keep adding to the same string but also make sure we don't overwrite ...
void SockList_Term(SockList *sl)
Frees all resources allocated by a SockList instance.
int64_t * levels
Number of levels for which we have experience.
sstring msg
If this is a book/sign/magic mouth/etc.
Archetypes * archetypes()
Get archetypes.
sstring object_get_value(const object *op, const char *const key)
Get an extra value by key.
void SockList_AddString(SockList *sl, const char *data)
Adds a string without length.
void send_map_info(socket_struct *ns)
Send information on available start maps.
Defines various structures and values that are used for the new client server communication method...
Defines and structures related to commands the player can send.
struct Settings settings
Global settings.
size_t SockList_Avail(const SockList *sl)
Returns the available bytes in a SockList instance.
#define AddShortAttr(New, Type)
uint16_t number
This is the image unique identifier.
void send_spell_paths(socket_struct *ns)
This sends the spell path to name mapping.
void send_class_list(socket_struct *ns)
Sends the list of classes to the client.
living stats
Str, Con, Dex, etc.
#define MAX_BUF
Used for all kinds of things.
#define NRSPELLPATHS
Number of spell paths.
void send_class_info(socket_struct *ns, char *params)
Send information on the specified class.
const char * confdir
Configuration files.
void SockList_AddChar(SockList *sl, unsigned char c)
Adds an 8 bit value.
void send_skill_info(socket_struct *ns, char *params)
This sends the skill number to name mapping.
static event_registration m
void esrv_send_face(socket_struct *ns, const Face *face, int nocache)
Sends a face to a client if they are in pixmap mode, nothing gets sent in bitmap mode.
uint8_t starting_stat_points
How many stat points character starts with.
sstring name
The name of the object, obviously...
void SockList_AddLen8Data(SockList *sl, const void *data, size_t len)
Adds a data block prepended with an 8 bit length field.
uint8_t type
PLAYER, BULLET, etc.
C function wrappers to interact with assets.
Structure containing object statistics.
uint8_t subtype
Subtype of object.
#define MAX_SKILLS
This is the maximum number of skills the game may handle.
Contains the base information we use to make up a packet we want to send.
void SockList_AddInt64(SockList *sl, uint64_t data)
Adds a 64 bit value.
#define CS_STAT_SKILLINFO
CS_STAT_SKILLINFO is used as the starting index point.
uint8_t * faces_sent
This is a bitmap on sent face status.
object clone
An object from which to do object_copy()
void send_exp_table(socket_struct *ns)
This sends the experience table the sever is using.
void Send_With_Handling(socket_struct *ns, SockList *sl)
Calls Write_To_Socket to send data to the client.
void each(std::function< void(T *)> op)
Apply a function to each asset.