Example #1
0
// This is called every time WriteChatColor is called by MQ2Main or any plugin, 
// IGNORING FILTERS, IF YOU NEED THEM MAKE SURE TO IMPLEMENT THEM. IF YOU DONT 
// CALL CEverQuest::dsp_chat MAKE SURE TO IMPLEMENT EVENTS HERE 
PLUGIN_API DWORD OnWriteChatColor(PCHAR Line, DWORD Color, DWORD Filter) 
{ 
    //DebugSpewAlways("MQ2ChatWnd::OnWriteChatColor(%s)",Line);

	if (!MQChatWnd) 
    { 
        if (gGameState==GAMESTATE_INGAME) 
        { 
            SetGameState(gGameState); 
        } 
        if (!MQChatWnd) 
        { 
            return 0; 
        } 
    } 
    MQChatWnd->dShow=1; 
    PFILTER pFilter=gpFilters; 
    while (pFilter) 
    { 
        if (!pFilter->pEnabled || (*pFilter->pEnabled)) 
        { 
            if (!_strnicmp(Line,pFilter->FilterText,pFilter->Length)) 
            { 
                return 0; 
            } 
        } 
        pFilter = pFilter->pNext; 
    } 
    Color=pChatManager->GetRGBAFromIndex(Color); 
    CHAR szProcessed[MAX_STRING]; 
	
	pPlugins;
    MQToSTML(Line,szProcessed,MAX_STRING,Color); 
	pPlugins;
    strcat_s(szProcessed,"<br>"); 
    CXStr NewText(szProcessed); 
    DebugTry(ConvertItemTags(NewText,FALSE)); 
    ChatBuffer *pNewBuffer = new ChatBuffer; 
    GetCXStr(NewText.Ptr,pNewBuffer->Text,MAX_STRING); 
    pNewBuffer->pPrev=pPendingChatTail; 
    pNewBuffer->pNext=0; 
    if (pPendingChatTail) 
    { 
        pPendingChatTail->pNext=pNewBuffer; 
    } 
    else 
    { 
        pPendingChat=pNewBuffer; 
    } 
    pPendingChatTail=pNewBuffer; 
    PendingChatLines++; 
    return 0; 
} 
void ConsoleService(bool Broadcast, unsigned int MSG, void *lpData)
{
    if (MSG != CONSOLE_OUTPUT_WITHCODES) {
        return;
    }
    // same as OnWriteChatColor
    if (!MQChatWnd) {
        EQGamestateService(false, GAMESTATESERVICE_CHANGED, (void*)gGameState);
        if (!MQChatWnd) {
            return;
        }
    }
    MQChatWnd->dShow = 1;

    PCHAR pConsOutput = (PCHAR)lpData;
    PFILTER pFilter = gpFilters;

    while (pFilter) {
        if (!pFilter->pEnabled || (*pFilter->pEnabled)) {
            if (!strnicmp(pConsOutput, pFilter->FilterText, pFilter->Length)) {
                return;
            }
        }
        pFilter = pFilter->pNext;
    }
    DWORD Color = pChatManager->GetRGBAFromIndex(USERCOLOR_DEFAULT);

    CHAR szProcessed[MAX_STRING];
    MQToSTML(pConsOutput, szProcessed, MAX_STRING, Color);
    strcat(szProcessed,"<br>");
    CXStr NewText(szProcessed);
    DebugTry(ConvertItemTags(NewText, 0));

    CLock L(&ChatS,1);

    ChatBuffer *pNewBuffer = new ChatBuffer;
    GetCXStr(NewText.Ptr, pNewBuffer->Text, MAX_STRING);
    pNewBuffer->pPrev = pPendingChatTail;
    pNewBuffer->pNext = 0;
    if (pPendingChatTail) {
        pPendingChatTail->pNext = pNewBuffer;
    }
    else {
        pPendingChat = pNewBuffer;
    }
    pPendingChatTail = pNewBuffer;
    PendingChatLines++;
}