Core/Players: Fixed glyph slots

This commit is contained in:
Shauren
2015-07-11 00:11:16 +02:00
parent facb038b94
commit da3247d5bb
7 changed files with 54 additions and 37 deletions

View File

@@ -927,9 +927,6 @@ CREATE TABLE `character_glyphs` (
`glyph4` smallint(5) unsigned DEFAULT '0',
`glyph5` smallint(5) unsigned DEFAULT '0',
`glyph6` smallint(5) unsigned DEFAULT '0',
`glyph7` smallint(5) unsigned DEFAULT '0',
`glyph8` smallint(5) unsigned DEFAULT '0',
`glyph9` smallint(5) unsigned DEFAULT '0',
PRIMARY KEY (`guid`,`talentGroup`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

View File

@@ -0,0 +1 @@
ALTER TABLE `character_glyphs` DROP `glyph7`, DROP `glyph8`, DROP `glyph9`;

View File

@@ -291,19 +291,20 @@ void DB2Manager::LoadStores(std::string const& dataPath)
for (uint32 j = 0; j < MAX_POWERS; ++j)
_powersByClass[i][j] = MAX_POWERS;
for (uint32 i = 0; i < sChrClassesXPowerTypesStore.GetNumRows(); ++i)
for (ChrClassesXPowerTypesEntry const* power : sChrClassesXPowerTypesStore)
{
if (ChrClassesXPowerTypesEntry const* power = sChrClassesXPowerTypesStore.LookupEntry(i))
{
uint32 index = 0;
for (uint32 j = 0; j < MAX_POWERS; ++j)
if (_powersByClass[power->ClassID][j] != MAX_POWERS)
++index;
uint32 index = 0;
for (uint32 j = 0; j < MAX_POWERS; ++j)
if (_powersByClass[power->ClassID][j] != MAX_POWERS)
++index;
_powersByClass[power->ClassID][power->PowerType] = index;
}
_powersByClass[power->ClassID][power->PowerType] = index;
}
for (GlyphSlotEntry const* glyphSlot : sGlyphSlotStore)
if (glyphSlot->Type == GLYPH_SLOT_MAJOR || glyphSlot->Type == GLYPH_SLOT_MINOR)
_glyphSlots.insert(glyphSlot);
for (ItemBonusEntry const* bonus : sItemBonusStore)
_itemBonusLists[bonus->BonusListID].push_back(bonus);
@@ -782,3 +783,17 @@ std::vector<SpellPowerEntry const*> DB2Manager::GetSpellPowers(uint32 spellId, D
return powers;
}
bool DB2Manager::GlyphSlotEntryComparator::operator()(GlyphSlotEntry const* left, GlyphSlotEntry const* right) const
{
if (left->Tooltip != right->Tooltip)
return left->Tooltip < right->Tooltip;
return left->Type > right->Type;
}
bool DB2Manager::MountTypeXCapabilityEntryComparator::operator()(MountTypeXCapabilityEntry const* left, MountTypeXCapabilityEntry const* right) const
{
if (left->MountTypeID == right->MountTypeID)
return left->OrderIndex > right->OrderIndex;
return left->ID < right->ID;
}

View File

@@ -112,22 +112,22 @@ struct HotfixNotify
typedef std::vector<HotfixNotify> HotfixData;
#define DEFINE_DB2_SET_COMPARATOR(structure) \
struct structure ## Comparator : public std::binary_function<structure const*, structure const*, bool> \
{ \
bool operator()(structure const* left, structure const* right) const; \
};
class DB2Manager
{
public:
struct MountTypeXCapabilityComparator : public std::binary_function<MountTypeXCapabilityEntry const*, MountTypeXCapabilityEntry const*, bool>
{
bool operator()(MountTypeXCapabilityEntry const* left, MountTypeXCapabilityEntry const* right) const
{
if (left->MountTypeID == right->MountTypeID)
return left->OrderIndex > right->OrderIndex;
return left->ID < right->ID;
}
};
DEFINE_DB2_SET_COMPARATOR(GlyphSlotEntry);
DEFINE_DB2_SET_COMPARATOR(MountTypeXCapabilityEntry);
typedef std::map<uint32 /*hash*/, DB2StorageBase*> StorageMap;
typedef std::unordered_map<uint32 /*areaGroupId*/, std::vector<uint32/*areaId*/>> AreaGroupMemberContainer;
typedef std::unordered_map<uint32, CharStartOutfitEntry const*> CharStartOutfitContainer;
typedef std::set<GlyphSlotEntry const*, GlyphSlotEntryComparator> GlyphSlotContainer;
typedef std::map<uint32 /*curveID*/, std::map<uint32/*index*/, CurvePointEntry const*, std::greater<uint32>>> HeirloomCurvesContainer;
typedef std::vector<ItemBonusEntry const*> ItemBonusList;
typedef std::unordered_map<uint32 /*bonusListId*/, ItemBonusList> ItemBonusListContainer;
@@ -136,7 +136,7 @@ public:
typedef std::unordered_map<uint32, std::set<ItemBonusTreeNodeEntry const*>> ItemBonusTreeContainer;
typedef std::unordered_map<uint32, std::vector<ItemSpecOverrideEntry const*>> ItemSpecOverridesContainer;
typedef std::unordered_map<uint32, MountEntry const*> MountContainer;
typedef std::set<MountTypeXCapabilityEntry const*, MountTypeXCapabilityComparator> MountTypeXCapabilitySet;
typedef std::set<MountTypeXCapabilityEntry const*, MountTypeXCapabilityEntryComparator> MountTypeXCapabilitySet;
typedef std::unordered_map<uint32, MountTypeXCapabilitySet> MountCapabilitiesByTypeContainer;
typedef std::unordered_map<uint32, std::array<std::vector<NameGenEntry const*>, 2>> NameGenContainer;
typedef std::unordered_map<uint32, std::set<uint32>> PhaseGroupContainer;
@@ -162,6 +162,7 @@ public:
static char const* GetBroadcastTextValue(BroadcastTextEntry const* broadcastText, LocaleConstant locale = DEFAULT_LOCALE, uint8 gender = GENDER_MALE, bool forceGender = false);
CharStartOutfitEntry const* GetCharStartOutfitEntry(uint8 race, uint8 class_, uint8 gender) const;
uint32 GetPowerIndexByClass(uint32 powerType, uint32 classId) const;
GlyphSlotContainer const& GetGlyphSlots() const { return _glyphSlots; }
uint32 GetHeirloomItemLevel(uint32 curveId, uint32 level) const;
ItemBonusList GetItemBonusList(uint32 bonusListId) const;
std::set<uint32> GetItemBonusTree(uint32 itemId, uint32 itemBonusTreeMod) const;
@@ -184,6 +185,7 @@ private:
AreaGroupMemberContainer _areaGroupMembers;
CharStartOutfitContainer _charStartOutfits;
uint32 _powersByClass[MAX_CLASSES][MAX_POWERS];
GlyphSlotContainer _glyphSlots;
HeirloomCurvesContainer _heirloomCurvePoints;
ItemBonusListContainer _itemBonusLists;
ItemBonusTreeContainer _itemBonusTrees;

View File

@@ -494,6 +494,13 @@ enum AbilytyLearnType
SKILL_LINE_ABILITY_LEARNED_ON_SKILL_LEARN = 2 // Spell will be learned/removed together with entire skill
};
enum GlyphSlotType
{
GLYPH_SLOT_MAJOR = 0,
GLYPH_SLOT_MINOR = 1,
GLYPH_SLOT_PRIME = 2
};
enum ItemEnchantmentType
{
ITEM_ENCHANTMENT_TYPE_NONE = 0,

View File

@@ -24293,20 +24293,16 @@ uint32 Player::GetBarberShopCost(BarberShopStyleEntry const* newHairStyle, uint8
void Player::InitGlyphsForLevel()
{
uint32 slot = 0;
for (uint32 i = 0; i < sGlyphSlotStore.GetNumRows() && slot < MAX_GLYPH_SLOT_INDEX; ++i)
if (GlyphSlotEntry const* gs = sGlyphSlotStore.LookupEntry(i))
SetGlyphSlot(slot++, gs->ID);
uint8 level = getLevel();
uint32 slotMask = 0;
uint8 slot = 0;
uint8 level = getLevel();
for (GlyphSlotEntry const* gs : sDB2Manager.GetGlyphSlots())
{
if (level >= ((gs->Tooltip + 1) * 25))
slotMask |= 1 << slot;
if (level >= 25)
slotMask |= 0x01 | 0x02 | 0x40;
if (level >= 50)
slotMask |= 0x04 | 0x08 | 0x80;
if (level >= 75)
slotMask |= 0x10 | 0x20 | 0x100;
SetGlyphSlot(slot++, gs->ID);
}
SetUInt32Value(PLAYER_GLYPHS_ENABLED, slotMask);
}
@@ -25420,7 +25416,6 @@ void Player::_SaveGlyphs(SQLTransaction& trans)
stmt->setUInt64(0, GetGUID().GetCounter());
trans->Append(stmt);
for (uint8 group = 0; group < GetTalentGroupsCount(); ++group)
{
uint8 index = 0;

View File

@@ -127,7 +127,7 @@ void CharacterDatabaseConnection::DoPrepareStatements()
PrepareStatement(CHAR_SEL_CHARACTER_EQUIPMENTSETS, "SELECT setguid, setindex, name, iconname, ignore_mask, item0, item1, item2, item3, item4, item5, item6, item7, item8, "
"item9, item10, item11, item12, item13, item14, item15, item16, item17, item18 FROM character_equipmentsets WHERE guid = ? ORDER BY setindex", CONNECTION_ASYNC);
PrepareStatement(CHAR_SEL_CHARACTER_BGDATA, "SELECT instanceId, team, joinX, joinY, joinZ, joinO, joinMapId, taxiStart, taxiEnd, mountSpell FROM character_battleground_data WHERE guid = ?", CONNECTION_ASYNC);
PrepareStatement(CHAR_SEL_CHARACTER_GLYPHS, "SELECT talentGroup, glyph1, glyph2, glyph3, glyph4, glyph5, glyph6, glyph7, glyph8, glyph9 FROM character_glyphs WHERE guid = ?", CONNECTION_ASYNC);
PrepareStatement(CHAR_SEL_CHARACTER_GLYPHS, "SELECT talentGroup, glyph1, glyph2, glyph3, glyph4, glyph5, glyph6 FROM character_glyphs WHERE guid = ?", CONNECTION_ASYNC);
PrepareStatement(CHAR_SEL_CHARACTER_TALENTS, "SELECT spell, talentGroup FROM character_talent WHERE guid = ?", CONNECTION_ASYNC);
PrepareStatement(CHAR_SEL_CHARACTER_SKILLS, "SELECT skill, value, max FROM character_skills WHERE guid = ?", CONNECTION_ASYNC);
PrepareStatement(CHAR_SEL_CHARACTER_RANDOMBG, "SELECT guid FROM character_battleground_random WHERE guid = ?", CONNECTION_ASYNC);
@@ -578,7 +578,7 @@ void CharacterDatabaseConnection::DoPrepareStatements()
"spellPower, resilience) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", CONNECTION_ASYNC);
PrepareStatement(CHAR_DEL_PETITION_BY_OWNER, "DELETE FROM petition WHERE ownerguid = ?", CONNECTION_ASYNC);
PrepareStatement(CHAR_DEL_PETITION_SIGNATURE_BY_OWNER, "DELETE FROM petition_sign WHERE ownerguid = ?", CONNECTION_ASYNC);
PrepareStatement(CHAR_INS_CHAR_GLYPHS, "INSERT INTO character_glyphs (guid, talentGroup, glyph1, glyph2, glyph3, glyph4, glyph5, glyph6, glyph7, glyph8, glyph9) VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", CONNECTION_ASYNC);
PrepareStatement(CHAR_INS_CHAR_GLYPHS, "INSERT INTO character_glyphs (guid, talentGroup, glyph1, glyph2, glyph3, glyph4, glyph5, glyph6) VALUES(?, ?, ?, ?, ?, ?, ?, ?)", CONNECTION_ASYNC);
PrepareStatement(CHAR_DEL_CHAR_TALENT_BY_SPELL_SPEC, "DELETE FROM character_talent WHERE guid = ? and spell = ? and talentGroup = ?", CONNECTION_ASYNC);
PrepareStatement(CHAR_INS_CHAR_TALENT, "INSERT INTO character_talent (guid, spell, talentGroup) VALUES (?, ?, ?)", CONNECTION_ASYNC);
PrepareStatement(CHAR_DEL_CHAR_ACTION_EXCEPT_SPEC, "DELETE FROM character_action WHERE spec<>? AND guid = ?", CONNECTION_ASYNC);