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

[svn] * Improve some arena team related DB access
* Cache GM tickets on server startup.
* Remove unused src/game/HateMatrix.h and references.
* Better check client inventory pos data received in some client packets to
skip invalid cases

Original author: KingPin?
Date: 2008-11-10 09:04:23-06:00

Files:
1 modified

Legend:

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

    r203 r207  
    40444044        if(LostDurability>0) 
    40454045        { 
    4046             ItemPrototype const *ditemProto = sItemStorage.LookupEntry<ItemPrototype>(item->GetEntry()); 
    4047             if(!ditemProto) 
    4048             { 
    4049                 sLog.outError("ERROR: RepairDurability: Unknown item id %u", ditemProto); 
    4050                 return TotalCost; 
    4051             } 
     4046            ItemPrototype const *ditemProto = item->GetProto(); 
    40524047 
    40534048            DurabilityCostsEntry const *dcost = sDurabilityCostsStore.LookupEntry(ditemProto->ItemLevel); 
    40544049            if(!dcost) 
    40554050            { 
    4056                 sLog.outError("ERROR: RepairDurability: Wrong item lvl %u", dcost); 
     4051                sLog.outError("ERROR: RepairDurability: Wrong item lvl %u", ditemProto->ItemLevel); 
    40574052                return TotalCost; 
    40584053            } 
    40594054 
    4060             DurabilityQualityEntry const *dQualitymodEntry = sDurabilityQualityStore.LookupEntry((ditemProto->Quality+1)*2); 
     4055            uint32 dQualitymodEntryId = (ditemProto->Quality+1)*2; 
     4056            DurabilityQualityEntry const *dQualitymodEntry = sDurabilityQualityStore.LookupEntry(dQualitymodEntryId); 
    40614057            if(!dQualitymodEntry) 
    40624058            { 
    4063                 sLog.outError("ERROR: RepairDurability: Wrong dQualityModEntry %u", dQualitymodEntry); 
     4059                sLog.outError("ERROR: RepairDurability: Wrong dQualityModEntry %u", dQualitymodEntryId); 
    40644060                return TotalCost; 
    40654061            } 
     
    61576153uint32 Player::GetArenaTeamIdFromDB(uint64 guid, uint8 type) 
    61586154{ 
    6159     QueryResult *result = CharacterDatabase.PQuery("SELECT arenateamid FROM arena_team_member WHERE guid='%u'", GUID_LOPART(guid)); 
    6160     if(result) 
    6161     { 
    6162         bool found = false; 
    6163         // init id to find the type of the arenateam 
    6164         uint32 id = (*result)[0].GetUInt32(); 
    6165         do 
    6166         { 
    6167             QueryResult *result2 = CharacterDatabase.PQuery("SELECT type FROM arena_team WHERE arenateamid='%u'", id); 
    6168             if(result2) 
    6169             { 
    6170                 uint8 dbtype = (*result2)[0].GetUInt32(); 
    6171                 delete result2; 
    6172                 if(dbtype == type) 
    6173                 { 
    6174                     // if the type matches, we've found the id 
    6175                     found = true; 
    6176                     break; 
    6177                 } 
    6178             } 
    6179         } while(result->NextRow()); 
    6180         delete result; 
    6181         if(found) return id; 
    6182     } 
    6183     // no arenateam for the specified guid, return 0 
    6184     return 0; 
     6155    QueryResult *result = CharacterDatabase.PQuery("SELECT arena_team_member.arenateamid FROM arena_team_member JOIN arena_team ON arena_team_member.arenateamid = arena_team.arenateamid WHERE guid='%u' AND type='%u' LIMIT 1", GUID_LOPART(guid), type); 
     6156    if(!result) 
     6157        return 0; 
     6158 
     6159    return (*result)[0].GetUInt32(); 
    61856160} 
    61866161 
     
    85738548    if( bag == INVENTORY_SLOT_BAG_0 && ( slot >= BANK_SLOT_BAG_START && slot < BANK_SLOT_BAG_END ) ) 
    85748549        return true; 
     8550    return false; 
     8551} 
     8552 
     8553bool Player::IsValidPos( uint8 bag, uint8 slot ) 
     8554{ 
     8555    // post selected 
     8556    if(bag == NULL_BAG) 
     8557        return true; 
     8558 
     8559    if (bag == INVENTORY_SLOT_BAG_0) 
     8560    { 
     8561        // any post selected 
     8562        if (slot == NULL_SLOT) 
     8563            return true; 
     8564 
     8565        // equipment 
     8566        if (slot < EQUIPMENT_SLOT_END) 
     8567            return true; 
     8568 
     8569        // bag equip slots 
     8570        if (slot >= INVENTORY_SLOT_BAG_START && slot < INVENTORY_SLOT_BAG_END) 
     8571            return true; 
     8572 
     8573        // backpack slots 
     8574        if (slot >= INVENTORY_SLOT_ITEM_START && slot < INVENTORY_SLOT_ITEM_END) 
     8575            return true; 
     8576 
     8577        // keyring slots 
     8578        if (slot >= KEYRING_SLOT_START && slot < KEYRING_SLOT_END) 
     8579            return true; 
     8580 
     8581        // bank main slots 
     8582        if (slot >= BANK_SLOT_ITEM_START && slot < BANK_SLOT_ITEM_END) 
     8583            return true; 
     8584 
     8585        // bank bag slots 
     8586        if (slot >= BANK_SLOT_BAG_START && slot < BANK_SLOT_BAG_END) 
     8587            return true; 
     8588 
     8589        return false; 
     8590    } 
     8591 
     8592    // bag content slots 
     8593    if (bag >= INVENTORY_SLOT_BAG_START && bag < INVENTORY_SLOT_BAG_END) 
     8594    { 
     8595        Bag* pBag = (Bag*)GetItemByPos (INVENTORY_SLOT_BAG_0, bag); 
     8596        if(!pBag) 
     8597            return false; 
     8598 
     8599        // any post selected 
     8600        if (slot == NULL_SLOT) 
     8601            return true; 
     8602 
     8603        return slot < pBag->GetBagSize(); 
     8604    } 
     8605 
     8606    // bank bag content slots 
     8607    if( bag >= BANK_SLOT_BAG_START && bag < BANK_SLOT_BAG_END ) 
     8608    { 
     8609        Bag* pBag = (Bag*)GetItemByPos (INVENTORY_SLOT_BAG_0, bag); 
     8610        if(!pBag) 
     8611            return false; 
     8612 
     8613        // any post selected 
     8614        if (slot == NULL_SLOT) 
     8615            return true; 
     8616 
     8617        return slot < pBag->GetBagSize(); 
     8618    } 
     8619 
     8620    // where this? 
    85758621    return false; 
    85768622}