//****************************************************************************** BOOL CBCGPRibbonCommandsListBox::AddCommand (CBCGPBaseRibbonElement* pCmd, BOOL bSelect, BOOL bDeep) { ASSERT_VALID (this); ASSERT_VALID (pCmd); int nIndex = GetCommandIndex (pCmd->GetID ()); if (nIndex >= 0 && pCmd->GetID () != 0) { return FALSE; } // Not found, add new: if (m_nTextOffset == 0) { BOOL bIsRibbonImageScale = globalData.IsRibbonImageScaleEnabled (); globalData.EnableRibbonImageScale (FALSE); m_nTextOffset = pCmd->GetImageSize (CBCGPBaseRibbonElement::RibbonImageSmall).cx + 2; globalData.EnableRibbonImageScale (bIsRibbonImageScale); } nIndex = pCmd->AddToListBox (this, bDeep); if (bSelect) { SetCurSel (nIndex); } return TRUE; }
LOCAL BOOL NeedSequence(LPCMDLIST lpCmdList) /***********************************************************************/ { LPCMDPKT lpCmdPkt; int i; lpCmdPkt = (LPCMDPKT)ListGetHead(&lpCmdList->PacketList); while (lpCmdPkt) { if ((i = GetCommandIndex(lpCmdPkt->idCommand)) >= 0) { if (GetCommandSequence(lpCmdPkt->idCommand)) return(TRUE); } lpCmdPkt = (LPCMDPKT)ListGetNext(lpCmdPkt); } return(FALSE); }
//----------------------------------------------------------------------------- // Dispatches the say and say_team commands. //----------------------------------------------------------------------------- void SayConCommand::Dispatch( const CCommand& command ) { // This is the case if just "say" or "say_team" was entered into the server if (command.ArgC() == 1) return; // Get the index of the player that used the command int iIndex = GetCommandIndex(); // Get the IPlayerInfo instance of the player IPlayerInfo* pPlayerInfo = PlayerInfoFromIndex(iIndex); // Get whether the command was say or say_team bool bTeamOnly = strcmp(command.Arg(0), "say_team") == 0; // Loop through all registered Say Filter callbacks for(int i = 0; i < s_SayFilters.m_vecCallables.Count(); i++) { BEGIN_BOOST_PY() // Get the PyObject instance of the callable PyObject* pCallable = s_SayFilters.m_vecCallables[i].ptr(); // Call the callable and store its return value object returnValue = CALL_PY_FUNC(pCallable, ptr(pPlayerInfo), bTeamOnly, boost::ref(command)); // Does the current Say Filter wish to block the command? if( !returnValue.is_none() && extract<int>(returnValue) == (int) BLOCK) { // Block the command return; } END_BOOST_PY_NORET() } // Get the name of the command used std::string szCommandString (command.Arg(1)); // Copy the string to get a char instance char * szCopyCommandString = new char [szCommandString.length() + 1]; std::strcpy(szCopyCommandString, szCommandString.c_str()); // Split the command using <space> as the delimiter // This should be the actual Say Command char * szCommand = std::strtok(szCopyCommandString, " "); // Find if the command is registered SayCommandMap::iterator commandMapIter = g_SayCommandMap.find(szCommand); if( commandMapIter != g_SayCommandMap.end() ) { // Get the CSayCommandManager instance for the command CSayCommandManager* pCSayCommandManager = commandMapIter->second; // Call the command and see it wants to block the command if( pCSayCommandManager->Dispatch(pPlayerInfo, bTeamOnly, command) == BLOCK) { // Block the command return; } } // Was the command previously registered? if( m_pOldCommand ) { // Call the old command callback m_pOldCommand->Dispatch(command); } }