Crossfire Server, Trunk
c_wiz.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 
20 #include "global.h"
21 
22 #include <ctype.h>
23 #include <stdlib.h>
24 #include <string.h>
25 #include <sys/stat.h>
26 
27 #include "sproto.h"
28 #include "spells.h"
29 #include "treasure.h"
30 #include "skills.h"
31 #include "assets.h"
32 
33 /* Defines for DM item stack **/
34 #define STACK_SIZE 50
36 enum {
41 };
42 
44 
59 static player *get_other_player_from_name(object *op, const char *name) {
60  player *pl;
61 
62  if (!name)
63  return NULL;
64 
65  for (pl = first_player; pl != NULL; pl = pl->next)
66  if (!strncmp(pl->ob->name, name, MAX_NAME))
67  break;
68 
69  if (pl == NULL) {
71  "No such player.");
72  return NULL;
73  }
74 
75  if (pl->ob == op) {
77  "You can't do that to yourself.");
78  return NULL;
79  }
80  if (pl->state != ST_PLAYING) {
82  "That player is in no state for that right now.");
83  return NULL;
84  }
85  return pl;
86 }
87 
94 static void dm_stack_pop(player *pl) {
95  if (!pl->stack_items || !pl->stack_position) {
97  "Empty stack!");
98  return;
99  }
100 
101  pl->stack_position--;
103  "Popped item from stack, %d left.",
104  pl->stack_position);
105 }
106 
119 static object *dm_stack_peek(player *pl) {
120  object *ob;
121 
122  if (!pl->stack_position) {
124  "Empty stack!");
125  return NULL;
126  }
127 
129  if (!ob) {
131  "Stacked item was removed!");
132  dm_stack_pop(pl);
133  return NULL;
134  }
135 
136  return ob;
137 }
138 
149 static void dm_stack_push(player *pl, tag_t item) {
150  if (!pl->stack_items) {
151  pl->stack_items = (tag_t *)malloc(sizeof(tag_t)*STACK_SIZE);
152  memset(pl->stack_items, 0, sizeof(tag_t)*STACK_SIZE);
153  }
154 
155  if (pl->stack_position == STACK_SIZE) {
157  "Item stack full!");
158  return;
159  }
160 
163  "Item stacked as %d.",
164  pl->stack_position);
165  pl->stack_position++;
166 }
167 
195 static object *get_dm_object(player *pl, const char **params, int *from) {
196  int item_tag, item_position;
197  object *ob;
198 
199  if (!pl)
200  return NULL;
201 
202  if (**params == '\0') {
203  if (from)
204  *from = STACK_FROM_TOP;
205  /* No parameter => get stack item */
206  return dm_stack_peek(pl);
207  }
208 
209  /* Let's clean white spaces */
210  while (**params == ' ')
211  (*params)++;
212 
213  /* Next case: number => item tag */
214  if (sscanf(*params, "%d", &item_tag)) {
215  /* Move parameter to next item */
216  while (isdigit(**params))
217  (*params)++;
218 
219  /* And skip blanks, too */
220  while (**params == ' ')
221  (*params)++;
222 
223  /* Get item */
224  ob = object_find_by_tag_global(item_tag);
225  if (!ob) {
226  if (from)
227  *from = STACK_FROM_NONE;
229  "No such item %d!",
230  item_tag);
231  return NULL;
232  }
233 
234  /* Got one, let's push it on stack */
235  dm_stack_push(pl, item_tag);
236  if (from)
237  *from = STACK_FROM_NUMBER;
238  return ob;
239  }
240 
241  /* Next case: $number => stack item */
242  if (sscanf(*params, "$%d", &item_position)) {
243  /* Move parameter to next item */
244  (*params)++;
245 
246  while (isdigit(**params))
247  (*params)++;
248  while (**params == ' ')
249  (*params)++;
250 
251  if (item_position >= pl->stack_position) {
252  if (from)
253  *from = STACK_FROM_NONE;
255  "No such stack item %d!",
256  item_position);
257  return NULL;
258  }
259 
260  ob = object_find_by_tag_global(pl->stack_items[item_position]);
261  if (!ob) {
262  if (from)
263  *from = STACK_FROM_NONE;
265  "Stack item %d was removed.",
266  item_position);
267  return NULL;
268  }
269 
270  if (from)
271  *from = item_position < pl->stack_position-1 ? STACK_FROM_STACK : STACK_FROM_TOP;
272  return ob;
273  }
274 
275  /* Next case: 'me' => return pl->ob */
276  if (!strncmp(*params, "me", 2)) {
277  if (from)
278  *from = STACK_FROM_NUMBER;
279  dm_stack_push(pl, pl->ob->count);
280 
281  /* Skip to next token */
282  (*params) += 2;
283  while (**params == ' ')
284  (*params)++;
285 
286  return pl->ob;
287  }
288 
289  /* Last case: get stack top */
290  if (from)
291  *from = STACK_FROM_TOP;
292  return dm_stack_peek(pl);
293 }
294 
305 void command_loadtest(object *op, const char *params) {
306  uint32_t x, y;
307  char buf[1024];
308 
310  "loadtest will stress server through teleporting at different map places. "
311  "Use at your own risk. Very long loop used so server may have to be reset. "
312  "type loadtest TRUE to run");
314  "{%s}",
315  params);
316  if (*params == '\0')
317  return;
318  if (strncmp(params, "TRUE", 4))
319  return;
320 
322  "gogogo");
323 
324  for (x = 0; x < settings.worldmaptilesx; x++) {
325  for (y = 0; y < settings.worldmaptilesy; y++) {
326  snprintf(buf, sizeof(buf), "/world/world_%u_%u", x+settings.worldmapstartx, y+settings.worldmapstarty);
327  command_goto(op, buf);
328  }
329  }
330 }
331 
332 static void unhide(object* op) {
333  op->contr->hidden = 0;
334  op->invisible = 1;
335  op->map->players++;
337  "You are no longer hidden from other players");
340  "%s has entered the game.", op->name);
341 }
342 
351 static void do_wizard_hide(object *op, int silent_dm) {
352  if (op->contr->hidden) {
353  unhide(op);
354  if (!silent_dm) {
357  "The Dungeon Master has arrived!");
358  }
359  } else {
360  op->contr->hidden = 1;
362  "Other players will no longer see you.");
363  op->map->players--;
364  if (!silent_dm) {
367  "The Dungeon Master is gone..");
368  }
371  "%s leaves the game.",
372  op->name);
375  "%s left the game.",
376  op->name);
377  }
378 }
379 
388 void command_hide(object *op, const char *params) {
389  (void)params;
390  do_wizard_hide(op, 0);
391 }
392 
402 static object *find_object_both(const char *params) {
403  if (params[0] == '#')
404  return object_find_by_tag_global(atol(params+1));
405  else
407 }
408 
417 void command_setgod(object *op, const char *params) {
418  object *ob;
419  const object *god;
420  char *str;
421 
422  if (*params == '\0' || !(str = strchr(params, ' '))) {
424  "Usage: set_god player god");
425  return;
426  }
427 
428  /* kill the space, and set string to the next param */
429  *str++ = '\0';
430  if (!(ob = find_object_both(params))) {
432  "Set whose god - can not find object %s?",
433  params);
434  return;
435  }
436 
437  /*
438  * Perhaps this is overly restrictive? Should we perhaps be able
439  * to rebless altars and the like?
440  */
441  if (ob->type != PLAYER) {
443  "%s is not a player - can not change its god",
444  ob->name);
445  return;
446  }
447 
448  god = find_god(str);
449  if (god == NULL) {
451  "No such god %s.",
452  str);
453  return;
454  }
455 
456  become_follower(ob, god);
457 }
458 
467 static void command_kick2(object *op, const char *params) {
468  struct pl *pl;
469 
470  for (pl = first_player; pl != NULL; pl = pl->next) {
471  if ((*params == '\0' || !strcmp(pl->ob->name, params)) && pl->ob != op) {
472  object *op;
473  int removed = 0;
474 
475  op = pl->ob;
476  if (!QUERY_FLAG(op, FLAG_REMOVED)) {
478  object_remove(op);
479  removed = 1;
480  }
481  op->direction = 0;
483  "%s is kicked out of the game.",
484  op->name);
485  strcpy(op->contr->killer, "left");
486  hiscore_check(op, 0); /* Always check score */
487 
488  /*
489  * not sure how the player would be freed, but did see
490  * a crash here - if that is the case, don't save the
491  * the player.
492  */
493  if (!removed && !QUERY_FLAG(op, FLAG_FREED)) {
494  (void)save_player(op, 0);
495  if (op->map)
496  op->map->players--;
497  }
498 #if MAP_MAXTIMEOUT
499  if (op->map)
500  op->map->timeout = MAP_TIMEOUT(op->map);
501 #endif
502  pl->socket.status = Ns_Dead;
503  }
504  }
505 }
506 
522 void command_banish(object *op, const char *params) {
523  player *pl;
524  FILE *banishfile;
525  char buf[MAX_BUF];
526  time_t now;
527 
528  if (*params == '\0') {
530  "Usage: banish <player>.");
531  return;
532  }
533 
535  if (!pl)
536  return;
537 
538  snprintf(buf, sizeof(buf), "%s/%s", settings.localdir, BANISHFILE);
539 
540  if ((banishfile = fopen(buf, "a")) == NULL) {
541  LOG(llevDebug, "Could not find file banish_file.\n");
543  "Could not find banish_file.");
544  return;
545  }
546 
547  now = time(NULL);
548  /*
549  * Record this as a comment - then we don't have to worry about changing
550  * the parsing code.
551  */
552  fprintf(banishfile, "# %s (%s) banned by %s at %s\n", pl->ob->name, pl->socket.host, op->name, ctime(&now));
553  fprintf(banishfile, "*@%s\n", pl->socket.host);
554  fclose(banishfile);
555 
556  LOG(llevDebug, "! %s banned %s from IP: %s.\n", op->name, pl->ob->name, pl->socket.host);
557 
559  "You banish %s",
560  pl->ob->name);
561 
563  "%s banishes %s from the land!",
564  op->name, pl->ob->name);
565  command_kick2(op, pl->ob->name);
566 }
567 
576 void command_kick(object *op, const char *params) {
578 }
579 
588 void command_overlay_save(object *op, const char *params) {
589  (void)params;
590  if (!op)
591  return;
592 
593  if (save_map(op->map, SAVE_MODE_OVERLAY) < 0)
595  "Overlay save error!");
596  else
598  "Current map has been saved as an overlay.");
599 }
600 
609 void command_overlay_reset(object *op, const char *params) {
610  char filename[MAX_BUF];
611  struct stat stats;
612  (void)params;
613 
615  if (!stat(filename, &stats))
616  if (!unlink(filename))
618  "Overlay successfully removed.");
619  else
621  "Overlay couldn't be removed.");
622  else
624  "No overlay for current map.");
625 }
626 
635 void command_toggle_shout(object *op, const char *params) {
636  player *pl;
637 
638  if (*params == '\0') {
640  "Usage: toggle_shout <player>.");
641  return;
642  }
643 
645  if (!pl)
646  return;
647 
648  if (pl->ob->contr->no_shout == 0) {
649  pl->ob->contr->no_shout = 1;
650 
652  "You have been muzzled by the DM!");
654  "You muzzle %s.",
655  pl->ob->name);
656 
658 
659  return;
660  }
661 
662  pl->ob->contr->no_shout = 0;
664  "You are allowed to shout and chat again.");
666  "You remove %s's muzzle.",
667  pl->ob->name);
668 }
669 
678 void command_shutdown(object *op, const char *params) {
679  if (strlen(params) == 0) {
680  /* Give DM command help and display current shutdown status. */
681  command_help(op, "shutdown");
684  MSG_TYPE_COMMAND_DM, "No shutdown is currently scheduled.");
685  } else if (shutdown_state.type == SHUTDOWN_TIME) {
686  time_t time_left = shutdown_state.time - time(NULL);
688  MSG_TYPE_COMMAND_DM, "Shutdown scheduled in %d minutes.", time_left/60);
689  } else if (shutdown_state.type == SHUTDOWN_IDLE) {
691  MSG_TYPE_COMMAND_DM, "Shutdown scheduled when there are no active players.");
692  }
693  } else if (strcmp(params, "cancel") == 0) {
696  MSG_TYPE_ADMIN_DM, "Server shutdown cancelled.");
697  LOG(llevInfo, "Server shutdown cancelled by %s.\n", op->name);
699  } else {
701  MSG_TYPE_COMMAND_ERROR, "No shutdown is pending.");
702  }
703  } else if (strncmp(params, "now", 3) == 0) {
704  /* Announce and shut down immediately. */
706  MSG_TYPE_ADMIN_DM, "This server is shutting down now!");
708  shutdown_state.time = time(NULL);
709  LOG(llevInfo, "Server shutdown initiated by %s.\n", op->name);
710  } else if (strcmp(params, "idle") == 0) {
712  MSG_TYPE_ADMIN_DM, "This server will shut down when all players leave.");
714  shutdown_state.time = 0;
716  LOG(llevInfo, "Server idle shutdown scheduled by %s.\n", op->name);
717  } else {
718  /* Schedule (but don't announce) a shutdown. */
719  int minutes = atoi(params);
720 
721  if (minutes > 0 && minutes <= 720) {
724  "Server will shut down in %d minutes.", minutes);
726  shutdown_state.time = time(NULL) + minutes * 60;
727  LOG(llevInfo, "Server shutdown scheduled in %d minutes by %s.\n", minutes, op->name);
728  } else {
731  "Please specify a reasonable time in minutes.");
732  }
733  }
734 }
735 
744 void command_goto(object *op, const char *params) {
745  if (!op)
746  return ;
747 
748  if (*params == '\0') {
750  "Go to what level?");
751  return;
752  }
753 
754  do_goto(op, params, -1, -1);
755 }
756 
765 void command_freeze(object *op, const char *params) {
766  int ticks;
767  player *pl;
768 
769  if (*params == '\0') {
771  "Usage: freeze [ticks] <player>.");
772  return;
773  }
774 
775  ticks = atoi(params);
776  if (ticks) {
777  while ((isdigit(*params) || isspace(*params)) && *params != 0)
778  params++;
779  if (*params == 0) {
781  "Usage: freeze [ticks] <player>.");
782  return;
783  }
784  } else
785  ticks = 100;
786 
788  if (!pl)
789  return;
790 
792  "You have been frozen by the DM!");
793 
795  "You freeze %s for %d ticks",
796  pl->ob->name, ticks);
797 
798  pl->ob->speed_left = -(pl->ob->speed*ticks);
799 }
800 
809 int player_arrest(object *who) {
810  object *dummy;
811  mapstruct *cur;
812  int x, y;
813 
814  if (who->type != PLAYER)
815  return -3;
816 
817  dummy = get_jail_exit(who);
818  if (!dummy) {
819  return -1;
820  }
821  cur = who->map;
822  x = who->x;
823  y = who->y;
824  enter_exit(who, dummy);
826 
827  if (cur == who->map && x == who->x && y == who->y)
828  return -2;
829 
830  return 0;
831 }
832 
841 void command_arrest(object *op, const char *params) {
842  player *pl;
843  int ret;
844 
845  if (!op)
846  return;
847  if (*params == '\0') {
849  "Usage: arrest <player>.");
850  return;
851  }
853  if (!pl)
854  return;
855 
856  ret = player_arrest(pl->ob);
857  if (ret == -1) {
858  /* we have nowhere to send the prisoner....*/
860  "Can't jail player, there is no map to hold them");
861  return;
862  }
863  if (ret == -2) {
864  /* something prevented jailing the player */
866  "Can't jail player, map loading issue or already in jail's position");
867  return;
868 
869  }
870 
872  "You have been arrested.");
874  "Jailed %s",
875  pl->ob->name);
876  LOG(llevInfo, "Player %s arrested by %s\n", pl->ob->name, op->name);
877 }
878 
886 void command_summon(object *op, const char *params) {
887  int i;
888  object *dummy;
889  player *pl;
890 
891  if (!op)
892  return;
893 
894  if (*params == '\0') {
896  "Usage: summon <player>.");
897  return;
898  }
899 
901  if (!pl)
902  return;
903 
904  i = object_find_free_spot(op, op->map, op->x, op->y, 1, 9);
905  if (i == -1) {
907  "Can not find a free spot to place summoned player.");
908  return;
909  }
910 
911  dummy = object_new();
912  EXIT_PATH(dummy) = add_string(op->map->path);
913  EXIT_X(dummy) = op->x+freearr_x[i];
914  EXIT_Y(dummy) = op->y+freearr_y[i];
915  enter_exit(pl->ob, dummy);
918  "You are summoned.");
920  "You summon %s",
921  pl->ob->name);
922 }
923 
932 /* mids 01/16/2002 */
933 void command_teleport(object *op, const char *params) {
934  int i;
935  object *dummy;
936  player *pl;
937 
938  if (!op)
939  return;
940 
941  if (*params == '\0') {
943  "Usage: teleport <player>.");
944  return;
945  }
946 
948  if (!pl) {
950  "No such player or ambiguous name.");
951  return;
952  }
953 
954  i = object_find_free_spot(pl->ob, pl->ob->map, pl->ob->x, pl->ob->y, 1, 9);
955  if (i == -1) {
957  "Can not find a free spot to teleport to.");
958  return;
959  }
960 
961  dummy = object_new();
962  EXIT_PATH(dummy) = add_string(pl->ob->map->path);
963  EXIT_X(dummy) = pl->ob->x+freearr_x[i];
964  EXIT_Y(dummy) = pl->ob->y+freearr_y[i];
965  enter_exit(op, dummy);
967  if (!op->contr->hidden)
969  "You see a portal open.");
971  "You teleport to %s",
972  pl->ob->name);
973 }
974 
999 void command_create(object *op, const char *params) {
1000  object *tmp = NULL;
1001  uint32_t i;
1002  int magic, set_magic = 0, set_nrof = 0, gotquote, gotspace;
1003  uint32_t nrof;
1004  char *cp, *bp, *bp2, *bp3, *endline, cpy[MAX_BUF];
1005  archetype *at, *at_spell = NULL;
1006  const artifact *art = NULL;
1007 
1008  if (!op)
1009  return;
1010 
1011  if (*params == '\0') {
1013  "Usage: create [nr] [magic] <archetype> [ of <artifact>] [variable_to_patch setting]");
1014  return;
1015  }
1016  safe_strncpy(cpy, params, sizeof(cpy));
1017  bp = cpy;
1018 
1019  /* We need to know where the line ends */
1020  endline = bp+strlen(bp);
1021 
1022  if (sscanf(bp, "%u ", &nrof)) {
1023  if ((bp = strchr(cpy, ' ')) == NULL) {
1025  "Usage: create [nr] [magic] <archetype> [ of <artifact>] [variable_to_patch setting]");
1026  return;
1027  }
1028  bp++;
1029  set_nrof = 1;
1030  LOG(llevDebug, "%s creates: (%u) %s\n", op->name, nrof, bp);
1031  }
1032  if (sscanf(bp, "%d ", &magic)) {
1033  if ((bp = strchr(bp, ' ')) == NULL) {
1035  "Usage: create [nr] [magic] <archetype> [ of <artifact>] [variable_to_patch setting]");
1036  return;
1037  }
1038  bp++;
1039  set_magic = 1;
1040  LOG(llevDebug, "%s creates: (%d) (%d) %s\n", op->name, nrof, magic, bp);
1041  }
1042  if ((cp = strstr(bp, " of ")) != NULL) {
1043  *cp = '\0';
1044  cp += 4;
1045  }
1046  for (bp2 = bp; *bp2; bp2++) {
1047  if (*bp2 == ' ') {
1048  *bp2 = '\0';
1049  bp2++;
1050  break;
1051  }
1052  }
1053 
1054  if ((at = try_find_archetype(bp)) == NULL) {
1056  "No such archetype.");
1057  return;
1058  }
1059 
1060  if (cp) {
1061  char spell_name[MAX_BUF], *fsp = NULL;
1062 
1063  /*
1064  * Try to find a spell object for this. Note that
1065  * we also set up spell_name which is only
1066  * the first word.
1067  */
1068 
1069  at_spell = try_find_archetype(cp);
1070  if (!at_spell || at_spell->clone.type != SPELL)
1071  at_spell = find_archetype_by_object_name(cp);
1072  if (!at_spell || at_spell->clone.type != SPELL) {
1073  safe_strncpy(spell_name, cp, sizeof(spell_name));
1074  fsp = strchr(spell_name, ' ');
1075  if (fsp) {
1076  *fsp = 0;
1077  fsp++;
1078  at_spell = try_find_archetype(spell_name);
1079 
1080  /* Got a spell, update the first string pointer */
1081  if (at_spell && at_spell->clone.type == SPELL)
1082  bp2 = cp+strlen(spell_name)+1;
1083  else
1084  at_spell = NULL;
1085  } else
1086  at_spell = NULL;
1087  }
1088 
1089  /* OK - we didn't find a spell - presume the 'of'
1090  * in this case means its an artifact.
1091  */
1092  if (!at_spell) {
1093  if (find_artifactlist(at->clone.type) == NULL) {
1095  "No artifact list for type %d\n",
1096  at->clone.type);
1097  } else {
1098  art = find_artifactlist(at->clone.type)->items;
1099 
1100  do {
1101  if (!strcmp(art->item->name, cp) && legal_artifact_combination(&at->clone, art))
1102  break;
1103  art = art->next;
1104  } while (art != NULL);
1105  if (!art) {
1107  "No such artifact ([%d] of %s)",
1108  at->clone.type, cp);
1109  }
1110  }
1111  LOG(llevDebug, "%s creates: (%d) (%d) (%s) of (%s)\n", op->name, set_nrof ? nrof : 0, set_magic ? magic : 0, bp, cp);
1112  }
1113  } /* if cp */
1114 
1115  /* rods and potions can get their spell from the artifact */
1116  if ((at->clone.type == ROD || at->clone.type == POTION) && !at_spell && (!art || !art->item->other_arch)) {
1118  "Unable to find spell %s for object that needs it, or it is of wrong type",
1119  cp);
1120  return;
1121  }
1122  if ((at->clone.type == WAND || at->clone.type == SCROLL || at->clone.type == SPELLBOOK)
1123  && !at_spell) {
1125  "Unable to find spell %s for object that needs it, or it is of wrong type",
1126  cp);
1127  return;
1128  }
1129 
1130  /*
1131  * Rather than have two different blocks with a lot of similar code,
1132  * just create one object, do all the processing, and then determine
1133  * if that one object should be inserted or if we need to make copies.
1134  */
1135  tmp = object_create_arch(at);
1136  if (settings.real_wiz == FALSE)
1138  if (set_magic)
1139  set_abs_magic(tmp, magic);
1140  if (art)
1142  if (!is_identifiable_type(tmp)) {
1145  }
1146 
1147  /*
1148  * This entire block here tries to find variable pairings,
1149  * eg, 'hp 4' or the like. The mess here is that values
1150  * can be quoted (eg "my cool sword"); So the basic logic
1151  * is we want to find two spaces, but if we got a quote,
1152  * any spaces there don't count.
1153  */
1154  while (*bp2 && bp2 <= endline) {
1155  gotspace = 0;
1156  gotquote = 0;
1157  /* find the first quote */
1158  for (bp3 = bp2; *bp3 && gotspace < 2 && gotquote < 2; bp3++) {
1159  /* Found a quote - now lets find the second one */
1160  if (*bp3 == '"') {
1161  *bp3 = ' ';
1162  bp2 = bp3+1; /* Update start of string */
1163  bp3++;
1164  gotquote++;
1165  while (*bp3) {
1166  if (*bp3 == '"') {
1167  *bp3 = '\0';
1168  gotquote++;
1169  } else
1170  bp3++;
1171  }
1172  } else if (*bp3 == ' ') {
1173  gotspace++;
1174  }
1175  }
1176 
1177  /*
1178  * If we got two spaces, send the second one to null.
1179  * if we've reached the end of the line, increase gotspace -
1180  * this is perfectly valid for the list entry listed.
1181  */
1182  if (gotspace == 2 || gotquote == 2) {
1183  bp3--; /* Undo the extra increment */
1184  *bp3 = '\0';
1185  } else if (*bp3 == '\0')
1186  gotspace++;
1187 
1188  if ((gotquote && gotquote != 2)
1189  || (gotspace != 2 && gotquote != 2)) {
1190  /*
1191  * Unfortunately, we've clobbered lots of values, so printing
1192  * out what we have probably isn't useful. Break out, because
1193  * trying to recover is probably won't get anything useful
1194  * anyways, and we'd be confused about end of line pointers
1195  * anyways.
1196  */
1198  "Malformed create line: %s",
1199  bp2);
1200  break;
1201  }
1202  /* bp2 should still point to the start of this line,
1203  * with bp3 pointing to the end
1204  */
1205  if (set_variable(tmp, bp2) == -1)
1207  "Unknown variable %s",
1208  bp2);
1209  else
1211  "(%s#%d)->%s",
1212  tmp->name, tmp->count, bp2);
1213  bp2 = bp3+1;
1214  }
1215 
1216  if (at->clone.nrof) {
1217  if (at_spell)
1219 
1220  if (set_nrof)
1221  tmp->nrof = nrof;
1222 
1223  if (at->clone.randomitems != NULL && !at_spell) {
1224  create_treasure(at->clone.randomitems, tmp, 0, op->map->difficulty, 0);
1225  if (QUERY_FLAG(tmp, FLAG_MONSTER)) {
1227  }
1228  }
1229 
1230  /* Multipart objects can't be in inventory, put'em on floor. */
1231  if (!tmp->more) {
1233  } else {
1234  object_insert_in_map_at(tmp, op->map, op, 0, op->x, op->y);
1235  }
1236 
1237  /* Let's put this created item on stack so dm can access it easily. */
1238  dm_stack_push(op->contr, tmp->count);
1239 
1240  return;
1241  }
1242 
1243  for (i = 0; i < (set_nrof ? nrof : 1); i++) {
1244  archetype *atmp;
1245  object *prev = NULL, *head = NULL, *dup;
1246 
1247  for (atmp = at; atmp != NULL; atmp = atmp->more) {
1248  dup = arch_to_object(atmp);
1249 
1250  if (at_spell)
1251  object_insert_in_ob(arch_to_object(at_spell), dup);
1252 
1253  /*
1254  * The head is what contains all the important bits,
1255  * so just copying it over should be fine.
1256  */
1257  if (head == NULL) {
1258  head = dup;
1259  object_copy(tmp, dup);
1260  }
1261  if (settings.real_wiz == FALSE)
1262  SET_FLAG(dup, FLAG_WAS_WIZ);
1263  dup->x = op->x+dup->arch->clone.x;
1264  dup->y = op->y+dup->arch->clone.y;
1265  dup->map = op->map;
1266 
1267  if (head != dup) {
1268  dup->head = head;
1269  prev->more = dup;
1270  }
1271  prev = dup;
1272  }
1273 
1274  if (QUERY_FLAG(head, FLAG_ALIVE)) {
1275  object *check = head;
1276  int size_x = 0;
1277  int size_y = 0;
1278 
1279  while (check) {
1280  size_x = MAX(size_x, check->arch->clone.x);
1281  size_y = MAX(size_y, check->arch->clone.y);
1282  check = check->more;
1283  }
1284 
1285  if (out_of_map(op->map, head->x+size_x, head->y+size_y)) {
1286  if (head->x < size_x || head->y < size_y) {
1287  dm_stack_pop(op->contr);
1290  "Object too big to insert in map, or wrong position.");
1292  return;
1293  }
1294 
1295  check = head;
1296  while (check) {
1297  check->x -= size_x;
1298  check->y -= size_y;
1299  check = check->more;
1300  }
1301  }
1302 
1303  object_insert_in_map_at(head, op->map, op, 0, head->x, head->y);
1304  } else
1305  head = object_insert_in_ob(head, op);
1306 
1307  /* Let's put this created item on stack so dm can access it easily. */
1308  /* Wonder if we really want to push all of these, but since
1309  * things like rods have nrof 0, we want to cover those.
1310  */
1311  dm_stack_push(op->contr, head->count);
1312 
1313  if (at->clone.randomitems != NULL && !at_spell) {
1314  create_treasure(at->clone.randomitems, head, 0, op->map->difficulty, 0);
1315  if (QUERY_FLAG(head, FLAG_MONSTER)) {
1317  }
1318  }
1319  }
1320 
1321  /* free the one we used to copy */
1323 }
1324 
1325 /*
1326  * Now follows dm-commands which are also acceptable from sockets
1327  */
1328 
1337 void command_inventory(object *op, const char *params) {
1338  object *tmp;
1339  int i;
1340 
1341  if (*params == '\0') {
1342  inventory(op, NULL);
1343  return;
1344  }
1345 
1346  if (!sscanf(params, "%d", &i) || (tmp = object_find_by_tag_global(i)) == NULL) {
1348  "Inventory of what object (nr)?");
1349  return;
1350  }
1351 
1352  inventory(op, tmp);
1353 }
1354 
1367 void command_skills(object *op, const char *params) {
1368  show_skills(op, *params == '\0' ? NULL : params);
1369 }
1370 
1379 void command_dump(object *op, const char *params) {
1380  object *tmp;
1381  StringBuffer *sb;
1382  char *diff;
1383 
1384  tmp = get_dm_object(op->contr, &params, NULL);
1385  if (!tmp)
1386  return;
1387 
1388  sb = stringbuffer_new();
1389  object_dump(tmp, sb);
1390  diff = stringbuffer_finish(sb);
1392  free(diff);
1395  "Object is marked original");
1396 }
1397 
1407 void command_mon_aggr(object *op, const char *params) {
1408  (void)params;
1409  if (op->enemy || !QUERY_FLAG(op, FLAG_UNAGGRESSIVE)) {
1410  object_set_enemy(op, NULL);
1413  "Aggression turned OFF");
1414  } else {
1418  "Aggression turned ON");
1419  }
1420 }
1421 
1434 void command_possess(object *op, const char *params) {
1435  object *victim;
1436  player *pl;
1437  int i;
1438  char buf[MAX_BUF];
1439 
1440  victim = NULL;
1441  if (*params != '\0') {
1442  if (sscanf(params, "%d", &i))
1444  else if (sscanf(params, "%s", buf))
1446  }
1447  if (victim == NULL) {
1449  "Patch what object (nr)?");
1450  return;
1451  }
1452 
1453  if (victim == op) {
1455  "As insane as you are, I cannot allow you to possess yourself.");
1456  return;
1457  }
1458 
1459  /* make the switch */
1460  pl = op->contr;
1461  victim->contr = pl;
1462  pl->ob = victim;
1463  victim->type = PLAYER;
1465 
1466  /* basic patchup */
1467  /* The use of hard coded values is terrible. Note
1468  * that really, to be fair, this shouldn't get changed at
1469  * all - if you are possessing a kobold, you should have the
1470  * same limitations. As it is, as more body locations are added,
1471  * this will give this player more locations than perhaps
1472  * they should be allowed.
1473  */
1474  for (i = 0; i < NUM_BODY_LOCATIONS; i++)
1475  if (i == 1 || i == 6 || i == 8 || i == 9)
1476  victim->body_info[i] = 2;
1477  else
1478  victim->body_info[i] = 1;
1479 
1480  esrv_new_player(pl, 80); /* just pick a weight, we don't care */
1482 
1483  fix_object(victim);
1484 
1486 }
1487 
1495 void command_patch(object *op, const char *params) {
1496  const char *arg, *arg2;
1497  object *tmp;
1498 
1499  tmp = get_dm_object(op->contr, &params, NULL);
1500  if (!tmp)
1501  /* Player already informed of failure */
1502  return;
1503 
1504  /* params set to first value by get_dm_default */
1505  arg = params;
1506  if (*arg == '\0') {
1508  "Patch what values?");
1509  return;
1510  }
1511 
1512  if ((arg2 = strchr(arg, ' ')))
1513  arg2++;
1514  if (settings.real_wiz == FALSE)
1515  SET_FLAG(tmp, FLAG_WAS_WIZ); /* To avoid cheating */
1516  if (set_variable(tmp, arg) == -1)
1518  "Unknown variable %s",
1519  arg);
1520  else {
1522  "(%s#%d)->%s=%s",
1523  tmp->name, tmp->count, arg, arg2);
1524  }
1525 }
1526 
1527 static void reset_faces_sent(struct socket_struct *socket) {
1528  free(socket->faces_sent);
1529  socket->faces_sent = calloc(sizeof(socket->faces_sent), get_faces_count());
1530  socket->faces_sent_len = get_faces_count();
1531 }
1532 
1533 void command_recollect(object *op, const char *params) {
1534  (void)op;
1535  (void)params;
1536  load_assets();
1537 
1538  // Clear sent faces for connected sockets so that clients see new faces.
1539  for (int i = 0; i < socket_info.allocated_sockets; i++) {
1540  if (init_sockets[i].status == Ns_Add) {
1542  }
1543  }
1544 
1545  player *next;
1546  for (player *pl = first_player; pl != NULL; pl = next) {
1548  next = pl->next;
1549  }
1550 }
1551 
1560 void command_remove(object *op, const char *params) {
1561  object *tmp;
1562  int from;
1563 
1564  tmp = get_dm_object(op->contr, &params, &from);
1565  if (!tmp) {
1567  "Remove what object (nr)?");
1568  return;
1569  }
1570 
1571  if (tmp->type == PLAYER) {
1573  "Unable to remove a player!");
1574  return;
1575  }
1576 
1577  if (QUERY_FLAG(tmp, FLAG_REMOVED)) {
1578  char name[MAX_BUF];
1579 
1582  "%s is already removed!",
1583  name);
1584  return;
1585  }
1586 
1587  if (from != STACK_FROM_STACK)
1588  /* Item is either stack top, or is a number thus is now stack top, let's remove it */
1589  dm_stack_pop(op->contr);
1590 
1591  /* Always work on the head - otherwise object will get in odd state */
1592  tmp = HEAD(tmp);
1593  if (tmp->speed != 0) {
1594  tmp->speed = 0;
1596  }
1597  object_remove(tmp);
1598 }
1599 
1607 void command_free(object *op, const char *params) {
1608  object *tmp;
1609  int from;
1610 
1611  tmp = get_dm_object(op->contr, &params, &from);
1612 
1613  if (!tmp) {
1615  "Free what object (nr)?");
1616  return;
1617  }
1618 
1619  if (from != STACK_FROM_STACK)
1620  /* Item is either stack top, or is a number thus is now stack top, let's remove it */
1621  dm_stack_pop(op->contr);
1622 
1623  tmp = HEAD(tmp);
1624  if (!QUERY_FLAG(tmp, FLAG_REMOVED)) {
1626  "Warning: item was not removed, will do so now.");
1627  object_remove(tmp);
1628  }
1629 
1631 }
1632 
1633 void command_accountpasswd(object *op, const char *params) {
1634  char account_name[MAX_BUF], newpw[MAX_BUF];
1635  // Password may contain spaces, so use %[^\n] format string.
1636  if (sscanf(params, "%s %[^\n]", account_name, newpw) != 2) {
1638  "Usage: accountpasswd ACCOUNT PASSWORD");
1639  return;
1640  }
1641 
1642  int ret = account_change_password(account_name, NULL, newpw);
1643  switch (ret) {
1644  case 0:
1646  "Updated account password.");
1647  return;
1648  case 1:
1650  "Invalid characters in new password.");
1651  return;
1652  case 2:
1654  "Invalid characters in new password.");
1655  return;
1656  default:
1658  "Error changing password.");
1659  return;
1660  }
1661 }
1662 
1671 void command_addexp(object *op, const char *params) {
1672  char buf[MAX_BUF], skill[MAX_BUF];
1673  int i, q;
1674  object *skillob = NULL;
1675  player *pl;
1676 
1677  skill[0] = '\0';
1678  if ((*params == '\0')
1679  || (strlen(params) > MAX_BUF)
1680  || ((q = sscanf(params, "%s %d %[^\r\n]", buf, &i, skill)) < 2)) {
1682  "Usage: addexp player quantity [skill].");
1683  return;
1684  }
1685 
1686  for (pl = first_player; pl != NULL; pl = pl->next)
1687  if (!strncmp(pl->ob->name, buf, MAX_NAME))
1688  break;
1689 
1690  if (pl == NULL) {
1692  "No such player.");
1693  return;
1694  }
1695 
1696  if (q >= 3) {
1697  skillob = find_skill_by_name(pl->ob, skill);
1698  if (!skillob) {
1700  "Unable to find skill %s in %s",
1701  skill, buf);
1702  return;
1703  }
1704 
1705  i = check_exp_adjust(skillob, i);
1706  skillob->stats.exp += i;
1707  calc_perm_exp(skillob);
1708  player_lvl_adj(pl->ob, skillob);
1709  }
1710 
1711  pl->ob->stats.exp += i;
1712  calc_perm_exp(pl->ob);
1713  player_lvl_adj(pl->ob, NULL);
1714 
1715  if (settings.real_wiz == FALSE)
1717 }
1718 
1727 void command_speed(object *op, const char *params) {
1728  int i;
1729 
1730  if (*params == '\0' || !sscanf(params, "%d", &i)) {
1732  "Current speed is %d",
1733  tick_duration);
1734  return;
1735  }
1736 
1737  set_tick_duration(i);
1738  reset_sleep();
1740  "The speed is changed to %d.",
1741  i);
1742 }
1743 
1744 /**************************************************************************/
1745 /* Mods made by Tyler Van Gorder, May 10-13, 1992. */
1746 /* CSUChico : tvangod@cscihp.ecst.csuchico.edu */
1747 /**************************************************************************/
1748 
1757 void command_stats(object *op, const char *params) {
1758  player *pl;
1759 
1760  if (*params == '\0') {
1762  "Who?");
1763  return;
1764  }
1765 
1767  if (pl == NULL) {
1769  "No such player.");
1770  return;
1771  }
1772 
1774  "[Fixed]Statistics for %s:", pl->ob->name);
1775 
1777  "[fixed]Str : %-2d H.P. : %-4d MAX : %d",
1778  pl->ob->stats.Str, pl->ob->stats.hp, pl->ob->stats.maxhp);
1779 
1781  "[fixed]Dex : %-2d S.P. : %-4d MAX : %d",
1782  pl->ob->stats.Dex, pl->ob->stats.sp, pl->ob->stats.maxsp);
1783 
1785  "[fixed]Con : %-2d AC : %-4d WC : %d",
1786  pl->ob->stats.Con, pl->ob->stats.ac, pl->ob->stats.wc);
1787 
1789  "[fixed]Int : %-2d Damage : %d",
1790  pl->ob->stats.Int, pl->ob->stats.dam);
1791 
1793  "[fixed]Wis : %-2d EXP : %"FMT64,
1794  pl->ob->stats.Wis, pl->ob->stats.exp);
1795 
1797  "[fixed]Pow : %-2d Grace : %d",
1798  pl->ob->stats.Pow, pl->ob->stats.grace);
1799 
1801  "[fixed]Cha : %-2d Food : %d",
1802  pl->ob->stats.Cha, pl->ob->stats.food);
1803 }
1804 
1814 void command_abil(object *op, const char *params) {
1815  char thing[20], thing2[20];
1816  int iii;
1817  player *pl;
1818 
1819  iii = 0;
1820  thing[0] = '\0';
1821  thing2[0] = '\0';
1822  if (*params == '\0'
1823  || sscanf(params, "%s %s %d", thing, thing2, &iii) != 3
1824  || thing[0] == '\0') {
1826  "Who?");
1827  return;
1828  }
1829 
1830  if (thing2[0] == '\0') {
1832  "You can't change that.");
1833  return;
1834  }
1835 
1836  if (iii < MIN_STAT || iii > settings.max_stat) {
1838  "Illegal range of stat.\n");
1839  return;
1840  }
1841 
1842  for (pl = first_player; pl != NULL; pl = pl->next) {
1843  if (!strcmp(pl->ob->name, thing)) {
1844  if (settings.real_wiz == FALSE)
1846  if (!strcmp("str", thing2))
1847  pl->ob->stats.Str = iii, pl->orig_stats.Str = iii;
1848  if (!strcmp("dex", thing2))
1849  pl->ob->stats.Dex = iii, pl->orig_stats.Dex = iii;
1850  if (!strcmp("con", thing2))
1851  pl->ob->stats.Con = iii, pl->orig_stats.Con = iii;
1852  if (!strcmp("wis", thing2))
1853  pl->ob->stats.Wis = iii, pl->orig_stats.Wis = iii;
1854  if (!strcmp("cha", thing2))
1855  pl->ob->stats.Cha = iii, pl->orig_stats.Cha = iii;
1856  if (!strcmp("int", thing2))
1857  pl->ob->stats.Int = iii, pl->orig_stats.Int = iii;
1858  if (!strcmp("pow", thing2))
1859  pl->ob->stats.Pow = iii, pl->orig_stats.Pow = iii;
1861  "%s has been altered.",
1862  pl->ob->name);
1863  fix_object(pl->ob);
1864  return;
1865  }
1866  }
1867 
1869  "No such player.");
1870 }
1871 
1880 void command_reset(object *op, const char *params) {
1881  mapstruct *m;
1882  object *dummy = NULL, *tmp = NULL;
1883  char path[HUGE_BUF];
1884  const char *space, *confirmation = NULL;
1885  int res = 0;
1886 
1887  if (*params == '\0') {
1889  MSG_TYPE_COMMAND_ERROR, "Which map should be reset?");
1890  return;
1891  }
1892 
1893  space = strchr(params, ' ');
1894  if (space != NULL) {
1895  confirmation = params;
1896  params = space + 1;
1897  }
1898 
1899  /* Use the DM's map if the current map was given. */
1900  if (strcmp(params, ".") == 0) {
1901  strlcpy(path, op->map->path, sizeof(path));
1902  } else {
1903  path_combine_and_normalize(op->map->path, params, path, sizeof(path));
1904  }
1905 
1906  m = has_been_loaded(path);
1907  if (m == NULL) {
1909  MSG_TYPE_COMMAND_ERROR, "No such map.");
1910  return;
1911  }
1912 
1913  if (confirmation) {
1914  if (m->unique && (op->map == m)) {
1917  "Cannot reset a unique player map while on it. Use "
1918  "'reset full-reset %s' while standing somewhere else.",
1919  m->path);
1920  return;
1921  }
1922 
1923  if (strncmp("full-reset", confirmation, strlen("full-reset"))) {
1925  MSG_TYPE_COMMAND_ERROR, "Confirm using 'full-reset'.");
1926  return;
1927  }
1928  }
1929 
1930  /* Forbid using reset on our own map when we're in a transport, as
1931  * it has the displeasant effect of crashing the server.
1932  * - gros, July 25th 2006 */
1933  if ((op->contr && op->contr->transport) && (op->map == m)) {
1935  "You need to disembark first.");
1936  return;
1937  }
1938 
1939  strlcpy(path, m->path, sizeof(path));
1940 
1941  if (m->in_memory != MAP_SWAPPED) {
1942  if (m->in_memory != MAP_IN_MEMORY) {
1943  LOG(llevError, "Tried to swap out map which was not in memory.\n");
1944  return;
1945  }
1946 
1947  /*
1948  * Only attempt to remove the player that is doing the reset, and not other
1949  * players or wiz's.
1950  */
1951  if (op->map == m) {
1952  if (strncmp(m->path, "/random/", 8) == 0) {
1953  /* This is not a very satisfying solution - it would be much better
1954  * to recreate a random map with the same seed value as the old one.
1955  * Unfortunately, I think recreating the map would require some
1956  * knowledge about its 'parent', which appears very non-trivial to
1957  * me.
1958  * On the other hand, this should prevent the freeze that this
1959  * situation caused. - gros, 26th July 2006.
1960  */
1962  "You cannot reset a random map when inside it.");
1963  return;
1964  }
1965 
1966  dummy = object_new();
1967  dummy->map = NULL;
1968  EXIT_X(dummy) = op->x;
1969  EXIT_Y(dummy) = op->y;
1970  EXIT_PATH(dummy) = add_string(op->map->path);
1971  object_remove(op);
1972  op->map = NULL;
1973  tmp = op;
1974  }
1975  res = swap_map(m);
1976  }
1977 
1978  if (res < 0 || m->in_memory != MAP_SWAPPED) {
1979  player *pl;
1980  int playercount = 0;
1981 
1982  /* Need to re-insert player if swap failed for some reason */
1983  if (tmp) {
1984  object_insert_in_map_at(op, m, NULL, 0, op->x, op->y);
1986  }
1987 
1988  if (res < 0 && res != SAVE_ERROR_PLAYER)
1989  /* no need to warn if player on map, code below checks that. */
1991  "Reset failed, error code: %d.", res);
1992  else {
1994  "Reset failed, couldn't swap map, the following players are on it:");
1995  for (pl = first_player; pl != NULL; pl = pl->next) {
1996  if (pl->ob->map == m && pl->ob != op) {
1998  pl->ob->name);
1999  playercount++;
2000  }
2001  }
2002  if (!playercount)
2004  "hmm, I don't see any other players on this map, something else is the problem.");
2005  return;
2006  }
2007  }
2008 
2009  /* Here, map reset succeeded. */
2010 
2011  if (m && m->in_memory == MAP_SWAPPED) {
2012  if (confirmation) {
2014  LOG(llevDebug, "DM %s fully resetting map %s.\n", op->name, m->path);
2015  } else
2016  LOG(llevDebug, "DM %s resetting map %s.\n", op->name, m->path);
2017 
2018  /* setting this effectively causes an immediate reload */
2019  m->reset_time = 1;
2020  flush_old_maps();
2021  }
2022 
2023  /* Display the appropriate success message. */
2024  if (confirmation) {
2026  MSG_TYPE_COMMAND_DM, "Fully resetting map %s.", path);
2027  } else {
2029  MSG_TYPE_COMMAND_DM, "Resetting map %s.", path);
2030  }
2031 
2032  if (tmp) {
2033  enter_exit(tmp, dummy);
2035  }
2036 
2037  /* Remind the DM how to fully reset the map. */
2038  if (confirmation == NULL) {
2041  "Use 'reset full-reset %s' to fully reset the map.", params);
2042  }
2043 }
2044 
2053 void command_nowiz(object *op, const char *params) { /* 'noadm' is alias */
2054  (void)params;
2058 
2059  if (settings.real_wiz == TRUE)
2061  if (op->contr->hidden) {
2062  unhide(op);
2063  } else
2065  "The Dungeon Master is gone..");
2066 
2067  update_los(op);
2068 }
2069 
2090 static int checkdm(object *op, const char *pl_name, const char *pl_passwd, const char *pl_host) {
2091  FILE *dmfile;
2092  char buf[MAX_BUF];
2093  char line_buf[160], name[160], passwd[160], host[160];
2094 
2095 #ifdef RESTRICTIVE_DM
2096  *pl_name = op->name ? op->name : "*";
2097 #else
2098  (void)op;
2099 #endif
2100 
2101  snprintf(buf, sizeof(buf), "%s/%s", settings.confdir, DMFILE);
2102  if ((dmfile = fopen(buf, "r")) == NULL) {
2103  LOG(llevDebug, "Could not find DM file.\n");
2104  return 0;
2105  }
2106 
2107  while (fgets(line_buf, 160, dmfile) != NULL) {
2108  // Skip empty lines as well as commented ones.
2109  if (line_buf[0] == '#' || line_buf[0] == '\n')
2110  continue;
2111  if (sscanf(line_buf, "%[^:]:%[^:]:%s\n", name, passwd, host) != 3) {
2112  LOG(llevError, "Warning - malformed dm file entry: %s\n", line_buf);
2113  } else if ((!strcmp(name, "*") || (pl_name && !strcmp(pl_name, name)))
2114  && (!strcmp(passwd, "*") || !strcmp(passwd, pl_passwd))
2115  && (!strcmp(host, "*") || !strcmp(host, pl_host))) {
2116  fclose(dmfile);
2117  return (1);
2118  }
2119  }
2120  fclose(dmfile);
2121  return (0);
2122 }
2123 
2138 static int do_wizard_dm(object *op, const char *params, int silent) {
2139  if (!op->contr)
2140  return 0;
2141 
2142  if (QUERY_FLAG(op, FLAG_WIZ)) {
2144  "You are already the Dungeon Master!");
2145  return 0;
2146  }
2147 
2148  if (checkdm(op, op->name, (*params != '\0' ? params : "*"), op->contr->socket.host)) {
2149  SET_FLAG(op, FLAG_WIZ);
2154  "Ok, you are the Dungeon Master!");
2155  /*
2156  * Remove setting flying here - that won't work, because next
2157  * fix_object() is called that will get cleared - proper solution
2158  * is probably something like a wiz_force which gives that and any
2159  * other desired abilities.
2160  */
2161  clear_los(op->contr);
2162 
2163  if (!silent)
2166  "The Dungeon Master has arrived!");
2167 
2168  return 1;
2169  }
2170 
2172  "Sorry Pal, I don't think so.");
2173  return 0;
2174 }
2175 
2187 void command_dm(object *op, const char *params) {
2188  do_wizard_dm(op, params, 0);
2189 }
2190 
2199 void command_invisible(object *op, const char *params) {
2200  (void)params;
2201  if (op) {
2202  op->invisible += 100;
2205  "You turn invisible.");
2206  }
2207 }
2208 
2226 static object *get_spell_by_name(object *op, const char *spell_name) {
2227  archetype *ar;
2228  archetype *found;
2229  int conflict_found;
2230  size_t spell_name_length;
2231 
2232  /* First check for full name matches. */
2233  conflict_found = 0;
2234  found = NULL;
2235  for (ar = get_next_archetype(NULL); ar != NULL; ar = get_next_archetype(ar)) {
2236  if (ar->clone.type != SPELL)
2237  continue;
2238 
2239  if (strncmp(ar->name, "spelldirect_", 12) == 0)
2240  continue;
2241 
2242  if (strcmp(ar->clone.name, spell_name) != 0)
2243  continue;
2244 
2245  if (found != NULL) {
2246  if (!conflict_found) {
2247  conflict_found = 1;
2249  "More than one archetype matches the spell name %s:",
2250  spell_name);
2252  "- %s",
2253  found->name);
2254  }
2256  "- %s",
2257  ar->name);
2258  continue;
2259  }
2260 
2261  found = ar;
2262  }
2263 
2264  /* No match if more more than one archetype matches. */
2265  if (conflict_found)
2266  return NULL;
2267 
2268  /* Return if exactly one archetype matches. */
2269  if (found != NULL)
2270  return arch_to_object(found);
2271 
2272  /* No full match found: now check for partial matches. */
2273  spell_name_length = strlen(spell_name);
2274  conflict_found = 0;
2275  found = NULL;
2276 
2277  for (ar = get_next_archetype(NULL); ar != NULL; ar = get_next_archetype(ar)) {
2278  if (ar->clone.type != SPELL)
2279  continue;
2280 
2281  if (strncmp(ar->name, "spelldirect_", 12) == 0)
2282  continue;
2283 
2284  if (strncmp(ar->clone.name, spell_name, spell_name_length) != 0)
2285  continue;
2286 
2287  if (found != NULL) {
2288  if (!conflict_found) {
2289  conflict_found = 1;
2291  "More than one spell matches %s:",
2292  spell_name);
2294  "- %s",
2295  found->clone.name);
2296  }
2298  "- %s",
2299  ar->clone.name);
2300  continue;
2301  }
2302 
2303  found = ar;
2304  }
2305 
2306  /* No match if more more than one archetype matches. */
2307  if (conflict_found)
2308  return NULL;
2309 
2310  /* Return if exactly one archetype matches. */
2311  if (found != NULL)
2312  return arch_to_object(found);
2313 
2314  /* No spell found: just print an error message. */
2316  "The spell %s does not exist.",
2317  spell_name);
2318  return NULL;
2319 }
2320 
2331 static void command_learn_spell_or_prayer(object *op, const char *params, int special_prayer) {
2332  object *tmp;
2333 
2334  if (op->contr == NULL || *params == '\0') {
2336  "Which spell do you want to learn?");
2337  return;
2338  }
2339 
2341  if (tmp == NULL) {
2342  return;
2343  }
2344 
2345  if (check_spell_known(op, tmp->name)) {
2347  "You already know the spell %s.",
2348  tmp->name);
2349  return;
2350  }
2351 
2352  do_learn_spell(op, tmp, special_prayer);
2354 }
2355 
2364 void command_learn_spell(object *op, const char *params) {
2366 }
2367 
2376 void command_learn_special_prayer(object *op, const char *params) {
2378 }
2379 
2389 void command_forget_spell(object *op, const char *params) {
2390  object *spell;
2391 
2392  if (op->contr == NULL || *params == '\0') {
2394  "Which spell do you want to forget?");
2395  return;
2396  }
2397 
2398  spell = lookup_spell_by_name(op, params);
2399  if (spell == NULL) {
2401  "You do not know the spell %s.",
2402  params);
2403  return;
2404  }
2405 
2406  do_forget_spell(op, spell->name);
2407 }
2408 
2417 void command_listplugins(object *op, const char *params) {
2418  (void)params;
2420 }
2421 
2432 void command_loadplugin(object *op, const char *params) {
2433  char buf[MAX_BUF];
2434 
2435  if (*params == '\0') {
2437  "Load which plugin?");
2438  return;
2439  }
2440 
2441  snprintf(buf, sizeof(buf), LIBDIR"/plugins/%s", params);
2442  LOG(llevDebug, "Requested plugin file is %s\n", buf);
2443  if (plugins_init_plugin(buf) == 0) {
2444  LOG(llevInfo, "DM %s loaded plugin %s\n", op->name, params);
2446  "Plugin %s successfully loaded.",
2447  params);
2448  } else
2450  "Could not load plugin %s.",
2451  params);
2452 }
2453 
2464 void command_unloadplugin(object *op, const char *params) {
2465  if (*params == '\0') {
2467  "Remove which plugin?");
2468  return;
2469  }
2470 
2471  if (plugins_remove_plugin(params) == 0) {
2472  LOG(llevInfo, "DM %s unloaded plugin %s\n", op->name, params);
2474  "Plugin %s successfully removed.",
2475  params);
2476  init_signals(); // Restore our signal handlers, some plugins (Python) mess with them
2477  } else
2479  "Could not remove plugin %s.",
2480  params);
2481 }
2482 
2493 void command_dmhide(object *op, const char *params) {
2494  if (!do_wizard_dm(op, params, 1))
2495  return;
2496 
2497  do_wizard_hide(op, 1);
2498 }
2499 
2508 void command_stack_pop(object *op, const char *params) {
2509  (void)params;
2510  dm_stack_pop(op->contr);
2511 }
2512 
2521 void command_stack_push(object *op, const char *params) {
2522  object *ob;
2523  int from;
2524  ob = get_dm_object(op->contr, &params, &from);
2525 
2526  if (ob && from != STACK_FROM_NUMBER)
2527  /* Object was from stack, need to push it again */
2528  dm_stack_push(op->contr, ob->count);
2529 }
2530 
2539 void command_stack_list(object *op, const char *params) {
2540  int item;
2541  object *display;
2542  player *pl = op->contr;
2543  (void)params;
2544 
2546  "Item stack contents:");
2547 
2548  for (item = 0; item < pl->stack_position; item++) {
2550  if (display)
2552  " %d : %s [%d]",
2553  item, display->name, display->count);
2554  else
2555  /* Item was freed */
2557  " %d : (lost item: %d)",
2558  item, pl->stack_items[item]);
2559  }
2560 }
2561 
2570 void command_stack_clear(object *op, const char *params) {
2571  (void)params;
2572  op->contr->stack_position = 0;
2574  "Item stack cleared.");
2575 }
2576 
2596 void command_diff(object *op, const char *params) {
2597  object *left, *right;
2598  char *diff;
2599  StringBuffer *sb;
2600  int left_from, right_from;
2601 
2602  left = get_dm_object(op->contr, &params, &left_from);
2603  if (!left) {
2605  "Compare to what item?");
2606  return;
2607  }
2608 
2609  if (left_from == STACK_FROM_NUMBER)
2610  /* Item was stacked, remove it else right will be the same... */
2611  dm_stack_pop(op->contr);
2612 
2613  right = get_dm_object(op->contr, &params, &right_from);
2614 
2615  if (!right) {
2617  "Compare what item?");
2618  return;
2619  }
2620 
2622  "Item difference:");
2623 
2624  if (left_from == STACK_FROM_TOP && right_from == STACK_FROM_TOP) {
2625  /*
2626  * Special case: both items were taken from stack top.
2627  * Override the behaviour, taking left as item just below top, if exists.
2628  * See function description for why.
2629  * Besides, if we don't do anything, compare an item to itself, not really useful.
2630  */
2631  if (op->contr->stack_position > 1) {
2632  left = object_find_by_tag_global(op->contr->stack_items[op->contr->stack_position-2]);
2633  if (left)
2635  "(Note: first item taken from undertop)");
2636  else
2637  /* Stupid case: item under top was freed, fallback to stack top */
2638  left = right;
2639  }
2640  }
2641 
2642  sb = stringbuffer_new();
2643  get_ob_diff(sb, left, right);
2644  diff = stringbuffer_finish(sb);
2645  if (*diff == '\0') {
2646  draw_ext_info(NDI_UNIQUE, 0, op, MSG_TYPE_COMMAND, MSG_TYPE_COMMAND_DM, "Objects are the same.");
2647  } else {
2649  }
2650  free(diff);
2651 }
2652 
2660 void command_insert_into(object *op, const char *params) {
2661  object *left, *right, *inserted;
2662  int left_from, right_from;
2663  char what[MAX_BUF], where[MAX_BUF];
2664 
2665  left = get_dm_object(op->contr, &params, &left_from);
2666  if (!left) {
2668  "Insert into what object?");
2669  return;
2670  }
2671 
2672  if (left_from == STACK_FROM_NUMBER)
2673  /* Item was stacked, remove it else right will be the same... */
2674  dm_stack_pop(op->contr);
2675 
2676  right = get_dm_object(op->contr, &params, &right_from);
2677 
2678  if (!right) {
2680  "Insert what item?");
2681  return;
2682  }
2683 
2684  if (left_from == STACK_FROM_TOP && right_from == STACK_FROM_TOP) {
2685  /*
2686  * Special case: both items were taken from stack top.
2687  * Override the behaviour, taking left as item just below top, if exists.
2688  * See function description for why.
2689  * Besides, can't insert an item into itself.
2690  */
2691  if (op->contr->stack_position > 1) {
2692  left = object_find_by_tag_global(op->contr->stack_items[op->contr->stack_position-2]);
2693  if (left)
2695  "(Note: item to insert into taken from undertop)");
2696  else
2697  /* Stupid case: item under top was freed, fallback to stack top */
2698  left = right;
2699  }
2700  }
2701 
2702  if (left == right) {
2704  "Can't insert an object into itself!");
2705  return;
2706  }
2707 
2708  if (right->type == PLAYER) {
2710  "Can't insert a player into something!");
2711  return;
2712  }
2713 
2714  if (!QUERY_FLAG(right, FLAG_REMOVED))
2715  object_remove(right);
2716  inserted = object_insert_in_ob(right, left);
2717  if (left->type == PLAYER) {
2718  if (inserted != right)
2719  /* item was merged, so updating name and such. */
2720  esrv_update_item(UPD_WEIGHT|UPD_NAME|UPD_NROF, left, inserted);
2721  }
2722  query_name(inserted, what, MAX_BUF);
2723  query_name(left, where, MAX_BUF);
2725  "Inserted %s in %s",
2726  what, where);
2727 }
2728 
2737 void command_style_map_info(object *op, const char *params) {
2738  extern mapstruct *styles;
2739  mapstruct *mp;
2740  int maps_used = 0, mapmem = 0, objects_used = 0, x, y;
2741  (void)params;
2742 
2743  for (mp = styles; mp != NULL; mp = mp->next) {
2744  maps_used++;
2745  mapmem += map_size(mp) * (sizeof(object *)+sizeof(MapSpace))+sizeof(mapstruct);
2746  for (x = 0; x < MAP_WIDTH(mp); x++) {
2747  for (y = 0; y < MAP_HEIGHT(mp); y++) {
2748  FOR_MAP_PREPARE(mp, x, y, tmp)
2749  objects_used++;
2750  FOR_MAP_FINISH();
2751  }
2752  }
2753  }
2755  "[fixed]Style maps loaded: %d",
2756  maps_used);
2758  "[fixed]Memory used, not");
2760  "[fixed]including objects: %d",
2761  mapmem);
2763  "[fixed]Style objects: %d",
2764  objects_used);
2766  "[fixed]Mem for objects: %lu",
2767  (unsigned long)(objects_used*sizeof(object)));
2768 }
2769 
2770 bool can_follow(object* op, player* other) {
2771  // Only allow follow from same party.
2772  return (other->ob->contr->party != NULL) && (op->contr->party == other->ob->contr->party);
2773 }
2774 
2783 void command_follow(object *op, const char *params) {
2784  player *other;
2785 
2786  if (*params == '\0') {
2787  if (op->contr->followed_player != NULL) {
2788  draw_ext_info_format(NDI_UNIQUE, 0, op, MSG_TYPE_COMMAND, MSG_TYPE_COMMAND_SUCCESS, "You stop following %s.", op->contr->followed_player);
2789  FREE_AND_CLEAR_STR(op->contr->followed_player);
2790  }
2791  return;
2792  }
2793 
2795  if (!other) {
2796  draw_ext_info(NDI_UNIQUE, 0, op, MSG_TYPE_COMMAND, MSG_TYPE_COMMAND_FAILURE, "No such player or ambiguous name.");
2797  return;
2798  }
2799  if (other == op->contr) {
2800  draw_ext_info(NDI_UNIQUE, 0, op, MSG_TYPE_COMMAND, MSG_TYPE_COMMAND_FAILURE, "You can't follow yourself.");
2801  return;
2802  }
2803 
2804  // Players trying to 'follow' are subject to additional checks.
2805  if (!QUERY_FLAG(op, FLAG_WIZ)) {
2806  if (!can_follow(op, other)) {
2809  "You can only follow members in the same party.");
2810  return;
2811  }
2812  rv_vector rv;
2813  if (!get_rangevector(op, other->ob, &rv, 0) || rv.distance > 1) {
2814  draw_ext_info(NDI_UNIQUE, 0, op, MSG_TYPE_COMMAND, MSG_TYPE_COMMAND_FAILURE, "You need to go to them first!");
2815  return;
2816  }
2818  }
2819 
2820  if (op->contr->followed_player)
2821  FREE_AND_CLEAR_STR(op->contr->followed_player);
2822 
2823  op->contr->followed_player = add_string(other->ob->name);
2824  draw_ext_info_format(NDI_UNIQUE, 0, op, MSG_TYPE_COMMAND, MSG_TYPE_COMMAND_SUCCESS, "Following %s.", op->contr->followed_player);
2825 }
2826 
2827 void command_purge_quest(object *op, const char * param) {
2828  (void)param;
2829  free_quest();
2830  draw_ext_info(NDI_UNIQUE, 0, op, MSG_TYPE_ADMIN, MSG_TYPE_ADMIN_DM, "Purged quest state.");
2831 }
2832 
2833 void command_purge_quest_definitions(object *op, const char * param) {
2834  (void)param;
2836  draw_ext_info(NDI_UNIQUE, 0, op, MSG_TYPE_ADMIN, MSG_TYPE_ADMIN_DM, "Purged quests definitions.");
2837 }
2838 
2839 static void do_dump(object *who, object *what) {
2840  StringBuffer *sb;
2841  char *diff;
2842 
2843  sb = stringbuffer_new();
2844  object_dump(what, sb);
2845  diff = stringbuffer_finish(sb);
2847  free(diff);
2848 
2849  /* Let's push that item on the dm's stack */
2850  dm_stack_push(who->contr, what->count);
2851 }
2852 
2861 void command_dumpbelow(object *op, const char *params) {
2862  (void)params;
2863  if (op && op->below) {
2864  do_dump(op, op->below);
2865  }
2866 }
2867 
2876 void command_dumpabove(object *op, const char *params) {
2877  (void)params;
2878  if (op && op->above) {
2879  do_dump(op, op->above);
2880  }
2881 }
2882 
2888 void command_settings(object *op, const char *ignored) {
2889  (void)ignored;
2890  draw_ext_info(NDI_UNIQUE, 0, op, MSG_TYPE_ADMIN, MSG_TYPE_ADMIN_DM, "Server settings:");
2891 
2893 
2894  if (settings.not_permadeth) {
2895  draw_ext_info(NDI_UNIQUE, 0, op, MSG_TYPE_ADMIN, MSG_TYPE_ADMIN_DM, " * death is not permanent");
2896  } else if (settings.resurrection) {
2897  draw_ext_info(NDI_UNIQUE, 0, op, MSG_TYPE_ADMIN, MSG_TYPE_ADMIN_DM, " * permanent death, resurrection is enabled");
2898  } else {
2899  draw_ext_info(NDI_UNIQUE, 0, op, MSG_TYPE_ADMIN, MSG_TYPE_ADMIN_DM, " * permanent death, resurrection is NOT enabled");
2900  }
2901 
2902  if (settings.set_title) {
2903  draw_ext_info(NDI_UNIQUE, 0, op, MSG_TYPE_ADMIN, MSG_TYPE_ADMIN_DM, " * players can set their title");
2904  } else {
2905  draw_ext_info(NDI_UNIQUE, 0, op, MSG_TYPE_ADMIN, MSG_TYPE_ADMIN_DM, " * players can't set their title");
2906  }
2907 
2910  draw_ext_info(NDI_UNIQUE, 0, op, MSG_TYPE_ADMIN, MSG_TYPE_ADMIN_DM, " * too much equipment can lead to spell failure and ill effects");
2911  } else {
2912  draw_ext_info(NDI_UNIQUE, 0, op, MSG_TYPE_ADMIN, MSG_TYPE_ADMIN_DM, " * too much equipment can lead to spell failure but no ill effects");
2913  }
2914  } else {
2915  draw_ext_info(NDI_UNIQUE, 0, op, MSG_TYPE_ADMIN, MSG_TYPE_ADMIN_DM, " * too much equipment can't lead to spell failure");
2916  }
2917 
2918  if (settings.casting_time) {
2919  draw_ext_info(NDI_UNIQUE, 0, op, MSG_TYPE_ADMIN, MSG_TYPE_ADMIN_DM, " * casting takes time");
2920  } else {
2921  draw_ext_info(NDI_UNIQUE, 0, op, MSG_TYPE_ADMIN, MSG_TYPE_ADMIN_DM, " * casting is immediate");
2922  }
2923 
2926 
2928 
2930  draw_ext_info(NDI_UNIQUE, 0, op, MSG_TYPE_ADMIN, MSG_TYPE_ADMIN_DM, " * players can't steal from other players");
2931  } else {
2932  draw_ext_info(NDI_UNIQUE, 0, op, MSG_TYPE_ADMIN, MSG_TYPE_ADMIN_DM, " * players can steal from other players");
2933  }
2934 
2936  draw_ext_info(NDI_UNIQUE, 0, op, MSG_TYPE_ADMIN, MSG_TYPE_ADMIN_DM, " * players can create portals from their apartments");
2937  } else {
2938  draw_ext_info(NDI_UNIQUE, 0, op, MSG_TYPE_ADMIN, MSG_TYPE_ADMIN_DM, " * players can't create portals from their apartments");
2939  }
2940 
2942  draw_ext_info(NDI_UNIQUE, 0, op, MSG_TYPE_ADMIN, MSG_TYPE_ADMIN_DM, " * players can write spells they are denied");
2943  } else {
2944  draw_ext_info(NDI_UNIQUE, 0, op, MSG_TYPE_ADMIN, MSG_TYPE_ADMIN_DM, " * players can't write spells they are denied");
2945  }
2946 }
Settings::casting_time
uint8_t casting_time
Definition: global.h:266
give.next
def next
Definition: give.py:44
UP_OBJ_FACE
#define UP_OBJ_FACE
Definition: object.h:520
PLAYER
@ PLAYER
Definition: object.h:107
global.h
FREE_OBJ_NO_DESTROY_CALLBACK
#define FREE_OBJ_NO_DESTROY_CALLBACK
Definition: object.h:532
STACK_FROM_NONE
@ STACK_FROM_NONE
Definition: c_wiz.c:37
command_stack_clear
void command_stack_clear(object *op, const char *params)
Definition: c_wiz.c:2570
liv::dam
int16_t dam
Definition: living.h:46
object_free
void object_free(object *ob, int flags)
Definition: object.c:1565
add_string
sstring add_string(const char *str)
Definition: shstr.c:124
command_invisible
void command_invisible(object *op, const char *params)
Definition: c_wiz.c:2199
object_remove
void object_remove(object *op)
Definition: object.c:1806
safe_strncpy
#define safe_strncpy
Definition: compat.h:27
FOR_MAP_FINISH
#define FOR_MAP_FINISH()
Definition: define.h:728
stringbuffer_new
StringBuffer * stringbuffer_new(void)
Definition: stringbuffer.c:57
object_set_enemy
void object_set_enemy(object *op, object *enemy)
Definition: object.c:908
NUM_BODY_LOCATIONS
#define NUM_BODY_LOCATIONS
Definition: object.h:13
MSG_TYPE_COMMAND_SUCCESS
#define MSG_TYPE_COMMAND_SUCCESS
Definition: newclient.h:530
command_stack_push
void command_stack_push(object *op, const char *params)
Definition: c_wiz.c:2521
llevError
@ llevError
Definition: logger.h:11
give_artifact_abilities
void give_artifact_abilities(object *op, const object *artifact)
Definition: artifact.c:194
WAND
@ WAND
Definition: object.h:220
MSG_TYPE_ADMIN_PLAYER
#define MSG_TYPE_ADMIN_PLAYER
Definition: newclient.h:496
SHUTDOWN_IDLE
@ SHUTDOWN_IDLE
Definition: commands.h:44
init_sockets
socket_struct * init_sockets
Definition: init.c:58
SET_FLAG
#define SET_FLAG(xyz, p)
Definition: define.h:224
Settings::resurrection
uint8_t resurrection
Definition: global.h:262
object_update
void object_update(object *op, int action)
Definition: object.c:1407
diamondslots.x
x
Definition: diamondslots.py:15
obj::count
tag_t count
Definition: object.h:300
set_tick_duration
void set_tick_duration(long t)
Definition: time.c:205
obj::map
struct mapdef * map
Definition: object.h:298
QUERY_FLAG
#define QUERY_FLAG(xyz, p)
Definition: define.h:226
checkdm
static int checkdm(object *op, const char *pl_name, const char *pl_passwd, const char *pl_host)
Definition: c_wiz.c:2090
plugins_remove_plugin
int plugins_remove_plugin(const char *id)
Definition: plugins.c:457
plugins_init_plugin
int plugins_init_plugin(const char *libfile)
Definition: plugins.c:366
get_next_archetype
archetype * get_next_archetype(archetype *current)
Definition: assets.cpp:278
Settings::set_title
uint8_t set_title
Definition: global.h:261
liv::wc
int8_t wc
Definition: living.h:37
do_learn_spell
void do_learn_spell(object *op, object *spell, int special_prayer)
Definition: apply.c:484
socket_struct
Definition: newserver.h:89
Socket_Info::allocated_sockets
int allocated_sockets
Definition: newserver.h:144
flush_old_maps
void flush_old_maps(void)
Definition: swap.c:247
out_of_map
int out_of_map(mapstruct *m, int x, int y)
Definition: map.c:2292
esrv_new_player
void esrv_new_player(player *pl, uint32_t weight)
Definition: request.c:942
liv::Str
int8_t Str
Definition: living.h:36
FALSE
#define FALSE
Definition: compat.h:14
Settings::not_permadeth
uint8_t not_permadeth
Definition: global.h:258
banquet.size_x
int size_x
Definition: banquet.py:23
Settings::permanent_exp_ratio
uint8_t permanent_exp_ratio
Definition: global.h:254
object_new
object * object_new(void)
Definition: object.c:1242
esrv_send_inventory
void esrv_send_inventory(object *pl, object *op)
Definition: item.c:312
Settings::datadir
const char * datadir
Definition: global.h:244
command_purge_quest_definitions
void command_purge_quest_definitions(object *op, const char *param)
Definition: c_wiz.c:2833
UPD_WEIGHT
#define UPD_WEIGHT
Definition: newclient.h:316
liv::maxhp
int16_t maxhp
Definition: living.h:41
pl::socket
socket_struct socket
Definition: player.h:94
pl
Definition: player.h:92
EXIT_PATH
#define EXIT_PATH(xyz)
Definition: define.h:439
FLAG_OBJ_ORIGINAL
#define FLAG_OBJ_ORIGINAL
Definition: define.h:357
get_ob_diff
void get_ob_diff(StringBuffer *sb, const object *op, const object *op2)
Definition: object.c:4952
socket_info
Socket_Info socket_info
Definition: init.c:49
Settings::worldmaptilesy
uint32_t worldmaptilesy
Definition: global.h:290
guildjoin.ob
ob
Definition: guildjoin.py:42
python_event.path
path
Definition: python_event.py:11
liv::hp
int16_t hp
Definition: living.h:40
command_remove
void command_remove(object *op, const char *params)
Definition: c_wiz.c:1560
Settings::worldmapstartx
uint32_t worldmapstartx
Definition: global.h:287
find_object_both
static object * find_object_both(const char *params)
Definition: c_wiz.c:402
command_skills
void command_skills(object *op, const char *params)
Definition: c_wiz.c:1367
command_learn_spell_or_prayer
static void command_learn_spell_or_prayer(object *op, const char *params, int special_prayer)
Definition: c_wiz.c:2331
pl::ob
object * ob
Definition: player.h:162
FLAG_WIZCAST
#define FLAG_WIZCAST
Definition: define.h:289
path_combine_and_normalize
char * path_combine_and_normalize(const char *src, const char *dst, char *path, size_t size)
Definition: path.c:172
artifactliststruct::items
struct artifactstruct * items
Definition: artifact.h:30
Ice.tmp
int tmp
Definition: Ice.py:207
can_follow
bool can_follow(object *op, player *other)
Definition: c_wiz.c:2770
NDI_RED
#define NDI_RED
Definition: newclient.h:245
command_addexp
void command_addexp(object *op, const char *params)
Definition: c_wiz.c:1671
get_other_player_from_name
static player * get_other_player_from_name(object *op, const char *name)
Definition: c_wiz.c:59
command_toggle_shout
void command_toggle_shout(object *op, const char *params)
Definition: c_wiz.c:635
command_recollect
void command_recollect(object *op, const char *params)
Definition: c_wiz.c:1533
UPD_NROF
#define UPD_NROF
Definition: newclient.h:321
plugins_display_list
void plugins_display_list(object *op)
Definition: plugins.c:506
get_rangevector
int get_rangevector(object *op1, const object *op2, rv_vector *retval, int flags)
Definition: map.c:2525
command_kick2
static void command_kick2(object *op, const char *params)
Definition: c_wiz.c:467
skills.h
npc_dialog.filename
filename
Definition: npc_dialog.py:99
MSG_TYPE_COMMAND_ERROR
#define MSG_TYPE_COMMAND_ERROR
Definition: newclient.h:529
create_treasure
void create_treasure(treasurelist *t, object *op, int flag, int difficulty, int tries)
Definition: treasure.c:242
set_variable
int set_variable(object *op, const char *buf)
Definition: loader.c:5267
command_forget_spell
void command_forget_spell(object *op, const char *params)
Definition: c_wiz.c:2389
obj::randomitems
struct treasureliststruct * randomitems
Definition: object.h:389
hiscore_check
void hiscore_check(object *op, int quiet)
Definition: hiscore.c:348
command_listplugins
void command_listplugins(object *op, const char *params)
Definition: c_wiz.c:2417
command_dm
void command_dm(object *op, const char *params)
Definition: c_wiz.c:2187
banquet.size_y
int size_y
Definition: banquet.py:24
HUGE_BUF
#define HUGE_BUF
Definition: define.h:37
find_artifactlist
const artifactlist * find_artifactlist(int type)
Definition: artifact.c:647
do_dump
static void do_dump(object *who, object *what)
Definition: c_wiz.c:2839
MAX
#define MAX(x, y)
Definition: compat.h:24
MSG_TYPE_COMMAND
#define MSG_TYPE_COMMAND
Definition: newclient.h:404
command_teleport
void command_teleport(object *op, const char *params)
Definition: c_wiz.c:933
freearr_x
short freearr_x[SIZEOFFREE]
Definition: object.c:288
obj::nrof
uint32_t nrof
Definition: object.h:335
freearr_y
short freearr_y[SIZEOFFREE]
Definition: object.c:294
reset_sleep
void reset_sleep(void)
Definition: time.c:132
NDI_ORANGE
#define NDI_ORANGE
Definition: newclient.h:246
reputation_trigger_connect.check
def check()
Definition: reputation_trigger_connect.py:18
SAVE_MODE_OVERLAY
#define SAVE_MODE_OVERLAY
Definition: map.h:123
dm_stack_pop
static void dm_stack_pop(player *pl)
Definition: c_wiz.c:94
Settings::worldmaptilesx
uint32_t worldmaptilesx
Definition: global.h:289
archt
Definition: object.h:468
settings
struct Settings settings
Definition: init.c:39
FLAG_ALIVE
#define FLAG_ALIVE
Definition: define.h:230
command_loadtest
void command_loadtest(object *op, const char *params)
Definition: c_wiz.c:305
Ns_Dead
@ Ns_Dead
Definition: newserver.h:67
calc_perm_exp
void calc_perm_exp(object *op)
Definition: living.c:1903
command_style_map_info
void command_style_map_info(object *op, const char *params)
Definition: c_wiz.c:2737
MSG_TYPE_ADMIN_DM
#define MSG_TYPE_ADMIN_DM
Definition: newclient.h:497
MSG_TYPE_COMMAND_DEBUG
#define MSG_TYPE_COMMAND_DEBUG
Definition: newclient.h:528
command_setgod
void command_setgod(object *op, const char *params)
Definition: c_wiz.c:417
ASSETS_QUESTS
#define ASSETS_QUESTS
Definition: assets.h:34
Settings::spell_encumbrance
uint8_t spell_encumbrance
Definition: global.h:264
m
static event_registration m
Definition: citylife.cpp:425
liv::maxsp
int16_t maxsp
Definition: living.h:43
autojail.who
who
Definition: autojail.py:3
MAP_IN_MEMORY
#define MAP_IN_MEMORY
Definition: map.h:131
liv::exp
int64_t exp
Definition: living.h:47
shutdown_s::time
time_t time
Definition: commands.h:49
item.q
q
Definition: item.py:32
pl::next
struct pl * next
Definition: player.h:93
FMT64
#define FMT64
Definition: compat.h:16
reset_faces_sent
static void reset_faces_sent(struct socket_struct *socket)
Definition: c_wiz.c:1527
STACK_FROM_NUMBER
@ STACK_FROM_NUMBER
Definition: c_wiz.c:40
command_unloadplugin
void command_unloadplugin(object *op, const char *params)
Definition: c_wiz.c:2464
FLAG_WAS_WIZ
#define FLAG_WAS_WIZ
Definition: define.h:234
obj::name
sstring name
Definition: object.h:312
command_dumpbelow
void command_dumpbelow(object *op, const char *params)
Definition: c_wiz.c:2861
command_hide
void command_hide(object *op, const char *params)
Definition: c_wiz.c:388
command_patch
void command_patch(object *op, const char *params)
Definition: c_wiz.c:1495
pl::state
uint8_t state
Definition: player.h:118
is_identifiable_type
int is_identifiable_type(const object *op)
Definition: item.c:1311
Settings::death_penalty_ratio
uint8_t death_penalty_ratio
Definition: global.h:255
object_copy
void object_copy(const object *src_ob, object *dest_ob)
Definition: object.c:1053
query_name
void query_name(const object *op, char *buf, size_t size)
Definition: item.c:584
POTION
@ POTION
Definition: object.h:111
Settings::set_friendly_fire
uint16_t set_friendly_fire
Definition: global.h:271
command_overlay_save
void command_overlay_save(object *op, const char *params)
Definition: c_wiz.c:588
object_dump
void object_dump(const object *op, StringBuffer *sb)
Definition: object.c:638
MSG_TYPE_COMMAND_DM
#define MSG_TYPE_COMMAND_DM
Definition: newclient.h:535
command_kick
void command_kick(object *op, const char *params)
Definition: c_wiz.c:576
artifactstruct::next
struct artifactstruct * next
Definition: artifact.h:18
Settings::worldmapstarty
uint32_t worldmapstarty
Definition: global.h:288
liv::Cha
int8_t Cha
Definition: living.h:36
HEAD
#define HEAD(op)
Definition: object.h:594
ROD
@ ROD
Definition: object.h:109
free_quest
void free_quest(void)
Definition: quest.c:910
shutdown_s::type
enum shutdown_type type
Definition: commands.h:48
make_face_from_files.str
str
Definition: make_face_from_files.py:24
obj::speed_left
float speed_left
Definition: object.h:331
FLAG_FREED
#define FLAG_FREED
Definition: define.h:233
socket_struct::host
char * host
Definition: newserver.h:100
shutdown_s
Definition: commands.h:47
lookup_spell_by_name
object * lookup_spell_by_name(object *op, const char *spname)
Definition: spell_util.c:409
command_accountpasswd
void command_accountpasswd(object *op, const char *params)
Definition: c_wiz.c:1633
get_jail_exit
object * get_jail_exit(object *op)
Definition: region.c:260
pl::no_shout
uint32_t no_shout
Definition: player.h:135
first_player
EXTERN player * first_player
Definition: global.h:115
obj::x
int16_t x
Definition: object.h:328
do_goto
void do_goto(object *op, const char *name, int x, int y)
Definition: c_move.c:151
command_help
void command_help(object *op, const char *params)
Definition: c_misc.c:1766
fix_object
void fix_object(object *op)
Definition: living.c:1126
command_follow
void command_follow(object *op, const char *params)
Definition: c_wiz.c:2783
show_skills
void show_skills(object *op, const char *search)
Definition: skill_util.c:851
object_create_arch
object * object_create_arch(archetype *at)
Definition: arch.cpp:301
styles
mapstruct * styles
Definition: style.c:122
stringbuffer_finish
char * stringbuffer_finish(StringBuffer *sb)
Definition: stringbuffer.c:76
FLAG_WIZPASS
#define FLAG_WIZPASS
Definition: define.h:314
Settings::item_power_factor
float item_power_factor
Definition: global.h:299
command_create
void command_create(object *op, const char *params)
Definition: c_wiz.c:999
obj::other_arch
struct archt * other_arch
Definition: object.h:417
MAX_NAME
#define MAX_NAME
Definition: define.h:41
command_stack_pop
void command_stack_pop(object *op, const char *params)
Definition: c_wiz.c:2508
archt::more
struct archt * more
Definition: object.h:471
command_possess
void command_possess(object *op, const char *params)
Definition: c_wiz.c:1434
DMFILE
#define DMFILE
Definition: config.h:361
tick_duration
uint32_t tick_duration
Definition: time.c:35
FLAG_UNAGGRESSIVE
#define FLAG_UNAGGRESSIVE
Definition: define.h:272
obj::speed
float speed
Definition: object.h:330
tag_t
uint32_t tag_t
Definition: object.h:12
object_give_identified_properties
void object_give_identified_properties(object *op)
Definition: item.c:1343
liv::Con
int8_t Con
Definition: living.h:36
command_settings
void command_settings(object *op, const char *ignored)
Definition: c_wiz.c:2888
command_nowiz
void command_nowiz(object *op, const char *params)
Definition: c_wiz.c:2053
Settings::confdir
const char * confdir
Definition: global.h:243
sproto.h
liv::food
int32_t food
Definition: living.h:48
command_arrest
void command_arrest(object *op, const char *params)
Definition: c_wiz.c:841
MapSpace
Definition: map.h:257
set_magic
static void set_magic(int difficulty, object *op, int max_magic, int flags)
Definition: treasure.c:639
mapdef
Definition: map.h:324
command_loadplugin
void command_loadplugin(object *op, const char *params)
Definition: c_wiz.c:2432
MSG_SUBTYPE_NONE
#define MSG_SUBTYPE_NONE
Definition: newclient.h:420
become_follower
int become_follower(object *op, const object *new_god)
Definition: gods.c:477
liv::Int
int8_t Int
Definition: living.h:36
init_signals
void init_signals()
Definition: init.c:1330
Settings::death_penalty_level
uint8_t death_penalty_level
Definition: global.h:256
command_speed
void command_speed(object *op, const char *params)
Definition: c_wiz.c:1727
SHUTDOWN_NONE
@ SHUTDOWN_NONE
Definition: commands.h:42
nlohmann::detail::void
j template void())
Definition: json.hpp:4099
create_overlay_pathname
void create_overlay_pathname(const char *name, char *buf, size_t size)
Definition: map.c:124
FLAG_MONSTER
#define FLAG_MONSTER
Definition: define.h:245
find_skill_by_name
object * find_skill_by_name(object *who, const char *name)
Definition: skill_util.c:202
MAP_WIDTH
#define MAP_WIDTH(m)
Definition: map.h:78
strlcpy
size_t strlcpy(char *dst, const char *src, size_t size)
Definition: porting.c:220
treasure.h
EXIT_X
#define EXIT_X(xyz)
Definition: define.h:441
MAX_BUF
#define MAX_BUF
Definition: define.h:35
artifactstruct
Definition: artifact.h:14
Ns_Add
@ Ns_Add
Definition: newserver.h:66
clear_los
void clear_los(player *pl)
Definition: los.c:252
monster_check_apply_all
void monster_check_apply_all(object *monster)
Definition: monster.c:1974
StringBuffer
Definition: stringbuffer.c:25
FREE_AND_CLEAR_STR
#define FREE_AND_CLEAR_STR(xyz)
Definition: global.h:196
save_map
int save_map(mapstruct *m, int flag)
Definition: map.c:1406
Settings::spell_failure_effects
uint8_t spell_failure_effects
Definition: global.h:265
is_valid_types_gen.found
found
Definition: is_valid_types_gen.py:39
MSG_TYPE_COMMAND_FAILURE
#define MSG_TYPE_COMMAND_FAILURE
Definition: newclient.h:531
FOR_MAP_PREPARE
#define FOR_MAP_PREPARE(map_, mx_, my_, it_)
Definition: define.h:721
obj::y
int16_t y
Definition: object.h:328
ST_PLAYING
#define ST_PLAYING
Definition: define.h:541
command_insert_into
void command_insert_into(object *op, const char *params)
Definition: c_wiz.c:2660
FLAG_REMOVED
#define FLAG_REMOVED
Definition: define.h:232
Settings::allow_denied_spells_writing
int allow_denied_spells_writing
Definition: global.h:311
player_lvl_adj
void player_lvl_adj(object *who, object *op)
Definition: living.c:1819
FLAG_WIZ
#define FLAG_WIZ
Definition: define.h:231
swap_map
int swap_map(mapstruct *map)
Definition: swap.c:135
llevInfo
@ llevInfo
Definition: logger.h:12
command_stats
void command_stats(object *op, const char *params)
Definition: c_wiz.c:1757
obj::type
uint8_t type
Definition: object.h:341
command_inventory
void command_inventory(object *op, const char *params)
Definition: c_wiz.c:1337
NDI_UNIQUE
#define NDI_UNIQUE
Definition: newclient.h:262
EVENT_MUZZLE
#define EVENT_MUZZLE
Definition: events.h:50
command_freeze
void command_freeze(object *op, const char *params)
Definition: c_wiz.c:765
object_find_by_tag_global
object * object_find_by_tag_global(tag_t i)
Definition: object.c:720
find_archetype_by_object_name
archetype * find_archetype_by_object_name(const char *name)
Definition: arch.cpp:55
command_diff
void command_diff(object *op, const char *params)
Definition: c_wiz.c:2596
FLAG_FRIENDLY
#define FLAG_FRIENDLY
Definition: define.h:246
spells.h
command_goto
void command_goto(object *op, const char *params)
Definition: c_wiz.c:744
obj::stats
living stats
Definition: object.h:371
STACK_FROM_TOP
@ STACK_FROM_TOP
Definition: c_wiz.c:38
archt::clone
object clone
Definition: object.h:472
obj::contr
struct pl * contr
Definition: object.h:277
BANISHFILE
#define BANISHFILE
Definition: config.h:512
command_reset
void command_reset(object *op, const char *params)
Definition: c_wiz.c:1880
liv::Dex
int8_t Dex
Definition: living.h:36
check_exp_adjust
int64_t check_exp_adjust(const object *op, int64_t exp)
Definition: living.c:2091
item
Definition: item.py:1
reputation.victim
victim
Definition: reputation.py:14
LOG
void LOG(LogLevel logLevel, const char *format,...)
Definition: logger.c:51
enter_exit
void enter_exit(object *op, object *exit_ob)
Definition: server.c:721
command_mon_aggr
void command_mon_aggr(object *op, const char *params)
Definition: c_wiz.c:1407
check_spell_known
object * check_spell_known(object *op, const char *name)
Definition: spell_util.c:393
liv::Wis
int8_t Wis
Definition: living.h:36
SHUTDOWN_TIME
@ SHUTDOWN_TIME
Definition: commands.h:43
liv::grace
int16_t grace
Definition: living.h:44
shutdown_state
struct shutdown_s shutdown_state
Definition: c_wiz.c:43
give.op
op
Definition: give.py:33
object_find_free_spot
int object_find_free_spot(const object *ob, mapstruct *m, int x, int y, int start, int stop)
Definition: object.c:3509
NDI_ALL
#define NDI_ALL
Definition: newclient.h:263
socket_struct::status
enum Sock_Status status
Definition: newserver.h:90
load_assets
void load_assets(void)
Definition: init.c:179
esrv_update_item
void esrv_update_item(int flags, object *pl, object *op)
Definition: main.c:360
do_wizard_hide
static void do_wizard_hide(object *op, int silent_dm)
Definition: c_wiz.c:351
Settings::max_stat
uint8_t max_stat
Definition: global.h:320
rv_vector
Definition: map.h:379
MAP_SWAPPED
#define MAP_SWAPPED
Definition: map.h:132
roll-o-matic.params
params
Definition: roll-o-matic.py:193
EXIT_Y
#define EXIT_Y(xyz)
Definition: define.h:442
pl::stack_position
int stack_position
Definition: player.h:204
diamondslots.y
y
Definition: diamondslots.py:16
assets.h
python_pickup.where
where
Definition: python_pickup.py:7
CLEAR_FLAG
#define CLEAR_FLAG(xyz, p)
Definition: define.h:225
command_learn_spell
void command_learn_spell(object *op, const char *params)
Definition: c_wiz.c:2364
socket_struct::faces_sent_len
size_t faces_sent_len
Definition: newserver.h:95
buf
StringBuffer * buf
Definition: readable.c:1606
MAP_HEIGHT
#define MAP_HEIGHT(m)
Definition: map.h:80
object_insert_in_ob
object * object_insert_in_ob(object *op, object *where)
Definition: object.c:2820
NDI_DK_ORANGE
#define NDI_DK_ORANGE
Definition: newclient.h:248
find_player_partial_name
player * find_player_partial_name(const char *plname)
Definition: player.c:111
account_change_password
int account_change_password(const char *account_name, const char *current_password, const char *new_password)
Definition: account.c:685
object_update_speed
void object_update_speed(object *op)
Definition: object.c:1317
obj::more
struct obj * more
Definition: object.h:296
socket_struct::faces_sent
uint8_t * faces_sent
Definition: newserver.h:96
object_find_by_name_global
object * object_find_by_name_global(const char *str)
Definition: object.c:740
arch_to_object
object * arch_to_object(archetype *at)
Definition: arch.cpp:232
map_size
uint32_t map_size(mapstruct *m)
Definition: map.c:813
MSG_TYPE_COMMAND_MAPS
#define MSG_TYPE_COMMAND_MAPS
Definition: newclient.h:520
artifactstruct::item
object * item
Definition: artifact.h:15
UPD_NAME
#define UPD_NAME
Definition: newclient.h:318
liv::ac
int8_t ac
Definition: living.h:38
get_dm_object
static object * get_dm_object(player *pl, const char **params, int *from)
Definition: c_wiz.c:195
save_player
int save_player(object *op, int flag)
Definition: login.c:230
command_shutdown
void command_shutdown(object *op, const char *params)
Definition: c_wiz.c:678
object_insert_in_map_at
object * object_insert_in_map_at(object *op, mapstruct *m, object *originator, int flag, int x, int y)
Definition: object.c:2067
Settings::real_wiz
uint8_t real_wiz
Definition: global.h:267
dm_stack_push
static void dm_stack_push(player *pl, tag_t item)
Definition: c_wiz.c:149
draw_ext_info
void draw_ext_info(int flags, int pri, const object *pl, uint8_t type, uint8_t subtype, const char *message)
Definition: main.c:309
object_free_drop_inventory
void object_free_drop_inventory(object *ob)
Definition: object.c:1533
MSG_TYPE_COMMUNICATION_PARTY
#define MSG_TYPE_COMMUNICATION_PARTY
Definition: newclient.h:627
try_find_archetype
archetype * try_find_archetype(const char *name)
Definition: assets.cpp:286
dm_stack_peek
static object * dm_stack_peek(player *pl)
Definition: c_wiz.c:119
castle_read.playercount
int playercount
Definition: castle_read.py:62
inventory
void inventory(object *op, object *inv)
Definition: c_object.c:2016
do_wizard_dm
static int do_wizard_dm(object *op, const char *params, int silent)
Definition: c_wiz.c:2138
do_forget_spell
void do_forget_spell(object *op, const char *spell)
Definition: apply.c:525
do_some_living
void do_some_living(object *op)
Definition: player.c:3247
command_free
void command_free(object *op, const char *params)
Definition: c_wiz.c:1607
archt::name
sstring name
Definition: object.h:469
set_abs_magic
void set_abs_magic(object *op, int magic)
Definition: treasure.c:591
SCROLL
@ SCROLL
Definition: object.h:221
shutdown_s::next_warn
int next_warn
Definition: commands.h:51
command_banish
void command_banish(object *op, const char *params)
Definition: c_wiz.c:522
assets_collect
void assets_collect(const char *datadir, int what)
Definition: assets.cpp:116
Settings::no_player_stealing
uint8_t no_player_stealing
Definition: global.h:306
say.item
dictionary item
Definition: say.py:149
command_learn_special_prayer
void command_learn_special_prayer(object *op, const char *params)
Definition: c_wiz.c:2376
command_dumpabove
void command_dumpabove(object *op, const char *params)
Definition: c_wiz.c:2876
MSG_TYPE_COMMUNICATION
#define MSG_TYPE_COMMUNICATION
Definition: newclient.h:410
command_dump
void command_dump(object *op, const char *params)
Definition: c_wiz.c:1379
pl::stack_items
tag_t * stack_items
Definition: player.h:202
get_faces_count
size_t get_faces_count()
Definition: assets.cpp:317
mapdef::path
char path[HUGE_BUF]
Definition: map.h:364
command_overlay_reset
void command_overlay_reset(object *op, const char *params)
Definition: c_wiz.c:609
MAP_TIMEOUT
#define MAP_TIMEOUT(m)
Definition: map.h:66
pl::party
partylist * party
Definition: player.h:188
TRUE
#define TRUE
Definition: compat.h:11
SPELL
@ SPELL
Definition: object.h:214
find_god
const object * find_god(const char *name)
Definition: gods.c:80
legal_artifact_combination
int legal_artifact_combination(const object *op, const artifact *art)
Definition: artifact.c:216
liv::sp
int16_t sp
Definition: living.h:42
command_stack_list
void command_stack_list(object *op, const char *params)
Definition: c_wiz.c:2539
Settings::create_home_portals
uint8_t create_home_portals
Definition: global.h:307
unhide
static void unhide(object *op)
Definition: c_wiz.c:332
command_abil
void command_abil(object *op, const char *params)
Definition: c_wiz.c:1814
altar_valkyrie.pl
pl
Definition: altar_valkyrie.py:28
STACK_SIZE
#define STACK_SIZE
Definition: c_wiz.c:34
get_spell_by_name
static object * get_spell_by_name(object *op, const char *spell_name)
Definition: c_wiz.c:2226
command_dmhide
void command_dmhide(object *op, const char *params)
Definition: c_wiz.c:2493
mapdef::next
struct mapdef * next
Definition: map.h:325
MSG_TYPE_ADMIN
#define MSG_TYPE_ADMIN
Definition: newclient.h:402
rv_vector::distance
unsigned int distance
Definition: map.h:380
STACK_FROM_STACK
@ STACK_FROM_STACK
Definition: c_wiz.c:39
SPELLBOOK
@ SPELLBOOK
Definition: object.h:203
command_purge_quest
void command_purge_quest(object *op, const char *param)
Definition: c_wiz.c:2827
EVENT_KICK
#define EVENT_KICK
Definition: events.h:42
takeitem.status
status
Definition: takeitem.py:35
SAVE_ERROR_PLAYER
#define SAVE_ERROR_PLAYER
Definition: map.h:153
altar_valkyrie.res
int res
Definition: altar_valkyrie.py:74
liv::Pow
int8_t Pow
Definition: living.h:36
draw_ext_info_format
void draw_ext_info_format(int flags, int pri, const object *pl, uint8_t type, uint8_t subtype, const char *format,...)
Definition: main.c:319
NDI_LT_GREEN
#define NDI_LT_GREEN
Definition: newclient.h:250
update_los
void update_los(object *op)
Definition: los.c:459
events_execute_global_event
void events_execute_global_event(int eventcode,...)
Definition: events.cpp:29
llevDebug
@ llevDebug
Definition: logger.h:13
player_arrest
int player_arrest(object *who)
Definition: c_wiz.c:809
pl::orig_stats
living orig_stats
Definition: player.h:152
command_summon
void command_summon(object *op, const char *params)
Definition: c_wiz.c:886
FLAG_IDENTIFIED
#define FLAG_IDENTIFIED
Definition: define.h:261
give.name
name
Definition: give.py:27
has_been_loaded
mapstruct * has_been_loaded(const char *name)
Definition: map.c:78
map_remove_unique_files
void map_remove_unique_files(const mapstruct *map)
Definition: map.c:2677
Settings::localdir
const char * localdir
Definition: global.h:245