All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Classes | Macros | Typedefs | Functions | Variables
Command Processing and Chat History

This module processes APme commands and the chat history. More...

Classes

struct  cmd_entry
 

Macros

#define CMD_COMMAND_CHAR   '?'
 
#define CMD_CHATHIST_CHAR   '^'
 
#define CMD_SIZE   64
 
#define CMD_ARGC_MAX   32
 
#define CMD_DELIM   " ,"
 
#define CMD_TEXT_SZ   AION_CHAT_SZ
 
#define CMD_RETVAL_OK   "OK"
 
#define CMD_RETVAL_ERROR   "Error"
 
#define CMD_RETVAL_UNKNOWN   "Unknown command"
 

Typedefs

typedef bool cmd_func_t (int argc, char *argv[], char *txt)
 

Functions

static bool cmd_func_translate (char *txt, int langid)
 
static bool cmd_func_rtranslate (char *txt, int langid)
 
static char * cmd_sanitize (char *str)
 
void cmd_retval_printf (char *fmt,...)
 
void cmd_retval_set (const char *txt)
 
bool cmd_func_help (int argc, char *argv[], char *txt)
 
bool cmd_func_hello (int argc, char *argv[], char *txt)
 
bool cmd_func_nameset (int argc, char *argv[], char *txt)
 
bool cmd_func_ap_stats (int argc, char *argv[], char *txt)
 
bool cmd_func_ap_loot (int argc, char *argv[], char *txt)
 
bool cmd_func_ap_set (int argc, char *argv[], char *txt)
 
bool cmd_func_ap_reset (int argc, char *argv[], char *txt)
 
bool cmd_func_ap_limit (int argc, char *argv[], char *txt)
 
bool cmd_func_ap_format (int argc, char *argv[], char *txt)
 
bool cmd_func_group_add (int argc, char *argv[], char *txt)
 
bool cmd_func_group_del (int argc, char *argv[], char *txt)
 
bool cmd_func_group_leave (int argc, char *argv[], char *txt)
 
bool cmd_func_elyos (int argc, char *argv[], char *txt)
 
bool cmd_func_asmo (int argc, char *argv[], char *txt)
 
bool cmd_func_relyos (int argc, char *argv[], char *txt)
 
bool cmd_func_rasmo (int argc, char *argv[], char *txt)
 
bool cmd_func_echo (int argc, char *argv[], char *txt)
 
bool cmd_func_apcalc (int argc, char *argv[], char *txt)
 
bool cmd_func_inv (int argc, char *argv[], char *txt)
 
bool cmd_func_dbgdump (int argc, char *argv[], char *txt)
 
bool cmd_func_dbgparse (int argc, char *argv[], char *txt)
 
bool cmd_chat_hist (int argc, char *argv[], char *player, size_t player_sz, int *msgnum)
 
void cmd_exec (char *txt)
 
void cmd_poll (void)
 

Variables

static char cmd_retval [CMD_TEXT_SZ]
 
static cmd_func_t cmd_func_help
 
static cmd_func_t cmd_func_hello
 
static cmd_func_t cmd_func_nameset
 
static cmd_func_t cmd_func_ap_stats
 
static cmd_func_t cmd_func_ap_loot
 
static cmd_func_t cmd_func_ap_set
 
static cmd_func_t cmd_func_ap_reset
 
static cmd_func_t cmd_func_ap_limit
 
static cmd_func_t cmd_func_ap_format
 
static cmd_func_t cmd_func_group_add
 
static cmd_func_t cmd_func_group_del
 
static cmd_func_t cmd_func_group_leave
 
static cmd_func_t cmd_func_elyos
 
static cmd_func_t cmd_func_asmo
 
static cmd_func_t cmd_func_relyos
 
static cmd_func_t cmd_func_rasmo
 
static cmd_func_t cmd_func_echo
 
static cmd_func_t cmd_func_apcalc
 
static cmd_func_t cmd_func_inv
 
static cmd_func_t cmd_func_dbgdump
 
static cmd_func_t cmd_func_dbgparse
 
struct cmd_entry cmd_list []
 

Detailed Description

This module processes APme commands and the chat history.

This module periodically polls the clipboard in cmd_poll(). If it detects a command text (oen starting with '?', or CMD_COMMAND_CHAR) it assumes it's an APme command text and it processes it.

Macro Definition Documentation

#define CMD_ARGC_MAX   32

Maximum number of arguments for a command

#define CMD_CHATHIST_CHAR   '^'

History command prefix

#define CMD_COMMAND_CHAR   '?'

Chat command prefix

#define CMD_DELIM   " ,"

delimiters between arguments

#define CMD_RETVAL_ERROR   "Error"

Default response on error

#define CMD_RETVAL_OK   "OK"

Default response on success

#define CMD_RETVAL_UNKNOWN   "Unknown command"

Default response if command not found

#define CMD_SIZE   64

Maximum command size

#define CMD_TEXT_SZ   AION_CHAT_SZ

Total command text size

Typedef Documentation

typedef bool cmd_func_t(int argc, char *argv[], char *txt)

This is the general command processing function format

Function Documentation

bool cmd_chat_hist ( int  argc,
char *  argv[],
char *  player,
size_t  player_sz,
int *  msgnum 
)

This functions scans the command arguments (argc,argv) and returns true if it contains a chatlog history command in the format of [N]^+NAME

In case a chat history command is matched, it returns the name of the player to retrieve the chat history and the message number, where 0 is the most recent message

Parameters
[in]argcNumber of elements in argv
[in]argvArgument array
[out]playerRequested chat history player name
[in]player_szSize of the buffer pointed to by player
[out]msgnumThe index of the chat history line requested (0 being most recent)
Return values
trueIf argc/argv contain a valid chathistory command
falseOtherwise
void cmd_exec ( char *  txt)

Parses the text in txt and if it starts with a '?' (CMD_COMMAND_CHAR) string it processes it as an APme command

All the command processing starts here.

Parameters
[in]txtText to process (usually from the clipboard)
bool cmd_func_ap_format ( int  argc,
char *  argv[],
char *  txt 
)

This function implements the ?apformat command, it sets the aploot format

Parameters
[in]argcNumber of arguments
[in]argvCommand arguments
  • argv[0] = Command name
  • argv[1] = New aploot format
[in]txtFull chat line text with the command stripped
Return values
trueOn success
falseIf argument format error
See Also
aion_aploot_fmt_set()
bool cmd_func_ap_limit ( int  argc,
char *  argv[],
char *  txt 
)

This function implements the ?aplimit command, sets the upper bound limit for the AP loot

Parameters
[in]argcNumber of arguments
[in]argvCommand arguments
  • argv[0] = Command name
  • argv[1] = New AP limit value
[in]txtFull chat line text with the command stripped
Return values
trueOn success
falseIf argument format error
See Also
aion_aplimit_set
bool cmd_func_ap_loot ( int  argc,
char *  argv[],
char *  txt 
)

This function implements the ?aploot command, which returns the current loot statistics

Parameters
[in]argcNumber of arguments
[in]argvCommand arguments
  • argv[0] = Command name
[in]txtFull chat line text with the command stripped
Return values
trueAlways returns true
bool cmd_func_ap_reset ( int  argc,
char *  argv[],
char *  txt 
)

This function implements the ?apreset command, which resets the AP statistics for all known players to 0

Parameters
[in]argcNumber of arguments
[in]argvCommand arguments
  • argv[0] = Command name
[in]txtFull chat line text with the command stripped
Return values
trueAlways returns true
bool cmd_func_ap_set ( int  argc,
char *  argv[],
char *  txt 
)

This function implements the ?apset command, sets the AP accumulated by a player to a certain value

Parameters
[in]argcNumber of arguments in argv
[in]argvCommand arguments:
  • argv[0] = Command name
  • argv[1] = Player name
  • argv[2] = New AP value
[in]txtFull chat line text with the command stripped
Return values
trueOn success
falseIf argument format error
bool cmd_func_ap_stats ( int  argc,
char *  argv[],
char *  txt 
)

This function implements the ?apstat command, which returns the current AP statistics of the group

Parameters
[in]argcNumber of arguments
[in]argvCommand arguments
  • argv[0] = Command name
[in]txtFull chat line text with the command stripped
Return values
trueAlways returns true
bool cmd_func_apcalc ( int  argc,
char *  argv[],
char *  txt 
)

This function implements the ?apcalc function

This is used for calculating the values of relics. For example, it can calculate how much AP is 5x<Major Ancient Crown>, or <Major Ancient Crown>x5

Note
This function is quite a complex function and rarely ever used. This was somehow made obosolete by the relic appriser, so currently it is a candidate for removal.
Parameters
[in]argcNumber of arguments
[in]argvCommand arguments
  • argv[0] = Command name
[in]txtFull chat line text with the command stripped
Return values
truetrue on success
falseOn error
bool cmd_func_asmo ( int  argc,
char *  argv[],
char *  txt 
)

This function implements the ?asmo translator command This is used by Elyos to talk to Asmodians

Parameters
[in]argcNumber of arguments
[in]argvCommand arguments
  • argv[0] = Command name
[in]txtFull chat line text with the command stripped
Returns
Returns the error code from cmd_func_translate()
bool cmd_func_dbgdump ( int  argc,
char *  argv[],
char *  txt 
)

Implements the ?dbgdump function, which dumps the console to stdout

This is a bit awkward to use so maybe somebody can improve this.

Parameters
[in]argcNumber of arguments
[in]argvCommand arguments
  • argv[0] = Command name
[in]txtFull chat line text with the command stripped
Return values
trueAlways returns true
bool cmd_func_dbgparse ( int  argc,
char *  argv[],
char *  txt 
)

Implements the ?dbgparse debugging command

It parses a piece of chatlog file from a file, which is useful for debugging

Parameters
[in]argcNumber of arguments
[in]argvCommand arguments
  • argv[0] = Command name
  • argv[1] = Path to chatlog file
[in]txtFull chat line text with the command stripped
Return values
trueTrue on error
falseIf parsing of the file fails
bool cmd_func_echo ( int  argc,
char *  argv[],
char *  txt 
)

This function implements the ?echo command

This function just echoes back whatever text it received as argument

Parameters
[in]argcNumber of arguments
[in]argvCommand arguments
  • argv[0] = Command name
[in]txtFull chat line text with the command stripped
Return values
trueAlways returns true
Note
This is mainly useful for retrieving the chathistory
bool cmd_func_elyos ( int  argc,
char *  argv[],
char *  txt 
)

This function implements the ?elyos translator command This is used by Elyos to talk to Asmodians

Parameters
[in]argcNumber of arguments
[in]argvCommand arguments
  • argv[0] = Command name
[in]txtFull chat line text with the command stripped
Returns
Returns the error code from cmd_func_translate()
bool cmd_func_group_add ( int  argc,
char *  argv[],
char *  txt 
)

This function implements the ?gradd command, which manually adds a character to the current group if it is not autodetected automatically

Parameters
[in]argcNumber of arguments
[in]argvCommand arguments
  • argv[0] = Command name
  • argv[1+] = Players to add to the group
[in]txtFull chat line text with the command stripped
Return values
trueAlways returns true
bool cmd_func_group_del ( int  argc,
char *  argv[],
char *  txt 
)

This function implements the ?grdeel command, which manually removes a character from the current group if it is not autodetected automatically

Parameters
[in]argcNumber of arguments
[in]argvCommand arguments
  • argv[0] = Command name
  • argv[1+] = Players to remove from the group
[in]txtFull chat line text with the command stripped
Return values
trueAlways returns true
bool cmd_func_group_leave ( int  argc,
char *  argv[],
char *  txt 
)

This function implements the ?leave command. The player should use this to leave the a group if it's not autodetected.

Parameters
[in]argcNumber of arguments
[in]argvCommand arguments
  • argv[0] = Command name
  • argv[1+] = Players to remove from the group
[in]txtFull chat line text with the command stripped
Return values
trueAlways returns true
bool cmd_func_hello ( int  argc,
char *  argv[],
char *  txt 
)

This function implements the ?hello command, just displays the version number

Parameters
[in]argcNumber of arguments in argv
[in]argvCommand arguments:
  • argv[0] = Command name
[in]txtFull chat line text with the command stripped
Return values
trueAlways returns true
bool cmd_func_help ( int  argc,
char *  argv[],
char *  txt 
)

This function implements the ?help command

Parameters
[in]argcNumber of arguments in argv
[in]argvCommand arguments:
  • argv[0] = Command name
  • argv[1] = Help topic
[in]txtFull chat line text with the command stripped
Return values
trueAlways returns true
bool cmd_func_inv ( int  argc,
char *  argv[],
char *  txt 
)

This function implements the ?inv command for setting the "inventory full" policy handling

It supports arguments:

  • ?inv off: turn inventory full policy enforcment off
  • ?inv on: Turn inventory full policy enforcment on
  • ?inv clear: Clear the inventory full flags for all players
Parameters
[in]argcNumber of arguments
[in]argvCommand arguments
  • argv[0] = Command name
  • argv[1] = ?inv sub-command
[in]txtFull chat line text with the command stripped
Return values
trueAlways returns true
bool cmd_func_nameset ( int  argc,
char *  argv[],
char *  txt 
)

This function implements the ?name command, which sets the player's name

Parameters
[in]argcNumber of arguments in argv
[in]argvCommand arguments
  • argv[0] = Command name
  • argv[1] = New name
[in]txtFull chat line text with the command stripped
Return values
trueAlways returns true
bool cmd_func_rasmo ( int  argc,
char *  argv[],
char *  txt 
)

This function implements the ?rasmo translator command

This function reverses the text translated by ?asmo back to the original text (if you want to see what other Elyos are saying to Asmodians)

Parameters
[in]argcNumber of arguments
[in]argvCommand arguments
  • argv[0] = Command name
[in]txtFull chat line text with the command stripped
Returns
Returns the error code from cmd_func_rtranslate()
bool cmd_func_relyos ( int  argc,
char *  argv[],
char *  txt 
)

This function implements the ?relyos translator command

This function reverses the text translated by ?elyos back to the original text (if you want to see what other Asmodians are saying to Elyos)

Parameters
[in]argcNumber of arguments
[in]argvCommand arguments
  • argv[0] = Command name
[in]txtFull chat line text with the command stripped
Returns
Returns the error code from cmd_func_rtranslate()
bool cmd_func_rtranslate ( char *  txt,
int  langid 
)
static

Generic reverse translate function, used by cmd_func_relyos() and cmd_func_rasmo

This function is the exact opposite of cmd_func_translate()

Parameters
[in,out]txtFull chat line text with the command stripped
[in]langidLanguage ID
Return values
trueAlways true at the moment
See Also
aion_rtranslate
bool cmd_func_translate ( char *  txt,
int  langid 
)
static

Generic translate functions, used by cmd_func_elyos() and cmd_func_asmo

Parameters
[in,out]txtFull chat line text with the command stripped
[in]langidLanguage ID
Return values
trueAlways true at the moment
See Also
aion_translate
void cmd_poll ( void  )

Poll the clipboard, if we get some text, pass it to cmd_exec().

void cmd_retval_printf ( char *  fmt,
  ... 
)

printf-like function for storing a command status strings to the return buffer

Parameters
[in]fmtprintf-like format
[in]...arguments
void cmd_retval_set ( const char *  txt)

Set the return string for a command

param[in] txt Return string

char * cmd_sanitize ( char *  str)
static

Sanitize the string str:

  • Remove any leading spaces and newlines
  • Use only the first line if it's a multi-line string
  • Remove any trailing spaces and newlines

Variable Documentation

cmd_func_t cmd_func_ap_format
static

Declaration of cmd_ap_format()

cmd_func_t cmd_func_ap_limit
static

Declaration of cmd_ap_limit()

cmd_func_t cmd_func_ap_loot
static

Declaration of cmd_func_aploot()

cmd_func_t cmd_func_ap_reset
static

Declaration of cmd_ap_reset()

cmd_func_t cmd_func_ap_set
static

Declaration of cmd_ap_set()

cmd_func_t cmd_func_ap_stats
static

Declaration of cmd_func_apstat()

cmd_func_t cmd_func_apcalc
static

Declaration of cmd_func_apcalc()

cmd_func_t cmd_func_asmo
static

Declaration of cmd_func_asmo()

cmd_func_t cmd_func_dbgdump
static

Declaration of cmd_func_dbgdump()

cmd_func_t cmd_func_dbgparse
static

Declaration of cmd_func_dbgparse()

cmd_func_t cmd_func_echo
static

Declaration of cmd_func_echo()

cmd_func_t cmd_func_elyos
static

Declaration of cmd_func_elyos()

cmd_func_t cmd_func_group_add
static

Declaration of cmd_func_group_add()

cmd_func_t cmd_func_group_del
static

Declaration of cmd_func_group_del()

cmd_func_t cmd_func_group_leave
static

Declaration of cmd_func_group_leave()

cmd_func_t cmd_func_hello
static

Declaration of cmd_func_hello()

cmd_func_t cmd_func_help
static

Declaration of cmd_func_helpi()

cmd_func_t cmd_func_inv
static

Declaration of cmd_func_inv()

cmd_func_t cmd_func_nameset
static

Declaration of cmd_func_nameset()

cmd_func_t cmd_func_rasmo
static

Declaration of cmd_func_rasmo()

cmd_func_t cmd_func_relyos
static

Declaration of cmd_func_relyos()

struct cmd_entry cmd_list[]

Global list of chat commands

char cmd_retval[CMD_TEXT_SZ]
static

Whatever a command returns back to the user is written into this static buffer