Crossfire Client, Trunk
Macros | Functions | Variables
p_cmd.c File Reference
#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)
 
void config_check (void)
 
static void do_clearinfo ()
 
static void do_clienthelp_list ()
 
static void do_disconnect ()
 
static void do_inv ()
 
static void do_magicmap ()
 
static void do_mapedit ()
 
static void do_savedefaults ()
 
static void do_savewinpos ()
 
static void do_script_list ()
 
static void do_set_mapscale (const char *used)
 
static void do_take (const char *used)
 
void extended_command (const char *ocommand)
 
const ConsoleCommandfind_command (const char *cmd)
 
ConsoleCommand ** get_cat_sorted_commands (void)
 
const char * get_category_name (CommCat cat)
 
static int get_num_commands (void)
 
int handle_local_command (const char *cp, const char *cpnext)
 
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_scriptkillall (void)
 
static const char * help_scripttell (void)
 
static const char * help_unbind (void)
 
void init_commands ()
 
void map_check_resize (void)
 
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

bool arm_mapedit = false
 
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

◆ cmd_raw()

static void cmd_raw ( const char *  cmd)
static

Definition at line 316 of file p_cmd.c.

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

Here is the call graph for this function:

◆ command_foodbeep()

static void command_foodbeep ( )
static

Definition at line 153 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:

◆ complete_command()

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 614 of file p_cmd.c.

References commands, CommonCommands, draw_ext_info(), MSG_TYPE_CLIENT, MSG_TYPE_CLIENT_NOTICE, 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:

◆ do_clearinfo()

static void do_clearinfo ( )
static

Definition at line 202 of file p_cmd.c.

References menu_clear().

Here is the call graph for this function:

◆ do_disconnect()

static void do_disconnect ( )
static

Definition at line 204 of file p_cmd.c.

References client_disconnect().

Here is the call graph for this function:

◆ do_inv()

static void do_inv ( )
static

Definition at line 207 of file p_cmd.c.

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

Here is the call graph for this function:

◆ do_magicmap()

static void do_magicmap ( )
static

Definition at line 209 of file p_cmd.c.

References draw_magic_map().

Here is the call graph for this function:

◆ do_mapedit()

static void do_mapedit ( )
static

Definition at line 217 of file p_cmd.c.

References arm_mapedit, and send_command().

Here is the call graph for this function:

◆ do_savedefaults()

static void do_savedefaults ( )
static

Definition at line 213 of file p_cmd.c.

References save_defaults().

Here is the call graph for this function:

◆ do_savewinpos()

static void do_savewinpos ( )
static

Definition at line 215 of file p_cmd.c.

References save_winpos().

Here is the call graph for this function:

◆ do_script_list()

static void do_script_list ( )
static

Definition at line 200 of file p_cmd.c.

References script_list().

Here is the call graph for this function:

◆ do_set_mapscale()

static void do_set_mapscale ( const char *  used)
static

Definition at line 222 of file p_cmd.c.

References config_check(), CONFIG_MAPSCALE, draw_ext_info(), MSG_TYPE_CLIENT, MSG_TYPE_CLIENT_CONFIG, NDI_RED, and want_config.

Here is the call graph for this function:

◆ do_take()

static void do_take ( const char *  used)
static

Definition at line 233 of file p_cmd.c.

References command_take().

Here is the call graph for this function:

◆ extended_command()

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 515 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:

◆ find_command()

const ConsoleCommand * find_command ( const char *  cmd)

Definition at line 428 of file p_cmd.c.

References name_sorted_commands, 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:

◆ 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. It's num_commands long.

Definition at line 468 of file p_cmd.c.

References cat_sorted_commands.

Referenced by do_clienthelp_list().

Here is the caller graph for this function:

◆ get_category_name()

const char* get_category_name ( CommCat  cat)

Definition at line 166 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:

◆ 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. 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 481 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:

◆ help_bind()

static const char* help_bind ( void  )
static

Definition at line 240 of file p_cmd.c.

References HELP_BIND_LONG.

◆ help_cwindow()

static const char* help_cwindow ( void  )
static

Definition at line 256 of file p_cmd.c.

◆ help_inv()

static const char* help_inv ( void  )
static

Definition at line 252 of file p_cmd.c.

References HELP_INV_LONG.

◆ help_magicmap()

static const char* help_magicmap ( void  )
static

Definition at line 248 of file p_cmd.c.

References HELP_MAGICMAP_LONG.

◆ help_savewinpos()

static const char* help_savewinpos ( void  )
static

Definition at line 287 of file p_cmd.c.

◆ help_script()

static const char* help_script ( void  )
static

Definition at line 269 of file p_cmd.c.

◆ help_scriptkill()

static const char* help_scriptkill ( void  )
static

Definition at line 296 of file p_cmd.c.

◆ help_scriptkillall()

static const char* help_scriptkillall ( void  )
static

Definition at line 306 of file p_cmd.c.

◆ help_scripttell()

static const char* help_scripttell ( void  )
static

Definition at line 276 of file p_cmd.c.

◆ help_unbind()

static const char* help_unbind ( void  )
static

Definition at line 244 of file p_cmd.c.

References HELP_UNBIND_LONG.

◆ init_commands()

void init_commands ( void  )

Fills some internal arrays. Run this on startup, but not before filling in ToolkitCommands and ToolkitCommandsSize.

Definition at line 407 of file p_cmd.c.

References cat_sorted_commands, CommonCommands, name_sorted_commands, 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:

◆ set_command_window()

static void set_command_window ( const char *  cpnext)
static

Definition at line 139 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:

◆ sort_by_category()

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

Definition at line 395 of file p_cmd.c.

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

Referenced by init_commands().

Here is the caller graph for this function:

◆ sort_by_name()

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

Definition at line 385 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

◆ cat_sorted_commands

ConsoleCommand** cat_sorted_commands
static

Definition at line 391 of file p_cmd.c.

Referenced by get_cat_sorted_commands(), and init_commands().

◆ 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 584 of file p_cmd.c.

Referenced by complete_command().

◆ CommonCommands

ConsoleCommand CommonCommands[]
static

Definition at line 320 of file p_cmd.c.

Referenced by complete_command(), and init_commands().

◆ name_sorted_commands

ConsoleCommand** name_sorted_commands
static

Definition at line 383 of file p_cmd.c.

Referenced by find_command(), and init_commands().

◆ num_commands

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

Definition at line 378 of file p_cmd.c.

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

◆ num_server_commands

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

Definition at line 605 of file p_cmd.c.

Referenced by complete_command().