Merge branch 'master' into Playerbot

This commit is contained in:
Yunfan Li
2024-09-22 21:56:15 +08:00
195 changed files with 1915 additions and 1883 deletions

View File

@@ -4336,6 +4336,49 @@ void Player::DeleteOldCharacters(uint32 keepDays)
}
}
/**
* Items which were kept back in the database after being deleted and are now too old (see config option "ItemDelete.KeepDays"), will be completely deleted.
*/
void Player::DeleteOldRecoveryItems()
{
uint32 keepDays = sWorld->getIntConfig(CONFIG_ITEMDELETE_KEEP_DAYS);
if (!keepDays)
return;
Player::DeleteOldRecoveryItems(keepDays);
}
/**
* Items which were kept back in the database after being deleted and are older than the specified amount of days, will be completely deleted.
*/
void Player::DeleteOldRecoveryItems(uint32 keepDays)
{
LOG_INFO("server.loading", "Player::DeleteOldRecoveryItems: Deleting all items which have been deleted {} days before...", keepDays);
LOG_INFO("server.loading", " ");
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_RECOVERY_ITEM_OLD_ITEMS);
stmt->SetData(0, uint32(GameTime::GetGameTime().count() - time_t(keepDays * DAY)));
PreparedQueryResult result = CharacterDatabase.Query(stmt);
if (result)
{
LOG_INFO("server.loading", "Player::DeleteOldRecoveryItems: Found {} item(s) to delete", result->GetRowCount());
do
{
Field* fields = result->Fetch();
uint32 guid = fields[0].Get<uint32>();
uint32 itemEntry = fields[1].Get<uint32>();
CharacterDatabasePreparedStatement* deleteStmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_RECOVERY_ITEM_BY_GUID);
deleteStmt->SetData(0, guid);
CharacterDatabase.Execute(deleteStmt);
LOG_INFO("server.loading", "Deleted item from recovery_item table where guid {} and item id {}", guid, itemEntry);
} while (result->NextRow());
}
}
void Player::SetMovement(PlayerMovementType pType)
{
WorldPacket data;
@@ -4686,7 +4729,7 @@ void Player::DurabilityLossAll(double percent, bool inventory)
void Player::DurabilityLoss(Item* item, double percent)
{
if(!item || percent == 0.0)
if (!item || percent == 0.0)
return;
uint32 pMaxDurability = item ->GetUInt32Value(ITEM_FIELD_MAXDURABILITY);
@@ -10012,13 +10055,13 @@ void Player::RemoveSpellMods(Spell* spell)
spell->m_appliedMods.erase(iterMod);
// MAGE T8P4 BONUS
if( spellInfo->SpellFamilyName == SPELLFAMILY_MAGE )
if (spellInfo->SpellFamilyName == SPELLFAMILY_MAGE)
{
SpellInfo const* sp = mod->ownerAura->GetSpellInfo();
// Missile Barrage, Hot Streak, Brain Freeze (trigger spell - Fireball!)
if( sp->SpellIconID == 3261 || sp->SpellIconID == 2999 || sp->SpellIconID == 2938 )
if( AuraEffect* aurEff = GetAuraEffectDummy(64869) )
if( roll_chance_i(aurEff->GetAmount()) )
if (sp->SpellIconID == 3261 || sp->SpellIconID == 2999 || sp->SpellIconID == 2938)
if (AuraEffect* aurEff = GetAuraEffectDummy(64869))
if (roll_chance_i(aurEff->GetAmount()))
{
mod->charges = 1;
continue;
@@ -15454,7 +15497,7 @@ void Player::PrepareCharmAISpells()
}
else if (spellInfo->Effects[i].ApplyAuraName == SPELL_AURA_PERIODIC_DAMAGE)
{
if( (int32)periodic_damage < CalculateSpellDamage(this, spellInfo, i) )
if ((int32)periodic_damage < CalculateSpellDamage(this, spellInfo, i))
{
m_charmAISpells[SPELL_DOT_DAMAGE] = spellInfo->Id;
break;

View File

@@ -1568,6 +1568,9 @@ public:
static void DeleteOldCharacters();
static void DeleteOldCharacters(uint32 keepDays);
static void DeleteOldRecoveryItems();
static void DeleteOldRecoveryItems(uint32 keepDays);
bool m_mailsUpdated;
void SetBindPoint(ObjectGuid guid);

View File

@@ -294,7 +294,7 @@ bool Player::CanCompleteQuest(uint32 quest_id, const QuestStatusData* q_savedSta
return false;
// Xinef: take seasonals into account
if(!qInfo->IsRepeatable() && !qInfo->IsSeasonal() && IsQuestRewarded(quest_id))
if (!qInfo->IsRepeatable() && !qInfo->IsSeasonal() && IsQuestRewarded(quest_id))
return false; // not allow re-complete quest
// auto complete quest

View File

@@ -991,7 +991,7 @@ InventoryResult Player::CanStoreItem_InBag(uint8 bag, ItemPosCountVec& dest, Ite
// skip not existed bag or self targeted bag
Bag* pBag = GetBagByPos(bag);
if (!pBag || pBag == pSrcItem || (pSrcItem && (pSrcItem->GetGUID() == pBag->GetGUID())) )
if (!pBag || pBag == pSrcItem || (pSrcItem && (pSrcItem->GetGUID() == pBag->GetGUID())))
return EQUIP_ERR_ITEM_DOESNT_GO_INTO_BAG;
if (pSrcItem && pSrcItem->IsNotEmptyBag())
@@ -1119,8 +1119,8 @@ InventoryResult Player::CanStoreItem(uint8 bag, uint8 slot, ItemPosCountVec& des
if (pItem)
{
// you bad chet0rz, wpe pro
if( bag == NULL_BAG && slot == NULL_SLOT )
if( pItem->IsBag() && pItem->IsNotEmptyBag() )
if (bag == NULL_BAG && slot == NULL_SLOT)
if (pItem->IsBag() && pItem->IsNotEmptyBag())
return EQUIP_ERR_CAN_ONLY_DO_WITH_EMPTY_BAGS;
// Xinef: Removed next loot generated check
@@ -7197,7 +7197,7 @@ void Player::_SaveAuras(CharacterDatabaseTransaction trans, bool logout)
continue;
Aura* aura = itr->second;
if( !logout && aura->GetDuration() < 60 * IN_MILLISECONDS )
if (!logout && aura->GetDuration() < 60 * IN_MILLISECONDS )
continue;
int32 damage[MAX_SPELL_EFFECTS];