Crossfire Server, Trunk  R21670
c_misc.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 #define WANT_UNARMED_SKILLS
21 
22 #include "global.h"
23 
24 #include <assert.h>
25 #include <errno.h>
26 #include <stdlib.h>
27 #include <string.h>
28 #include <sys/stat.h>
29 
30 #undef SS_STATISTICS
31 #include "loader.h"
32 #include "shstr.h"
33 #include "sounds.h"
34 #include "sproto.h"
35 #include "version.h"
36 
45 void map_info(object *op, const char *search) {
46  if ( *search != 0 ) {
48  i18n(op, "Maps matching search: '%s'"), search);
49  }
50  if (QUERY_FLAG(op, FLAG_WIZ)) {
52  i18n(op, "[fixed]Path Reset In (HH:MM:SS) Pl IM TO"));
53  } else {
55  i18n(op, "[fixed]Path Reset In (HH:MM)"));
56  }
57 
58  /* Allow a comma-separate list of search strings; more complicated because of the const */
59  char *to_be_freed = NULL;
60  char *search_array[64];
61  int search_array_count = 0;
62  if ( search[0] ) {
63  to_be_freed = strdup(search);
64  if ( !to_be_freed ) {
65  search_array[0] = to_be_freed;
66  search_array_count = 1;
67  } else {
68  search_array_count = split_string(to_be_freed,search_array,64,',');
69  }
70  }
71 
72  for (mapstruct *m = first_map; m != NULL; m = m->next) {
73  bool match = TRUE;
74  if ( search_array_count ) {
75  match = FALSE;
76  for (int i=0; i<search_array_count; ++i) {
77  if ( strstr(m->path,search_array[i]) ) {
78  match=TRUE;
79  break;
80  }
81  }
82  }
83  if ( !match ) continue; /* Skip unwanted maps */
84 
85  /* Print out the last 26 characters of the map name... */
86  char map_path[MAX_BUF];
87  if (strlen(m->path) <= 26) {
88  strcpy(map_path, m->path);
89  } else {
90  safe_strncpy(map_path, m->path + strlen(m->path) - 26, sizeof(map_path));
91  }
92 
93  uint32_t ttr = MAP_WHEN_RESET(m) - seconds() > 0 ? MAP_WHEN_RESET(m) - seconds() : 0;
94  if ( !m->reset_timeout && !m->unique ) set_map_reset_time(m);
95  if (m->players) {
96  ttr = (m->unique ? 0 : m->reset_timeout) + 300;
97  }
98  else if (m->timeout) {
99  ttr = (m->unique ? 0 : m->reset_timeout) + m->timeout;
100  }
101  const uint32_t hh = ttr/3600, mm = (ttr%3600)/60, ss = ttr%60;
102  if (QUERY_FLAG(op, FLAG_WIZ)) {
105  i18n(op, "[fixed]%-26.26s %2d:%02d:%02d %2d %2d %4d"),
106  map_path, hh, mm, ss, m->players, m->in_memory, m->timeout);
107  } else {
110  i18n(op, "[fixed]%-26.26s %2d:%02d%s"), map_path, hh, mm,
111  m->players ? " (in use)" : "");
112  }
113  }
114  if ( to_be_freed ) free( to_be_freed );
115 }
116 
125 void command_language(object *op, const char *params) {
126  int language = -1;
127 
128  if (!op->contr)
129  return;
130 
131  if (*params == '\0' || (!strcmp(params, ""))) {
133  i18n(op, "Your current language is set to: English."));
135  i18n(op, "Available languages:"));
137  return;
138  }
139 
140  language = i18n_find_language_by_code(params);
141 
142  /* Error out if unknown language. */
143  if (language == -1) {
145  i18n(op, "Unknown language."));
146  return;
147  }
148 
149  op->contr->language = language;
150 
152  i18n(op, "Your current language is set to English."));
153 }
154 
168 void command_body(object *op, const char *params) {
169  int i;
170 
171  /* Too hard to try and make a header that lines everything up, so just
172  * give a description.
173  */
175  i18n(op, "The first column is the name of the body location."));
176 
178  i18n(op, "The second column is how many of those locations your body has."));
179 
181  i18n(op, "The third column is how many slots in that location are available."));
182 
183  for (i = 0; i < NUM_BODY_LOCATIONS; i++) {
184  /* really debugging - normally body_used should not be set to anything
185  * if body_info isn't also set.
186  */
187  if (op->body_info[i] || op->body_used[i]) {
189  i18n(op, "[fixed]%-30s %5d %5d"),
190  i18n(op, body_locations[i].use_name), op->body_info[i], op->body_used[i]);
191  }
192  }
193  if (!QUERY_FLAG(op, FLAG_USE_ARMOUR))
195  i18n(op, "You are not allowed to wear armor."));
196  if (!QUERY_FLAG(op, FLAG_USE_WEAPON))
198  i18n(op, "You are not allowed to use weapons."));
199 }
200 
209 void command_motd(object *op, const char *params) {
210  display_motd(op);
211 }
212 
221 void command_rules(object *op, const char *params) {
222  send_rules(op);
223 }
224 
233 void command_news(object *op, const char *params) {
234  send_news(op);
235 }
236 
243 static void malloc_info(object *op) {
244  int ob_used = object_count_used(), ob_free = object_count_free(), players, nrofmaps;
245  int nrm = 0, mapmem = 0, anr, anims, sum_alloc = 0, sum_used = 0, i, tlnr, alnr;
246  treasurelist *tl;
247  player *pl;
248  mapstruct *m;
249  archetype *at;
250  artifactlist *al;
251 
252  for (tl = first_treasurelist, tlnr = 0; tl != NULL; tl = tl->next, tlnr++)
253  ;
254  for (al = first_artifactlist, alnr = 0; al != NULL; al = al->next, alnr++)
255  ;
256 
257  for (at = first_archetype, anr = 0, anims = 0; at != NULL; at = at->more == NULL ? at->next : at->more, anr++)
258  ;
259 
260  for (i = 1; i < num_animations; i++)
261  anims += animations[i].num_animations;
262 
263  for (pl = first_player, players = 0; pl != NULL; pl = pl->next, players++)
264  ;
265 
266  for (m = first_map, nrofmaps = 0; m != NULL; m = m->next, nrofmaps++)
267  if (m->in_memory == MAP_IN_MEMORY) {
268  mapmem += map_size(m) * (sizeof(object *) + sizeof(MapSpace));
269  nrm++;
270  }
271 
273  i18n(op, "Sizeof: object=%d player=%d map=%d"),
274  sizeof(object), sizeof(player), sizeof(mapstruct));
275 
277  i18n(op, "[fixed]Objects:"));
278 
280  i18n(op, "[fixed]%6d used"), ob_used);
281 
282  if (ob_used != nrofallocobjects - nroffreeobjects) {
284  i18n(op, "[fixed] (used list mismatch: %d)"),
286  }
287 
289  i18n(op, "[fixed]%6d free (%.2f%% of %d allocated)"),
290  ob_free, (float)ob_free / nrofallocobjects * 100, nrofallocobjects);
291 
292  if (ob_free != nroffreeobjects) {
294  i18n(op, "[fixed] (free list mismatch: %d)"),
296  }
297 
299  i18n(op, "[fixed]%6d on active list"),
301 
302  i = (ob_used*sizeof(object));
303  sum_used += i;
304  sum_alloc += i;
305 
307  i18n(op, "[fixed] object total: %11d"), i);
308 
309  i = (ob_free*sizeof(object));
310  sum_alloc += i;
311 
313  i18n(op, "[fixed]%4d players: %8d"),
314  players, i = (players*sizeof(player)));
315 
316  sum_alloc += i;
317  sum_used += i;
318 
320  i18n(op, "[fixed]%4d maps allocated: %8d"),
321  nrofmaps, i = (nrofmaps*sizeof(mapstruct)));
322 
323  sum_alloc += i;
324  sum_used += nrm*sizeof(mapstruct);
325 
327  i18n(op, "[fixed]%4d maps in memory: %8d"),
328  nrm, mapmem);
329 
330  sum_alloc += mapmem;
331  sum_used += mapmem;
332 
334  i18n(op, "[fixed]%4d archetypes: %8d"),
335  anr, i = (anr*sizeof(archetype)));
336 
337  sum_alloc += i;
338  sum_used += i;
339 
341  i18n(op, "[fixed]%4d animations: %8d"),
342  anims, i = (anims*sizeof(uint16_t)));
343 
344  sum_alloc += i;
345  sum_used += i;
346 
348  i18n(op, "[fixed]%4d treasurelists %8d"),
349  tlnr, i = (tlnr*sizeof(treasurelist)));
350 
351  sum_alloc += i;
352  sum_used += i;
353 
355  i18n(op, "[fixed]%4ld treasures %8d"),
356  nroftreasures, i = (nroftreasures*sizeof(treasure)));
357 
358  sum_alloc += i;
359  sum_used += i;
360 
362  i18n(op, "[fixed]%4ld artifacts %8d"),
363  nrofartifacts, i = (nrofartifacts*sizeof(artifact)));
364 
365  sum_alloc += i;
366  sum_used += i;
367 
369  i18n(op, "[fixed]%4ld artifacts strngs %8d"),
370  nrofallowedstr, i = (nrofallowedstr*sizeof(linked_char)));
371 
372  sum_alloc += i;
373  sum_used += i;
374 
376  i18n(op, "[fixed]%4d artifactlists %8d"),
377  alnr, i = (alnr*sizeof(artifactlist)));
378 
379  sum_alloc += i;
380  sum_used += i;
381 
383  i18n(op, "[fixed]Total space allocated:%8d"),
384  sum_alloc);
385 
387  i18n(op, "[fixed]Total space used: %8d"),
388  sum_used);
389 }
390 
402 void current_region_info(object *op) {
403  /*
404  * Ok I /suppose/ I should write a seperate function for this, but it isn't
405  * going to be /that/ slow, and won't get called much
406  */
408 
409  /* This should only be possible if regions are not operating on this server. */
410  if (!r)
411  return;
412 
414  i18n(op, "You are in %s.\n%s"),
416 }
417 
424 void current_map_info(object *op) {
425  mapstruct *m = op->map;
426 
427  if (!m)
428  return;
429 
431  "%s (%s) in %s",
433 
434  if (QUERY_FLAG(op, FLAG_WIZ)) {
436  i18n(op, "players:%d difficulty:%d size:%dx%d start:%dx%d timeout %d"),
437  m->players, m->difficulty,
438  MAP_WIDTH(m), MAP_HEIGHT(m),
439  MAP_ENTER_X(m), MAP_ENTER_Y(m),
440  MAP_TIMEOUT(m));
441  }
442  if (m->msg)
444 }
445 
446 #ifdef DEBUG_MALLOC_LEVEL
447 
455 void command_malloc_verify(object *op, char *parms) {
456  extern int malloc_verify(void);
457 
458  if (!malloc_verify())
460  i18n(op, "Heap is corrupted."));
461  else
463  i18n(op, "Heap checks out OK."));
464 
465  return 1;
466 }
467 #endif
468 
479 void command_whereabouts(object *op, const char *params) {
480  region *reg;
481  player *pl;
482 
483  /*
484  * reset the counter on the region, then use it to store the number of
485  * players there.
486  * I don't know how thread-safe this would be, I suspect not very....
487  */
488  for (reg = first_region; reg != NULL; reg = reg->next) {
489  reg->counter = 0;
490  }
491  for (pl = first_player; pl != NULL; pl = pl->next)
492  if (pl->ob->map != NULL)
493  get_region_by_map(pl->ob->map)->counter++;
494 
495  /* we only want to print out by places with a 'longname' field...*/
496  for (reg = first_region; reg != NULL; reg = reg->next) {
497  if (reg->longname == NULL && reg->counter > 0) {
498  if (reg->parent != NULL) {
499  reg->parent->counter += reg->counter;
500  reg->counter = 0;
501  } else /*uh oh, we shouldn't be here. */
502  LOG(llevError, "command_whereabouts() Region %s with no longname has no parent\n", reg->name);
503  }
504  }
506  i18n(op, "In the world currently there are:"));
507 
508  for (reg = first_region; reg != NULL; reg = reg->next)
509  if (reg->counter > 0) {
511  i18n(op, "%u players in %s"),
512  reg->counter, get_region_longname(reg));
513  }
514 }
515 
517 typedef struct {
518  char namebuf[MAX_BUF];
520 } chars_names;
521 
531 static int name_cmp(const chars_names *c1, const chars_names *c2) {
532  return strcasecmp(c1->namebuf, c2->namebuf);
533 }
534 
545 void list_players(object *op, region *reg, partylist *party) {
546  player *pl;
547  uint16_t i;
548  char *format;
549  int num_players = 0, num_wiz = 0, num_afk = 0, num_bot = 0;
550  chars_names *chars = NULL;
551 
552  if (op == NULL || QUERY_FLAG(op, FLAG_WIZ))
553  format = settings.who_wiz_format;
554  else
555  format = settings.who_format;
556 
557  for (pl = first_player; pl != NULL; pl = pl->next) {
558  if (pl->ob->map == NULL)
559  continue;
560  if (pl->hidden && !QUERY_FLAG(op, FLAG_WIZ))
561  continue;
562 
563  if (reg && !region_is_child_of_region(get_region_by_map(pl->ob->map), reg))
564  continue;
565  if (party && pl->party != party)
566  continue;
567 
568  if (pl->state == ST_PLAYING || pl->state == ST_GET_PARTY_PASSWORD) {
569  num_players++;
570  chars = (chars_names *)realloc(chars, num_players*sizeof(chars_names));
571  if (chars == NULL) {
573  i18n(op, "who failed - out of memory!"));
574  return;
575  }
576  sprintf(chars[num_players-1].namebuf, "%s", pl->ob->name);
577  chars[num_players-1].login_order = num_players;
578 
579  /* Check for WIZ's & AFK's*/
580  if (QUERY_FLAG(pl->ob, FLAG_WIZ))
581  num_wiz++;
582 
583  if (QUERY_FLAG(pl->ob, FLAG_AFK))
584  num_afk++;
585 
586  if (pl->socket.is_bot)
587  num_bot++;
588  }
589  }
590  if (first_player != (player *)NULL) {
591  if (reg == NULL && party == NULL)
593  i18n(op, "Total Players (%d) -- WIZ(%d) AFK(%d) BOT(%d)"),
594  num_players, num_wiz, num_afk, num_bot);
595  else if (party == NULL)
597  i18n(op, "Total Players in %s (%d) -- WIZ(%d) AFK(%d) BOT(%d)"),
598  reg->longname ? reg->longname : reg->name, num_players, num_wiz, num_afk, num_bot);
599  else
601  i18n(op, "Total Players in party %s (%d) -- WIZ(%d) AFK(%d) BOT(%d)"),
602  party->partyname, num_players, num_wiz, num_afk, num_bot);
603  }
604  qsort(chars, num_players, sizeof(chars_names), (int (*)(const void *, const void *))name_cmp);
605  for (i = 0; i < num_players; i++)
606  display_who_entry(op, find_player(chars[i].namebuf), format);
607  free(chars);
608 }
609 
618 void command_who(object *op, const char *params) {
619  region *reg;
620 
621  reg = get_region_from_string(params);
622  list_players(op, reg, NULL);
623 }
624 
635 void display_who_entry(object *op, player *pl, const char *format) {
636  char tmpbuf[MAX_BUF];
637  char outbuf[MAX_BUF];
638  size_t i;
639 
640  strcpy(outbuf, "[fixed]");
641 
642  if (pl == NULL) {
643  LOG(llevError, "display_who_entry(): I was passed a null player\n");
644  return;
645  }
646  for (i = 0; i <= strlen(format); i++) {
647  if (format[i] == '%') {
648  i++;
649  get_who_escape_code_value(tmpbuf, sizeof(tmpbuf), format[i], pl);
650  strcat(outbuf, tmpbuf);
651  } else if (format[i] == '_') {
652  strcat(outbuf, " "); /* allow '_' to be used in place of spaces */
653  } else {
654  snprintf(tmpbuf, sizeof(tmpbuf), "%c", format[i]);
655  strcat(outbuf, tmpbuf);
656  }
657  }
659 }
660 
691 void get_who_escape_code_value(char *return_val, int size, const char letter, player *pl) {
692  switch (letter) {
693  case 'N':
694  strlcpy(return_val, pl->ob->name, size);
695  break;
696 
697  case 't':
698  player_get_title(pl, return_val, size);
699  break;
700 
701  case 'c':
702  snprintf(return_val, size, "%u", pl->ob->count);
703  break;
704 
705  case 'n':
706  snprintf(return_val, size, "\n");
707  break;
708 
709  case 'h':
710  strlcpy(return_val, pl->peaceful ? "" : " <Hostile>", size);
711  break;
712 
713  case 'l':
714  snprintf(return_val, size, "%d", pl->ob->level);
715  break;
716 
717  case 'd':
718  strlcpy(return_val, (QUERY_FLAG(pl->ob, FLAG_WIZ) ? " <WIZ>" : ""), size);
719  break;
720 
721  case 'a':
722  strlcpy(return_val, (QUERY_FLAG(pl->ob, FLAG_AFK) ? " <AFK>" : ""), size);
723  break;
724 
725  case 'b':
726  strlcpy(return_val, (pl->socket.is_bot == 1) ? " <BOT>" : "", size);
727  break;
728 
729  case 'm':
730  strlcpy(return_val, pl->ob->map->path, size);
731  break;
732 
733  case 'M':
734  strlcpy(return_val, pl->ob->map->name ? pl->ob->map->name : "Untitled", size);
735  break;
736 
737  case 'r':
738  strlcpy(return_val, get_name_of_region_for_map(pl->ob->map), size);
739  break;
740 
741  case 'R':
742  strlcpy(return_val, get_region_longname(get_region_by_map(pl->ob->map)), size);
743  break;
744 
745  case 'i':
746  strlcpy(return_val, pl->socket.host, size);
747  break;
748 
749  case '%':
750  snprintf(return_val, size, "%%");
751  break;
752 
753  case '_':
754  snprintf(return_val, size, "_");
755  break;
756  }
757 }
758 
767 void command_afk(object *op, const char *params) {
768  if (QUERY_FLAG(op, FLAG_AFK)) {
769  CLEAR_FLAG(op, FLAG_AFK);
771  i18n(op, "You are no longer AFK"));
772  } else {
773  SET_FLAG(op, FLAG_AFK);
775  i18n(op, "You are now AFK"));
776  }
777 }
778 
787 void command_malloc(object *op, const char *params) {
788  malloc_info(op);
789 }
790 
799 void command_mapinfo(object *op, const char *params) {
800  current_map_info(op);
801 }
802 
811 void command_whereami(object *op, const char *params) {
813 }
814 
823 void command_maps(object *op, const char *params) {
824  map_info(op, params);
825 }
826 
835 void command_strings(object *op, const char *params) {
836  char stats[HUGE_BUF];
837 
838  ss_dump_statistics(stats, sizeof(stats));
840  "[fixed]%s\n",
841  stats);
842 
844  ss_dump_table(SS_DUMP_TOTALS, stats, sizeof(stats)));
845 }
846 
855 void command_time(object *op, const char *params) {
856  time_info(op);
857 }
858 
867 void command_archs(object *op, const char *params) {
868  arch_info(op);
869 }
870 
879 void command_hiscore(object *op, const char *params) {
880  hiscore_display(op, op == NULL ? 9999 : 50, params);
881 }
882 
891 void command_debug(object *op, const char *params) {
892  int i;
893 
894  if (*params == '\0' || !sscanf(params, "%d", &i)) {
896  i18n(op, "Global debug level is %d."),
897  settings.debug);
898  return;
899  }
900  settings.debug = (enum LogLevel)FABS(i);
902  i18n(op, "Debug level set to %d."),
903  i);
904 }
905 
906 
915 void command_wizpass(object *op, const char *params) {
916  int i;
917 
918  if (!op)
919  return;
920 
921  if (*params == '\0')
922  i = (QUERY_FLAG(op, FLAG_WIZPASS)) ? 0 : 1;
923  else
924  i = onoff_value(params);
925 
926  if (i) {
928  i18n(op, "You will now walk through walls."));
929  SET_FLAG(op, FLAG_WIZPASS);
930  } else {
932  i18n(op, "You will now be stopped by walls."));
934  }
935 }
936 
945 void command_wizcast(object *op, const char *params) {
946  int i;
947 
948  if (!op)
949  return;
950 
951  if (*params == '\0')
952  i = (QUERY_FLAG(op, FLAG_WIZCAST)) ? 0 : 1;
953  else
954  i = onoff_value(params);
955 
956  if (i) {
958  i18n(op, "You can now cast spells anywhere."));
959  SET_FLAG(op, FLAG_WIZCAST);
960  } else {
962  i18n(op, "You now cannot cast spells in no-magic areas."));
964  }
965 }
966 
975 void command_dumpallobjects(object *op, const char *params) {
976  object_dump_all();
977 }
978 
987 void command_dumpfriendlyobjects(object *op, const char *params) {
989 }
990 
999 void command_dumpallarchetypes(object *op, const char *params) {
1001 }
1002 
1011 void command_ssdumptable(object *op, const char *params) {
1012  ss_dump_table(SS_DUMP_TABLE, NULL, 0);
1013 }
1014 
1023 void command_dumpmap(object *op, const char *params) {
1024  if (op)
1025  dump_map(op->map);
1026 }
1027 
1036 void command_dumpallmaps(object *op, const char *params) {
1037  dump_all_maps();
1038 }
1039 
1048 void command_printlos(object *op, const char *params) {
1049  if (op)
1050  print_los(op);
1051 }
1052 
1053 
1062 void command_version(object *op, const char *params) {
1064  MSG_TYPE_ADMIN_VERSION, "Crossfire "FULL_VERSION);
1065 }
1066 
1075 void command_listen(object *op, const char *params) {
1076  int i;
1077 
1078  if (*params == '\0' || !sscanf(params, "%d", &i)) {
1080  i18n(op, "Set listen to what (presently %d)?"),
1081  op->contr->listening);
1082  return;
1083  }
1084  if (i < 0) {
1086  i18n(op, "Verbose level should be positive."));
1087  return;
1088  }
1089  op->contr->listening = (char)i;
1091  i18n(op, "Your verbose level is now %d."),
1092  i);
1093 }
1094 
1106 void command_statistics(object *pl, const char *params) {
1107  char buf[MAX_BUF];
1108  uint32_t hours, minutes;
1109  uint64_t seconds; /* 64 bit to prevent overflows an intermediate results */
1110 
1111  if (!pl->contr)
1112  return;
1113  safe_strncpy(buf, i18n(pl, "[fixed] Experience: %"), sizeof(buf));
1114  strcat(buf, FMT64);
1116  buf,
1117  pl->stats.exp);
1118  safe_strncpy(buf, i18n(pl, "[fixed] Next Level: %"), sizeof(buf));
1119  strcat(buf, FMT64);
1121  buf,
1122  level_exp(pl->level+1, pl->expmul));
1123 
1125  i18n(pl, "[fixed]\nStat Nat/Real/Max"));
1126 
1128  i18n(pl, "[fixed]Str %2d/ %3d/%3d"),
1129  pl->contr->orig_stats.Str, pl->stats.Str, 20+pl->arch->clone.stats.Str);
1131  i18n(pl, "[fixed]Dex %2d/ %3d/%3d"),
1132  pl->contr->orig_stats.Dex, pl->stats.Dex, 20+pl->arch->clone.stats.Dex);
1134  i18n(pl, "[fixed]Con %2d/ %3d/%3d"),
1135  pl->contr->orig_stats.Con, pl->stats.Con, 20+pl->arch->clone.stats.Con);
1137  i18n(pl, "[fixed]Int %2d/ %3d/%3d"),
1138  pl->contr->orig_stats.Int, pl->stats.Int, 20+pl->arch->clone.stats.Int);
1140  i18n(pl, "[fixed]Wis %2d/ %3d/%3d"),
1141  pl->contr->orig_stats.Wis, pl->stats.Wis, 20+pl->arch->clone.stats.Wis);
1143  i18n(pl, "[fixed]Pow %2d/ %3d/%3d"),
1144  pl->contr->orig_stats.Pow, pl->stats.Pow, 20+pl->arch->clone.stats.Pow);
1146  i18n(pl, "[fixed]Cha %2d/ %3d/%3d"),
1147  pl->contr->orig_stats.Cha, pl->stats.Cha, 20+pl->arch->clone.stats.Cha);
1149  i18n(pl, "\nAttack Mode: %s"),
1150  i18n(pl, pl->contr->peaceful ? "Peaceful" : "Hostile"));
1154  float weap_speed = pl->weapon_speed; // This is the number of attacks per tick.
1155  if (weap_speed < 0.0f)
1156  weap_speed = 0.0f;
1157  if (weap_speed > 1.0f)
1158  weap_speed = 1.0f;
1159  // We will initially calculate the damage if every attack you perform hits.
1160  // This will serve as a baseline for future calculations
1161  float dps = (1000000.0f / max_time) * weap_speed * pl->stats.dam;
1162  // TODO: Account for opposing AC in calculations, make some sort of table/chart.
1163  // Then we round the floating-point.
1165  i18n(pl, "\n\nDam/Sec: %4d"), (int)(dps + 0.5f));
1166 
1167  /* max_time is in microseconds - thus divide by 1000000.
1168  * Need 64 bit values, as otherwise ticks_played * max_time
1169  * can easily overflow.
1170  * Note the message displayed here isn't really
1171  * perfect, since if max_time has been changed since the player started,
1172  * the time estimates use the current value. But I'm presuming that
1173  * max_time won't change very often. MSW 2009-12-01
1174  */
1175  seconds = (uint64_t)pl->contr->ticks_played * (uint64_t)max_time / 1000000;
1176  minutes = (uint32_t)seconds / 60;
1177  hours = minutes / 60;
1178  minutes = minutes % 60;
1179 
1181  "You have played this character for %u ticks, which amounts "
1182  "to %d hours and %d minutes.",
1183  pl->contr->ticks_played, hours, minutes);
1184 
1185 
1186  /* Can't think of anything else to print right now */
1187 }
1188 
1197 void command_fix_me(object *op, const char *params) {
1198  object_sum_weight(op);
1199  fix_object(op);
1200 }
1201 
1210 void command_players(object *op, const char *params) {
1211  char buf[MAX_BUF];
1212  char *t;
1213  DIR *dir;
1214 
1215  snprintf(buf, sizeof(buf), "%s/%s/", settings.localdir, settings.playerdir);
1216  t = buf+strlen(buf);
1217  if ((dir = opendir(buf)) != NULL) {
1218  const struct dirent *entry;
1219 
1220  while ((entry = readdir(dir)) != NULL) {
1221  /* skip '.' , '..' */
1222  if (!((entry->d_name[0] == '.' && entry->d_name[1] == '\0')
1223  || (entry->d_name[0] == '.' && entry->d_name[1] == '.' && entry->d_name[2] == '\0'))) {
1224  struct stat st;
1225 
1226  strcpy(t, entry->d_name);
1227  if (stat(buf, &st) == 0) {
1228  /* This was not posix compatible
1229  * if ((st.st_mode & S_IFMT)==S_IFDIR) {
1230  */
1231  if (S_ISDIR(st.st_mode)) {
1232  struct tm *tm = localtime(&st.st_mtime);
1233 
1235  i18n(op, "[fixed]%s\t%04d %02d %02d %02d %02d %02d"),
1236  entry->d_name,
1237  1900+tm->tm_year,
1238  1+tm->tm_mon,
1239  tm->tm_mday,
1240  tm->tm_hour,
1241  tm->tm_min,
1242  tm->tm_sec);
1243  }
1244  }
1245  }
1246  }
1247  }
1248  closedir(dir);
1249 }
1250 
1259 void command_applymode(object *op, const char *params) {
1260  unapplymode unapply = op->contr->unapply;
1261  static const char *const types[] = {
1262  "nochoice",
1263  "never",
1264  "always"
1265  };
1266 
1267  if (*params == '\0') {
1269  i18n(op, "applymode is set to %s"),
1270  types[op->contr->unapply]);
1271  return;
1272  }
1273 
1274  if (!strcmp(params, "nochoice"))
1276  else if (!strcmp(params, "never"))
1277  op->contr->unapply = unapply_never;
1278  else if (!strcmp(params, "always"))
1279  op->contr->unapply = unapply_always;
1280  else {
1282  i18n(op, "applymode: Unknown options %s, valid options are nochoice, never, always"),
1283  params);
1284  return;
1285  }
1287  i18n(op, "applymode%s set to %s"),
1288  (unapply == op->contr->unapply ? "" : " now"),
1289  types[op->contr->unapply]);
1290 }
1291 
1300 void command_bowmode(object *op, const char *params) {
1301  bowtype_t oldtype = op->contr->bowtype;
1302  static const char *const types[] = {
1303  "normal",
1304  "threewide",
1305  "spreadshot",
1306  "firenorth",
1307  "firene",
1308  "fireeast",
1309  "firese",
1310  "firesouth",
1311  "firesw",
1312  "firewest",
1313  "firenw",
1314  "bestarrow"
1315  };
1316  int i, found;
1317 
1318  if (*params == '\0') {
1320  i18n(op, "bowmode is set to %s"),
1321  types[op->contr->bowtype]);
1322  return;
1323  }
1324 
1325  for (i = 0, found = 0; i <= bow_bestarrow; i++) {
1326  if (!strcmp(params, types[i])) {
1327  found++;
1328  op->contr->bowtype = i;
1329  break;
1330  }
1331  }
1332  if (!found) {
1333  StringBuffer *buf = stringbuffer_new();
1334  stringbuffer_append_printf(buf, "bowmode: Unknown options %s, valid options are:", params);
1335  for (i = 0; i <= bow_bestarrow; i++) {
1336  stringbuffer_append_string(buf, " ");
1337  stringbuffer_append_string(buf, types[i]);
1338  if (i < bow_nw)
1339  stringbuffer_append_string(buf, ",");
1340  else
1341  stringbuffer_append_string(buf, ".");
1342  }
1343  char *result = stringbuffer_finish(buf);
1345  free(result);
1346  return;
1347  }
1349  i18n(op, "bowmode%s set to %s"),
1350  (oldtype == op->contr->bowtype ? "" : " now"),
1351  types[op->contr->bowtype]);
1352  return;
1353 }
1354 
1363 void command_unarmed_skill(object *op, const char *params) {
1364  object *skill;
1365  size_t i;
1366 
1367  if (*params == '\0') {
1369  "unarmed skill is set to %s",
1370  op->contr->unarmed_skill ? op->contr->unarmed_skill: "nothing");
1371  return;
1372  }
1373 
1374  /* find_skill_by_name() will ready any skill tools - which
1375  * is OK for us because no unarmed skills require skill tools,
1376  * but this could be an issue if you reuse this code for other skills.
1377  */
1378  skill = find_skill_by_name(op, params);
1379 
1380  if (!skill) {
1382  "You do not know any such skill called %s",
1383  params);
1384  return;
1385  }
1386  for (i = 0; i < sizeof(unarmed_skills); i++)
1387  if (skill->subtype == unarmed_skills[i])
1388  break;
1389  if (i == sizeof(unarmed_skills)) {
1391  "%s is not an unarmed skill!",
1392  skill->name);
1393  return;
1394 
1395  }
1396 
1397  if (op->contr->unarmed_skill)
1399 
1400  /* Taking actual skill name is better than taking params,
1401  * as params could be something more than an exact skill name.
1402  */
1403  op->contr->unarmed_skill = add_string(skill->name);
1404 
1406  "unarmed skill is now set to %s",
1407  op->contr->unarmed_skill);
1408 }
1409 
1410 
1419 void command_petmode(object *op, const char *params) {
1420  petmode_t oldtype = op->contr->petmode;
1421  static const char *const types[] = {
1422  "normal",
1423  "sad",
1424  "defend",
1425  "arena"
1426  };
1427 
1428  if (*params == '\0') {
1430  i18n(op, "petmode is set to %s"),
1431  types[op->contr->petmode]);
1432  return;
1433  }
1434 
1435  if (!strcmp(params, "normal"))
1436  op->contr->petmode = pet_normal;
1437  else if (!strcmp(params, "sad"))
1438  op->contr->petmode = pet_sad;
1439  else if (!strcmp(params, "defend"))
1440  op->contr->petmode = pet_defend;
1441  else if (!strcmp(params, "arena"))
1442  op->contr->petmode = pet_arena;
1443  else {
1445  i18n(op, "petmode: Unknown options %s, valid options are normal, sad (seek and destroy), defend, arena"),
1446  params);
1447  return;
1448  }
1450  i18n(op, "petmode%s set to %s"),
1451  (oldtype == op->contr->petmode ? "" : " now"),
1452  types[op->contr->petmode]);
1453 }
1454 
1463 void command_showpets(object *op, const char *params) {
1464  objectlink *obl, *next;
1465  int counter = 0, target = 0;
1466  int have_shown_pet = 0;
1467  if (*params != '\0')
1468  target = atoi(params);
1469 
1470  for (obl = first_friendly_object; obl != NULL; obl = next) {
1471  object *ob = obl->ob;
1472 
1473  next = obl->next;
1474  if (object_get_owner(ob) == op) {
1475  if (target == 0) {
1476  if (counter == 0)
1478  i18n(op, "Pets:"));
1480  i18n(op, "%d %s - level %d"),
1481  ++counter, ob->name, ob->level);
1482  } else if (!have_shown_pet && ++counter == target) {
1484  i18n(op, "[fixed]level %d %s"),
1485  ob->level, ob->name);
1487  i18n(op, "[fixed]%d/%d HP, %d/%d SP"),
1488  ob->stats.hp, ob->stats.maxhp, ob->stats.sp, ob->stats.maxsp);
1489 
1490  /* this is not a nice way to do this, it should be made to be more like the statistics command */
1492  i18n(op, "[fixed]Str %d"),
1493  ob->stats.Str);
1495  i18n(op, "[fixed]Dex %d"),
1496  ob->stats.Dex);
1498  i18n(op, "[fixed]Con %d"),
1499  ob->stats.Con);
1501  i18n(op, "[fixed]Int %d"),
1502  ob->stats.Int);
1504  i18n(op, "[fixed]Wis %d"),
1505  ob->stats.Wis);
1507  i18n(op, "[fixed]Cha %d"),
1508  ob->stats.Cha);
1510  i18n(op, "[fixed]Pow %d"),
1511  ob->stats.Pow);
1513  i18n(op, "[fixed]wc %d damage %d ac %d"),
1514  ob->stats.wc, ob->stats.dam, ob->stats.ac);
1515  have_shown_pet = 1;
1516  }
1517  }
1518  }
1519  if (counter == 0)
1521  i18n(op, "You have no pets."));
1522  else if (target != 0 && have_shown_pet == 0)
1524  i18n(op, "No such pet."));
1525 }
1526 
1535 void command_usekeys(object *op, const char *params) {
1536  usekeytype oldtype = op->contr->usekeys;
1537  static const char *const types[] = {
1538  "inventory",
1539  "keyrings",
1540  "containers"
1541  };
1542 
1543  if (*params == '\0') {
1545  i18n(op, "usekeys is set to %s"),
1546  types[op->contr->usekeys]);
1547  return;
1548  }
1549 
1550  if (!strcmp(params, "inventory"))
1551  op->contr->usekeys = key_inventory;
1552  else if (!strcmp(params, "keyrings"))
1553  op->contr->usekeys = keyrings;
1554  else if (!strcmp(params, "containers"))
1555  op->contr->usekeys = containers;
1556  else {
1558  i18n(op, "usekeys: Unknown option %s, valid options are inventory, keyrings, containers"),
1559  params);
1560  return;
1561  }
1563  i18n(op, "usekeys%s set to %s"),
1564  (oldtype == op->contr->usekeys ? "" : " now"),
1565  types[op->contr->usekeys]);
1566 }
1567 
1576 void command_resistances(object *op, const char *params) {
1577  int i;
1578  if (!op)
1579  return;
1580 
1581  for (i = 0; i < NROFATTACKS; i++) {
1582  if (i == ATNR_INTERNAL)
1583  continue;
1584 
1586  i18n(op, "[fixed]%-20s %+5d"),
1587  attacktype_desc[i], op->resist[i]);
1588  }
1589 
1590  /* If dragon player, let's display natural resistances */
1591  if (is_dragon_pl(op)) {
1592  int attack;
1593  object *tmp;
1594 
1595  tmp = object_find_by_type_and_arch_name(op, FORCE, "dragon_skin_force");
1596  if (tmp != NULL) {
1598  i18n(op, "\nNatural skin resistances:"));
1599 
1600  for (attack = 0; attack < NROFATTACKS; attack++) {
1601  if (atnr_is_dragon_enabled(attack)) {
1603  i18n(op, "%s: %d"),
1604  change_resist_msg[attack], tmp->resist[attack]);
1605  }
1606  }
1607  }
1608  }
1609 }
1610 
1621 static void help_topics(object *op, int what) {
1622  DIR *dirp;
1623  struct dirent *de;
1624  char filename[MAX_BUF], line[HUGE_BUF];
1625  char suffix[MAX_BUF];
1626  int namelen;
1627  const char *language;
1628 
1629  language = i18n_get_language_code(op->contr->language);
1630  snprintf(suffix, sizeof(suffix), ".%s", language);
1631 
1632  switch (what) {
1633  case 1:
1634  snprintf(filename, sizeof(filename), "%s/wizhelp", settings.datadir);
1636  i18n(op, " Wiz commands:"));
1637  break;
1638 
1639  case 3:
1640  snprintf(filename, sizeof(filename), "%s/mischelp", settings.datadir);
1642  i18n(op, " Misc help:"));
1643  break;
1644 
1645  default:
1646  snprintf(filename, sizeof(filename), "%s/help", settings.datadir);
1648  i18n(op, " Commands:"));
1649  break;
1650  }
1651  if (!(dirp = opendir(filename)))
1652  return;
1653 
1654  line[0] = '\0';
1655  for (de = readdir(dirp); de; de = readdir(dirp)) {
1656  namelen = NAMLEN(de);
1657 
1658  if (namelen <= 2
1659  && *de->d_name == '.'
1660  && (namelen == 1 || de->d_name[1] == '.'))
1661  continue;
1662  if (strstr(de->d_name, suffix)) {
1663  strcat(line, strtok(de->d_name, "."));
1664  strcat(line, " ");
1665  }
1666  }
1668  line);
1669  closedir(dirp);
1670 }
1671 
1682 static void show_commands(object *op, int what) {
1683  char line[HUGE_BUF];
1684  int i, size;
1686 
1687  switch (what) {
1688  case 1:
1689  ap = WizCommands;
1690  size = WizCommandsSize;
1692  i18n(op, " Wiz commands:"));
1693  break;
1694 
1695  case 2:
1696  ap = CommunicationCommands;
1697  size = CommunicationCommandSize;
1699  i18n(op, " Communication commands:"));
1700  break;
1701 
1702  default:
1703  ap = Commands;
1704  size = CommandsSize;
1706  i18n(op, " Commands:"));
1707  break;
1708  }
1709 
1710  line[0] = '\0';
1711  for (i = 0; i < size; i++) {
1712  strcat(line, ap[i].name);
1713  strcat(line, " ");
1714  }
1716 }
1717 
1729 static int find_help_file(const char *name, const char *language, int wiz, char *path, int length) {
1730  struct stat st;
1731 
1732  snprintf(path, length, "%s/help/%s.%s", settings.datadir, name, language);
1733  if (stat(path, &st) == 0 && S_ISREG(st.st_mode)) {
1734  return 1;
1735  }
1736 
1737  if (strcmp(language, "en")) {
1738  snprintf(path, length, "%s/help/%s.en", settings.datadir, name);
1739  if (stat(path, &st) == 0 && S_ISREG(st.st_mode)) {
1740  return 1;
1741  }
1742  }
1743 
1744  if (!wiz)
1745  return 0;
1746 
1747  snprintf(path, length, "%s/wizhelp/%s.%s", settings.datadir, name, language);
1748  if (stat(path, &st) == 0 && S_ISREG(st.st_mode)) {
1749  return 1;
1750  }
1751  if (strcmp(language, "en")) {
1752  snprintf(path, length, "%s/wizhelp/%s.en", settings.datadir, name);
1753  if (stat(path, &st) == 0 && S_ISREG(st.st_mode)) {
1754  return 1;
1755  }
1756  }
1757 
1758  return 0;
1759 }
1760 
1769 void command_help(object *op, const char *params) {
1770  FILE *fp;
1771  char filename[MAX_BUF], line[MAX_BUF];
1772  int len;
1773  const char *language;
1774 
1775  /*
1776  * Main help page?
1777  */
1778  if (*params == '\0') {
1779  snprintf(filename, sizeof(filename), "%s/def_help", settings.datadir);
1780  if ((fp = fopen(filename, "r")) == NULL) {
1781  LOG(llevError, "Cannot open help file %s: %s\n", filename, strerror(errno));
1782  return;
1783  }
1784  while (fgets(line, MAX_BUF, fp)) {
1785  line[MAX_BUF-1] = '\0';
1786  len = strlen(line)-1;
1787  if (line[len] == '\n')
1788  line[len] = '\0';
1790  }
1791  fclose(fp);
1792  return;
1793  }
1794 
1795  /*
1796  * Topics list
1797  */
1798  if (!strcmp(params, "topics")) {
1799  help_topics(op, 3);
1800  help_topics(op, 0);
1801  if (QUERY_FLAG(op, FLAG_WIZ))
1802  help_topics(op, 1);
1803  return;
1804  }
1805 
1806  /*
1807  * Commands list
1808  */
1809  if (!strcmp(params, "commands")) {
1810  show_commands(op, 0);
1812  show_commands(op, 2); /* show comm commands */
1813  if (QUERY_FLAG(op, FLAG_WIZ)) {
1815  show_commands(op, 1);
1816  }
1817  return;
1818  }
1819 
1820  /*
1821  * User wants info about command
1822  */
1823  if (strchr(params, '.') || strchr(params, ' ') || strchr(params, '/')) {
1825  i18n(op, "Illegal characters in '%s'"),
1826  params);
1827  return;
1828  }
1829 
1830  language = i18n_get_language_code(op->contr->language);
1831 
1832  if (!find_help_file(params, language, QUERY_FLAG(op, FLAG_WIZ), filename, sizeof(filename))) {
1834  i18n(op, "No help available on '%s'"),
1835  params);
1836  return;
1837  }
1838 
1839  /*
1840  * Found that. Just cat it to screen.
1841  */
1842  if ((fp = fopen(filename, "r")) == NULL) {
1843  LOG(llevError, "Cannot open help file %s: %s\n", filename, strerror(errno));
1844  return;
1845  }
1846 
1848  i18n(op, "Help about '%s'"),
1849  params);
1850 
1851  while (fgets(line, MAX_BUF, fp)) {
1852  line[MAX_BUF-1] = '\0';
1853  len = strlen(line)-1;
1854  if (line[len] == '\n')
1855  line[len] = '\0';
1857  }
1858  fclose(fp);
1859 }
1860 
1871 int onoff_value(const char *line) {
1872  int i;
1873 
1874  if (sscanf(line, "%d", &i))
1875  return (i != 0);
1876 
1877  switch (line[0]) {
1878  case 'o':
1879  switch (line[1]) {
1880  case 'n':
1881  return 1; /* on */
1882  default:
1883  return 0; /* o[ff] */
1884  }
1885 
1886  case 'y': /* y[es] */
1887  case 'k': /* k[ylla] */
1888  case 's':
1889  case 'd':
1890  return 1;
1891 
1892  case 'n': /* n[o] */
1893  case 'e': /* e[i] */
1894  case 'u':
1895  default:
1896  return 0;
1897  }
1898 }
1899 
1905 void command_quit(object* op, const char* params) {
1906  draw_ext_info(
1908  i18n(op,
1909  "To leave the game, sleep in (apply) a bed to reality. To "
1910  "permenantly delete your character, use the 'delete' command."));
1911 }
1912 
1921 void command_delete(object *op, const char *params) {
1922  if (QUERY_FLAG(op, FLAG_WAS_WIZ)) {
1923  draw_ext_info(NDI_UNIQUE, 0, op, MSG_TYPE_COMMAND, MSG_TYPE_ADMIN_DM, "Can't quit when in DM mode.");
1924  return;
1925  }
1926 
1928  i18n(op, "Quitting will delete your character.\nAre you sure you want to delete your character (y/n):"));
1929 
1931 }
1932 
1941 void command_sound(object *op, const char *params) {
1942  if (!(op->contr->socket.sound&SND_MUTE)) {
1943  op->contr->socket.sound = op->contr->socket.sound|SND_MUTE;
1945  i18n(op, "Sounds are turned off."));
1946  } else {
1947  op->contr->socket.sound = op->contr->socket.sound&~SND_MUTE;
1949  i18n(op, "The sounds are enabled."));
1950  }
1951  return;
1952 }
1953 
1963 void receive_player_name(object *op) {
1964  if (!check_name(op->contr, op->contr->write_buf+1)) {
1965  get_name(op);
1966  return;
1967  }
1968  FREE_AND_COPY(op->name, op->contr->write_buf+1);
1969  FREE_AND_COPY(op->name_pl, op->contr->write_buf+1);
1971  op->contr->name_changed = 1;
1972  get_password(op);
1973 }
1974 
1981 void receive_player_password(object *op) {
1982  unsigned int pwd_len = strlen(op->contr->write_buf);
1983 
1984  if (pwd_len <= 1 || pwd_len > 17) {
1985  if (op->contr->state == ST_CHANGE_PASSWORD_OLD
1987  || op->contr->state == ST_CHANGE_PASSWORD_CONFIRM) {
1989  i18n(op, "Password changed cancelled."));
1991  } else
1992  get_name(op);
1993  return;
1994  }
1995  /* To hide the password better */
1996  /* With currently clients, not sure if this is really the case - MSW */
1998 
1999  if (checkbanned(op->name, op->contr->socket.host)) {
2000  LOG(llevInfo, "Banned player tried to add: [%s@%s]\n", op->name, op->contr->socket.host);
2002  i18n(op, "You are not allowed to play."));
2003  get_name(op);
2004  return;
2005  }
2006 
2007  if (op->contr->state == ST_CONFIRM_PASSWORD) {
2008  if (!check_password(op->contr->write_buf+1, op->contr->password)) {
2010  i18n(op, "The passwords did not match."));
2011  get_name(op);
2012  return;
2013  }
2014  LOG(llevInfo, "LOGIN: New player named %s from ip %s\n", op->name, op->contr->socket.host);
2015  display_motd(op);
2017  i18n(op, "\nWelcome, Brave New Warrior!\n"));
2018  roll_again(op);
2020  return;
2021  }
2022 
2023  if (op->contr->state == ST_CHANGE_PASSWORD_OLD) {
2024  if (!check_password(op->contr->write_buf+1, op->contr->password)) {
2026  i18n(op, "You entered the wrong current password."));
2028  } else {
2029  send_query(&op->contr->socket, CS_QUERY_HIDEINPUT, i18n(op, "Please enter your new password, or blank to cancel:"));
2031  }
2032  return;
2033  }
2034 
2035  if (op->contr->state == ST_CHANGE_PASSWORD_NEW) {
2037  sizeof(op->contr->new_password));
2039  i18n(op, "Please confirm your new password, or blank to cancel:"));
2041  return;
2042  }
2043 
2044  if (op->contr->state == ST_CHANGE_PASSWORD_CONFIRM) {
2045  if (!check_password(op->contr->write_buf+1, op->contr->new_password)) {
2047  i18n(op, "The new passwords don't match!"));
2048  } else {
2050  i18n(op, "Password changed."));
2051  strncpy(op->contr->password, op->contr->new_password, 13);
2052  }
2054  return;
2055  }
2056 
2058  sizeof(op->contr->password));
2060  check_login(op, TRUE);
2061 }
2062 
2073 void command_title(object *op, const char *params) {
2074  char buf[MAX_BUF];
2075 
2076  if (settings.set_title == FALSE) {
2078  i18n(op, "You cannot change your title."));
2079  return;
2080  }
2081 
2082  /* dragon players cannot change titles */
2083  if (is_dragon_pl(op)) {
2085  i18n(op, "Dragons cannot change titles."));
2086  return;
2087  }
2088 
2089  if (*params == '\0') {
2090  char tmp[MAX_BUF];
2091 
2092  player_get_title(op->contr, tmp, sizeof(tmp));
2093  snprintf(buf, sizeof(buf), i18n(op, "Your title is '%s'."), tmp);
2095  return;
2096  }
2097  if (strcmp(params, "clear") == 0 || strcmp(params, "default") == 0) {
2098  if (!player_has_own_title(op->contr))
2100  i18n(op, "Your title is the default title."));
2101  else
2103  i18n(op, "Title set to default."));
2104  player_set_own_title(op->contr, "");
2105  return;
2106  }
2107 
2108  if ((int)strlen(params) >= MAX_NAME) {
2110  i18n(op, "Title too long."));
2111  return;
2112  }
2113  player_set_own_title(op->contr, params);
2114 }
2115 
2124 void command_save(object *op, const char *params) {
2125  if (get_map_flags(op->map, NULL, op->x, op->y, NULL, NULL)&P_NO_CLERIC) {
2127  i18n(op, "You can not save on unholy ground."));
2128  } else if (!op->stats.exp) {
2130  i18n(op, "You don't deserve to save yet."));
2131  } else {
2132  if (save_player(op, 1))
2134  i18n(op, "You have been saved."));
2135  else
2137  i18n(op, "SAVE FAILED!"));
2138  }
2139 }
2140 
2149 void command_peaceful(object *op, const char *params) {
2150  if ((op->contr->peaceful = !op->contr->peaceful))
2152  i18n(op, "You will not attack other players."));
2153  else
2155  i18n(op, "You will attack other players."));
2156 }
2157 
2166 void command_wimpy(object *op, const char *params) {
2167  int i;
2168 
2169  if (*params == '\0' || !sscanf(params, "%d", &i)) {
2171  i18n(op, "Your current wimpy level is %d."),
2172  op->run_away);
2173  return;
2174  }
2175 
2176  if (i < 0 || i > 100) {
2178  i18n(op, "Wimpy level should be between 1 and 100."),
2179  i);
2180  return;
2181  }
2182 
2184  i18n(op, "Your new wimpy level is %d."),
2185  i);
2186  op->run_away = i;
2187 }
2188 
2197 void command_brace(object *op, const char *params) {
2198  if (*params == '\0')
2199  op->contr->braced = !op->contr->braced;
2200  else
2201  op->contr->braced = onoff_value(params);
2202 
2203  if (op->contr->braced)
2205  i18n(op, "You are braced."));
2206  else
2208  i18n(op, "Not braced."));
2209 
2210  fix_object(op);
2211 }
2212 
2221 void command_kill_pets(object *op, const char *params) {
2222  objectlink *obl, *next;
2223  int counter = 0, removecount = 0;
2224 
2225  if (*params == '\0') {
2226  pets_terminate_all(op);
2228  i18n(op, "Your pets have been killed."));
2229  } else {
2230  int target = atoi(params);
2231  for (obl = first_friendly_object; obl != NULL; obl = next) {
2232  object *ob = obl->ob;
2233  next = obl->next;
2234  if (object_get_owner(ob) == op)
2235  if (++counter == target || (target == 0 && !strcasecmp(ob->name, params))) {
2236  if (!QUERY_FLAG(ob, FLAG_REMOVED))
2237  object_remove(ob);
2240  removecount++;
2241  }
2242  }
2243  if (removecount != 0)
2245  i18n(op, "Killed %d pets."),
2246  removecount);
2247  else
2249  i18n(op, "Couldn't find any suitable pets to kill."));
2250  }
2251 }
2252 
2261 void command_passwd(object *pl, const char *params) {
2262  /* If old client, this is the way you change your password. */
2263  if (pl->contr->socket.login_method < 1){
2264  send_query(&pl->contr->socket, CS_QUERY_HIDEINPUT, i18n(pl, "Password change.\nPlease enter your current password, or empty string to cancel."));
2265 
2267  }
2268  /* If new client (login_method = 2) or jxclient (login_method = 1), changing the password does nothing anyway, so error out */
2269  else{
2271  i18n(pl, "passwd is maintained for older clients that do not support the account system. Please use the 'Password' button in your character selection screen to change your password."));
2272  }
2273 }
2274 
2284 void do_harvest(object *pl, int dir, object *skill) {
2285  int16_t x, y;
2286  int count = 0, proba; /* Probability to get the item, 100 based. */
2287  int level, exp, check_exhaust = 0;
2288  object *found[10]; /* Found items that can be harvested. */
2289  mapstruct *map;
2290  object *item, *inv, *harvested;
2291  sstring trace, ttool, tspeed, race, tool, slevel, sexp;
2292  float speed;
2293 
2294  x = pl->x+freearr_x[dir];
2295  y = pl->y+freearr_y[dir];
2296  map = pl->map;
2297 
2298  if (!IS_PLAYER(pl))
2299  return;
2300 
2301  if (!map)
2302  return;
2303 
2304  if (get_map_flags(map, &map, x, y, &x, &y)&P_OUT_OF_MAP) {
2305  draw_ext_info_format(NDI_WHITE, 0, pl, MSG_TYPE_SKILL, MSG_TYPE_SKILL_FAILURE, "You can't %s anything here.", skill->slaying);
2306  return;
2307  }
2308 
2309  if (!pl->chosen_skill || pl->chosen_skill->skill != skill->skill)
2310  return;
2311 
2312  trace = object_get_value(pl->chosen_skill, "harvest_race");
2313  ttool = object_get_value(pl->chosen_skill, "harvest_tool");
2314  tspeed = object_get_value(pl->chosen_skill, "harvest_speed");
2315  if (!trace || strcmp(trace, "") == 0 || !ttool || strcmp(ttool, "") == 0 || !tspeed || strcmp(tspeed, "") == 0) {
2316  draw_ext_info_format(NDI_WHITE, 0, pl, MSG_TYPE_SKILL, MSG_TYPE_SKILL_FAILURE, "You can't %s anything here.", skill->slaying);
2317  LOG(llevError, "do_harvest: tool %s without harvest_[race|tool|speed]\n", pl->chosen_skill->name);
2318  return;
2319  }
2320 
2321  item = GET_MAP_OB(map, x, y);
2322  while (item && count < 10) {
2323  FOR_INV_PREPARE(item, inv) {
2324  if (object_get_value(inv, "harvestable") == NULL)
2325  continue;
2326  race = object_get_value(inv, "harvest_race");
2327  tool = object_get_value(inv, "harvest_tool");
2328  slevel = object_get_value(inv, "harvest_level");
2329  sexp = object_get_value(inv, "harvest_exp");
2330  if (race && (!slevel || !sexp)) {
2331  LOG(llevError, "do_harvest: item %s without harvest_[level|exp]\n", inv->name);
2332  continue;
2333  }
2334  if (race == trace && (!tool || tool == ttool))
2335  found[count++] = inv;
2336  } FOR_INV_FINISH();
2337  item = item->above;
2338  }
2339  if (count == 0) {
2340  draw_ext_info_format(NDI_WHITE, 0, pl, MSG_TYPE_SKILL, MSG_TYPE_SKILL_FAILURE, "You can't %s anything here.", skill->slaying);
2341  return;
2342  }
2343 
2344  inv = found[rndm(0, count-1)];
2345  assert(inv);
2346  item = inv->env;
2347  assert(item);
2348 
2349  slevel = object_get_value(inv, "harvest_level");
2350  sexp = object_get_value(inv, "harvest_exp");
2351  level = atoi(slevel);
2352  exp = atoi(sexp);
2353 
2354  speed = atof(tspeed);
2355  if (speed < 0)
2356  speed = -speed*pl->speed;
2357  pl->speed_left -= speed;
2358 
2359 
2360  /* Now we found something to harvest, randomly try to get it. */
2361  if (level > skill->level+10) {
2362  draw_ext_info_format(NDI_WHITE, 0, pl, MSG_TYPE_SKILL, MSG_TYPE_SKILL_FAILURE, "You fail to %s anything.", skill->slaying);
2363  return;
2364  }
2365 
2366  if (level >= skill->level)
2367  /* Up to 10 more levels, 1 to 11 percent probability. */
2368  proba = 10+skill->level-level;
2369  else if (skill->level <= level+10)
2370  proba = 10+(skill->level-level)*2;
2371  else
2372  proba = 30;
2373 
2374  if (proba <= random_roll(0, 100, pl, 1)) {
2375  draw_ext_info_format(NDI_WHITE, 0, pl, MSG_TYPE_SKILL, MSG_TYPE_SKILL_FAILURE, "You fail to %s anything.", skill->slaying);
2376  return;
2377  }
2378 
2379  /* Check the new item can fit into inventory.
2380  * Fixes bug #3060474: fishing puts more fishes into inventory than you can carry. */
2381  if (((uint32_t)(pl->weight + pl->carrying + inv->weight)) > get_weight_limit(pl->stats.Str)) {
2382  draw_ext_info_format(NDI_WHITE, 0, pl, MSG_TYPE_SKILL, MSG_TYPE_SKILL_FAILURE, "You are carrying too much to %s a %s.", skill->slaying, inv->name);
2383  return;
2384  }
2385 
2386  /* Ok, got it. */
2387  if (inv->nrof == 0) {
2388  harvested = object_new();
2389  object_copy_with_inv(inv, harvested);
2390  } else {
2391  if (count == 1 && inv->nrof == 1) {
2392  check_exhaust = 1;
2393  }
2394  harvested = object_split(inv, 1, NULL, 0);
2395  }
2396  object_set_value(harvested, "harvestable", NULL, 0);
2397  if (QUERY_FLAG(harvested, FLAG_MONSTER)) {
2398  int spot = object_find_free_spot(harvested, pl->map, pl->x, pl->y, 0, SIZEOFFREE);
2399  if (spot == -1) {
2400  /* Better luck next time...*/
2401  object_remove(harvested);
2402  draw_ext_info_format(NDI_WHITE, 0, pl, MSG_TYPE_SKILL, MSG_TYPE_SKILL_FAILURE, "You fail to %s anything.", skill->slaying);
2403  return;
2404  }
2405  object_insert_in_map_at(harvested, pl->map, NULL, 0, pl->x+freearr_x[spot], pl->y+freearr_y[spot]);
2406  draw_ext_info_format(NDI_WHITE, 0, pl, MSG_TYPE_SKILL, MSG_TYPE_SKILL_FAILURE, "You %s a %s!", skill->slaying, harvested->name);
2407  } else {
2408  harvested = object_insert_in_ob(harvested, pl);
2409  draw_ext_info_format(NDI_WHITE, 0, pl, MSG_TYPE_SKILL, MSG_TYPE_SKILL_FAILURE, "You %s some %s", skill->slaying, harvested->name);
2410  }
2411 
2412  /* Get exp */
2413  change_exp(pl, exp, skill->name, SK_EXP_ADD_SKILL);
2414 
2415  if (check_exhaust) {
2416  sstring replacement = object_get_value(item, "harvest_exhaust_replacement");
2417  if (replacement) {
2418  if (replacement[0] != '-') {
2419  archetype *other = find_archetype(replacement);
2420  if (other) {
2421  object *final = object_create_arch(other);
2422  object_insert_in_map_at(final, map, item, INS_BELOW_ORIGINATOR, item->x, item->y);
2423  }
2424  }
2425  object_remove(item);
2427  }
2428  }
2429 
2430  return;
2431 }
#define MSG_TYPE_COMMAND_MAPS
Definition: newclient.h:500
void draw_ext_info_format(int flags, int pri, const object *pl, uint8_t type, uint8_t subtype, const char *format,...)
Definition: main.c:316
uint8_t login_method
Definition: newserver.h:128
void command_petmode(object *op, const char *params)
Definition: c_misc.c:1419
char path[HUGE_BUF]
Definition: map.h:365
void command_save(object *op, const char *params)
Definition: c_misc.c:2124
void command_afk(object *op, const char *params)
Definition: c_misc.c:767
int8_t Int
Definition: living.h:36
#define NUM_BODY_LOCATIONS
Definition: object.h:13
Definition: player.h:92
archetype * find_archetype(const char *name)
Definition: arch.c:695
void command_malloc(object *op, const char *params)
Definition: c_misc.c:787
int8_t ac
Definition: living.h:38
void command_help(object *op, const char *params)
Definition: c_misc.c:1769
#define ST_GET_PARTY_PASSWORD
Definition: define.h:586
#define INS_BELOW_ORIGINATOR
Definition: object.h:572
void display_who_entry(object *op, player *pl, const char *format)
Definition: c_misc.c:635
void command_unarmed_skill(object *op, const char *params)
Definition: c_misc.c:1363
struct mapdef mapstruct
void command_who(object *op, const char *params)
Definition: c_misc.c:618
command_array_struct Commands[]
Definition: commands.c:36
void object_free(object *ob, int flags)
Definition: object.c:1336
const int WizCommandsSize
Definition: commands.c:268
Definition: player.h:39
void roll_again(object *op)
Definition: player.c:1115
int64_t level_exp(int level, double expmul)
Definition: living.c:1868
int check_name(player *me, const char *name)
Definition: login.c:163
void command_wizpass(object *op, const char *params)
Definition: c_misc.c:915
Definition: object.h:444
#define SET_FLAG(xyz, p)
Definition: define.h:223
void command_maps(object *op, const char *params)
Definition: c_misc.c:823
bool check_password(const char *typed, const char *crypted)
Definition: server.c:109
region * get_region_by_name(const char *region_name)
Definition: region.c:46
#define FABS(x)
Definition: define.h:22
uint32_t braced
Definition: player.h:124
#define MSG_TYPE_COMMAND_CONFIG
Definition: newclient.h:505
void player_get_title(const struct pl *pl, char *buf, size_t bufsize)
Definition: player.c:224
#define NDI_WHITE
Definition: newclient.h:222
EXTERN int num_animations
Definition: global.h:162
uint32_t name_changed
Definition: player.h:130
#define FLAG_USE_ARMOUR
Definition: define.h:296
void command_motd(object *op, const char *params)
Definition: c_misc.c:209
char who_wiz_format[MAX_BUF]
Definition: global.h:278
int region_is_child_of_region(const region *child, const region *r)
Definition: region.c:190
uint32_t map_size(mapstruct *m)
Definition: map.c:825
EXTERN objectlink * first_friendly_object
Definition: global.h:121
void object_copy_with_inv(const object *src_ob, object *dest_ob)
Definition: object.c:952
int16_t players
Definition: map.h:344
void command_dumpallobjects(object *op, const char *params)
Definition: c_misc.c:975
unapplymode
Definition: player.h:62
int login_order
Definition: c_misc.c:519
int save_player(object *op, int flag)
Definition: login.c:212
StringBuffer * stringbuffer_new(void)
Definition: stringbuffer.c:57
uint32_t in_memory
Definition: map.h:345
const char * playerdir
Definition: global.h:249
#define MAP_ENTER_X(m)
Definition: map.h:85
void free_string(sstring str)
Definition: shstr.c:280
signed long object_sum_weight(object *op)
Definition: object.c:338
void command_brace(object *op, const char *params)
Definition: c_misc.c:2197
#define HUGE_BUF
Definition: define.h:37
const char * object_get_value(const object *op, const char *const key)
Definition: object.c:4125
#define SND_MUTE
Definition: sounds.h:14
#define SS_DUMP_TOTALS
Definition: shstr.h:47
#define ST_CHANGE_PASSWORD_CONFIRM
Definition: define.h:589
#define MAP_HEIGHT(m)
Definition: map.h:80
void command_kill_pets(object *op, const char *params)
Definition: c_misc.c:2221
char new_password[16]
Definition: player.h:177
object clone
Definition: object.h:472
struct treasureliststruct * next
Definition: treasure.h:89
socket_struct socket
Definition: player.h:94
short freearr_x[SIZEOFFREE]
Definition: object.c:65
#define ST_CONFIRM_PASSWORD
Definition: define.h:585
int object_count_active(void)
Definition: object.c:1527
const char * slaying
Definition: object.h:319
region * get_region_by_map(mapstruct *m)
Definition: region.c:74
DIR * opendir(const char *)
Definition: win32.c:37
void command_dumpallmaps(object *op, const char *params)
Definition: c_misc.c:1036
void command_dumpmap(object *op, const char *params)
Definition: c_misc.c:1023
void dump_all_archetypes(void)
Definition: arch.c:245
uint8_t subtype
Definition: object.h:341
#define FLAG_USE_WEAPON
Definition: define.h:297
void command_resistances(object *op, const char *params)
Definition: c_misc.c:1576
int checkbanned(const char *login, const char *host)
Definition: ban.c:32
int64_t exp
Definition: living.h:47
struct obj * above
Definition: object.h:288
void object_dump_all(void)
Definition: object.c:468
double expmul
Definition: object.h:398
#define ST_CHANGE_PASSWORD_NEW
Definition: define.h:588
int language
Definition: player.h:201
#define FLAG_AFK
Definition: define.h:377
#define TRUE
Definition: compat.h:10
player * find_player(const char *plname)
Definition: player.c:55
LogLevel debug
Definition: global.h:243
body_locations_struct body_locations[NUM_BODY_LOCATIONS]
Definition: item.c:54
#define FALSE
Definition: compat.h:11
void remove_friendly_object(object *op)
Definition: friend.c:56
int16_t sp
Definition: living.h:42
uint32_t get_weight_limit(int stat)
Definition: living.c:2356
#define SS_DUMP_TABLE
Definition: shstr.h:46
#define MSG_TYPE_COMMAND_STATISTICS
Definition: newclient.h:504
Definition: win32.h:110
#define safe_strncpy
Definition: compat.h:23
uint32_t hidden
Definition: player.h:132
char * partyname
Definition: party.h:14
void pets_terminate_all(object *owner)
Definition: pets.c:225
#define ST_ROLL_STAT
Definition: define.h:580
struct obj object
void draw_ext_info(int flags, int pri, const object *pl, uint8_t type, uint8_t subtype, const char *message)
Definition: main.c:311
Definition: object.h:467
#define ST_PLAYING
Definition: define.h:578
void command_whereami(object *op, const char *params)
Definition: c_misc.c:811
char * host
Definition: newserver.h:100
const int CommunicationCommandSize
Definition: commands.c:201
void command_debug(object *op, const char *params)
Definition: c_misc.c:891
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 MAP_WHEN_RESET(m)
Definition: map.h:62
char namebuf[MAX_BUF]
Definition: c_misc.c:518
region * get_region_from_string(const char *name)
Definition: region.c:121
int nrofallocobjects
Definition: object.c:57
void command_dumpfriendlyobjects(object *op, const char *params)
Definition: c_misc.c:987
short freearr_y[SIZEOFFREE]
Definition: object.c:71
partylist * party
Definition: player.h:186
void hiscore_display(object *op, int max, const char *match)
Definition: hiscore.c:382
void get_name(object *op)
Definition: player.c:856
void current_region_info(object *op)
Definition: c_misc.c:402
object * ob
Definition: object.h:445
uint32_t ticks_played
Definition: player.h:203
#define MSG_TYPE_ADMIN_DM
Definition: newclient.h:475
int rndm(int min, int max)
Definition: utils.c:162
void command_printlos(object *op, const char *params)
Definition: c_misc.c:1048
#define NAMLEN(dirent)
Definition: global.h:218
const char * get_region_longname(const region *r)
Definition: region.c:217
void command_fix_me(object *op, const char *params)
Definition: c_misc.c:1197
int player_has_own_title(const struct pl *pl)
Definition: player.c:239
char * name
Definition: map.h:328
#define MAP_IN_MEMORY
Definition: map.h:130
struct obj * chosen_skill
Definition: object.h:389
int object_set_value(object *op, const char *key, const char *value, int add_key)
Definition: object.c:4248
void object_free_drop_inventory(object *ob)
Definition: object.c:1316
int16_t y
Definition: object.h:327
object * object_insert_in_map_at(object *op, mapstruct *m, object *originator, int flag, int x, int y)
Definition: object.c:1838
#define NDI_RED
Definition: newclient.h:224
int16_t maxhp
Definition: living.h:41
char * name
Definition: map.h:278
#define FREE_OBJ_FREE_INVENTORY
Definition: object.h:532
#define MSG_TYPE_COMMAND
Definition: newclient.h:379
uint32_t sound
Definition: newserver.h:111
Definition: win32.h:120
struct artifactliststruct * next
Definition: artifact.h:29
object * object_new(void)
Definition: object.c:1011
const char * name_pl
Definition: object.h:315
usekeytype
Definition: player.h:52
void stringbuffer_append_string(StringBuffer *sb, const char *str)
Definition: stringbuffer.c:95
void player_set_own_title(struct pl *pl, const char *title)
Definition: player.c:264
object * object_insert_in_ob(object *op, object *where)
Definition: object.c:2591
void send_query(socket_struct *ns, uint8_t flags, const char *text)
Definition: request.c:677
void command_players(object *op, const char *params)
Definition: c_misc.c:1210
float speed_left
Definition: object.h:330
unapplymode unapply
Definition: player.h:108
#define MSG_TYPE_COMMAND_ERROR
Definition: newclient.h:509
void command_wizcast(object *op, const char *params)
Definition: c_misc.c:945
signed short int16_t
Definition: win32.h:160
void command_passwd(object *pl, const char *params)
Definition: c_misc.c:2261
enum _petmode petmode_t
int32_t weight
Definition: object.h:367
static bool IS_PLAYER(object *op)
Definition: object.h:596
int8_t Wis
Definition: living.h:36
#define ST_CONFIRM_QUIT
Definition: define.h:582
void get_password(object *op)
Definition: player.c:868
struct mapdef * map
Definition: object.h:297
int is_dragon_pl(const object *op)
Definition: player.c:114
struct regiondef * next
Definition: map.h:277
void receive_player_password(object *op)
Definition: c_misc.c:1981
Definition: map.h:276
#define snprintf
Definition: win32.h:46
void player_set_state(player *pl, uint8_t state)
Definition: player.c:4532
#define MAP_TIMEOUT(m)
Definition: map.h:66
void dump_all_maps(void)
Definition: map.c:278
#define FOR_INV_FINISH()
Definition: define.h:714
char * msg
Definition: map.h:361
#define FMT64
Definition: compat.h:12
type_definition ** types
int16_t dam
Definition: living.h:46
void command_rules(object *op, const char *params)
Definition: c_misc.c:221
void command_applymode(object *op, const char *params)
Definition: c_misc.c:1259
int object_count_free(void)
Definition: object.c:1495
void do_harvest(object *pl, int dir, object *skill)
Definition: c_misc.c:2284
int32_t carrying
Definition: object.h:369
const char * name
Definition: object.h:311
living orig_stats
Definition: player.h:148
long seconds(void)
Definition: time.c:344
struct obj * env
Definition: object.h:293
void command_mapinfo(object *op, const char *params)
Definition: c_misc.c:799
#define ATNR_INTERNAL
Definition: attack.h:72
struct archt * more
Definition: object.h:471
static void show_commands(object *op, int what)
Definition: c_misc.c:1682
uint8_t state
Definition: player.h:118
#define CS_QUERY_SINGLECHAR
Definition: newclient.h:67
#define MSG_TYPE_COMMAND_WHO
Definition: newclient.h:499
uint32_t counter
Definition: map.h:294
uint32_t nrof
Definition: object.h:334
#define MAP_ENTER_Y(m)
Definition: map.h:87
uint8_t listening
Definition: player.h:120
int8_t Cha
Definition: living.h:36
EXTERN const char *const change_resist_msg[NROFATTACKS]
Definition: attack.h:135
#define SIZEOFFREE
Definition: define.h:154
#define P_OUT_OF_MAP
Definition: map.h:251
EXTERN Animations * animations
Definition: global.h:161
struct pl * contr
Definition: object.h:276
char * ss_dump_table(int what, char *buf, size_t size)
Definition: shstr.c:354
#define MSG_TYPE_SKILL_FAILURE
Definition: newclient.h:585
void command_hiscore(object *op, const char *params)
Definition: c_misc.c:879
EXTERN treasurelist * first_treasurelist
Definition: global.h:118
void time_info(object *op)
Definition: time.c:294
char d_name[_MAX_FNAME+1]
Definition: win32.h:114
void command_listen(object *op, const char *params)
Definition: c_misc.c:1075
float speed
Definition: object.h:329
unsigned __int64 uint64_t
Definition: win32.h:167
struct regiondef * parent
Definition: map.h:286
void command_whereabouts(object *op, const char *params)
Definition: c_misc.c:479
#define QUERY_FLAG(xyz, p)
Definition: define.h:225
#define MSG_TYPE_ADMIN_VERSION
Definition: newclient.h:479
#define CLEAR_FLAG(xyz, p)
Definition: define.h:224
EXTERN artifactlist * first_artifactlist
Definition: global.h:119
uint32_t is_bot
Definition: newserver.h:107
EXTERN const char *const attacktype_desc[NROFATTACKS]
Definition: attack.h:138
#define FLAG_WIZ
Definition: define.h:231
void change_exp(object *op, int64_t exp, const char *skill_name, int flag)
Definition: living.c:2162
void command_language(object *op, const char *params)
Definition: c_misc.c:125
void command_news(object *op, const char *params)
Definition: c_misc.c:233
void dump_map(const mapstruct *m)
Definition: map.c:255
#define MAX_BUF
Definition: define.h:35
command_array_struct WizCommands[]
Definition: commands.c:204
void command_body(object *op, const char *params)
Definition: c_misc.c:168
LogLevel
Definition: logger.h:10
object * object_create_arch(archetype *at)
Definition: arch.c:736
char who_format[MAX_BUF]
Definition: global.h:277
#define MSG_TYPE_ADMIN
Definition: newclient.h:377
uint32_t peaceful
Definition: player.h:131
enum _bowtype bowtype_t
int16_t x
Definition: object.h:327
void command_wimpy(object *op, const char *params)
Definition: c_misc.c:2166
int nroffreeobjects
Definition: object.c:56
const char * skill
Definition: object.h:321
int8_t wc
Definition: living.h:37
unsigned short uint16_t
Definition: win32.h:163
void command_sound(object *op, const char *params)
Definition: c_misc.c:1941
void command_delete(object *op, const char *params)
Definition: c_misc.c:1921
uint16_t difficulty
Definition: map.h:343
int8_t Str
Definition: living.h:36
int16_t resist[NROFATTACKS]
Definition: object.h:343
object * ob
Definition: player.h:158
EXTERN long nrofartifacts
Definition: global.h:144
const char * sstring
Definition: global.h:40
unsigned int uint32_t
Definition: win32.h:162
const char * datadir
Definition: global.h:247
EXTERN long nrofallowedstr
Definition: global.h:145
void command_showpets(object *op, const char *params)
Definition: c_misc.c:1463
void set_map_reset_time(mapstruct *map)
Definition: map.c:2241
bowtype_t bowtype
Definition: player.h:101
void command_ssdumptable(object *op, const char *params)
Definition: c_misc.c:1011
int8_t body_info[NUM_BODY_LOCATIONS]
Definition: object.h:375
object * object_split(object *orig_ob, uint32_t nr, char *err, size_t size)
Definition: object.c:2371
void print_los(object *op)
Definition: los.c:606
Definition: map.h:258
#define FREE_AND_COPY(sv, nv)
Definition: global.h:210
#define MSG_TYPE_COMMAND_MALLOC
Definition: newclient.h:502
static void malloc_info(object *op)
Definition: c_misc.c:243
void command_time(object *op, const char *params)
Definition: c_misc.c:855
const int CommandsSize
Definition: commands.c:128
const char * localdir
Definition: global.h:248
char password[16]
Definition: player.h:176
tag_t count
Definition: object.h:299
living stats
Definition: object.h:370
#define FLAG_WIZCAST
Definition: define.h:290
#define MSG_TYPE_LAST
Definition: newclient.h:396
int8_t Dex
Definition: living.h:36
void command_statistics(object *pl, const char *params)
Definition: c_misc.c:1106
struct archt * arch
Definition: object.h:415
sstring i18n_get_language_code(int language)
Definition: languages.c:122
struct oblnk * next
Definition: object.h:446
#define MAP_WIDTH(m)
Definition: map.h:78
void command_title(object *op, const char *params)
Definition: c_misc.c:2073
void check_login(object *op, int check_pass)
Definition: login.c:501
void command_strings(object *op, const char *params)
Definition: c_misc.c:835
struct Settings settings
Definition: init.c:39
void arch_info(object *op)
Definition: arch.c:199
#define SK_EXP_ADD_SKILL
Definition: skills.h:78
#define MSG_TYPE_COMMAND_INFO
Definition: newclient.h:506
struct archt * next
Definition: object.h:469
#define NROFATTACKS
Definition: attack.h:17
struct dirent * readdir(DIR *)
Definition: win32.c:75
void command_peaceful(object *op, const char *params)
Definition: c_misc.c:2149
uint32_t max_time
Definition: time.c:35
command_array_struct CommunicationCommands[]
Definition: commands.c:131
#define ST_CHANGE_PASSWORD_OLD
Definition: define.h:587
void ss_dump_statistics(char *buf, size_t size)
Definition: shstr.c:323
static void help_topics(object *op, int what)
Definition: c_misc.c:1621
int object_count_used(void)
Definition: object.c:1511
void send_news(const object *op)
Definition: player.c:202
#define MSG_TYPE_COMMAND_BODY
Definition: newclient.h:501
void send_rules(const object *op)
Definition: player.c:166
sstring add_string(const char *str)
Definition: shstr.c:124
const char * get_name_of_region_for_map(const mapstruct *m)
Definition: region.c:92
EXTERN player * first_player
Definition: global.h:115
void get_who_escape_code_value(char *return_val, int size, const char letter, player *pl)
Definition: c_misc.c:691
void stringbuffer_append_printf(StringBuffer *sb, const char *format,...)
Definition: stringbuffer.c:104
struct pl * next
Definition: player.h:93
#define GET_MAP_OB(M, X, Y)
Definition: map.h:172
int strcasecmp(const char *s1, const char *s2)
Definition: porting.c:256
int i18n_find_language_by_code(const char *code)
Definition: languages.c:95
#define FLAG_MONSTER
Definition: define.h:245
#define MSG_TYPE_SKILL
Definition: newclient.h:383
int8_t Pow
Definition: living.h:36
int closedir(DIR *)
Definition: win32.c:108
char * strdup(const char *str)
Definition: porting.c:200
int get_map_flags(mapstruct *oldmap, mapstruct **newmap, int16_t x, int16_t y, int16_t *nx, int16_t *ny)
Definition: map.c:310
size_t split_string(char *str, char *array[], size_t array_size, char sep)
Definition: utils.c:500
uint8_t set_title
Definition: global.h:266
petmode_t petmode
Definition: player.h:102
#define NDI_UNIQUE
Definition: newclient.h:245
#define S_ISDIR(x)
Definition: win32.h:69
#define MSG_SUBTYPE_NONE
Definition: newclient.h:398
usekeytype usekeys
Definition: player.h:107
Definition: player.h:46
void LOG(LogLevel logLevel, const char *format,...)
Definition: logger.c:51
#define CS_QUERY_HIDEINPUT
Definition: newclient.h:68
void receive_player_name(object *op)
Definition: c_misc.c:1963
#define FLAG_WAS_WIZ
Definition: define.h:234
EXTERN region * first_region
Definition: global.h:117
void command_archs(object *op, const char *params)
Definition: c_misc.c:867
#define MAX_NAME
Definition: define.h:41
uint8_t run_away
Definition: object.h:387
#define FULL_VERSION
Definition: version.h:6
struct mapdef * next
Definition: map.h:326
int object_find_free_spot(const object *ob, mapstruct *m, int x, int y, int start, int stop)
Definition: object.c:3280
void command_dumpallarchetypes(object *op, const char *params)
Definition: c_misc.c:999
void map_info(object *op, const char *search)
Definition: c_misc.c:45
void dump_friendly_objects(void)
Definition: friend.c:100
void command_quit(object *op, const char *params)
Definition: c_misc.c:1905
Definition: map.h:325
int random_roll(int min, int max, const object *op, int goodbad)
Definition: utils.c:42
char write_buf[MAX_BUF]
Definition: player.h:174
void command_usekeys(object *op, const char *params)
Definition: c_misc.c:1535
void command_bowmode(object *op, const char *params)
Definition: c_misc.c:1300
object * object_find_by_type_and_arch_name(const object *who, int type, const char *name)
Definition: object.c:4056
int onoff_value(const char *line)
Definition: c_misc.c:1871
#define FLAG_WIZPASS
Definition: define.h:315
const char * unarmed_skill
Definition: player.h:202
#define S_ISREG(x)
Definition: win32.h:70
int16_t level
Definition: object.h:353
char const * newhash(char const *password)
void fix_object(object *op)
Definition: living.c:1120
const char * i18n(const object *who, const char *code)
Definition: languages.c:69
float weapon_speed
Definition: object.h:331
void list_players(object *op, region *reg, partylist *party)
Definition: c_misc.c:545
EXTERN mapstruct * first_map
Definition: global.h:116
EXTERN archetype * first_archetype
Definition: global.h:120
object * find_skill_by_name(object *who, const char *name)
Definition: skill_util.c:192
char * longname
Definition: map.h:291
void command_version(object *op, const char *params)
Definition: c_misc.c:1062
object * object_get_owner(object *op)
Definition: object.c:568
const char * name
Definition: object.h:468
char * stringbuffer_finish(StringBuffer *sb)
Definition: stringbuffer.c:76
static int find_help_file(const char *name, const char *language, int wiz, char *path, int length)
Definition: c_misc.c:1729
#define P_NO_CLERIC
Definition: map.h:238
size_t strlcpy(char *dst, const char *src, size_t size)
Definition: porting.c:366
#define FOR_INV_PREPARE(op_, it_)
Definition: define.h:707
void object_remove(object *op)
Definition: object.c:1577
const char * get_region_msg(const region *r)
Definition: region.c:238
void i18n_list_languages(object *who)
Definition: languages.c:132
int8_t body_used[NUM_BODY_LOCATIONS]
Definition: object.h:376
int atnr_is_dragon_enabled(int attacknr)
Definition: player.c:95
Definition: object.h:224
void current_map_info(object *op)
Definition: c_misc.c:424
static int name_cmp(const chars_names *c1, const chars_names *c2)
Definition: c_misc.c:531
void display_motd(const object *op)
Definition: player.c:135
EXTERN long nroftreasures
Definition: global.h:143