ChatBlade SDK Documentation

Class   CBAliasList
Header   CBAliasList.h

Data    Member Summary    Member Details


CBAliasList is a class used to support the /alias command.  
/alias allows the user to create their own local Slash Commands.  
Using the /alias Slash Command, Players can create their own local Slash Commands which map to existing Game supplied commands.  
ChatBlade uses CBChatHandler::m_AliasList to keep track of the Aliases that a Player has created.  
Aliases consist of a single word that starts with a '/' Character.  This word should not be an existing Slash Command, and the new Alias shall be local only to the Player who created the Alias.  
Each Alias created maps to an existing Slash Command and any optional Parameters.  
When a Player enters in the Alias, ChatBlade shall expand that Alias to its related Slash Command before processing.  
Some sample Aliases might be:  
    "/alias /bail, /exit"   would create an Alias named /bail that would perform the same as the /exit Slash Command.  
    "/alias /backflip, /emote Backflips"  would create an Alias named /Backflip which expands to "/emote Backflips".  
    "/alias /Mike, /tell Velorian Orcsmasher," would create an Alias name /Mike would might allow the Player to easily send a tell to his Real Life Friend.  The Player could then type something like "/mike Whats Up?" which would expand to "/tell Velorian Orcsmasher, Whats Up?"
    "/alias /p, /g"  would create an Alias name /p which would expand to be /g before Chat processing.  
Aliases are a secondary way that ChatBlade allows the Player to alter the Slash Command interface.  
Game Developers should also take advantage of ChatBlades ability to allow Players to set the initial Slash Commands for a Game, either via XML, or an in-game Dialog.  
An Alias that is created that matches an existing Slash Command may prohibit the existing Slash Command from functioning until the conflicting Alias is removed.  
Players can remove an Alias with the /unalias Slash Command (if using the recommended Slash Commands).  
Players can display their current Aliases with the /alias list or /aliaslist Slash Commands.  
Game Developers should load up a Players current Aliases upon Game startup.  

Game Developer Implementation:  

Game Developers do not need to implement or instantiate CBAliasList.  This class is used internally by ChatBlade.  
When the Game Developer instantiates an instance of CBChatHandler, CBChatHandler contains an internal instance of CBAliasList for support of /alias and related Commands.  
Upon Game startup the Alias List stored in CBChatHandler should be loaded with any existing Aliases the Player may have created in previous Game sessions.  
Game Developers should persist any new Aliases created by the Character so that they may be loaded again next play session.  

Source File Comments:  

// Represents a map of user defined Slash Commands and their associated game defined equivalents
// Used to support the /alias function which lets users define their own / commands
// Users may make their own commands and map them to an existing command
// /alias aliasname without a value clears that aliasname
// /alias list displays ones aliases
// for example:
//   /alias /backflip, /emote backflips
//     would allow the user to now type in /backflips, thus creating their own / command
//     this class is designed to store the relation between "/backflip" and "/emote backflips"
// other examples:
//   /alias /mike, /tell tiguron androculous,
//   /alias /gang, /guild
//   /alias /fel, /group
//   /alias /fel (clears this alias)
//   /alias list (lists our aliases)

// CBAliasList is implemented as a map of the user defined / command and its game defined equivalent
// Commands are converted to Uppercase before storage


// ChatBlade shall check each line the user enters and see if it starts with an alias
//   If so, ChatBlade shall replace that alias with its equivalent text


// An alias can consist of just 1 word which starts with a slash (CB_SLASHCOMMAND_CHARACTER)
//    Its game equivalent can be more than 1 word but the first word must be a normal slash command


// An alias cannot be used as an alias for another user defined alias, only for existing game defined commands


std::map<CBSTRING, CBSTRING> m_AliasMap;
        A map of string aliases and their game defined replacement strings

Member Function Summary:  

int  ClearList()
        Empties out all members in the alias list
int  AddAlias(CBSTRING sAlias, CBSTRING sExistingCommandString)
        Adds an alias to the aliaslist
int  RemoveAlias(CBSTRING sAlias)
        Removes an alias from the aliaslist
int  IsAlias(CBSTRING sAlias)
        Returns CB_TRUE if the / command is an alias
int  ExpandAlias(CBSTRING & sCommandLine /*IN OUT*/)
        Replaces the alias with its / command equivalent

Member Function Details:  

Empty Constructor
int  CBAliasList::ClearList()
Empties out all members in the alias list
int  CBAliasList::AddAlias( CBSTRING sAlias,
CBSTRING sExistingCommandString)
Adds an alias to the aliaslist.  
Replaces an existing alias if it is already in the list.  
If sExistingCommandString is empty it shall clear out the alias. 
Called from  CBSlashCommands::OnCommandAlias()
    The New Alias the Player wants to create.  
    The existing in-game Slash Command that the Alias shall expand to.  
Example:  AddAlias("/backflip", "/emote Backflips");
CB_ERROR_EMPTY_STRING if sAlias is too short
CB_ERROR_BAD_CHAT_COMMAND if either parameter is missing its initial '/'
CB_SUCCESS upon successful alias addition
int  CBAliasList::RemoveAlias( CBSTRING sAlias)
Removes an alias from the aliaslist
Called from CBSlashCommands::OnCommandUnAlias()
    The alias the Player wants to delete
CB_ERROR_EMPTY_STRING if sAlias is too short
CB_ERROR_DOES_NOT_EXIST if sAlias is not a current alias
CB_SUCCESS upon successful removal of the alias
int  CBAliasList::IsAlias( CBSTRING sAlias)
Checks to see if this / command is an alias
Returns CB_TRUE if the / command is an alias
Called from CBAliasList::ExpandAlias() and CBSlashCommands::OnCommandChatHelp().  
    The command we want to check to determine if it is an alias
CB_FALSE if sAlias is too short or is not an alias
CB_TRUE if sAlias is an alias for another Slash Command
int  CBAliasList::ExpandAlias( CBSTRING & sCommandLine /*IN OUT*/)
Replaces the alias with its / command equivalent.  
Takes an incoming line and does an in-place replacement of the alias if one exists
For Example:  If "/point" is an alias for "/emote points at "
  then "/point Xodar"  would get expanded to "/emote points at Xodar"
Called from CBChatHandler::OnLineEntered()
    Initially a reference to the incoming line that the Player has entered.
    Upon exit this parameter is changed to be the expanded Slash Command if this parameter started with an alias.
    If it does not start with an alias, this parameter remains unchanged.
If sCommandLine starts with an alias it gets altered to be the expanded slash command (and any additional text).
CB_SUCCESS regardless of if an alias got expanded or not.  




ChatBlade Copyright Flex Dolphynn