Crossfire Server, Branches 1.12
R18729
|
#include <global.h>
#include <sproto.h>
#include <sockproto.h>
#include <sys/types.h>
#include <sys/time.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
#include <loader.h>
#include <newserver.h>
Go to the source code of this file.
Data Structures | |
struct | client_cmd_mapping |
struct | player_cmd_mapping |
Typedefs | |
typedef void(* | func_uint8_int_ns )(char *, int, socket_struct *) |
typedef void(* | func_uint8_int_pl )(char *, int, player *) |
Functions | |
static void | block_until_new_connection (void) |
void | do_server (void) |
void | handle_client (socket_struct *ns, player *pl) |
static int | is_fd_valid (int fd) |
void | request_info_cmd (char *buf, int len, socket_struct *ns) |
Variables | |
static const struct client_cmd_mapping | client_commands [] |
static const struct player_cmd_mapping | player_commands [] |
unsigned long | todtick |
Main client/server loops.
Mainly deals with initialization and higher level socket maintenance (checking for lost connections and if data has arrived.) The reading of data is handled in lowlevel.c
Definition in file loop.c.
typedef void(* func_uint8_int_ns)(char *, int, socket_struct *) |
typedef void(* func_uint8_int_pl)(char *, int, player *) |
|
static |
Waits for new connection
Definition at line 309 of file loop.c.
References Settings::fastclock, flush_old_maps(), init_sockets, llevInfo, LOG(), Socket_Info::max_filedescriptor, metaserver_update(), reset_sleep(), settings, socket_info, tick_the_clock(), and watchdog().
Referenced by do_server().
void do_server | ( | void | ) |
This checks the sockets for input and exceptions, does the right thing.
A bit of this code is grabbed out of socket.c There are 2 lists we need to look through - init_sockets is a list
Definition at line 383 of file loop.c.
References Socket_Info::allocated_sockets, block_until_new_connection(), socket_struct::can_write, checkbanned(), CS_LOGTIME, cst_lst, draw_client_map(), esrv_draw_look(), esrv_update_item(), esrv_update_stats(), socket_struct::faces_sent, socket_struct::faces_sent_len, fatal(), socket_struct::fd, final_free_player(), first_player, FLAG_REMOVED, free_newsocket(), handle_client(), socket_struct::host, init_connection(), init_sockets, is_fd_valid(), pl::last_weight, leave(), llevDebug, llevError, llevInfo, LOG(), MAX_BUF, Socket_Info::max_filedescriptor, obj::name, Socket_Info::nconns, pl::next, nrofpixmaps, Ns_Add, Ns_Avail, Ns_Dead, pl::ob, OUT_OF_MEMORY, QUERY_FLAG, remove_ob(), save_player(), send_tick(), snprintf(), pl::socket, socket_info, socklen_t, socket_struct::status, strerror_local(), terminate_all_pets(), socket_struct::tick, CS_Stats::time_start, Socket_Info::timeout, UPD_WEIGHT, socket_struct::update_look, WEIGHT, write_cs_stats(), and write_socket_buffer().
Referenced by server_main().
void handle_client | ( | socket_struct * | ns, |
player * | pl | ||
) |
Handle client commands.
We only get here once there is input, and only do basic connection checking.
ns | socket sending the command. Will be set to Ns_Dead if read error. |
pl | player associated to the socket. If NULL, only commands in client_cmd_mapping will be checked. |
Definition at line 200 of file loop.c.
References SockList::buf, client_cmd_mapping::cmdname, player_cmd_mapping::cmdname, client_cmd_mapping::cmdproc, player_cmd_mapping::cmdproc, socket_struct::fd, player_cmd_mapping::flag, socket_struct::inbuf, SockList::len, llevDebug, LOG(), obj::name, Ns_Dead, pl::ob, SockList_NullTerminate(), SockList_ReadPacket(), SockList_ResetRead(), obj::speed_left, ST_PLAYING, pl::state, and socket_struct::status.
Referenced by do_server(), and handle_newcs_player().
|
static |
Checks if file descriptor is valid.
fd | file descriptor to check. |
Definition at line 368 of file loop.c.
Referenced by do_server().
void request_info_cmd | ( | char * | buf, |
int | len, | ||
socket_struct * | ns | ||
) |
request_info_cmd is sort of a meta command. There is some specific request of information, but we call other functions to provide that information.
Definition at line 146 of file loop.c.
References send_class_info(), send_class_list(), send_exp_table(), send_image_info(), send_image_sums(), send_race_info(), send_race_list(), send_skill_info(), send_spell_paths(), Send_With_Handling(), SockList_AddString(), SockList_Init(), and SockList_Term().
|
static |
Commands sent directly by client, when connecting or when needed.
|
static |
Dispatch tables for the server.
CmdMapping is the dispatch table for the server, used in handle_client, which gets called when the client has input. All commands called here use the same parameter form (char *data, int len, int clientnum. We do implicit casts, because the data that is being passed is unsigned (pretty much needs to be for binary data), however, most of these treat it only as strings, so it makes things easier to cast it here instead of a bunch of times in the function itself. flag is 1 if the player must be in the playing state to issue the command, 0 if they can issue it at any time.Commands sent by the client reacting to player's actions.
unsigned long todtick |
Ingame time
Definition at line 418 of file init.c.
Referenced by init_clocks(), and write_todclock().