mirror of
https://github.com/azerothcore/mod-transmog
synced 2025-11-29 22:48:30 +08:00
chore: replace query with charCache & various fixes
This commit is contained in:
@@ -550,9 +550,9 @@ bool Transmogrification::SuitableForTransmogrification(Player* player, ItemTempl
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Transmogrification::SuitableForTransmogrification(ObjectGuid::LowType playerGuid, ItemTemplate const* proto) const
|
bool Transmogrification::SuitableForTransmogrification(ObjectGuid guid, ItemTemplate const* proto) const
|
||||||
{
|
{
|
||||||
if (!playerGuid || !proto)
|
if (!guid || !proto)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (proto->Class != ITEM_CLASS_ARMOR &&
|
if (proto->Class != ITEM_CLASS_ARMOR &&
|
||||||
@@ -566,28 +566,18 @@ bool Transmogrification::SuitableForTransmogrification(ObjectGuid::LowType playe
|
|||||||
if (!CheckPureProtoRequirements(proto))
|
if (!CheckPureProtoRequirements(proto))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
uint32 playerRaceMask;
|
ObjectGuid::LowType playerGuid = guid.GetCounter();
|
||||||
uint32 playerClassMask;
|
CharacterCacheEntry const* playerData = sCharacterCache->GetCharacterCacheByGuid(guid);
|
||||||
TeamId playerTeamId;
|
if (!playerData)
|
||||||
uint8 playerLevel;
|
|
||||||
std::unordered_map<uint32, uint32> playerSkillValues;
|
|
||||||
|
|
||||||
if (QueryResult resultPlayer = CharacterDatabase.Query("SELECT `race`, `class`, `level` FROM `characters` WHERE `guid` = {}", playerGuid))
|
|
||||||
{
|
|
||||||
Field* fields = resultPlayer->Fetch();
|
|
||||||
uint8 playerRace = fields[0].Get<uint8>();
|
|
||||||
uint8 playerClass = fields[1].Get<uint8>();
|
|
||||||
playerLevel = fields[2].Get<uint8>();
|
|
||||||
playerRaceMask = 1 << (playerRace - 1);
|
|
||||||
playerClassMask = 1 << (playerClass - 1);
|
|
||||||
playerTeamId = Player::TeamIdForRace(playerRace);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
LOG_ERROR("module", "Transmogification could not find player with guid {} in database.", playerGuid);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
|
|
||||||
|
uint8 playerRace = playerData->Race;
|
||||||
|
uint8 playerLevel = playerData->Level;
|
||||||
|
uint32 playerRaceMask = 1 << (playerRace - 1);
|
||||||
|
uint32 playerClassMask = 1 << (playerData->Class - 1);
|
||||||
|
TeamId playerTeamId = Player::TeamIdForRace(playerRace);
|
||||||
|
|
||||||
|
std::unordered_map<uint32, uint32> playerSkillValues;
|
||||||
if (QueryResult resultSkills = CharacterDatabase.Query("SELECT `skill`, `value` FROM `character_skills` WHERE `guid` = {}", playerGuid))
|
if (QueryResult resultSkills = CharacterDatabase.Query("SELECT `skill`, `value` FROM `character_skills` WHERE `guid` = {}", playerGuid))
|
||||||
{
|
{
|
||||||
do
|
do
|
||||||
|
|||||||
@@ -158,7 +158,7 @@ public:
|
|||||||
TransmogAcoreStrings Transmogrify(Player* player, Item* itemTransmogrifier, uint8 slot, /*uint32 newEntry, */bool no_cost = false, bool hidden_transmog = false);
|
TransmogAcoreStrings Transmogrify(Player* player, Item* itemTransmogrifier, uint8 slot, /*uint32 newEntry, */bool no_cost = false, bool hidden_transmog = false);
|
||||||
bool CanTransmogrifyItemWithItem(Player* player, ItemTemplate const* destination, ItemTemplate const* source) const;
|
bool CanTransmogrifyItemWithItem(Player* player, ItemTemplate const* destination, ItemTemplate const* source) const;
|
||||||
bool SuitableForTransmogrification(Player* player, ItemTemplate const* proto) const;
|
bool SuitableForTransmogrification(Player* player, ItemTemplate const* proto) const;
|
||||||
bool SuitableForTransmogrification(ObjectGuid::LowType playerGuid, ItemTemplate const* proto) const;
|
bool SuitableForTransmogrification(ObjectGuid guid, ItemTemplate const* proto) const;
|
||||||
bool CheckPureProtoRequirements(ItemTemplate const* proto) const;
|
bool CheckPureProtoRequirements(ItemTemplate const* proto) const;
|
||||||
// bool CanBeTransmogrified(Item const* item);
|
// bool CanBeTransmogrified(Item const* item);
|
||||||
// bool CanTransmogrify(Item const* item);
|
// bool CanTransmogrify(Item const* item);
|
||||||
|
|||||||
@@ -129,7 +129,7 @@ public:
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
suitableForTransmog = sTransmogrification->SuitableForTransmogrification(player->GetGUID().GetCounter(), itemTemplate);
|
suitableForTransmog = sTransmogrification->SuitableForTransmogrification(player->GetGUID(), itemTemplate);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!sTransmogrification->GetTrackUnusableItems() && !suitableForTransmog)
|
if (!sTransmogrification->GetTrackUnusableItems() && !suitableForTransmog)
|
||||||
@@ -146,18 +146,13 @@ public:
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32 itemId = itemTemplate->ItemId;
|
auto guid = player->GetGUID();
|
||||||
uint32 accountId;
|
CharacterCacheEntry const* playerData = sCharacterCache->GetCharacterCacheByGuid(guid);
|
||||||
auto guid = player->GetGUID().GetCounter();
|
if (!playerData)
|
||||||
if (QueryResult result = CharacterDatabase.Query("SELECT `account` FROM `characters` WHERE `guid` = {}", guid))
|
|
||||||
{
|
|
||||||
Field* fields = result->Fetch();
|
|
||||||
accountId = fields[0].Get<uint32>();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
|
uint32 itemId = itemTemplate->ItemId;
|
||||||
|
uint32 accountId = playerData->AccountId;
|
||||||
|
|
||||||
std::stringstream tempStream;
|
std::stringstream tempStream;
|
||||||
tempStream << std::hex << ItemQualityColors[itemTemplate->Quality];
|
tempStream << std::hex << ItemQualityColors[itemTemplate->Quality];
|
||||||
@@ -228,21 +223,15 @@ public:
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto guid = player->GetGUID();
|
||||||
|
CharacterCacheEntry const* playerData = sCharacterCache->GetCharacterCacheByGuid(guid);
|
||||||
|
if (!playerData)
|
||||||
|
return false;
|
||||||
|
|
||||||
bool added = false;
|
bool added = false;
|
||||||
uint32 error = 0;
|
uint32 error = 0;
|
||||||
uint32 itemId;
|
uint32 itemId;
|
||||||
uint32 accountId;
|
uint32 accountId = playerData->AccountId;
|
||||||
|
|
||||||
auto guid = player->GetGUID().GetCounter();
|
|
||||||
if (QueryResult result = CharacterDatabase.Query("SELECT `account` FROM `characters` WHERE `guid` = {}", guid))
|
|
||||||
{
|
|
||||||
Field* fields = result->Fetch();
|
|
||||||
accountId = fields[0].Get<uint32>();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (uint32 i = 0; i < MAX_ITEM_SET_ITEMS; ++i)
|
for (uint32 i = 0; i < MAX_ITEM_SET_ITEMS; ++i)
|
||||||
{
|
{
|
||||||
@@ -254,7 +243,7 @@ public:
|
|||||||
{
|
{
|
||||||
if (!sTransmogrification->GetTrackUnusableItems() && (
|
if (!sTransmogrification->GetTrackUnusableItems() && (
|
||||||
(target && !sTransmogrification->SuitableForTransmogrification(target, itemTemplate)) ||
|
(target && !sTransmogrification->SuitableForTransmogrification(target, itemTemplate)) ||
|
||||||
!sTransmogrification->SuitableForTransmogrification(player->GetGUID().GetCounter(), itemTemplate)
|
!sTransmogrification->SuitableForTransmogrification(guid, itemTemplate)
|
||||||
))
|
))
|
||||||
{
|
{
|
||||||
error = LANG_CMD_TRANSMOG_ADD_UNSUITABLE;
|
error = LANG_CMD_TRANSMOG_ADD_UNSUITABLE;
|
||||||
@@ -284,7 +273,7 @@ public:
|
|||||||
|
|
||||||
int locale = handler->GetSessionDbcLocale();
|
int locale = handler->GetSessionDbcLocale();
|
||||||
std::string setName = set->name[locale];
|
std::string setName = set->name[locale];
|
||||||
std::string nameLink = handler->playerLink(target->GetName());
|
std::string nameLink = handler->playerLink(player->GetName());
|
||||||
|
|
||||||
// Feedback of command execution to GM
|
// Feedback of command execution to GM
|
||||||
if (isNotConsole)
|
if (isNotConsole)
|
||||||
|
|||||||
Reference in New Issue
Block a user