System announcement garbled code

Junior Spellweaver
Joined
May 13, 2020
Messages
177
Reaction score
22
1740842059349 - System announcement garbled code - RaGEZONE Forums

Other areas are displaying normally - only one system announcement has garbled text. But English letters and numbers display system announcements normally
 
I also want to know where to modify it. Can you tell me how to use the source code to find it?
You can use free tools (like textcrawler) to find references within the directories you select. To speed up the searches, do specify to only use *.cpp;*.h;*.rc;*.inc;*.txt;*.txt.txt file filters. Best to select the source and resource directories. The files it finds you can than open in your preferred editor. ALT+C -> ALT + V are your friend! Be sure to always have a revision backed up before making changes so you can backtrack later. Good luck!
 
Last edited:
Upvote 0
Who knows how to solve the problem of garbled language in this announcement? Can someone help? Thank you
Numbers and English letters are displayed normally - garbled characters are displayed in other languages


Code:
#ifdef __CLIENT
#include "PlayerData.h"
#include "resdata.h"
#include "DPClient.h"
extern CDPClient g_DPlay;
#endif

namespace AnnounceRenderer {

#ifdef __CLIENT
    void CAnnounceRenderer::AddTopAnnounce(const std::string strAnnounce, const std::uint32_t nPlayerIndex) {
        AnnounceData data;

        auto pOldFont = g_Neuz.m_2DRender.GetFont();
        g_Neuz.m_2DRender.SetFont(CWndBase::m_Theme.m_pFontText);

        CEditString str;
        str.SetParsingString(strAnnounce.c_str());

        auto nRightPosition = g_Neuz.m_2DRender.m_clipRect.Width();

        std::string character;

        std::uint16_t index = 0;
        for (auto const& it : strAnnounce) {
            textData chardata;
            chardata.m_char = it;


            CEditString strEdit;
            strEdit.SetParsingString(character.c_str());

            chardata.m_nPositionX = nRightPosition + g_Neuz.m_2DRender.m_pFont->GetTextExtent_EditString(strEdit).cx;
            data.m_strAnnounce.push_back(chardata);
            character.push_back(it);
            index++;

        }

        g_Neuz.m_2DRender.SetFont(pOldFont);

        data.m_nPlayerCasterIndex = nPlayerIndex;
        m_vTopAnnounces.push_back(data);
    }
    
    void CAnnounceRenderer::AddCenterAnnounce(const std::string strAnnounce, const std::uint32_t nPlayerIndex) {
        AnnounceData data;

        auto pOldFont = g_Neuz.m_2DRender.GetFont();
        g_Neuz.m_2DRender.SetFont(CWndBase::m_Theme.m_pFontText);


        CEditString str;
        str.SetParsingString(strAnnounce.c_str());

        const std::uint16_t nRectWidth = 450;
        int pointX = (g_Neuz.m_2DRender.m_clipRect.Width() / 2) - (nRectWidth / 2);
        //int pointX = (g_Neuz.m_2DRender.m_clipRect.Width() / 2) - (g_Neuz.m_2DRender.m_pFont->GetTextExtent_EditString(str).cx / 2);

        auto nRightPosition = pointX + nRectWidth;

        std::string character;

        std::uint16_t index = 0;
        for (auto const& it : strAnnounce) {
            textData chardata;
            chardata.m_char = it;


            CEditString strEdit;
            strEdit.SetParsingString(character.c_str());

            chardata.m_nPositionX = nRightPosition + g_Neuz.m_2DRender.m_pFont->GetTextExtent_EditString(strEdit).cx;
            data.m_strAnnounce.push_back(chardata);
            character.push_back(it);
            index++;

        }

        g_Neuz.m_2DRender.SetFont(pOldFont);

        data.m_nPlayerCasterIndex = nPlayerIndex;
        m_vCenteredAnnounces.push_back(data);
    }

    bool CAnnounceRenderer::OnRightClickUp(UINT nFlags, CPoint point)
    {

        if (g_pPlayer == nullptr) return false;

        if (m_vTopAnnounces.empty()) return false;

        auto itAnnounce = m_vTopAnnounces.begin();


        if (itAnnounce->m_strAnnounce.empty()) return false;

        auto nLeftPoint = itAnnounce->m_strAnnounce.front().m_nPositionX;
        auto nRightPoint = itAnnounce->m_strAnnounce.back().m_nPositionX;

        CRect rect = CRect(nLeftPoint, 5, nRightPoint, 25);

        if (rect.PtInRect(point))
        {
            if (itAnnounce->m_nPlayerCasterIndex == 0) return false;
            if (itAnnounce->m_nPlayerCasterIndex == g_pPlayer->m_idPlayer)
            {
                g_WndMng.PutString("You cannot send messages to your own character !", nullptr, 0xFFFF0000);
                return false;
            }


            CWndMessage* pWndMessage = g_WndMng.OpenMessage(CPlayerDataCenter::GetInstance()->GetPlayerString(itAnnounce->m_nPlayerCasterIndex));
            return true;
        }


        return false;
    }

    void CAnnounceRenderer::ProcessAnnounce(std::vector<AnnounceData>& vAnnounce) {
        if (vAnnounce.empty()) return;


        __time64_t         tTimeLeft;
        __time64_t         tCurrentTick = GetTickCount();
        auto itAnnounce = vAnnounce.begin();

        if (itAnnounce->m_tDelay == 0) return;

        tTimeLeft = itAnnounce->m_tDelay - tCurrentTick;

        if (tTimeLeft < 1000)
        {
            itAnnounce->m_nAlpha -= ((DOUBLE)tTimeLeft * 0.001);
        }
        else if (REMOVE_DELAY - tTimeLeft <= 500)
        {
            itAnnounce->m_nAlpha -= ((DOUBLE)tTimeLeft * 0.002);
        }

        if (itAnnounce->m_nAlpha <= 0)
            vAnnounce.erase(itAnnounce);
    }


    BOOL CAnnounceRenderer::Process()
    {
        ProcessAnnounce(m_vCenteredAnnounces);
        ProcessAnnounce(m_vTopAnnounces);
        return true;
    }

    void CAnnounceRenderer::RenderRectangles(C2DRender* p2DRender, const CRect &drawRect, const std::uint32_t  nAlpha, const std::uint32_t  nOffset)
    {
        /** Left of Rect **/
        p2DRender->RenderFillRect(CRect(drawRect.left - nOffset, drawRect.top, drawRect.left, drawRect.bottom), D3DCOLOR_ARGB(0, 0, 0, 0), D3DCOLOR_ARGB(nAlpha, 0, 0, 0), D3DCOLOR_ARGB(0, 0, 0, 0), D3DCOLOR_ARGB(nAlpha, 0, 0, 0));
        /** Center of Rect **/
        p2DRender->RenderFillRect(CRect(drawRect.left, drawRect.top, drawRect.right, drawRect.bottom), D3DCOLOR_ARGB(nAlpha, 0, 0, 0), D3DCOLOR_ARGB(nAlpha, 0, 0, 0), D3DCOLOR_ARGB(nAlpha, 0, 0, 0), D3DCOLOR_ARGB(nAlpha, 0, 0, 0));
        /** Right of rect **/
        p2DRender->RenderFillRect(CRect(drawRect.right, drawRect.top, drawRect.right + nOffset, drawRect.bottom), D3DCOLOR_ARGB(nAlpha, 0, 0, 0), D3DCOLOR_ARGB(0, 0, 0, 0), D3DCOLOR_ARGB(nAlpha, 0, 0, 0), D3DCOLOR_ARGB(0, 0, 0, 0));

        p2DRender->RenderFillRect(CRect(drawRect.left - nOffset, drawRect.top - 2, drawRect.left, drawRect.top), D3DCOLOR_ARGB(0, 246, 207, 77), D3DCOLOR_ARGB(nAlpha, 246, 207, 77), D3DCOLOR_ARGB(0, 246, 207, 77), D3DCOLOR_ARGB(nAlpha, 246, 207, 77));
        p2DRender->RenderFillRect(CRect(drawRect.left, drawRect.top - 2, drawRect.right, drawRect.top), D3DCOLOR_ARGB(nAlpha, 246, 207, 77), D3DCOLOR_ARGB(nAlpha, 246, 207, 77), D3DCOLOR_ARGB(nAlpha, 246, 207, 77), D3DCOLOR_ARGB(nAlpha, 246, 207, 77));
        p2DRender->RenderFillRect(CRect(drawRect.right, drawRect.top - 2, drawRect.right + nOffset, drawRect.top), D3DCOLOR_ARGB(nAlpha, 246, 207, 77), D3DCOLOR_ARGB(0, 246, 207, 77), D3DCOLOR_ARGB(nAlpha, 246, 207, 77), D3DCOLOR_ARGB(0, 246, 207, 77));

        p2DRender->RenderFillRect(CRect(drawRect.left - nOffset, drawRect.bottom, drawRect.left, drawRect.bottom + 2), D3DCOLOR_ARGB(0, 246, 207, 77), D3DCOLOR_ARGB(nAlpha, 246, 207, 77), D3DCOLOR_ARGB(0, 246, 207, 77), D3DCOLOR_ARGB(nAlpha, 246, 207, 77));
        p2DRender->RenderFillRect(CRect(drawRect.left, drawRect.bottom, drawRect.right, drawRect.bottom + 2), D3DCOLOR_ARGB(nAlpha, 246, 207, 77), D3DCOLOR_ARGB(nAlpha, 246, 207, 77), D3DCOLOR_ARGB(nAlpha, 246, 207, 77), D3DCOLOR_ARGB(nAlpha, 246, 207, 77));
        p2DRender->RenderFillRect(CRect(drawRect.right, drawRect.bottom, drawRect.right + nOffset, drawRect.bottom + 2), D3DCOLOR_ARGB(nAlpha, 246, 207, 77), D3DCOLOR_ARGB(0, 246, 207, 77), D3DCOLOR_ARGB(nAlpha, 246, 207, 77), D3DCOLOR_ARGB(0, 246, 207, 77));
    }

    void CAnnounceRenderer::RenderTopAnnounces(C2DRender* p2DRender) {
        CPoint point = CPoint(50, 5);

        if (m_vTopAnnounces.empty()) return;
        auto itAnnounce = m_vTopAnnounces.begin();

        RenderRectangles(p2DRender, CRect(point.x, point.y - 5, g_Neuz.m_2DRender.m_clipRect.Width() - 50, point.y + 20), itAnnounce->m_nAlpha, 50);

        for (auto itLetter = itAnnounce->m_strAnnounce.begin(); itLetter != itAnnounce->m_strAnnounce.end();)
        {
            if (itLetter->m_nPositionX <= g_Neuz.m_2DRender.m_clipRect.Width())
            {
                std::string strLetter;
                strLetter.push_back(itLetter->m_char);
                CEditString string;
                string.SetParsingString(strLetter.c_str(), D3DCOLOR_ARGB(255, 254, 254, 254));
                p2DRender->TextOut_EditString(itLetter->m_nPositionX, point.y, string);
            }

            itLetter->m_nPositionX -= 2; // 2 before

            if (itLetter->m_nPositionX <= 0)
            {
                itLetter->m_nPositionX += g_Neuz.m_2DRender.m_clipRect.Width();

                itLetter->m_nRoundsCount++;

                if (itLetter->m_nRoundsCount >= MAX_ROUNDS_TOP)
                    itLetter = itAnnounce->m_strAnnounce.erase(itLetter);
                else
                    ++itLetter;
            }
            else
                ++itLetter;
        }

        if (itAnnounce->m_strAnnounce.empty()) {
            if (itAnnounce->m_tDelay == 0) {
                if (std::distance(itAnnounce, m_vTopAnnounces.end()) == 1)
                    itAnnounce->m_tDelay = GetTickCount() + REMOVE_DELAY;
                else
                    m_vTopAnnounces.erase(itAnnounce);
            }
        }
    }

    void CAnnounceRenderer::RenderCenterAnnounces(C2DRender* p2DRender) {
        auto offSetY = (184 * p2DRender->m_clipRect.Height() / 768) - 120;
        if (m_vCenteredAnnounces.empty()) return;

        auto itAnnounce = m_vCenteredAnnounces.begin();

        std::string strFull;

        for (auto const [character, position, count] : itAnnounce->m_strAnnounce) {
            strFull.push_back(character);
        }

        CEditString str;
        str.SetParsingString(strFull.c_str());

        const std::uint16_t nRectWidth = 450;

        CPoint point = CPoint((p2DRender->m_clipRect.Width() / 2) - (nRectWidth / 2), offSetY);

        RenderRectangles(p2DRender, CRect(point.x, point.y - 5, point.x + nRectWidth, point.y + 20), itAnnounce->m_nAlpha, 50);

        for (auto itLetter = itAnnounce->m_strAnnounce.begin(); itLetter != itAnnounce->m_strAnnounce.end();)
        {
            if (itLetter->m_nPositionX <= point.x + nRectWidth && itLetter->m_nPositionX >= point.x)
            {
                std::string strLetter;
                strLetter.push_back(itLetter->m_char);
                CEditString string;
                string.SetParsingString(strLetter.c_str(), D3DCOLOR_ARGB(255, 254, 254, 254));
                p2DRender->TextOut_EditString(itLetter->m_nPositionX, point.y, string);
            }

            itLetter->m_nPositionX -= 2; // 2 before

            if (std::distance(itLetter, itAnnounce->m_strAnnounce.end()) == 1 && itLetter->m_nPositionX <= point.x)
            {
                itAnnounce->m_strAnnounce.clear();
                break;
            }
            else
                ++itLetter;
        }

        if (itAnnounce->m_strAnnounce.empty()) {
            if (itAnnounce->m_tDelay == 0) {
            if( std::distance(itAnnounce, m_vCenteredAnnounces.end()) == 1)
                itAnnounce->m_tDelay = GetTickCount() + REMOVE_DELAY;
            else
                m_vCenteredAnnounces.erase(itAnnounce);
            }
        }
    }

    void CAnnounceRenderer::RenderAnnounces(C2DRender* p2DRender) {
        auto pOldFont = p2DRender->GetFont();
        p2DRender->SetFont(CWndBase::m_Theme.m_pFontText);
        RenderCenterAnnounces(p2DRender);
        RenderTopAnnounces(p2DRender);
    
        p2DRender->SetFont(pOldFont);
    }


    /********************/

    void CWndAnnouncement::SetUsedItem(const std::uint32_t nItemId) {
        m_nItemId = nItemId;
    }

    BOOL CWndAnnouncement::OnChildNotify(UINT message, UINT nID, LRESULT* pLResult)
    {
        switch (nID)
        {
        case WIDC_BUTTON:   
            std::string str = m_pWndEdit->GetString();

            if (str.length() < MAX_ANNOUNCE_SIZE)
            {
                g_DPlay.SendAnnouncement(str, m_nItemId);
                Destroy();
            }
            else
            {
                CString strError;
                strError.Format("Your announcement should not exceed %d name !", MAX_ANNOUNCE_SIZE);
                g_WndMng.OpenMessageBox(strError);
            }
            break;
            break;
        }

        return CWndNeuz::OnChildNotify(message, nID, pLResult);
    }

    void CWndAnnouncement::OnInitialUpdate()
    {
        CWndNeuz::OnInitialUpdate();

        m_pWndEdit = (CWndEdit*)GetDlgItem(WIDC_EDIT);

        MoveParentCenter();
    }
    BOOL CWndAnnouncement::Initialize(CWndBase* pWndParent, DWORD dwWndId)
    {
        return CWndNeuz::InitDialog(g_Neuz.GetSafeHwnd(), APP_ANNOUNCE, 0, CPoint(0, 0), pWndParent);
    }
#endif
}

#ifdef __CLIENT
AnnounceRenderer::CAnnounceRenderer g_AnnounceRenderer = AnnounceRenderer::CAnnounceRenderer();
#endif
 
Upvote 0
Who knows how to solve the problem of garbled language in this announcement? Can someone help? Thank you
Numbers and English letters are displayed normally - garbled characters are displayed in other languages

Might actually have to do with the wordalign and lanuage formatting in the editstring parts of the source.
 
Upvote 0
I also encountered this problem


I feel that I should add a global encoding conversion in the .cpp or .h file where the garbled characters appear, and then read it correctly, but I am a novice in C++ and I can't do anything about it now.

Might actually have to do with the wordalign and lanuage formatting in the editstring parts of the source.
Can you explain it in more detail? The vague explanation is like telling a joke to the newbies. I can't understand it.
 
Last edited:
Upvote 0
I also encountered this problem


I feel that I should add a global encoding conversion in the .cpp or .h file where the garbled characters appear, and then read it correctly, but I am a novice in C++ and I can't do anything about it now.


Can you explain it in more detail? The vague explanation is like telling a joke to the newbies. I can't understand it.
read through WndEditCtrl.cpp it adds support to many different charsets.
 
Last edited:
Upvote 0
Do you also have garbled characters in the same language as me?

I also encountered this problem


I feel that I should add a global encoding conversion in the .cpp or .h file where the garbled characters appear, and then read it correctly, but I am a novice in C++ and I can't do anything about it now.


Can you explain it in more detail? The vague explanation is like telling a joke to the newbies. I can't understand it.
Do you also have garbled characters in the same language as me?
 
Last edited:
Upvote 0
Do you also have garbled characters in the same language as me?


Do you also have garbled characters in the same language as me?
The garbled characters are all the same, but I haven't fixed it yet, and I can't do anything about it. I think it's a problem with the new announcement system. This kind of announcement doesn't take multiple languages into account, but I don't know where to modify it.
 
Upvote 0
The garbled characters are all the same, but I haven't fixed it yet, and I can't do anything about it. I think it's a problem with the new announcement system. This kind of announcement doesn't take multiple languages into account, but I don't know where to modify it.
I think it's because the source code supports normal display of letters. Does not support other languages
 
Upvote 0
I think it's because the source code supports normal display of letters. Does not support other languages
We should add support for languages other than English, but I don't know where to add it or what to add.
 
Upvote 0
We should add support for languages other than English, but I don't know where to add it or what to add.
You don't need to add anything, just modify Source \ Neuz \ WinMain.rc \ IDS-CODPAGE "1252".//Modify here. Here I am in English. Modify the language you need
There are other displays that only need to translate the XXX.txt.txt text in the Resource \ folder into the language you need
 
Upvote 0
You don't need to add anything, just modify Source \ Neuz \ WinMain.rc \ IDS-CODPAGE "1252".//Modify here. Here I am in English. Modify the language you need
There are other displays that only need to translate the XXX.txt.txt text in the Resource \ folder into the language you need
As you said, look for GetCodePageFromCharset for the code definements to select.
 
Upvote 0
As you said, look for GetCodePageFromCharset for the code definements to select.
Yes, everything else is normal for me. The only issue is that the system's announcement and notification display garbled text, except for English and data, all other languages display garbled text
 
Upvote 0
Yes, everything else is normal for me. The only issue is that the system's announcement and notification display garbled text, except for English and data, all other languages display garbled text
It's wrong no matter how I modify it. Have you fixed it?
 
Upvote 0
Back