Crossfire Server, Trunk  R21086
request.c
Go to the documentation of this file.
1 /*
2  * Crossfire -- cooperative multi-player graphical RPG and adventure game
3  *
4  * Copyright (c) 1999-2014 Mark Wedel and the Crossfire Development Team
5  * Copyright (c) 1992 Frank Tore Johansen
6  *
7  * Crossfire is free software and comes with ABSOLUTELY NO WARRANTY. You are
8  * welcome to redistribute it under certain conditions. For details, please
9  * see COPYING and LICENSE.
10  *
11  * The authors can be reached via e-mail at <crossfire@metalforge.org>.
12  */
13 
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 #endif /* win32 */
59 
60 #include "commands.h"
61 #include "living.h"
62 #include "newserver.h"
63 #include "shared/newclient.h"
64 #include "sounds.h"
65 #include "sproto.h"
66 
73 static const short atnr_cs_stat[NROFATTACKS] = {
78  CS_STAT_RES_DRAIN, -1 /* weaponmagic */,
82  CS_STAT_RES_FEAR, -1 /* Cancellation */,
84  -1 /* Chaos */, -1 /* Counterspell */,
85  -1 /* Godpower */, CS_STAT_RES_HOLYWORD,
87  -1, /* Internal */
88  -1, /* life stealing */
89  -1 /* Disease - not fully done yet */
90 };
91 
93 void set_up_cmd(char *buf, int len, socket_struct *ns) {
94  int s = 0;
95  char *cmd, *param;
96  SockList sl;
97 
98  if (len <= 0 || !buf) {
99  LOG(llevDebug, "IP '%s' sent bogus set_up_cmd information\n", ns->host);
100  return;
101  }
102 
103  /* run through the cmds of setup
104  * syntax is setup <cmdname1> <parameter> <cmdname2> <parameter> ...
105  *
106  * we send the status of the cmd back, or a FALSE is the cmd
107  * is the server unknown
108  * The client then must sort this out
109  */
110 
111  LOG(llevDebug, "setup: %s\n", buf);
112  SockList_Init(&sl);
113  SockList_AddString(&sl, "setup");
114  while (s < len) {
115  cmd = &buf[s];
116 
117  /* find the next space, and put a null there */
118  for (; buf[s] && buf[s] != ' '; s++)
119  ;
120  if (s >= len)
121  break;
122  buf[s++] = 0;
123 
124  while (buf[s] == ' ')
125  s++;
126  if (s >= len)
127  break;
128  param = &buf[s];
129 
130  for (; buf[s] && buf[s] != ' '; s++)
131  ;
132  buf[s++] = 0;
133 
134  while (s < len && buf[s] == ' ')
135  s++;
136 
137  SockList_AddPrintf(&sl, " %s ", cmd);
138 
139  if (!strcmp(cmd, "sound2")) {
140  ns->sound = atoi(param)&(SND_EFFECTS|SND_MUSIC|SND_MUTE);
141  SockList_AddString(&sl, param);
142  } else if (!strcmp(cmd, "spellmon")) {
143  int monitor_spells;
144 
145  monitor_spells = atoi(param);
146  if (monitor_spells < 0 || monitor_spells > 2) {
147  SockList_AddString(&sl, "FALSE");
148  } else {
149  ns->monitor_spells = monitor_spells;
150  SockList_AddPrintf(&sl, "%d", monitor_spells);
151  }
152  } else if (!strcmp(cmd, "darkness")) {
153  int darkness;
154 
155  darkness = atoi(param);
156  if (darkness != 0 && darkness != 1) {
157  SockList_AddString(&sl, "FALSE");
158  } else {
159  ns->darkness = darkness;
160  SockList_AddPrintf(&sl, "%d", darkness);
161  }
162  } else if (!strcmp(cmd, "map2cmd")) {
163  int map2cmd;
164 
165  map2cmd = atoi(param);
166  if (map2cmd != 1) {
167  SockList_AddString(&sl, "FALSE");
168  } else {
169  SockList_AddString(&sl, "1");
170  }
171  } else if (!strcmp(cmd, "facecache")) {
172  int facecache;
173 
174  facecache = atoi(param);
175  if (facecache != 0 && facecache != 1) {
176  SockList_AddString(&sl, "FALSE");
177  } else {
178  ns->facecache = facecache;
179  SockList_AddPrintf(&sl, "%d", facecache);
180  }
181  } else if (!strcmp(cmd, "faceset")) {
182  int q = atoi(param);
183 
184  if (is_valid_faceset(q))
185  ns->faceset = q;
186  SockList_AddPrintf(&sl, "%d", ns->faceset);
187  } else if (!strcmp(cmd, "mapsize")) {
188  int x, y, n;
189 
190  if (sscanf(param, "%dx%d%n", &x, &y, &n) != 2 || n != (int)strlen(param)) {
191  x = 0;
192  y = 0;
193  }
194  if (x < 9 || y < 9 || x > MAP_CLIENT_X || y > MAP_CLIENT_Y) {
196  } else {
197  player *pl;
198  ns->mapx = x;
199  ns->mapy = y;
200  /* better to send back what we are really using and not the
201  * param as given to us in case it gets parsed differently.
202  */
203  SockList_AddPrintf(&sl, "%dx%d", x, y);
204  /* need to update the los, else the view jumps */
205  pl = find_player_socket(ns);
206  if (pl)
207  update_los(pl->ob);
208 
209  /* Client and server need to resynchronize on data - treating it as
210  * a new map is best way to go.
211  */
212  map_newmap_cmd(ns);
213  }
214  } else if (!strcmp(cmd, "tick")) {
215  int tick;
216 
217  tick = atoi(param);
218  if (tick != 0 && tick != 1) {
219  SockList_AddString(&sl, "FALSE");
220  } else {
221  ns->tick = tick;
222  SockList_AddPrintf(&sl, "%d", tick);
223  }
224  } else if (!strcmp(cmd, "bot")) {
225  int is_bot;
226 
227  is_bot = atoi(param);
228  if (is_bot != 0 && is_bot != 1) {
229  SockList_AddString(&sl, "FALSE");
230  } else {
231  ns->is_bot = is_bot;
232  SockList_AddPrintf(&sl, "%d", is_bot);
233  }
234  } else if (!strcmp(cmd, "want_pickup")) {
235  int want_pickup;
236 
237  want_pickup = atoi(param);
238  if (want_pickup != 0 && want_pickup != 1) {
239  SockList_AddString(&sl, "FALSE");
240  } else {
241  ns->want_pickup = want_pickup;
242  SockList_AddPrintf(&sl, "%d", want_pickup);
243  }
244  } else if (!strcmp(cmd, "num_look_objects")) {
245  int tmp;
246  player *pl;
247 
248  tmp = atoi(param);
249  if (tmp < MIN_NUM_LOOK_OBJECTS) {
250  tmp = MIN_NUM_LOOK_OBJECTS;
251  } else if (tmp > MAX_NUM_LOOK_OBJECTS) {
252  tmp = MAX_NUM_LOOK_OBJECTS;
253  }
254  ns->num_look_objects = (uint8_t)tmp;
255  SockList_AddPrintf(&sl, "%d", tmp);
256 
257  pl = find_player_socket(ns);
258  if (pl && pl->ob) {
259  ns->update_look = 1;
260  esrv_draw_look(pl->ob);
261  }
262  } else if (!strcmp(cmd, "extended_stats")) {
263  int extended_stats;
264 
265  extended_stats = atoi(param);
266  if (extended_stats != 0 && extended_stats != 1) {
267  SockList_AddString(&sl, "FALSE");
268  } else {
269  ns->extended_stats = extended_stats;
270  SockList_AddPrintf(&sl, "%d", extended_stats);
271  }
272  } else if (!strcmp(cmd, "beat")) {
273  int use_beat = atoi(param);
274 
275  if (use_beat != 0 && use_beat != 1) {
276  SockList_AddString(&sl, "FALSE");
277  } else {
278  ns->heartbeat = use_beat ? true : false;
279 
280  // Send setup command with standard beat interval.
281  SockList_AddPrintf(&sl, "%d", BEAT_INTERVAL);
282  }
283  } else if (!strcmp(cmd, "loginmethod")) {
284  int loginmethod;
285 
286  loginmethod = atoi(param);
287 
288  /* Only support basic login right now */
289  if (loginmethod > 2) loginmethod=2;
290 
291  ns->login_method = loginmethod;
292  SockList_AddPrintf(&sl, "%d", loginmethod);
293 
294  } else if (!strcmp(cmd, "notifications")) {
295  int notifications;
296 
297  notifications = atoi(param);
298 
299  ns->notifications = notifications;
300  SockList_AddPrintf(&sl, "%d", notifications);
301 
302  } else if (!strcmp(cmd, "newmapcmd")) {
303  /* newmapcmd is deprecated (now standard part), but some
304  * clients still use this setup option, and if the server
305  * doesn't respond, erroneously report that the client is
306  * too old. Since it is always on, regardless of what is
307  * request, send back one.
308  */
309  SockList_AddString(&sl, "1");
310  } else if (!strcmp(cmd, "extendedTextInfos")) {
311  /* like newmapcmd above, extendedTextInfos is
312  * obsolete, but we respond for the same reason as we do
313  * in newmapcmd
314  */
315  SockList_AddString(&sl, "1");
316  } else if (!strcmp(cmd, "itemcmd")) {
317  /* like newmapcmd above, itemcmd is
318  * obsolete, but we respond for the same reason as we do
319  * in newmapcmd
320  */
321  SockList_AddString(&sl, "2");
322  } else if (!strcmp(cmd, "exp64")) {
323  /* like newmapcmd above, exp64 is
324  * obsolete, but we respond for the same reason as we do
325  * in newmapcmd
326  */
327  SockList_AddString(&sl, "1");
328  } else {
329  /* Didn't get a setup command we understood -
330  * report a failure to the client.
331  */
332  SockList_AddString(&sl, "FALSE");
333  }
334  } /* for processing all the setup commands */
335  Send_With_Handling(ns, &sl);
336  SockList_Term(&sl);
337 }
338 
347 void add_me_cmd(char *buf, int len, socket_struct *ns) {
348  Settings oldsettings;
349  SockList sl;
350 
351  oldsettings = settings;
352  if (ns->status != Ns_Add) {
353  SockList_Init(&sl);
354  SockList_AddString(&sl, "addme_failed");
355  Send_With_Handling(ns, &sl);
356  SockList_Term(&sl);
357  } else if (find_player_socket(ns) == NULL) {
358  /* if there is already a player for this socket (add_me was already called),
359  * just ignore, else weird issues. */
360 
361  add_player(ns, 0);
362  /* Basically, the add_player copies the socket structure into
363  * the player structure, so this one (which is from init_sockets)
364  * is not needed anymore. The write below should still work,
365  * as the stuff in ns is still relevant.
366  */
367  SockList_Init(&sl);
368  SockList_AddString(&sl, "addme_success");
369  Send_With_Handling(ns, &sl);
370  SockList_Term(&sl);
371  if (ns->sc_version < 1027 || ns->cs_version < 1023) {
372  /* The space in the link isn't correct, but in my
373  * quick test with client 1.1.0, it didn't print it
374  * out correctly when done as a single line.
375  */
377  "Warning: Your client is too old to receive map data. Please update to a new client at http://sourceforge.net/project/showfiles.php ?group_id=13833");
378  }
379 
380  ns->status = Ns_Avail;
381  }
382  settings = oldsettings;
383 }
384 
392 static void send_smooth(socket_struct *ns, uint16_t face) {
393  uint16_t smoothface;
394  SockList sl;
395 
396  // Try to find a smoothing face, or the default smoothing face. If this
397  // fails, set NS_FACESENT_SMOOTH so we don't try to send it again.
398  //
399  // Failures are usually due to map makers changing the face of a ground
400  // tile, but forgetting to unset smoothlevel.
401  if (!find_smooth(face, &smoothface)
402  && !find_smooth(smooth_face->number, &smoothface)) {
403  LOG(llevDebug,
404  "Could not smooth face %d\n"
405  "Check that this face has a smoothing pixmap, or remove its smoothlevel.\n",
406  face);
407  ns->faces_sent[face] |= NS_FACESENT_SMOOTH;
408  return;
409  }
410 
411  if (!(ns->faces_sent[smoothface]&NS_FACESENT_FACE))
412  esrv_send_face(ns, smoothface, 0);
413 
414  ns->faces_sent[face] |= NS_FACESENT_SMOOTH;
415 
416  SockList_Init(&sl);
417  SockList_AddString(&sl, "smooth ");
418  SockList_AddShort(&sl, face);
419  SockList_AddShort(&sl, smoothface);
420  Send_With_Handling(ns, &sl);
421  SockList_Term(&sl);
422 }
423 
428 void ask_smooth_cmd(char *buf, int len, socket_struct *ns) {
429  uint16_t facenbr;
430 
431  if (len <= 0 || !buf) {
432  LOG(llevDebug, "IP '%s' sent bogus ask_smooth_cmd information\n", ns->host);
433  return;
434  }
435 
436  facenbr = atoi(buf);
437  send_smooth(ns, facenbr);
438 }
439 
452 void new_player_cmd(uint8_t *buf, int len, player *pl) {
453  int time, repeat;
454  short packet;
455  char command[MAX_BUF];
456  SockList sl;
457 
458  if (len < 7) {
459  LOG(llevDebug, "Corrupt ncom command - not long enough - discarding\n");
460  return;
461  }
462 
463  packet = GetShort_String(buf);
464  repeat = GetInt_String(buf+2);
465  /* -1 is special - no repeat, but don't update */
466  if (repeat != -1) {
467  pl->count = repeat;
468  }
469  if (len-4 >= MAX_BUF)
470  len = MAX_BUF-5;
471 
472  strncpy(command, (char *)buf+6, len-4);
473  command[len-4] = '\0';
474 
475  /* The following should never happen with a proper or honest client.
476  * Therefore, the error message doesn't have to be too clear - if
477  * someone is playing with a hacked/non working client, this gives them
478  * an idea of the problem, but they deserve what they get
479  */
480  if (pl->state != ST_PLAYING) {
482  "You can not issue commands - state is not ST_PLAYING (%s)",
483  buf);
484  return;
485  }
486 
487  /* This should not happen anymore. */
488  if (pl->ob->speed_left < 0) {
489  LOG(llevError, "Player has negative time - shouldn't do command.\n");
490  }
491  /* In c_new.c */
492  execute_newserver_command(pl->ob, command);
493  /* Perhaps something better should be done with a left over count.
494  * Cleaning up the input should probably be done first - all actions
495  * for the command that issued the count should be done before
496  * any other commands.
497  */
498  pl->count = 0;
499 
500  /* Send confirmation of command execution now */
501  SockList_Init(&sl);
502  SockList_AddString(&sl, "comc ");
503  SockList_AddShort(&sl, packet);
504  if (FABS(pl->ob->speed) < 0.001)
505  time = MAX_TIME*100;
506  else
507  time = (int)(MAX_TIME/FABS(pl->ob->speed));
508  SockList_AddInt(&sl, time);
509  Send_With_Handling(&pl->socket, &sl);
510  SockList_Term(&sl);
511 }
512 
514 void reply_cmd(char *buf, int len, player *pl) {
515 
516  if (len <= 0 || !buf) {
517  LOG(llevDebug, "Player '%s' sent bogus reply_cmd information\n", pl->ob->name);
518  return;
519  }
520 
521  /* This is to synthesize how the data would be stored if it
522  * was normally entered. A bit of a hack, and should be cleaned up
523  * once all the X11 code is removed from the server.
524  *
525  * We pass 13 to many of the functions because this way they
526  * think it was the carriage return that was entered, and the
527  * function then does not try to do additional input.
528  */
529  snprintf(pl->write_buf, sizeof(pl->write_buf), ":%s", buf);
530 
531  /* this avoids any hacking here */
532 
533  switch (pl->state) {
534  case ST_PLAYING:
535  LOG(llevError, "Got reply message with ST_PLAYING input state\n");
536  break;
537 
538  case ST_PLAY_AGAIN:
539  /* We can check this for return value (2==quit). Maybe we
540  * should, and do something appropriate?
541  */
542  receive_play_again(pl->ob, buf[0]);
543  break;
544 
545  case ST_ROLL_STAT:
546  key_roll_stat(pl->ob, buf[0]);
547  break;
548 
549  case ST_CHANGE_CLASS:
550 
551  key_change_class(pl->ob, buf[0]);
552  break;
553 
554  case ST_CONFIRM_QUIT:
555  key_confirm_quit(pl->ob, buf[0]);
556  break;
557 
558  case ST_GET_NAME:
559  receive_player_name(pl->ob);
560  break;
561 
562  case ST_GET_PASSWORD:
563  case ST_CONFIRM_PASSWORD:
568  break;
569 
570  case ST_GET_PARTY_PASSWORD: /* Get password for party */
572  break;
573 
574  default:
575  LOG(llevError, "Unknown input state: %d\n", pl->state);
576  }
577 }
578 
586 void version_cmd(char *buf, int len, socket_struct *ns) {
587  char *rest;
588  char *cs_str = strtok_r(buf, " ", &rest);
589  char *sc_str = strtok_r(NULL, " ", &rest);
590 
591  if (cs_str == NULL || sc_str == NULL) {
592  LOG(llevError, "%s: sent invalid version string\n", ns->host);
593  return;
594  } else {
595  ns->cs_version = atoi(cs_str);
596  ns->sc_version = atoi(sc_str);
597  }
598 
599 #ifdef ESRV_DEBUG
600  if (VERSION_CS != ns->cs_version) {
601  LOG(llevDebug, "CS: csversion mismatch (%d,%d)\n", VERSION_CS, ns->cs_version);
602  }
603 
604  if (VERSION_SC != ns->sc_version) {
605  LOG(llevDebug, "CS: scversion mismatch (%d,%d)\n", VERSION_SC, ns->sc_version);
606  }
607 #endif
608 
609  if (rest != NULL) {
610  LOG(llevInfo, "%s: connected using '%s'\n", ns->host, rest);
611  }
612 }
613 
621  SockList sl;
622 
623  /* If getting a newmap command, this scroll information
624  * is no longer relevant.
625  */
626  ns->map_scroll_x = 0;
627  ns->map_scroll_y = 0;
628 
629 
630  memset(&ns->lastmap, 0, sizeof(ns->lastmap));
631  SockList_Init(&sl);
632  SockList_AddString(&sl, "newmap");
633  Send_With_Handling(ns, &sl);
634  SockList_Term(&sl);
635 }
636 
641 void move_cmd(char *buf, int len, player *pl) {
642  int vals[3], i;
643 
644  if (len <= 0 || !buf) {
645  LOG(llevDebug, "Player '%s' sent bogus move_cmd information\n", pl->ob->name);
646  return;
647  }
648 
649  /* A little funky here. We only cycle for 2 records, because
650  * we obviously am not going to find a space after the third
651  * record. Perhaps we should just replace this with a
652  * sscanf?
653  */
654  for (i = 0; i < 2; i++) {
655  vals[i] = atoi(buf);
656  if (!(buf = strchr(buf, ' '))) {
657  LOG(llevError, "Incomplete move command: %s\n", buf);
658  return;
659  }
660  buf++;
661  }
662  vals[2] = atoi(buf);
663 
664 /* LOG(llevDebug, "Move item %d (nrof=%d) to %d.\n", vals[1], vals[2], vals[0]);*/
665  esrv_move_object(pl->ob, vals[0], vals[1], vals[2]);
666 }
667 
668 /***************************************************************************
669  *
670  * Start of commands the server sends to the client.
671  *
672  ***************************************************************************
673  */
674 
679 void send_query(socket_struct *ns, uint8_t flags, const char *text) {
680  SockList sl;
681 
682  SockList_Init(&sl);
683  SockList_AddPrintf(&sl, "query %d %s", flags, text ? text : "");
684  Send_With_Handling(ns, &sl);
685  SockList_Term(&sl);
686 }
687 
688 #define AddIfInt64(Old, New, Type) \
689  if (Old != New) { \
690  Old = New; \
691  SockList_AddChar(&sl, Type); \
692  SockList_AddInt64(&sl, New); \
693  }
694 
695 #define AddIfInt(Old, New, Type) \
696  if (Old != New) { \
697  Old = New; \
698  SockList_AddChar(&sl, Type); \
699  SockList_AddInt(&sl, New); \
700  }
701 
702 #define AddIfShort(Old, New, Type) \
703  if (Old != New) { \
704  Old = New; \
705  SockList_AddChar(&sl, Type); \
706  SockList_AddShort(&sl, New); \
707  }
708 
709 #define AddIfFloat(Old, New, Type) \
710  if (Old != New) { \
711  Old = New; \
712  SockList_AddChar(&sl, Type); \
713  SockList_AddInt(&sl, (long)(New*FLOAT_MULTI));\
714  }
715 
716 #define AddIfString(Old, New, Type) \
717  if (Old == NULL || strcmp(Old, New)) { \
718  free(Old); \
719  Old = strdup_local(New); \
720  SockList_AddChar(&sl, Type); \
721  SockList_AddLen8Data(&sl, New, strlen(New));\
722  }
723 
731  SockList sl;
732  char buf[MAX_BUF];
733  uint16_t flags;
734  uint8_t s;
735 
736  SockList_Init(&sl);
737  SockList_AddString(&sl, "stats ");
738 
739  if (pl->ob != NULL) {
753  }
754  if (pl->socket.extended_stats) {
755  int16_t golem_hp, golem_maxhp;
763  if (pl->ob != NULL) {
778  }
779  if (pl->ranges[range_golem]) {
780  object *golem = pl->ranges[range_golem];
781  if (QUERY_FLAG(golem, FLAG_REMOVED) || golem->count != pl->golem_count || QUERY_FLAG(golem, FLAG_FREED)) {
782  golem_hp = 0;
783  golem_maxhp = 0;
784  } else {
785  golem_hp = golem->stats.hp;
786  golem_maxhp = golem->stats.maxhp;
787  }
788  } else {
789  golem_hp = 0;
790  golem_maxhp = 0;
791  }
792  /* send first the maxhp, so the client can set up the display */
794  AddIfShort(pl->last_golem_hp, golem_hp, CS_STAT_GOLEM_HP);
795  }
796 
797  for (s = 0; s < NUM_SKILLS; s++) {
798  if (pl->last_skill_ob[s]
799  && pl->last_skill_exp[s] != pl->last_skill_ob[s]->stats.exp) {
800  /* Always send along the level if exp changes. This
801  * is only 1 extra byte, but keeps processing simpler.
802  */
803  SockList_AddChar(&sl, (char)(s+CS_STAT_SKILLINFO));
804  SockList_AddChar(&sl, (char)pl->last_skill_ob[s]->level);
806  pl->last_skill_exp[s] = pl->last_skill_ob[s]->stats.exp;
807  }
808  }
810  AddIfShort(pl->last_level, (char)pl->ob->level, CS_STAT_LEVEL);
818  flags = 0;
819  if (pl->fire_on)
820  flags |= SF_FIREON;
821  if (pl->run_on)
822  flags |= SF_RUNON;
823 
824  AddIfShort(pl->last_flags, flags, CS_STAT_FLAGS);
825  if (pl->socket.sc_version < 1025) {
827  } else {
828  int i;
829 
830  for (i = 0; i < NROFATTACKS; i++) {
831  /* Skip ones we won't send */
832  if (atnr_cs_stat[i] == -1)
833  continue;
834  AddIfShort(pl->last_resist[i], pl->ob->resist[i], (char)atnr_cs_stat[i]);
835  }
836  }
837  if (pl->socket.monitor_spells) {
841  }
842  /* we want to use the new fire & run system in new client */
843  rangetostring(pl->ob, buf, sizeof(buf));
845  set_title(pl->ob, buf, sizeof(buf));
847 
848  /* Only send it away if we have some actual data - 2 bytes for length, 6 for "stats ". */
849  if (sl.len > 8) {
850 #ifdef ESRV_DEBUG
851  LOG(llevDebug, "Sending stats command, %d bytes long.\n", sl.len);
852 #endif
853  Send_With_Handling(&pl->socket, &sl);
854  }
855  SockList_Term(&sl);
856 }
857 
862  SockList sl;
863 
864  pl->last_weight = weight;
865 
866  if (!(pl->socket.faces_sent[pl->ob->face->number]&NS_FACESENT_FACE))
867  esrv_send_face(&pl->socket, pl->ob->face->number, 0);
868 
869  SockList_Init(&sl);
870  SockList_AddString(&sl, "player ");
871  SockList_AddInt(&sl, pl->ob->count);
872  SockList_AddInt(&sl, weight);
873  SockList_AddInt(&sl, pl->ob->face->number);
874  SockList_AddLen8Data(&sl, pl->ob->name, strlen(pl->ob->name));
875 
876  Send_With_Handling(&pl->socket, &sl);
877  SockList_Term(&sl);
879 }
880 
888 void esrv_send_animation(socket_struct *ns, short anim_num) {
889  SockList sl;
890  int i;
891 
892  /* Do some checking on the anim_num we got. Note that the animations
893  * are added in contigous order, so if the number is in the valid
894  * range, it must be a valid animation.
895  */
896  if (anim_num < 0 || anim_num > num_animations) {
897  LOG(llevError, "esrv_send_anim (%d) out of bounds??\n", anim_num);
898  return;
899  }
900 
901  SockList_Init(&sl);
902  SockList_AddString(&sl, "anim ");
903  SockList_AddShort(&sl, anim_num);
904  SockList_AddShort(&sl, 0); /* flags - not used right now */
905  /* Build up the list of faces. Also, send any information (ie, the
906  * the face itself) down to the client.
907  */
908  for (i = 0; i < animations[anim_num].num_animations; i++) {
909  if (!(ns->faces_sent[animations[anim_num].faces[i]->number]&NS_FACESENT_FACE))
910  esrv_send_face(ns, animations[anim_num].faces[i]->number, 0);
911  /* flags - not used right now */
912  SockList_AddShort(&sl, animations[anim_num].faces[i]->number);
913  }
914  Send_With_Handling(ns, &sl);
915  SockList_Term(&sl);
916  ns->anims_sent[anim_num] = 1;
917 }
918 
919 /****************************************************************************
920  *
921  * Start of map related commands.
922  *
923  ****************************************************************************/
924 
926 static void map_clearcell(struct map_cell_struct *cell, int face, int count) {
927  cell->darkness = count;
928  memset(cell->faces, face, sizeof(cell->faces));
929 }
930 
931 #define MAX_HEAD_POS MAX(MAX_CLIENT_X, MAX_CLIENT_Y)
932 
940 static const object *heads[MAX_HEAD_POS][MAX_HEAD_POS][MAP_LAYERS];
941 
942 /****************************************************************************
943  * This block is for map2 drawing related commands.
944  * Note that the map2 still uses other functions.
945  *
946  ***************************************************************************/
947 
967 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) {
968  uint16_t face_num;
969  uint8_t nlayer, smoothlevel = 0;
970  const object *head;
971 
972  assert(ob != NULL);
973 
974  head = HEAD(ob);
975  face_num = ob->face->number;
976 
977  /* This is a multipart object, and we are not at the lower
978  * right corner. So we need to store away the lower right corner.
979  */
980  if (!is_head && (head->arch->tail_x || head->arch->tail_y)
981  && (head->arch->tail_x != ob->arch->clone.x || head->arch->tail_y != ob->arch->clone.y)) {
982  int bx, by, l;
983 
984  /* Basically figure out where the offset is from where we
985  * are right now. the ob->arch->clone.{x,y} values hold
986  * the offset that this current piece is from the head,
987  * and the tail is where the tail is from the head.
988  * Note that bx and by will equal sx and sy if we are
989  * already working on the bottom right corner. If ob is
990  * the head, the clone values will be zero, so the right
991  * thing will still happen.
992  */
993  bx = ax+head->arch->tail_x-ob->arch->clone.x;
994  by = ay+head->arch->tail_y-ob->arch->clone.y;
995 
996  /* I don't think this can ever happen, but better to check
997  * for it just in case.
998  */
999  if (bx < ax || by < ay) {
1000  LOG(llevError, "map2_add_ob: bx (%d) or by (%d) is less than ax (%d) or ay (%d)\n", bx, by, ax, ay);
1001  face_num = 0;
1002  }
1003  /* the target position must be within +/-1 of our current
1004  * layer as the layers are defined. We are basically checking
1005  * to see if we have already stored this object away.
1006  */
1007  for (l = layer-1; l <= layer+1; l++) {
1008  if (l < 0 || l >= MAP_LAYERS)
1009  continue;
1010  if (heads[by][bx][l] == head)
1011  break;
1012  }
1013  /* Didn't find it. So we need to store it away. Try to store it
1014  * on our original layer, and then move up a layer.
1015  */
1016  if (l == layer+2) {
1017  if (!heads[by][bx][layer])
1018  heads[by][bx][layer] = head;
1019  else if (layer+1 < MAP_LAYERS && !heads[by][bx][layer+1])
1020  heads[by][bx][layer+1] = head;
1021  }
1022  return 0;
1023  /* Ok - All done storing away the head for future use */
1024  } else {
1025  (*has_obj)++;
1028  face_num = ob->animation_id|(1<<15);
1030  face_num |= ANIM_SYNC;
1031  else if (QUERY_FLAG(ob, FLAG_CLIENT_ANIM_RANDOM))
1032  face_num |= ANIM_RANDOM;
1033  }
1034  /* Since face_num includes the bits for the animation tag,
1035  * and we will store that away in the faces[] array, below
1036  * check works fine _except_ for the case where animation
1037  * speed chances.
1038  */
1039  if (ns->lastmap.cells[ax][ay].faces[layer] != face_num) {
1040  uint8_t len, anim_speed = 0, i;
1041 
1042  /* This block takes care of sending the actual face
1043  * to the client. */
1044  ns->lastmap.cells[ax][ay].faces[layer] = face_num;
1045 
1046  /* Now form the data packet */
1047  nlayer = MAP2_LAYER_START+layer;
1048 
1049  len = 2;
1050 
1051  if (ob->map && !MAP_NOSMOOTH(ob->map)) {
1052  smoothlevel = ob->smoothlevel;
1053  if (smoothlevel)
1054  len++;
1055  }
1056 
1059  len++;
1060  /* 1/0.004 == 250, so this is a good cap for an
1061  * upper limit */
1062  if (ob->anim_speed)
1063  anim_speed = ob->anim_speed;
1064  else if (FABS(ob->speed) < 0.004)
1065  anim_speed = 255;
1066  else if (FABS(ob->speed) >= 1.0)
1067  anim_speed = 1;
1068  else
1069  anim_speed = (int)(1.0/FABS(ob->speed));
1070 
1071  if (!ns->anims_sent[ob->animation_id])
1073 
1074  /* If smoothing, need to send smoothing information
1075  * for all faces in the animation sequence. Since
1076  * smoothlevel is an object attribute,
1077  * it applies to all faces.
1078  */
1079  if (smoothlevel) {
1080  for (i = 0; i < NUM_ANIMATIONS(ob); i++) {
1083  }
1084  }
1085  } else if (!(ns->faces_sent[face_num]&NS_FACESENT_FACE)) {
1086  esrv_send_face(ns, face_num, 0);
1087  }
1088 
1089  if (smoothlevel
1090  && !(ns->faces_sent[ob->face->number]&NS_FACESENT_SMOOTH))
1091  send_smooth(ns, ob->face->number);
1092 
1093  /* Length of packet */
1094  nlayer |= len<<5;
1095 
1096  SockList_AddChar(sl, nlayer);
1097  SockList_AddShort(sl, face_num);
1098  if (anim_speed)
1099  SockList_AddChar(sl, anim_speed);
1100  if (smoothlevel)
1101  SockList_AddChar(sl, smoothlevel);
1102  return 1;
1103  } /* Face is different */
1104  }
1105  return 0;
1106 }
1107 
1108 /* This function is used see if a layer needs to be cleared.
1109  * It updates the socklist, and returns 1 if the update is
1110  * needed, 0 otherwise.
1111  */
1112 static int map2_delete_layer(int ax, int ay, int layer, SockList *sl, socket_struct *ns) {
1113  int nlayer;
1114 
1115  if (ns->lastmap.cells[ax][ay].faces[layer] != 0) {
1116  /* Now form the data packet */
1117  nlayer = 0x10+layer+(2<<5);
1118  SockList_AddChar(sl, nlayer);
1119  SockList_AddShort(sl, 0);
1120  ns->lastmap.cells[ax][ay].faces[layer] = 0;
1121  return 1;
1122  }
1123  return 0;
1124 }
1125 
1137 static int check_probe(int ax, int ay, const object *ob, SockList *sl, socket_struct *ns, int *has_obj, int *alive_layer) {
1138  int got_one = 0, poisoned = 0, diseased = 0;
1139  char name[60];
1140  int value, granularity;
1141  const object *probe;
1142 
1143  /* send hp bar if needed */
1144  if ((*alive_layer) != -1 || ob->head || !CAN_PROBE(ob))
1145  return 0;
1146 
1147  if (settings.always_show_hp == 2) {
1148  /* global hp bars are enabled */
1149  granularity = 30;
1150  } else if (settings.always_show_hp == 1 && ob->stats.hp < ob->stats.maxhp) {
1151  granularity = 30;
1152  } else {
1153  /* only give hp bars to monsters that have been probed */
1154  if (!QUERY_FLAG(ob, FLAG_PROBE)) {
1155  return 0;
1156  }
1157  probe = object_find_by_type_and_name(ob, FORCE, "probe_force");
1158  if (probe == NULL || probe->level < 15) {
1159  /* if probe is not null, this is an error, but well */
1160  return 0;
1161  }
1162 
1163  granularity = (probe->level - 14) / 3;
1164  if (granularity <= 0)
1165  granularity = 1;
1166  else if (granularity > 30)
1167  granularity = 30;
1168  }
1169 
1170  if (ob->stats.maxhp > 0) {
1171  value = (ob->stats.hp * granularity) / (ob->stats.maxhp);
1172 
1173  if (value < 0)
1174  value = 0;
1175  else if (value > granularity)
1176  value = granularity;
1177  } else
1178  value = 30;
1179 
1180  value = (value * 30) / granularity;
1181 
1182  if (object_present_in_ob(POISONING, ob) != NULL)
1183  poisoned = 1;
1184  if (object_present_in_ob(DISEASE, ob) != NULL)
1185  diseased = 1;
1186 
1187  if (value > 0) {
1188  archetype *dummy;
1189 
1190  snprintf(name, sizeof(name), "hpbar%s%s%s_%d",
1191  poisoned ? "_poisoned" : "",
1192  diseased ? "_diseased" : "",
1193  (!poisoned && !diseased) ? "_standard" : "",
1194  value);
1195  dummy = try_find_archetype(name);
1196  if (dummy != NULL) {
1197  got_one += map2_add_ob(ax, ay, MAP_LAYER_FLY2, &dummy->clone, sl, ns, has_obj, 0);
1198  (*alive_layer) = MAP_LAYER_FLY2;
1199  }
1200  }
1201 
1202  return got_one;
1203 }
1204 
1205 /*
1206  * This function is used to check a space (ax, ay) whose only
1207  * data we may care about are any heads. Basically, this
1208  * space is out of direct view. This is only used with the
1209  * Map2 protocol.
1210  *
1211  * @param ax
1212  * viewport relative x-coordinate
1213  * @param ay
1214  * viewport relative y-coordinate
1215  * @param sl
1216  * the reply to append to
1217  * @param ns
1218  * the client socket
1219  */
1220 static void check_space_for_heads(int ax, int ay, SockList *sl, socket_struct *ns) {
1221  int layer, got_one = 0, del_one = 0, oldlen, has_obj = 0;
1222  uint16_t coord;
1223 
1224  coord = MAP2_COORD_ENCODE(ax, ay, 0);
1225  oldlen = sl->len;
1226  SockList_AddShort(sl, coord);
1227 
1228  for (layer = 0; layer < MAP_LAYERS; layer++) {
1229  const object *head;
1230 
1231  head = heads[ay][ax][layer];
1232  if (head) {
1233  /* in this context, got_one should always increase
1234  * because heads should always point to data to really send.
1235  */
1236  got_one += map2_add_ob(ax, ay, layer, head, sl, ns, &has_obj, 1);
1237  } else {
1238  del_one += map2_delete_layer(ax, ay, layer, sl, ns);
1239  }
1240  }
1241  /* Note - if/when lighting information is added, some code is
1242  * needed here - lighting sources that are out of sight may still
1243  * extend into the viewable area.
1244  */
1245 
1246  /* If nothing to do for this space, we
1247  * can erase the coordinate bytes
1248  */
1249  if (!del_one && !got_one) {
1250  sl->len = oldlen;
1251  } else if (del_one && !has_obj) {
1252  /* If we're only deleting faces and not adding, and there
1253  * are not any faces on the space we care about,
1254  * more efficient
1255  * to send 0 as the type/len field.
1256  */
1257  sl->len = oldlen+2; /* 2 bytes for coordinate */
1258  SockList_AddChar(sl, 0); /* Clear byte */
1259  SockList_AddChar(sl, 255); /* Termination byte */
1260  // Reduce defreferences by passing the inner array offset instead of address of value
1261  map_clearcell(ns->lastmap.cells[ax] + ay, 0, 0);
1262  } else {
1263  SockList_AddChar(sl, 255); /* Termination byte */
1264  }
1265 }
1266 
1267 static void draw_client_map2(object *pl) {
1268  int x, y, ax, ay, d, min_x, max_x, min_y, max_y, oldlen, layer;
1269  size_t startlen;
1270  int16_t nx, ny;
1271  SockList sl;
1272  uint16_t coord;
1273  mapstruct *m;
1274  // Dereference once. It should not change in the middle of processing.
1275  player *plyr = pl->contr;
1276 
1277  SockList_Init(&sl);
1278  SockList_AddString(&sl, "map2 ");
1279  startlen = sl.len;
1280 
1281  /* Handle map scroll */
1282  if (plyr->socket.map_scroll_x || plyr->socket.map_scroll_y) {
1283  coord = MAP2_COORD_ENCODE(plyr->socket.map_scroll_x, plyr->socket.map_scroll_y, 1);
1284  plyr->socket.map_scroll_x = 0;
1285  plyr->socket.map_scroll_y = 0;
1286  SockList_AddShort(&sl, coord);
1287  }
1288 
1289  /* Init data to zero */
1290  memset(heads, 0, sizeof(heads));
1291 
1292  /* We could do this logic as conditionals in the if statement,
1293  * but that started to get a bit messy to look at.
1294  */
1295  min_x = pl->x-plyr->socket.mapx/2;
1296  min_y = pl->y-plyr->socket.mapy/2;
1297  max_x = pl->x+(plyr->socket.mapx+1)/2+MAX_HEAD_OFFSET;
1298  max_y = pl->y+(plyr->socket.mapy+1)/2+MAX_HEAD_OFFSET;
1299 
1300  /* x, y are the real map locations. ax, ay are viewport relative
1301  * locations.
1302  */
1303  ay = 0;
1304  for (y = min_y; y < max_y; y++, ay++) {
1305  ax = 0;
1306  for (x = min_x; x < max_x; x++, ax++) {
1307  /* If this space is out of the normal viewable area,
1308  * we only check the heads value. This is used to
1309  * handle big images - if they extend to a viewable
1310  * portion, we need to send just the lower right corner.
1311  */
1312  if (ax >= plyr->socket.mapx || ay >= plyr->socket.mapy) {
1313  check_space_for_heads(ax, ay, &sl, &plyr->socket);
1314  } else {
1315  /* This space is within the viewport of the client. Due
1316  * to walls or darkness, it may still not be visible.
1317  */
1318 
1319  /* Meaning of d:
1320  * 0 - object is in plain sight, full brightness.
1321  * 1 - MAX_DARKNESS - how dark the space is - higher
1322  * value is darker space. If level is at max darkness,
1323  * you can't see the space (too dark)
1324  * 100 - space is blocked from sight.
1325  */
1326  d = plyr->blocked_los[ax][ay];
1327 
1328  /* If the coordinates are not valid, or it is too
1329  * dark to see, we tell the client as such
1330  */
1331  nx = x;
1332  ny = y;
1333  m = get_map_from_coord(pl->map, &nx, &ny);
1334  coord = MAP2_COORD_ENCODE(ax, ay, 0);
1335 
1336  if (!m) {
1337  /* space is out of map. Update space and clear
1338  * values if this hasn't already been done.
1339  * If the space is out of the map, it shouldn't
1340  * have a head.
1341  */
1342  if (plyr->socket.lastmap.cells[ax][ay].darkness != 0) {
1343  SockList_AddShort(&sl, coord);
1345  SockList_AddChar(&sl, 255); /* Termination byte */
1346  // Reduce dereferences by passing the inner array offset instead of address of value
1347  map_clearcell(plyr->socket.lastmap.cells[ax] + ay, 0, 0);
1348  }
1349  } else if (d >= MAX_LIGHT_RADII) {
1350  /* This block deals with spaces that are not
1351  * visible due to darkness or walls. Still
1352  * need to send the heads for this space.
1353  */
1354  check_space_for_heads(ax, ay, &sl, &plyr->socket);
1355  } else {
1356  int have_darkness = 0, has_obj = 0, got_one = 0, del_one = 0, g1, alive_layer = -1, old_got;
1357 
1358  /* In this block, the space is visible. */
1359 
1360  /* Rather than try to figure out what everything
1361  * that we might need to send is, then form the
1362  * packet after that, we presume that we will in
1363  * fact form a packet, and update the bits by what
1364  * we do actually send. If we send nothing, we
1365  * just back out sl.len to the old value, and no
1366  * harm is done.
1367  * I think this is simpler than doing a bunch of
1368  * checks to see what if anything we need to send,
1369  * setting the bits, then doing those checks again
1370  * to add the real data.
1371  */
1372 
1373  oldlen = sl.len;
1374  SockList_AddShort(&sl, coord);
1375 
1376  /* Darkness changed */
1377  if (plyr->socket.lastmap.cells[ax][ay].darkness != d
1378  && plyr->socket.darkness) {
1379  plyr->socket.lastmap.cells[ax][ay].darkness = d;
1380  /* Darkness tag & length*/
1382  SockList_AddChar(&sl, 255-d*(256/MAX_LIGHT_RADII));
1383  have_darkness = 1;
1384  }
1385 
1386  for (layer = 0; layer < MAP_LAYERS; layer++) {
1387  const object *ob = GET_MAP_FACE_OBJ(m, nx, ny, layer);
1388 
1389  /* Special case: send player itself if invisible */
1390  if (!ob
1391  && x == pl->x
1392  && y == pl->y
1393  && (pl->invisible&(pl->invisible < 50 ? 4 : 1))
1394  && (layer == MAP_LAYER_LIVING1 || layer == MAP_LAYER_LIVING2))
1395  ob = pl;
1396 
1397  if (ob) {
1398  g1 = has_obj;
1399  old_got = got_one;
1400  got_one += map2_add_ob(ax, ay, layer, ob, &sl, &plyr->socket, &has_obj, 0);
1401 
1402  /* if we added the face, or it is a monster's head, check probe spell */
1403  if (got_one != old_got || (ob->head == NULL && ob->more))
1404  got_one += check_probe(ax, ay, ob, &sl, &plyr->socket, &has_obj, &alive_layer);
1405 
1406  /* If we are just storing away the head
1407  * for future use, then effectively this
1408  * space/layer is blank, and we should clear
1409  * it if needed.
1410  */
1411  if (g1 == has_obj) {
1412  del_one += map2_delete_layer(ax, ay, layer, &sl, &plyr->socket);
1413  } else if (ob->head == NULL) {
1414  /* for single-part items */
1415  got_one += check_probe(ax, ay, ob, &sl, &plyr->socket, &has_obj, &alive_layer);
1416  }
1417  } else {
1418  if (layer != alive_layer)
1419  del_one += map2_delete_layer(ax, ay, layer, &sl, &plyr->socket);
1420  }
1421  }
1422  /* If nothing to do for this space, we
1423  * can erase the coordinate bytes
1424  */
1425  if (!del_one && !got_one && !have_darkness) {
1426  sl.len = oldlen;
1427  } else if (del_one && !has_obj) {
1428  /* If we're only deleting faces and don't
1429  * have any objs we care about, just clear
1430  * space. Note it is possible we may have
1431  * darkness, but if there is nothing on the
1432  * space, darkness isn't all that interesting
1433  * - we can send it when an object shows up.
1434  */
1435  sl.len = oldlen+2; /* 2 bytes for coordinate */
1437  SockList_AddChar(&sl, 255); /* Termination byte */
1438  // Reduce dereferences by passing the inner array offset instead of address of value
1439  map_clearcell(plyr->socket.lastmap.cells[ax] + ay, 0, 0);
1440  } else {
1441  SockList_AddChar(&sl, 255); /* Termination byte */
1442  }
1443  }
1444  } /* else this is a viewable space */
1445  } /* for x loop */
1446  } /* for y loop */
1447 
1448  /* Only send this if there are in fact some differences. */
1449  if (sl.len > startlen) {
1450  Send_With_Handling(&plyr->socket, &sl);
1451  }
1452  SockList_Term(&sl);
1453 }
1454 
1458 void draw_client_map(object *pl) {
1459  int i, j;
1460  int16_t ax, ay;
1461  int mflags;
1462  mapstruct *m, *pm;
1463  int min_x, min_y, max_x, max_y;
1464 
1465  if (pl->type != PLAYER) {
1466  LOG(llevError, "draw_client_map called with non player/non eric-server\n");
1467  return;
1468  }
1469 
1470  if (pl->contr->transport) {
1471  pm = pl->contr->transport->map;
1472  } else
1473  pm = pl->map;
1474 
1475  /* If player is just joining the game, he isn't here yet, so
1476  * the map can get swapped out. If so, don't try to send them
1477  * a map. All will be OK once they really log in.
1478  */
1479  if (pm == NULL || pm->in_memory != MAP_IN_MEMORY)
1480  return;
1481 
1482  /*
1483  * This block just makes sure all the spaces are properly
1484  * updated in terms of what they look like.
1485  */
1486  min_x = pl->x-pl->contr->socket.mapx/2;
1487  min_y = pl->y-pl->contr->socket.mapy/2;
1488  max_x = pl->x+(pl->contr->socket.mapx+1)/2;
1489  max_y = pl->y+(pl->contr->socket.mapy+1)/2;
1490  for (j = min_y; j < max_y; j++) {
1491  for (i = min_x; i < max_x; i++) {
1492  ax = i;
1493  ay = j;
1494  m = pm;
1495  mflags = get_map_flags(m, &m, ax, ay, &ax, &ay);
1496  if (mflags&P_OUT_OF_MAP)
1497  continue;
1498  if (mflags&P_NEED_UPDATE)
1499  update_position(m, ax, ay);
1500  /* If a map is visible to the player, we don't want
1501  * to swap it out just to reload it. This should
1502  * really call something like swap_map, but this is
1503  * much more efficient and 'good enough'
1504  */
1505  if (mflags&P_NEW_MAP)
1506  m->timeout = 50;
1507  }
1508  }
1509 
1510  /* do LOS after calls to update_position */
1511  if (pl->contr->do_los) {
1512  update_los(pl);
1513  pl->contr->do_los = 0;
1514  }
1515 
1516  draw_client_map2(pl);
1517 }
1518 
1519 void esrv_map_scroll(socket_struct *ns, int dx, int dy) {
1520  struct Map newmap;
1521  int x, y, mx, my;
1522 
1523  ns->map_scroll_x += dx;
1524  ns->map_scroll_y += dy;
1525 
1526  mx = ns->mapx+MAX_HEAD_OFFSET;
1527  my = ns->mapy+MAX_HEAD_OFFSET;
1528 
1529  /* the x and y here are coordinates for the new map, i.e. if we moved
1530  * (dx,dy), newmap[x][y] = oldmap[x-dx][y-dy]. For this reason,
1531  * if the destination x or y coordinate is outside the viewable
1532  * area, we clear the values - otherwise, the old values
1533  * are preserved, and the check_head thinks it needs to clear them.
1534  */
1535  for (x = 0; x < mx; x++) {
1536  for (y = 0; y < my; y++) {
1537  if (x >= ns->mapx || y >= ns->mapy) {
1538  /* clear cells outside the viewable area */
1539  memset(&newmap.cells[x][y], 0, sizeof(newmap.cells[x][y]));
1540  } else if (x+dx < 0 || x+dx >= ns->mapx || y+dy < 0 || y+dy >= ns->mapy) {
1541  /* clear newly visible tiles within the viewable area */
1542  memset(&newmap.cells[x][y], 0, sizeof(newmap.cells[x][y]));
1543  } else {
1544  memcpy(&newmap.cells[x][y], &ns->lastmap.cells[x+dx][y+dy], sizeof(newmap.cells[x][y]));
1545  }
1546  }
1547  }
1548 
1549  memcpy(&ns->lastmap, &newmap, sizeof(ns->lastmap));
1550 }
1551 
1557 void send_plugin_custom_message(object *pl, char *buf) {
1558  SockList sl;
1559 
1560  SockList_Init(&sl);
1561  SockList_AddString(&sl, buf);
1562  Send_With_Handling(&pl->contr->socket, &sl);
1563  SockList_Term(&sl);
1564 }
1565 
1572  SockList sl;
1573  int flags = 0;
1574  client_spell *spell_info;
1575 
1576  if (!pl->socket.monitor_spells)
1577  return;
1578 
1579  /* Handles problem at login, where this is called from fix_object
1580  * before we have had a chance to send spells to the player. It does seem
1581  * to me that there should never be a case where update_spells is called
1582  * before add_spells has been called. Add_spells() will update the
1583  * spell_state to non null.
1584  */
1585  if (!pl->spell_state)
1586  return;
1587 
1588  FOR_INV_PREPARE(pl->ob, spell) {
1589  if (spell->type == SPELL) {
1590  spell_info = get_client_spell_state(pl, spell);
1591  /* check if we need to update it*/
1592  if (spell_info->last_sp != SP_level_spellpoint_cost(pl->ob, spell, SPELL_MANA)) {
1593  spell_info->last_sp = SP_level_spellpoint_cost(pl->ob, spell, SPELL_MANA);
1594  flags |= UPD_SP_MANA;
1595  }
1596  if (spell_info->last_grace != SP_level_spellpoint_cost(pl->ob, spell, SPELL_GRACE)) {
1597  spell_info->last_grace = SP_level_spellpoint_cost(pl->ob, spell, SPELL_GRACE);
1598  flags |= UPD_SP_GRACE;
1599  }
1600  if (spell_info->last_dam != spell->stats.dam+SP_level_dam_adjust(pl->ob, spell)) {
1601  spell_info->last_dam = spell->stats.dam+SP_level_dam_adjust(pl->ob, spell);
1602  flags |= UPD_SP_DAMAGE;
1603  }
1604  if (flags != 0) {
1605  SockList_Init(&sl);
1606  SockList_AddString(&sl, "updspell ");
1607  SockList_AddChar(&sl, flags);
1608  SockList_AddInt(&sl, spell->count);
1609  if (flags&UPD_SP_MANA)
1610  SockList_AddShort(&sl, spell_info->last_sp);
1611  if (flags&UPD_SP_GRACE)
1612  SockList_AddShort(&sl, spell_info->last_grace);
1613  if (flags&UPD_SP_DAMAGE)
1614  SockList_AddShort(&sl, spell_info->last_dam);
1615  flags = 0;
1616  Send_With_Handling(&pl->socket, &sl);
1617  SockList_Term(&sl);
1618  }
1619  }
1620  } FOR_INV_FINISH();
1621 }
1622 
1623 void esrv_remove_spell(player *pl, object *spell) {
1624  SockList sl;
1625 
1626  if (!pl || !spell || spell->env != pl->ob) {
1627  LOG(llevError, "Invalid call to esrv_remove_spell\n");
1628  return;
1629  }
1630  if (!pl->socket.monitor_spells)
1631  return;
1632 
1633  SockList_Init(&sl);
1634  SockList_AddString(&sl, "delspell ");
1635  SockList_AddInt(&sl, spell->count);
1636  Send_With_Handling(&pl->socket, &sl);
1637  SockList_Term(&sl);
1638 }
1639 
1647  SockList sl;
1648 
1649  if (!pl->socket.want_pickup)
1650  return;
1651  SockList_Init(&sl);
1652  SockList_AddString(&sl, "pickup ");
1653  SockList_AddInt(&sl, pl->mode);
1654  Send_With_Handling(&pl->socket, &sl);
1655  SockList_Term(&sl);
1656 }
1657 
1666 static int spell_client_use(const object *spell) {
1667  switch (spell->type)
1668  {
1669  case SP_RAISE_DEAD:
1670  case SP_MAKE_MARK:
1671  return 3;
1672  case SP_RUNE:
1673  if (!spell->other_arch)
1674  return 1;
1675  break;
1676  case SP_CREATE_FOOD:
1677  case SP_CREATE_MISSILE:
1678  return 2;
1679  case SP_SUMMON_MONSTER:
1680  if (spell->randomitems != NULL)
1681  return 2;
1682  /* break; */// If add conditins below, use this break statement
1683  }
1684  // This is not in the switch statement so that it supports fallthrough logic
1685  // on the few spell types that have additional conditions attached.
1686  return 0;
1687 }
1688 
1690 static void append_spell(player *pl, SockList *sl, object *spell) {
1691  client_spell *spell_info;
1692  int len, i, skill = 0;
1693 
1694  if (!spell->name) {
1695  LOG(llevError, "item number %d is a spell with no name.\n", spell->count);
1696  return;
1697  }
1698 
1699  if (spell->face && !(pl->socket.faces_sent[spell->face->number]&NS_FACESENT_FACE))
1700  esrv_send_face(&pl->socket, spell->face->number, 0);
1701 
1702  spell_info = get_client_spell_state(pl, spell);
1703  SockList_AddInt(sl, spell->count);
1704  SockList_AddShort(sl, spell->level);
1705  SockList_AddShort(sl, spell->casting_time);
1706  /* store costs and damage in the object struct, to compare to later */
1707  spell_info->last_sp = SP_level_spellpoint_cost(pl->ob, spell, SPELL_MANA);
1708  spell_info->last_grace = SP_level_spellpoint_cost(pl->ob, spell, SPELL_GRACE);
1709  spell_info->last_dam = spell->stats.dam+SP_level_dam_adjust(pl->ob, spell);
1710  /* send the current values */
1711  SockList_AddShort(sl, spell_info->last_sp);
1712  SockList_AddShort(sl, spell_info->last_grace);
1713  SockList_AddShort(sl, spell_info->last_dam);
1714 
1715  /* figure out which skill it uses, if it uses one */
1716  if (spell->skill) {
1717  for (i = 1; i < NUM_SKILLS; i++)
1718  if (!strcmp(spell->skill, skill_names[i])) {
1719  skill = i+CS_STAT_SKILLINFO;
1720  break;
1721  }
1722  }
1723  SockList_AddChar(sl, skill);
1724 
1725  SockList_AddInt(sl, spell->path_attuned);
1726  SockList_AddInt(sl, spell->face ? spell->face->number : 0);
1727  SockList_AddLen8Data(sl, spell->name, strlen(spell->name));
1728 
1729  if (!spell->msg) {
1730  SockList_AddShort(sl, 0);
1731  } else {
1732  len = strlen(spell->msg);
1733  SockList_AddShort(sl, len);
1734  SockList_AddData(sl, spell->msg, len);
1735  }
1736 
1737  /* Extended spell information available if the client wants it.
1738  */
1739  if (pl->socket.monitor_spells >= 2) {
1740  /* spellmon 2
1741  */
1742  sstring req = object_get_value(spell, "casting_requirements");
1743 
1744  SockList_AddChar(sl, spell_client_use(spell)); /* Usage code */
1745 
1746  if (req) { /* Requirements */
1747  SockList_AddLen8Data(sl, req, strlen(req));
1748  } else {
1749  SockList_AddChar(sl, 0);
1750  }
1751  /* end spellmon 2
1752  */
1753  }
1754 }
1755 
1760 void esrv_add_spells(player *pl, object *spell) {
1761  SockList sl;
1762  size_t size;
1763  sstring value;
1764 
1765  if (!pl) {
1766  LOG(llevError, "esrv_add_spells, tried to add a spell to a NULL player\n");
1767  return;
1768  }
1769 
1770  if (!pl->socket.monitor_spells)
1771  return;
1772 
1773  SockList_Init(&sl);
1774  SockList_AddString(&sl, "addspell ");
1775  if (!spell) {
1776  FOR_INV_PREPARE(pl->ob, spell) {
1777  if (spell->type != SPELL)
1778  continue;
1779  /* Were we to simply keep appending data here, we could
1780  * exceed the SockList buffer if the player has enough spells
1781  * to add. We know that append_spell will always append
1782  * 23 data bytes, plus 3 length bytes and 2 strings
1783  * (because that is the spec) so we need to check that
1784  * the length of those 2 strings, plus the 26 bytes,
1785  * won't take us over the length limit for the socket.
1786  * If it does, we need to send what we already have,
1787  * and restart packet formation.
1788  */
1789  size = 26+strlen(spell->name)+(spell->msg ? strlen(spell->msg) : 0);
1790  if (pl->socket.monitor_spells >= 2) {
1792  value = object_get_value(spell, "casting_requirements");
1793  size += 2 + (value ? strlen(value) : 0);
1794  }
1795  if (SockList_Avail(&sl) < size) {
1796  Send_With_Handling(&pl->socket, &sl);
1797  SockList_Reset(&sl);
1798  SockList_AddString(&sl, "addspell ");
1799  }
1800  append_spell(pl, &sl, spell);
1801  } FOR_INV_FINISH();
1802  } else if (spell->type != SPELL) {
1803  LOG(llevError, "Asked to send a non-spell object as a spell\n");
1804  return;
1805  } else
1806  append_spell(pl, &sl, spell);
1807  /* finally, we can send the packet */
1808  Send_With_Handling(&pl->socket, &sl);
1809  SockList_Term(&sl);
1810 }
1811 
1812 /* sends a 'tick' information to the client.
1813  * We also take the opportunity to toggle TCP_NODELAY -
1814  * this forces the data in the socket to be flushed sooner to the
1815  * client - otherwise, the OS tries to wait for full packets
1816  * and will this hold sending the data for some amount of time,
1817  * which thus adds some additional latency.
1818  */
1820  SockList sl;
1821  int tmp;
1822 
1823  SockList_Init(&sl);
1824  SockList_AddString(&sl, "tick ");
1825  SockList_AddInt(&sl, pticks);
1826  tmp = 1;
1827  if (setsockopt(pl->socket.fd, IPPROTO_TCP, TCP_NODELAY, &tmp, sizeof(tmp)))
1828  LOG(llevError, "send_tick: Unable to turn on TCP_NODELAY\n");
1829 
1830  Send_With_Handling(&pl->socket, &sl);
1831  tmp = 0;
1832  if (setsockopt(pl->socket.fd, IPPROTO_TCP, TCP_NODELAY, &tmp, sizeof(tmp)))
1833  LOG(llevError, "send_tick: Unable to turn off TCP_NODELAY\n");
1834  SockList_Term(&sl);
1835 }
1836 
1849 static void add_char_field(SockList *sl, int type, const char *data)
1850 {
1851  int len;
1852 
1853  len = strlen(data);
1854 
1855  if (len) {
1856  /* one extra for length for the type byte */
1857  SockList_AddChar(sl, len+1);
1858  SockList_AddChar(sl, type);
1859  SockList_AddString(sl, data);
1860  }
1861 }
1862 
1884 {
1885  SockList sl;
1886  Account_Char *acn;
1887  int i, num_chars, need_send[MAX_CHARACTERS_PER_ACCOUNT];
1888  char **chars;
1889 
1891 
1892  /*
1893  * The acocunt logic here is a little tricky - account_char_load()
1894  * is best source as it has a lot more data. However, if a user
1895  * has just added an player to an account, that will not be filled
1896  * in until the player has actually logged in with that character -
1897  * to fill the data in at time of adding the character to the account
1898  * requires a fair amount of work to check_login(), since the load
1899  * of the player file and other initialization is fairly closely
1900  * intertwined. So until that is done, we still at least have
1901  * account names we can get and send.
1902  * note: chars[] has the last entry NULL terminated - thus,
1903  * if there are 2 valid accounts, chars[0], chars[1] will be
1904  * set, and chars[2] will be NULL. chars[3...MAX] will have
1905  * undefined values.
1906  */
1908 
1909  SockList_Init(&sl);
1910  SockList_AddString(&sl, "accountplayers ");
1911  num_chars=0;
1912 
1913  /* First, set up an array so we know which character we may
1914  * need to send specially. Only non NULL values would
1915  * ever need to get sent.
1916  */
1917  for (i=0; i<MAX_CHARACTERS_PER_ACCOUNT; i++) {
1918  if (chars[i])
1919  need_send[i] = 1;
1920  else break;
1921  }
1922  /* This counts up the number of characters.
1923  * But also, we look and see if the character exists
1924  * in chars[i] - if so, we set need_send[i] to 0.
1925  */
1926  for (acn = ns->account_chars; acn; acn = acn->next) {
1927  num_chars++;
1928  for (i=0; i<MAX_CHARACTERS_PER_ACCOUNT; i++) {
1929  /* If this is NULL, we know there will not be
1930  * any more entries - so break out.
1931  */
1932  if (!chars[i]) break;
1933 
1934  if (!strcmp(chars[i], acn->name)) {
1935  need_send[i] = 0;
1936  break;
1937  }
1938  }
1939  }
1940 
1941  /* total up number with limited information */
1942  for (i=0; i< MAX_CHARACTERS_PER_ACCOUNT; i++) {
1943  if (!chars[i]) break;
1944 
1945  if (need_send[i])
1946  num_chars++;
1947  }
1948 
1949  SockList_AddChar(&sl, num_chars);
1950 
1951  /* Now add real character data */
1952  for (acn = ns->account_chars; acn; acn = acn->next) {
1953  uint16_t faceno;
1954 
1955  /* Ignore a dead character. They don't need to show up. */
1956  if (acn->isDead) {
1957  continue;
1958  }
1959 
1960  add_char_field(&sl, ACL_NAME, acn->name);
1962  add_char_field(&sl, ACL_RACE, acn->race);
1963  add_char_field(&sl, ACL_FACE, acn->face);
1964  if (acn->face[0] != 0 ) {
1965  faceno = find_face(acn->face, 0);
1966 
1967  if (faceno != 0) {
1968  if (!(ns->faces_sent[faceno]&NS_FACESENT_FACE)) {
1969  esrv_send_face(ns, faceno, 0);
1970  }
1971  }
1972  } else
1973  faceno=0;
1974 
1975  add_char_field(&sl, ACL_PARTY, acn->party);
1976  add_char_field(&sl, ACL_MAP, acn->map);
1977  SockList_AddChar(&sl, 3);
1979  SockList_AddShort(&sl, acn->level);
1980  if (faceno) {
1981  SockList_AddChar(&sl, 3);
1983  SockList_AddShort(&sl, faceno);
1984  }
1985 
1986  SockList_AddChar(&sl, 0);
1987  }
1988  /* Now for any characters where we just have the name */
1989  for (i=0; i< MAX_CHARACTERS_PER_ACCOUNT; i++) {
1990  if (!chars[i]) break;
1991 
1992  if (need_send[i]) {
1993  add_char_field(&sl, ACL_NAME, chars[i]);
1994  SockList_AddChar(&sl, 0);
1995  }
1996  }
1997 
1998  Send_With_Handling(ns, &sl);
1999  SockList_Term(&sl);
2000 }
2001 
2023 static int decode_name_password(const char *buf, int *len, char *name, char *password)
2024 {
2025  int nlen, plen;
2026 
2027  if (*len < 2) {
2028  return 1;
2029  }
2030 
2031  nlen = (unsigned char)buf[0];
2032  if (nlen >= MAX_BUF || nlen > *len-2) {
2033  return 1;
2034  }
2035  memcpy(name, buf+1, nlen);
2036  name[nlen] = 0;
2037 
2038  plen = (unsigned char)buf[nlen+1];
2039  if (plen >= MAX_BUF || plen > *len-2-nlen) {
2040  return 2;
2041  }
2042  memcpy(password, buf+2+nlen, plen);
2043  password[plen] = 0;
2044 
2045  *len = nlen+plen+2;
2046 
2047  return 0;
2048 }
2059 void account_login_cmd(char *buf, int len, socket_struct *ns) {
2060  char name[MAX_BUF], password[MAX_BUF];
2061  int status;
2062  SockList sl;
2063 
2064  if (len <= 0 || !buf) {
2065  LOG(llevDebug, "IP '%s' sent bogus add_player_cmd information\n", ns->host);
2066  return;
2067  }
2068 
2069  SockList_Init(&sl);
2070 
2071  status = decode_name_password(buf, &len, name, password);
2072 
2073  if (status == 1) {
2074  SockList_AddString(&sl, "failure accountlogin Name is too long");
2075  Send_With_Handling(ns, &sl);
2076  SockList_Term(&sl);
2077  return;
2078  }
2079  if (status == 2) {
2080  SockList_AddString(&sl, "failure accountlogin Password is too long");
2081  Send_With_Handling(ns, &sl);
2082  SockList_Term(&sl);
2083  return;
2084  }
2085 
2086  if (!account_exists(name)) {
2087  SockList_AddString(&sl, "failure accountlogin No such account name exists on this server");
2088  Send_With_Handling(ns, &sl);
2089  SockList_Term(&sl);
2090  return;
2091  }
2092 
2093  if (account_login(name, password)) {
2094  player *pl;
2095  socket_struct *tns;
2096 
2097  /* Checking against init_sockets must be done before
2098  * we set ns->account - otherwise we will match
2099  * that. What we are doing here is limiting the account
2100  * to only one login.
2101  */
2103  /* Other code will clean this up. We could try to
2104  * set the same state this other socket is in, but we
2105  * really don't know what that state is, and then
2106  * we would have to try to communicate that to the client
2107  * so it can activate the right dialogs. Simpler to
2108  * just go to a known state.
2109  */
2110  if (tns && tns != ns)
2111  tns->status = Ns_Dead;
2112 
2113  /* Same note as above applies - it can be simpler in
2114  * this case - we could check against the ST_PLAYING
2115  * value, but right now we don't have a method to
2116  * tell the client to go directly from login to playing.
2117  */
2118  pl = account_get_logged_in_player(name);
2119  if (pl)
2120  pl->socket.status = Ns_Dead;
2121 
2122 
2123  if (ns->account_name) free(ns->account_name);
2124  /* We want to store away official name so we do not
2125  * have any case sensitivity issues on the files.
2126  * because we have already checked password, we
2127  * know that account_exists should never return NULL in
2128  * this case.
2129  */
2131 
2133 
2134  } else {
2135  SockList_AddString(&sl, "failure accountlogin Incorrect password for account");
2136  Send_With_Handling(ns, &sl);
2137  SockList_Term(&sl);
2138  }
2139 }
2140 
2149 static int account_block_create(const socket_struct *ns) {
2150  /* Check if account creation is blocked. */
2152  /* Account creation is allowed for everyone. */
2153  return 0;
2154  }
2155 
2156  /* Has the trusted host been defined? */
2157  if(settings.account_trusted_host == NULL) {
2158  /* No, allocate it and set it to localhost now. */
2160  }
2161 
2162  /* Return false if the client connected from the trusted host. */
2163  if(strcmp(ns->host, settings.account_trusted_host) == 0){
2164  return 0;
2165  }
2166 
2167  /*
2168  * If we are here, then we are blocking account create and we do
2169  * not trust this client's IP address.
2170  */
2171  return 1;
2172 }
2173 
2185 void account_new_cmd(char *buf, int len, socket_struct *ns) {
2186  char name[MAX_BUF], password[MAX_BUF];
2187  int status;
2188  SockList sl;
2189 
2190  if (len <= 0 || !buf) {
2191  LOG(llevDebug, "IP '%s' sent bogus add_player_cmd information\n", ns->host);
2192  return;
2193  }
2194 
2195  SockList_Init(&sl);
2196 
2197  status = decode_name_password(buf, &len, name, password);
2198 
2199  if (account_block_create(ns)) {
2200  LOG(llevInfo, "Account create blocked from %s\n", ns->host);
2201  SockList_AddString(&sl, "failure accountnew Account creation is disabled");
2202  Send_With_Handling(ns, &sl);
2203  SockList_Term(&sl);
2204  return;
2205  }
2206 
2207  if (status == 1) {
2208  SockList_AddString(&sl, "failure accountnew Name is too long");
2209  Send_With_Handling(ns, &sl);
2210  SockList_Term(&sl);
2211  return;
2212  }
2213  if (status == 2) {
2214  SockList_AddString(&sl, "failure accountnew Password is too long");
2215  Send_With_Handling(ns, &sl);
2216  SockList_Term(&sl);
2217  return;
2218  }
2219  /*The minimum length isn't exactly required, but in the current implementation,
2220  * client will send the same password for character for which there is a
2221  * 2 character minimum size. Thus an account with a one character password
2222  * won't be able to create a character. */
2223  if (strlen(password)<2) {
2224  SockList_AddString(&sl, "failure accountnew Password is too short");
2225  Send_With_Handling(ns, &sl);
2226  SockList_Term(&sl);
2227  return;
2228  }
2229 
2230  if (account_exists(name)) {
2231  SockList_AddString(&sl, "failure accountnew That account already exists on this server");
2232  Send_With_Handling(ns, &sl);
2233  SockList_Term(&sl);
2234  return;
2235  }
2236 
2237  status = account_check_string(name);
2238  if (status == 1) {
2239  SockList_AddString(&sl,
2240  "failure accountnew That account name contains invalid characters.");
2241  Send_With_Handling(ns, &sl);
2242  SockList_Term(&sl);
2243  return;
2244  }
2245 
2246  if (status == 2) {
2247  SockList_AddString(&sl,
2248  "failure accountnew That account name is too long");
2249  Send_With_Handling(ns, &sl);
2250  SockList_Term(&sl);
2251  return;
2252  }
2253 
2254  status = account_check_string(password);
2255  if (status == 1) {
2256  SockList_AddString(&sl,
2257  "failure accountnew That password contains invalid characters.");
2258  Send_With_Handling(ns, &sl);
2259  SockList_Term(&sl);
2260  return;
2261  }
2262 
2263  if (status == 2) {
2264  SockList_AddString(&sl,
2265  "failure accountnew That password is too long");
2266  Send_With_Handling(ns, &sl);
2267  SockList_Term(&sl);
2268  return;
2269  }
2270 
2271  /* If we got here, we passed all checks - so now add it */
2272  if (ns->account_name) free(ns->account_name);
2273  ns->account_name = strdup_local(name);
2274  account_new(name, password);
2275  /* save account information */
2276  accounts_save();
2278 }
2279 
2293 void account_add_player_cmd(char *buf, int len, socket_struct *ns) {
2294  char name[MAX_BUF], password[MAX_BUF];
2295  int status, force, nlen;
2296  SockList sl;
2297  const char *cp;
2298 
2299  if (len <= 0 || !buf) {
2300  LOG(llevDebug, "IP '%s' sent bogus add_player_cmd information\n", ns->host);
2301  return;
2302  }
2303 
2304  SockList_Init(&sl);
2305 
2306  if (ns->account_name == NULL) {
2307  SockList_AddString(&sl, "failure accountaddplayer Not logged in");
2308  Send_With_Handling(ns, &sl);
2309  SockList_Term(&sl);
2310  return;
2311  }
2312 
2313  force = buf[0];
2314  nlen = len - 1;
2315  status = decode_name_password(buf+1, &nlen, name, password);
2316  if (status == 1) {
2317  SockList_AddString(&sl, "failure accountaddplayer Name is too long");
2318  Send_With_Handling(ns, &sl);
2319  SockList_Term(&sl);
2320  return;
2321  }
2322  if (status == 2) {
2323  SockList_AddString(&sl, "failure accountaddplayer Password is too long");
2324  Send_With_Handling(ns, &sl);
2325  SockList_Term(&sl);
2326  return;
2327  }
2328 
2329  status = verify_player(name, password);
2330  if (status) {
2331  /* From a security standpoint, telling random folks if it
2332  * it as wrong password makes it easier to hack. However,
2333  * it is fairly easy to determine what characters exist on a server
2334  * (either by trying to create a new one and see if the name is in
2335  * in use, or just looking at the high score file), so this
2336  * really does not make things much less secure
2337  */
2338  if (status == 1)
2339  SockList_AddString(&sl, "failure accountaddplayer 0 The character does not exist.");
2340  else
2341  SockList_AddString(&sl, "failure accountaddplayer 0 That password is incorrect.");
2342 
2343  Send_With_Handling(ns, &sl);
2344  SockList_Term(&sl);
2345  return;
2346  }
2347  /* Check to see if this character is associated with an account.
2348  */
2349  cp = account_get_account_for_char(name);
2350  if (cp) {
2351  if (!strcmp(cp, ns->account_name)) {
2352  SockList_AddString(&sl, "failure accountaddplayer 0 That character is already connected to this account.");
2353  Send_With_Handling(ns, &sl);
2354  SockList_Term(&sl);
2355  return;
2356  } else {
2357  if (!force) {
2358  SockList_AddString(&sl, "failure accountaddplayer 1 That character is already connected to a different account.");
2359  Send_With_Handling(ns, &sl);
2360  SockList_Term(&sl);
2361  return;
2362  } else if (account_is_logged_in(cp)) {
2363  /* We could be clever and try to handle this case, but it is
2364  * trickier. If the character is logged in, it has to
2365  * be logged out. And the socket holds some data which
2366  * needs to be cleaned up. Since it should be fairly
2367  * uncommon that users need to do this, just disallowing
2368  * it makes things a lot simpler.
2369  */
2370  SockList_AddString(&sl, "failure accountaddplayer 0 That character is already connected to a different account which is currently logged in.");
2371  Send_With_Handling(ns, &sl);
2372  SockList_Term(&sl);
2373  return;
2374  }
2375  }
2376  }
2377  /* If we have gotten this far, the name/password provided is OK,
2378  * and the character is not associated with a different account (or
2379  * force is true). Now try to add the character to this account.
2380  */
2381  status = account_link(ns->account_name, name);
2382 
2383  /* This should never happen, but check for it just in case -
2384  * if we were able to log in, the account should exist. but
2385  * if this fails, need to give the user some clue.
2386  */
2387  if (status==1) {
2388  SockList_AddString(&sl, "failure accountaddplayer 0 Could not find your account.");
2389  Send_With_Handling(ns, &sl);
2390  SockList_Term(&sl);
2391  return;
2392  } else if (status == 2) {
2393  SockList_AddString(&sl, "failure accountaddplayer 0 You have reached the maximum number of characters allowed per account.");
2394  Send_With_Handling(ns, &sl);
2395  SockList_Term(&sl);
2396  return;
2397  }
2398 
2399  /* If cp is set, then this character used to belong to a different
2400  * account. Remove it now.
2401  */
2402  if (cp) {
2403  Account_Char *chars;
2404 
2405  account_remove_player(cp, name);
2406  chars = account_char_load(cp);
2407  chars=account_char_remove(chars, name);
2408  account_char_save(cp, chars);
2409  account_char_free(chars);
2410  }
2411 
2413 
2414  /* store data so nothing is lost in case of crash */
2416 }
2417 
2422 void account_play_cmd(char *buf, int len, socket_struct *ns)
2423 {
2424  char **chars;
2425  int i;
2426  SockList sl;
2427  player *pl;
2428 
2429  if (len <= 0 || !buf) {
2430  LOG(llevDebug, "IP '%s' sent bogus account_play_cmd information\n", ns->host);
2431  return;
2432  }
2433 
2434  SockList_Init(&sl);
2435 
2436  if (!buf[0]) {
2437  SockList_AddString(&sl, "failure accountplay Malformed character name");
2438  Send_With_Handling(ns, &sl);
2439  SockList_Term(&sl);
2440  return;
2441  }
2442 
2443  if (ns->account_name == NULL) {
2444  SockList_AddString(&sl, "failure accountplay Not logged in");
2445  Send_With_Handling(ns, &sl);
2446  SockList_Term(&sl);
2447  return;
2448  }
2449 
2451 
2452  for (i=0; i<MAX_CHARACTERS_PER_ACCOUNT; i++) {
2453  if (!chars[i] || !strcmp(chars[i], buf)) break;
2454  }
2455  /* Make sure a client is not trying to spoof us here */
2456  if (i == MAX_CHARACTERS_PER_ACCOUNT || !chars[i]) {
2457  SockList_AddPrintf(&sl,
2458  "failure accountplay Character %s is not associated with account %s",
2459  buf, ns->account_name);
2460  Send_With_Handling(ns, &sl);
2461  SockList_Term(&sl);
2462  return;
2463  }
2464 
2465  /* from a protocol standpoint, accountplay can be used
2466  * before there is a player structure (first login) or after
2467  * (character has logged in and is changing characters).
2468  * Checkthe sockets for that second case - if so,
2469  * we don't need to make a new player object, etc.
2470  */
2471  for (pl=first_player; pl; pl=pl->next) {
2472  if (&pl->socket == ns) {
2473  /* The player still in the socket must be saved first. */
2474  save_player(pl->ob, 0);
2475  break;
2476  }
2477  }
2478 
2479  /* Some of this logic is from add_player()
2480  * we just don't use add_player() as it does some other work
2481  * we don't really want to do.
2482  */
2483  if (!pl) {
2484  pl = get_player(NULL);
2485  memcpy(&pl->socket, ns, sizeof(socket_struct));
2486  ns->faces_sent = NULL;
2488  } else {
2489  pl->state = ST_PLAYING;
2490  }
2491 
2492  pl->ob->name = add_string(buf);
2493  check_login(pl->ob, 0);
2494 
2495  SockList_AddString(&sl, "addme_success");
2496  Send_With_Handling(ns, &sl);
2497  SockList_Term(&sl);
2498 
2499  ns->status = Ns_Avail;
2500 }
2501 
2502 #define MAX_CHOICES 100
2503 
2509 void create_player_cmd(char *buf, int len, socket_struct *ns)
2510 {
2511  char name[MAX_BUF], password[MAX_BUF], *choices[MAX_CHOICES];
2512  int status, nlen, choice_num=0, i;
2513  SockList sl;
2514  player *pl;
2515  archetype *map=NULL, *race_a=NULL, *class_a=NULL;
2516  living new_stats;
2517 
2518  if (len <= 0 || !buf) {
2519  LOG(llevDebug, "IP '%s' sent bogus create_player_cmd information\n", ns->host);
2520  return;
2521  }
2522 
2523  SockList_Init(&sl);
2524 
2525  nlen = len;
2526  status = decode_name_password(buf, &nlen, name, password);
2527  if (status == 1) {
2528  SockList_AddString(&sl, "failure createplayer Name is too long");
2529  Send_With_Handling(ns, &sl);
2530  SockList_Term(&sl);
2531  return;
2532  }
2533 
2534  /* 2 characters minimum for password */
2535  if (strlen(password)<2) {
2536  SockList_AddString(&sl, "failure createplayer Password is too short");
2537  Send_With_Handling(ns, &sl);
2538  SockList_Term(&sl);
2539  return;
2540  }
2541 
2543  if (status == 2) {
2544  SockList_AddString(&sl, "failure createplayer Password is too long");
2545  Send_With_Handling(ns, &sl);
2546  SockList_Term(&sl);
2547  return;
2548  }
2549 
2550  /* This is a fairly ugly solution - we're truncating the password.
2551  * however, the password information for characters is really
2552  * a legacy issue - when every character is associated with
2553  * an account, legacy login (character name/password) will get
2554  * removed, at which point the only use for password might be
2555  * to move characters from one account to another, but not sure
2556  * if that is something we want to allow.
2557  */
2558  if (strlen(password)>17)
2559  password[16] = 0;
2560 
2561  /* We just can't call check_name(), since that uses draw_info() to
2562  * report status. We are also more permissive on names, so we use
2563  * account_check_string() - if that is safe for account, also safe
2564  * for player names.
2565  */
2566  if (account_check_string(name)) {
2567  SockList_AddString(&sl, "failure createplayer The name contains illegal characters");
2568  Send_With_Handling(ns, &sl);
2569  SockList_Term(&sl);
2570  return;
2571  }
2572 
2573  /* 1 means no such player, 0 is correct name/password (which in this
2574  * case, is an error), and 2 is incorrect password. Only way we
2575  * go onward is if there is no such player.
2576  */
2577  if (verify_player(name, password) != 1) {
2578  SockList_AddString(&sl, "failure createplayer That name is already in use");
2579  Send_With_Handling(ns, &sl);
2580  SockList_Term(&sl);
2581  return;
2582  }
2583 
2584  /* from a protocol standpoint, accountplay can be used
2585  * before there is a player structure (first login) or after
2586  * (character has logged in and is changing characters).
2587  * Check the sockets for that second case - if so,
2588  * we don't need to make a new player object, etc.
2589  */
2590  for (pl=first_player; pl; pl=pl->next)
2591  if (&pl->socket == ns) {
2592  if (pl->ob->name && !strcmp(pl->ob->name, name)) {
2593  /* For some reason not only the socket is the same but also
2594  * the player is already playing. If this happens at this
2595  * point let's assume the character never was able to apply
2596  * a bet of reality to make a correct first-time save.
2597  * So, for safety remove it and start over.
2598  */
2599  if (!QUERY_FLAG(pl->ob, FLAG_REMOVED))
2600  object_remove(pl->ob);
2601  }
2602  break;
2603  }
2604 
2605  /* In this mode, we have additional data
2606  * Note that because there are a lot of failure cases in here
2607  * (where we end up not creating the new player), the code
2608  * to create the new player is done within this routine
2609  * after all checks pass. Note that all of the checks
2610  * done are done without using the player structure,
2611  * as pl may be null right now.
2612  */
2613  if (ns->login_method >= 2) {
2614  int i, j, stat_total=0;
2615  char *key, *value, *race=NULL, *class=NULL;
2616 
2617  /* By setting this to zero, then we can easily
2618  * check to see if all stats have been set.
2619  */
2620  memset(&new_stats, 0, sizeof(living));
2621 
2622  while (nlen < len) {
2623  i = buf[nlen]; /* Length of this line */
2624  /* Sanity check from client - don't want to loop
2625  * forever if there is a 0 length, and don't
2626  * want to read beyond size of packet.
2627  * Likewise, client should have sent
2628  * the string to us already null terminated,
2629  * but we will just make sure.
2630  */
2631  if ((i == 0) || (nlen + i > len)) break;
2632  buf[nlen + i] = 0;
2633 
2634  /* What we have are a series of lines -
2635  * 'key value' format. Find that space,
2636  * and null it out so we can do strcasecmp.
2637  * If no space, abort processing
2638  */
2639  key = buf + nlen + 1;
2640  value = strchr(key, ' ');
2641  if (!value) break;
2642  *value = 0;
2643  value++;
2644 
2645  if (!strcasecmp(key,"race")) race = value;
2646  else if (!strcasecmp(key,"class")) class = value;
2647  else if (!strcasecmp(key,"starting_map")) {
2648  map = try_find_archetype(value);
2649  if (!map || map->clone.type != MAP || map->clone.subtype !=MAP_TYPE_CHOICE) {
2650  SockList_AddString(&sl,
2651  "failure createplayer Invalid or map");
2652  Send_With_Handling(ns, &sl);
2653  SockList_Term(&sl);
2654  return;
2655  }
2656  }
2657  else if (!strcasecmp(key,"choice")) {
2658  /* In general, MAX_CHOICES should be large enough
2659  * to always handle the choices from the client - of
2660  * course, the client could be broken and send us many
2661  * more choices than we should have, so handle that.
2662  */
2663  if (choice_num == MAX_CHOICES) {
2664  LOG(llevError,
2665  "Number of choices receive exceed max value: %d>%d\n",
2666  choice_num, MAX_CHOICES);
2667  } else {
2668  choices[choice_num] = value;
2669  choice_num++;
2670  }
2671  }
2672  else {
2673  /* Do stat processing here */
2674  for (j=0; j < NUM_STATS; j++) {
2675  if (!strcasecmp(key,short_stat_name[j])) {
2676  int val = atoi(value);
2677 
2678  set_attr_value(&new_stats, j, val);
2679  break;
2680  }
2681  }
2682  if (j >= NUM_STATS) {
2683  /* Bad clients could do this - we should at least report
2684  * it, and useful when trying to add new parameters.
2685  */
2686  LOG(llevError, "Got unknown key/value from client: %s %s\n", key, value);
2687  }
2688  }
2689  nlen += i + 1;
2690  }
2691  /* Do some sanity checking now. But checking the stat
2692  * values here, we will catch any 0 values since we do
2693  * a memset above. A properly behaving client should
2694  * never do any of these things, but we do not presume
2695  * clients will behave properly.
2696  */
2697  for (j=0; j<NUM_STATS; j++) {
2698  int val = get_attr_value(&new_stats, j);
2699 
2700  stat_total += val;
2701  if (val > settings.starting_stat_max ||
2702  val < settings.starting_stat_min) {
2703  SockList_AddPrintf(&sl,
2704  "failure createplayer Stat value is out of range - %d must be between %d and %d",
2706  Send_With_Handling(ns, &sl);
2707  SockList_Term(&sl);
2708  return;
2709  }
2710  }
2711  if (stat_total > settings.starting_stat_points) {
2712  SockList_AddPrintf(&sl,
2713  "failure createplayer Total allocated statistics is higher than allowed (%d>%d)",
2714  stat_total, settings.starting_stat_points);
2715  Send_With_Handling(ns, &sl);
2716  SockList_Term(&sl);
2717  return;
2718  }
2719 
2720  if (race)
2721  race_a = try_find_archetype(race);
2722 
2723  if (class)
2724  class_a = try_find_archetype(class);
2725 
2726  /* This should never happen with a properly behaving client, so the error message
2727  * doesn't have to be that great.
2728  */
2729  if (!race_a || race_a->clone.type != PLAYER || !class_a || class_a->clone.type != CLASS) {
2730  SockList_AddString(&sl,
2731  "failure createplayer Invalid or unknown race or class");
2732  Send_With_Handling(ns, &sl);
2733  SockList_Term(&sl);
2734  return;
2735  }
2736 
2737  /* At current time, only way this can fail is if the adjusted
2738  * stat is less than 1.
2739  */
2740  if (check_race_and_class(&new_stats, race_a, class_a)) {
2741  SockList_AddString(&sl,
2742  "failure createplayer Unable to apply race or class - statistic is out of bounds");
2743  Send_With_Handling(ns, &sl);
2744  SockList_Term(&sl);
2745  return;
2746  }
2747 
2748  if (!pl)
2750 
2751  apply_race_and_class(pl->ob, race_a, class_a, &new_stats);
2752 
2753  } else {
2754  /* In thise case, old login method */
2755  if (!pl)
2756  pl = add_player(ns, ADD_PLAYER_NEW);
2757 /* already done by add_player
2758  roll_again(pl->ob);
2759  pl->state = ST_ROLL_STAT;
2760  set_first_map(pl->ob);*/
2761  }
2762 
2763  /* add_player does a lot of the work, but there are a few
2764  * things we need to update, like starting name and
2765  * password.
2766  * This is done before processing in login_method>2.
2767  * The character creation process it does when
2768  * applying the race/class will use this
2769  * name information.
2770  */
2771  FREE_AND_COPY(pl->ob->name, name);
2772  FREE_AND_COPY(pl->ob->name_pl, name);
2773  pl->name_changed = 1;
2774  safe_strncpy(pl->password, newhash(password), sizeof(pl->password));
2775 
2776  SockList_AddString(&sl, "addme_success");
2777  Send_With_Handling(ns, &sl);
2778  SockList_Term(&sl);
2779 
2780  if (ns->login_method >= 2) {
2781  /* The client could have provided us a map - if so, map will be set
2782  * and we don't want to overwrite it
2783  */
2784  if (!map)
2786 
2787  if (!map) {
2788  /* This should never happen - its not something that can
2789  * be easily worked around without other weird issues,
2790  * like having 2 classes.
2791  */
2792  LOG(llevError, "Can not find object of type MAP subtype MAP_TYPE_DEFAULT.\n");
2793  LOG(llevError, "Are the archetype files up to date? Can not continue.\n");
2794  abort();
2795  }
2796 
2797  enter_exit(pl->ob, &map->clone);
2798 
2799  if (pl->ob->map == NULL) {
2800  LOG(llevError, "Couldn't put player %s on start map %s!", pl->ob->name, map->name);
2801  abort();
2802  }
2803 
2804  /* copy information to bed of reality information, in case the player dies */
2805  safe_strncpy(pl->savebed_map, pl->ob->map->path, sizeof(pl->savebed_map));
2806  pl->bed_x = pl->ob->x;
2807  pl->bed_y = pl->ob->y;
2808 
2810  }
2811 
2812  /* We insert any objects after we have put the player on the map -
2813  * this makes things safer, as certain objects may expect a normal
2814  * environment. Note that choice_num will only be set in the
2815  * loginmethod > 2, which also checks (and errors out) if the
2816  * race/class is not set, which is why explicit checking for
2817  * those is not need.
2818  */
2819  for (i=0; i < choice_num; i++) {
2820  char *choiceval, *cp;
2821  const char *value;
2822  archetype *arch;
2823  object *op;
2824 
2825  choiceval = strchr(choices[i], ' ');
2826  if (!choiceval) {
2827  LOG(llevError, "Choice does not specify value: %s\n", choices[i]);
2828  continue;
2829  }
2830  *choiceval=0;
2831  choiceval++;
2832  value = object_get_value(&race_a->clone, choices[i]);
2833  if (!value)
2834  value = object_get_value(&class_a->clone, choices[i]);
2835 
2836  if (!value) {
2837  LOG(llevError, "Choice not found in archetype: %s\n", choices[i]);
2838  continue;
2839  }
2840  cp = strstr(value, choiceval);
2841  if (!cp) {
2842  LOG(llevError, "Choice value not found in archetype: %s %s\n",
2843  choices[i], choiceval);
2844  continue;
2845  }
2846 
2847  /* Check to make sure that the matched string is an entire word,
2848  * and not a substring (eg, valid choice being great_sword but
2849  * we just get sword) - the space after the match should either be a
2850  * space or null, and space before match should also be a space
2851  * or the start of the string.
2852  */
2853  if ((cp[strlen(choiceval)] != ' ') && (cp[strlen(choiceval)] != 0) &&
2854  (cp != value) && (*(cp-1) != ' ')) {
2855 
2856  LOG(llevError, "Choice value matches substring but not entire word: %s substring %s\n",
2857  choiceval, value);
2858  continue;
2859  }
2860  arch = try_find_archetype(choiceval);
2861  if (!arch) {
2862  LOG(llevError, "Choice value can not find archetype %s\n", choiceval);
2863  continue;
2864  }
2865  op = arch_to_object(arch);
2866  op = object_insert_in_ob(op, pl->ob);
2867  if (QUERY_FLAG(op, FLAG_AUTO_APPLY))
2868  ob_apply(op, pl->ob, 0);
2869  }
2870 
2871  ns->status = Ns_Avail;
2872  LOG(llevInfo, "new character %s from %s\n", pl->ob->name, pl->ob->contr->socket.host);
2875  "%s has entered the game.", pl->ob->name);
2876 }
2877 
2888 void account_password(char *buf, int len, socket_struct *ns) {
2889  char old[MAX_BUF], change[MAX_BUF];
2890  int status;
2891  SockList sl;
2892 
2893  if (len <= 0 || !buf) {
2894  LOG(llevDebug, "IP '%s' sent bogus account_password_cmd information\n", ns->host);
2895  return;
2896  }
2897 
2898  SockList_Init(&sl);
2899 
2900  if (ns->account_name == NULL) {
2901  SockList_AddString(&sl, "failure accountpw Not logged in");
2902  Send_With_Handling(ns, &sl);
2903  SockList_Term(&sl);
2904  return;
2905  }
2906 
2907  status = decode_name_password(buf, &len, old, change);
2908  if (status == 1) {
2909  SockList_AddString(&sl, "failure accountpw Old password is too long");
2910  Send_With_Handling(ns, &sl);
2911  SockList_Term(&sl);
2912  return;
2913  }
2914  if (status == 2) {
2915  SockList_AddString(&sl, "failure accountpw New password is too long");
2916  Send_With_Handling(ns, &sl);
2917  SockList_Term(&sl);
2918  return;
2919  }
2920  /*The minimum length isn't exactly required, but in the current implementation,
2921  * client will send the same password for character for which there is a
2922  * 2 character minimum size. Thus an account with a one character password
2923  * won't be able to create a character. */
2924  if (strlen(change)<2) {
2925  SockList_AddString(&sl, "failure accountpw New password is too short");
2926  Send_With_Handling(ns, &sl);
2927  SockList_Term(&sl);
2928  return;
2929  }
2930 
2931  status = account_check_string(change);
2932  if (status == 1) {
2933  SockList_AddString(&sl,
2934  "failure accountpw That password contains invalid characters.");
2935  Send_With_Handling(ns, &sl);
2936  SockList_Term(&sl);
2937  return;
2938  }
2939 
2940  if (status == 2) {
2941  SockList_AddString(&sl,
2942  "failure accountpw That password is too long");
2943  Send_With_Handling(ns, &sl);
2944  SockList_Term(&sl);
2945  return;
2946  }
2947 
2948  status = account_change_password(ns->account_name, old, change);
2949  if (status != 0) {
2950  const char *error;
2951 
2952  if (status == 1) {
2953  error = "failure accountpw Illegal characters present";
2954  } else if (status == 2) {
2955  error = "failure accountpw Invalid account";
2956  } else {
2957  error = "failure accountpw Incorrect current password";
2958  }
2959 
2960  SockList_AddString(&sl, error);
2961  Send_With_Handling(ns, &sl);
2962  SockList_Term(&sl);
2963  return;
2964  }
2965 
2966  /* If we got here, we passed all checks, and password was changed */
2968 }
void map_newmap_cmd(socket_struct *ns)
Definition: request.c:620
void draw_ext_info_format(int flags, int pri, const object *pl, uint8_t type, uint8_t subtype, const char *format,...)
Definition: main.c:315
object * object_find_by_type_and_name(const object *who, int type, const char *name)
Definition: object.c:4019
const char * party
Definition: account_char.h:32
uint8_t login_method
Definition: newserver.h:128
#define CS_STAT_AC
Definition: newclient.h:100
char path[HUGE_BUF]
Definition: map.h:365
#define ACL_CLASS
Definition: newclient.h:197
void set_attr_value(living *stats, int attr, int8_t value)
Definition: living.c:218
void SockList_AddPrintf(SockList *sl, const char *format,...)
Definition: lowlevel.c:194
int16_t last_golem_maxhp
Definition: player.h:157
int8_t Int
Definition: living.h:36
#define CS_STAT_RES_GHOSTHIT
Definition: newclient.h:152
Definition: player.h:92
#define CS_STAT_APPLIED_CON
Definition: newclient.h:135
uint8_t faceset
Definition: newserver.h:117
int8_t ac
Definition: living.h:38
int16_t last_sp
Definition: player.h:76
#define CS_STAT_BASE_WIS
Definition: newclient.h:126
size_t len
Definition: newclient.h:685
#define MAX_HEAD_POS
Definition: request.c:931
#define ST_GET_PARTY_PASSWORD
Definition: define.h:587
#define SP_MAKE_MARK
Definition: spells.h:77
uint32_t tick
Definition: newserver.h:106
void SockList_Reset(SockList *sl)
Definition: lowlevel.c:66
int8_t tail_x
Definition: object.h:471
void new_player_cmd(uint8_t *buf, int len, player *pl)
Definition: request.c:452
void enter_exit(object *op, object *exit_ob)
Definition: server.c:716
void esrv_send_face(socket_struct *ns, uint16_t face_num, int nocache)
Definition: image.c:70
#define NS_FACESENT_FACE
Definition: newserver.h:137
Definition: object.h:125
void esrv_add_spells(player *pl, object *spell)
Definition: request.c:1760
int account_login(const char *account_name, const char *account_password)
Definition: account.c:333
const char * name
Definition: account_char.h:27
uint32_t want_pickup
Definition: newserver.h:108
living last_race_stats
Definition: player.h:151
#define P_NEED_UPDATE
Definition: map.h:239
int16_t last_dam
Definition: player.h:78
int account_remove_player(const char *account_name, const char *player_name)
Definition: account.c:497
char * account_name
Definition: newserver.h:126
#define CS_STAT_RES_POISON
Definition: newclient.h:153
#define MAX_LIGHT_RADII
Definition: define.h:466
#define ANIM_RANDOM
Definition: newclient.h:322
static int map2_delete_layer(int ax, int ay, int layer, SockList *sl, socket_struct *ns)
Definition: request.c:1112
void SockList_Init(SockList *sl)
Definition: lowlevel.c:48
#define CS_STAT_RACE_INT
Definition: newclient.h:118
#define SET_FLAG(xyz, p)
Definition: define.h:223
void receive_player_password(object *op)
Definition: c_misc.c:1918
uint8_t starting_stat_min
Definition: global.h:317
#define CS_STAT_INT
Definition: newclient.h:92
#define CS_STAT_RES_DRAIN
Definition: newclient.h:151
#define CS_STAT_BASE_POW
Definition: newclient.h:130
#define NDI_ALL
Definition: newclient.h:246
int16_t bed_x
Definition: player.h:98
uint32_t run_on
Definition: player.h:128
#define FABS(x)
Definition: define.h:22
unsigned char uint8_t
Definition: win32.h:161
void SockList_ResetRead(SockList *sl)
Definition: lowlevel.c:75
uint16_t animation_id
Definition: object.h:416
int GetInt_String(const unsigned char *data)
Definition: lowlevel.c:246
EXTERN int num_animations
Definition: global.h:164
uint32_t name_changed
Definition: player.h:130
#define strdup_local
Definition: compat.h:25
uint8_t anim_speed
Definition: object.h:417
#define ACL_FACE_NUM
Definition: newclient.h:203
int16_t last_resist[NROFATTACKS]
Definition: player.h:155
player * add_player(socket_struct *ns, int flags)
Definition: player.c:453
void send_account_players(socket_struct *ns)
Definition: request.c:1883
#define UPD_SP_GRACE
Definition: newclient.h:300
int account_change_password(const char *account_name, const char *current_password, const char *new_password)
Definition: account.c:658
#define SND_EFFECTS
Definition: sounds.h:12
#define CS_STAT_RES_CONF
Definition: newclient.h:149
const char * account_get_account_for_char(const char *charname)
Definition: account.c:562
int account_new(const char *account_name, const char *account_password)
Definition: account.c:408
void send_tick(player *pl)
Definition: request.c:1819
#define ACL_LEVEL
Definition: newclient.h:199
#define SPELL_GRACE
Definition: spells.h:59
int save_player(object *op, int flag)
Definition: login.c:211
uint32_t in_memory
Definition: map.h:345
void account_play_cmd(char *buf, int len, socket_struct *ns)
Definition: request.c:2422
int16_t maxgrace
Definition: living.h:45
void print_ext_msg(socket_struct *ns, int color, uint8_t type, uint8_t subtype, const char *message)
Definition: info.c:49
mapstruct * get_map_from_coord(mapstruct *m, int16_t *x, int16_t *y)
Definition: map.c:2380
#define CS_STAT_SPEED
Definition: newclient.h:103
const char * object_get_value(const object *op, const char *const key)
Definition: object.c:4266
struct Map lastmap
Definition: newserver.h:93
struct treasureliststruct * randomitems
Definition: object.h:385
void key_roll_stat(object *op, char key)
Definition: player.c:1184
uint32_t pticks
Definition: time.c:45
#define SND_MUTE
Definition: sounds.h:14
void SockList_AddShort(SockList *sl, uint16_t data)
Definition: lowlevel.c:108
#define ST_CHANGE_PASSWORD_CONFIRM
Definition: define.h:590
static int decode_name_password(const char *buf, int *len, char *name, char *password)
Definition: request.c:2023
object clone
Definition: object.h:470
#define MAP2_TYPE_CLEAR
Definition: newclient.h:42
socket_struct socket
Definition: player.h:94
int16_t invisible
Definition: object.h:360
#define NS_FACESENT_SMOOTH
Definition: newserver.h:138
#define ST_CONFIRM_PASSWORD
Definition: define.h:586
int16_t SP_level_spellpoint_cost(object *caster, object *spell, int flags)
Definition: spell_util.c:277
#define CS_STAT_DEX
Definition: newclient.h:94
Definition: object.h:138
const char * skill_names[NUM_SKILLS]
Definition: skill_util.c:57
object * ranges[range_size]
Definition: player.h:103
void account_add_player_cmd(char *buf, int len, socket_struct *ns)
Definition: request.c:2293
bool heartbeat
Definition: newserver.h:112
uint8_t subtype
Definition: object.h:339
#define CS_STAT_BASE_STR
Definition: newclient.h:124
#define SF_RUNON
Definition: newclient.h:186
int is_valid_faceset(int fsn)
Definition: image.c:563
int SP_level_dam_adjust(const object *caster, const object *spob)
Definition: spell_util.c:328
int64_t exp
Definition: living.h:47
int16_t last_golem_hp
Definition: player.h:156
const char * account_exists(const char *account_name)
Definition: account.c:309
#define AddIfInt64(Old, New, Type)
Definition: request.c:688
uint8_t starting_stat_max
Definition: global.h:318
void SockList_AddInt(SockList *sl, uint32_t data)
Definition: lowlevel.c:119
#define ST_CHANGE_PASSWORD_NEW
Definition: define.h:589
#define CS_STAT_RES_DEATH
Definition: newclient.h:159
enum Sock_Status status
Definition: newserver.h:90
int verify_player(const char *name, char *password)
Definition: login.c:109
Definition: living.h:35
#define ACL_FACE
Definition: newclient.h:200
int8_t get_attr_value(const living *stats, int attr)
Definition: living.c:313
#define CS_STAT_MAXSP
Definition: newclient.h:90
const char * map
Definition: account_char.h:33
#define CS_STAT_WIS
Definition: newclient.h:93
uint32_t path_attuned
Definition: object.h:343
method_ret ob_apply(object *op, object *applier, int aflags)
Definition: ob_methods.c:42
void account_char_free(Account_Char *chars)
Definition: account_char.c:334
void esrv_remove_spell(player *pl, object *spell)
Definition: request.c:1623
int16_t sp
Definition: living.h:42
#define AddIfString(Old, New, Type)
Definition: request.c:716
uint32_t get_weight_limit(int stat)
Definition: living.c:2281
int apply_race_and_class(object *op, archetype *race, archetype *opclass, living *stats)
Definition: player.c:1450
#define SP_CREATE_MISSILE
Definition: spells.h:113
uint8_t smoothlevel
Definition: object.h:421
#define CS_STAT_FLAGS
Definition: newclient.h:111
uint32_t path_repelled
Definition: object.h:344
char * title
Definition: newserver.h:57
#define safe_strncpy
Definition: compat.h:23
#define ACL_MAP
Definition: newclient.h:202
#define CS_STAT_RACE_CON
Definition: newclient.h:121
struct archt * other_arch
Definition: object.h:413
#define ST_ROLL_STAT
Definition: define.h:581
Definition: object.h:465
#define ST_PLAYING
Definition: define.h:579
char savebed_map[MAX_BUF]
Definition: player.h:97
#define NDI_DK_ORANGE
Definition: newclient.h:227
char * host
Definition: newserver.h:100
int8_t tail_y
Definition: object.h:471
int16_t maxsp
Definition: living.h:43
int8_t Con
Definition: living.h:36
#define FLAG_REMOVED
Definition: define.h:232
int16_t hp
Definition: living.h:40
#define CS_STAT_WEIGHT_LIM
Definition: newclient.h:112
#define VERSION_SC
Definition: newserver.h:150
uint16_t number
Definition: face.h:15
#define MAP_LAYER_LIVING2
Definition: map.h:47
#define CS_STAT_EXP64
Definition: newclient.h:113
uint16_t notifications
Definition: newserver.h:129
#define CS_STAT_BASE_CON
Definition: newclient.h:128
#define CS_STAT_RACE_DEX
Definition: newclient.h:120
void version_cmd(char *buf, int len, socket_struct *ns)
Definition: request.c:586
client_spell * get_client_spell_state(player *pl, object *spell)
Definition: player.c:136
struct account_char_struct * next
Definition: account_char.h:35
void send_query(socket_struct *ns, uint8_t flags, const char *text)
Definition: request.c:679
#define CS_STAT_WC
Definition: newclient.h:99
int probe(object *op, object *caster, object *spell_ob, int dir, int level)
Definition: spell_effect.c:683
#define MAP_IN_MEMORY
Definition: map.h:130
uint32_t update_look
Definition: newserver.h:104
uint32_t facecache
Definition: newserver.h:102
#define MAX_NUM_LOOK_OBJECTS
Definition: newserver.h:28
int16_t y
Definition: object.h:326
int16_t maxhp
Definition: living.h:41
#define NDI_RED
Definition: newclient.h:224
living applied_stats
Definition: player.h:152
#define MSG_TYPE_COMMAND
Definition: newclient.h:379
#define FLAG_CLIENT_ANIM_RANDOM
Definition: define.h:241
uint32_t path_denied
Definition: object.h:345
uint32_t sound
Definition: newserver.h:111
#define strtok_r(x, y, z)
Definition: win32.h:62
Account_Char * account_chars
Definition: newserver.h:127
#define ADD_PLAYER_NO_STATS_ROLL
Definition: player.h:224
uint32_t cs_version
Definition: newserver.h:113
void move_cmd(char *buf, int len, player *pl)
Definition: request.c:641
void SockList_AddData(SockList *sl, const void *data, size_t len)
Definition: lowlevel.c:159
int account_is_logged_in(const char *name)
Definition: account.c:630
void accounts_save(void)
Definition: account.c:267
const char * name_pl
Definition: object.h:315
#define CS_STAT_RES_FIRE
Definition: newclient.h:146
uint8_t num_look_objects
Definition: newserver.h:122
#define CS_STAT_RES_HOLYWORD
Definition: newclient.h:160
#define AddIfInt(Old, New, Type)
Definition: request.c:695
object * object_insert_in_ob(object *op, object *where)
Definition: object.c:2707
float speed_left
Definition: object.h:329
void key_change_class(object *op, char key)
Definition: player.c:1260
#define MSG_TYPE_COMMAND_ERROR
Definition: newclient.h:509
int8_t last_level
Definition: player.h:121
signed short int16_t
Definition: win32.h:160
#define FLAG_CLIENT_SENT
Definition: define.h:349
void draw_client_map(object *pl)
Definition: request.c:1458
uint16_t last_flags
Definition: player.h:141
#define ADD_PLAYER_NEW
Definition: player.h:222
int8_t Wis
Definition: living.h:36
#define CS_STAT_LEVEL
Definition: newclient.h:98
static const short atnr_cs_stat[NROFATTACKS]
Definition: request.c:73
void receive_party_password(object *op)
Definition: c_party.c:49
#define ST_CONFIRM_QUIT
Definition: define.h:583
void key_confirm_quit(object *op, char key)
Definition: player.c:1562
#define UPD_SP_DAMAGE
Definition: newclient.h:301
#define BEAT_INTERVAL
Definition: config.h:680
#define MSG_TYPE_ADMIN_PLAYER
Definition: newclient.h:474
short GetShort_String(const unsigned char *data)
Definition: lowlevel.c:250
struct mapdef * map
Definition: object.h:297
uint8_t always_show_hp
Definition: global.h:269
void SockList_Term(SockList *sl)
Definition: lowlevel.c:58
Definition: newserver.h:48
#define snprintf
Definition: win32.h:46
#define CS_STAT_WEAP_SP
Definition: newclient.h:105
#define CS_STAT_BASE_DEX
Definition: newclient.h:127
void player_set_state(player *pl, uint8_t state)
Definition: player.c:4454
#define CS_STAT_APPLIED_INT
Definition: newclient.h:132
#define MAX_HEAD_OFFSET
Definition: newserver.h:42
socket_struct * account_get_logged_in_init_socket(const char *name)
Definition: account.c:608
static int check_probe(int ax, int ay, const object *ob, SockList *sl, socket_struct *ns, int *has_obj, int *alive_layer)
Definition: request.c:1137
#define FLAG_CLIENT_ANIM_SYNC
Definition: define.h:240
static int spell_client_use(const object *spell)
Definition: request.c:1666
object * transport
Definition: player.h:195
#define FOR_INV_FINISH()
Definition: define.h:714
void update_position(mapstruct *m, int x, int y)
Definition: map.c:2131
#define CS_STAT_BASE_CHA
Definition: newclient.h:129
int16_t dam
Definition: living.h:46
#define MAP_LAYERS
Definition: map.h:32
int8_t map_scroll_y
Definition: newserver.h:94
#define FLAG_PROBE
Definition: define.h:257
uint32_t sc_version
Definition: newserver.h:113
const char * name
Definition: object.h:311
int16_t bed_y
Definition: player.h:98
living orig_stats
Definition: player.h:148
static void append_spell(player *pl, SockList *sl, object *spell)
Definition: request.c:1690
struct obj * env
Definition: object.h:293
living last_applied_stats
Definition: player.h:153
#define MAX_TIME
Definition: config.h:246
player * account_get_logged_in_player(const char *name)
Definition: account.c:587
Account_Char * account_char_load(const char *account_name)
Definition: account_char.c:80
#define CS_STAT_RACE_POW
Definition: newclient.h:123
#define CS_STAT_TURN_UNDEAD
Definition: newclient.h:156
#define ST_PLAY_AGAIN
Definition: define.h:580
uint8_t state
Definition: player.h:118
object * object_present_in_ob(uint8_t type, const object *op)
Definition: object.c:3018
void SockList_AddString(SockList *sl, const char *data)
Definition: lowlevel.c:149
#define AddIfFloat(Old, New, Type)
Definition: request.c:709
uint8_t num_animations
Definition: face.h:28
int16_t last_grace
Definition: player.h:77
#define MAX_CHOICES
Definition: request.c:2502
int8_t Cha
Definition: living.h:36
#define P_OUT_OF_MAP
Definition: map.h:251
#define CS_STAT_CHA
Definition: newclient.h:96
EXTERN Animations * animations
Definition: global.h:163
player * get_player(player *p)
Definition: player.c:280
New_Face * smooth_face
Definition: image.c:39
#define MAP_TYPE_DEFAULT
Definition: map.h:58
struct pl * contr
Definition: object.h:276
void create_player_cmd(char *buf, int len, socket_struct *ns)
Definition: request.c:2509
static void send_smooth(socket_struct *ns, uint16_t face)
Definition: request.c:392
void execute_newserver_command(object *pl, char *command)
Definition: c_new.c:83
int find_smooth(uint16_t face, uint16_t *smoothed)
Definition: image.c:379
size_t SockList_Avail(const SockList *sl)
Definition: lowlevel.c:238
#define UPD_SP_MANA
Definition: newclient.h:299
#define ATNR_PHYSICAL
Definition: attack.h:49
#define VERSION_CS
Definition: newserver.h:149
int32_t last_weight_limit
Definition: player.h:143
archetype * try_find_archetype(const char *name)
Definition: arch.c:663
int8_t blocked_los[MAP_CLIENT_X][MAP_CLIENT_Y]
Definition: player.h:159
char * range
Definition: newserver.h:57
#define CS_STAT_APPLIED_POW
Definition: newclient.h:137
float speed
Definition: object.h:328
Definition: object.h:214
#define SP_RUNE
Definition: spells.h:76
#define QUERY_FLAG(xyz, p)
Definition: define.h:225
#define CS_STAT_SPELL_REPEL
Definition: newclient.h:115
#define CS_STAT_STR
Definition: newclient.h:91
#define MSG_TYPE_ADMIN_VERSION
Definition: newclient.h:479
static void draw_client_map2(object *pl)
Definition: request.c:1267
#define HEAD(op)
Definition: object.h:592
struct map_cell_struct cells[MAX_CLIENT_X][MAX_CLIENT_Y]
Definition: newserver.h:49
uint32_t is_bot
Definition: newserver.h:107
#define CS_STAT_FOOD
Definition: newclient.h:104
#define CS_STAT_APPLIED_DEX
Definition: newclient.h:134
uint32_t golem_count
Definition: player.h:106
#define MAX_BUF
Definition: define.h:35
void ask_smooth_cmd(char *buf, int len, socket_struct *ns)
Definition: request.c:428
#define MIN_NUM_LOOK_OBJECTS
Definition: newserver.h:16
#define CS_STAT_RES_SLOW
Definition: newclient.h:154
#define MSG_TYPE_ADMIN
Definition: newclient.h:377
Account_Char * account_char_remove(Account_Char *chars, const char *pl_name)
Definition: account_char.c:298
int16_t x
Definition: object.h:326
uint32_t extended_stats
Definition: newserver.h:109
const char * character_class
Definition: account_char.h:28
#define AddIfShort(Old, New, Type)
Definition: request.c:702
const char * skill
Definition: object.h:321
uint8_t mapx
Definition: newserver.h:116
void add_me_cmd(char *buf, int len, socket_struct *ns)
Definition: request.c:347
#define MAP_CLIENT_X
Definition: config.h:237
#define NUM_SKILLS
Definition: skills.h:71
int8_t wc
Definition: living.h:37
unsigned short uint16_t
Definition: win32.h:163
void SockList_AddChar(SockList *sl, char c)
Definition: lowlevel.c:98
static const flag_definition flags[]
#define ANIM_SYNC
Definition: newclient.h:323
uint8_t account_block_create
Definition: global.h:325
client_spell * spell_state
Definition: player.h:196
int8_t Str
Definition: living.h:36
void receive_player_name(object *op)
Definition: c_misc.c:1900
#define CS_STAT_APPLIED_CHA
Definition: newclient.h:136
int16_t resist[NROFATTACKS]
Definition: object.h:341
#define CS_STAT_RES_PARA
Definition: newclient.h:155
object * ob
Definition: player.h:158
#define CS_STAT_RES_COLD
Definition: newclient.h:148
const char * sstring
Definition: global.h:40
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.c:967
const New_Face ** faces
Definition: face.h:31
int32_t timeout
Definition: map.h:341
Definition: object.h:107
unsigned int uint32_t
Definition: win32.h:162
uint32_t darkness
Definition: newserver.h:103
#define GET_MAP_FACE_OBJ(M, X, Y, L)
Definition: map.h:184
void esrv_draw_look(object *pl)
Definition: item.c:187
int account_check_string(const char *str)
Definition: account.c:369
int account_link(const char *account_name, const char *player_name)
Definition: account.c:461
#define FLAG_AUTO_APPLY
Definition: define.h:250
#define MAP2_TYPE_DARKNESS
Definition: newclient.h:43
#define P_NEW_MAP
Definition: map.h:252
#define MAP_CLIENT_Y
Definition: config.h:238
#define MAP_LAYER_LIVING1
Definition: map.h:46
void account_password(char *buf, int len, socket_struct *ns)
Definition: request.c:2888
void set_up_cmd(char *buf, int len, socket_struct *ns)
Definition: request.c:93
float last_speed
Definition: player.h:154
living last_stats
Definition: player.h:149
#define CS_STAT_RES_ELEC
Definition: newclient.h:147
#define FREE_AND_COPY(sv, nv)
Definition: global.h:211
int16_t grace
Definition: living.h:44
static int account_block_create(const socket_struct *ns)
Definition: request.c:2149
#define CS_STAT_APPLIED_STR
Definition: newclient.h:131
#define NUM_ANIMATIONS(ob)
Definition: global.h:177
#define CS_STAT_SP
Definition: newclient.h:89
player * find_player_socket(const socket_struct *ns)
Definition: player.c:118
uint32_t fire_on
Definition: player.h:127
archetype * get_archetype_by_type_subtype(int type, int subtype)
Definition: arch.c:136
#define CS_STAT_RES_MAG
Definition: newclient.h:145
#define CS_STAT_GOLEM_HP
Definition: newclient.h:138
void esrv_update_spells(player *pl)
Definition: request.c:1571
char password[16]
Definition: player.h:176
int32_t last_weight
Definition: player.h:142
tag_t count
Definition: object.h:299
static void check_space_for_heads(int ax, int ay, SockList *sl, socket_struct *ns)
Definition: request.c:1220
living stats
Definition: object.h:368
uint8_t starting_stat_points
Definition: global.h:319
int8_t Dex
Definition: living.h:36
struct archt * arch
Definition: object.h:412
#define MAP_TYPE_CHOICE
Definition: map.h:59
float last_weapon_sp
Definition: player.h:140
void send_plugin_custom_message(object *pl, char *buf)
Definition: request.c:1557
void account_char_save(const char *account, Account_Char *chars)
Definition: account_char.c:146
uint8_t anims_sent[MAXANIMNUM]
Definition: newserver.h:97
void esrv_send_pickup(player *pl)
Definition: request.c:1646
#define CS_STAT_RES_DEPLETE
Definition: newclient.h:158
struct statsinfo stats
Definition: newserver.h:98
uint8_t type
Definition: object.h:338
void check_login(object *op, int check_pass)
Definition: login.c:494
uint32_t do_los
Definition: player.h:126
uint32_t mode
Definition: player.h:110
struct Settings settings
Definition: init.c:40
void esrv_new_player(player *pl, uint32_t weight)
Definition: request.c:861
uint32_t monitor_spells
Definition: newserver.h:110
void SockList_AddLen8Data(SockList *sl, const void *data, size_t len)
Definition: lowlevel.c:171
#define CS_STAT_RES_FEAR
Definition: newclient.h:157
#define ADD_PLAYER_NO_MAP
Definition: player.h:223
#define NROFATTACKS
Definition: attack.h:17
#define ACL_PARTY
Definition: newclient.h:201
static void map_clearcell(struct map_cell_struct *cell, int face, int count)
Definition: request.c:926
#define CS_STAT_APPLIED_WIS
Definition: newclient.h:133
#define CS_STAT_ARMOUR
Definition: newclient.h:102
#define ST_CHANGE_PASSWORD_OLD
Definition: define.h:588
signed int int32_t
Definition: win32.h:159
#define CS_STAT_DAM
Definition: newclient.h:101
int64_t last_skill_exp[NUM_SKILLS]
Definition: player.h:138
#define MAX_CHARACTERS_PER_ACCOUNT
Definition: account_char.h:20
#define ST_CHANGE_CLASS
Definition: define.h:582
const char * msg
Definition: object.h:322
#define SP_SUMMON_MONSTER
Definition: spells.h:101
int16_t casting_time
Definition: object.h:402
void update_los(object *op)
Definition: los.c:459
void receive_play_again(object *op, char key)
Definition: player.c:930
#define CS_STAT_TITLE
Definition: newclient.h:107
void esrv_send_animation(socket_struct *ns, short anim_num)
Definition: request.c:888
sstring add_string(const char *str)
Definition: shstr.c:124
EXTERN player * first_player
Definition: global.h:117
#define CS_STAT_RACE_STR
Definition: newclient.h:117
struct pl * next
Definition: player.h:93
int strcasecmp(const char *s1, const char *s2)
Definition: porting.c:256
#define ACL_RACE
Definition: newclient.h:198
#define CS_STAT_SPELL_DENY
Definition: newclient.h:116
#define CS_STAT_HP
Definition: newclient.h:87
void esrv_update_stats(player *pl)
Definition: request.c:730
int8_t Pow
Definition: living.h:36
int get_map_flags(mapstruct *oldmap, mapstruct **newmap, int16_t x, int16_t y, int16_t *nx, int16_t *ny)
Definition: map.c:300
#define NDI_UNIQUE
Definition: newclient.h:245
static void add_char_field(SockList *sl, int type, const char *data)
Definition: request.c:1849
uint32_t last_path_repelled
Definition: player.h:145
struct obj * head
Definition: object.h:296
#define CS_STAT_RES_PHYS
Definition: newclient.h:144
void LOG(LogLevel logLevel, const char *format,...)
Definition: logger.c:51
#define CS_STAT_RES_BLIND
Definition: newclient.h:161
#define SF_FIREON
Definition: newclient.h:185
#define CS_STAT_POW
Definition: newclient.h:108
int8_t map_scroll_x
Definition: newserver.h:94
#define CS_STAT_GOLEM_MAXHP
Definition: newclient.h:139
void set_title(const object *pl, char *buf, size_t len)
Definition: info.c:300
#define SND_MUSIC
Definition: sounds.h:13
object * last_skill_ob[NUM_SKILLS]
Definition: player.h:137
char ** account_get_players_for_account(const char *account_name)
Definition: account.c:543
#define CS_STAT_RANGE
Definition: newclient.h:106
uint32_t last_path_attuned
Definition: player.h:144
#define SPELL_MANA
Definition: spells.h:58
#define CS_STAT_RACE_WIS
Definition: newclient.h:119
#define CS_STAT_RACE_CHA
Definition: newclient.h:122
void rangetostring(const object *pl, char *obuf, size_t len)
Definition: info.c:230
#define CS_STAT_MAXHP
Definition: newclient.h:88
#define MAP_LAYER_FLY2
Definition: map.h:49
void SockList_AddInt64(SockList *sl, uint64_t data)
Definition: lowlevel.c:132
Definition: map.h:325
#define ST_GET_NAME
Definition: define.h:584
const New_Face * face
Definition: object.h:332
char write_buf[MAX_BUF]
Definition: player.h:174
#define CS_STAT_CON
Definition: newclient.h:95
#define CS_STAT_SPELL_ATTUNE
Definition: newclient.h:114
void reply_cmd(char *buf, int len, player *pl)
Definition: request.c:514
void account_login_cmd(char *buf, int len, socket_struct *ns)
Definition: request.c:2059
const char *const short_stat_name[NUM_STATS]
Definition: living.c:194
uint8_t mapy
Definition: newserver.h:116
#define ACL_NAME
Definition: newclient.h:196
#define CS_STAT_MAXGRACE
Definition: newclient.h:110
int16_t level
Definition: object.h:351
char const * newhash(char const *password)
float weapon_speed
Definition: object.h:330
unsigned find_face(const char *name, unsigned error)
Definition: image.c:303
#define CS_STAT_RES_ACID
Definition: newclient.h:150
#define SP_CREATE_FOOD
Definition: spells.h:96
struct obj * more
Definition: object.h:295
#define MAP2_LAYER_START
Definition: newclient.h:53
object * arch_to_object(archetype *at)
Definition: arch.c:569
const char * face
Definition: account_char.h:31
#define CS_STAT_SKILLINFO
Definition: newclient.h:168
uint8_t * faces_sent
Definition: newserver.h:96
#define CS_STAT_BASE_INT
Definition: newclient.h:125
#define MAP_NOSMOOTH(m)
Definition: map.h:89
int check_race_and_class(living *stats, archetype *race, archetype *opclass)
Definition: player.c:1400
const char * name
Definition: object.h:466
static const object * heads[MAX_HEAD_POS][MAX_HEAD_POS][MAP_LAYERS]
Definition: request.c:940
#define MAP2_COORD_ENCODE(x, y, flags)
Definition: newclient.h:64
uint16_t faces[MAP_LAYERS]
Definition: newserver.h:32
void esrv_map_scroll(socket_struct *ns, int dx, int dy)
Definition: request.c:1519
void account_new_cmd(char *buf, int len, socket_struct *ns)
Definition: request.c:2185
const char * race
Definition: account_char.h:29
#define CS_STAT_GRACE
Definition: newclient.h:109
#define FOR_INV_PREPARE(op_, it_)
Definition: define.h:707
SockList inbuf
Definition: newserver.h:99
void object_remove(object *op)
Definition: object.c:1669
uint32_t last_path_denied
Definition: player.h:146
living last_orig_stats
Definition: player.h:150
#define ST_GET_PASSWORD
Definition: define.h:585
int32_t food
Definition: living.h:48
static bool CAN_PROBE(const object *ob)
Definition: object.h:601
#define FLAG_FREED
Definition: define.h:233
uint32_t count
Definition: player.h:109
void Send_With_Handling(socket_struct *ns, SockList *sl)
Definition: lowlevel.c:434
Definition: object.h:224
#define SP_RAISE_DEAD
Definition: spells.h:75
void esrv_move_object(object *pl, tag_t to, tag_t tag, long nrof)
Definition: item.c:845
char * account_trusted_host
Definition: global.h:326