Index: src/game/ItemPrototype.h =================================================================== --- src/game/ItemPrototype.h (revision 5306) +++ src/game/ItemPrototype.h (working copy) @@ -536,7 +536,7 @@ uint32 socketBonus; // id from SpellItemEnchantment.dbc uint32 GemProperties; // id from GemProperties.dbc uint32 ExtendedCost; // id from ItemExtendedCost.dbc - uint32 RequiredArenaRank; + uint32 RequiredArenaRank; // id from ItemCondExtCosts.dbc // note: this field should be renamed accordingly uint32 RequiredDisenchantSkill; float ArmorDamageModifier; char* ScriptName; Index: src/game/ObjectMgr.cpp =================================================================== --- src/game/ObjectMgr.cpp (revision 5306) +++ src/game/ObjectMgr.cpp (working copy) @@ -1340,6 +1340,10 @@ if(proto->ExtendedCost && !sItemExtendedCostStore.LookupEntry(proto->ExtendedCost)) sLog.outErrorDb("Item (Entry: %u) has wrong ExtendedCost (%u)",i,proto->ExtendedCost); + // check if the extended cost and the required arena rank pair is valid (does it have entry in ItemCondExtCosts.dbc?) + if(proto->ExtendedCost && proto->RequiredArenaRank && !GetItemCondExtCostsMask(proto->RequiredArenaRank, proto->ExtendedCost)) + sLog.outErrorDb("Item (Entry: %u) has wrong ExtendedCost - RequiredArenaRank pair (%u, %u)",i,proto->ExtendedCost,proto->RequiredArenaRank); + if(proto->FoodType >= MAX_PET_DIET) { sLog.outErrorDb("Item (Entry: %u) has wrong FoodType value (%u)",i,proto->FoodType); Index: src/game/Player.cpp =================================================================== --- src/game/Player.cpp (revision 5306) +++ src/game/Player.cpp (working copy) @@ -15280,6 +15280,9 @@ if(pProto->ExtendedCost) { ItemExtendedCostEntry const* iece = sItemExtendedCostStore.LookupEntry(pProto->ExtendedCost); + uint32 mask = 0; + if(pProto->RequiredArenaRank) + mask = GetItemCondExtCostsMask(pProto->RequiredArenaRank, pProto->ExtendedCost); if(iece) { if(GetHonorPoints() < (iece->reqhonorpoints * count)) @@ -15299,6 +15302,13 @@ SendEquipError(EQUIP_ERR_VENDOR_MISSING_TURNINS, NULL, NULL); return false; } + // check for personal arena rating requirement + if( (mask & (1<<3)) && (GetMaxPersonalArenaRatingRequirement() < iece->reqpersonalarenarating) ) + { + // probably not the proper equip err + SendEquipError(EQUIP_ERR_CANT_EQUIP_RANK,NULL,NULL); + return false; + } } else { @@ -15434,6 +15444,26 @@ return false; } +uint32 Player::GetMaxPersonalArenaRatingRequirement() +{ + // returns the maximal personal arena rating that can be used to purchase items requiring this condition + // the personal rating of the arena team must match the required limit as well + // so return max[in arenateams](min(personalrating[teamtype], teamrating[teamtype])) + uint32 max_personal_rating = 0; + for(int i = 0; i < 3; ++i) + { + if(ArenaTeam * at = objmgr.GetArenaTeamById(GetArenaTeamId(i))) + { + uint32 p_rating = GetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (i * 6) + 5); + uint32 t_rating = at->GetRating(); + p_rating = p_rating sItemSetStore(ItemSetEntryfmt); //DBCStorage sItemDisplayInfoStore(ItemDisplayTemplateEntryfmt); -- not used currently +DBCStorage sItemCondExtCostsStore(ItemCondExtCostsEntryfmt); DBCStorage sItemExtendedCostStore(ItemExtendedCostEntryfmt); DBCStorage sItemRandomPropertiesStore(ItemRandomPropertiesfmt); DBCStorage sItemRandomSuffixStore(ItemRandomSuffixfmt); @@ -170,7 +171,7 @@ { std::string tmpPath=""; - const uint32 DBCFilesCount = 48; + const uint32 DBCFilesCount = 49; barGoLink bar( DBCFilesCount ); @@ -230,6 +231,7 @@ LoadDBC(bar,bad_dbc_files,sGtRegenMPPerSptStore, dataPath+"dbc/gtRegenMPPerSpt.dbc"); //LoadDBC(bar,bad_dbc_files,sItemDisplayInfoStore, dataPath+"dbc/ItemDisplayInfo.dbc"); -- not used currently + LoadDBC(bar,bad_dbc_files,sItemCondExtCostsStore, dataPath+"dbc/ItemCondExtCosts.dbc"); LoadDBC(bar,bad_dbc_files,sItemExtendedCostStore, dataPath+"dbc/ItemExtendedCost.dbc"); LoadDBC(bar,bad_dbc_files,sItemRandomPropertiesStore,dataPath+"dbc/ItemRandomProperties.dbc"); LoadDBC(bar,bad_dbc_files,sItemRandomSuffixStore, dataPath+"dbc/ItemRandomSuffix.dbc"); @@ -542,6 +544,19 @@ return sTalentTabPages[cls]; } +uint32 GetItemCondExtCostsMask(uint32 requiredarenarank, uint32 itemextendedcost) +{ + // create and return mask for (RequiredArenaRank, ItemExtendedCost) pair + uint32 mask = 0; + for(uint32 i = 0; i < sItemCondExtCostsStore.nCount; ++i) + { + ItemCondExtCostsEntry const* icece = sItemCondExtCostsStore.LookupEntry(i); + if(icece && icece->requiredarenarank == requiredarenarank && icece->itemextendedcostentry == itemextendedcost) + mask |= (1 << icece->requirementtype); + } + return mask; +} + // script support functions MANGOS_DLL_SPEC DBCStorage const* GetSpellStore() { return &sSpellStore; } MANGOS_DLL_SPEC DBCStorage const* GetSpellRangeStore() { return &sSpellRangeStore; } Index: src/shared/Database/DBCStores.h =================================================================== --- src/shared/Database/DBCStores.h (revision 5306) +++ src/shared/Database/DBCStores.h (working copy) @@ -44,6 +44,7 @@ uint32 GetTalentInspectBitPosInTab(uint32 talentId); uint32 GetTalentTabInspectBitSize(uint32 talentTabId); uint32 const* /*[3]*/ GetTalentTabPages(uint32 cls); +uint32 GetItemCondExtCostsMask(uint32 requiredarenarank, uint32 itemextendedcost); template class DBCStorage Index: src/shared/Database/DBCStructure.h =================================================================== --- src/shared/Database/DBCStructure.h (revision 5306) +++ src/shared/Database/DBCStructure.h (working copy) @@ -283,6 +283,16 @@ uint32 randomPropertyChance; }; +struct ItemCondExtCostsEntry +{ + // uint32 ID; + uint32 requiredarenarank; // ItemPrototype::RequiredArenaRank + uint32 itemextendedcostentry; // ItemPrototype::ExtendedCost + uint32 requirementtype; // 1 - honor and/or arena point from itemextendedcost + // 2 - required item(s) from itemextendedcost + // 3 - required personal arena rating from itemextendedcost +}; + struct ItemExtendedCostEntry { uint32 ID; // 0 extended-cost entry id @@ -296,7 +306,7 @@ uint32 reqitemcount2; // 9 required count of 2st item uint32 reqitemcount3; // 10 required count of 3st item // 11-12 not used, always 0 (4-5 item count?) - // 13 not used + uint32 reqpersonalarenarating; // 13 required personal arena rating }; struct ItemRandomPropertiesEntry