Merge branch 'master' into 310

Conflicts:
	src/game/MiscHandler.cpp
	src/game/Player.cpp
	src/game/Player.h
	src/shared/Database/DBCStores.cpp
This commit is contained in:
tomrus88 2009-03-22 09:41:17 +03:00
commit 9debf4dfc0
15 changed files with 182 additions and 48 deletions

View file

@ -2742,7 +2742,7 @@ bool Player::addSpell(uint32 spell_id, bool active, bool learning, bool dependen
{
if(TalentEntry const *talentInfo = sTalentStore.LookupEntry( talentPos->talent_id ))
{
for(int i=0; i <5; ++i)
for(int i=0; i < MAX_TALENT_RANK; ++i)
{
// skip learning spell and no rank spell case
uint32 rankSpellId = talentInfo->RankID[i];
@ -3355,7 +3355,7 @@ bool Player::resetTalents(bool no_cost)
if( (getClassMask() & talentTabInfo->ClassMask) == 0 )
continue;
for (int j = 0; j < 5; j++)
for (int j = 0; j < MAX_TALENT_RANK; j++)
{
for(PlayerSpellMap::iterator itr = GetSpellMap().begin(); itr != GetSpellMap().end();)
{
@ -6012,9 +6012,11 @@ bool Player::SetOneFactionReputation(FactionEntry const* factionEntry, int32 sta
//Calculate total reputation percent player gain with quest/creature level
int32 Player::CalculateReputationGain(uint32 creatureOrQuestLevel, int32 rep, bool for_quest)
{
int32 percent = 100;
int32 repMod = GetTotalAuraModifier(SPELL_AURA_MOD_REPUTATION_GAIN);
int32 percent = rep > 0 ? repMod : -repMod;
percent += rep > 0 ? repMod : -repMod;
if(percent <=0)
return 0;
@ -8975,7 +8977,7 @@ uint8 Player::_CanStoreItem_InSpecificSlot( uint8 bag, uint8 slot, ItemPosCountV
return EQUIP_ERR_ITEM_DOESNT_GO_INTO_BAG;
// currencytoken case (disabled until proper implement)
if(slot >= CURRENCYTOKEN_SLOT_START && slot < CURRENCYTOKEN_SLOT_END && !(false /*pProto->BagFamily & BAG_FAMILY_MASK_CURRENCY_TOKENS*/))
if(slot >= CURRENCYTOKEN_SLOT_START && slot < CURRENCYTOKEN_SLOT_END && !(pProto->BagFamily & BAG_FAMILY_MASK_CURRENCY_TOKENS))
return EQUIP_ERR_ITEM_DOESNT_GO_INTO_BAG;
// prevent cheating
@ -9309,9 +9311,25 @@ uint8 Player::_CanStoreItem( uint8 bag, uint8 slot, ItemPosCountVec &dest, uint3
*no_space_count = count + no_similar_count;
return EQUIP_ERR_CANT_CARRY_MORE_OF_THIS;
}
}
/* until proper implementation
res = _CanStoreItem_InInventorySlots(CURRENCYTOKEN_SLOT_START,CURRENCYTOKEN_SLOT_END,dest,pProto,count,false,pItem,bag,slot);
if(res!=EQUIP_ERR_OK)
{
if(no_space_count)
*no_space_count = count + no_similar_count;
return res;
}
if(count==0)
{
if(no_similar_count==0)
return EQUIP_ERR_OK;
if(no_space_count)
*no_space_count = count + no_similar_count;
return EQUIP_ERR_CANT_CARRY_MORE_OF_THIS;
}
}
else if(pProto->BagFamily & BAG_FAMILY_MASK_CURRENCY_TOKENS)
{
res = _CanStoreItem_InInventorySlots(CURRENCYTOKEN_SLOT_START,CURRENCYTOKEN_SLOT_END,dest,pProto,count,false,pItem,bag,slot);
@ -9332,7 +9350,6 @@ uint8 Player::_CanStoreItem( uint8 bag, uint8 slot, ItemPosCountVec &dest, uint3
return EQUIP_ERR_CANT_CARRY_MORE_OF_THIS;
}
}
*/
res = _CanStoreItem_InInventorySlots(INVENTORY_SLOT_ITEM_START,INVENTORY_SLOT_ITEM_END,dest,pProto,count,false,pItem,bag,slot);
if(res!=EQUIP_ERR_OK)
@ -9480,9 +9497,7 @@ uint8 Player::_CanStoreItem( uint8 bag, uint8 slot, ItemPosCountVec &dest, uint3
return EQUIP_ERR_CANT_CARRY_MORE_OF_THIS;
}
}
/* until proper implementation
else if(false pProto->BagFamily & BAG_FAMILY_MASK_CURRENCY_TOKENS)
else if(pProto->BagFamily & BAG_FAMILY_MASK_CURRENCY_TOKENS)
{
res = _CanStoreItem_InInventorySlots(CURRENCYTOKEN_SLOT_START,CURRENCYTOKEN_SLOT_END,dest,pProto,count,false,pItem,bag,slot);
if(res!=EQUIP_ERR_OK)
@ -9502,7 +9517,6 @@ uint8 Player::_CanStoreItem( uint8 bag, uint8 slot, ItemPosCountVec &dest, uint3
return EQUIP_ERR_CANT_CARRY_MORE_OF_THIS;
}
}
*/
for(int i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; i++)
{
@ -10401,6 +10415,10 @@ Item* Player::_StoreItem( uint16 pos, Item *pItem, uint32 count, bool clone, boo
pItem->SetSlot( slot );
pItem->SetContainer( NULL );
// need update known currency
if (slot >= CURRENCYTOKEN_SLOT_START && slot < CURRENCYTOKEN_SLOT_END)
UpdateKnownCurrencies(pItem->GetEntry(),true);
if( IsInWorld() && update )
{
pItem->AddToWorld();
@ -10668,23 +10686,32 @@ void Player::RemoveItem( uint8 bag, uint8 slot, bool update )
// remove item dependent auras and casts (only weapon and armor slots)
if(slot < EQUIPMENT_SLOT_END)
{
RemoveItemDependentAurasAndCasts(pItem);
// remove held enchantments
if ( slot == EQUIPMENT_SLOT_MAINHAND )
{
if (pItem->GetItemSuffixFactor())
// remove held enchantments, update expertise
if ( slot == EQUIPMENT_SLOT_MAINHAND )
{
pItem->ClearEnchantment(PROP_ENCHANTMENT_SLOT_3);
pItem->ClearEnchantment(PROP_ENCHANTMENT_SLOT_4);
}
else
{
pItem->ClearEnchantment(PROP_ENCHANTMENT_SLOT_0);
pItem->ClearEnchantment(PROP_ENCHANTMENT_SLOT_1);
if (pItem->GetItemSuffixFactor())
{
pItem->ClearEnchantment(PROP_ENCHANTMENT_SLOT_3);
pItem->ClearEnchantment(PROP_ENCHANTMENT_SLOT_4);
}
else
{
pItem->ClearEnchantment(PROP_ENCHANTMENT_SLOT_0);
pItem->ClearEnchantment(PROP_ENCHANTMENT_SLOT_1);
}
UpdateExpertise(BASE_ATTACK);
}
else if( slot == EQUIPMENT_SLOT_OFFHAND )
UpdateExpertise(OFF_ATTACK);
}
}
// need update known currency
else if (slot >= CURRENCYTOKEN_SLOT_START && slot < CURRENCYTOKEN_SLOT_END)
UpdateKnownCurrencies(pItem->GetEntry(),false);
m_items[slot] = NULL;
SetUInt64Value((uint16)(PLAYER_FIELD_INV_SLOT_HEAD + (slot*2)), 0);
@ -10703,11 +10730,6 @@ void Player::RemoveItem( uint8 bag, uint8 slot, bool update )
pItem->SetSlot( NULL_SLOT );
if( IsInWorld() && update )
pItem->SendUpdateToPlayer( this );
if( slot == EQUIPMENT_SLOT_MAINHAND )
UpdateExpertise(BASE_ATTACK);
else if( slot == EQUIPMENT_SLOT_OFFHAND )
UpdateExpertise(OFF_ATTACK);
}
}
@ -10792,9 +10814,18 @@ void Player::DestroyItem( uint8 bag, uint8 slot, bool update )
// remove item dependent auras and casts (only weapon and armor slots)
RemoveItemDependentAurasAndCasts(pItem);
// update expertise
if ( slot == EQUIPMENT_SLOT_MAINHAND )
UpdateExpertise(BASE_ATTACK);
else if( slot == EQUIPMENT_SLOT_OFFHAND )
UpdateExpertise(OFF_ATTACK);
// equipment visual show
SetVisibleItemSlot(slot,NULL);
}
// need update known currency
else if (slot >= CURRENCYTOKEN_SLOT_START && slot < CURRENCYTOKEN_SLOT_END)
UpdateKnownCurrencies(pItem->GetEntry(),false);
m_items[slot] = NULL;
}
@ -19859,7 +19890,7 @@ void Player::LearnTalent(uint32 talentId, uint32 talentRank)
if(CurTalentPoints == 0)
return;
if (talentRank > 4)
if (talentRank >= MAX_TALENT_RANK)
return;
TalentEntry const *talentInfo = sTalentStore.LookupEntry( talentId );
@ -19878,7 +19909,7 @@ void Player::LearnTalent(uint32 talentId, uint32 talentRank)
// find current max talent rank
int32 curtalent_maxrank = 0;
for(int32 k = 4; k > -1; --k)
for(int32 k = MAX_TALENT_RANK-1; k > -1; --k)
{
if(talentInfo->RankID[k] && HasSpell(talentInfo->RankID[k]))
{
@ -19901,7 +19932,7 @@ void Player::LearnTalent(uint32 talentId, uint32 talentRank)
if(TalentEntry const *depTalentInfo = sTalentStore.LookupEntry(talentInfo->DependsOn))
{
bool hasEnoughRank = false;
for (int i = talentInfo->DependsOnRank; i <= 4; i++)
for (int i = talentInfo->DependsOnRank; i < MAX_TALENT_RANK; i++)
{
if (depTalentInfo->RankID[i] != 0)
if (HasSpell(depTalentInfo->RankID[i]))
@ -19927,7 +19958,7 @@ void Player::LearnTalent(uint32 talentId, uint32 talentRank)
{
if (tmpTalent->TalentTab == tTab)
{
for (int j = 0; j <= 4; j++)
for (int j = 0; j < MAX_TALENT_RANK; j++)
{
if (tmpTalent->RankID[j] != 0)
{
@ -19943,7 +19974,7 @@ void Player::LearnTalent(uint32 talentId, uint32 talentRank)
}
// not have required min points spent in talent tree
if(spentPoints < (talentInfo->Row * 5))
if(spentPoints < (talentInfo->Row * MAX_TALENT_RANK))
return;
// spell not set in talent.dbc
@ -19981,7 +20012,7 @@ void Player::LearnPetTalent(uint64 petGuid, uint32 talentId, uint32 talentRank)
if(CurTalentPoints == 0)
return;
if (talentRank > 2)
if (talentRank >= MAX_PET_TALENT_RANK)
return;
TalentEntry const *talentInfo = sTalentStore.LookupEntry(talentId);
@ -20013,7 +20044,7 @@ void Player::LearnPetTalent(uint64 petGuid, uint32 talentId, uint32 talentRank)
// find current max talent rank
int32 curtalent_maxrank = 0;
for(int32 k = 4; k > -1; --k)
for(int32 k = MAX_TALENT_RANK-1; k > -1; --k)
{
if(talentInfo->RankID[k] && pet->HasSpell(talentInfo->RankID[k]))
{
@ -20036,7 +20067,7 @@ void Player::LearnPetTalent(uint64 petGuid, uint32 talentId, uint32 talentRank)
if(TalentEntry const *depTalentInfo = sTalentStore.LookupEntry(talentInfo->DependsOn))
{
bool hasEnoughRank = false;
for (int i = talentInfo->DependsOnRank; i <= 4; i++)
for (int i = talentInfo->DependsOnRank; i < MAX_TALENT_RANK; i++)
{
if (depTalentInfo->RankID[i] != 0)
if (pet->HasSpell(depTalentInfo->RankID[i]))
@ -20062,7 +20093,7 @@ void Player::LearnPetTalent(uint64 petGuid, uint32 talentId, uint32 talentRank)
{
if (tmpTalent->TalentTab == tTab)
{
for (int j = 0; j <= 4; j++)
for (int j = 0; j < MAX_TALENT_RANK; j++)
{
if (tmpTalent->RankID[j] != 0)
{
@ -20078,7 +20109,7 @@ void Player::LearnPetTalent(uint64 petGuid, uint32 talentId, uint32 talentRank)
}
// not have required min points spent in talent tree
if(spentPoints < (talentInfo->Row * 3))
if(spentPoints < (talentInfo->Row * MAX_PET_TALENT_RANK))
return;
// spell not set in talent.dbc
@ -20095,12 +20126,23 @@ void Player::LearnPetTalent(uint64 petGuid, uint32 talentId, uint32 talentRank)
// learn! (other talent ranks will unlearned at learning)
pet->learnSpell(spellid);
sLog.outDetail("TalentID: %u Rank: %u Spell: %u\n", talentId, talentRank, spellid);
sLog.outDetail("PetTalentID: %u Rank: %u Spell: %u\n", talentId, talentRank, spellid);
// update free talent points
pet->SetFreeTalentPoints(CurTalentPoints - (talentRank - curtalent_maxrank + 1));
}
void Player::UpdateKnownCurrencies(uint32 itemId, bool apply)
{
if(CurrencyTypesEntry const* ctEntry = sCurrencyTypesStore.LookupEntry(itemId))
{
if(apply)
SetFlag64(PLAYER_FIELD_KNOWN_CURRENCIES,(1LL << (ctEntry->BitIndex-1)));
else
RemoveFlag64(PLAYER_FIELD_KNOWN_CURRENCIES,(1LL << (ctEntry->BitIndex-1)));
}
}
void Player::BuildPlayerTalentsInfoData(WorldPacket *data)
{
*data << uint32(GetFreeTalentPoints()); // unspentTalentPoints