Crossfire Server, Trunk
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 <stdlib.h>
26 #include <string.h>
27 #include <sys/stat.h>
28 
29 #undef SS_STATISTICS
30 #include "loader.h"
31 #include "shstr.h"
32 #include "sounds.h"
33 #include "sproto.h"
34 #include "version.h"
35 
36 #include "assets.h"
37 
38 /* Static declarations where needed (when ordering would be an issue) */
39 static void display_who_entry(object *op, player *pl, const char *format);
40 static void get_who_escape_code_value(char *return_val, int size, const char letter, player *pl);
41 static int onoff_value(const char *line);
42 
51 static void map_info(object *op, const char *search) {
52  if ( *search != 0 ) {
54  "Maps matching search: '%s'", search);
55  }
56  if (QUERY_FLAG(op, FLAG_WIZ)) {
58  "[fixed]Path Reset In (HH:MM:SS) Pl IM TO");
59  } else {
61  "[fixed]Path Reset In (HH:MM)");
62  }
63 
64  /* Allow a comma-separate list of search strings; more complicated because of the const */
65  char *to_be_freed = NULL;
66  char *search_array[64];
67  int search_array_count = 0;
68  if ( search[0] ) {
69  to_be_freed = strdup(search);
70  if ( !to_be_freed ) {
71  search_array[0] = to_be_freed;
72  search_array_count = 1;
73  } else {
74  search_array_count = split_string(to_be_freed,search_array,64,',');
75  }
76  }
77 
78  for (mapstruct *m = first_map; m != NULL; m = m->next) {
79  bool match = TRUE;
80  if ( search_array_count ) {
81  match = FALSE;
82  for (int i=0; i<search_array_count; ++i) {
83  if ( strstr(m->path,search_array[i]) ) {
84  match=TRUE;
85  break;
86  }
87  }
88  }
89  if ( !match ) continue; /* Skip unwanted maps */
90 
91  /* Print out the last 26 characters of the map name... */
92  char map_path[MAX_BUF];
93  if (strlen(m->path) <= 26) {
94  strcpy(map_path, m->path);
95  } else {
96  safe_strncpy(map_path, m->path + strlen(m->path) - 26, sizeof(map_path));
97  }
98 
99  uint32_t ttr = MAP_WHEN_RESET(m) - seconds() > 0 ? MAP_WHEN_RESET(m) - seconds() : 0;
100  if ( !m->reset_timeout && !m->unique ) set_map_reset_time(m);
101  if (m->players) {
102  ttr = (m->unique ? 0 : m->reset_timeout) + 300;
103  }
104  else if (m->timeout) {
105  ttr = (m->unique ? 0 : m->reset_timeout) + m->timeout;
106  }
107  const uint32_t hh = ttr/3600, mm = (ttr%3600)/60, ss = ttr%60;
108  if (QUERY_FLAG(op, FLAG_WIZ)) {
111  "[fixed]%-26.26s %2d:%02d:%02d %2d %2d %4d",
112  map_path, hh, mm, ss, m->players, m->in_memory, m->timeout);
113  } else {
116  "[fixed]%-26.26s %2d:%02d%s", map_path, hh, mm,
117  m->players ? " (in use)" : "");
118  }
119  }
120  if ( to_be_freed ) free( to_be_freed );
121 }
122 
131 void command_language(object *op, const char *params) {
132  int language = -1;
133 
134  if (!op->contr)
135  return;
136 
137  if (*params == '\0' || (!strcmp(params, ""))) {
139  "Your current language is set to: English.");
141  "Available languages:");
143  return;
144  }
145 
147 
148  /* Error out if unknown language. */
149  if (language == -1) {
151  "Unknown language.");
152  return;
153  }
154 
155  op->contr->language = language;
156 
158  "Your current language is set to English.");
159 }
160 
174 void command_body(object *op, const char *params) {
175  int i;
176  (void)params;
177 
178  /* Too hard to try and make a header that lines everything up, so just
179  * give a description.
180  */
182  "The first column is the name of the body location.");
183 
185  "The second column is how many of those locations your body has.");
186 
188  "The third column is how many slots in that location are available.");
189 
190  for (i = 0; i < NUM_BODY_LOCATIONS; i++) {
191  /* really debugging - normally body_used should not be set to anything
192  * if body_info isn't also set.
193  */
194  if (op->body_info[i] || op->body_used[i]) {
196  "[fixed]%-30s %5d %5d",
197  i18n(op, body_locations[i].use_name), op->body_info[i], op->body_used[i]);
198  }
199  }
202  "You are not allowed to wear armor.");
205  "You are not allowed to use weapons.");
206 }
207 
216 void command_motd(object *op, const char *params) {
217  (void)params;
218  display_motd(op);
219 }
220 
229 void command_rules(object *op, const char *params) {
230  (void)params;
231  send_rules(op);
232 }
233 
242 void command_news(object *op, const char *params) {
243  (void)params;
244  send_news(op);
245 }
246 
253 static void malloc_info(object *op) {
254  int ob_used = object_count_used(), ob_free = object_count_free(), players, nrofmaps;
255  int nrm = 0, mapmem = 0, anr, anims, sum_alloc = 0, sum_used = 0, i, alnr;
256  player *pl;
257  mapstruct *m;
258  artifactlist *al;
259 
260  for (al = first_artifactlist, alnr = 0; al != NULL; al = al->next, alnr++)
261  ;
262 
264 
266 
267  for (pl = first_player, players = 0; pl != NULL; pl = pl->next, players++)
268  ;
269 
270  for (m = first_map, nrofmaps = 0; m != NULL; m = m->next, nrofmaps++)
271  if (m->in_memory == MAP_IN_MEMORY) {
272  mapmem += map_size(m) * (sizeof(object *) + sizeof(MapSpace));
273  nrm++;
274  }
275 
277  "Sizeof: object=%d player=%d map=%d",
278  sizeof(object), sizeof(player), sizeof(mapstruct));
279 
281  "[fixed]Objects:");
282 
284  "[fixed]%6d used", ob_used);
285 
286  if (ob_used != nrofallocobjects - nroffreeobjects) {
288  "[fixed] (used list mismatch: %d)",
290  }
291 
293  "[fixed]%6d free (%.2f%% of %d allocated)",
294  ob_free, (float)ob_free / nrofallocobjects * 100, nrofallocobjects);
295 
296  if (ob_free != nroffreeobjects) {
298  "[fixed] (free list mismatch: %d)",
300  }
301 
303  "[fixed]%6d on active list",
305 
306  i = (ob_used*sizeof(object));
307  sum_used += i;
308  sum_alloc += i;
309 
311  "[fixed] object total: %11d", i);
312 
313  i = (ob_free*sizeof(object));
314  sum_alloc += i;
315 
317  "[fixed]%4d players: %8d",
318  players, i = (players*sizeof(player)));
319 
320  sum_alloc += i;
321  sum_used += i;
322 
324  "[fixed]%4d maps allocated: %8d",
325  nrofmaps, i = (nrofmaps*sizeof(mapstruct)));
326 
327  sum_alloc += i;
328  sum_used += nrm*sizeof(mapstruct);
329 
331  "[fixed]%4d maps in memory: %8d",
332  nrm, mapmem);
333 
334  sum_alloc += mapmem;
335  sum_used += mapmem;
336 
338  "[fixed]%4d archetypes: %8d",
339  anr, i = (anr*sizeof(archetype)));
340 
341  sum_alloc += i;
342  sum_used += i;
343 
345  "[fixed]%4d animations: %8d",
346  anims, i = (anims*sizeof(uint16_t)));
347 
348  sum_alloc += i;
349  sum_used += i;
350 
352  "[fixed]%4d treasurelists %8d",
354 
355  sum_alloc += i;
356  sum_used += i;
357 
359  "[fixed]%4ld treasures %8d",
361 
362  sum_alloc += i;
363  sum_used += i;
364 
366  "[fixed]%4ld artifacts %8d",
367  nrofartifacts, i = (nrofartifacts*sizeof(artifact)));
368 
369  sum_alloc += i;
370  sum_used += i;
371 
373  "[fixed]%4ld artifacts strngs %8d",
374  nrofallowedstr, i = (nrofallowedstr*sizeof(linked_char)));
375 
376  sum_alloc += i;
377  sum_used += i;
378 
380  "[fixed]%4d artifactlists %8d",
381  alnr, i = (alnr*sizeof(artifactlist)));
382 
383  sum_alloc += i;
384  sum_used += i;
385 
387  "[fixed]Total space allocated:%8d",
388  sum_alloc);
389 
391  "[fixed]Total space used: %8d",
392  sum_used);
393 }
394 
406 static void current_region_info(object *op) {
407  /*
408  * Ok I /suppose/ I should write a seperate function for this, but it isn't
409  * going to be /that/ slow, and won't get called much
410  */
412 
413  /* This should only be possible if regions are not operating on this server. */
414  if (!r)
415  return;
416 
418  "You are in %s.\n%s",
420 }
421 
428 static void current_map_info(object *op) {
429  mapstruct *m = op->map;
430 
431  if (!m)
432  return;
433 
435  "%s (%s) in %s",
436  m->name, m->path, get_region_longname(get_region_by_map(m)));
437 
438  if (QUERY_FLAG(op, FLAG_WIZ)) {
440  "players:%d difficulty:%d size:%dx%d start:%dx%d timeout %d",
441  m->players, m->difficulty,
442  MAP_WIDTH(m), MAP_HEIGHT(m),
444  MAP_TIMEOUT(m));
445  }
446  if (m->msg)
448 }
449 
450 #ifdef DEBUG_MALLOC_LEVEL
451 
459 void command_malloc_verify(object *op, char *parms) {
460  extern int malloc_verify(void);
461 
462  if (!malloc_verify())
464  "Heap is corrupted.");
465  else
467  "Heap checks out OK.");
468 
469  return 1;
470 }
471 #endif
472 
483 void command_whereabouts(object *op, const char *params) {
484  region *reg;
485  player *pl;
486  (void)params;
487 
488  /*
489  * reset the counter on the region, then use it to store the number of
490  * players there.
491  * I don't know how thread-safe this would be, I suspect not very....
492  */
493  for (reg = first_region; reg != NULL; reg = reg->next) {
494  reg->counter = 0;
495  }
496  for (pl = first_player; pl != NULL; pl = pl->next)
497  if (pl->ob->map != NULL)
499 
500  /* we only want to print out by places with a 'longname' field...*/
501  for (reg = first_region; reg != NULL; reg = reg->next) {
502  if (reg->longname == NULL && reg->counter > 0) {
503  if (reg->parent != NULL) {
504  reg->parent->counter += reg->counter;
505  reg->counter = 0;
506  } else /*uh oh, we shouldn't be here. */
507  LOG(llevError, "command_whereabouts() Region %s with no longname has no parent\n", reg->name);
508  }
509  }
511  "In the world currently there are:");
512 
513  for (reg = first_region; reg != NULL; reg = reg->next)
514  if (reg->counter > 0) {
516  "%u players in %s",
517  reg->counter, get_region_longname(reg));
518  }
519 }
520 
522 typedef struct {
523  char namebuf[MAX_BUF];
525 } chars_names;
526 
536 static int name_cmp(const chars_names *c1, const chars_names *c2) {
537  return strcasecmp(c1->namebuf, c2->namebuf);
538 }
539 
550 void list_players(object *op, region *reg, partylist *party) {
551  player *pl;
552  uint16_t i;
553  char *format;
554  int num_players = 0, num_wiz = 0, num_afk = 0, num_bot = 0;
555  chars_names *chars = NULL;
556 
557  if (op == NULL || QUERY_FLAG(op, FLAG_WIZ))
558  format = settings.who_wiz_format;
559  else
560  format = settings.who_format;
561 
562  for (pl = first_player; pl != NULL; pl = pl->next) {
563  if (pl->ob->map == NULL)
564  continue;
565  if (pl->hidden && !QUERY_FLAG(op, FLAG_WIZ))
566  continue;
567 
568  if (reg && !region_is_child_of_region(get_region_by_map(pl->ob->map), reg))
569  continue;
570  if (party && pl->party != party)
571  continue;
572 
573  if (pl->state == ST_PLAYING || pl->state == ST_GET_PARTY_PASSWORD) {
574  num_players++;
575  chars = (chars_names *)realloc(chars, num_players*sizeof(chars_names));
576  if (chars == NULL) {
578  "who failed - out of memory!");
579  return;
580  }
581  sprintf(chars[num_players-1].namebuf, "%s", pl->ob->name);
582  chars[num_players-1].login_order = num_players;
583 
584  /* Check for WIZ's & AFK's*/
585  if (QUERY_FLAG(pl->ob, FLAG_WIZ))
586  num_wiz++;
587 
588  if (QUERY_FLAG(pl->ob, FLAG_AFK))
589  num_afk++;
590 
591  if (pl->socket.is_bot)
592  num_bot++;
593  }
594  }
595  if (first_player != (player *)NULL) {
596  if (reg == NULL && party == NULL)
598  "Total Players (%d) -- WIZ(%d) AFK(%d) BOT(%d)",
599  num_players, num_wiz, num_afk, num_bot);
600  else if (party == NULL)
602  "Total Players in %s (%d) -- WIZ(%d) AFK(%d) BOT(%d)",
603  reg->longname ? reg->longname : reg->name, num_players, num_wiz, num_afk, num_bot);
604  else
606  "Total Players in party %s (%d) -- WIZ(%d) AFK(%d) BOT(%d)",
607  party->partyname, num_players, num_wiz, num_afk, num_bot);
608  }
609  qsort(chars, num_players, sizeof(chars_names), (int (*)(const void *, const void *))name_cmp);
610  for (i = 0; i < num_players; i++)
611  display_who_entry(op, find_player(chars[i].namebuf), format);
612  free(chars);
613 }
614 
623 void command_who(object *op, const char *params) {
624  region *reg;
625 
627  list_players(op, reg, NULL);
628 }
629 
640 static void display_who_entry(object *op, player *pl, const char *format) {
641  char tmpbuf[MAX_BUF];
642  char outbuf[MAX_BUF];
643  size_t i;
644 
645  strcpy(outbuf, "[fixed]");
646 
647  if (pl == NULL) {
648  LOG(llevError, "display_who_entry(): I was passed a null player\n");
649  return;
650  }
651  for (i = 0; i <= strlen(format); i++) {
652  if (format[i] == '%') {
653  i++;
654  get_who_escape_code_value(tmpbuf, sizeof(tmpbuf), format[i], pl);
655  strcat(outbuf, tmpbuf);
656  } else if (format[i] == '_') {
657  strcat(outbuf, " "); /* allow '_' to be used in place of spaces */
658  } else {
659  snprintf(tmpbuf, sizeof(tmpbuf), "%c", format[i]);
660  strcat(outbuf, tmpbuf);
661  }
662  }
664 }
665 
696 static void get_who_escape_code_value(char *return_val, int size, const char letter, player *pl) {
697  switch (letter) {
698  case 'N':
699  strlcpy(return_val, pl->ob->name, size);
700  break;
701 
702  case 't':
703  player_get_title(pl, return_val, size);
704  break;
705 
706  case 'c':
707  snprintf(return_val, size, "%u", pl->ob->count);
708  break;
709 
710  case 'n':
711  snprintf(return_val, size, "\n");
712  break;
713 
714  case 'h':
715  strlcpy(return_val, pl->peaceful ? "" : " <Hostile>", size);
716  break;
717 
718  case 'l':
719  snprintf(return_val, size, "%d", pl->ob->level);
720  break;
721 
722  case 'd':
723  strlcpy(return_val, (QUERY_FLAG(pl->ob, FLAG_WIZ) ? " <WIZ>" : ""), size);
724  break;
725 
726  case 'a':
727  strlcpy(return_val, (QUERY_FLAG(pl->ob, FLAG_AFK) ? " <AFK>" : ""), size);
728  break;
729 
730  case 'b':
731  strlcpy(return_val, (pl->socket.is_bot == 1) ? " <BOT>" : "", size);
732  break;
733 
734  case 'm':
735  strlcpy(return_val, pl->ob->map->path, size);
736  break;
737 
738  case 'M':
739  strlcpy(return_val, pl->ob->map->name ? pl->ob->map->name : "Untitled", size);
740  break;
741 
742  case 'r':
743  strlcpy(return_val, get_name_of_region_for_map(pl->ob->map), size);
744  break;
745 
746  case 'R':
747  strlcpy(return_val, get_region_longname(get_region_by_map(pl->ob->map)), size);
748  break;
749 
750  case 'i':
751  strlcpy(return_val, pl->socket.host, size);
752  break;
753 
754  case '%':
755  snprintf(return_val, size, "%%");
756  break;
757 
758  case '_':
759  snprintf(return_val, size, "_");
760  break;
761  }
762 }
763 
772 void command_afk(object *op, const char *params) {
773  (void)params;
774  if (QUERY_FLAG(op, FLAG_AFK)) {
777  "You are no longer AFK");
778  } else {
779  SET_FLAG(op, FLAG_AFK);
781  "You are now AFK");
782  }
783 }
784 
793 void command_malloc(object *op, const char *params) {
794  (void)params;
795  malloc_info(op);
796 }
797 
806 void command_mapinfo(object *op, const char *params) {
807  (void)params;
809 }
810 
819 void command_whereami(object *op, const char *params) {
820  (void)params;
822 }
823 
832 void command_maps(object *op, const char *params) {
833  map_info(op, params);
834 }
835 
844 void command_strings(object *op, const char *params) {
845  char stats[HUGE_BUF];
846  (void)params;
847 
848  ss_dump_statistics(stats, sizeof(stats));
850  "[fixed]%s\n",
851  stats);
852 
854  ss_dump_table(SS_DUMP_TOTALS, stats, sizeof(stats)));
855 }
856 
865 void command_time(object *op, const char *params) {
866  (void)params;
867  time_info(op);
868 }
869 
878 void command_hiscore(object *op, const char *params) {
879  hiscore_display(op, op == NULL ? 9999 : 50, params);
880 }
881 
890 void command_debug(object *op, const char *params) {
891  int i;
892 
893  if (*params == '\0' || !sscanf(params, "%d", &i)) {
895  "Global debug level is %d.",
896  settings.debug);
897  return;
898  }
899  settings.debug = (enum LogLevel)FABS(i);
901  "Debug level set to %d.",
902  i);
903 }
904 
905 
914 void command_wizpass(object *op, const char *params) {
915  int i;
916 
917  if (!op)
918  return;
919 
920  if (*params == '\0')
921  i = (QUERY_FLAG(op, FLAG_WIZPASS)) ? 0 : 1;
922  else
923  i = onoff_value(params);
924 
925  if (i) {
927  "You will now walk through walls.");
929  } else {
931  "You will now be stopped by walls.");
933  }
934 }
935 
944 void command_wizcast(object *op, const char *params) {
945  int i;
946 
947  if (!op)
948  return;
949 
950  if (*params == '\0')
951  i = (QUERY_FLAG(op, FLAG_WIZCAST)) ? 0 : 1;
952  else
953  i = onoff_value(params);
954 
955  if (i) {
957  "You can now cast spells anywhere.");
959  } else {
961  "You now cannot cast spells in no-magic areas.");
963  }
964 }
965 
974 void command_dumpallobjects(object *op, const char *params) {
975  (void)op;
976  (void)params;
977  object_dump_all();
978 }
979 
988 void command_dumpfriendlyobjects(object *op, const char *params) {
989  (void)op;
990  (void)params;
992 }
993 
1002 void command_dumpallarchetypes(object *op, const char *params) {
1003  (void)op;
1004  (void)params;
1006 }
1007 
1016 void command_ssdumptable(object *op, const char *params) {
1017  (void)op;
1018  (void)params;
1019  ss_dump_table(SS_DUMP_TABLE, NULL, 0);
1020 }
1021 
1030 void command_dumpmap(object *op, const char *params) {
1031  (void)params;
1032  if (op)
1033  dump_map(op->map);
1034 }
1035 
1044 void command_dumpallmaps(object *op, const char *params) {
1045  (void)op;
1046  (void)params;
1047  dump_all_maps();
1048 }
1049 
1058 void command_printlos(object *op, const char *params) {
1059  (void)params;
1060  if (op)
1061  print_los(op);
1062 }
1063 
1064 
1073 void command_version(object *op, const char *params) {
1074  (void)params;
1076  MSG_TYPE_ADMIN_VERSION, "Crossfire "FULL_VERSION);
1077 }
1078 
1087 void command_listen(object *op, const char *params) {
1088  int i;
1089 
1090  if (*params == '\0' || !sscanf(params, "%d", &i)) {
1092  "Set listen to what (presently %d)?",
1093  op->contr->listening);
1094  return;
1095  }
1096  if (i < 0) {
1098  "Verbose level should be positive.");
1099  return;
1100  }
1101  op->contr->listening = (char)i;
1103  "Your verbose level is now %d.",
1104  i);
1105 }
1106 
1118 void command_statistics(object *pl, const char *params) {
1119  char buf[MAX_BUF];
1120  uint32_t hours, minutes;
1121  uint64_t seconds; /* 64 bit to prevent overflows an intermediate results */
1122  (void)params;
1123 
1124  if (!pl->contr)
1125  return;
1126  safe_strncpy(buf, i18n(pl, "[fixed] Experience: %"), sizeof(buf));
1127  strcat(buf, FMT64);
1129  buf,
1130  pl->stats.exp);
1131  safe_strncpy(buf, i18n(pl, "[fixed] Next Level: %"), sizeof(buf));
1132  strcat(buf, FMT64);
1134  buf,
1135  level_exp(pl->level+1, pl->expmul));
1136 
1138  "[fixed]\nStat Nat/Real/Max");
1139 
1141  "[fixed]Str %2d/ %3d/%3d",
1142  pl->contr->orig_stats.Str, pl->stats.Str, 20+pl->arch->clone.stats.Str);
1144  "[fixed]Dex %2d/ %3d/%3d",
1145  pl->contr->orig_stats.Dex, pl->stats.Dex, 20+pl->arch->clone.stats.Dex);
1147  "[fixed]Con %2d/ %3d/%3d",
1148  pl->contr->orig_stats.Con, pl->stats.Con, 20+pl->arch->clone.stats.Con);
1150  "[fixed]Int %2d/ %3d/%3d",
1151  pl->contr->orig_stats.Int, pl->stats.Int, 20+pl->arch->clone.stats.Int);
1153  "[fixed]Wis %2d/ %3d/%3d",
1154  pl->contr->orig_stats.Wis, pl->stats.Wis, 20+pl->arch->clone.stats.Wis);
1156  "[fixed]Pow %2d/ %3d/%3d",
1157  pl->contr->orig_stats.Pow, pl->stats.Pow, 20+pl->arch->clone.stats.Pow);
1159  "[fixed]Cha %2d/ %3d/%3d",
1160  pl->contr->orig_stats.Cha, pl->stats.Cha, 20+pl->arch->clone.stats.Cha);
1162  "\nAttack Mode: %s",
1163  i18n(pl, pl->contr->peaceful ? "Peaceful" : "Hostile"));
1167  float weap_speed = pl->weapon_speed; // This is the number of attacks per tick.
1168  if (weap_speed < 0.0f)
1169  weap_speed = 0.0f;
1170  if (weap_speed > 1.0f)
1171  weap_speed = 1.0f;
1172  // We will initially calculate the damage if every attack you perform hits.
1173  // This will serve as a baseline for future calculations
1174  float dps = (1000000.0f / max_time) * weap_speed * pl->stats.dam;
1175  // TODO: Account for opposing AC in calculations, make some sort of table/chart.
1176  // Then we round the floating-point.
1178  "\n\nDam/Sec: %4d", (int)(dps + 0.5f));
1179 
1180  /* max_time is in microseconds - thus divide by 1000000.
1181  * Need 64 bit values, as otherwise ticks_played * max_time
1182  * can easily overflow.
1183  * Note the message displayed here isn't really
1184  * perfect, since if max_time has been changed since the player started,
1185  * the time estimates use the current value. But I'm presuming that
1186  * max_time won't change very often. MSW 2009-12-01
1187  */
1188  seconds = (uint64_t)pl->contr->ticks_played * (uint64_t)max_time / 1000000;
1189  minutes = (uint32_t)seconds / 60;
1190  hours = minutes / 60;
1191  minutes = minutes % 60;
1192 
1194  "You have played this character for %u ticks, which amounts "
1195  "to %d hours and %d minutes.",
1196  pl->contr->ticks_played, hours, minutes);
1197 
1198 
1199  /* Can't think of anything else to print right now */
1200 }
1201 
1210 void command_fix_me(object *op, const char *params) {
1211  (void)params;
1213  fix_object(op);
1214 }
1215 
1224 void command_players(object *op, const char *params) {
1225  char buf[MAX_BUF];
1226  char *t;
1227  DIR *dir;
1228  (void)params;
1229 
1230  snprintf(buf, sizeof(buf), "%s/%s/", settings.localdir, settings.playerdir);
1231  t = buf+strlen(buf);
1232  if ((dir = opendir(buf)) != NULL) {
1233  const struct dirent *entry;
1234 
1235  while ((entry = readdir(dir)) != NULL) {
1236  /* skip '.' , '..' */
1237  if (!((entry->d_name[0] == '.' && entry->d_name[1] == '\0')
1238  || (entry->d_name[0] == '.' && entry->d_name[1] == '.' && entry->d_name[2] == '\0'))) {
1239  struct stat st;
1240 
1241  strcpy(t, entry->d_name);
1242  if (stat(buf, &st) == 0) {
1243  /* This was not posix compatible
1244  * if ((st.st_mode & S_IFMT)==S_IFDIR) {
1245  */
1246  if (S_ISDIR(st.st_mode)) {
1247  struct tm *tm = localtime(&st.st_mtime);
1248 
1250  "[fixed]%s\t%04d %02d %02d %02d %02d %02d",
1251  entry->d_name,
1252  1900+tm->tm_year,
1253  1+tm->tm_mon,
1254  tm->tm_mday,
1255  tm->tm_hour,
1256  tm->tm_min,
1257  tm->tm_sec);
1258  }
1259  }
1260  }
1261  }
1262  }
1263  closedir(dir);
1264 }
1265 
1274 void command_applymode(object *op, const char *params) {
1275  unapplymode unapply = op->contr->unapply;
1276  static const char *const types[] = {
1277  "nochoice",
1278  "never",
1279  "always"
1280  };
1281 
1282  if (*params == '\0') {
1284  "applymode is set to %s",
1285  types[op->contr->unapply]);
1286  return;
1287  }
1288 
1289  if (!strcmp(params, "nochoice"))
1290  op->contr->unapply = unapply_nochoice;
1291  else if (!strcmp(params, "never"))
1292  op->contr->unapply = unapply_never;
1293  else if (!strcmp(params, "always"))
1294  op->contr->unapply = unapply_always;
1295  else {
1297  "applymode: Unknown options %s, valid options are nochoice, never, always",
1298  params);
1299  return;
1300  }
1302  "applymode%s set to %s",
1303  (unapply == op->contr->unapply ? "" : " now"),
1304  types[op->contr->unapply]);
1305 }
1306 
1315 void command_bowmode(object *op, const char *params) {
1316  bowtype_t oldtype = op->contr->bowtype;
1317  static const char *const types[] = {
1318  "normal",
1319  "threewide",
1320  "spreadshot",
1321  "firenorth",
1322  "firene",
1323  "fireeast",
1324  "firese",
1325  "firesouth",
1326  "firesw",
1327  "firewest",
1328  "firenw",
1329  "bestarrow"
1330  };
1331  int i, found;
1332 
1333  if (*params == '\0') {
1335  "bowmode is set to %s",
1336  types[op->contr->bowtype]);
1337  return;
1338  }
1339 
1340  for (i = 0, found = 0; i <= bow_bestarrow; i++) {
1341  if (!strcmp(params, types[i])) {
1342  found++;
1343  op->contr->bowtype = i;
1344  break;
1345  }
1346  }
1347  if (!found) {
1349  stringbuffer_append_printf(buf, "bowmode: Unknown options %s, valid options are:", params);
1350  for (i = 0; i <= bow_bestarrow; i++) {
1353  if (i < bow_nw)
1355  else
1357  }
1358  char *result = stringbuffer_finish(buf);
1360  free(result);
1361  return;
1362  }
1364  "bowmode%s set to %s",
1365  (oldtype == op->contr->bowtype ? "" : " now"),
1366  types[op->contr->bowtype]);
1367  return;
1368 }
1369 
1378 void command_unarmed_skill(object *op, const char *params) {
1379  object *skill;
1380  size_t i;
1381 
1382  if (*params == '\0') {
1384  "unarmed skill is set to %s",
1385  op->contr->unarmed_skill ? op->contr->unarmed_skill: "nothing");
1386  return;
1387  }
1388 
1389  /* find_skill_by_name() will ready any skill tools - which
1390  * is OK for us because no unarmed skills require skill tools,
1391  * but this could be an issue if you reuse this code for other skills.
1392  */
1393  skill = find_skill_by_name(op, params);
1394 
1395  if (!skill) {
1397  "You do not know any such skill called %s",
1398  params);
1399  return;
1400  }
1401  for (i = 0; i < sizeof(unarmed_skills); i++)
1402  if (skill->subtype == unarmed_skills[i])
1403  break;
1404  if (i == sizeof(unarmed_skills)) {
1406  "%s is not an unarmed skill!",
1407  skill->name);
1408  return;
1409 
1410  }
1411 
1412  if (op->contr->unarmed_skill)
1413  free_string(op->contr->unarmed_skill);
1414 
1415  /* Taking actual skill name is better than taking params,
1416  * as params could be something more than an exact skill name.
1417  */
1418  op->contr->unarmed_skill = add_string(skill->name);
1419 
1421  "unarmed skill is now set to %s",
1422  op->contr->unarmed_skill);
1423 }
1424 
1425 
1434 void command_petmode(object *op, const char *params) {
1435  petmode_t oldtype = op->contr->petmode;
1436  static const char *const types[] = {
1437  "normal",
1438  "sad",
1439  "defend",
1440  "arena"
1441  };
1442 
1443  if (*params == '\0') {
1445  "petmode is set to %s",
1446  types[op->contr->petmode]);
1447  return;
1448  }
1449 
1450  if (!strcmp(params, "normal"))
1451  op->contr->petmode = pet_normal;
1452  else if (!strcmp(params, "sad"))
1453  op->contr->petmode = pet_sad;
1454  else if (!strcmp(params, "defend"))
1455  op->contr->petmode = pet_defend;
1456  else if (!strcmp(params, "arena"))
1457  op->contr->petmode = pet_arena;
1458  else {
1460  "petmode: Unknown options %s, valid options are normal, sad (seek and destroy), defend, arena",
1461  params);
1462  return;
1463  }
1465  "petmode%s set to %s",
1466  (oldtype == op->contr->petmode ? "" : " now"),
1467  types[op->contr->petmode]);
1468 }
1469 
1478 void command_showpets(object *op, const char *params) {
1479  objectlink *obl, *next;
1480  int counter = 0, target = 0;
1481  int have_shown_pet = 0;
1482  if (*params != '\0')
1483  target = atoi(params);
1484 
1485  for (obl = first_friendly_object; obl != NULL; obl = next) {
1486  object *ob = obl->ob;
1487 
1488  next = obl->next;
1489  if (object_get_owner(ob) == op) {
1490  if (target == 0) {
1491  if (counter == 0)
1493  "Pets:");
1495  "%d %s - level %d",
1496  ++counter, ob->name, ob->level);
1497  } else if (!have_shown_pet && ++counter == target) {
1499  "[fixed]level %d %s",
1500  ob->level, ob->name);
1502  "[fixed]%d/%d HP, %d/%d SP",
1503  ob->stats.hp, ob->stats.maxhp, ob->stats.sp, ob->stats.maxsp);
1504 
1505  /* this is not a nice way to do this, it should be made to be more like the statistics command */
1507  "[fixed]Str %d",
1508  ob->stats.Str);
1510  "[fixed]Dex %d",
1511  ob->stats.Dex);
1513  "[fixed]Con %d",
1514  ob->stats.Con);
1516  "[fixed]Int %d",
1517  ob->stats.Int);
1519  "[fixed]Wis %d",
1520  ob->stats.Wis);
1522  "[fixed]Cha %d",
1523  ob->stats.Cha);
1525  "[fixed]Pow %d",
1526  ob->stats.Pow);
1528  "[fixed]wc %d damage %d ac %d",
1529  ob->stats.wc, ob->stats.dam, ob->stats.ac);
1530  have_shown_pet = 1;
1531  }
1532  }
1533  }
1534  if (counter == 0)
1536  "You have no pets.");
1537  else if (target != 0 && have_shown_pet == 0)
1539  "No such pet.");
1540 }
1541 
1550 void command_usekeys(object *op, const char *params) {
1551  usekeytype oldtype = op->contr->usekeys;
1552  static const char *const types[] = {
1553  "inventory",
1554  "keyrings",
1555  "containers"
1556  };
1557 
1558  if (*params == '\0') {
1560  "usekeys is set to %s",
1561  types[op->contr->usekeys]);
1562  return;
1563  }
1564 
1565  if (!strcmp(params, "inventory"))
1566  op->contr->usekeys = key_inventory;
1567  else if (!strcmp(params, "keyrings"))
1568  op->contr->usekeys = keyrings;
1569  else if (!strcmp(params, "containers"))
1570  op->contr->usekeys = containers;
1571  else {
1573  "usekeys: Unknown option %s, valid options are inventory, keyrings, containers",
1574  params);
1575  return;
1576  }
1578  "usekeys%s set to %s",
1579  (oldtype == op->contr->usekeys ? "" : " now"),
1580  types[op->contr->usekeys]);
1581 }
1582 
1591 void command_resistances(object *op, const char *params) {
1592  int i;
1593  (void)params;
1594  if (!op)
1595  return;
1596 
1597  for (i = 0; i < NROFATTACKS; i++) {
1598  if (i == ATNR_INTERNAL)
1599  continue;
1600 
1602  "[fixed]%-20s %+5d",
1603  attacktype_desc[i], op->resist[i]);
1604  }
1605 
1606  /* If dragon player, let's display natural resistances */
1607  if (is_dragon_pl(op)) {
1608  int attack;
1609  object *tmp;
1610 
1611  tmp = object_find_by_type_and_arch_name(op, FORCE, "dragon_skin_force");
1612  if (tmp != NULL) {
1614  "\nNatural skin resistances:");
1615 
1616  for (attack = 0; attack < NROFATTACKS; attack++) {
1617  if (atnr_is_dragon_enabled(attack)) {
1619  "%s: %d",
1620  change_resist_msg[attack], tmp->resist[attack]);
1621  }
1622  }
1623  }
1624  }
1625 }
1626 
1637 static void help_topics(object *op, int what) {
1638  DIR *dirp;
1639  struct dirent *de;
1640  char filename[MAX_BUF], line[HUGE_BUF];
1641  char suffix[MAX_BUF];
1642  int namelen;
1643  const char *language;
1644 
1645  language = i18n_get_language_code(op->contr->language);
1646  snprintf(suffix, sizeof(suffix), ".%s", language);
1647 
1648  switch (what) {
1649  case 1:
1650  snprintf(filename, sizeof(filename), "%s/wizhelp", settings.datadir);
1652  " Wiz commands:");
1653  break;
1654 
1655  case 3:
1656  snprintf(filename, sizeof(filename), "%s/mischelp", settings.datadir);
1658  " Misc help:");
1659  break;
1660 
1661  default:
1662  snprintf(filename, sizeof(filename), "%s/help", settings.datadir);
1664  " Commands:");
1665  break;
1666  }
1667  if (!(dirp = opendir(filename)))
1668  return;
1669 
1670  line[0] = '\0';
1671  for (de = readdir(dirp); de; de = readdir(dirp)) {
1672  namelen = NAMLEN(de);
1673 
1674  if (namelen <= 2
1675  && *de->d_name == '.'
1676  && (namelen == 1 || de->d_name[1] == '.'))
1677  continue;
1678  if (strstr(de->d_name, suffix)) {
1679  strcat(line, strtok(de->d_name, "."));
1680  strcat(line, " ");
1681  }
1682  }
1684  line);
1685  closedir(dirp);
1686 }
1687 
1697 static int find_help_file_in(const char *dir, const char *name, const char *language, char *path, int length) {
1698  struct stat st;
1699 
1700  snprintf(path, length, "%s/%s/%s.%s", settings.datadir, dir, name, language);
1701  if (stat(path, &st) == 0 && S_ISREG(st.st_mode)) {
1702  return 1;
1703  }
1704  return 0;
1705 }
1706 
1720 static int find_help_file(const char *name, const char *language, int wiz, char *path, int length) {
1721  if (wiz) {
1722  if (find_help_file_in("wizhelp", name, language, path, length))
1723  return 1;
1724  if (strcmp(language, "en") && find_help_file_in("wizhelp", name, "en", path, length))
1725  return 1;
1726  }
1727 
1728  if (find_help_file_in("help", name, language, path, length))
1729  return 1;
1730  if (strcmp(language, "en") && find_help_file_in("help", name, "en", path, length))
1731  return 1;
1732 
1733  return 0;
1734 }
1735 
1743 static void display_help_file(object *op, const char *filename) {
1744  BufferReader *br;
1745  const char *line;
1746 
1747  if ((br = bufferreader_init_from_file(NULL, filename, "Cannot open help file %s: %s\n", llevError)) == NULL) {
1748  return;
1749  }
1750 
1751  while ((line = bufferreader_next_line(br))) {
1753  }
1754 
1756 }
1757 
1766 void command_help(object *op, const char *params) {
1767  char filename[MAX_BUF];
1768  const char *language;
1769 
1770  /*
1771  * Main help page?
1772  */
1773  if (*params == '\0') {
1774  snprintf(filename, sizeof(filename), "%s/def_help", settings.datadir);
1776  return;
1777  }
1778 
1779  /*
1780  * Topics list
1781  */
1782  if (!strcmp(params, "topics")) {
1783  help_topics(op, 3);
1784  help_topics(op, 0);
1785  if (QUERY_FLAG(op, FLAG_WIZ))
1786  help_topics(op, 1);
1787  return;
1788  }
1789 
1790  /*
1791  * Commands list
1792  */
1793  if (!strcmp(params, "commands")) {
1795  return;
1796  }
1797 
1798  /*
1799  * User wants info about command
1800  */
1801  if (strchr(params, '.') || strchr(params, ' ') || strchr(params, '/')) {
1803  "Illegal characters in '%s'",
1804  params);
1805  return;
1806  }
1807 
1808  language = i18n_get_language_code(op->contr->language);
1809 
1810  if (!find_help_file(params, language, QUERY_FLAG(op, FLAG_WIZ), filename, sizeof(filename))) {
1812  "No help available on '%s'",
1813  params);
1814  return;
1815  }
1816 
1817  /*
1818  * Found that. Just cat it to screen.
1819  */
1821 }
1822 
1833 static int onoff_value(const char *line) {
1834  int i;
1835 
1836  if (sscanf(line, "%d", &i))
1837  return (i != 0);
1838 
1839  switch (line[0]) {
1840  case 'o':
1841  switch (line[1]) {
1842  case 'n':
1843  return 1; /* on */
1844  default:
1845  return 0; /* o[ff] */
1846  }
1847 
1848  case 'y': /* y[es] */
1849  case 'k': /* k[ylla] */
1850  case 's':
1851  case 'd':
1852  return 1;
1853 
1854  case 'n': /* n[o] */
1855  case 'e': /* e[i] */
1856  case 'u':
1857  default:
1858  return 0;
1859  }
1860 }
1861 
1867 void command_quit(object* op, const char* params) {
1868  (void)params;
1869  draw_ext_info(
1871  "To leave the game, sleep in (apply) a bed to reality. To "
1872  "permenantly delete your character, use the 'delete' command.");
1873 }
1874 
1883 void command_delete(object *op, const char *params) {
1884  (void)params;
1885  if (QUERY_FLAG(op, FLAG_WAS_WIZ)) {
1886  draw_ext_info(NDI_UNIQUE, 0, op, MSG_TYPE_COMMAND, MSG_TYPE_ADMIN_DM, "Can't quit when in DM mode.");
1887  return;
1888  }
1889 
1890  send_query(&op->contr->socket, CS_QUERY_SINGLECHAR,
1891  i18n(op, "Quitting will delete your character.\nAre you sure you want to delete your character (y/n):"));
1892 
1894 }
1895 
1904 void command_sound(object *op, const char *params) {
1905  (void)params;
1906  if (!(op->contr->socket.sound&SND_MUTE)) {
1907  op->contr->socket.sound = op->contr->socket.sound|SND_MUTE;
1909  "Sounds are turned off.");
1910  } else {
1911  op->contr->socket.sound = op->contr->socket.sound&~SND_MUTE;
1913  "The sounds are enabled.");
1914  }
1915  return;
1916 }
1917 
1929 void receive_player_name(object *op, const char *name) {
1930  if (!check_name(op->contr, name)) {
1931  get_name(op);
1932  return;
1933  }
1934  FREE_AND_COPY(op->name, name);
1935  FREE_AND_COPY(op->name_pl, name);
1937  op->contr->name_changed = 1;
1938  get_password(op);
1939 }
1940 
1949 void receive_player_password(object *op, const char *password) {
1950  unsigned int pwd_len = strlen(password);
1951 
1952  if (pwd_len == 0 || pwd_len > 16) {
1953  if (op->contr->state == ST_CHANGE_PASSWORD_OLD
1954  || op->contr->state == ST_CHANGE_PASSWORD_NEW
1955  || op->contr->state == ST_CHANGE_PASSWORD_CONFIRM) {
1957  "Password changed cancelled.");
1958  player_set_state(op->contr, ST_PLAYING);
1959  } else
1960  get_name(op);
1961  return;
1962  }
1963  /* To hide the password better */
1964  /* With currently clients, not sure if this is really the case - MSW */
1966 
1967  if (checkbanned(op->name, op->contr->socket.host)) {
1968  LOG(llevInfo, "Banned player tried to add: [%s@%s]\n", op->name, op->contr->socket.host);
1970  "You are not allowed to play.");
1971  get_name(op);
1972  return;
1973  }
1974 
1975  if (op->contr->state == ST_CONFIRM_PASSWORD) {
1976  if (!check_password(password, op->contr->password)) {
1978  "The passwords did not match.");
1979  get_name(op);
1980  return;
1981  }
1982  LOG(llevInfo, "LOGIN: New player named %s from ip %s\n", op->name, op->contr->socket.host);
1983  display_motd(op);
1985  "\nWelcome, Brave New Warrior!\n");
1986  roll_again(op);
1987  player_set_state(op->contr, ST_ROLL_STAT);
1988  return;
1989  }
1990 
1991  if (op->contr->state == ST_CHANGE_PASSWORD_OLD) {
1992  if (!check_password(password, op->contr->password)) {
1994  "You entered the wrong current password.");
1995  player_set_state(op->contr, ST_PLAYING);
1996  } else {
1997  send_query(&op->contr->socket, CS_QUERY_HIDEINPUT, i18n(op, "Please enter your new password, or blank to cancel:"));
1999  }
2000  return;
2001  }
2002 
2003  if (op->contr->state == ST_CHANGE_PASSWORD_NEW) {
2004  safe_strncpy(op->contr->new_password, newhash(password),
2005  sizeof(op->contr->new_password));
2006  send_query(&op->contr->socket, CS_QUERY_HIDEINPUT,
2007  i18n(op, "Please confirm your new password, or blank to cancel:"));
2009  return;
2010  }
2011 
2012  if (op->contr->state == ST_CHANGE_PASSWORD_CONFIRM) {
2013  if (!check_password(password, op->contr->new_password)) {
2015  "The new passwords don't match!");
2016  } else {
2018  "Password changed.");
2019  strncpy(op->contr->password, op->contr->new_password, 13);
2020  }
2021  player_set_state(op->contr, ST_PLAYING);
2022  return;
2023  }
2024 
2025  safe_strncpy(op->contr->password, newhash(password),
2026  sizeof(op->contr->password));
2027  player_set_state(op->contr, ST_ROLL_STAT);
2028  check_login(op, password);
2029 }
2030 
2041 void command_title(object *op, const char *params) {
2042  char buf[MAX_BUF];
2043 
2044  if (settings.set_title == FALSE) {
2046  "You cannot change your title.");
2047  return;
2048  }
2049 
2050  /* dragon players cannot change titles */
2051  if (is_dragon_pl(op)) {
2053  "Dragons cannot change titles.");
2054  return;
2055  }
2056 
2057  if (*params == '\0') {
2058  char tmp[MAX_BUF];
2059 
2060  player_get_title(op->contr, tmp, sizeof(tmp));
2061  snprintf(buf, sizeof(buf), "Your title is '%s'.", tmp);
2063  return;
2064  }
2065  if (strcmp(params, "clear") == 0 || strcmp(params, "default") == 0) {
2066  if (!player_has_own_title(op->contr))
2068  "Your title is the default title.");
2069  else
2071  "Title set to default.");
2072  player_set_own_title(op->contr, "");
2073  return;
2074  }
2075 
2076  if ((int)strlen(params) >= MAX_NAME) {
2078  "Title too long.");
2079  return;
2080  }
2081  player_set_own_title(op->contr, params);
2082 }
2083 
2092 void command_save(object *op, const char *params) {
2093  (void)params;
2094  if (get_map_flags(op->map, NULL, op->x, op->y, NULL, NULL)&P_NO_CLERIC) {
2096  "You can not save on unholy ground.");
2097  } else if (!op->stats.exp) {
2099  "You don't deserve to save yet.");
2100  } else {
2101  if (save_player(op, 1))
2103  "You have been saved.");
2104  else
2106  "SAVE FAILED!");
2107  }
2108 }
2109 
2118 void command_peaceful(object *op, const char *params) {
2119  (void)params;
2120  if ((op->contr->peaceful = !op->contr->peaceful))
2122  "You will not attack other players.");
2123  else
2125  "You will attack other players.");
2126 }
2127 
2136 void command_wimpy(object *op, const char *params) {
2137  int i;
2138 
2139  if (*params == '\0' || !sscanf(params, "%d", &i)) {
2141  "Your current wimpy level is %d.",
2142  op->run_away);
2143  return;
2144  }
2145 
2146  if (i < 0 || i > 100) {
2148  "Wimpy level should be between 1 and 100.",
2149  i);
2150  return;
2151  }
2152 
2154  "Your new wimpy level is %d.",
2155  i);
2156  op->run_away = i;
2157 }
2158 
2167 void command_brace(object *op, const char *params) {
2168  if (*params == '\0')
2169  op->contr->braced = !op->contr->braced;
2170  else
2171  op->contr->braced = onoff_value(params);
2172 
2173  if (op->contr->braced)
2175  "You are braced.");
2176  else
2178  "Not braced.");
2179 
2180  fix_object(op);
2181 }
2182 
2191 void command_kill_pets(object *op, const char *params) {
2192  objectlink *obl, *next;
2193  int counter = 0, removecount = 0;
2194 
2195  if (*params == '\0') {
2198  "Your pets have been killed.");
2199  } else {
2200  int target = atoi(params);
2201  for (obl = first_friendly_object; obl != NULL; obl = next) {
2202  object *ob = obl->ob;
2203  next = obl->next;
2204  if (object_get_owner(ob) == op)
2205  if (++counter == target || (target == 0 && !strcasecmp(ob->name, params))) {
2206  if (!QUERY_FLAG(ob, FLAG_REMOVED))
2207  object_remove(ob);
2210  removecount++;
2211  }
2212  }
2213  if (removecount != 0)
2215  "Killed %d pets.",
2216  removecount);
2217  else
2219  "Couldn't find any suitable pets to kill.");
2220  }
2221 }
2222 
2231 void command_passwd(object *pl, const char *params) {
2232  (void)params;
2233  /* If old client, this is the way you change your password. */
2234  if (pl->contr->socket.login_method < 1){
2235  send_query(&pl->contr->socket, CS_QUERY_HIDEINPUT, i18n(pl, "Password change.\nPlease enter your current password, or empty string to cancel."));
2236 
2238  }
2239  /* If new client (login_method = 2) or jxclient (login_method = 1), changing the password does nothing anyway, so error out */
2240  else{
2242  "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.");
2243  }
2244 }
2245 
2255 void do_harvest(object *pl, int dir, object *skill) {
2256  int16_t x, y;
2257  int count = 0, proba; /* Probability to get the item, 100 based. */
2258  int level, exp, check_exhaust = 0;
2259  object *found[10]; /* Found items that can be harvested. */
2260  mapstruct *map;
2261  object *item, *inv, *harvested;
2262  sstring trace, ttool, tspeed, race, tool, slevel, sexp;
2263  float speed;
2264 
2265  x = pl->x+freearr_x[dir];
2266  y = pl->y+freearr_y[dir];
2267  map = pl->map;
2268 
2269  if (!IS_PLAYER(pl))
2270  return;
2271 
2272  if (!map)
2273  return;
2274 
2275  if (get_map_flags(map, &map, x, y, &x, &y)&P_OUT_OF_MAP) {
2276  draw_ext_info_format(NDI_WHITE, 0, pl, MSG_TYPE_SKILL, MSG_TYPE_SKILL_FAILURE, i18n(pl, "You cannot %s here."), skill->slaying);
2277  return;
2278  }
2279 
2280  if (!pl->chosen_skill || pl->chosen_skill->skill != skill->skill)
2281  return;
2282 
2283  trace = object_get_value(pl->chosen_skill, "harvest_race");
2284  ttool = object_get_value(pl->chosen_skill, "harvest_tool");
2285  tspeed = object_get_value(pl->chosen_skill, "harvest_speed");
2286  if (!trace || strcmp(trace, "") == 0 || !ttool || strcmp(ttool, "") == 0 || !tspeed || strcmp(tspeed, "") == 0) {
2287  draw_ext_info_format(NDI_WHITE, 0, pl, MSG_TYPE_SKILL, MSG_TYPE_SKILL_FAILURE, i18n(pl, "You start to %s, but change your mind."), skill->slaying);
2288  LOG(llevError, "do_harvest: tool %s without harvest_[race|tool|speed]\n", pl->chosen_skill->name);
2289  return;
2290  }
2291 
2292  item = GET_MAP_OB(map, x, y);
2293  while (item && count < 10) {
2295  if (object_value_set(inv, "harvestable") == false)
2296  continue;
2297  race = object_get_value(inv, "harvest_race");
2298  tool = object_get_value(inv, "harvest_tool");
2299  slevel = object_get_value(inv, "harvest_level");
2300  sexp = object_get_value(inv, "harvest_exp");
2301  if (race && (!slevel || !sexp)) {
2302  LOG(llevError, "do_harvest: item %s without harvest_[level|exp]\n", inv->name);
2303  continue;
2304  }
2305  if (race == trace && (!tool || tool == ttool))
2306  found[count++] = inv;
2307  } FOR_INV_FINISH();
2308  item = item->above;
2309  }
2310  if (count == 0) {
2311  draw_ext_info_format(NDI_WHITE, 0, pl, MSG_TYPE_SKILL, MSG_TYPE_SKILL_FAILURE, i18n(pl, "You find nothing to %s here."), skill->slaying);
2312  return;
2313  }
2314 
2315  inv = found[rndm(0, count-1)];
2316  assert(inv);
2317  item = inv->env;
2318  assert(item);
2319 
2320  slevel = object_get_value(inv, "harvest_level");
2321  sexp = object_get_value(inv, "harvest_exp");
2322  level = atoi(slevel);
2323  exp = atoi(sexp);
2324 
2325  speed = atof(tspeed);
2326  if (speed < 0)
2327  speed = -speed*pl->speed;
2328  pl->speed_left -= speed;
2329 
2330 
2331  /* Now we found something to harvest, randomly try to get it. */
2332  if (level > skill->level+10) {
2333  draw_ext_info_format(NDI_WHITE, 0, pl, MSG_TYPE_SKILL, MSG_TYPE_SKILL_FAILURE, i18n(pl, "You find something, but it is too difficult for you to %s."), skill->slaying);
2334  return;
2335  }
2336 
2337  if (level >= skill->level)
2338  /* Up to 10 more levels, 1 to 11 percent probability. */
2339  proba = 10+skill->level-level;
2340  else if (skill->level <= level+10)
2341  proba = 10+(skill->level-level)*2;
2342  else
2343  proba = 30;
2344 
2345  if (proba <= random_roll(0, 100, pl, 1)) {
2346  draw_ext_info_format(NDI_WHITE, 0, pl, MSG_TYPE_SKILL, MSG_TYPE_SKILL_FAILURE, i18n(pl, "You find something, but fail to %s it."), skill->slaying);
2347  return;
2348  }
2349 
2350  /* Check the new item can fit into inventory.
2351  * Fixes bug #3060474: fishing puts more fishes into inventory than you can carry. */
2352  if (((uint32_t)(pl->weight + pl->carrying + inv->weight)) > get_weight_limit(pl->stats.Str)) {
2353  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);
2354  return;
2355  }
2356 
2357  /* Ok, got it. */
2358  if (inv->nrof == 0) {
2359  harvested = object_new();
2360  object_copy_with_inv(inv, harvested);
2361  } else {
2362  if (count == 1 && inv->nrof == 1) {
2363  check_exhaust = 1;
2364  }
2365  harvested = object_split(inv, 1, NULL, 0);
2366  }
2367  object_set_value(harvested, "harvestable", NULL, 0);
2368  if (QUERY_FLAG(harvested, FLAG_MONSTER)) {
2369  int spot = object_find_free_spot(harvested, pl->map, pl->x, pl->y, 0, SIZEOFFREE);
2370  if (spot == -1) {
2371  /* Better luck next time...*/
2372  object_remove(harvested);
2373  draw_ext_info_format(NDI_WHITE, 0, pl, MSG_TYPE_SKILL, MSG_TYPE_SKILL_FAILURE, "You fail to %s anything.", skill->slaying);
2374  return;
2375  }
2376  object_insert_in_map_at(harvested, pl->map, NULL, 0, pl->x+freearr_x[spot], pl->y+freearr_y[spot]);
2377  draw_ext_info_format(NDI_WHITE, 0, pl, MSG_TYPE_SKILL, MSG_TYPE_SKILL_FAILURE, "You %s a %s!", skill->slaying, harvested->name);
2378  } else {
2379  harvested = object_insert_in_ob(harvested, pl);
2380  draw_ext_info_format(NDI_WHITE, 0, pl, MSG_TYPE_SKILL, MSG_TYPE_SKILL_FAILURE, "You %s some %s.", skill->slaying, harvested->name);
2381  }
2382 
2383  /* Get exp */
2384  change_exp(pl, exp, skill->name, SK_EXP_ADD_SKILL);
2385 
2386  if (check_exhaust) {
2387  sstring replacement = object_get_value(item, "harvest_exhaust_replacement");
2388  if (replacement) {
2389  if (replacement[0] != '-') {
2390  archetype *other = try_find_archetype(replacement);
2391  if (other) {
2392  object *final = object_create_arch(other);
2394  }
2395  }
2398  }
2399  }
2400 
2401  return;
2402 }
give.next
def next
Definition: give.py:44
GET_MAP_OB
#define GET_MAP_OB(M, X, Y)
Definition: map.h:173
get_weight_limit
uint32_t get_weight_limit(int stat)
Definition: living.c:2362
command_version
void command_version(object *op, const char *params)
Definition: c_misc.c:1073
nrofallowedstr
EXTERN long nrofallowedstr
Definition: global.h:140
global.h
make_face_from_files.anims
list anims
Definition: make_face_from_files.py:52
object
struct obj object
get_who_escape_code_value
static void get_who_escape_code_value(char *return_val, int size, const char letter, player *pl)
Definition: c_misc.c:696
ST_CHANGE_PASSWORD_OLD
#define ST_CHANGE_PASSWORD_OLD
Definition: define.h:550
bow_nw
@ bow_nw
Definition: player.h:39
object_free
void object_free(object *ob, int flags)
Definition: object.c:1565
chars_names::login_order
int login_order
Definition: c_misc.c:524
add_string
sstring add_string(const char *str)
Definition: shstr.c:124
object_remove
void object_remove(object *op)
Definition: object.c:1806
safe_strncpy
#define safe_strncpy
Definition: compat.h:27
stringbuffer_new
StringBuffer * stringbuffer_new(void)
Definition: stringbuffer.c:57
pets_terminate_all
void pets_terminate_all(object *owner)
Definition: pets.c:225
object_sum_weight
signed long object_sum_weight(object *op)
Definition: object.c:561
assets_number_of_animations
size_t assets_number_of_animations()
Definition: assets.cpp:286
NUM_BODY_LOCATIONS
#define NUM_BODY_LOCATIONS
Definition: object.h:13
ATNR_INTERNAL
#define ATNR_INTERNAL
Definition: attack.h:72
time_info
void time_info(object *op)
Definition: time.c:294
command_list
void command_list(object *pl, bool is_dm)
Definition: commands.cpp:377
llevError
@ llevError
Definition: logger.h:11
FABS
#define FABS(x)
Definition: define.h:22
hiscore_display
void hiscore_display(object *op, int max, const char *match)
Definition: hiscore.c:449
get_region_from_string
region * get_region_from_string(const char *name)
Definition: region.c:121
command_motd
void command_motd(object *op, const char *params)
Definition: c_misc.c:216
command_afk
void command_afk(object *op, const char *params)
Definition: c_misc.c:772
SET_FLAG
#define SET_FLAG(xyz, p)
Definition: define.h:224
command_bowmode
void command_bowmode(object *op, const char *params)
Definition: c_misc.c:1315
send_news
void send_news(const object *op)
Definition: player.c:203
command_help
void command_help(object *op, const char *params)
Definition: c_misc.c:1766
object_find_by_type_and_arch_name
object * object_find_by_type_and_arch_name(const object *who, int type, const char *name)
Definition: object.c:4285
diamondslots.x
x
Definition: diamondslots.py:15
obj::count
tag_t count
Definition: object.h:300
obj::map
struct mapdef * map
Definition: object.h:298
MSG_TYPE_SKILL
#define MSG_TYPE_SKILL
Definition: newclient.h:407
QUERY_FLAG
#define QUERY_FLAG(xyz, p)
Definition: define.h:226
newhash
char const * newhash(char const *password)
Settings::set_title
uint8_t set_title
Definition: global.h:261
pl::peaceful
uint32_t peaceful
Definition: player.h:133
types
type_definition ** types
Definition: gridarta-types-convert.c:56
bufferreader_init_from_file
BufferReader * bufferreader_init_from_file(BufferReader *br, const char *filepath, const char *failureMessage, LogLevel failureLevel)
Definition: bufferreader.c:65
find_help_file
static int find_help_file(const char *name, const char *language, int wiz, char *path, int length)
Definition: c_misc.c:1720
liv::Str
int8_t Str
Definition: living.h:36
FALSE
#define FALSE
Definition: compat.h:14
object_new
object * object_new(void)
Definition: object.c:1242
i18n_find_language_by_code
int i18n_find_language_by_code(const char *code)
Definition: languages.c:81
Settings::datadir
const char * datadir
Definition: global.h:244
entry
Definition: entry.py:1
manor.params
params
Definition: manor.py:295
FULL_VERSION
#define FULL_VERSION
Definition: version.h:4
player_has_own_title
int player_has_own_title(const struct pl *pl)
Definition: player.c:250
pl::socket
socket_struct socket
Definition: player.h:94
name_cmp
static int name_cmp(const chars_names *c1, const chars_names *c2)
Definition: c_misc.c:536
command_whereami
void command_whereami(object *op, const char *params)
Definition: c_misc.c:819
pl
Definition: player.h:92
command_petmode
void command_petmode(object *op, const char *params)
Definition: c_misc.c:1434
receive_player_password
void receive_player_password(object *op, const char *password)
Definition: c_misc.c:1949
command_save
void command_save(object *op, const char *params)
Definition: c_misc.c:2092
command_dumpfriendlyobjects
void command_dumpfriendlyobjects(object *op, const char *params)
Definition: c_misc.c:988
guildjoin.ob
ob
Definition: guildjoin.py:42
command_resistances
void command_resistances(object *op, const char *params)
Definition: c_misc.c:1591
get_password
void get_password(object *op)
Definition: player.c:873
get_name_of_region_for_map
const char * get_name_of_region_for_map(const mapstruct *m)
Definition: region.c:92
python_event.path
path
Definition: python_event.py:11
get_region_longname
const char * get_region_longname(const region *r)
Definition: region.c:217
commongive.inv
inv
Definition: commongive.py:28
command_unarmed_skill
void command_unarmed_skill(object *op, const char *params)
Definition: c_misc.c:1378
CS_QUERY_SINGLECHAR
#define CS_QUERY_SINGLECHAR
Definition: newclient.h:67
first_artifactlist
EXTERN artifactlist * first_artifactlist
Definition: global.h:118
pl::ob
object * ob
Definition: player.h:162
socket_struct::is_bot
uint32_t is_bot
Definition: newserver.h:107
MSG_TYPE_LAST
#define MSG_TYPE_LAST
Definition: newclient.h:418
bufferreader_next_line
char * bufferreader_next_line(BufferReader *br)
Definition: bufferreader.c:102
bowtype_t
enum _bowtype bowtype_t
FLAG_WIZCAST
#define FLAG_WIZCAST
Definition: define.h:289
Ice.tmp
int tmp
Definition: Ice.py:207
NDI_RED
#define NDI_RED
Definition: newclient.h:245
max_time
uint32_t max_time
Definition: time.c:35
command_kill_pets
void command_kill_pets(object *op, const char *params)
Definition: c_misc.c:2191
dump_all_maps
void dump_all_maps(void)
Definition: map.c:279
guildbuy.players
list players
Definition: guildbuy.py:17
remove_friendly_object
void remove_friendly_object(object *op)
Definition: friend.c:56
unapply_always
@ unapply_always
Definition: player.h:65
assets_number_of_archetypes
size_t assets_number_of_archetypes()
Definition: assets.cpp:270
current_region_info
static void current_region_info(object *op)
Definition: c_misc.c:406
player_set_own_title
void player_set_own_title(struct pl *pl, const char *title)
Definition: player.c:275
NROFATTACKS
#define NROFATTACKS
Definition: attack.h:17
command_dumpallmaps
void command_dumpallmaps(object *op, const char *params)
Definition: c_misc.c:1044
give.parms
parms
Definition: give.py:28
npc_dialog.filename
filename
Definition: npc_dialog.py:99
MSG_TYPE_COMMAND_ERROR
#define MSG_TYPE_COMMAND_ERROR
Definition: newclient.h:529
first_map
EXTERN mapstruct * first_map
Definition: global.h:116
first_friendly_object
EXTERN objectlink * first_friendly_object
Definition: global.h:119
version.h
command_printlos
void command_printlos(object *op, const char *params)
Definition: c_misc.c:1058
HUGE_BUF
#define HUGE_BUF
Definition: define.h:37
treasurestruct
Definition: treasure.h:63
MSG_TYPE_COMMAND
#define MSG_TYPE_COMMAND
Definition: newclient.h:404
shstr.h
command_dumpallobjects
void command_dumpallobjects(object *op, const char *params)
Definition: c_misc.c:974
freearr_x
short freearr_x[SIZEOFFREE]
Definition: object.c:288
freearr_y
short freearr_y[SIZEOFFREE]
Definition: object.c:294
party_struct::partyname
char * partyname
Definition: party.h:14
linked_char
Definition: global.h:86
archt
Definition: object.h:468
settings
struct Settings settings
Definition: init.c:39
command_brace
void command_brace(object *op, const char *params)
Definition: c_misc.c:2167
object_get_value
const char * object_get_value(const object *op, const char *const key)
Definition: object.c:4354
MSG_TYPE_ADMIN_DM
#define MSG_TYPE_ADMIN_DM
Definition: newclient.h:497
obj::slaying
sstring slaying
Definition: object.h:320
free_string
void free_string(sstring str)
Definition: shstr.c:280
command_applymode
void command_applymode(object *op, const char *params)
Definition: c_misc.c:1274
regiondef::next
struct regiondef * next
Definition: map.h:276
m
static event_registration m
Definition: citylife.cpp:425
MAP_IN_MEMORY
#define MAP_IN_MEMORY
Definition: map.h:131
pl::next
struct pl * next
Definition: player.h:93
FMT64
#define FMT64
Definition: compat.h:16
opendir
DIR * opendir(const char *)
is_valid_types_gen.line
line
Definition: is_valid_types_gen.py:34
object_dump_all
void object_dump_all(void)
Definition: object.c:697
command_debug
void command_debug(object *op, const char *params)
Definition: c_misc.c:890
disinfect.map
map
Definition: disinfect.py:4
object_copy_with_inv
void object_copy_with_inv(const object *src_ob, object *dest_ob)
Definition: object.c:1183
command_dumpmap
void command_dumpmap(object *op, const char *params)
Definition: c_misc.c:1030
oblnk::next
struct oblnk * next
Definition: object.h:447
Settings::debug
LogLevel debug
Definition: global.h:240
FLAG_WAS_WIZ
#define FLAG_WAS_WIZ
Definition: define.h:234
send_rules
void send_rules(const object *op)
Definition: player.c:167
obj::name
sstring name
Definition: object.h:312
command_wizcast
void command_wizcast(object *op, const char *params)
Definition: c_misc.c:944
pl::state
uint8_t state
Definition: player.h:118
print_los
void print_los(object *op)
Definition: los.c:606
bow_bestarrow
@ bow_bestarrow
Definition: player.h:40
ST_CHANGE_PASSWORD_CONFIRM
#define ST_CHANGE_PASSWORD_CONFIRM
Definition: define.h:552
command_fix_me
void command_fix_me(object *op, const char *params)
Definition: c_misc.c:1210
SS_DUMP_TABLE
#define SS_DUMP_TABLE
Definition: shstr.h:46
check_login
void check_login(object *op, const char *password)
Definition: login.c:519
pet_normal
@ pet_normal
Definition: player.h:45
unapplymode
unapplymode
Definition: player.h:62
regiondef::counter
uint32_t counter
Definition: map.h:293
petmode_t
enum _petmode petmode_t
MSG_TYPE_COMMAND_INFO
#define MSG_TYPE_COMMAND_INFO
Definition: newclient.h:526
liv::Cha
int8_t Cha
Definition: living.h:36
display_motd
void display_motd(const object *op)
Definition: player.c:136
stringbuffer_append_string
void stringbuffer_append_string(StringBuffer *sb, const char *str)
Definition: stringbuffer.c:95
pet_defend
@ pet_defend
Definition: player.h:47
command_whereabouts
void command_whereabouts(object *op, const char *params)
Definition: c_misc.c:483
MAP_WHEN_RESET
#define MAP_WHEN_RESET(m)
Definition: map.h:62
readdir
struct dirent * readdir(DIR *)
MSG_TYPE_COMMAND_MALLOC
#define MSG_TYPE_COMMAND_MALLOC
Definition: newclient.h:522
i18n_get_language_code
sstring i18n_get_language_code(int language)
Definition: languages.c:108
get_region_by_name
region * get_region_by_name(const char *region_name)
Definition: region.c:46
ss_dump_statistics
void ss_dump_statistics(char *buf, size_t size)
Definition: shstr.c:323
socket_struct::host
char * host
Definition: newserver.h:100
FLAG_AFK
#define FLAG_AFK
Definition: define.h:368
MSG_TYPE_COMMAND_STATISTICS
#define MSG_TYPE_COMMAND_STATISTICS
Definition: newclient.h:524
command_players
void command_players(object *op, const char *params)
Definition: c_misc.c:1224
ss_dump_table
char * ss_dump_table(int what, char *buf, size_t size)
Definition: shstr.c:354
FREE_AND_COPY
#define FREE_AND_COPY(sv, nv)
Definition: global.h:202
regiondef::name
char * name
Definition: map.h:277
artifactliststruct::next
struct artifactliststruct * next
Definition: artifact.h:29
first_player
EXTERN player * first_player
Definition: global.h:115
fix_object
void fix_object(object *op)
Definition: living.c:1126
object_create_arch
object * object_create_arch(archetype *at)
Definition: arch.cpp:301
stringbuffer_finish
char * stringbuffer_finish(StringBuffer *sb)
Definition: stringbuffer.c:76
nrofallocobjects
int nrofallocobjects
Definition: object.c:280
FLAG_WIZPASS
#define FLAG_WIZPASS
Definition: define.h:314
artifactliststruct
Definition: artifact.h:26
FOR_INV_FINISH
#define FOR_INV_FINISH()
Definition: define.h:675
MAX_NAME
#define MAX_NAME
Definition: define.h:41
ST_CHANGE_PASSWORD_NEW
#define ST_CHANGE_PASSWORD_NEW
Definition: define.h:551
current_map_info
static void current_map_info(object *op)
Definition: c_misc.c:428
INS_BELOW_ORIGINATOR
#define INS_BELOW_ORIGINATOR
Definition: object.h:571
object_set_value
int object_set_value(object *op, const char *key, const char *value, int add_key)
Definition: object.c:4489
sstring
const typedef char * sstring
Definition: global.h:40
rndm
int rndm(int min, int max)
Definition: utils.c:162
disinfect.count
int count
Definition: disinfect.py:7
command_hiscore
void command_hiscore(object *op, const char *params)
Definition: c_misc.c:878
push.match
bool match
Definition: push.py:61
liv::Con
int8_t Con
Definition: living.h:36
command_rules
void command_rules(object *op, const char *params)
Definition: c_misc.c:229
FLAG_USE_WEAPON
#define FLAG_USE_WEAPON
Definition: define.h:296
sproto.h
SND_MUTE
#define SND_MUTE
Definition: sounds.h:14
chars_names::namebuf
char namebuf[MAX_BUF]
Definition: c_misc.c:523
MapSpace
Definition: map.h:257
mapdef
Definition: map.h:324
MSG_SUBTYPE_NONE
#define MSG_SUBTYPE_NONE
Definition: newclient.h:420
is_dragon_pl
int is_dragon_pl(const object *op)
Definition: player.c:125
liv::Int
int8_t Int
Definition: living.h:36
command_mapinfo
void command_mapinfo(object *op, const char *params)
Definition: c_misc.c:806
command_language
void command_language(object *op, const char *params)
Definition: c_misc.c:131
nlohmann::detail::void
j template void())
Definition: json.hpp:4099
command_body
void command_body(object *op, const char *params)
Definition: c_misc.c:174
FLAG_MONSTER
#define FLAG_MONSTER
Definition: define.h:245
party_struct
Definition: party.h:10
key_inventory
@ key_inventory
Definition: player.h:53
find_skill_by_name
object * find_skill_by_name(object *who, const char *name)
Definition: skill_util.c:202
command_passwd
void command_passwd(object *pl, const char *params)
Definition: c_misc.c:2231
mapdef::name
char * name
Definition: map.h:327
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
SIZEOFFREE
#define SIZEOFFREE
Definition: define.h:155
P_OUT_OF_MAP
#define P_OUT_OF_MAP
Definition: map.h:250
command_wimpy
void command_wimpy(object *op, const char *params)
Definition: c_misc.c:2136
MAX_BUF
#define MAX_BUF
Definition: define.h:35
artifactstruct
Definition: artifact.h:14
split_string
size_t split_string(char *str, char *array[], size_t array_size, char sep)
Definition: utils.c:500
NAMLEN
#define NAMLEN(dirent)
Definition: global.h:209
checkbanned
int checkbanned(const char *login, const char *host)
Definition: ban.c:32
level_exp
int64_t level_exp(int level, double expmul)
Definition: living.c:1874
Settings::playerdir
const char * playerdir
Definition: global.h:246
command_sound
void command_sound(object *op, const char *params)
Definition: c_misc.c:1904
IS_PLAYER
static bool IS_PLAYER(object *op)
Definition: object.h:596
StringBuffer
Definition: stringbuffer.c:25
random_roll
int random_roll(int min, int max, const object *op, int goodbad)
Definition: utils.c:42
is_valid_types_gen.found
found
Definition: is_valid_types_gen.py:39
object_count_used
int object_count_used(void)
Definition: object.c:1740
ST_PLAYING
#define ST_PLAYING
Definition: define.h:541
object_count_active
int object_count_active(void)
Definition: object.c:1756
sounds.h
FLAG_REMOVED
#define FLAG_REMOVED
Definition: define.h:232
help_topics
static void help_topics(object *op, int what)
Definition: c_misc.c:1637
do_harvest
void do_harvest(object *pl, int dir, object *skill)
Definition: c_misc.c:2255
command_ssdumptable
void command_ssdumptable(object *op, const char *params)
Definition: c_misc.c:1016
dump_friendly_objects
void dump_friendly_objects(void)
Definition: friend.c:100
FLAG_WIZ
#define FLAG_WIZ
Definition: define.h:231
llevInfo
@ llevInfo
Definition: logger.h:12
dirent
#define dirent
Definition: xdir.h:12
change_resist_msg
const EXTERN char *const change_resist_msg[NROFATTACKS]
Definition: attack.h:135
Floor.t
t
Definition: Floor.py:62
NDI_UNIQUE
#define NDI_UNIQUE
Definition: newclient.h:262
get_region_by_map
region * get_region_by_map(mapstruct *m)
Definition: region.c:74
object_count_free
int object_count_free(void)
Definition: object.c:1724
regiondef::parent
struct regiondef * parent
Definition: map.h:285
chars_names
Definition: c_misc.c:522
MSG_TYPE_SKILL_FAILURE
#define MSG_TYPE_SKILL_FAILURE
Definition: newclient.h:590
Settings::who_wiz_format
char who_wiz_format[MAX_BUF]
Definition: global.h:273
malloc_info
static void malloc_info(object *op)
Definition: c_misc.c:253
i18n_list_languages
void i18n_list_languages(object *who)
Definition: languages.c:118
ST_CONFIRM_PASSWORD
#define ST_CONFIRM_PASSWORD
Definition: define.h:548
liv::Dex
int8_t Dex
Definition: living.h:36
unapply_nochoice
@ unapply_nochoice
Definition: player.h:63
FLAG_USE_ARMOUR
#define FLAG_USE_ARMOUR
Definition: define.h:295
item
Definition: item.py:1
LOG
void LOG(LogLevel logLevel, const char *format,...)
Definition: logger.c:51
liv::Wis
int8_t Wis
Definition: living.h:36
MSG_TYPE_COMMAND_BODY
#define MSG_TYPE_COMMAND_BODY
Definition: newclient.h:521
command_title
void command_title(object *op, const char *params)
Definition: c_misc.c:2041
roll_again
void roll_again(object *op)
Definition: player.c:1117
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
assets_number_of_treasurelists
size_t assets_number_of_treasurelists()
Definition: assets.cpp:266
receive_player_name
void receive_player_name(object *op, const char *name)
Definition: c_misc.c:1929
pet_sad
@ pet_sad
Definition: player.h:46
object_value_set
bool object_value_set(const object *op, const char *const key)
Definition: object.c:4384
pet_arena
@ pet_arena
Definition: player.h:48
command_showpets
void command_showpets(object *op, const char *params)
Definition: c_misc.c:1478
bufferreader_destroy
void bufferreader_destroy(BufferReader *br)
Definition: bufferreader.c:40
command_listen
void command_listen(object *op, const char *params)
Definition: c_misc.c:1087
attacktype_desc
const EXTERN char *const attacktype_desc[NROFATTACKS]
Definition: attack.h:138
diamondslots.y
y
Definition: diamondslots.py:16
NDI_WHITE
#define NDI_WHITE
Definition: newclient.h:243
command_quit
void command_quit(object *op, const char *params)
Definition: c_misc.c:1867
oblnk::ob
object * ob
Definition: object.h:446
assets.h
CLEAR_FLAG
#define CLEAR_FLAG(xyz, p)
Definition: define.h:225
buf
StringBuffer * buf
Definition: readable.c:1606
pl::hidden
uint32_t hidden
Definition: player.h:134
stringbuffer_append_printf
void stringbuffer_append_printf(StringBuffer *sb, const char *format,...)
Definition: stringbuffer.c:104
change_exp
void change_exp(object *op, int64_t exp, const char *skill_name, int flag)
Definition: living.c:2168
MAP_HEIGHT
#define MAP_HEIGHT(m)
Definition: map.h:80
MAP_ENTER_Y
#define MAP_ENTER_Y(m)
Definition: map.h:87
object_insert_in_ob
object * object_insert_in_ob(object *op, object *where)
Definition: object.c:2820
command_news
void command_news(object *op, const char *params)
Definition: c_misc.c:242
dump_map
void dump_map(const mapstruct *m)
Definition: map.c:256
MSG_TYPE_COMMAND_CONFIG
#define MSG_TYPE_COMMAND_CONFIG
Definition: newclient.h:525
obj::subtype
uint8_t subtype
Definition: object.h:342
command_time
void command_time(object *op, const char *params)
Definition: c_misc.c:865
containers
@ containers
Definition: player.h:55
list_players
void list_players(object *op, region *reg, partylist *party)
Definition: c_misc.c:550
map_size
uint32_t map_size(mapstruct *m)
Definition: map.c:823
keyrings
@ keyrings
Definition: player.h:54
MSG_TYPE_COMMAND_MAPS
#define MSG_TYPE_COMMAND_MAPS
Definition: newclient.h:520
strcasecmp
int strcasecmp(const char *s1, const char *s2)
obj::skill
sstring skill
Definition: object.h:322
loader.h
get_region_msg
const char * get_region_msg(const region *r)
Definition: region.c:238
nroffreeobjects
int nroffreeobjects
Definition: object.c:279
save_player
int save_player(object *op, int flag)
Definition: login.c:230
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
ST_GET_PARTY_PASSWORD
#define ST_GET_PARTY_PASSWORD
Definition: define.h:549
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
command_delete
void command_delete(object *op, const char *params)
Definition: c_misc.c:1883
object_free_drop_inventory
void object_free_drop_inventory(object *ob)
Definition: object.c:1533
command_strings
void command_strings(object *op, const char *params)
Definition: c_misc.c:844
pl::ticks_played
uint32_t ticks_played
Definition: player.h:207
i18n
const char * i18n(const object *who, const char *code)
Definition: languages.c:55
MAP_ENTER_X
#define MAP_ENTER_X(m)
Definition: map.h:85
player_set_state
void player_set_state(player *pl, uint8_t state)
Definition: player.c:4428
try_find_archetype
archetype * try_find_archetype(const char *name)
Definition: assets.cpp:282
command_peaceful
void command_peaceful(object *op, const char *params)
Definition: c_misc.c:2118
command_dumpallarchetypes
void command_dumpallarchetypes(object *op, const char *params)
Definition: c_misc.c:1002
check_password
bool check_password(const char *typed, const char *crypted)
Definition: server.c:114
SS_DUMP_TOTALS
#define SS_DUMP_TOTALS
Definition: shstr.h:47
level
int level
Definition: readable.c:1604
seconds
long seconds(void)
Definition: time.c:344
socket_struct::login_method
uint8_t login_method
Definition: newserver.h:128
P_NO_CLERIC
#define P_NO_CLERIC
Definition: map.h:239
nrofartifacts
EXTERN long nrofartifacts
Definition: global.h:139
ST_CONFIRM_QUIT
#define ST_CONFIRM_QUIT
Definition: define.h:545
FREE_OBJ_FREE_INVENTORY
#define FREE_OBJ_FREE_INVENTORY
Definition: object.h:531
command_usekeys
void command_usekeys(object *op, const char *params)
Definition: c_misc.c:1550
SK_EXP_ADD_SKILL
#define SK_EXP_ADD_SKILL
Definition: skills.h:78
command_malloc
void command_malloc(object *op, const char *params)
Definition: c_misc.c:793
say.item
dictionary item
Definition: say.py:149
MSG_TYPE_ADMIN_VERSION
#define MSG_TYPE_ADMIN_VERSION
Definition: newclient.h:501
unapply_never
@ unapply_never
Definition: player.h:64
atnr_is_dragon_enabled
int atnr_is_dragon_enabled(int attacknr)
Definition: player.c:106
LogLevel
LogLevel
Definition: logger.h:10
display_help_file
static void display_help_file(object *op, const char *filename)
Definition: c_misc.c:1743
map_info
static void map_info(object *op, const char *search)
Definition: c_misc.c:51
command_who
void command_who(object *op, const char *params)
Definition: c_misc.c:623
oblnk
Definition: object.h:445
mapdef::path
char path[HUGE_BUF]
Definition: map.h:364
command_statistics
void command_statistics(object *pl, const char *params)
Definition: c_misc.c:1118
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
ST_ROLL_STAT
#define ST_ROLL_STAT
Definition: define.h:543
get_map_flags
int get_map_flags(mapstruct *oldmap, mapstruct **newmap, int16_t x, int16_t y, int16_t *nx, int16_t *ny)
Definition: map.c:311
player_get_title
void player_get_title(const struct pl *pl, char *buf, size_t bufsize)
Definition: player.c:235
check_name
int check_name(player *me, const char *name)
Definition: login.c:181
closedir
int closedir(DIR *)
command_wizpass
void command_wizpass(object *op, const char *params)
Definition: c_misc.c:914
MSG_TYPE_COMMAND_WHO
#define MSG_TYPE_COMMAND_WHO
Definition: newclient.h:519
first_region
EXTERN region * first_region
Definition: global.h:117
display_who_entry
static void display_who_entry(object *op, player *pl, const char *format)
Definition: c_misc.c:640
body_locations
body_locations_struct body_locations[NUM_BODY_LOCATIONS]
Definition: item.c:54
regiondef::longname
char * longname
Definition: map.h:290
altar_valkyrie.pl
pl
Definition: altar_valkyrie.py:28
set_map_reset_time
void set_map_reset_time(mapstruct *map)
Definition: map.c:2237
BufferReader
Definition: bufferreader.c:21
command_maps
void command_maps(object *op, const char *params)
Definition: c_misc.c:832
send_query
void send_query(socket_struct *ns, uint8_t flags, const char *text)
Definition: request.c:679
object_split
object * object_split(object *orig_ob, uint32_t nr, char *err, size_t size)
Definition: object.c:2600
MSG_TYPE_ADMIN
#define MSG_TYPE_ADMIN
Definition: newclient.h:402
mapstruct
struct mapdef mapstruct
Settings::who_format
char who_format[MAX_BUF]
Definition: global.h:272
FOR_INV_PREPARE
#define FOR_INV_PREPARE(op_, it_)
Definition: define.h:668
find_help_file_in
static int find_help_file_in(const char *dir, const char *name, const char *language, char *path, int length)
Definition: c_misc.c:1697
FORCE
@ FORCE
Definition: object.h:224
usekeytype
usekeytype
Definition: player.h:52
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
ring_occidental_mages.r
r
Definition: ring_occidental_mages.py:6
region_is_child_of_region
int region_is_child_of_region(const region *child, const region *r)
Definition: region.c:190
obj::level
int16_t level
Definition: object.h:354
dump_all_archetypes
void dump_all_archetypes(void)
Definition: arch.cpp:152
assets_number_of_treasures
size_t assets_number_of_treasures()
Definition: assets.cpp:263
pl::orig_stats
living orig_stats
Definition: player.h:152
treasureliststruct
Definition: treasure.h:82
give.name
name
Definition: give.py:27
castle_read.suffix
string suffix
Definition: castle_read.py:30
get_name
void get_name(object *op)
Definition: player.c:862
object_get_owner
object * object_get_owner(object *op)
Definition: object.c:797
CS_QUERY_HIDEINPUT
#define CS_QUERY_HIDEINPUT
Definition: newclient.h:68
onoff_value
static int onoff_value(const char *line)
Definition: c_misc.c:1833
find_player
player * find_player(const char *plname)
Definition: player.c:56
level
Definition: level.py:1
Settings::localdir
const char * localdir
Definition: global.h:245
regiondef
Definition: map.h:275