<commit_before>#include "stdafx.h"

#include "UpdateGeneral.h"
#include <ATF/global.hpp>


namespace GameServer
{
    namespace Fixes
    {
        template <typename T, size_t N>
        constexpr size_t size_array(T(&)[N])
        {
            return N;
        }

        using namespace ATF;

        void CUpdateGeneral::load()
        {
            auto& core = CATFCore::get_instance();
            core.set_hook(&ATF::CMainThread::_db_Update_General, &CUpdateGeneral::_db_Update_General);
        }

        void CUpdateGeneral::unload()
        {
            auto& core = CATFCore::get_instance();
            core.unset_hook(&ATF::CMainThread::_db_Update_General);
        }

        void CUpdateGeneral::loop()
        {
        }

        ModuleVersion_t CUpdateGeneral::get_version()
        {
            return usVersion;
        }

        ModuleName_t CUpdateGeneral::get_name()
        {
            static const ModuleName_t name = "fix_updategeneral";
            return name;
        }

        void CUpdateGeneral::configure(
            const rapidjson::Value & nodeConfig)
        {
            UNREFERENCED_PARAMETER(nodeConfig);
        }

        bool WINAPIV CUpdateGeneral::_db_Update_General(
            ATF::CMainThread *pObj,
            unsigned int dwSerial,
            ATF::_AVATOR_DATA* pNewData,
            ATF::_AVATOR_DATA* pOldData,
            char* pSzQuery,
            bool bCheckLowHigh,
            ATF::info::CMainThread_db_Update_General258_ptr next)
        {
            UNREFERENCED_PARAMETER(pObj);
            UNREFERENCED_PARAMETER(bCheckLowHigh);
            UNREFERENCED_PARAMETER(next);
            char Source[200];
            memset(&Source[0], '\0', sizeof(Source));
            sprintf(pSzQuery, "UPDATE tbl_general SET ");

            size_t nStartLen = strlen(pSzQuery);

            if (pOldData->dbAvator.m_dExp != pNewData->dbAvator.m_dExp)
            {
                sprintf(Source, "Exp=%f,", pNewData->dbAvator.m_dExp);
                strcat(pSzQuery, Source);
            }
            if (pOldData->dbAvator.m_dLossExp != pNewData->dbAvator.m_dLossExp)
            {
                sprintf(Source, "LossExp=%f,", pNewData->dbAvator.m_dLossExp);
                strcat(pSzQuery, Source);
            }
            for (int i = 0; i < size_array(pOldData->dbAvator.m_zClassHistory); ++i)
            {
                if (pOldData->dbAvator.m_zClassHistory[i] != pNewData->dbAvator.m_zClassHistory[i])
                {
                    sprintf(Source, "Class%d=%d,", i, pNewData->dbAvator.m_zClassHistory[i]);
                    strcat(pSzQuery, Source);
                }
            }
            if (pOldData->dbAvator.m_dwClassInitCnt != pNewData->dbAvator.m_dwClassInitCnt)
            {
                sprintf(Source, "ClassInitCnt=%d,", pNewData->dbAvator.m_dwClassInitCnt);
                strcat(pSzQuery, Source);
            }
            if (pOldData->dbAvator.m_byLastClassGrade != pNewData->dbAvator.m_byLastClassGrade)
            {
                sprintf(Source, "LastClassGrade=%d,", pNewData->dbAvator.m_byLastClassGrade);
                strcat(pSzQuery, Source);
            }
            if (pOldData->dbAvator.m_dwHP != pNewData->dbAvator.m_dwHP)
            {
                sprintf(Source, "HP=%d,", pNewData->dbAvator.m_dwHP);
                strcat(pSzQuery, Source);
            }
            if (pOldData->dbAvator.m_dwFP != pNewData->dbAvator.m_dwFP)
            {
                sprintf(Source, "FP=%d,", pNewData->dbAvator.m_dwFP);
                strcat(pSzQuery, Source);
            }
            if (pOldData->dbAvator.m_dwSP != pNewData->dbAvator.m_dwSP)
            {
                sprintf(Source, "SP=%d,", pNewData->dbAvator.m_dwSP);
                strcat(pSzQuery, Source);
            }
            if (pOldData->dbAvator.m_dwDP != pNewData->dbAvator.m_dwDP)
            {
                sprintf(Source, "DP=%d,", pNewData->dbAvator.m_dwDP);
                strcat(pSzQuery, Source);
            }
            if (pOldData->dbAvator.m_byMapCode != pNewData->dbAvator.m_byMapCode)
            {
                sprintf(Source, "Map=%d,", pNewData->dbAvator.m_byMapCode);
                strcat(pSzQuery, Source);
            }
            if (pOldData->dbAvator.m_fStartPos[0] != pNewData->dbAvator.m_fStartPos[0])
            {
                if (_STD isfinite(pNewData->dbAvator.m_fStartPos[0]))
                {
                    sprintf(Source, "X=%f,", pNewData->dbAvator.m_fStartPos[0]);
                    strcat(pSzQuery, Source);
                }
            }
            if (pOldData->dbAvator.m_fStartPos[1] != pNewData->dbAvator.m_fStartPos[1])
            {
                if (_STD isfinite(pNewData->dbAvator.m_fStartPos[1]))
                {
                    sprintf(Source, "Y=%f,", pNewData->dbAvator.m_fStartPos[1]);
                    strcat(pSzQuery, Source);
                }
            }
            if (pOldData->dbAvator.m_fStartPos[2] != pNewData->dbAvator.m_fStartPos[2])
            {
                if (_STD isfinite(pNewData->dbAvator.m_fStartPos[2]))
                {
                    sprintf(Source, "Z=%f,", pNewData->dbAvator.m_fStartPos[2]);
                    strcat(pSzQuery, Source);
                }
            }
            if (pOldData->dbAvator.m_byBagNum != pNewData->dbAvator.m_byBagNum)
            {
                sprintf(Source, "BagNum=%d,", pNewData->dbAvator.m_byBagNum);
                strcat(pSzQuery, Source);
            }
            
            for (int i = 0; i < size_array(pNewData->dbEquip.m_EmbellishList); ++i)
            {
                if (pNewData->dbEquip.m_EmbellishList[i].Key.IsFilled())
                {
                    if (pOldData->dbEquip.m_EmbellishList[i].Key.IsFilled())
                    {
                        unsigned int newDbKey = pNewData->dbEquip.m_EmbellishList[i].Key.CovDBKey();
                        unsigned int oldDbKey = pOldData->dbEquip.m_EmbellishList[i].Key.CovDBKey();
                        if (newDbKey != oldDbKey)
                        {
                            sprintf(Source, "EK%d=%d,", i, newDbKey);
                            strcat(pSzQuery, Source);
                        }
<commit_msg>Fix array size<commit_after>#include "stdafx.h"

#include "UpdateGeneral.h"
#include <ATF/global.hpp>


namespace GameServer
{
    namespace Fixes
    {
        template <typename T, size_t N>
        constexpr size_t size_array(T(&)[N])
        {
            return N;
        }

        using namespace ATF;

        void CUpdateGeneral::load()
        {
            auto& core = CATFCore::get_instance();
            core.set_hook(&ATF::CMainThread::_db_Update_General, &CUpdateGeneral::_db_Update_General);
        }

        void CUpdateGeneral::unload()
        {
            auto& core = CATFCore::get_instance();
            core.unset_hook(&ATF::CMainThread::_db_Update_General);
        }

        void CUpdateGeneral::loop()
        {
        }

        ModuleVersion_t CUpdateGeneral::get_version()
        {
            return usVersion;
        }

        ModuleName_t CUpdateGeneral::get_name()
        {
            static const ModuleName_t name = "fix_updategeneral";
            return name;
        }

        void CUpdateGeneral::configure(
            const rapidjson::Value & nodeConfig)
        {
            UNREFERENCED_PARAMETER(nodeConfig);
        }

        bool WINAPIV CUpdateGeneral::_db_Update_General(
            ATF::CMainThread *pObj,
            unsigned int dwSerial,
            ATF::_AVATOR_DATA* pNewData,
            ATF::_AVATOR_DATA* pOldData,
            char* pSzQuery,
            bool bCheckLowHigh,
            ATF::info::CMainThread_db_Update_General258_ptr next)
        {
            UNREFERENCED_PARAMETER(pObj);
            UNREFERENCED_PARAMETER(bCheckLowHigh);
            UNREFERENCED_PARAMETER(next);
            char Source[200];
            memset(&Source[0], '\0', sizeof(Source));
            sprintf(pSzQuery, "UPDATE tbl_general SET ");

            size_t nStartLen = strlen(pSzQuery);

            if (pOldData->dbAvator.m_dExp != pNewData->dbAvator.m_dExp)
            {
                sprintf(Source, "Exp=%f,", pNewData->dbAvator.m_dExp);
                strcat(pSzQuery, Source);
            }
            if (pOldData->dbAvator.m_dLossExp != pNewData->dbAvator.m_dLossExp)
            {
                sprintf(Source, "LossExp=%f,", pNewData->dbAvator.m_dLossExp);
                strcat(pSzQuery, Source);
            }
            for (int i = 0; i < size_array(pOldData->dbAvator.m_zClassHistory); ++i)
            {
                if (pOldData->dbAvator.m_zClassHistory[i] != pNewData->dbAvator.m_zClassHistory[i])
                {
                    sprintf(Source, "Class%d=%d,", i, pNewData->dbAvator.m_zClassHistory[i]);
                    strcat(pSzQuery, Source);
                }
            }
            if (pOldData->dbAvator.m_dwClassInitCnt != pNewData->dbAvator.m_dwClassInitCnt)
            {
                sprintf(Source, "ClassInitCnt=%d,", pNewData->dbAvator.m_dwClassInitCnt);
                strcat(pSzQuery, Source);
            }
            if (pOldData->dbAvator.m_byLastClassGrade != pNewData->dbAvator.m_byLastClassGrade)
            {
                sprintf(Source, "LastClassGrade=%d,", pNewData->dbAvator.m_byLastClassGrade);
                strcat(pSzQuery, Source);
            }
            if (pOldData->dbAvator.m_dwHP != pNewData->dbAvator.m_dwHP)
            {
                sprintf(Source, "HP=%d,", pNewData->dbAvator.m_dwHP);
                strcat(pSzQuery, Source);
            }
            if (pOldData->dbAvator.m_dwFP != pNewData->dbAvator.m_dwFP)
            {
                sprintf(Source, "FP=%d,", pNewData->dbAvator.m_dwFP);
                strcat(pSzQuery, Source);
            }
            if (pOldData->dbAvator.m_dwSP != pNewData->dbAvator.m_dwSP)
            {
                sprintf(Source, "SP=%d,", pNewData->dbAvator.m_dwSP);
                strcat(pSzQuery, Source);
            }
            if (pOldData->dbAvator.m_dwDP != pNewData->dbAvator.m_dwDP)
            {
                sprintf(Source, "DP=%d,", pNewData->dbAvator.m_dwDP);
                strcat(pSzQuery, Source);
            }
            if (pOldData->dbAvator.m_byMapCode != pNewData->dbAvator.m_byMapCode)
            {
                sprintf(Source, "Map=%d,", pNewData->dbAvator.m_byMapCode);
                strcat(pSzQuery, Source);
            }
            if (pOldData->dbAvator.m_fStartPos[0] != pNewData->dbAvator.m_fStartPos[0])
            {
                if (_STD isfinite(pNewData->dbAvator.m_fStartPos[0]))
                {
                    sprintf(Source, "X=%f,", pNewData->dbAvator.m_fStartPos[0]);
                    strcat(pSzQuery, Source);
                }
            }
            if (pOldData->dbAvator.m_fStartPos[1] != pNewData->dbAvator.m_fStartPos[1])
            {
                if (_STD isfinite(pNewData->dbAvator.m_fStartPos[1]))
                {
                    sprintf(Source, "Y=%f,", pNewData->dbAvator.m_fStartPos[1]);
                    strcat(pSzQuery, Source);
                }
            }
            if (pOldData->dbAvator.m_fStartPos[2] != pNewData->dbAvator.m_fStartPos[2])
            {
                if (_STD isfinite(pNewData->dbAvator.m_fStartPos[2]))
                {
                    sprintf(Source, "Z=%f,", pNewData->dbAvator.m_fStartPos[2]);
                    strcat(pSzQuery, Source);
                }
            }
            if (pOldData->dbAvator.m_byBagNum != pNewData->dbAvator.m_byBagNum)
            {
                sprintf(Source, "BagNum=%d,", pNewData->dbAvator.m_byBagNum);
                strcat(pSzQuery, Source);
            }
            
            for (int i = 0; i < 6; ++i)
            {
                if (pNewData->dbEquip.m_EmbellishList[i].Key.IsFilled())
                {
                    if (pOldData->dbEquip.m_EmbellishList[i].Key.IsFilled())
                    {
                        unsigned int newDbKey = pNewData->dbEquip.m_EmbellishList[i].Key.CovDBKey();
                        unsigned int oldDbKey = pOldData->dbEquip.m_EmbellishList[i].Key.CovDBKey();
                        if (newDbKey != oldDbKey)
                        {
                            sprintf(Source, "EK%d=%d,", i, newDbKey);
                            strcat(pSzQuery, Source);
                        }

{'fraction_non_alphanumeric': 0.11759533136141978, 'fraction_numerical': 0.003597409864897274, 'mean_word_length': 1.5852448853068817, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 108, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7432632', 'n_tokens_mistral': 4093, 'n_tokens_neox': 3961, 'n_words': 496}