Crossfire Client, Trunk  R19900
p_cmd.c
Go to the documentation of this file.
1 /*
2  * Crossfire -- cooperative multi-player graphical RPG and adventure game
3  *
4  * Copyright (c) 1999-2013 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 
19 #include <ctype.h>
20 
21 #include "client.h"
22 #include "external.h"
23 #include "p_cmd.h"
24 #include "script.h"
25 
31 #define H1(a) draw_ext_info(NDI_BLACK, MSG_TYPE_CLIENT, MSG_TYPE_CLIENT_NOTICE, a)
32 #define H2(a) draw_ext_info(NDI_BLACK, MSG_TYPE_CLIENT, MSG_TYPE_CLIENT_NOTICE, a)
33 #define LINE(a) draw_ext_info(NDI_BLACK, MSG_TYPE_CLIENT, MSG_TYPE_CLIENT_NOTICE, a)
34 
35 /* TODO Help topics other than commands? Refer to other documents? */
36 
37 static void do_clienthelp_list() {
38  ConsoleCommand **commands_array = get_cat_sorted_commands();
39  CommCat current_cat = COMM_CAT_MISC;
40  GString *line = g_string_new(NULL);
41 
42  H1(" === Client Side Commands === ");
43  for (int i = 0; i < get_num_commands(); i++) {
44  ConsoleCommand *commands_copy = commands_array[i];
45  if (commands_copy->cat != current_cat) {
46  // If moving on to next category, dump line_buf and print header.
47  char buf[MAX_BUF];
48  snprintf(buf, sizeof(buf), " --- %s Commands --- ", get_category_name(commands_copy->cat));
49  LINE(line->str);
50  H2(buf);
51 
52  current_cat = commands_copy->cat;
53  g_string_free(line, true);
54  line = g_string_new(NULL);
55  }
56 
57  g_string_append_printf(line, "%s ", commands_copy->name);
58  }
59 
60  LINE(line->str);
61  g_string_free(line, true);
62 }
63 
64 static void show_help(const ConsoleCommand *cc) {
65  char buf[MAX_BUF];
66  if (cc->desc != NULL) {
67  snprintf(buf, MAX_BUF - 1, "%s - %s", cc->name, cc->desc);
68  } else {
69  snprintf(buf, MAX_BUF - 1, "Help for '%s':", cc->name);
70  }
71  H2(buf);
72 
73  if (cc->helpfunc != NULL) {
74  const char *long_help = NULL;
75  long_help = cc->helpfunc();
76 
77  if (long_help != NULL) {
78  LINE(long_help);
79  } else {
80  LINE("Extended help for this command is broken.");
81  }
82  } else {
83  LINE("No extended help is available for this command.");
84  }
85 }
86 
87 static void command_help(const char *cpnext) {
88  if (cpnext) {
89  const ConsoleCommand * cc;
90  char buf[MAX_BUF];
91 
92  cc = find_command(cpnext);
93  if (cc != NULL) {
94  show_help(cc);
95  } else {
96  snprintf(buf, sizeof(buf), "help %s", cpnext);
97  /* maybe not a must send, but we probably don't want to drop it */
98  send_command(buf, -1, 1);
99  }
100  } else {
102  /* Now fetch (in theory) command list from the server.
103  TODO Protocol command - feed it to the tab completer.
104 
105  Nope! It effectivey fetches '/help commands for commands'.
106  */
107  send_command("help", -1, 1); /* TODO make install in server branch doesn't install def_help. */
108  }
109 }
110 
111 static const char * help_help(void) {
112  return
113  "Syntax:\n"
114  "\n"
115  " help\n"
116  " help <topic>\n"
117  "\n"
118  "Without any arguments, displays a list of client-side "
119  "commands, and fetches the without-arguments help from "
120  "the server.\n"
121  "\n"
122  "With arguments, first checks if there's a client command "
123  "named <topic>. If there is, display it's help. If there "
124  "isn't, send the topic to the server.";
125 }
126  /* EndOf PCmdHelpCommands
129  */
130 
131 static void set_command_window(const char *cpnext) {
132  if (!cpnext) {
134  "cwindow command requires a number parameter");
135  } else {
136  want_config[CONFIG_CWINDOW] = atoi(cpnext);
139  } else {
141  }
142  }
143 }
144 
145 static void command_foodbeep(const char *cpnext) {
149  "Warning bell when low on food disabled");
150  } else {
153  "Warning bell when low on food enabled");
154  }
156 }
157 
158 const char * get_category_name(CommCat cat) {
159  const char * cat_name;
160 
161  /* HACK Need to keep this in sync. with player.h */
162  switch(cat) {
163  case COMM_CAT_MISC:
164  cat_name = "Miscellaneous";
165  break;
166  case COMM_CAT_HELP:
167  cat_name = "Help";
168  break;
169  case COMM_CAT_INFO:
170  cat_name = "Informational";
171  break;
172  case COMM_CAT_SETUP:
173  cat_name = "Configuration";
174  break;
175  case COMM_CAT_SCRIPT:
176  cat_name = "Scripting";
177  break;
178  case COMM_CAT_DEBUG:
179  cat_name = "Debugging";
180  break;
181  default:
182  cat_name = "PROGRAMMER ERROR";
183  break;
184  }
185 
186  return cat_name;
187 }
188 
189 /*
190  * Command table.
191  *
192  * Implementation basically stolen verbatim from the server.
193  */
194 
195 /* "Typecasters" (and some forwards) */
196 
197 static void do_script_list(const char *ignored) {
198  script_list();
199 }
200 
201 static void do_clearinfo(const char *ignored) {
202  menu_clear();
203 }
204 
205 static void do_disconnect(const char * ignored) {
207 }
208 
209 #ifdef HAVE_DMALLOC_H
210 #ifndef DMALLOC_VERIFY_NOERROR
211 #define DMALLOC_VERIFY_NOERROR 1
212 #endif
213 static void do_dmalloc(const char *ignored) {
214  if (dmalloc_verify(NULL)==DMALLOC_VERIFY_NOERROR)
216  "Heap checks out OK");
217  else
219  "Heap corruption detected");
220 }
221 #endif
222 
223 static void do_inv(const char *ignored) {
225 }
226 
227 static void do_magicmap(const char *ignored) {
228  cpl.showmagic=1;
229  draw_magic_map();
230 }
231 
232 static void do_savedefaults(const char *ignored) {
233  save_defaults();
234 }
235 
236 static void do_savewinpos(const char *ignored) {
237  save_winpos();
238 }
239 
240 static void do_take(const char *used) {
241  command_take("take", used); /* I dunno why they want it. */
242 }
243 
244 static void do_num_free_items(const char *ignored) {
245  LOG(LOG_INFO,"common::extended_command","num_free_items=%d", num_free_items());
246 }
247 
248 /* Help "typecasters". */
249 #include "chelp.h"
250 
251 static const char * help_bind(void) {
252  return HELP_BIND_LONG;
253 }
254 
255 static const char * help_unbind(void) {
256  return HELP_UNBIND_LONG;
257 }
258 
259 static const char * help_magicmap(void) {
260  return HELP_MAGICMAP_LONG;
261 }
262 
263 static const char * help_inv(void) {
264  return HELP_INV_LONG;
265 }
266 
267 static const char * help_cwindow(void) {
268  return
269  "Syntax:\n"
270  "\n"
271  " cwindow <val>\n"
272  "\n"
273  "set size of command"
274  "window (if val is exceeded"
275  "client won't send new"
276  "commands to server\n\n"
277  "(What does this mean, 'put a lid on it'?) TODO";
278 }
279 
280 static const char * help_script(void) {
281  return
282  "Syntax: script <path>\n\n"
283  "Start an executable client script located at <path>. For details on "
284  "client-side scripting, please see the Crossfire Wiki.";
285 }
286 
287 static const char * help_scripttell(void) {
288  return
289  "Syntax:\n"
290  "\n"
291  " scripttell <yourname> <data>\n"
292  "\n"
293  "?";
294 }
295 
296 /* Toolkit-dependent. */
297 
298 static const char * help_savewinpos(void) {
299  return
300  "Syntax:\n"
301  "\n"
302  " savewinpos\n"
303  "\n"
304  "save window positions - split windows mode only.";
305 }
306 
307 static const char * help_scriptkill(void) {
308  return
309  "Syntax:\n"
310  "\n"
311  " scriptkill <name>\n"
312  "\n"
313  "Stop scripts named <name>.\n"
314  "(Not guaranteed to work?)";
315 }
316 
317 static const char * help_showweight(void) {
318  return
319  "Syntax:\n"
320  "\n"
321  " showweight\n"
322  " showweight inventory\n"
323  " showweight look\n"
324  "\n"
325  "(Or any prefix of the arguments.)"
326  "Toggles if you see the weight of"
327  "items in your inventory (also if"
328  "no argument given) or your"
329  "look-window.";
330 }
331 
332 /* TODO Wrap these? Um. */
334  /* From player.h:
335  name, cat,
336  func, helpfunc,
337  long_desc
338  */
339 
340  {
341  "autorepeat", COMM_CAT_MISC,
342  set_autorepeat, NULL,
343  "toggle autorepeat" /* XXX Eh? */
344  },
345 
346  {
347  "bind", COMM_CAT_SETUP,
350  },
351 
352  {
353  "script", COMM_CAT_SCRIPT,
355  NULL
356  },
357 #ifdef HAVE_LUA
358  {
359  "lua_load", COMM_CAT_SCRIPT,
360  script_lua_load, NULL, NULL
361  },
362 
363  {
364  "lua_list", COMM_CAT_SCRIPT,
365  script_lua_list, NULL, NULL
366  },
367 
368  {
369  "lua_kill", COMM_CAT_SCRIPT,
370  script_lua_kill, NULL, NULL
371  },
372 #endif
373  {
374  "scripts", COMM_CAT_SCRIPT,
375  do_script_list, NULL,
376  "List the running scripts(?)"
377  },
378 
379  {
380  "scriptkill", COMM_CAT_SCRIPT,
382  NULL
383  },
384 
385  {
386  "scripttell", COMM_CAT_SCRIPT,
388  NULL
389  },
390 
391  {
392  "clearinfo", COMM_CAT_MISC,
393  do_clearinfo, NULL,
394  "clear the info window"
395  },
396 
397  {
398  "cwindow", COMM_CAT_SETUP,
400  NULL
401  },
402 
403  {
404  "disconnect", COMM_CAT_MISC,
405  do_disconnect, NULL,
406  "close connection to server"
407  },
408 
409 
410 #ifdef HAVE_DMALLOC_H
411  {
412  "dmalloc", COMM_CAT_DEBUG,
413  do_dmalloc, NULL,
414  NULL
415  },
416 #endif
417 
418  {
419  "foodbeep", COMM_CAT_SETUP,
420  command_foodbeep, NULL,
421  "toggle audible low on food warning"
422 
423  },
424 
425  {
426  "help", COMM_CAT_HELP,
428  NULL
429  },
430 
431  {
432  "inv", COMM_CAT_DEBUG,
433  do_inv, help_inv,
435  },
436 
437  {
438  "magicmap", COMM_CAT_MISC,
441  },
442 
443  {
444  "savedefaults", COMM_CAT_SETUP,
445  do_savedefaults, NULL,
446  HELP_SAVEDEFAULTS_SHORT /* How do we make sure showicons stays on? */
447  },
448 
449  {
450  "savewinpos", COMM_CAT_SETUP,
452  "Saves the position and sizes of windows." /* Panes? */
453  },
454 
455  {
456  "scroll", COMM_CAT_SETUP,
457  set_scroll, NULL,
458  "toggle scroll/wrap mode in info window"
459  },
460 
461  {
462  "showicon", COMM_CAT_SETUP,
463  set_show_icon, NULL,
464  "Toggles if you see the worn, locked, cursed etc state in the inventory pane."
465  },
466 
467  {
468  "showweight", COMM_CAT_SETUP,
470  "Toggles if you see item weights in inventory look windows."
471  },
472 
473  {
474  "take", COMM_CAT_MISC,
475  do_take, NULL,
476  NULL
477  },
478 
479  {
480  "unbind", COMM_CAT_SETUP,
482  NULL
483  },
484 
485  {
486  "num_free_items", COMM_CAT_DEBUG,
487  do_num_free_items, NULL,
488  "log the number of free items?"
489  },
490  {
491  "show", COMM_CAT_SETUP,
492  command_show, NULL,
493  "Change what items to show in inventory"
494  },
495 
496 };
497 
498 const int CommonCommandsSize = sizeof(CommonCommands) / sizeof(ConsoleCommand);
499 
500 #ifdef TOOLKIT_COMMANDS
501 extern ConsoleCommand ToolkitCommands[];
502 
503 extern const int ToolkitCommandsSize;
504 #endif
505 
506 /* ------------------------------------------------------------------ */
507 
509 
510 int get_num_commands(void) {
511  return num_commands;
512 }
513 
515 
516 static int sort_by_name(const void * a_, const void * b_) {
517  ConsoleCommand * a = *((ConsoleCommand **)a_);
518  ConsoleCommand * b = *((ConsoleCommand **)b_);
519  return strcmp(a->name, b->name);
520 }
521 
523 
524 /* Sort by category, then by name. */
525 
526 static int sort_by_category(const void *a_, const void *b_) {
527  /* Typecasts, so it goes. */
528  ConsoleCommand * a = *((ConsoleCommand **)a_);
529  ConsoleCommand * b = *((ConsoleCommand **)b_);
530 
531  if (a->cat == b->cat) {
532  return strcmp(a->name, b->name);
533  }
534 
535  return a->cat - b->cat;
536 }
537 
538 void init_commands(void) {
539 #ifdef TOOLKIT_COMMANDS
540  init_toolkit_commands();
541 
542  /* TODO I dunno ... go through the list and print commands without helps? */
543  num_commands = CommonCommandsSize + ToolkitCommandsSize;
544 #else
545  num_commands = CommonCommandsSize;
546 #endif
547 
548  /* Make a list of (pointers to statically allocated!) all the commands.
549  We have a list; the toolkit has a
550  ToolkitCommands and ToolkitCommandsSize, initialized before calling this.
551  */
552 
553  /* XXX Leak! */
554  name_sorted_commands = g_malloc(sizeof(ConsoleCommand *) * num_commands);
555 
556  for (int i = 0; i < CommonCommandsSize; i++) {
557  name_sorted_commands[i] = &CommonCommands[i];
558  }
559 
560 #ifdef TOOLKIT_COMMANDS
561  for (int i = 0; i < ToolkitCommandsSize; i++) {
562  name_sorted_commands[CommonCommandsSize + i] = &ToolkitCommands[i];
563  }
564 #endif
565 
566  /* Sort them. */
567  qsort(name_sorted_commands, num_commands, sizeof(ConsoleCommand *), sort_by_name);
568 
569  /* Copy the list, then sort it by category. */
570  cat_sorted_commands = g_malloc(sizeof(ConsoleCommand *) * num_commands);
571 
572  memcpy(cat_sorted_commands, name_sorted_commands, sizeof(ConsoleCommand *) * num_commands);
573 
574  qsort(cat_sorted_commands, num_commands, sizeof(ConsoleCommand *), sort_by_category);
575 
576  /* TODO Add to the list of tab-completion items. */
577 }
578 
579 const ConsoleCommand * find_command(const char *cmd) {
580  ConsoleCommand ** asp_p = NULL, dummy;
581  ConsoleCommand * dummy_p;
582  ConsoleCommand * asp;
583  char *cp, *cmd_cpy;
584  cmd_cpy = g_strdup(cmd);
585 
586  for (cp=cmd_cpy; *cp; cp++) {
587  *cp =tolower(*cp);
588  }
589 
590  dummy.name = cmd_cpy;
591  dummy_p = &dummy;
592  asp_p = bsearch(
593  (void *)&dummy_p,
594  (void *)name_sorted_commands,
595  num_commands,
596  sizeof(ConsoleCommand *),
597  sort_by_name);
598 
599  if (asp_p == NULL) {
600  free(cmd_cpy);
601  return NULL;
602  }
603 
604  asp = *asp_p;
605 
606  /* TODO The server's find_command() searches first the commands,
607  then the emotes. We might have to do something similar someday, too. */
608  /* if (asp == NULL) search something else? */
609 
610  free(cmd_cpy);
611 
612  return asp;
613 }
614 
620  return cat_sorted_commands;
621 }
622 
632 int handle_local_command(const char* cp, const char *cpnext) {
633  const ConsoleCommand * cc = NULL;
634 
635  cc = find_command(cp);
636 
637  if (cc == NULL) {
638  return FALSE;
639  }
640 
641  if (cc->dofunc == NULL) {
642  char buf[MAX_BUF];
643 
644  snprintf(buf, MAX_BUF - 1, "Client command %s has no implementation!", cc->name);
646 
647  return FALSE;
648  }
649 
650  cc->dofunc(cpnext);
651 
652  return TRUE;
653 }
654 
666 void extended_command(const char *ocommand) {
667  const char *cp = ocommand;
668  char *cpnext, command[MAX_BUF];
669 
670  if ((cpnext = strchr(cp, ' '))!=NULL) {
671  int len = cpnext - ocommand;
672  if (len > (MAX_BUF -1 )) {
673  len = MAX_BUF-1;
674  }
675 
676  strncpy(command, ocommand, len);
677  command[len] = '\0';
678  cp = command;
679  while (*cpnext == ' ') {
680  cpnext++;
681  }
682  if (*cpnext == 0) {
683  cpnext = NULL;
684  }
685  }
686  /*
687  * Try to prevent potential client hang by trying to delete a
688  * character when there is no character to delete.
689  * Thus, only send quit command if there is a player to delete.
690  */
691  if (cpl.title[0] == '\0' && strcmp(cp, "quit") == 0){
692  // Bail here, there isn't anything this should be doing.
693  return;
694  }
695 
696  /* cp now contains the command (everything before first space),
697  * and cpnext contains everything after that first space. cpnext
698  * could be NULL.
699  */
700 #ifdef HAVE_LUA
701  if ( script_lua_command(cp, cpnext) ) {
702  return;
703  }
704 #endif
705 
706  /* If this isn't a client-side command, send it to the server. */
707  if (!handle_local_command(cp, cpnext)) {
708  /* just send the command(s) (if `ocommand' is a compound command */
709  /* then split it and send each part seperately */
710  /* TODO Remove this from the server; end of commands.c. */
711  strncpy(command, ocommand, MAX_BUF-1);
712  command[MAX_BUF-1]=0;
713  cp = strtok(command, ";");
714  while ( cp ) {
715  while( *cp == ' ' ) {
716  cp++;
717  } /* throw out leading spaces; server
718  does not like them */
719  send_command(cp, cpl.count, 0);
720  cp = strtok(NULL, ";");
721  }
722  }
723 }
724 
725 /* ------------------------------------------------------------------ */
726 
727 /* This list is used for the 'tab' completion, and nothing else.
728  * Therefore, if it is out of date, it isn't that terrible, but
729  * ideally it should stay somewhat up to date with regards to
730  * the commands the server supports.
731  */
732 
733 /* TODO Dynamically generate. */
734 
735 static const char *const commands[] = {
736  "accuse", "afk", "apply", "applymode", "archs", "beg", "bleed", "blush",
737  "body", "bounce", "bow", "bowmode", "brace", "build", "burp", "cackle", "cast",
738  "chat", "chuckle", "clap", "cointoss", "cough", "cringe", "cry", "dance",
739  "disarm", "dm", "dmhide", "drop", "dropall", "east", "examine", "explore",
740  "fire", "fire_stop", "fix_me", "flip", "frown", "gasp", "get", "giggle",
741  "glare", "grin", "groan", "growl", "gsay", "help", "hiccup", "hiscore", "hug",
742  "inventory", "invoke", "killpets", "kiss", "laugh", "lick", "listen", "logs",
743  "mapinfo", "maps", "mark", "me", "motd", "nod", "north", "northeast",
744  "northwest", "orcknuckle", "output-count", "output-sync", "party", "peaceful",
745  "petmode", "pickup", "players", "poke", "pout", "prepare", "printlos", "puke",
746  "quests", "quit", "ready_skill", "rename", "reply", "resistances",
747  "rotateshoottype", "run", "run_stop", "save", "say", "scream", "search",
748  "search-items", "shake", "shiver", "shout", "showpets", "shrug", "shutdown",
749  "sigh", "skills", "slap", "smile", "smirk", "snap", "sneeze", "snicker",
750  "sniff", "snore", "sound", "south", "southeast", "southwest", "spit",
751  "statistics", "stay", "strings", "strut", "sulk", "take", "tell", "thank",
752  "think", "throw", "time", "title", "twiddle", "use_skill", "usekeys",
753  "version", "wave", "weather", "west", "whereabouts", "whereami", "whistle",
754  "who", "wimpy", "wink", "yawn",
755 };
756 const int NUM_COMMANDS = sizeof(commands) / sizeof(char *);
757 
765 const char * complete_command(const char *command) {
766  int i, len, display = 0;
767  const char *match;
768  static char result[64];
769  char list[500];
770 
771  len = strlen(command);
772 
773  if (len == 0) {
774  return NULL;
775  }
776 
777  strcpy(list, "Matching commands:");
778 
779  /* TODO Partial match, e.g.:
780  If the completion list was:
781  wear
782  wet #?
783 
784  If we type 'w' then hit tab, put in the e.
785 
786  Basically part of bash (readline?)'s behaviour.
787  */
788 
789  match = NULL;
790 
791  /* check server side commands */
792  for (i=0; i<NUM_COMMANDS; i++) {
793  if (!strncmp(command, commands[i], len)) {
794  if (display) {
795  snprintf(list + strlen(list), 499 - strlen(list), " %s", commands[i]);
796  } else if (match != NULL) {
797  display = 1;
798  snprintf(list + strlen(list), 499 - strlen(list), " %s %s", match, commands[i]);
799  match = NULL;
800  } else {
801  match = commands[i];
802  }
803  }
804  }
805 
806  /* check client side commands */
807  for (i=0; i<CommonCommandsSize; i++) {
808  if (!strncmp(command, CommonCommands[i].name, len)) {
809  if (display) {
810  snprintf(list + strlen(list), 499 - strlen(list), " %s", CommonCommands[i].name);
811  } else if (match != NULL) {
812  display = 1;
813  snprintf(list + strlen(list), 499 - strlen(list), " %s %s", match, CommonCommands[i].name);
814  match = NULL;
815  } else {
816  match = CommonCommands[i].name;
817  }
818  }
819  }
820 
821  if (match == NULL) {
822  if (display) {
823  strncat(list, "\n", 499 - strlen(list));
826  } else
828  "No matching command.\n");
829  /* No match. */
830  return NULL;
831  }
832 
833  /*
834  * Append a space to allow typing arguments. For commands without arguments
835  * the excess space should be stripped off automatically.
836  */
837  snprintf(result, sizeof(result), "%s ", match);
838  return result;
839 }
#define HELP_BIND_SHORT
Definition: chelp.h:6
void set_autorepeat(const char *s)
A stub function that does nothing.
Definition: info.c:1342
int num_free_items(void)
Definition: item.c:458
void script_lua_list(const char *param)
#define COMMAND_WINDOW
Do not send more than this many outstanding commands to the server this is only a default value...
Definition: client.h:87
int script_lua_command(const char *command, const char *param)
int handle_local_command(const char *cp, const char *cpnext)
Tries to handle command cp (with optional params in cpnext, which may be null) as a local command...
Definition: p_cmd.c:632
static const char * help_unbind(void)
Definition: p_cmd.c:255
void command_take(const char *command, const char *cpnext)
Definition: player.c:277
gint16 use_config[CONFIG_NUMS]
Definition: init.c:40
static void do_clienthelp_list()
Definition: p_cmd.c:37
#define H1(a)
Definition: p_cmd.c:31
void set_show_icon(const char *s)
Definition: inventory.c:572
void script_lua_kill(const char *param)
#define HELP_MAGICMAP_SHORT
Definition: chelp.h:54
static void command_foodbeep(const char *cpnext)
Definition: p_cmd.c:145
#define H2(a)
Definition: p_cmd.c:32
#define HELP_BIND_LONG
Definition: chelp.h:7
CommFunc dofunc
Definition: p_cmd.h:60
#define HELP_MAGICMAP_LONG
Definition: chelp.h:55
item * ob
Player object.
Definition: client.h:348
const char * get_category_name(CommCat cat)
Definition: p_cmd.c:158
static const char *const commands[]
Definition: p_cmd.c:735
CommCat cat
Definition: p_cmd.h:59
static const char * help_showweight(void)
Definition: p_cmd.c:317
#define CONFIG_FOODBEEP
Definition: client.h:217
void init_commands(void)
Fills some internal arrays.
Definition: p_cmd.c:538
#define MSG_TYPE_CLIENT
Client originated Messages.
Definition: newclient.h:420
static void set_command_window(const char *cpnext)
Definition: p_cmd.c:131
static const char * help_savewinpos(void)
Definition: p_cmd.c:298
Contains external calls that the common area makes callbacks to.
#define NDI_BLACK
Definition: newclient.h:249
CommCat
Definition: p_cmd.h:44
static void do_clearinfo(const char *ignored)
Definition: p_cmd.c:201
#define HELP_UNBIND_LONG
Definition: chelp.h:45
void LOG(LogLevel level, const char *origin, const char *format,...)
Log messages of a certain importance to stderr.
Definition: misc.c:112
void client_disconnect()
Closes the connection to the server.
Definition: client.c:187
#define MSG_TYPE_CLIENT_ERROR
Bad things happening.
Definition: newclient.h:692
void script_init(const char *cparams)
Definition: script.c:205
#define NDI_RED
Definition: newclient.h:252
const char * desc
Definition: p_cmd.h:63
static const char * help_scripttell(void)
Definition: p_cmd.c:287
static const char * help_help(void)
Definition: p_cmd.c:111
Includes and prototypes for p_cmd.c for player-commands like '/magicmap'.
#define MSG_TYPE_CLIENT_NOTICE
Non-critical note to player.
Definition: newclient.h:689
int send_command(const char *command, int repeat, int must_send)
Definition: player.c:200
static void do_magicmap(const char *ignored)
Definition: p_cmd.c:227
void save_winpos(void)
Save client window positions to a file unique to each layout.
Definition: config.c:1131
#define HELP_SAVEDEFAULTS_SHORT
Definition: chelp.h:59
const char * name
Definition: p_cmd.h:58
Client_Player cpl
Player object.
Definition: client.c:69
#define CONFIG_CWINDOW
Definition: client.h:200
static const char * help_scriptkill(void)
Definition: p_cmd.c:307
#define MAX_BUF
Definition: client.h:51
static const char * help_magicmap(void)
Definition: p_cmd.c:259
const int CommonCommandsSize
Definition: p_cmd.c:498
void extended_command(const char *ocommand)
This is an extended command (ie, 'who, 'whatever, etc).
Definition: p_cmd.c:666
gint16 want_config[CONFIG_NUMS]
Definition: init.c:40
int num_commands
Definition: p_cmd.c:508
static void do_take(const char *used)
Definition: p_cmd.c:240
static void command_help(const char *cpnext)
Definition: p_cmd.c:87
CommHelpFunc helpfunc
Definition: p_cmd.h:62
const char * complete_command(const char *command)
Player has entered 'command' and hit tab to complete it.
Definition: p_cmd.c:765
guint32 count
Repeat count on command.
Definition: client.h:371
#define HELP_INV_SHORT
Definition: chelp.h:66
void script_list(void)
Definition: script.c:494
static int sort_by_category(const void *a_, const void *b_)
Definition: p_cmd.c:526
const int NUM_COMMANDS
Definition: p_cmd.c:756
guint8 showmagic
If 0, show the normal map, otherwise show the magic map.
Definition: client.h:376
int get_num_commands(void)
Definition: p_cmd.c:510
#define HELP_INV_LONG
Definition: chelp.h:67
void save_defaults(void)
This function saves user settings chosen using the configuration popup dialog.
Definition: config.c:500
void bind_key(const char *params)
static ConsoleCommand ** name_sorted_commands
Definition: p_cmd.c:514
static ConsoleCommand CommonCommands[]
Definition: p_cmd.c:333
static void do_num_free_items(const char *ignored)
Definition: p_cmd.c:244
void print_inventory(item *op)
Definition: item.c:678
const ConsoleCommand * find_command(const char *cmd)
Definition: p_cmd.c:579
#define LINE(a)
Definition: p_cmd.c:33
void script_tell(const char *params)
Definition: script.c:947
static const char * help_bind(void)
Definition: p_cmd.c:251
void menu_clear(void)
Clears all the message panels.
Definition: info.c:1311
void script_kill(const char *params)
Definition: script.c:516
void draw_ext_info(int orig_color, int type, int subtype, const char *message)
A message processor that accepts messages along with meta information color and type.
Definition: info.c:931
void set_show_weight(const char *s)
Definition: inventory.c:579
void command_show(const char *params)
Definition: inventory.c:606
static void do_disconnect(const char *ignored)
Definition: p_cmd.c:205
static void show_help(const ConsoleCommand *cc)
Definition: p_cmd.c:64
static void do_savewinpos(const char *ignored)
Definition: p_cmd.c:236
void script_lua_load(const char *name)
void draw_magic_map(void)
Draws the magic map - basically, it is just a simple encoding of space X is color C...
Definition: magicmap.c:35
char title[MAX_BUF]
Title of character.
Definition: client.h:363
Includes various dependencies header files needed by most everything.
char * name
Definition: image.c:39
static int sort_by_name(const void *a_, const void *b_)
Definition: p_cmd.c:516
static void do_inv(const char *ignored)
Definition: p_cmd.c:223
static const char * help_script(void)
Definition: p_cmd.c:280
void unbind_key(const char *params)
Definition: keys.c:1456
static ConsoleCommand ** cat_sorted_commands
Definition: p_cmd.c:522
static const char * help_inv(void)
Definition: p_cmd.c:263
Minor, non-harmful issues.
Definition: client.h:454
static void do_script_list(const char *ignored)
Definition: p_cmd.c:197
static void do_savedefaults(const char *ignored)
Definition: p_cmd.c:232
static const char * help_cwindow(void)
Definition: p_cmd.c:267
ConsoleCommand ** get_cat_sorted_commands(void)
Returns a pointer to the head of an array of ConsoleCommands sorted by category, then by name...
Definition: p_cmd.c:619
void set_scroll(const char *s)
A stub function that does nothing.
Definition: info.c:1329