Crossfire Client, Trunk  R20507
Macros | Functions | Variables
p_cmd.c File Reference

Contains a lot about the commands typed into the client. More...

#include <ctype.h>
#include "client.h"
#include "external.h"
#include "p_cmd.h"
#include "script.h"
#include "chelp.h"
Include dependency graph for p_cmd.c:

Go to the source code of this file.

Macros

#define H1(a)   draw_ext_info(NDI_BLACK, MSG_TYPE_CLIENT, MSG_TYPE_CLIENT_NOTICE, a)
 
#define H2(a)   draw_ext_info(NDI_BLACK, MSG_TYPE_CLIENT, MSG_TYPE_CLIENT_NOTICE, a)
 
#define LINE(a)   draw_ext_info(NDI_BLACK, MSG_TYPE_CLIENT, MSG_TYPE_CLIENT_NOTICE, a)
 

Functions

static void cmd_raw (const char *cmd)
 
static void command_foodbeep ()
 
static void command_help (const char *cpnext)
 
const char * complete_command (const char *command)
 Player has entered 'command' and hit tab to complete it. More...
 
static void do_clearinfo ()
 
static void do_clienthelp_list ()
 
static void do_disconnect ()
 
static void do_inv ()
 
static void do_magicmap ()
 
static void do_num_free_items ()
 
static void do_savedefaults ()
 
static void do_savewinpos ()
 
static void do_script_list ()
 
static void do_take (const char *used)
 
void extended_command (const char *ocommand)
 This is an extended command (ie, 'who, 'whatever, etc). More...
 
const ConsoleCommandfind_command (const char *cmd)
 
ConsoleCommand ** get_cat_sorted_commands (void)
 Returns a pointer to the head of an array of ConsoleCommands sorted by category, then by name. More...
 
const char * get_category_name (CommCat cat)
 
static int get_num_commands (void)
 
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. More...
 
static const char * help_bind (void)
 
static const char * help_cwindow (void)
 
static const char * help_help (void)
 
static const char * help_inv (void)
 
static const char * help_magicmap (void)
 
static const char * help_savewinpos (void)
 
static const char * help_script (void)
 
static const char * help_scriptkill (void)
 
static const char * help_scripttell (void)
 
static const char * help_unbind (void)
 
void init_commands ()
 Fills some internal arrays. More...
 
static void set_command_window (const char *cpnext)
 
static void show_help (const ConsoleCommand *cc)
 
static int sort_by_category (const void *a_, const void *b_)
 
static int sort_by_name (const void *a_, const void *b_)
 

Variables

static ConsoleCommand ** cat_sorted_commands
 
static const char *const commands []
 
static ConsoleCommand CommonCommands []
 
static ConsoleCommand ** name_sorted_commands
 
const size_t num_commands = sizeof(CommonCommands) / sizeof(ConsoleCommand)
 
const size_t num_server_commands = sizeof(commands) / sizeof(char *)
 

Detailed Description

Contains a lot about the commands typed into the client.

Definition in file p_cmd.c.

Function Documentation

static void cmd_raw ( const char *  cmd)
static

Definition at line 289 of file p_cmd.c.

References cs_print_string(), csocket, and ClientSocket::fd.

Here is the call graph for this function:

static void command_foodbeep ( )
static

Definition at line 147 of file p_cmd.c.

References CONFIG_FOODBEEP, draw_ext_info(), MSG_TYPE_CLIENT, MSG_TYPE_CLIENT_NOTICE, NDI_BLACK, use_config, and want_config.

Here is the call graph for this function:

const char* complete_command ( const char *  command)

Player has entered 'command' and hit tab to complete it.

See if we can find a completion. Returns matching command. Returns NULL if no command matches.

Parameters
command

Definition at line 583 of file p_cmd.c.

References draw_ext_info(), MSG_TYPE_CLIENT, MSG_TYPE_CLIENT_NOTICE, name, ConsoleCommand::name, NDI_BLACK, num_commands, and num_server_commands.

Referenced by gtk_complete_command().

Here is the call graph for this function:

Here is the caller graph for this function:

static void do_clearinfo ( )
static

Definition at line 196 of file p_cmd.c.

References menu_clear().

Here is the call graph for this function:

static void do_disconnect ( )
static

Definition at line 198 of file p_cmd.c.

References client_disconnect().

Here is the call graph for this function:

static void do_inv ( )
static

Definition at line 201 of file p_cmd.c.

References cpl, Player_Struct::ob, and print_inventory().

Here is the call graph for this function:

static void do_magicmap ( )
static

Definition at line 203 of file p_cmd.c.

References draw_magic_map().

Here is the call graph for this function:

static void do_num_free_items ( )
static

Definition at line 215 of file p_cmd.c.

References LOG(), LOG_INFO, and num_free_items().

Here is the call graph for this function:

static void do_savedefaults ( )
static

Definition at line 207 of file p_cmd.c.

References save_defaults().

Here is the call graph for this function:

static void do_savewinpos ( )
static

Definition at line 209 of file p_cmd.c.

References save_winpos().

Here is the call graph for this function:

static void do_script_list ( )
static

Definition at line 194 of file p_cmd.c.

References script_list().

Here is the call graph for this function:

static void do_take ( const char *  used)
static

Definition at line 211 of file p_cmd.c.

References command_take().

Here is the call graph for this function:

void extended_command ( const char *  ocommand)

This is an extended command (ie, 'who, 'whatever, etc).

In general, we just send the command to the server, but there are a few that we care about (bind, unbind)

The command passed to us can not be modified - if it is a keybinding, we get passed the string that is that binding - modifying it effectively changes the binding.

Parameters
ocommand

Definition at line 484 of file p_cmd.c.

References Player_Struct::count, cpl, handle_local_command(), MAX_BUF, script_lua_command(), send_command(), and Player_Struct::title.

Referenced by menu_quit_character(), on_entry_commands_activate(), and parse_key().

Here is the call graph for this function:

Here is the caller graph for this function:

const ConsoleCommand * find_command ( const char *  cmd)

Definition at line 397 of file p_cmd.c.

References num_commands, and sort_by_name().

Referenced by command_help(), and handle_local_command().

Here is the call graph for this function:

Here is the caller graph for this function:

ConsoleCommand** get_cat_sorted_commands ( void  )

Returns a pointer to the head of an array of ConsoleCommands sorted by category, then by name.

It's num_commands long.

Definition at line 437 of file p_cmd.c.

References cat_sorted_commands.

Referenced by do_clienthelp_list().

Here is the caller graph for this function:

const char* get_category_name ( CommCat  cat)

Definition at line 160 of file p_cmd.c.

References COMM_CAT_DEBUG, COMM_CAT_INFO, COMM_CAT_MISC, COMM_CAT_SCRIPT, and COMM_CAT_SETUP.

Referenced by do_clienthelp_list().

Here is the caller graph for this function:

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.

If this was a local command, returns true to indicate command was handled. This code was moved from extended_command so scripts ca issue local commands to handle keybindings or anything else.

Parameters
cp
cpnext

Definition at line 450 of file p_cmd.c.

References ConsoleCommand::dofunc, draw_ext_info(), find_command(), MAX_BUF, MSG_TYPE_CLIENT, MSG_TYPE_CLIENT_NOTICE, ConsoleCommand::name, and NDI_RED.

Referenced by extended_command(), and script_process_cmd().

Here is the call graph for this function:

Here is the caller graph for this function:

static const char* help_bind ( void  )
static

Definition at line 223 of file p_cmd.c.

References HELP_BIND_LONG.

static const char* help_cwindow ( void  )
static

Definition at line 239 of file p_cmd.c.

static const char* help_inv ( void  )
static

Definition at line 235 of file p_cmd.c.

References HELP_INV_LONG.

static const char* help_magicmap ( void  )
static

Definition at line 231 of file p_cmd.c.

References HELP_MAGICMAP_LONG.

static const char* help_savewinpos ( void  )
static

Definition at line 270 of file p_cmd.c.

static const char* help_script ( void  )
static

Definition at line 252 of file p_cmd.c.

static const char* help_scriptkill ( void  )
static

Definition at line 279 of file p_cmd.c.

static const char* help_scripttell ( void  )
static

Definition at line 259 of file p_cmd.c.

static const char* help_unbind ( void  )
static

Definition at line 227 of file p_cmd.c.

References HELP_UNBIND_LONG.

void init_commands ( void  )

Fills some internal arrays.

Run this on startup, but not before filling in ToolkitCommands and ToolkitCommandsSize.

Definition at line 376 of file p_cmd.c.

References num_commands, sort_by_category(), and sort_by_name().

Referenced by client_init().

Here is the call graph for this function:

Here is the caller graph for this function:

static void set_command_window ( const char *  cpnext)
static

Definition at line 133 of file p_cmd.c.

References COMMAND_WINDOW, CONFIG_CWINDOW, draw_ext_info(), MSG_TYPE_CLIENT, MSG_TYPE_CLIENT_NOTICE, NDI_BLACK, use_config, and want_config.

Here is the call graph for this function:

static int sort_by_category ( const void *  a_,
const void *  b_ 
)
static

Definition at line 364 of file p_cmd.c.

References ConsoleCommand::cat, and ConsoleCommand::name.

Referenced by init_commands().

Here is the caller graph for this function:

static int sort_by_name ( const void *  a_,
const void *  b_ 
)
static

Definition at line 354 of file p_cmd.c.

References ConsoleCommand::name.

Referenced by find_command(), and init_commands().

Here is the caller graph for this function:

Variable Documentation

ConsoleCommand** cat_sorted_commands
static

Definition at line 360 of file p_cmd.c.

Referenced by get_cat_sorted_commands().

const char* const commands[]
static
Initial value:
= {
"accuse", "afk", "apply", "applymode", "archs", "beg", "bleed", "blush",
"body", "bounce", "bow", "bowmode", "brace", "build", "burp", "cackle", "cast",
"chat", "chuckle", "clap", "cointoss", "cough", "cringe", "cry", "dance",
"disarm", "dm", "dmhide", "drop", "dropall", "east", "examine", "explore",
"fire", "fire_stop", "fix_me", "flip", "frown", "gasp", "get", "giggle",
"glare", "grin", "groan", "growl", "gsay", "help", "hiccup", "hiscore", "hug",
"inventory", "invoke", "killpets", "kiss", "laugh", "lick", "listen", "logs",
"mapinfo", "maps", "mark", "me", "motd", "nod", "north", "northeast",
"northwest", "orcknuckle", "output-count", "output-sync", "party", "peaceful",
"petmode", "pickup", "players", "poke", "pout", "prepare", "printlos", "puke",
"quests", "quit", "ready_skill", "rename", "reply", "resistances",
"rotateshoottype", "run", "run_stop", "save", "say", "scream", "search",
"search-items", "shake", "shiver", "shout", "showpets", "shrug", "shutdown",
"sigh", "skills", "slap", "smile", "smirk", "snap", "sneeze", "snicker",
"sniff", "snore", "sound", "south", "southeast", "southwest", "spit",
"statistics", "stay", "strings", "strut", "sulk", "take", "tell", "thank",
"think", "throw", "time", "title", "twiddle", "use_skill", "usekeys",
"version", "wave", "weather", "west", "whereabouts", "whereami", "whistle",
"who", "wimpy", "wink", "yawn",
}

Definition at line 553 of file p_cmd.c.

ConsoleCommand CommonCommands[]
static

Definition at line 293 of file p_cmd.c.

ConsoleCommand** name_sorted_commands
static

Definition at line 352 of file p_cmd.c.

const size_t num_commands = sizeof(CommonCommands) / sizeof(ConsoleCommand)

Definition at line 347 of file p_cmd.c.

Referenced by complete_command(), find_command(), get_num_commands(), and init_commands().

const size_t num_server_commands = sizeof(commands) / sizeof(char *)

Definition at line 574 of file p_cmd.c.

Referenced by complete_command().