Crossfire Client, Trunk
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 #include "mapdata.h"
26 
32 #define H1(a) draw_ext_info(NDI_BLACK, MSG_TYPE_CLIENT, MSG_TYPE_CLIENT_NOTICE, a)
33 #define H2(a) draw_ext_info(NDI_BLACK, MSG_TYPE_CLIENT, MSG_TYPE_CLIENT_NOTICE, a)
34 #define LINE(a) draw_ext_info(NDI_BLACK, MSG_TYPE_CLIENT, MSG_TYPE_CLIENT_NOTICE, a)
35 
36 extern void config_check(void);
37 extern void map_check_resize(void);
38 
40 bool arm_mapedit = false;
41 
42 /* TODO Help topics other than commands? Refer to other documents? */
43 
44 static int get_num_commands(void);
45 
47 
48 static void do_clienthelp_list() {
49  ConsoleCommand **sorted_cmds = get_cat_sorted_commands();
50  CommCat category = COMM_CAT_MISC;
51  GString *line = g_string_new(NULL);
52 
53  H1("Client commands:");
54  for (int i = 0; i < get_num_commands(); i++) {
55  ConsoleCommand *cmd = sorted_cmds[i];
56  if (cmd->cat != category) {
57  // If moving on to next category, dump line_buf and print header.
58  char buf[MAX_BUF];
59  snprintf(buf, sizeof(buf), "%s commands:",
60  get_category_name(cmd->cat));
61  LINE(line->str);
62  H2(buf);
63 
64  category = cmd->cat;
65  g_string_free(line, true);
66  line = g_string_new(NULL);
67  }
68  g_string_append_printf(line, "%s ", cmd->name);
69  }
70 
71  LINE(line->str);
72  g_string_free(line, true);
73 }
74 
75 static void show_help(const ConsoleCommand *cc) {
76  char buf[MAX_BUF];
77  if (cc->desc != NULL) {
78  snprintf(buf, MAX_BUF - 1, "%s - %s", cc->name, cc->desc);
79  } else {
80  snprintf(buf, MAX_BUF - 1, "Help for '%s':", cc->name);
81  }
82  H2(buf);
83 
84  if (cc->helpfunc != NULL) {
85  const char *long_help = NULL;
86  long_help = cc->helpfunc();
87 
88  if (long_help != NULL) {
89  LINE(long_help);
90  } else {
91  LINE("Extended help for this command is broken.");
92  }
93  } else {
94  LINE("No extended help is available for this command.");
95  }
96 }
97 
98 static void command_help(const char *cpnext) {
99  if (cpnext) {
100  const ConsoleCommand * cc;
101  char buf[MAX_BUF];
102 
103  cc = find_command(cpnext);
104  if (cc != NULL) {
105  show_help(cc);
106  } else {
107  snprintf(buf, sizeof(buf), "help %s", cpnext);
108  /* maybe not a must send, but we probably don't want to drop it */
109  send_command(buf, -1, 1);
110  }
111  } else {
113  /* Now fetch (in theory) command list from the server.
114  TODO Protocol command - feed it to the tab completer.
115 
116  Nope! It effectivey fetches '/help commands for commands'.
117  */
118  send_command("help", -1, 1); /* TODO make install in server branch doesn't install def_help. */
119  }
120 }
121 
122 static const char * help_help(void) {
123  return
124  "Syntax:\n"
125  "\n"
126  " help\n"
127  " help <topic>\n"
128  "\n"
129  "Without any arguments, displays a list of client-side "
130  "commands, and fetches the without-arguments help from "
131  "the server.\n"
132  "\n"
133  "With arguments, first checks if there's a client command "
134  "named <topic>. If there is, display it's help. If there "
135  "isn't, send the topic to the server.";
136 }
137  /* EndOf PCmdHelpCommands
140  */
141 
142 static void set_command_window(const char *cpnext) {
143  if (!cpnext) {
145  "cwindow command requires a number parameter");
146  } else {
147  want_config[CONFIG_CWINDOW] = atoi(cpnext);
150  } else {
152  }
153  }
154 }
155 
156 static void command_foodbeep() {
160  "Warning bell when low on food disabled");
161  } else {
164  "Warning bell when low on food enabled");
165  }
167 }
168 
169 const char * get_category_name(CommCat cat) {
170  const char * cat_name;
171 
172  /* HACK Need to keep this in sync. with player.h */
173  switch(cat) {
174  case COMM_CAT_MISC:
175  cat_name = "Miscellaneous";
176  break;
177  case COMM_CAT_INFO:
178  cat_name = "Informational";
179  break;
180  case COMM_CAT_SETUP:
181  cat_name = "Configuration";
182  break;
183  case COMM_CAT_SCRIPT:
184  cat_name = "Scripting";
185  break;
186  case COMM_CAT_DEBUG:
187  cat_name = "Debugging";
188  break;
189  default:
190  cat_name = "PROGRAMMER ERROR";
191  break;
192  }
193 
194  return cat_name;
195 }
196 
197 /*
198  * Command table.
199  *
200  * Implementation basically stolen verbatim from the server.
201  */
202 
203 static void do_script_list() { script_list(); }
204 
205 static void do_clearinfo() { menu_clear(); }
206 
207 static void do_disconnect() { client_disconnect(); }
208 
209 
210 static void do_inv() { print_inventory(cpl.ob); }
211 
212 static void do_magicmap() {
213  draw_magic_map();
214 }
215 
216 static void do_savedefaults() { save_defaults(); }
217 
218 static void do_savewinpos() { save_winpos(); }
219 
220 static void do_mapedit() {
221  send_command("mapinfo", -1, 1);
222  arm_mapedit = true;
223 }
224 
225 static void do_set_mapscale(const char *used) {
226  if (used != NULL) {
227  long long scale = strtoll(used, NULL, 0);
228  want_config[CONFIG_MAPSCALE] = scale;
229  config_check();
230  } else {
232  "mapscale command requires an argument");
233  }
234 }
235 
236 static void do_take(const char *used) {
237  command_take("take", used); /* I dunno why they want it. */
238 }
239 
240 /* Help "typecasters". */
241 #include "chelp.h"
242 
243 static const char * help_bind(void) {
244  return HELP_BIND_LONG;
245 }
246 
247 static const char * help_unbind(void) {
248  return HELP_UNBIND_LONG;
249 }
250 
251 static const char * help_magicmap(void) {
252  return HELP_MAGICMAP_LONG;
253 }
254 
255 static const char * help_inv(void) {
256  return HELP_INV_LONG;
257 }
258 
259 static const char * help_cwindow(void) {
260  return
261  "Syntax:\n"
262  "\n"
263  " cwindow <val>\n"
264  "\n"
265  "set size of command"
266  "window (if val is exceeded"
267  "client won't send new"
268  "commands to server\n\n"
269  "(What does this mean, 'put a lid on it'?) TODO";
270 }
271 
272 static const char * help_script(void) {
273  return
274  "Syntax: script <path>\n\n"
275  "Start an executable client script located at <path>. For details on "
276  "client-side scripting, please see the Crossfire Wiki.";
277 }
278 
279 static const char * help_scripttell(void) {
280  return
281  "Syntax:\n"
282  "\n"
283  " scripttell <yourname> <data>\n"
284  "\n"
285  "?";
286 }
287 
288 /* Toolkit-dependent. */
289 
290 static const char * help_savewinpos(void) {
291  return
292  "Syntax:\n"
293  "\n"
294  " savewinpos\n"
295  "\n"
296  "save window positions - split windows mode only.";
297 }
298 
299 static const char * help_scriptkill(void) {
300  return
301  "Syntax:\n"
302  "\n"
303  " scriptkill <name>\n"
304  "\n"
305  "Stop scripts named <name>.\n"
306  "(Not guaranteed to work?)";
307 }
308 
309 static const char * help_scriptkillall(void) {
310  return
311  "Syntax:\n"
312  "\n"
313  " scriptkillall\n"
314  "\n"
315  "Stop all active scripts.\n"
316  "(Not guaranteed to work?)";
317 }
318 
319 static void cmd_raw(const char *cmd) {
320  cs_print_string(csocket.fd, "%s", cmd);
321 }
322 
323 void cmd_debugrender(const char *cmd) {
326  } else {
328  }
329  char buf[MAX_BUF];
330  snprintf(buf, sizeof(buf), "Rendering %d layers.", render_debug_layers);
332 }
333 
335  {"cmd", COMM_CAT_DEBUG, cmd_raw, NULL, "Send a raw command to the server"},
336 
337  {"debugrender", COMM_CAT_DEBUG, cmd_debugrender, NULL, "Enable renderer debugging"},
338 
340 
341  {"script", COMM_CAT_SCRIPT, script_init, help_script, NULL},
342 #ifdef HAVE_LUA
343  {"lua_load", COMM_CAT_SCRIPT, script_lua_load, NULL, NULL},
344 
345  {"lua_list", COMM_CAT_SCRIPT, script_lua_list, NULL, NULL},
346 
347  {"lua_kill", COMM_CAT_SCRIPT, script_lua_kill, NULL, NULL},
348 #endif
349  {"scripts", COMM_CAT_SCRIPT, do_script_list, NULL, "List running scripts"},
350 
351  {"scriptkill", COMM_CAT_SCRIPT, script_kill, help_scriptkill, NULL},
352 
353  {"scriptkillall", COMM_CAT_SCRIPT, script_killall_wrapper, help_scriptkillall, NULL},
354 
355  {"scripttell", COMM_CAT_SCRIPT, script_tell, help_scripttell, NULL},
356 
357  {"clearinfo", COMM_CAT_MISC, do_clearinfo, NULL, "Clear message window"},
358 
359  {"cwindow", COMM_CAT_SETUP, set_command_window, help_cwindow, NULL},
360 
361  {"disconnect", COMM_CAT_MISC, do_disconnect, NULL, NULL},
362 
363 
364  {"foodbeep", COMM_CAT_SETUP, command_foodbeep, NULL,
365  "toggle audible low on food warning"},
366 
367  {"help", COMM_CAT_MISC, command_help, help_help, NULL},
368 
370 
371  {"magicmap", COMM_CAT_MISC, do_magicmap, help_magicmap,
373 
374  {"mapedit", COMM_CAT_MISC, do_mapedit, NULL, NULL},
375 
376  {"mapscale", COMM_CAT_MISC, do_set_mapscale, NULL, NULL},
377 
378  {"savedefaults", COMM_CAT_SETUP, do_savedefaults, NULL,
380 
381  {
383  "Saves the position and sizes of windows." /* Panes? */
384  },
385 
386  {"take", COMM_CAT_MISC, do_take, NULL, NULL},
387 
388  {"unbind", COMM_CAT_SETUP, unbind_key, help_unbind, NULL},
389 
390  {"show", COMM_CAT_SETUP, command_show, NULL,
391  "Change what items to show in inventory"},
392 };
393 
394 const size_t num_commands = sizeof(CommonCommands) / sizeof(ConsoleCommand);
395 static int get_num_commands() {
396  return num_commands;
397 }
398 
400 
401 static int sort_by_name(const void * a_, const void * b_) {
402  ConsoleCommand * a = *((ConsoleCommand **)a_);
403  ConsoleCommand * b = *((ConsoleCommand **)b_);
404  return strcmp(a->name, b->name);
405 }
406 
408 
409 /* Sort by category, then by name. */
410 
411 static int sort_by_category(const void *a_, const void *b_) {
412  /* Typecasts, so it goes. */
413  ConsoleCommand * a = *((ConsoleCommand **)a_);
414  ConsoleCommand * b = *((ConsoleCommand **)b_);
415 
416  if (a->cat == b->cat) {
417  return strcmp(a->name, b->name);
418  }
419 
420  return a->cat - b->cat;
421 }
422 
424  /* XXX Leak! */
425  name_sorted_commands = g_malloc(sizeof(ConsoleCommand *) * num_commands);
426 
427  for (size_t i = 0; i < num_commands; i++) {
429  }
430 
431  /* Sort them. */
433 
434  /* Copy the list, then sort it by category. */
435  cat_sorted_commands = g_malloc(sizeof(ConsoleCommand *) * num_commands);
436 
438 
440 
441  /* TODO Add to the list of tab-completion items. */
442 }
443 
444 const ConsoleCommand * find_command(const char *cmd) {
445  ConsoleCommand ** asp_p = NULL, dummy;
446  ConsoleCommand * dummy_p;
447  ConsoleCommand * asp;
448  char *cp, *cmd_cpy;
449  cmd_cpy = g_strdup(cmd);
450 
451  for (cp=cmd_cpy; *cp; cp++) {
452  *cp =tolower(*cp);
453  }
454 
455  dummy.name = cmd_cpy;
456  dummy_p = &dummy;
457  asp_p = bsearch(
458  (void *)&dummy_p,
459  (void *)name_sorted_commands,
460  num_commands,
461  sizeof(ConsoleCommand *),
462  sort_by_name);
463 
464  if (asp_p == NULL) {
465  free(cmd_cpy);
466  return NULL;
467  }
468 
469  asp = *asp_p;
470 
471  /* TODO The server's find_command() searches first the commands,
472  then the emotes. We might have to do something similar someday, too. */
473  /* if (asp == NULL) search something else? */
474 
475  free(cmd_cpy);
476 
477  return asp;
478 }
479 
485  return cat_sorted_commands;
486 }
487 
497 int handle_local_command(const char* cp, const char *cpnext) {
498  const ConsoleCommand * cc = NULL;
499 
500  cc = find_command(cp);
501 
502  if (cc == NULL) {
503  return FALSE;
504  }
505 
506  if (cc->dofunc == NULL) {
507  char buf[MAX_BUF];
508 
509  snprintf(buf, MAX_BUF - 1, "Client command %s has no implementation!", cc->name);
511 
512  return FALSE;
513  }
514 
515  cc->dofunc(cpnext);
516 
517  return TRUE;
518 }
519 
531 void extended_command(const char *ocommand) {
532  const char *cp = ocommand;
533  char *cpnext, command[MAX_BUF];
534 
535  if ((cpnext = strchr(cp, ' '))!=NULL) {
536  int len = cpnext - ocommand;
537  if (len > (MAX_BUF -1 )) {
538  len = MAX_BUF-1;
539  }
540 
541  strncpy(command, ocommand, len);
542  command[len] = '\0';
543  cp = command;
544  while (*cpnext == ' ') {
545  cpnext++;
546  }
547  if (*cpnext == 0) {
548  cpnext = NULL;
549  }
550  }
551  /*
552  * Try to prevent potential client hang by trying to delete a
553  * character when there is no character to delete.
554  * Thus, only send quit command if there is a player to delete.
555  */
556  if (cpl.title[0] == '\0' && strcmp(cp, "quit") == 0){
557  // Bail here, there isn't anything this should be doing.
558  return;
559  }
560 
561  /* cp now contains the command (everything before first space),
562  * and cpnext contains everything after that first space. cpnext
563  * could be NULL.
564  */
565 #ifdef HAVE_LUA
566  if ( script_lua_command(cp, cpnext) ) {
567  return;
568  }
569 #endif
570 
571  /* If this isn't a client-side command, send it to the server. */
572  if (!handle_local_command(cp, cpnext)) {
573  /* just send the command(s) (if `ocommand' is a compound command */
574  /* then split it and send each part separately */
575  /* TODO Remove this from the server; end of commands.c. */
576  strncpy(command, ocommand, MAX_BUF-1);
577  command[MAX_BUF-1]=0;
578  cp = strtok(command, ";");
579  while ( cp ) {
580  while( *cp == ' ' ) {
581  cp++;
582  } /* throw out leading spaces; server
583  does not like them */
584  send_command(cp, cpl.count, 0);
585  cp = strtok(NULL, ";");
586  }
587  }
588 }
589 
590 /* ------------------------------------------------------------------ */
591 
592 /* This list is used for the 'tab' completion, and nothing else.
593  * Therefore, if it is out of date, it isn't that terrible, but
594  * ideally it should stay somewhat up to date with regards to
595  * the commands the server supports.
596  */
597 
598 /* TODO Dynamically generate. */
599 
600 static const char *const commands[] = {
601  "accuse", "afk", "apply", "applymode", "archs", "beg", "bleed", "blush",
602  "body", "bounce", "bow", "bowmode", "brace", "build", "burp", "cackle", "cast",
603  "chat", "chuckle", "clap", "cointoss", "cough", "cringe", "cry", "dance",
604  "disarm", "dm", "dmhide", "drop", "dropall", "east", "examine", "explore",
605  "fire", "fire_stop", "fix_me", "flip", "frown", "gasp", "get", "giggle",
606  "glare", "grin", "groan", "growl", "gsay", "help", "hiccup", "hiscore", "hug",
607  "inventory", "invoke", "killpets", "kiss", "laugh", "lick", "listen", "logs",
608  "mapinfo", "maps", "mark", "me", "motd", "nod", "north", "northeast",
609  "northwest", "orcknuckle", "output-count", "output-sync", "party", "peaceful",
610  "petmode", "pickup", "players", "poke", "pout", "prepare", "printlos", "puke",
611  "quests", "quit", "ready_skill", "rename", "reply", "resistances",
612  "rotateshoottype", "run", "run_stop", "save", "say", "scream", "search",
613  "search-items", "shake", "shiver", "shout", "showpets", "shrug", "shutdown",
614  "sigh", "skills", "slap", "smile", "smirk", "snap", "sneeze", "snicker",
615  "sniff", "snore", "sound", "south", "southeast", "southwest", "spit",
616  "statistics", "stay", "strings", "strut", "sulk", "take", "tell", "thank",
617  "think", "throw", "time", "title", "twiddle", "use_skill", "usekeys",
618  "version", "wave", "weather", "west", "whereabouts", "whereami", "whistle",
619  "who", "wimpy", "wink", "yawn",
620 };
621 const size_t num_server_commands = sizeof(commands) / sizeof(char *);
622 
630 const char * complete_command(const char *command) {
631  int len, display = 0;
632  const char *match;
633  static char result[64];
634  char list[500];
635 
636  len = strlen(command);
637 
638  if (len == 0) {
639  return NULL;
640  }
641 
642  strcpy(list, "Matching commands:");
643 
644  /* TODO Partial match, e.g.:
645  If the completion list was:
646  wear
647  wet #?
648 
649  If we type 'w' then hit tab, put in the e.
650 
651  Basically part of bash (readline?)'s behaviour.
652  */
653 
654  match = NULL;
655 
656  /* check server side commands */
657  for (size_t i = 0; i < num_server_commands; i++) {
658  if (!strncmp(command, commands[i], len)) {
659  if (display) {
660  snprintf(list + strlen(list), 499 - strlen(list), " %s", commands[i]);
661  } else if (match != NULL) {
662  display = 1;
663  snprintf(list + strlen(list), 499 - strlen(list), " %s %s", match, commands[i]);
664  match = NULL;
665  } else {
666  match = commands[i];
667  }
668  }
669  }
670 
671  /* check client side commands */
672  for (size_t i = 0; i < num_commands; i++) {
673  if (!strncmp(command, CommonCommands[i].name, len)) {
674  if (display) {
675  snprintf(list + strlen(list), 499 - strlen(list), " %s", CommonCommands[i].name);
676  } else if (match != NULL) {
677  display = 1;
678  snprintf(list + strlen(list), 499 - strlen(list), " %s %s", match, CommonCommands[i].name);
679  match = NULL;
680  } else {
681  match = CommonCommands[i].name;
682  }
683  }
684  }
685 
686  if (match == NULL) {
687  if (display) {
688  strncat(list, "\n", 499 - strlen(list));
691  } else
693  "No matching command.\n");
694  /* No match. */
695  return NULL;
696  }
697 
698  /*
699  * Append a space to allow typing arguments. For commands without arguments
700  * the excess space should be stripped off automatically.
701  */
702  snprintf(result, sizeof(result), "%s ", match);
703  return result;
704 }
COMM_CAT_INFO
@ COMM_CAT_INFO
Definition: p_cmd.h:46
help_cwindow
static const char * help_cwindow(void)
Definition: p_cmd.c:259
MSG_TYPE_CLIENT
#define MSG_TYPE_CLIENT
Client originated Messages.
Definition: newclient.h:390
CONFIG_CWINDOW
#define CONFIG_CWINDOW
Definition: client.h:186
CommonCommands
static ConsoleCommand CommonCommands[]
Definition: p_cmd.c:334
HELP_INV_SHORT
#define HELP_INV_SHORT
Definition: chelp.h:66
find_command
const ConsoleCommand * find_command(const char *cmd)
Definition: p_cmd.c:444
Player_Struct::title
char title[MAX_BUF]
Title of character.
Definition: client.h:352
help_savewinpos
static const char * help_savewinpos(void)
Definition: p_cmd.c:290
client_disconnect
void client_disconnect()
Closes the connection to the server.
Definition: client.c:175
ClientSocket::fd
GSocketConnection * fd
Definition: client.h:124
HELP_BIND_LONG
#define HELP_BIND_LONG
Definition: chelp.h:7
extended_command
void extended_command(const char *ocommand)
This is an extended command (ie, 'who, 'whatever, etc).
Definition: p_cmd.c:531
HELP_INV_LONG
#define HELP_INV_LONG
Definition: chelp.h:67
external.h
init_commands
void init_commands()
Fills some internal arrays.
Definition: p_cmd.c:423
HELP_MAGICMAP_LONG
#define HELP_MAGICMAP_LONG
Definition: chelp.h:55
script_lua_kill
void script_lua_kill(const char *param)
ConsoleCommand::name
const char * name
Definition: p_cmd.h:57
COMM_CAT_MISC
@ COMM_CAT_MISC
Definition: p_cmd.h:45
CommCat
CommCat
Definition: p_cmd.h:44
CONFIG_MAPSCALE
#define CONFIG_MAPSCALE
Definition: client.h:190
chelp.h
get_category_name
const char * get_category_name(CommCat cat)
Definition: p_cmd.c:169
NDI_RED
#define NDI_RED
Definition: newclient.h:227
save_defaults
void save_defaults(void)
This function saves user settings chosen using the configuration popup dialog.
Definition: config.c:517
map_check_resize
void map_check_resize(void)
Calculate and set desired map size based on map window size.
Definition: map.c:49
menu_clear
void menu_clear(void)
Clears all the message panels.
Definition: info.c:1329
help_scriptkill
static const char * help_scriptkill(void)
Definition: p_cmd.c:299
render_debug_layers
int render_debug_layers
Current number of layers to render for renderer debugging purposes.
Definition: p_cmd.c:46
do_savedefaults
static void do_savedefaults()
Definition: p_cmd.c:216
cmd_raw
static void cmd_raw(const char *cmd)
Definition: p_cmd.c:319
HELP_SAVEDEFAULTS_SHORT
#define HELP_SAVEDEFAULTS_SHORT
Definition: chelp.h:59
do_take
static void do_take(const char *used)
Definition: p_cmd.c:236
set_command_window
static void set_command_window(const char *cpnext)
Definition: p_cmd.c:142
draw_magic_map
void draw_magic_map(void)
Definition: magicmap.c:24
command_help
static void command_help(const char *cpnext)
Definition: p_cmd.c:98
ConsoleCommand::cat
CommCat cat
Definition: p_cmd.h:58
mapdata.h
CONFIG_FOODBEEP
#define CONFIG_FOODBEEP
Definition: client.h:203
HELP_UNBIND_LONG
#define HELP_UNBIND_LONG
Definition: chelp.h:45
MAX_BUF
#define MAX_BUF
Definition: client.h:40
do_clienthelp_list
static void do_clienthelp_list()
Definition: p_cmd.c:48
command_take
void command_take(const char *command, const char *cpnext)
Definition: player.c:349
help_help
static const char * help_help(void)
Definition: p_cmd.c:122
COMM_CAT_DEBUG
@ COMM_CAT_DEBUG
Definition: p_cmd.h:49
num_commands
const size_t num_commands
Definition: p_cmd.c:394
do_script_list
static void do_script_list()
Definition: p_cmd.c:203
Player_Struct::ob
item * ob
Player object.
Definition: client.h:337
show_help
static void show_help(const ConsoleCommand *cc)
Definition: p_cmd.c:75
H2
#define H2(a)
Definition: p_cmd.c:33
script_lua_load
void script_lua_load(const char *name)
bind_key
void bind_key(const char *params)
COMM_CAT_SCRIPT
@ COMM_CAT_SCRIPT
Definition: p_cmd.h:48
command_foodbeep
static void command_foodbeep()
Definition: p_cmd.c:156
complete_command
const char * complete_command(const char *command)
Player has entered 'command' and hit tab to complete it.
Definition: p_cmd.c:630
name_sorted_commands
static ConsoleCommand ** name_sorted_commands
Definition: p_cmd.c:399
cs_print_string
int cs_print_string(GSocketConnection *fd, const char *str,...)
Send a printf-formatted packet to the socket.
Definition: newsocket.c:251
script_kill
void script_kill(const char *params)
Definition: script.c:515
want_config
gint16 want_config[CONFIG_NUMS]
Definition: init.c:44
csocket
ClientSocket csocket
Definition: client.c:70
draw_ext_info
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:915
do_mapedit
static void do_mapedit()
Definition: p_cmd.c:220
NDI_BLACK
#define NDI_BLACK
Definition: newclient.h:224
COMM_CAT_SETUP
@ COMM_CAT_SETUP
Definition: p_cmd.h:47
num_server_commands
const size_t num_server_commands
Definition: p_cmd.c:621
arm_mapedit
bool arm_mapedit
If true, the next drawextinfo is expected to contain a map path.
Definition: p_cmd.c:40
LINE
#define LINE(a)
Definition: p_cmd.c:34
MSG_TYPE_CLIENT_DEBUG
#define MSG_TYPE_CLIENT_DEBUG
General debug messages.
Definition: newclient.h:637
sort_by_category
static int sort_by_category(const void *a_, const void *b_)
Definition: p_cmd.c:411
save_winpos
void save_winpos(void)
Save client window positions to a file unique to each layout.
Definition: config.c:809
script_list
void script_list(void)
Definition: script.c:493
H1
#define H1(a)
Definition: p_cmd.c:32
do_set_mapscale
static void do_set_mapscale(const char *used)
Definition: p_cmd.c:225
script_lua_list
void script_lua_list(const char *param)
do_clearinfo
static void do_clearinfo()
Definition: p_cmd.c:205
p_cmd.h
help_magicmap
static const char * help_magicmap(void)
Definition: p_cmd.c:251
ConsoleCommand::dofunc
CommFunc dofunc
Definition: p_cmd.h:59
send_command
int send_command(const char *command, int repeat, int must_send)
Definition: player.c:231
do_disconnect
static void do_disconnect()
Definition: p_cmd.c:207
cpl
Client_Player cpl
Player object.
Definition: client.c:69
MSG_TYPE_CLIENT_CONFIG
#define MSG_TYPE_CLIENT_CONFIG
Local configuration issues.
Definition: newclient.h:633
ConsoleCommand::helpfunc
CommHelpFunc helpfunc
Definition: p_cmd.h:61
NDI_BROWN
#define NDI_BROWN
Sienna.
Definition: newclient.h:235
script_lua_command
int script_lua_command(const char *command, const char *param)
ConsoleCommand
Definition: p_cmd.h:56
COMMAND_WINDOW
#define COMMAND_WINDOW
Do not send more than this many outstanding commands to the server this is only a default value.
Definition: client.h:76
unbind_key
void unbind_key(const char *params)
Definition: keys.c:1471
MSG_TYPE_CLIENT_NOTICE
#define MSG_TYPE_CLIENT_NOTICE
Non-critical note to player.
Definition: newclient.h:638
handle_local_command
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:497
ConsoleCommand::desc
const char * desc
Definition: p_cmd.h:62
help_scripttell
static const char * help_scripttell(void)
Definition: p_cmd.c:279
Player_Struct::count
guint32 count
Repeat count on command.
Definition: client.h:360
script.h
use_config
gint16 use_config[CONFIG_NUMS]
Definition: client.h:245
get_num_commands
static int get_num_commands(void)
Definition: p_cmd.c:395
MAXLAYERS
#define MAXLAYERS
The protocol supports 10 layers, so set MAXLAYERS accordingly.
Definition: mapdata.h:6
do_magicmap
static void do_magicmap()
Definition: p_cmd.c:212
HELP_MAGICMAP_SHORT
#define HELP_MAGICMAP_SHORT
Definition: chelp.h:54
cat_sorted_commands
static ConsoleCommand ** cat_sorted_commands
Definition: p_cmd.c:407
help_bind
static const char * help_bind(void)
Definition: p_cmd.c:243
HELP_BIND_SHORT
#define HELP_BIND_SHORT
Definition: chelp.h:6
get_cat_sorted_commands
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:484
script_init
void script_init(const char *cparams)
Definition: script.c:205
script_tell
void script_tell(const char *params)
Definition: script.c:959
script_killall_wrapper
void script_killall_wrapper(const char *params)
Definition: script.c:536
sort_by_name
static int sort_by_name(const void *a_, const void *b_)
Definition: p_cmd.c:401
do_savewinpos
static void do_savewinpos()
Definition: p_cmd.c:218
commands
static const char *const commands[]
Definition: p_cmd.c:600
client.h
help_scriptkillall
static const char * help_scriptkillall(void)
Definition: p_cmd.c:309
help_script
static const char * help_script(void)
Definition: p_cmd.c:272
help_unbind
static const char * help_unbind(void)
Definition: p_cmd.c:247
cmd_debugrender
void cmd_debugrender(const char *cmd)
Definition: p_cmd.c:323
help_inv
static const char * help_inv(void)
Definition: p_cmd.c:255
print_inventory
void print_inventory(item *op)
Definition: item.c:620
do_inv
static void do_inv()
Definition: p_cmd.c:210
command_show
void command_show(const char *params)
Definition: inventory.c:650
config_check
void config_check(void)
Check that want_config is valid, copy the new configuration to use_config, and apply the new configur...
Definition: config.c:334