Fix corrupt item cache crashes, bot whispers, trade crashes

This commit is contained in:
郑佩茹
2022-03-22 10:51:50 -06:00
parent ff0e5d5e3b
commit db71f4739c
25 changed files with 299 additions and 88 deletions

View File

@@ -12005,11 +12005,21 @@ bool Player::GetBGAccessByLevel(BattlegroundTypeId bgTypeId) const
float Player::GetReputationPriceDiscount(Creature const* creature) const
{
FactionTemplateEntry const* vendor_faction = creature->GetFactionTemplateEntry();
if (!vendor_faction || !vendor_faction->faction)
FactionTemplateEntry const* vendorFaction = creature->GetFactionTemplateEntry();
if (!vendorFaction)
{
return 1.0f;
}
return GetReputationPriceDiscount(vendorFaction);
}
float Player::GetReputationPriceDiscount(FactionTemplateEntry const* vendorFaction) const
{
if (!vendorFaction->faction)
return 1.0f;
ReputationRank rank = GetReputationRank(vendor_faction->faction);
ReputationRank rank = GetReputationRank(vendorFaction->faction);
if (rank <= REP_NEUTRAL)
return 1.0f;
@@ -15935,3 +15945,9 @@ uint32 Player::GetSpellCooldownDelay(uint32 spell_id) const
SpellCooldowns::const_iterator itr = m_spellCooldowns.find(spell_id);
return uint32(itr != m_spellCooldowns.end() && itr->second.end > getMSTime() ? itr->second.end - getMSTime() : 0);
}
void Player::ResetSpeakTimers()
{
m_speakTime = 0;
m_speakCount = 0;
}

View File

@@ -662,7 +662,7 @@ enum PlayerSlots
#define INVENTORY_SLOT_BAG_0 255
enum EquipmentSlots // 19 slots
enum EquipmentSlots : uint32 // 19 slots
{
EQUIPMENT_SLOT_START = 0,
EQUIPMENT_SLOT_HEAD = 0,
@@ -1323,6 +1323,7 @@ public:
bool _StoreOrEquipNewItem(uint32 vendorslot, uint32 item, uint8 count, uint8 bag, uint8 slot, int32 price, ItemTemplate const* pProto, Creature* pVendor, VendorItem const* crItem, bool bStore);
float GetReputationPriceDiscount(Creature const* creature) const;
float GetReputationPriceDiscount(FactionTemplateEntry const* vendorFaction) const;
[[nodiscard]] Player* GetTrader() const { return m_trade ? m_trade->GetTrader() : nullptr; }
[[nodiscard]] TradeData* GetTradeData() const { return m_trade; }
@@ -2538,6 +2539,8 @@ public:
[[nodiscard]] PlayerSetting GetPlayerSetting(std::string source, uint8 index);
void UpdatePlayerSetting(std::string source, uint8 index, uint32 value);
void ResetSpeakTimers();
protected:
// Gamemaster whisper whitelist
WhisperListContainer WhisperList;