Yardım Warning Çözüm?

Konu sahibi bu konuda soru soruyor. Sorusu ile ilgili bilgisi olanların yanıtlamasını bekliyor.

melihalbayrak

Geliştirici
Geliştirici
Yardımsever Üye
Usta Üye
Mesaj
1.246
Çözümler
81
Beğeni
674
Puan
1.109
Ticaret Puanı
0
Bazı warningler alıyorum hepsini çözdüm ama bunları çözemedim bir türlü;

C++:
input_db.cpp: In function 'long int fix_shop_event(LPEVENT, long int)':
input_db.cpp:490:23: warning: ', socket' directive writing 8 bytes into a region of size between 1 and 1024 [-Wformat-overflow=]
  490 |     sprintf(query, "%s, socket%d='%d'", query, s, socket[s]);
      |                       ^~~~~~~~
input_db.cpp:490:20: note: directive argument in the range [0, 2]
  490 |     sprintf(query, "%s, socket%d='%d'", query, s, socket[s]);
      |                    ^~~~~~~~~~~~~~~~~~~
input_db.cpp:490:20: note: using the range [-2147483648, 2147483647] for directive argument
input_db.cpp:490:12: note: 'sprintf' output between 14 and 1047 bytes into a destination of size 1024
  490 |     sprintf(query, "%s, socket%d='%d'", query, s, socket[s]);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
input_db.cpp:490:12: warning: 'sprintf' argument 3 overlaps destination object 'query' [-Wrestrict]
input_db.cpp:484:9: note: destination object referenced by 'restrict'-qualified argument 1 was declared here
  484 |    char query[1024];
      |         ^~~~~
input_db.cpp:496:24: warning: ', attrtype' directive writing 10 bytes into a region of size between 1 and 1024 [-Wformat-overflow=]
  496 |      sprintf(query, "%s, attrtype%d='%d'", query, ia, attr[ia][0]);
      |                        ^~~~~~~~~~
input_db.cpp:496:21: note: directive argument in the range [0, 6]
  496 |      sprintf(query, "%s, attrtype%d='%d'", query, ia, attr[ia][0]);
      |                     ^~~~~~~~~~~~~~~~~~~~~
input_db.cpp:496:21: note: using the range [-2147483648, 2147483647] for directive argument
input_db.cpp:496:13: note: 'sprintf' output between 16 and 1049 bytes into a destination of size 1024
  496 |      sprintf(query, "%s, attrtype%d='%d'", query, ia, attr[ia][0]);
      |      ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
input_db.cpp:496:13: warning: 'sprintf' argument 3 overlaps destination object 'query' [-Wrestrict]
input_db.cpp:484:9: note: destination object referenced by 'restrict'-qualified argument 1 was declared here
  484 |    char query[1024];
      |         ^~~~~
input_db.cpp:497:24: warning: ', attrvalue' directive writing 11 bytes into a region of size between 1 and 1024 [-Wformat-overflow=]
  497 |      sprintf(query, "%s, attrvalue%d='%d'", query, ia, attr[ia][1]);
      |                        ^~~~~~~~~~~
input_db.cpp:497:21: note: directive argument in the range [0, 6]
  497 |      sprintf(query, "%s, attrvalue%d='%d'", query, ia, attr[ia][1]);
      |                     ^~~~~~~~~~~~~~~~~~~~~~
input_db.cpp:497:21: note: using the range [-2147483648, 2147483647] for directive argument
input_db.cpp:497:13: note: 'sprintf' output between 17 and 1050 bytes into a destination of size 1024
  497 |      sprintf(query, "%s, attrvalue%d='%d'", query, ia, attr[ia][1]);
      |      ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
input_db.cpp:497:13: warning: 'sprintf' argument 3 overlaps destination object 'query' [-Wrestrict]
input_db.cpp:484:9: note: destination object referenced by 'restrict'-qualified argument 1 was declared here
  484 |    char query[1024];


İlgili kod bloğu;

C++:
EVENTFUNC(fix_shop_event)
{
    char szSockets[1024] = { '\0' };
    char *tempSockets = szSockets;
    for (int i = 0; i < ITEM_SOCKET_MAX_NUM; i++)
    {
        tempSockets += sprintf(tempSockets, "ps.socket%d", i);

        if (i<ITEM_SOCKET_MAX_NUM - 1)
            tempSockets += sprintf(tempSockets, ",");
    }
    char szAttrs[1024] = { '\0' };
    char *tempAttrs = szAttrs;
    for (int i = 0; i < ITEM_ATTRIBUTE_MAX_NUM; i++)
    {
        if (i < 7)
            tempAttrs += sprintf(tempAttrs, "ps.attrtype%d,attrvalue%d", i, i);
        else
            tempAttrs += sprintf(tempAttrs, "ps.applytype%d,applyvalue%d", i - 7, i - 7);
        if (i<ITEM_ATTRIBUTE_MAX_NUM - 1)
            tempAttrs += sprintf(tempAttrs, ",");
    }
    SQLMsg * pkMsg(DBManager::instance().DirectQuery("SELECT ps.id,ps.player_id,REPLACE('%s','#PLAYER_NAME#',p.name),ps.vnum,ps.count,ps.price,%s,%s FROM `player_shop_items` ps LEFT JOIN player p ON p.id=ps.player_id where not EXISTS(select name from player_shop WHERE id=ps.shop_id) and not ISNULL(p.name)", LC_TEXT("SHOP_NAME"), szSockets, szAttrs));
    SQLResult * pRes = pkMsg->Get();
    if (pRes->uiNumRows>0)
    {
        MYSQL_ROW row;
        while ((row = mysql_fetch_row(pRes->pSQLResult)) != NULL)
        {
            DWORD id = 0, pid = 0, vnum = 0, count = 0, socket[6], attr[7][2];
            int col = 0;
            str_to_number(id, row[col++]);
            str_to_number(pid, row[col++]);
            col++;

            str_to_number(vnum, row[col++]);
            str_to_number(count, row[col++]);
            for (int i = 0;i < ITEM_SOCKET_MAX_NUM;i++)
                str_to_number(socket[i], row[col++]);
            for (int i = 0;i < ITEM_ATTRIBUTE_MAX_NUM;i++)
            {
                str_to_number(attr[i][0], row[col++]);
                str_to_number(attr[i][1], row[col++]);
            }
            char query[1024];
            sprintf(query, "INSERT INTO player_gift SET owner_id=%d,vnum=%d,count=%d,reason='%s',`from`=replace(\"%s\",' ','_'),status='WAIT',date_add=NOW()",
                pid, vnum,count, LC_TEXT("SHOP_REASON"), row[3]);

            for (int s = 0; s < ITEM_SOCKET_MAX_NUM; s++)
            {
                sprintf(query, "%s, socket%d='%d'", query, s, socket[s]);
            }
            for (int ia = 0; ia < ITEM_ATTRIBUTE_MAX_NUM; ia++)
            {
                if (ia < 7)
                {
                    sprintf(query, "%s, attrtype%d='%d'", query, ia, attr[ia][0]);
                    sprintf(query, "%s, attrvalue%d='%d'", query, ia, attr[ia][1]);
                }
                else{
                    sprintf(query, "%s, applytype%d='%d'", query, ia-7, attr[ia][0]);
                    sprintf(query, "%s, applyvalue%d='%d'", query, ia-7, attr[ia][1]);
                }
            }

            DBManager::instance().DirectQuery(query);
            DBManager::instance().DirectQuery("delete from player_shop_items where id=%d",id);
        }
    }

    return PASSES_PER_SEC(SHOP_TIME_REFRESH*60);
}


Diğer bir warning;

C++:
shop.cpp: In member function 'bool CShop::GetItems()':
shop.cpp:465:22: warning: ', socket' directive writing 8 bytes into a region of size between 1 and 8192 [-Wformat-overflow=]
  465 |    sprintf(query, "%s, socket%d='%ld'", query, s, m_itemVector[i].pkItem->GetSocket(s));
      |                      ^~~~~~~~
shop.cpp:465:19: note: directive argument in the range [0, 2]
  465 |    sprintf(query, "%s, socket%d='%ld'", query, s, m_itemVector[i].pkItem->GetSocket(s));
      |                   ^~~~~~~~~~~~~~~~~~~~
shop.cpp:465:11: note: 'sprintf' output between 14 and 8215 bytes into a destination of size 8192
  465 |    sprintf(query, "%s, socket%d='%ld'", query, s, m_itemVector[i].pkItem->GetSocket(s));
      |    ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
shop.cpp:465:11: warning: 'sprintf' argument 3 overlaps destination object 'query' [-Wrestrict]
shop.cpp:458:8: note: destination object referenced by 'restrict'-qualified argument 1 was declared here
  458 |   char query[8192];
      |        ^~~~~
shop.cpp:472:23: warning: ', attrtype' directive writing 10 bytes into a region of size between 1 and 8192 [-Wformat-overflow=]
  472 |     sprintf(query, "%s, attrtype%d='%u'", query, ia, attr.bType);
      |                       ^~~~~~~~~~
shop.cpp:472:20: note: directive argument in the range [0, 6]
  472 |     sprintf(query, "%s, attrtype%d='%u'", query, ia, attr.bType);
      |                    ^~~~~~~~~~~~~~~~~~~~~
shop.cpp:472:20: note: directive argument in the range [0, 255]
shop.cpp:472:12: note: 'sprintf' output between 16 and 8209 bytes into a destination of size 8192
  472 |     sprintf(query, "%s, attrtype%d='%u'", query, ia, attr.bType);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
shop.cpp:472:12: warning: 'sprintf' argument 3 overlaps destination object 'query' [-Wrestrict]
shop.cpp:458:8: note: destination object referenced by 'restrict'-qualified argument 1 was declared here
  458 |   char query[8192];
      |        ^~~~~
shop.cpp:473:23: warning: ', attrvalue' directive writing 11 bytes into a region of size between 1 and 8192 [-Wformat-overflow=]
  473 |     sprintf(query, "%s, attrvalue%d='%d'", query, ia, attr.sValue);
      |                       ^~~~~~~~~~~
shop.cpp:473:20: note: directive argument in the range [0, 6]
  473 |     sprintf(query, "%s, attrvalue%d='%d'", query, ia, attr.sValue);
      |                    ^~~~~~~~~~~~~~~~~~~~~~
shop.cpp:473:20: note: directive argument in the range [-32768, 32767]
shop.cpp:473:12: note: 'sprintf' output between 17 and 8213 bytes into a destination of size 8192
  473 |     sprintf(query, "%s, attrvalue%d='%d'", query, ia, attr.sValue);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
shop.cpp:473:12: warning: 'sprintf' argument 3 overlaps destination object 'query' [-Wrestrict]
shop.cpp:458:8: note: destination object referenced by 'restrict'-qualified argument 1 was declared here
  458 |   char query[8192];

İlgili kod bloğu;

C#:
bool CShop::GetItems()
{
    if (!m_pkPC)
        return false;
    if (!m_pkPC)
        return false;
    for (DWORD i = 0; i < m_itemVector.size() && i < SHOP_HOST_ITEM_MAX_NUM; ++i)
    {
        if (!m_itemVector[i].pkItem)
            continue;
        char query[8192];
        sprintf(query, "INSERT INTO player_gift SET \
        owner_id=%d,vnum=%d,count=%d,reason='%s',`from`=replace(\"%s\",' ','_'),status='WAIT',date_add=NOW()",
        m_pkPC->GetPrivShopOwner(), m_itemVector[i].vnum, m_itemVector[i].count, LC_TEXT("SHOP_REASON"), m_pkPC->GetName());

        for (int s = 0; s < ITEM_SOCKET_MAX_NUM; s++)
        {
            sprintf(query, "%s, socket%d='%ld'", query, s, m_itemVector[i].pkItem->GetSocket(s));
        }
        for (int ia = 0; ia < ITEM_ATTRIBUTE_MAX_NUM; ia++)
        {
            const TPlayerItemAttribute& attr = m_itemVector[i].pkItem->GetAttribute(ia);
            if (ia < 7)
            {
                sprintf(query, "%s, attrtype%d='%u'", query, ia, attr.bType);
                sprintf(query, "%s, attrvalue%d='%d'", query, ia, attr.sValue);
            }
            else
            {
                sprintf(query, "%s, applytype%d='%u'", query, ia-7, attr.bType);
                sprintf(query, "%s, applyvalue%d='%d'", query, ia-7, attr.sValue);
            }
        }
        DBManager::instance().DirectQuery(query);

        DBManager::instance().DirectQuery("delete from player_shop_items where id='%d'", m_itemVector[i].itemid);
        m_itemVector[i].pkItem->RemoveFromCharacter();
        m_itemVector[i].pkItem = NULL;
        BroadcastUpdateItem(i);
    }

    return true;
}

Son warning ise;

C++:
shop_manager.cpp: In member function 'bool CShopManager::CreateOfflineShop(LPCHARACTER, const char*, std::vector<SShopItemTable*>, DWORD)':
shop_manager.cpp:204:23: warning: ' player_id='' directive writing 12 bytes into a region of size between 1 and 1024 [-Wformat-overflow=]
  204 |     sprintf(query, "%s player_id='%d'", query, owner->GetPlayerID());
      |                       ^~~~~~~~~~~~
shop_manager.cpp:204:20: note: using the range [-2147483648, 2147483647] for directive argument
  204 |     sprintf(query, "%s player_id='%d'", query, owner->GetPlayerID());
      |                    ^~~~~~~~~~~~~~~~~~~
shop_manager.cpp:204:12: note: 'sprintf' output between 15 and 1048 bytes into a destination of size 1024
  204 |     sprintf(query, "%s player_id='%d'", query, owner->GetPlayerID());
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
shop_manager.cpp:204:12: warning: 'sprintf' argument 3 overlaps destination object 'query' [-Wrestrict]
shop_manager.cpp:202:10: note: destination object referenced by 'restrict'-qualified argument 1 was declared here
  202 |     char query[1024];
      |          ^~~~~
shop_manager.cpp:205:23: warning: ', shop_id='' directive writing 11 bytes into a region of size between 1 and 1024 [-Wformat-overflow=]
  205 |     sprintf(query, "%s, shop_id='%d'", query, shop_id);
      |                       ^~~~~~~~~~~
shop_manager.cpp:205:20: note: using the range [-2147483648, 2147483647] for directive argument
  205 |     sprintf(query, "%s, shop_id='%d'", query, shop_id);
      |                    ^~~~~~~~~~~~~~~~~~
shop_manager.cpp:205:12: note: 'sprintf' output between 14 and 1047 bytes into a destination of size 1024
  205 |     sprintf(query, "%s, shop_id='%d'", query, shop_id);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
shop_manager.cpp:205:12: warning: 'sprintf' argument 3 overlaps destination object 'query' [-Wrestrict]
shop_manager.cpp:202:10: note: destination object referenced by 'restrict'-qualified argument 1 was declared here
  202 |     char query[1024];
      |          ^~~~~
shop_manager.cpp:206:23: warning: ', vnum='' directive writing 8 bytes into a region of size between 1 and 1024 [-Wformat-overflow=]
  206 |     sprintf(query, "%s, vnum='%d'", query, item->GetVnum());
      |                       ^~~~~~~~
shop_manager.cpp:206:20: note: using the range [-2147483648, 2147483647] for directive argument
  206 |     sprintf(query, "%s, vnum='%d'", query, item->GetVnum());
      |                    ^~~~~~~~~~~~~~~
shop_manager.cpp:206:12: note: 'sprintf' output between 11 and 1044 bytes into a destination of size 1024
  206 |     sprintf(query, "%s, vnum='%d'", query, item->GetVnum());
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
shop_manager.cpp:206:12: warning: 'sprintf' argument 3 overlaps destination object 'query' [-Wrestrict]
shop_manager.cpp:202:10: note: destination object referenced by 'restrict'-qualified argument 1 was declared here
  202 |     char query[1024];
      |          ^~~~~
shop_manager.cpp:207:23: warning: ', count='' directive writing 9 bytes into a region of size between 1 and 1024 [-Wformat-overflow=]
  207 |     sprintf(query, "%s, count='%d'", query, item->GetCount());
      |                       ^~~~~~~~~
shop_manager.cpp:207:20: note: using the range [-2147483648, 2147483647] for directive argument
  207 |     sprintf(query, "%s, count='%d'", query, item->GetCount());
      |                    ^~~~~~~~~~~~~~~~
shop_manager.cpp:207:12: note: 'sprintf' output between 12 and 1045 bytes into a destination of size 1024
  207 |     sprintf(query, "%s, count='%d'", query, item->GetCount());
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
shop_manager.cpp:207:12: warning: 'sprintf' argument 3 overlaps destination object 'query' [-Wrestrict]
shop_manager.cpp:202:10: note: destination object referenced by 'restrict'-qualified argument 1 was declared here
  202 |     char query[1024];
      |          ^~~~~
shop_manager.cpp:208:23: warning: ', price='' directive writing 9 bytes into a region of size between 1 and 1024 [-Wformat-overflow=]
  208 |     sprintf(query, "%s, price='%d'", query, pTable[i]->price);
      |                       ^~~~~~~~~
shop_manager.cpp:208:20: note: using the range [-2147483648, 2147483647] for directive argument
  208 |     sprintf(query, "%s, price='%d'", query, pTable[i]->price);
      |                    ^~~~~~~~~~~~~~~~
shop_manager.cpp:208:12: note: 'sprintf' output between 12 and 1045 bytes into a destination of size 1024
  208 |     sprintf(query, "%s, price='%d'", query, pTable[i]->price);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
shop_manager.cpp:208:12: warning: 'sprintf' argument 3 overlaps destination object 'query' [-Wrestrict]
shop_manager.cpp:202:10: note: destination object referenced by 'restrict'-qualified argument 1 was declared here
  202 |     char query[1024];
      |          ^~~~~
shop_manager.cpp:209:23: warning: ', display_pos='' directive writing 15 bytes into a region of size between 1 and 1024 [-Wformat-overflow=]
  209 |     sprintf(query, "%s, display_pos='%u'", query, pTable[i]->display_pos);
      |                       ^~~~~~~~~~~~~~~
shop_manager.cpp:209:20: note: directive argument in the range [0, 255]
  209 |     sprintf(query, "%s, display_pos='%u'", query, pTable[i]->display_pos);
      |                    ^~~~~~~~~~~~~~~~~~~~~~
shop_manager.cpp:209:12: note: 'sprintf' output between 18 and 1043 bytes into a destination of size 1024
  209 |     sprintf(query, "%s, display_pos='%u'", query, pTable[i]->display_pos);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
shop_manager.cpp:209:12: warning: 'sprintf' argument 3 overlaps destination object 'query' [-Wrestrict]
shop_manager.cpp:202:10: note: destination object referenced by 'restrict'-qualified argument 1 was declared here
  202 |     char query[1024];
      |          ^~~~~
shop_manager.cpp:212:24: warning: ', socket' directive writing 8 bytes into a region of size between 1 and 1024 [-Wformat-overflow=]
  212 |      sprintf(query, "%s, socket%d='%ld'", query, s, item->GetSocket(s));
      |                        ^~~~~~~~
shop_manager.cpp:212:21: note: directive argument in the range [0, 2]
  212 |      sprintf(query, "%s, socket%d='%ld'", query, s, item->GetSocket(s));
      |                     ^~~~~~~~~~~~~~~~~~~~
shop_manager.cpp:212:13: note: 'sprintf' output between 14 and 1047 bytes into a destination of size 1024
  212 |      sprintf(query, "%s, socket%d='%ld'", query, s, item->GetSocket(s));
      |      ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
shop_manager.cpp:212:13: warning: 'sprintf' argument 3 overlaps destination object 'query' [-Wrestrict]
shop_manager.cpp:202:10: note: destination object referenced by 'restrict'-qualified argument 1 was declared here
  202 |     char query[1024];
      |          ^~~~~
shop_manager.cpp:220:25: warning: ', attrtype' directive writing 10 bytes into a region of size between 1 and 1024 [-Wformat-overflow=]
  220 |       sprintf(query, "%s, attrtype%d='%u'", query, ia, attr.bType);
      |                         ^~~~~~~~~~
shop_manager.cpp:220:22: note: directive argument in the range [0, 6]
  220 |       sprintf(query, "%s, attrtype%d='%u'", query, ia, attr.bType);
      |                      ^~~~~~~~~~~~~~~~~~~~~
shop_manager.cpp:220:22: note: directive argument in the range [0, 255]
shop_manager.cpp:220:14: note: 'sprintf' output between 16 and 1041 bytes into a destination of size 1024
  220 |       sprintf(query, "%s, attrtype%d='%u'", query, ia, attr.bType);
      |       ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
shop_manager.cpp:220:14: warning: 'sprintf' argument 3 overlaps destination object 'query' [-Wrestrict]
shop_manager.cpp:202:10: note: destination object referenced by 'restrict'-qualified argument 1 was declared here
  202 |     char query[1024];
      |          ^~~~~
shop_manager.cpp:221:25: warning: ', attrvalue' directive writing 11 bytes into a region of size between 1 and 1024 [-Wformat-overflow=]
  221 |       sprintf(query, "%s, attrvalue%d='%d'", query, ia, attr.sValue);
      |                         ^~~~~~~~~~~
shop_manager.cpp:221:22: note: directive argument in the range [0, 6]
  221 |       sprintf(query, "%s, attrvalue%d='%d'", query, ia, attr.sValue);
      |                      ^~~~~~~~~~~~~~~~~~~~~~
shop_manager.cpp:221:22: note: directive argument in the range [-32768, 32767]
shop_manager.cpp:221:14: note: 'sprintf' output between 17 and 1045 bytes into a destination of size 1024
  221 |       sprintf(query, "%s, attrvalue%d='%d'", query, ia, attr.sValue);
      |       ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
shop_manager.cpp:221:14: warning: 'sprintf' argument 3 overlaps destination object 'query' [-Wrestrict]
shop_manager.cpp:202:10: note: destination object referenced by 'restrict'-qualified argument 1 was declared here
  202 |     char query[1024];

İlgili kod bloğu;

C++:
extern std::map<int, TShopCost> g_ShopCosts;
bool CShopManager::CreateOfflineShop(LPCHARACTER owner, const char *szSign, const std::vector<TShopItemTable *> pTable, DWORD id)
{
    if (g_ShopCosts.find(id) == g_ShopCosts.end())
    {
        sys_log(0, "CreateOfflineShop:Shop days error %d", id);
        return false;
    }

    DWORD map_index = owner->GetMapIndex();
    long x = (owner->GetX() + number(50, 200));
    long y = (owner->GetY() + number(50, 200));
    long z = owner->GetZ();
    char szQuery[4096];
    DWORD date_close = get_global_time() + (g_ShopCosts[id].time * g_ShopCosts[id].days);
    sprintf(szQuery, "insert into player_shop set item_count=%d,player_id=%d,name=\"%s\",map_index=%d,x=%ld,y=%ld,z=%ld,ip='%s',date=NOW(),date_close=FROM_UNIXTIME(%d),channel=%d",
        pTable.size(), owner->GetPlayerID(), szSign, map_index, x, y, z, inet_ntoa(owner->GetDesc()->GetAddr().sin_addr), date_close, g_bChannel);
    SQLMsg * pkMsg(DBManager::instance().DirectQuery(szQuery));
    SQLResult * pRes = pkMsg->Get();
    DWORD shop_id = pRes->uiInsertID;

    if (shop_id>0)
    {
        for (int i = 0;i < pTable.size();i++)
        {
            LPITEM item = owner->GetItem(pTable[i]->pos);
            if (item)
            {
                char query[1024];
                sprintf(query, "INSERT INTO player_shop_items SET");
                sprintf(query, "%s player_id='%d'", query, owner->GetPlayerID());
                sprintf(query, "%s, shop_id='%d'", query, shop_id);
                sprintf(query, "%s, vnum='%d'", query, item->GetVnum());
                sprintf(query, "%s, count='%d'", query, item->GetCount());
                sprintf(query, "%s, price='%d'", query, pTable[i]->price);
                sprintf(query, "%s, display_pos='%u'", query, pTable[i]->display_pos);
                for (int s = 0; s < ITEM_SOCKET_MAX_NUM; s++)
                {
                    sprintf(query, "%s, socket%d='%ld'", query, s, item->GetSocket(s));
                    
                }
                for (int ia = 0; ia < ITEM_ATTRIBUTE_MAX_NUM; ia++)
                {
                    const TPlayerItemAttribute& attr = item->GetAttribute(ia);
                    if (ia < 7)
                    {
                        sprintf(query, "%s, attrtype%d='%u'", query, ia, attr.bType);
                        sprintf(query, "%s, attrvalue%d='%d'", query, ia, attr.sValue);
                    }
                    else{
                        sprintf(query, "%s, applytype%d='%u'", query, ia - 7, attr.bType);
                        sprintf(query, "%s, applyvalue%d='%d'", query, ia - 7, attr.sValue);
                    }


                }
                DBManager::instance().DirectQuery(query);
                ITEM_MANAGER::Instance().RemoveItem(item, "Priv shop");
            }
        }
        StartOfflineShop(shop_id);
        owner->SendShops();
        return true;
    }
    return false;
}
 
query'e verdiğin byte kimi kısımda az kimi kısımda fazla kalmış. Örneğin;
PID (player_id) 1024 byte'lık bi değer fakat 5'le 1048 arası byte yazıyor diyor. Tüm dataları tek bir 'query' olarak çağırdığın için bu sorun oluyor büyük ihtimalle.

Linkleri görebilmek için giriş yap veya kayıt ol.


Burdaki tabloya göre kendine lazım olan byte'ı
C++:
char query[x];
Buraya yazarsan sorun çözülücektir.
 
Örnek denermisin

Ara:
    char szSockets[1024] = { '\0' }

Değiştir:
    char szSockets[1047] = { '\0' }
 
Örnek denermisin

Ara:
    char szSockets[1024] = { '\0' }

Değiştir:
    char szSockets[1047] = { '\0' }
Bunun bir faydası olmadı yine birebir aynı warningi verdi.

query'e verdiğin byte kimi kısımda az kimi kısımda fazla kalmış. Örneğin;
PID (player_id) 1024 byte'lık bi değer fakat 5'le 1048 arası byte yazıyor diyor. Tüm dataları tek bir 'query' olarak çağırdığın için bu sorun oluyor büyük ihtimalle.

Linkleri görebilmek için giriş yap veya kayıt ol.


Burdaki tabloya göre kendine lazım olan byte'ı
C++:
char query[x];
Buraya yazarsan sorun çözülücektir.
Tam anlayamadım bir örnek verebilir misiniz? Mesela input_db deki için kaç byte yazmam gerekiyor?
 
Denermisin

Ara:
char query[1024];

Değiştir:
char query[1047];
Bu bir çözüm değil, bellekte fazladan yer tutturuyorsunuz bu şekilde. bazı kısımlar max 1048 byte alıyor. 1047 verdiğinizde sorun oluşur. genelde bu işlemler tek bir query üstünden yapılıp total byte değeri çekilir.
 
Denermisin

Ara:
char query[1024];

Değiştir:
char query[1047];
Aynı değişiklik yok.

input_db.cpp:490:23: warning: ', socket' directive writing 8 bytes into a region of size between 1 and 1047 [-Wformat-overflow=]
490 | sprintf(query, "%s, socket%d='%d'", query, s, socket);
 
Biraz uğraştırdı ama mobilden olduğu kadar ^^ Sen parantezlere vs. bir daha bakarsın. Herhangi bir hata alırsan yaz mobilden belki hata yapmış olabilirim.

C++:
            if (item)
            {
              
                char query[4096];
                for (int s = 0; s < ITEM_SOCKET_MAX_NUM; s++)
                {
                    for (int ia = 0; ia < ITEM_ATTRIBUTE_MAX_NUM; ia++)
                    {
                        const TPlayerItemAttribute& attr = item->GetAttribute(ia);
                        // QUERY BAŞLANGIÇ
                        sprintf(query, "INSERT INTO player_shop_items SET player_id=%d,shop_id=%d,vnum=%d,count%d,"

                            #ifdef FULL_YANG
                            "price=%lld'"
                            #else
                            "price=%d"
                            #endif
                            ",display_pos=%u,socket%d=%ld,attrtype%d=%u,attrvalue%d=%d",
                                owner->GetPlayerID(), shop_id, item->GetVnum(), item->GetCount(), pTable[i]->price, pTable[i]->display_pos, s, item->GetSocket(s), ia, attr.bType, ia, attr.sValue
                        );
                        // QUERY END
                    }
                }
                DBManager::instance().DirectQuery(query);
                ITEM_MANAGER::Instance().RemoveItem(item, "Priv shop");
            }
 
Son düzenleme:
Biraz uğraştırdı ama mobilden olduğu kadar ^^ Sen parantezlere vs. bir daha bakarsın. Herhangi bir hata alırsan yaz mobilden belki hata yapmış olabilirim.

C++:
            if (item)
            {
             
                char query[4096];
                for (int s = 0; s < ITEM_SOCKET_MAX_NUM; s++)
                {
                    for (int ia = 0; ia < ITEM_ATTRIBUTE_MAX_NUM; ia++)
                    {
                        const TPlayerItemAttribute& attr = item->GetAttribute(ia);
                        // QUERY BAŞLANGIÇ
                        sprintf(query, "INSERT INTO player_shop_items SET player_id=%d,shop_id=%d,vnum=%d,count%d,"

                            #ifdef FULL_YANG
                            "price=%lld'"
                            #else
                            "price=%d"
                            #endif
                            ",display_pos=%u,socket%d=%ld,attrtype%d=%u,attrvalue%d=%d",
                                owner->GetPlayerID(), shop_id, item->GetVnum(), item->GetCount(), pTable[i]->price, pTable[i]->display_pos, s, item->GetSocket(s), ia, attr.bType, ia, attr.sValue
                        );
                        // QUERY END
                    }
                }
                DBManager::instance().DirectQuery(query);
                ITEM_MANAGER::Instance().RemoveItem(item, "Priv shop");
            }
Tamamda bu hangi warningin çözümü? 3 farklı dosyanın warningini verdim ben eğer input_db için ise hata veriyor.

Kod:
compile input_db.cpp
input_db.cpp: In function 'long int fix_shop_event(LPEVENT, long int)':
input_db.cpp:484:8: error: 'item' was not declared in this scope
  484 |    if (item)
      |        ^~~~
input_db.cpp:502:9: error: 'owner' was not declared in this scope
  502 |         owner->GetPlayerID(), shop_id, item->GetVnum(), item->GetCount(), pTable[i]->price, pTable[i]->display_pos, s, item->GetSocket(s), ia, attr.bType, ia, attr.sValue
      |         ^~~~~
input_db.cpp:502:31: error: 'shop_id' was not declared in this scope
  502 |         owner->GetPlayerID(), shop_id, item->GetVnum(), item->GetCount(), pTable[i]->price, pTable[i]->display_pos, s, item->GetSocket(s), ia, attr.bType, ia, attr.sValue
      |                               ^~~~~~~
input_db.cpp:502:75: error: 'pTable' was not declared in this scope
  502 |         owner->GetPlayerID(), shop_id, item->GetVnum(), item->GetCount(), pTable[i]->price, pTable[i]->display_pos, s, item->GetSocket(s), ia, attr.bType, ia, attr.sValue
      |                                                                           ^~~~~~
input_db.cpp:502:82: error: 'i' was not declared in this scope; did you mean 'ia'?
  502 |         owner->GetPlayerID(), shop_id, item->GetVnum(), item->GetCount(), pTable[i]->price, pTable[i]->display_pos, s, item->GetSocket(s), ia, attr.bType, ia, attr.sValue
      |                                                                                  ^
      |                                                                                  ia
input_db.cpp:511:38: error: 'query' was not declared in this scope
  511 |    DBManager::instance().DirectQuery(query);
 
Tamamda bu hangi warningin çözümü? 3 farklı dosyanın warningini verdim ben eğer input_db için ise hata veriyor.

Kod:
compile input_db.cpp
input_db.cpp: In function 'long int fix_shop_event(LPEVENT, long int)':
input_db.cpp:484:8: error: 'item' was not declared in this scope
  484 |    if (item)
      |        ^~~~
input_db.cpp:502:9: error: 'owner' was not declared in this scope
  502 |         owner->GetPlayerID(), shop_id, item->GetVnum(), item->GetCount(), pTable[i]->price, pTable[i]->display_pos, s, item->GetSocket(s), ia, attr.bType, ia, attr.sValue
      |         ^~~~~
input_db.cpp:502:31: error: 'shop_id' was not declared in this scope
  502 |         owner->GetPlayerID(), shop_id, item->GetVnum(), item->GetCount(), pTable[i]->price, pTable[i]->display_pos, s, item->GetSocket(s), ia, attr.bType, ia, attr.sValue
      |                               ^~~~~~~
input_db.cpp:502:75: error: 'pTable' was not declared in this scope
  502 |         owner->GetPlayerID(), shop_id, item->GetVnum(), item->GetCount(), pTable[i]->price, pTable[i]->display_pos, s, item->GetSocket(s), ia, attr.bType, ia, attr.sValue
      |                                                                           ^~~~~~
input_db.cpp:502:82: error: 'i' was not declared in this scope; did you mean 'ia'?
  502 |         owner->GetPlayerID(), shop_id, item->GetVnum(), item->GetCount(), pTable[i]->price, pTable[i]->display_pos, s, item->GetSocket(s), ia, attr.bType, ia, attr.sValue
      |                                                                                  ^
      |                                                                                  ia
input_db.cpp:511:38: error: 'query' was not declared in this scope
  511 |    DBManager::instance().DirectQuery(query);
Koddan anlaşılıyor zaten shop_manager için verdim.
 
Dalgınlık başka bişeyle uğraşıyordum farketmemişim. shop_manager warningi çözüldü diğer iki cpp warningi kaldı.
Süper, diğerlerine de aynı şeyleri yapabilirsin. Mantığı anlamışsındır diğerlerini de aynı şekilde deneyebilirsin. Byte değerini shop.cpp için byte değerini sabit tut, inpud_db için 1024'de dene olmazsa 2048 yapıp dene hesaplayamadım onu şimdi.
 
Süper, diğerlerine de aynı şeyleri yapabilirsin. Mantığı anlamışsındır diğerlerini de aynı şekilde deneyebilirsin. Byte değerini shop.cpp için byte değerini sabit tut, inpud_db için 1024'de dene olmazsa 2048 yapıp dene hesaplayamadım onu şimdi.
Hatalı çalışıyor. Buildde sorun yok ama oyun içinde pazarı açınca pazar ismi gözükmüyor pazara tıklayıncada pencere vs gelmiyor. pazarı kapatıncada item giftboxa düşmüyor kayboluyor.
 
Hatalı çalışıyor. Buildde sorun yok ama oyun içinde pazarı açınca pazar ismi gözükmüyor pazara tıklayıncada pencere vs gelmiyor. pazarı kapatıncada item giftboxa düşmüyor kayboluyor.
Warning ayrı ayrı query gönderiyor. Bu şekilde düşündüm warning gidiyor ama dediğin gibiyse geri alabilirsin. Tüm greatlerde bu şekilde biraz bakındım. Gizleyebilirsin çok önemli bir şey olduğunu düşünmüyorum
 
Warning ayrı ayrı query gönderiyor. Bu şekilde düşündüm warning gidiyor ama dediğin gibiyse geri alabilirsin. Tüm greatlerde bu şekilde biraz bakındım. Gizleyebilirsin çok önemli bir şey olduğunu düşünmüyorum
Bende yaklaşık 10 filese baktım bu kısımı düzenleyen yok nedense. :)
 
Verdiğim düzenlemede belki verdiğim byte değeri az gelmiş olabilir bir daha hesaplayayım öyle dene olmadı geri alıp CFLAGS'a -Wformat-overflow= ekleyip gizleyebilirsin.
Konu eski ama tekrar denedim. Şu şekilde ch1 syser veriyor.

Kod:
SYSERR: Jun  3 21:26:55 :: DirectQuery: AsyncSQL::DirectQuery : mysql_query error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ',price=123,display_pos=0,socket2=1,attrtype6=0,attrvalue6=0' at line 1
query: INSERT INTO player_shop_items SET player_id=1,shop_id=6,vnum=149,count1,price=123,display_pos=0,socket2=1,attrtype6=0,attrvalue6=0
 
Geri
Üst