Crossfire Server, Trunk  R20513
c_misc.c
Go to the documentation of this file.
1 /*
2  * Crossfire -- cooperative multi-player graphical RPG and adventure game
3  *
4  * Copyright (c) 1999-2014 Mark Wedel and the Crossfire Development Team
5  * Copyright (c) 1992 Frank Tore Johansen
6  *
7  * Crossfire is free software and comes with ABSOLUTELY NO WARRANTY. You are
8  * welcome to redistribute it under certain conditions. For details, please
9  * see COPYING and LICENSE.
10  *
11  * The authors can be reached via e-mail at <crossfire@metalforge.org>.
12  */
13 
20 #define WANT_UNARMED_SKILLS
21 
22 #include "global.h"
23 
24 #include <assert.h>
25 #include <errno.h>
26 #include <stdlib.h>
27 #include <string.h>
28 #include <sys/stat.h>
29 
30 #undef SS_STATISTICS
31 #include "loader.h"
32 #include "shstr.h"
33 #include "sounds.h"
34 #include "sproto.h"
35 #include "version.h"
36 
45 void map_info(object *op, const char *search) {
46  mapstruct *m;
47  char map_path[MAX_BUF];
48  long sec = seconds();
49 
51  i18n(op, "Current time is: %02ld:%02ld:%02ld."),
52  (sec%86400)/3600, (sec%3600)/60, sec%60);
53 
55  i18n(op, "[fixed]Path Pl PlM IM TO Dif Reset"));
56 
57  for (m = first_map; m != NULL; m = m->next) {
58  if (*search != '\0' && strstr(m->path, search) == NULL)
59  continue; /* Skip unwanted maps */
60 
61  /* Print out the last 18 characters of the map name... */
62  if (strlen(m->path) <= 18) {
63  strcpy(map_path, m->path);
64  } else {
65  safe_strncpy(map_path, m->path + strlen(m->path) - 18, sizeof(map_path));
66  }
67 
69  i18n(op, "[fixed]%-18.18s %2d %2d %1d %4d %2d %02d:%02d:%02d"),
70  map_path, m->players, players_on_map(m, FALSE),
71  m->in_memory, m->timeout, m->difficulty,
72  (MAP_WHEN_RESET(m)%86400)/3600, (MAP_WHEN_RESET(m)%3600)/60,
73  MAP_WHEN_RESET(m)%60);
74  }
75 }
76 
85 void command_language(object *op, const char *params) {
86  int language = -1;
87 
88  if (!op->contr)
89  return;
90 
91  if (*params == '\0' || (!strcmp(params, ""))) {
93  i18n(op, "Your current language is set to: English."));
95  i18n(op, "Available languages:"));
97  return;
98  }
99 
100  language = i18n_find_language_by_code(params);
101 
102  /* Error out if unknown language. */
103  if (language == -1) {
105  i18n(op, "Unknown language."));
106  return;
107  }
108 
109  op->contr->language = language;
110 
112  i18n(op, "Your current language is set to English."));
113 }
114 
128 void command_body(object *op, const char *params) {
129  int i;
130 
131  /* Too hard to try and make a header that lines everything up, so just
132  * give a description.
133  */
135  i18n(op, "The first column is the name of the body location."));
136 
138  i18n(op, "The second column is how many of those locations your body has."));
139 
141  i18n(op, "The third column is how many slots in that location are available."));
142 
143  for (i = 0; i < NUM_BODY_LOCATIONS; i++) {
144  /* really debugging - normally body_used should not be set to anything
145  * if body_info isn't also set.
146  */
147  if (op->body_info[i] || op->body_used[i]) {
149  i18n(op, "[fixed]%-30s %5d %5d"),
150  i18n(op, body_locations[i].use_name), op->body_info[i], op->body_used[i]);
151  }
152  }
153  if (!QUERY_FLAG(op, FLAG_USE_ARMOUR))
155  i18n(op, "You are not allowed to wear armor."));
156  if (!QUERY_FLAG(op, FLAG_USE_WEAPON))
158  i18n(op, "You are not allowed to use weapons."));
159 }
160 
169 void command_motd(object *op, const char *params) {
170  display_motd(op);
171 }
172 
181 void command_rules(object *op, const char *params) {
182  send_rules(op);
183 }
184 
193 void command_news(object *op, const char *params) {
194  send_news(op);
195 }
196 
203 static void malloc_info(object *op) {
204  int ob_used = object_count_used(), ob_free = object_count_free(), players, nrofmaps;
205  int nrm = 0, mapmem = 0, anr, anims, sum_alloc = 0, sum_used = 0, i, tlnr, alnr;
206  treasurelist *tl;
207  player *pl;
208  mapstruct *m;
209  archetype *at;
210  artifactlist *al;
211 
212  for (tl = first_treasurelist, tlnr = 0; tl != NULL; tl = tl->next, tlnr++)
213  ;
214  for (al = first_artifactlist, alnr = 0; al != NULL; al = al->next, alnr++)
215  ;
216 
217  for (at = first_archetype, anr = 0, anims = 0; at != NULL; at = at->more == NULL ? at->next : at->more, anr++)
218  ;
219 
220  for (i = 1; i < num_animations; i++)
221  anims += animations[i].num_animations;
222 
223  for (pl = first_player, players = 0; pl != NULL; pl = pl->next, players++)
224  ;
225 
226  for (m = first_map, nrofmaps = 0; m != NULL; m = m->next, nrofmaps++)
227  if (m->in_memory == MAP_IN_MEMORY) {
228  mapmem += map_size(m) * (sizeof(object *) + sizeof(MapSpace));
229  nrm++;
230  }
231 
233  i18n(op, "Sizeof: object=%d player=%d map=%d"),
234  sizeof(object), sizeof(player), sizeof(mapstruct));
235 
237  i18n(op, "[fixed]%4d used objects: %8d"),
238  ob_used, i = (ob_used*sizeof(object)));
239 
240  sum_used += i;
241  sum_alloc += i;
243  i18n(op, "[fixed]%4d free objects: %8d"),
244  ob_free, i = (ob_free*sizeof(object)));
245 
247  i18n(op, "[fixed]%4d active objects: %8d"),
248  object_count_active(), 0);
249 
250  sum_alloc += i;
252  i18n(op, "[fixed]%4d players: %8d"),
253  players, i = (players*sizeof(player)));
254 
255  sum_alloc += i;
256  sum_used += i;
257 
259  i18n(op, "[fixed]%4d maps allocated: %8d"),
260  nrofmaps, i = (nrofmaps*sizeof(mapstruct)));
261 
262  sum_alloc += i;
263  sum_used += nrm*sizeof(mapstruct);
264 
266  i18n(op, "[fixed]%4d maps in memory: %8d"),
267  nrm, mapmem);
268 
269  sum_alloc += mapmem;
270  sum_used += mapmem;
271 
273  i18n(op, "[fixed]%4d archetypes: %8d"),
274  anr, i = (anr*sizeof(archetype)));
275 
276  sum_alloc += i;
277  sum_used += i;
278 
280  i18n(op, "[fixed]%4d animations: %8d"),
281  anims, i = (anims*sizeof(uint16_t)));
282 
283  sum_alloc += i;
284  sum_used += i;
285 
287  i18n(op, "[fixed]%4d treasurelists %8d"),
288  tlnr, i = (tlnr*sizeof(treasurelist)));
289 
290  sum_alloc += i;
291  sum_used += i;
292 
294  i18n(op, "[fixed]%4ld treasures %8d"),
295  nroftreasures, i = (nroftreasures*sizeof(treasure)));
296 
297  sum_alloc += i;
298  sum_used += i;
299 
301  i18n(op, "[fixed]%4ld artifacts %8d"),
302  nrofartifacts, i = (nrofartifacts*sizeof(artifact)));
303 
304  sum_alloc += i;
305  sum_used += i;
306 
308  i18n(op, "[fixed]%4ld artifacts strngs %8d"),
309  nrofallowedstr, i = (nrofallowedstr*sizeof(linked_char)));
310 
311  sum_alloc += i;
312  sum_used += i;
313 
315  i18n(op, "[fixed]%4d artifactlists %8d"),
316  alnr, i = (alnr*sizeof(artifactlist)));
317 
318  sum_alloc += i;
319  sum_used += i;
320 
322  i18n(op, "[fixed]Total space allocated:%8d"),
323  sum_alloc);
324 
326  i18n(op, "[fixed]Total space used: %8d"),
327  sum_used);
328 }
329 
341 void current_region_info(object *op) {
342  /*
343  * Ok I /suppose/ I should write a seperate function for this, but it isn't
344  * going to be /that/ slow, and won't get called much
345  */
347 
348  /* This should only be possible if regions are not operating on this server. */
349  if (!r)
350  return;
351 
353  i18n(op, "You are in %s.\n%s"),
355 }
356 
363 void current_map_info(object *op) {
364  mapstruct *m = op->map;
365 
366  if (!m)
367  return;
368 
370  "%s (%s) in %s",
372 
373  if (QUERY_FLAG(op, FLAG_WIZ)) {
375  i18n(op, "players:%d difficulty:%d size:%dx%d start:%dx%d timeout %d"),
376  m->players, m->difficulty,
377  MAP_WIDTH(m), MAP_HEIGHT(m),
378  MAP_ENTER_X(m), MAP_ENTER_Y(m),
379  MAP_TIMEOUT(m));
380  }
381  if (m->msg)
383 }
384 
385 #ifdef DEBUG_MALLOC_LEVEL
386 
394 void command_malloc_verify(object *op, char *parms) {
395  extern int malloc_verify(void);
396 
397  if (!malloc_verify())
399  i18n(op, "Heap is corrupted."));
400  else
402  i18n(op, "Heap checks out OK."));
403 
404  return 1;
405 }
406 #endif
407 
418 void command_whereabouts(object *op, const char *params) {
419  region *reg;
420  player *pl;
421 
422  /*
423  * reset the counter on the region, then use it to store the number of
424  * players there.
425  * I don't know how thread-safe this would be, I suspect not very....
426  */
427  for (reg = first_region; reg != NULL; reg = reg->next) {
428  reg->counter = 0;
429  }
430  for (pl = first_player; pl != NULL; pl = pl->next)
431  if (pl->ob->map != NULL)
432  get_region_by_map(pl->ob->map)->counter++;
433 
434  /* we only want to print out by places with a 'longname' field...*/
435  for (reg = first_region; reg != NULL; reg = reg->next) {
436  if (reg->longname == NULL && reg->counter > 0) {
437  if (reg->parent != NULL) {
438  reg->parent->counter += reg->counter;
439  reg->counter = 0;
440  } else /*uh oh, we shouldn't be here. */
441  LOG(llevError, "command_whereabouts() Region %s with no longname has no parent\n", reg->name);
442  }
443  }
445  i18n(op, "In the world currently there are:"));
446 
447  for (reg = first_region; reg != NULL; reg = reg->next)
448  if (reg->counter > 0) {
450  i18n(op, "%u players in %s"),
451  reg->counter, get_region_longname(reg));
452  }
453 }
454 
456 typedef struct {
457  char namebuf[MAX_BUF];
459 } chars_names;
460 
470 static int name_cmp(const chars_names *c1, const chars_names *c2) {
471  return strcasecmp(c1->namebuf, c2->namebuf);
472 }
473 
484 void list_players(object *op, region *reg, partylist *party) {
485  player *pl;
486  uint16_t i;
487  char *format;
488  int num_players = 0, num_wiz = 0, num_afk = 0, num_bot = 0;
489  chars_names *chars = NULL;
490 
491  if (op == NULL || QUERY_FLAG(op, FLAG_WIZ))
492  format = settings.who_wiz_format;
493  else
494  format = settings.who_format;
495 
496  for (pl = first_player; pl != NULL; pl = pl->next) {
497  if (pl->ob->map == NULL)
498  continue;
499  if (pl->hidden && !QUERY_FLAG(op, FLAG_WIZ))
500  continue;
501 
502  if (reg && !region_is_child_of_region(get_region_by_map(pl->ob->map), reg))
503  continue;
504  if (party && pl->party != party)
505  continue;
506 
507  if (pl->state == ST_PLAYING || pl->state == ST_GET_PARTY_PASSWORD) {
508  num_players++;
509  chars = (chars_names *)realloc(chars, num_players*sizeof(chars_names));
510  if (chars == NULL) {
512  i18n(op, "who failed - out of memory!"));
513  return;
514  }
515  sprintf(chars[num_players-1].namebuf, "%s", pl->ob->name);
516  chars[num_players-1].login_order = num_players;
517 
518  /* Check for WIZ's & AFK's*/
519  if (QUERY_FLAG(pl->ob, FLAG_WIZ))
520  num_wiz++;
521 
522  if (QUERY_FLAG(pl->ob, FLAG_AFK))
523  num_afk++;
524 
525  if (pl->socket.is_bot)
526  num_bot++;
527  }
528  }
529  if (first_player != (player *)NULL) {
530  if (reg == NULL && party == NULL)
532  i18n(op, "Total Players (%d) -- WIZ(%d) AFK(%d) BOT(%d)"),
533  num_players, num_wiz, num_afk, num_bot);
534  else if (party == NULL)
536  i18n(op, "Total Players in %s (%d) -- WIZ(%d) AFK(%d) BOT(%d)"),
537  reg->longname ? reg->longname : reg->name, num_players, num_wiz, num_afk, num_bot);
538  else
540  i18n(op, "Total Players in party %s (%d) -- WIZ(%d) AFK(%d) BOT(%d)"),
541  party->partyname, num_players, num_wiz, num_afk, num_bot);
542  }
543  qsort(chars, num_players, sizeof(chars_names), (int (*)(const void *, const void *))name_cmp);
544  for (i = 0; i < num_players; i++)
545  display_who_entry(op, find_player(chars[i].namebuf), format);
546  free(chars);
547 }
548 
557 void command_who(object *op, const char *params) {
558  region *reg;
559 
560  reg = get_region_from_string(params);
561  list_players(op, reg, NULL);
562 }
563 
574 void display_who_entry(object *op, player *pl, const char *format) {
575  char tmpbuf[MAX_BUF];
576  char outbuf[MAX_BUF];
577  size_t i;
578 
579  strcpy(outbuf, "[fixed]");
580 
581  if (pl == NULL) {
582  LOG(llevError, "display_who_entry(): I was passed a null player\n");
583  return;
584  }
585  for (i = 0; i <= strlen(format); i++) {
586  if (format[i] == '%') {
587  i++;
588  get_who_escape_code_value(tmpbuf, sizeof(tmpbuf), format[i], pl);
589  strcat(outbuf, tmpbuf);
590  } else if (format[i] == '_') {
591  strcat(outbuf, " "); /* allow '_' to be used in place of spaces */
592  } else {
593  snprintf(tmpbuf, sizeof(tmpbuf), "%c", format[i]);
594  strcat(outbuf, tmpbuf);
595  }
596  }
598 }
599 
630 void get_who_escape_code_value(char *return_val, int size, const char letter, player *pl) {
631  switch (letter) {
632  case 'N':
633  snprintf(return_val, size, "%s", pl->ob->name);
634  break;
635 
636  case 't':
637  player_get_title(pl, return_val, size);
638  break;
639 
640  case 'c':
641  snprintf(return_val, size, "%u", pl->ob->count);
642  break;
643 
644  case 'n':
645  snprintf(return_val, size, "\n");
646  break;
647 
648  case 'h':
649  snprintf(return_val, size, "%s", pl->peaceful ? "" : " <Hostile>");
650  break;
651 
652  case 'l':
653  snprintf(return_val, size, "%d", pl->ob->level);
654  break;
655 
656  case 'd':
657  snprintf(return_val, size, "%s", (QUERY_FLAG(pl->ob, FLAG_WIZ) ? " <WIZ>" : ""));
658  break;
659 
660  case 'a':
661  snprintf(return_val, size, "%s", (QUERY_FLAG(pl->ob, FLAG_AFK) ? " <AFK>" : ""));
662  break;
663 
664  case 'b':
665  snprintf(return_val, size, "%s", (pl->socket.is_bot == 1) ? " <BOT>" : "");
666  break;
667 
668  case 'm':
669  snprintf(return_val, size, "%s", pl->ob->map->path);
670  break;
671 
672  case 'M':
673  snprintf(return_val, size, "%s", pl->ob->map->name ? pl->ob->map->name : "Untitled");
674  break;
675 
676  case 'r':
677  snprintf(return_val, size, "%s", get_name_of_region_for_map(pl->ob->map));
678  break;
679 
680  case 'R':
681  snprintf(return_val, size, "%s", get_region_longname(get_region_by_map(pl->ob->map)));
682  break;
683 
684  case 'i':
685  snprintf(return_val, size, "%s", pl->socket.host);
686  break;
687 
688  case '%':
689  snprintf(return_val, size, "%%");
690  break;
691 
692  case '_':
693  snprintf(return_val, size, "_");
694  break;
695  }
696 }
697 
706 void command_afk(object *op, const char *params) {
707  if (QUERY_FLAG(op, FLAG_AFK)) {
708  CLEAR_FLAG(op, FLAG_AFK);
710  i18n(op, "You are no longer AFK"));
711  } else {
712  SET_FLAG(op, FLAG_AFK);
714  i18n(op, "You are now AFK"));
715  }
716 }
717 
726 void command_malloc(object *op, const char *params) {
727  malloc_info(op);
728 }
729 
738 void command_mapinfo(object *op, const char *params) {
739  current_map_info(op);
740 }
741 
750 void command_whereami(object *op, const char *params) {
752 }
753 
762 void command_maps(object *op, const char *params) {
763  map_info(op, params);
764 }
765 
774 void command_strings(object *op, const char *params) {
775  char stats[HUGE_BUF];
776 
777  ss_dump_statistics(stats, sizeof(stats));
779  "[fixed]%s\n",
780  stats);
781 
783  ss_dump_table(SS_DUMP_TOTALS, stats, sizeof(stats)));
784 }
785 
794 void command_time(object *op, const char *params) {
795  time_info(op);
796 }
797 
806 void command_archs(object *op, const char *params) {
807  arch_info(op);
808 }
809 
818 void command_hiscore(object *op, const char *params) {
819  hiscore_display(op, op == NULL ? 9999 : 50, params);
820 }
821 
830 void command_debug(object *op, const char *params) {
831  int i;
832 
833  if (*params == '\0' || !sscanf(params, "%d", &i)) {
835  i18n(op, "Global debug level is %d."),
836  settings.debug);
837  return;
838  }
839  settings.debug = (enum LogLevel)FABS(i);
841  i18n(op, "Debug level set to %d."),
842  i);
843 }
844 
845 
854 void command_wizpass(object *op, const char *params) {
855  int i;
856 
857  if (!op)
858  return;
859 
860  if (*params == '\0')
861  i = (QUERY_FLAG(op, FLAG_WIZPASS)) ? 0 : 1;
862  else
863  i = onoff_value(params);
864 
865  if (i) {
867  i18n(op, "You will now walk through walls."));
868  SET_FLAG(op, FLAG_WIZPASS);
869  } else {
871  i18n(op, "You will now be stopped by walls."));
873  }
874 }
875 
884 void command_wizcast(object *op, const char *params) {
885  int i;
886 
887  if (!op)
888  return;
889 
890  if (*params == '\0')
891  i = (QUERY_FLAG(op, FLAG_WIZCAST)) ? 0 : 1;
892  else
893  i = onoff_value(params);
894 
895  if (i) {
897  i18n(op, "You can now cast spells anywhere."));
898  SET_FLAG(op, FLAG_WIZCAST);
899  } else {
901  i18n(op, "You now cannot cast spells in no-magic areas."));
903  }
904 }
905 
914 void command_dumpallobjects(object *op, const char *params) {
915  object_dump_all();
916 }
917 
926 void command_dumpfriendlyobjects(object *op, const char *params) {
928 }
929 
938 void command_dumpallarchetypes(object *op, const char *params) {
940 }
941 
950 void command_ssdumptable(object *op, const char *params) {
951  ss_dump_table(SS_DUMP_TABLE, NULL, 0);
952 }
953 
962 void command_dumpmap(object *op, const char *params) {
963  if (op)
964  dump_map(op->map);
965 }
966 
975 void command_dumpallmaps(object *op, const char *params) {
976  dump_all_maps();
977 }
978 
987 void command_printlos(object *op, const char *params) {
988  if (op)
989  print_los(op);
990 }
991 
992 
1001 void command_version(object *op, const char *params) {
1003  MSG_TYPE_ADMIN_VERSION, "Crossfire "FULL_VERSION);
1004 }
1005 
1014 void command_listen(object *op, const char *params) {
1015  int i;
1016 
1017  if (*params == '\0' || !sscanf(params, "%d", &i)) {
1019  i18n(op, "Set listen to what (presently %d)?"),
1020  op->contr->listening);
1021  return;
1022  }
1023  if (i < 0) {
1025  i18n(op, "Verbose level should be positive."));
1026  return;
1027  }
1028  op->contr->listening = (char)i;
1030  i18n(op, "Your verbose level is now %d."),
1031  i);
1032 }
1033 
1045 void command_statistics(object *pl, const char *params) {
1046  char buf[MAX_BUF];
1047  uint32_t hours, minutes;
1048  uint64_t seconds; /* 64 bit to prevent overflows an intermediate results */
1049 
1050  if (!pl->contr)
1051  return;
1052  safe_strncpy(buf, i18n(pl, "[fixed] Experience: %"), sizeof(buf));
1053  strcat(buf, FMT64);
1055  buf,
1056  pl->stats.exp);
1057  safe_strncpy(buf, i18n(pl, "[fixed] Next Level: %"), sizeof(buf));
1058  strcat(buf, FMT64);
1060  buf,
1061  level_exp(pl->level+1, pl->expmul));
1062 
1064  i18n(pl, "[fixed]\nStat Nat/Real/Max"));
1065 
1067  i18n(pl, "[fixed]Str %2d/ %3d/%3d"),
1068  pl->contr->orig_stats.Str, pl->stats.Str, 20+pl->arch->clone.stats.Str);
1070  i18n(pl, "[fixed]Dex %2d/ %3d/%3d"),
1071  pl->contr->orig_stats.Dex, pl->stats.Dex, 20+pl->arch->clone.stats.Dex);
1073  i18n(pl, "[fixed]Con %2d/ %3d/%3d"),
1074  pl->contr->orig_stats.Con, pl->stats.Con, 20+pl->arch->clone.stats.Con);
1076  i18n(pl, "[fixed]Int %2d/ %3d/%3d"),
1077  pl->contr->orig_stats.Int, pl->stats.Int, 20+pl->arch->clone.stats.Int);
1079  i18n(pl, "[fixed]Wis %2d/ %3d/%3d"),
1080  pl->contr->orig_stats.Wis, pl->stats.Wis, 20+pl->arch->clone.stats.Wis);
1082  i18n(pl, "[fixed]Pow %2d/ %3d/%3d"),
1083  pl->contr->orig_stats.Pow, pl->stats.Pow, 20+pl->arch->clone.stats.Pow);
1085  i18n(pl, "[fixed]Cha %2d/ %3d/%3d"),
1086  pl->contr->orig_stats.Cha, pl->stats.Cha, 20+pl->arch->clone.stats.Cha);
1088  i18n(pl, "\nAttack Mode: %s"),
1089  i18n(pl, pl->contr->peaceful ? "Peaceful" : "Hostile"));
1093  float weap_speed = pl->weapon_speed; // This is the number of attacks per tick.
1094  if (weap_speed < 0.0f)
1095  weap_speed = 0.0f;
1096  if (weap_speed > 1.0f)
1097  weap_speed = 1.0f;
1098  // We will initially calculate the damage if every attack you perform hits.
1099  // This will serve as a baseline for future calculations
1100  float dps = (1000000.0f / max_time) * weap_speed * pl->stats.dam;
1101  // TODO: Account for opposing AC in calculations, make some sort of table/chart.
1102  // Then we round the floating-point.
1104  i18n(pl, "\n\nDam/Sec: %4d"), (int)(dps + 0.5f));
1105 
1106  /* max_time is in microseconds - thus divide by 1000000.
1107  * Need 64 bit values, as otherwise ticks_played * max_time
1108  * can easily overflow.
1109  * Note the message displayed here isn't really
1110  * perfect, since if max_time has been changed since the player started,
1111  * the time estimates use the current value. But I'm presuming that
1112  * max_time won't change very often. MSW 2009-12-01
1113  */
1114  seconds = (uint64_t)pl->contr->ticks_played * (uint64_t)max_time / 1000000;
1115  minutes = (uint32_t)seconds / 60;
1116  hours = minutes / 60;
1117  minutes = minutes % 60;
1118 
1120  "You have played this character for %u ticks, which amounts "
1121  "to %d hours and %d minutes.",
1122  pl->contr->ticks_played, hours, minutes);
1123 
1124 
1125  /* Can't think of anything else to print right now */
1126 }
1127 
1136 void command_fix_me(object *op, const char *params) {
1137  object_sum_weight(op);
1138  fix_object(op);
1139 }
1140 
1149 void command_players(object *op, const char *params) {
1150  char buf[MAX_BUF];
1151  char *t;
1152  DIR *dir;
1153 
1154  snprintf(buf, sizeof(buf), "%s/%s/", settings.localdir, settings.playerdir);
1155  t = buf+strlen(buf);
1156  if ((dir = opendir(buf)) != NULL) {
1157  const struct dirent *entry;
1158 
1159  while ((entry = readdir(dir)) != NULL) {
1160  /* skip '.' , '..' */
1161  if (!((entry->d_name[0] == '.' && entry->d_name[1] == '\0')
1162  || (entry->d_name[0] == '.' && entry->d_name[1] == '.' && entry->d_name[2] == '\0'))) {
1163  struct stat st;
1164 
1165  strcpy(t, entry->d_name);
1166  if (stat(buf, &st) == 0) {
1167  /* This was not posix compatible
1168  * if ((st.st_mode & S_IFMT)==S_IFDIR) {
1169  */
1170  if (S_ISDIR(st.st_mode)) {
1171  struct tm *tm = localtime(&st.st_mtime);
1172 
1174  i18n(op, "[fixed]%s\t%04d %02d %02d %02d %02d %02d"),
1175  entry->d_name,
1176  1900+tm->tm_year,
1177  1+tm->tm_mon,
1178  tm->tm_mday,
1179  tm->tm_hour,
1180  tm->tm_min,
1181  tm->tm_sec);
1182  }
1183  }
1184  }
1185  }
1186  }
1187  closedir(dir);
1188 }
1189 
1198 void command_applymode(object *op, const char *params) {
1199  unapplymode unapply = op->contr->unapply;
1200  static const char *const types[] = {
1201  "nochoice",
1202  "never",
1203  "always"
1204  };
1205 
1206  if (*params == '\0') {
1208  i18n(op, "applymode is set to %s"),
1209  types[op->contr->unapply]);
1210  return;
1211  }
1212 
1213  if (!strcmp(params, "nochoice"))
1215  else if (!strcmp(params, "never"))
1216  op->contr->unapply = unapply_never;
1217  else if (!strcmp(params, "always"))
1218  op->contr->unapply = unapply_always;
1219  else {
1221  i18n(op, "applymode: Unknown options %s, valid options are nochoice, never, always"),
1222  params);
1223  return;
1224  }
1226  i18n(op, "applymode%s set to %s"),
1227  (unapply == op->contr->unapply ? "" : " now"),
1228  types[op->contr->unapply]);
1229 }
1230 
1239 void command_bowmode(object *op, const char *params) {
1240  bowtype_t oldtype = op->contr->bowtype;
1241  static const char *const types[] = {
1242  "normal",
1243  "threewide",
1244  "spreadshot",
1245  "firenorth",
1246  "firene",
1247  "fireeast",
1248  "firese",
1249  "firesouth",
1250  "firesw",
1251  "firewest",
1252  "firenw",
1253  "bestarrow"
1254  };
1255  char buf[MAX_BUF];
1256  int i, found;
1257 
1258  if (*params == '\0') {
1260  i18n(op, "bowmode is set to %s"),
1261  types[op->contr->bowtype]);
1262  return;
1263  }
1264 
1265  for (i = 0, found = 0; i <= bow_bestarrow; i++) {
1266  if (!strcmp(params, types[i])) {
1267  found++;
1268  op->contr->bowtype = i;
1269  break;
1270  }
1271  }
1272  if (!found) {
1273  snprintf(buf, sizeof(buf), "bowmode: Unknown options %s, valid options are:", params);
1274  for (i = 0; i <= bow_bestarrow; i++) {
1275  strcat(buf, " ");
1276  strcat(buf, types[i]);
1277  if (i < bow_nw)
1278  strcat(buf, ",");
1279  else
1280  strcat(buf, ".");
1281  }
1283  return;
1284  }
1286  i18n(op, "bowmode%s set to %s"),
1287  (oldtype == op->contr->bowtype ? "" : " now"),
1288  types[op->contr->bowtype]);
1289  return;
1290 }
1291 
1300 void command_unarmed_skill(object *op, const char *params) {
1301  object *skill;
1302  size_t i;
1303 
1304  if (*params == '\0') {
1306  "unarmed skill is set to %s",
1307  op->contr->unarmed_skill ? op->contr->unarmed_skill: "nothing");
1308  return;
1309  }
1310 
1311  /* find_skill_by_name() will ready any skill tools - which
1312  * is OK for us because no unarmed skills require skill tools,
1313  * but this could be an issue if you reuse this code for other skills.
1314  */
1315  skill = find_skill_by_name(op, params);
1316 
1317  if (!skill) {
1319  "You do not know any such skill called %s",
1320  params);
1321  return;
1322  }
1323  for (i = 0; i < sizeof(unarmed_skills); i++)
1324  if (skill->subtype == unarmed_skills[i])
1325  break;
1326  if (i == sizeof(unarmed_skills)) {
1328  "%s is not an unarmed skill!",
1329  skill->name);
1330  return;
1331 
1332  }
1333 
1334  if (op->contr->unarmed_skill)
1336 
1337  /* Taking actual skill name is better than taking params,
1338  * as params could be something more than an exact skill name.
1339  */
1340  op->contr->unarmed_skill = add_string(skill->name);
1341 
1343  "unarmed skill is now set to %s",
1344  op->contr->unarmed_skill);
1345 }
1346 
1347 
1356 void command_petmode(object *op, const char *params) {
1357  petmode_t oldtype = op->contr->petmode;
1358  static const char *const types[] = {
1359  "normal",
1360  "sad",
1361  "defend",
1362  "arena"
1363  };
1364 
1365  if (*params == '\0') {
1367  i18n(op, "petmode is set to %s"),
1368  types[op->contr->petmode]);
1369  return;
1370  }
1371 
1372  if (!strcmp(params, "normal"))
1373  op->contr->petmode = pet_normal;
1374  else if (!strcmp(params, "sad"))
1375  op->contr->petmode = pet_sad;
1376  else if (!strcmp(params, "defend"))
1377  op->contr->petmode = pet_defend;
1378  else if (!strcmp(params, "arena"))
1379  op->contr->petmode = pet_arena;
1380  else {
1382  i18n(op, "petmode: Unknown options %s, valid options are normal, sad (seek and destroy), defend, arena"),
1383  params);
1384  return;
1385  }
1387  i18n(op, "petmode%s set to %s"),
1388  (oldtype == op->contr->petmode ? "" : " now"),
1389  types[op->contr->petmode]);
1390 }
1391 
1400 void command_showpets(object *op, const char *params) {
1401  objectlink *obl, *next;
1402  int counter = 0, target = 0;
1403  int have_shown_pet = 0;
1404  if (*params != '\0')
1405  target = atoi(params);
1406 
1407  for (obl = first_friendly_object; obl != NULL; obl = next) {
1408  object *ob = obl->ob;
1409 
1410  next = obl->next;
1411  if (object_get_owner(ob) == op) {
1412  if (target == 0) {
1413  if (counter == 0)
1415  i18n(op, "Pets:"));
1417  i18n(op, "%d %s - level %d"),
1418  ++counter, ob->name, ob->level);
1419  } else if (!have_shown_pet && ++counter == target) {
1421  i18n(op, "[fixed]level %d %s"),
1422  ob->level, ob->name);
1424  i18n(op, "[fixed]%d/%d HP, %d/%d SP"),
1425  ob->stats.hp, ob->stats.maxhp, ob->stats.sp, ob->stats.maxsp);
1426 
1427  /* this is not a nice way to do this, it should be made to be more like the statistics command */
1429  i18n(op, "[fixed]Str %d"),
1430  ob->stats.Str);
1432  i18n(op, "[fixed]Dex %d"),
1433  ob->stats.Dex);
1435  i18n(op, "[fixed]Con %d"),
1436  ob->stats.Con);
1438  i18n(op, "[fixed]Int %d"),
1439  ob->stats.Int);
1441  i18n(op, "[fixed]Wis %d"),
1442  ob->stats.Wis);
1444  i18n(op, "[fixed]Cha %d"),
1445  ob->stats.Cha);
1447  i18n(op, "[fixed]Pow %d"),
1448  ob->stats.Pow);
1450  i18n(op, "[fixed]wc %d damage %d ac %d"),
1451  ob->stats.wc, ob->stats.dam, ob->stats.ac);
1452  have_shown_pet = 1;
1453  }
1454  }
1455  }
1456  if (counter == 0)
1458  i18n(op, "You have no pets."));
1459  else if (target != 0 && have_shown_pet == 0)
1461  i18n(op, "No such pet."));
1462 }
1463 
1472 void command_usekeys(object *op, const char *params) {
1473  usekeytype oldtype = op->contr->usekeys;
1474  static const char *const types[] = {
1475  "inventory",
1476  "keyrings",
1477  "containers"
1478  };
1479 
1480  if (*params == '\0') {
1482  i18n(op, "usekeys is set to %s"),
1483  types[op->contr->usekeys]);
1484  return;
1485  }
1486 
1487  if (!strcmp(params, "inventory"))
1488  op->contr->usekeys = key_inventory;
1489  else if (!strcmp(params, "keyrings"))
1490  op->contr->usekeys = keyrings;
1491  else if (!strcmp(params, "containers"))
1492  op->contr->usekeys = containers;
1493  else {
1495  i18n(op, "usekeys: Unknown option %s, valid options are inventory, keyrings, containers"),
1496  params);
1497  return;
1498  }
1500  i18n(op, "usekeys%s set to %s"),
1501  (oldtype == op->contr->usekeys ? "" : " now"),
1502  types[op->contr->usekeys]);
1503 }
1504 
1513 void command_resistances(object *op, const char *params) {
1514  int i;
1515  if (!op)
1516  return;
1517 
1518  for (i = 0; i < NROFATTACKS; i++) {
1519  if (i == ATNR_INTERNAL)
1520  continue;
1521 
1523  i18n(op, "[fixed]%-20s %+5d"),
1524  attacktype_desc[i], op->resist[i]);
1525  }
1526 
1527  /* If dragon player, let's display natural resistances */
1528  if (is_dragon_pl(op)) {
1529  int attack;
1530  object *tmp;
1531 
1532  tmp = object_find_by_type_and_arch_name(op, FORCE, "dragon_skin_force");
1533  if (tmp != NULL) {
1535  i18n(op, "\nNatural skin resistances:"));
1536 
1537  for (attack = 0; attack < NROFATTACKS; attack++) {
1538  if (atnr_is_dragon_enabled(attack)) {
1540  i18n(op, "%s: %d"),
1541  change_resist_msg[attack], tmp->resist[attack]);
1542  }
1543  }
1544  }
1545  }
1546 }
1547 
1558 static void help_topics(object *op, int what) {
1559  DIR *dirp;
1560  struct dirent *de;
1561  char filename[MAX_BUF], line[HUGE_BUF];
1562  char suffix[MAX_BUF];
1563  int namelen;
1564  const char *language;
1565 
1566  language = i18n_get_language_code(op->contr->language);
1567  snprintf(suffix, sizeof(suffix), ".%s", language);
1568 
1569  switch (what) {
1570  case 1:
1571  snprintf(filename, sizeof(filename), "%s/wizhelp", settings.datadir);
1573  i18n(op, " Wiz commands:"));
1574  break;
1575 
1576  case 3:
1577  snprintf(filename, sizeof(filename), "%s/mischelp", settings.datadir);
1579  i18n(op, " Misc help:"));
1580  break;
1581 
1582  default:
1583  snprintf(filename, sizeof(filename), "%s/help", settings.datadir);
1585  i18n(op, " Commands:"));
1586  break;
1587  }
1588  if (!(dirp = opendir(filename)))
1589  return;
1590 
1591  line[0] = '\0';
1592  for (de = readdir(dirp); de; de = readdir(dirp)) {
1593  namelen = NAMLEN(de);
1594 
1595  if (namelen <= 2
1596  && *de->d_name == '.'
1597  && (namelen == 1 || de->d_name[1] == '.'))
1598  continue;
1599  if (strstr(de->d_name, suffix)) {
1600  strcat(line, strtok(de->d_name, "."));
1601  strcat(line, " ");
1602  }
1603  }
1605  line);
1606  closedir(dirp);
1607 }
1608 
1619 static void show_commands(object *op, int what) {
1620  char line[HUGE_BUF];
1621  int i, size;
1623 
1624  switch (what) {
1625  case 1:
1626  ap = WizCommands;
1627  size = WizCommandsSize;
1629  i18n(op, " Wiz commands:"));
1630  break;
1631 
1632  case 2:
1633  ap = CommunicationCommands;
1634  size = CommunicationCommandSize;
1636  i18n(op, " Communication commands:"));
1637  break;
1638 
1639  default:
1640  ap = Commands;
1641  size = CommandsSize;
1643  i18n(op, " Commands:"));
1644  break;
1645  }
1646 
1647  line[0] = '\0';
1648  for (i = 0; i < size; i++) {
1649  strcat(line, ap[i].name);
1650  strcat(line, " ");
1651  }
1653 }
1654 
1666 static int find_help_file(const char *name, const char *language, int wiz, char *path, int length) {
1667  struct stat st;
1668 
1669  snprintf(path, length, "%s/help/%s.%s", settings.datadir, name, language);
1670  if (stat(path, &st) == 0 && S_ISREG(st.st_mode)) {
1671  return 1;
1672  }
1673 
1674  if (strcmp(language, "en")) {
1675  snprintf(path, length, "%s/help/%s.en", settings.datadir, name);
1676  if (stat(path, &st) == 0 && S_ISREG(st.st_mode)) {
1677  return 1;
1678  }
1679  }
1680 
1681  if (!wiz)
1682  return 0;
1683 
1684  snprintf(path, length, "%s/wizhelp/%s.%s", settings.datadir, name, language);
1685  if (stat(path, &st) == 0 && S_ISREG(st.st_mode)) {
1686  return 1;
1687  }
1688  if (strcmp(language, "en")) {
1689  snprintf(path, length, "%s/wizhelp/%s.en", settings.datadir, name);
1690  if (stat(path, &st) == 0 && S_ISREG(st.st_mode)) {
1691  return 1;
1692  }
1693  }
1694 
1695  return 0;
1696 }
1697 
1706 void command_help(object *op, const char *params) {
1707  FILE *fp;
1708  char filename[MAX_BUF], line[MAX_BUF];
1709  int len;
1710  const char *language;
1711 
1712  /*
1713  * Main help page?
1714  */
1715  if (*params == '\0') {
1716  snprintf(filename, sizeof(filename), "%s/def_help", settings.datadir);
1717  if ((fp = fopen(filename, "r")) == NULL) {
1718  LOG(llevError, "Cannot open help file %s: %s\n", filename, strerror(errno));
1719  return;
1720  }
1721  while (fgets(line, MAX_BUF, fp)) {
1722  line[MAX_BUF-1] = '\0';
1723  len = strlen(line)-1;
1724  if (line[len] == '\n')
1725  line[len] = '\0';
1727  }
1728  fclose(fp);
1729  return;
1730  }
1731 
1732  /*
1733  * Topics list
1734  */
1735  if (!strcmp(params, "topics")) {
1736  help_topics(op, 3);
1737  help_topics(op, 0);
1738  if (QUERY_FLAG(op, FLAG_WIZ))
1739  help_topics(op, 1);
1740  return;
1741  }
1742 
1743  /*
1744  * Commands list
1745  */
1746  if (!strcmp(params, "commands")) {
1747  show_commands(op, 0);
1749  show_commands(op, 2); /* show comm commands */
1750  if (QUERY_FLAG(op, FLAG_WIZ)) {
1752  show_commands(op, 1);
1753  }
1754  return;
1755  }
1756 
1757  /*
1758  * User wants info about command
1759  */
1760  if (strchr(params, '.') || strchr(params, ' ') || strchr(params, '/')) {
1762  i18n(op, "Illegal characters in '%s'"),
1763  params);
1764  return;
1765  }
1766 
1767  language = i18n_get_language_code(op->contr->language);
1768 
1769  if (!find_help_file(params, language, QUERY_FLAG(op, FLAG_WIZ), filename, sizeof(filename))) {
1771  i18n(op, "No help available on '%s'"),
1772  params);
1773  return;
1774  }
1775 
1776  /*
1777  * Found that. Just cat it to screen.
1778  */
1779  if ((fp = fopen(filename, "r")) == NULL) {
1780  LOG(llevError, "Cannot open help file %s: %s\n", filename, strerror(errno));
1781  return;
1782  }
1783 
1785  i18n(op, "Help about '%s'"),
1786  params);
1787 
1788  while (fgets(line, MAX_BUF, fp)) {
1789  line[MAX_BUF-1] = '\0';
1790  len = strlen(line)-1;
1791  if (line[len] == '\n')
1792  line[len] = '\0';
1794  }
1795  fclose(fp);
1796 }
1797 
1808 int onoff_value(const char *line) {
1809  int i;
1810 
1811  if (sscanf(line, "%d", &i))
1812  return (i != 0);
1813 
1814  switch (line[0]) {
1815  case 'o':
1816  switch (line[1]) {
1817  case 'n':
1818  return 1; /* on */
1819  default:
1820  return 0; /* o[ff] */
1821  }
1822 
1823  case 'y': /* y[es] */
1824  case 'k': /* k[ylla] */
1825  case 's':
1826  case 'd':
1827  return 1;
1828 
1829  case 'n': /* n[o] */
1830  case 'e': /* e[i] */
1831  case 'u':
1832  default:
1833  return 0;
1834  }
1835 }
1836 
1845 void command_quit(object *op, const char *params) {
1846  if (QUERY_FLAG(op, FLAG_WAS_WIZ)) {
1847  draw_ext_info(NDI_UNIQUE, 0, op, MSG_TYPE_COMMAND, MSG_TYPE_ADMIN_DM, "Can't quit when in DM mode.");
1848  return;
1849  }
1850 
1852  i18n(op, "Quitting will delete your character.\nAre you sure you want to delete your character (y/n):"));
1853 
1855 }
1856 
1865 void command_sound(object *op, const char *params) {
1866  if (!(op->contr->socket.sound&SND_MUTE)) {
1867  op->contr->socket.sound = op->contr->socket.sound|SND_MUTE;
1869  i18n(op, "Sounds are turned off."));
1870  } else {
1871  op->contr->socket.sound = op->contr->socket.sound&~SND_MUTE;
1873  i18n(op, "The sounds are enabled."));
1874  }
1875  return;
1876 }
1877 
1887 void receive_player_name(object *op) {
1888  if (!check_name(op->contr, op->contr->write_buf+1)) {
1889  get_name(op);
1890  return;
1891  }
1892  FREE_AND_COPY(op->name, op->contr->write_buf+1);
1893  FREE_AND_COPY(op->name_pl, op->contr->write_buf+1);
1895  op->contr->name_changed = 1;
1896  get_password(op);
1897 }
1898 
1905 void receive_player_password(object *op) {
1906  unsigned int pwd_len = strlen(op->contr->write_buf);
1907 
1908  if (pwd_len <= 1 || pwd_len > 17) {
1909  if (op->contr->state == ST_CHANGE_PASSWORD_OLD
1911  || op->contr->state == ST_CHANGE_PASSWORD_CONFIRM) {
1913  i18n(op, "Password changed cancelled."));
1915  } else
1916  get_name(op);
1917  return;
1918  }
1919  /* To hide the password better */
1920  /* With currently clients, not sure if this is really the case - MSW */
1922 
1923  if (checkbanned(op->name, op->contr->socket.host)) {
1924  LOG(llevInfo, "Banned player tried to add: [%s@%s]\n", op->name, op->contr->socket.host);
1926  i18n(op, "You are not allowed to play."));
1927  get_name(op);
1928  return;
1929  }
1930 
1931  if (op->contr->state == ST_CONFIRM_PASSWORD) {
1932  if (!check_password(op->contr->write_buf+1, op->contr->password)) {
1934  i18n(op, "The passwords did not match."));
1935  get_name(op);
1936  return;
1937  }
1938  LOG(llevInfo, "LOGIN: New player named %s from ip %s\n", op->name, op->contr->socket.host);
1939  display_motd(op);
1941  i18n(op, "\nWelcome, Brave New Warrior!\n"));
1942  roll_again(op);
1944  return;
1945  }
1946 
1947  if (op->contr->state == ST_CHANGE_PASSWORD_OLD) {
1948  if (!check_password(op->contr->write_buf+1, op->contr->password)) {
1950  i18n(op, "You entered the wrong current password."));
1952  } else {
1953  send_query(&op->contr->socket, CS_QUERY_HIDEINPUT, i18n(op, "Please enter your new password, or blank to cancel:"));
1955  }
1956  return;
1957  }
1958 
1959  if (op->contr->state == ST_CHANGE_PASSWORD_NEW) {
1961  sizeof(op->contr->new_password));
1963  i18n(op, "Please confirm your new password, or blank to cancel:"));
1965  return;
1966  }
1967 
1968  if (op->contr->state == ST_CHANGE_PASSWORD_CONFIRM) {
1969  if (!check_password(op->contr->write_buf+1, op->contr->new_password)) {
1971  i18n(op, "The new passwords don't match!"));
1972  } else {
1974  i18n(op, "Password changed."));
1975  strncpy(op->contr->password, op->contr->new_password, 13);
1976  }
1978  return;
1979  }
1980 
1982  sizeof(op->contr->password));
1984  check_login(op, TRUE);
1985 }
1986 
1997 void command_title(object *op, const char *params) {
1998  char buf[MAX_BUF];
1999 
2000  if (settings.set_title == FALSE) {
2002  i18n(op, "You cannot change your title."));
2003  return;
2004  }
2005 
2006  /* dragon players cannot change titles */
2007  if (is_dragon_pl(op)) {
2009  i18n(op, "Dragons cannot change titles."));
2010  return;
2011  }
2012 
2013  if (*params == '\0') {
2014  char tmp[MAX_BUF];
2015 
2016  player_get_title(op->contr, tmp, sizeof(tmp));
2017  snprintf(buf, sizeof(buf), i18n(op, "Your title is '%s'."), tmp);
2019  return;
2020  }
2021  if (strcmp(params, "clear") == 0 || strcmp(params, "default") == 0) {
2022  if (!player_has_own_title(op->contr))
2024  i18n(op, "Your title is the default title."));
2025  else
2027  i18n(op, "Title set to default."));
2028  player_set_own_title(op->contr, "");
2029  return;
2030  }
2031 
2032  if ((int)strlen(params) >= MAX_NAME) {
2034  i18n(op, "Title too long."));
2035  return;
2036  }
2037  player_set_own_title(op->contr, params);
2038 }
2039 
2048 void command_save(object *op, const char *params) {
2049  if (get_map_flags(op->map, NULL, op->x, op->y, NULL, NULL)&P_NO_CLERIC) {
2051  i18n(op, "You can not save on unholy ground."));
2052  } else if (!op->stats.exp) {
2054  i18n(op, "You don't deserve to save yet."));
2055  } else {
2056  if (save_player(op, 1))
2058  i18n(op, "You have been saved."));
2059  else
2061  i18n(op, "SAVE FAILED!"));
2062  }
2063 }
2064 
2073 void command_peaceful(object *op, const char *params) {
2074  if ((op->contr->peaceful = !op->contr->peaceful))
2076  i18n(op, "You will not attack other players."));
2077  else
2079  i18n(op, "You will attack other players."));
2080 }
2081 
2090 void command_wimpy(object *op, const char *params) {
2091  int i;
2092 
2093  if (*params == '\0' || !sscanf(params, "%d", &i)) {
2095  i18n(op, "Your current wimpy level is %d."),
2096  op->run_away);
2097  return;
2098  }
2099 
2100  if (i < 0 || i > 100) {
2102  i18n(op, "Wimpy level should be between 1 and 100."),
2103  i);
2104  return;
2105  }
2106 
2108  i18n(op, "Your new wimpy level is %d."),
2109  i);
2110  op->run_away = i;
2111 }
2112 
2121 void command_brace(object *op, const char *params) {
2122  if (*params == '\0')
2123  op->contr->braced = !op->contr->braced;
2124  else
2125  op->contr->braced = onoff_value(params);
2126 
2127  if (op->contr->braced)
2129  i18n(op, "You are braced."));
2130  else
2132  i18n(op, "Not braced."));
2133 
2134  fix_object(op);
2135 }
2136 
2145 void command_kill_pets(object *op, const char *params) {
2146  objectlink *obl, *next;
2147  int counter = 0, removecount = 0;
2148 
2149  if (*params == '\0') {
2150  pets_terminate_all(op);
2152  i18n(op, "Your pets have been killed."));
2153  } else {
2154  int target = atoi(params);
2155  for (obl = first_friendly_object; obl != NULL; obl = next) {
2156  object *ob = obl->ob;
2157  next = obl->next;
2158  if (object_get_owner(ob) == op)
2159  if (++counter == target || (target == 0 && !strcasecmp(ob->name, params))) {
2160  if (!QUERY_FLAG(ob, FLAG_REMOVED))
2161  object_remove(ob);
2164  removecount++;
2165  }
2166  }
2167  if (removecount != 0)
2169  i18n(op, "Killed %d pets."),
2170  removecount);
2171  else
2173  i18n(op, "Couldn't find any suitable pets to kill."));
2174  }
2175 }
2176 
2185 void command_passwd(object *pl, const char *params) {
2186  /* If old client, this is the way you change your password. */
2187  if (pl->contr->socket.login_method < 1){
2188  send_query(&pl->contr->socket, CS_QUERY_HIDEINPUT, i18n(pl, "Password change.\nPlease enter your current password, or empty string to cancel."));
2189 
2191  }
2192  /* If new client (login_method = 2) or jxclient (login_method = 1), changing the password does nothing anyway, so error out */
2193  else{
2195  i18n(pl, "passwd is maintained for older clients that do not support the account system. Please use the 'Password' button in your character selection screen to change your password."));
2196  }
2197 }
2198 
2208 void do_harvest(object *pl, int dir, object *skill) {
2209  int16_t x, y;
2210  int count = 0, proba; /* Probability to get the item, 100 based. */
2211  int level, exp;
2212  object *found[10]; /* Found items that can be harvested. */
2213  mapstruct *map;
2214  object *item, *inv;
2215  sstring trace, ttool, tspeed, race, tool, slevel, sexp;
2216  float speed;
2217 
2218  x = pl->x+freearr_x[dir];
2219  y = pl->y+freearr_y[dir];
2220  map = pl->map;
2221 
2222  if (!pl->type == PLAYER)
2223  return;
2224 
2225  if (!map)
2226  return;
2227 
2228  if (get_map_flags(map, &map, x, y, &x, &y)&P_OUT_OF_MAP) {
2229  draw_ext_info_format(NDI_WHITE, 0, pl, MSG_TYPE_SKILL, MSG_TYPE_SKILL_FAILURE, "You can't %s anything here.", skill->slaying);
2230  return;
2231  }
2232 
2233  if (!pl->chosen_skill || pl->chosen_skill->skill != skill->skill)
2234  return;
2235 
2236  trace = object_get_value(pl->chosen_skill, "harvest_race");
2237  ttool = object_get_value(pl->chosen_skill, "harvest_tool");
2238  tspeed = object_get_value(pl->chosen_skill, "harvest_speed");
2239  if (!trace || strcmp(trace, "") == 0 || !ttool || strcmp(ttool, "") == 0 || !tspeed || strcmp(tspeed, "") == 0) {
2240  draw_ext_info_format(NDI_WHITE, 0, pl, MSG_TYPE_SKILL, MSG_TYPE_SKILL_FAILURE, "You can't %s anything here.", skill->slaying);
2241  LOG(llevError, "do_harvest: tool %s without harvest_[race|tool|speed]\n", pl->chosen_skill->name);
2242  return;
2243  }
2244 
2245  item = GET_MAP_OB(map, x, y);
2246  while (item && count < 10) {
2247  FOR_INV_PREPARE(item, inv) {
2248  if (object_get_value(inv, "harvestable") == NULL)
2249  continue;
2250  race = object_get_value(inv, "harvest_race");
2251  tool = object_get_value(inv, "harvest_tool");
2252  slevel = object_get_value(inv, "harvest_level");
2253  sexp = object_get_value(inv, "harvest_exp");
2254  if (race && (!slevel || !sexp)) {
2255  LOG(llevError, "do_harvest: item %s without harvest_[level|exp]\n", inv->name);
2256  continue;
2257  }
2258  if (race == trace && (!tool || tool == ttool))
2259  found[count++] = inv;
2260  } FOR_INV_FINISH();
2261  item = item->above;
2262  }
2263  if (count == 0) {
2264  draw_ext_info_format(NDI_WHITE, 0, pl, MSG_TYPE_SKILL, MSG_TYPE_SKILL_FAILURE, "You can't %s anything here.", skill->slaying);
2265  return;
2266  }
2267 
2268  inv = found[rndm(0, count-1)];
2269  assert(inv);
2270 
2271  slevel = object_get_value(inv, "harvest_level");
2272  sexp = object_get_value(inv, "harvest_exp");
2273  level = atoi(slevel);
2274  exp = atoi(sexp);
2275 
2276  speed = atof(tspeed);
2277  if (speed < 0)
2278  speed = -speed*pl->speed;
2279  pl->speed_left -= speed;
2280 
2281 
2282  /* Now we found something to harvest, randomly try to get it. */
2283  if (level > skill->level+10) {
2284  draw_ext_info_format(NDI_WHITE, 0, pl, MSG_TYPE_SKILL, MSG_TYPE_SKILL_FAILURE, "You fail to %s anything.", skill->slaying);
2285  return;
2286  }
2287 
2288  if (level >= skill->level)
2289  /* Up to 10 more levels, 1 to 11 percent probability. */
2290  proba = 10+skill->level-level;
2291  else if (skill->level <= level+10)
2292  proba = 10+(skill->level-level)*2;
2293  else
2294  proba = 30;
2295 
2296  if (proba <= random_roll(0, 100, pl, 1)) {
2297  draw_ext_info_format(NDI_WHITE, 0, pl, MSG_TYPE_SKILL, MSG_TYPE_SKILL_FAILURE, "You fail to %s anything.", skill->slaying);
2298  return;
2299  }
2300 
2301  /* Check the new item can fit into inventory.
2302  * Fixes bug #3060474: fishing puts more fishes into inventory than you can carry. */
2303  if (((uint32_t)(pl->weight + pl->carrying + inv->weight)) > get_weight_limit(pl->stats.Str)) {
2304  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);
2305  return;
2306  }
2307 
2308  /* Ok, got it. */
2309  item = object_new();
2310  object_copy_with_inv(inv, item);
2311  object_set_value(item, "harvestable", NULL, 0);
2312  if (QUERY_FLAG(item, FLAG_MONSTER)) {
2313  int spot = object_find_free_spot(item, pl->map, pl->x, pl->y, 0, SIZEOFFREE);
2314  if (spot == -1) {
2315  /* Better luck next time...*/
2316  object_remove(item);
2317  draw_ext_info_format(NDI_WHITE, 0, pl, MSG_TYPE_SKILL, MSG_TYPE_SKILL_FAILURE, "You fail to %s anything.", skill->slaying);
2318  return;
2319  }
2320  object_insert_in_map_at(item, pl->map, NULL, 0, pl->x+freearr_x[spot], pl->y+freearr_y[spot]);
2321  draw_ext_info_format(NDI_WHITE, 0, pl, MSG_TYPE_SKILL, MSG_TYPE_SKILL_FAILURE, "You %s a %s!", skill->slaying, item->name);
2322  } else {
2323  item = object_insert_in_ob(item, pl);
2324  draw_ext_info_format(NDI_WHITE, 0, pl, MSG_TYPE_SKILL, MSG_TYPE_SKILL_FAILURE, "You %s some %s", skill->slaying, item->name);
2325  }
2326 
2327  /* Get exp */
2328  change_exp(pl, exp, skill->name, SK_EXP_ADD_SKILL);
2329 
2330  return;
2331 }
#define MSG_TYPE_COMMAND_MAPS
Definition: newclient.h:500
void draw_ext_info_format(int flags, int pri, const object *pl, uint8_t type, uint8_t subtype, const char *format,...)
Sends message to player(s).
Definition: main.c:315
Error, serious thing.
Definition: logger.h:11
uint8_t login_method
Login method this client is using.
Definition: newserver.h:140
void command_petmode(object *op, const char *params)
Player wants to change how her pets behave.
Definition: c_misc.c:1356
char path[HUGE_BUF]
Filename of the map.
Definition: map.h:365
void command_save(object *op, const char *params)
Player wants to get saved.
Definition: c_misc.c:2048
Will unapply whatever is necessary - this goes beyond no choice - if there are multiple ojbect of the...
Definition: player.h:65
void command_afk(object *op, const char *params)
Toggles the afk status of a player.
Definition: c_misc.c:706
int8_t Int
Definition: living.h:35
#define NUM_BODY_LOCATIONS
Number of body locations.
Definition: object.h:13
One player.
Definition: player.h:92
Sound-related defines.
Use keys in inventory and active containers.
Definition: player.h:55
void command_malloc(object *op, const char *params)
Display memory information.
Definition: c_misc.c:726
int8_t ac
Armour Class, how hard to hit, the lower the better.
Definition: living.h:37
void command_help(object *op, const char *params)
Player is asking for some help.
Definition: c_misc.c:1706
#define ST_GET_PARTY_PASSWORD
Player tried to join a password-protected party.
Definition: define.h:585
void display_who_entry(object *op, player *pl, const char *format)
Display a line of &#39;who&#39; to op, about pl, using the formatting specified by format.
Definition: c_misc.c:574
void command_unarmed_skill(object *op, const char *params)
Player wants to change prefered unarmed skill.
Definition: c_misc.c:1300
struct mapdef mapstruct
This is a game-map.
void command_who(object *op, const char *params)
&#39;who&#39; command.
Definition: c_misc.c:557
command_array_struct Commands[]
Normal game commands.
Definition: commands.c:36
Information.
Definition: logger.h:12
const int WizCommandsSize
Length of WizCommands array.
Definition: commands.c:265
Fire north-west whatever the facing direction.
Definition: player.h:39
void roll_again(object *op)
Ask the player what to do with the statistics.
Definition: player.c:1112
treasureliststruct represents one logical group of items to be generated together.
Definition: treasure.h:82
int64_t level_exp(int level, double expmul)
Returns how much experience is needed for a player to become the given level.
Definition: living.c:1822
Attack other players in arena.
Definition: player.h:48
int check_name(player *me, const char *name)
Ensure player&#39;s name is valid.
Definition: login.c:162
void command_wizpass(object *op, const char *params)
Wizard toggling wall-crossing.
Definition: c_misc.c:854
Used to link together several objects.
Definition: object.h:442
#define SET_FLAG(xyz, p)
Definition: define.h:223
void command_maps(object *op, const char *params)
&#39;maps&#39; command.
Definition: c_misc.c:762
bool check_password(const char *typed, const char *crypted)
Hash a password and compare it to the stored version.
Definition: server.c:100
region * get_region_by_name(const char *region_name)
Gets a region by name.
Definition: region.c:46
#define FABS(x)
Decstations have trouble with fabs()...
Definition: define.h:22
uint32_t braced
Will not move if braced, only attack.
Definition: player.h:124
#define MSG_TYPE_COMMAND_CONFIG
bowmode, petmode, applymode
Definition: newclient.h:505
void player_get_title(const struct pl *pl, char *buf, size_t bufsize)
Returns the player&#39;s title.
Definition: player.c:224
#define NDI_WHITE
Definition: newclient.h:222
EXTERN int num_animations
Definition: global.h:166
uint32_t name_changed
If true, the player has set a name.
Definition: player.h:130
#define FLAG_USE_ARMOUR
(Monster) can wear armour/shield/helmet
Definition: define.h:296
void command_motd(object *op, const char *params)
Display the message of the day.
Definition: c_misc.c:169
char who_wiz_format[MAX_BUF]
The format that the who command should use when called by a dm.
Definition: global.h:274
int region_is_child_of_region(const region *child, const region *r)
Checks if a region is a child of another.
Definition: region.c:190
uint32_t map_size(mapstruct *m)
Calculate map size without intermediate sign extension.
Definition: map.c:830
One party.
Definition: party.h:10
EXTERN objectlink * first_friendly_object
Objects monsters will go after.
Definition: global.h:123
void object_copy_with_inv(const object *src_ob, object *dest_ob)
copy an object with an inventory...
Definition: object.c:975
int16_t players
How many players are on this level right now.
Definition: map.h:344
Shared-strings defines.
void command_dumpallobjects(object *op, const char *params)
Various object-related statistics.
Definition: c_misc.c:914
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:62
int login_order
Definition: c_misc.c:458
int save_player(object *op, int flag)
Saves a player to disk.
Definition: login.c:211
uint32_t in_memory
Combination of IN_MEMORY_xxx flags.
Definition: map.h:345
const char * playerdir
Where the player files are.
Definition: global.h:246
#define MAP_ENTER_X(m)
Default X coordinate for map enter.
Definition: map.h:85
void free_string(sstring str)
This will reduce the refcount, and if it has reached 0, str will be freed.
Definition: shstr.c:280
signed long object_sum_weight(object *op)
object_sum_weight() is a recursive function which calculates the weight an object is carrying...
Definition: object.c:311
void command_brace(object *op, const char *params)
Player toggles her braced status.
Definition: c_misc.c:2121
#define HUGE_BUF
Used for messages - some can be quite long.
Definition: define.h:37
const char * object_get_value(const object *op, const char *const key)
Get an extra value by key.
Definition: object.c:4246
#define SND_MUTE
Don&#39;t sent anything for now.
Definition: sounds.h:14
#define SS_DUMP_TOTALS
Definition: shstr.h:47
#define ST_CHANGE_PASSWORD_CONFIRM
Player is confirming new password.
Definition: define.h:588
#define MAP_HEIGHT(m)
Map height.
Definition: map.h:80
void command_kill_pets(object *op, const char *params)
Player wants to get rid of pets.
Definition: c_misc.c:2145
char new_password[16]
2 (seed) + 11 (crypted) + 1 (EOS) + 2 (safety) = 16
Definition: player.h:177
object clone
An object from which to do object_copy()
Definition: object.h:470
struct treasureliststruct * next
Next treasure-item in linked list.
Definition: treasure.h:89
socket_struct socket
Socket information for this player.
Definition: player.h:94
short freearr_x[SIZEOFFREE]
X offset when searching around a spot.
Definition: object.c:65
#define ST_CONFIRM_PASSWORD
New character, confirm password.
Definition: define.h:584
int object_count_active(void)
Objects statistics.
Definition: object.c:1598
const char * slaying
Which race to do double damage to.
Definition: object.h:319
region * get_region_by_map(mapstruct *m)
Gets a region from a map.
Definition: region.c:74
DIR * opendir(const char *)
Opens a directory for reading.
Definition: win32.c:37
void command_dumpallmaps(object *op, const char *params)
Various map-related statistics.
Definition: c_misc.c:975
void command_dumpmap(object *op, const char *params)
Various map-related statistics.
Definition: c_misc.c:962
void dump_all_archetypes(void)
Dumps all archetypes to debug-level output.
Definition: arch.c:242
uint8_t subtype
Subtype of object.
Definition: object.h:339
#define FLAG_USE_WEAPON
(Monster) can wield weapons
Definition: define.h:297
void command_resistances(object *op, const char *params)
Players wants to know her resistances.
Definition: c_misc.c:1513
int checkbanned(const char *login, const char *host)
Check if a player and/or host is banned.
Definition: ban.c:32
int64_t exp
Experience.
Definition: living.h:46
struct obj * above
Pointer to the object stacked above this one.
Definition: object.h:288
void object_dump_all(void)
Dumps all objects to console.
Definition: object.c:450
double expmul
needed experience = (calc_exp*expmul) - means some races/classes can need less/more exp to gain level...
Definition: object.h:395
#define ST_CHANGE_PASSWORD_NEW
Player is entering new password.
Definition: define.h:587
int language
The language the player wishes to use.
Definition: player.h:201
#define FLAG_AFK
Player is AFK.
Definition: define.h:377
treasure is one element in a linked list, which together consist of a complete treasure-list.
Definition: treasure.h:63
#define TRUE
Definition: compat.h:10
player * find_player(const char *plname)
Find a player by her full name.
Definition: player.c:54
LogLevel debug
Default debugging level.
Definition: global.h:240
body_locations_struct body_locations[NUM_BODY_LOCATIONS]
The ordering of this is actually doesn&#39;t make a difference However, for ease of use, new entries should go at the end so those people that debug the code that get used to something being in the location 4 don&#39;t get confused.
Definition: item.c:54
#define FALSE
Definition: compat.h:11
void remove_friendly_object(object *op)
Removes the specified object from the linked list of friendly objects.
Definition: friend.c:56
int16_t sp
Spell points.
Definition: living.h:41
uint32_t get_weight_limit(int stat)
Definition: living.c:2255
#define SS_DUMP_TABLE
Definition: shstr.h:46
Use keys in inventory and active key rings.
Definition: player.h:54
#define MSG_TYPE_COMMAND_STATISTICS
Definition: newclient.h:504
Try to find an arrow matching the target.
Definition: player.h:40
Definition: win32.h:110
Global type definitions and header inclusions.
#define safe_strncpy
Definition: compat.h:23
uint32_t hidden
If True, player (DM) is hidden from view.
Definition: player.h:132
char * partyname
Party name.
Definition: party.h:14
void pets_terminate_all(object *owner)
Removes all pets someone owns.
Definition: pets.c:231
Will not unapply objects automatically.
Definition: player.h:64
#define ST_ROLL_STAT
New character, rolling stats.
Definition: define.h:579
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.c:310
The archetype structure is a set of rules on how to generate and manipulate objects which point to ar...
Definition: object.h:465
#define ST_PLAYING
Usual state.
Definition: define.h:577
void command_whereami(object *op, const char *params)
&#39;whereami&#39; command.
Definition: c_misc.c:750
char * host
Which host it is connected from (ip address).
Definition: newserver.h:110
const int CommunicationCommandSize
Length of the CommunicationCommands array.
Definition: commands.c:199
void command_debug(object *op, const char *params)
Player wants to see/change the debug level.
Definition: c_misc.c:830
int16_t maxsp
Max spell points.
Definition: living.h:42
int8_t Con
Definition: living.h:35
#define FLAG_REMOVED
Object is not in any map or invenory.
Definition: define.h:232
int16_t hp
Hit Points.
Definition: living.h:39
#define MAP_WHEN_RESET(m)
This is when the map will reset.
Definition: map.h:62
char namebuf[MAX_BUF]
Definition: c_misc.c:457
region * get_region_from_string(const char *name)
Tries to find a region that &#39;name&#39; corresponds to.
Definition: region.c:121
void command_dumpfriendlyobjects(object *op, const char *params)
Various friendly object-related statistics.
Definition: c_misc.c:926
short freearr_y[SIZEOFFREE]
Y offset when searching around a spot.
Definition: object.c:71
partylist * party
Party this player is part of.
Definition: player.h:186
void hiscore_display(object *op, int max, const char *match)
Displays the high score file.
Definition: hiscore.c:386
void get_name(object *op)
Waiting for the player&#39;s name.
Definition: player.c:854
void current_region_info(object *op)
&#39;whereami&#39; command.
Definition: c_misc.c:341
object * ob
Item to link to.
Definition: object.h:443
uint32_t ticks_played
How many ticks this player has played.
Definition: player.h:203
#define MSG_TYPE_ADMIN_DM
DM related admin actions.
Definition: newclient.h:475
int rndm(int min, int max)
Returns a number between min and max.
Definition: utils.c:161
void command_printlos(object *op, const char *params)
Various LOS-related statistics.
Definition: c_misc.c:987
#define NAMLEN(dirent)
Definition: global.h:221
const char * get_region_longname(const region *r)
Gets the longname of a region.
Definition: region.c:217
void command_fix_me(object *op, const char *params)
Wrapper to fix a player.
Definition: c_misc.c:1136
int player_has_own_title(const struct pl *pl)
Returns whether the player has a custom title.
Definition: player.c:239
char * name
Name of map as given by its creator.
Definition: map.h:328
#define MAP_IN_MEMORY
Map is fully loaded.
Definition: map.h:130
struct obj * chosen_skill
The skill chosen to use.
Definition: object.h:386
int object_set_value(object *op, const char *key, const char *value, int add_key)
Updates the key in op to value.
Definition: object.c:4375
void object_free_drop_inventory(object *ob)
Frees everything allocated by an object, removes it from the list of used objects, and puts it on the list of free objects.
Definition: object.c:1368
int16_t y
Position in the map for this object.
Definition: object.h:326
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.c:1921
#define NDI_RED
Definition: newclient.h:224
int16_t maxhp
Max hit points.
Definition: living.h:40
char * name
Shortend name of the region as maps refer to it.
Definition: map.h:278
#define MSG_TYPE_COMMAND
Responses to commands, eg, who.
Definition: newclient.h:379
uint32_t sound
Client sound mode.
Definition: newserver.h:123
Definition: win32.h:120
struct artifactliststruct * next
Next list of artifacts.
Definition: artifact.h:29
object * object_new(void)
Grabs an object from the list of unused objects, makes sure it is initialised, and returns it...
Definition: object.c:1037
const char * name_pl
The plural name of the object.
Definition: object.h:315
usekeytype
How to use keys.
Definition: player.h:52
void player_set_own_title(struct pl *pl, const char *title)
Sets the custom title.
Definition: player.c:264
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.c:2690
void send_query(socket_struct *ns, uint8_t flags, const char *text)
Asks the client to query the user.
Definition: request.c:674
void command_players(object *op, const char *params)
Display all known players.
Definition: c_misc.c:1149
float speed_left
How much speed is left to spend this round.
Definition: object.h:329
unapplymode unapply
Method for auto unapply.
Definition: player.h:108
#define MSG_TYPE_COMMAND_ERROR
Bad syntax/can&#39;t use command.
Definition: newclient.h:509
Defines for loader.l / loader.c.
void command_wizcast(object *op, const char *params)
Wizard toggling "cast everywhere" ability.
Definition: c_misc.c:884
signed short int16_t
Definition: win32.h:160
void command_passwd(object *pl, const char *params)
Player is asking to change password.
Definition: c_misc.c:2185
enum _petmode petmode_t
Petmode.
int32_t weight
Attributes of the object.
Definition: object.h:365
int8_t Wis
Definition: living.h:35
#define ST_CONFIRM_QUIT
Player used the &#39;quit&#39; command, make sure that&#39;s ok.
Definition: define.h:581
void get_password(object *op)
Waiting for the player&#39;s password.
Definition: player.c:866
struct mapdef * map
Pointer to the map in which this object is present.
Definition: object.h:297
int is_dragon_pl(const object *op)
Checks if player is a dragon.
Definition: player.c:114
struct regiondef * next
Pointer to next region, NULL for the last one.
Definition: map.h:277
void receive_player_password(object *op)
A player just entered her password, including for changing it.
Definition: c_misc.c:1905
This is a game region.
Definition: map.h:276
#define snprintf
Definition: win32.h:46
char const * newhash(char const password[static 1])
Definition: server.c:87
void player_set_state(player *pl, uint8_t state)
Set the player&#39;s state to the specified one.
Definition: player.c:4457
#define MAP_TIMEOUT(m)
Definition: map.h:66
void dump_all_maps(void)
Prints out debug-information about all maps.
Definition: map.c:270
#define FOR_INV_FINISH()
Finishes FOR_INV_PREPARE().
Definition: define.h:712
char * msg
Message map creator may have left.
Definition: map.h:361
#define FMT64
Definition: compat.h:12
type_definition ** types
Defined types.
int16_t dam
How much damage this object does when hitting.
Definition: living.h:45
void command_rules(object *op, const char *params)
Display the server rules.
Definition: c_misc.c:181
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.c:1198
int object_count_free(void)
Objects statistics.
Definition: object.c:1560
void do_harvest(object *pl, int dir, object *skill)
Player is trying to harvest something.
Definition: c_misc.c:2208
int32_t carrying
How much weight this object contains.
Definition: object.h:367
const char * name
The name of the object, obviously...
Definition: object.h:311
living orig_stats
Permanent real stats of player.
Definition: player.h:148
long seconds(void)
Return wall clock time in seconds.
Definition: time.c:344
void command_mapinfo(object *op, const char *params)
&#39;mapinfo&#39; command.
Definition: c_misc.c:738
#define ATNR_INTERNAL
Definition: attack.h:72
struct archt * more
Next part of a linked object.
Definition: object.h:469
static void show_commands(object *op, int what)
Helper function to display commands.
Definition: c_misc.c:1619
uint8_t state
Input state of the player (name, password, etc).
Definition: player.h:118
#define CS_QUERY_SINGLECHAR
Single character response expected.
Definition: newclient.h:67
#define MSG_TYPE_COMMAND_WHO
Definition: newclient.h:499
uint32_t counter
A generic counter for holding temporary data.
Definition: map.h:294
#define MAP_ENTER_Y(m)
Default Y coordinate for map enter.
Definition: map.h:87
uint8_t listening
Which priority will be used in info_all.
Definition: player.h:120
int8_t Cha
Definition: living.h:35
EXTERN const char *const change_resist_msg[NROFATTACKS]
Definition: attack.h:135
#define SIZEOFFREE
Definition: define.h:154
#define P_OUT_OF_MAP
This space is outside the map.
Definition: map.h:251
EXTERN Animations * animations
Definition: global.h:165
struct pl * contr
Pointer to the player which control this object.
Definition: object.h:276
char * ss_dump_table(int what, char *buf, size_t size)
Dump the contents of the share string tables.
Definition: shstr.c:354
#define MSG_TYPE_SKILL_FAILURE
Failure in using skill.
Definition: newclient.h:585
void command_hiscore(object *op, const char *params)
Player is asking for the hiscore.
Definition: c_misc.c:818
This represents all archetypes for one particular object type.
Definition: artifact.h:26
EXTERN treasurelist * first_treasurelist
First treasure.
Definition: global.h:120
void time_info(object *op)
Players wants to know the time.
Definition: time.c:294
char d_name[_MAX_FNAME+1]
Definition: win32.h:114
void command_listen(object *op, const char *params)
Change the player&#39;s listen level.
Definition: c_misc.c:1014
float speed
The overall speed of this object.
Definition: object.h:328
unsigned __int64 uint64_t
Definition: win32.h:167
struct regiondef * parent
Pointer to the region that is a parent of the current region, if a value isn&#39;t defined in the current...
Definition: map.h:286
void command_whereabouts(object *op, const char *params)
&#39;whereabouts&#39; command.
Definition: c_misc.c:418
#define QUERY_FLAG(xyz, p)
Definition: define.h:225
#define MSG_TYPE_ADMIN_VERSION
version info
Definition: newclient.h:479
#define CLEAR_FLAG(xyz, p)
Definition: define.h:224
EXTERN artifactlist * first_artifactlist
First artifact.
Definition: global.h:121
uint32_t is_bot
Client shouldn&#39;t be reported to metaserver.
Definition: newserver.h:119
EXTERN const char *const attacktype_desc[NROFATTACKS]
Definition: attack.h:138
#define FLAG_WIZ
Object has special privilegies.
Definition: define.h:231
void change_exp(object *op, int64_t exp, const char *skill_name, int flag)
Changes experience to a player/monster.
Definition: living.c:2076
void command_language(object *op, const char *params)
This is the &#39;language&#39; command.
Definition: c_misc.c:85
void command_news(object *op, const char *params)
Display the server news.
Definition: c_misc.c:193
void dump_map(const mapstruct *m)
Prints out debug-information about a map.
Definition: map.c:247
#define MAX_BUF
Used for all kinds of things.
Definition: define.h:35
This is one artifact, ie one special item.
Definition: artifact.h:14
command_array_struct WizCommands[]
Wizard commands.
Definition: commands.c:202
Standard mode/.
Definition: player.h:45
void command_body(object *op, const char *params)
This command dumps the body information for object *op.
Definition: c_misc.c:128
LogLevel
Log levels for the LOG() function.
Definition: logger.h:10
char who_format[MAX_BUF]
The format that the who command should use.
Definition: global.h:273
#define MSG_TYPE_ADMIN
Definition: newclient.h:377
uint32_t peaceful
If set, won&#39;t attack friendly creatures.
Definition: player.h:131
enum _bowtype bowtype_t
Bow firing mode.
int16_t x
Definition: object.h:326
int players_on_map(mapstruct *m, int show_all)
Returns the count of players on a map, calculated from player list.
Definition: swap.c:276
void command_wimpy(object *op, const char *params)
Player wants to change how soon she&#39;ll flee.
Definition: c_misc.c:2090
const char * skill
Name of the skill this object uses/grants.
Definition: object.h:321
int8_t wc
Weapon Class, how skilled, the lower the better.
Definition: living.h:36
unsigned short uint16_t
Definition: win32.h:163
void command_sound(object *op, const char *params)
Player wants to change sound status.
Definition: c_misc.c:1865
uint16_t difficulty
What level the player should be to play here.
Definition: map.h:343
int8_t Str
Definition: living.h:35
int16_t resist[NROFATTACKS]
Resistance adjustments for attacks.
Definition: object.h:341
object * ob
The object representing the player.
Definition: player.h:158
EXTERN long nrofartifacts
Only used in malloc_info().
Definition: global.h:148
const char * sstring
Strings that should be manipulated through add_string() and free_string().
Definition: global.h:40
int32_t timeout
Swapout is set to this.
Definition: map.h:341
See Player.
Definition: object.h:107
unsigned int uint32_t
Definition: win32.h:162
const char * datadir
Read only data files.
Definition: global.h:244
EXTERN long nrofallowedstr
Only used in malloc_info().
Definition: global.h:149
void command_showpets(object *op, const char *params)
Players wants to know her pets.
Definition: c_misc.c:1400
bowtype_t bowtype
Which firemode?
Definition: player.h:101
void command_ssdumptable(object *op, const char *params)
Various string-related statistics.
Definition: c_misc.c:950
Represents one command.
Definition: commands.h:37
int8_t body_info[NUM_BODY_LOCATIONS]
Body info as loaded from the file.
Definition: object.h:372
void print_los(object *op)
Debug-routine which dumps the array which specifies the visible area of a player. ...
Definition: los.c:602
This structure contains all information related to one map square.
Definition: map.h:258
#define FREE_AND_COPY(sv, nv)
Release the shared string if not NULL, and make it a reference to nv.
Definition: global.h:213
#define MSG_TYPE_COMMAND_MALLOC
Definition: newclient.h:502
static void malloc_info(object *op)
Sends various memory-related statistics.
Definition: c_misc.c:203
void command_time(object *op, const char *params)
Players asks for the time.
Definition: c_misc.c:794
const int CommandsSize
Length of Commands array.
Definition: commands.c:126
const char * localdir
Read/write data files.
Definition: global.h:245
char password[16]
2 (seed) + 11 (crypted) + 1 (EOS) + 2 (safety) = 16
Definition: player.h:176
tag_t count
Unique object number for this object.
Definition: object.h:299
living stats
Str, Con, Dex, etc.
Definition: object.h:368
#define FLAG_WIZCAST
The wizard can cast spells in no-magic area.
Definition: define.h:290
#define MSG_TYPE_LAST
Definition: newclient.h:396
int8_t Dex
Definition: living.h:35
void command_statistics(object *pl, const char *params)
Prints out some useful information for the character.
Definition: c_misc.c:1045
struct archt * arch
Pointer to archetype.
Definition: object.h:412
sstring i18n_get_language_code(int language)
Return the code of a specified language.
Definition: languages.c:122
struct oblnk * next
Next item to link to.
Definition: object.h:444
#define MAP_WIDTH(m)
Map width.
Definition: map.h:78
Utility structure for the &#39;who&#39; command.
Definition: c_misc.c:456
void command_title(object *op, const char *params)
Player wishes to change her title.
Definition: c_misc.c:1997
uint8_t type
PLAYER, BULLET, etc.
Definition: object.h:338
void check_login(object *op, int check_pass)
Actually login a player, load from disk and such.
Definition: login.c:494
void command_strings(object *op, const char *params)
Various string-related statistics.
Definition: c_misc.c:774
struct Settings settings
Server settings.
Definition: init.c:40
void arch_info(object *op)
Stores debug-information about how efficient the hashtable used for archetypes has been in the static...
Definition: arch.c:196
#define SK_EXP_ADD_SKILL
Give the player the skill.
Definition: skills.h:79
#define MSG_TYPE_COMMAND_INFO
Generic info: resistances, etc.
Definition: newclient.h:506
struct archt * next
Next archetype in a linked list.
Definition: object.h:467
#define NROFATTACKS
Definition: attack.h:17
struct dirent * readdir(DIR *)
Returns the next file/directory for specified directory handle, obtained through a call to opendir()...
Definition: win32.c:75
void command_peaceful(object *op, const char *params)
Player toggles her peaceful status.
Definition: c_misc.c:2073
uint32_t max_time
Gloabal variables:
Definition: time.c:35
command_array_struct CommunicationCommands[]
Chat/shout related commands.
Definition: commands.c:129
#define ST_CHANGE_PASSWORD_OLD
Player is entering old password to change password.
Definition: define.h:586
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.c:323
static void help_topics(object *op, int what)
Player wants to know available help topics.
Definition: c_misc.c:1558
int object_count_used(void)
Object statistics.
Definition: object.c:1579
void send_news(const object *op)
Send the news to a player.
Definition: player.c:201
#define MSG_TYPE_COMMAND_BODY
Definition: newclient.h:501
void send_rules(const object *op)
Send the rules to a player.
Definition: player.c:165
sstring add_string(const char *str)
This will add &#39;str&#39; to the hash table.
Definition: shstr.c:124
const char * get_name_of_region_for_map(const mapstruct *m)
Gets the name of a region for a map.
Definition: region.c:92
EXTERN player * first_player
First player.
Definition: global.h:117
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.c:630
struct pl * next
Pointer to next player, NULL if this is last.
Definition: player.h:93
#define GET_MAP_OB(M, X, Y)
Gets the bottom object on a map.
Definition: map.h:172
int strcasecmp(const char *s1, const char *s2)
Case-insensitive comparaison of strings.
Definition: porting.c:256
int i18n_find_language_by_code(const char *code)
Attenmpt to find the identifier of a language from its code.
Definition: languages.c:95
#define FLAG_MONSTER
Will attack players.
Definition: define.h:245
Will unapply objects when there no choice to unapply.
Definition: player.h:63
#define MSG_TYPE_SKILL
Messages related to skill use.
Definition: newclient.h:383
int8_t Pow
Definition: living.h:35
int closedir(DIR *)
Dispose of a directory handle.
Definition: win32.c:108
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.c:302
uint8_t set_title
Players can set thier title.
Definition: global.h:263
petmode_t petmode
Which petmode?
Definition: player.h:102
#define NDI_UNIQUE
Print immediately, don&#39;t buffer.
Definition: newclient.h:245
#define S_ISDIR(x)
Definition: win32.h:69
#define MSG_SUBTYPE_NONE
Definition: newclient.h:398
usekeytype usekeys
Method for finding keys for doors.
Definition: player.h:107
Try to find enemies.
Definition: player.h:46
void LOG(LogLevel logLevel, const char *format,...)
Logs a message to stderr, or to file.
Definition: logger.c:51
#define CS_QUERY_HIDEINPUT
Hide input being entered.
Definition: newclient.h:68
void receive_player_name(object *op)
A player just entered her name.
Definition: c_misc.c:1887
#define FLAG_WAS_WIZ
Player was once a wiz.
Definition: define.h:234
EXTERN region * first_region
First region.
Definition: global.h:119
Stay close to the owner.
Definition: player.h:47
void command_archs(object *op, const char *params)
Archetype-related statistics.
Definition: c_misc.c:806
#define MAX_NAME
Definition: define.h:41
uint8_t run_away
Monster runs away if it&#39;s hp goes below this percentage.
Definition: object.h:384
#define FULL_VERSION
Definition: version.h:6
struct mapdef * next
Next map, linked list.
Definition: map.h:326
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.c:3415
void command_dumpallarchetypes(object *op, const char *params)
Various archetypes-related statistics.
Definition: c_misc.c:938
void map_info(object *op, const char *search)
This is the &#39;maps&#39; command.
Definition: c_misc.c:45
Only use keys in inventory.
Definition: player.h:53
void dump_friendly_objects(void)
Dumps all friendly objects.
Definition: friend.c:100
void command_quit(object *op, const char *params)
Player wants to totally delete her character.
Definition: c_misc.c:1845
This is a game-map.
Definition: map.h:325
int random_roll(int min, int max, const object *op, int goodbad)
Roll a random number between min and max.
Definition: utils.c:42
char write_buf[MAX_BUF]
Holds arbitrary input from client.
Definition: player.h:174
void command_usekeys(object *op, const char *params)
Player wants to change how keys are used.
Definition: c_misc.c:1472
void command_bowmode(object *op, const char *params)
Player wants to change the bowmode, how arrows are fired.
Definition: c_misc.c:1239
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.c:4168
int onoff_value(const char *line)
Utility function to convert a reply to a yes/no or on/off value.
Definition: c_misc.c:1808
#define FLAG_WIZPASS
The wizard can go through walls.
Definition: define.h:315
const char * unarmed_skill
Prefered skill to use in unarmed combat.
Definition: player.h:202
#define S_ISREG(x)
Definition: win32.h:70
int16_t level
Level of creature or object.
Definition: object.h:351
void fix_object(object *op)
Updates all abilities given by applied objects in the inventory of the given object.
Definition: living.c:1120
const char * i18n(const object *who, const char *code)
Translate a message in the appropriate language.
Definition: languages.c:69
float weapon_speed
The overall speed of this object.
Definition: object.h:330
void list_players(object *op, region *reg, partylist *party)
Displays the players in a region or party.
Definition: c_misc.c:484
EXTERN mapstruct * first_map
First map.
Definition: global.h:118
EXTERN archetype * first_archetype
First archetype.
Definition: global.h:122
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.c:213
char * longname
Official title of the region, this might be defined to be the same as name.
Definition: map.h:291
void command_version(object *op, const char *params)
Server version.
Definition: c_misc.c:1001
object * object_get_owner(object *op)
Returns the object which this object marks as being the owner.
Definition: object.c:559
const char * name
More definite name, like "generate_kobold".
Definition: object.h:466
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.c:1666
#define P_NO_CLERIC
No clerical spells cast here.
Definition: map.h:238
#define FOR_INV_PREPARE(op_, it_)
Constructs a loop iterating over the inventory of an object.
Definition: define.h:705
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.c:1654
const char * get_region_msg(const region *r)
Gets a message for a region.
Definition: region.c:238
void i18n_list_languages(object *who)
List all languages for who.
Definition: languages.c:132
int8_t body_used[NUM_BODY_LOCATIONS]
Calculated value based on items equipped.
Definition: object.h:373
int atnr_is_dragon_enabled(int attacknr)
Determine if the attacktype represented by the specified attack-number is enabled for dragon players...
Definition: player.c:95
Definition: object.h:224
void current_map_info(object *op)
&#39;mapinfo&#39; command.
Definition: c_misc.c:363
static int name_cmp(const chars_names *c1, const chars_names *c2)
Local function for qsort comparison.
Definition: c_misc.c:470
void display_motd(const object *op)
Sends the message of the day to the player.
Definition: player.c:134
EXTERN long nroftreasures
Only used in malloc_info().
Definition: global.h:147