Crossfire Server, Trunk  1.75.0
c_misc.cpp
Go to the documentation of this file.
1 /*
2  * Crossfire -- cooperative multi-player graphical RPG and adventure game
3  *
4  * Copyright (c) 1999-2014 Mark Wedel and the Crossfire Development Team
5  * Copyright (c) 1992 Frank Tore Johansen
6  *
7  * Crossfire is free software and comes with ABSOLUTELY NO WARRANTY. You are
8  * welcome to redistribute it under certain conditions. For details, please
9  * see COPYING and LICENSE.
10  *
11  * The authors can be reached via e-mail at <crossfire@metalforge.org>.
12  */
13 
20 #include "global.h"
21 
22 #include <assert.h>
23 #include <stdlib.h>
24 #include <string.h>
25 #include <sys/stat.h>
26 
27 #undef SS_STATISTICS
28 #include "loader.h"
29 #include "shstr.h"
30 #include "sounds.h"
31 #include "sproto.h"
32 #include "version.h"
33 
34 #include "assets.h"
35 #include "AssetsManager.h"
36 
37 /* Static declarations where needed (when ordering would be an issue) */
38 static void display_who_entry(object *op, player *pl, const char *format);
39 static void get_who_escape_code_value(char *return_val, int size, const char letter, player *pl);
40 static int onoff_value(const char *line);
41 
50 static void map_info(object *op, const char *search) {
51  if ( *search != 0 ) {
53  "Maps matching search: '%s'", search);
54  }
55  if (QUERY_FLAG(op, FLAG_WIZ)) {
57  "[fixed]Path Reset In (HH:MM:SS) Pl IM TO");
58  } else {
60  "[fixed]Path Reset In (HH:MM)");
61  }
62 
63  /* Allow a comma-separate list of search strings; more complicated because of the const */
64  char *to_be_freed = NULL;
65  char *search_array[64];
66  int search_array_count = 0;
67  if ( search[0] ) {
68  to_be_freed = strdup(search);
69  if ( !to_be_freed ) {
70  search_array[0] = to_be_freed;
71  search_array_count = 1;
72  } else {
73  search_array_count = split_string(to_be_freed,search_array,64,',');
74  }
75  }
76 
77  for (mapstruct *m = first_map; m != NULL; m = m->next) {
78  bool match = TRUE;
79  if ( search_array_count ) {
80  match = FALSE;
81  for (int i=0; i<search_array_count; ++i) {
82  if ( strstr(m->path,search_array[i]) ) {
83  match=TRUE;
84  break;
85  }
86  }
87  }
88  if ( !match ) continue; /* Skip unwanted maps */
89 
90  /* Print out the last 26 characters of the map name... */
91  char map_path[MAX_BUF];
92  if (strlen(m->path) <= 26) {
93  strcpy(map_path, m->path);
94  } else {
95  safe_strncpy(map_path, m->path + strlen(m->path) - 26, sizeof(map_path));
96  }
97 
98  uint32_t ttr = MAP_WHEN_RESET(m) - seconds() > 0 ? MAP_WHEN_RESET(m) - seconds() : 0;
99  if ( !m->reset_timeout && !m->unique ) set_map_reset_time(m);
100  if (m->players) {
101  ttr = (m->unique ? 0 : m->reset_timeout) + ticks_to_seconds(MAP_MINTIMEOUT);
102  }
103  else if (m->timeout) {
104  ttr = (m->unique ? 0 : m->reset_timeout) + ticks_to_seconds(m->timeout);
105  }
106  const uint32_t hh = ttr/3600, mm = (ttr%3600)/60, ss = ttr%60;
107  if (QUERY_FLAG(op, FLAG_WIZ)) {
110  "[fixed]%-26.26s %2d:%02d:%02d %2d %2d %4d",
111  map_path, hh, mm, ss, m->players, m->in_memory, m->timeout);
112  } else {
115  "[fixed]%-26.26s %2d:%02d%s", map_path, hh, mm,
116  m->players ? " (in use)" : "");
117  }
118  }
119  if ( to_be_freed ) free( to_be_freed );
120 }
121 
130 void command_language(object *op, const char *params) {
131  language_t language = nullptr;
132 
133  if (!op->contr)
134  return;
135 
136  if (*params == '\0' || (!strcmp(params, ""))) {
138  "Your current language is set to: English.");
140  "Available languages:");
142  return;
143  }
144 
145  language = i18n_find_language_by_code(params);
146 
147  /* Error out if unknown language. */
148  if (language == nullptr) {
150  "Unknown language.");
151  return;
152  }
153 
154  op->contr->language = language;
155 
157  "Your current language is set to English.");
158 }
159 
173 void command_body(object *op, const char *params) {
174  int i;
175  (void)params;
176 
177  /* Too hard to try and make a header that lines everything up, so just
178  * give a description.
179  */
181  "The first column is the name of the body location.");
182 
184  "The second column is how many of those locations your body has.");
185 
187  "The third column is how many slots in that location are available.");
188 
189  for (i = 0; i < NUM_BODY_LOCATIONS; i++) {
190  /* really debugging - normally body_used should not be set to anything
191  * if body_info isn't also set.
192  */
193  if (op->body_info[i] || op->body_used[i]) {
195  "[fixed]%-30s %5d %5d",
196  i18n(op, body_locations[i].use_name), op->body_info[i], op->body_used[i]);
197  }
198  }
199  if (!QUERY_FLAG(op, FLAG_USE_ARMOUR))
201  "You are not allowed to wear armor.");
202  if (!QUERY_FLAG(op, FLAG_USE_WEAPON))
204  "You are not allowed to use weapons.");
205 }
206 
215 void command_motd(object *op, const char *params) {
216  (void)params;
217  display_motd(op);
218 }
219 
228 void command_rules(object *op, const char *params) {
229  (void)params;
230  send_rules(op);
231 }
232 
241 void command_news(object *op, const char *params) {
242  (void)params;
243  send_news(op);
244 }
245 
252 static void malloc_info(object *op) {
253  int ob_used = object_count_used(), ob_free = object_count_free(), players, nrofmaps;
254  int nrm = 0, mapmem = 0, anr, anims, sum_alloc = 0, sum_used = 0, i, alnr;
255  player *pl;
256  mapstruct *m;
257  artifactlist *al;
258 
259  for (al = first_artifactlist, alnr = 0; al != NULL; al = al->next, alnr++)
260  ;
261 
262  anr = getManager()->archetypes()->count();
263 
264  anims = getManager()->animations()->count();
265 
266  for (pl = first_player, players = 0; pl != NULL; pl = pl->next, players++)
267  ;
268 
269  for (m = first_map, nrofmaps = 0; m != NULL; m = m->next, nrofmaps++)
270  if (m->in_memory == MAP_IN_MEMORY) {
271  mapmem += map_size(m) * (sizeof(object *) + sizeof(MapSpace));
272  nrm++;
273  }
274 
276  "Sizeof: object=%zu player=%zu map=%zu",
277  sizeof(object), sizeof(player), sizeof(mapstruct));
278 
280  "[fixed]Objects:");
281 
283  "[fixed]%6d used", ob_used);
284 
285  if (ob_used != nrofallocobjects - nroffreeobjects) {
287  "[fixed] (used list mismatch: %d)",
289  }
290 
292  "[fixed]%6d free (%.2f%% of %d allocated)",
293  ob_free, (float)ob_free / nrofallocobjects * 100, nrofallocobjects);
294 
295  if (ob_free != nroffreeobjects) {
297  "[fixed] (free list mismatch: %d)",
299  }
300 
302  "[fixed]%6d on active list",
304 
305  i = (ob_used*sizeof(object));
306  sum_used += i;
307  sum_alloc += i;
308 
310  "[fixed] object total: %11d", i);
311 
312  i = (ob_free*sizeof(object));
313  sum_alloc += i;
314 
316  "[fixed]%4d players: %8d",
317  players, i = (players*sizeof(player)));
318 
319  sum_alloc += i;
320  sum_used += i;
321 
323  "[fixed]%4d maps allocated: %8d",
324  nrofmaps, i = (nrofmaps*sizeof(mapstruct)));
325 
326  sum_alloc += i;
327  sum_used += nrm*sizeof(mapstruct);
328 
330  "[fixed]%4d maps in memory: %8d",
331  nrm, mapmem);
332 
333  sum_alloc += mapmem;
334  sum_used += mapmem;
335 
337  "[fixed]%4d archetypes: %8d",
338  anr, i = (anr*sizeof(archetype)));
339 
340  sum_alloc += i;
341  sum_used += i;
342 
344  "[fixed]%4d animations: %8d",
345  anims, i = (anims*sizeof(uint16_t)));
346 
347  sum_alloc += i;
348  sum_used += i;
349 
351  "[fixed]%4zu treasurelists %8d",
353 
354  sum_alloc += i;
355  sum_used += i;
356 
358  "[fixed]%4ld treasures %8d",
360 
361  sum_alloc += i;
362  sum_used += i;
363 
365  "[fixed]%4ld artifacts %8d",
366  nrofartifacts, i = (nrofartifacts*sizeof(artifact)));
367 
368  sum_alloc += i;
369  sum_used += i;
370 
372  "[fixed]%4ld artifacts strngs %8d",
373  nrofallowedstr, i = (nrofallowedstr*sizeof(linked_char)));
374 
375  sum_alloc += i;
376  sum_used += i;
377 
379  "[fixed]%4d artifactlists %8d",
380  alnr, i = (alnr*sizeof(artifactlist)));
381 
382  sum_alloc += i;
383  sum_used += i;
384 
386  "[fixed]Total space allocated:%8d",
387  sum_alloc);
388 
390  "[fixed]Total space used: %8d",
391  sum_used);
392 }
393 
405 static void current_region_info(object *op) {
406  /*
407  * Ok I /suppose/ I should write a separate function for this, but it isn't
408  * going to be /that/ slow, and won't get called much
409  */
411 
412  /* This should only be possible if regions are not operating on this server. */
413  if (!r)
414  return;
415 
417  "You are in %s.\n%s",
419 }
420 
427 static void current_map_info(object *op) {
428  mapstruct *m = op->map;
429 
430  if (!m)
431  return;
432 
434  "%s (%s) in %s",
435  m->name, m->path, get_region_longname(get_region_by_map(m)));
436 
437  if (QUERY_FLAG(op, FLAG_WIZ)) {
439  "players:%d difficulty:%d size:%dx%d start:%dx%d timeout %d reset_group: %s",
440  m->players, m->difficulty,
441  MAP_WIDTH(m), MAP_HEIGHT(m),
443  MAP_TIMEOUT(m), m->reset_group ? m->reset_group : "(none)");
444  }
445  if (m->msg)
447 }
448 
449 #ifdef DEBUG_MALLOC_LEVEL
450 
458 void command_malloc_verify(object *op, char *parms) {
459  extern int malloc_verify(void);
460 
461  if (!malloc_verify())
463  "Heap is corrupted.");
464  else
466  "Heap checks out OK.");
467 
468  return 1;
469 }
470 #endif
471 
482 void command_whereabouts(object *op, const char *params) {
483  player *pl;
484  (void)params;
485 
486  /*
487  * reset the counter on the region, then use it to store the number of
488  * players there.
489  * I don't know how thread-safe this would be, I suspect not very....
490  */
491  for (auto reg : all_regions) {
492  reg->counter = 0;
493  }
494  for (pl = first_player; pl != NULL; pl = pl->next)
495  if (pl->ob->map != NULL)
496  get_region_by_map(pl->ob->map)->counter++;
497 
498  /* we only want to print out by places with a 'longname' field...*/
499  for (auto reg : all_regions) {
500  if (reg->longname == NULL && reg->counter > 0) {
501  if (reg->parent != NULL) {
502  reg->parent->counter += reg->counter;
503  reg->counter = 0;
504  } else /*uh oh, we shouldn't be here. */
505  LOG(llevError, "command_whereabouts() Region %s with no longname has no parent\n", reg->name);
506  }
507  }
509  "In the world currently there are:");
510 
511  for (auto reg : all_regions)
512  if (reg->counter > 0) {
514  "%u players in %s",
515  reg->counter, get_region_longname(reg));
516  }
517 }
518 
520 struct chars_names {
523 };
524 
534 static int name_cmp(const chars_names *c1, const chars_names *c2) {
535  return strcasecmp(c1->namebuf, c2->namebuf);
536 }
537 
548 void list_players(object *op, region *reg, partylist *party) {
549  player *pl;
550  uint16_t i;
551  char *format;
552  int num_players = 0, num_wiz = 0, num_afk = 0, num_bot = 0;
553  chars_names *chars = NULL;
554 
555  if (op == NULL || QUERY_FLAG(op, FLAG_WIZ))
556  format = settings.who_wiz_format;
557  else
558  format = settings.who_format;
559 
560  for (pl = first_player; pl != NULL; pl = pl->next) {
561  if (pl->ob->map == NULL)
562  continue;
563  if (pl->hidden && !QUERY_FLAG(op, FLAG_WIZ))
564  continue;
565 
566  if (reg && !region_is_child_of_region(get_region_by_map(pl->ob->map), reg))
567  continue;
568  if (party && pl->party != party)
569  continue;
570 
571  if (pl->state == ST_PLAYING || pl->state == ST_GET_PARTY_PASSWORD) {
572  num_players++;
573  chars = (chars_names *)realloc(chars, num_players*sizeof(chars_names));
574  if (chars == NULL) {
576  "who failed - out of memory!");
577  return;
578  }
579  sprintf(chars[num_players-1].namebuf, "%s", pl->ob->name);
581 
582  /* Check for WIZ's & AFK's*/
583  if (QUERY_FLAG(pl->ob, FLAG_WIZ))
584  num_wiz++;
585 
586  if (QUERY_FLAG(pl->ob, FLAG_AFK))
587  num_afk++;
588 
589  if (pl->socket->is_bot)
590  num_bot++;
591  }
592  }
593  if (first_player != (player *)NULL) {
594  if (reg == NULL && party == NULL)
596  "Total Players (%d) -- WIZ(%d) AFK(%d) BOT(%d)",
597  num_players, num_wiz, num_afk, num_bot);
598  else if (party == NULL)
600  "Total Players in %s (%d) -- WIZ(%d) AFK(%d) BOT(%d)",
601  reg->longname ? reg->longname : reg->name, num_players, num_wiz, num_afk, num_bot);
602  else
604  "Total Players in party %s (%d) -- WIZ(%d) AFK(%d) BOT(%d)",
605  party->partyname, num_players, num_wiz, num_afk, num_bot);
606  }
607  if (chars == NULL)
608  return;
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 
626  reg = get_region_from_string(params);
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  default:
763  return_val[0] = '\0';
764  }
765 }
766 
775 void command_afk(object *op, const char *params) {
776  (void)params;
777  if (QUERY_FLAG(op, FLAG_AFK)) {
778  CLEAR_FLAG(op, FLAG_AFK);
780  "You are no longer AFK");
781  } else {
782  SET_FLAG(op, FLAG_AFK);
784  "You are now AFK");
785  }
786 }
787 
796 void command_malloc(object *op, const char *params) {
797  (void)params;
798  malloc_info(op);
799 }
800 
809 void command_mapinfo(object *op, const char *params) {
810  (void)params;
811  current_map_info(op);
812 }
813 
822 void command_whereami(object *op, const char *params) {
823  (void)params;
825 }
826 
835 void command_maps(object *op, const char *params) {
836  map_info(op, params);
837 }
838 
847 void command_strings(object *op, const char *params) {
848  char stats[HUGE_BUF];
849  (void)params;
850 
851  ss_dump_statistics(stats, sizeof(stats));
853  "[fixed]%s\n",
854  stats);
855 
858 }
859 
868 void command_time(object *op, const char *params) {
869  (void)params;
870  time_info(op);
871 }
872 
881 void command_hiscore(object *op, const char *params) {
882  hiscore_display(op, op == NULL ? 9999 : 50, params);
883 }
884 
893 void command_debug(object *op, const char *params) {
894  int i;
895 
896  if (*params == '\0' || !sscanf(params, "%d", &i)) {
898  "Global debug level is %d.",
899  settings.debug);
900  return;
901  }
902  settings.debug = (enum LogLevel)FABS(i);
904  "Debug level set to %d.",
905  i);
906 }
907 
908 
917 void command_wizpass(object *op, const char *params) {
918  int i;
919 
920  if (!op)
921  return;
922 
923  if (*params == '\0')
924  i = (QUERY_FLAG(op, FLAG_WIZPASS)) ? 0 : 1;
925  else
926  i = onoff_value(params);
927 
928  if (i) {
930  "You will now walk through walls.");
931  SET_FLAG(op, FLAG_WIZPASS);
932  } else {
934  "You will now be stopped by walls.");
936  }
937 }
938 
947 void command_wizcast(object *op, const char *params) {
948  int i;
949 
950  if (!op)
951  return;
952 
953  if (*params == '\0')
954  i = (QUERY_FLAG(op, FLAG_WIZCAST)) ? 0 : 1;
955  else
956  i = onoff_value(params);
957 
958  if (i) {
960  "You can now cast spells anywhere.");
961  SET_FLAG(op, FLAG_WIZCAST);
962  } else {
964  "You now cannot cast spells in no-magic areas.");
966  }
967 }
968 
977 void command_dumpallobjects(object *op, const char *params) {
978  (void)op;
979  (void)params;
980  object_dump_all();
981 }
982 
991 void command_dumpfriendlyobjects(object *op, const char *params) {
992  (void)op;
993  (void)params;
995 }
996 
1005 void command_dumpallarchetypes(object *op, const char *params) {
1006  (void)op;
1007  (void)params;
1009 }
1010 
1019 void command_ssdumptable(object *op, const char *params) {
1020  (void)op;
1021  (void)params;
1022  ss_dump_table(SS_DUMP_TABLE, NULL, 0);
1023 }
1024 
1033 void command_dumpmap(object *op, const char *params) {
1034  (void)params;
1035  if (op)
1036  dump_map(op->map);
1037 }
1038 
1047 void command_dumpallmaps(object *op, const char *params) {
1048  (void)op;
1049  (void)params;
1050  dump_all_maps();
1051 }
1052 
1061 void command_printlos(object *op, const char *params) {
1062  (void)params;
1063  if (op)
1064  print_los(op);
1065 }
1066 
1067 
1076 void command_version(object *op, const char *params) {
1077  (void)params;
1079  MSG_TYPE_ADMIN_VERSION, "Crossfire " FULL_VERSION);
1080 }
1081 
1090 void command_listen(object *op, const char *params) {
1091  int i;
1092 
1093  if (*params == '\0' || !sscanf(params, "%d", &i)) {
1095  "Set listen to what (presently %d)?",
1096  op->contr->listening);
1097  return;
1098  }
1099  if (i < 0) {
1101  "Verbose level should be positive.");
1102  return;
1103  }
1104  op->contr->listening = (char)i;
1106  "Your verbose level is now %d.",
1107  i);
1108 }
1109 
1121 void command_statistics(object *pl, const char *params) {
1122  char buf[MAX_BUF];
1123  uint32_t hours, minutes;
1124  uint64_t seconds; /* 64 bit to prevent overflows an intermediate results */
1125  (void)params;
1126 
1127  if (!pl->contr)
1128  return;
1129  safe_strncpy(buf, i18n(pl, "[fixed] Experience: %"), sizeof(buf));
1130  strcat(buf, FMT64);
1132  buf,
1133  pl->stats.exp);
1134  safe_strncpy(buf, i18n(pl, "[fixed] Next Level: %"), sizeof(buf));
1135  strcat(buf, FMT64);
1137  buf,
1138  level_exp(pl->level+1, pl->expmul));
1139 
1141  "[fixed]\nStat Nat/Real/Max");
1142 
1144  "[fixed]Str %2d/ %3d/%3d",
1145  pl->contr->orig_stats.Str, pl->stats.Str, 20+pl->arch->clone.stats.Str);
1147  "[fixed]Dex %2d/ %3d/%3d",
1148  pl->contr->orig_stats.Dex, pl->stats.Dex, 20+pl->arch->clone.stats.Dex);
1150  "[fixed]Con %2d/ %3d/%3d",
1151  pl->contr->orig_stats.Con, pl->stats.Con, 20+pl->arch->clone.stats.Con);
1153  "[fixed]Int %2d/ %3d/%3d",
1154  pl->contr->orig_stats.Int, pl->stats.Int, 20+pl->arch->clone.stats.Int);
1156  "[fixed]Wis %2d/ %3d/%3d",
1157  pl->contr->orig_stats.Wis, pl->stats.Wis, 20+pl->arch->clone.stats.Wis);
1159  "[fixed]Pow %2d/ %3d/%3d",
1160  pl->contr->orig_stats.Pow, pl->stats.Pow, 20+pl->arch->clone.stats.Pow);
1162  "[fixed]Cha %2d/ %3d/%3d",
1163  pl->contr->orig_stats.Cha, pl->stats.Cha, 20+pl->arch->clone.stats.Cha);
1165  "\nAttack Mode: %s",
1166  i18n(pl, pl->contr->peaceful ? "Peaceful" : "Hostile"));
1170  float weap_speed = pl->weapon_speed; // This is the number of attacks per tick.
1171  if (weap_speed < 0.0f)
1172  weap_speed = 0.0f;
1173  if (weap_speed > 1.0f)
1174  weap_speed = 1.0f;
1175  // We will initially calculate the damage if every attack you perform hits.
1176  // This will serve as a baseline for future calculations
1177  float dps = (1000000.0f / tick_duration) * weap_speed * pl->stats.dam;
1178  // TODO: Account for opposing AC in calculations, make some sort of table/chart.
1179  // Then we round the floating-point.
1181  "\n\nDam/Sec: %4d", (int)(dps + 0.5f));
1182 
1183  /* max_time is in microseconds - thus divide by 1000000.
1184  * Need 64 bit values, as otherwise ticks_played * max_time
1185  * can easily overflow.
1186  * Note the message displayed here isn't really
1187  * perfect, since if max_time has been changed since the player started,
1188  * the time estimates use the current value. But I'm presuming that
1189  * max_time won't change very often. MSW 2009-12-01
1190  */
1191  seconds = (uint64_t)pl->contr->ticks_played * (uint64_t)tick_duration / 1000000;
1192  minutes = (uint32_t)seconds / 60;
1193  hours = minutes / 60;
1194  minutes = minutes % 60;
1195 
1197  "You have played this character for %u ticks, which amounts "
1198  "to %d hours and %d minutes.",
1199  pl->contr->ticks_played, hours, minutes);
1200 
1201 
1202  /* Can't think of anything else to print right now */
1203 }
1204 
1213 void command_fix_me(object *op, const char *params) {
1214  (void)params;
1215  object_sum_weight(op);
1216  fix_object(op);
1217 }
1218 
1227 void command_players(object *op, const char *params) {
1228  char buf[MAX_BUF];
1229  char *t;
1230  DIR *dir;
1231  (void)params;
1232 
1233  snprintf(buf, sizeof(buf), "%s/%s/", settings.localdir, settings.playerdir);
1234  t = buf+strlen(buf);
1235  if ((dir = opendir(buf)) != NULL) {
1236  const struct dirent *entry;
1237 
1238  while ((entry = readdir(dir)) != NULL) {
1239  /* skip '.' , '..' */
1240  if (!((entry->d_name[0] == '.' && entry->d_name[1] == '\0')
1241  || (entry->d_name[0] == '.' && entry->d_name[1] == '.' && entry->d_name[2] == '\0'))) {
1242  struct stat st;
1243 
1244  strcpy(t, entry->d_name);
1245  if (stat(buf, &st) == 0) {
1246  /* This was not posix compatible
1247  * if ((st.st_mode & S_IFMT)==S_IFDIR) {
1248  */
1249  if (S_ISDIR(st.st_mode)) {
1250  struct tm *tm = localtime(&st.st_mtime);
1251 
1253  "[fixed]%s\t%04d %02d %02d %02d %02d %02d",
1254  entry->d_name,
1255  1900+tm->tm_year,
1256  1+tm->tm_mon,
1257  tm->tm_mday,
1258  tm->tm_hour,
1259  tm->tm_min,
1260  tm->tm_sec);
1261  }
1262  }
1263  }
1264  }
1265  closedir(dir);
1266  }
1267 }
1268 
1277 void command_applymode(object *op, const char *params) {
1278  unapplymode unapply = op->contr->unapply;
1279  static const char *const types[] = {
1280  "nochoice",
1281  "never",
1282  "always"
1283  };
1284 
1285  if (*params == '\0') {
1287  "applymode is set to %s",
1288  types[op->contr->unapply]);
1289  return;
1290  }
1291 
1292  if (!strcmp(params, "nochoice"))
1294  else if (!strcmp(params, "never"))
1295  op->contr->unapply = unapply_never;
1296  else if (!strcmp(params, "always"))
1297  op->contr->unapply = unapply_always;
1298  else {
1300  "applymode: Unknown options %s, valid options are nochoice, never, always",
1301  params);
1302  return;
1303  }
1305  "applymode%s set to %s",
1306  (unapply == op->contr->unapply ? "" : " now"),
1307  types[op->contr->unapply]);
1308 }
1309 
1318 void command_bowmode(object *op, const char *params) {
1319  bowtype_t oldtype = op->contr->bowtype;
1320  static const char *const types[] = {
1321  "normal",
1322  "threewide",
1323  "spreadshot",
1324  "firenorth",
1325  "firene",
1326  "fireeast",
1327  "firese",
1328  "firesouth",
1329  "firesw",
1330  "firewest",
1331  "firenw",
1332  "bestarrow"
1333  };
1334  int i, found;
1335 
1336  if (*params == '\0') {
1338  "bowmode is set to %s",
1339  types[op->contr->bowtype]);
1340  return;
1341  }
1342 
1343  for (i = 0, found = 0; i <= bow_bestarrow; i++) {
1344  if (!strcmp(params, types[i])) {
1345  found++;
1346  op->contr->bowtype = static_cast<bowtype_t>(i);
1347  break;
1348  }
1349  }
1350  if (!found) {
1352  stringbuffer_append_printf(buf, "bowmode: Unknown options %s, valid options are:", params);
1353  for (i = 0; i <= bow_bestarrow; i++) {
1356  if (i < bow_nw)
1358  else
1360  }
1361  char *result = stringbuffer_finish(buf);
1363  free(result);
1364  return;
1365  }
1367  "bowmode%s set to %s",
1368  (oldtype == op->contr->bowtype ? "" : " now"),
1369  types[op->contr->bowtype]);
1370  return;
1371 }
1372 
1381 void command_unarmed_skill(object *op, const char *params) {
1382  object *skill;
1383  size_t i;
1384 
1385  if (*params == '\0') {
1387  "unarmed skill is set to %s",
1388  op->contr->unarmed_skill ? op->contr->unarmed_skill: "nothing");
1389  return;
1390  }
1391 
1392  /* find_skill_by_name() will ready any skill tools - which
1393  * is OK for us because no unarmed skills require skill tools,
1394  * but this could be an issue if you reuse this code for other skills.
1395  */
1396  skill = find_skill_by_name(op, params);
1397 
1398  if (!skill) {
1400  "You do not know any such skill called %s",
1401  params);
1402  return;
1403  }
1404  for (i = 0; i < sizeof(unarmed_skills); i++)
1405  if (skill->subtype == unarmed_skills[i])
1406  break;
1407  if (i == sizeof(unarmed_skills)) {
1409  "%s is not an unarmed skill!",
1410  skill->name);
1411  return;
1412 
1413  }
1414 
1415  if (op->contr->unarmed_skill)
1417 
1418  /* Taking actual skill name is better than taking params,
1419  * as params could be something more than an exact skill name.
1420  */
1421  op->contr->unarmed_skill = add_string(skill->name);
1422 
1424  "unarmed skill is now set to %s",
1425  op->contr->unarmed_skill);
1426 }
1427 
1428 
1437 void command_petmode(object *op, const char *params) {
1438  petmode_t oldtype = op->contr->petmode;
1439  static const char *const types[] = {
1440  "normal",
1441  "sad",
1442  "defend",
1443  "arena"
1444  };
1445 
1446  if (*params == '\0') {
1448  "petmode is set to %s",
1449  types[op->contr->petmode]);
1450  return;
1451  }
1452 
1453  if (!strcmp(params, "normal"))
1454  op->contr->petmode = pet_normal;
1455  else if (!strcmp(params, "sad"))
1456  op->contr->petmode = pet_sad;
1457  else if (!strcmp(params, "defend"))
1458  op->contr->petmode = pet_defend;
1459  else if (!strcmp(params, "arena"))
1460  op->contr->petmode = pet_arena;
1461  else {
1463  "petmode: Unknown options %s, valid options are normal, sad (seek and destroy), defend, arena",
1464  params);
1465  return;
1466  }
1468  "petmode%s set to %s",
1469  (oldtype == op->contr->petmode ? "" : " now"),
1470  types[op->contr->petmode]);
1471 }
1472 
1481 void command_showpets(object *op, const char *params) {
1482  objectlink *obl, *list;
1483  int counter = 0, target = 0;
1484  int have_shown_pet = 0;
1485  if (*params != '\0')
1486  target = atoi(params);
1487 
1488  list = get_friends_of(op);
1489 
1490  for (obl = list; obl != NULL; obl = obl->next) {
1491  object *ob = obl->ob;
1492 
1493  if (target == 0) {
1494  if (counter == 0)
1496  "Pets:");
1498  "%d %s - level %d",
1499  ++counter, ob->name, ob->level);
1500  } else if (!have_shown_pet && ++counter == target) {
1502  "[fixed]level %d %s",
1503  ob->level, ob->name);
1505  "[fixed]%d/%d HP, %d/%d SP",
1506  ob->stats.hp, ob->stats.maxhp, ob->stats.sp, ob->stats.maxsp);
1507 
1508  /* this is not a nice way to do this, it should be made to be more like the statistics command */
1510  "[fixed]Str %d",
1511  ob->stats.Str);
1513  "[fixed]Dex %d",
1514  ob->stats.Dex);
1516  "[fixed]Con %d",
1517  ob->stats.Con);
1519  "[fixed]Int %d",
1520  ob->stats.Int);
1522  "[fixed]Wis %d",
1523  ob->stats.Wis);
1525  "[fixed]Cha %d",
1526  ob->stats.Cha);
1528  "[fixed]Pow %d",
1529  ob->stats.Pow);
1531  "[fixed]wc %d damage %d ac %d",
1532  ob->stats.wc, ob->stats.dam, ob->stats.ac);
1533  have_shown_pet = 1;
1534  }
1535  }
1536  if (list) {
1538  }
1539 
1540  if (counter == 0)
1542  "You have no pets.");
1543  else if (target != 0 && have_shown_pet == 0)
1545  "No such pet.");
1546 }
1547 
1556 void command_usekeys(object *op, const char *params) {
1557  usekeytype oldtype = op->contr->usekeys;
1558  static const char *const types[] = {
1559  "inventory",
1560  "keyrings",
1561  "containers"
1562  };
1563 
1564  if (*params == '\0') {
1566  "usekeys is set to %s",
1567  types[op->contr->usekeys]);
1568  return;
1569  }
1570 
1571  if (!strcmp(params, "inventory"))
1572  op->contr->usekeys = key_inventory;
1573  else if (!strcmp(params, "keyrings"))
1574  op->contr->usekeys = keyrings;
1575  else if (!strcmp(params, "containers"))
1576  op->contr->usekeys = containers;
1577  else {
1579  "usekeys: Unknown option %s, valid options are inventory, keyrings, containers",
1580  params);
1581  return;
1582  }
1584  "usekeys%s set to %s",
1585  (oldtype == op->contr->usekeys ? "" : " now"),
1586  types[op->contr->usekeys]);
1587 }
1588 
1597 void command_resistances(object *op, const char *params) {
1598  int i;
1599  (void)params;
1600  if (!op)
1601  return;
1602 
1603  for (i = 0; i < NROFATTACKS; i++) {
1604  if (i == ATNR_INTERNAL)
1605  continue;
1606 
1608  "[fixed]%-20s %+5d",
1609  attacktype_desc[i], op->resist[i]);
1610  }
1611 
1612  /* If dragon player, let's display natural resistances */
1613  if (is_dragon_pl(op)) {
1614  int attack;
1615  object *tmp;
1616 
1617  tmp = object_find_by_type_and_arch_name(op, FORCE, "dragon_skin_force");
1618  if (tmp != NULL) {
1620  "\nNatural skin resistances:");
1621 
1622  for (attack = 0; attack < NROFATTACKS; attack++) {
1623  if (atnr_is_dragon_enabled(attack)) {
1625  "%s: %d",
1626  change_resist_msg[attack], tmp->resist[attack]);
1627  }
1628  }
1629  }
1630  }
1631 }
1632 
1643 static void help_topics(object *op, int what) {
1644  DIR *dirp;
1645  struct dirent *de;
1646  char filename[MAX_BUF], line[HUGE_BUF];
1647  char suffix[MAX_BUF];
1648  int namelen;
1649  const char *language;
1650 
1651  language = i18n_get_language_code(op->contr->language);
1652  snprintf(suffix, sizeof(suffix), ".%s", language);
1653 
1654  switch (what) {
1655  case 1:
1656  snprintf(filename, sizeof(filename), "%s/wizhelp", settings.datadir);
1658  " Wiz commands:");
1659  break;
1660 
1661  case 3:
1662  snprintf(filename, sizeof(filename), "%s/mischelp", settings.datadir);
1664  " Misc help:");
1665  break;
1666 
1667  default:
1668  snprintf(filename, sizeof(filename), "%s/help", settings.datadir);
1670  " Commands:");
1671  break;
1672  }
1673  if (!(dirp = opendir(filename)))
1674  return;
1675 
1676  line[0] = '\0';
1677  for (de = readdir(dirp); de; de = readdir(dirp)) {
1678  namelen = NAMLEN(de);
1679 
1680  if (namelen <= 2
1681  && *de->d_name == '.'
1682  && (namelen == 1 || de->d_name[1] == '.'))
1683  continue;
1684  if (strstr(de->d_name, suffix)) {
1685  strcat(line, strtok(de->d_name, "."));
1686  strcat(line, " ");
1687  }
1688  }
1690  line);
1691  closedir(dirp);
1692 }
1693 
1703 static int find_help_file_in(const char *dir, const char *name, const char *language, char *path, int length) {
1704  struct stat st;
1705 
1706  snprintf(path, length, "%s/%s/%s.%s", settings.datadir, dir, name, language);
1707  if (stat(path, &st) == 0 && S_ISREG(st.st_mode)) {
1708  return 1;
1709  }
1710  return 0;
1711 }
1712 
1726 static int find_help_file(const char *name, const char *language, int wiz, char *path, int length) {
1727  if (wiz) {
1728  if (find_help_file_in("wizhelp", name, language, path, length))
1729  return 1;
1730  if (strcmp(language, "en") && find_help_file_in("wizhelp", name, "en", path, length))
1731  return 1;
1732  }
1733 
1734  if (find_help_file_in("help", name, language, path, length))
1735  return 1;
1736  if (strcmp(language, "en") && find_help_file_in("help", name, "en", path, length))
1737  return 1;
1738 
1739  return 0;
1740 }
1741 
1749 static void display_help_file(object *op, const char *filename) {
1750  BufferReader *br;
1751  const char *line;
1752 
1753  if ((br = bufferreader_init_from_file(NULL, filename, "Cannot open help file %s: %s\n", llevError)) == NULL) {
1754  return;
1755  }
1756 
1757  while ((line = bufferreader_next_line(br))) {
1759  }
1760 
1762 }
1763 
1772 void command_help(object *op, const char *params) {
1773  char filename[MAX_BUF];
1774  const char *language;
1775 
1776  /*
1777  * Main help page?
1778  */
1779  if (*params == '\0') {
1780  snprintf(filename, sizeof(filename), "%s/def_help", settings.datadir);
1781  display_help_file(op, filename);
1782  return;
1783  }
1784 
1785  /*
1786  * Topics list
1787  */
1788  if (!strcmp(params, "topics")) {
1789  help_topics(op, 3);
1790  help_topics(op, 0);
1791  if (QUERY_FLAG(op, FLAG_WIZ))
1792  help_topics(op, 1);
1793  return;
1794  }
1795 
1796  /*
1797  * Commands list
1798  */
1799  if (!strcmp(params, "commands")) {
1800  command_list(op, QUERY_FLAG(op, FLAG_WIZ));
1801  return;
1802  }
1803 
1804  /*
1805  * User wants info about command
1806  */
1807  if (strchr(params, '.') || strchr(params, ' ') || strchr(params, '/')) {
1809  "Illegal characters in '%s'",
1810  params);
1811  return;
1812  }
1813 
1814  language = i18n_get_language_code(op->contr->language);
1815 
1816  if (!find_help_file(params, language, QUERY_FLAG(op, FLAG_WIZ), filename, sizeof(filename))) {
1818  "No help available on '%s'",
1819  params);
1820  return;
1821  }
1822 
1823  /*
1824  * Found that. Just cat it to screen.
1825  */
1826  display_help_file(op, filename);
1827 }
1828 
1839 static int onoff_value(const char *line) {
1840  int i;
1841 
1842  if (sscanf(line, "%d", &i))
1843  return (i != 0);
1844 
1845  switch (line[0]) {
1846  case 'o':
1847  switch (line[1]) {
1848  case 'n':
1849  return 1; /* on */
1850  default:
1851  return 0; /* o[ff] */
1852  }
1853 
1854  case 'y': /* y[es] */
1855  case 'k': /* k[ylla] */
1856  case 's':
1857  case 'd':
1858  return 1;
1859 
1860  case 'n': /* n[o] */
1861  case 'e': /* e[i] */
1862  case 'u':
1863  default:
1864  return 0;
1865  }
1866 }
1867 
1873 void command_quit(object* op, const char* params) {
1874  (void)params;
1875  draw_ext_info(
1877  "To leave the game, sleep in (apply) a bed to reality. To "
1878  "permenantly delete your character, use the 'delete' command.");
1879 }
1880 
1889 void command_delete(object *op, const char *params) {
1890  (void)params;
1891  if (QUERY_FLAG(op, FLAG_WIZ)) {
1892  draw_ext_info(NDI_UNIQUE, 0, op, MSG_TYPE_COMMAND, MSG_TYPE_ADMIN_DM, "Can't quit when in DM mode.");
1893  return;
1894  }
1895 
1897  i18n(op, "Quitting will delete your character.\nAre you sure you want to delete your character (y/n):"));
1898 
1900 }
1901 
1910 void command_sound(object *op, const char *params) {
1911  (void)params;
1912  if (!(op->contr->socket->sound&SND_MUTE)) {
1913  op->contr->socket->sound = op->contr->socket->sound|SND_MUTE;
1915  "Sounds are turned off.");
1916  } else {
1917  op->contr->socket->sound = op->contr->socket->sound&~SND_MUTE;
1919  "The sounds are enabled.");
1920  }
1921  return;
1922 }
1923 
1935 void receive_player_name(object *op, const char *name) {
1936  if (!check_name(op->contr, name)) {
1937  get_name(op);
1938  return;
1939  }
1940  FREE_AND_COPY(op->name, name);
1941  FREE_AND_COPY(op->name_pl, name);
1943  op->contr->name_changed = 1;
1944  get_password(op);
1945 }
1946 
1955 void receive_player_password(object *op, const char *password) {
1956  unsigned int pwd_len = strlen(password);
1957 
1958  if (pwd_len == 0 || pwd_len > 16) {
1959  if (op->contr->state == ST_CHANGE_PASSWORD_OLD
1961  || op->contr->state == ST_CHANGE_PASSWORD_CONFIRM) {
1963  "Password changed cancelled.");
1965  } else
1966  get_name(op);
1967  return;
1968  }
1969  /* To hide the password better */
1970  /* With currently clients, not sure if this is really the case - MSW */
1972 
1973  if (checkbanned(op->name, op->contr->socket->host)) {
1974  LOG(llevInfo, "Banned player tried to add: [%s@%s]\n", op->name, op->contr->socket->host);
1976  "You are not allowed to play.");
1977  get_name(op);
1978  return;
1979  }
1980 
1981  if (op->contr->state == ST_CONFIRM_PASSWORD) {
1982  if (!check_password(password, op->contr->password)) {
1984  "The passwords did not match.");
1985  get_name(op);
1986  return;
1987  }
1988  LOG(llevInfo, "LOGIN: New player named %s from ip %s\n", op->name, op->contr->socket->host);
1989  display_motd(op);
1991  "\nWelcome, Brave New Warrior!\n");
1992  roll_again(op);
1994  return;
1995  }
1996 
1997  if (op->contr->state == ST_CHANGE_PASSWORD_OLD) {
1998  if (!check_password(password, op->contr->password)) {
2000  "You entered the wrong current password.");
2002  } else {
2003  send_query(op->contr->socket, CS_QUERY_HIDEINPUT, i18n(op, "Please enter your new password, or blank to cancel:"));
2005  }
2006  return;
2007  }
2008 
2009  if (op->contr->state == ST_CHANGE_PASSWORD_NEW) {
2010  safe_strncpy(op->contr->new_password, newhash(password),
2011  sizeof(op->contr->new_password));
2013  i18n(op, "Please confirm your new password, or blank to cancel:"));
2015  return;
2016  }
2017 
2018  if (op->contr->state == ST_CHANGE_PASSWORD_CONFIRM) {
2019  if (!check_password(password, op->contr->new_password)) {
2021  "The new passwords don't match!");
2022  } else {
2024  "Password changed.");
2025  strncpy(op->contr->password, op->contr->new_password, 13);
2026  }
2028  return;
2029  }
2030 
2031  safe_strncpy(op->contr->password, newhash(password),
2032  sizeof(op->contr->password));
2034  check_login(op, password);
2035 }
2036 
2047 void command_title(object *op, const char *params) {
2048  char buf[HUGE_BUF];
2049 
2050  if (settings.set_title == FALSE) {
2052  "You cannot change your title.");
2053  return;
2054  }
2055 
2056  /* dragon players cannot change titles */
2057  if (is_dragon_pl(op)) {
2059  "Dragons cannot change titles.");
2060  return;
2061  }
2062 
2063  if (*params == '\0') {
2064  char tmp[MAX_BUF];
2065 
2066  player_get_title(op->contr, tmp, sizeof(tmp));
2067  snprintf(buf, sizeof(buf), "Your title is '%s'.", tmp);
2069  return;
2070  }
2071  if (strcmp(params, "clear") == 0 || strcmp(params, "default") == 0) {
2072  if (!player_has_own_title(op->contr))
2074  "Your title is the default title.");
2075  else
2077  "Title set to default.");
2078  player_set_own_title(op->contr, "");
2079  return;
2080  }
2081 
2082  if ((int)strlen(params) >= MAX_NAME) {
2084  "Title too long.");
2085  return;
2086  }
2087  player_set_own_title(op->contr, params);
2088 }
2089 
2098 void command_save(object *op, const char *params) {
2099  (void)params;
2100  if (get_map_flags(op->map, NULL, op->x, op->y, NULL, NULL)&P_NO_CLERIC) {
2102  "You can not save on unholy ground.");
2103  } else if (!op->stats.exp) {
2105  "You don't deserve to save yet.");
2106  } else {
2107  if (save_player(op, 1))
2109  "You have been saved.");
2110  else
2112  "SAVE FAILED!");
2113  }
2114 }
2115 
2124 void command_peaceful(object *op, const char *params) {
2125  (void)params;
2126  if ((op->contr->peaceful = !op->contr->peaceful))
2128  "You will not attack other players.");
2129  else
2131  "You will attack other players.");
2132 }
2133 
2142 void command_wimpy(object *op, const char *params) {
2143  int i;
2144 
2145  if (*params == '\0' || !sscanf(params, "%d", &i)) {
2147  "Your current wimpy level is %d.",
2148  op->run_away);
2149  return;
2150  }
2151 
2152  if (i < 0 || i > 100) {
2154  "Wimpy level must be between 1 and 100.");
2155  return;
2156  }
2157 
2159  "Your new wimpy level is %d.",
2160  i);
2161  op->run_away = i;
2162 }
2163 
2172 void command_brace(object *op, const char *params) {
2173  if (*params == '\0')
2174  op->contr->braced = !op->contr->braced;
2175  else
2176  op->contr->braced = onoff_value(params);
2177 
2178  if (op->contr->braced)
2180  "You are braced.");
2181  else
2183  "Not braced.");
2184 
2185  fix_object(op);
2186 }
2187 
2196 void command_kill_pets(object *op, const char *params) {
2197  if (*params == '\0') {
2198  pets_terminate_all(op);
2200  "Your pets have been killed.");
2201  } else {
2202  objectlink *obl, *list = get_friends_of(op);
2203  int counter = 0, removecount = 0;
2204  int target = atoi(params);
2205 
2206  for (obl = list; obl != NULL; obl = obl->next) {
2207  object *ob = obl->ob;
2208  if (object_get_owner(ob) == op) {
2209  if (++counter == target || (target == 0 && !strcasecmp(ob->name, params))) {
2210  pets_terminate(ob);
2211  removecount++;
2212  }
2213  }
2214  }
2215  if (list) {
2217  }
2218  if (removecount != 0)
2220  "Killed %d pets.",
2221  removecount);
2222  else
2224  "Couldn't find any suitable pets to kill.");
2225  }
2226 }
2227 
2236 void command_passwd(object *pl, const char *params) {
2237  (void)params;
2238  /* If old client, this is the way you change your password. */
2239  if (pl->contr->socket->login_method < 1){
2240  send_query(pl->contr->socket, CS_QUERY_HIDEINPUT, i18n(pl, "Password change.\nPlease enter your current password, or empty string to cancel."));
2241 
2243  }
2244  /* If new client (login_method = 2) or jxclient (login_method = 1), changing the password does nothing anyway, so error out */
2245  else{
2247  "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.");
2248  }
2249 }
2250 
2260 void do_harvest(object *pl, int dir, object *skill) {
2261  int16_t x, y;
2262  int level, exp, check_exhaust = 0;
2263  const int max_harvest = 10;
2264  object *found[max_harvest]; /* Found items that can be harvested. */
2265  mapstruct *map;
2266  object *item, *inv, *harvested;
2267  sstring trace, ttool, tspeed, race, tool, slevel, sexp;
2268  float speed;
2269 
2270  x = pl->x+freearr_x[dir];
2271  y = pl->y+freearr_y[dir];
2272  map = pl->map;
2273 
2274  if (!IS_PLAYER(pl))
2275  return;
2276 
2277  if (!map)
2278  return;
2279 
2280  if (get_map_flags(map, &map, x, y, &x, &y)&P_OUT_OF_MAP) {
2281  draw_ext_info_format(NDI_WHITE, 0, pl, MSG_TYPE_SKILL, MSG_TYPE_SKILL_FAILURE, i18n(pl, "You cannot %s here."), skill->slaying);
2282  return;
2283  }
2284 
2285  if (!pl->chosen_skill || pl->chosen_skill->skill != skill->skill)
2286  return;
2287 
2288  trace = object_get_value(pl->chosen_skill, "harvest_race");
2289  ttool = object_get_value(pl->chosen_skill, "harvest_tool");
2290  tspeed = object_get_value(pl->chosen_skill, "harvest_speed");
2291  if (!trace || strcmp(trace, "") == 0 || !ttool || strcmp(ttool, "") == 0 || !tspeed || strcmp(tspeed, "") == 0) {
2292  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);
2293  LOG(llevError, "do_harvest: tool %s without harvest_[race|tool|speed]\n", pl->chosen_skill->name);
2294  return;
2295  }
2296 
2297  int count = 0; // number of harvested items
2298  FOR_MAP_PREPARE(map, x, y, item) {
2299  if (!LOOK_OBJ(item))
2300  continue;
2301  // do not skip floors, because you can harvest from mountains/lakes
2316  const char* harvestitems;
2317  if ((harvestitems = object_get_value(item, "harvestitems"))) {
2318  struct treasurelist* t = find_treasurelist(harvestitems);
2319  if (t) {
2320  create_treasure(t, item, 0, map->difficulty, 0);
2321  }
2322  object_set_value(item, "harvestitems", NULL, false);
2323  }
2324 
2325  FOR_INV_PREPARE(item, inv) {
2326  if (object_value_set(inv, "harvestable") == false)
2327  continue;
2328  race = object_get_value(inv, "harvest_race");
2329  tool = object_get_value(inv, "harvest_tool");
2330  slevel = object_get_value(inv, "harvest_level");
2331  sexp = object_get_value(inv, "harvest_exp");
2332  if (race && (!slevel || !sexp)) {
2333  LOG(llevError, "do_harvest: item %s without harvest_[level|exp]\n", inv->name);
2334  continue;
2335  }
2336  if (race == trace && (!tool || tool == ttool))
2337  found[count++] = inv;
2338 
2339  if (count >= max_harvest)
2340  break;
2341  } FOR_INV_FINISH();
2342 
2343  if (count >= max_harvest)
2344  break;
2345  } FOR_MAP_FINISH();
2346  if (count == 0) {
2347  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);
2348  return;
2349  }
2350 
2351  assert(count <= max_harvest); // otherwise we have a stack overflow...
2352 
2353  inv = found[rndm(0, count-1)];
2354  assert(inv);
2355  item = inv->env;
2356  assert(item);
2357 
2358  slevel = object_get_value(inv, "harvest_level");
2359  sexp = object_get_value(inv, "harvest_exp");
2360  level = atoi(slevel);
2361  exp = atoi(sexp);
2362 
2363  speed = atof(tspeed);
2364  if (speed < 0)
2365  speed = -speed*pl->speed;
2366  pl->speed_left -= speed;
2367 
2368 
2369  /* Now we found something to harvest, randomly try to get it. */
2370  if (level > skill->level+10) {
2371  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);
2372  return;
2373  }
2374 
2375  int proba; /* Probability to get the item, 100 based. */
2376  if (level >= skill->level)
2377  /* Up to 10 more levels, 1 to 11 percent probability. */
2378  proba = 10+skill->level-level;
2379  else if (skill->level <= level+10)
2380  proba = 10+(skill->level-level)*2;
2381  else
2382  proba = 30;
2383 
2384  if (proba <= random_roll(0, 100, pl, 1)) {
2385  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);
2386  return;
2387  }
2388 
2389  /* Check the new item can fit into inventory.
2390  * Fixes bug #3060474: fishing puts more fishes into inventory than you can carry. */
2391  if (((uint32_t)(pl->weight + pl->carrying + inv->weight)) > get_weight_limit(pl->stats.Str)) {
2392  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);
2393  return;
2394  }
2395 
2396  /* Ok, got it. */
2397 
2398  /* If we have nrof 0, treat it like a singleton.
2399  * Old behavior was infinite here, and extremely abuseable.
2400  * Neila H. 2024-02-06
2401  */
2402  if (inv->nrof == 0) {
2403  check_exhaust = (count == 1 ? 1 : 0);
2404  object_remove(inv);
2405  harvested = inv;
2406  } else {
2407  if (count == 1 && inv->nrof == 1) {
2408  check_exhaust = 1;
2409  }
2410  if ( inv->nrof == 1 ) {
2411  /* Avoid dumping object inventory like a dead monster if it has an inventory */
2412  object_remove(inv);
2413  harvested = inv;
2414  }
2415  else {
2416  harvested = object_split(inv, 1, NULL, 0);
2417  }
2418  }
2419  object_set_value(harvested, "harvestable", NULL, 0);
2420  if (QUERY_FLAG(harvested, FLAG_MONSTER)) {
2421  int spot = object_find_free_spot(harvested, pl->map, pl->x, pl->y, 0, SIZEOFFREE);
2422  if (spot == -1) {
2423  /* Better luck next time...*/
2424  object_remove(harvested);
2425  draw_ext_info_format(NDI_WHITE, 0, pl, MSG_TYPE_SKILL, MSG_TYPE_SKILL_FAILURE, "You fail to %s anything.", skill->slaying);
2426  return;
2427  }
2428  object_insert_in_map_at(harvested, pl->map, NULL, 0, pl->x+freearr_x[spot], pl->y+freearr_y[spot]);
2429  draw_ext_info_format(NDI_WHITE, 0, pl, MSG_TYPE_SKILL, MSG_TYPE_SKILL_FAILURE, "You %s a %s!", skill->slaying, harvested->name);
2430  } else {
2431  harvested = object_insert_in_ob(harvested, pl);
2432  draw_ext_info_format(NDI_WHITE, 0, pl, MSG_TYPE_SKILL, MSG_TYPE_SKILL_FAILURE, "You %s some %s.", skill->slaying, harvested->name);
2433  }
2434 
2435  /* Get exp */
2436  change_exp(pl, exp, skill->name, SK_EXP_ADD_SKILL);
2437 
2438  if (check_exhaust) {
2439  sstring replacement = object_get_value(item, "harvest_exhaust_replacement");
2440  if (replacement) {
2441  if (replacement[0] != '-') {
2442  archetype *other = try_find_archetype(replacement);
2443  if (other) {
2444  object *final = object_create_arch(other);
2445  object_insert_in_map_at(final, map, item, INS_BELOW_ORIGINATOR, item->x, item->y);
2446  }
2447  }
2448  object_remove(item);
2450  }
2451  }
2452 
2453  return;
2454 }
AssetsCollection::count
size_t count() const
Get the number of assets.
Definition: AssetsCollection.h:80
object_value_set
bool object_value_set(const object *op, const char *const key)
Determine if an extra value is set.
Definition: object.cpp:4361
object::name_pl
sstring name_pl
The plural name of the object.
Definition: object.h:323
command_dumpallarchetypes
void command_dumpallarchetypes(object *op, const char *params)
Various archetypes-related statistics.
Definition: c_misc.cpp:1005
living::exp
int64_t exp
Experience.
Definition: living.h:47
object
Main Crossfire structure, one ingame object.
Definition: object.h:282
object_get_owner
object * object_get_owner(object *op)
Returns the object which this object marks as being the owner.
Definition: object.cpp:789
get_name_of_region_for_map
const char * get_name_of_region_for_map(const mapstruct *m)
Gets the name of a region for a map.
Definition: region.cpp:89
player::next
player * next
Pointer to next player, NULL if this is last.
Definition: player.h:108
global.h
nrofartifacts
long nrofartifacts
Only used in malloc_info().
Definition: init.cpp:116
first_player
player * first_player
First player.
Definition: init.cpp:106
settings
struct Settings settings
Global settings.
Definition: init.cpp:139
chars_names::login_order
int login_order
Definition: c_misc.cpp:522
safe_strncpy
#define safe_strncpy
Definition: compat.h:27
FOR_MAP_FINISH
#define FOR_MAP_FINISH()
Finishes FOR_MAP_PREPARE().
Definition: define.h:714
pets_terminate_all
void pets_terminate_all(object *owner)
Removes all pets someone owns.
Definition: pets.cpp:242
living::maxhp
int16_t maxhp
Max hit points.
Definition: living.h:41
object_count_active
int object_count_active(void)
Objects statistics.
Definition: object.cpp:1768
NUM_BODY_LOCATIONS
#define NUM_BODY_LOCATIONS
Number of body locations.
Definition: object.h:15
ATNR_INTERNAL
#define ATNR_INTERNAL
Definition: attack.h:70
player::unarmed_skill
const char * unarmed_skill
Prefered skill to use in unarmed combat.
Definition: player.h:223
command_list
void command_list(object *pl, bool is_dm)
Display the list of commands to a player.
Definition: commands.cpp:390
name_cmp
static int name_cmp(const chars_names *c1, const chars_names *c2)
Local function for qsort comparison.
Definition: c_misc.cpp:534
llevError
@ llevError
Error, serious thing.
Definition: logger.h:11
FABS
#define FABS(x)
Decstations have trouble with fabs()...
Definition: define.h:22
mapstruct::difficulty
uint16_t difficulty
What level the player should be to play here.
Definition: map.h:336
hiscore_display
void hiscore_display(object *op, int max, const char *match)
Displays the high score file.
Definition: hiscore.cpp:451
LOG
void LOG(LogLevel logLevel, const char *format,...)
Logs a message to stderr, or to file.
Definition: logger.cpp:58
language_t
void * language_t
Strings that should be manipulated through add_string() and free_string().
Definition: global.h:69
SET_FLAG
#define SET_FLAG(xyz, p)
Definition: define.h:369
send_news
void send_news(const object *op)
Send the news to a player.
Definition: player.cpp:206
get_region_by_name
region * get_region_by_name(const char *region_name)
Gets a region by name.
Definition: region.cpp:45
player
One player.
Definition: player.h:107
map_info
static void map_info(object *op, const char *search)
This is the 'maps' command.
Definition: c_misc.cpp:50
ss_dump_statistics
void ss_dump_statistics(char *buf, size_t size)
A call to this function will cause the statistics to be dumped into specified buffer.
Definition: shstr.cpp:337
dump_friendly_objects
void dump_friendly_objects(void)
Dumps all friendly objects.
Definition: friend.cpp:70
time_info
void time_info(object *op)
Players wants to know the time.
Definition: time.cpp:298
MSG_TYPE_SKILL
#define MSG_TYPE_SKILL
Messages related to skill use.
Definition: newclient.h:411
QUERY_FLAG
#define QUERY_FLAG(xyz, p)
Definition: define.h:371
receive_player_name
void receive_player_name(object *op, const char *name)
A player just entered her name.
Definition: c_misc.cpp:1935
newhash
char const * newhash(char const *password)
Definition: server.cpp:101
Settings::set_title
uint8_t set_title
Players can set thier title.
Definition: global.h:266
AssetsManager.h
socket_struct::sound
uint32_t sound
Client sound mode.
Definition: newserver.h:116
command_dumpallobjects
void command_dumpallobjects(object *op, const char *params)
Various object-related statistics.
Definition: c_misc.cpp:977
ST_CONFIRM_PASSWORD
#define ST_CONFIRM_PASSWORD
New character, confirm password.
Definition: define.h:532
stringbuffer_append_printf
void stringbuffer_append_printf(StringBuffer *sb, const char *format,...)
Append a formatted string to a string buffer instance.
Definition: stringbuffer.cpp:138
command_dumpallmaps
void command_dumpallmaps(object *op, const char *params)
Various map-related statistics.
Definition: c_misc.cpp:1047
FALSE
#define FALSE
Definition: compat.h:14
command_body
void command_body(object *op, const char *params)
This command dumps the body information for object *op.
Definition: c_misc.cpp:173
get_friends_of
objectlink * get_friends_of(const object *owner)
Get a list of friendly objects for the specified owner.
Definition: friend.cpp:117
bowtype_t
bowtype_t
Bow firing mode.
Definition: player.h:41
pet_defend
@ pet_defend
Stay close to the owner.
Definition: player.h:60
region_is_child_of_region
int region_is_child_of_region(const region *child, const region *r)
Checks if a region is a child of another.
Definition: region.cpp:182
Settings::datadir
const char * datadir
Read only data files.
Definition: global.h:249
object::arch
struct archetype * arch
Pointer to archetype.
Definition: object.h:424
P_NO_CLERIC
#define P_NO_CLERIC
No clerical spells cast here.
Definition: map.h:241
stringbuffer_new
StringBuffer * stringbuffer_new(void)
Create a new string buffer.
Definition: stringbuffer.cpp:57
FULL_VERSION
#define FULL_VERSION
Definition: version.h:4
object::speed
float speed
Frequency of object 'moves' relative to server tick rate.
Definition: object.h:337
command_showpets
void command_showpets(object *op, const char *params)
Players wants to know her pets.
Definition: c_misc.cpp:1481
living::Dex
int8_t Dex
Definition: living.h:36
object::x
int16_t x
Definition: object.h:335
player::peaceful
uint32_t peaceful
If set, won't attack friendly creatures.
Definition: player.h:148
player::ob
object * ob
The object representing the player.
Definition: player.h:179
object_dump_all
void object_dump_all(void)
Dumps all objects to console.
Definition: object.cpp:689
onoff_value
static int onoff_value(const char *line)
Utility function to convert a reply to a yes/no or on/off value.
Definition: c_misc.cpp:1839
FLAG_USE_ARMOUR
#define FLAG_USE_ARMOUR
(Monster) can wear armour/shield/helmet
Definition: define.h:282
object::speed_left
float speed_left
How much speed is left to spend this round.
Definition: object.h:338
MAP_IN_MEMORY
#define MAP_IN_MEMORY
Map is fully loaded.
Definition: map.h:129
AssetsManager::animations
AllAnimations * animations()
Get animations.
Definition: AssetsManager.h:49
object::map
struct mapstruct * map
Pointer to the map in which this object is present.
Definition: object.h:305
find_treasurelist
treasurelist * find_treasurelist(const char *name)
Search for the given treasurelist by name.
Definition: assets.cpp:253
object::expmul
double expmul
needed experience = (calc_exp*expmul) - means some races/classes can need less/more exp to gain level...
Definition: object.h:407
get_password
void get_password(object *op)
Waiting for the player's password.
Definition: player.cpp:898
ST_CHANGE_PASSWORD_NEW
#define ST_CHANGE_PASSWORD_NEW
Player is entering new password.
Definition: define.h:535
unarmed_skills
uint8_t unarmed_skills[UNARMED_SKILLS_COUNT]
Table of unarmed attack skills.
Definition: skills.cpp:31
player_set_own_title
void player_set_own_title(struct player *pl, const char *title)
Sets the custom title.
Definition: player.cpp:273
draw_ext_info_format
void draw_ext_info_format(int flags, int pri, const object *pl, uint8_t type, uint8_t subtype, const char *format,...) PRINTF_ARGS(6
command_statistics
void command_statistics(object *pl, const char *params)
Prints out some useful information for the character.
Definition: c_misc.cpp:1121
FLAG_WIZ
#define FLAG_WIZ
Object has special privilegies.
Definition: define.h:218
FLAG_AFK
#define FLAG_AFK
Player is AFK.
Definition: define.h:355
map_path
void map_path(const char *map, int flags, char *pathname, size_t bufsize)
Definition: map.cpp:1174
CS_QUERY_SINGLECHAR
#define CS_QUERY_SINGLECHAR
Single character response expected.
Definition: newclient.h:71
bufferreader_destroy
void bufferreader_destroy(BufferReader *br)
Destroy a BufferReader.
Definition: bufferreader.cpp:40
socket_struct::is_bot
uint32_t is_bot
Client shouldn't be reported to metaserver.
Definition: newserver.h:112
command_hiscore
void command_hiscore(object *op, const char *params)
Player is asking for the hiscore.
Definition: c_misc.cpp:881
MSG_TYPE_LAST
#define MSG_TYPE_LAST
Definition: newclient.h:422
object::count
tag_t count
Unique object number for this object.
Definition: object.h:307
player_has_own_title
int player_has_own_title(const struct player *pl)
Returns whether the player has a custom title.
Definition: player.cpp:248
command_kill_pets
void command_kill_pets(object *op, const char *params)
Player wants to get rid of pets.
Definition: c_misc.cpp:2196
ST_PLAYING
#define ST_PLAYING
Usual state.
Definition: define.h:525
fix_object
void fix_object(object *op)
Updates all abilities given by applied objects in the inventory of the given object.
Definition: living.cpp:1132
FREE_OBJ_FREE_INVENTORY
#define FREE_OBJ_FREE_INVENTORY
Free inventory objects; if not set, drop inventory.
Definition: object.h:544
artifactlist::next
artifactlist * next
Next list of artifacts.
Definition: artifact.h:27
NDI_RED
#define NDI_RED
Definition: newclient.h:249
dump_map
void dump_map(const mapstruct *m)
Prints out debug-information about a map.
Definition: map.cpp:245
command_rules
void command_rules(object *op, const char *params)
Display the server rules.
Definition: c_misc.cpp:228
command_ssdumptable
void command_ssdumptable(object *op, const char *params)
Various string-related statistics.
Definition: c_misc.cpp:1019
player::hidden
uint32_t hidden
If True, player (DM) is hidden from view.
Definition: player.h:149
region::name
char * name
Shortend name of the region as maps refer to it.
Definition: map.h:278
unapply_always
@ unapply_always
Will unapply whatever is necessary - this goes beyond no choice - if there are multiple ojbect of the...
Definition: player.h:78
NROFATTACKS
#define NROFATTACKS
Definition: attack.h:15
rndm
int rndm(int min, int max)
Returns a number between min and max.
Definition: utils.cpp:162
MSG_TYPE_COMMAND_ERROR
#define MSG_TYPE_COMMAND_ERROR
Bad syntax/can't use command.
Definition: newclient.h:533
partylist
One party.
Definition: party.h:10
mapstruct::path
char path[HUGE_BUF]
Filename of the map.
Definition: map.h:358
object::level
int16_t level
Level of creature or object.
Definition: object.h:361
bow_bestarrow
@ bow_bestarrow
Try to find an arrow matching the target.
Definition: player.h:53
buf
StringBuffer * buf
Definition: readable.cpp:1565
version.h
getManager
AssetsManager * getManager()
Definition: assets.cpp:309
object_insert_in_ob
object * object_insert_in_ob(object *op, object *where)
This function inserts the object op in the linked list inside the object environment.
Definition: object.cpp:2842
get_region_longname
const char * get_region_longname(const region *r)
Gets the longname of a region.
Definition: region.cpp:209
HUGE_BUF
#define HUGE_BUF
Used for messages - some can be quite long.
Definition: define.h:37
MSG_TYPE_COMMAND
#define MSG_TYPE_COMMAND
Responses to commands, eg, who.
Definition: newclient.h:408
shstr.h
object::resist
int16_t resist[NROFATTACKS]
Resistance adjustments for attacks.
Definition: object.h:351
name
Plugin animator file specs[Config] name
Definition: animfiles.txt:4
linked_char
Definition: global.h:98
ticks_to_seconds
float ticks_to_seconds(int ticks)
Definition: time.cpp:386
draw_ext_info
vs only yadda is in because all tags get reset on the next draw_ext_info In the second since it is all in one draw_ext_info
Definition: media-tags.txt:61
region::longname
char * longname
Official title of the region, this might be defined to be the same as name.
Definition: map.h:284
help_topics
static void help_topics(object *op, int what)
Player wants to know available help topics.
Definition: c_misc.cpp:1643
MSG_TYPE_ADMIN_DM
#define MSG_TYPE_ADMIN_DM
DM related admin actions.
Definition: newclient.h:501
object::carrying
int32_t carrying
How much weight this object contains.
Definition: object.h:377
LOOK_OBJ
#define LOOK_OBJ(ob)
This returns TRUE if the object is something that should be displayed in the look window.
Definition: object.h:521
st
Player Stats effect how well a character can survie and interact inside the crossfire world This section discusses the various what they and how they effect the player s actions Also in this section are the stat modifiers that specific classes professions bring Player and sps the current and maximum the Current and Maximum The Current Sp can go somewhat negative When Sp is negative not all spells can be and a more negative Sp makes spell casting less likey to succeed can affect Damage and how the characters as well as how often the character can attack this affects the prices when buying and selling items if this drops the player will start losing hit points wd Cleric or Dwarf sm Elf wd Fireborn ft Human ra Mage C Monk se Ninja hi Priest C Quetzalcoatl mw Swashbuckler st
Definition: stats.txt:110
command_debug
void command_debug(object *op, const char *params)
Player wants to see/change the debug level.
Definition: c_misc.cpp:893
object::y
int16_t y
Position in the map for this object.
Definition: object.h:335
command_time
void command_time(object *op, const char *params)
Players asks for the time.
Definition: c_misc.cpp:868
m
static event_registration m
Definition: citylife.cpp:424
pets_terminate
void pets_terminate(object *pet)
Removes a pet, taking care of clearning the owner's fields if needed.
Definition: pets.cpp:224
ST_CHANGE_PASSWORD_CONFIRM
#define ST_CHANGE_PASSWORD_CONFIRM
Player is confirming new password.
Definition: define.h:536
stringbuffer_finish
char * stringbuffer_finish(StringBuffer *sb)
Deallocate the string buffer instance and return the string.
Definition: stringbuffer.cpp:76
letter
**Media tags please refer to the protocol file in doc Developers protocol Quick for your pleasure an example[/b][i] This is an old letter
Definition: media-tags.txt:15
object::contr
struct player * contr
Pointer to the player which control this object.
Definition: object.h:284
bufferreader_init_from_file
BufferReader * bufferreader_init_from_file(BufferReader *br, const char *filepath, const char *failureMessage, LogLevel failureLevel)
Initialize or create a BufferReader from a file path.
Definition: bufferreader.cpp:65
command_news
void command_news(object *op, const char *params)
Display the server news.
Definition: c_misc.cpp:241
MAP_MINTIMEOUT
#define MAP_MINTIMEOUT
At least that many ticks before swapout.
Definition: config.h:409
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
map_size
uint32_t map_size(mapstruct *m)
Calculate map size without intermediate sign extension.
Definition: map.cpp:808
object::chosen_skill
object * chosen_skill
The skill chosen to use.
Definition: object.h:396
nrofallowedstr
long nrofallowedstr
Only used in malloc_info().
Definition: init.cpp:117
Settings::debug
LogLevel debug
Default debugging level.
Definition: global.h:244
send_rules
void send_rules(const object *op)
Send the rules to a player.
Definition: player.cpp:170
display_who_entry
static void display_who_entry(object *op, player *pl, const char *format)
Display a line of 'who' to op, about pl, using the formatting specified by format.
Definition: c_misc.cpp:640
current_region_info
static void current_region_info(object *op)
'whereami' command.
Definition: c_misc.cpp:405
freearr_y
short freearr_y[SIZEOFFREE]
Y offset when searching around a spot.
Definition: object.cpp:305
command_malloc
void command_malloc(object *op, const char *params)
Display memory information.
Definition: c_misc.cpp:796
i18n_get_language_code
sstring i18n_get_language_code(language_t language)
Return the code of a specified language.
Definition: languages.cpp:86
SS_DUMP_TABLE
#define SS_DUMP_TABLE
Definition: shstr.h:46
check_login
void check_login(object *op, const char *password)
Actually login a player, load from disk and such.
Definition: login.cpp:522
object::weapon_speed
float weapon_speed
The overall speed of this object.
Definition: object.h:339
list_players
void list_players(object *op, region *reg, partylist *party)
Displays the players in a region or party.
Definition: c_misc.cpp:548
unapplymode
unapplymode
This is used to control what to do when we need to unapply an object before we can apply another one.
Definition: player.h:75
treasurelist
treasurelist represents one logical group of items to be generated together.
Definition: treasure.h:85
split_string
size_t split_string(char *str, char *array[], size_t array_size, char sep)
Splits a string delimited by passed in sep value into characters into an array of strings.
Definition: utils.cpp:473
command_dumpfriendlyobjects
void command_dumpfriendlyobjects(object *op, const char *params)
Various friendly object-related statistics.
Definition: c_misc.cpp:991
archetype::clone
object clone
An object from which to do object_copy()
Definition: object.h:487
object::run_away
uint8_t run_away
Monster runs away if it's hp goes below this percentage.
Definition: object.h:394
command_language
void command_language(object *op, const char *params)
This is the 'language' command.
Definition: c_misc.cpp:130
command_petmode
void command_petmode(object *op, const char *params)
Player wants to change how her pets behave.
Definition: c_misc.cpp:1437
MSG_TYPE_COMMAND_INFO
#define MSG_TYPE_COMMAND_INFO
Generic info: resistances, etc.
Definition: newclient.h:530
add_string
sstring add_string(const char *str)
Share a string.
Definition: shstr.cpp:137
speed
Player Stats effect how well a character can survie and interact inside the crossfire world This section discusses the various what they and how they effect the player s actions Also in this section are the stat modifiers that specific classes professions bring Player and sps the current and maximum the Current and Maximum The Current Sp can go somewhat negative When Sp is negative not all spells can be and a more negative Sp makes spell casting less likey to succeed can affect Damage and how the characters speed
Definition: stats.txt:23
FLAG_MONSTER
#define FLAG_MONSTER
Will attack players.
Definition: define.h:232
object_count_free
int object_count_free(void)
Objects statistics.
Definition: object.cpp:1736
first_map
mapstruct * first_map
First map.
Definition: init.cpp:107
get_region_msg
const char * get_region_msg(const region *r)
Gets a message for a region.
Definition: region.cpp:230
display_motd
void display_motd(const object *op)
Sends the message of the day to the player.
Definition: player.cpp:139
petmode_t
petmode_t
Petmode.
Definition: player.h:57
MAP_WHEN_RESET
#define MAP_WHEN_RESET(m)
This is when the map will reset.
Definition: map.h:65
readdir
struct dirent * readdir(DIR *)
MSG_TYPE_COMMAND_MALLOC
#define MSG_TYPE_COMMAND_MALLOC
Definition: newclient.h:526
socket_struct::host
char * host
Which host it is connected from (ip address).
Definition: newserver.h:104
command_passwd
void command_passwd(object *pl, const char *params)
Player is asking to change password.
Definition: c_misc.cpp:2236
MSG_TYPE_COMMAND_STATISTICS
#define MSG_TYPE_COMMAND_STATISTICS
Definition: newclient.h:528
change_resist_msg
const char *const change_resist_msg[NROFATTACKS]
These are the descriptions of the resistances displayed when a player puts on/takes off an item.
Definition: init.cpp:70
ST_ROLL_STAT
#define ST_ROLL_STAT
New character, rolling stats.
Definition: define.h:527
FREE_AND_COPY
#define FREE_AND_COPY(sv, nv)
Release the shared string if not NULL, and make it a reference to nv.
Definition: global.h:206
living::dam
int16_t dam
How much damage this object does when hitting.
Definition: living.h:46
t
in that case they will be relative to whatever the PWD of the crossfire server process is You probably shouldn t
Definition: server-directories.txt:28
bow_nw
@ bow_nw
Fire north-west whatever the facing direction.
Definition: player.h:52
object_create_arch
object * object_create_arch(archetype *at)
Create a full object using the given archetype.
Definition: arch.cpp:296
do_harvest
void do_harvest(object *pl, int dir, object *skill)
Player is trying to harvest something.
Definition: c_misc.cpp:2260
command_quit
void command_quit(object *op, const char *params)
Tell players to use the 'delete' command.
Definition: c_misc.cpp:1873
object_free
void object_free(object *ob, int flags)
Frees everything allocated by an object, removes it from the list of used objects,...
Definition: object.cpp:1577
find_help_file_in
static int find_help_file_in(const char *dir, const char *name, const char *language, char *path, int length)
Find a (help) file in the specified subdirectory of data.
Definition: c_misc.cpp:1703
artifactlist
This represents all archetypes for one particular object type.
Definition: artifact.h:24
FOR_INV_FINISH
#define FOR_INV_FINISH()
Finishes FOR_INV_PREPARE().
Definition: define.h:661
MAX_NAME
#define MAX_NAME
Definition: define.h:41
command_applymode
void command_applymode(object *op, const char *params)
Players wants to change the apply mode, ie how to handle applying an item when no body slot available...
Definition: c_misc.cpp:1277
change_exp
void change_exp(object *op, int64_t exp, const char *skill_name, int flag)
Changes experience to a player/monster.
Definition: living.cpp:2179
ST_CONFIRM_QUIT
#define ST_CONFIRM_QUIT
Player used the 'quit' command, make sure that's ok.
Definition: define.h:529
level_exp
int64_t level_exp(int level, double expmul)
Returns how much experience is needed for a player to become the given level.
Definition: living.cpp:1885
body_locations
body_locations_struct body_locations[NUM_BODY_LOCATIONS]
The ordering of this is actually doesn't make a difference However, for ease of use,...
Definition: item.cpp:56
archetype
The archetype structure is a set of rules on how to generate and manipulate objects which point to ar...
Definition: object.h:483
display_help_file
static void display_help_file(object *op, const char *filename)
Attempt to send the contents of the specified file to the player.
Definition: c_misc.cpp:1749
P_OUT_OF_MAP
#define P_OUT_OF_MAP
This space is outside the map.
Definition: map.h:252
sproto.h
command_strings
void command_strings(object *op, const char *params)
Various string-related statistics.
Definition: c_misc.cpp:847
ss_dump_table
char * ss_dump_table(int what, char *buf, size_t size)
Dump the contents of the share string tables.
Definition: shstr.cpp:368
living::sp
int16_t sp
Spell points.
Definition: living.h:42
SND_MUTE
#define SND_MUTE
Don't sent anything for now.
Definition: sounds.h:14
nrofallocobjects
int nrofallocobjects
How many OBs allocated (free + used)
Definition: object.cpp:291
stringbuffer_append_string
void stringbuffer_append_string(StringBuffer *sb, const char *str)
Append a string to a string buffer instance.
Definition: stringbuffer.cpp:95
chars_names::namebuf
char namebuf[MAX_BUF]
Definition: c_misc.cpp:521
MapSpace
This structure contains all information related to one map square.
Definition: map.h:259
living::Int
int8_t Int
Definition: living.h:36
random_roll
int random_roll(int min, int max, const object *op, int goodbad)
Roll a random number between min and max.
Definition: utils.cpp:42
command_usekeys
void command_usekeys(object *op, const char *params)
Player wants to change how keys are used.
Definition: c_misc.cpp:1556
command_whereabouts
void command_whereabouts(object *op, const char *params)
'whereabouts' command.
Definition: c_misc.cpp:482
MSG_SUBTYPE_NONE
#define MSG_SUBTYPE_NONE
Definition: newclient.h:424
partylist::partyname
char * partyname
Party name.
Definition: party.h:14
command_afk
void command_afk(object *op, const char *params)
Toggles the afk status of a player.
Definition: c_misc.cpp:775
command_sound
void command_sound(object *op, const char *params)
Player wants to change sound status.
Definition: c_misc.cpp:1910
command_save
void command_save(object *op, const char *params)
Player wants to get saved.
Definition: c_misc.cpp:2098
object_insert_in_map_at
object * object_insert_in_map_at(object *op, mapstruct *m, object *originator, int flag, int x, int y)
Same as object_insert_in_map() except it handle separate coordinates and do a clean job preparing mul...
Definition: object.cpp:2085
command_resistances
void command_resistances(object *op, const char *params)
Players wants to know her resistances.
Definition: c_misc.cpp:1597
key_inventory
@ key_inventory
Only use keys in inventory.
Definition: player.h:66
find_skill_by_name
object * find_skill_by_name(object *who, const char *name)
This returns the skill pointer of the given name (the one that accumulates exp, has the level,...
Definition: skill_util.cpp:209
seconds
long seconds(void)
Return wall clock time in seconds.
Definition: time.cpp:348
MAP_WIDTH
#define MAP_WIDTH(m)
Map width.
Definition: map.h:76
SIZEOFFREE
#define SIZEOFFREE
Definition: define.h:155
AssetsManager::archetypes
Archetypes * archetypes()
Get archetypes.
Definition: AssetsManager.h:44
FLAG_USE_WEAPON
#define FLAG_USE_WEAPON
(Monster) can wield weapons
Definition: define.h:283
MAX_BUF
#define MAX_BUF
Used for all kinds of things.
Definition: define.h:35
receive_player_password
void receive_player_password(object *op, const char *password)
A player just entered her password, including for changing it.
Definition: c_misc.cpp:1955
player::listening
uint8_t listening
Which priority will be used in info_all.
Definition: player.h:135
strlcpy
size_t strlcpy(char *dst, const char *src, size_t size)
Portable implementation of strlcpy(3).
Definition: porting.cpp:222
NAMLEN
#define NAMLEN(dirent)
Definition: global.h:213
checkbanned
int checkbanned(const char *login, const char *host)
Check if a player and/or host is banned.
Definition: ban.cpp:32
command_printlos
void command_printlos(object *op, const char *params)
Various LOS-related statistics.
Definition: c_misc.cpp:1061
player::orig_stats
living orig_stats
Permanent real stats of player.
Definition: player.h:169
set_map_reset_time
void set_map_reset_time(mapstruct *map)
Updates the map's timeout.
Definition: map.cpp:2262
get_weight_limit
uint32_t get_weight_limit(int stat)
Definition: living.cpp:2373
object::weight
int32_t weight
Attributes of the object.
Definition: object.h:375
nroffreeobjects
int nroffreeobjects
How many OBs allocated and free (free)
Definition: object.cpp:290
free_string
void free_string(sstring str)
This will reduce the refcount, and if it has reached 0, str will be freed.
Definition: shstr.cpp:294
pet_sad
@ pet_sad
Try to find enemies.
Definition: player.h:59
living::wc
int8_t wc
Weapon Class, lower WC increases probability of hitting.
Definition: living.h:37
player::unapply
unapplymode unapply
Method for auto unapply.
Definition: player.h:123
Settings::playerdir
const char * playerdir
Where the player files are.
Definition: global.h:251
IS_PLAYER
static bool IS_PLAYER(object *op)
Definition: object.h:609
StringBuffer
A buffer that will be expanded as content is added to it.
Definition: stringbuffer.cpp:25
print_los
void print_los(object *op)
Debug-routine which dumps the array which specifies the visible area of a player.
Definition: los.cpp:665
is_valid_types_gen.found
found
Definition: is_valid_types_gen.py:39
player::new_password
char new_password[16]
2 (seed) + 11 (crypted) + 1 (EOS) + 2 (safety) = 16
Definition: player.h:196
ST_CHANGE_PASSWORD_OLD
#define ST_CHANGE_PASSWORD_OLD
Player is entering old password to change password.
Definition: define.h:534
FOR_MAP_PREPARE
#define FOR_MAP_PREPARE(map_, mx_, my_, it_)
Constructs a loop iterating over all objects of a map tile.
Definition: define.h:707
command_delete
void command_delete(object *op, const char *params)
Player wants to totally delete her character.
Definition: c_misc.cpp:1889
living::Wis
int8_t Wis
Definition: living.h:36
region
This is a game region.
Definition: map.h:277
sounds.h
command_version
void command_version(object *op, const char *params)
Server version.
Definition: c_misc.cpp:1076
types
Crossfire Protocol which is used between clients and servers to play Crossfire This documentation is intended primarily for client implementers This manual is the collective result of various authors compiled over the course of many most of the time several years after the actual code was written As such it will surely contain omit certain important and possibly make life miserable many working open source server and client implementations of this protocol are available Fixes and improvements to this documentation are welcome History the communications plan was set to be a text based system It was up to the server and client to parse these messages and determine what to do These messages were assumed to be line per message At a reasonably early stage of Eric Anderson wrote a then the data itself you could send many data types
Definition: protocol.txt:32
llevInfo
@ llevInfo
Information.
Definition: logger.h:12
command_players
void command_players(object *op, const char *params)
Display all known players.
Definition: c_misc.cpp:1227
NDI_UNIQUE
#define NDI_UNIQUE
Print immediately, don't buffer.
Definition: newclient.h:266
all_regions
std::vector< region * > all_regions
Definition: init.cpp:108
object::name
sstring name
The name of the object, obviously...
Definition: object.h:319
attacktype_desc
const char *const attacktype_desc[NROFATTACKS]
Short description of names of the attacktypes.
Definition: init.cpp:40
chars_names
Utility structure for the 'who' command.
Definition: c_misc.cpp:520
MSG_TYPE_SKILL_FAILURE
#define MSG_TYPE_SKILL_FAILURE
Failure in using skill.
Definition: newclient.h:594
pet_normal
@ pet_normal
Standard mode/.
Definition: player.h:58
object_count_used
int object_count_used(void)
Object statistics.
Definition: object.cpp:1752
command_dumpmap
void command_dumpmap(object *op, const char *params)
Various map-related statistics.
Definition: c_misc.cpp:1033
Settings::who_wiz_format
char who_wiz_format[MAX_BUF]
The format that the who command should use when called by a dm.
Definition: global.h:278
is_dragon_pl
int is_dragon_pl(const object *op)
Checks if player is a dragon.
Definition: player.cpp:123
players
std::vector< archetype * > players
Definition: player.cpp:502
command_maps
void command_maps(object *op, const char *params)
'maps' command.
Definition: c_misc.cpp:835
unapply_nochoice
@ unapply_nochoice
Will unapply objects when there no choice to unapply.
Definition: player.h:76
get_map_flags
int get_map_flags(mapstruct *oldmap, mapstruct **newmap, int16_t x, int16_t y, int16_t *nx, int16_t *ny)
This rolls up wall, blocks_magic, blocks_view, etc, all into one function that just returns a P_.
Definition: map.cpp:300
living::maxsp
int16_t maxsp
Max spell points.
Definition: living.h:43
mapstruct
This is a game-map.
Definition: map.h:318
object::env
object * env
Pointer to the object which is the environment.
Definition: object.h:301
MSG_TYPE_COMMAND_BODY
#define MSG_TYPE_COMMAND_BODY
Definition: newclient.h:525
num_players
non standard information is not specified num_players
Definition: arch-handbook.txt:200
sstring
const typedef char * sstring
Definition: sstring.h:2
roll_again
void roll_again(object *op)
Ask the player what to do with the statistics.
Definition: player.cpp:1147
command_motd
void command_motd(object *op, const char *params)
Display the message of the day.
Definition: c_misc.cpp:215
living::Cha
int8_t Cha
Definition: living.h:36
assets_number_of_treasurelists
size_t assets_number_of_treasurelists()
Definition: assets.cpp:262
i18n_list_languages
void i18n_list_languages(object *who)
List all languages for who.
Definition: languages.cpp:96
object::skill
sstring skill
Name of the skill this object uses/grants.
Definition: object.h:329
player::language
language_t language
The language the player wishes to use.
Definition: player.h:222
object_split
object * object_split(object *orig_ob, uint32_t nr, char *err, size_t size)
object_split(ob,nr) splits up ob into two parts.
Definition: object.cpp:2622
player::state
uint8_t state
Input state of the player (name, password, etc).
Definition: player.h:133
command_brace
void command_brace(object *op, const char *params)
Player toggles her braced status.
Definition: c_misc.cpp:2172
mapstruct::name
char * name
Name of map as given by its creator.
Definition: map.h:321
object_find_free_spot
int object_find_free_spot(const object *ob, mapstruct *m, int x, int y, int start, int stop)
object_find_free_spot(object, map, x, y, start, stop) will search for a spot at the given map and coo...
Definition: object.cpp:3544
command_title
void command_title(object *op, const char *params)
Player wishes to change her title.
Definition: c_misc.cpp:2047
i18n_find_language_by_code
language_t i18n_find_language_by_code(const char *code)
Attempt to find the identifier of a language from its code.
Definition: languages.cpp:60
player::braced
uint32_t braced
Will not move if braced, only attack.
Definition: player.h:141
object_get_value
sstring object_get_value(const object *op, const char *const key)
Get an extra value by key.
Definition: object.cpp:4331
NDI_WHITE
#define NDI_WHITE
Definition: newclient.h:247
assets.h
pet_arena
@ pet_arena
Attack other players in arena.
Definition: player.h:61
CLEAR_FLAG
#define CLEAR_FLAG(xyz, p)
Definition: define.h:370
get_region_from_string
region * get_region_from_string(const char *name)
Tries to find a region that 'name' corresponds to.
Definition: region.cpp:116
living::ac
int8_t ac
Armor Class, lower AC increases probability of not getting hit.
Definition: living.h:38
tick_duration
uint32_t tick_duration
Gloabal variables:
Definition: time.cpp:35
MAP_HEIGHT
#define MAP_HEIGHT(m)
Map height.
Definition: map.h:78
MAP_ENTER_Y
#define MAP_ENTER_Y(m)
Default Y coordinate for map enter.
Definition: map.h:85
MSG_TYPE_COMMAND_CONFIG
#define MSG_TYPE_COMMAND_CONFIG
bowmode, petmode, applymode
Definition: newclient.h:529
atnr_is_dragon_enabled
int atnr_is_dragon_enabled(int attacknr)
Determine if the attacktype represented by the specified attack-number is enabled for dragon players.
Definition: player.cpp:104
command_who
void command_who(object *op, const char *params)
'who' command.
Definition: c_misc.cpp:623
object_find_by_type_and_arch_name
object * object_find_by_type_and_arch_name(const object *who, int type, const char *name)
Find object in inventory by type and archetype name.
Definition: object.cpp:4262
stats
Player Stats effect how well a character can survie and interact inside the crossfire world This section discusses the various stats
Definition: stats.txt:2
level
int level
Definition: readable.cpp:1563
player::party
partylist * party
Party this player is part of.
Definition: player.h:205
first_artifactlist
artifactlist * first_artifactlist
First artifact.
Definition: init.cpp:109
containers
@ containers
Use keys in inventory and active containers.
Definition: player.h:68
keyrings
@ keyrings
Use keys in inventory and active key rings.
Definition: player.h:67
MSG_TYPE_COMMAND_MAPS
#define MSG_TYPE_COMMAND_MAPS
Definition: newclient.h:524
FLAG_WIZCAST
#define FLAG_WIZCAST
The wizard can cast spells in no-magic area.
Definition: define.h:276
strcasecmp
int strcasecmp(const char *s1, const char *s2)
malloc_info
static void malloc_info(object *op)
Sends various memory-related statistics.
Definition: c_misc.cpp:252
find_help_file
static int find_help_file(const char *name, const char *language, int wiz, char *path, int length)
Find an appropriate help file.
Definition: c_misc.cpp:1726
object::body_info
int8_t body_info[NUM_BODY_LOCATIONS]
Body info as loaded from the file.
Definition: object.h:382
command_whereami
void command_whereami(object *op, const char *params)
'whereami' command.
Definition: c_misc.cpp:822
get_region_by_map
region * get_region_by_map(mapstruct *m)
Gets a region from a map.
Definition: region.cpp:71
command_help
void command_help(object *op, const char *params)
Player is asking for some help.
Definition: c_misc.cpp:1772
loader.h
command_bowmode
void command_bowmode(object *op, const char *params)
Player wants to change the bowmode, how arrows are fired.
Definition: c_misc.cpp:1318
save_player
int save_player(object *op, int flag)
Saves a player to disk.
Definition: login.cpp:239
command_wizpass
void command_wizpass(object *op, const char *params)
Wizard toggling wall-crossing.
Definition: c_misc.cpp:917
region::counter
uint32_t counter
A generic counter for holding temporary data.
Definition: map.h:287
skill
skill
Definition: arch-handbook.txt:585
current_map_info
static void current_map_info(object *op)
'mapinfo' command.
Definition: c_misc.cpp:427
MAP_ENTER_X
#define MAP_ENTER_X(m)
Default X coordinate for map enter.
Definition: map.h:83
object_remove
void object_remove(object *op)
This function removes the object op from the linked list of objects which it is currently tied to.
Definition: object.cpp:1818
player_set_state
void player_set_state(player *pl, uint8_t state)
Set the player's state to the specified one.
Definition: player.cpp:4494
try_find_archetype
archetype * try_find_archetype(const char *name)
Definition: assets.cpp:274
get_who_escape_code_value
static void get_who_escape_code_value(char *return_val, int size, const char letter, player *pl)
Returns the value of the escape code used in the who format specifier.
Definition: c_misc.cpp:696
object_sum_weight
signed long object_sum_weight(object *op)
object_sum_weight() is a recursive function which calculates the weight an object is carrying.
Definition: object.cpp:553
check_password
bool check_password(const char *typed, const char *crypted)
Hash a password and compare it to the stored version.
Definition: server.cpp:114
SS_DUMP_TOTALS
#define SS_DUMP_TOTALS
Definition: shstr.h:47
socket_struct::login_method
uint8_t login_method
Login method this client is using.
Definition: newserver.h:133
player::password
char password[16]
2 (seed) + 11 (crypted) + 1 (EOS) + 2 (safety) = 16
Definition: player.h:195
command_wimpy
void command_wimpy(object *op, const char *params)
Player wants to change how soon she'll flee.
Definition: c_misc.cpp:2142
SK_EXP_ADD_SKILL
#define SK_EXP_ADD_SKILL
Give the player the skill.
Definition: skills.h:78
object::nrof
uint32_t nrof
Number of objects.
Definition: object.h:342
player::socket
socket_struct * socket
Socket information for this player.
Definition: player.h:109
object::body_used
int8_t body_used[NUM_BODY_LOCATIONS]
Calculated value based on items equipped.
Definition: object.h:383
object::stats
living stats
Str, Con, Dex, etc.
Definition: object.h:378
MSG_TYPE_ADMIN_VERSION
#define MSG_TYPE_ADMIN_VERSION
version info
Definition: newclient.h:505
unapply_never
@ unapply_never
Will not unapply objects automatically.
Definition: player.h:77
treasure
treasure is one element in a linked list, which together consist of a complete treasure-list.
Definition: treasure.h:63
list
How to Install a Crossfire Server on you must install a python script engine on your computer Python is the default script engine of Crossfire You can find the python engine you have only to install them The VisualC Crossfire settings are for but you habe then to change the pathes in the VC settings Go in Settings C and Settings Link and change the optional include and libs path to the new python installation path o except the maps ! You must download a map package and install them the share folder Its must look like doubleclick on crossfire32 dsw There are projects in your libcross lib and plugin_python You need to compile all Easiest way is to select the plugin_python ReleaseLog as active this will compile all others too Then in Visual C press< F7 > to compile If you don t have an appropriate compiler you can try to get the the VC copies the crossfire32 exe in the crossfire folder and the plugin_python dll in the crossfire share plugins folder we will remove it when we get time for it o Last showing lots of weird write to the Crossfire mailing list
Definition: INSTALL_WIN32.txt:50
LogLevel
LogLevel
Log levels for the LOG() function.
Definition: logger.h:10
artifact
This is one artifact, ie one special item.
Definition: artifact.h:14
object_set_value
int object_set_value(object *op, const char *key, const char *value, int add_key)
Updates the key in op to value.
Definition: object.cpp:4484
command_unarmed_skill
void command_unarmed_skill(object *op, const char *params)
Player wants to change prefered unarmed skill.
Definition: c_misc.cpp:1381
freearr_x
short freearr_x[SIZEOFFREE]
X offset when searching around a spot.
Definition: object.cpp:299
player::petmode
petmode_t petmode
Which petmode?
Definition: player.h:117
MAP_TIMEOUT
#define MAP_TIMEOUT(m)
Definition: map.h:69
TRUE
#define TRUE
Definition: compat.h:11
check_name
int check_name(player *me, const char *name)
Ensure player's name is valid.
Definition: login.cpp:181
closedir
int closedir(DIR *)
MSG_TYPE_COMMAND_WHO
#define MSG_TYPE_COMMAND_WHO
Definition: newclient.h:523
living::Pow
int8_t Pow
Definition: living.h:36
FLAG_WIZPASS
#define FLAG_WIZPASS
The wizard can go through walls.
Definition: define.h:301
player::name_changed
uint32_t name_changed
If true, the player has set a name.
Definition: player.h:147
command_wizcast
void command_wizcast(object *op, const char *params)
Wizard toggling "cast everywhere" ability.
Definition: c_misc.cpp:947
BufferReader
Definition: bufferreader.cpp:21
send_query
void send_query(socket_struct *ns, uint8_t flags, const char *text)
Asks the client to query the user.
Definition: request.cpp:749
command_peaceful
void command_peaceful(object *op, const char *params)
Player toggles her peaceful status.
Definition: c_misc.cpp:2124
MSG_TYPE_ADMIN
#define MSG_TYPE_ADMIN
Definition: newclient.h:406
player::bowtype
bowtype_t bowtype
Which firemode?
Definition: player.h:116
command_mapinfo
void command_mapinfo(object *op, const char *params)
'mapinfo' command.
Definition: c_misc.cpp:809
Settings::who_format
char who_format[MAX_BUF]
The format that the who command should use.
Definition: global.h:277
FOR_INV_PREPARE
#define FOR_INV_PREPARE(op_, it_)
Constructs a loop iterating over the inventory of an object.
Definition: define.h:654
living::hp
int16_t hp
Hit Points.
Definition: living.h:40
create_treasure
void create_treasure(treasurelist *t, object *op, int flag, int difficulty, int tries)
This calls the appropriate treasure creation function.
Definition: treasure.cpp:287
FORCE
@ FORCE
Definition: object.h:229
usekeytype
usekeytype
How to use keys.
Definition: player.h:65
command_listen
void command_listen(object *op, const char *params)
Change the player's listen level.
Definition: c_misc.cpp:1090
dump_all_maps
void dump_all_maps(void)
Prints out debug-information about all maps.
Definition: map.cpp:268
player::ticks_played
uint32_t ticks_played
How many ticks this player has played.
Definition: player.h:224
player::usekeys
usekeytype usekeys
Method for finding keys for doors.
Definition: player.h:122
command_fix_me
void command_fix_me(object *op, const char *params)
Wrapper to fix a player.
Definition: c_misc.cpp:1213
dump_all_archetypes
void dump_all_archetypes(void)
Dumps all archetypes to debug-level output.
Definition: arch.cpp:148
assets_number_of_treasures
size_t assets_number_of_treasures()
Definition: assets.cpp:259
ST_GET_PARTY_PASSWORD
#define ST_GET_PARTY_PASSWORD
Player tried to join a password-protected party.
Definition: define.h:533
INS_BELOW_ORIGINATOR
#define INS_BELOW_ORIGINATOR
Insert new object immediately below originator.
Definition: object.h:584
i18n
const char * i18n(const object *who, const char *code)
Translate a message in the appropriate language.
Definition: languages.cpp:42
living::Con
int8_t Con
Definition: living.h:36
living::Str
int8_t Str
Definition: living.h:36
player_get_title
void player_get_title(const player *pl, char *buf, size_t bufsize)
Returns the player's title.
Definition: player.cpp:233
get_name
void get_name(object *op)
Waiting for the player's name.
Definition: player.cpp:887
bufferreader_next_line
char * bufferreader_next_line(BufferReader *br)
Return the next line in the buffer, as separated by a newline.
Definition: bufferreader.cpp:102
CS_QUERY_HIDEINPUT
#define CS_QUERY_HIDEINPUT
Hide input being entered.
Definition: newclient.h:72
find_player
player * find_player(const char *plname)
Find a player by her full name.
Definition: player.cpp:59
Settings::localdir
const char * localdir
Read/write data files.
Definition: global.h:250