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 (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);
580  chars[num_players-1].login_order = num_players;
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, "[help]");
1686  strcat(line, strtok(de->d_name, "."));
1687  strcat(line, "[/help] ");
1688  }
1689  }
1691  line);
1692  closedir(dirp);
1693 }
1694 
1704 static int find_help_file_in(const char *dir, const char *name, const char *language, char *path, int length) {
1705  struct stat st;
1706 
1707  snprintf(path, length, "%s/%s/%s.%s", settings.datadir, dir, name, language);
1708  if (stat(path, &st) == 0 && S_ISREG(st.st_mode)) {
1709  return 1;
1710  }
1711  return 0;
1712 }
1713 
1727 static int find_help_file(const char *name, const char *language, int wiz, char *path, int length) {
1728  if (wiz) {
1729  if (find_help_file_in("wizhelp", name, language, path, length))
1730  return 1;
1731  if (strcmp(language, "en") && find_help_file_in("wizhelp", name, "en", path, length))
1732  return 1;
1733  }
1734 
1735  if (find_help_file_in("help", name, language, path, length))
1736  return 1;
1737  if (strcmp(language, "en") && find_help_file_in("help", name, "en", path, length))
1738  return 1;
1739 
1740  return 0;
1741 }
1742 
1750 static void display_help_file(object *op, const char *filename) {
1751  BufferReader *br;
1752  const char *line;
1753 
1754  if ((br = bufferreader_init_from_file(NULL, filename, "Cannot open help file %s: %s\n", llevError)) == NULL) {
1755  return;
1756  }
1757 
1758  while ((line = bufferreader_next_line(br))) {
1760  }
1761 
1763 }
1764 
1773 void command_help(object *op, const char *params) {
1774  char filename[MAX_BUF];
1775  const char *language;
1776 
1777  /*
1778  * Main help page?
1779  */
1780  if (*params == '\0') {
1781  snprintf(filename, sizeof(filename), "%s/def_help", settings.datadir);
1782  display_help_file(op, filename);
1783  return;
1784  }
1785 
1786  /*
1787  * Topics list
1788  */
1789  if (!strcmp(params, "topics")) {
1790  help_topics(op, 3);
1791  help_topics(op, 0);
1792  if (QUERY_FLAG(op, FLAG_WIZ))
1793  help_topics(op, 1);
1794  return;
1795  }
1796 
1797  /*
1798  * Commands list
1799  */
1800  if (!strcmp(params, "commands")) {
1801  command_list(op, QUERY_FLAG(op, FLAG_WIZ));
1802  return;
1803  }
1804 
1805  /*
1806  * User wants info about command
1807  */
1808  if (strchr(params, '.') || strchr(params, ' ') || strchr(params, '/')) {
1810  "Illegal characters in '%s'",
1811  params);
1812  return;
1813  }
1814 
1815  language = i18n_get_language_code(op->contr->language);
1816 
1817  if (!find_help_file(params, language, QUERY_FLAG(op, FLAG_WIZ), filename, sizeof(filename))) {
1819  "No help available on '%s'",
1820  params);
1821  return;
1822  }
1823 
1824  /*
1825  * Found that. Just cat it to screen.
1826  */
1827  display_help_file(op, filename);
1828 }
1829 
1840 static int onoff_value(const char *line) {
1841  int i;
1842 
1843  if (sscanf(line, "%d", &i))
1844  return (i != 0);
1845 
1846  switch (line[0]) {
1847  case 'o':
1848  switch (line[1]) {
1849  case 'n':
1850  return 1; /* on */
1851  default:
1852  return 0; /* o[ff] */
1853  }
1854 
1855  case 'y': /* y[es] */
1856  case 'k': /* k[ylla] */
1857  case 's':
1858  case 'd':
1859  return 1;
1860 
1861  case 'n': /* n[o] */
1862  case 'e': /* e[i] */
1863  case 'u':
1864  default:
1865  return 0;
1866  }
1867 }
1868 
1874 void command_quit(object* op, const char* params) {
1875  (void)params;
1876  draw_ext_info(
1878  "To leave the game, sleep in (apply) a bed to reality. To "
1879  "permenantly delete your character, use the 'delete' command.");
1880 }
1881 
1890 void command_delete(object *op, const char *params) {
1891  (void)params;
1892  if (QUERY_FLAG(op, FLAG_WIZ)) {
1893  draw_ext_info(NDI_UNIQUE, 0, op, MSG_TYPE_COMMAND, MSG_TYPE_ADMIN_DM, "Can't quit when in DM mode.");
1894  return;
1895  }
1896 
1898  i18n(op, "Quitting will delete your character.\nAre you sure you want to delete your character (y/n):"));
1899 
1901 }
1902 
1911 void command_sound(object *op, const char *params) {
1912  (void)params;
1913  if (!(op->contr->socket->sound&SND_MUTE)) {
1914  op->contr->socket->sound = op->contr->socket->sound|SND_MUTE;
1916  "Sounds are turned off.");
1917  } else {
1918  op->contr->socket->sound = op->contr->socket->sound&~SND_MUTE;
1920  "The sounds are enabled.");
1921  }
1922  return;
1923 }
1924 
1936 void receive_player_name(object *op, const char *name) {
1937  if (!check_name(op->contr, name)) {
1938  get_name(op);
1939  return;
1940  }
1941  FREE_AND_COPY(op->name, name);
1942  FREE_AND_COPY(op->name_pl, name);
1944  op->contr->name_changed = 1;
1945  get_password(op);
1946 }
1947 
1956 void receive_player_password(object *op, const char *password) {
1957  unsigned int pwd_len = strlen(password);
1958 
1959  if (pwd_len == 0 || pwd_len > 16) {
1960  if (op->contr->state == ST_CHANGE_PASSWORD_OLD
1962  || op->contr->state == ST_CHANGE_PASSWORD_CONFIRM) {
1964  "Password changed cancelled.");
1966  } else
1967  get_name(op);
1968  return;
1969  }
1970  /* To hide the password better */
1971  /* With currently clients, not sure if this is really the case - MSW */
1973 
1974  if (checkbanned(op->name, op->contr->socket->host)) {
1975  LOG(llevInfo, "Banned player tried to add: [%s@%s]\n", op->name, op->contr->socket->host);
1977  "You are not allowed to play.");
1978  get_name(op);
1979  return;
1980  }
1981 
1982  if (op->contr->state == ST_CONFIRM_PASSWORD) {
1983  if (!check_password(password, op->contr->password)) {
1985  "The passwords did not match.");
1986  get_name(op);
1987  return;
1988  }
1989  LOG(llevInfo, "LOGIN: New player named %s from ip %s\n", op->name, op->contr->socket->host);
1990  display_motd(op);
1992  "\nWelcome, Brave New Warrior!\n");
1993  roll_again(op);
1995  return;
1996  }
1997 
1998  if (op->contr->state == ST_CHANGE_PASSWORD_OLD) {
1999  if (!check_password(password, op->contr->password)) {
2001  "You entered the wrong current password.");
2003  } else {
2004  send_query(op->contr->socket, CS_QUERY_HIDEINPUT, i18n(op, "Please enter your new password, or blank to cancel:"));
2006  }
2007  return;
2008  }
2009 
2010  if (op->contr->state == ST_CHANGE_PASSWORD_NEW) {
2011  safe_strncpy(op->contr->new_password, newhash(password),
2012  sizeof(op->contr->new_password));
2014  i18n(op, "Please confirm your new password, or blank to cancel:"));
2016  return;
2017  }
2018 
2019  if (op->contr->state == ST_CHANGE_PASSWORD_CONFIRM) {
2020  if (!check_password(password, op->contr->new_password)) {
2022  "The new passwords don't match!");
2023  } else {
2025  "Password changed.");
2026  strncpy(op->contr->password, op->contr->new_password, 13);
2027  }
2029  return;
2030  }
2031 
2032  safe_strncpy(op->contr->password, newhash(password),
2033  sizeof(op->contr->password));
2035  check_login(op, password);
2036 }
2037 
2048 void command_title(object *op, const char *params) {
2049  char buf[HUGE_BUF];
2050 
2051  if (settings.set_title == FALSE) {
2053  "You cannot change your title.");
2054  return;
2055  }
2056 
2057  /* dragon players cannot change titles */
2058  if (is_dragon_pl(op)) {
2060  "Dragons cannot change titles.");
2061  return;
2062  }
2063 
2064  if (*params == '\0') {
2065  char tmp[MAX_BUF];
2066 
2067  player_get_title(op->contr, tmp, sizeof(tmp));
2068  snprintf(buf, sizeof(buf), "Your title is '%s'.", tmp);
2070  return;
2071  }
2072  if (strcmp(params, "clear") == 0 || strcmp(params, "default") == 0) {
2073  if (!player_has_own_title(op->contr))
2075  "Your title is the default title.");
2076  else
2078  "Title set to default.");
2079  player_set_own_title(op->contr, "");
2080  return;
2081  }
2082 
2083  if ((int)strlen(params) >= MAX_NAME) {
2085  "Title too long.");
2086  return;
2087  }
2088  player_set_own_title(op->contr, params);
2089 }
2090 
2099 void command_save(object *op, const char *params) {
2100  (void)params;
2101  if (get_map_flags(op->map, NULL, op->x, op->y, NULL, NULL)&P_NO_CLERIC) {
2103  "You can not save on unholy ground.");
2104  } else if (!op->stats.exp) {
2106  "You don't deserve to save yet.");
2107  } else {
2108  if (save_player(op, 1))
2110  "You have been saved.");
2111  else
2113  "SAVE FAILED!");
2114  }
2115 }
2116 
2125 void command_peaceful(object *op, const char *params) {
2126  (void)params;
2127  if ((op->contr->peaceful = !op->contr->peaceful))
2129  "You will not attack other players.");
2130  else
2132  "You will attack other players.");
2133 }
2134 
2143 void command_wimpy(object *op, const char *params) {
2144  int i;
2145 
2146  if (*params == '\0' || !sscanf(params, "%d", &i)) {
2148  "Your current wimpy level is %d.",
2149  op->run_away);
2150  return;
2151  }
2152 
2153  if (i < 0 || i > 100) {
2155  "Wimpy level must be between 1 and 100.");
2156  return;
2157  }
2158 
2160  "Your new wimpy level is %d.",
2161  i);
2162  op->run_away = i;
2163 }
2164 
2173 void command_brace(object *op, const char *params) {
2174  if (*params == '\0')
2175  op->contr->braced = !op->contr->braced;
2176  else
2177  op->contr->braced = onoff_value(params);
2178 
2179  if (op->contr->braced)
2181  "You are braced.");
2182  else
2184  "Not braced.");
2185 
2186  fix_object(op);
2187 }
2188 
2197 void command_kill_pets(object *op, const char *params) {
2198  if (*params == '\0') {
2199  pets_terminate_all(op);
2201  "Your pets have been killed.");
2202  } else {
2203  objectlink *obl, *list = get_friends_of(op);
2204  int counter = 0, removecount = 0;
2205  int target = atoi(params);
2206 
2207  for (obl = list; obl != NULL; obl = obl->next) {
2208  object *ob = obl->ob;
2209  if (object_get_owner(ob) == op) {
2210  if (++counter == target || (target == 0 && !strcasecmp(ob->name, params))) {
2211  pets_terminate(ob);
2212  removecount++;
2213  }
2214  }
2215  }
2216  if (list) {
2218  }
2219  if (removecount != 0)
2221  "Killed %d pets.",
2222  removecount);
2223  else
2225  "Couldn't find any suitable pets to kill.");
2226  }
2227 }
2228 
2237 void command_passwd(object *pl, const char *params) {
2238  (void)params;
2239  /* If old client, this is the way you change your password. */
2240  if (pl->contr->socket->login_method < 1){
2241  send_query(pl->contr->socket, CS_QUERY_HIDEINPUT, i18n(pl, "Password change.\nPlease enter your current password, or empty string to cancel."));
2242 
2244  }
2245  /* If new client (login_method = 2) or jxclient (login_method = 1), changing the password does nothing anyway, so error out */
2246  else{
2248  "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.");
2249  }
2250 }
2251 
2261 void do_harvest(object *pl, int dir, object *skill) {
2262  int16_t x, y;
2263  int level, exp, check_exhaust = 0;
2264  const int max_harvest = 10;
2265  object *found[max_harvest]; /* Found items that can be harvested. */
2266  mapstruct *map;
2267  object *item, *inv, *harvested;
2268  sstring trace, ttool, tspeed, race, tool, slevel, sexp;
2269  float speed;
2270 
2271  x = pl->x+freearr_x[dir];
2272  y = pl->y+freearr_y[dir];
2273  map = pl->map;
2274 
2275  if (!IS_PLAYER(pl))
2276  return;
2277 
2278  if (!map)
2279  return;
2280 
2281  if (get_map_flags(map, &map, x, y, &x, &y)&P_OUT_OF_MAP) {
2282  draw_ext_info_format(NDI_WHITE, 0, pl, MSG_TYPE_SKILL, MSG_TYPE_SKILL_FAILURE, i18n(pl, "You cannot %s here."), skill->slaying);
2283  return;
2284  }
2285 
2286  if (!pl->chosen_skill || pl->chosen_skill->skill != skill->skill)
2287  return;
2288 
2289  trace = object_get_value(pl->chosen_skill, "harvest_race");
2290  ttool = object_get_value(pl->chosen_skill, "harvest_tool");
2291  tspeed = object_get_value(pl->chosen_skill, "harvest_speed");
2292  if (!trace || strcmp(trace, "") == 0 || !ttool || strcmp(ttool, "") == 0 || !tspeed || strcmp(tspeed, "") == 0) {
2293  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);
2294  LOG(llevError, "do_harvest: tool %s without harvest_[race|tool|speed]\n", pl->chosen_skill->name);
2295  return;
2296  }
2297 
2298  int count = 0; // number of harvested items
2299  FOR_MAP_PREPARE(map, x, y, item) {
2300  if (!LOOK_OBJ(item))
2301  continue;
2302  // do not skip floors, because you can harvest from mountains/lakes
2317  const char* harvestitems;
2318  if ((harvestitems = object_get_value(item, "harvestitems"))) {
2319  struct treasurelist* t = find_treasurelist(harvestitems);
2320  if (t) {
2321  create_treasure(t, item, 0, map->difficulty, 0);
2322  }
2323  object_set_value(item, "harvestitems", NULL, false);
2324  }
2325 
2326  FOR_INV_PREPARE(item, inv) {
2327  if (object_value_set(inv, "harvestable") == false)
2328  continue;
2329  race = object_get_value(inv, "harvest_race");
2330  tool = object_get_value(inv, "harvest_tool");
2331  slevel = object_get_value(inv, "harvest_level");
2332  sexp = object_get_value(inv, "harvest_exp");
2333  if (race && (!slevel || !sexp)) {
2334  LOG(llevError, "do_harvest: item %s without harvest_[level|exp]\n", inv->name);
2335  continue;
2336  }
2337  if (race == trace && (!tool || tool == ttool))
2338  found[count++] = inv;
2339 
2340  if (count >= max_harvest)
2341  break;
2342  } FOR_INV_FINISH();
2343 
2344  if (count >= max_harvest)
2345  break;
2346  } FOR_MAP_FINISH();
2347  if (count == 0) {
2348  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);
2349  return;
2350  }
2351 
2352  assert(count <= max_harvest); // otherwise we have a stack overflow...
2353 
2354  inv = found[rndm(0, count-1)];
2355  assert(inv);
2356  item = inv->env;
2357  assert(item);
2358 
2359  slevel = object_get_value(inv, "harvest_level");
2360  sexp = object_get_value(inv, "harvest_exp");
2361  level = atoi(slevel);
2362  exp = atoi(sexp);
2363 
2364  speed = atof(tspeed);
2365  if (speed < 0)
2366  speed = -speed*pl->speed;
2367  pl->speed_left -= speed;
2368 
2369 
2370  /* Now we found something to harvest, randomly try to get it. */
2371  if (level > skill->level+10) {
2372  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);
2373  return;
2374  }
2375 
2376  int proba; /* Probability to get the item, 100 based. */
2377  if (level >= skill->level)
2378  /* Up to 10 more levels, 1 to 11 percent probability. */
2379  proba = 10+skill->level-level;
2380  else if (skill->level <= level+10)
2381  proba = 10+(skill->level-level)*2;
2382  else
2383  proba = 30;
2384 
2385  if (proba <= random_roll(0, 100, pl, 1)) {
2386  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);
2387  return;
2388  }
2389 
2390  /* Check the new item can fit into inventory.
2391  * Fixes bug #3060474: fishing puts more fishes into inventory than you can carry. */
2392  if (((uint32_t)(pl->weight + pl->carrying + inv->weight)) > get_weight_limit(pl->stats.Str)) {
2393  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);
2394  return;
2395  }
2396 
2397  /* Ok, got it. */
2398 
2399  /* If we have nrof 0, treat it like a singleton.
2400  * Old behavior was infinite here, and extremely abuseable.
2401  * Neila H. 2024-02-06
2402  */
2403  if (inv->nrof == 0) {
2404  check_exhaust = (count == 1 ? 1 : 0);
2405  object_remove(inv);
2406  harvested = inv;
2407  } else {
2408  if (count == 1 && inv->nrof == 1) {
2409  check_exhaust = 1;
2410  }
2411  if ( inv->nrof == 1 ) {
2412  /* Avoid dumping object inventory like a dead monster if it has an inventory */
2413  object_remove(inv);
2414  harvested = inv;
2415  }
2416  else {
2417  harvested = object_split(inv, 1, NULL, 0);
2418  }
2419  }
2420  object_set_value(harvested, "harvestable", NULL, 0);
2421  if (QUERY_FLAG(harvested, FLAG_MONSTER)) {
2422  int spot = object_find_free_spot(harvested, pl->map, pl->x, pl->y, 0, SIZEOFFREE);
2423  if (spot == -1) {
2424  /* Better luck next time...*/
2425  object_remove(harvested);
2426  draw_ext_info_format(NDI_WHITE, 0, pl, MSG_TYPE_SKILL, MSG_TYPE_SKILL_FAILURE, "You fail to %s anything.", skill->slaying);
2427  return;
2428  }
2429  object_insert_in_map_at(harvested, pl->map, NULL, 0, pl->x+freearr_x[spot], pl->y+freearr_y[spot]);
2430  draw_ext_info_format(NDI_WHITE, 0, pl, MSG_TYPE_SKILL, MSG_TYPE_SKILL_FAILURE, "You %s a %s!", skill->slaying, harvested->name);
2431  } else {
2432  harvested = object_insert_in_ob(harvested, pl);
2433  draw_ext_info_format(NDI_WHITE, 0, pl, MSG_TYPE_SKILL, MSG_TYPE_SKILL_FAILURE, "You %s some %s.", skill->slaying, harvested->name);
2434  }
2435 
2436  /* Get exp */
2437  change_exp(pl, exp, skill->name, SK_EXP_ADD_SKILL);
2438 
2439  if (check_exhaust) {
2440  sstring replacement = object_get_value(item, "harvest_exhaust_replacement");
2441  if (replacement) {
2442  if (replacement[0] != '-') {
2443  archetype *other = try_find_archetype(replacement);
2444  if (other) {
2445  object *final = object_create_arch(other);
2446  object_insert_in_map_at(final, map, item, INS_BELOW_ORIGINATOR, item->x, item->y);
2447  }
2448  }
2449  object_remove(item);
2451  }
2452  }
2453 
2454  return;
2455 }
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:4375
object::name_pl
sstring name_pl
The plural name of the object.
Definition: object.h:325
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:284
object_get_owner
object * object_get_owner(object *op)
Returns the object which this object marks as being the owner.
Definition: object.cpp:801
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:1782
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:396
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
Problems requiring server admin to fix.
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:337
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:82
language_t
void * language_t
Strings that should be manipulated through add_string() and free_string().
Definition: global.h:73
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:1936
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:269
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:79
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:253
object::arch
struct archetype * arch
Pointer to archetype.
Definition: object.h:426
P_NO_CLERIC
#define P_NO_CLERIC
No clerical spells cast here.
Definition: map.h:243
stringbuffer_new
StringBuffer * stringbuffer_new(void)
Create a new string buffer.
Definition: stringbuffer.cpp:24
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:339
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:337
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:695
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:1840
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:340
MAP_IN_MEMORY
#define MAP_IN_MEMORY
Map is fully loaded.
Definition: map.h:131
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:307
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:409
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:1154
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:41
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:309
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:2197
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:545
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:225
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:280
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:163
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:360
object::level
int16_t level
Level of creature or object.
Definition: object.h:363
bow_bestarrow
@ bow_bestarrow
Try to find an arrow matching the target.
Definition: player.h:53
buf
StringBuffer * buf
Definition: readable.cpp:1564
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:2856
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:353
name
Plugin animator file specs[Config] name
Definition: animfiles.txt:4
linked_char
Definition: global.h:102
ticks_to_seconds
float ticks_to_seconds(int ticks)
Definition: time.cpp:386
region::longname
char * longname
Official title of the region, this might be defined to be the same as name.
Definition: map.h:286
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:379
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:522
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:337
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:32
object::contr
struct player * contr
Pointer to the player which control this object.
Definition: object.h:286
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:67
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:788
object::chosen_skill
object * chosen_skill
The skill chosen to use.
Definition: object.h:398
nrofallowedstr
long nrofallowedstr
Only used in malloc_info().
Definition: init.cpp:117
Settings::debug
LogLevel debug
Default debugging level.
Definition: global.h:248
object::subtype
uint8_t subtype
Subtype of object.
Definition: object.h:351
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:309
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:341
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:479
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:489
object::run_away
uint8_t run_away
Monster runs away if it's hp goes below this percentage.
Definition: object.h:396
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
StringBuffer
std::string StringBuffer
The string buffer state.
Definition: stringbuffer.h:33
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:1750
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:2237
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:210
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:27
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:2261
command_quit
void command_quit(object *op, const char *params)
Tell players to use the 'delete' command.
Definition: c_misc.cpp:1874
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:1590
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:1704
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:485
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:1750
P_OUT_OF_MAP
#define P_OUT_OF_MAP
This space is outside the map.
Definition: map.h:254
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:293
stringbuffer_append_string
void stringbuffer_append_string(StringBuffer *sb, const char *str)
Append a string to a string buffer instance.
Definition: stringbuffer.cpp:44
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:261
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:43
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:1911
command_save
void command_save(object *op, const char *params)
Player wants to get saved.
Definition: c_misc.cpp:2099
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:2099
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:1956
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:225
NAMLEN
#define NAMLEN(dirent)
Definition: global.h:217
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:2242
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:377
nroffreeobjects
int nroffreeobjects
How many OBs allocated and free (free)
Definition: object.cpp:292
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:255
IS_PLAYER
static bool IS_PLAYER(object *op)
Definition: object.h:610
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:1890
living::Wis
int8_t Wis
Definition: living.h:36
region
This is a game region.
Definition: map.h:279
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:14
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
object::slaying
sstring slaying
Which race to do double damage to.
Definition: object.h:329
all_regions
std::vector< region * > all_regions
Definition: init.cpp:108
object::name
sstring name
The name of the object, obviously...
Definition: object.h:321
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:1766
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:281
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:280
living::maxsp
int16_t maxsp
Max spell points.
Definition: living.h:43
mapstruct
This is a game-map.
Definition: map.h:320
object::env
object * env
Pointer to the object which is the environment.
Definition: object.h:303
MSG_TYPE_COMMAND_BODY
#define MSG_TYPE_COMMAND_BODY
Definition: newclient.h:525
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:331
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:2636
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:2173
mapstruct::name
char * name
Name of map as given by its creator.
Definition: map.h:323
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:3558
command_title
void command_title(object *op, const char *params)
Player wishes to change her title.
Definition: c_misc.cpp:2048
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:4345
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:4276
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:1562
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:1727
object::body_info
int8_t body_info[NUM_BODY_LOCATIONS]
Body info as loaded from the file.
Definition: object.h:384
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:1773
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
draw_ext_info
void draw_ext_info(int flags, int pri, const object *pl, uint8_t type, uint8_t subtype, const char *message)
Sends message to player(s).
Definition: main.cpp:316
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:289
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:1832
player_set_state
void player_set_state(player *pl, uint8_t state)
Set the player's state to the specified one.
Definition: player.cpp:4496
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:559
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:2143
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:344
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:385
object::stats
living stats
Str, Con, Dex, etc.
Definition: object.h:380
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:4498
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:303
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:22
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:2125
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:280
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:290
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:248
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:585
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:110
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:254