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;
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
if (proto->Class != ITEM_CLASS_ARMOR &&
|
||||
@@ -566,28 +566,18 @@ bool Transmogrification::SuitableForTransmogrification(ObjectGuid::LowType playe
|
||||
if (!CheckPureProtoRequirements(proto))
|
||||
return false;
|
||||
|
||||
uint32 playerRaceMask;
|
||||
uint32 playerClassMask;
|
||||
TeamId playerTeamId;
|
||||
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);
|
||||
ObjectGuid::LowType playerGuid = guid.GetCounter();
|
||||
CharacterCacheEntry const* playerData = sCharacterCache->GetCharacterCacheByGuid(guid);
|
||||
if (!playerData)
|
||||
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))
|
||||
{
|
||||
do
|
||||
|
||||
@@ -158,7 +158,7 @@ public:
|
||||
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 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 CanBeTransmogrified(Item const* item);
|
||||
// bool CanTransmogrify(Item const* item);
|
||||
|
||||
@@ -129,7 +129,7 @@ public:
|
||||
}
|
||||
else
|
||||
{
|
||||
suitableForTransmog = sTransmogrification->SuitableForTransmogrification(player->GetGUID().GetCounter(), itemTemplate);
|
||||
suitableForTransmog = sTransmogrification->SuitableForTransmogrification(player->GetGUID(), itemTemplate);
|
||||
}
|
||||
|
||||
if (!sTransmogrification->GetTrackUnusableItems() && !suitableForTransmog)
|
||||
@@ -146,18 +146,13 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
uint32 itemId = itemTemplate->ItemId;
|
||||
uint32 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
|
||||
{
|
||||
auto guid = player->GetGUID();
|
||||
CharacterCacheEntry const* playerData = sCharacterCache->GetCharacterCacheByGuid(guid);
|
||||
if (!playerData)
|
||||
return false;
|
||||
}
|
||||
|
||||
uint32 itemId = itemTemplate->ItemId;
|
||||
uint32 accountId = playerData->AccountId;
|
||||
|
||||
std::stringstream tempStream;
|
||||
tempStream << std::hex << ItemQualityColors[itemTemplate->Quality];
|
||||
@@ -228,21 +223,15 @@ public:
|
||||
return false;
|
||||
}
|
||||
|
||||
auto guid = player->GetGUID();
|
||||
CharacterCacheEntry const* playerData = sCharacterCache->GetCharacterCacheByGuid(guid);
|
||||
if (!playerData)
|
||||
return false;
|
||||
|
||||
bool added = false;
|
||||
uint32 error = 0;
|
||||
uint32 itemId;
|
||||
uint32 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;
|
||||
}
|
||||
uint32 accountId = playerData->AccountId;
|
||||
|
||||
for (uint32 i = 0; i < MAX_ITEM_SET_ITEMS; ++i)
|
||||
{
|
||||
@@ -254,7 +243,7 @@ public:
|
||||
{
|
||||
if (!sTransmogrification->GetTrackUnusableItems() && (
|
||||
(target && !sTransmogrification->SuitableForTransmogrification(target, itemTemplate)) ||
|
||||
!sTransmogrification->SuitableForTransmogrification(player->GetGUID().GetCounter(), itemTemplate)
|
||||
!sTransmogrification->SuitableForTransmogrification(guid, itemTemplate)
|
||||
))
|
||||
{
|
||||
error = LANG_CMD_TRANSMOG_ADD_UNSUITABLE;
|
||||
@@ -284,7 +273,7 @@ public:
|
||||
|
||||
int locale = handler->GetSessionDbcLocale();
|
||||
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
|
||||
if (isNotConsole)
|
||||
|
||||
Reference in New Issue
Block a user