Merge branch 'master' of github.com:azerothcore/azerothcore-wotlk into Playerbot

This commit is contained in:
Yunfan Li
2023-09-23 22:44:15 +08:00
154 changed files with 7913 additions and 4858 deletions

View File

@@ -384,6 +384,8 @@ Player::Player(WorldSession* session): Unit(true), m_mover(this)
_activeCheats = CHEAT_NONE;
m_creationTime = 0s;
_cinematicMgr = new CinematicMgr(this);
m_achievementMgr = new AchievementMgr(this);
@@ -8043,6 +8045,12 @@ void Player::SendLoot(ObjectGuid guid, LootType loot_type)
// need know merged fishing/corpse loot type for achievements
loot->loot_type = loot_type;
if (!sScriptMgr->OnAllowedToLootContainerCheck(this, guid))
{
SendLootError(guid, LOOT_ERROR_DIDNT_KILL);
return;
}
if (permission != NONE_PERMISSION)
{
SetLootGUID(guid);
@@ -13268,6 +13276,8 @@ void Player::SetTitle(CharTitlesEntry const* title, bool lost)
data << uint32(title->bit_index);
data << uint32(lost ? 0 : 1); // 1 - earned, 0 - lost
GetSession()->SendPacket(&data);
UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_OWN_RANK);
}
uint32 Player::GetRuneBaseCooldown(uint8 index, bool skipGrace)
@@ -13544,8 +13554,13 @@ uint32 Player::CalculateTalentsPoints() const
return uint32(talentPointsForLevel * sWorld->getRate(RATE_TALENT));
}
bool Player::canFlyInZone(uint32 mapid, uint32 zone, SpellInfo const* bySpell) const
bool Player::canFlyInZone(uint32 mapid, uint32 zone, SpellInfo const* bySpell)
{
if (!sScriptMgr->OnCanPlayerFlyInZone(this, mapid,zone,bySpell))
{
return false;
}
// continent checked in SpellInfo::CheckLocation at cast and area update
uint32 v_map = GetVirtualMapForMapAndZone(mapid, zone);
if (v_map == 571 && !bySpell->HasAttribute(SPELL_ATTR7_IGNORES_COLD_WEATHER_FLYING_REQUIREMENT))

View File

@@ -2299,7 +2299,7 @@ public:
}
void HandleFall(MovementInfo const& movementInfo);
[[nodiscard]] bool canFlyInZone(uint32 mapid, uint32 zone, SpellInfo const* bySpell) const;
[[nodiscard]] bool canFlyInZone(uint32 mapid, uint32 zone, SpellInfo const* bySpell);
void SetClientControl(Unit* target, bool allowMove, bool packetOnly = false);
@@ -2495,6 +2495,9 @@ public:
void CompletedAchievement(AchievementEntry const* entry);
[[nodiscard]] AchievementMgr* GetAchievementMgr() const { return m_achievementMgr; }
void SetCreationTime(Seconds creationTime) { m_creationTime = creationTime; }
[[nodiscard]] Seconds GetCreationTime() const { return m_creationTime; }
[[nodiscard]] bool HasTitle(uint32 bitIndex) const;
bool HasTitle(CharTitlesEntry const* title) const { return HasTitle(title->bit_index); }
void SetTitle(CharTitlesEntry const* title, bool lost = false);
@@ -2951,6 +2954,8 @@ private:
bool _wasOutdoor;
PlayerSettingMap m_charSettingsMap;
Seconds m_creationTime;
};
void AddItemsSetItem(Player* player, Item* item);

View File

@@ -4948,8 +4948,8 @@ bool Player::LoadFromDB(ObjectGuid playerGuid, CharacterDatabaseQueryHolder cons
//"arenaPoints, totalHonorPoints, todayHonorPoints, yesterdayHonorPoints, totalKills, todayKills, yesterdayKills, chosenTitle, knownCurrencies, watchedFaction, drunk, "
// 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
//"health, power1, power2, power3, power4, power5, power6, power7, instance_id, talentGroupsCount, activeTalentGroup, exploredZones, equipmentCache, ammoId, knownTitles,
// 70 71 72 73
//"actionBars, grantableLevels, innTriggerId, extraBonusTalentCount FROM characters WHERE guid = '{}'", guid);
// 70 71 72 73 74
//"actionBars, grantableLevels, innTriggerId, extraBonusTalentCount, UNIX_TIMESTAMP(creation_date) FROM characters WHERE guid = '{}'", guid);
PreparedQueryResult result = holder.GetPreparedResult(PLAYER_LOGIN_QUERY_LOAD_FROM);
if (!result)
@@ -5026,6 +5026,9 @@ bool Player::LoadFromDB(ObjectGuid playerGuid, CharacterDatabaseQueryHolder cons
SetObjectScale(1.0f);
SetFloatValue(UNIT_FIELD_HOVERHEIGHT, 1.0f);
// load character creation date, relevant for achievements of type average
SetCreationTime(fields[74].Get<Seconds>());
// load achievements before anything else to prevent multiple gains for the same achievement/criteria on every loading (as loading does call UpdateAchievementCriteria)
m_achievementMgr->LoadFromDB(holder.GetPreparedResult(PLAYER_LOGIN_QUERY_LOAD_ACHIEVEMENTS), holder.GetPreparedResult(PLAYER_LOGIN_QUERY_LOAD_CRITERIA_PROGRESS));