Jump to content

Recommended Posts

  • Active+ Member

Hello guys I have a problem with my safebox it doesn't store items when I close the safebox every item I moved in it vanishes and I don't know what to do... I get this syserr but I checked my Cache.cpp and ClientManager.cpp and the query is just fine...

Here is syserr:

Spoiler

SYSERR: Feb 18 06:04:05.788040 :: ChildLoop: AsyncSQL: query failed: 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 '' at line 1 (query: REPLACE INTO item (id, owner_id, window, pos, count, vnum, socket0, socket1, socket2, attrtype0, attrvalue0, attrtype1, attrvalue1, attrtype2, attrvalue2, attrtype3, attrvalue3, attrtype4, attrvalue4, attrtype5, attrvalue5, attrtype6, attrvalue6, attrtype7, attrvalue7, applytype0, applyvalue0, applytype1, applyvalue1, applytype2, applyvalue2, applytype3, applyvalue3, applytype4, applyvalue4, applytype5, applyvalue5, applytype6, applyvalue6, applytype7, applyvalue7)VALUES(10000841, 100, 3, 18, 1, 6099, 1, 1 errno: 1064)
 

Here is my Cache.cpp's query function:

Spoiler

void CItemCache::OnFlush()
{
    if (m_data.vnum == 0) // vnumΐΜ 0ΐΜΈι »θΑ¦ΗΟ¶σ°ν Η¥½ΓµΘ °ΝΐΜ΄Ω.
    {
        char szQuery[QUERY_MAX_LEN];
        snprintf(szQuery, sizeof(szQuery), "DELETE FROM item%s WHERE id=%u", GetTablePostfix(), m_data.id);
        CDBManager::instance().ReturnQuery(szQuery, QID_ITEM_DESTROY, 0, NULL);

        if (g_test_server)
            sys_log(0, "ItemCache::Flush : DELETE %u %s", m_data.id, szQuery);
    }
    else
    {
        long alSockets[ITEM_SOCKET_MAX_NUM];
        TPlayerItemAttribute aAttr[ITEM_ATTRIBUTE_MAX_NUM];
        bool isSocket = false, isAttr = false;

        memset(&alSockets, 0, sizeof(long) * ITEM_SOCKET_MAX_NUM);
        memset(&aAttr, 0, sizeof(TPlayerItemAttribute) * ITEM_ATTRIBUTE_MAX_NUM);

        TPlayerItem * p = &m_data;

        if (memcmp(alSockets, p->alSockets, sizeof(long) * ITEM_SOCKET_MAX_NUM))
            isSocket = true;

        if (memcmp(aAttr, p->aAttr, sizeof(TPlayerItemAttribute) * ITEM_ATTRIBUTE_MAX_NUM))
            isAttr = true;

        char szColumns[QUERY_MAX_LEN];
        char szValues[QUERY_MAX_LEN];
        char szUpdate[QUERY_MAX_LEN];

        int iLen = snprintf(szColumns, sizeof(szColumns), "id, owner_id, window, pos, count, vnum");

        int iValueLen = snprintf(szValues, sizeof(szValues), "%u, %u, %d, %d, %u, %u",
                p->id, p->owner, p->window, p->pos, p->count, p->vnum);

        int iUpdateLen = snprintf(szUpdate, sizeof(szUpdate), "owner_id=%u, window=%d, pos=%d, count=%u, vnum=%u",
                p->owner, p->window, p->pos, p->count, p->vnum);

        if (isSocket)
        {
            iLen += snprintf(szColumns + iLen, sizeof(szColumns) - iLen, ", socket0, socket1, socket2");
            iValueLen += snprintf(szValues + iValueLen, sizeof(szValues) - iValueLen,
                    ", %lu, %lu, %lu", p->alSockets[0], p->alSockets[1], p->alSockets[2]);
            iUpdateLen += snprintf(szUpdate + iUpdateLen, sizeof(szUpdate) - iUpdateLen,
                    ", socket0=%lu, socket1=%lu, socket2=%lu", p->alSockets[0], p->alSockets[1], p->alSockets[2]);
        }

        if (isAttr)
        {
            iLen += snprintf(szColumns + iLen, sizeof(szColumns) - iLen, 
                    ", attrtype0, attrvalue0, attrtype1, attrvalue1, attrtype2, attrvalue2, attrtype3, attrvalue3"
                    ", attrtype4, attrvalue4, attrtype5, attrvalue5, attrtype6, attrvalue6, attrtype7, attrvalue7"
                    ", applytype0, applyvalue0, applytype1, applyvalue1, applytype2, applyvalue2, applytype3, applyvalue3"
                    ", applytype4, applyvalue4, applytype5, applyvalue5, applytype6, applyvalue6, applytype7, applyvalue7");

            iValueLen += snprintf(szValues + iValueLen, sizeof(szValues) - iValueLen,
                    ", %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d",
                    p->aAttr[0].bType, p->aAttr[0].sValue,
                    p->aAttr[1].bType, p->aAttr[1].sValue,
                    p->aAttr[2].bType, p->aAttr[2].sValue,
                    p->aAttr[3].bType, p->aAttr[3].sValue,
                    p->aAttr[4].bType, p->aAttr[4].sValue,
                    p->aAttr[5].bType, p->aAttr[5].sValue,
                    p->aAttr[6].bType, p->aAttr[6].sValue,
                    p->aAttr[7].bType, p->aAttr[7].sValue,
                    p->aAttr[8].bType, p->aAttr[8].sValue,
                    p->aAttr[9].bType, p->aAttr[9].sValue,
                    p->aAttr[10].bType, p->aAttr[10].sValue,
                    p->aAttr[11].bType, p->aAttr[11].sValue,
                    p->aAttr[12].bType, p->aAttr[12].sValue,
                    p->aAttr[13].bType, p->aAttr[13].sValue,
                    p->aAttr[14].bType, p->aAttr[14].sValue,
                    p->aAttr[15].bType, p->aAttr[15].sValue);

            iUpdateLen += snprintf(szUpdate + iUpdateLen, sizeof(szUpdate) - iUpdateLen,
                    ", attrtype0=%d, attrvalue0=%d"
                    ", attrtype1=%d, attrvalue1=%d"
                    ", attrtype2=%d, attrvalue2=%d"
                    ", attrtype3=%d, attrvalue3=%d"
                    ", attrtype4=%d, attrvalue4=%d"
                    ", attrtype5=%d, attrvalue5=%d"
                    ", attrtype6=%d, attrvalue6=%d"
                    ", attrtype7=%d, attrvalue7=%d"
                    ", applytype0=%d, applyvalue0=%d"
                    ", applytype1=%d, applyvalue1=%d"
                    ", applytype2=%d, applyvalue2=%d"
                    ", applytype3=%d, applyvalue3=%d"
                    ", applytype4=%d, applyvalue4=%d"
                    ", applytype5=%d, applyvalue5=%d"
                    ", applytype6=%d, applyvalue6=%d"
                    ", applytype7=%d, applyvalue7=%d",
                    p->aAttr[0].bType, p->aAttr[0].sValue,
                    p->aAttr[1].bType, p->aAttr[1].sValue,
                    p->aAttr[2].bType, p->aAttr[2].sValue,
                    p->aAttr[3].bType, p->aAttr[3].sValue,
                    p->aAttr[4].bType, p->aAttr[4].sValue,
                    p->aAttr[5].bType, p->aAttr[5].sValue,
                    p->aAttr[6].bType, p->aAttr[6].sValue,
                    p->aAttr[7].bType, p->aAttr[7].sValue,
                    p->aAttr[8].bType, p->aAttr[8].sValue,
                    p->aAttr[9].bType, p->aAttr[9].sValue,
                    p->aAttr[10].bType, p->aAttr[10].sValue,
                    p->aAttr[11].bType, p->aAttr[11].sValue,
                    p->aAttr[12].bType, p->aAttr[12].sValue,
                    p->aAttr[13].bType, p->aAttr[13].sValue,
                    p->aAttr[14].bType, p->aAttr[14].sValue,
                    p->aAttr[15].bType, p->aAttr[15].sValue);
        }

        char szItemQuery[QUERY_MAX_LEN + QUERY_MAX_LEN];
        snprintf(szItemQuery, sizeof(szItemQuery), "REPLACE INTO item%s (%s) VALUES(%s)", GetTablePostfix(), szColumns, szValues);

        if (g_test_server)    
            sys_log(0, "ItemCache::Flush :REPLACE  (%s)", szItemQuery);

        CDBManager::instance().ReturnQuery(szItemQuery, QID_ITEM_SAVE, 0, NULL);

        //g_item_info.Add(p->vnum);
        ++g_item_count;
    }

    m_bNeedQuery = false;
}

And here is my ClientManager.cpp's query function:

Spoiler

void CClientManager::QUERY_ITEM_SAVE(CPeer * pkPeer, const char * c_pData)
{
    TPlayerItem * p = (TPlayerItem *) c_pData;

    // ΓΆ°νΈι Δ³½¬ΗΟΑφ ΎΚ°ν, Δ³½¬Ώ΅ ΐΦ΄ψ °Νµµ »©Ήφ·ΑΎί ΗΡ΄Ω.
    // auctionΐΊ ΐΜ ·ηΖ®Έ¦ ΕΈΑφ ΎΚΎΖΎί ΗΡ΄Ω. EnrollInAuctionΐ» ΕΈΎίΗΡ΄Ω.

    if (p->window == SAFEBOX || p->window == MALL)
    {
        CItemCache * c = GetItemCache(p->id);

        if (c)
        {
            TItemCacheSetPtrMap::iterator it = m_map_pkItemCacheSetPtr.find(c->Get()->owner);

            if (it != m_map_pkItemCacheSetPtr.end())
            {
                if (g_test_server)
                    sys_log(0, "ITEM_CACHE: safebox owner %u id %u", c->Get()->owner, c->Get()->id);

                it->second->erase(c);
            }

            m_map_itemCache.erase(p->id);

            delete c;
        }
        char szQuery[512];

        snprintf(szQuery, sizeof(szQuery), 
            "REPLACE INTO item%s (id, owner_id, window, pos, count, vnum, socket0, socket1, socket2, "
            "attrtype0, attrvalue0, "
            "attrtype1, attrvalue1, "
            "attrtype2, attrvalue2, "
            "attrtype3, attrvalue3, "
            "attrtype4, attrvalue4, "
            "attrtype5, attrvalue5, "
            "attrtype6, attrvalue6, "
            "attrtype7, attrvalue7, "
            "applytype0, applyvalue0, "
            "applytype1, applyvalue1, "
            "applytype2, applyvalue2, "
            "applytype3, applyvalue3, "
            "applytype4, applyvalue4, "
            "applytype5, applyvalue5, "
            "applytype6, applyvalue6, "
            "applytype7, applyvalue7)"
            "VALUES(%u, %u, %d, %d, %u, %u, %ld, %ld, %ld, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d)",
            GetTablePostfix(),
            p->id,
            p->owner,
            p->window,
            p->pos,
            p->count,
            p->vnum,
            p->alSockets[0],
            p->alSockets[1],
            p->alSockets[2],
            p->aAttr[0].bType, p->aAttr[0].sValue,
            p->aAttr[1].bType, p->aAttr[1].sValue,
            p->aAttr[2].bType, p->aAttr[2].sValue,
            p->aAttr[3].bType, p->aAttr[3].sValue,
            p->aAttr[4].bType, p->aAttr[4].sValue,
            p->aAttr[5].bType, p->aAttr[5].sValue,
            p->aAttr[6].bType, p->aAttr[6].sValue,
            p->aAttr[7].bType, p->aAttr[7].sValue,
            p->aAttr[8].bType, p->aAttr[8].sValue,
            p->aAttr[9].bType, p->aAttr[9].sValue,
            p->aAttr[10].bType, p->aAttr[10].sValue,
            p->aAttr[11].bType, p->aAttr[11].sValue,
            p->aAttr[12].bType, p->aAttr[12].sValue,
            p->aAttr[13].bType, p->aAttr[13].sValue,
            p->aAttr[14].bType, p->aAttr[14].sValue,
            p->aAttr[15].bType, p->aAttr[15].sValue);

        CDBManager::instance().ReturnQuery(szQuery, QID_ITEM_SAVE, pkPeer->GetHandle(), NULL);
    }
#ifdef __AUCTION__
    else if (p->window == AUCTION)
    {
        sys_err("invalid window. how can you enter this route?");
        return ;
    }
#endif
    else
    {
        if (g_test_server)
            sys_log(0, "QUERY_ITEM_SAVE => PutItemCache() owner %d id %d vnum %d ", p->owner, p->id, p->vnum);

        PutItemCache(p);
    }
}
 

Note that I have 6 normal and 2 special attributes available and imported Sash System... I need help please if you know the answer to this problem post it below I'd be so greatful :)

Link to comment
https://metin2.dev/topic/10789-help-safebox-query-problem/
Share on other sites

  • 3 months later...
  • Active+ Member

Well I got this enum:

Spoiler

enum EWindows
{
    RESERVED_WINDOW,
    INVENTORY,
    EQUIPMENT,
    SAFEBOX,
    MALL,
    DRAGON_SOUL_INVENTORY,
    BELT_INVENTORY,
#ifdef __AUCTION__
    AUCTION,
#endif
    GROUND
};

and in SQL I have these:

Spoiler

'INVENTORY','EQUIPMENT','SAFEBOX','MALL','DRAGON_SOUL_INVENTORY','BELT_INVENTORY'

There are some missing is that a thing?

Link to comment
https://metin2.dev/topic/10789-help-safebox-query-problem/#findComment-69173
Share on other sites

  • Premium
1 hour ago, Mind Rapist said:

Well I got this enum:

  Reveal hidden contents

enum EWindows
{
    RESERVED_WINDOW,
    INVENTORY,
    EQUIPMENT,
    SAFEBOX,
    MALL,
    DRAGON_SOUL_INVENTORY,
    BELT_INVENTORY,
#ifdef __AUCTION__
    AUCTION,
#endif
    GROUND
};

and in SQL I have these:

  Reveal hidden contents

'INVENTORY','EQUIPMENT','SAFEBOX','MALL','DRAGON_SOUL_INVENTORY','BELT_INVENTORY'

There are some missing is that a thing?

you can try enable general log in mysql, maybe it will log whole wrong query and we will be able to check what's wrong

Link to comment
https://metin2.dev/topic/10789-help-safebox-query-problem/#findComment-69178
Share on other sites

  • Active+ Member
2 hours ago, Istny said:

add into my.cnf

my.cnf file should be int /var/db/mysql by default in freebsd

 

  Hide contents

[mysqld]
general_log = on
general_log_file=/var/db/mysql/general.log

 

I did it and no general.log file created in /var/db/mysql.. I looked up for broken queries in other logs too, nothing found :S any other ideas please?

Link to comment
https://metin2.dev/topic/10789-help-safebox-query-problem/#findComment-69196
Share on other sites

  • Premium
22 minutes ago, Mind Rapist said:

I did it and no general.log file created in /var/db/mysql.. I looked up for broken queries in other logs too, nothing found :S any other ideas please?

create file manulaly, give chmod 666 and restart mysql

Link to comment
https://metin2.dev/topic/10789-help-safebox-query-problem/#findComment-69197
Share on other sites

  • Active+ Member

#FIXED! To everyone sees this post the fix is in ClientManager:

Search:

Spoiler

"REPLACE INTO item%s (id, owner_id, window, pos, count, vnum, socket0, socket1, socket2, "

and find (just 2 lines above):

Spoiler

char szQuery[512]

now change it to:

Spoiler

char szQuery[QUERY_MAX_LEN];

Happy coding :D

  • Love 2
Link to comment
https://metin2.dev/topic/10789-help-safebox-query-problem/#findComment-69198
Share on other sites

Don't use any images from : imgur, turkmmop, freakgamers, inforge, hizliresim... Or your content will be deleted without notice...
Use : https://metin2.download/media/add/

Please use https://metin2.download/ when uploading files smaller than 100MB, otherwise the approval will take longer due to manual upload.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...

Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.