Changeset 177 for trunk/src/game/Player.cpp
- Timestamp:
- 11/19/08 13:43:30 (17 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/game/Player.cpp
r174 r177 3926 3926 for(int i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; i++) 3927 3927 if(Bag* pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, i )) 3928 if(ItemPrototype const *pBagProto = pBag->GetProto()) 3929 for(uint32 j = 0; j < pBagProto->ContainerSlots; j++) 3930 if(Item* pItem = GetItemByPos( i, j )) 3931 DurabilityLoss(pItem,percent); 3928 for(uint32 j = 0; j < pBag->GetBagSize(); j++) 3929 if(Item* pItem = GetItemByPos( i, j )) 3930 DurabilityLoss(pItem,percent); 3932 3931 } 3933 3932 } … … 3971 3970 for(int i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; i++) 3972 3971 if(Bag* pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, i )) 3973 if(ItemPrototype const *pBagProto = pBag->GetProto()) 3974 for(uint32 j = 0; j < pBagProto->ContainerSlots; j++) 3975 if(Item* pItem = GetItemByPos( i, j )) 3976 DurabilityPointsLoss(pItem,points); 3972 for(uint32 j = 0; j < pBag->GetBagSize(); j++) 3973 if(Item* pItem = GetItemByPos( i, j )) 3974 DurabilityPointsLoss(pItem,points); 3977 3975 } 3978 3976 } … … 8327 8325 } 8328 8326 Bag *pBag; 8329 ItemPrototype const *pBagProto;8330 8327 for(int i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; i++) 8331 8328 { … … 8333 8330 if( pBag ) 8334 8331 { 8335 pBagProto = pBag->GetProto();8336 if( pBagProto )8337 {8338 for(uint32 j = 0; j < pBagProto->ContainerSlots; j++)8332 for(uint32 j = 0; j < pBag->GetBagSize(); j++) 8333 { 8334 pItem = GetItemByPos( i, j ); 8335 if( pItem && pItem->GetEntry() == item ) 8339 8336 { 8340 pItem = GetItemByPos( i, j ); 8341 if( pItem && pItem->GetEntry() == item ) 8342 { 8343 tempcount += pItem->GetCount(); 8344 if( tempcount >= count ) 8345 return EQUIP_ERR_OK; 8346 } 8337 tempcount += pItem->GetCount(); 8338 if( tempcount >= count ) 8339 return EQUIP_ERR_OK; 8347 8340 } 8348 8341 } … … 8435 8428 if( pBag ) 8436 8429 { 8437 ItemPrototype const *pBagProto = pBag->GetProto(); 8438 if( pBagProto ) 8439 { 8440 for(uint32 j = 0; j < pBagProto->ContainerSlots; j++) 8441 { 8442 Item* pItem = pBag->GetItemByPos( j ); 8443 if( pItem && pItem->GetGUID() == guid ) 8444 return pItem; 8445 } 8430 for(uint32 j = 0; j < pBag->GetBagSize(); j++) 8431 { 8432 Item* pItem = pBag->GetItemByPos( j ); 8433 if( pItem && pItem->GetGUID() == guid ) 8434 return pItem; 8446 8435 } 8447 8436 } … … 8452 8441 if( pBag ) 8453 8442 { 8454 ItemPrototype const *pBagProto = pBag->GetProto(); 8455 if( pBagProto ) 8456 { 8457 for(uint32 j = 0; j < pBagProto->ContainerSlots; j++) 8458 { 8459 Item* pItem = pBag->GetItemByPos( j ); 8460 if( pItem && pItem->GetGUID() == guid ) 8461 return pItem; 8462 } 8443 for(uint32 j = 0; j < pBag->GetBagSize(); j++) 8444 { 8445 Item* pItem = pBag->GetItemByPos( j ); 8446 if( pItem && pItem->GetGUID() == guid ) 8447 return pItem; 8463 8448 } 8464 8449 } … … 8618 8603 if(Bag* pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, i )) 8619 8604 { 8620 if(ItemPrototype const *pBagProto = pBag->GetProto()) 8621 { 8622 for(uint32 j = 0; j < pBagProto->ContainerSlots; j++) 8605 for(uint32 j = 0; j < pBag->GetBagSize(); j++) 8606 { 8607 Item* pItem = GetItemByPos( i, j ); 8608 if( pItem && pItem->GetEntry() == item ) 8609 { 8610 tempcount += pItem->GetCount(); 8611 if( tempcount >= count ) 8612 return true; 8613 } 8614 } 8615 } 8616 } 8617 8618 if(inBankAlso) 8619 { 8620 for(int i = BANK_SLOT_ITEM_START; i < BANK_SLOT_ITEM_END; i++) 8621 { 8622 Item *pItem = GetItemByPos( INVENTORY_SLOT_BAG_0, i ); 8623 if( pItem && pItem->GetEntry() == item ) 8624 { 8625 tempcount += pItem->GetCount(); 8626 if( tempcount >= count ) 8627 return true; 8628 } 8629 } 8630 for(int i = BANK_SLOT_BAG_START; i < BANK_SLOT_BAG_END; i++) 8631 { 8632 if(Bag* pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, i )) 8633 { 8634 for(uint32 j = 0; j < pBag->GetBagSize(); j++) 8623 8635 { 8624 8636 Item* pItem = GetItemByPos( i, j ); … … 8634 8646 } 8635 8647 8636 if(inBankAlso)8637 {8638 for(int i = BANK_SLOT_ITEM_START; i < BANK_SLOT_ITEM_END; i++)8639 {8640 Item *pItem = GetItemByPos( INVENTORY_SLOT_BAG_0, i );8641 if( pItem && pItem->GetEntry() == item )8642 {8643 tempcount += pItem->GetCount();8644 if( tempcount >= count )8645 return true;8646 }8647 }8648 for(int i = BANK_SLOT_BAG_START; i < BANK_SLOT_BAG_END; i++)8649 {8650 if(Bag* pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, i ))8651 {8652 if(ItemPrototype const *pBagProto = pBag->GetProto())8653 {8654 for(uint32 j = 0; j < pBagProto->ContainerSlots; j++)8655 {8656 Item* pItem = GetItemByPos( i, j );8657 if( pItem && pItem->GetEntry() == item )8658 {8659 tempcount += pItem->GetCount();8660 if( tempcount >= count )8661 return true;8662 }8663 }8664 }8665 }8666 }8667 }8668 8669 8648 return false; 8670 8649 } … … 8738 8717 return true; 8739 8718 } 8740 Bag *pBag;8741 ItemPrototype const *pBagProto;8742 8719 for(uint8 i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; ++i) 8743 8720 { 8744 pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, i ); 8745 if( pBag ) 8746 { 8747 pBagProto = pBag->GetProto(); 8748 if( pBagProto ) 8749 { 8750 for(uint32 j = 0; j < pBagProto->ContainerSlots; ++j) 8751 { 8752 pItem = GetItemByPos( i, j ); 8753 if( pItem && IsTotemCategoryCompatiableWith(pItem->GetProto()->TotemCategory,TotemCategory )) 8754 return true; 8755 } 8721 if(Bag *pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, i )) 8722 { 8723 for(uint32 j = 0; j < pBag->GetBagSize(); ++j) 8724 { 8725 pItem = GetItemByPos( i, j ); 8726 if( pItem && IsTotemCategoryCompatiableWith(pItem->GetProto()->TotemCategory,TotemCategory )) 8727 return true; 8756 8728 } 8757 8729 } … … 8847 8819 return EQUIP_ERR_ITEM_DOESNT_GO_INTO_BAG; 8848 8820 8849 for(uint32 j = 0; j < pBag Proto->ContainerSlots; j++)8821 for(uint32 j = 0; j < pBag->GetBagSize(); j++) 8850 8822 { 8851 8823 // skip specific slot already processed in first called _CanStoreItem_InSpecificSlot … … 9354 9326 for(int i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; i++) 9355 9327 { 9356 Bag *pBag; 9357 ItemPrototype const *pBagProto; 9358 9359 pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, i ); 9360 if( pBag ) 9361 { 9362 pBagProto = pBag->GetProto(); 9363 9364 if( pBagProto ) 9365 { 9366 for(uint32 j = 0; j < pBagProto->ContainerSlots; j++) 9328 if(Bag* pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, i )) 9329 { 9330 for(uint32 j = 0; j < pBag->GetBagSize(); j++) 9331 { 9332 pItem2 = GetItemByPos( i, j ); 9333 if (pItem2 && !pItem2->IsInTrade()) 9367 9334 { 9368 pItem2 = GetItemByPos( i, j ); 9369 if (pItem2 && !pItem2->IsInTrade()) 9370 { 9371 inv_bags[i-INVENTORY_SLOT_BAG_START][j] = pItem2->GetCount(); 9372 } 9335 inv_bags[i-INVENTORY_SLOT_BAG_START][j] = pItem2->GetCount(); 9373 9336 } 9374 9337 } … … 9437 9400 if( pBag ) 9438 9401 { 9439 pBagProto = pBag->GetProto(); 9440 if( pBagProto ) 9402 for(uint32 j = 0; j < pBag->GetBagSize(); j++) 9441 9403 { 9442 for(uint32 j = 0; j < pBagProto->ContainerSlots; j++) 9404 pItem2 = GetItemByPos( t, j ); 9405 if( pItem2 && pItem2->GetEntry() == pItem->GetEntry() && inv_bags[t-INVENTORY_SLOT_BAG_START][j] + pItem->GetCount() <= pProto->Stackable ) 9443 9406 { 9444 pItem2 = GetItemByPos( t, j ); 9445 if( pItem2 && pItem2->GetEntry() == pItem->GetEntry() && inv_bags[t-INVENTORY_SLOT_BAG_START][j] + pItem->GetCount() <= pProto->Stackable ) 9446 { 9447 inv_bags[t-INVENTORY_SLOT_BAG_START][j] += pItem->GetCount(); 9448 b_found = true; 9449 break; 9450 } 9407 inv_bags[t-INVENTORY_SLOT_BAG_START][j] += pItem->GetCount(); 9408 b_found = true; 9409 break; 9451 9410 } 9452 9411 } … … 9487 9446 ItemCanGoIntoBag(pProto,pBagProto) ) 9488 9447 { 9489 for(uint32 j = 0; j < pBag Proto->ContainerSlots; j++)9448 for(uint32 j = 0; j < pBag->GetBagSize(); j++) 9490 9449 { 9491 9450 if( inv_bags[t-INVENTORY_SLOT_BAG_START][j] == 0 ) … … 9521 9480 if( pBag ) 9522 9481 { 9523 pBagProto = pBag->GetProto(); 9524 if( pBagProto && ItemCanGoIntoBag(pProto,pBagProto)) 9482 for(uint32 j = 0; j < pBag->GetBagSize(); j++) 9525 9483 { 9526 for(uint32 j = 0; j < pBagProto->ContainerSlots; j++)9484 if( inv_bags[t-INVENTORY_SLOT_BAG_START][j] == 0 ) 9527 9485 { 9528 if( inv_bags[t-INVENTORY_SLOT_BAG_START][j] == 0 ) 9529 { 9530 inv_bags[t-INVENTORY_SLOT_BAG_START][j] = 1; 9531 b_found = true; 9532 break; 9533 } 9486 inv_bags[t-INVENTORY_SLOT_BAG_START][j] = 1; 9487 b_found = true; 9488 break; 9534 9489 } 9535 9490 } … … 10625 10580 10626 10581 // in inventory bags 10627 Bag *pBag;10628 ItemPrototype const *pBagProto;10629 10582 for(int i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; i++) 10630 10583 { 10631 pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, i ); 10632 if( pBag ) 10633 { 10634 pBagProto = pBag->GetProto(); 10635 if( pBagProto ) 10636 { 10637 for(uint32 j = 0; j < pBagProto->ContainerSlots; j++) 10584 if(Bag *pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, i )) 10585 { 10586 for(uint32 j = 0; j < pBag->GetBagSize(); j++) 10587 { 10588 pItem = pBag->GetItemByPos(j); 10589 if( pItem && pItem->GetEntry() == item ) 10638 10590 { 10639 pItem = pBag->GetItemByPos(j);10640 if( pItem && pItem->GetEntry() == item)10591 // all items in bags can be unequipped 10592 if( pItem->GetCount() + remcount <= count ) 10641 10593 { 10642 // all items in bags can be unequipped 10643 if( pItem->GetCount() + remcount <= count ) 10644 { 10645 remcount += pItem->GetCount(); 10646 DestroyItem( i, j, update ); 10647 10648 if(remcount >=count) 10649 return; 10650 } 10651 else 10652 { 10653 pProto = pItem->GetProto(); 10654 ItemRemovedQuestCheck( pItem->GetEntry(), count - remcount ); 10655 pItem->SetCount( pItem->GetCount() - count + remcount ); 10656 if( IsInWorld() && update ) 10657 pItem->SendUpdateToPlayer( this ); 10658 pItem->SetState(ITEM_CHANGED, this); 10594 remcount += pItem->GetCount(); 10595 DestroyItem( i, j, update ); 10596 10597 if(remcount >=count) 10659 10598 return; 10660 } 10599 } 10600 else 10601 { 10602 pProto = pItem->GetProto(); 10603 ItemRemovedQuestCheck( pItem->GetEntry(), count - remcount ); 10604 pItem->SetCount( pItem->GetCount() - count + remcount ); 10605 if( IsInWorld() && update ) 10606 pItem->SendUpdateToPlayer( this ); 10607 pItem->SetState(ITEM_CHANGED, this); 10608 return; 10661 10609 } 10662 10610 } … … 10720 10668 if( pBag ) 10721 10669 { 10722 ItemPrototype const *pBagProto = pBag->GetProto(); 10723 if( pBagProto ) 10724 { 10725 for(uint32 j = 0; j < pBagProto->ContainerSlots; j++) 10726 { 10727 Item* pItem = pBag->GetItemByPos(j); 10728 if( pItem && pItem->IsLimitedToAnotherMapOrZone(GetMapId(),new_zone) ) 10729 DestroyItem( i, j, update); 10730 } 10670 for(uint32 j = 0; j < pBag->GetBagSize(); j++) 10671 { 10672 Item* pItem = pBag->GetItemByPos(j); 10673 if( pItem && pItem->IsLimitedToAnotherMapOrZone(GetMapId(),new_zone) ) 10674 DestroyItem( i, j, update); 10731 10675 } 10732 10676 } … … 10764 10708 if( pBag ) 10765 10709 { 10766 ItemPrototype const *pBagProto = pBag->GetProto(); 10767 if( pBagProto ) 10768 { 10769 for(uint32 j = 0; j < pBagProto->ContainerSlots; j++) 10770 { 10771 Item* pItem = pBag->GetItemByPos(j); 10772 if( pItem && pItem->GetProto() && 10773 (pItem->GetProto()->Class == ITEM_CLASS_CONSUMABLE) && 10774 (pItem->GetProto()->Flags & ITEM_FLAGS_CONJURED) ) 10775 DestroyItem( i, j, update); 10776 } 10710 for(uint32 j = 0; j < pBag->GetBagSize(); j++) 10711 { 10712 Item* pItem = pBag->GetItemByPos(j); 10713 if( pItem && pItem->GetProto() && 10714 (pItem->GetProto()->Class == ITEM_CLASS_CONSUMABLE) && 10715 (pItem->GetProto()->Flags & ITEM_FLAGS_CONJURED) ) 10716 DestroyItem( i, j, update); 10777 10717 } 10778 10718 } … … 11423 11363 if( pBag ) 11424 11364 { 11425 ItemPrototype const *pBagProto = pBag->GetProto(); 11426 if( pBagProto ) 11427 { 11428 for(uint32 j = 0; j < pBagProto->ContainerSlots; j++) 11429 { 11430 Item* pItem = pBag->GetItemByPos(j); 11431 if( pItem && pItem->GetEnchantmentId(slot) ) 11432 pItem->ClearEnchantment(slot); 11433 } 11365 for(uint32 j = 0; j < pBag->GetBagSize(); j++) 11366 { 11367 Item* pItem = pBag->GetItemByPos(j); 11368 if( pItem && pItem->GetEnchantmentId(slot) ) 11369 pItem->ClearEnchantment(slot); 11434 11370 } 11435 11371 } … … 15717 15653 } 15718 15654 15655 void Player::PlaySound(uint32 Sound, bool OnlySelf) 15656 { 15657 WorldPacket data(SMSG_PLAY_SOUND, 4); 15658 data << Sound; 15659 if (OnlySelf) 15660 GetSession()->SendPacket( &data ); 15661 else 15662 SendMessageToSet( &data, true ); 15663 } 15664 15719 15665 void Player::SendExplorationExperience(uint32 Area, uint32 Experience) 15720 15666 {