ChatBlade How To Documentation
How To Load the Chat Filter

Related ChatBlade Classes and functions:  
    CBClientImplementation
    CBSampleImplementation
    CBChatHandler
    Filter.XML

 
Summary:  
  Jump to Section   Implement CBClientImplementation::LoadChatFilter().  
  Jump to Section Add each word that should be filtered to ChatBlade via CBChatFilter.AddString().   
  Jump to Section Optionally set the initial Chat Filtering state to Enabled or Disabled via CBChatFilter.EnableFilter().  
  Jump to Section Optionally add in any player specified words to the Chat Filter.  
   ChatBlade uses the CBChatFilter instance contained in CBChatHander, CBData::pChatHandler->m_ChatFilter.  
 

 
Details:  
 
Implement CBClientImplementation::LoadChatFilter().  
     The Loading of the Chat Filter should take place in CBClientImplementation::LoadChatFilter().  
ChatBlade shall call this function from CBChatHandler::InitializeChat() via CBChatHandler::InitializeChatFilter().  
Developers should implement CBClientImplementation::LoadChatFilter().  
An example of an implementation that uses an XML file containing bad words to be Filtered is included in CBSampleImplementation::LoadChatFilter().  
See CBSampleImplementation.cpp and Filter.XML.  
Sample Code:  
 
Add each word that should be filtered to ChatBlade via CBChatFilter.AddString().  
     ChatBlade uses the CBChatFilter instance contained in the CBChatHandler class to filter out offensive text.  
Any words loaded into this instance that match Game Chat shall be replaced in the Game Chat with $#!@% style text if the Chat Filter is enabled.  
Only exact words are filtered, but case is not important.  Developers should add in all variations of a bad word to the Chat Filter.  
Words are added to the Chat Filter by calling CBData::pChatHandler->m_ChatFilter.AddString(sBadWord).  
Only single words should be added to the Chat Filter, no spaces are allowed.  
An example of an implementation that reads in a bad word list from an XML file is included in CBSampleImplementation::LoadChatFilter().  
See CBSampleImplementation.cpp and Filter.XML.  
Sample Code:  
 
Optionally set the initial Chat Filtering state to Enabled or Disabled via CBChatFilter.EnableFilter().  
     Filtering of offensive Chat Text shall only take place if the Chat Filter is Enabled.  
CBClientImplementation::LoadChatFilter() is a good place to set the initial Filtering state.  
To Enable the Chat Filter call CBData::pChatHandler->m_ChatFilter.EnableFilter().
To Disable the Chat Filter call CBData::pChatHandler->m_ChatFilter.DisableFilter();
It is optimal for a game to keep track of a Players Chat Filter preference and load up his setting when the Player logs in.  ChatBlade does not do this by default.  
Sample Code:  
 
Optionally add in any player specified changes to the Chat Filter.  
     ChatBlade allows each Player to add to or remove words from their Chat Filter.  
Players may use the Slash Commands /filterword, or /unfilterword to modify the default Chat Filter.  
ChatBlade does not persist these changes and by default, these changes shall revert to the base filter the next time the Player logs in.  
It would be optimal if the Players Chat Filter modifications were persisted though.  Game Developers would need to keep track of each Players Chat Filter modifications and load the changes upon Game startup.  
If developers want to persist these changes, modifications should be made to CBSlashCommands::OnCommandFilterWord() and CBSlashCommands::OnCommandUnFilterWord(), as well as loading the changes in CBClientImplementation::LoadChatFilter().  
 

 

Code Samples:  

See CBSampleImplementation.cpp  and Filter.XML for a complete sample of LoadChatFilter() using an XML file.  
 
Adding some words to the Chat Filter.  
     CBData::pChatHandler->m_ChatFilter.AddString("BUTT");
CBData::pChatHandler->m_ChatFilter.AddString("BUTTS");
CBData::pChatHandler->m_ChatFilter.AddString("BUTTHEAD");
CBData::pChatHandler->m_ChatFilter.AddString("LARDBUTT");
CBData::pChatHandler->m_ChatFilter.AddString("BIATCH");
 
Setting the Chat Filter to be initially Enabled.  
     CBData::pChatHandler->m_ChatFilter.EnableFilter();
 
    
    
 
    
 
    

 

 

 

 

 

 
 
 
 
ChatBlade Copyright Flex Dolphynn