Crossfire Server, Trunk
request.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 
42 #include "global.h"
43 
44 #include <assert.h>
45 #include <stdlib.h>
46 #include <string.h>
47 #include <sys/time.h>
48 #include <unistd.h>
49 
50 /* This block is basically taken from socket.c - I assume if it works there,
51  * it should work here.
52  */
53 #ifndef WIN32 /* ---win32 exclude unix headers */
54 #include <sys/types.h>
55 #include <netinet/in.h>
56 #include <netinet/tcp.h>
57 #include <netdb.h>
58 typedef int ssop_t;
59 #else
60 #include <winsock2.h>
61 typedef char ssop_t;
62 #endif /* win32 */
63 
64 #include "commands.h"
65 #include "living.h"
66 #include "newserver.h"
67 #include "shared/newclient.h"
68 #include "sounds.h"
69 #include "sproto.h"
70 
71 #define VALIDCHAR_MSG "The first character must be alphanumeric and the last cannot be a space. None of these characters are allowed: :;/\\["
72 
73 static const int MAP2_COORD_MIN = -MAP2_COORD_OFFSET;
74 static const int MAP2_COORD_MAX = 63 - MAP2_COORD_OFFSET;
75 
76 static bool map2_coord_valid(int x) {
77  return x >= MAP2_COORD_MIN && x<= MAP2_COORD_MAX;
78 }
79 
89 static uint16_t MAP2_COORD_ENCODE(int x, int y, int flags) {
90  assert(map2_coord_valid(x));
91  assert(map2_coord_valid(y));
92  assert(flags >= 0 && flags <= 15);
93  return ((x+MAP2_COORD_OFFSET)&0x3f)<<10 | ((y+MAP2_COORD_OFFSET)&0x3f)<<4 | (flags&0x0f);
94 }
95 
96 static int clamp(int x, int min, int max) {
97  return MAX(min, MIN(x, max));
98 }
99 
104 static void handle_scroll(socket_struct *socket, SockList *sl) {
105  // It is possible for map_scroll_x/y to exceed the maximum value that can be encoded
106  // in one scroll command. If that is the case, encode multiple.
107  while (socket->map_scroll_x || socket->map_scroll_y) { // either are non-zero
108  int8_t tx = clamp(socket->map_scroll_x, MAP2_COORD_MIN, MAP2_COORD_MAX);
109  int8_t ty = clamp(socket->map_scroll_y, MAP2_COORD_MIN, MAP2_COORD_MAX);
110  uint16_t coord = MAP2_COORD_ENCODE(tx, ty, 1);
112  socket->map_scroll_x -= tx;
113  socket->map_scroll_y -= ty;
114  }
115 }
116 
123 static const short atnr_cs_stat[NROFATTACKS] = {
128  CS_STAT_RES_DRAIN, -1 /* weaponmagic */,
132  CS_STAT_RES_FEAR, -1 /* Cancellation */,
134  -1 /* Chaos */, -1 /* Counterspell */,
135  -1 /* Godpower */, CS_STAT_RES_HOLYWORD,
137  -1, /* Internal */
138  -1, /* life stealing */
139  -1 /* Disease - not fully done yet */
140 };
141 
143 void set_up_cmd(char *buf, int len, socket_struct *ns) {
144  int s = 0;
145  char *cmd, *param;
146  SockList sl;
147 
148  if (len <= 0 || !buf) {
149  LOG(llevDebug, "IP '%s' sent bogus set_up_cmd information\n", ns->host);
150  return;
151  }
152 
153  /* run through the cmds of setup
154  * syntax is setup <cmdname1> <parameter> <cmdname2> <parameter> ...
155  *
156  * we send the status of the cmd back, or a FALSE is the cmd
157  * is the server unknown
158  * The client then must sort this out
159  */
160 
161  LOG(llevDebug, "setup: %s\n", buf);
162  SockList_Init(&sl);
163  SockList_AddString(&sl, "setup");
164  while (s < len) {
165  cmd = &buf[s];
166 
167  /* find the next space, and put a null there */
168  for (; buf[s] && buf[s] != ' '; s++)
169  ;
170  if (s >= len)
171  break;
172  buf[s++] = 0;
173 
174  while (buf[s] == ' ')
175  s++;
176  if (s >= len)
177  break;
178  param = &buf[s];
179 
180  for (; buf[s] && buf[s] != ' '; s++)
181  ;
182  buf[s++] = 0;
183 
184  while (s < len && buf[s] == ' ')
185  s++;
186 
187  SockList_AddPrintf(&sl, " %s ", cmd);
188 
189  if (!strcmp(cmd, "sound2")) {
190  ns->sound = atoi(param)&(SND_EFFECTS|SND_MUSIC|SND_MUTE);
191  SockList_AddString(&sl, param);
192  } else if (!strcmp(cmd, "spellmon")) {
193  int monitor_spells;
194 
195  monitor_spells = atoi(param);
196  if (monitor_spells < 0 || monitor_spells > 2) {
197  SockList_AddString(&sl, "FALSE");
198  } else {
199  ns->monitor_spells = monitor_spells;
200  SockList_AddPrintf(&sl, "%d", monitor_spells);
201  }
202  } else if (!strcmp(cmd, "darkness")) {
203  int darkness;
204 
205  darkness = atoi(param);
206  if (darkness != 0 && darkness != 1) {
207  SockList_AddString(&sl, "FALSE");
208  } else {
209  ns->darkness = darkness;
210  SockList_AddPrintf(&sl, "%d", darkness);
211  }
212  } else if (!strcmp(cmd, "map2cmd")) {
213  int map2cmd;
214 
215  map2cmd = atoi(param);
216  if (map2cmd != 1) {
217  SockList_AddString(&sl, "FALSE");
218  } else {
219  SockList_AddString(&sl, "1");
220  }
221  } else if (!strcmp(cmd, "facecache")) {
222  int facecache;
223 
224  facecache = atoi(param);
225  if (facecache != 0 && facecache != 1) {
226  SockList_AddString(&sl, "FALSE");
227  } else {
228  ns->facecache = facecache;
229  SockList_AddPrintf(&sl, "%d", facecache);
230  }
231  } else if (!strcmp(cmd, "faceset")) {
232  int q = atoi(param);
233 
234  if (is_valid_faceset(q))
235  ns->faceset = q;
236  SockList_AddPrintf(&sl, "%d", ns->faceset);
237  } else if (!strcmp(cmd, "mapsize")) {
238  int x, y, n;
239 
240  if (sscanf(param, "%dx%d%n", &x, &y, &n) != 2 || n != (int)strlen(param)) {
241  /* mapsize command is invalid, return maximum map size */
242  x = 0;
243  y = 0;
244  }
245 
246  /* Return the maximum map size if the requested x/y is 0, as per
247  * protocol.txt. Note this does not actually change the map size.
248  */
249  if ((x <= 0) && (y <= 0)) {
251  } else {
252  player *pl;
253 
254  /* Constrain the provided map size to what is defined in config.h */
255  if (x < MAP_CLIENT_X_MINIMUM)
257  if (y < MAP_CLIENT_Y_MINIMUM)
259  if (x > MAP_CLIENT_X)
260  x = MAP_CLIENT_X;
261  if (y > MAP_CLIENT_Y)
262  y = MAP_CLIENT_Y;
263 
264  ns->mapx = x;
265  ns->mapy = y;
266 
267  /* better to send back what we are really using and not the
268  * param as given to us in case it gets parsed differently.
269  */
270  SockList_AddPrintf(&sl, "%dx%d", x, y);
271 
272  /* need to update the los, else the view jumps */
273  pl = find_player_socket(ns);
274  if (pl)
275  update_los(pl->ob);
276 
277  /* Client and server need to resynchronize on data - treating it as
278  * a new map is best way to go.
279  */
280  map_newmap_cmd(ns);
281  }
282  } else if (!strcmp(cmd, "tick")) {
283  int tick;
284 
285  tick = atoi(param);
286  if (tick != 0 && tick != 1) {
287  SockList_AddString(&sl, "FALSE");
288  } else {
289  ns->tick = tick;
290  SockList_AddPrintf(&sl, "%d", tick);
291  }
292  } else if (!strcmp(cmd, "bot")) {
293  int is_bot;
294 
295  is_bot = atoi(param);
296  if (is_bot != 0 && is_bot != 1) {
297  SockList_AddString(&sl, "FALSE");
298  } else {
299  ns->is_bot = is_bot;
300  SockList_AddPrintf(&sl, "%d", is_bot);
301  }
302  } else if (!strcmp(cmd, "want_pickup")) {
303  int want_pickup;
304 
305  want_pickup = atoi(param);
306  if (want_pickup != 0 && want_pickup != 1) {
307  SockList_AddString(&sl, "FALSE");
308  } else {
309  ns->want_pickup = want_pickup;
310  SockList_AddPrintf(&sl, "%d", want_pickup);
311  }
312  } else if (!strcmp(cmd, "num_look_objects")) {
313  int tmp;
314  player *pl;
315 
316  tmp = atoi(param);
317  if (tmp < MIN_NUM_LOOK_OBJECTS) {
319  } else if (tmp > MAX_NUM_LOOK_OBJECTS) {
321  }
322  ns->num_look_objects = (uint8_t)tmp;
323  SockList_AddPrintf(&sl, "%d", tmp);
324 
325  pl = find_player_socket(ns);
326  if (pl && pl->ob) {
327  ns->update_look = 1;
328  esrv_draw_look(pl->ob);
329  }
330  } else if (!strcmp(cmd, "extended_stats")) {
331  int extended_stats;
332 
333  extended_stats = atoi(param);
334  if (extended_stats != 0 && extended_stats != 1) {
335  SockList_AddString(&sl, "FALSE");
336  } else {
337  ns->extended_stats = extended_stats;
338  SockList_AddPrintf(&sl, "%d", extended_stats);
339  }
340  } else if (!strcmp(cmd, "beat")) {
341  int use_beat = atoi(param);
342 
343  if (use_beat != 0 && use_beat != 1) {
344  SockList_AddString(&sl, "FALSE");
345  } else {
346  ns->heartbeat = use_beat ? true : false;
347 
348  // Send setup command with standard beat interval.
349  SockList_AddPrintf(&sl, "%d", BEAT_INTERVAL);
350  }
351  } else if (!strcmp(cmd, "loginmethod")) {
352  int loginmethod;
353 
354  loginmethod = atoi(param);
355 
356  /* Only support basic login right now */
357  if (loginmethod > 2) loginmethod=2;
358 
359  ns->login_method = loginmethod;
360  SockList_AddPrintf(&sl, "%d", loginmethod);
361 
362  } else if (!strcmp(cmd, "notifications")) {
363  int notifications;
364 
365  notifications = atoi(param);
366 
367  ns->notifications = MIN(notifications, 3);
368  SockList_AddPrintf(&sl, "%d", ns->notifications);
369 
370  } else if (!strcmp(cmd, "newmapcmd")) {
371  /* newmapcmd is deprecated (now standard part), but some
372  * clients still use this setup option, and if the server
373  * doesn't respond, erroneously report that the client is
374  * too old. Since it is always on, regardless of what is
375  * request, send back one.
376  */
377  SockList_AddString(&sl, "1");
378  } else if (!strcmp(cmd, "extendedTextInfos")) {
379  /* like newmapcmd above, extendedTextInfos is
380  * obsolete, but we respond for the same reason as we do
381  * in newmapcmd
382  */
383  SockList_AddString(&sl, "1");
384  } else if (!strcmp(cmd, "itemcmd")) {
385  /* like newmapcmd above, itemcmd is
386  * obsolete, but we respond for the same reason as we do
387  * in newmapcmd
388  */
389  SockList_AddString(&sl, "2");
390  } else if (!strcmp(cmd, "exp64")) {
391  /* like newmapcmd above, exp64 is
392  * obsolete, but we respond for the same reason as we do
393  * in newmapcmd
394  */
395  SockList_AddString(&sl, "1");
396  } else {
397  /* Didn't get a setup command we understood -
398  * report a failure to the client.
399  */
400  SockList_AddString(&sl, "FALSE");
401  }
402  } /* for processing all the setup commands */
403  Send_With_Handling(ns, &sl);
404  SockList_Term(&sl);
405 }
406 
415 void add_me_cmd(char *buf, int len, socket_struct *ns) {
416  Settings oldsettings;
417  SockList sl;
418  (void)buf;
419  (void)len;
420 
421  oldsettings = settings;
422  if (ns->status != Ns_Add) {
423  SockList_Init(&sl);
424  SockList_AddString(&sl, "addme_failed");
425  Send_With_Handling(ns, &sl);
426  SockList_Term(&sl);
427  } else if (find_player_socket(ns) == NULL) {
428  /* if there is already a player for this socket (add_me was already called),
429  * just ignore, else weird issues. */
430 
431  add_player(ns, 0);
432  /* Basically, the add_player copies the socket structure into
433  * the player structure, so this one (which is from init_sockets)
434  * is not needed anymore. The write below should still work,
435  * as the stuff in ns is still relevant.
436  */
437  SockList_Init(&sl);
438  SockList_AddString(&sl, "addme_success");
439  Send_With_Handling(ns, &sl);
440  SockList_Term(&sl);
441  if (ns->sc_version < 1027 || ns->cs_version < 1023) {
443  "Warning: Your client is too old to receive map data. Please update to a new client at: "
444  "https://sourceforge.net/projects/crossfire/");
445  }
446  }
447  settings = oldsettings;
448 }
449 
459 static void send_smooth(socket_struct *ns, const Face *face) {
460  const Face *smoothface;
461  SockList sl;
462 
463  // A malicious client can send bogus asksmooth commands that don't
464  // translate to any face. Catch those here before the message below
465  // in order to avoid a segfault.
466  if (!face) {
467  LOG(llevError, "Tried to smooth null face.\n");
468  return;
469  }
470 
471  // Try to find a smoothing face, or the default smoothing face. If this
472  // fails, set NS_FACESENT_SMOOTH so we don't try to send it again.
473  //
474  // Failures are usually due to map makers changing the face of a ground
475  // tile, but forgetting to unset smoothlevel.
476  if (!find_smooth(face, &smoothface)
477  && !find_smooth(smooth_face, &smoothface)) {
478  LOG(llevInfo,
479  "Could not smooth face %s. "
480  "Check that this face has a smoothing pixmap, or remove its smoothlevel.\n",
481  face->name);
482  ns->faces_sent[face->number] |= NS_FACESENT_SMOOTH;
483  return;
484  }
485 
486  if (!(ns->faces_sent[smoothface->number]&NS_FACESENT_FACE))
487  esrv_send_face(ns, smoothface, 0);
488 
489  ns->faces_sent[face->number] |= NS_FACESENT_SMOOTH;
490 
491  SockList_Init(&sl);
492  SockList_AddString(&sl, "smooth ");
493  SockList_AddShort(&sl, face->number);
494  SockList_AddShort(&sl, smoothface->number);
495  Send_With_Handling(ns, &sl);
496  SockList_Term(&sl);
497 }
498 
503 void ask_smooth_cmd(char *buf, int len, socket_struct *ns) {
504  uint16_t facenid;
505 
506  if (len <= 0 || !buf) {
507  LOG(llevDebug, "IP '%s' sent bogus ask_smooth_cmd information\n", ns->host);
508  return;
509  }
510 
511  facenid = atoi(buf);
512  send_smooth(ns, get_face_by_id(facenid));
513 }
514 
527 void new_player_cmd(uint8_t *buf, int len, player *pl) {
528  int time, repeat;
529  short packet;
530  char command[MAX_BUF];
531  SockList sl;
532 
533  if (len < 7) {
534  LOG(llevDebug, "Corrupt ncom command - not long enough - discarding\n");
535  return;
536  }
537 
538  packet = GetShort_String(buf);
539  repeat = GetInt_String(buf+2);
540  /* -1 is special - no repeat, but don't update */
541  if (repeat != -1) {
542  pl->count = repeat;
543  }
544  if (len-4 >= MAX_BUF)
545  len = MAX_BUF-5;
546 
547  strncpy(command, (char *)buf+6, len-4);
548  command[len-4] = '\0';
549 
550  /* The following should never happen with a proper or honest client.
551  * Therefore, the error message doesn't have to be too clear - if
552  * someone is playing with a hacked/non working client, this gives them
553  * an idea of the problem, but they deserve what they get
554  */
555  if (pl->state != ST_PLAYING) {
557  "You can not issue commands - state is not ST_PLAYING (%s)",
558  buf);
559  return;
560  }
561 
562  /* This should not happen anymore. */
563  if (pl->ob->speed_left < 0) {
564  LOG(llevError, "Player %s (%s) has negative time - shouldn't do command.\n",
565  pl->ob->name ? pl->ob->name : "(unnamed)", pl->socket->account_name ? pl->socket->account_name : "(no account)");
566  }
567  ssop_t tmp = 1;
568  if (setsockopt(pl->socket->fd, IPPROTO_TCP, TCP_NODELAY, &tmp, sizeof(tmp)))
569  LOG(llevError, "send_tick: Unable to turn off TCP_NODELAY\n");
570  command_execute(pl->ob, command);
571  /* Perhaps something better should be done with a left over count.
572  * Cleaning up the input should probably be done first - all actions
573  * for the command that issued the count should be done before
574  * any other commands.
575  */
576  pl->count = 0;
577 
578  /* Send confirmation of command execution now */
579  SockList_Init(&sl);
580  SockList_AddString(&sl, "comc ");
581  SockList_AddShort(&sl, packet);
582  if (FABS(pl->ob->speed) < 0.001)
583  time = MAX_TIME*100;
584  else
585  time = (int)(MAX_TIME/FABS(pl->ob->speed));
586  SockList_AddInt(&sl, time);
587  Send_With_Handling(pl->socket, &sl);
588  SockList_Term(&sl);
589  tmp = 0;
590  if (setsockopt(pl->socket->fd, IPPROTO_TCP, TCP_NODELAY, &tmp, sizeof(tmp)))
591  LOG(llevError, "send_tick: Unable to turn on TCP_NODELAY\n");
592 }
593 
595 void reply_cmd(char *buf, int len, player *pl) {
596 
597  if (len <= 0 || !buf) {
598  LOG(llevDebug, "Player '%s' sent bogus reply_cmd information\n", pl->ob->name);
599  return;
600  }
601 
602  /* this avoids any hacking here */
603 
604  switch (pl->state) {
605  case ST_PLAYING:
606  LOG(llevError, "Got reply message with ST_PLAYING input state\n");
607  break;
608 
609  case ST_PLAY_AGAIN:
610  /* We can check this for return value (2==quit). Maybe we
611  * should, and do something appropriate?
612  */
613  receive_play_again(pl->ob, buf[0]);
614  break;
615 
616  case ST_ROLL_STAT:
617  key_roll_stat(pl->ob, buf[0]);
618  break;
619 
620  case ST_CHANGE_CLASS:
621 
622  key_change_class(pl->ob, buf[0]);
623  break;
624 
625  case ST_CONFIRM_QUIT:
626  key_confirm_quit(pl->ob, buf[0]);
627  break;
628 
629  case ST_GET_NAME:
630  receive_player_name(pl->ob, buf);
631  break;
632 
633  case ST_GET_PASSWORD:
634  case ST_CONFIRM_PASSWORD:
639  break;
640 
641  case ST_GET_PARTY_PASSWORD: /* Get password for party */
643  break;
644 
645  default:
646  LOG(llevError, "Unknown input state: %d\n", pl->state);
647  }
648 }
649 
657 void version_cmd(char *buf, int len, socket_struct *ns) {
658  char *rest = NULL;
659  char *cs_str = strtok_r(buf, " ", &rest);
660  char *sc_str = strtok_r(NULL, " ", &rest);
661  (void)len;
662 
663  if (cs_str == NULL || sc_str == NULL) {
664  LOG(llevError, "%s: sent invalid version string\n", ns->host);
665  return;
666  } else {
667  ns->cs_version = atoi(cs_str);
668  ns->sc_version = atoi(sc_str);
669  }
670 
671 #ifdef ESRV_DEBUG
672  if (VERSION_CS != ns->cs_version) {
673  LOG(llevDebug, "CS: csversion mismatch (%d,%d)\n", VERSION_CS, ns->cs_version);
674  }
675 
676  if (VERSION_SC != ns->sc_version) {
677  LOG(llevDebug, "CS: scversion mismatch (%d,%d)\n", VERSION_SC, ns->sc_version);
678  }
679 #endif
680 
681  if (rest != NULL) {
682  LOG(llevInfo, "Connection from %s (%s), CS %d, SC %d\n",
683  ns->host, rest, ns->cs_version, ns->sc_version);
684  }
685 }
686 
694  SockList sl;
695 
696  /* If getting a newmap command, this scroll information
697  * is no longer relevant.
698  */
699  ns->map_scroll_x = 0;
700  ns->map_scroll_y = 0;
701 
702 
703  memset(&ns->lastmap, 0, sizeof(ns->lastmap));
704  SockList_Init(&sl);
705  SockList_AddString(&sl, "newmap");
706  Send_With_Handling(ns, &sl);
707  SockList_Term(&sl);
708 }
709 
714 void move_cmd(char *buf, int len, player *pl) {
715  int vals[3], i;
716 
717  if (len <= 0 || !buf) {
718  LOG(llevDebug, "Player '%s' sent bogus move_cmd information\n", pl->ob->name);
719  return;
720  }
721 
722  /* A little funky here. We only cycle for 2 records, because
723  * we obviously am not going to find a space after the third
724  * record. Perhaps we should just replace this with a
725  * sscanf?
726  */
727  for (i = 0; i < 2; i++) {
728  vals[i] = atoi(buf);
729  if (!(buf = strchr(buf, ' '))) {
730  LOG(llevError, "Incomplete move command: %s\n", buf);
731  return;
732  }
733  buf++;
734  }
735  vals[2] = atoi(buf);
736 
737 /* LOG(llevDebug, "Move item %d (nrof=%d) to %d.\n", vals[1], vals[2], vals[0]);*/
738  esrv_move_object(pl->ob, vals[0], vals[1], vals[2]);
739 }
740 
741 /***************************************************************************
742  *
743  * Start of commands the server sends to the client.
744  *
745  ***************************************************************************
746  */
747 
752 void send_query(socket_struct *ns, uint8_t flags, const char *text) {
753  SockList sl;
754 
755  SockList_Init(&sl);
756  SockList_AddPrintf(&sl, "query %d %s", flags, text ? text : "");
757  Send_With_Handling(ns, &sl);
758  SockList_Term(&sl);
759 }
760 
761 #define AddIfInt64(Old, New, sl, Type) \
762  if (Old != New) { \
763  Old = New; \
764  SockList_AddChar(sl, Type); \
765  SockList_AddInt64(sl, New); \
766  }
767 
768 #define AddIfInt(Old, New, sl, Type) \
769  if (Old != New) { \
770  Old = New; \
771  SockList_AddChar(sl, Type); \
772  SockList_AddInt(sl, New); \
773  }
774 
775 #define AddIfShort(Old, New, sl, Type) \
776  if (Old != New) { \
777  Old = New; \
778  SockList_AddChar(sl, Type); \
779  SockList_AddShort(sl, New); \
780  }
781 
782 #define AddIfFloat(Old, New, sl, Type) \
783  if (Old != New) { \
784  Old = New; \
785  SockList_AddChar(sl, Type); \
786  SockList_AddInt(sl, (long)(New*FLOAT_MULTI));\
787  }
788 
789 #define AddIfString(Old, New, sl, Type) \
790  if (Old == NULL || strcmp(Old, New)) { \
791  free(Old); \
792  Old = strdup_local(New); \
793  SockList_AddChar(sl, Type); \
794  SockList_AddLen8Data(sl, New, strlen(New)); \
795  }
796 
802 static uint8_t is_perfect(const player *pl) {
803  const int16_t until = MIN(11, pl->ob->level);
804  for (int16_t i = 1; i < until; i++) {
805  if (pl->levhp[i] < 9 || pl->levsp[i] < 6 || pl->levgrace[i] < 3) {
806  return 0;
807  }
808  }
809  return 1;
810 }
811 
817 static void send_extra_stats(SockList *sl, player *pl) {
818  uint32_t uflags = 0;
819  const char *god = "none";
820 
821  if (pl->socket->notifications < 3) {
822  return;
823  }
824 
825  if (!pl->peaceful) {
826  uflags |= CF_HOSTILE;
827  }
828  if (!is_perfect(pl)) {
829  uflags |= CF_NOT_PERFECT;
830  }
831 
832 #define FIF(F, C) \
833  if (QUERY_FLAG(pl->ob, F)) { \
834  uflags |= C; \
835  }
837  FIF(FLAG_CONFUSED, CF_CONFUSED); // If confused by an item
841 
842  FOR_INV_PREPARE(pl->ob, item) {
843  if (item->type == DISEASE && !QUERY_FLAG(item, FLAG_STARTEQUIP)) {
844  uflags |= CF_DISEASED;
845  }
846  if (strcmp(item->arch->name, "poisoning") == 0) {
847  uflags |= CF_POISONED;
848  }
849  if (strcmp(item->arch->name, "blindness") == 0) {
850  uflags |= CF_BLIND;
851  }
852  if (item->type == FORCE && strcmp(item->name, "confusion") == 0) {
853  uflags |= CF_CONFUSED;
854  }
855  if (item->type == SKILL && item->subtype == SK_PRAYING && item->title) {
856  god = item->title;
857  }
858  }
859  FOR_INV_FINISH();
860 
861  AddIfInt(pl->last_character_flags, uflags, sl, CS_STAT_CHARACTER_FLAGS);
862  AddIfFloat(pl->last_character_load, pl->character_load, sl, CS_STAT_OVERLOAD);
863  AddIfString(pl->socket->stats.god, god, sl, CS_STAT_GOD_NAME);
864  AddIfShort(pl->last_item_power, pl->item_power, sl, CS_STAT_ITEM_POWER);
865 }
866 
874  SockList sl;
875  char buf[MAX_BUF];
876  uint16_t flags;
877  uint8_t s;
878 
879  SockList_Init(&sl);
880  SockList_AddString(&sl, "stats ");
881 
882  if (pl->ob != NULL) {
883  AddIfShort(pl->last_stats.hp, pl->ob->stats.hp, &sl, CS_STAT_HP);
884  AddIfShort(pl->last_stats.maxhp, pl->ob->stats.maxhp, &sl, CS_STAT_MAXHP);
885  AddIfShort(pl->last_stats.sp, pl->ob->stats.sp, &sl, CS_STAT_SP);
886  AddIfShort(pl->last_stats.maxsp, pl->ob->stats.maxsp, &sl, CS_STAT_MAXSP);
887  AddIfShort(pl->last_stats.grace, pl->ob->stats.grace, &sl, CS_STAT_GRACE);
888  AddIfShort(pl->last_stats.maxgrace, pl->ob->stats.maxgrace, &sl, CS_STAT_MAXGRACE);
889  AddIfShort(pl->last_stats.Str, pl->ob->stats.Str, &sl, CS_STAT_STR);
890  AddIfShort(pl->last_stats.Int, pl->ob->stats.Int, &sl, CS_STAT_INT);
891  AddIfShort(pl->last_stats.Pow, pl->ob->stats.Pow, &sl, CS_STAT_POW);
892  AddIfShort(pl->last_stats.Wis, pl->ob->stats.Wis, &sl, CS_STAT_WIS);
893  AddIfShort(pl->last_stats.Dex, pl->ob->stats.Dex, &sl, CS_STAT_DEX);
894  AddIfShort(pl->last_stats.Con, pl->ob->stats.Con, &sl, CS_STAT_CON);
895  AddIfShort(pl->last_stats.Cha, pl->ob->stats.Cha, &sl, CS_STAT_CHA);
896  }
897  if (pl->socket->extended_stats) {
898  int16_t golem_hp, golem_maxhp;
899  AddIfShort(pl->last_orig_stats.Str, pl->orig_stats.Str, &sl, CS_STAT_BASE_STR);
900  AddIfShort(pl->last_orig_stats.Int, pl->orig_stats.Int, &sl, CS_STAT_BASE_INT);
901  AddIfShort(pl->last_orig_stats.Pow, pl->orig_stats.Pow, &sl, CS_STAT_BASE_POW);
902  AddIfShort(pl->last_orig_stats.Wis, pl->orig_stats.Wis, &sl, CS_STAT_BASE_WIS);
903  AddIfShort(pl->last_orig_stats.Dex, pl->orig_stats.Dex, &sl, CS_STAT_BASE_DEX);
904  AddIfShort(pl->last_orig_stats.Con, pl->orig_stats.Con, &sl, CS_STAT_BASE_CON);
905  AddIfShort(pl->last_orig_stats.Cha, pl->orig_stats.Cha, &sl, CS_STAT_BASE_CHA);
906  if (pl->ob != NULL) {
907  AddIfShort(pl->last_race_stats.Str, 20 + pl->ob->arch->clone.stats.Str, &sl, CS_STAT_RACE_STR);
908  AddIfShort(pl->last_race_stats.Int, 20 + pl->ob->arch->clone.stats.Int, &sl, CS_STAT_RACE_INT);
909  AddIfShort(pl->last_race_stats.Pow, 20 + pl->ob->arch->clone.stats.Pow, &sl, CS_STAT_RACE_POW);
910  AddIfShort(pl->last_race_stats.Wis, 20 + pl->ob->arch->clone.stats.Wis, &sl, CS_STAT_RACE_WIS);
911  AddIfShort(pl->last_race_stats.Dex, 20 + pl->ob->arch->clone.stats.Dex, &sl, CS_STAT_RACE_DEX);
912  AddIfShort(pl->last_race_stats.Con, 20 + pl->ob->arch->clone.stats.Con, &sl, CS_STAT_RACE_CON);
913  AddIfShort(pl->last_race_stats.Cha, 20 + pl->ob->arch->clone.stats.Cha, &sl, CS_STAT_RACE_CHA);
914  AddIfShort(pl->last_applied_stats.Str, pl->applied_stats.Str, &sl, CS_STAT_APPLIED_STR);
915  AddIfShort(pl->last_applied_stats.Int, pl->applied_stats.Int, &sl, CS_STAT_APPLIED_INT);
916  AddIfShort(pl->last_applied_stats.Pow, pl->applied_stats.Pow, &sl, CS_STAT_APPLIED_POW);
917  AddIfShort(pl->last_applied_stats.Wis, pl->applied_stats.Wis, &sl, CS_STAT_APPLIED_WIS);
918  AddIfShort(pl->last_applied_stats.Dex, pl->applied_stats.Dex, &sl, CS_STAT_APPLIED_DEX);
919  AddIfShort(pl->last_applied_stats.Con, pl->applied_stats.Con, &sl, CS_STAT_APPLIED_CON);
920  AddIfShort(pl->last_applied_stats.Cha, pl->applied_stats.Cha, &sl, CS_STAT_APPLIED_CHA);
921  }
922  if (pl->ranges[range_golem]) {
923  object *golem = pl->ranges[range_golem];
924  if (QUERY_FLAG(golem, FLAG_REMOVED) || golem->count != pl->golem_count || QUERY_FLAG(golem, FLAG_FREED)) {
925  golem_hp = 0;
926  golem_maxhp = 0;
927  } else {
928  golem_hp = golem->stats.hp;
929  golem_maxhp = golem->stats.maxhp;
930  }
931  } else {
932  golem_hp = 0;
933  golem_maxhp = 0;
934  }
935  /* send first the maxhp, so the client can set up the display */
936  AddIfShort(pl->last_golem_maxhp, golem_maxhp, &sl, CS_STAT_GOLEM_MAXHP);
937  AddIfShort(pl->last_golem_hp, golem_hp, &sl, CS_STAT_GOLEM_HP);
938  }
939 
940  for (s = 0; s < MAX_SKILLS; s++) {
941  if (pl->last_skill_ob[s]) {
942  // Skill objects can be removed without updating last_skill_ob.
943  // Clean them up here if that's the case.
944  if (QUERY_FLAG(pl->last_skill_ob[s], FLAG_REMOVED)) {
945  LOG(llevDebug, "pruning removed object from last_skill_ob\n");
946  pl->last_skill_ob[s] = NULL;
947  continue;
948  }
949 
950  if (pl->last_skill_exp[s] != pl->last_skill_ob[s]->stats.exp) {
951  /* Always send along the level if exp changes. This
952  * is only 1 extra byte, but keeps processing simpler.
953  */
954  SockList_AddChar(&sl, (char)(get_skill_client_code(pl->last_skill_ob[s]->name) + CS_STAT_SKILLINFO));
955  SockList_AddChar(&sl, (char)pl->last_skill_ob[s]->level);
956  SockList_AddInt64(&sl, pl->last_skill_ob[s]->stats.exp);
957  pl->last_skill_exp[s] = pl->last_skill_ob[s]->stats.exp;
958  }
959  }
960  }
961  AddIfInt64(pl->last_stats.exp, pl->ob->stats.exp, &sl, CS_STAT_EXP64);
962  AddIfShort(pl->last_level, (char)pl->ob->level, &sl, CS_STAT_LEVEL);
963  AddIfShort(pl->last_stats.wc, pl->ob->stats.wc, &sl, CS_STAT_WC);
964  AddIfShort(pl->last_stats.ac, pl->ob->stats.ac, &sl, CS_STAT_AC);
965  AddIfShort(pl->last_stats.dam, pl->ob->stats.dam, &sl, CS_STAT_DAM);
966  AddIfFloat(pl->last_speed, pl->ob->speed, &sl, CS_STAT_SPEED);
967  AddIfShort(pl->last_stats.food, pl->ob->stats.food, &sl, CS_STAT_FOOD);
968  AddIfFloat(pl->last_weapon_sp, pl->ob->weapon_speed, &sl, CS_STAT_WEAP_SP);
969  AddIfInt(pl->last_weight_limit, (int32_t)get_weight_limit(pl->ob->stats.Str), &sl, CS_STAT_WEIGHT_LIM);
970  flags = 0;
971  if (pl->fire_on)
972  flags |= SF_FIREON;
973  if (pl->run_on)
974  flags |= SF_RUNON;
975 
976  AddIfShort(pl->last_flags, flags, &sl, CS_STAT_FLAGS);
977  if (pl->socket->sc_version < 1025) {
978  AddIfShort(pl->last_resist[ATNR_PHYSICAL], pl->ob->resist[ATNR_PHYSICAL], &sl, CS_STAT_ARMOUR);
979  } else {
980  int i;
981 
982  for (i = 0; i < NROFATTACKS; i++) {
983  /* Skip ones we won't send */
984  if (atnr_cs_stat[i] == -1)
985  continue;
986  AddIfShort(pl->last_resist[i], pl->ob->resist[i], &sl, (char)atnr_cs_stat[i]);
987  }
988  }
989  if (pl->socket->monitor_spells) {
990  AddIfInt(pl->last_path_attuned, pl->ob->path_attuned, &sl, CS_STAT_SPELL_ATTUNE);
991  AddIfInt(pl->last_path_repelled, pl->ob->path_repelled, &sl, CS_STAT_SPELL_REPEL);
992  AddIfInt(pl->last_path_denied, pl->ob->path_denied, &sl, CS_STAT_SPELL_DENY);
993  }
994  /* we want to use the new fire & run system in new client */
995  rangetostring(pl->ob, buf, sizeof(buf));
996  AddIfString(pl->socket->stats.range, buf, &sl, CS_STAT_RANGE);
997  set_title(pl->ob, buf, sizeof(buf));
998  AddIfString(pl->socket->stats.title, buf, &sl, CS_STAT_TITLE);
999 
1000  send_extra_stats(&sl, pl);
1001 
1002  /* Only send it away if we have some actual data - 2 bytes for length, 6 for "stats ". */
1003  if (sl.len > 8) {
1004 #ifdef ESRV_DEBUG
1005  LOG(llevDebug, "Sending stats command, %d bytes long.\n", sl.len);
1006 #endif
1007  Send_With_Handling(pl->socket, &sl);
1008  }
1009  SockList_Term(&sl);
1010 }
1011 
1015 void esrv_new_player(player *pl, uint32_t weight) {
1016  SockList sl;
1017 
1018  pl->last_weight = weight;
1019 
1020  if (!(pl->socket->faces_sent[pl->ob->face->number]&NS_FACESENT_FACE))
1021  esrv_send_face(pl->socket, pl->ob->face, 0);
1022 
1023  SockList_Init(&sl);
1024  SockList_AddString(&sl, "player ");
1025  SockList_AddInt(&sl, pl->ob->count);
1026  SockList_AddInt(&sl, weight);
1027  SockList_AddInt(&sl, pl->ob->face->number);
1028  SockList_AddLen8Data(&sl, pl->ob->name, strlen(pl->ob->name));
1029 
1030  Send_With_Handling(pl->socket, &sl);
1031  SockList_Term(&sl);
1033 }
1034 
1046  SockList sl;
1047  int i;
1048 
1049  if (anim == NULL) {
1050  LOG(llevError, "esrv_send_anim NULL??\n");
1051  return;
1052  }
1053 
1054  SockList_Init(&sl);
1055  SockList_AddString(&sl, "anim ");
1056  SockList_AddShort(&sl, anim->num);
1057  SockList_AddShort(&sl, 0); /* flags - not used right now */
1058  /* Build up the list of faces. Also, send any information (ie, the
1059  * the face itself) down to the client.
1060  */
1061  for (i = 0; i < anim->num_animations; i++) {
1062  if (!(ns->faces_sent[anim->faces[i]->number]&NS_FACESENT_FACE))
1063  esrv_send_face(ns, anim->faces[i], 0);
1064  /* flags - not used right now */
1065  SockList_AddShort(&sl, anim->faces[i]->number);
1066  }
1067  Send_With_Handling(ns, &sl);
1068  SockList_Term(&sl);
1069  ns->anims_sent[anim->num] = 1;
1070 }
1071 
1072 /****************************************************************************
1073  *
1074  * Start of map related commands.
1075  *
1076  ****************************************************************************/
1077 
1079 static void map_clearcell(struct map_cell_struct *cell, int face, int darkness) {
1080  cell->darkness = darkness;
1081  memset(cell->faces, face, sizeof(cell->faces));
1082 }
1083 
1084 #define MAX_HEAD_POS MAX(MAX_CLIENT_X, MAX_CLIENT_Y)
1085 
1093 static const object *heads[MAX_HEAD_POS][MAX_HEAD_POS][MAP_LAYERS];
1094 
1095 /****************************************************************************
1096  * This block is for map2 drawing related commands.
1097  * Note that the map2 still uses other functions.
1098  *
1099  ***************************************************************************/
1100 
1120 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) {
1121  uint8_t nlayer, smoothlevel = 0;
1122  const object *head;
1123 
1124  assert(ob != NULL);
1125 
1126  head = HEAD(ob);
1127  const Face *face = ob->face;
1128 
1129  /* This is a multipart object, and we are not at the lower
1130  * right corner. So we need to store away the lower right corner.
1131  */
1132  if (!is_head && (head->arch->tail_x || head->arch->tail_y)
1133  && (head->arch->tail_x != ob->arch->clone.x || head->arch->tail_y != ob->arch->clone.y)) {
1134  int bx, by, l;
1135 
1136  /* Basically figure out where the offset is from where we
1137  * are right now. the ob->arch->clone.{x,y} values hold
1138  * the offset that this current piece is from the head,
1139  * and the tail is where the tail is from the head.
1140  * Note that bx and by will equal sx and sy if we are
1141  * already working on the bottom right corner. If ob is
1142  * the head, the clone values will be zero, so the right
1143  * thing will still happen.
1144  */
1145  bx = ax+head->arch->tail_x-ob->arch->clone.x;
1146  by = ay+head->arch->tail_y-ob->arch->clone.y;
1147 
1148  /* I don't think this can ever happen, but better to check
1149  * for it just in case.
1150  */
1151  if (bx < ax || by < ay) {
1152  LOG(llevError, "map2_add_ob: bx (%d) or by (%d) is less than ax (%d) or ay (%d)\n", bx, by, ax, ay);
1153  face = NULL;
1154  }
1155  /* the target position must be within +/-1 of our current
1156  * layer as the layers are defined. We are basically checking
1157  * to see if we have already stored this object away.
1158  */
1159  for (l = layer-1; l <= layer+1; l++) {
1160  if (l < 0 || l >= MAP_LAYERS)
1161  continue;
1162  if (heads[by][bx][l] == head)
1163  break;
1164  }
1165  /* Didn't find it. So we need to store it away. Try to store it
1166  * on our original layer, and then move up a layer.
1167  */
1168  if (l == layer+2) {
1169  if (!heads[by][bx][layer])
1170  heads[by][bx][layer] = head;
1171  else if (layer+1 < MAP_LAYERS && !heads[by][bx][layer+1])
1172  heads[by][bx][layer+1] = head;
1173  }
1174  return 0;
1175  /* Ok - All done storing away the head for future use */
1176  } else {
1177  uint16_t face_num = face ? face->number : 0;
1178  (*has_obj)++;
1181  face_num = (ob->animation ? ob->animation->num : 0)|(1<<15);
1183  face_num |= ANIM_SYNC;
1185  face_num |= ANIM_RANDOM;
1186  }
1187  /* Since face_num includes the bits for the animation tag,
1188  * and we will store that away in the faces[] array, below
1189  * check works fine _except_ for the case where animation
1190  * speed chances.
1191  */
1192  if (ns->lastmap.cells[ax][ay].faces[layer] != face_num) {
1193  uint8_t len, anim_speed = 0, i;
1194 
1195  /* This block takes care of sending the actual face
1196  * to the client. */
1197  ns->lastmap.cells[ax][ay].faces[layer] = face_num;
1198 
1199  /* Now form the data packet */
1200  nlayer = MAP2_LAYER_START+layer;
1201 
1202  len = 2;
1203 
1204  if (ob->map && !MAP_NOSMOOTH(ob->map)) {
1205  smoothlevel = ob->smoothlevel;
1206  if (smoothlevel)
1207  len++;
1208  }
1209 
1212  len++;
1213  /* 1/0.004 == 250, so this is a good cap for an
1214  * upper limit */
1215  if (ob->anim_speed)
1216  anim_speed = ob->anim_speed;
1217  else if (FABS(ob->speed) < 0.004)
1218  anim_speed = 255;
1219  else if (FABS(ob->speed) >= 1.0)
1220  anim_speed = 1;
1221  else
1222  anim_speed = (int)(1.0/FABS(ob->speed));
1223 
1224  if (ob->animation && !ns->anims_sent[ob->animation->num])
1225  esrv_send_animation(ns, ob->animation);
1226 
1227  /* If smoothing, need to send smoothing information
1228  * for all faces in the animation sequence. Since
1229  * smoothlevel is an object attribute,
1230  * it applies to all faces.
1231  */
1232  if (smoothlevel) {
1233  for (i = 0; i < NUM_ANIMATIONS(ob); i++) {
1234  if (!(ns->faces_sent[ob->animation->faces[i]->number]&NS_FACESENT_SMOOTH))
1235  send_smooth(ns, ob->animation->faces[i]);
1236  }
1237  }
1238  } else if (!(ns->faces_sent[face_num]&NS_FACESENT_FACE)) {
1239  esrv_send_face(ns, face, 0);
1240  }
1241 
1242  if (smoothlevel
1243  && !(ns->faces_sent[ob->face->number]&NS_FACESENT_SMOOTH))
1244  send_smooth(ns, ob->face);
1245 
1246  /* Length of packet */
1247  nlayer |= len<<5;
1248 
1249  SockList_AddChar(sl, nlayer);
1250  SockList_AddShort(sl, face_num);
1251  if (anim_speed)
1252  SockList_AddChar(sl, anim_speed);
1253  if (smoothlevel)
1254  SockList_AddChar(sl, smoothlevel);
1255  return 1;
1256  } /* Face is different */
1257  }
1258  return 0;
1259 }
1260 
1261 /* This function is used see if a layer needs to be cleared.
1262  * It updates the socklist, and returns 1 if the update is
1263  * needed, 0 otherwise.
1264  */
1265 static int map2_delete_layer(int ax, int ay, int layer, SockList *sl, socket_struct *ns) {
1266  int nlayer;
1267 
1268  if (ns->lastmap.cells[ax][ay].faces[layer] != 0) {
1269  /* Now form the data packet */
1270  nlayer = 0x10+layer+(2<<5);
1271  SockList_AddChar(sl, nlayer);
1272  SockList_AddShort(sl, 0);
1273  ns->lastmap.cells[ax][ay].faces[layer] = 0;
1274  return 1;
1275  }
1276  return 0;
1277 }
1278 
1290 static int check_probe(int ax, int ay, const object *ob, SockList *sl, socket_struct *ns, int *has_obj, int *alive_layer) {
1291  int got_one = 0, poisoned = 0, diseased = 0;
1292  char name[60];
1293  int value, granularity;
1294  const object *probe;
1295 
1296  /* send hp bar if needed */
1297  if ((*alive_layer) != -1 || ob->head || !CAN_PROBE(ob))
1298  return 0;
1299 
1300  if (settings.always_show_hp == 2) {
1301  /* global hp bars are enabled */
1302  granularity = 30;
1303  } else if (settings.always_show_hp == 1 && ob->stats.hp < ob->stats.maxhp) {
1304  granularity = 30;
1305  } else {
1306  /* only give hp bars to monsters that have been probed */
1307  if (!QUERY_FLAG(ob, FLAG_PROBE)) {
1308  return 0;
1309  }
1310  probe = object_find_by_type_and_name(ob, FORCE, "probe_force");
1311  if (probe == NULL || probe->level < 15) {
1312  /* if probe is not null, this is an error, but well */
1313  return 0;
1314  }
1315 
1316  granularity = (probe->level - 14) / 3;
1317  if (granularity <= 0)
1318  granularity = 1;
1319  else if (granularity > 30)
1320  granularity = 30;
1321  }
1322 
1323  if (ob->stats.maxhp > 0) {
1324  value = (ob->stats.hp * granularity) / (ob->stats.maxhp);
1325 
1326  if (value < 0)
1327  value = 0;
1328  else if (value > granularity)
1329  value = granularity;
1330  } else
1331  value = 30;
1332 
1333  value = (value * 30) / granularity;
1334 
1335  if (object_present_in_ob(POISONING, ob) != NULL)
1336  poisoned = 1;
1337  if (object_present_in_ob(DISEASE, ob) != NULL)
1338  diseased = 1;
1339 
1340  if (value > 0) {
1341  archetype *dummy;
1342 
1343  snprintf(name, sizeof(name), "hpbar%s%s%s_%d",
1344  poisoned ? "_poisoned" : "",
1345  diseased ? "_diseased" : "",
1346  (!poisoned && !diseased) ? "_standard" : "",
1347  value);
1348  dummy = try_find_archetype(name);
1349  if (dummy != NULL) {
1350  got_one += map2_add_ob(ax, ay, MAP_LAYER_FLY2, &dummy->clone, sl, ns, has_obj, 0);
1351  (*alive_layer) = MAP_LAYER_FLY2;
1352  }
1353  }
1354 
1355  return got_one;
1356 }
1357 
1358 static int annotate_ob(int ax, int ay, const object *ob, SockList *sl, socket_struct *ns, int *has_obj, int *alive_layer) {
1359  int got_one = check_probe(ax, ay, ob, sl, ns, has_obj, alive_layer);
1361  if (ob->msg != NULL || object_find_by_arch_name(ob, "npc_dialog")) {
1362  archetype *dummy = try_find_archetype("speechbubble");
1363  if (dummy != NULL) {
1364  got_one += map2_add_ob(ax, ay, MAP_LAYER_FLY2, &dummy->clone, sl, ns, has_obj, 0);
1365  (*alive_layer) = MAP_LAYER_FLY2;
1366  }
1367  }
1368  }
1369  return got_one;
1370 }
1371 
1372 /*
1373  * This function is used to check a space (ax, ay) whose only
1374  * data we may care about are any heads. Basically, this
1375  * space is out of direct view. This is only used with the
1376  * Map2 protocol.
1377  *
1378  * @param ax
1379  * viewport relative x-coordinate
1380  * @param ay
1381  * viewport relative y-coordinate
1382  * @param sl
1383  * the reply to append to
1384  * @param ns
1385  * the client socket
1386  */
1387 static void check_space_for_heads(int ax, int ay, SockList *sl, socket_struct *ns) {
1388  int layer, got_one = 0, del_one = 0, oldlen, has_obj = 0;
1389  uint16_t coord;
1390 
1391  coord = MAP2_COORD_ENCODE(ax, ay, 0);
1392  oldlen = sl->len;
1393  SockList_AddShort(sl, coord);
1394 
1395  for (layer = 0; layer < MAP_LAYERS; layer++) {
1396  const object *head;
1397 
1398  head = heads[ay][ax][layer];
1399  if (head) {
1400  /* in this context, got_one should always increase
1401  * because heads should always point to data to really send.
1402  */
1403  got_one += map2_add_ob(ax, ay, layer, head, sl, ns, &has_obj, 1);
1404  } else {
1405  del_one += map2_delete_layer(ax, ay, layer, sl, ns);
1406  }
1407  }
1408  /* Note - if/when lighting information is added, some code is
1409  * needed here - lighting sources that are out of sight may still
1410  * extend into the viewable area.
1411  */
1412 
1413  /* If nothing to do for this space, we
1414  * can erase the coordinate bytes
1415  */
1416  if (!del_one && !got_one) {
1417  sl->len = oldlen;
1418  } else if (del_one && !has_obj) {
1419  /* If we're only deleting faces and not adding, and there
1420  * are not any faces on the space we care about,
1421  * more efficient
1422  * to send 0 as the type/len field.
1423  */
1424  sl->len = oldlen+2; /* 2 bytes for coordinate */
1425  SockList_AddChar(sl, MAP2_TYPE_CLEAR); /* Clear byte */
1426  SockList_AddChar(sl, 255); /* Termination byte */
1427  // Reduce defreferences by passing the inner array offset instead of address of value
1428  map_clearcell(ns->lastmap.cells[ax] + ay, 0, 0);
1429  } else {
1430  SockList_AddChar(sl, 255); /* Termination byte */
1431  }
1432 }
1433 
1434 static void draw_client_map2(object *pl) {
1435  int x, y, ax, ay, darkness, min_x, max_x, min_y, max_y, oldlen, layer;
1436  size_t startlen;
1437  int16_t nx, ny;
1438  SockList sl;
1439  uint16_t coord;
1440  mapstruct *m;
1441  // Dereference once. It should not change in the middle of processing.
1442  player *plyr = pl->contr;
1443 
1444  SockList_Init(&sl);
1445  SockList_AddString(&sl, "map2 ");
1446  startlen = sl.len;
1447 
1448  handle_scroll(plyr->socket, &sl);
1449 
1450  /* Init data to zero */
1451  memset(heads, 0, sizeof(heads));
1452 
1453  /* We could do this logic as conditionals in the if statement,
1454  * but that started to get a bit messy to look at.
1455  */
1456  min_x = pl->x-plyr->socket->mapx/2;
1457  min_y = pl->y-plyr->socket->mapy/2;
1458  max_x = pl->x+(plyr->socket->mapx+1)/2+MAX_HEAD_OFFSET;
1459  max_y = pl->y+(plyr->socket->mapy+1)/2+MAX_HEAD_OFFSET;
1460 
1461  /* x, y are the real map locations. ax, ay are viewport relative
1462  * locations.
1463  */
1464  ay = 0;
1465  for (y = min_y; y < max_y; y++, ay++) {
1466  ax = 0;
1467  for (x = min_x; x < max_x; x++, ax++) {
1468  /* If this space is out of the normal viewable area,
1469  * we only check the heads value. This is used to
1470  * handle big images - if they extend to a viewable
1471  * portion, we need to send just the lower right corner.
1472  */
1473  if (ax >= plyr->socket->mapx || ay >= plyr->socket->mapy) {
1474  check_space_for_heads(ax, ay, &sl, plyr->socket);
1475  } else {
1476  /* This space is within the viewport of the client. Due
1477  * to walls or darkness, it may still not be visible.
1478  */
1479 
1480  /* Meaning of darkness (see defines in LOS_* in los.c):
1481  * LOS_NO_DARKNESS (0) - object is in plain sight, full brightness.
1482  * 1 - MAX_DARKNESS - how dark the space is - higher
1483  * value is darker space. If level is at max darkness,
1484  * you can't see the space (too dark)
1485  * LOS_BLOCKED (100) - space is blocked from sight.
1486  */
1487  darkness = plyr->blocked_los[ax][ay];
1488 
1489  /* If the coordinates are not valid, or it is too
1490  * dark to see, we tell the client as such
1491  */
1492  nx = x;
1493  ny = y;
1494  m = get_map_from_coord(pl->map, &nx, &ny);
1495  coord = MAP2_COORD_ENCODE(ax, ay, 0);
1496 
1497  if (!m) {
1498  /* space is out of map. Update space and clear
1499  * values if this hasn't already been done.
1500  * If the space is out of the map, it shouldn't
1501  * have a head.
1502  */
1503  if (plyr->socket->lastmap.cells[ax][ay].darkness != 0) {
1504  SockList_AddShort(&sl, coord);
1506  SockList_AddChar(&sl, 255); /* Termination byte */
1507  // Reduce dereferences by passing the inner array offset instead of address of value
1508  map_clearcell(plyr->socket->lastmap.cells[ax] + ay, 0, 0);
1509  }
1510  } else if (darkness >= MAX_LIGHT_RADII) {
1511  /* This block deals with spaces that are not
1512  * visible due to darkness or walls. Still
1513  * need to send the heads for this space.
1514  */
1515  check_space_for_heads(ax, ay, &sl, plyr->socket);
1516  } else {
1517  int have_darkness = 0, has_obj = 0, got_one = 0, del_one = 0, g1, alive_layer = -1, old_got;
1518 
1519  /* In this block, the space is visible. */
1520 
1521  /* Rather than try to figure out what everything
1522  * that we might need to send is, then form the
1523  * packet after that, we presume that we will in
1524  * fact form a packet, and update the bits by what
1525  * we do actually send. If we send nothing, we
1526  * just back out sl.len to the old value, and no
1527  * harm is done.
1528  * I think this is simpler than doing a bunch of
1529  * checks to see what if anything we need to send,
1530  * setting the bits, then doing those checks again
1531  * to add the real data.
1532  */
1533 
1534  oldlen = sl.len;
1535  SockList_AddShort(&sl, coord);
1536 
1537  /* Darkness changed */
1538  if (plyr->socket->lastmap.cells[ax][ay].darkness != darkness
1539  && plyr->socket->darkness) {
1540  plyr->socket->lastmap.cells[ax][ay].darkness = darkness;
1541  /* Darkness tag & length (length=1) */
1542  SockList_AddChar(&sl, MAP2_TYPE_DARKNESS|(1<<5));
1543 
1544  /* Convert darkness level (0-MAX_DARKNESS) to a value
1545  * from 1 (dark) to 255 (bright) for the client.
1546  * Darkness values of 0 (completely dark) are not sent,
1547  * as the space is completely dark.
1548  */
1549  SockList_AddChar(&sl, 255-darkness*(256/MAX_LIGHT_RADII));
1550  have_darkness = 1;
1551  }
1552 
1553  for (layer = 0; layer < MAP_LAYERS; layer++) {
1554  const object *ob = GET_MAP_FACE_OBJ(m, nx, ny, layer);
1555 
1556  /* Special case: send player itself if invisible */
1557  if (!ob
1558  && x == pl->x
1559  && y == pl->y
1560  && (pl->invisible&(pl->invisible < 50 ? 4 : 1))
1561  && (layer == MAP_LAYER_LIVING1 || layer == MAP_LAYER_LIVING2))
1562  ob = pl;
1563 
1564  if (ob) {
1565  g1 = has_obj;
1566  old_got = got_one;
1567  got_one += map2_add_ob(ax, ay, layer, ob, &sl, plyr->socket, &has_obj, 0);
1568 
1569  /* if we added the face, or it is a monster's head, check probe spell */
1570  if (got_one != old_got || (ob->head == NULL && ob->more))
1571  got_one += annotate_ob(ax, ay, ob, &sl, plyr->socket, &has_obj, &alive_layer);
1572 
1573  /* If we are just storing away the head
1574  * for future use, then effectively this
1575  * space/layer is blank, and we should clear
1576  * it if needed.
1577  */
1578  if (g1 == has_obj) {
1579  del_one += map2_delete_layer(ax, ay, layer, &sl, plyr->socket);
1580  } else if (ob->head == NULL) {
1581  /* for single-part items */
1582  got_one += annotate_ob(ax, ay, ob, &sl, plyr->socket, &has_obj, &alive_layer);
1583  }
1584  } else {
1585  if (layer != alive_layer)
1586  del_one += map2_delete_layer(ax, ay, layer, &sl, plyr->socket);
1587  }
1588  }
1589  /* If nothing to do for this space, we
1590  * can erase the coordinate bytes
1591  */
1592  if (!del_one && !got_one && !have_darkness) {
1593  sl.len = oldlen;
1594  } else if (del_one && !has_obj) {
1595  /* If we're only deleting faces and don't
1596  * have any objs we care about, just clear
1597  * space. Note it is possible we may have
1598  * darkness, but if there is nothing on the
1599  * space, darkness isn't all that interesting
1600  * - we can send it when an object shows up.
1601  */
1602  sl.len = oldlen+2; /* 2 bytes for coordinate */
1604  SockList_AddChar(&sl, 255); /* Termination byte */
1605  // Reduce dereferences by passing the inner array offset instead of address of value
1606  map_clearcell(plyr->socket->lastmap.cells[ax] + ay, 0, 0);
1607  } else {
1608  SockList_AddChar(&sl, 255); /* Termination byte */
1609  }
1610  }
1611  } /* else this is a viewable space */
1612  } /* for x loop */
1613  } /* for y loop */
1614 
1615  /* Only send this if there are in fact some differences. */
1616  if (sl.len > startlen) {
1617  Send_With_Handling(plyr->socket, &sl);
1618  }
1619  SockList_Term(&sl);
1620 }
1621 
1625 void draw_client_map(object *pl) {
1626  int i, j;
1627  int16_t ax, ay;
1628  int mflags;
1629  mapstruct *m, *pm;
1630  int min_x, min_y, max_x, max_y;
1631 
1632  if (pl->type != PLAYER) {
1633  LOG(llevError, "draw_client_map called with non player/non eric-server\n");
1634  return;
1635  }
1636 
1637  if (pl->contr->transport) {
1638  pm = pl->contr->transport->map;
1639  } else
1640  pm = pl->map;
1641 
1642  /* If player is just joining the game, he isn't here yet, so
1643  * the map can get swapped out. If so, don't try to send them
1644  * a map. All will be OK once they really log in.
1645  */
1646  if (pm == NULL || pm->in_memory != MAP_IN_MEMORY)
1647  return;
1648 
1649  /*
1650  * This block just makes sure all the spaces are properly
1651  * updated in terms of what they look like.
1652  */
1653  min_x = pl->x-pl->contr->socket->mapx/2;
1654  min_y = pl->y-pl->contr->socket->mapy/2;
1655  max_x = pl->x+(pl->contr->socket->mapx+1)/2;
1656  max_y = pl->y+(pl->contr->socket->mapy+1)/2;
1657  for (j = min_y; j < max_y; j++) {
1658  for (i = min_x; i < max_x; i++) {
1659  ax = i;
1660  ay = j;
1661  m = pm;
1662  mflags = get_map_flags(m, &m, ax, ay, &ax, &ay);
1663  if (mflags&P_OUT_OF_MAP)
1664  continue;
1665  if (mflags&P_NEED_UPDATE)
1666  update_position(m, ax, ay);
1667  /* If a map is visible to the player, we don't want
1668  * to swap it out just to reload it. This should
1669  * really call something like swap_map, but this is
1670  * much more efficient and 'good enough'
1671  */
1672  if (mflags&P_NEW_MAP)
1673  m->timeout = 50;
1674  }
1675  }
1676 
1677  /* do LOS after calls to update_position */
1678  if (pl->contr->do_los) {
1679  update_los(pl);
1680  pl->contr->do_los = 0;
1681  }
1682 
1684 }
1685 
1686 void esrv_map_scroll(socket_struct *ns, int dx, int dy) {
1687  struct Map newmap;
1688  int x, y, mx, my;
1689 
1690  ns->map_scroll_x += dx;
1691  ns->map_scroll_y += dy;
1692 
1693  mx = ns->mapx+MAX_HEAD_OFFSET;
1694  my = ns->mapy+MAX_HEAD_OFFSET;
1695 
1696  /* the x and y here are coordinates for the new map, i.e. if we moved
1697  * (dx,dy), newmap[x][y] = oldmap[x-dx][y-dy]. For this reason,
1698  * if the destination x or y coordinate is outside the viewable
1699  * area, we clear the values - otherwise, the old values
1700  * are preserved, and the check_head thinks it needs to clear them.
1701  */
1702  for (x = 0; x < mx; x++) {
1703  for (y = 0; y < my; y++) {
1704  if (x >= ns->mapx || y >= ns->mapy) {
1705  /* clear cells outside the viewable area */
1706  memset(&newmap.cells[x][y], 0, sizeof(newmap.cells[x][y]));
1707  } else if (x+dx < 0 || x+dx >= ns->mapx || y+dy < 0 || y+dy >= ns->mapy) {
1708  /* clear newly visible tiles within the viewable area */
1709  memset(&newmap.cells[x][y], 0, sizeof(newmap.cells[x][y]));
1710  } else {
1711  memcpy(&newmap.cells[x][y], &ns->lastmap.cells[x+dx][y+dy], sizeof(newmap.cells[x][y]));
1712  }
1713  }
1714  }
1715 
1716  memcpy(&ns->lastmap, &newmap, sizeof(ns->lastmap));
1717 }
1718 
1724 void send_plugin_custom_message(object *pl, char *buf) {
1725  SockList sl;
1726 
1727  SockList_Init(&sl);
1728  SockList_AddString(&sl, buf);
1729  Send_With_Handling(pl->contr->socket, &sl);
1730  SockList_Term(&sl);
1731 }
1732 
1739  SockList sl;
1740  int flags = 0;
1741  client_spell *spell_info;
1742 
1743  if (!pl->socket || !pl->socket->monitor_spells)
1744  return;
1745 
1746  /* Handles problem at login, where this is called from fix_object
1747  * before we have had a chance to send spells to the player. It does seem
1748  * to me that there should never be a case where update_spells is called
1749  * before add_spells has been called. Add_spells() will update the
1750  * spell_state to non null.
1751  */
1752  if (!pl->spell_state)
1753  return;
1754 
1755  FOR_INV_PREPARE(pl->ob, spell) {
1756  if (spell->type == SPELL) {
1757  spell_info = get_client_spell_state(pl, spell);
1758  /* check if we need to update it*/
1759  if (spell_info->last_sp != SP_level_spellpoint_cost(pl->ob, spell, SPELL_MANA)) {
1760  spell_info->last_sp = SP_level_spellpoint_cost(pl->ob, spell, SPELL_MANA);
1761  flags |= UPD_SP_MANA;
1762  }
1763  if (spell_info->last_grace != SP_level_spellpoint_cost(pl->ob, spell, SPELL_GRACE)) {
1764  spell_info->last_grace = SP_level_spellpoint_cost(pl->ob, spell, SPELL_GRACE);
1765  flags |= UPD_SP_GRACE;
1766  }
1767  if (spell_info->last_dam != spell->stats.dam+SP_level_dam_adjust(pl->ob, spell)) {
1768  spell_info->last_dam = spell->stats.dam+SP_level_dam_adjust(pl->ob, spell);
1769  flags |= UPD_SP_DAMAGE;
1770  }
1771  if (flags != 0) {
1772  SockList_Init(&sl);
1773  SockList_AddString(&sl, "updspell ");
1774  SockList_AddChar(&sl, flags);
1775  SockList_AddInt(&sl, spell->count);
1776  if (flags&UPD_SP_MANA)
1777  SockList_AddShort(&sl, spell_info->last_sp);
1778  if (flags&UPD_SP_GRACE)
1779  SockList_AddShort(&sl, spell_info->last_grace);
1780  if (flags&UPD_SP_DAMAGE)
1781  SockList_AddShort(&sl, spell_info->last_dam);
1782  flags = 0;
1783  Send_With_Handling(pl->socket, &sl);
1784  SockList_Term(&sl);
1785  }
1786  }
1787  } FOR_INV_FINISH();
1788 }
1789 
1790 void esrv_remove_spell(player *pl, object *spell) {
1791  SockList sl;
1792 
1793  if (!pl || !spell || spell->env != pl->ob) {
1794  LOG(llevError, "Invalid call to esrv_remove_spell\n");
1795  return;
1796  }
1797  if (!pl->socket->monitor_spells)
1798  return;
1799 
1800  SockList_Init(&sl);
1801  SockList_AddString(&sl, "delspell ");
1802  SockList_AddInt(&sl, spell->count);
1803  Send_With_Handling(pl->socket, &sl);
1804  SockList_Term(&sl);
1805 }
1806 
1814  SockList sl;
1815 
1816  if (!pl->socket->want_pickup)
1817  return;
1818  SockList_Init(&sl);
1819  SockList_AddString(&sl, "pickup ");
1820  SockList_AddInt(&sl, pl->mode);
1821  Send_With_Handling(pl->socket, &sl);
1822  SockList_Term(&sl);
1823 }
1824 
1833 static int spell_client_use(const object *spell) {
1834  switch (spell->type)
1835  {
1836  case SP_RAISE_DEAD:
1837  case SP_MAKE_MARK:
1838  return 3;
1839  case SP_RUNE:
1840  if (!spell->other_arch)
1841  return 1;
1842  break;
1843  case SP_CREATE_FOOD:
1844  case SP_CREATE_MISSILE:
1845  return 2;
1846  case SP_SUMMON_MONSTER:
1847  if (spell->randomitems != NULL)
1848  return 2;
1849  /* break; */// If add conditins below, use this break statement
1850  }
1851  // This is not in the switch statement so that it supports fallthrough logic
1852  // on the few spell types that have additional conditions attached.
1853  return 0;
1854 }
1855 
1857 static void append_spell(player *pl, SockList *sl, object *spell) {
1858  client_spell *spell_info;
1859  int len, i, skill = 0;
1860 
1861  if (!spell->name) {
1862  LOG(llevError, "item number %d is a spell with no name.\n", spell->count);
1863  return;
1864  }
1865 
1866  if (spell->face && !(pl->socket->faces_sent[spell->face->number]&NS_FACESENT_FACE))
1867  esrv_send_face(pl->socket, spell->face, 0);
1868 
1869  spell_info = get_client_spell_state(pl, spell);
1870  SockList_AddInt(sl, spell->count);
1871  SockList_AddShort(sl, spell->level);
1872  SockList_AddShort(sl, spell->casting_time);
1873  /* store costs and damage in the object struct, to compare to later */
1874  spell_info->last_sp = SP_level_spellpoint_cost(pl->ob, spell, SPELL_MANA);
1875  spell_info->last_grace = SP_level_spellpoint_cost(pl->ob, spell, SPELL_GRACE);
1876  spell_info->last_dam = spell->stats.dam+SP_level_dam_adjust(pl->ob, spell);
1877  /* send the current values */
1878  SockList_AddShort(sl, spell_info->last_sp);
1879  SockList_AddShort(sl, spell_info->last_grace);
1880  SockList_AddShort(sl, spell_info->last_dam);
1881 
1882  /* figure out which skill it uses, if it uses one */
1883  if (spell->skill) {
1884  for (i = 0; i < MAX_SKILLS && skill_names[i]; i++)
1885  if (!strcmp(spell->skill, skill_names[i])) {
1886  skill = i+CS_STAT_SKILLINFO;
1887  break;
1888  }
1889  }
1890  SockList_AddChar(sl, skill);
1891 
1892  SockList_AddInt(sl, spell->path_attuned);
1893  SockList_AddInt(sl, spell->face ? spell->face->number : 0);
1894  SockList_AddLen8Data(sl, spell->name, strlen(spell->name));
1895 
1896  if (!spell->msg) {
1897  SockList_AddShort(sl, 0);
1898  } else {
1899  len = strlen(spell->msg);
1900  SockList_AddShort(sl, len);
1901  SockList_AddData(sl, spell->msg, len);
1902  }
1903 
1904  /* Extended spell information available if the client wants it.
1905  */
1906  if (pl->socket->monitor_spells >= 2) {
1907  /* spellmon 2
1908  */
1909  sstring req = object_get_value(spell, "casting_requirements");
1910 
1911  SockList_AddChar(sl, spell_client_use(spell)); /* Usage code */
1912 
1913  if (req) { /* Requirements */
1914  SockList_AddLen8Data(sl, req, strlen(req));
1915  } else {
1916  SockList_AddChar(sl, 0);
1917  }
1918  /* end spellmon 2
1919  */
1920  }
1921 }
1922 
1927 void esrv_add_spells(player *pl, object *spell) {
1928  SockList sl;
1929  size_t size;
1930  sstring value;
1931 
1932  if (!pl) {
1933  LOG(llevError, "esrv_add_spells, tried to add a spell to a NULL player\n");
1934  return;
1935  }
1936 
1937  if (!pl->socket->monitor_spells)
1938  return;
1939 
1940  SockList_Init(&sl);
1941  SockList_AddString(&sl, "addspell ");
1942  if (!spell) {
1943  FOR_INV_PREPARE(pl->ob, spell) {
1944  if (spell->type != SPELL)
1945  continue;
1946  /* Were we to simply keep appending data here, we could
1947  * exceed the SockList buffer if the player has enough spells
1948  * to add. We know that append_spell will always append
1949  * 23 data bytes, plus 3 length bytes and 2 strings
1950  * (because that is the spec) so we need to check that
1951  * the length of those 2 strings, plus the 26 bytes,
1952  * won't take us over the length limit for the socket.
1953  * If it does, we need to send what we already have,
1954  * and restart packet formation.
1955  */
1956  size = 26+strlen(spell->name)+(spell->msg ? strlen(spell->msg) : 0);
1957  if (pl->socket->monitor_spells >= 2) {
1959  value = object_get_value(spell, "casting_requirements");
1960  size += 2 + (value ? strlen(value) : 0);
1961  }
1962  if (SockList_Avail(&sl) < size) {
1963  Send_With_Handling(pl->socket, &sl);
1964  SockList_Reset(&sl);
1965  SockList_AddString(&sl, "addspell ");
1966  }
1967  append_spell(pl, &sl, spell);
1968  } FOR_INV_FINISH();
1969  } else if (spell->type != SPELL) {
1970  LOG(llevError, "Asked to send a non-spell object as a spell\n");
1971  return;
1972  } else
1973  append_spell(pl, &sl, spell);
1974  /* finally, we can send the packet */
1975  Send_With_Handling(pl->socket, &sl);
1976  SockList_Term(&sl);
1977 }
1978 
1979 /* sends a 'tick' information to the client.
1980  * We also take the opportunity to toggle TCP_NODELAY -
1981  * this forces the data in the socket to be flushed sooner to the
1982  * client - otherwise, the OS tries to wait for full packets
1983  * and will this hold sending the data for some amount of time,
1984  * which thus adds some additional latency.
1985  */
1987  SockList sl;
1988  ssop_t tmp;
1989 
1990  SockList_Init(&sl);
1991  SockList_AddString(&sl, "tick ");
1992  SockList_AddInt(&sl, pticks);
1993  tmp = 1;
1994  if (setsockopt(pl->socket->fd, IPPROTO_TCP, TCP_NODELAY, &tmp, sizeof(tmp)))
1995  LOG(llevError, "send_tick: Unable to turn on TCP_NODELAY\n");
1996 
1997  Send_With_Handling(pl->socket, &sl);
1998  tmp = 0;
1999  if (setsockopt(pl->socket->fd, IPPROTO_TCP, TCP_NODELAY, &tmp, sizeof(tmp)))
2000  LOG(llevError, "send_tick: Unable to turn off TCP_NODELAY\n");
2001  SockList_Term(&sl);
2002 }
2003 
2016 static void add_char_field(SockList *sl, int type, const char *data)
2017 {
2018  int len;
2019 
2020  len = strlen(data);
2021 
2022  if (len) {
2023  /* one extra for length for the type byte */
2024  SockList_AddChar(sl, len+1);
2025  SockList_AddChar(sl, type);
2026  SockList_AddString(sl, data);
2027  }
2028 }
2029 
2051 {
2052  SockList sl;
2053  int num_chars;
2054  linked_char *extra;
2055 
2056  if (ns->account_chars) {
2058  }
2060 
2061  num_chars = 0;
2062  extra = account_get_additional_chars(ns->account_name, ns->account_chars, &num_chars);
2063 
2064  SockList_Init(&sl);
2065  SockList_AddString(&sl, "accountplayers ");
2066 
2067  SockList_AddChar(&sl, static_cast<char>(ns->account_chars->chars.size() + num_chars));
2068 
2069  /* Now add real character data */
2070  for (auto acn : ns->account_chars->chars) {
2071  uint16_t faceno = 0;
2072 
2073  /* Ignore a dead character. They don't need to show up. */
2074  if (acn->isDead) {
2075  continue;
2076  }
2077 
2078  add_char_field(&sl, ACL_NAME, acn->name);
2079  add_char_field(&sl, ACL_CLASS, acn->character_class);
2080  add_char_field(&sl, ACL_RACE, acn->race);
2081  add_char_field(&sl, ACL_FACE, acn->face);
2082  if (acn->face[0] != 0 ) {
2083  const Face *face = try_find_face(acn->face, NULL);
2084 
2085  if (face != NULL) {
2086  if (!(ns->faces_sent[face->number]&NS_FACESENT_FACE)) {
2087  esrv_send_face(ns, face, 0);
2088  }
2089  faceno = face->number;
2090  }
2091  }
2092 
2093  add_char_field(&sl, ACL_PARTY, acn->party);
2094  add_char_field(&sl, ACL_MAP, acn->map);
2095  SockList_AddChar(&sl, 3);
2097  SockList_AddShort(&sl, acn->level);
2098  if (faceno) {
2099  SockList_AddChar(&sl, 3);
2101  SockList_AddShort(&sl, faceno);
2102  }
2103 
2104  SockList_AddChar(&sl, 0);
2105  }
2106  /* Now for any characters where we just have the name */
2107  for (linked_char *e = extra; e != NULL; e = e->next) {
2108  add_char_field(&sl, ACL_NAME, e->name);
2109  SockList_AddChar(&sl, 0);
2110  }
2111 
2112  Send_With_Handling(ns, &sl);
2113  SockList_Term(&sl);
2114 
2115  if (extra) {
2116  free_charlinks(extra);
2117  }
2118 }
2119 
2141 static int decode_name_password(const char *buf, int *len, char *name, char *password)
2142 {
2143  int nlen, plen;
2144 
2145  if (*len < 2) {
2146  return 1;
2147  }
2148 
2149  nlen = (unsigned char)buf[0];
2150  if (nlen >= MAX_BUF || nlen > *len-2) {
2151  return 1;
2152  }
2153  memcpy(name, buf+1, nlen);
2154  name[nlen] = 0;
2155 
2156  plen = (unsigned char)buf[nlen+1];
2157  if (plen >= MAX_BUF || plen > *len-2-nlen) {
2158  return 2;
2159  }
2160  memcpy(password, buf+2+nlen, plen);
2161  password[plen] = 0;
2162 
2163  *len = nlen+plen+2;
2164 
2165  return 0;
2166 }
2177 void account_login_cmd(char *buf, int len, socket_struct *ns) {
2178  char name[MAX_BUF], password[MAX_BUF];
2179  int status;
2180  SockList sl;
2181 
2182  if (len <= 0 || !buf) {
2183  LOG(llevDebug, "IP '%s' sent bogus add_player_cmd information\n", ns->host);
2184  return;
2185  }
2186 
2187  SockList_Init(&sl);
2188 
2189  status = decode_name_password(buf, &len, name, password);
2190 
2191  if (status == 1) {
2192  SockList_AddString(&sl, "failure accountlogin Name is too long");
2193  Send_With_Handling(ns, &sl);
2194  SockList_Term(&sl);
2195  return;
2196  }
2197  if (status == 2) {
2198  SockList_AddString(&sl, "failure accountlogin Password is too long");
2199  Send_With_Handling(ns, &sl);
2200  SockList_Term(&sl);
2201  return;
2202  }
2203 
2204  if (!account_exists(name)) {
2205  SockList_AddString(&sl, "failure accountlogin No such account name exists on this server");
2206  Send_With_Handling(ns, &sl);
2207  SockList_Term(&sl);
2208  return;
2209  }
2210 
2211  if (account_login(name, password)) {
2212  LOG(llevInfo, "Account login for '%s' from %s\n", name, ns->host);
2213 
2214  if (ns->account_name) free(ns->account_name);
2215  /* We want to store away official name so we do not
2216  * have any case sensitivity issues on the files.
2217  * because we have already checked password, we
2218  * know that account_exists should never return NULL in
2219  * this case.
2220  */
2222 
2224  } else {
2225  LOG(llevInfo, "Failed account login for '%s' from %s\n", name, ns->host);
2226  SockList_AddString(&sl, "failure accountlogin Incorrect password for account");
2227  Send_With_Handling(ns, &sl);
2228  SockList_Term(&sl);
2229  }
2230 }
2231 
2240 static int account_block_create(const socket_struct *ns) {
2241  /* Check if account creation is blocked. */
2243  /* Account creation is allowed for everyone. */
2244  return 0;
2245  }
2246 
2247  /* Has the trusted host been defined? */
2248  if(settings.account_trusted_host == NULL) {
2249  /* No, allocate it and set it to localhost now. */
2251  }
2252 
2253  /* Return false if the client connected from the trusted host. */
2254  if(strcmp(ns->host, settings.account_trusted_host) == 0){
2255  return 0;
2256  }
2257 
2258  /*
2259  * If we are here, then we are blocking account create and we do
2260  * not trust this client's IP address.
2261  */
2262  return 1;
2263 }
2264 
2276 void account_new_cmd(char *buf, int len, socket_struct *ns) {
2277  char name[MAX_BUF], password[MAX_BUF];
2278  int status;
2279  SockList sl;
2280 
2281  if (len <= 0 || !buf) {
2282  LOG(llevDebug, "IP '%s' sent bogus add_player_cmd information\n", ns->host);
2283  return;
2284  }
2285 
2286  SockList_Init(&sl);
2287 
2288  status = decode_name_password(buf, &len, name, password);
2289 
2290  if (account_block_create(ns)) {
2291  LOG(llevInfo, "Account create blocked from %s\n", ns->host);
2292  SockList_AddString(&sl, "failure accountnew Account creation is disabled");
2293  Send_With_Handling(ns, &sl);
2294  SockList_Term(&sl);
2295  return;
2296  }
2297 
2298  if (status == 1) {
2299  SockList_AddString(&sl, "failure accountnew Name is too long");
2300  Send_With_Handling(ns, &sl);
2301  SockList_Term(&sl);
2302  return;
2303  }
2304  if (status == 2) {
2305  SockList_AddString(&sl, "failure accountnew Password is too long");
2306  Send_With_Handling(ns, &sl);
2307  SockList_Term(&sl);
2308  return;
2309  }
2310  /*The minimum length isn't exactly required, but in the current implementation,
2311  * client will send the same password for character for which there is a
2312  * 2 character minimum size. Thus an account with a one character password
2313  * won't be able to create a character. */
2314  if (strlen(name)<settings.min_name) {
2315  SockList_AddString(&sl, "failure accountnew Name is too short");
2316  Send_With_Handling(ns, &sl);
2317  SockList_Term(&sl);
2318  return;
2319  }
2320  if (strlen(password)<2) {
2321  SockList_AddString(&sl, "failure accountnew Password is too short");
2322  Send_With_Handling(ns, &sl);
2323  SockList_Term(&sl);
2324  return;
2325  }
2326 
2327  if (account_exists(name)) {
2328  SockList_AddString(&sl, "failure accountnew That account already exists on this server");
2329  Send_With_Handling(ns, &sl);
2330  SockList_Term(&sl);
2331  return;
2332  }
2333 
2335  if (status == 1) {
2336  SockList_AddString(&sl,
2337  "failure accountnew Choose a different account name. " VALIDCHAR_MSG);
2338  Send_With_Handling(ns, &sl);
2339  SockList_Term(&sl);
2340  return;
2341  }
2342 
2343  if (status == 2) {
2344  SockList_AddString(&sl,
2345  "failure accountnew That account name is too long");
2346  Send_With_Handling(ns, &sl);
2347  SockList_Term(&sl);
2348  return;
2349  }
2350 
2351  status = account_check_string(password);
2352  if (status == 1) {
2353  SockList_AddString(&sl,
2354  "failure accountnew Choose a different password. " VALIDCHAR_MSG);
2355  Send_With_Handling(ns, &sl);
2356  SockList_Term(&sl);
2357  return;
2358  }
2359 
2360  if (status == 2) {
2361  SockList_AddString(&sl,
2362  "failure accountnew That password is too long");
2363  Send_With_Handling(ns, &sl);
2364  SockList_Term(&sl);
2365  return;
2366  }
2367 
2368  /* If we got here, we passed all checks - so now add it */
2369  if (ns->account_name) free(ns->account_name);
2371  account_new(name, password);
2372  /* save account information */
2373  accounts_save();
2375 }
2376 
2390 void account_add_player_cmd(char *buf, int len, socket_struct *ns) {
2391  char name[MAX_BUF], password[MAX_BUF];
2392  int status, force, nlen;
2393  SockList sl;
2394  const char *cp;
2395 
2396  if (len <= 0 || !buf) {
2397  LOG(llevDebug, "IP '%s' sent bogus add_player_cmd information\n", ns->host);
2398  return;
2399  }
2400 
2401  SockList_Init(&sl);
2402 
2403  if (ns->account_name == NULL) {
2404  SockList_AddString(&sl, "failure accountaddplayer Not logged in");
2405  Send_With_Handling(ns, &sl);
2406  SockList_Term(&sl);
2407  return;
2408  }
2409 
2410  force = buf[0];
2411  nlen = len - 1;
2412  status = decode_name_password(buf+1, &nlen, name, password);
2413  if (status == 1) {
2414  SockList_AddString(&sl, "failure accountaddplayer Name is too long");
2415  Send_With_Handling(ns, &sl);
2416  SockList_Term(&sl);
2417  return;
2418  }
2419  if (status == 2) {
2420  SockList_AddString(&sl, "failure accountaddplayer Password is too long");
2421  Send_With_Handling(ns, &sl);
2422  SockList_Term(&sl);
2423  return;
2424  }
2425 
2426  status = verify_player(name, password);
2427  if (status) {
2428  /* From a security standpoint, telling random folks if it
2429  * it as wrong password makes it easier to hack. However,
2430  * it is fairly easy to determine what characters exist on a server
2431  * (either by trying to create a new one and see if the name is in
2432  * in use, or just looking at the high score file), so this
2433  * really does not make things much less secure
2434  */
2435  if (status == 1)
2436  SockList_AddString(&sl, "failure accountaddplayer 0 The character does not exist.");
2437  else
2438  SockList_AddString(&sl, "failure accountaddplayer 0 That password is incorrect.");
2439 
2440  Send_With_Handling(ns, &sl);
2441  SockList_Term(&sl);
2442  return;
2443  }
2444  /* Check to see if this character is associated with an account.
2445  */
2447  if (cp) {
2448  if (!strcmp(cp, ns->account_name)) {
2449  SockList_AddString(&sl, "failure accountaddplayer 0 That character is already connected to this account.");
2450  Send_With_Handling(ns, &sl);
2451  SockList_Term(&sl);
2452  return;
2453  } else {
2454  if (!force) {
2455  SockList_AddString(&sl, "failure accountaddplayer 1 That character is already connected to a different account.");
2456  Send_With_Handling(ns, &sl);
2457  SockList_Term(&sl);
2458  return;
2459  } else if (account_is_logged_in(cp)) {
2460  /* We could be clever and try to handle this case, but it is
2461  * trickier. If the character is logged in, it has to
2462  * be logged out. And the socket holds some data which
2463  * needs to be cleaned up. Since it should be fairly
2464  * uncommon that users need to do this, just disallowing
2465  * it makes things a lot simpler.
2466  */
2467  SockList_AddString(&sl, "failure accountaddplayer 0 That character is already connected to a different account which is currently logged in.");
2468  Send_With_Handling(ns, &sl);
2469  SockList_Term(&sl);
2470  return;
2471  }
2472  }
2473  }
2474  /* If we have gotten this far, the name/password provided is OK,
2475  * and the character is not associated with a different account (or
2476  * force is true). Now try to add the character to this account.
2477  */
2479 
2480  /* This should never happen, but check for it just in case -
2481  * if we were able to log in, the account should exist. but
2482  * if this fails, need to give the user some clue.
2483  */
2484  if (status==1) {
2485  SockList_AddString(&sl, "failure accountaddplayer 0 Could not find your account.");
2486  Send_With_Handling(ns, &sl);
2487  SockList_Term(&sl);
2488  return;
2489  } else if (status == 2) {
2490  SockList_AddString(&sl, "failure accountaddplayer 0 You have reached the maximum number of characters allowed per account.");
2491  Send_With_Handling(ns, &sl);
2492  SockList_Term(&sl);
2493  return;
2494  }
2495 
2496  /* If cp is set, then this character used to belong to a different
2497  * account. Remove it now.
2498  */
2499  if (cp) {
2500  Account_Chars *chars;
2501 
2503  chars = account_char_load(cp);
2504  account_char_remove(chars, name);
2505  account_char_save(chars);
2506  account_char_free(chars);
2507  }
2508 
2510 
2511  /* store data so nothing is lost in case of crash */
2513 }
2514 
2519 void account_play_cmd(char *buf, int len, socket_struct *ns)
2520 {
2521  char **chars;
2522  int i;
2523  SockList sl;
2524  player *pl;
2525 
2526  if (len <= 0 || !buf) {
2527  LOG(llevDebug, "IP '%s' sent bogus account_play_cmd information\n", ns->host);
2528  return;
2529  }
2530 
2531  SockList_Init(&sl);
2532 
2533  if (ns->status != Ns_Add) {
2534  SockList_AddString(&sl, "failure accountplay Not allowed right now");
2535  Send_With_Handling(ns, &sl);
2536  SockList_Term(&sl);
2537  return;
2538  }
2539 
2540  if (!buf[0]) {
2541  SockList_AddString(&sl, "failure accountplay Malformed character name");
2542  Send_With_Handling(ns, &sl);
2543  SockList_Term(&sl);
2544  return;
2545  }
2546 
2547  if (ns->account_name == NULL) {
2548  SockList_AddString(&sl, "failure accountplay Not logged in");
2549  Send_With_Handling(ns, &sl);
2550  SockList_Term(&sl);
2551  return;
2552  }
2553 
2554  /* Make sure a client is not trying to spoof us here */
2556 
2557  for (i=0; chars[i]; i++) {
2558  if (strcmp(chars[i], buf) == 0)
2559  break;
2560  }
2561  if (!chars[i]) {
2562  SockList_AddPrintf(&sl,
2563  "failure accountplay Character %s is not associated with account %s",
2564  buf, ns->account_name);
2565  Send_With_Handling(ns, &sl);
2566  SockList_Term(&sl);
2567  return;
2568  }
2569 
2570  for (pl = first_player; pl; pl = pl->next) {
2571  if (pl->ob && pl->socket != ns && strcmp(buf, pl->ob->name) == 0 && pl->state != ST_PLAY_AGAIN && pl->state != ST_GET_NAME) {
2572  SockList_AddPrintf(&sl,
2573  "failure accountplay Character %s is already playing",
2574  buf);
2575  Send_With_Handling(ns, &sl);
2576  SockList_Term(&sl);
2577  return;
2578  }
2579  }
2580 
2581  /* from a protocol standpoint, accountplay can be used
2582  * before there is a player structure (first login) or after
2583  * (character has logged in and is changing characters).
2584  * Checkthe sockets for that second case - if so,
2585  * we don't need to make a new player object, etc.
2586  */
2587  for (pl=first_player; pl; pl=pl->next) {
2588  if (pl->socket == ns) {
2589  /* The player still in the socket must be saved first. */
2590  save_player(pl->ob, 0);
2591  break;
2592  }
2593  }
2594 
2595  /* Some of this logic is from add_player()
2596  * we just don't use add_player() as it does some other work
2597  * we don't really want to do.
2598  */
2599  if (!pl) {
2600  pl = get_player(NULL);
2601  set_player_socket(pl, ns);
2602  ns->status = Ns_Avail;
2603  ns->account_chars = NULL;
2604  SockList_ResetRead(&pl->socket->inbuf);
2605  } else {
2606  pl->state = ST_PLAYING;
2607  }
2608 
2609  pl->ob->name = add_string(buf);
2610  check_login(pl->ob, NULL);
2611 
2612  SockList_AddString(&sl, "addme_success");
2613  Send_With_Handling(ns, &sl);
2614  SockList_Term(&sl);
2615 }
2616 
2617 #define MAX_CHOICES 100
2618 
2624 void create_player_cmd(char *buf, int len, socket_struct *ns)
2625 {
2626  char name[MAX_BUF], password[MAX_BUF], *choices[MAX_CHOICES];
2627  int status, nlen, choice_num=0, i;
2628  SockList sl;
2629  player *pl;
2630  archetype *map=NULL, *race_a=NULL, *class_a=NULL;
2631  living new_stats;
2632 
2633  if (len <= 0 || !buf) {
2634  LOG(llevDebug, "IP '%s' sent bogus create_player_cmd information\n", ns->host);
2635  return;
2636  }
2637 
2638  SockList_Init(&sl);
2639 
2640  if (ns->status != Ns_Add) {
2641  SockList_AddString(&sl, "failure createplayer Not allowed right now");
2642  Send_With_Handling(ns, &sl);
2643  SockList_Term(&sl);
2644  return;
2645  }
2646 
2647  nlen = len;
2648  status = decode_name_password(buf, &nlen, name, password);
2649  if (status == 1) {
2650  SockList_AddString(&sl, "failure createplayer Name is too long");
2651  Send_With_Handling(ns, &sl);
2652  SockList_Term(&sl);
2653  return;
2654  }
2655 
2656  /* Minimum character name limit (if set) */
2657  if (strlen(name)<settings.min_name) {
2658  SockList_AddString(&sl, "failure createplayer Name is too short");
2659  Send_With_Handling(ns, &sl);
2660  SockList_Term(&sl);
2661  return;
2662  }
2663 
2664  if (playername_ok(name) == 0) {
2665  SockList_AddString(&sl, "failure createplayer Player name contains invalid characters");
2666  Send_With_Handling(ns, &sl);
2667  SockList_Term(&sl);
2668  return;
2669  }
2670 
2671  /* 2 characters minimum for password */
2672  if (strlen(password)<2) {
2673  SockList_AddString(&sl, "failure createplayer Password is too short");
2674  Send_With_Handling(ns, &sl);
2675  SockList_Term(&sl);
2676  return;
2677  }
2678 
2680  if (status == 2) {
2681  SockList_AddString(&sl, "failure createplayer Password is too long");
2682  Send_With_Handling(ns, &sl);
2683  SockList_Term(&sl);
2684  return;
2685  }
2686 
2687  /* This is a fairly ugly solution - we're truncating the password.
2688  * however, the password information for characters is really
2689  * a legacy issue - when every character is associated with
2690  * an account, legacy login (character name/password) will get
2691  * removed, at which point the only use for password might be
2692  * to move characters from one account to another, but not sure
2693  * if that is something we want to allow.
2694  */
2695  if (strlen(password)>17)
2696  password[16] = 0;
2697 
2698  /* We just can't call check_name(), since that uses draw_info() to
2699  * report status. We are also more permissive on names, so we use
2700  * account_check_string() - if that is safe for account, also safe
2701  * for player names.
2702  */
2703  if (account_check_string(name)) {
2704  SockList_AddString(&sl, "failure createplayer Choose a different character name. " VALIDCHAR_MSG);
2705  Send_With_Handling(ns, &sl);
2706  SockList_Term(&sl);
2707  return;
2708  }
2709 
2710  /* 1 means no such player, 0 is correct name/password (which in this
2711  * case, is an error), and 2 is incorrect password. Only way we
2712  * go onward is if there is no such player.
2713  */
2714  if (verify_player(name, password) != 1) {
2715  SockList_AddString(&sl, "failure createplayer That name is already in use");
2716  Send_With_Handling(ns, &sl);
2717  SockList_Term(&sl);
2718  return;
2719  }
2720 
2721  /* from a protocol standpoint, accountplay can be used
2722  * before there is a player structure (first login) or after
2723  * (character has logged in and is changing characters).
2724  * Check the sockets for that second case - if so,
2725  * we don't need to make a new player object, etc.
2726  */
2727  for (pl=first_player; pl; pl=pl->next)
2728  if (pl->socket == ns) {
2729  if (pl->ob->name) {
2730  if (!strcmp(pl->ob->name, name)) {
2731  /* For some reason not only the socket is the same but also
2732  * the player is already playing. If this happens at this
2733  * point let's assume the character never was able to apply
2734  * a bet of reality to make a correct first-time save.
2735  * So, for safety remove it and start over.
2736  */
2737  if (!QUERY_FLAG(pl->ob, FLAG_REMOVED))
2738  object_remove(pl->ob);
2739  }
2740  else {
2741  /* If this is a different player on the same socket, then we
2742  * need to make sure that the old one is not connected to the player
2743  *
2744  * This prevents bizarre scenarios where the player is on the map
2745  * multiple times (from multiple createplayer commands), and
2746  * only one of them is controlled by the player.
2747  */
2748  if (pl->ob->contr == pl) {
2749  if (!QUERY_FLAG(pl->ob, FLAG_REMOVED))
2750  object_remove(pl->ob);
2751  }
2752  }
2753  }
2754  break;
2755  }
2756 
2757  /* In this mode, we have additional data
2758  * Note that because there are a lot of failure cases in here
2759  * (where we end up not creating the new player), the code
2760  * to create the new player is done within this routine
2761  * after all checks pass. Note that all of the checks
2762  * done are done without using the player structure,
2763  * as pl may be null right now.
2764  */
2765  if (ns->login_method >= 2) {
2766  int i, j, stat_total=0;
2767  char *key, *value, *race=NULL, *class_name=NULL;
2768 
2769  /* By setting this to zero, then we can easily
2770  * check to see if all stats have been set.
2771  */
2772  memset(&new_stats, 0, sizeof(living));
2773 
2774  while (nlen < len) {
2775  i = buf[nlen]; /* Length of this line */
2776  /* Sanity check from client - don't want to loop
2777  * forever if there is a 0 length, and don't
2778  * want to read beyond size of packet.
2779  * Likewise, client should have sent
2780  * the string to us already null terminated,
2781  * but we will just make sure.
2782  */
2783  if ((i == 0) || (nlen + i > len)) break;
2784  buf[nlen + i] = 0;
2785 
2786  /* What we have are a series of lines -
2787  * 'key value' format. Find that space,
2788  * and null it out so we can do strcasecmp.
2789  * If no space, abort processing
2790  */
2791  key = buf + nlen + 1;
2792  value = strchr(key, ' ');
2793  if (!value) break;
2794  *value = 0;
2795  value++;
2796 
2797  if (!strcasecmp(key,"race")) race = value;
2798  else if (!strcasecmp(key,"class")) class_name = value;
2799  else if (!strcasecmp(key,"starting_map")) {
2801  if (!map || map->clone.type != MAP || map->clone.subtype !=MAP_TYPE_CHOICE) {
2802  SockList_AddString(&sl,
2803  "failure createplayer Invalid starting map");
2804  Send_With_Handling(ns, &sl);
2805  SockList_Term(&sl);
2806  return;
2807  }
2808  }
2809  else if (!strcasecmp(key,"choice")) {
2810  /* In general, MAX_CHOICES should be large enough
2811  * to always handle the choices from the client - of
2812  * course, the client could be broken and send us many
2813  * more choices than we should have, so handle that.
2814  */
2815  if (choice_num == MAX_CHOICES) {
2816  LOG(llevError,
2817  "Number of choices receive exceed max value: %d>%d\n",
2818  choice_num, MAX_CHOICES);
2819  } else {
2820  choices[choice_num] = value;
2821  choice_num++;
2822  }
2823  }
2824  else {
2825  /* Do stat processing here */
2826  for (j=0; j < NUM_STATS; j++) {
2827  if (!strcasecmp(key,short_stat_name[j])) {
2828  int val = atoi(value);
2829 
2830  set_attr_value(&new_stats, j, val);
2831  break;
2832  }
2833  }
2834  if (j >= NUM_STATS) {
2835  /* Bad clients could do this - we should at least report
2836  * it, and useful when trying to add new parameters.
2837  */
2838  LOG(llevError, "Got unknown key/value from client: %s %s\n", key, value);
2839  }
2840  }
2841  nlen += i + 1;
2842  }
2843  /* Do some sanity checking now. But checking the stat
2844  * values here, we will catch any 0 values since we do
2845  * a memset above. A properly behaving client should
2846  * never do any of these things, but we do not presume
2847  * clients will behave properly.
2848  */
2849  for (j=0; j<NUM_STATS; j++) {
2850  int val = get_attr_value(&new_stats, j);
2851 
2852  stat_total += val;
2853  if (val > settings.starting_stat_max ||
2854  val < settings.starting_stat_min) {
2855  SockList_AddPrintf(&sl,
2856  "failure createplayer Stat value is out of range - %d must be between %d and %d",
2858  Send_With_Handling(ns, &sl);
2859  SockList_Term(&sl);
2860  return;
2861  }
2862  }
2863  if (stat_total > settings.starting_stat_points) {
2864  SockList_AddPrintf(&sl,
2865  "failure createplayer Total allocated statistics is higher than allowed (%d>%d)",
2866  stat_total, settings.starting_stat_points);
2867  Send_With_Handling(ns, &sl);
2868  SockList_Term(&sl);
2869  return;
2870  }
2871 
2872  if (race)
2873  race_a = try_find_archetype(race);
2874 
2875  if (class_name)
2876  class_a = try_find_archetype(class_name);
2877 
2878  /* This should never happen with a properly behaving client, so the error message
2879  * doesn't have to be that great.
2880  */
2881  if (!race_a || race_a->clone.type != PLAYER || !class_a || class_a->clone.type != CLASS) {
2882  SockList_AddString(&sl,
2883  "failure createplayer Invalid or unknown race or class");
2884  Send_With_Handling(ns, &sl);
2885  SockList_Term(&sl);
2886  return;
2887  }
2888 
2889  /* At current time, only way this can fail is if the adjusted
2890  * stat is less than 1.
2891  */
2892  if (check_race_and_class(&new_stats, race_a, class_a)) {
2893  SockList_AddString(&sl,
2894  "failure createplayer Unable to apply race or class - statistic is out of bounds");
2895  Send_With_Handling(ns, &sl);
2896  SockList_Term(&sl);
2897  return;
2898  }
2899 
2900  if (!pl)
2902  // If we already have a player, we a replaying on the same connection.
2903  // Since add_player normally sets ns->status, we still need that to happen.
2904  else
2905  ns->status = Ns_Avail;
2906 
2907  // We need to copy the name in before apply_race_and_class() because it
2908  // tells the client our character name. If we don't update it, they get the old one.
2909  FREE_AND_COPY(pl->ob->name, name);
2910 
2911  apply_race_and_class(pl->ob, race_a, class_a, &new_stats);
2912 
2913  } else {
2914  /* In thise case, old login method */
2915  if (!pl)
2916  pl = add_player(ns, ADD_PLAYER_NEW);
2917  // If we already have a player, we a replaying on the same connection.
2918  // Since add_player normally sets ns->status, we still need that to happen.
2919  else
2920  ns->status = Ns_Avail;
2921 
2922  // Make sure to do this on both code branches.
2923  FREE_AND_COPY(pl->ob->name, name);
2924 /* already done by add_player
2925  roll_again(pl->ob);
2926  pl->state = ST_ROLL_STAT;
2927  set_first_map(pl->ob);*/
2928  }
2929 
2930  /* add_player does a lot of the work, but there are a few
2931  * things we need to update, like starting name and
2932  * password.
2933  * This is done before processing in login_method>2.
2934  * The character creation process it does when
2935  * applying the race/class will use this
2936  * name information.
2937  */
2938  FREE_AND_COPY(pl->ob->name_pl, name);
2939  pl->name_changed = 1;
2940  safe_strncpy(pl->password, newhash(password), sizeof(pl->password));
2941 
2942  SockList_AddString(&sl, "addme_success");
2943  Send_With_Handling(ns, &sl);
2944  SockList_Term(&sl);
2945 
2946  if (ns->login_method >= 2) {
2947  /* The client could have provided us a map - if so, map will be set
2948  * and we don't want to overwrite it
2949  */
2950  if (!map)
2952  assert(map); // Existence checked in init_dynamic()
2953 
2954  enter_exit(pl->ob, &map->clone);
2955 
2956  if (pl->ob->map == NULL) {
2957  LOG(llevError, "Couldn't put player %s on start map %s!", pl->ob->name, map->name);
2958  abort();
2959  }
2960 
2961  /* copy information to bed of reality information, in case the player dies */
2962  safe_strncpy(pl->savebed_map, pl->ob->map->path, sizeof(pl->savebed_map));
2963  pl->bed_x = pl->ob->x;
2964  pl->bed_y = pl->ob->y;
2965 
2967  }
2968 
2969  /* We insert any objects after we have put the player on the map -
2970  * this makes things safer, as certain objects may expect a normal
2971  * environment. Note that choice_num will only be set in the
2972  * loginmethod > 2, which also checks (and errors out) if the
2973  * race/class is not set, which is why explicit checking for
2974  * those is not need.
2975  */
2976  for (i=0; i < choice_num; i++) {
2977  char *choiceval;
2978  const char *value, *cp;
2979  archetype *arch;
2980  object *op;
2981 
2982  choiceval = strchr(choices[i], ' ');
2983  if (!choiceval) {
2984  LOG(llevError, "Choice does not specify value: %s\n", choices[i]);
2985  continue;
2986  }
2987  *choiceval=0;
2988  choiceval++;
2989  value = object_get_value(&race_a->clone, choices[i]);
2990  if (!value)
2991  value = object_get_value(&class_a->clone, choices[i]);
2992 
2993  if (!value) {
2994  LOG(llevError, "Choice not found in archetype: %s\n", choices[i]);
2995  continue;
2996  }
2997  cp = strstr(value, choiceval);
2998  if (!cp) {
2999  LOG(llevError, "Choice value not found in archetype: %s %s\n",
3000  choices[i], choiceval);
3001  continue;
3002  }
3003 
3004  /* Check to make sure that the matched string is an entire word,
3005  * and not a substring (eg, valid choice being great_sword but
3006  * we just get sword) - the space after the match should either be a
3007  * space or null, and space before match should also be a space
3008  * or the start of the string.
3009  */
3010  if ((cp[strlen(choiceval)] != ' ') && (cp[strlen(choiceval)] != 0) &&
3011  (cp != value) && (*(cp-1) != ' ')) {
3012 
3013  LOG(llevError, "Choice value matches substring but not entire word: %s substring %s\n",
3014  choiceval, value);
3015  continue;
3016  }
3017  arch = try_find_archetype(choiceval);
3018  if (!arch) {
3019  LOG(llevError, "Choice value can not find archetype %s\n", choiceval);
3020  continue;
3021  }
3022  op = arch_to_object(arch);
3023  op = object_insert_in_ob(op, pl->ob);
3025  ob_apply(op, pl->ob, 0);
3026  }
3027 
3028  LOG(llevInfo, "new character %s from %s\n", pl->ob->name, pl->ob->contr->socket->host);
3031  "%s has entered the game.", pl->ob->name);
3032 }
3033 
3044 void account_password(char *buf, int len, socket_struct *ns) {
3045  char old[MAX_BUF], change[MAX_BUF];
3046  int status;
3047  SockList sl;
3048 
3049  if (len <= 0 || !buf) {
3050  LOG(llevDebug, "IP '%s' sent bogus account_password_cmd information\n", ns->host);
3051  return;
3052  }
3053 
3054  SockList_Init(&sl);
3055 
3056  if (ns->account_name == NULL) {
3057  SockList_AddString(&sl, "failure accountpw Not logged in");
3058  Send_With_Handling(ns, &sl);
3059  SockList_Term(&sl);
3060  return;
3061  }
3062 
3063  status = decode_name_password(buf, &len, old, change);
3064  if (status == 1) {
3065  SockList_AddString(&sl, "failure accountpw Old password is too long");
3066  Send_With_Handling(ns, &sl);
3067  SockList_Term(&sl);
3068  return;
3069  }
3070  if (status == 2) {
3071  SockList_AddString(&sl, "failure accountpw New password is too long");
3072  Send_With_Handling(ns, &sl);
3073  SockList_Term(&sl);
3074  return;
3075  }
3076  /*The minimum length isn't exactly required, but in the current implementation,
3077  * client will send the same password for character for which there is a
3078  * 2 character minimum size. Thus an account with a one character password
3079  * won't be able to create a character. */
3080  if (strlen(change)<2) {
3081  SockList_AddString(&sl, "failure accountpw New password is too short");
3082  Send_With_Handling(ns, &sl);
3083  SockList_Term(&sl);
3084  return;
3085  }
3086 
3087  status = account_check_string(change);
3088  if (status == 1) {
3089  SockList_AddString(&sl,
3090  "failure accountpw Choose a different password. " VALIDCHAR_MSG);
3091  Send_With_Handling(ns, &sl);
3092  SockList_Term(&sl);
3093  return;
3094  }
3095 
3096  if (status == 2) {
3097  SockList_AddString(&sl,
3098  "failure accountpw That password is too long");
3099  Send_With_Handling(ns, &sl);
3100  SockList_Term(&sl);
3101  return;
3102  }
3103 
3104  status = account_change_password(ns->account_name, old, change);
3105  if (status != 0) {
3106  const char *error;
3107 
3108  if (status == 1) {
3109  error = "failure accountpw Illegal characters present";
3110  } else if (status == 2) {
3111  error = "failure accountpw Invalid account";
3112  } else {
3113  error = "failure accountpw Incorrect current password";
3114  }
3115 
3116  SockList_AddString(&sl, error);
3117  Send_With_Handling(ns, &sl);
3118  SockList_Term(&sl);
3119  return;
3120  }
3121 
3122  /* If we got here, we passed all checks, and password was changed */
3124 }
find_player_socket
player * find_player_socket(const socket_struct *ns)
Definition: player.cpp:123
ADD_PLAYER_NO_STATS_ROLL
#define ADD_PLAYER_NO_STATS_ROLL
Definition: player.h:247
SF_FIREON
#define SF_FIREON
Definition: newclient.h:178
CF_BLIND
#define CF_BLIND
Definition: newclient.h:189
Face::name
sstring name
Definition: face.h:19
account_add_player_cmd
void account_add_player_cmd(char *buf, int len, socket_struct *ns)
Definition: request.cpp:2390
CLASS
@ CLASS
Definition: object.h:143
CS_STAT_RES_DEPLETE
#define CS_STAT_RES_DEPLETE
Definition: newclient.h:151
Face
Definition: face.h:14
MAP_CLIENT_X
#define MAP_CLIENT_X
Definition: config.h:237
CF_STEALTHY
#define CF_STEALTHY
Definition: newclient.h:194
socket_struct::tick
uint32_t tick
Definition: newserver.h:106
atnr_cs_stat
static const short atnr_cs_stat[NROFATTACKS]
Definition: request.cpp:123
PLAYER
@ PLAYER
Definition: object.h:112
MAP_CLIENT_X_MINIMUM
#define MAP_CLIENT_X_MINIMUM
Definition: config.h:245
SockList_AddInt
void SockList_AddInt(SockList *sl, uint32_t data)
Definition: lowlevel.cpp:127
global.h
ANIM_SYNC
#define ANIM_SYNC
Definition: newclient.h:337
NS_FACESENT_FACE
#define NS_FACESENT_FACE
Definition: newserver.h:137
socket_struct::sc_version
uint32_t sc_version
Definition: newserver.h:113
first_player
player * first_player
Definition: init.cpp:106
ST_CHANGE_PASSWORD_OLD
#define ST_CHANGE_PASSWORD_OLD
Definition: define.h:550
settings
struct Settings settings
Definition: init.cpp:139
CS_STAT_RACE_CON
#define CS_STAT_RACE_CON
Definition: newclient.h:110
print_ext_msg
void print_ext_msg(socket_struct *ns, int color, uint8_t type, uint8_t subtype, const char *message)
Definition: info.cpp:62
banquet.l
l
Definition: banquet.py:164
CS_STAT_GRACE
#define CS_STAT_GRACE
Definition: newclient.h:98
safe_strncpy
#define safe_strncpy
Definition: compat.h:27
find_smooth
int find_smooth(const Face *face, const Face **smoothed)
Definition: image.cpp:102
annotate_ob
static int annotate_ob(int ax, int ay, const object *ob, SockList *sl, socket_struct *ns, int *has_obj, int *alive_layer)
Definition: request.cpp:1358
MAP
@ MAP
Definition: object.h:130
living::maxhp
int16_t maxhp
Definition: living.h:41
socket_struct::heartbeat
bool heartbeat
Definition: newserver.h:112
SockList_AddInt64
void SockList_AddInt64(SockList *sl, uint64_t data)
Definition: lowlevel.cpp:140
ST_GET_PASSWORD
#define ST_GET_PASSWORD
Definition: define.h:547
ACL_FACE_NUM
#define ACL_FACE_NUM
Definition: newclient.h:213
FLAG_CONFUSED
#define FLAG_CONFUSED
Definition: define.h:311
CAN_PROBE
static bool CAN_PROBE(const object *ob)
Definition: object.h:616
llevError
@ llevError
Definition: logger.h:11
FABS
#define FABS(x)
Definition: define.h:22
FLAG_CLIENT_ANIM_RANDOM
#define FLAG_CLIENT_ANIM_RANDOM
Definition: define.h:241
send_account_players
void send_account_players(socket_struct *ns)
Definition: request.cpp:2050
object::path_attuned
uint32_t path_attuned
Definition: object.h:353
CS_STAT_APPLIED_WIS
#define CS_STAT_APPLIED_WIS
Definition: newclient.h:122
MAP2_COORD_MAX
static const int MAP2_COORD_MAX
Definition: request.cpp:74
ssop_t
int ssop_t
Definition: request.cpp:58
MSG_TYPE_ADMIN_PLAYER
#define MSG_TYPE_ADMIN_PLAYER
Definition: newclient.h:485
LOG
void LOG(LogLevel logLevel, const char *format,...)
Definition: logger.cpp:58
send_query
void send_query(socket_struct *ns, uint8_t flags, const char *text)
Definition: request.cpp:752
Map
Definition: newserver.h:48
account_play_cmd
void account_play_cmd(char *buf, int len, socket_struct *ns)
Definition: request.cpp:2519
SET_FLAG
#define SET_FLAG(xyz, p)
Definition: define.h:224
new_player_cmd
void new_player_cmd(uint8_t *buf, int len, player *pl)
Definition: request.cpp:527
client_spell
Definition: player.h:87
CS_STAT_RES_FEAR
#define CS_STAT_RES_FEAR
Definition: newclient.h:150
MAP2_COORD_OFFSET
#define MAP2_COORD_OFFSET
Definition: newclient.h:32
player
Definition: player.h:105
CS_STAT_DAM
#define CS_STAT_DAM
Definition: newclient.h:90
strdup_local
#define strdup_local
Definition: compat.h:29
ACL_RACE
#define ACL_RACE
Definition: newclient.h:208
diamondslots.x
x
Definition: diamondslots.py:15
FLAG_STARTEQUIP
#define FLAG_STARTEQUIP
Definition: define.h:268
CS_STAT_RES_FIRE
#define CS_STAT_RES_FIRE
Definition: newclient.h:139
ask_smooth_cmd
void ask_smooth_cmd(char *buf, int len, socket_struct *ns)
Definition: request.cpp:503
QUERY_FLAG
#define QUERY_FLAG(xyz, p)
Definition: define.h:226
newhash
char const * newhash(char const *password)
Definition: server.cpp:101
archininventory.arch
arch
DIALOGCHECK MINARGS 1 MAXARGS 1
Definition: archininventory.py:16
socket_struct::sound
uint32_t sound
Definition: newserver.h:111
account_get_additional_chars
linked_char * account_get_additional_chars(const char *account_name, const Account_Chars *chars, int *count)
Definition: account.cpp:551
CS_STAT_APPLIED_POW
#define CS_STAT_APPLIED_POW
Definition: newclient.h:126
CS_STAT_HP
#define CS_STAT_HP
Definition: newclient.h:76
socket_struct
Definition: newserver.h:89
socket_struct::mapx
uint8_t mapx
Definition: newserver.h:116
get_skill_client_code
int get_skill_client_code(const char *skill_name)
Definition: skill_util.cpp:116
ST_GET_NAME
#define ST_GET_NAME
Definition: define.h:546
map2_delete_layer
static int map2_delete_layer(int ax, int ay, int layer, SockList *sl, socket_struct *ns)
Definition: request.cpp:1265
update_position
void update_position(mapstruct *m, int x, int y)
Definition: map.cpp:2110
MAX_NUM_LOOK_OBJECTS
#define MAX_NUM_LOOK_OBJECTS
Definition: newserver.h:28
MAP2_COORD_MIN
static const int MAP2_COORD_MIN
Definition: request.cpp:73
socket_struct::num_look_objects
uint8_t num_look_objects
Definition: newserver.h:122
object::arch
struct archetype * arch
Definition: object.h:424
command_execute
void command_execute(object *pl, char *command)
Definition: commands.cpp:455
AddIfInt64
#define AddIfInt64(Old, New, sl, Type)
Definition: request.cpp:761
SockList_AddString
void SockList_AddString(SockList *sl, const char *data)
Definition: lowlevel.cpp:157
ring_occidental_mages.rest
rest
Definition: ring_occidental_mages.py:16
MAX_TIME
#define MAX_TIME
Definition: config.h:254
CS_STAT_SPELL_DENY
#define CS_STAT_SPELL_DENY
Definition: newclient.h:105
account_get_players_for_account
char ** account_get_players_for_account(const char *account_name)
Definition: account.cpp:520
accounts_save
void accounts_save(void)
Definition: account.cpp:256
CS_STAT_WIS
#define CS_STAT_WIS
Definition: newclient.h:82
reply_cmd
void reply_cmd(char *buf, int len, player *pl)
Definition: request.cpp:595
CS_STAT_SPEED
#define CS_STAT_SPEED
Definition: newclient.h:92
socket_struct::extended_stats
uint32_t extended_stats
Definition: newserver.h:109
CS_STAT_INT
#define CS_STAT_INT
Definition: newclient.h:81
append_spell
static void append_spell(player *pl, SockList *sl, object *spell)
Definition: request.cpp:1857
guildjoin.ob
ob
Definition: guildjoin.py:42
Settings::min_name
uint8_t min_name
Definition: global.h:331
SK_PRAYING
@ SK_PRAYING
Definition: skills.h:49
CS_STAT_MAXSP
#define CS_STAT_MAXSP
Definition: newclient.h:79
draw_ext_info_format
void draw_ext_info_format(int flags, int pri, const object *pl, uint8_t type, uint8_t subtype, const char *format,...) PRINTF_ARGS(6
MIN
#define MIN(x, y)
Definition: compat.h:21
CS_STAT_BASE_DEX
#define CS_STAT_BASE_DEX
Definition: newclient.h:116
CS_STAT_RES_MAG
#define CS_STAT_RES_MAG
Definition: newclient.h:138
FIF
#define FIF(F, C)
MAP_LAYERS
#define MAP_LAYERS
Definition: map.h:32
Settings::starting_stat_min
uint8_t starting_stat_min
Definition: global.h:320
SKILL
@ SKILL
Definition: object.h:148
client_spell::last_sp
int16_t last_sp
Definition: player.h:89
socket_struct::is_bot
uint32_t is_bot
Definition: newserver.h:107
get_player
player * get_player(player *p)
Definition: player.cpp:285
send_extra_stats
static void send_extra_stats(SockList *sl, player *pl)
Definition: request.cpp:817
object::count
tag_t count
Definition: object.h:307
flags
static const flag_definition flags[]
Definition: gridarta-types-convert.cpp:101
CS_STAT_SP
#define CS_STAT_SP
Definition: newclient.h:78
SP_CREATE_FOOD
#define SP_CREATE_FOOD
Definition: spells.h:96
ACL_NAME
#define ACL_NAME
Definition: newclient.h:206
CS_STAT_RES_HOLYWORD
#define CS_STAT_RES_HOLYWORD
Definition: newclient.h:153
Ice.tmp
int tmp
Definition: Ice.py:207
CS_STAT_GOLEM_HP
#define CS_STAT_GOLEM_HP
Definition: newclient.h:127
CS_STAT_RES_CONF
#define CS_STAT_RES_CONF
Definition: newclient.h:142
NDI_RED
#define NDI_RED
Definition: newclient.h:234
MAX_HEAD_OFFSET
#define MAX_HEAD_OFFSET
Definition: newserver.h:42
account_link
int account_link(const char *account_name, const char *player_name)
Definition: account.cpp:445
ATNR_PHYSICAL
#define ATNR_PHYSICAL
Definition: attack.h:49
CS_STAT_TURN_UNDEAD
#define CS_STAT_TURN_UNDEAD
Definition: newclient.h:149
ACL_CLASS
#define ACL_CLASS
Definition: newclient.h:207
SP_CREATE_MISSILE
#define SP_CREATE_MISSILE
Definition: spells.h:113
CF_NOT_PERFECT
#define CF_NOT_PERFECT
Definition: newclient.h:192
NROFATTACKS
#define NROFATTACKS
Definition: attack.h:17
receive_play_again
void receive_play_again(object *op, char key)
Definition: player.cpp:956
set_player_socket
void set_player_socket(player *p, socket_struct *ns)
Definition: player.cpp:413
MSG_TYPE_COMMAND_ERROR
#define MSG_TYPE_COMMAND_ERROR
Definition: newclient.h:518
map_clearcell
static void map_clearcell(struct map_cell_struct *cell, int face, int darkness)
Definition: request.cpp:1079
CS_STAT_EXP64
#define CS_STAT_EXP64
Definition: newclient.h:102
map2_coord_valid
static bool map2_coord_valid(int x)
Definition: request.cpp:76
FLAG_PROBE
#define FLAG_PROBE
Definition: define.h:257
range_golem
@ range_golem
Definition: player.h:34
send_plugin_custom_message
void send_plugin_custom_message(object *pl, char *buf)
Definition: request.cpp:1724
SockList_Reset
void SockList_Reset(SockList *sl)
Definition: lowlevel.cpp:74
CS_STAT_CHARACTER_FLAGS
#define CS_STAT_CHARACTER_FLAGS
Definition: newclient.h:129
socket_struct::map_scroll_x
int8_t map_scroll_x
Definition: newserver.h:94
object_get_value
const char * object_get_value(const object *op, const char *const key)
Definition: object.cpp:4342
set_up_cmd
void set_up_cmd(char *buf, int len, socket_struct *ns)
Definition: request.cpp:143
UPD_SP_MANA
#define UPD_SP_MANA
Definition: newclient.h:313
object::level
int16_t level
Definition: object.h:361
FLAG_STEALTH
#define FLAG_STEALTH
Definition: define.h:312
heads
static const object * heads[MAX_HEAD_POS][MAX_HEAD_POS][MAP_LAYERS]
Definition: request.cpp:1093
pticks
uint32_t pticks
Definition: time.cpp:47
buf
StringBuffer * buf
Definition: readable.cpp:1565
key_confirm_quit
void key_confirm_quit(object *op, char key)
Definition: player.cpp:1592
CS_STAT_APPLIED_DEX
#define CS_STAT_APPLIED_DEX
Definition: newclient.h:123
add_player
player * add_player(socket_struct *ns, int flags)
Definition: player.cpp:460
object_insert_in_ob
object * object_insert_in_ob(object *op, object *where)
Definition: object.cpp:2853
POISONING
@ POISONING
Definition: object.h:223
MSG_TYPE_COMMAND
#define MSG_TYPE_COMMAND
Definition: newclient.h:393
MAX
#define MAX(x, y)
Definition: compat.h:24
CS_STAT_RACE_STR
#define CS_STAT_RACE_STR
Definition: newclient.h:106
CS_STAT_GOLEM_MAXHP
#define CS_STAT_GOLEM_MAXHP
Definition: newclient.h:128
SND_EFFECTS
#define SND_EFFECTS
Definition: sounds.h:12
ACL_MAP
#define ACL_MAP
Definition: newclient.h:212
linked_char
Definition: global.h:96
Account_Chars::chars
std::vector< Account_Char * > chars
Definition: account_char.h:30
FLAG_ALIVE
#define FLAG_ALIVE
Definition: define.h:230
socket_struct::update_look
uint32_t update_look
Definition: newserver.h:104
SockList_Avail
size_t SockList_Avail(const SockList *sl)
Definition: lowlevel.cpp:246
GetShort_String
short GetShort_String(const unsigned char *data)
Definition: lowlevel.cpp:258
short_stat_name
const char *const short_stat_name[NUM_STATS]
Definition: living.cpp:194
SP_SUMMON_MONSTER
#define SP_SUMMON_MONSTER
Definition: spells.h:101
UPD_SP_DAMAGE
#define UPD_SP_DAMAGE
Definition: newclient.h:315
m
static event_registration m
Definition: citylife.cpp:425
AddIfShort
#define AddIfShort(Old, New, sl, Type)
Definition: request.cpp:775
socket_struct::account_chars
Account_Chars * account_chars
Definition: newserver.h:127
esrv_send_animation
void esrv_send_animation(socket_struct *ns, const Animations *anim)
Definition: request.cpp:1045
VALIDCHAR_MSG
#define VALIDCHAR_MSG
Definition: request.cpp:71
socket_struct::mapy
uint8_t mapy
Definition: newserver.h:116
MAP_IN_MEMORY
#define MAP_IN_MEMORY
Definition: map.h:126
Ns_Avail
@ Ns_Avail
Definition: newserver.h:65
CS_STAT_RACE_DEX
#define CS_STAT_RACE_DEX
Definition: newclient.h:109
CS_STAT_ARMOUR
#define CS_STAT_ARMOUR
Definition: newclient.h:91
positioning_system.coord
coord
Definition: positioning_system.py:26
item.q
q
Definition: item.py:32
set_title
void set_title(const object *pl, char *buf, size_t len)
Definition: info.cpp:334
clamp
static int clamp(int x, int min, int max)
Definition: request.cpp:96
map_cell_struct
Definition: newserver.h:31
MAP_CLIENT_Y
#define MAP_CLIENT_Y
Definition: config.h:238
CS_STAT_SPELL_REPEL
#define CS_STAT_SPELL_REPEL
Definition: newclient.h:104
disinfect.map
map
Definition: disinfect.py:4
CS_STAT_RACE_CHA
#define CS_STAT_RACE_CHA
Definition: newclient.h:111
P_NEW_MAP
#define P_NEW_MAP
Definition: map.h:248
CS_STAT_LEVEL
#define CS_STAT_LEVEL
Definition: newclient.h:87
CS_STAT_CON
#define CS_STAT_CON
Definition: newclient.h:84
account_new_cmd
void account_new_cmd(char *buf, int len, socket_struct *ns)
Definition: request.cpp:2276
account_login_cmd
void account_login_cmd(char *buf, int len, socket_struct *ns)
Definition: request.cpp:2177
playername_ok
int playername_ok(const char *cp)
Definition: player.cpp:257
esrv_send_face
void esrv_send_face(socket_struct *ns, const Face *face, int nocache)
Definition: image.cpp:72
client_spell::last_dam
int16_t last_dam
Definition: player.h:91
ACL_PARTY
#define ACL_PARTY
Definition: newclient.h:211
CS_STAT_CHA
#define CS_STAT_CHA
Definition: newclient.h:85
CS_STAT_APPLIED_CHA
#define CS_STAT_APPLIED_CHA
Definition: newclient.h:125
ST_CHANGE_PASSWORD_CONFIRM
#define ST_CHANGE_PASSWORD_CONFIRM
Definition: define.h:552
CS_STAT_RES_SLOW
#define CS_STAT_RES_SLOW
Definition: newclient.h:147
socket_struct::facecache
uint32_t facecache
Definition: newserver.h:102
check_race_and_class
int check_race_and_class(living *stats, archetype *race, archetype *opclass)
Definition: player.cpp:1429
player::blocked_los
int8_t blocked_los[MAP_CLIENT_X][MAP_CLIENT_Y]
Definition: player.h:178
check_login
void check_login(object *op, const char *password)
Definition: login.cpp:511
CS_STAT_BASE_POW
#define CS_STAT_BASE_POW
Definition: newclient.h:119
account_get_account_for_char
const char * account_get_account_for_char(const char *charname)
Definition: account.cpp:580
CS_STAT_RES_PHYS
#define CS_STAT_RES_PHYS
Definition: newclient.h:137
Settings::account_block_create
uint8_t account_block_create
Definition: global.h:328
ST_PLAY_AGAIN
#define ST_PLAY_AGAIN
Definition: define.h:542
CS_STAT_GOD_NAME
#define CS_STAT_GOD_NAME
Definition: newclient.h:130
Face::number
uint16_t number
Definition: face.h:15
ADD_PLAYER_NO_MAP
#define ADD_PLAYER_NO_MAP
Definition: player.h:246
map_cell_struct::darkness
int darkness
Definition: newserver.h:33
account_char_free
void account_char_free(Account_Chars *chars)
Definition: account_char.cpp:345
archetype::clone
object clone
Definition: object.h:487
send_smooth
static void send_smooth(socket_struct *ns, const Face *face)
Definition: request.cpp:459
handle_scroll
static void handle_scroll(socket_struct *socket, SockList *sl)
Definition: request.cpp:104
add_string
sstring add_string(const char *str)
Definition: shstr.cpp:124
draw_client_map
void draw_client_map(object *pl)
Definition: request.cpp:1625
account_remove_player
int account_remove_player(const char *account_name, const char *player_name)
Definition: account.cpp:475
HEAD
#define HEAD(op)
Definition: object.h:607
MAX_HEAD_POS
#define MAX_HEAD_POS
Definition: request.cpp:1084
SockList_AddShort
void SockList_AddShort(SockList *sl, uint16_t data)
Definition: lowlevel.cpp:116
object::casting_time
int16_t casting_time
Definition: object.h:414
ANIM_RANDOM
#define ANIM_RANDOM
Definition: newclient.h:336
CS_STAT_BASE_CHA
#define CS_STAT_BASE_CHA
Definition: newclient.h:118
object_find_by_type_and_name
object * object_find_by_type_and_name(const object *who, int type, const char *name)
Definition: object.cpp:4104
SockList_AddChar
void SockList_AddChar(SockList *sl, unsigned char c)
Definition: lowlevel.cpp:106
set_attr_value
void set_attr_value(living *stats, int attr, int8_t value)
Definition: living.cpp:218
FLAG_FREED
#define FLAG_FREED
Definition: define.h:233
socket_struct::lastmap
struct Map lastmap
Definition: newserver.h:93
CF_POISONED
#define CF_POISONED
Definition: newclient.h:188
MAP2_LAYER_START
#define MAP2_LAYER_START
Definition: newclient.h:53
SPELL_GRACE
#define SPELL_GRACE
Definition: spells.h:59
object::face
const Face * face
Definition: object.h:341
CS_STAT_APPLIED_STR
#define CS_STAT_APPLIED_STR
Definition: newclient.h:120
socket_struct::host
char * host
Definition: newserver.h:100
CS_STAT_RACE_POW
#define CS_STAT_RACE_POW
Definition: newclient.h:112
account_password
void account_password(char *buf, int len, socket_struct *ns)
Definition: request.cpp:3044
esrv_map_scroll
void esrv_map_scroll(socket_struct *ns, int dx, int dy)
Definition: request.cpp:1686
GET_MAP_FACE_OBJ
#define GET_MAP_FACE_OBJ(M, X, Y, L)
Definition: map.h:182
socket_struct::account_name
char * account_name
Definition: newserver.h:126
CS_STAT_AC
#define CS_STAT_AC
Definition: newclient.h:89
FREE_AND_COPY
#define FREE_AND_COPY(sv, nv)
Definition: global.h:204
client_spell::last_grace
int16_t last_grace
Definition: player.h:90
check_space_for_heads
static void check_space_for_heads(int ax, int ay, SockList *sl, socket_struct *ns)
Definition: request.cpp:1387
CS_STAT_OVERLOAD
#define CS_STAT_OVERLOAD
Definition: newclient.h:131
object::type
uint8_t type
Definition: object.h:348
living::dam
int16_t dam
Definition: living.h:46
CS_STAT_WEAP_SP
#define CS_STAT_WEAP_SP
Definition: newclient.h:94
socket_struct::monitor_spells
uint32_t monitor_spells
Definition: newserver.h:110
FLAG_PARALYZED
#define FLAG_PARALYZED
Definition: define.h:371
CS_STAT_APPLIED_CON
#define CS_STAT_APPLIED_CON
Definition: newclient.h:124
MAP_LAYER_LIVING1
#define MAP_LAYER_LIVING1
Definition: map.h:46
navar-midane_time.data
data
Definition: navar-midane_time.py:11
esrv_update_spells
void esrv_update_spells(player *pl)
Definition: request.cpp:1738
skill_names
const char * skill_names[MAX_SKILLS]
Definition: skill_util.cpp:59
map_cell_struct::faces
uint16_t faces[MAP_LAYERS]
Definition: newserver.h:32
socket_struct::faceset
uint8_t faceset
Definition: newserver.h:117
CS_STAT_RES_GHOSTHIT
#define CS_STAT_RES_GHOSTHIT
Definition: newclient.h:145
linked_char::next
struct linked_char * next
Definition: global.h:98
CS_STAT_SKILLINFO
#define CS_STAT_SKILLINFO
Definition: newclient.h:161
FOR_INV_FINISH
#define FOR_INV_FINISH()
Definition: define.h:677
account_new
int account_new(const char *account_name, const char *account_password)
Definition: account.cpp:400
ST_CHANGE_PASSWORD_NEW
#define ST_CHANGE_PASSWORD_NEW
Definition: define.h:551
CS_STAT_RES_BLIND
#define CS_STAT_RES_BLIND
Definition: newclient.h:154
FLAG_UNAGGRESSIVE
#define FLAG_UNAGGRESSIVE
Definition: define.h:272
say.max
dictionary max
Definition: say.py:148
CF_DISEASED
#define CF_DISEASED
Definition: newclient.h:191
MAP2_TYPE_DARKNESS
#define MAP2_TYPE_DARKNESS
Definition: newclient.h:43
socket_struct::map_scroll_y
int8_t map_scroll_y
Definition: newserver.h:94
MAP2_COORD_ENCODE
static uint16_t MAP2_COORD_ENCODE(int x, int y, int flags)
Definition: request.cpp:89
archetype
Definition: object.h:483
sproto.h
CS_STAT_RACE_INT
#define CS_STAT_RACE_INT
Definition: newclient.h:107
SND_MUTE
#define SND_MUTE
Definition: sounds.h:14
MAX_SKILLS
#define MAX_SKILLS
Definition: skills.h:70
get_map_from_coord
mapstruct * get_map_from_coord(mapstruct *m, int16_t *x, int16_t *y)
Definition: map.cpp:2362
VERSION_SC
#define VERSION_SC
Definition: newserver.h:150
animate.anim
string anim
Definition: animate.py:20
get_face_by_id
const Face * get_face_by_id(uint16_t id)
Definition: assets.cpp:315
devourers.command
command
Definition: devourers.py:16
SP_level_spellpoint_cost
int16_t SP_level_spellpoint_cost(object *caster, object *spell, int flags)
Definition: spell_util.cpp:236
account_is_logged_in
int account_is_logged_in(const char *name)
Definition: account.cpp:605
MAP_TYPE_CHOICE
#define MAP_TYPE_CHOICE
Definition: map.h:59
SockList_Init
void SockList_Init(SockList *sl)
Definition: lowlevel.cpp:55
nlohmann::detail::void
j template void())
Definition: json.hpp:4099
SockList::len
size_t len
Definition: newclient.h:675
CS_STAT_BASE_WIS
#define CS_STAT_BASE_WIS
Definition: newclient.h:115
is_perfect
static uint8_t is_perfect(const player *pl)
Definition: request.cpp:802
CS_STAT_FOOD
#define CS_STAT_FOOD
Definition: newclient.h:93
socket_struct::cs_version
uint32_t cs_version
Definition: newserver.h:113
object::other_arch
struct archetype * other_arch
Definition: object.h:425
living
Definition: living.h:35
guild_entry.text
text
Definition: guild_entry.py:40
P_OUT_OF_MAP
#define P_OUT_OF_MAP
Definition: map.h:247
CS_STAT_WEIGHT_LIM
#define CS_STAT_WEIGHT_LIM
Definition: newclient.h:101
MAX_BUF
#define MAX_BUF
Definition: define.h:35
Ns_Add
@ Ns_Add
Definition: newserver.h:66
CS_STAT_ITEM_POWER
#define CS_STAT_ITEM_POWER
Definition: newclient.h:132
CS_STAT_RES_POISON
#define CS_STAT_RES_POISON
Definition: newclient.h:146
receive_player_name
void receive_player_name(object *op, const char *name)
Definition: c_misc.cpp:1935
is_valid_faceset
int is_valid_faceset(int fsn)
Definition: image.cpp:117
CS_STAT_WC
#define CS_STAT_WC
Definition: newclient.h:88
ADD_PLAYER_NEW
#define ADD_PLAYER_NEW
Definition: player.h:245
object_present_in_ob
object * object_present_in_ob(uint8_t type, const object *op)
Definition: object.cpp:3164
get_weight_limit
uint32_t get_weight_limit(int stat)
Definition: living.cpp:2362
SockList_Term
void SockList_Term(SockList *sl)
Definition: lowlevel.cpp:65
AddIfInt
#define AddIfInt(Old, New, sl, Type)
Definition: request.cpp:768
probe
int probe(object *op, object *caster, object *spell_ob, int dir, int level)
Definition: spell_effect.cpp:699
FLAG_CLIENT_SENT
#define FLAG_CLIENT_SENT
Definition: define.h:346
CS_STAT_MAXGRACE
#define CS_STAT_MAXGRACE
Definition: newclient.h:99
key_roll_stat
void key_roll_stat(object *op, char key)
Definition: player.cpp:1213
MAP2_TYPE_CLEAR
#define MAP2_TYPE_CLEAR
Definition: newclient.h:42
FLAG_CLIENT_ANIM_SYNC
#define FLAG_CLIENT_ANIM_SYNC
Definition: define.h:240
Settings::starting_stat_points
uint8_t starting_stat_points
Definition: global.h:322
ST_PLAYING
#define ST_PLAYING
Definition: define.h:541
Settings
Definition: global.h:240
create_player_cmd
void create_player_cmd(char *buf, int len, socket_struct *ns)
Definition: request.cpp:2624
CS_STAT_STR
#define CS_STAT_STR
Definition: newclient.h:80
apply_race_and_class
int apply_race_and_class(object *op, archetype *race, archetype *opclass, living *stats)
Definition: player.cpp:1479
CS_STAT_BASE_INT
#define CS_STAT_BASE_INT
Definition: newclient.h:114
sounds.h
FLAG_REMOVED
#define FLAG_REMOVED
Definition: define.h:232
ST_CHANGE_CLASS
#define ST_CHANGE_CLASS
Definition: define.h:544
CS_STAT_SPELL_ATTUNE
#define CS_STAT_SPELL_ATTUNE
Definition: newclient.h:103
FLAG_WIZ
#define FLAG_WIZ
Definition: define.h:231
llevInfo
@ llevInfo
Definition: logger.h:12
SockList_AddData
void SockList_AddData(SockList *sl, const void *data, size_t len)
Definition: lowlevel.cpp:167
NDI_UNIQUE
#define NDI_UNIQUE
Definition: newclient.h:251
esrv_move_object
void esrv_move_object(object *pl, tag_t to, tag_t tag, long nrof)
Definition: item.cpp:899
FLAG_FRIENDLY
#define FLAG_FRIENDLY
Definition: define.h:246
get_client_spell_state
client_spell * get_client_spell_state(player *pl, object *spell)
Definition: player.cpp:144
archetype::tail_x
int8_t tail_x
Definition: object.h:488
object::name
sstring name
Definition: object.h:319
SP_level_dam_adjust
int SP_level_dam_adjust(const object *caster, const object *spob)
Definition: spell_util.cpp:287
socket_struct::want_pickup
uint32_t want_pickup
Definition: newserver.h:108
object_find_by_arch_name
object * object_find_by_arch_name(const object *who, const char *name)
Definition: object.cpp:4248
AddIfFloat
#define AddIfFloat(Old, New, sl, Type)
Definition: request.cpp:782
ST_CONFIRM_PASSWORD
#define ST_CONFIRM_PASSWORD
Definition: define.h:548
send_tick
void send_tick(player *pl)
Definition: request.cpp:1986
map2_add_ob
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)
Definition: request.cpp:1120
get_map_flags
int get_map_flags(mapstruct *oldmap, mapstruct **newmap, int16_t x, int16_t y, int16_t *nx, int16_t *ny)
Definition: map.cpp:300
account_block_create
static int account_block_create(const socket_struct *ns)
Definition: request.cpp:2240
item
Definition: item.py:1
DISEASE
@ DISEASE
Definition: object.h:249
P_NEED_UPDATE
#define P_NEED_UPDATE
Definition: map.h:237
newserver.h
mapstruct
Definition: map.h:313
enter_exit
void enter_exit(object *op, object *exit_ob)
Definition: server.cpp:738
SP_RUNE
#define SP_RUNE
Definition: spells.h:76
BEAT_INTERVAL
#define BEAT_INTERVAL
Definition: config.h:636
object::env
object * env
Definition: object.h:301
map_newmap_cmd
void map_newmap_cmd(socket_struct *ns)
Definition: request.cpp:693
esrv_add_spells
void esrv_add_spells(player *pl, object *spell)
Definition: request.cpp:1927
SND_MUSIC
#define SND_MUSIC
Definition: sounds.h:13
sstring
const typedef char * sstring
Definition: sstring.h:2
give.op
op
Definition: give.py:33
NDI_ALL
#define NDI_ALL
Definition: newclient.h:252
socket_struct::status
enum Sock_Status status
Definition: newserver.h:90
Animations
Definition: face.h:25
MAP_CLIENT_Y_MINIMUM
#define MAP_CLIENT_Y_MINIMUM
Definition: config.h:246
autojail.value
value
Definition: autojail.py:6
CS_STAT_RES_COLD
#define CS_STAT_RES_COLD
Definition: newclient.h:141
FLAG_AUTO_APPLY
#define FLAG_AUTO_APPLY
Definition: define.h:250
object::skill
sstring skill
Definition: object.h:329
esrv_remove_spell
void esrv_remove_spell(player *pl, object *spell)
Definition: request.cpp:1790
SockList_AddLen8Data
void SockList_AddLen8Data(SockList *sl, const void *data, size_t len)
Definition: lowlevel.cpp:179
receive_player_password
void receive_player_password(object *op, const char *password)
Definition: c_misc.cpp:1955
mapstruct::in_memory
uint32_t in_memory
Definition: map.h:333
add_me_cmd
void add_me_cmd(char *buf, int len, socket_struct *ns)
Definition: request.cpp:415
esrv_draw_look
void esrv_draw_look(object *pl)
Definition: item.cpp:193
object::msg
sstring msg
Definition: object.h:330
version_cmd
void version_cmd(char *buf, int len, socket_struct *ns)
Definition: request.cpp:657
diamondslots.y
y
Definition: diamondslots.py:16
Map::cells
struct map_cell_struct cells[MAX_CLIENT_X][MAX_CLIENT_Y]
Definition: newserver.h:49
CF_CONFUSED
#define CF_CONFUSED
Definition: newclient.h:187
ob_apply
method_ret ob_apply(object *op, object *applier, int aflags)
Definition: ob_methods.cpp:44
NUM_ANIMATIONS
#define NUM_ANIMATIONS(ob)
Definition: global.h:171
SockList_ResetRead
void SockList_ResetRead(SockList *sl)
Definition: lowlevel.cpp:83
NDI_DK_ORANGE
#define NDI_DK_ORANGE
Definition: newclient.h:237
socket_struct::anims_sent
uint8_t anims_sent[MAXANIMNUM]
Definition: newserver.h:97
account_change_password
int account_change_password(const char *account_name, const char *current_password, const char *new_password)
Definition: account.cpp:628
socket_struct::faces_sent
uint8_t * faces_sent
Definition: newserver.h:96
CS_STAT_RES_DEATH
#define CS_STAT_RES_DEATH
Definition: newclient.h:152
arch_to_object
object * arch_to_object(archetype *at)
Definition: arch.cpp:229
GetInt_String
int GetInt_String(const unsigned char *data)
Definition: lowlevel.cpp:254
draw_client_map2
static void draw_client_map2(object *pl)
Definition: request.cpp:1434
strcasecmp
int strcasecmp(const char *s1, const char *s2)
castle_read.key
key
Definition: castle_read.py:64
make_face_from_files.int
int
Definition: make_face_from_files.py:32
ACL_LEVEL
#define ACL_LEVEL
Definition: newclient.h:209
MAP_LAYER_FLY2
#define MAP_LAYER_FLY2
Definition: map.h:49
CS_STAT_TITLE
#define CS_STAT_TITLE
Definition: newclient.h:96
MAP_TYPE_DEFAULT
#define MAP_TYPE_DEFAULT
Definition: map.h:58
object::randomitems
struct treasurelist * randomitems
Definition: object.h:395
newclient.h
save_player
int save_player(object *op, int flag)
Definition: login.cpp:230
ST_GET_PARTY_PASSWORD
#define ST_GET_PARTY_PASSWORD
Definition: define.h:549
VERSION_CS
#define VERSION_CS
Definition: newserver.h:149
Account_Chars
Definition: account_char.h:27
UPD_SP_GRACE
#define UPD_SP_GRACE
Definition: newclient.h:314
get_archetype_by_type_subtype
archetype * get_archetype_by_type_subtype(int type, int subtype)
Definition: arch.cpp:99
CS_STAT_POW
#define CS_STAT_POW
Definition: newclient.h:97
CF_WIZARD
#define CF_WIZARD
Definition: newclient.h:196
esrv_send_pickup
void esrv_send_pickup(player *pl)
Definition: request.cpp:1813
object_remove
void object_remove(object *op)
Definition: object.cpp:1833
player_set_state
void player_set_state(player *pl, uint8_t state)
Definition: player.cpp:4467
free_charlinks
void free_charlinks(linked_char *lc)
Definition: utils.cpp:616
try_find_archetype
archetype * try_find_archetype(const char *name)
Definition: assets.cpp:270
CS_STAT_RACE_WIS
#define CS_STAT_RACE_WIS
Definition: newclient.h:108
AddIfString
#define AddIfString(Old, New, sl, Type)
Definition: request.cpp:789
MAX_CHOICES
#define MAX_CHOICES
Definition: request.cpp:2617
try_find_face
const Face * try_find_face(const char *name, const Face *error)
Definition: assets.cpp:286
SP_RAISE_DEAD
#define SP_RAISE_DEAD
Definition: spells.h:75
MIN_NUM_LOOK_OBJECTS
#define MIN_NUM_LOOK_OBJECTS
Definition: newserver.h:16
SP_MAKE_MARK
#define SP_MAKE_MARK
Definition: spells.h:77
MAP_LAYER_LIVING2
#define MAP_LAYER_LIVING2
Definition: map.h:47
socket_struct::login_method
uint8_t login_method
Definition: newserver.h:128
archetype::tail_y
int8_t tail_y
Definition: object.h:488
check_probe
static int check_probe(int ax, int ay, const object *ob, SockList *sl, socket_struct *ns, int *has_obj, int *alive_layer)
Definition: request.cpp:1290
commands.h
ST_CONFIRM_QUIT
#define ST_CONFIRM_QUIT
Definition: define.h:545
CS_STAT_MAXHP
#define CS_STAT_MAXHP
Definition: newclient.h:77
move_cmd
void move_cmd(char *buf, int len, player *pl)
Definition: request.cpp:714
account_char_load
Account_Chars * account_char_load(const char *account_name)
Definition: account_char.cpp:135
key_change_class
void key_change_class(object *op, char key)
Definition: player.cpp:1289
receive_party_password
void receive_party_password(object *op, const char *password)
Definition: c_party.cpp:53
spell_client_use
static int spell_client_use(const object *spell)
Definition: request.cpp:1833
account_check_string
int account_check_string(const char *str)
Definition: account.cpp:361
esrv_update_stats
void esrv_update_stats(player *pl)
Definition: request.cpp:873
socket_struct::darkness
uint32_t darkness
Definition: newserver.h:103
FLAG_XRAYS
#define FLAG_XRAYS
Definition: define.h:300
player::socket
socket_struct * socket
Definition: player.h:107
socket_struct::notifications
uint16_t notifications
Definition: newserver.h:129
SF_RUNON
#define SF_RUNON
Definition: newclient.h:179
CS_STAT_RANGE
#define CS_STAT_RANGE
Definition: newclient.h:95
Settings::account_trusted_host
char * account_trusted_host
Definition: global.h:329
report.error
def error(pl)
Definition: report.py:43
object::stats
living stats
Definition: object.h:378
MSG_TYPE_ADMIN_VERSION
#define MSG_TYPE_ADMIN_VERSION
Definition: newclient.h:490
get_attr_value
int8_t get_attr_value(const living *stats, int attr)
Definition: living.cpp:313
update_los
void update_los(object *op)
Definition: los.cpp:509
CS_STAT_BASE_CON
#define CS_STAT_BASE_CON
Definition: newclient.h:117
add_char_field
static void add_char_field(SockList *sl, int type, const char *data)
Definition: request.cpp:2016
CS_STAT_DEX
#define CS_STAT_DEX
Definition: newclient.h:83
account_login
int account_login(const char *account_name, const char *account_password)
Definition: account.cpp:319
Settings::always_show_hp
uint8_t always_show_hp
Definition: global.h:273
verify_player
int verify_player(const char *name, char *password)
Definition: login.cpp:111
ST_ROLL_STAT
#define ST_ROLL_STAT
Definition: define.h:543
SPELL
@ SPELL
Definition: object.h:219
CS_STAT_BASE_STR
#define CS_STAT_BASE_STR
Definition: newclient.h:113
smooth_face
const Face * smooth_face
Definition: image.cpp:36
esrv_new_player
void esrv_new_player(player *pl, uint32_t weight)
Definition: request.cpp:1015
decode_name_password
static int decode_name_password(const char *buf, int *len, char *name, char *password)
Definition: request.cpp:2141
account_char_save
void account_char_save(Account_Chars *chars)
Definition: account_char.cpp:158
CS_STAT_RES_DRAIN
#define CS_STAT_RES_DRAIN
Definition: newclient.h:144
altar_valkyrie.pl
pl
Definition: altar_valkyrie.py:28
MAP_NOSMOOTH
#define MAP_NOSMOOTH(m)
Definition: map.h:84
living.h
Send_With_Handling
void Send_With_Handling(socket_struct *ns, SockList *sl)
Definition: lowlevel.cpp:447
MSG_TYPE_ADMIN
#define MSG_TYPE_ADMIN
Definition: newclient.h:391
CF_HOSTILE
#define CF_HOSTILE
Definition: newclient.h:193
SockList
Definition: newclient.h:670
CF_PARALYZED
#define CF_PARALYZED
Definition: newclient.h:195
NUM_STATS
@ NUM_STATS
Definition: living.h:18
FOR_INV_PREPARE
#define FOR_INV_PREPARE(op_, it_)
Definition: define.h:670
living::hp
int16_t hp
Definition: living.h:40
takeitem.status
status
Definition: takeitem.py:38
FORCE
@ FORCE
Definition: object.h:229
account_char_remove
void account_char_remove(Account_Chars *chars, const char *pl_name)
Definition: account_char.cpp:313
CS_STAT_APPLIED_INT
#define CS_STAT_APPLIED_INT
Definition: newclient.h:121
MAX_LIGHT_RADII
#define MAX_LIGHT_RADII
Definition: define.h:450
ACL_FACE
#define ACL_FACE
Definition: newclient.h:210
CF_XRAY
#define CF_XRAY
Definition: newclient.h:190
rangetostring
void rangetostring(const object *pl, char *obuf, size_t len)
Definition: info.cpp:264
llevDebug
@ llevDebug
Definition: logger.h:13
NS_FACESENT_SMOOTH
#define NS_FACESENT_SMOOTH
Definition: newserver.h:138
is_valid_types_gen.type
list type
Definition: is_valid_types_gen.py:25
SockList_AddPrintf
void SockList_AddPrintf(SockList *sl, const char *format,...)
Definition: lowlevel.cpp:202
account_exists
const char * account_exists(const char *account_name)
Definition: account.cpp:297
give.name
name
Definition: give.py:27
CS_STAT_RES_PARA
#define CS_STAT_RES_PARA
Definition: newclient.h:148
Settings::starting_stat_max
uint8_t starting_stat_max
Definition: global.h:321
CS_STAT_RES_ACID
#define CS_STAT_RES_ACID
Definition: newclient.h:143
SPELL_MANA
#define SPELL_MANA
Definition: spells.h:58
dragon_attune.force
force
Definition: dragon_attune.py:45
CS_STAT_RES_ELEC
#define CS_STAT_RES_ELEC
Definition: newclient.h:140
CS_STAT_FLAGS
#define CS_STAT_FLAGS
Definition: newclient.h:100