Crossfire Server, Trunk  1.75.0
init.cpp
Go to the documentation of this file.
1 /*
2  * Crossfire -- cooperative multi-player graphical RPG and adventure game
3  *
4  * Copyright (c) 1999-2014 Mark Wedel and the Crossfire Development Team
5  * Copyright (c) 1992 Frank Tore Johansen
6  *
7  * Crossfire is free software and comes with ABSOLUTELY NO WARRANTY. You are
8  * welcome to redistribute it under certain conditions. For details, please
9  * see COPYING and LICENSE.
10  *
11  * The authors can be reached via e-mail at <crossfire@metalforge.org>.
12  */
13 
25 #include "global.h"
26 
27 #include <assert.h>
28 #include <errno.h>
29 #include <fcntl.h>
30 #include <stdlib.h>
31 #include <string.h>
32 #include <unistd.h>
33 
34 #ifndef WIN32 /* ---win32 exclude include files */
35 #include <arpa/inet.h>
36 #include <sys/types.h>
37 #include <sys/time.h>
38 #include <netinet/in.h>
39 #include <netinet/tcp.h>
40 typedef int ssop_t;
41 #include <netdb.h>
42 #else
43 #include <winsock2.h>
44 typedef char ssop_t;
45 #endif /* win32 */
46 
47 #include "image.h"
48 #include "newserver.h"
49 #include "sproto.h"
50 
53 
67 
68 static void set_output_sock_buf(socket_struct *ns, int bufsize) {
69  int oldbufsize;
70  socklen_t buflen = sizeof(oldbufsize);
71  if (getsockopt(ns->fd, SOL_SOCKET, SO_SNDBUF, (char *)&oldbufsize, &buflen) == -1)
72  oldbufsize = 0;
73  if (oldbufsize < bufsize) {
74 #ifdef ESRV_DEBUG
75  LOG(llevDebug, "Default buffer size was %d bytes, will reset it to %d\n", oldbufsize, bufsize);
76 #endif
77  if (setsockopt(ns->fd, SOL_SOCKET, SO_SNDBUF, (char *)&bufsize, sizeof(bufsize))) {
78  LOG(llevError, "init_connection: setsockopt unable to set output buf size to %d\n", bufsize);
79  }
80  }
81  buflen = sizeof(oldbufsize);
82  getsockopt(ns->fd, SOL_SOCKET, SO_SNDBUF, (char *)&oldbufsize, &buflen);
83 #ifdef ESRV_DEBUG
84  LOG(llevDebug, "Socket buffer size now %d bytes\n", oldbufsize);
85 #endif
86  ssop_t tmp = 1;
87  if (setsockopt(ns->fd, IPPROTO_TCP, TCP_NODELAY, &tmp, sizeof(tmp)))
88  LOG(llevError, "Unable to turn on TCP_NODELAY\n");
89 }
90 
96 void init_connection(socket_struct *ns, const char *from_ip) {
97  SockList sl;
98 
99 #ifdef WIN32 /* ***WIN32 SOCKET: init win32 non blocking socket */
100  u_long temp = 1;
101  if (ioctlsocket(ns->fd, FIONBIO , &temp) == -1)
102  LOG(llevError, "init_connection: Error on ioctlsocket.\n");
103 #else
104  if (fcntl(ns->fd, F_SETFL, O_NONBLOCK) == -1) {
105  LOG(llevError, "init_connection: Error on fcntl.\n");
106  }
107 #endif /* end win32 */
108 
110 
111  ns->faceset = 0;
112  ns->facecache = 0;
113  ns->sound = 0;
114  ns->sounds_this_tick = 0;
115  ns->monitor_spells = 0;
116  ns->darkness = 1;
117  ns->status = Ns_Add;
120  ns->look_position = 0;
121  ns->container_position = 0;
122  ns->update_look = 0;
123  ns->update_inventory = 0;
124  ns->tick = 0;
125  ns->is_bot = 0;
127  ns->want_pickup = 0;
128  ns->extended_stats = 0;
130  if (ns->account_chars) {
132  ns->account_chars = NULL;
133  }
134  ns->login_method = 0;
135  ns->notifications = 0;
136  ns->heartbeat = 0;
137 
138  /* we should really do some checking here - if total clients overflows
139  * we need to do something more intelligent, because client id's will start
140  * duplicating (not likely in normal cases, but malicous attacks that
141  * just open and close connections could get this total up.
142  */
143  SockList_Init(&ns->inbuf);
145  /* Basic initialization. Needed because we do a check in
146  * handle_client for oldsocketmode without checking the
147  * length of data.
148  */
149  memset(ns->inbuf.buf, 0, sizeof(ns->inbuf.buf));
150  memset(&ns->lastmap, 0, sizeof(struct Map));
151  free(ns->faces_sent);
152  ns->faces_sent = static_cast<uint8_t *>(calloc(sizeof(*ns->faces_sent), get_faces_count()));
154 
155  memset(&ns->anims_sent, 0, sizeof(ns->anims_sent));
156  memset(&ns->stats, 0, sizeof(struct statsinfo));
157  ns->map_scroll_x = 0;
158  ns->map_scroll_y = 0;
159  /* Do this so we don't send a face command for the client for
160  * this face. Face 0 is sent to the client to say clear
161  * face information.
162  */
163  ns->faces_sent[0] = NS_FACESENT_FACE;
164 
165  ns->password_fails = 0;
166 
167  free(ns->host);
168  ns->host = strdup_local(from_ip);
169  SockList_Init(&sl);
170  SockList_AddPrintf(&sl, "version %d %d %s\n", VERSION_CS, VERSION_SC, VERSION_INFO);
171  Send_With_Handling(ns, &sl);
172  SockList_Term(&sl);
173 #ifdef CS_LOGSTATS
178 #endif
179 }
180 
188  struct linger linger_opt;
189  char buf1[MAX_BUF], buf2[MAX_BUF];
190 
191  if (ns == NULL || ns->listen == NULL) {
192  LOG(llevError, "init_listening_socket: missing listen info in socket_struct?!\n");
194  }
195 
196  ns->status = Ns_Dead;
197 
198  ns->fd = socket(ns->listen->family, ns->listen->socktype, ns->listen->protocol);
199  if (ns->fd == -1) {
200  LOG(llevError, "Cannot create socket: %s\n", strerror(errno));
201  return;
202  }
203 
204  linger_opt.l_onoff = 0;
205  linger_opt.l_linger = 0;
206  if (setsockopt(ns->fd, SOL_SOCKET, SO_LINGER, (char *)&linger_opt, sizeof(struct linger))) {
207  LOG(llevError, "Cannot setsockopt(SO_LINGER): %s\n", strerror(errno));
208  }
209 /* Would be nice to have an autoconf check for this. It appears that
210  * these functions are both using the same calling syntax, just one
211  * of them needs extra valus passed.
212  */
213 #if defined(__osf__) || defined(hpux) || defined(sgi) || defined(NeXT) || \
214  defined(__sun__) || defined(__linux__) || defined(SVR4) || \
215  defined(__FreeBSD__) || defined(__OpenBSD__) || \
216  defined(WIN32) /* ---win32 add this here */ || \
217  defined(__GNU__) /* HURD */
218  {
219 #ifdef WIN32
220  char tmp = 1;
221 #else
222  int tmp = 1;
223 #endif
224 
225  if (setsockopt(ns->fd, SOL_SOCKET, SO_REUSEADDR, &tmp, sizeof(tmp))) {
226  LOG(llevError, "Cannot setsockopt(SO_REUSEADDR): %s\n", strerror(errno));
227  }
228 #ifdef HAVE_GETADDRINFO
229  if ((ns->listen->family == AF_INET6) && setsockopt(ns->fd, IPPROTO_IPV6, IPV6_V6ONLY, &tmp, sizeof(tmp))) {
230  LOG(llevError, "Cannot setsockopt(IPV6_V6ONLY): %s\n", strerror(errno));
231  }
232 #endif
233  }
234 #else
235  if (setsockopt(ns->fd, SOL_SOCKET, SO_REUSEADDR, (char *)NULL, 0)) {
236  LOG(llevError, "Cannot setsockopt(SO_REUSEADDR): %s\n", strerror(errno));
237  }
238 #endif
239 
240  if (bind(ns->fd, ns->listen->addr, ns->listen->addrlen) == (-1)) {
241 #ifdef HAVE_GETNAMEINFO
242  getnameinfo(ns->listen->addr, ns->listen->addrlen, buf1, sizeof(buf1), buf2, sizeof(buf2), NI_NUMERICHOST|NI_NUMERICSERV);
243 #else
244  short port;
245  long ip;
246 
247  ip = ntohl(((struct sockaddr_in *)ns->listen->addr)->sin_addr.s_addr);
248  port = ntohs(((struct sockaddr_in *)ns->listen->addr)->sin_port);
249  snprintf(buf1, sizeof(buf1), "%ld.%ld.%ld.%ld", (ip>>24)&255, (ip>>16)&255, (ip>>8)&255, ip&255);
250  snprintf(buf2, sizeof(buf2), "%d", port&65535);
251 #endif
252  LOG(llevError, "Cannot bind socket to [%s]:%s: %s\n", buf1, buf2, strerror(errno));
253 #ifdef WIN32 /* ***win32: close() -> closesocket() */
254  shutdown(ns->fd, SD_BOTH);
255  closesocket(ns->fd);
256 #else
257  close(ns->fd);
258 #endif /* win32 */
259  ns->fd = -1;
260  return;
261  }
262  if (listen(ns->fd, 5) == (-1)) {
263  LOG(llevError, "Cannot listen on socket: %s\n", strerror(errno));
264 #ifdef WIN32 /* ***win32: close() -> closesocket() */
265  shutdown(ns->fd, SD_BOTH);
266  closesocket(ns->fd);
267 #else
268  close(ns->fd);
269 #endif /* win32 */
270  ns->fd = -1;
271  return;
272  }
273  ns->status = Ns_Add;
274 }
275 
278 void init_server(void) {
279  int i, e, listen_socket_count;
280 #ifdef HAVE_GETADDRINFO
281  struct addrinfo *ai, *ai_p;
282  struct addrinfo hints;
283  char buf[MAX_BUF];
284 #else
285  struct sockaddr_in *insock;
286  struct protoent *protox;
287 #endif
288 
289 #ifdef WIN32 /* ***win32 - we init a windows socket */
290  WSADATA w;
291 
292  socket_info.max_filedescriptor = 1; /* used in select, ignored in winsockets */
293  WSAStartup(0x0101, &w); /* this setup all socket stuff */
294  /* ill include no error tests here, winsocket 1.1 should always work */
295  /* except some old win95 versions without tcp/ip stack */
296 #else /* non windows */
297 
298 #ifdef HAVE_SYSCONF
299  socket_info.max_filedescriptor = sysconf(_SC_OPEN_MAX);
300 #else
301 # ifdef HAVE_GETDTABLESIZE
302  socket_info.max_filedescriptor = getdtablesize();
303 # else
304 #error "Unable to find usable function to get max filedescriptors"
305 # endif
306 #endif
307 #endif /* win32 */
308 
309  // Modern operating systems support more file descriptors than select() can handle.
311 
312  socket_info.timeout.tv_sec = 0;
313  socket_info.timeout.tv_usec = 0;
314 
315 #ifdef CS_LOGSTATS
318 #endif
319 
320 #ifdef HAVE_GETADDRINFO
321  memset(&hints, '\0', sizeof(hints));
322  hints.ai_flags = AI_PASSIVE | AI_ADDRCONFIG;
323  hints.ai_socktype = SOCK_STREAM;
324  snprintf(buf, sizeof(buf), "%d", settings.csport);
325  e = getaddrinfo(NULL, buf, &hints, &ai);
326  if (e != 0) {
327  LOG(llevError, "init_server: getaddrinfo: %s\n", gai_strerror(e));
329  }
330 
331  listen_socket_count = 0;
332  for (ai_p = ai; ai_p != NULL; ai_p = ai_p->ai_next) {
333  listen_socket_count++;
334  }
335 
336  assert(listen_socket_count > 0);
337 #else
338  listen_socket_count = 1;
339 #endif
340 
341  LOG(llevDebug, "Initialize new client/server data\n");
342  init_sockets = static_cast<socket_struct *>(malloc(sizeof(socket_struct) * listen_socket_count));
343  socket_info.allocated_sockets = listen_socket_count;
344  for (i = 0; i < listen_socket_count; i++) {
345  init_sockets[i].listen = static_cast<listen_info *>(calloc(sizeof(struct listen_info), 1));
346  init_sockets[i].faces_sent = NULL; /* unused */
347  init_sockets[i].account_name = NULL; /* Must be set to avoid undef behaviour elsewhere. */
348  }
349 
350 #ifdef HAVE_GETADDRINFO
351  for (i = 0, ai_p = ai; i < listen_socket_count && ai_p != NULL; i++, ai_p = ai_p->ai_next) {
352  init_sockets[i].listen->family = ai_p->ai_family;
353  init_sockets[i].listen->socktype = ai_p->ai_socktype;
354  init_sockets[i].listen->protocol = ai_p->ai_protocol;
355  init_sockets[i].listen->addrlen = ai_p->ai_addrlen;
356  init_sockets[i].listen->addr = static_cast<sockaddr *>(malloc(ai_p->ai_addrlen));
357  memcpy(init_sockets[i].listen->addr, ai_p->ai_addr, ai_p->ai_addrlen);
358  }
359  freeaddrinfo(ai);
360 #else
361  protox = getprotobyname("tcp");
362  if (protox == NULL) {
363  LOG(llevError, "init_server: Error getting protox\n");
365  }
366  init_sockets[0].listen->family = PF_INET;
367  init_sockets[0].listen->socktype = SOCK_STREAM;
368  init_sockets[0].listen->protocol = protox->p_proto;
369  insock = static_cast<struct sockaddr_in *>(calloc(sizeof(struct sockaddr_in), 1));
370  insock->sin_family = AF_INET;
371  insock->sin_port = htons(settings.csport);
372  insock->sin_addr.s_addr = htonl(INADDR_ANY);
373  init_sockets[0].listen->addr = (struct sockaddr *) insock;
374  init_sockets[0].listen->addrlen = sizeof(struct sockaddr_in);
375 #endif
376 
377  e = 1;
378  for (i = 0; i < listen_socket_count; i++) {
380  if (init_sockets[i].fd != -1)
381  e = 0;
382  }
383  if (e != 0) {
384  LOG(llevError, "init_server: can't open any listening socket\n");
386  }
387 }
388 
389 /*******************************************************************************
390  *
391  * Start of functions dealing with freeing of the data.
392  *
393  ******************************************************************************/
394 
396 void free_all_newserver(void) {
397  int i;
398  LOG(llevDebug, "Freeing all new client/server information.\n");
399  for (i = 0; i < socket_info.allocated_sockets && init_sockets[i].listen; i++) {
400  free(init_sockets[i].listen->addr);
401  free(init_sockets[i].listen);
402  }
403  free(init_sockets);
404 }
405 
414 #ifdef WIN32 /* ***win32: closesocket in windows style */
415  shutdown(ns->fd, SD_BOTH);
416  if (closesocket(ns->fd)) {
417 #else
418  if (close(ns->fd)) {
419 #endif /* win32 */
420 
421 #ifdef ESRV_DEBUG
422  LOG(llevDebug, "Error closing socket %d\n", ns->fd);
423 #endif
424  }
425  ns->fd = -1;
427  if (ns->stats.range)
429  if (ns->stats.title)
432  FREE_AND_CLEAR(ns->stats.god);
433  if (ns->host)
434  FREE_AND_CLEAR(ns->host);
435  if (ns->client)
437  if (ns->account_name) {
440  }
441  if (ns->account_chars) {
444  ns->account_chars = NULL;
445  }
446  SockList_Term(&ns->inbuf);
447 }
448 
451  SockList sl;
452 
453  SockList_Init(&sl);
454  SockList_AddString(&sl, "goodbye");
455  Send_With_Handling(pl->socket, &sl);
456  SockList_Term(&sl);
457  // If the player wasn't saved (new for instance), then pl->ob isn't removed,
458  // and the socket is needed for updating inventory. So keep it and free after.
459  socket_struct *socket = pl->socket;
460  free_player(pl);
461  free_newsocket(socket);
462  free(socket);
463 }
socket_struct::tick
uint32_t tick
Client wishes to get tick commands.
Definition: newserver.h:111
global.h
NS_FACESENT_FACE
#define NS_FACESENT_FACE
Bitmask for the faces_sent[] array - what portion of the face have we sent?
Definition: newserver.h:142
settings
struct Settings settings
Global settings.
Definition: init.cpp:139
socket_struct::heartbeat
bool heartbeat
Client will send hearbeats.
Definition: newserver.h:117
llevError
@ llevError
Problems requiring server admin to fix.
Definition: logger.h:11
LOG
void LOG(LogLevel logLevel, const char *format,...)
Logs a message to stderr, or to file.
Definition: logger.cpp:82
Map
One map for a player.
Definition: newserver.h:52
socket_info
Socket_Info socket_info
Socket information.
Definition: init.cpp:52
socket_struct::container_position
uint16_t container_position
Start of container contents to send to client.
Definition: newserver.h:120
player
One player.
Definition: player.h:107
strdup_local
#define strdup_local
Definition: compat.h:29
socket_struct::look_position
uint16_t look_position
Start of drawing of look window.
Definition: newserver.h:119
listen_info::protocol
int protocol
Definition: newserver.h:82
listen_info
Contains parameters for socket() and bind() for listening sockets.
Definition: newserver.h:79
socket_struct::sound
uint32_t sound
Client sound mode.
Definition: newserver.h:116
socket_struct
Socket structure, represents a client-server connection.
Definition: newserver.h:93
socket_struct::mapx
uint8_t mapx
Definition: newserver.h:121
Socket_Info::allocated_sockets
int allocated_sockets
Number of allocated items in init_sockets.
Definition: newserver.h:149
free_all_newserver
void free_all_newserver(void)
Free's all the memory that ericserver allocates.
Definition: init.cpp:396
socket_struct::num_look_objects
uint8_t num_look_objects
The maximum number of objects to show on the ground view; this number includes the prev/next group fa...
Definition: newserver.h:127
SockList_AddString
void SockList_AddString(SockList *sl, const char *data)
Adds a string without length.
Definition: lowlevel.cpp:157
ssop_t
int ssop_t
Parameter type for setsockopt, different between WIN32 and Linux.
Definition: init.cpp:40
DEFAULT_NUM_LOOK_OBJECTS
#define DEFAULT_NUM_LOOK_OBJECTS
Default value for the number of objects to send for the 'look' window (container or ground view).
Definition: newserver.h:22
socket_struct::extended_stats
uint32_t extended_stats
Client wants base and maximum statistics information.
Definition: newserver.h:114
init_listening_socket
void init_listening_socket(socket_struct *ns)
This opens *ns for listening to connections.
Definition: init.cpp:187
socket_struct::update_inventory
uint32_t update_inventory
If true, we need to send the inventory list.
Definition: newserver.h:110
MIN
#define MIN(x, y)
Definition: compat.h:21
listen_info::addr
struct sockaddr * addr
Definition: newserver.h:84
Socket_Info::max_filedescriptor
int max_filedescriptor
max filedescriptor on the system.
Definition: newserver.h:148
socket_struct::is_bot
uint32_t is_bot
Client shouldn't be reported to metaserver.
Definition: newserver.h:112
set_output_sock_buf
static void set_output_sock_buf(socket_struct *ns, int bufsize)
Definition: init.cpp:68
socket_struct::listen
struct listen_info * listen
Definition: newserver.h:96
listen_info::socktype
int socktype
Definition: newserver.h:81
SEE_LAST_ERROR
@ SEE_LAST_ERROR
Definition: define.h:52
socket_struct::inbuf
SockList inbuf
If we get an incomplete packet, this is used to hold the data.
Definition: newserver.h:103
Settings::csport
uint16_t csport
Port for new client/server.
Definition: global.h:247
socket_struct::map_scroll_x
int8_t map_scroll_x
Definition: newserver.h:98
buf
StringBuffer * buf
Definition: readable.cpp:1564
init_server
void init_server(void)
This sets up the listening socket.
Definition: init.cpp:278
Socket_Info
Holds some system-related information.
Definition: newserver.h:146
socket_struct::update_look
uint32_t update_look
If true, we need to send the look window.
Definition: newserver.h:109
Ns_Dead
@ Ns_Dead
Definition: newserver.h:71
init_sockets
socket_struct * init_sockets
Established connections for clients not yet playing.
Definition: init.cpp:66
socket_struct::account_chars
Account_Chars * account_chars
Detailed information on characters on this account.
Definition: newserver.h:132
socket_struct::mapy
uint8_t mapy
How large a map the client wants.
Definition: newserver.h:121
socket_struct::stats
struct statsinfo stats
Definition: newserver.h:102
socklen_t
#define socklen_t
Definition: win32.h:17
socket_struct::facecache
uint32_t facecache
If true, client is caching images.
Definition: newserver.h:107
socket_struct::client
sstring client
Client string sent by client.
Definition: newserver.h:105
account_char_free
void account_char_free(Account_Chars *chars)
This frees all data associated with the character information.
Definition: account_char.cpp:345
statsinfo
Contains the last range/title information sent to client.
Definition: newserver.h:60
socket_struct::lastmap
struct Map lastmap
Definition: newserver.h:97
socket_struct::host
char * host
Which host it is connected from (ip address).
Definition: newserver.h:104
socket_struct::account_name
char * account_name
Name of the account logged in on this socket.
Definition: newserver.h:131
socket_struct::monitor_spells
uint32_t monitor_spells
Client wishes to be informed when their spell list changes.
Definition: newserver.h:115
socket_struct::faceset
uint8_t faceset
Set the client is using, default 0.
Definition: newserver.h:122
init_connection
void init_connection(socket_struct *ns, const char *from_ip)
Initializes a connection.
Definition: init.cpp:96
socket_struct::map_scroll_y
int8_t map_scroll_y
Definition: newserver.h:98
statsinfo::title
char * title
Definition: newserver.h:61
sproto.h
VERSION_SC
#define VERSION_SC
Definition: newserver.h:155
SockList_Init
void SockList_Init(SockList *sl)
Initializes the SockList instance.
Definition: lowlevel.cpp:55
image.h
fatal
void fatal(enum fatal_error err)
fatal() is meant to be called whenever a fatal signal is intercepted.
Definition: utils.cpp:595
MAX_BUF
#define MAX_BUF
Used for all kinds of things.
Definition: define.h:35
Ns_Add
@ Ns_Add
Definition: newserver.h:70
free_newsocket
void free_newsocket(socket_struct *ns)
Frees a socket.
Definition: init.cpp:413
SockList_Term
void SockList_Term(SockList *sl)
Frees all resources allocated by a SockList instance.
Definition: lowlevel.cpp:65
listen_info::family
int family
Definition: newserver.h:80
FREE_AND_CLEAR_STR
#define FREE_AND_CLEAR_STR(xyz)
Release the shared string, and set it to NULL.
Definition: global.h:204
cst_tot
CS_Stats cst_tot
socket_struct::sounds_this_tick
int8_t sounds_this_tick
Number of sounds sent this tick.
Definition: newserver.h:126
socket_struct::want_pickup
uint32_t want_pickup
Client wants pickup information when logging in.
Definition: newserver.h:113
FREE_AND_CLEAR
#define FREE_AND_CLEAR(xyz)
Free the pointer and then set it to NULL.
Definition: global.h:199
Socket_Info::timeout
struct timeval timeout
Timeout for select.
Definition: newserver.h:147
newserver.h
socket_struct::status
enum Sock_Status status
Definition: newserver.h:94
SOCKETBUFSIZE
#define SOCKETBUFSIZE
SOCKETBUFSIZE is the size of the output socket buffer we request from the operating system.
Definition: config.h:472
final_free_player
void final_free_player(player *pl)
Sends the 'goodbye' command to the player, and closes connection.
Definition: init.cpp:450
statsinfo::god
char * god
Definition: newserver.h:61
reset_stats
void reset_stats(struct CS_Stats *stats)
socket_struct::faces_sent_len
size_t faces_sent_len
This is the number of elements allocated in faces_sent[].
Definition: newserver.h:99
SockList_ResetRead
void SockList_ResetRead(SockList *sl)
Resets the length of the stored data for reading.
Definition: lowlevel.cpp:83
socket_struct::anims_sent
uint8_t anims_sent[MAXANIMNUM]
What animations we sent.
Definition: newserver.h:101
socket_struct::faces_sent
uint8_t * faces_sent
This is a bitmap on sent face status.
Definition: newserver.h:100
VERSION_CS
#define VERSION_CS
Version >= 1023 understand setup cmd.
Definition: newserver.h:154
MAP_CLIENT_Y_DEFAULT
#define MAP_CLIENT_Y_DEFAULT
Definition: config.h:242
socket_struct::fd
int fd
Definition: newserver.h:95
socket_struct::login_method
uint8_t login_method
Login method this client is using.
Definition: newserver.h:133
statsinfo::range
char * range
Definition: newserver.h:61
listen_info::addrlen
socklen_t addrlen
Definition: newserver.h:83
socket_struct::darkness
uint32_t darkness
True if client wants darkness information.
Definition: newserver.h:108
player::socket
socket_struct * socket
Socket information for this player.
Definition: player.h:109
socket_struct::notifications
uint16_t notifications
Notifications this client wants to get.
Definition: newserver.h:134
socket_struct::password_fails
uint8_t password_fails
How many times the player has failed to give the right password.
Definition: newserver.h:106
get_faces_count
size_t get_faces_count()
Definition: assets.cpp:297
cst_lst
CS_Stats cst_lst
Definition: newclient.h:713
SockList::buf
unsigned char buf[MAXSOCKBUF]
Definition: newclient.h:691
account_char_save
void account_char_save(Account_Chars *chars)
Saves the character information for the given account.
Definition: account_char.cpp:158
MAP_CLIENT_X_DEFAULT
#define MAP_CLIENT_X_DEFAULT
Definition: config.h:241
Send_With_Handling
void Send_With_Handling(socket_struct *ns, SockList *sl)
Calls Write_To_Socket to send data to the client.
Definition: lowlevel.cpp:447
SockList
Contains the base information we use to make up a packet we want to send.
Definition: newclient.h:685
VERSION_INFO
#define VERSION_INFO
Definition: newserver.h:156
llevDebug
@ llevDebug
Only for debugging purposes.
Definition: logger.h:15
free_player
void free_player(player *pl)
Frees player structure, including pointed object (through object_free_drop_inventory()).
Definition: player.cpp:69
SockList_AddPrintf
void SockList_AddPrintf(SockList *sl, const char *format,...)
Adds a printf like formatted string.
Definition: lowlevel.cpp:202
account_logout
void account_logout(const char *account_name)
Remove 'account_name' from the list of logged in accounts.
Definition: account.cpp:348
CS_Stats::max_conn
short max_conn
Maximum connections received.
Definition: newclient.h:701