mirror of
https://github.com/azerothcore/mod-transmog
synced 2025-11-29 22:48:30 +08:00
Use new unit hooks to optimize BuildValuesUpdate (#146)
* Use new unit hooks to optimize BuildValuesUpdate * Parameter not used * Address code review feedback --------- Co-authored-by: Pagani Walter <paganiwalter@gmail.com>
This commit is contained in:
committed by
GitHub
parent
08e9273fcd
commit
a21dac36ea
@@ -1118,21 +1118,24 @@ class unit_transmog_script : public UnitScript
|
||||
public:
|
||||
unit_transmog_script() : UnitScript("unit_transmog_script") { }
|
||||
|
||||
bool OnBuildValuesUpdate(Unit const* unit, uint8 /*updateType*/, ByteBuffer& fieldBuffer, Player* target, uint16 index) override
|
||||
bool ShouldTrackValuesUpdatePosByIndex(Unit const* unit, uint8 /*updateType*/, uint16 index) override
|
||||
{
|
||||
if (unit->IsPlayer() && index >= PLAYER_VISIBLE_ITEM_1_ENTRYID && index <= PLAYER_VISIBLE_ITEM_19_ENTRYID && (index & 1))
|
||||
{
|
||||
if (Item* item = unit->ToPlayer()->GetItemByPos(INVENTORY_SLOT_BAG_0, ((index - PLAYER_VISIBLE_ITEM_1_ENTRYID) / 2U)))
|
||||
{
|
||||
if (!sTransmogrification->IsEnabled() || target->GetPlayerSetting("mod-transmog", SETTING_HIDE_TRANSMOG).value)
|
||||
{
|
||||
fieldBuffer << item->GetEntry();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return unit->IsPlayer() && index >= PLAYER_VISIBLE_ITEM_1_ENTRYID && index <= PLAYER_VISIBLE_ITEM_19_ENTRYID && (index & 1);
|
||||
}
|
||||
|
||||
return false;
|
||||
void OnPatchValuesUpdate(Unit const* unit, ByteBuffer& valuesUpdateBuf, BuildValuesCachePosPointers& posPointers, Player* target) override
|
||||
{
|
||||
if (!unit->IsPlayer())
|
||||
return;
|
||||
|
||||
for (auto it = posPointers.other.begin(); it != posPointers.other.end(); ++it)
|
||||
{
|
||||
uint16 index = it->first;
|
||||
if (index >= PLAYER_VISIBLE_ITEM_1_ENTRYID && index <= PLAYER_VISIBLE_ITEM_19_ENTRYID && (index & 1))
|
||||
if (Item* item = unit->ToPlayer()->GetItemByPos(INVENTORY_SLOT_BAG_0, ((index - PLAYER_VISIBLE_ITEM_1_ENTRYID) / 2U)))
|
||||
if (!sTransmogrification->IsEnabled() || target->GetPlayerSetting("mod-transmog", SETTING_HIDE_TRANSMOG).value)
|
||||
valuesUpdateBuf.put(it->second, item->GetEntry());
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user