Jump to content
  • 0

db problem c++


bumxd

Question

  • Answers 28
  • Created
  • Last Reply

Top Posters For This Question

Top Posters For This Question

Recommended Posts

  • 0

Change Antiflag in the Database.

no in this problem.. i have 4 in antiflag.. when it`s drop with 50011 does not add up item in 200.. but on 10x.. but when i click moust 10x for other 10x = 20x..antiflag-work

Link to comment
  • 0
  • VIP
Group    gold_box            
{                
    Vnum    50011        
    1    71084    1    1
    2    71085    1    1
    3    70024    1    1
    4    25040    1    1
}

??

If code.isTurkisch:
    self.suicide();
elif code.isPoland:
   self.giveHate()

 

Link to comment
  • 0

 

You use this?

 

 

This is bugged on stack item

yes this.. but how fix stack?

 

 

bool CClientManager::InitializeItemTable()
{
    char query[4096];
    snprintf(query, sizeof(query),
        "SELECT vnum, vnum_range, name, %s, type, subtype, gold, shop_buy_price, weight, size, flag, wearflag, "
        "antiflag, immuneflag+0, refined_vnum, refine_set, magic_pct, socket_pct, addon_type, "
        "limittype0, limitvalue0, limittype1, limitvalue1, "
        "applytype0, applyvalue0, applytype1, applyvalue1, applytype2, applyvalue2, "
        "value0, value1, value2, value3, value4, value5 "
        "FROM item_proto%s ORDER BY vnum",
        g_stLocaleNameColumn.c_str(), GetTablePostfix());


    std::auto_ptr<SQLMsg> pkMsg(CDBManager::instance().DirectQuery(query));
    SQLResult * pRes = pkMsg->Get();


    if (!pRes->uiNumRows)
    {
        sys_err("Could not load item_proto. No results!");
        return false;
    }


    sys_log(0, "ITEM_PROTO loading...");


    if (!m_vec_itemTable.empty())
    {
        sys_log(0, "RELOAD: item_proto");
        m_vec_itemTable.clear();
        m_map_itemTableByVnum.clear();
    }


    m_vec_itemTable.resize(pRes->uiNumRows);
    memset(&m_vec_itemTable[0], 0, sizeof(TItemTable) * m_vec_itemTable.size());
    TItemTable * item_table = &m_vec_itemTable[0];


    MYSQL_ROW data;
    int col;


    while ((data = mysql_fetch_row(pRes->pSQLResult)))
    {
        col = 0;


        str_to_number(item_table->dwVnum, data[col++]);
        str_to_number(item_table->dwVnumRange, data[col++]);
        strlcpy(item_table->szName, data[col++], sizeof(item_table->szName));
        strlcpy(item_table->szLocaleName, data[col++], sizeof(item_table->szLocaleName));
        str_to_number(item_table->bType, data[col++]);
        str_to_number(item_table->bSubType, data[col++]);
        str_to_number(item_table->dwGold, data[col++]);
        str_to_number(item_table->dwShopBuyPrice, data[col++]);
        str_to_number(item_table->bWeight, data[col++]);
        str_to_number(item_table->bSize, data[col++]);
        str_to_number(item_table->dwFlags, data[col++]);
        str_to_number(item_table->dwWearFlags, data[col++]);
        str_to_number(item_table->dwAntiFlags, data[col++]);
        str_to_number(item_table->dwImmuneFlag, data[col++]);
        str_to_number(item_table->dwRefinedVnum, data[col++]);
        str_to_number(item_table->wRefineSet, data[col++]);
        str_to_number(item_table->bAlterToMagicItemPct, data[col++]);
        str_to_number(item_table->bGainSocketPct, data[col++]);
        str_to_number(item_table->sAddonType, data[col++]);


        item_table->cLimitRealTimeFirstUseIndex = -1;
        item_table->cLimitTimerBasedOnWearIndex = -1;


        int i;
        for (i = 0; i < ITEM_LIMIT_MAX_NUM; ++i)
        {
            str_to_number(item_table->aLimits[i].bType, data[col++]);
            str_to_number(item_table->aLimits[i].lValue, data[col++]);


            if (LIMIT_REAL_TIME_START_FIRST_USE == item_table->aLimits[i].bType)
                item_table->cLimitRealTimeFirstUseIndex = (char)i;


            if (LIMIT_TIMER_BASED_ON_WEAR == item_table->aLimits[i].bType)
                item_table->cLimitTimerBasedOnWearIndex = (char)i;
        }


        for (i = 0; i < ITEM_APPLY_MAX_NUM; ++i)
        {
            str_to_number(item_table->aApplies[i].bType, data[col++]);
            str_to_number(item_table->aApplies[i].lValue, data[col++]);
        }


        for (i = 0; i < ITEM_VALUES_MAX_NUM; ++i)
            str_to_number(item_table->alValues[i], data[col++]);


        sys_log(1, "ITEM: #%-5lu %-24s %-24s VAL: %ld %ld %ld %ld %ld %ld WEAR %lu ANTI %lu IMMUNE %lu REFINE %lu REFINE_SET %u MAGIC_PCT %u",
                item_table->dwVnum,item_table->szName,item_table->szLocaleName,
                item_table->alValues[0],item_table->alValues[1],item_table->alValues[2],
                item_table->alValues[3],item_table->alValues[4],item_table->alValues[5],
                item_table->dwWearFlags,item_table->dwAntiFlags,item_table->dwImmuneFlag,
                item_table->dwRefinedVnum,item_table->wRefineSet,item_table->bAlterToMagicItemPct);


        m_map_itemTableByVnum.insert(std::map<DWORD, TItemTable *>::value_type(item_table->dwVnum, item_table));
        ++item_table;
    }


    sort(m_vec_itemTable.begin(), m_vec_itemTable.end(), FCompareVnum());
    sys_log(0, "CClientManager::InitializeMobTable:: %d items loaded.n", m_vec_itemTable.size());
    return true;
}
Link to comment
  • 0

 

 

You use this?

 

 

This is bugged on stack item

yes this.. but how fix stack?

 

 

bool CClientManager::InitializeItemTable()
{
    char query[4096];
    snprintf(query, sizeof(query),
        "SELECT vnum, vnum_range, name, %s, type, subtype, gold, shop_buy_price, weight, size, flag, wearflag, "
        "antiflag, immuneflag+0, refined_vnum, refine_set, magic_pct, socket_pct, addon_type, "
        "limittype0, limitvalue0, limittype1, limitvalue1, "
        "applytype0, applyvalue0, applytype1, applyvalue1, applytype2, applyvalue2, "
        "value0, value1, value2, value3, value4, value5 "
        "FROM item_proto%s ORDER BY vnum",
        g_stLocaleNameColumn.c_str(), GetTablePostfix());


    std::auto_ptr<SQLMsg> pkMsg(CDBManager::instance().DirectQuery(query));
    SQLResult * pRes = pkMsg->Get();


    if (!pRes->uiNumRows)
    {
        sys_err("Could not load item_proto. No results!");
        return false;
    }


    sys_log(0, "ITEM_PROTO loading...");


    if (!m_vec_itemTable.empty())
    {
        sys_log(0, "RELOAD: item_proto");
        m_vec_itemTable.clear();
        m_map_itemTableByVnum.clear();
    }


    m_vec_itemTable.resize(pRes->uiNumRows);
    memset(&m_vec_itemTable[0], 0, sizeof(TItemTable) * m_vec_itemTable.size());
    TItemTable * item_table = &m_vec_itemTable[0];


    MYSQL_ROW data;
    int col;


    while ((data = mysql_fetch_row(pRes->pSQLResult)))
    {
        col = 0;


        str_to_number(item_table->dwVnum, data[col++]);
        str_to_number(item_table->dwVnumRange, data[col++]);
        strlcpy(item_table->szName, data[col++], sizeof(item_table->szName));
        strlcpy(item_table->szLocaleName, data[col++], sizeof(item_table->szLocaleName));
        str_to_number(item_table->bType, data[col++]);
        str_to_number(item_table->bSubType, data[col++]);
        str_to_number(item_table->dwGold, data[col++]);
        str_to_number(item_table->dwShopBuyPrice, data[col++]);
        str_to_number(item_table->bWeight, data[col++]);
        str_to_number(item_table->bSize, data[col++]);
        str_to_number(item_table->dwFlags, data[col++]);
        str_to_number(item_table->dwWearFlags, data[col++]);
        str_to_number(item_table->dwAntiFlags, data[col++]);
        str_to_number(item_table->dwImmuneFlag, data[col++]);
        str_to_number(item_table->dwRefinedVnum, data[col++]);
        str_to_number(item_table->wRefineSet, data[col++]);
        str_to_number(item_table->bAlterToMagicItemPct, data[col++]);
        str_to_number(item_table->bGainSocketPct, data[col++]);
        str_to_number(item_table->sAddonType, data[col++]);


        item_table->cLimitRealTimeFirstUseIndex = -1;
        item_table->cLimitTimerBasedOnWearIndex = -1;


        int i;
        for (i = 0; i < ITEM_LIMIT_MAX_NUM; ++i)
        {
            str_to_number(item_table->aLimits[i].bType, data[col++]);
            str_to_number(item_table->aLimits[i].lValue, data[col++]);


            if (LIMIT_REAL_TIME_START_FIRST_USE == item_table->aLimits[i].bType)
                item_table->cLimitRealTimeFirstUseIndex = (char)i;


            if (LIMIT_TIMER_BASED_ON_WEAR == item_table->aLimits[i].bType)
                item_table->cLimitTimerBasedOnWearIndex = (char)i;
        }


        for (i = 0; i < ITEM_APPLY_MAX_NUM; ++i)
        {
            str_to_number(item_table->aApplies[i].bType, data[col++]);
            str_to_number(item_table->aApplies[i].lValue, data[col++]);
        }


        for (i = 0; i < ITEM_VALUES_MAX_NUM; ++i)
            str_to_number(item_table->alValues[i], data[col++]);


        sys_log(1, "ITEM: #%-5lu %-24s %-24s VAL: %ld %ld %ld %ld %ld %ld WEAR %lu ANTI %lu IMMUNE %lu REFINE %lu REFINE_SET %u MAGIC_PCT %u",
                item_table->dwVnum,item_table->szName,item_table->szLocaleName,
                item_table->alValues[0],item_table->alValues[1],item_table->alValues[2],
                item_table->alValues[3],item_table->alValues[4],item_table->alValues[5],
                item_table->dwWearFlags,item_table->dwAntiFlags,item_table->dwImmuneFlag,
                item_table->dwRefinedVnum,item_table->wRefineSet,item_table->bAlterToMagicItemPct);


        m_map_itemTableByVnum.insert(std::map<DWORD, TItemTable *>::value_type(item_table->dwVnum, item_table));
        ++item_table;
    }


    sort(m_vec_itemTable.begin(), m_vec_itemTable.end(), FCompareVnum());
    sys_log(0, "CClientManager::InitializeMobTable:: %d items loaded.n", m_vec_itemTable.size());
    return true;
}

 

this without txt db?

Link to comment
  • 0

you can fix it on me function?

bool CClientManager::InitializeItemTable()

{

/* I needed to make 2 mysql queries because with only 1 there was always a stackoverflow....

  * However^^ It works so idc :)

*/

const char * c_ist_doof = "SELECT refined_vnum, refine_set, magic_pct FROM item_proto ORDER BY vnum";

SQLMsg* sqlMsg1 = CDBManager::instance().DirectQuery(c_ist_doof);

 

const char * query = "SELECT vnum, name, locale_name, type, subtype, weight, size, antiflag+0,"

"flag+0, wearflag+0, immuneflag+0, gold, shop_buy_price, refined_vnum,"

"refine_set, magic_pct, limittype0, limitvalue0, limittype1, limitvalue1,"

"applytype0, applyvalue0, applytype1, applyvalue1, applytype2, applyvalue2,"

"value0, value1, value2, value3, value4, value5, socket0, socket1, socket2,"

"socket3, socket4, socket5, specular, socket_pct, addon_type FROM item_proto ORDER BY vnum";

SQLMsg* sqlMsg = CDBManager::instance().DirectQuery(query);

 

MYSQL_RES* pRes1 = sqlMsg1->vec_pkResult[0]->pSQLResult;

MYSQL_RES* pRes = sqlMsg->vec_pkResult[0]->pSQLResult;

if (sizeof(pRes) <= 1 || sizeof(pRes1) <= 1)

{

  sys_err("Kein Ergebnis aus Item_Proto!");

  return false;

}

if (!m_vec_itemTable.empty()) {

  sys_log(0, "Reloading Item_Proto");

  m_vec_itemTable.clear();

}

MYSQL_ROW data;

MYSQL_ROW data1;

while ((data = mysql_fetch_row(pRes)) && (data1 = mysql_fetch_row(pRes1)))

{

  TItemTable t;

  TItemTable baum;

 

  str_to_number(baum.dwRefinedVnum, data1[0]);

  str_to_number(baum.wRefineSet, data1[1]);

  str_to_number(baum.bAlterToMagicItemPct, data1[2]);

 

  str_to_number(t.dwVnum, data[0]);  

  strlcpy(t.szName, data[1], sizeof(t.szName));

  strlcpy(t.szLocaleName, data[2], sizeof(t.szLocaleName));

  str_to_number(t.bType, data[3]);

  str_to_number(t.bSubType, data[4]);

  str_to_number(t.bWeight, data[5]);

  str_to_number(t.bSize, data[6]);

  str_to_number(t.dwAntiFlags, data[7]);

  str_to_number(t.dwFlags, data[8]);

  str_to_number(t.dwWearFlags, data[9]);

  str_to_number(t.dwImmuneFlag, data[10]);

  str_to_number(t.dwGold, data[11]);

  str_to_number(t.dwShopBuyPrice,data[12]);

  str_to_number(t.aLimits[0].bType, data[16]);

  str_to_number(t.aLimits[0].lValue, data[17]);

  str_to_number(t.aLimits[1].bType, data[18]);

  str_to_number(t.aLimits[1].lValue, data[19]);

  str_to_number(t.aApplies[0].bType, data[20]);

  str_to_number(t.aApplies[0].lValue, data[21]);

  str_to_number(t.aApplies[1].bType, data[22]);

  str_to_number(t.aApplies[1].lValue, data[23]);

  str_to_number(t.aApplies[2].bType, data[24]);

  str_to_number(t.aApplies[2].lValue, data[25]);

  str_to_number(t.alValues[0], data[26]);

  str_to_number(t.alValues[1], data[27]);

  str_to_number(t.alValues[2], data[28]);

  str_to_number(t.alValues[3], data[29]);

  str_to_number(t.alValues[4], data[30]);

  str_to_number(t.alValues[5], data[31]);

  str_to_number(t.alSockets[0], data[32]);

  str_to_number(t.alSockets[1], data[33]);

  str_to_number(t.alSockets[2], data[34]);

  str_to_number(t.alSockets[3], data[35]);

  str_to_number(t.alSockets[4], data[36]);

  str_to_number(t.alSockets[5], data[37]);

  str_to_number(t.bSpecular, data[38]);

  str_to_number(t.bGainSocketPct, data[39]);

  str_to_number(t.sAddonType, data[40]); 

  t.cLimitRealTimeFirstUseIndex = -1;

  t.cLimitTimerBasedOnWearIndex = -1;

  for (int i = 0; i < ITEM_LIMIT_MAX_NUM; ++i) {

   if (LIMIT_REAL_TIME_START_FIRST_USE == t.aLimits.bType)

    t.cLimitRealTimeFirstUseIndex = (char) i;

   if (LIMIT_TIMER_BASED_ON_WEAR == t.aLimits.bType)

   t.cLimitTimerBasedOnWearIndex = (char) i;

  }

 

  // Conversion

  t.dwRefinedVnum = baum.dwRefinedVnum;

  t.wRefineSet = baum.wRefineSet;

  t.bAlterToMagicItemPct = baum.bAlterToMagicItemPct;

   

  //Debug

  //sys_log(0,"%d %d %d",t.dwRefinedVnum, t.wRefineSet, t.bAlterToMagicItemPct);

  //sys_log(0,"%d %d %d",baum.dwRefinedVnum, baum.wRefineSet, baum.bAlterToMagicItemPct);

 

  m_vec_itemTable.push_back(t);

}  

m_map_itemTableByVnum.clear();

__gnu_cxx::__normal_iterator<SItemTable*, std::vector<SItemTable, std::allocator<SItemTable> > > it = m_vec_itemTable.begin();

while (it != m_vec_itemTable.end())

{

  TItemTable * item_table = &(*(it++));

  sys_log(0,"Item %s geladen", item_table->szLocaleName); 

  m_map_itemTableByVnum.insert(std::map<DWORD, TItemTable *>::value_type(item_table->dwVnum, item_table));

}

sort(m_vec_itemTable.begin(), m_vec_itemTable.end(), FCompareVnum());

return true;

}

Link to comment
  • 0

 

 

You use this?

 

 

This is bugged on stack item

yes this.. but how fix stack?

 

 

bool CClientManager::InitializeItemTable()
{
    char query[4096];
    snprintf(query, sizeof(query),
        "SELECT vnum, vnum_range, name, %s, type, subtype, gold, shop_buy_price, weight, size, flag, wearflag, "
        "antiflag, immuneflag+0, refined_vnum, refine_set, magic_pct, socket_pct, addon_type, "
        "limittype0, limitvalue0, limittype1, limitvalue1, "
        "applytype0, applyvalue0, applytype1, applyvalue1, applytype2, applyvalue2, "
        "value0, value1, value2, value3, value4, value5 "
        "FROM item_proto%s ORDER BY vnum",
        g_stLocaleNameColumn.c_str(), GetTablePostfix());


    std::auto_ptr<SQLMsg> pkMsg(CDBManager::instance().DirectQuery(query));
    SQLResult * pRes = pkMsg->Get();


    if (!pRes->uiNumRows)
    {
        sys_err("Could not load item_proto. No results!");
        return false;
    }


    sys_log(0, "ITEM_PROTO loading...");


    if (!m_vec_itemTable.empty())
    {
        sys_log(0, "RELOAD: item_proto");
        m_vec_itemTable.clear();
        m_map_itemTableByVnum.clear();
    }


    m_vec_itemTable.resize(pRes->uiNumRows);
    memset(&m_vec_itemTable[0], 0, sizeof(TItemTable) * m_vec_itemTable.size());
    TItemTable * item_table = &m_vec_itemTable[0];


    MYSQL_ROW data;
    int col;


    while ((data = mysql_fetch_row(pRes->pSQLResult)))
    {
        col = 0;


        str_to_number(item_table->dwVnum, data[col++]);
        str_to_number(item_table->dwVnumRange, data[col++]);
        strlcpy(item_table->szName, data[col++], sizeof(item_table->szName));
        strlcpy(item_table->szLocaleName, data[col++], sizeof(item_table->szLocaleName));
        str_to_number(item_table->bType, data[col++]);
        str_to_number(item_table->bSubType, data[col++]);
        str_to_number(item_table->dwGold, data[col++]);
        str_to_number(item_table->dwShopBuyPrice, data[col++]);
        str_to_number(item_table->bWeight, data[col++]);
        str_to_number(item_table->bSize, data[col++]);
        str_to_number(item_table->dwFlags, data[col++]);
        str_to_number(item_table->dwWearFlags, data[col++]);
        str_to_number(item_table->dwAntiFlags, data[col++]);
        str_to_number(item_table->dwImmuneFlag, data[col++]);
        str_to_number(item_table->dwRefinedVnum, data[col++]);
        str_to_number(item_table->wRefineSet, data[col++]);
        str_to_number(item_table->bAlterToMagicItemPct, data[col++]);
        str_to_number(item_table->bGainSocketPct, data[col++]);
        str_to_number(item_table->sAddonType, data[col++]);


        item_table->cLimitRealTimeFirstUseIndex = -1;
        item_table->cLimitTimerBasedOnWearIndex = -1;


        int i;
        for (i = 0; i < ITEM_LIMIT_MAX_NUM; ++i)
        {
            str_to_number(item_table->aLimits[i].bType, data[col++]);
            str_to_number(item_table->aLimits[i].lValue, data[col++]);


            if (LIMIT_REAL_TIME_START_FIRST_USE == item_table->aLimits[i].bType)
                item_table->cLimitRealTimeFirstUseIndex = (char)i;


            if (LIMIT_TIMER_BASED_ON_WEAR == item_table->aLimits[i].bType)
                item_table->cLimitTimerBasedOnWearIndex = (char)i;
        }


        for (i = 0; i < ITEM_APPLY_MAX_NUM; ++i)
        {
            str_to_number(item_table->aApplies[i].bType, data[col++]);
            str_to_number(item_table->aApplies[i].lValue, data[col++]);
        }


        for (i = 0; i < ITEM_VALUES_MAX_NUM; ++i)
            str_to_number(item_table->alValues[i], data[col++]);


        sys_log(1, "ITEM: #%-5lu %-24s %-24s VAL: %ld %ld %ld %ld %ld %ld WEAR %lu ANTI %lu IMMUNE %lu REFINE %lu REFINE_SET %u MAGIC_PCT %u",
                item_table->dwVnum,item_table->szName,item_table->szLocaleName,
                item_table->alValues[0],item_table->alValues[1],item_table->alValues[2],
                item_table->alValues[3],item_table->alValues[4],item_table->alValues[5],
                item_table->dwWearFlags,item_table->dwAntiFlags,item_table->dwImmuneFlag,
                item_table->dwRefinedVnum,item_table->wRefineSet,item_table->bAlterToMagicItemPct);


        m_map_itemTableByVnum.insert(std::map<DWORD, TItemTable *>::value_type(item_table->dwVnum, item_table));
        ++item_table;
    }


    sort(m_vec_itemTable.begin(), m_vec_itemTable.end(), FCompareVnum());
    sys_log(0, "CClientManager::InitializeMobTable:: %d items loaded.n", m_vec_itemTable.size());
    return true;
}

 

with your code i haven`t connect with server..item proto don`t load

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

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.