Show
Ignore:
Timestamp:
11/19/08 13:43:02 (17 years ago)
Author:
yumileroy
Message:

[svn] * Avoid access to bag item prototype for getting bag size, use related item update field instead as more fast source.
* Better check client inventory pos data received in some client packets to skip invalid cases.
* Removed some unnecessary database queries.
* Make guid lookup for adding ignore async.
* Added two parameter versions of the AsyncQuery? function
* Make queries for adding friends async. - Hunuza
* Replace some PQuery() calls with more simple Query() - Hunuza
* Mark spell as executed instead of deleteable to solve crash.
*** Source mangos.

**Its a big commit. so test with care... or without care.... whatever floats your boat.

Original author: KingPin?
Date: 2008-11-05 20:10:19-06:00

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/game/Level3.cpp

    r169 r173  
    20052005    sLog.outDetail(GetTrinityString(LANG_ADDITEMSET), itemsetId); 
    20062006 
    2007     QueryResult *result = WorldDatabase.PQuery("SELECT entry FROM item_template WHERE itemset = %u",itemsetId); 
    2008  
    2009     if(!result) 
     2007    bool found = false; 
     2008    for (uint32 id = 0; id < sItemStorage.MaxEntry; id++) 
     2009    { 
     2010        ItemPrototype const *pProto = sItemStorage.LookupEntry<ItemPrototype>(id); 
     2011        if (!pProto) 
     2012            continue; 
     2013 
     2014        if (pProto->ItemSet == itemsetId) 
     2015        { 
     2016            found = true; 
     2017            ItemPosCountVec dest; 
     2018            uint8 msg = plTarget->CanStoreNewItem( NULL_BAG, NULL_SLOT, dest, pProto->ItemId, 1 ); 
     2019            if (msg == EQUIP_ERR_OK) 
     2020            { 
     2021                Item* item = plTarget->StoreNewItem( dest, pProto->ItemId, true); 
     2022                // remove binding (let GM give it to another player later) 
     2023                if (pl==plTarget) 
     2024                    item->SetBinding( false ); 
     2025 
     2026            pl->SendNewItem(item,1,false,true); 
     2027            if (pl!=plTarget) 
     2028                plTarget->SendNewItem(item,1,true,false); 
     2029            } 
     2030            else 
     2031            { 
     2032                pl->SendEquipError( msg, NULL, NULL ); 
     2033                PSendSysMessage(LANG_ITEM_CANNOT_CREATE, pProto->ItemId, 1); 
     2034            } 
     2035        } 
     2036    } 
     2037 
     2038    if (!found) 
    20102039    { 
    20112040        PSendSysMessage(LANG_NO_ITEMS_FROM_ITEMSET_FOUND,itemsetId); 
     
    20142043        return false; 
    20152044    } 
    2016  
    2017     do 
    2018     { 
    2019         Field *fields = result->Fetch(); 
    2020         uint32 itemId = fields[0].GetUInt32(); 
    2021  
    2022         ItemPosCountVec dest; 
    2023         uint8 msg = plTarget->CanStoreNewItem( NULL_BAG, NULL_SLOT, dest, itemId, 1 ); 
    2024         if( msg == EQUIP_ERR_OK ) 
    2025         { 
    2026             Item* item = plTarget->StoreNewItem( dest, itemId, true); 
    2027  
    2028             // remove binding (let GM give it to another player later) 
    2029             if(pl==plTarget) 
    2030                 item->SetBinding( false ); 
    2031  
    2032             pl->SendNewItem(item,1,false,true); 
    2033             if(pl!=plTarget) 
    2034                 plTarget->SendNewItem(item,1,true,false); 
    2035         } 
    2036         else 
    2037         { 
    2038             pl->SendEquipError( msg, NULL, NULL ); 
    2039             PSendSysMessage(LANG_ITEM_CANNOT_CREATE, itemId, 1); 
    2040         } 
    2041  
    2042     }while( result->NextRow() ); 
    2043  
    2044     delete result; 
    2045  
    20462045    return true; 
    20472046} 
     
    47664765 
    47674766    // check item starting quest (it can work incorrectly if added without item in inventory) 
    4768     QueryResult *result = WorldDatabase.PQuery("SELECT entry FROM item_template WHERE startquest = '%u' LIMIT 1",entry); 
    4769     if(result) 
    4770     { 
    4771         Field* fields = result->Fetch(); 
    4772         uint32 item_id = fields[0].GetUInt32(); 
    4773         delete result; 
    4774  
    4775         PSendSysMessage(LANG_COMMAND_QUEST_STARTFROMITEM, entry,item_id); 
    4776         SetSentErrorMessage(true); 
    4777         return false; 
     4767    for (uint32 id = 0; id < sItemStorage.MaxEntry; id++) 
     4768    { 
     4769        ItemPrototype const *pProto = sItemStorage.LookupEntry<ItemPrototype>(id); 
     4770        if (!pProto) 
     4771            continue; 
     4772 
     4773        if (pProto->StartQuest == entry) 
     4774        { 
     4775            PSendSysMessage(LANG_COMMAND_QUEST_STARTFROMITEM, entry, pProto->ItemId); 
     4776            SetSentErrorMessage(true); 
     4777            return false; 
     4778        } 
    47784779    } 
    47794780