Crossfire Server, Trunk  R21024
loop.c
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 <arpa/inet.h>
28 #include <assert.h>
29 #include <errno.h>
30 #include <fcntl.h>
31 #include <stdlib.h>
32 #include <string.h>
33 #include <unistd.h>
34 
35 #ifndef WIN32 /* ---win32 exclude unix headers */
36 #include <sys/types.h>
37 #include <sys/time.h>
38 #include <netinet/in.h>
39 #include <netdb.h>
40 #endif /* end win32 */
41 
42 #include "image.h"
43 #include "newserver.h"
44 #include "sockproto.h"
45 #include "sproto.h"
46 
47 /*****************************************************************************
48  * Start of command dispatch area.
49  * The commands here are protocol commands.
50  ****************************************************************************/
51 
52 /* Either keep this near the start or end of the file so it is
53  * at least reasonablye easy to find.
54  * There are really 2 commands - those which are sent/received
55  * before player joins, and those happen after the player has joined.
56  * As such, we have function types that might be called, so
57  * we end up having 2 tables.
58  */
59 
61 typedef void (*func_uint8_int_ns)(char *, int, socket_struct *);
62 
65  const char *cmdname;
67 };
68 
70 typedef void (*func_uint8_int_pl)(char *, int, player *);
73  const char *cmdname;
75  const uint8_t flag;
76 };
77 
93 static const struct player_cmd_mapping player_commands[] = {
94  { "examine", examine_cmd, 1 },
95  { "apply", apply_cmd, 1 },
96  { "move", move_cmd, 1 },
97  { "reply", reply_cmd, 0 },
98  { "ncom", (func_uint8_int_pl)new_player_cmd, 1 },
99  { "lookat", look_at_cmd, 1 },
100  { "lock", (func_uint8_int_pl)lock_item_cmd, 1 },
101  { "mark", (func_uint8_int_pl)mark_item_cmd, 1 },
102  { "inscribe", inscribe_scroll_cmd, 0 },
103  { NULL, NULL, 0 } /* terminator */
104 };
105 
107 static const struct client_cmd_mapping client_commands[] = {
108  { "addme", add_me_cmd },
109  { "askface", send_face_cmd }, /* Added: phil */
110  { "beat", NULL },
111  { "requestinfo", request_info_cmd },
112  { "setup", set_up_cmd },
113  { "version", version_cmd },
114  { "asksmooth", ask_smooth_cmd }, /*Added: tchize (smoothing technologies)*/
115  { "accountlogin", account_login_cmd },
116  { "accountnew", account_new_cmd },
117  { "accountaddplayer", account_add_player_cmd },
118  { "accountplay", account_play_cmd },
119  { "accountpw", account_password },
120  { "createplayer", create_player_cmd },
121  { NULL, NULL } /* terminator (I, II & III)*/
122 };
123 
132 void request_info_cmd(char *buf, int len, socket_struct *ns) {
133  char *params = NULL, *cp;
134  /* No match */
135  SockList sl;
136 
137  if (len <= 0 || !buf) {
138  LOG(llevDebug, "IP '%s' sent bogus request_info_cmd information\n", ns->host);
139  return;
140  }
141 
142  /* Set up replyinfo before we modify any of the buffers - this is used
143  * if we don't find a match.
144  */
145  SockList_Init(&sl);
146  SockList_AddString(&sl, "replyinfo ");
147  SockList_AddString(&sl, buf);
148 
149  /* find the first space, make it null, and update the
150  * params pointer.
151  */
152  for (cp = buf; *cp != '\0'; cp++)
153  if (*cp == ' ') {
154  *cp = '\0';
155  params = cp+1;
156  break;
157  }
158  if (!strcmp(buf, "image_info"))
159  send_image_info(ns);
160  else if (!strcmp(buf, "image_sums"))
161  send_image_sums(ns, params);
162  else if (!strcmp(buf, "skill_info"))
163  send_skill_info(ns, params);
164  else if (!strcmp(buf, "spell_paths"))
165  send_spell_paths(ns, params);
166  else if (!strcmp(buf, "exp_table"))
167  send_exp_table(ns, params);
168  else if (!strcmp(buf, "race_list"))
169  send_race_list(ns, params);
170  else if (!strcmp(buf, "race_info"))
171  send_race_info(ns, params);
172  else if (!strcmp(buf, "class_list"))
173  send_class_list(ns, params);
174  else if (!strcmp(buf, "class_info"))
175  send_class_info(ns, params);
176  else if (!strcmp(buf, "rules"))
177  send_file(ns, "rules");
178  else if (!strcmp(buf, "motd"))
179  send_file(ns, "motd");
180  else if (!strcmp(buf, "news"))
181  send_file(ns, "news");
182  else if (!strcmp(buf,"newcharinfo"))
183  send_new_char_info(ns);
184  else if (!strcmp(buf,"startingmap"))
185  send_map_info(ns);
186  else if (!strcmp(buf, "knowledge_info"))
188  else
189  Send_With_Handling(ns, &sl);
190  SockList_Term(&sl);
191 }
192 
193 static int
194 handle_cmd(socket_struct *ns, player *pl, char *cmd, char *data, int len) {
195  assert(cmd != NULL);
196  for (int i = 0; client_commands[i].cmdname != NULL; i++) {
197  if (strcmp(cmd, client_commands[i].cmdname) == 0) {
198  if (client_commands[i].cmdproc != NULL) {
199  client_commands[i].cmdproc(data, len, ns);
200  }
201  return 0;
202  }
203  }
204  /* Player must be in the playing state or the flag on the
205  * the command must be zero for the user to use the command -
206  * otherwise, a player cam save, be in the play_again state, and
207  * the map they were on getsswapped out, yet things that try to look
208  * at the map causes a crash. If the command is valid, but
209  * one they can't use, we still swallow it up.
210  */
211  if (pl) {
212  for (int i = 0; player_commands[i].cmdname != NULL; i++) {
213  if (strcmp(cmd, player_commands[i].cmdname) == 0) {
214  if (pl->state == ST_PLAYING || player_commands[i].flag == 0) {
215  player_commands[i].cmdproc(data, len, pl);
216  }
217  return 1;
218  }
219  }
220  }
221  LOG(llevDebug, "%s: invalid command '%s'\n", ns->host, cmd);
222  return 0;
223 }
224 
235  /* Loop through this - maybe we have several complete packets here. */
236  /* Command_count is used to limit the number of requests from
237  * clients that have not logged in - we do not want an unauthenticated
238  * connection to spew us with hundreds of requests. As such,
239  * this counter is only increased in the case of socket level commands.
240  * Note that this also has the effect of throttling down face and other
241  * socket commands from the client. As such, if we have a player attached,
242  * we will process more of these, as getting a fair number when entering
243  * a map may not be uncommon.
244  */
245  int command_count = 0;
246  while (command_count < 5 || (pl && command_count < 25)) {
247  if (pl && pl->state == ST_PLAYING && pl->ob != NULL && pl->ob->speed_left < 0) {
248  // Skip processing players with no turns left.
249  return false;
250  }
251 
252  int status = SockList_ReadPacket(ns->fd, &ns->inbuf, sizeof(ns->inbuf.buf)-1);
253  if (status != 1) {
254  if (status < 0) {
255  ns->status = Ns_Dead;
256  }
257  return false;
258  }
259 
260  /* Since we have a full packet, reset last tick time. */
261  ns->last_tick = 0;
262 
264  assert(ns->inbuf.len >= 2);
265  char *data;
266  char *cmd = strtok_r((char *)ns->inbuf.buf + 2, " ", &data);
267 
268  int got_player_cmd;
269  if (data != NULL) {
270  int rem = ns->inbuf.len - ((unsigned char *)data - ns->inbuf.buf);
271  got_player_cmd = handle_cmd(ns, pl, cmd, data, rem);
272  } else {
273  got_player_cmd = handle_cmd(ns, pl, cmd, NULL, 0);
274  }
275 
277  if (got_player_cmd) {
278  return true;
279  }
280 
281  command_count += 1;
282  /* Evil case, and not a nice workaround, but well...
283  * If we receive eg an accountplay command, the socket is copied
284  * to the player structure, and its faces_sent is set to NULL.
285  * This leads to issues when processing the next commands in the queue,
286  * especially if related to faces...
287  * So get out of here in this case, which we detect because faces_sent is NULL.
288  */
289  if (ns->faces_sent == NULL) {
290  command_count = 6;
291  }
292  }
293  return false;
294 }
295 
296 /*****************************************************************************
297  *
298  * Low level socket looping - select calls and watchdog udp packet
299  * sending.
300  *
301  ******************************************************************************/
302 
303 #ifdef WATCHDOG
304 
310 void watchdog(void) {
311  static int fd = -1;
312  static struct sockaddr_in insock;
313 
314  if (fd == -1) {
315  struct protoent *protoent;
316 
317  if ((protoent = getprotobyname("udp")) == NULL
318  || (fd = socket(PF_INET, SOCK_DGRAM, protoent->p_proto)) == -1) {
319  return;
320  }
321  insock.sin_family = AF_INET;
322  insock.sin_port = htons((unsigned short)13325);
323  insock.sin_addr.s_addr = inet_addr("127.0.0.1");
324  }
325  sendto(fd, (void *)&fd, 1, 0, (struct sockaddr *)&insock, sizeof(insock));
326 }
327 #endif
328 
329 extern unsigned long todtick;
330 
334 static void block_until_new_connection(void) {
335  struct timeval Timeout;
336  fd_set readfs;
337  int cycles;
338  int i;
339 
340  LOG(llevInfo, "Waiting for connections...\n");
341 
342  cycles = 1;
343  do {
344  /* Every minutes is a bit often for updates - especially if nothing is going
345  * on. This slows it down to every 6 minutes.
346  */
347  cycles++;
348  if (cycles%2 == 0)
349  tick_the_clock();
350 
351  FD_ZERO(&readfs);
352  for (i = 0; i < socket_info.allocated_sockets && init_sockets[i].listen; i++)
353  if (init_sockets[i].status == Ns_Add)
354  FD_SET((uint32_t)init_sockets[i].fd, &readfs);
355 
356  /* If fastclock is set, we need to seriously slow down the updates
357  * to the metaserver as well as watchdog. Do same for flush_old_maps() -
358  * that is time sensitive, so there is no good reason to call it 2000 times
359  * a second.
360  */
361  if (settings.fastclock > 0) {
362 #ifdef WATCHDOG
363  if (cycles%120000 == 0) {
364  watchdog();
365  flush_old_maps();
366  }
367 #endif
368  if (cycles == 720000) {
370  cycles = 1;
371  }
372  Timeout.tv_sec = 0;
373  Timeout.tv_usec = 50;
374  } else {
375  Timeout.tv_sec = 60;
376  Timeout.tv_usec = 0;
377  if (cycles == 7) {
379  cycles = 1;
380  }
381  flush_old_maps();
382  }
383  } while (select(socket_info.max_filedescriptor, &readfs, NULL, NULL, &Timeout) == 0);
384 
385  reset_sleep(); /* Or the game would go too fast */
386 }
387 
396 static int is_fd_valid(int fd) {
397 #ifndef WIN32
398  return fcntl(fd, F_GETFL) != -1 || errno != EBADF;
399 #else
400  return 1;
401 #endif
402 }
403 
408 static void new_connection(int listen_fd) {
409  int newsocknum = -1, j;
410 #ifdef HAVE_GETNAMEINFO
411  struct sockaddr_storage addr;
412 #else
413  struct sockaddr_in addr;
414 #endif
415  socklen_t addrlen = sizeof(addr);
416 
417 #ifdef ESRV_DEBUG
418  LOG(llevDebug, "do_server: New Connection\n");
419 #endif
420 
421  for (j = 0; j < socket_info.allocated_sockets; j++)
422  if (init_sockets[j].status == Ns_Avail) {
423  newsocknum = j;
424  break;
425  }
426 
427  if (newsocknum == -1) {
428  /* If this is the case, all sockets currently in used */
430  if (!init_sockets)
432  newsocknum = socket_info.allocated_sockets;
434  init_sockets[newsocknum].listen = NULL;
436  init_sockets[newsocknum].faces_sent = calloc(nrofpixmaps, sizeof(*init_sockets[newsocknum].faces_sent));
437  if (!init_sockets[newsocknum].faces_sent)
439  init_sockets[newsocknum].status = Ns_Avail;
440  }
441 
442  if (newsocknum < 0) {
443  LOG(llevError, "FATAL: didn't allocate a newsocket?? alloc = %d, newsocknum = %d", socket_info.allocated_sockets, newsocknum);
445  }
446 
447  init_sockets[newsocknum].fd = accept(listen_fd, (struct sockaddr *)&addr, &addrlen);
448  if (init_sockets[newsocknum].fd == -1) {
449  LOG(llevError, "accept failed: %s\n", strerror(errno));
450  } else {
451  char buf[MAX_BUF];
452 #ifndef HAVE_GETNAMEINFO
453  long ip;
454 #endif
455  socket_struct *ns;
456 
457  ns = &init_sockets[newsocknum];
458 
459 #ifdef HAVE_GETNAMEINFO
460  getnameinfo((struct sockaddr *) &addr, addrlen, buf, sizeof(buf), NULL, 0, NI_NUMERICHOST);
461 #else
462  ip = ntohl(addr.sin_addr.s_addr);
463  snprintf(buf, sizeof(buf), "%ld.%ld.%ld.%ld", (ip>>24)&255, (ip>>16)&255, (ip>>8)&255, ip&255);
464 #endif
465 
466  if (checkbanned(NULL, buf)) {
467  LOG(llevInfo, "Banned host tried to connect: [%s]\n", buf);
468  close(init_sockets[newsocknum].fd);
469  init_sockets[newsocknum].fd = -1;
470  } else {
471  init_connection(ns, buf);
472  }
473  }
474 }
475 
482  // If the client doesn't send heartbeats, assume it's connected.
483  if (!socket.heartbeat) {
484  return true;
485  }
486 
487  // If a client message was received recently, it's connected.
488  if (socket.last_tick < tick_length(BEAT_INTERVAL + 1)) {
489  return true;
490  }
491 
492  return false;
493 }
494 
498 static void send_updates(player *pl) {
499  /* Update the players stats once per tick. More efficient than
500  * sending them whenever they change, and probably just as useful
501  */
502  esrv_update_stats(pl);
503  if (pl->last_weight != -1 && pl->last_weight != WEIGHT(pl->ob)) {
504  esrv_update_item(UPD_WEIGHT, pl->ob, pl->ob);
505  if (pl->last_weight != WEIGHT(pl->ob))
506  LOG(llevError, "esrv_update_item(UPD_WEIGHT) did not set player weight: is %lu, should be %lu\n", (unsigned long)pl->last_weight, (unsigned long)WEIGHT(pl->ob));
507  }
508  /* draw_client_map does sanity checking that map is
509  * valid, so don't do it here.
510  */
511  draw_client_map(pl->ob);
512  if (pl->socket.update_look)
513  esrv_draw_look(pl->ob);
514  if (pl->socket.update_inventory) {
515  if (pl->ob->container != NULL)
516  esrv_send_inventory(pl->ob, pl->ob->container);
517  pl->socket.update_inventory = 0;
518  }
519 }
520 
528 void do_server(void) {
529  fd_set tmp_read, tmp_exceptions;
530  int active = 0;
531  FD_ZERO(&tmp_read);
532  FD_ZERO(&tmp_exceptions);
533 
534  for (int i = 0; i < socket_info.allocated_sockets; i++) {
535  if (init_sockets[i].status == Ns_Add && !is_fd_valid(init_sockets[i].fd)) {
536  LOG(llevError, "do_server: invalid waiting fd %d\n", i);
538  }
539  if (init_sockets[i].status == Ns_Dead) {
540  if (init_sockets[i].listen) {
541  /* try to reopen the listening socket */
543  } else {
546  }
547  } else if (init_sockets[i].status != Ns_Avail) {
548  FD_SET((uint32_t)init_sockets[i].fd, &tmp_read);
549  FD_SET((uint32_t)init_sockets[i].fd, &tmp_exceptions);
550  active++;
551  }
552  }
553 
554  /* Go through the players. Let the loop set the next pl value,
555  * since we may remove some
556  */
557  player *pl, *next;
558  for (pl = first_player; pl != NULL; ) {
559  if (pl->socket.status != Ns_Dead && !is_fd_valid(pl->socket.fd)) {
560  LOG(llevError, "do_server: invalid file descriptor for player %s [%s]: %d\n", (pl->ob && pl->ob->name) ? pl->ob->name : "(unnamed player?)", (pl->socket.host) ? pl->socket.host : "(unknown ip?)", pl->socket.fd);
561  pl->socket.status = Ns_Dead;
562  }
563 
564  if (pl->socket.status == Ns_Dead) {
565  player *npl = pl->next;
566 
567  save_player(pl->ob, 0);
568  leave(pl, 1);
569  final_free_player(pl);
570  pl = npl;
571  } else {
572  FD_SET((uint32_t)pl->socket.fd, &tmp_read);
573  FD_SET((uint32_t)pl->socket.fd, &tmp_exceptions);
574  pl = pl->next;
575  }
576  }
577 
578  if (active == 1 && first_player == NULL)
580 
581  long sleep_time = get_sleep_remaining();
582  if (sleep_time < 0) {
583  LOG(llevInfo, "skipping time\n");
584  jump_time();
585  }
586 
587  while (sleep_time > 0) {
588  socket_info.timeout.tv_sec = 0;
589  socket_info.timeout.tv_usec = sleep_time;
590  int pollret = select(socket_info.max_filedescriptor, &tmp_read, NULL,
591  &tmp_exceptions, &socket_info.timeout);
592  if (pollret == -1) {
593  LOG(llevError, "select failed: %s\n", strerror(errno));
594  return;
595  } else if (!pollret) {
596  return;
597  }
598 
599  /* Check for any exceptions/input on the sockets */
600  for (int i = 0; i < socket_info.allocated_sockets; i++) {
601  /* listen sockets can stay in status Ns_Dead */
602  if (init_sockets[i].status != Ns_Add) {
603  continue;
604  }
605  if (FD_ISSET(init_sockets[i].fd, &tmp_exceptions)) {
608  continue;
609  }
610  if (FD_ISSET(init_sockets[i].fd, &tmp_read)) {
611  if (init_sockets[i].listen)
613  else
614  handle_client(&init_sockets[i], NULL);
615  }
616  }
617 
618  /* This does roughly the same thing, but for the players now */
619  for (pl = first_player; pl != NULL; pl = next) {
620  next = pl->next;
621  if (pl->socket.status == Ns_Dead)
622  continue;
623 
624  if (FD_ISSET(pl->socket.fd, &tmp_exceptions)) {
625  save_player(pl->ob, 0);
626  leave(pl, 1);
627  final_free_player(pl);
628  } else {
629  bool keep_processing = handle_client(&pl->socket, pl);
630  if (!keep_processing) {
631  FD_CLR(pl->socket.fd, &tmp_read);
632  }
633 
634  /* There seems to be rare cases where next points to a removed/freed player.
635  * My belief is that this player does something (shout, move, whatever)
636  * that causes data to be sent to the next player on the list, but
637  * that player is defunct, so the socket codes removes that player.
638  * End result is that next now points at the removed player, and
639  * that has garbage data so we crash. So update the next pointer
640  * while pl is still valid. MSW 2007-04-21
641  */
642  next = pl->next;
643 
644 
645  /* If the player has left the game, then the socket status
646  * will be set to this be the leave function. We don't
647  * need to call leave again, as it has already been called
648  * once.
649  */
650  if (pl->socket.status == Ns_Dead) {
651  save_player(pl->ob, 0);
652  leave(pl, 1);
653  final_free_player(pl);
654  } else {
655  send_updates(pl);
656  }
657  }
658  }
659  sleep_time = get_sleep_remaining();
660  }
661 }
662 
667  player *pl, *next;
668  for (pl = first_player; pl != NULL; pl = next) {
669  next = pl->next;
670  send_updates(pl);
671  /* Increment time since last contact only if logged in. */
672  if (pl->state == ST_PLAYING) {
673  pl->socket.last_tick++;
674 
675  if (!connection_alive(pl->socket)) {
676  // TODO: Handle a lost client connection.
677  LOG(llevDebug, "Lost client connection!\n");
678  }
679  }
680 
681  if (pl->socket.tick)
682  send_tick(pl);
683  }
684 }
const char * cmdname
Definition: loop.c:73
Definition: player.h:92
static void send_updates(player *pl)
Definition: loop.c:498
size_t len
Definition: newclient.h:685
uint32_t tick
Definition: newserver.h:106
void leave(player *pl, int draw_exit)
Definition: server.c:1197
const func_uint8_int_ns cmdproc
Definition: loop.c:66
void SockList_Init(SockList *sl)
Definition: lowlevel.c:48
unsigned char buf[MAXSOCKBUF]
Definition: newclient.h:686
void account_login_cmd(char *buf, int len, socket_struct *ns)
Definition: request.c:2050
unsigned char uint8_t
Definition: win32.h:161
void SockList_ResetRead(SockList *sl)
Definition: lowlevel.c:75
void mark_item_cmd(uint8_t *data, int len, player *pl)
Definition: item.c:723
void look_at_cmd(char *buf, int len, player *pl)
Definition: item.c:819
void version_cmd(char *buf, int len, socket_struct *ns)
Definition: request.c:581
void metaserver_update(void)
Definition: metaserver.c:49
struct obj * container
Definition: object.h:291
const func_uint8_int_pl cmdproc
Definition: loop.c:74
void fatal(enum fatal_error err)
Definition: utils.c:597
uint32_t last_tick
Definition: newserver.h:130
int save_player(object *op, int flag)
Definition: login.c:211
void do_server(void)
Definition: loop.c:528
void esrv_update_item(int flags, object *pl, object *op)
Definition: main.c:342
void send_map_info(socket_struct *ns)
Definition: requestinfo.c:404
void send_image_sums(socket_struct *ns, char *params)
Definition: image.c:139
socket_struct socket
Definition: player.h:94
void esrv_send_inventory(object *pl, object *op)
Definition: item.c:307
bool heartbeat
Definition: newserver.h:112
void new_player_cmd(uint8_t *buf, int len, player *pl)
Definition: request.c:447
int checkbanned(const char *login, const char *host)
Definition: ban.c:32
enum Sock_Status status
Definition: newserver.h:90
#define socklen_t
Definition: win32.h:130
void inscribe_scroll_cmd(char *buf, int len, player *pl)
Definition: item.c:908
int max_filedescriptor
Definition: newserver.h:143
void send_skill_info(socket_struct *ns, char *params)
Definition: requestinfo.c:67
#define ST_PLAYING
Definition: define.h:579
int tick_length(float seconds)
Definition: time.c:378
char * host
Definition: newserver.h:100
unsigned int nrofpixmaps
Definition: image.c:45
socket_struct * init_sockets
Definition: init.c:56
void send_class_list(socket_struct *ns, char *params)
Definition: requestinfo.c:359
void free_newsocket(socket_struct *ns)
Definition: init.c:413
size_t faces_sent_len
Definition: newserver.h:95
uint32_t update_look
Definition: newserver.h:104
static int handle_cmd(socket_struct *ns, player *pl, char *cmd, char *data, int len)
Definition: loop.c:194
const uint8_t flag
Definition: loop.c:75
void flush_old_maps(void)
Definition: swap.c:289
static const struct client_cmd_mapping client_commands[]
Definition: loop.c:107
#define strtok_r(x, y, z)
Definition: win32.h:62
Socket_Info socket_info
Definition: init.c:47
float speed_left
Definition: object.h:329
void send_exp_table(socket_struct *ns, char *params)
Definition: requestinfo.c:121
#define BEAT_INTERVAL
Definition: config.h:680
void SockList_Term(SockList *sl)
Definition: lowlevel.c:58
#define snprintf
Definition: win32.h:46
long get_sleep_remaining()
Definition: time.c:184
void(* func_uint8_int_ns)(char *, int, socket_struct *)
Definition: loop.c:61
void update_players()
Definition: loop.c:666
void account_password(char *buf, int len, socket_struct *ns)
Definition: request.c:2879
bool connection_alive(socket_struct socket)
Definition: loop.c:481
const char * name
Definition: object.h:311
#define WEIGHT(op)
Definition: define.h:688
void jump_time()
Definition: time.c:192
void init_listening_socket(socket_struct *ns)
Definition: init.c:171
uint8_t state
Definition: player.h:118
void SockList_AddString(SockList *sl, const char *data)
Definition: lowlevel.c:149
void account_new_cmd(char *buf, int len, socket_struct *ns)
Definition: request.c:2176
uint32_t update_inventory
Definition: newserver.h:105
void send_race_info(socket_struct *ns, char *params)
Definition: requestinfo.c:313
#define UPD_WEIGHT
Definition: newclient.h:291
void tick_the_clock(void)
Definition: weather.c:96
int allocated_sockets
Definition: newserver.h:144
void send_image_info(socket_struct *ns)
Definition: image.c:112
#define MAX_BUF
Definition: define.h:35
static int is_fd_valid(int fd)
Definition: loop.c:396
void reset_sleep(void)
Definition: time.c:130
void send_class_info(socket_struct *ns, char *params)
Definition: requestinfo.c:380
void set_up_cmd(char *buf, int len, socket_struct *ns)
Definition: request.c:93
object * ob
Definition: player.h:158
void draw_client_map(object *pl)
Definition: request.c:1449
unsigned int uint32_t
Definition: win32.h:162
void esrv_draw_look(object *pl)
Definition: item.c:187
static const struct player_cmd_mapping player_commands[]
Definition: loop.c:93
unsigned long todtick
Definition: init.c:407
void init_connection(socket_struct *ns, const char *from_ip)
Definition: init.c:83
const char * cmdname
Definition: loop.c:65
void send_tick(player *pl)
Definition: request.c:1810
void send_spell_paths(socket_struct *ns, char *params)
Definition: requestinfo.c:97
void request_info_cmd(char *buf, int len, socket_struct *ns)
Definition: loop.c:132
int32_t last_weight
Definition: player.h:142
void lock_item_cmd(uint8_t *data, int len, player *pl)
Definition: item.c:671
struct timeval timeout
Definition: newserver.h:142
struct Settings settings
Definition: init.c:40
void ask_smooth_cmd(char *buf, int len, socket_struct *ns)
Definition: request.c:423
void(* func_uint8_int_pl)(char *, int, player *)
Definition: loop.c:70
void send_file(socket_struct *ns, const char *file)
Definition: requestinfo.c:443
bool handle_client(socket_struct *ns, player *pl)
Definition: loop.c:234
void examine_cmd(char *buf, int len, player *pl)
Definition: item.c:612
uint8_t fastclock
Definition: global.h:294
void apply_cmd(char *buf, int len, player *pl)
Definition: item.c:631
static void block_until_new_connection(void)
Definition: loop.c:334
EXTERN player * first_player
Definition: global.h:117
struct pl * next
Definition: player.h:93
void account_add_player_cmd(char *buf, int len, socket_struct *ns)
Definition: request.c:2284
void watchdog(void)
void final_free_player(player *pl)
Definition: init.c:444
void LOG(LogLevel logLevel, const char *format,...)
Definition: logger.c:51
void add_me_cmd(char *buf, int len, socket_struct *ns)
Definition: request.c:347
void send_race_list(socket_struct *ns, char *params)
Definition: requestinfo.c:292
void reply_cmd(char *buf, int len, player *pl)
Definition: request.c:509
void send_new_char_info(socket_struct *ns)
Definition: requestinfo.c:484
static void new_connection(int listen_fd)
Definition: loop.c:408
void knowledge_send_info(socket_struct *ns)
Definition: knowledge.c:1382
void SockList_NullTerminate(SockList *sl)
Definition: lowlevel.c:229
void esrv_update_stats(player *pl)
Definition: request.c:725
int SockList_ReadPacket(int fd, SockList *sl, int len)
Definition: lowlevel.c:267
void send_face_cmd(char *buff, int len, socket_struct *ns)
Definition: image.c:43
struct listen_info * listen
Definition: newserver.h:92
uint8_t * faces_sent
Definition: newserver.h:96
void move_cmd(char *buf, int len, player *pl)
Definition: request.c:636
void create_player_cmd(char *buf, int len, socket_struct *ns)
Definition: request.c:2500
SockList inbuf
Definition: newserver.h:99
void Send_With_Handling(socket_struct *ns, SockList *sl)
Definition: lowlevel.c:434
void account_play_cmd(char *buf, int len, socket_struct *ns)
Definition: request.c:2413