From 695ceabe3e635efaff956d16256d595365f1ce51 Mon Sep 17 00:00:00 2001 From: VladimirMangos Date: Sat, 21 Mar 2009 20:12:16 +0300 Subject: [PATCH 1/9] [7509] Use defines instead explcit value for talent rank cound (in general and for pets) --- src/game/Chat.cpp | 2 +- src/game/Level3.cpp | 4 ++-- src/game/MiscHandler.cpp | 2 +- src/game/Pet.cpp | 4 ++-- src/game/Player.cpp | 26 +++++++++++++------------- src/game/Player.h | 2 +- src/shared/Database/DBCStores.cpp | 4 ++-- src/shared/Database/DBCStructure.h | 5 ++++- src/shared/revision_nr.h | 2 +- 9 files changed, 27 insertions(+), 24 deletions(-) diff --git a/src/game/Chat.cpp b/src/game/Chat.cpp index 57b66f900..e0aa19aed 100644 --- a/src/game/Chat.cpp +++ b/src/game/Chat.cpp @@ -1352,7 +1352,7 @@ uint32 ChatHandler::extractSpellIdFromLink(char* text) return 0; int32 rank = param1_str ? (uint32)atol(param1_str) : 0; - if(rank >= 5) + if(rank >= MAX_TALENT_RANK) return 0; if(rank < 0) diff --git a/src/game/Level3.cpp b/src/game/Level3.cpp index 6022214ed..182f1817d 100644 --- a/src/game/Level3.cpp +++ b/src/game/Level3.cpp @@ -1766,8 +1766,8 @@ bool ChatHandler::HandleLearnAllMyTalentsCommand(const char* /*args*/) // search highest talent rank uint32 spellid = 0; - int rank = 4; - for(; rank >= 0; --rank) + + for(int rank = MAX_TALENT_RANK-1; rank >= 0; --rank) { if(talentInfo->RankID[rank]!=0) { diff --git a/src/game/MiscHandler.cpp b/src/game/MiscHandler.cpp index d90b7ad80..77040a331 100644 --- a/src/game/MiscHandler.cpp +++ b/src/game/MiscHandler.cpp @@ -1222,7 +1222,7 @@ void WorldSession::HandleInspectOpcode(WorldPacket& recv_data) // find talent rank uint32 curtalent_maxrank = 0; - for(uint32 k = 5; k > 0; --k) + for(uint32 k = MAX_TALENT_RANK; k > 0; --k) { if(talentInfo->RankID[k-1] && plr->HasSpell(talentInfo->RankID[k-1])) { diff --git a/src/game/Pet.cpp b/src/game/Pet.cpp index 0f7121750..d699d3c60 100644 --- a/src/game/Pet.cpp +++ b/src/game/Pet.cpp @@ -1277,7 +1277,7 @@ bool Pet::addSpell(uint32 spell_id, uint16 active, PetSpellState state, PetSpell { 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]; @@ -1554,7 +1554,7 @@ bool Pet::resetTalents(bool no_cost) if(!((1 << pet_family->petTalentType) & talentTabInfo->petTalentMask)) continue; - for (int j = 0; j < 5; j++) + for (int j = 0; j < MAX_TALENT_RANK; j++) { for(PetSpellMap::iterator itr = m_spells.begin(); itr != m_spells.end();) { diff --git a/src/game/Player.cpp b/src/game/Player.cpp index 7b6c31e1a..6105ba116 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -2746,7 +2746,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]; @@ -3359,7 +3359,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();) { @@ -19916,7 +19916,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 ); @@ -19935,7 +19935,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])) { @@ -19958,7 +19958,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])) @@ -19984,7 +19984,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) { @@ -20000,7 +20000,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 @@ -20038,7 +20038,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); @@ -20070,7 +20070,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])) { @@ -20093,7 +20093,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])) @@ -20119,7 +20119,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) { @@ -20135,7 +20135,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 @@ -20152,7 +20152,7 @@ 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)); diff --git a/src/game/Player.h b/src/game/Player.h index c1e9f668f..423f05bdb 100644 --- a/src/game/Player.h +++ b/src/game/Player.h @@ -629,7 +629,7 @@ enum KeyRingSlots // 32 slots enum VanityPetSlots // 18 slots { VANITYPET_SLOT_START = 118, // not use, vanity pets stored as spells - VANITYPET_SLOT_END = 136 // not alloed any content in. + VANITYPET_SLOT_END = 136 // not allowed any content in. }; enum CurrencyTokenSlots // 32 slots diff --git a/src/shared/Database/DBCStores.cpp b/src/shared/Database/DBCStores.cpp index 671efa5ea..4c48894d8 100644 --- a/src/shared/Database/DBCStores.cpp +++ b/src/shared/Database/DBCStores.cpp @@ -343,7 +343,7 @@ void LoadDBCStores(const std::string& dataPath) { TalentEntry const *talentInfo = sTalentStore.LookupEntry(i); if (!talentInfo) continue; - for (int j = 0; j < 5; j++) + for (int j = 0; j < MAX_TALENT_RANK; j++) if(talentInfo->RankID[j]) sTalentSpellPosMap[talentInfo->RankID[j]] = TalentSpellPos(i,j); } @@ -367,7 +367,7 @@ void LoadDBCStores(const std::string& dataPath) // find talent rank uint32 curtalent_maxrank = 0; - for(uint32 k = 5; k > 0; --k) + for(uint32 k = MAX_TALENT_RANK; k > 0; --k) { if(talentInfo->RankID[k-1]) { diff --git a/src/shared/Database/DBCStructure.h b/src/shared/Database/DBCStructure.h index d20d3d66d..9b825e175 100644 --- a/src/shared/Database/DBCStructure.h +++ b/src/shared/Database/DBCStructure.h @@ -1396,13 +1396,16 @@ struct StableSlotPricesEntry uint32 Flags; // 5 };*/ +#define MAX_TALENT_RANK 5 +#define MAX_PET_TALENT_RANK 3 // use in calculations, expected <= MAX_TALENT_RANK + struct TalentEntry { uint32 TalentID; // 0 uint32 TalentTab; // 1 index in TalentTab.dbc (TalentTabEntry) uint32 Row; // 2 uint32 Col; // 3 - uint32 RankID[5]; // 4-8 + uint32 RankID[MAX_TALENT_RANK]; // 4-8 // 9-12 not used, always 0, maybe not used high ranks uint32 DependsOn; // 13 index in Talent.dbc (TalentEntry) // 14-15 not used diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 2728d6344..ef787e69e 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "7508" + #define REVISION_NR "7509" #endif // __REVISION_NR_H__ From ff48408dbb0dfb3a50ba706f2f2acc9e0dbf63d2 Mon Sep 17 00:00:00 2001 From: VladimirMangos Date: Sat, 21 Mar 2009 21:20:38 +0300 Subject: [PATCH 2/9] [7510] Some cleanups and commens for special forbidden slots --- src/game/Player.cpp | 4 ++-- src/game/Player.h | 4 ++-- src/shared/revision_nr.h | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/game/Player.cpp b/src/game/Player.cpp index 6105ba116..4b09f3256 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -8996,8 +8996,8 @@ uint8 Player::_CanStoreItem_InSpecificSlot( uint8 bag, uint8 slot, ItemPosCountV if(slot >= CURRENCYTOKEN_SLOT_START && slot < CURRENCYTOKEN_SLOT_END && !(false /*pProto->BagFamily & BAG_FAMILY_MASK_CURRENCY_TOKENS*/)) return EQUIP_ERR_ITEM_DOESNT_GO_INTO_BAG; - // guestbag case (disabled until proper implement) - if(slot >= QUESTBAG_SLOT_START && slot < QUESTBAG_SLOT_END && !(false /*pProto->BagFamily & BAG_FAMILY_MASK_QUEST_ITEMS*/)) + // guestbag case (not use) + if(slot >= QUESTBAG_SLOT_START && slot < QUESTBAG_SLOT_END) return EQUIP_ERR_ITEM_DOESNT_GO_INTO_BAG; // prevent cheating diff --git a/src/game/Player.h b/src/game/Player.h index 423f05bdb..ae1dfe5cc 100644 --- a/src/game/Player.h +++ b/src/game/Player.h @@ -640,8 +640,8 @@ enum CurrencyTokenSlots // 32 slots enum QuestBagSlots // 32 slots { - QUESTBAG_SLOT_START = 168, - QUESTBAG_SLOT_END = 200 + QUESTBAG_SLOT_START = 168, // not use + QUESTBAG_SLOT_END = 200 // not allowed any content in. }; struct ItemPosCount diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index ef787e69e..c652d0e49 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "7509" + #define REVISION_NR "7510" #endif // __REVISION_NR_H__ From 2885091dfe35dd577a7c0e6c921d8bba6fb69dab Mon Sep 17 00:00:00 2001 From: VladimirMangos Date: Sun, 22 Mar 2009 02:48:17 +0300 Subject: [PATCH 3/9] [7511] Fixed expertise update at items unequip/drop. * Not attempt update at item move from slot in bag with equip-like slot number. * Update at item drop from bag. --- src/game/Player.cpp | 39 +++++++++++++++++++++++---------------- src/shared/revision_nr.h | 2 +- 2 files changed, 24 insertions(+), 17 deletions(-) diff --git a/src/game/Player.cpp b/src/game/Player.cpp index 4b09f3256..195a918df 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -10707,21 +10707,27 @@ 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); } } @@ -10742,11 +10748,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); } } @@ -10831,6 +10832,12 @@ 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); } diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index c652d0e49..871f8dc6a 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "7510" + #define REVISION_NR "7511" #endif // __REVISION_NR_H__ From 38395ac07da0073de756a6485d551e0fe911b2f0 Mon Sep 17 00:00:00 2001 From: VladimirMangos Date: Sun, 22 Mar 2009 03:19:54 +0300 Subject: [PATCH 4/9] [7512] Implement checks of item bag mask at server startup. --- src/game/ItemPrototype.h | 2 +- src/game/ObjectMgr.cpp | 18 ++++++++++++++++++ src/shared/Database/DBCStores.cpp | 4 +++- src/shared/Database/DBCStores.h | 1 + src/shared/Database/DBCStructure.h | 7 +++++++ src/shared/Database/DBCfmt.cpp | 1 + src/shared/revision_nr.h | 2 +- 7 files changed, 32 insertions(+), 3 deletions(-) diff --git a/src/game/ItemPrototype.h b/src/game/ItemPrototype.h index c7a14215d..c5f0f4d8a 100644 --- a/src/game/ItemPrototype.h +++ b/src/game/ItemPrototype.h @@ -557,7 +557,7 @@ struct ItemPrototype uint32 MaxDurability; uint32 Area; // id from AreaTable.dbc uint32 Map; // id from Map.dbc - uint32 BagFamily; // id from ItemBagFamily.dbc + uint32 BagFamily; // bit string (1 << id from ItemBagFamily.dbc) uint32 TotemCategory; // id from TotemCategory.dbc _Socket Socket[MAX_ITEM_PROTO_SOCKETS]; uint32 socketBonus; // id from SpellItemEnchantment.dbc diff --git a/src/game/ObjectMgr.cpp b/src/game/ObjectMgr.cpp index 21925cc29..51fc9108b 100644 --- a/src/game/ObjectMgr.cpp +++ b/src/game/ObjectMgr.cpp @@ -1715,6 +1715,24 @@ void ObjectMgr::LoadItemPrototypes() if(proto->Map && !sMapStore.LookupEntry(proto->Map)) sLog.outErrorDb("Item (Entry: %u) has wrong Map (%u)",i,proto->Map); + if(proto->BagFamily) + { + // check bits + for(uint32 i = 0; i < sizeof(proto->BagFamily)*8; ++i) + { + uint32 mask = 1 << i; + if((proto->BagFamily & mask)==0) + continue; + + ItemBagFamilyEntry const* bf = sItemBagFamilyStore.LookupEntry(i+1); + if(!bf) + { + sLog.outErrorDb("Item (Entry: %u) has bag family bit set not listed in ItemBagFamily.dbc, remove bit",i); + const_cast(proto)->BagFamily &= ~mask; + } + } + } + if(proto->TotemCategory && !sTotemCategoryStore.LookupEntry(proto->TotemCategory)) sLog.outErrorDb("Item (Entry: %u) has wrong TotemCategory (%u)",i,proto->TotemCategory); diff --git a/src/shared/Database/DBCStores.cpp b/src/shared/Database/DBCStores.cpp index 4c48894d8..caafdb5d9 100644 --- a/src/shared/Database/DBCStores.cpp +++ b/src/shared/Database/DBCStores.cpp @@ -77,6 +77,7 @@ DBCStorage sGtRegenHPPerSptStore(GtRegenHPPerSptf DBCStorage sGtRegenMPPerSptStore(GtRegenMPPerSptfmt); DBCStorage sHolidaysStore(Holidaysfmt); DBCStorage sItemStore(Itemfmt); +DBCStorage sItemBagFamilyStore(ItemBagFamilyfmt); //DBCStorage sItemCondExtCostsStore(ItemCondExtCostsEntryfmt); //DBCStorage sItemDisplayInfoStore(ItemDisplayTemplateEntryfmt); -- not used currently DBCStorage sItemExtendedCostStore(ItemExtendedCostEntryfmt); @@ -194,7 +195,7 @@ void LoadDBCStores(const std::string& dataPath) { std::string dbcPath = dataPath+"dbc/"; - const uint32 DBCFilesCount = 73; + const uint32 DBCFilesCount = 74; barGoLink bar( DBCFilesCount ); @@ -269,6 +270,7 @@ void LoadDBCStores(const std::string& dataPath) LoadDBC(availableDbcLocales,bar,bad_dbc_files,sGtRegenMPPerSptStore, dbcPath,"gtRegenMPPerSpt.dbc"); LoadDBC(availableDbcLocales,bar,bad_dbc_files,sHolidaysStore, dbcPath,"Holidays.dbc"); LoadDBC(availableDbcLocales,bar,bad_dbc_files,sItemStore, dbcPath,"Item.dbc"); + LoadDBC(availableDbcLocales,bar,bad_dbc_files,sItemBagFamilyStore, dbcPath,"ItemBagFamily.dbc"); //LoadDBC(availableDbcLocales,bar,bad_dbc_files,sItemDisplayInfoStore, dbcPath,"ItemDisplayInfo.dbc"); -- not used currently //LoadDBC(availableDbcLocales,bar,bad_dbc_files,sItemCondExtCostsStore, dbcPath,"ItemCondExtCosts.dbc"); LoadDBC(availableDbcLocales,bar,bad_dbc_files,sItemExtendedCostStore, dbcPath,"ItemExtendedCost.dbc"); diff --git a/src/shared/Database/DBCStores.h b/src/shared/Database/DBCStores.h index 5a37201db..a4b68910a 100644 --- a/src/shared/Database/DBCStores.h +++ b/src/shared/Database/DBCStores.h @@ -169,6 +169,7 @@ extern DBCStorage sGtRegenHPPerSptStore; extern DBCStorage sGtRegenMPPerSptStore; extern DBCStorage sHolidaysStore; extern DBCStorage sItemStore; +extern DBCStorage sItemBagFamilyStore; //extern DBCStorage sItemDisplayInfoStore; -- not used currently extern DBCStorage sItemExtendedCostStore; extern DBCStorage sItemLimitCategoryStore; diff --git a/src/shared/Database/DBCStructure.h b/src/shared/Database/DBCStructure.h index 9b825e175..ccd3835a5 100644 --- a/src/shared/Database/DBCStructure.h +++ b/src/shared/Database/DBCStructure.h @@ -901,6 +901,13 @@ struct ItemEntry uint32 Sheath; // 7 }; +struct ItemBagFamilyEntry +{ + uint32 ID; // 0 + //char* name[16] // 1-16 m_name_lang + // // 17 name flags +}; + struct ItemDisplayInfoEntry { uint32 ID; // 0 m_ID diff --git a/src/shared/Database/DBCfmt.cpp b/src/shared/Database/DBCfmt.cpp index 61eb52463..6f99b923d 100644 --- a/src/shared/Database/DBCfmt.cpp +++ b/src/shared/Database/DBCfmt.cpp @@ -55,6 +55,7 @@ const char GtRegenHPPerSptfmt[]="f"; const char GtRegenMPPerSptfmt[]="f"; const char Holidaysfmt[]="nxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; const char Itemfmt[]="nixiiiii"; +const char ItemBagFamilyfmt[]="nxxxxxxxxxxxxxxxxx"; //const char ItemDisplayTemplateEntryfmt[]="nxxxxxxxxxxixxxxxxxxxxx"; //const char ItemCondExtCostsEntryfmt[]="xiii"; const char ItemExtendedCostEntryfmt[]="niiiiiiiiiiiiix"; diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 871f8dc6a..c28abd5de 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "7511" + #define REVISION_NR "7512" #endif // __REVISION_NR_H__ From 54acc587dad366fd7b71cd164be142a7a81e54a4 Mon Sep 17 00:00:00 2001 From: VladimirMangos Date: Sun, 22 Mar 2009 05:19:35 +0300 Subject: [PATCH 5/9] [7513] Implement currencies tab work. Also check related item data at server startup. --- src/game/ObjectMgr.cpp | 11 +++++++ src/game/Player.cpp | 49 +++++++++++++++++++++++++----- src/game/Player.h | 1 + src/shared/Database/DBCStores.cpp | 4 ++- src/shared/Database/DBCStores.h | 1 + src/shared/Database/DBCStructure.h | 17 +++++++++++ src/shared/Database/DBCfmt.cpp | 1 + src/shared/revision_nr.h | 2 +- 8 files changed, 76 insertions(+), 10 deletions(-) diff --git a/src/game/ObjectMgr.cpp b/src/game/ObjectMgr.cpp index 51fc9108b..da9b8cc49 100644 --- a/src/game/ObjectMgr.cpp +++ b/src/game/ObjectMgr.cpp @@ -1729,6 +1729,17 @@ void ObjectMgr::LoadItemPrototypes() { sLog.outErrorDb("Item (Entry: %u) has bag family bit set not listed in ItemBagFamily.dbc, remove bit",i); const_cast(proto)->BagFamily &= ~mask; + continue; + } + + if(BAG_FAMILY_MASK_CURRENCY_TOKENS & mask) + { + CurrencyTypesEntry const* ctEntry = sCurrencyTypesStore.LookupEntry(proto->ItemId); + if(!ctEntry) + { + sLog.outErrorDb("Item (Entry: %u) has currency bag family bit set in BagFamily but not listed in CurrencyTypes.dbc, remove bit",i); + const_cast(proto)->BagFamily &= ~mask; + } } } } diff --git a/src/game/Player.cpp b/src/game/Player.cpp index 195a918df..2d3a0dd82 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -8993,7 +8993,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; // guestbag case (not use) @@ -9331,9 +9331,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); @@ -9354,7 +9370,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) @@ -9502,9 +9517,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) @@ -9524,7 +9537,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++) { @@ -10423,6 +10435,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(); @@ -10730,6 +10746,9 @@ void Player::RemoveItem( uint8 bag, uint8 slot, bool update ) 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); @@ -10841,6 +10860,9 @@ void Player::DestroyItem( uint8 bag, uint8 slot, bool update ) // 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; } @@ -20164,3 +20186,14 @@ void Player::LearnPetTalent(uint64 petGuid, uint32 talentId, uint32 talentRank) // 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))); + } +} diff --git a/src/game/Player.h b/src/game/Player.h index ae1dfe5cc..62a8210bd 100644 --- a/src/game/Player.h +++ b/src/game/Player.h @@ -2348,6 +2348,7 @@ class MANGOS_DLL_SPEC Player : public Unit uint8 _CanStoreItem_InBag( uint8 bag, ItemPosCountVec& dest, ItemPrototype const *pProto, uint32& count, bool merge, bool non_specialized, Item *pSrcItem, uint8 skip_bag, uint8 skip_slot ) const; uint8 _CanStoreItem_InInventorySlots( uint8 slot_begin, uint8 slot_end, ItemPosCountVec& dest, ItemPrototype const *pProto, uint32& count, bool merge, Item *pSrcItem, uint8 skip_bag, uint8 skip_slot ) const; Item* _StoreItem( uint16 pos, Item *pItem, uint32 count, bool clone, bool update ); + void UpdateKnownCurrencies(uint32 itemId, bool apply); void AdjustQuestReqItemCount( Quest const* pQuest, QuestStatusData& questStatusData ); diff --git a/src/shared/Database/DBCStores.cpp b/src/shared/Database/DBCStores.cpp index caafdb5d9..a84eada59 100644 --- a/src/shared/Database/DBCStores.cpp +++ b/src/shared/Database/DBCStores.cpp @@ -50,6 +50,7 @@ DBCStorage sCreatureDisplayInfoStore(CreatureDisplayI DBCStorage sCreatureFamilyStore(CreatureFamilyfmt); DBCStorage sCreatureSpellDataStore(CreatureSpellDatafmt); DBCStorage sCreatureTypeStore(CreatureTypefmt); +DBCStorage sCurrencyTypesStore(CurrencyTypesfmt); DBCStorage sDurabilityQualityStore(DurabilityQualityfmt); DBCStorage sDurabilityCostsStore(DurabilityCostsfmt); @@ -195,7 +196,7 @@ void LoadDBCStores(const std::string& dataPath) { std::string dbcPath = dataPath+"dbc/"; - const uint32 DBCFilesCount = 74; + const uint32 DBCFilesCount = 75; barGoLink bar( DBCFilesCount ); @@ -236,6 +237,7 @@ void LoadDBCStores(const std::string& dataPath) LoadDBC(availableDbcLocales,bar,bad_dbc_files,sCreatureFamilyStore, dbcPath,"CreatureFamily.dbc"); LoadDBC(availableDbcLocales,bar,bad_dbc_files,sCreatureSpellDataStore, dbcPath,"CreatureSpellData.dbc"); LoadDBC(availableDbcLocales,bar,bad_dbc_files,sCreatureTypeStore, dbcPath,"CreatureType.dbc"); + LoadDBC(availableDbcLocales,bar,bad_dbc_files,sCurrencyTypesStore, dbcPath,"CurrencyTypes.dbc"); LoadDBC(availableDbcLocales,bar,bad_dbc_files,sDurabilityCostsStore, dbcPath,"DurabilityCosts.dbc"); LoadDBC(availableDbcLocales,bar,bad_dbc_files,sDurabilityQualityStore, dbcPath,"DurabilityQuality.dbc"); LoadDBC(availableDbcLocales,bar,bad_dbc_files,sEmotesTextStore, dbcPath,"EmotesText.dbc"); diff --git a/src/shared/Database/DBCStores.h b/src/shared/Database/DBCStores.h index a4b68910a..71f03a6a5 100644 --- a/src/shared/Database/DBCStores.h +++ b/src/shared/Database/DBCStores.h @@ -148,6 +148,7 @@ extern DBCStorage sCreatureDisplayInfoStore; extern DBCStorage sCreatureFamilyStore; extern DBCStorage sCreatureSpellDataStore; extern DBCStorage sCreatureTypeStore; +extern DBCStorage sCurrencyTypesStore; extern DBCStorage sDurabilityCostsStore; extern DBCStorage sDurabilityQualityStore; extern DBCStorage sEmotesTextStore; diff --git a/src/shared/Database/DBCStructure.h b/src/shared/Database/DBCStructure.h index ccd3835a5..2f1b0b1ae 100644 --- a/src/shared/Database/DBCStructure.h +++ b/src/shared/Database/DBCStructure.h @@ -697,6 +697,23 @@ struct CreatureTypeEntry //uint32 no_expirience; // 18 no exp? critters, non-combat pets, gas cloud. }; +/* not used +struct CurrencyCategoryEntry +{ + uint32 ID; // 0 + uint32 Unk1; // 1 0 for known categories and 3 for unknown one (3.0.9) + char* Name[16]; // 2-17 name + // // 18 string flags +}; +*/ + +struct CurrencyTypesEntry +{ + //uint32 ID; // 0 not used + uint32 ItemId; // 1 used as real index + uint32 BitIndex; // 2 bit index in PLAYER_FIELD_KNOWN_CURRENCIES (1 << (index-1)) +}; + struct DurabilityCostsEntry { uint32 Itemlvl; // 0 diff --git a/src/shared/Database/DBCfmt.cpp b/src/shared/Database/DBCfmt.cpp index 6f99b923d..5049fcdf3 100644 --- a/src/shared/Database/DBCfmt.cpp +++ b/src/shared/Database/DBCfmt.cpp @@ -35,6 +35,7 @@ const char CreatureDisplayInfofmt[]="nxxxfxxxxxxxxxxx"; const char CreatureFamilyfmt[]="nfifiiiiixssssssssssssssssxx"; const char CreatureSpellDatafmt[]="nxxxxxxxx"; const char CreatureTypefmt[]="nxxxxxxxxxxxxxxxxxx"; +const char CurrencyTypesfmt[]="xnxi"; const char DurabilityCostsfmt[]="niiiiiiiiiiiiiiiiiiiiiiiiiiiii"; const char DurabilityQualityfmt[]="nf"; const char EmoteEntryfmt[]="nxixxxxxxxxxxxxxxxx"; diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index c28abd5de..17612a387 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "7512" + #define REVISION_NR "7513" #endif // __REVISION_NR_H__ From e39a836115f9480ea43eca24191eccf6e9b4c3ea Mon Sep 17 00:00:00 2001 From: VladimirMangos Date: Sun, 22 Mar 2009 05:28:00 +0300 Subject: [PATCH 6/9] [7514] Revert bogus reputation calculation change added with merge from 310. Reputation must work now. Instead have near to 0 percent values always. --- src/game/Player.cpp | 5 ++++- src/shared/revision_nr.h | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/game/Player.cpp b/src/game/Player.cpp index 2d3a0dd82..62af51a70 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -6026,9 +6026,12 @@ 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) { + // for grey creature kill received 20%, in other case 100. + int32 percent = (!for_quest && (creatureOrQuestLevel <= MaNGOS::XP::GetGrayLevel(getLevel()))) ? 20 : 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; diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 17612a387..8957ac4d3 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "7513" + #define REVISION_NR "7514" #endif // __REVISION_NR_H__ From 636b0a9464d8c44d567c85b0f07982466014f6e9 Mon Sep 17 00:00:00 2001 From: DonTomika Date: Sun, 22 Mar 2009 05:36:19 +0300 Subject: [PATCH 7/9] [7515] Not allow caster cast different polymorph spells at different targets in same time. Signed-off-by: VladimirMangos --- src/game/SpellMgr.cpp | 1 + src/shared/revision_nr.h | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/game/SpellMgr.cpp b/src/game/SpellMgr.cpp index 1f6a7467b..43db31e65 100644 --- a/src/game/SpellMgr.cpp +++ b/src/game/SpellMgr.cpp @@ -530,6 +530,7 @@ bool IsSingleTargetSpells(SpellEntry const *spellInfo1, SpellEntry const *spellI switch(spec1) { case SPELL_JUDGEMENT: + case SPELL_MAGE_POLYMORPH: if(GetSpellSpecific(spellInfo2->Id) == spec1) return true; break; diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 8957ac4d3..37325603e 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "7514" + #define REVISION_NR "7515" #endif // __REVISION_NR_H__ From 1d95ae7555ca7042aac76bc4e4d61159bfb210a8 Mon Sep 17 00:00:00 2001 From: Sarjuuk Date: Sun, 22 Mar 2009 06:33:33 +0300 Subject: [PATCH 8/9] [7516] Add form/mounting/self control loss limitations to 48505 and ranks. Signed-off-by: VladimirMangos --- src/game/SpellEffects.cpp | 12 ++++++++++++ src/shared/revision_nr.h | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/game/SpellEffects.cpp b/src/game/SpellEffects.cpp index ace5eade1..51bd8e48e 100644 --- a/src/game/SpellEffects.cpp +++ b/src/game/SpellEffects.cpp @@ -1367,6 +1367,18 @@ void Spell::EffectDummy(uint32 i) // Starfall if (m_spellInfo->SpellFamilyFlags2 & 0x00000100LL) { + //Shapeshifting into an animal form or mounting cancels the effect. + if(m_caster->GetCreatureType() == CREATURE_TYPE_BEAST || m_caster->IsMounted()) + { + if(m_triggeredByAuraSpell) + m_caster->RemoveAurasDueToSpell(m_triggeredByAuraSpell->Id); + return; + } + + //Any effect which causes you to lose control of your character will supress the starfall effect. + if(m_caster->hasUnitState(UNIT_STAT_STUNNED | UNIT_STAT_FLEEING | UNIT_STAT_ROOT | UNIT_STAT_CONFUSED)) + return; + switch(m_spellInfo->Id) { case 50286: m_caster->CastSpell(unitTarget, 50288, true); return; diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 37325603e..9a60cb66f 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "7515" + #define REVISION_NR "7516" #endif // __REVISION_NR_H__ From b14bf188c5de0f0c5231077e4c7c14eb99f4f995 Mon Sep 17 00:00:00 2001 From: VladimirMangos Date: Sun, 22 Mar 2009 06:50:09 +0300 Subject: [PATCH 9/9] [7517] Add tick targets amount limitations to 48505 and ranks. --- src/game/Spell.cpp | 14 ++++++++++++++ src/shared/revision_nr.h | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/game/Spell.cpp b/src/game/Spell.cpp index 311f7c02b..bbbaba92a 100644 --- a/src/game/Spell.cpp +++ b/src/game/Spell.cpp @@ -1326,6 +1326,19 @@ void Spell::SetTargetMap(uint32 i,uint32 cur,std::list &TagUnitMap) // Get spell max affected targets uint32 unMaxTargets = m_spellInfo->MaxAffectedTargets; + + // custom target amount cases + switch(m_spellInfo->SpellFamilyName) + { + case SPELLFAMILY_DRUID: + // Starfall + if (m_spellInfo->SpellFamilyFlags2 & 0x00000100LL) + unMaxTargets = 2; + break; + default: + break; + } + Unit::AuraList const& mod = m_caster->GetAurasByType(SPELL_AURA_MOD_MAX_AFFECTED_TARGETS); for(Unit::AuraList::const_iterator m = mod.begin(); m != mod.end(); ++m) { @@ -1333,6 +1346,7 @@ void Spell::SetTargetMap(uint32 i,uint32 cur,std::list &TagUnitMap) continue; unMaxTargets+=(*m)->GetModifier()->m_amount; } + switch(cur) { case TARGET_TOTEM_EARTH: diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 9a60cb66f..c2ffcecab 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "7516" + #define REVISION_NR "7517" #endif // __REVISION_NR_H__