aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/game/ObjectMgr.cpp11
-rw-r--r--src/game/Player.cpp49
-rw-r--r--src/game/Player.h1
-rw-r--r--src/shared/Database/DBCStores.cpp4
-rw-r--r--src/shared/Database/DBCStores.h1
-rw-r--r--src/shared/Database/DBCStructure.h17
-rw-r--r--src/shared/Database/DBCfmt.cpp1
7 files changed, 75 insertions, 9 deletions
diff --git a/src/game/ObjectMgr.cpp b/src/game/ObjectMgr.cpp
index fec531f96d9..dfd451665c2 100644
--- a/src/game/ObjectMgr.cpp
+++ b/src/game/ObjectMgr.cpp
@@ -1824,6 +1824,17 @@ void ObjectMgr::LoadItemPrototypes()
{
sLog.outErrorDb("Item (Entry: %u) has bag family bit set not listed in ItemBagFamily.dbc, remove bit",i);
const_cast<ItemPrototype*>(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<ItemPrototype*>(proto)->BagFamily &= ~mask;
+ }
}
}
}
diff --git a/src/game/Player.cpp b/src/game/Player.cpp
index 691a56557bc..6133026222d 100644
--- a/src/game/Player.cpp
+++ b/src/game/Player.cpp
@@ -9289,7 +9289,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)
@@ -9627,9 +9627,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);
@@ -9650,7 +9666,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)
@@ -9798,9 +9813,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)
@@ -9820,7 +9833,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++)
{
@@ -10719,6 +10731,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();
@@ -11026,6 +11042,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);
@@ -11137,6 +11156,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;
}
@@ -20875,3 +20897,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 acaa1af8c89..8eb26c3b6fd 100644
--- a/src/game/Player.h
+++ b/src/game/Player.h
@@ -2371,6 +2371,7 @@ class TRINITY_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 2565eb2cc1e..6b59489f77e 100644
--- a/src/shared/Database/DBCStores.cpp
+++ b/src/shared/Database/DBCStores.cpp
@@ -52,6 +52,7 @@ DBCStorage <CreatureDisplayInfoEntry> sCreatureDisplayInfoStore(CreatureDisplayI
DBCStorage <CreatureFamilyEntry> sCreatureFamilyStore(CreatureFamilyfmt);
DBCStorage <CreatureSpellDataEntry> sCreatureSpellDataStore(CreatureSpellDatafmt);
DBCStorage <CreatureTypeEntry> sCreatureTypeStore(CreatureTypefmt);
+DBCStorage <CurrencyTypesEntry> sCurrencyTypesStore(CurrencyTypesfmt);
DBCStorage <DurabilityQualityEntry> sDurabilityQualityStore(DurabilityQualityfmt);
DBCStorage <DurabilityCostsEntry> sDurabilityCostsStore(DurabilityCostsfmt);
@@ -197,7 +198,7 @@ void LoadDBCStores(const std::string& dataPath)
{
std::string dbcPath = dataPath+"dbc/";
- const uint32 DBCFilesCount = 74;
+ const uint32 DBCFilesCount = 75;
barGoLink bar( DBCFilesCount );
@@ -238,6 +239,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 07ed80571f9..3e8d3280596 100644
--- a/src/shared/Database/DBCStores.h
+++ b/src/shared/Database/DBCStores.h
@@ -150,6 +150,7 @@ extern DBCStorage <CreatureDisplayInfoEntry> sCreatureDisplayInfoStore;
extern DBCStorage <CreatureFamilyEntry> sCreatureFamilyStore;
extern DBCStorage <CreatureSpellDataEntry> sCreatureSpellDataStore;
extern DBCStorage <CreatureTypeEntry> sCreatureTypeStore;
+extern DBCStorage <CurrencyTypesEntry> sCurrencyTypesStore;
extern DBCStorage <DurabilityCostsEntry> sDurabilityCostsStore;
extern DBCStorage <DurabilityQualityEntry> sDurabilityQualityStore;
extern DBCStorage <EmotesTextEntry> sEmotesTextStore;
diff --git a/src/shared/Database/DBCStructure.h b/src/shared/Database/DBCStructure.h
index 4cb57a165f2..bc44caa8127 100644
--- a/src/shared/Database/DBCStructure.h
+++ b/src/shared/Database/DBCStructure.h
@@ -700,6 +700,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 6230298b11d..53c15827bae 100644
--- a/src/shared/Database/DBCfmt.cpp
+++ b/src/shared/Database/DBCfmt.cpp
@@ -37,6 +37,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";