Crossfire Server, Trunk
|
#include "global.h"
#include <assert.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"
Go to the source code of this file.
Macros | |
#define | AddIfFloat(Old, New, sl, Type) |
#define | AddIfInt(Old, New, sl, Type) |
#define | AddIfInt64(Old, New, sl, Type) |
#define | AddIfShort(Old, New, sl, Type) |
#define | AddIfString(Old, New, sl, Type) |
#define | FIF(F, C) |
#define | MAX_CHOICES 100 |
#define | MAX_HEAD_POS MAX(MAX_CLIENT_X, MAX_CLIENT_Y) |
#define | VALIDCHAR_MSG "The first character must be alphanumeric and the last cannot be a space. None of these characters are allowed: :;/\\[" |
Typedefs | |
typedef int | ssop_t |
Functions | |
void | account_add_player_cmd (char *buf, int len, socket_struct *ns) |
static int | account_block_create (const socket_struct *ns) |
void | account_login_cmd (char *buf, int len, socket_struct *ns) |
void | account_new_cmd (char *buf, int len, socket_struct *ns) |
void | account_password (char *buf, int len, socket_struct *ns) |
void | account_play_cmd (char *buf, int len, socket_struct *ns) |
static void | add_char_field (SockList *sl, int type, const char *data) |
void | add_me_cmd (char *buf, int len, socket_struct *ns) |
static int | annotate_ob (int ax, int ay, const object *ob, SockList *sl, player *plyr, int *has_obj, int *alive_layer) |
static void | append_spell (player *pl, SockList *sl, object *spell) |
void | ask_smooth_cmd (char *buf, int len, socket_struct *ns) |
static int | check_probe (int ax, int ay, const object *ob, SockList *sl, socket_struct *ns, int *has_obj, int *alive_layer) |
static void | check_space_for_heads (int ax, int ay, SockList *sl, socket_struct *ns) |
static int | clamp (int x, int min, int max) |
void | create_player_cmd (char *buf, int len, socket_struct *ns) |
static int | decode_name_password (const char *buf, int *len, char *name, char *password) |
void | draw_client_map (object *pl) |
static void | draw_client_map2 (object *pl) |
void | esrv_add_spells (player *pl, object *spell) |
void | esrv_map_scroll (socket_struct *ns, int dx, int dy) |
void | esrv_new_player (player *pl, uint32_t weight) |
void | esrv_remove_spell (player *pl, object *spell) |
void | esrv_send_animation (socket_struct *ns, const Animations *anim) |
void | esrv_send_pickup (player *pl) |
void | esrv_update_spells (player *pl) |
void | esrv_update_stats (player *pl) |
static void | handle_scroll (socket_struct *socket, SockList *sl) |
static uint8_t | is_perfect (const player *pl) |
static void | map2_add_label (socket_struct *ns, SockList *sl, enum map2_label subtype, const char *label) |
static int | map2_add_ob (int ax, int ay, int layer, const object *ob, SockList *sl, socket_struct *ns, int *has_obj, int is_head) |
static uint16_t | MAP2_COORD_ENCODE (int x, int y, int flags) |
static bool | map2_coord_valid (int x) |
static int | map2_delete_layer (int ax, int ay, int layer, SockList *sl, socket_struct *ns) |
static void | map_clearcell (struct map_cell_struct *cell, int face, int darkness) |
void | map_newmap_cmd (socket_struct *ns) |
void | move_cmd (char *buf, int len, player *pl) |
void | new_player_cmd (uint8_t *buf, int len, player *pl) |
void | reply_cmd (char *buf, int len, player *pl) |
void | send_account_players (socket_struct *ns) |
static void | send_extra_stats (SockList *sl, player *pl) |
void | send_plugin_custom_message (object *pl, char *buf) |
void | send_query (socket_struct *ns, uint8_t flags, const char *text) |
static void | send_smooth (socket_struct *ns, const Face *face) |
void | send_tick (player *pl) |
void | set_up_cmd (char *buf, int len, socket_struct *ns) |
static int | spell_client_use (const object *spell) |
void | version_cmd (char *buf, int len, socket_struct *ns) |
Variables | |
static const short | atnr_cs_stat [NROFATTACKS] |
static const object * | heads [MAX_HEAD_POS][MAX_HEAD_POS][MAP_LAYERS] |
static const int | MAP2_COORD_MAX = 63 - MAP2_COORD_OFFSET |
static const int | MAP2_COORD_MIN = -MAP2_COORD_OFFSET |
Client handling.
This file implements all of the goo on the server side for handling clients. It's got a bunch of global variables for keeping track of each of the clients.
Note: All functions that are used to process data from the client have the prototype of (char *data, int datalen, int client_num). This way, we can use one dispatch table.
esrv_map_scroll tells the client to scroll the map, and does similarily for the locally cached copy.
This file should probably be broken up into smaller sections - having all request handling from the client in one file makes this a very large file in which it is hard to find data (and know how it is related). In addition, a lot of the function is not actually requests from the client, but push from the server (stats, maps)
Definition in file request.cpp.
#define AddIfFloat | ( | Old, | |
New, | |||
sl, | |||
Type | |||
) |
Definition at line 776 of file request.cpp.
#define AddIfInt | ( | Old, | |
New, | |||
sl, | |||
Type | |||
) |
Definition at line 762 of file request.cpp.
#define AddIfInt64 | ( | Old, | |
New, | |||
sl, | |||
Type | |||
) |
Definition at line 755 of file request.cpp.
#define AddIfShort | ( | Old, | |
New, | |||
sl, | |||
Type | |||
) |
Definition at line 769 of file request.cpp.
#define AddIfString | ( | Old, | |
New, | |||
sl, | |||
Type | |||
) |
Definition at line 783 of file request.cpp.
#define FIF | ( | F, | |
C | |||
) |
#define MAX_CHOICES 100 |
Definition at line 2626 of file request.cpp.
#define MAX_HEAD_POS MAX(MAX_CLIENT_X, MAX_CLIENT_Y) |
Definition at line 1078 of file request.cpp.
#define VALIDCHAR_MSG "The first character must be alphanumeric and the last cannot be a space. None of these characters are allowed: :;/\\[" |
Definition at line 71 of file request.cpp.
typedef int ssop_t |
Parameter type for setsockopt, different between WIN32 and Linux.
Definition at line 58 of file request.cpp.
void account_add_player_cmd | ( | char * | buf, |
int | len, | ||
socket_struct * | ns | ||
) |
Handle accountaddplayer from server (add a character to this account). We check to see if character exists, if password is correct, if character is associated with other account.
buf | socket data to process |
len | length of socket data. |
ns | socket of incoming request. |
Definition at line 2399 of file request.cpp.
References account_char_free(), account_char_load(), account_char_remove(), account_char_save(), socket_struct::account_chars, account_get_account_for_char(), account_is_logged_in(), account_link(), socket_struct::account_name, account_remove_player(), buf, decode_name_password(), dragon_attune::force, socket_struct::host, llevDebug, LOG(), MAX_BUF, give::name, send_account_players(), Send_With_Handling(), SockList_AddString(), SockList_Init(), SockList_Term(), takeitem::status, and verify_player().
|
static |
Checks if account creation is blocked for this connection.
ns | pointer to socket structure. |
0 | Account creation is not blocked. |
1 | Account creation is blocked for this connection. |
Definition at line 2249 of file request.cpp.
References Settings::account_block_create, Settings::account_trusted_host, socket_struct::host, settings, and strdup_local.
Referenced by account_new_cmd().
void account_login_cmd | ( | char * | buf, |
int | len, | ||
socket_struct * | ns | ||
) |
Handles the account login
buf | remaining socket data - from this we need to extract name & password |
len | length of this buffer |
ns | pointer to socket structure. |
Definition at line 2186 of file request.cpp.
References account_exists(), account_login(), socket_struct::account_name, buf, decode_name_password(), socket_struct::host, llevDebug, llevInfo, LOG(), MAX_BUF, give::name, send_account_players(), Send_With_Handling(), SockList_AddString(), SockList_Init(), SockList_Term(), takeitem::status, and strdup_local.
void account_new_cmd | ( | char * | buf, |
int | len, | ||
socket_struct * | ns | ||
) |
Handles the account creation This function shares a fair amount of the same logic as account_login_cmd() above.
buf | remaining socket data - from this we need to extract name & password |
len | length of this buffer |
ns | pointer to socket structure. |
Definition at line 2285 of file request.cpp.
References account_block_create(), account_check_string(), account_exists(), socket_struct::account_name, account_new(), accounts_save(), buf, decode_name_password(), socket_struct::host, llevDebug, llevInfo, LOG(), MAX_BUF, Settings::min_name, give::name, send_account_players(), Send_With_Handling(), settings, SockList_AddString(), SockList_Init(), SockList_Term(), takeitem::status, strdup_local, and VALIDCHAR_MSG.
void account_password | ( | char * | buf, |
int | len, | ||
socket_struct * | ns | ||
) |
Handles the account password change.
buf | remaining socket data - from this we need to extract old & new password |
len | length of this buffer |
ns | pointer to socket structure. |
Definition at line 3053 of file request.cpp.
References account_change_password(), account_check_string(), socket_struct::account_name, buf, decode_name_password(), report::error(), socket_struct::host, llevDebug, LOG(), MAX_BUF, send_account_players(), Send_With_Handling(), SockList_AddString(), SockList_Init(), SockList_Term(), takeitem::status, and VALIDCHAR_MSG.
Referenced by account_login(), and account_new().
void account_play_cmd | ( | char * | buf, |
int | len, | ||
socket_struct * | ns | ||
) |
We have received an accountplay command. try to log in and play the character.
Definition at line 2528 of file request.cpp.
References socket_struct::account_chars, account_get_players_for_account(), socket_struct::account_name, add_string(), buf, check_login(), first_player, get_player(), socket_struct::host, llevDebug, LOG(), Ns_Add, Ns_Avail, altar_valkyrie::pl, save_player(), Send_With_Handling(), set_player_socket(), SockList_AddPrintf(), SockList_AddString(), SockList_Init(), SockList_ResetRead(), SockList_Term(), ST_GET_NAME, ST_PLAY_AGAIN, ST_PLAYING, and socket_struct::status.
|
static |
Basic helper function which adds a piece of data for the accountplayers protocol command. Called from send_account_players. If data is empty, we don't add.
sl | socklist to add data to. |
type | type of data (ACL_.. value) |
data | string data to add |
Definition at line 2025 of file request.cpp.
References navar-midane_time::data, SockList_AddChar(), SockList_AddString(), and is_valid_types_gen::type.
Referenced by send_account_players().
void add_me_cmd | ( | char * | buf, |
int | len, | ||
socket_struct * | ns | ||
) |
The client has requested to be added to the game. This is what takes care of it. We tell the client how things worked out. I am not sure if this file is the best place for this function. However, it either has to be here or init_sockets needs to be exported.
Definition at line 415 of file request.cpp.
References add_player(), buf, socket_struct::cs_version, find_player_socket(), MSG_TYPE_ADMIN, MSG_TYPE_ADMIN_VERSION, NDI_RED, Ns_Add, print_ext_msg(), socket_struct::sc_version, Send_With_Handling(), settings, SockList_AddString(), SockList_Init(), SockList_Term(), socket_struct::status, and nlohmann::detail::void().
|
static |
Definition at line 1369 of file request.cpp.
References check_probe(), archetype::clone, FLAG_ALIVE, FLAG_FRIENDLY, FLAG_UNAGGRESSIVE, FLAG_WIZ, map2_add_label(), map2_add_ob(), MAP2_LABEL_DM, MAP2_LABEL_PLAYER, MAP2_LABEL_PLAYER_PARTY, MAP_LAYER_FLY2, guildjoin::ob, object_find_by_arch_name(), player::party, PLAYER, QUERY_FLAG, player::socket, and try_find_archetype().
Referenced by draw_client_map2().
appends the spell *spell to the Socklist we will send the data to.
Definition at line 1880 of file request.cpp.
References object::casting_time, object::count, CS_STAT_SKILLINFO, living::dam, esrv_send_face(), object::face, get_client_spell_state(), client_spell::last_dam, client_spell::last_grace, client_spell::last_sp, object::level, llevError, LOG(), MAX_SKILLS, object::msg, object::name, NS_FACESENT_FACE, Face::number, object_get_value(), object::path_attuned, altar_valkyrie::pl, object::skill, skill_names, SockList_AddChar(), SockList_AddData(), SockList_AddInt(), SockList_AddLen8Data(), SockList_AddShort(), SP_level_dam_adjust(), SP_level_spellpoint_cost(), spell_client_use(), SPELL_GRACE, SPELL_MANA, sstring, and object::stats.
Referenced by esrv_add_spells().
void ask_smooth_cmd | ( | char * | buf, |
int | len, | ||
socket_struct * | ns | ||
) |
Tells client the picture it has to use to smooth a picture number given as argument.
Definition at line 503 of file request.cpp.
References buf, get_face_by_id(), socket_struct::host, llevDebug, LOG(), and send_smooth().
|
static |
Check if a hp bar should be added to the map square.
ax | x coordinate. |
ay | y coordinate. |
ob | object to check for hp bar. |
sl | where to write data. |
ns | to know if the face was sent or not. |
has_obj | number of objects, modified. |
alive_layer | will be filled with the layer containing the hp bar if applicable. |
Definition at line 1284 of file request.cpp.
References Settings::always_show_hp, CAN_PROBE(), archetype::clone, DISEASE, FLAG_PROBE, FORCE, map2_add_ob(), MAP_LAYER_FLY2, give::name, guildjoin::ob, object_find_by_type_and_name(), object_present_in_ob(), POISONING, probe(), QUERY_FLAG, settings, try_find_archetype(), and autojail::value.
Referenced by annotate_ob().
|
static |
Definition at line 1413 of file request.cpp.
References Map::cells, positioning_system::coord, heads, socket_struct::lastmap, SockList::len, map2_add_ob(), MAP2_COORD_ENCODE(), map2_delete_layer(), MAP2_TYPE_CLEAR, map_clearcell(), MAP_LAYERS, SockList_AddChar(), and SockList_AddShort().
Referenced by draw_client_map2().
|
static |
Definition at line 96 of file request.cpp.
References MAX, say::max, MIN, and diamondslots::x.
Referenced by handle_scroll().
void create_player_cmd | ( | char * | buf, |
int | len, | ||
socket_struct * | ns | ||
) |
We have received a createplayer command.
buf | received command. |
len | length of buf. |
ns | socket to communicate with the client. |
too long, buffer overflow
Definition at line 2633 of file request.cpp.
References account_check_string(), add_player(), ADD_PLAYER_NEW, ADD_PLAYER_NO_MAP, ADD_PLAYER_NO_STATS_ROLL, apply_race_and_class(), archininventory::arch, arch_to_object(), buf, check_race_and_class(), CLASS, decode_name_password(), draw_ext_info_format(), enter_exit(), first_player, FLAG_AUTO_APPLY, FLAG_REMOVED, FREE_AND_COPY, get_archetype_by_type_subtype(), get_attr_value(), socket_struct::host, castle_read::key, llevDebug, llevError, llevInfo, LOG(), socket_struct::login_method, disinfect::map, MAP, MAP_TYPE_CHOICE, MAP_TYPE_DEFAULT, MAX_BUF, MAX_CHOICES, Settings::min_name, MSG_TYPE_ADMIN, MSG_TYPE_ADMIN_PLAYER, give::name, NDI_ALL, NDI_DK_ORANGE, NDI_UNIQUE, newhash(), Ns_Add, Ns_Avail, NUM_STATS, ob_apply(), object_get_value(), object_insert_in_ob(), object_remove(), give::op, altar_valkyrie::pl, PLAYER, player_set_state(), playername_ok(), QUERY_FLAG, safe_strncpy, Send_With_Handling(), set_attr_value(), settings, short_stat_name, SockList_AddPrintf(), SockList_AddString(), SockList_Init(), SockList_Term(), ST_PLAYING, Settings::starting_stat_max, Settings::starting_stat_min, Settings::starting_stat_points, takeitem::status, socket_struct::status, strcasecmp(), try_find_archetype(), VALIDCHAR_MSG, autojail::value, and verify_player().
|
static |
This is a basic routine which extracts the name/password from the buffer. Several of the account login routines provide a length prefixed string for name, and another for password.
buf | character data to process. |
len | length of this buffer. This will be updated to be the next byte to process in the case that there is additional data in this packet that the caller may need to process. |
name | preallocated (MAX_BUF) buffer to return the name (really, first string) in |
password | preallocated (MAX_BUF) buffer to return the password (second string) in |
Definition at line 2150 of file request.cpp.
References buf, MAX_BUF, and give::name.
Referenced by account_add_player_cmd(), account_login_cmd(), account_new_cmd(), account_password(), and create_player_cmd().
void draw_client_map | ( | object * | pl | ) |
Draws client map.
Definition at line 1648 of file request.cpp.
References draw_client_map2(), get_map_flags(), mapstruct::in_memory, llevError, LOG(), m, MAP_IN_MEMORY, map_reset_swap(), P_NEED_UPDATE, P_NEW_MAP, P_OUT_OF_MAP, altar_valkyrie::pl, PLAYER, update_los(), and update_position().
Referenced by send_updates().
|
static |
Definition at line 1460 of file request.cpp.
References annotate_ob(), player::blocked_los, Map::cells, check_space_for_heads(), positioning_system::coord, map_cell_struct::darkness, socket_struct::darkness, GET_MAP_FACE_OBJ, get_map_from_coord(), handle_scroll(), heads, socket_struct::lastmap, SockList::len, m, map2_add_ob(), MAP2_COORD_ENCODE(), map2_delete_layer(), MAP2_TYPE_CLEAR, MAP2_TYPE_DARKNESS, map_clearcell(), MAP_LAYER_LIVING1, MAP_LAYER_LIVING2, MAP_LAYERS, socket_struct::mapx, socket_struct::mapy, MAX_HEAD_OFFSET, MAX_LIGHT_RADII, guildjoin::ob, altar_valkyrie::pl, Send_With_Handling(), player::socket, SockList_AddChar(), SockList_AddShort(), SockList_AddString(), SockList_Init(), SockList_Term(), diamondslots::x, and diamondslots::y.
Referenced by draw_client_map().
This tells the client to add the spell *spell, if spell is NULL, then add all spells in the player's inventory.
Definition at line 1950 of file request.cpp.
References append_spell(), FOR_INV_FINISH, FOR_INV_PREPARE, llevError, LOG(), object::msg, object::name, object_get_value(), altar_valkyrie::pl, Send_With_Handling(), SockList_AddString(), SockList_Avail(), SockList_Init(), SockList_Reset(), SockList_Term(), SPELL, sstring, object::type, and autojail::value.
Referenced by apply_race_and_class(), check_login(), and do_learn_spell().
void esrv_map_scroll | ( | socket_struct * | ns, |
int | dx, | ||
int | dy | ||
) |
Definition at line 1709 of file request.cpp.
References Map::cells, socket_struct::lastmap, socket_struct::map_scroll_x, socket_struct::map_scroll_y, socket_struct::mapx, socket_struct::mapy, MAX_HEAD_OFFSET, diamondslots::x, and diamondslots::y.
Referenced by attempt_jump(), move_ob(), push_ob(), shop_mat_type_move_on(), transport_type_apply(), and turn_one_transport().
void esrv_new_player | ( | player * | pl, |
uint32_t | weight | ||
) |
Tells the client that here is a player it should start using.
Definition at line 1009 of file request.cpp.
References esrv_send_face(), FLAG_CLIENT_SENT, NS_FACESENT_FACE, altar_valkyrie::pl, Send_With_Handling(), SET_FLAG, SockList_AddInt(), SockList_AddLen8Data(), SockList_AddString(), SockList_Init(), and SockList_Term().
Referenced by apply_race_and_class(), check_login(), command_possess(), key_change_class(), and roll_again().
Definition at line 1813 of file request.cpp.
References object::count, object::env, llevError, LOG(), altar_valkyrie::pl, Send_With_Handling(), SockList_AddInt(), SockList_AddString(), SockList_Init(), and SockList_Term().
Referenced by do_forget_spell().
void esrv_send_animation | ( | socket_struct * | ns, |
const Animations * | anim | ||
) |
Need to send an animation sequence to the client. We will send appropriate face commands to the client if we haven't sent them the face yet (this can become quite costly in terms of how much we are sending - on the other hand, this should only happen when the player logs in and picks stuff up.
ns | where to send the animation. |
anim | animation to send. |
Definition at line 1039 of file request.cpp.
References animate::anim, socket_struct::anims_sent, esrv_send_face(), socket_struct::faces_sent, llevError, LOG(), NS_FACESENT_FACE, Send_With_Handling(), SockList_AddShort(), SockList_AddString(), SockList_Init(), and SockList_Term().
Referenced by add_object_to_socklist(), and map2_add_ob().
void esrv_send_pickup | ( | player * | pl | ) |
Sends the "pickup" state to pl if client wants it requested.
pl | player that just logged in. |
Definition at line 1836 of file request.cpp.
References altar_valkyrie::pl, Send_With_Handling(), SockList_AddInt(), SockList_AddString(), SockList_Init(), and SockList_Term().
Referenced by check_login(), display_new_pickup(), and kill_player_not_permadeath().
void esrv_update_spells | ( | player * | pl | ) |
This looks for any spells the player may have that have changed their stats. It then sends an updspell packet for each spell that has changed in this way.
Definition at line 1761 of file request.cpp.
References flags, FOR_INV_FINISH, FOR_INV_PREPARE, get_client_spell_state(), client_spell::last_dam, client_spell::last_grace, client_spell::last_sp, altar_valkyrie::pl, Send_With_Handling(), SockList_AddChar(), SockList_AddInt(), SockList_AddShort(), SockList_AddString(), SockList_Init(), SockList_Term(), SP_level_dam_adjust(), SP_level_spellpoint_cost(), SPELL, SPELL_GRACE, SPELL_MANA, UPD_SP_DAMAGE, UPD_SP_GRACE, and UPD_SP_MANA.
void esrv_update_stats | ( | player * | pl | ) |
Sends a statistics update. We look at the old values, and only send what has changed. Stat mapping values are in newclient.h Since this gets sent a lot, this is actually one of the few binary commands for now.
Definition at line 867 of file request.cpp.
References AddIfFloat, AddIfInt, AddIfInt64, AddIfShort, AddIfString, atnr_cs_stat, ATNR_PHYSICAL, buf, object::count, CS_STAT_AC, CS_STAT_APPLIED_CHA, CS_STAT_APPLIED_CON, CS_STAT_APPLIED_DEX, CS_STAT_APPLIED_INT, CS_STAT_APPLIED_POW, CS_STAT_APPLIED_STR, CS_STAT_APPLIED_WIS, CS_STAT_ARMOUR, CS_STAT_BASE_CHA, CS_STAT_BASE_CON, CS_STAT_BASE_DEX, CS_STAT_BASE_INT, CS_STAT_BASE_POW, CS_STAT_BASE_STR, CS_STAT_BASE_WIS, CS_STAT_CHA, CS_STAT_CON, CS_STAT_DAM, CS_STAT_DEX, CS_STAT_EXP64, CS_STAT_FLAGS, CS_STAT_FOOD, CS_STAT_GOLEM_HP, CS_STAT_GOLEM_MAXHP, CS_STAT_GRACE, CS_STAT_HP, CS_STAT_INT, CS_STAT_LEVEL, CS_STAT_MAXGRACE, CS_STAT_MAXHP, CS_STAT_MAXSP, CS_STAT_POW, CS_STAT_RACE_CHA, CS_STAT_RACE_CON, CS_STAT_RACE_DEX, CS_STAT_RACE_INT, CS_STAT_RACE_POW, CS_STAT_RACE_STR, CS_STAT_RACE_WIS, CS_STAT_RANGE, CS_STAT_SKILLINFO, CS_STAT_SP, CS_STAT_SPEED, CS_STAT_SPELL_ATTUNE, CS_STAT_SPELL_DENY, CS_STAT_SPELL_REPEL, CS_STAT_STR, CS_STAT_TITLE, CS_STAT_WC, CS_STAT_WEAP_SP, CS_STAT_WEIGHT_LIM, CS_STAT_WIS, FLAG_FREED, FLAG_REMOVED, flags, get_skill_client_code(), get_weight_limit(), living::hp, SockList::len, llevDebug, LOG(), MAX_BUF, MAX_SKILLS, living::maxhp, NROFATTACKS, altar_valkyrie::pl, QUERY_FLAG, range_golem, rangetostring(), send_extra_stats(), Send_With_Handling(), set_title(), SF_FIREON, SF_RUNON, SockList_AddChar(), SockList_AddInt64(), SockList_AddString(), SockList_Init(), SockList_Term(), and object::stats.
Referenced by send_updates().
|
static |
As part of sending the map2 command, send one or more scroll commands to update the client map to match the scroll sent on the server.
Definition at line 104 of file request.cpp.
References clamp(), positioning_system::coord, MAP2_COORD_ENCODE(), MAP2_COORD_MAX, MAP2_COORD_MIN, socket_struct::map_scroll_x, socket_struct::map_scroll_y, and SockList_AddShort().
Referenced by draw_client_map2().
|
static |
Check whether the player is perfect relatively to improvement potions.
pl | who to check. |
Definition at line 796 of file request.cpp.
References MIN, and altar_valkyrie::pl.
Referenced by send_extra_stats().
|
static |
Definition at line 1352 of file request.cpp.
References llevError, LOG(), MAP2_ADD_LENGTH, MAP2_TYPE_LABEL, socket_struct::sc_version, SockList_AddChar(), and SockList_AddString().
Referenced by annotate_ob().
|
static |
object 'ob' at 'ax,ay' on 'layer' is visible to the client. This function does the following things: If is_head head is set, this means this is from the heads[] array, so don't try to store it away again - just send it and update our look faces.
1) If a multipart object and we are not at the lower right corner, store this info away for later use. 2) Check to see if this face has been sent to the client. If not, we add data to the socklist, update the last map, and send any other data the client will need (smoothing table, image data, etc) 3) Return 1 if function increased socket. 4) has_obj is increased by one if there are visible objects on this this space, whether or not we sent them. Basically, if has_obj is 0, we can clear info about this space. It could be set to 1 with the function returning zero - this means there are objects on the space we have already sent to the client.
Definition at line 1114 of file request.cpp.
References ANIM_RANDOM, ANIM_SYNC, socket_struct::anims_sent, object::arch, Map::cells, esrv_send_animation(), esrv_send_face(), FABS, map_cell_struct::faces, socket_struct::faces_sent, FLAG_CLIENT_ANIM_RANDOM, FLAG_CLIENT_ANIM_SYNC, HEAD, heads, make_face_from_files::int, banquet::l, socket_struct::lastmap, llevError, LOG(), MAP2_LAYER_START, MAP_LAYERS, MAP_NOSMOOTH, NS_FACESENT_FACE, NS_FACESENT_SMOOTH, NUM_ANIMATIONS, Face::number, guildjoin::ob, QUERY_FLAG, send_smooth(), SockList_AddChar(), SockList_AddShort(), archetype::tail_x, and archetype::tail_y.
Referenced by annotate_ob(), check_probe(), check_space_for_heads(), and draw_client_map2().
|
static |
Encodes a (x, y) pair suitable for map2 parameters. The coordinates must be between [-MAP2_COORD_OFFSET..63-MAP2_COORD_OFFSET]. The flags value must be between [0..15].
x | the x-coordinate |
y | the y-coordinate |
flags | the flags value |
Definition at line 89 of file request.cpp.
References flags, MAP2_COORD_OFFSET, map2_coord_valid(), diamondslots::x, and diamondslots::y.
Referenced by check_space_for_heads(), draw_client_map2(), and handle_scroll().
|
static |
Definition at line 76 of file request.cpp.
References MAP2_COORD_MAX, MAP2_COORD_MIN, and diamondslots::x.
Referenced by MAP2_COORD_ENCODE().
|
static |
Definition at line 1259 of file request.cpp.
References Map::cells, map_cell_struct::faces, socket_struct::lastmap, SockList_AddChar(), and SockList_AddShort().
Referenced by check_space_for_heads(), and draw_client_map2().
|
static |
Clears a map cell
Definition at line 1073 of file request.cpp.
References map_cell_struct::darkness, and map_cell_struct::faces.
Referenced by check_space_for_heads(), and draw_client_map2().
void map_newmap_cmd | ( | socket_struct * | ns | ) |
Sound related function.
Newmap command
Definition at line 687 of file request.cpp.
References socket_struct::lastmap, socket_struct::map_scroll_x, socket_struct::map_scroll_y, Send_With_Handling(), SockList_AddString(), SockList_Init(), and SockList_Term().
Referenced by dimension_door(), do_follow(), enter_map(), object_teleport(), set_up_cmd(), teleport(), and transfer_ob().
void move_cmd | ( | char * | buf, |
int | len, | ||
player * | pl | ||
) |
Moves an object (typically, container to inventory). syntax is: move (to) (tag) (nrof)
Definition at line 708 of file request.cpp.
References buf, esrv_move_object(), llevDebug, llevError, LOG(), and altar_valkyrie::pl.
void new_player_cmd | ( | uint8_t * | buf, |
int | len, | ||
player * | pl | ||
) |
This handles the commands issued by the player (ie, north, fire, cast, etc.). This is called with the 'ncom' method which gives more information back to the client so it can throttle.
buf | data received. |
len | length of buf. |
pl | player who issued the command. Mustn't be NULL. |
Definition at line 527 of file request.cpp.
References buf, devourers::command, command_execute(), draw_ext_info_format(), FABS, GetInt_String(), GetShort_String(), make_face_from_files::int, llevDebug, llevError, LOG(), MAX_BUF, MAX_TIME, MSG_TYPE_COMMAND, MSG_TYPE_COMMAND_ERROR, NDI_UNIQUE, altar_valkyrie::pl, Send_With_Handling(), SockList_AddInt(), SockList_AddShort(), SockList_AddString(), SockList_Init(), SockList_Term(), and ST_PLAYING.
void reply_cmd | ( | char * | buf, |
int | len, | ||
player * | pl | ||
) |
This is a reply to a previous query.
Definition at line 589 of file request.cpp.
References buf, key_change_class(), key_confirm_quit(), key_roll_stat(), llevDebug, llevError, LOG(), altar_valkyrie::pl, receive_party_password(), receive_play_again(), receive_player_name(), receive_player_password(), ST_CHANGE_CLASS, ST_CHANGE_PASSWORD_CONFIRM, ST_CHANGE_PASSWORD_NEW, ST_CHANGE_PASSWORD_OLD, ST_CONFIRM_PASSWORD, ST_CONFIRM_QUIT, ST_GET_NAME, ST_GET_PARTY_PASSWORD, ST_GET_PASSWORD, ST_PLAY_AGAIN, ST_PLAYING, and ST_ROLL_STAT.
void send_account_players | ( | socket_struct * | ns | ) |
Upon successful login/account creation, we send a list of characters associated with the account to the client - in this way, it lets the client present a nice list so that the player can choose one. Note it is important that ns->account_name is set before calling this. Note 2: Some of the operations here are not especially efficient - O(n^2) or repeating same loop instead of trying to combine them. This is not a worry as MAX_CHARACTERS_PER_ACCOUNT is a fairly low value (less than 20), so even inefficient operations don't take much time. If that value as a lot larger, then some rethink may be needed. For now, having clearer code is better than trying to save a few microseconds of execution time.
ns | socket structure to send data for. |
Definition at line 2059 of file request.cpp.
References account_char_free(), account_char_load(), socket_struct::account_chars, account_get_additional_chars(), socket_struct::account_name, ACL_CLASS, ACL_FACE, ACL_FACE_NUM, ACL_LEVEL, ACL_MAP, ACL_NAME, ACL_PARTY, ACL_RACE, add_char_field(), Account_Chars::chars, esrv_send_face(), socket_struct::faces_sent, free_charlinks(), linked_char::next, NS_FACESENT_FACE, Face::number, Send_With_Handling(), SockList_AddChar(), SockList_AddShort(), SockList_AddString(), SockList_Init(), SockList_Term(), and try_find_face().
Referenced by account_add_player_cmd(), account_login_cmd(), account_new_cmd(), account_password(), key_confirm_quit(), kill_player_permadeath(), and receive_play_again().
Send extra stats for the player, if 'notification' is 3.
sl | buffer to use to send stats. |
pl | player to send stats of. |
Definition at line 811 of file request.cpp.
References AddIfFloat, AddIfInt, AddIfShort, AddIfString, CF_BLIND, CF_CONFUSED, CF_DISEASED, CF_HOSTILE, CF_NOT_PERFECT, CF_PARALYZED, CF_POISONED, CF_STEALTHY, CF_WIZARD, CF_XRAY, CS_STAT_CHARACTER_FLAGS, CS_STAT_GOD_NAME, CS_STAT_ITEM_POWER, CS_STAT_OVERLOAD, DISEASE, FIF, FLAG_CONFUSED, FLAG_PARALYZED, FLAG_STARTEQUIP, FLAG_STEALTH, FLAG_WIZ, FLAG_XRAYS, FOR_INV_FINISH, FOR_INV_PREPARE, FORCE, is_perfect(), altar_valkyrie::pl, QUERY_FLAG, SK_PRAYING, and SKILL.
Referenced by esrv_update_stats().
void send_plugin_custom_message | ( | object * | pl, |
char * | buf | ||
) |
GROS: The following one is used to allow a plugin to send a generic cmd to a player. Of course, the client need to know the command to be able to manage it !
Definition at line 1747 of file request.cpp.
References buf, altar_valkyrie::pl, Send_With_Handling(), SockList_AddString(), SockList_Init(), and SockList_Term().
void send_query | ( | socket_struct * | ns, |
uint8_t | flags, | ||
const char * | text | ||
) |
Asks the client to query the user. This way, the client knows it needs to send something back (vs just printing out a message)
Definition at line 746 of file request.cpp.
References flags, Send_With_Handling(), SockList_AddPrintf(), SockList_Init(), SockList_Term(), and guild_entry::text.
Referenced by command_delete(), command_passwd(), confirm_password(), get_name(), get_party_password(), get_password(), key_change_class(), key_roll_stat(), play_again(), receive_player_password(), and roll_again().
|
static |
A lot like the old AskSmooth (in fact, now called by AskSmooth). Basically, it makes no sense to wait for the client to request a a piece of data from us that we know the client wants. So if we know the client wants it, might as well push it to the client.
ns | where to send smooth information. |
face | face to send smooth face of. |
Definition at line 459 of file request.cpp.
References esrv_send_face(), socket_struct::faces_sent, find_smooth(), llevError, llevInfo, LOG(), Face::name, NS_FACESENT_FACE, NS_FACESENT_SMOOTH, Face::number, Send_With_Handling(), smooth_face, SockList_AddShort(), SockList_AddString(), SockList_Init(), and SockList_Term().
Referenced by ask_smooth_cmd(), and map2_add_ob().
void send_tick | ( | player * | pl | ) |
Definition at line 2004 of file request.cpp.
References altar_valkyrie::pl, pticks, Send_With_Handling(), SockList_AddInt(), SockList_AddString(), SockList_Init(), and SockList_Term().
Referenced by update_players().
void set_up_cmd | ( | char * | buf, |
int | len, | ||
socket_struct * | ns | ||
) |
This is the Setup cmd - easy first implementation
Definition at line 143 of file request.cpp.
References BEAT_INTERVAL, buf, socket_struct::darkness, esrv_draw_look(), socket_struct::extended_stats, socket_struct::facecache, socket_struct::faceset, find_player_socket(), socket_struct::heartbeat, socket_struct::host, socket_struct::is_bot, is_valid_faceset(), llevDebug, LOG(), socket_struct::login_method, MAP_CLIENT_X, MAP_CLIENT_X_MINIMUM, MAP_CLIENT_Y, MAP_CLIENT_Y_MINIMUM, map_newmap_cmd(), socket_struct::mapx, socket_struct::mapy, MAX_NUM_LOOK_OBJECTS, MIN, MIN_NUM_LOOK_OBJECTS, socket_struct::monitor_spells, socket_struct::notifications, socket_struct::num_look_objects, altar_valkyrie::pl, item::q, Send_With_Handling(), SND_EFFECTS, SND_MUSIC, SND_MUTE, SockList_AddPrintf(), SockList_AddString(), SockList_Init(), SockList_Term(), socket_struct::sound, socket_struct::tick, Ice::tmp, socket_struct::update_look, update_los(), socket_struct::want_pickup, diamondslots::x, and diamondslots::y.
|
static |
Give the client-side use information for a spell, to know how to use a spell.
spell | what to check. |
0 | spell needs no argument. |
1 | spell needs the name of another spell. |
2 | spell can use a freeform string argument. |
3 | spell requires a freeform string argument. |
Definition at line 1856 of file request.cpp.
References object::other_arch, object::randomitems, SP_CREATE_FOOD, SP_CREATE_MISSILE, SP_MAKE_MARK, SP_RAISE_DEAD, SP_RUNE, SP_SUMMON_MONSTER, and object::subtype.
Referenced by append_spell().
void version_cmd | ( | char * | buf, |
int | len, | ||
socket_struct * | ns | ||
) |
Client tells its version. If there is a mismatch, we close the socket. In real life, all we should care about is the client having something older than the server. If we assume the client will be backwards compatible, having it be a later version should not be a problem.
Definition at line 651 of file request.cpp.
References buf, socket_struct::cs_version, socket_struct::host, llevDebug, llevError, llevInfo, LOG(), ring_occidental_mages::rest, socket_struct::sc_version, VERSION_CS, VERSION_SC, and nlohmann::detail::void().
|
static |
This table translates the attack numbers as used within the program to the value we use when sending STATS command to the client. If a value is -1, then we don't send that to the client.
Definition at line 123 of file request.cpp.
Referenced by esrv_update_stats().
|
static |
Using a global really isn't a good approach, but saves the over head of allocating and deallocating such a block of data each time run through, and saves the space of allocating this in the socket object when we only need it for this cycle. If the serve is ever threaded, this needs to be re-examined.
Definition at line 1087 of file request.cpp.
Referenced by check_space_for_heads(), draw_client_map2(), and map2_add_ob().
|
static |
Definition at line 74 of file request.cpp.
Referenced by handle_scroll(), and map2_coord_valid().
|
static |
Definition at line 73 of file request.cpp.
Referenced by handle_scroll(), and map2_coord_valid().