Merge branch 'master' into Playerbot

This commit is contained in:
Yunfan Li
2023-12-12 20:52:42 +08:00
1088 changed files with 35633 additions and 19812 deletions
+1 -1
View File
@@ -50,7 +50,7 @@ public:
KillMagnetEvent(Unit& self) : _self(self) { }
bool Execute(uint64 /*e_time*/, uint32 /*p_time*/) override
{
_self.setDeathState(JUST_DIED);
_self.setDeathState(DeathState::JustDied);
return true;
}
+10 -3
View File
@@ -152,7 +152,7 @@ struct PowerUsersSelector : public Acore::unary_function<Unit*, bool>
struct FarthestTargetSelector : public Acore::unary_function<Unit*, bool>
{
FarthestTargetSelector(Unit const* unit, float dist, bool playerOnly, bool inLos) : _me(unit), _dist(dist), _playerOnly(playerOnly), _inLos(inLos) {}
FarthestTargetSelector(Unit const* unit, float maxDist, bool playerOnly, bool inLos, float minDist = 0.f) : _me(unit), _minDist(minDist), _maxDist(maxDist), _playerOnly(playerOnly), _inLos(inLos) {}
bool operator()(Unit const* target) const
{
@@ -162,7 +162,7 @@ struct FarthestTargetSelector : public Acore::unary_function<Unit*, bool>
if (_playerOnly && target->GetTypeId() != TYPEID_PLAYER)
return false;
if (_dist > 0.0f && !_me->IsWithinCombatRange(target, _dist))
if (_maxDist > 0.0f && !_me->IsInRange(target, _minDist, _maxDist))
return false;
if (_inLos && !_me->IsWithinLOSInMap(target))
@@ -173,7 +173,7 @@ struct FarthestTargetSelector : public Acore::unary_function<Unit*, bool>
private:
Unit const* _me;
float _dist;
float _minDist, _maxDist;
bool _playerOnly;
bool _inLos;
};
@@ -364,6 +364,13 @@ public:
// Called when the unit heals
virtual void HealDone(Unit* /*done_to*/, uint32& /*addhealth*/) {}
// Called during damage calculations
virtual void OnCalculateMeleeDamageReceived(uint32& /*damage*/, Unit* /*attacker*/) {}
virtual void OnCalculateSpellDamageReceived(int32& /*damage*/, Unit* /*attacker*/) {}
// Called during calculation when receiving periodic healing or damage (DoT or HoT)
virtual void OnCalculatePeriodicTickReceived(uint32& /*damage*/, Unit* /*attacker*/) {}
void AttackStartCaster(Unit* victim, float dist);
SpellCastResult DoAddAuraToAllHostilePlayers(uint32 spellid);
+2 -2
View File
@@ -15,8 +15,8 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "AreaBoundary.h"
#include "CreatureAI.h"
#include "AreaBoundary.h"
#include "Creature.h"
#include "CreatureAIImpl.h"
#include "CreatureGroups.h"
@@ -24,8 +24,8 @@
#include "Log.h"
#include "MapReference.h"
#include "Player.h"
#include "Vehicle.h"
#include "ScriptMgr.h"
#include "Vehicle.h"
#include "ZoneScript.h"
//Disable CreatureAI when charmed
+3 -1
View File
@@ -21,8 +21,9 @@
#include "AreaBoundary.h"
#include "Common.h"
#include "Creature.h"
#include "UnitAI.h"
#include "EventMap.h"
#include "TaskScheduler.h"
#include "UnitAI.h"
class WorldObject;
class Unit;
@@ -72,6 +73,7 @@ protected:
Creature* const me;
EventMap events;
TaskScheduler scheduler;
bool UpdateVictim();
bool UpdateVictimWithGaze();
+1 -1
View File
@@ -18,6 +18,7 @@
#include "CreatureAIRegistry.h"
#include "CombatAI.h"
#include "CreatureAIFactory.h"
#include "GameObjectAIFactory.h"
#include "GuardAI.h"
#include "MovementGenerator.h"
#include "PassiveAI.h"
@@ -27,7 +28,6 @@
#include "SmartAI.h"
#include "TotemAI.h"
#include "WaypointMovementGenerator.h"
#include "GameObjectAIFactory.h"
namespace AIRegistry
{
+1 -1
View File
@@ -15,8 +15,8 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "Creature.h"
#include "CreatureAISelector.h"
#include "Creature.h"
#include "CreatureAIFactory.h"
#include "MovementGenerator.h"
+3
View File
@@ -18,6 +18,8 @@
#ifndef ACORE_CREATUREAISELECTOR_H
#define ACORE_CREATUREAISELECTOR_H
#include "Define.h"
class CreatureAI;
class Creature;
class MovementGenerator;
@@ -31,4 +33,5 @@ namespace FactorySelector
AC_GAME_API MovementGenerator* SelectMovementGenerator(Unit* unit);
AC_GAME_API GameObjectAI* SelectGameObjectAI(GameObject* go);
}
#endif
+2 -1
View File
@@ -18,8 +18,9 @@
#ifndef ACORE_GAMEOBJECTAIFACTORY_H
#define ACORE_GAMEOBJECTAIFACTORY_H
#include "ObjectRegistry.h"
#include "FactoryHolder.h"
#include "GameObjectAI.h"
#include "ObjectRegistry.h"
typedef FactoryHolder<GameObjectAI, GameObject> GameObjectAICreator;
@@ -311,6 +311,29 @@ Creature* ScriptedAI::DoSpawnCreature(uint32 entry, float offsetX, float offsetY
return me->SummonCreature(entry, me->GetPositionX() + offsetX, me->GetPositionY() + offsetY, me->GetPositionZ() + offsetZ, angle, TempSummonType(type), despawntime);
}
void ScriptedAI::ScheduleTimedEvent(Milliseconds timerMin, Milliseconds timerMax, std::function<void()> exec, Milliseconds repeatMin, Milliseconds repeatMax, uint32 uniqueId)
{
if (uniqueId && IsUniqueTimedEventDone(uniqueId))
{
return;
}
scheduler.Schedule(timerMin == 0s ? timerMax : timerMin, timerMax, [exec, repeatMin, repeatMax, uniqueId](TaskContext context)
{
exec();
if (!uniqueId)
{
repeatMax > 0s ? context.Repeat(repeatMin, repeatMax) : context.Repeat(repeatMin);
}
});
if (uniqueId)
{
SetUniqueTimedEventDone(uniqueId);
}
}
SpellInfo const* ScriptedAI::SelectSpell(Unit* target, uint32 school, uint32 mechanic, SelectTargetType targets, uint32 powerCostMin, uint32 powerCostMax, float rangeMin, float rangeMax, SelectEffect effects)
{
//No target so we can't cast
@@ -556,6 +579,13 @@ BossAI::BossAI(Creature* creature, uint32 bossId) : ScriptedAI(creature),
{
if (instance)
SetBoundary(instance->GetBossBoundary(bossId));
// Prevents updating the scheduler's timer while the creature is casting.
// Clear it in the script if you need it to update while the creature is casting.
scheduler.SetValidator([this]
{
return !me->HasUnitState(UNIT_STATE_CASTING);
});
}
bool BossAI::CanRespawn()
@@ -581,6 +611,7 @@ void BossAI::_Reset()
events.Reset();
scheduler.CancelAll();
summons.DespawnAll();
ClearUniqueTimedEventsDone();
_healthCheckEvents.clear();
if (instance)
instance->SetBossState(_bossId, NOT_STARTED);
@@ -21,8 +21,8 @@
#include "Creature.h"
#include "CreatureAI.h"
#include "CreatureAIImpl.h"
#include "InstanceScript.h"
#include "EventMap.h"
#include "InstanceScript.h"
#include "TaskScheduler.h"
#define CAST_AI(a, b) (dynamic_cast<a*>(b))
@@ -353,6 +353,18 @@ struct ScriptedAI : public CreatureAI
//Spawns a creature relative to me
Creature* DoSpawnCreature(uint32 entry, float offsetX, float offsetY, float offsetZ, float angle, uint32 type, uint32 despawntime);
bool IsUniqueTimedEventDone(uint32 id) const { return _uniqueTimedEvents.find(id) != _uniqueTimedEvents.end(); }
void SetUniqueTimedEventDone(uint32 id) { _uniqueTimedEvents.insert(id); }
void ResetUniqueTimedEvent(uint32 id) { _uniqueTimedEvents.erase(id); }
void ClearUniqueTimedEventsDone() { _uniqueTimedEvents.clear(); }
// Schedules a timed event using task scheduler.
void ScheduleTimedEvent(Milliseconds timerMin, Milliseconds timerMax, std::function<void()> exec, Milliseconds repeatMin, Milliseconds repeatMax = 0s, uint32 uniqueId = 0);
void ScheduleTimedEvent(Milliseconds timerMax, std::function<void()> exec, Milliseconds repeatMin, Milliseconds repeatMax = 0s, uint32 uniqueId = 0) { ScheduleTimedEvent(0s, timerMax, exec, repeatMin, repeatMax, uniqueId); };
// Schedules a timed event using task scheduler that never repeats. Requires an unique non-zero ID.
void ScheduleUniqueTimedEvent(Milliseconds timer, std::function<void()> exec, uint32 uniqueId) { ScheduleTimedEvent(0s, timer, exec, 0s, 0s, uniqueId); };
bool HealthBelowPct(uint32 pct) const { return me->HealthBelowPct(pct); }
bool HealthAbovePct(uint32 pct) const { return me->HealthAbovePct(pct); }
@@ -442,6 +454,7 @@ private:
Difficulty _difficulty;
bool _isCombatMovementAllowed;
bool _isHeroic;
std::unordered_set<uint32> _uniqueTimedEvents;
};
struct HealthCheckEventData
@@ -494,9 +507,7 @@ protected:
void TeleportCheaters();
EventMap events;
SummonList summons;
TaskScheduler scheduler;
private:
uint32 const _bossId;
@@ -259,7 +259,7 @@ void npc_escortAI::UpdateAI(uint32 diff)
if (m_bCanInstantRespawn)
{
me->setDeathState(JUST_DIED);
me->setDeathState(DeathState::JustDied);
me->Respawn();
}
else
@@ -299,7 +299,7 @@ void npc_escortAI::UpdateAI(uint32 diff)
{
if (m_bCanInstantRespawn)
{
me->setDeathState(JUST_DIED);
me->setDeathState(DeathState::JustDied);
me->Respawn();
}
else
+1 -1
View File
@@ -16,13 +16,13 @@
*/
#include "SmartAI.h"
#include "AreaTriggerScript.h"
#include "CellImpl.h"
#include "GridDefines.h"
#include "GridNotifiers.h"
#include "Group.h"
#include "ObjectDefines.h"
#include "ObjectMgr.h"
#include "ScriptMgr.h"
#include "ScriptedCreature.h"
#include "SpellMgr.h"
#include "Vehicle.h"
@@ -3243,7 +3243,7 @@ void SmartScript::GetTargets(ObjectVector& targets, SmartScriptHolder const& e,
case SMART_TARGET_FARTHEST:
if (me)
{
if (Unit* u = me->AI()->SelectTarget(SelectTargetMethod::MinDistance, 0, FarthestTargetSelector(me, e.target.farthest.maxDist, e.target.farthest.playerOnly, e.target.farthest.isInLos)))
if (Unit* u = me->AI()->SelectTarget(SelectTargetMethod::MinDistance, 0, FarthestTargetSelector(me, e.target.farthest.maxDist, e.target.farthest.playerOnly, e.target.farthest.isInLos, e.target.farthest.minDist)))
targets.push_back(u);
}
break;
@@ -1488,7 +1488,7 @@ enum SMARTAI_TARGETS
SMART_TARGET_CLOSEST_ENEMY = 25, // maxDist, playerOnly
SMART_TARGET_CLOSEST_FRIENDLY = 26, // maxDist, playerOnly
SMART_TARGET_LOOT_RECIPIENTS = 27, // all players that have tagged this creature (for kill credit)
SMART_TARGET_FARTHEST = 28, // maxDist, playerOnly, isInLos
SMART_TARGET_FARTHEST = 28, // maxDist, playerOnly, isInLos, minDist
SMART_TARGET_VEHICLE_PASSENGER = 29, // seat number (vehicle can target it's own accessory)
SMART_TARGET_TC_END = 30, // placeholder
@@ -1538,6 +1538,7 @@ struct SmartTarget
uint32 maxDist;
SAIBool playerOnly;
SAIBool isInLos;
uint32 minDist;
} farthest;
struct
-5
View File
@@ -278,11 +278,6 @@ namespace AccountMgr
return gmlevel == SEC_PLAYER;
}
bool IsGMAccount(uint32 gmlevel)
{
return gmlevel >= SEC_MODERATOR && gmlevel <= SEC_CONSOLE;
}
bool IsAdminAccount(uint32 gmlevel)
{
return gmlevel >= SEC_ADMINISTRATOR && gmlevel <= SEC_CONSOLE;
-1
View File
@@ -49,7 +49,6 @@ namespace AccountMgr
uint32 GetCharactersCount(uint32 accountId);
bool IsPlayerAccount(uint32 gmlevel);
bool IsGMAccount(uint32 gmlevel);
bool IsAdminAccount(uint32 gmlevel);
bool IsConsoleAccount(uint32 gmlevel);
};
@@ -140,8 +140,8 @@ bool AchievementCriteriaData::IsValid(AchievementCriteriaEntry const* criteria)
case ACHIEVEMENT_CRITERIA_DATA_TYPE_S_AURA:
case ACHIEVEMENT_CRITERIA_DATA_TYPE_T_AURA:
{
SpellInfo const* spellEntry = sSpellMgr->GetSpellInfo(aura.spell_id);
if (!spellEntry)
SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(aura.spell_id);
if (!spellInfo)
{
LOG_ERROR("sql.sql", "Table `achievement_criteria_data` (Entry: {} Type: {}) for data type {} ({}) has wrong spell id in value1 ({}), ignored.",
criteria->ID, criteria->requiredType, (dataType == ACHIEVEMENT_CRITERIA_DATA_TYPE_S_AURA ? "ACHIEVEMENT_CRITERIA_DATA_TYPE_S_AURA" : "ACHIEVEMENT_CRITERIA_DATA_TYPE_T_AURA"), dataType, aura.spell_id);
@@ -153,7 +153,7 @@ bool AchievementCriteriaData::IsValid(AchievementCriteriaEntry const* criteria)
criteria->ID, criteria->requiredType, (dataType == ACHIEVEMENT_CRITERIA_DATA_TYPE_S_AURA ? "ACHIEVEMENT_CRITERIA_DATA_TYPE_S_AURA" : "ACHIEVEMENT_CRITERIA_DATA_TYPE_T_AURA"), dataType, aura.effect_idx);
return false;
}
if (!spellEntry->Effects[aura.effect_idx].ApplyAuraName)
if (!spellInfo->Effects[aura.effect_idx].ApplyAuraName)
{
LOG_ERROR("sql.sql", "Table `achievement_criteria_data` (Entry: {} Type: {}) for data type {} ({}) has non-aura spell effect (ID: {} Effect: {}), ignores.",
criteria->ID, criteria->requiredType, (dataType == ACHIEVEMENT_CRITERIA_DATA_TYPE_S_AURA ? "ACHIEVEMENT_CRITERIA_DATA_TYPE_S_AURA" : "ACHIEVEMENT_CRITERIA_DATA_TYPE_T_AURA"), dataType, aura.spell_id, aura.effect_idx);
+1 -1
View File
@@ -16,8 +16,8 @@
*/
#include "AddonMgr.h"
#include "DatabaseEnv.h"
#include "CryptoHash.h"
#include "DatabaseEnv.h"
#include "Log.h"
#include "Timer.h"
#include <list>
@@ -16,10 +16,10 @@
*/
#include "AutobroadcastMgr.h"
#include "Config.h"
#include "Chat.h"
#include "Player.h"
#include "Config.h"
#include "GridNotifiers.h"
#include "Player.h"
AutobroadcastMgr* AutobroadcastMgr::instance()
{
+2 -2
View File
@@ -815,7 +815,7 @@ Creature* Battlefield::SpawnCreature(uint32 entry, float x, float y, float z, fl
// Set creature in world
map->AddToMap(creature);
creature->SetFarVisible(true);
creature->setActive(true);
return creature;
}
@@ -840,7 +840,7 @@ GameObject* Battlefield::SpawnGameObject(uint32 entry, float x, float y, float z
// Add to world
map->AddToMap(go);
go->SetFarVisible(true);
go->setActive(true);
return go;
}
@@ -1159,7 +1159,6 @@ struct BfWGGameObjectBuilding
// Rebuild gameobject
go->SetDestructibleState(GO_DESTRUCTIBLE_REBUILDING, nullptr, true);
go->SetUInt32Value(GAMEOBJECT_FACTION, WintergraspFaction[m_Team]);
go->setActive(false); // Everything is reset, no need keep active at this point.
}
// Update worldstate
@@ -1171,10 +1170,6 @@ struct BfWGGameObjectBuilding
// Called when associated gameobject is damaged
void Damaged()
{
GameObject* go = m_WG->GetGameObject(m_Build);
if (go)
go->setActive(true);
// Update worldstate
m_State = BATTLEFIELD_WG_OBJECTSTATE_ALLIANCE_DAMAGE - (m_Team * 3);
m_WG->SendUpdateWorldState(m_WorldState, m_State);
@@ -1198,10 +1193,6 @@ struct BfWGGameObjectBuilding
// Called when associated gameobject is destroyed
void Destroyed()
{
GameObject* go = m_WG->GetGameObject(m_Build);
if (go)
go->setActive(true);
// Update worldstate
m_State = BATTLEFIELD_WG_OBJECTSTATE_ALLIANCE_DESTROY - (m_Team * 3);
m_WG->SendUpdateWorldState(m_WorldState, m_State);
+2 -2
View File
@@ -20,11 +20,11 @@
#include "GroupMgr.h"
#include "Log.h"
#include "ObjectAccessor.h"
#include "Pet.h"
#include "Player.h"
#include "ScriptMgr.h"
#include "World.h"
#include "WorldSession.h"
#include "Pet.h"
#include "ScriptMgr.h"
//#include "WorldStatePackets.h"
void ArenaScore::AppendToPacket(WorldPacket& data)
@@ -29,6 +29,7 @@
#include "Creature.h"
#include "CreatureTextMgr.h"
#include "Formulas.h"
#include "GameEventMgr.h"
#include "GameGraveyard.h"
#include "GridNotifiersImpl.h"
#include "GroupMgr.h"
@@ -861,7 +862,7 @@ void Battleground::EndBattleground(PvPTeamId winnerTeamId)
UpdatePlayerScore(player, SCORE_BONUS_HONOR, GetBonusHonorFromKill(winner_kills));
// Xinef: check player level and not bracket level if (CanAwardArenaPoints())
if (player->GetLevel() >= BG_AWARD_ARENA_POINTS_MIN_LEVEL)
if (player->GetLevel() >= sWorld->getIntConfig(CONFIG_DAILY_RBG_MIN_LEVEL_AP_REWARD))
player->ModifyArenaPoints(winner_arena);
if (!player->GetRandomWinner())
@@ -1635,7 +1636,7 @@ bool Battleground::AddSpiritGuide(uint32 type, float x, float y, float z, float
if (Creature* creature = AddCreature(entry, type, x, y, z, o))
{
creature->setDeathState(DEAD);
creature->setDeathState(DeathState::Dead);
creature->SetGuidValue(UNIT_FIELD_CHANNEL_OBJECT, creature->GetGUID());
// aura
/// @todo: Fix display here
+1 -2
View File
@@ -45,7 +45,7 @@ class BattlegroundIC;
struct PvPDifficultyEntry;
struct GraveyardStruct;
enum BattlegroundDesertionType
enum BattlegroundDesertionType : uint8
{
BG_DESERTION_TYPE_LEAVE_BG = 0, // player leaves the BG
BG_DESERTION_TYPE_OFFLINE = 1, // player is kicked from BG because offline
@@ -277,7 +277,6 @@ enum BGHonorMode
BG_HONOR_MODE_NUM
};
#define BG_AWARD_ARENA_POINTS_MIN_LEVEL 71
#define ARENA_TIMELIMIT_POINTS_LOSS -16
#define ARENA_READY_MARKER_ENTRY 301337
@@ -43,6 +43,7 @@
#include "ObjectMgr.h"
#include "Opcodes.h"
#include "Player.h"
#include "ScriptMgr.h"
#include "SharedDefines.h"
#include "World.h"
#include "WorldPacket.h"
@@ -23,8 +23,8 @@
#include "Common.h"
#include "CreatureAIImpl.h"
#include "DBCEnums.h"
#include <unordered_map>
#include <functional>
#include <unordered_map>
typedef std::map<uint32, Battleground*> BattlegroundContainer;
typedef std::set<uint32> BattlegroundClientIdsContainer;
@@ -551,6 +551,6 @@ void BattlegroundAB::ApplyPhaseMask()
for (auto const& itr : bgPlayerMap)
{
itr.second->SetPhaseMask(phaseMask, false);
itr.second->UpdateObjectVisibility(true);
itr.second->UpdateObjectVisibility(true, false);
}
}
@@ -339,7 +339,7 @@ Creature* BattlegroundAV::AddAVCreature(uint16 cinfoid, uint16 type)
//else wander_distance will be 15, so creatures move maximum=10
//creature->SetDefaultMovementType(RANDOM_MOTION_TYPE);
creature->GetMotionMaster()->Initialize();
creature->setDeathState(JUST_DIED);
creature->setDeathState(DeathState::JustDied);
creature->Respawn();
//TODO: find a way to add a motionmaster without killing the creature (i
//just copied this code from a gm-command
@@ -20,8 +20,8 @@
#include "Battleground.h"
#include "BattlegroundScore.h"
#include "Language.h"
#include "EventMap.h"
#include "Language.h"
enum BG_EY_Events
{
+39 -50
View File
@@ -198,8 +198,7 @@ void Channel::JoinChannel(Player* player, std::string const& pass)
player->JoinedChannel(this);
if (_announce && (!AccountMgr::IsGMAccount(player->GetSession()->GetSecurity()) ||
!sWorld->getBoolConfig(CONFIG_SILENTLY_GM_JOIN_TO_CHANNEL)))
if (_announce && ShouldAnnouncePlayer(player))
{
WorldPacket data;
MakeJoined(&data, guid);
@@ -222,7 +221,7 @@ void Channel::JoinChannel(Player* player, std::string const& pass)
JoinNotify(player);
playersStore[guid].SetOwnerGM(AccountMgr::IsGMAccount(player->GetSession()->GetSecurity()));
playersStore[guid].SetOwnerGM(player->GetSession()->IsGMAccount());
// Custom channel handling
if (!IsConstant())
@@ -276,8 +275,7 @@ void Channel::LeaveChannel(Player* player, bool send)
bool changeowner = playersStore[guid].IsOwner();
playersStore.erase(guid);
if (_announce && (!AccountMgr::IsGMAccount(player->GetSession()->GetSecurity()) ||
!sWorld->getBoolConfig(CONFIG_SILENTLY_GM_JOIN_TO_CHANNEL)))
if (_announce && ShouldAnnouncePlayer(player))
{
WorldPacket data;
MakeLeft(&data, guid);
@@ -301,7 +299,7 @@ void Channel::LeaveChannel(Player* player, bool send)
for (Channel::PlayerContainer::const_iterator itr = playersStore.begin(); itr != playersStore.end(); ++itr)
{
newowner = itr->second.player;
if (AccountMgr::IsGMAccount(itr->second.plrPtr->GetSession()->GetSecurity()))
if (itr->second.plrPtr->GetSession()->IsGMAccount())
_isOwnerGM = true;
else
_isOwnerGM = false;
@@ -319,7 +317,6 @@ void Channel::LeaveChannel(Player* player, bool send)
void Channel::KickOrBan(Player const* player, std::string const& badname, bool ban)
{
AccountTypes sec = player->GetSession()->GetSecurity();
ObjectGuid good = player->GetGUID();
if (!IsOn(good))
@@ -330,7 +327,7 @@ void Channel::KickOrBan(Player const* player, std::string const& badname, bool b
return;
}
if (!playersStore[good].IsModerator() && !AccountMgr::IsGMAccount(sec))
if (!playersStore[good].IsModerator() && !player->GetSession()->IsGMAccount())
{
WorldPacket data;
MakeNotModerator(&data);
@@ -343,19 +340,17 @@ void Channel::KickOrBan(Player const* player, std::string const& badname, bool b
ObjectGuid victim;
uint32 badAccId = 0;
uint32 badSecurity = 0;
Player* bad = ObjectAccessor::FindPlayerByName(badname, false);
if (bad)
{
victim = bad->GetGUID();
badAccId = bad->GetSession()->GetAccountId();
badSecurity = bad->GetSession()->GetSecurity();
}
bool isOnChannel = victim && IsOn(victim);
if (!isOnChannel)
{
if (ban && (AccountMgr::IsGMAccount(sec) || isGoodConstantModerator))
if (ban && (player->GetSession()->IsGMAccount() || isGoodConstantModerator))
{
if (ObjectGuid guid = sCharacterCache->GetCharacterGuidByName(badname))
{
@@ -395,7 +390,7 @@ void Channel::KickOrBan(Player const* player, std::string const& badname, bool b
bool changeowner = _ownerGUID == victim;
bool isBadConstantModerator = _channelRights.moderators.find(badAccId) != _channelRights.moderators.end();
if (!AccountMgr::IsGMAccount(sec) && !isGoodConstantModerator)
if (!player->GetSession()->IsGMAccount() && !isGoodConstantModerator)
{
if (changeowner && good != _ownerGUID)
{
@@ -413,7 +408,7 @@ void Channel::KickOrBan(Player const* player, std::string const& badname, bool b
return;
}
if (isBadConstantModerator || AccountMgr::IsGMAccount(badSecurity))
if (isBadConstantModerator || bad->GetSession()->IsGMAccount())
{
WorldPacket data;
MakeNotModerator(&data);
@@ -422,8 +417,6 @@ void Channel::KickOrBan(Player const* player, std::string const& badname, bool b
}
}
bool notify = !(AccountMgr::IsGMAccount(sec) && sWorld->getBoolConfig(CONFIG_SILENTLY_GM_JOIN_TO_CHANNEL));
if (ban)
{
if (!IsBanned(victim))
@@ -431,7 +424,7 @@ void Channel::KickOrBan(Player const* player, std::string const& badname, bool b
bannedStore[victim] = GameTime::GetGameTime().count() + CHANNEL_BAN_DURATION;
AddChannelBanToDB(victim, GameTime::GetGameTime().count() + CHANNEL_BAN_DURATION);
if (notify)
if (ShouldAnnouncePlayer(player))
{
WorldPacket data;
MakePlayerBanned(&data, victim, good);
@@ -439,7 +432,7 @@ void Channel::KickOrBan(Player const* player, std::string const& badname, bool b
}
}
}
else if (notify)
else if (ShouldAnnouncePlayer(player))
{
WorldPacket data;
MakePlayerKicked(&data, victim, good);
@@ -476,7 +469,6 @@ void Channel::KickOrBan(Player const* player, std::string const& badname, bool b
void Channel::UnBan(Player const* player, std::string const& badname)
{
uint32 sec = player->GetSession()->GetSecurity();
ObjectGuid good = player->GetGUID();
if (!IsOn(good))
@@ -487,7 +479,7 @@ void Channel::UnBan(Player const* player, std::string const& badname)
return;
}
if (!playersStore[good].IsModerator() && !AccountMgr::IsGMAccount(sec))
if (!playersStore[good].IsModerator() && !player->GetSession()->IsGMAccount())
{
WorldPacket data;
MakeNotModerator(&data);
@@ -510,7 +502,7 @@ void Channel::UnBan(Player const* player, std::string const& badname)
}
bool isConstantModerator = _channelRights.moderators.find(player->GetSession()->GetAccountId()) != _channelRights.moderators.end();
if (!AccountMgr::IsGMAccount(sec) && !isConstantModerator)
if (!player->GetSession()->IsGMAccount() && !isConstantModerator)
{
if (_channelRights.flags & CHANNEL_RIGHT_CANT_BAN)
{
@@ -555,7 +547,7 @@ void Channel::Password(Player const* player, std::string const& pass)
return;
}
if (!playersStore[guid].IsModerator() && !AccountMgr::IsGMAccount(player->GetSession()->GetSecurity()))
if (!playersStore[guid].IsModerator() && !player->GetSession()->IsGMAccount())
{
WorldPacket data;
MakeNotModerator(&data);
@@ -583,7 +575,6 @@ void Channel::Password(Player const* player, std::string const& pass)
void Channel::SetMode(Player const* player, std::string const& p2n, bool mod, bool set)
{
ObjectGuid guid = player->GetGUID();
uint32 sec = player->GetSession()->GetSecurity();
if (!IsOn(guid))
{
@@ -593,7 +584,7 @@ void Channel::SetMode(Player const* player, std::string const& p2n, bool mod, bo
return;
}
if (!playersStore[guid].IsModerator() && !AccountMgr::IsGMAccount(sec))
if (!playersStore[guid].IsModerator() && !player->GetSession()->IsGMAccount())
{
WorldPacket data;
MakeNotModerator(&data);
@@ -610,7 +601,7 @@ void Channel::SetMode(Player const* player, std::string const& p2n, bool mod, bo
if (!victim || !IsOn(victim) ||
// allow make moderator from another team only if both is GMs
// at this moment this only way to show channel post for GM from another team
((!AccountMgr::IsGMAccount(sec) || !AccountMgr::IsGMAccount(newp->GetSession()->GetSecurity())) && player->GetTeamId() != newp->GetTeamId() &&
((!player->GetSession()->IsGMAccount() || !newp->GetSession()->IsGMAccount()) && player->GetTeamId() != newp->GetTeamId() &&
!sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_CHANNEL)))
{
WorldPacket data;
@@ -636,7 +627,7 @@ void Channel::SetMode(Player const* player, std::string const& p2n, bool mod, bo
else
{
bool isGoodConstantModerator = _channelRights.moderators.find(player->GetSession()->GetAccountId()) != _channelRights.moderators.end();
if (!AccountMgr::IsGMAccount(sec) && !isGoodConstantModerator)
if (!player->GetSession()->IsGMAccount() && !isGoodConstantModerator)
{
if (_channelRights.flags & CHANNEL_RIGHT_CANT_MUTE)
{
@@ -654,7 +645,6 @@ void Channel::SetMode(Player const* player, std::string const& p2n, bool mod, bo
void Channel::SetOwner(Player const* player, std::string const& newname)
{
ObjectGuid guid = player->GetGUID();
uint32 sec = player->GetSession()->GetSecurity();
if (!IsOn(guid))
{
@@ -665,7 +655,7 @@ void Channel::SetOwner(Player const* player, std::string const& newname)
}
bool isGoodConstantModerator = _channelRights.moderators.find(player->GetSession()->GetAccountId()) != _channelRights.moderators.end();
if (!AccountMgr::IsGMAccount(sec) && guid != _ownerGUID && !isGoodConstantModerator)
if (!player->GetSession()->IsGMAccount() && guid != _ownerGUID && !isGoodConstantModerator)
{
WorldPacket data;
MakeNotOwner(&data);
@@ -737,7 +727,6 @@ void Channel::List(Player const* player)
void Channel::Announce(Player const* player)
{
ObjectGuid guid = player->GetGUID();
uint32 sec = player->GetSession()->GetSecurity();
if (!IsOn(guid))
{
@@ -747,7 +736,7 @@ void Channel::Announce(Player const* player)
return;
}
if (!playersStore[guid].IsModerator() && !AccountMgr::IsGMAccount(sec))
if (!playersStore[guid].IsModerator() && !player->GetSession()->IsGMAccount())
{
WorldPacket data;
MakeNotModerator(&data);
@@ -895,30 +884,25 @@ void Channel::SetOwner(ObjectGuid guid, bool exclaim)
pinfo.SetModerator(true);
uint8 oldFlag = pinfo.flags;
pinfo.SetOwner(true);
bool notify = true;
Player* player = ObjectAccessor::FindPlayer(_ownerGUID);
if (player)
{
uint32 sec = player->GetSession()->GetSecurity();
notify = !(AccountMgr::IsGMAccount(sec) && sWorld->getBoolConfig(CONFIG_SILENTLY_GM_JOIN_TO_CHANNEL));
}
WorldPacket data;
if (notify)
{
MakeModeChange(&data, _ownerGUID, oldFlag);
SendToAll(&data);
}
FlagsNotify(pinfo.plrPtr);
if (exclaim && notify)
Player* player = ObjectAccessor::FindPlayer(_ownerGUID);
if (player)
{
MakeOwnerChanged(&data, _ownerGUID);
SendToAll(&data);
if (ShouldAnnouncePlayer(player))
{
WorldPacket data;
MakeModeChange(&data, _ownerGUID, oldFlag);
SendToAll(&data);
if (exclaim)
{
// MakeOwnerChanged will reset the packet for us
MakeOwnerChanged(&data, _ownerGUID);
SendToAll(&data);
}
}
}
}
}
@@ -949,6 +933,11 @@ void Channel::SendToAllWatching(WorldPacket* data)
(*i)->GetSession()->SendPacket(data);
}
bool Channel::ShouldAnnouncePlayer(Player const* player) const
{
return !(player->GetSession()->IsGMAccount() && sWorld->getBoolConfig(CONFIG_SILENTLY_GM_JOIN_TO_CHANNEL));
}
void Channel::Voice(ObjectGuid /*guid1*/, ObjectGuid /*guid2*/)
{
}
+2
View File
@@ -271,6 +271,8 @@ private:
void SendToOne(WorldPacket* data, ObjectGuid who);
void SendToAllWatching(WorldPacket* data);
bool ShouldAnnouncePlayer(Player const* player) const;
[[nodiscard]] bool IsOn(ObjectGuid who) const { return playersStore.find(who) != playersStore.end(); }
[[nodiscard]] bool IsBanned(ObjectGuid guid) const;
+2 -2
View File
@@ -18,9 +18,9 @@
#include "ChannelMgr.h"
#include "Log.h"
#include "Player.h"
#include "World.h"
#include "Tokenize.h"
#include "StringConvert.h"
#include "Tokenize.h"
#include "World.h"
ChannelMgr::~ChannelMgr()
{
+18 -12
View File
@@ -62,8 +62,7 @@ bool ChatHandler::HasLowerSecurity(Player* target, ObjectGuid guid, bool strong)
if (!target_session && !target_account)
{
SendSysMessage(LANG_PLAYER_NOT_FOUND);
SetSentErrorMessage(true);
SendErrorMessage(LANG_PLAYER_NOT_FOUND);
return true;
}
@@ -92,8 +91,7 @@ bool ChatHandler::HasLowerSecurityAccount(WorldSession* target, uint32 target_ac
AccountTypes target_ac_sec = AccountTypes(target_sec);
if (m_session->GetSecurity() < target_ac_sec || (strong && m_session->GetSecurity() <= target_ac_sec))
{
SendSysMessage(LANG_YOURS_SECURITY_IS_LOW);
SetSentErrorMessage(true);
SendErrorMessage(LANG_YOURS_SECURITY_IS_LOW);
return true;
}
@@ -151,6 +149,18 @@ void ChatHandler::SendSysMessage(uint32 entry)
SendSysMessage(GetAcoreString(entry));
}
void ChatHandler::SendErrorMessage(uint32 entry)
{
SendSysMessage(entry);
SetSentErrorMessage(true);
}
void ChatHandler::SendErrorMessage(std::string_view str, bool escapeCharacters)
{
SendSysMessage(str, escapeCharacters);
SetSentErrorMessage(true);
}
bool ChatHandler::_ParseCommands(std::string_view text)
{
if (Acore::ChatCommands::TryExecuteCommand(*this, text))
@@ -161,8 +171,7 @@ bool ChatHandler::_ParseCommands(std::string_view text)
return false;
// Send error message for GMs
PSendSysMessage(LANG_CMD_INVALID, STRING_VIEW_FMT_ARG(text));
SetSentErrorMessage(true);
SendErrorMessage(LANG_CMD_INVALID, STRING_VIEW_FMT_ARG(text));
return true;
}
@@ -682,8 +691,7 @@ bool ChatHandler::extractPlayerTarget(char* args, Player** player, ObjectGuid* p
std::string name = extractPlayerNameFromLink(args);
if (name.empty())
{
SendSysMessage(LANG_PLAYER_NOT_FOUND);
SetSentErrorMessage(true);
SendErrorMessage(LANG_PLAYER_NOT_FOUND);
return false;
}
@@ -725,8 +733,7 @@ bool ChatHandler::extractPlayerTarget(char* args, Player** player, ObjectGuid* p
// some from req. data must be provided (note: name is empty if player not exist)
if ((!player || !*player) && (!player_guid || !*player_guid) && (!player_name || player_name->empty()))
{
SendSysMessage(LANG_PLAYER_NOT_FOUND);
SetSentErrorMessage(true);
SendErrorMessage(LANG_PLAYER_NOT_FOUND);
return false;
}
@@ -839,8 +846,7 @@ bool ChatHandler::GetPlayerGroupAndGUIDByName(const char* cname, Player*& player
{
if (!normalizePlayerName(name))
{
PSendSysMessage(LANG_PLAYER_NOT_FOUND);
SetSentErrorMessage(true);
SendErrorMessage(LANG_PLAYER_NOT_FOUND);
return false;
}
+17
View File
@@ -74,6 +74,23 @@ public:
return Acore::StringFormat(GetAcoreString(entry), std::forward<Args>(args)...);
}
void SendErrorMessage(uint32 entry);
void SendErrorMessage(std::string_view str, bool escapeCharacters);
template<typename... Args>
void SendErrorMessage(char const* fmt, Args&&... args)
{
PSendSysMessage(fmt, std::forward<Args>(args)...);
SetSentErrorMessage(true);
}
template<typename... Args>
void SendErrorMessage(uint32 entry, Args&&... args)
{
PSendSysMessage(entry, std::forward<Args>(args)...);
SetSentErrorMessage(true);
}
bool _ParseCommands(std::string_view text);
virtual bool ParseCommands(std::string_view text);
@@ -27,7 +27,6 @@
#include "Optional.h"
#include "StringFormat.h"
#include "Util.h"
#include "advstd.h"
#include <cstddef>
#include <map>
#include <tuple>
@@ -115,7 +114,7 @@ namespace Acore::Impl::ChatCommands
}
template <typename T> struct HandlerToTuple { static_assert(Acore::dependant_false_v<T>, "Invalid command handler signature"); };
template <typename... Ts> struct HandlerToTuple<bool(ChatHandler*, Ts...)> { using type = std::tuple<ChatHandler*, advstd::remove_cvref_t<Ts>...>; };
template <typename... Ts> struct HandlerToTuple<bool(ChatHandler*, Ts...)> { using type = std::tuple<ChatHandler*, std::remove_cvref_t<Ts>...>; };
template <typename T> using TupleType = typename HandlerToTuple<T>::type;
struct CommandInvoker
@@ -23,7 +23,6 @@
#include "ObjectGuid.h"
#include "Optional.h"
#include "Util.h"
#include "advstd.h"
#include <boost/preprocessor/punctuation/comma_if.hpp>
#include <boost/preprocessor/repetition/repeat.hpp>
#include <cmath>
@@ -204,7 +203,7 @@ namespace Acore::ChatCommands
struct Hyperlink : Acore::Impl::ChatCommands::ContainerTag
{
using value_type = typename linktag::value_type;
using storage_type = advstd::remove_cvref_t<value_type>;
using storage_type = std::remove_cvref_t<value_type>;
operator value_type() const { return val; }
value_type operator*() const { return val; }
+1 -1
View File
@@ -20,8 +20,8 @@
#include "GameEventMgr.h"
#include "InstanceScript.h"
#include "ObjectMgr.h"
#include "Player.h"
#include "Pet.h"
#include "Player.h"
#include "ReputationMgr.h"
#include "ScriptMgr.h"
#include "ScriptedCreature.h"
+2 -2
View File
@@ -23,9 +23,9 @@
#include "Player.h"
#include "SpellInfo.h"
#include "SpellMgr.h"
#include "World.h"
#include "Tokenize.h"
#include "StringConvert.h"
#include "Tokenize.h"
#include "World.h"
namespace DisableMgr
{
+4 -4
View File
@@ -448,8 +448,8 @@ void LoadDBCStores(const std::string& dataPath)
for (SkillLineAbilityEntry const* skillLine : sSkillLineAbilityStore)
{
SpellEntry const* spellInfo = sSpellStore.LookupEntry(skillLine->Spell);
if (spellInfo && spellInfo->Attributes & SPELL_ATTR0_PASSIVE)
SpellEntry const* spellEntry = sSpellStore.LookupEntry(skillLine->Spell);
if (spellEntry && spellEntry->Attributes & SPELL_ATTR0_PASSIVE)
{
for (CreatureFamilyEntry const* cFamily : sCreatureFamilyStore)
{
@@ -458,7 +458,7 @@ void LoadDBCStores(const std::string& dataPath)
continue;
}
if (spellInfo->SpellLevel)
if (spellEntry->SpellLevel)
{
continue;
}
@@ -468,7 +468,7 @@ void LoadDBCStores(const std::string& dataPath)
continue;
}
sPetFamilySpellsStore[cFamily->ID].insert(spellInfo->Id);
sPetFamilySpellsStore[cFamily->ID].insert(spellEntry->Id);
}
}
}
+1 -1
View File
@@ -37,7 +37,7 @@ WMOAreaTableEntry const* GetWMOAreaTableEntryByTripple(int32 rootid, int32 adtid
uint32 GetVirtualMapForMapAndZone(uint32 mapid, uint32 zoneId);
enum ContentLevels
enum ContentLevels : uint8
{
CONTENT_1_60 = 0,
CONTENT_61_70,
+2 -2
View File
@@ -15,11 +15,11 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "DBCStores.h"
#include "M2Stores.h"
#include "Containers.h"
#include "DBCStores.h"
#include "Log.h"
#include "M2Structure.h"
#include "M2Stores.h"
#include "World.h"
#include <boost/filesystem/path.hpp>
#include <fstream>
+1 -1
View File
@@ -18,8 +18,8 @@
#ifndef ACORE_M2STRUCTURE_H
#define ACORE_M2STRUCTURE_H
#include <G3D/Vector3.h>
#include <G3D/AABox.h>
#include <G3D/Vector3.h>
// Structures for M2 file. Source: https://wowdev.wiki
#pragma pack(push, 1)
+18 -14
View File
@@ -34,6 +34,7 @@
#include "ObjectMgr.h"
#include "Opcodes.h"
#include "Player.h"
#include "ScriptMgr.h"
#include "SharedDefines.h"
#include "SocialMgr.h"
#include "SpellAuras.h"
@@ -43,9 +44,6 @@ namespace lfg
{
LFGMgr::LFGMgr(): m_lfgProposalId(1), m_options(sWorld->getIntConfig(CONFIG_LFG_OPTIONSMASK)), m_Testing(false)
{
new LFGPlayerScript();
new LFGGroupScript();
for (uint8 team = 0; team < 2; ++team)
{
m_raidBrowserUpdateTimer[team] = 10000;
@@ -2128,14 +2126,6 @@ namespace lfg
return;
}
if (out)
{
if (player->GetMapId() == uint32(dungeon->map))
player->TeleportToEntryPoint();
return;
}
LfgTeleportError error = LFG_TELEPORTERROR_OK;
if (!player->IsAlive())
@@ -2158,6 +2148,13 @@ namespace lfg
{
error = LFG_TELEPORTERROR_COMBAT;
}
else if (out && error == LFG_TELEPORTERROR_OK)
{
if (player->GetMapId() == uint32(dungeon->map))
player->TeleportToEntryPoint();
return;
}
else
{
uint32 mapid = dungeon->map;
@@ -2183,11 +2180,18 @@ namespace lfg
}
if (error != LFG_TELEPORTERROR_OK)
{
player->GetSession()->SendLfgTeleportError(uint8(error));
//LOG_DEBUG("lfg", "TeleportPlayer: Player {} is being teleported in to map {} "
// "(x: {}, y: {}, z: {}) Result: {}", player->GetName(), dungeon->map,
// dungeon->x, dungeon->y, dungeon->z, error);
LOG_DEBUG("lfg", "Player [{}] could NOT be teleported in to map [{}] (x: {}, y: {}, z: {}) Error: {}",
player->GetName(), dungeon->map, dungeon->x, dungeon->y, dungeon->z, error);
}
else
{
LOG_DEBUG("lfg", "Player [{}] is being teleported in to map [{}] (x: {}, y: {}, z: {})",
player->GetName(), dungeon->map, dungeon->x, dungeon->y, dungeon->z);
}
}
/**
+3
View File
@@ -633,6 +633,9 @@ namespace lfg
bool m_Testing;
};
template <typename T, FMT_ENABLE_IF(std::is_enum_v<T>)>
auto format_as(T f) { return fmt::underlying(f); }
} // namespace lfg
#define sLFGMgr lfg::LFGMgr::instance()
@@ -297,4 +297,9 @@ namespace lfg
}
}
void AddSC_LFGScripts()
{
new LFGPlayerScript();
new LFGGroupScript();
}
} // namespace lfg
+5 -4
View File
@@ -19,16 +19,15 @@
* Interaction between core and LFGScripts
*/
#include "Common.h"
#include "ScriptMgr.h"
#include "SharedDefines.h"
#include "GroupScript.h"
#include "ObjectGuid.h"
#include "PlayerScript.h"
class Player;
class Group;
namespace lfg
{
class LFGPlayerScript : public PlayerScript
{
public:
@@ -55,4 +54,6 @@ namespace lfg
void OnInviteMember(Group* group, ObjectGuid guid) override;
};
void AddSC_LFGScripts();
} // namespace lfg
+157 -149
View File
@@ -31,13 +31,13 @@
#include "GroupMgr.h"
#include "Log.h"
#include "LootMgr.h"
#include "MapMgr.h"
#include "ObjectMgr.h"
#include "Opcodes.h"
#include "OutdoorPvPMgr.h"
#include "Pet.h"
#include "Player.h"
#include "PoolMgr.h"
#include "ScriptMgr.h"
#include "ScriptedGossip.h"
#include "SpellAuraEffects.h"
#include "SpellMgr.h"
@@ -301,6 +301,9 @@ void Creature::RemoveFromWorld()
if (m_formation)
sFormationMgr->RemoveCreatureFromGroup(m_formation, this);
if (Transport* transport = GetTransport())
transport->RemovePassenger(this, true);
Unit::RemoveFromWorld();
if (m_spawnId)
@@ -316,7 +319,7 @@ void Creature::DisappearAndDie()
//SetVisibility(VISIBILITY_OFF);
//ObjectAccessor::UpdateObjectVisibility(this);
if (IsAlive())
setDeathState(JUST_DIED, true);
setDeathState(DeathState::JustDied, true);
RemoveCorpse(false, true);
}
@@ -342,11 +345,11 @@ void Creature::SearchFormation()
void Creature::RemoveCorpse(bool setSpawnTime, bool skipVisibility)
{
if (getDeathState() != CORPSE)
if (getDeathState() != DeathState::Corpse)
return;
m_corpseRemoveTime = GameTime::GetGameTime().count();
setDeathState(DEAD);
setDeathState(DeathState::Dead);
RemoveAllAuras();
if (!skipVisibility) // pussywizard
DestroyForNearbyPlayers(); // pussywizard: previous UpdateObjectVisibility()
@@ -362,15 +365,17 @@ void Creature::RemoveCorpse(bool setSpawnTime, bool skipVisibility)
//SaveRespawnTime();
}
float x, y, z, o;
GetRespawnPosition(x, y, z, &o);
SetHomePosition(x, y, z, o);
SetPosition(x, y, z, o);
// xinef: relocate notifier
m_last_notify_position.Relocate(-5000.0f, -5000.0f, -5000.0f, 0.0f);
// pussywizard: if corpse was removed during falling then the falling will continue after respawn, so stop falling is such case
if (IsFalling())
StopMoving();
float x, y, z, o;
GetRespawnPosition(x, y, z, &o);
UpdateAllowedPositionZ(x, y, z);
SetHomePosition(x, y, z, o);
GetMap()->CreatureRelocation(this, x, y, z, o);
}
/**
@@ -604,61 +609,28 @@ void Creature::Update(uint32 diff)
switch (m_deathState)
{
case JUST_RESPAWNED:
case DeathState::JustRespawned:
// Must not be called, see Creature::setDeathState JUST_RESPAWNED -> ALIVE promoting.
LOG_ERROR("entities.unit", "Creature ({}) in wrong state: JUST_RESPAWNED (4)", GetGUID().ToString());
LOG_ERROR("entities.unit", "Creature ({}) in wrong state: DeathState::JustRespawned (4)", GetGUID().ToString());
break;
case JUST_DIED:
case DeathState::JustDied:
// Must not be called, see Creature::setDeathState JUST_DIED -> CORPSE promoting.
LOG_ERROR("entities.unit", "Creature ({}) in wrong state: JUST_DEAD (1)", GetGUID().ToString());
LOG_ERROR("entities.unit", "Creature ({}) in wrong state: DeathState::JustDead (1)", GetGUID().ToString());
break;
case DEAD:
case DeathState::Dead:
{
time_t now = GameTime::GetGameTime().count();
if (m_respawnTime <= now)
{
ConditionList conditions = sConditionMgr->GetConditionsForNotGroupedEntry(CONDITION_SOURCE_TYPE_CREATURE_RESPAWN, GetEntry());
if (!sConditionMgr->IsObjectMeetToConditions(this, conditions))
{
// Creature should not respawn, reset respawn timer. Conditions will be checked again the next time it tries to respawn.
m_respawnTime = GameTime::GetGameTime().count() + m_respawnDelay;
break;
}
bool allowed = !IsAIEnabled || AI()->CanRespawn(); // First check if there are any scripts that prevent us respawning
if (!allowed) // Will be rechecked on next Update call
break;
ObjectGuid dbtableHighGuid = ObjectGuid::Create<HighGuid::Unit>(m_creatureData ? m_creatureData->id1 : GetEntry(), m_spawnId);
time_t linkedRespawntime = GetMap()->GetLinkedRespawnTime(dbtableHighGuid);
CreatureTemplate const* cInfo = sObjectMgr->GetCreatureTemplate(GetEntry());
if (!linkedRespawntime || (cInfo && cInfo->HasFlagsExtra(CREATURE_FLAG_EXTRA_HARD_RESET))) // Can respawn
Respawn();
else // the master is dead
{
ObjectGuid targetGuid = sObjectMgr->GetLinkedRespawnGuid(dbtableHighGuid);
if (targetGuid == dbtableHighGuid) // if linking self, never respawn (check delayed to next day)
{
SetRespawnTime(DAY);
}
else
{
m_respawnTime = (now > linkedRespawntime ? now : linkedRespawntime) + urand(5, MINUTE); // else copy time from master and add a little
}
SaveRespawnTime(); // also save to DB immediately
}
Respawn();
}
break;
}
case CORPSE:
case DeathState::Corpse:
{
Unit::Update(diff);
// deathstate changed on spells update, prevent problems
if (m_deathState != CORPSE)
if (m_deathState != DeathState::Corpse)
break;
if (m_groupLootTimer && lootingGroupLowGUID)
@@ -683,7 +655,7 @@ void Creature::Update(uint32 diff)
}
break;
}
case ALIVE:
case DeathState::Alive:
{
Unit::Update(diff);
@@ -1721,12 +1693,12 @@ bool Creature::LoadCreatureFromDB(ObjectGuid::LowType spawnId, Map* map, bool ad
m_wanderDistance = data->wander_distance;
m_respawnDelay = data->spawntimesecs;
m_deathState = ALIVE;
m_deathState = DeathState::Alive;
m_respawnTime = GetMap()->GetCreatureRespawnTime(m_spawnId);
if (m_respawnTime) // respawn on Update
{
m_deathState = DEAD;
m_deathState = DeathState::Dead;
if (CanFly())
{
float tz = map->GetHeight(GetPhaseMask(), data->posX, data->posY, data->posZ, true, MAX_FALL_DISTANCE);
@@ -1756,7 +1728,7 @@ bool Creature::LoadCreatureFromDB(ObjectGuid::LowType spawnId, Map* map, bool ad
SetPower(POWER_MANA, GetMaxPower(POWER_MANA));
}
SetHealth(m_deathState == ALIVE ? curhealth : 0);
SetHealth(m_deathState == DeathState::Alive ? curhealth : 0);
// checked at creature_template loading
m_defaultMovementType = MovementGeneratorType(data->movementType);
@@ -1824,25 +1796,7 @@ void Creature::DeleteFromDB()
return;
}
CreatureData const* data = sObjectMgr->GetCreatureData(m_spawnId);
if (!data)
return;
CharacterDatabaseTransaction charTrans = CharacterDatabase.BeginTransaction();
sMapMgr->DoForAllMapsWithMapId(data->mapid,
[this, charTrans](Map* map) -> void
{
// despawn all active creatures, and remove their respawns
std::vector<Creature*> toUnload;
for (auto const& pair : Acore::Containers::MapEqualRange(map->GetCreatureBySpawnIdStore(), m_spawnId))
toUnload.push_back(pair.second);
for (Creature* creature : toUnload)
map->AddObjectToRemoveList(creature);
map->RemoveCreatureRespawnTime(m_spawnId);
}
);
GetMap()->RemoveCreatureRespawnTime(m_spawnId);
sObjectMgr->DeleteCreatureData(m_spawnId);
WorldDatabaseTransaction trans = WorldDatabase.BeginTransaction();
@@ -1951,7 +1905,7 @@ void Creature::setDeathState(DeathState s, bool despawn)
{
Unit::setDeathState(s, despawn);
if (s == JUST_DIED)
if (s == DeathState::JustDied)
{
_lastDamagedTime.reset();
@@ -1985,9 +1939,9 @@ void Creature::setDeathState(DeathState s, bool despawn)
if (needsFalling)
GetMotionMaster()->MoveFall(0, true);
Unit::setDeathState(CORPSE, despawn);
Unit::setDeathState(DeathState::Corpse, despawn);
}
else if (s == JUST_RESPAWNED)
else if (s == DeathState::JustRespawned)
{
//if (IsPet())
// setActive(true);
@@ -2009,7 +1963,7 @@ void Creature::setDeathState(DeathState s, bool despawn)
ClearUnitState(uint32(UNIT_STATE_ALL_STATE & ~(UNIT_STATE_IGNORE_PATHFINDING | UNIT_STATE_NO_ENVIRONMENT_UPD)));
SetMeleeDamageSchool(SpellSchools(cinfo->dmgschool));
Unit::setDeathState(ALIVE, despawn);
Unit::setDeathState(DeathState::Alive, despawn);
Motion_Initialize();
LoadCreaturesAddon(true);
@@ -2020,81 +1974,121 @@ void Creature::setDeathState(DeathState s, bool despawn)
void Creature::Respawn(bool force)
{
//DestroyForNearbyPlayers(); // pussywizard: not needed
if (force)
{
if (IsAlive())
setDeathState(JUST_DIED);
else if (getDeathState() != CORPSE)
setDeathState(CORPSE);
{
setDeathState(DeathState::JustDied);
}
else if (getDeathState() != DeathState::Corpse)
{
setDeathState(DeathState::Corpse);
}
}
RemoveCorpse(false, false);
ConditionList conditions = sConditionMgr->GetConditionsForNotGroupedEntry(CONDITION_SOURCE_TYPE_CREATURE_RESPAWN, GetEntry());
if (getDeathState() == DEAD)
if (!sConditionMgr->IsObjectMeetToConditions(this, conditions) && !force)
{
if (m_spawnId)
{
GetMap()->RemoveCreatureRespawnTime(m_spawnId);
CreatureData const* data = sObjectMgr->GetCreatureData(m_spawnId);
// Respawn check if spawn has 2 entries
if (data->id2)
{
uint32 entry = GetRandomId(data->id1, data->id2, data->id3);
UpdateEntry(entry, data, true); // Select Random Entry
m_defaultMovementType = MovementGeneratorType(data->movementType); // Reload Movement Type
LoadEquipment(data->equipmentId); // Reload Equipment
AIM_Initialize(); // Reload AI
}
else
{
if (m_originalEntry != GetEntry())
UpdateEntry(m_originalEntry);
}
}
LOG_DEBUG("entities.unit", "Respawning creature {} (SpawnId: {}, {})", GetName(), GetSpawnId(), GetGUID().ToString());
m_respawnTime = 0;
ResetPickPocketLootTime();
loot.clear();
SelectLevel();
setDeathState(JUST_RESPAWNED);
// MDic - Acidmanifesto
// Do not override transform auras
if (GetAuraEffectsByType(SPELL_AURA_TRANSFORM).empty())
{
uint32 displayID = GetNativeDisplayId();
if (sObjectMgr->GetCreatureModelRandomGender(&displayID)) // Cancel load if no model defined
{
SetDisplayId(displayID);
SetNativeDisplayId(displayID);
}
}
GetMotionMaster()->InitDefault();
//Call AI respawn virtual function
if (IsAIEnabled)
{
//reset the AI to be sure no dirty or uninitialized values will be used till next tick
AI()->Reset();
TriggerJustRespawned = true;//delay event to next tick so all creatures are created on the map before processing
}
uint32 poolid = m_spawnId ? sPoolMgr->IsPartOfAPool<Creature>(m_spawnId) : 0;
if (poolid)
sPoolMgr->UpdatePool<Creature>(poolid, m_spawnId);
//Re-initialize reactstate that could be altered by movementgenerators
InitializeReactState();
m_respawnedTime = GameTime::GetGameTime().count();
// Creature should not respawn, reset respawn timer. Conditions will be checked again the next time it tries to respawn.
m_respawnTime = GameTime::GetGameTime().count() + m_respawnDelay;
return;
}
bool allowed = !IsAIEnabled || AI()->CanRespawn(); // First check if there are any scripts that prevent us respawning
if (!allowed && !force) // Will be rechecked on next Update call
return;
ObjectGuid dbtableHighGuid = ObjectGuid::Create<HighGuid::Unit>(m_creatureData ? m_creatureData->id1 : GetEntry(), m_spawnId);
time_t linkedRespawntime = GetMap()->GetLinkedRespawnTime(dbtableHighGuid);
CreatureTemplate const* cInfo = sObjectMgr->GetCreatureTemplate(GetEntry());
if (!linkedRespawntime || (cInfo && cInfo->HasFlagsExtra(CREATURE_FLAG_EXTRA_HARD_RESET)) || force) // Should respawn
{
RemoveCorpse(false, false);
if (getDeathState() == DeathState::Dead)
{
if (m_spawnId)
{
GetMap()->RemoveCreatureRespawnTime(m_spawnId);
CreatureData const* data = sObjectMgr->GetCreatureData(m_spawnId);
// Respawn check if spawn has 2 entries
if (data->id2)
{
uint32 entry = GetRandomId(data->id1, data->id2, data->id3);
UpdateEntry(entry, data, true); // Select Random Entry
m_defaultMovementType = MovementGeneratorType(data->movementType); // Reload Movement Type
LoadEquipment(data->equipmentId); // Reload Equipment
AIM_Initialize(); // Reload AI
}
else
{
if (m_originalEntry != GetEntry())
UpdateEntry(m_originalEntry);
}
}
LOG_DEBUG("entities.unit", "Respawning creature {} (SpawnId: {}, {})", GetName(), GetSpawnId(), GetGUID().ToString());
m_respawnTime = 0;
ResetPickPocketLootTime();
loot.clear();
SelectLevel();
setDeathState(DeathState::JustRespawned);
// MDic - Acidmanifesto
// Do not override transform auras
if (GetAuraEffectsByType(SPELL_AURA_TRANSFORM).empty())
{
uint32 displayID = GetNativeDisplayId();
if (sObjectMgr->GetCreatureModelRandomGender(&displayID)) // Cancel load if no model defined
{
SetDisplayId(displayID);
SetNativeDisplayId(displayID);
}
}
GetMotionMaster()->InitDefault();
//Call AI respawn virtual function
if (IsAIEnabled)
{
//reset the AI to be sure no dirty or uninitialized values will be used till next tick
AI()->Reset();
TriggerJustRespawned = true;//delay event to next tick so all creatures are created on the map before processing
}
uint32 poolid = m_spawnId ? sPoolMgr->IsPartOfAPool<Creature>(m_spawnId) : 0;
if (poolid)
sPoolMgr->UpdatePool<Creature>(poolid, m_spawnId);
//Re-initialize reactstate that could be altered by movementgenerators
InitializeReactState();
m_respawnedTime = GameTime::GetGameTime().count();
}
m_respawnedTime = GameTime::GetGameTime().count();
// xinef: relocate notifier, fixes npc appearing in corpse position after forced respawn (instead of spawn)
m_last_notify_position.Relocate(-5000.0f, -5000.0f, -5000.0f, 0.0f);
UpdateObjectVisibility(false);
}
else // the master is dead
{
ObjectGuid targetGuid = sObjectMgr->GetLinkedRespawnGuid(dbtableHighGuid);
if (targetGuid == dbtableHighGuid) // if linking self, never respawn (check delayed to next day)
{
SetRespawnTime(DAY);
}
else
{
time_t now = GameTime::GetGameTime().count();
m_respawnTime = (now > linkedRespawntime ? now : linkedRespawntime) + urand(5, MINUTE); // else copy time from master and add a little
}
SaveRespawnTime(); // also save to DB immediately
}
m_respawnedTime = GameTime::GetGameTime().count();
UpdateObjectVisibility();
}
void Creature::ForcedDespawn(uint32 timeMSToDespawn, Seconds forceRespawnTimer)
@@ -2107,15 +2101,17 @@ void Creature::ForcedDespawn(uint32 timeMSToDespawn, Seconds forceRespawnTimer)
}
if (IsAlive())
setDeathState(JUST_DIED, true);
setDeathState(DeathState::JustDied, true);
// Xinef: set new respawn time, ignore corpse decay time...
RemoveCorpse(true);
if (forceRespawnTimer > Seconds::zero())
{
m_respawnTime = GameTime::GetGameTime().count() + forceRespawnTimer.count();
m_respawnDelay = forceRespawnTimer.count();
if (GetMap())
{
GetMap()->ScheduleCreatureRespawn(GetGUID(), forceRespawnTimer);
}
}
}
@@ -3076,7 +3072,10 @@ std::string const& Creature::GetNameForLocaleIdx(LocaleConstant loc_idx) const
void Creature::SetPosition(float x, float y, float z, float o)
{
UpdatePosition(x, y, z, o, false);
if (!Acore::IsValidMapCoord(x, y, z, o))
return;
GetMap()->CreatureRelocation(this, x, y, z, o);
}
bool Creature::IsDungeonBoss() const
@@ -3745,6 +3744,15 @@ bool Creature::CanCastSpell(uint32 spellID) const
return true;
}
ObjectGuid Creature::GetSummonerGUID() const
{
if (TempSummon const* temp = ToTempSummon())
return temp->GetSummonerGUID();
LOG_DEBUG("entities.unit", "Creature::GetSummonerGUID() called by creature that is not a summon. Creature: {} ({})", GetEntry(), GetName());
return ObjectGuid::Empty;
}
std::string Creature::GetDebugInfo() const
{
std::stringstream sstr;
+6 -1
View File
@@ -68,7 +68,6 @@ public:
void Update(uint32 time) override; // overwrited Unit::Update
void GetRespawnPosition(float& x, float& y, float& z, float* ori = nullptr, float* dist = nullptr) const;
bool IsSpawnedOnTransport() const { return m_creatureData && m_creatureData->mapid != GetMapId(); }
void SetCorpseDelay(uint32 delay) { m_corpseDelay = delay; }
void SetCorpseRemoveTime(uint32 delay);
@@ -408,6 +407,12 @@ public:
* */
bool CanCastSpell(uint32 spellID) const;
/**
* @brief Helper to get the creature's summoner GUID, if it is a summon
*
* */
[[nodiscard]] ObjectGuid GetSummonerGUID() const;
std::string GetDebugInfo() const override;
protected:
@@ -17,11 +17,12 @@
#include "GossipDef.h"
#include "Formulas.h"
#include "ObjectMgr.h"
#include "Object.h"
#include "ObjectMgr.h"
#include "Opcodes.h"
#include "Player.h"
#include "QuestDef.h"
#include "ScriptMgr.h"
#include "WorldPacket.h"
#include "WorldSession.h"
@@ -67,7 +67,7 @@ void TempSummon::Update(uint32 diff)
{
Creature::Update(diff);
if (m_deathState == DEAD)
if (m_deathState == DeathState::Dead)
{
UnSummon();
return;
@@ -107,7 +107,7 @@ void TempSummon::Update(uint32 diff)
}
case TEMPSUMMON_TIMED_DESPAWN_OOC_ALIVE:
{
if (!IsInCombat() && m_deathState != CORPSE)
if (!IsInCombat() && m_deathState != DeathState::Corpse)
{
if (m_timer <= diff)
{
@@ -124,7 +124,7 @@ void TempSummon::Update(uint32 diff)
}
case TEMPSUMMON_CORPSE_TIMED_DESPAWN:
{
if (m_deathState == CORPSE)
if (m_deathState == DeathState::Corpse)
{
if (m_timer <= diff)
{
@@ -139,7 +139,7 @@ void TempSummon::Update(uint32 diff)
case TEMPSUMMON_CORPSE_DESPAWN:
{
// if m_deathState is DEAD, CORPSE was skipped
if (m_deathState == CORPSE)
if (m_deathState == DeathState::Corpse)
{
UnSummon();
return;
@@ -154,7 +154,7 @@ void TempSummon::Update(uint32 diff)
case TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN:
{
// if m_deathState is DEAD, CORPSE was skipped
if (m_deathState == CORPSE)
if (m_deathState == DeathState::Corpse)
{
UnSummon();
return;
@@ -395,7 +395,7 @@ bool Minion::IsGuardianPet() const
void Minion::setDeathState(DeathState s, bool despawn)
{
Creature::setDeathState(s, despawn);
if (s == JUST_DIED && IsGuardianPet())
if (s == DeathState::JustDied && IsGuardianPet())
if (Unit* owner = GetOwner())
if (owner->GetTypeId() == TYPEID_PLAYER && owner->GetMinionGUID() == GetGUID())
for (Unit::ControlSet::const_iterator itr = owner->m_Controlled.begin(); itr != owner->m_Controlled.end(); ++itr)
@@ -15,12 +15,12 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "SpellAuraEffects.h"
#include "GameTime.h"
#include "GridNotifiers.h"
#include "ObjectAccessor.h"
#include "Opcodes.h"
#include "ScriptMgr.h"
#include "SpellAuraEffects.h"
#include "Transport.h"
#include "UpdateMask.h"
#include "World.h"
@@ -47,6 +47,14 @@ DynamicObject::~DynamicObject()
void DynamicObject::CleanupsBeforeDelete(bool finalCleanup /* = true */)
{
if (Transport* transport = GetTransport())
{
transport->RemovePassenger(this);
SetTransport(nullptr);
m_movementInfo.transport.Reset();
m_movementInfo.RemoveMovementFlag(MOVEMENTFLAG_ONTRANSPORT);
}
WorldObject::CleanupsBeforeDelete(finalCleanup);
}
@@ -80,6 +88,9 @@ void DynamicObject::RemoveFromWorld()
UnbindFromCaster();
if (Transport* transport = GetTransport())
transport->RemovePassenger(this, true);
WorldObject::RemoveFromWorld();
GetMap()->GetObjectsStore().Remove<DynamicObject>(GetGUID());
@@ -114,15 +125,17 @@ bool DynamicObject::CreateDynamicObject(ObjectGuid::LowType guidlow, Unit* caste
SetFloatValue(DYNAMICOBJECT_RADIUS, radius);
SetUInt32Value(DYNAMICOBJECT_CASTTIME, GameTime::GetGameTimeMS().count());
if (IsWorldObject())
setActive(true); //must before add to map to be put in world container
if (!GetMap()->AddToMap(this, true))
{
// Returning false will cause the object to be deleted - remove from transport
return false;
}
if (IsWorldObject())
{
setActive(true);
}
return true;
}
@@ -27,7 +27,6 @@
#include "GridNotifiersImpl.h"
#include "Group.h"
#include "GroupMgr.h"
#include "MapMgr.h"
#include "ObjectMgr.h"
#include "OutdoorPvPMgr.h"
#include "PoolMgr.h"
@@ -103,9 +102,18 @@ std::string const& GameObject::GetAIName() const
return sObjectMgr->GetGameObjectTemplate(GetEntry())->AIName;
}
void GameObject::CleanupsBeforeDelete(bool finalCleanup)
void GameObject::CleanupsBeforeDelete(bool /*finalCleanup*/)
{
WorldObject::CleanupsBeforeDelete(finalCleanup);
if (GetTransport() && !ToTransport())
{
GetTransport()->RemovePassenger(this);
SetTransport(nullptr);
m_movementInfo.transport.Reset();
m_movementInfo.RemoveMovementFlag(MOVEMENTFLAG_ONTRANSPORT);
}
if (IsInWorld())
RemoveFromWorld();
if (m_uint32Values) // field array can be not exist if GameOBject not loaded
RemoveFromOwner();
@@ -174,6 +182,9 @@ void GameObject::RemoveFromWorld()
if (GetMap()->ContainsGameObjectModel(*m_model))
GetMap()->RemoveGameObjectModel(*m_model);
if (Transport* transport = GetTransport())
transport->RemovePassenger(this, true);
// If linked trap exists, despawn it
if (GameObject* linkedTrap = GetLinkedTrap())
{
@@ -877,11 +888,7 @@ void GameObject::Update(uint32 diff)
if (!m_spawnedByDefault)
{
m_respawnTime = 0;
if (m_spawnId)
DestroyForNearbyPlayers(); // xinef: old UpdateObjectVisibility();
else
Delete();
DestroyForNearbyPlayers(); // xinef: old UpdateObjectVisibility();
return;
}
@@ -1178,31 +1185,7 @@ bool GameObject::LoadGameObjectFromDB(ObjectGuid::LowType spawnId, Map* map, boo
void GameObject::DeleteFromDB()
{
if (!m_spawnId)
{
LOG_ERROR("entities.gameobject", "Trying to delete not saved gameobject: {}", GetGUID().ToString());
return;
}
GameObjectData const* data = sObjectMgr->GetGameObjectData(m_spawnId);
if (!data)
return;
CharacterDatabaseTransaction charTrans = CharacterDatabase.BeginTransaction();
sMapMgr->DoForAllMapsWithMapId(data->mapid,
[this, charTrans](Map* map) -> void
{
// despawn all active objects, and remove their respawns
std::vector<GameObject*> toUnload;
for (auto const& pair : Acore::Containers::MapEqualRange(map->GetGameObjectBySpawnIdStore(), m_spawnId))
toUnload.push_back(pair.second);
for (GameObject* obj : toUnload)
map->AddObjectToRemoveList(obj);
map->RemoveGORespawnTime(m_spawnId);
}
);
GetMap()->RemoveGORespawnTime(m_spawnId);
sObjectMgr->DeleteGOData(m_spawnId);
WorldDatabasePreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_DEL_GAMEOBJECT);
@@ -2191,6 +2174,15 @@ bool GameObject::IsInRange(float x, float y, float z, float radius) const
&& dz < (info->maxZ * scale) + radius && dz > (info->minZ * scale) - radius;
}
void GameObject::SendMessageToSetInRange(WorldPacket const* data, float dist, bool /*self*/, bool includeMargin, Player const* skipped_rcvr) const
{
dist += GetObjectSize();
if (includeMargin)
dist += VISIBILITY_COMPENSATION * 2.0f; // pussywizard: to ensure everyone receives all important packets
Acore::MessageDistDeliverer notifier(this, data, dist, false, skipped_rcvr);
Cell::VisitWorldObjects(this, notifier, dist);
}
void GameObject::EventInform(uint32 eventId)
{
if (!eventId)
@@ -2807,7 +2799,7 @@ void GameObject::BuildValuesUpdate(uint8 updateType, ByteBuffer* data, Player* t
return;
bool forcedFlags = GetGoType() == GAMEOBJECT_TYPE_CHEST && GetGOInfo()->chest.groupLootRules && HasLootRecipient();
bool targetIsGM = target->IsGameMaster() && AccountMgr::IsGMAccount(target->GetSession()->GetSecurity());
bool targetIsGM = target->IsGameMaster() && target->GetSession()->IsGMAccount();
ByteBuffer fieldBuffer;
@@ -21,10 +21,10 @@
#include "Common.h"
#include "DatabaseEnv.h"
#include "G3D/Quat.h"
#include "GameObjectData.h"
#include "LootMgr.h"
#include "Object.h"
#include "SharedDefines.h"
#include "GameObjectData.h"
#include "Unit.h"
#include <array>
@@ -289,6 +289,8 @@ public:
void SendCustomAnim(uint32 anim);
[[nodiscard]] bool IsInRange(float x, float y, float z, float radius) const;
void SendMessageToSetInRange(WorldPacket const* data, float dist, bool /*self*/, bool includeMargin = false, Player const* skipped_rcvr = nullptr) const override; // pussywizard!
void ModifyHealth(int32 change, Unit* attackerOrHealer = nullptr, uint32 spellId = 0);
void SetDestructibleBuildingModifyState(bool allow) { m_allowModifyDestructibleBuilding = allow; }
// sets GameObject type 33 destruction flags and optionally default health for that state
+2 -2
View File
@@ -26,9 +26,9 @@
#include "ScriptMgr.h"
#include "SpellInfo.h"
#include "SpellMgr.h"
#include "WorldPacket.h"
#include "Tokenize.h"
#include "StringConvert.h"
#include "Tokenize.h"
#include "WorldPacket.h"
void AddItemsSetItem(Player* player, Item* item)
{
+2 -2
View File
@@ -36,7 +36,7 @@ struct ItemSetEffect
};
// EnumUtils: DESCRIBE THIS
enum InventoryResult
enum InventoryResult : uint8
{
EQUIP_ERR_OK = 0,
EQUIP_ERR_CANT_EQUIP_LEVEL_I = 1,
@@ -158,7 +158,7 @@ enum SellResult
};
// -1 from client enchantment slot number
enum EnchantmentSlot
enum EnchantmentSlot : uint8
{
PERM_ENCHANTMENT_SLOT = 0,
TEMP_ENCHANTMENT_SLOT = 1,
@@ -15,8 +15,8 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "Item.h"
#include "Define.h"
#include "Item.h"
#include "SmartEnum.h"
#include <stdexcept>
+97 -41
View File
@@ -21,6 +21,7 @@
#include "CellImpl.h"
#include "Chat.h"
#include "Creature.h"
#include "DynamicVisibility.h"
#include "GameObjectAI.h"
#include "GameTime.h"
#include "GridNotifiers.h"
@@ -37,8 +38,10 @@
#include "ScriptMgr.h"
#include "SharedDefines.h"
#include "SpellAuraEffects.h"
#include "StringConvert.h"
#include "TargetedMovementGenerator.h"
#include "TemporarySummon.h"
#include "Tokenize.h"
#include "Totem.h"
#include "Transport.h"
#include "UpdateData.h"
@@ -48,8 +51,6 @@
#include "Vehicle.h"
#include "World.h"
#include "WorldPacket.h"
#include "Tokenize.h"
#include "StringConvert.h"
/// @todo: this import is not necessary for compilation and marked as unused by the IDE
// however, for some reasons removing it would cause a damn linking issue
@@ -64,7 +65,7 @@ constexpr float VisibilityDistances[AsUnderlyingType(VisibilityDistanceType::Max
VISIBILITY_DISTANCE_SMALL,
VISIBILITY_DISTANCE_LARGE,
VISIBILITY_DISTANCE_GIGANTIC,
MAX_VISIBILITY_DISTANCE
VISIBILITY_DISTANCE_INFINITE
};
Object::Object() : m_PackGUID(sizeof(uint64) + 1)
@@ -248,10 +249,7 @@ void Object::SendUpdateToPlayer(Player* player)
UpdateData upd;
WorldPacket packet;
if (player->HaveAtClient(this))
BuildValuesUpdateBlockForPlayer(&upd, player);
else
BuildCreateUpdateBlockForPlayer(&upd, player);
BuildCreateUpdateBlockForPlayer(&upd, player);
upd.BuildPacket(&packet);
player->GetSession()->SendPacket(&packet);
}
@@ -1050,7 +1048,7 @@ void MovementInfo::OutDebug()
}
WorldObject::WorldObject(bool isWorldObject) : WorldLocation(),
LastUsedScriptID(0), m_name(""), m_isActive(false), m_isFarVisible(false), m_visibilityDistanceOverride(), m_isWorldObject(isWorldObject), m_zoneScript(nullptr),
LastUsedScriptID(0), m_name(""), m_isActive(false), m_visibilityDistanceOverride(), m_isWorldObject(isWorldObject), m_zoneScript(nullptr),
_zoneId(0), _areaId(0), _floorZ(INVALID_HEIGHT), _outdoors(false), _liquidData(), _updatePositionData(false), m_transport(nullptr),
m_currMap(nullptr), m_InstanceId(0), m_phaseMask(PHASEMASK_NORMAL), m_useCombinedPhases(true), m_notifyflags(0), m_executed_notifies(0)
{
@@ -1107,6 +1105,8 @@ void WorldObject::setActive(bool on)
map->AddToActive(this->ToCreature());
else if (GetTypeId() == TYPEID_DYNAMICOBJECT)
map->AddToActive((DynamicObject*)this);
else if (GetTypeId() == TYPEID_GAMEOBJECT)
map->AddToActive((GameObject*)this);
}
else
{
@@ -1114,17 +1114,11 @@ void WorldObject::setActive(bool on)
map->RemoveFromActive(this->ToCreature());
else if (GetTypeId() == TYPEID_DYNAMICOBJECT)
map->RemoveFromActive((DynamicObject*)this);
else if (GetTypeId() == TYPEID_GAMEOBJECT)
map->RemoveFromActive((GameObject*)this);
}
}
void WorldObject::SetFarVisible(bool on)
{
if (GetTypeId() == TYPEID_PLAYER)
return;
m_isFarVisible = on;
}
void WorldObject::SetVisibilityDistanceOverride(VisibilityDistanceType type)
{
ASSERT(type < VisibilityDistanceType::Max);
@@ -1140,9 +1134,6 @@ void WorldObject::CleanupsBeforeDelete(bool /*finalCleanup*/)
{
if (IsInWorld())
RemoveFromWorld();
if (Transport* transport = GetTransport())
transport->RemovePassenger(this, true);
}
void WorldObject::_Create(ObjectGuid::LowType guidlow, HighGuid guidhigh, uint32 phaseMask)
@@ -1635,9 +1626,9 @@ float WorldObject::GetGridActivationRange() const
{
if (ToPlayer()->GetCinematicMgr()->IsOnCinematic())
{
return std::max(DEFAULT_VISIBILITY_INSTANCE, GetMap()->GetVisibilityRange());
return DEFAULT_VISIBILITY_INSTANCE;
}
return IsInWintergrasp() ? VISIBILITY_DISTANCE_LARGE : GetMap()->GetVisibilityRange();
return IsInWintergrasp() ? VISIBILITY_DIST_WINTERGRASP : GetMap()->GetVisibilityRange();
}
else if (ToCreature())
{
@@ -1653,12 +1644,29 @@ float WorldObject::GetGridActivationRange() const
float WorldObject::GetVisibilityRange() const
{
if (IsVisibilityOverridden() && !ToPlayer())
if (IsVisibilityOverridden() && GetTypeId() == TYPEID_UNIT)
{
return *m_visibilityDistanceOverride;
else if (IsFarVisible() && !ToPlayer())
return MAX_VISIBILITY_DISTANCE;
}
else if (GetTypeId() == TYPEID_GAMEOBJECT)
{
{
if (IsInWintergrasp())
{
return VISIBILITY_DIST_WINTERGRASP + VISIBILITY_INC_FOR_GOBJECTS;
}
else if (IsVisibilityOverridden())
{
return *m_visibilityDistanceOverride;
}
else
{
return GetMap()->GetVisibilityRange() + VISIBILITY_INC_FOR_GOBJECTS;
}
}
}
else
return IsInWintergrasp() ? VISIBILITY_DISTANCE_LARGE : GetMap()->GetVisibilityRange();
return IsInWintergrasp() ? VISIBILITY_DIST_WINTERGRASP : GetMap()->GetVisibilityRange();
}
float WorldObject::GetSightRange(WorldObject const* target) const
@@ -1667,19 +1675,44 @@ float WorldObject::GetSightRange(WorldObject const* target) const
{
if (ToPlayer())
{
if (target && target->IsVisibilityOverridden() && !target->ToPlayer())
return *target->m_visibilityDistanceOverride;
else if (target && target->IsFarVisible() && !target->ToPlayer())
return MAX_VISIBILITY_DISTANCE;
else if (ToPlayer()->GetCinematicMgr()->IsOnCinematic())
return DEFAULT_VISIBILITY_INSTANCE;
else
return IsInWintergrasp() ? VISIBILITY_DISTANCE_LARGE : GetMap()->GetVisibilityRange();
if (target)
{
if (target->IsVisibilityOverridden() && target->GetTypeId() == TYPEID_UNIT)
{
return *target->m_visibilityDistanceOverride;
}
else if (target->GetTypeId() == TYPEID_GAMEOBJECT)
{
if (IsInWintergrasp() && target->IsInWintergrasp())
{
return VISIBILITY_DIST_WINTERGRASP + VISIBILITY_INC_FOR_GOBJECTS;
}
else if (target->IsVisibilityOverridden())
{
return *target->m_visibilityDistanceOverride;
}
else if (ToPlayer()->GetCinematicMgr()->IsOnCinematic())
{
return DEFAULT_VISIBILITY_INSTANCE;
}
else
{
return GetMap()->GetVisibilityRange() + VISIBILITY_INC_FOR_GOBJECTS;
}
}
return IsInWintergrasp() && target->IsInWintergrasp() ? VISIBILITY_DIST_WINTERGRASP : GetMap()->GetVisibilityRange();
}
return IsInWintergrasp() ? VISIBILITY_DIST_WINTERGRASP : GetMap()->GetVisibilityRange();
}
else if (ToCreature())
{
return ToCreature()->m_SightDistance;
}
else
{
return SIGHT_RANGE_UNIT;
}
}
if (ToDynObject() && isActiveObject())
@@ -2044,8 +2077,11 @@ void Unit::BuildHeartBeatMsg(WorldPacket* data) const
BuildMovementPacket(data);
}
void WorldObject::SendMessageToSetInRange(WorldPacket const* data, float dist, bool /*self*/, Player const* skipped_rcvr) const
void WorldObject::SendMessageToSetInRange(WorldPacket const* data, float dist, bool /*self*/, bool includeMargin, Player const* skipped_rcvr) const
{
dist += GetObjectSize();
if (includeMargin)
dist += VISIBILITY_COMPENSATION; // pussywizard: to ensure everyone receives all important packets
Acore::MessageDistDeliverer notifier(this, data, dist, false, skipped_rcvr);
Cell::VisitWorldObjects(this, notifier, dist);
}
@@ -2192,8 +2228,7 @@ TempSummon* Map::SummonCreature(uint32 entry, Position const& pos, SummonPropert
return nullptr;
}
if (!IsGridLoaded(pos.GetPositionX(), pos.GetPositionY()))
EnsureGridLoaded(Cell(pos.GetPositionX(), pos.GetPositionY()));
EnsureGridLoaded(Cell(pos.GetPositionX(), pos.GetPositionY()));
if (!summon->Create(GenerateLowGuid<HighGuid::Unit>(), this, phase, entry, vehId, pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), pos.GetOrientation()))
{
delete summon;
@@ -2866,8 +2901,8 @@ void WorldObject::DestroyForNearbyPlayers()
return;
std::list<Player*> targets;
Acore::AnyPlayerInObjectRangeCheck check(this, GetVisibilityRange(), false);
Acore::PlayerListSearcher<Acore::AnyPlayerInObjectRangeCheck> searcher(this, targets, check);
Acore::AnyPlayerInObjectRangeCheck check(this, GetVisibilityRange() + VISIBILITY_COMPENSATION, false);
Acore::PlayerListSearcherWithSharedVision<Acore::AnyPlayerInObjectRangeCheck> searcher(this, targets, check);
Cell::VisitWorldObjects(this, searcher, GetVisibilityRange());
for (std::list<Player*>::const_iterator iter = targets.begin(); iter != targets.end(); ++iter)
{
@@ -2887,7 +2922,7 @@ void WorldObject::DestroyForNearbyPlayers()
}
}
void WorldObject::UpdateObjectVisibility(bool /*forced*/)
void WorldObject::UpdateObjectVisibility(bool /*forced*/, bool /*fromUpdate*/)
{
//updates object's visibility for nearby players
Acore::VisibleChangesNotifier notifier(*this);
@@ -2896,7 +2931,28 @@ void WorldObject::UpdateObjectVisibility(bool /*forced*/)
void WorldObject::AddToNotify(uint16 f)
{
m_notifyflags |= f;
if (!(m_notifyflags & f))
if (Unit* u = ToUnit())
{
if (f & NOTIFY_VISIBILITY_CHANGED)
{
uint32 EVENT_VISIBILITY_DELAY = u->FindMap() ? DynamicVisibilityMgr::GetVisibilityNotifyDelay(u->FindMap()->GetEntry()->map_type) : 1000;
uint32 diff = getMSTimeDiff(u->m_last_notify_mstime, GameTime::GetGameTimeMS().count());
if (diff >= EVENT_VISIBILITY_DELAY / 2)
EVENT_VISIBILITY_DELAY /= 2;
else
EVENT_VISIBILITY_DELAY -= diff;
u->m_delayed_unit_relocation_timer = EVENT_VISIBILITY_DELAY;
u->m_last_notify_mstime = GameTime::GetGameTimeMS().count() + EVENT_VISIBILITY_DELAY - 1;
}
else if (f & NOTIFY_AI_RELOCATION)
{
u->m_delayed_unit_ai_notify_timer = u->FindMap() ? DynamicVisibilityMgr::GetAINotifyDelay(u->FindMap()->GetEntry()->map_type) : 500;
}
m_notifyflags |= f;
}
}
struct WorldObjectChangeAccumulator
@@ -2949,7 +3005,7 @@ struct WorldObjectChangeAccumulator
source = iter->GetSource();
ObjectGuid guid = source->GetCasterGUID();
if (guid.IsPlayer())
if (guid)
{
//Caster may be nullptr if DynObj is in removelist
if (Player* caster = ObjectAccessor::FindPlayer(guid))
+8 -18
View File
@@ -379,23 +379,14 @@ class MovableMapObject
template<class T> friend class RandomMovementGenerator;
protected:
MovableMapObject() : _moveState(MAP_OBJECT_CELL_MOVE_NONE)
{
_newPosition.Relocate(0.0f, 0.0f, 0.0f, 0.0f);
}
MovableMapObject() = default;
private:
Cell _currentCell;
[[nodiscard]] Cell const& GetCurrentCell() const { return _currentCell; }
void SetCurrentCell(Cell const& cell) { _currentCell = cell; }
MapObjectCellMoveState _moveState;
Position _newPosition;
void SetNewCellPosition(float x, float y, float z, float o)
{
_moveState = MAP_OBJECT_CELL_MOVE_ACTIVE;
_newPosition.Relocate(x, y, z, o);
}
Cell _currentCell;
MapObjectCellMoveState _moveState{MAP_OBJECT_CELL_MOVE_NONE};
};
class WorldObject : public Object, public WorldLocation
@@ -488,9 +479,9 @@ public:
virtual void CleanupsBeforeDelete(bool finalCleanup = true); // used in destructor or explicitly before mass creature delete to remove cross-references to already deleted units
virtual void SendMessageToSet(WorldPacket const* data, bool self) const { if (IsInWorld()) SendMessageToSetInRange(data, GetVisibilityRange(), self); } // pussywizard!
virtual void SendMessageToSetInRange(WorldPacket const* data, float dist, bool /*self*/, Player const* skipped_rcvr = nullptr) const; // pussywizard!
virtual void SendMessageToSet(WorldPacket const* data, Player const* skipped_rcvr) const { if (IsInWorld()) SendMessageToSetInRange(data, GetVisibilityRange(), false, skipped_rcvr); } // pussywizard!
virtual void SendMessageToSet(WorldPacket const* data, bool self) const { if (IsInWorld()) SendMessageToSetInRange(data, GetVisibilityRange(), self, true); } // pussywizard!
virtual void SendMessageToSetInRange(WorldPacket const* data, float dist, bool /*self*/, bool includeMargin = false, Player const* skipped_rcvr = nullptr) const; // pussywizard!
virtual void SendMessageToSet(WorldPacket const* data, Player const* skipped_rcvr) const { if (IsInWorld()) SendMessageToSetInRange(data, GetVisibilityRange(), false, true, skipped_rcvr); } // pussywizard!
virtual uint8 getLevelForTarget(WorldObject const* /*target*/) const { return 1; }
@@ -547,7 +538,7 @@ public:
void GetDeadCreatureListInGrid(std::list<Creature*>& lList, float maxSearchRange, bool alive = false) const;
void DestroyForNearbyPlayers();
virtual void UpdateObjectVisibility(bool forced = true);
virtual void UpdateObjectVisibility(bool forced = true, bool fromUpdate = false);
void BuildUpdate(UpdateDataMapType& data_map, UpdatePlayerSet& player_set) override;
void GetCreaturesWithEntryInRange(std::list<Creature*>& creatureList, float radius, uint32 entry);
@@ -569,7 +560,6 @@ public:
[[nodiscard]] bool isActiveObject() const { return m_isActive; }
void setActive(bool isActiveObject);
[[nodiscard]] bool IsFarVisible() const { return m_isFarVisible; }
void SetFarVisible(bool on);
[[nodiscard]] bool IsVisibilityOverridden() const { return m_visibilityDistanceOverride.has_value(); }
void SetVisibilityDistanceOverride(VisibilityDistanceType type);
void SetWorldObject(bool apply);
@@ -578,7 +568,7 @@ public:
[[nodiscard]] bool IsInWintergrasp() const
{
return GetMapId() == 571 && GetZoneId() == 4197;
return GetMapId() == 571 && GetPositionX() > 3733.33331f && GetPositionX() < 5866.66663f && GetPositionY() > 1599.99999f && GetPositionY() < 4799.99997f;
}
#ifdef MAP_BASED_RAND_GEN
@@ -23,18 +23,23 @@
#define CONTACT_DISTANCE 0.5f
#define INTERACTION_DISTANCE 5.5f
#define ATTACK_DISTANCE 5.0f
#define VISIBILITY_COMPENSATION 15.0f // increase searchers
#define INSPECT_DISTANCE 28.0f
#define VISIBILITY_INC_FOR_GOBJECTS 30.0f // pussywizard
#define SPELL_SEARCHER_COMPENSATION 30.0f // increase searchers size in case we have large npc near cell border
#define TRADE_DISTANCE 11.11f
#define MAX_VISIBILITY_DISTANCE SIZE_OF_GRIDS // max distance for visible objects, experimental
#define MAX_VISIBILITY_DISTANCE 250.0f // max distance for visible objects, experimental
#define SIGHT_RANGE_UNIT 50.0f
#define MAX_SEARCHER_DISTANCE 150.0f // pussywizard: replace the use of MAX_VISIBILITY_DISTANCE in searchers, because MAX_VISIBILITY_DISTANCE is quite too big for this purpose
#define VISIBILITY_DISTANCE_INFINITE 533.0f
#define VISIBILITY_DISTANCE_GIGANTIC 400.0f
#define VISIBILITY_DISTANCE_LARGE 200.0f
#define VISIBILITY_DISTANCE_NORMAL 100.0f
#define VISIBILITY_DISTANCE_SMALL 50.0f
#define VISIBILITY_DISTANCE_TINY 25.0f
#define DEFAULT_VISIBILITY_DISTANCE VISIBILITY_DISTANCE_NORMAL // default visible distance, 100 yards on continents
#define DEFAULT_VISIBILITY_DISTANCE 100.0f // default visible distance, 100 yards on continents
#define DEFAULT_VISIBILITY_INSTANCE 170.0f // default visible distance in instances, 170 yards
#define VISIBILITY_DIST_WINTERGRASP 175.0f
#define DEFAULT_VISIBILITY_BGARENAS 533.0f // default visible distance in BG/Arenas, roughly 533 yards
#define DEFAULT_WORLD_OBJECT_SIZE 0.388999998569489f // player size, also currently used (correctly?) for any non Unit world objects
@@ -134,7 +134,6 @@ class ObjectGuid
ObjectGuid(HighGuid hi, uint32 entry, LowType counter) : _guid(counter ? uint64(counter) | (uint64(entry) << 24) | (uint64(hi) << 48) : 0) { }
ObjectGuid(HighGuid hi, LowType counter) : _guid(counter ? uint64(counter) | (uint64(hi) << 48) : 0) { }
operator uint64() const { return _guid; }
PackedGuidReader ReadAsPacked() { return PackedGuidReader(*this); }
void Set(uint64 guid) { _guid = guid; }
@@ -21,7 +21,6 @@
#include "Define.h"
#include <cmath>
#include <map>
#include <math.h>
enum UsedPosType { USED_POS_PLUS, USED_POS_MINUS };
+1 -1
View File
@@ -17,8 +17,8 @@
#include "Position.h"
#include "ByteBuffer.h"
#include "GridDefines.h"
#include "Geometry.h"
#include "GridDefines.h"
#include <G3D/g3dmath.h>
#include <sstream>
+1 -1
View File
@@ -18,9 +18,9 @@
#ifndef ACore_game_Position_h__
#define ACore_game_Position_h__
#include <cmath>
#include "Common.h"
#include "G3D/Vector3.h"
#include <cmath>
class ByteBuffer;
+12 -11
View File
@@ -21,6 +21,7 @@
#include "DatabaseEnv.h"
#include "GameTime.h"
#include "Group.h"
#include "InstanceScript.h"
#include "Log.h"
#include "ObjectMgr.h"
#include "PetPackets.h"
@@ -472,7 +473,7 @@ bool Pet::LoadPetFromDB(Player* owner, uint32 petEntry, uint32 petnumber, bool c
else
{
if (!curHealth && getPetType() == HUNTER_PET)
setDeathState(JUST_DIED);
setDeathState(DeathState::JustDied);
else
{
SetHealth(curHealth > GetMaxHealth() ? GetMaxHealth() : curHealth);
@@ -616,7 +617,7 @@ void Pet::DeleteFromDB(ObjectGuid::LowType guidlow)
void Pet::setDeathState(DeathState s, bool /*despawn = false*/) // overwrite virtual Creature::setDeathState and Unit::setDeathState
{
Creature::setDeathState(s);
if (getDeathState() == CORPSE)
if (getDeathState() == DeathState::Corpse)
{
if (getPetType() == HUNTER_PET)
{
@@ -632,7 +633,7 @@ void Pet::setDeathState(DeathState s, bool /*despawn = false*/)
//SetUnitFlag(UNIT_FLAG_STUNNED);
}
}
else if (getDeathState() == ALIVE)
else if (getDeathState() == DeathState::Alive)
{
//RemoveUnitFlag(UNIT_FLAG_STUNNED);
CastPetAuras(true);
@@ -651,7 +652,7 @@ void Pet::Update(uint32 diff)
switch (m_deathState)
{
case CORPSE:
case DeathState::Corpse:
{
if (getPetType() != HUNTER_PET || m_corpseRemoveTime <= GameTime::GetGameTime().count())
{
@@ -660,7 +661,7 @@ void Pet::Update(uint32 diff)
}
break;
}
case ALIVE:
case DeathState::Alive:
{
// unsummon pet that lost owner
Player* owner = GetOwner();
@@ -1941,16 +1942,16 @@ void Pet::InitLevelupSpellsForLevel()
{
for (uint32 spellId : defSpells->spellid)
{
SpellInfo const* spellEntry = sSpellMgr->GetSpellInfo(spellId);
if (!spellEntry)
SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId);
if (!spellInfo)
continue;
// will called first if level down
if (spellEntry->SpellLevel > level && sScriptMgr->CanUnlearnSpellDefault(this, spellEntry))
unlearnSpell(spellEntry->Id, true);
if (spellInfo->SpellLevel > level && sScriptMgr->CanUnlearnSpellDefault(this, spellInfo))
unlearnSpell(spellInfo->Id, true);
// will called if level up
else
learnSpell(spellEntry->Id);
learnSpell(spellInfo->Id);
}
}
}
@@ -2240,7 +2241,7 @@ uint8 Pet::GetMaxTalentPointsForLevel(uint8 level)
sScriptMgr->OnCalculateMaxTalentPointsForLevel(this, level, points);
return points;
return uint8(points * sWorld->getRate(RATE_TALENT_PET));
}
void Pet::ToggleAutocast(SpellInfo const* spellInfo, bool apply)
@@ -20,6 +20,7 @@
#include "Group.h"
#include "Pet.h"
#include "Player.h"
#include "ScriptMgr.h"
#include "SpellAuraEffects.h"
// KillRewarder incapsulates logic of rewarding player upon kill with:
+36 -25
View File
@@ -53,14 +53,12 @@
#include "InstanceSaveMgr.h"
#include "InstanceScript.h"
#include "LFGMgr.h"
#include "Language.h"
#include "Log.h"
#include "LootItemStorage.h"
#include "MapMgr.h"
#include "MiscPackets.h"
#include "ObjectAccessor.h"
#include "ObjectMgr.h"
#include "Opcodes.h"
#include "OutdoorPvP.h"
#include "OutdoorPvPMgr.h"
#include "Pet.h"
@@ -75,18 +73,17 @@
#include "SpellAuraEffects.h"
#include "SpellAuras.h"
#include "SpellMgr.h"
#include "StringConvert.h"
#include "TicketMgr.h"
#include "Tokenize.h"
#include "Transport.h"
#include "UpdateData.h"
#include "UpdateFieldFlags.h"
#include "Util.h"
#include "Vehicle.h"
#include "Weather.h"
#include "World.h"
#include "WorldPacket.h"
#include "WorldSession.h"
#include "Tokenize.h"
#include "StringConvert.h"
/// @todo: this import is not necessary for compilation and marked as unused by the IDE
// however, for some reasons removing it would cause a damn linking issue
@@ -1010,7 +1007,7 @@ void Player::setDeathState(DeathState s, bool /*despawn = false*/)
bool cur = IsAlive();
if (s == JUST_DIED)
if (s == DeathState::JustDied)
{
if (!cur)
{
@@ -1025,7 +1022,7 @@ void Player::setDeathState(DeathState s, bool /*despawn = false*/)
clearResurrectRequestData();
//FIXME: is pet dismissed at dying or releasing spirit? if second, add setDeathState(DEAD) to HandleRepopRequestOpcode and define pet unsummon here with (s == DEAD)
//FIXME: is pet dismissed at dying or releasing spirit? if second, add setDeathState(DeathState::Dead) to HandleRepopRequestOpcode and define pet unsummon here with (s == DEAD)
RemovePet(nullptr, PET_SAVE_NOT_IN_SLOT, true);
// save value before aura remove in Unit::setDeathState
@@ -1045,7 +1042,7 @@ void Player::setDeathState(DeathState s, bool /*despawn = false*/)
ResetAchievementCriteria(ACHIEVEMENT_CRITERIA_CONDITION_NO_DEATH, 0);
}
// xinef: enable passive area auras!
else if (s == ALIVE)
else if (s == DeathState::Alive)
ClearUnitState(UNIT_STATE_ISOLATED);
Unit::setDeathState(s);
@@ -1054,7 +1051,7 @@ void Player::setDeathState(DeathState s, bool /*despawn = false*/)
ArenaSpectator::SendCommand_UInt32Value(FindMap(), GetGUID(), "STA", IsAlive() ? 1 : 0);
// restore resurrection spell id for player after aura remove
if (s == JUST_DIED && cur && ressSpellId)
if (s == DeathState::JustDied && cur && ressSpellId)
SetUInt32Value(PLAYER_SELF_RES_SPELL, ressSpellId);
if (IsAlive() && !cur)
@@ -1313,9 +1310,6 @@ void Player::SendTeleportAckPacket()
bool Player::TeleportTo(uint32 mapid, float x, float y, float z, float orientation, uint32 options /*= 0*/, Unit* target /*= nullptr*/, bool newInstance /*= false*/)
{
// for except kick by antispeedhack
sScriptMgr->AnticheatSetSkipOnePacketForASH(this, true);
if (!MapMgr::IsValidMapCoord(mapid, x, y, z, orientation))
{
LOG_ERROR("entities.player", "TeleportTo: invalid map ({}) or invalid coordinates (X: {}, Y: {}, Z: {}, O: {}) given when teleporting player ({}, name: {}, map: {}, X: {}, Y: {}, Z: {}, O: {}).",
@@ -1353,7 +1347,10 @@ bool Player::TeleportTo(uint32 mapid, float x, float y, float z, float orientati
if (GetTransport())
{
m_transport->RemovePassenger(this, true);
m_transport->RemovePassenger(this);
m_transport = nullptr;
m_movementInfo.transport.Reset();
m_movementInfo.RemoveMovementFlag(MOVEMENTFLAG_ONTRANSPORT);
RepopAtGraveyard(); // teleport to near graveyard if on transport, looks blizz like :)
}
@@ -1395,7 +1392,10 @@ bool Player::TeleportTo(uint32 mapid, float x, float y, float z, float orientati
AddUnitMovementFlag(MOVEMENTFLAG_ONTRANSPORT);
else
{
m_transport->RemovePassenger(this, true);
m_transport->RemovePassenger(this);
m_transport = nullptr;
m_movementInfo.transport.Reset();
m_movementInfo.RemoveMovementFlag(MOVEMENTFLAG_ONTRANSPORT);
}
}
@@ -2186,14 +2186,14 @@ void Player::SetGameMaster(bool on)
if (on)
{
m_ExtraFlags |= PLAYER_EXTRA_GM_ON;
if (AccountMgr::IsGMAccount(GetSession()->GetSecurity()))
if (GetSession()->IsGMAccount())
SetFaction(FACTION_FRIENDLY);
SetPlayerFlag(PLAYER_FLAGS_GM);
SetUnitFlag2(UNIT_FLAG2_ALLOW_CHEAT_SPELLS);
if (Pet* pet = GetPet())
{
if (AccountMgr::IsGMAccount(GetSession()->GetSecurity()))
if (GetSession()->IsGMAccount())
pet->SetFaction(FACTION_FRIENDLY);
pet->getHostileRefMgr().setOnlineOfflineState(false);
}
@@ -2292,7 +2292,6 @@ bool Player::IsInSameGroupWith(Player const* p) const
}
///- If the player is invited, remove him. If the group if then only 1 person, disband the group.
/// \todo Shouldn't we also check if there is no other invitees before disbanding the group?
void Player::UninviteFromGroup()
{
Group* group = GetGroupInvite();
@@ -2301,14 +2300,17 @@ void Player::UninviteFromGroup()
group->RemoveInvite(this);
if (group->GetMembersCount() <= 1) // group has just 1 member => disband
if (group->IsCreated())
{
if (group->IsCreated())
if (group->GetMembersCount() <= 1) // group has just 1 member => disband
{
group->Disband(true);
group = nullptr; // gets deleted in disband
}
else
}
else
{
if (group->GetInviteeCount() <= 1)
{
group->RemoveAllInvites();
delete group;
@@ -4398,7 +4400,7 @@ void Player::ResurrectPlayer(float restore_percent, bool applySickness)
if (GetSession()->IsARecruiter() || (GetSession()->GetRecruiterId() != 0))
SetDynamicFlag(UNIT_DYNFLAG_REFER_A_FRIEND);
setDeathState(ALIVE);
setDeathState(DeathState::Alive);
SetMovement(MOVE_LAND_WALK);
SetMovement(MOVE_UNROOT);
SetWaterWalking(false);
@@ -4465,7 +4467,7 @@ void Player::KillPlayer()
StopMirrorTimers(); //disable timers(bars)
setDeathState(CORPSE);
setDeathState(DeathState::Corpse);
//SetUnitFlag(UNIT_FLAG_NOT_IN_PVP);
ReplaceAllDynamicFlags(UNIT_DYNFLAG_NONE);
@@ -4481,6 +4483,7 @@ void Player::KillPlayer()
if (corpseReclaimDelay >= 0)
SendCorpseReclaimDelay(corpseReclaimDelay);
sScriptMgr->OnPlayerJustDied(this);
// don't create corpse at this moment, player might be falling
// update visibility
@@ -5577,11 +5580,14 @@ void Player::SaveRecallPosition()
m_recallO = GetOrientation();
}
void Player::SendMessageToSetInRange(WorldPacket const* data, float dist, bool self, Player const* skipped_rcvr) const
void Player::SendMessageToSetInRange(WorldPacket const* data, float dist, bool self, bool includeMargin, Player const* skipped_rcvr) const
{
if (self)
GetSession()->SendPacket(data);
dist += GetObjectSize();
if (includeMargin)
dist += VISIBILITY_COMPENSATION; // pussywizard: to ensure everyone receives all important packets
Acore::MessageDistDeliverer notifier(this, data, dist, false, skipped_rcvr);
Cell::VisitWorldObjects(this, notifier, dist);
}
@@ -11315,7 +11321,7 @@ WorldLocation Player::GetStartPosition() const
return WorldLocation(mapId, info->positionX, info->positionY, info->positionZ, 0);
}
bool Player::HaveAtClient(Object const* u) const
bool Player::HaveAtClient(WorldObject const* u) const
{
if (u == this)
{
@@ -13089,11 +13095,14 @@ void Player::SetViewpoint(WorldObject* target, bool apply)
UpdateVisibilityOf(target);
if (target->isType(TYPEMASK_UNIT) && !GetVehicle())
static_cast<Unit*>(target)->AddPlayerToVision(this);
((Unit*)target)->AddPlayerToVision(this);
SetSeer(target);
}
else
{
//must immediately set seer back otherwise may crash
m_seer = this;
LOG_DEBUG("maps", "Player::CreateViewpoint: Player {} remove seer", GetName());
if (!RemoveGuidValue(PLAYER_FARSIGHT, target->GetGUID()))
@@ -15173,6 +15182,8 @@ void Player::ActivateSpec(uint8 spec)
else
++iter;
}
sScriptMgr->OnAfterSpecSlotChanged(this, GetActiveSpec());
}
void Player::LoadActions(PreparedQueryResult result)
+9 -8
View File
@@ -37,8 +37,8 @@
#include "PlayerTaxi.h"
#include "QuestDef.h"
#include "SpellAuras.h"
#include "SpellMgr.h"
#include "SpellInfo.h"
#include "SpellMgr.h"
#include "TradeData.h"
#include "Unit.h"
#include "WorldSession.h"
@@ -1986,10 +1986,10 @@ public:
void ProcessTerrainStatusUpdate() override;
void SendMessageToSet(WorldPacket const* data, bool self) const override { SendMessageToSetInRange(data, GetVisibilityRange(), self); } // pussywizard!
void SendMessageToSetInRange(WorldPacket const* data, float dist, bool self, Player const* skipped_rcvr = nullptr) const override; // pussywizard!
void SendMessageToSetInRange_OwnTeam(WorldPacket const* data, float dist, bool self) const; // pussywizard!
void SendMessageToSet(WorldPacket const* data, Player const* skipped_rcvr) const override { SendMessageToSetInRange(data, GetVisibilityRange(), skipped_rcvr != this, skipped_rcvr); } // pussywizard!
void SendMessageToSet(WorldPacket const* data, bool self) const override { SendMessageToSetInRange(data, GetVisibilityRange(), self, true); } // pussywizard!
void SendMessageToSetInRange(WorldPacket const* data, float dist, bool self, bool includeMargin = false, Player const* skipped_rcvr = nullptr) const override; // pussywizard!
void SendMessageToSetInRange_OwnTeam(WorldPacket const* data, float dist, bool self) const; // pussywizard! param includeMargin not needed here
void SendMessageToSet(WorldPacket const* data, Player const* skipped_rcvr) const override { SendMessageToSetInRange(data, GetVisibilityRange(), skipped_rcvr != this, true, skipped_rcvr); } // pussywizard!
void SendTeleportAckPacket();
@@ -2342,8 +2342,9 @@ public:
// currently visible objects at player client
GuidUnorderedSet m_clientGUIDs;
std::vector<Unit*> m_newVisible; // pussywizard
[[nodiscard]] bool HaveAtClient(Object const* u) const;
[[nodiscard]] bool HaveAtClient(WorldObject const* u) const;
[[nodiscard]] bool HaveAtClient(ObjectGuid guid) const;
[[nodiscard]] bool IsNeverVisible() const override;
@@ -2351,13 +2352,13 @@ public:
bool IsVisibleGloballyFor(Player const* player) const;
void GetInitialVisiblePackets(Unit* target);
void UpdateObjectVisibility(bool forced = true) override;
void UpdateObjectVisibility(bool forced = true, bool fromUpdate = false) override;
void UpdateVisibilityForPlayer(bool mapChange = false);
void UpdateVisibilityOf(WorldObject* target);
void UpdateTriggerVisibility();
template<class T>
void UpdateVisibilityOf(T* target, UpdateData& data, std::set<Unit*>& visibleNow);
void UpdateVisibilityOf(T* target, UpdateData& data, std::vector<Unit*>& visibleNow);
uint8 m_forced_speed_changes[MAX_MOVE_TYPE];
@@ -17,6 +17,7 @@
#include "CreatureAI.h"
#include "DisableMgr.h"
#include "GameEventMgr.h"
#include "GameObjectAI.h"
#include "GameTime.h"
#include "GitRevision.h"
@@ -62,6 +62,8 @@
#include "SpellAuraEffects.h"
#include "SpellAuras.h"
#include "SpellMgr.h"
#include "StringConvert.h"
#include "Tokenize.h"
#include "Transport.h"
#include "UpdateData.h"
#include "UpdateFieldFlags.h"
@@ -70,8 +72,6 @@
#include "Weather.h"
#include "World.h"
#include "WorldPacket.h"
#include "Tokenize.h"
#include "StringConvert.h"
/// @todo: this import is not necessary for compilation and marked as unused by the IDE
// however, for some reasons removing it would cause a damn linking issue
@@ -5454,7 +5454,7 @@ bool Player::LoadFromDB(ObjectGuid playerGuid, CharacterDatabaseQueryHolder cons
// add ghost flag (must be after aura load: PLAYER_FLAGS_GHOST set in aura)
if (HasPlayerFlag(PLAYER_FLAGS_GHOST))
{
m_deathState = DEAD;
m_deathState = DeathState::Dead;
AddUnitState(UNIT_STATE_ISOLATED);
}
@@ -17,8 +17,8 @@
#include "ObjectMgr.h"
#include "Player.h"
#include "Tokenize.h"
#include "StringConvert.h"
#include "Tokenize.h"
void PlayerTaxi::InitTaxiNodesForLevel(uint32 race, uint32 chrClass, uint8 level)
{
@@ -15,6 +15,7 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "AchievementMgr.h"
#include "BattlefieldMgr.h"
#include "CellImpl.h"
#include "Channel.h"
@@ -35,6 +36,7 @@
#include "SpellMgr.h"
#include "UpdateFieldFlags.h"
#include "Vehicle.h"
#include "Weather.h"
#include "WeatherMgr.h"
#include "WorldStatePackets.h"
@@ -311,7 +313,7 @@ void Player::Update(uint32 p_time)
RegenerateAll();
}
if (m_deathState == JUST_DIED)
if (m_deathState == DeathState::JustDied)
KillPlayer();
if (m_nextSave)
@@ -413,6 +415,13 @@ void Player::Update(uint32 p_time)
TeleportTo(teleportStore_dest, teleportStore_options);
}
if (!IsBeingTeleported() && bRequestForcedVisibilityUpdate)
{
bRequestForcedVisibilityUpdate = false;
UpdateObjectVisibility(true, true);
m_delayed_unit_relocation_timer = 0;
RemoveFromNotify(NOTIFY_VISIBILITY_CHANGED);
}
sScriptMgr->OnAfterPlayerUpdate(this, p_time);
}
@@ -789,8 +798,8 @@ bool Player::UpdateCraftSkill(uint32 spellid)
GetPureSkillValue(_spell_idx->second->SkillLine);
// Alchemy Discoveries here
SpellInfo const* spellEntry = sSpellMgr->GetSpellInfo(spellid);
if (spellEntry && spellEntry->Mechanic == MECHANIC_DISCOVERY)
SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellid);
if (spellInfo && spellInfo->Mechanic == MECHANIC_DISCOVERY)
{
if (uint32 discoveredSpell = GetSkillDiscoverySpell(
_spell_idx->second->SkillLine, spellid, this))
@@ -1523,11 +1532,17 @@ void Player::UpdatePotionCooldown(Spell* spell)
SetLastPotionId(0);
}
template void Player::UpdateVisibilityOf(Player* target, UpdateData& data, std::set<Unit*>& visibleNow);
template void Player::UpdateVisibilityOf(Creature* target, UpdateData& data, std::set<Unit*>& visibleNow);
template void Player::UpdateVisibilityOf(Corpse* target, UpdateData& data, std::set<Unit*>& visibleNow);
template void Player::UpdateVisibilityOf(GameObject* target, UpdateData& data, std::set<Unit*>& visibleNow);
template void Player::UpdateVisibilityOf(DynamicObject* target, UpdateData& data, std::set<Unit*>& visibleNow);
template void Player::UpdateVisibilityOf(Player* target, UpdateData& data,
std::vector<Unit*>& visibleNow);
template void Player::UpdateVisibilityOf(Creature* target, UpdateData& data,
std::vector<Unit*>& visibleNow);
template void Player::UpdateVisibilityOf(Corpse* target, UpdateData& data,
std::vector<Unit*>& visibleNow);
template void Player::UpdateVisibilityOf(GameObject* target, UpdateData& data,
std::vector<Unit*>& visibleNow);
template void Player::UpdateVisibilityOf(DynamicObject* target,
UpdateData& data,
std::vector<Unit*>& visibleNow);
void Player::UpdateVisibilityForPlayer(bool mapChange)
{
@@ -1538,13 +1553,23 @@ void Player::UpdateVisibilityForPlayer(bool mapChange)
m_seer = this;
}
// updates visibility of all objects around point of view for current player
Acore::VisibleNotifier notifier(*this);
Cell::VisitAllObjects(m_seer, notifier, GetSightRange());
notifier.SendToSelf(); // send gathered data
Acore::VisibleNotifier notifierNoLarge(
*this, mapChange,
false); // visit only objects which are not large; default distance
Cell::VisitAllObjects(m_seer, notifierNoLarge,
GetSightRange() + VISIBILITY_INC_FOR_GOBJECTS);
notifierNoLarge.SendToSelf();
Acore::VisibleNotifier notifierLarge(
*this, mapChange, true); // visit only large objects; maximum distance
Cell::VisitAllObjects(m_seer, notifierLarge, GetSightRange());
notifierLarge.SendToSelf();
if (mapChange)
m_last_notify_position.Relocate(-5000.0f, -5000.0f, -5000.0f, 0.0f);
}
void Player::UpdateObjectVisibility(bool forced)
void Player::UpdateObjectVisibility(bool forced, bool fromUpdate)
{
// Prevent updating visibility if player is not in world (example: LoadFromDB sets drunkstate which updates invisibility while player is not in map)
if (!IsInWorld())
@@ -1554,19 +1579,26 @@ void Player::UpdateObjectVisibility(bool forced)
AddToNotify(NOTIFY_VISIBILITY_CHANGED);
else if (!isBeingLoaded())
{
if (!fromUpdate) // pussywizard:
{
bRequestForcedVisibilityUpdate = true;
return;
}
Unit::UpdateObjectVisibility(true);
UpdateVisibilityForPlayer();
}
}
template <class T>
inline void UpdateVisibilityOf_helper(GuidUnorderedSet& s64, T* target, std::set<Unit*>& /*v*/)
inline void UpdateVisibilityOf_helper(GuidUnorderedSet& s64, T* target,
std::vector<Unit*>& /*v*/)
{
s64.insert(target->GetGUID());
}
template <>
inline void UpdateVisibilityOf_helper(GuidUnorderedSet& s64, GameObject* target, std::set<Unit*>& /*v*/)
inline void UpdateVisibilityOf_helper(GuidUnorderedSet& s64, GameObject* target,
std::vector<Unit*>& /*v*/)
{
// @HACK: This is to prevent objects like deeprun tram from disappearing
// when player moves far from its spawn point while riding it
@@ -1575,17 +1607,19 @@ inline void UpdateVisibilityOf_helper(GuidUnorderedSet& s64, GameObject* target,
}
template <>
inline void UpdateVisibilityOf_helper(GuidUnorderedSet& s64, Creature* target, std::set<Unit*>& v)
inline void UpdateVisibilityOf_helper(GuidUnorderedSet& s64, Creature* target,
std::vector<Unit*>& v)
{
s64.insert(target->GetGUID());
v.insert(target);
v.push_back(target);
}
template <>
inline void UpdateVisibilityOf_helper(GuidUnorderedSet& s64, Player* target, std::set<Unit*>& v)
inline void UpdateVisibilityOf_helper(GuidUnorderedSet& s64, Player* target,
std::vector<Unit*>& v)
{
s64.insert(target->GetGUID());
v.insert(target);
v.push_back(target);
}
template <class T>
@@ -1601,7 +1635,8 @@ inline void BeforeVisibilityDestroy<Creature>(Creature* t, Player* p)
}
template <class T>
void Player::UpdateVisibilityOf(T* target, UpdateData& data, std::set<Unit*>& visibleNow)
void Player::UpdateVisibilityOf(T* target, UpdateData& data,
std::vector<Unit*>& visibleNow)
{
if (HaveAtClient(target))
{
@@ -220,7 +220,7 @@ void SocialMgr::GetFriendInfo(Player* player, ObjectGuid friendGUID, FriendInfo&
friendInfo.Class = 0;
Player* pFriend = ObjectAccessor::FindConnectedPlayer(friendGUID);
if (!pFriend || AccountMgr::IsGMAccount(pFriend->GetSession()->GetSecurity()))
if (!pFriend || pFriend->GetSession()->IsGMAccount())
return;
TeamId teamId = player->GetTeamId();
@@ -32,7 +32,7 @@
#include "World.h"
#include "WorldModel.h"
MotionTransport::MotionTransport() : Transport(), _transportInfo(nullptr), _isMoving(true), _pendingStop(false), _triggeredArrivalEvent(false), _triggeredDepartureEvent(false), _delayedTeleport(false)
MotionTransport::MotionTransport() : Transport(), _transportInfo(nullptr), _isMoving(true), _pendingStop(false), _triggeredArrivalEvent(false), _triggeredDepartureEvent(false), _passengersLoaded(false), _delayedTeleport(false)
{
m_updateFlag = UPDATEFLAG_TRANSPORT | UPDATEFLAG_LOWGUID | UPDATEFLAG_STATIONARY_POSITION | UPDATEFLAG_ROTATION;
}
@@ -230,14 +230,8 @@ void MotionTransport::Update(uint32 diff)
3. transport moves from active to inactive grid
4. the grid that transport is currently in unloads
*/
bool gridActive = GetMap()->IsGridLoaded(GetPositionX(), GetPositionY());
if (_staticPassengers.empty() && gridActive) // 2.
if (_staticPassengers.empty() && GetMap()->IsGridLoaded(GetPositionX(), GetPositionY())) // 2.
LoadStaticPassengers();
else if (!_staticPassengers.empty() && !gridActive)
// 4. - if transports stopped on grid edge, some passengers can remain in active grids
// unload all static passengers otherwise passengers won't load correctly when the grid that transport is currently in becomes active
UnloadStaticPassengers();
}
}
@@ -254,27 +248,18 @@ void MotionTransport::DelayedUpdate(uint32 /*diff*/)
void MotionTransport::UpdatePosition(float x, float y, float z, float o)
{
bool newActive = GetMap()->IsGridLoaded(x, y);
Cell oldCell(GetPositionX(), GetPositionY());
if (!GetMap()->IsGridLoaded(x, y)) // pussywizard: should not happen, but just in case
GetMap()->LoadGrid(x, y);
Relocate(x, y, z, o);
UpdateModelPosition();
UpdatePassengerPositions(_passengers);
/* There are four possible scenarios that trigger loading/unloading passengers:
1. transport moves from inactive to active grid
2. the grid that transport is currently in becomes active
3. transport moves from active to inactive grid
4. the grid that transport is currently in unloads
*/
if (_staticPassengers.empty() && newActive) // 1.
if (_staticPassengers.empty())
LoadStaticPassengers();
else if (!_staticPassengers.empty() && !newActive && oldCell.DiffGrid(Cell(GetPositionX(), GetPositionY()))) // 3.
UnloadStaticPassengers();
else
UpdatePassengerPositions(_staticPassengers);
// 4. is handed by grid unload
}
void MotionTransport::AddPassenger(WorldObject* passenger, bool withAll)
@@ -321,7 +306,8 @@ void MotionTransport::RemovePassenger(WorldObject* passenger, bool withAll)
{
passenger->SetTransport(nullptr);
passenger->m_movementInfo.flags &= ~MOVEMENTFLAG_ONTRANSPORT;
passenger->m_movementInfo.transport.Reset();
passenger->m_movementInfo.transport.guid.Clear();
passenger->m_movementInfo.transport.pos.Relocate(0.0f, 0.0f, 0.0f, 0.0f);
if (passenger->ToUnit())
{
passenger->ToUnit()->ClearUnitState(UNIT_STATE_IGNORE_PATHFINDING);
@@ -421,6 +407,9 @@ GameObject* MotionTransport::CreateGOPassenger(ObjectGuid::LowType guid, GameObj
void MotionTransport::LoadStaticPassengers()
{
if (PassengersLoaded())
return;
SetPassengersLoaded(true);
if (uint32 mapId = GetGOInfo()->moTransport.mapID)
{
CellObjectGuidsMap const& cells = sObjectMgr->GetMapObjectGuids(mapId, GetMap()->GetSpawnMode());
@@ -442,6 +431,7 @@ void MotionTransport::LoadStaticPassengers()
void MotionTransport::UnloadStaticPassengers()
{
SetPassengersLoaded(false);
while (!_staticPassengers.empty())
{
WorldObject* obj = *_staticPassengers.begin();
@@ -552,19 +542,11 @@ void MotionTransport::DelayedTeleportTransport()
_delayedTeleport = false;
uint32 newMapId = _nextFrame->Node->mapid;
Map* newMap = sMapMgr->CreateBaseMap(newMapId);
GetMap()->RemoveFromMap<MotionTransport>(this, false);
float x = _nextFrame->Node->x,
y = _nextFrame->Node->y,
z = _nextFrame->Node->z,
o = _nextFrame->InitialOrientation;
if (!newMap->IsGridLoaded(x, y) && !_passengers.empty())
newMap->LoadGrid(x, y); // xinef: load before adding passengers to new map
SetMap(newMap);
PassengerSet _passengersCopy = _passengers;
for (PassengerSet::iterator itr = _passengersCopy.begin(); itr != _passengersCopy.end(); )
{
@@ -610,8 +592,15 @@ void MotionTransport::DelayedTeleportTransport()
}
}
Map* newMap = sMapMgr->CreateBaseMap(newMapId);
GetMap()->RemoveFromMap<MotionTransport>(this, false);
newMap->LoadGrid(x, y); // xinef: load before adding passengers to new map
SetMap(newMap);
Relocate(x, y, z, o);
GetMap()->AddToMap<MotionTransport>(this);
LoadStaticPassengers();
}
void MotionTransport::UpdatePassengerPositions(PassengerSet& passengers)
@@ -642,7 +631,7 @@ void MotionTransport::UpdatePassengerPositions(PassengerSet& passengers)
case TYPEID_UNIT:
{
Creature* creature = passenger->ToCreature();
GetMap()->CreatureRelocation(creature, x, y, z, o, false);
GetMap()->CreatureRelocation(creature, x, y, z, o);
creature->GetTransportHomePosition(x, y, z, o);
CalculatePassengerPosition(x, y, z, &o);
@@ -654,7 +643,7 @@ void MotionTransport::UpdatePassengerPositions(PassengerSet& passengers)
GetMap()->PlayerRelocation(passenger->ToPlayer(), x, y, z, o);
break;
case TYPEID_GAMEOBJECT:
GetMap()->GameObjectRelocation(passenger->ToGameObject(), x, y, z, o, false);
GetMap()->GameObjectRelocation(passenger->ToGameObject(), x, y, z, o);
break;
case TYPEID_DYNAMICOBJECT:
GetMap()->DynamicObjectRelocation(passenger->ToDynObject(), x, y, z, o);
@@ -791,6 +780,7 @@ bool StaticTransport::Create(ObjectGuid::LowType guidlow, uint32 name_id, Map* m
LastUsedScriptID = GetGOInfo()->ScriptId;
AIM_Initialize();
this->setActive(true);
return true;
}
@@ -925,8 +915,7 @@ void StaticTransport::UpdatePosition(float x, float y, float z, float o)
if (!GetMap()->IsGridLoaded(x, y)) // pussywizard: should not happen, but just in case
GetMap()->LoadGrid(x, y);
Relocate(x, y, z, o);
UpdateModelPosition();
GetMap()->GameObjectRelocation(this, x, y, z, o); // this also relocates the model
UpdatePassengerPositions();
}
@@ -953,14 +942,17 @@ void StaticTransport::UpdatePassengerPositions()
switch (passenger->GetTypeId())
{
case TYPEID_UNIT:
GetMap()->CreatureRelocation(passenger->ToCreature(), x, y, z, o, false);
GetMap()->CreatureRelocation(passenger->ToCreature(), x, y, z, o);
break;
case TYPEID_PLAYER:
if (passenger->IsInWorld())
{
GetMap()->PlayerRelocation(passenger->ToPlayer(), x, y, z, o);
passenger->ToPlayer()->SetFallInformation(GameTime::GetGameTime().count(), z);
}
break;
case TYPEID_GAMEOBJECT:
GetMap()->GameObjectRelocation(passenger->ToGameObject(), x, y, z, o, false);
GetMap()->GameObjectRelocation(passenger->ToGameObject(), x, y, z, o);
break;
case TYPEID_DYNAMICOBJECT:
GetMap()->DynamicObjectRelocation(passenger->ToDynObject(), x, y, z, o);
@@ -1009,7 +1001,8 @@ void StaticTransport::RemovePassenger(WorldObject* passenger, bool withAll)
{
passenger->SetTransport(nullptr);
passenger->m_movementInfo.flags &= ~MOVEMENTFLAG_ONTRANSPORT;
passenger->m_movementInfo.transport.Reset();
passenger->m_movementInfo.transport.guid.Clear();
passenger->m_movementInfo.transport.pos.Relocate(0.0f, 0.0f, 0.0f, 0.0f);
}
}
}
@@ -68,6 +68,8 @@ public:
PassengerSet const& GetStaticPassengers() const { return _staticPassengers; }
void UnloadStaticPassengers();
void UnloadNonStaticPassengers();
void SetPassengersLoaded(bool loaded) { _passengersLoaded = loaded; }
bool PassengersLoaded() const { return _passengersLoaded; }
KeyFrameVec const& GetKeyFrames() const { return _transportInfo->keyFrames; }
void EnableMovement(bool enabled);
@@ -102,6 +104,7 @@ private:
PassengerSet _staticPassengers;
mutable std::mutex Lock;
bool _passengersLoaded;
bool _delayedTeleport;
};
+1 -1
View File
@@ -15,8 +15,8 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "Creature.h"
#include "Config.h"
#include "Creature.h"
#include "Pet.h"
#include "Player.h"
#include "ScriptMgr.h"
+239 -85
View File
@@ -32,6 +32,7 @@
#include "CreatureAIImpl.h"
#include "CreatureGroups.h"
#include "DisableMgr.h"
#include "DynamicVisibility.h"
#include "Formulas.h"
#include "GameObjectAI.h"
#include "GameTime.h"
@@ -43,23 +44,24 @@
#include "MoveSpline.h"
#include "MoveSplineInit.h"
#include "MovementGenerator.h"
#include "MovementPacketBuilder.h"
#include "ObjectAccessor.h"
#include "ObjectMgr.h"
#include "Opcodes.h"
#include "OutdoorPvP.h"
#include "PassiveAI.h"
#include "Pet.h"
#include "PetAI.h"
#include "Player.h"
#include "ReputationMgr.h"
#include "ScriptMgr.h"
#include "Spell.h"
#include "SpellAuraEffects.h"
#include "SpellAuras.h"
#include "SpellInfo.h"
#include "SpellMgr.h"
#include "StringConvert.h"
#include "TargetedMovementGenerator.h"
#include "TemporarySummon.h"
#include "Tokenize.h"
#include "Totem.h"
#include "TotemAI.h"
#include "Transport.h"
@@ -68,8 +70,6 @@
#include "Vehicle.h"
#include "World.h"
#include "WorldPacket.h"
#include "Tokenize.h"
#include "StringConvert.h"
#include <math.h>
float baseMoveSpeed[MAX_MOVE_TYPE] =
@@ -247,7 +247,7 @@ Unit::Unit(bool isWorldObject) : WorldObject(isWorldObject),
m_rootTimes = 0;
m_state = 0;
m_deathState = ALIVE;
m_deathState = DeathState::Alive;
for (uint8 i = 0; i < CURRENT_MAX_SPELL; ++i)
m_currentSpells[i] = nullptr;
@@ -317,6 +317,12 @@ Unit::Unit(bool isWorldObject) : WorldObject(isWorldObject),
m_serverSideVisibility.SetValue(SERVERSIDE_VISIBILITY_GHOST, GHOST_VISIBILITY_ALIVE);
m_last_notify_position.Relocate(-5000.0f, -5000.0f, -5000.0f, 0.0f);
m_last_notify_mstime = 0;
m_delayed_unit_relocation_timer = 0;
m_delayed_unit_ai_notify_timer = 0;
bRequestForcedVisibilityUpdate = false;
m_applyResilience = false;
_instantCast = false;
@@ -405,6 +411,32 @@ void Unit::Update(uint32 p_time)
if (!IsInWorld())
return;
// pussywizard:
if (GetTypeId() != TYPEID_PLAYER || (!ToPlayer()->IsBeingTeleported() && !bRequestForcedVisibilityUpdate))
{
if (m_delayed_unit_relocation_timer)
{
if (m_delayed_unit_relocation_timer <= p_time)
{
m_delayed_unit_relocation_timer = 0;
//ExecuteDelayedUnitRelocationEvent();
FindMap()->i_objectsForDelayedVisibility.insert(this);
}
else
m_delayed_unit_relocation_timer -= p_time;
}
if (m_delayed_unit_ai_notify_timer)
{
if (m_delayed_unit_ai_notify_timer <= p_time)
{
m_delayed_unit_ai_notify_timer = 0;
ExecuteDelayedUnitAINotifyEvent();
}
else
m_delayed_unit_ai_notify_timer -= p_time;
}
}
_UpdateSpells( p_time );
if (CanHaveThreatList() && GetThreatMgr().isNeedUpdateToClient(p_time))
@@ -568,27 +600,14 @@ void Unit::UpdateSplineMovement(uint32 t_diff)
SplineHandler handler(this);
movespline->updateState(t_diff, handler);
// Xinef: Spline was cleared by StopMoving, return
if (!movespline->Initialized()) {
if (!movespline->Initialized())
{
DisableSpline();
return;
}
bool arrived = movespline->Finalized();
if (movespline->isCyclic())
{
m_splineSyncTimer.Update(t_diff);
if (m_splineSyncTimer.Passed())
{
m_splineSyncTimer.Reset(5000); // Retail value, do not change
WorldPacket data(SMSG_FLIGHT_SPLINE_SYNC, 4 + GetPackGUID().size());
Movement::PacketBuilder::WriteSplineSync(*movespline, data);
data.appendPackGUID(GetGUID());
SendMessageToSet(&data, true);
}
}
if (arrived)
{
DisableSpline();
@@ -597,11 +616,17 @@ void Unit::UpdateSplineMovement(uint32 t_diff)
SetByteValue(UNIT_FIELD_BYTES_1, UNIT_BYTES_1_OFFSET_ANIM_TIER, movespline->GetAnimationType());
}
// pussywizard: update always! not every 400ms, because movement generators need the actual position
//m_movesplineTimer.Update(t_diff);
//if (m_movesplineTimer.Passed() || arrived)
UpdateSplinePosition();
}
void Unit::UpdateSplinePosition()
{
//static uint32 const positionUpdateDelay = 400;
//m_movesplineTimer.Reset(positionUpdateDelay);
Movement::Location loc = movespline->ComputePosition();
if (movespline->onTransport)
@@ -614,14 +639,16 @@ void Unit::UpdateSplinePosition()
if (TransportBase* transport = GetDirectTransport())
transport->CalculatePassengerPosition(loc.x, loc.y, loc.z, &loc.orientation);
else
return;
}
if (HasUnitState(UNIT_STATE_CANNOT_TURN))
loc.orientation = GetOrientation();
// Xinef: if we had spline running update orientation along with position
//if (HasUnitState(UNIT_STATE_CANNOT_TURN))
// loc.orientation = GetOrientation();
UpdatePosition(loc.x, loc.y, loc.z, loc.orientation);
if (GetTypeId() == TYPEID_PLAYER)
UpdatePosition(loc.x, loc.y, loc.z, loc.orientation);
else
ToCreature()->SetPosition(loc.x, loc.y, loc.z, loc.orientation);
}
void Unit::DisableSpline()
@@ -1281,6 +1308,11 @@ void Unit::CalculateSpellDamageTaken(SpellNonMeleeDamage* damageInfo, int32 dama
// Script Hook For CalculateSpellDamageTaken -- Allow scripts to change the Damage post class mitigation calculations
sScriptMgr->ModifySpellDamageTaken(damageInfo->target, damageInfo->attacker, damage, spellInfo);
if (victim->GetAI())
{
victim->GetAI()->OnCalculateSpellDamageReceived(damage, this);
}
int32 cleanDamage = 0;
if (Unit::IsDamageReducedByArmor(damageSchoolMask, spellInfo))
{
@@ -1531,6 +1563,11 @@ void Unit::CalculateMeleeDamage(Unit* victim, CalcDamageInfo* damageInfo, Weapon
// Script Hook For CalculateMeleeDamage -- Allow scripts to change the Damage pre class mitigation calculations
sScriptMgr->ModifyMeleeDamage(damageInfo->target, damageInfo->attacker, damage);
if (victim->GetAI())
{
victim->GetAI()->OnCalculateMeleeDamageReceived(damage, this);
}
// Calculate armor reduction
if (IsDamageReducedByArmor((SpellSchoolMask)(damageInfo->damages[i].damageSchoolMask)))
{
@@ -4535,7 +4572,7 @@ void Unit::_UnapplyAura(AuraApplicationMap::iterator& i, AuraRemoveMode removeMo
if (aurApp->GetRemoveMode() == AURA_REMOVE_BY_EXPIRE && IsTotem() && GetGUID() == aura->GetCasterGUID())
{
if (ToTotem()->GetSpell() == aura->GetId() && ToTotem()->GetTotemType() == TOTEM_PASSIVE)
ToTotem()->setDeathState(JUST_DIED);
ToTotem()->setDeathState(DeathState::JustDied);
}
// Remove aurastates only if were not found
@@ -5502,7 +5539,7 @@ Aura* Unit::GetAuraOfRankedSpell(uint32 spellId, ObjectGuid casterGUID, ObjectGu
return aurApp ? aurApp->GetBase() : nullptr;
}
void Unit::GetDispellableAuraList(Unit* caster, uint32 dispelMask, DispelChargesList& dispelList)
void Unit::GetDispellableAuraList(Unit* caster, uint32 dispelMask, DispelChargesList& dispelList, SpellInfo const* dispelSpell)
{
// we should not be able to dispel diseases if the target is affected by unholy blight
if (dispelMask & (1 << DISPEL_DISEASE) && HasAura(50536))
@@ -5548,6 +5585,12 @@ void Unit::GetDispellableAuraList(Unit* caster, uint32 dispelMask, DispelCharges
continue;
}
// Banish should only be dispelled by Mass Dispel
if (aura->GetSpellInfo()->Mechanic == MECHANIC_BANISH && !dispelSpell->HasAttribute(SPELL_ATTR0_NO_IMMUNITIES))
{
continue;
}
// The charges / stack amounts don't count towards the total number of auras that can be dispelled.
// Ie: A dispel on a target with 5 stacks of Winters Chill and a Polymorph has 1 / (1 + 1) -> 50% chance to dispell
// Polymorph instead of 1 / (5 + 1) -> 16%.
@@ -9592,7 +9635,6 @@ bool Unit::HandleProcTriggerSpell(Unit* victim, uint32 damage, AuraEffect* trigg
// Cast positive spell on enemy target
case 7099: // Curse of Mending
case 39703: // Curse of Mending
case 29494: // Temptation
case 20233: // Improved Lay on Hands (cast on target)
{
target = victim;
@@ -14514,7 +14556,7 @@ void Unit::setDeathState(DeathState s, bool despawn)
// death state needs to be updated before RemoveAllAurasOnDeath() calls HandleChannelDeathItem(..) so that
// it can be used to check creation of death items (such as soul shards).
if (s != ALIVE && s != JUST_RESPAWNED)
if (s != DeathState::Alive && s != DeathState::JustRespawned)
{
CombatStop();
GetThreatMgr().ClearAllThreat();
@@ -14529,7 +14571,7 @@ void Unit::setDeathState(DeathState s, bool despawn)
RemoveAllAurasOnDeath();
}
if (s == JUST_DIED)
if (s == DeathState::JustDied)
{
// remove aurastates allowing special moves
ClearAllReactives();
@@ -14558,7 +14600,7 @@ void Unit::setDeathState(DeathState s, bool despawn)
if (ZoneScript* zoneScript = GetZoneScript() ? GetZoneScript() : (ZoneScript*)GetInstanceScript())
zoneScript->OnUnitDeath(this);
}
else if (s == JUST_RESPAWNED)
else if (s == DeathState::JustRespawned)
{
RemoveFlag (UNIT_FIELD_FLAGS, UNIT_FLAG_SKINNABLE); // clear skinnable for creature and player (at battleground)
}
@@ -15437,9 +15479,9 @@ void Unit::SetLevel(uint8 lvl, bool showLevelChange)
void Unit::SetHealth(uint32 val)
{
if (getDeathState() == JUST_DIED)
if (getDeathState() == DeathState::JustDied)
val = 0;
else if (GetTypeId() == TYPEID_PLAYER && getDeathState() == DEAD)
else if (GetTypeId() == TYPEID_PLAYER && getDeathState() == DeathState::Dead)
val = 1;
else
{
@@ -15731,9 +15773,15 @@ void Unit::CleanupBeforeRemoveFromMap(bool finalCleanup)
void Unit::CleanupsBeforeDelete(bool finalCleanup)
{
CleanupBeforeRemoveFromMap(finalCleanup);
if (GetTransport())
{
GetTransport()->RemovePassenger(this);
SetTransport(nullptr);
m_movementInfo.transport.Reset();
m_movementInfo.RemoveMovementFlag(MOVEMENTFLAG_ONTRANSPORT);
}
WorldObject::CleanupsBeforeDelete(finalCleanup);
CleanupBeforeRemoveFromMap(finalCleanup);
}
void Unit::UpdateCharmAI()
@@ -17506,17 +17554,13 @@ void Unit::SetContestedPvP(Player* attackedPlayer, bool lookForNearContestedGuar
player->AddUnitState(UNIT_STATE_ATTACK_PLAYER);
player->SetPlayerFlag(PLAYER_FLAGS_CONTESTED_PVP);
// call MoveInLineOfSight for nearby contested guards
Acore::AIRelocationNotifier notifier(*this);
Cell::VisitWorldObjects(this, notifier, GetVisibilityRange());
AddToNotify(NOTIFY_AI_RELOCATION);
}
for (Unit* unit : m_Controlled)
if (!HasUnitState(UNIT_STATE_ATTACK_PLAYER))
{
if (!unit->HasUnitState(UNIT_STATE_ATTACK_PLAYER))
{
unit->AddUnitState(UNIT_STATE_ATTACK_PLAYER);
Acore::AIRelocationNotifier notifier(*unit);
Cell::VisitWorldObjects(this, notifier, GetVisibilityRange());
}
AddUnitState(UNIT_STATE_ATTACK_PLAYER);
// call MoveInLineOfSight for nearby contested guards
AddToNotify(NOTIFY_AI_RELOCATION);
}
}
@@ -18103,12 +18147,12 @@ void Unit::Kill(Unit* killer, Unit* victim, bool durabilityLoss, WeaponAttackTyp
if (!spiritOfRedemption)
{
LOG_DEBUG("entities.unit", "SET JUST_DIED");
victim->setDeathState(JUST_DIED);
LOG_DEBUG("entities.unit", "SET DeathState::JustDied");
victim->setDeathState(DeathState::JustDied);
}
// Inform pets (if any) when player kills target)
// MUST come after victim->setDeathState(JUST_DIED); or pet next target
// MUST come after victim->setDeathState(DeathState::JustDied); or pet next target
// selection will get stuck on same target and break pet react state
if (player)
{
@@ -18517,11 +18561,6 @@ void Unit::SetFeared(bool apply, Unit* fearedBy /*= nullptr*/, bool isFear /*= f
{
SetTarget();
GetMotionMaster()->MoveFleeing(fearedBy, isFear ? 0 : sWorld->getIntConfig(CONFIG_CREATURE_FAMILY_FLEE_DELAY));
if (GetTypeId() == TYPEID_PLAYER)
{
sScriptMgr->AnticheatSetSkipOnePacketForASH(ToPlayer(), true);
}
}
else
{
@@ -18554,11 +18593,6 @@ void Unit::SetConfused(bool apply)
{
SetTarget();
GetMotionMaster()->MoveConfused();
if (GetTypeId() == TYPEID_PLAYER)
{
sScriptMgr->AnticheatSetSkipOnePacketForASH(ToPlayer(), true);
}
}
else
{
@@ -19377,7 +19411,7 @@ void Unit::SetPhaseMask(uint32 newPhaseMask, bool update)
}
}
void Unit::UpdateObjectVisibility(bool forced)
void Unit::UpdateObjectVisibility(bool forced, bool /*fromUpdate*/)
{
if (!forced)
AddToNotify(NOTIFY_VISIBILITY_CHANGED);
@@ -19385,7 +19419,8 @@ void Unit::UpdateObjectVisibility(bool forced)
{
WorldObject::UpdateObjectVisibility(true);
Acore::AIRelocationNotifier notifier(*this);
Cell::VisitAllObjects(this, notifier, GetVisibilityRange());
float radius = 60.0f;
Cell::VisitAllObjects(this, notifier, radius);
}
}
@@ -19424,7 +19459,6 @@ void Unit::KnockbackFrom(float x, float y, float speedXY, float speedZ)
if (player->HasAuraType(SPELL_AURA_MOD_INCREASE_MOUNTED_FLIGHT_SPEED) || player->HasAuraType(SPELL_AURA_FLY))
player->SetCanFly(true, true);
sScriptMgr->AnticheatSetSkipOnePacketForASH(player, true);
player->SetCanKnockback(true);
}
}
@@ -19821,10 +19855,10 @@ bool Unit::HandleSpellClick(Unit* clicker, int8 seatId)
Unit* target = (itr->second.castFlags & NPC_CLICK_CAST_TARGET_CLICKER) ? clicker : this;
ObjectGuid origCasterGUID = (itr->second.castFlags & NPC_CLICK_CAST_ORIG_CASTER_OWNER) ? GetOwnerGUID() : clicker->GetGUID();
SpellInfo const* spellEntry = sSpellMgr->GetSpellInfo(itr->second.spellId);
SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(itr->second.spellId);
// xinef: dont allow players to enter vehicles on arena
if (spellEntry->HasAura(SPELL_AURA_CONTROL_VEHICLE) && caster->GetTypeId() == TYPEID_PLAYER && caster->FindMap() && caster->FindMap()->IsBattleArena())
if (spellInfo->HasAura(SPELL_AURA_CONTROL_VEHICLE) && caster->GetTypeId() == TYPEID_PLAYER && caster->FindMap() && caster->FindMap()->IsBattleArena())
continue;
if (seatId > -1)
@@ -19833,7 +19867,7 @@ bool Unit::HandleSpellClick(Unit* clicker, int8 seatId)
bool valid = false;
while (i < MAX_SPELL_EFFECTS)
{
if (spellEntry->Effects[i].ApplyAuraName == SPELL_AURA_CONTROL_VEHICLE)
if (spellInfo->Effects[i].ApplyAuraName == SPELL_AURA_CONTROL_VEHICLE)
{
valid = true;
break;
@@ -19853,18 +19887,18 @@ bool Unit::HandleSpellClick(Unit* clicker, int8 seatId)
{
int32 bp0[MAX_SPELL_EFFECTS];
for (uint32 j = 0; j < MAX_SPELL_EFFECTS; ++j)
bp0[j] = spellEntry->Effects[j].BasePoints;
bp0[j] = spellInfo->Effects[j].BasePoints;
bp0[i] = seatId;
Aura::TryRefreshStackOrCreate(spellEntry, MAX_EFFECT_MASK, this, clicker, bp0, nullptr, origCasterGUID);
Aura::TryRefreshStackOrCreate(spellInfo, MAX_EFFECT_MASK, this, clicker, bp0, nullptr, origCasterGUID);
}
}
else
{
if (IsInMap(caster))
caster->CastSpell(target, spellEntry, GetVehicleKit() ? TRIGGERED_IGNORE_CASTER_MOUNTED_OR_ON_VEHICLE : TRIGGERED_NONE, nullptr, nullptr, origCasterGUID);
caster->CastSpell(target, spellInfo, GetVehicleKit() ? TRIGGERED_IGNORE_CASTER_MOUNTED_OR_ON_VEHICLE : TRIGGERED_NONE, nullptr, nullptr, origCasterGUID);
else
Aura::TryRefreshStackOrCreate(spellEntry, MAX_EFFECT_MASK, this, clicker, nullptr, nullptr, origCasterGUID);
Aura::TryRefreshStackOrCreate(spellInfo, MAX_EFFECT_MASK, this, clicker, nullptr, nullptr, origCasterGUID);
}
result = true;
@@ -19883,7 +19917,6 @@ void Unit::EnterVehicle(Unit* base, int8 seatId)
if (Player* player = ToPlayer())
{
sScriptMgr->AnticheatSetUnderACKmount(player);
sScriptMgr->AnticheatSetSkipOnePacketForASH(player, true);
}
}
@@ -19926,7 +19959,6 @@ void Unit::_EnterVehicle(Vehicle* vehicle, int8 seatId, AuraApplication const* a
return;
sScriptMgr->AnticheatSetUnderACKmount(player);
sScriptMgr->AnticheatSetSkipOnePacketForASH(player, true);
InterruptNonMeleeSpells(false);
player->StopCastingCharm();
@@ -19999,7 +20031,6 @@ void Unit::ExitVehicle(Position const* /*exitPosition*/)
if (Player* player = ToPlayer())
{
sScriptMgr->AnticheatSetUnderACKmount(player);
sScriptMgr->AnticheatSetSkipOnePacketForASH(player, true);
}
}
@@ -20073,7 +20104,6 @@ void Unit::_ExitVehicle(Position const* exitPosition)
player->SetFallInformation(GameTime::GetGameTime().count(), GetPositionZ());
sScriptMgr->AnticheatSetUnderACKmount(player);
sScriptMgr->AnticheatSetSkipOnePacketForASH(player, true);
}
else if (HasUnitMovementFlag(MOVEMENTFLAG_ROOT))
{
@@ -20136,8 +20166,8 @@ void Unit::_ExitVehicle(Position const* exitPosition)
if (HasUnitTypeMask(UNIT_MASK_ACCESSORY))
{
// Vehicle just died, we die too
if (vehicleBase->getDeathState() == JUST_DIED)
setDeathState(JUST_DIED);
if (vehicleBase->getDeathState() == DeathState::JustDied)
setDeathState(DeathState::JustDied);
// If for other reason we as minion are exiting the vehicle (ejected, master dismounted) - unsummon
else
{
@@ -20283,14 +20313,10 @@ bool Unit::UpdatePosition(float x, float y, float z, float orientation, bool tel
if (!Acore::IsValidMapCoord(x, y, z, orientation))
return false;
// Check if angular distance changed
bool const turn = G3D::fuzzyGt(M_PI - fabs(fabs(GetOrientation() - orientation) - M_PI), 0.0f);
// G3D::fuzzyEq won't help here, in some cases magnitudes differ by a little more than G3D::eps, but should be considered equal
bool const relocated = (teleport ||
std::fabs(GetPositionX() - x) > 0.001f ||
std::fabs(GetPositionY() - y) > 0.001f ||
std::fabs(GetPositionZ() - z) > 0.001f);
float old_orientation = GetOrientation();
float current_z = GetPositionZ();
bool turn = (old_orientation != orientation);
bool relocated = (teleport || GetPositionX() != x || GetPositionY() != y || current_z != z);
if (!GetVehicle())
{
@@ -20316,8 +20342,6 @@ bool Unit::UpdatePosition(float x, float y, float z, float orientation, bool tel
UpdateObjectVisibility(false);
}
UpdatePositionData();
return (relocated || turn);
}
@@ -20748,6 +20772,124 @@ bool ConflagrateAuraStateDelayEvent::Execute(uint64 /*e_time*/, uint32 /*p_time
return true;
}
void Unit::ExecuteDelayedUnitRelocationEvent()
{
this->RemoveFromNotify(NOTIFY_VISIBILITY_CHANGED);
if (!this->IsInWorld() || this->IsDuringRemoveFromWorld())
return;
if (this->HasSharedVision())
for (SharedVisionList::const_iterator itr = this->GetSharedVisionList().begin(); itr != this->GetSharedVisionList().end(); ++itr)
if (Player* player = (*itr))
{
if (player->IsOnVehicle(this) || !player->IsInWorld() || player->IsDuringRemoveFromWorld()) // players on vehicles have their own event executed (due to passenger relocation)
continue;
WorldObject* viewPoint = player;
if (player->m_seer && player->m_seer->IsInWorld())
viewPoint = player->m_seer;
if (!viewPoint->IsPositionValid() || !player->IsPositionValid())
continue;
if (Unit* active = viewPoint->ToUnit())
{
//if (active->IsVehicle()) // always check original unit here, last notify position is not relocated
// active = player;
float dx = active->m_last_notify_position.GetPositionX() - active->GetPositionX();
float dy = active->m_last_notify_position.GetPositionY() - active->GetPositionY();
float dz = active->m_last_notify_position.GetPositionZ() - active->GetPositionZ();
float distsq = dx * dx + dy * dy + dz * dz;
float mindistsq = DynamicVisibilityMgr::GetReqMoveDistSq(active->FindMap()->GetEntry()->map_type);
if (distsq < mindistsq)
continue;
// this will be relocated below sharedvision!
//active->m_last_notify_position.Relocate(active->GetPositionX(), active->GetPositionY(), active->GetPositionZ());
}
Acore::PlayerRelocationNotifier relocateNoLarge(*player, false); // visit only objects which are not large; default distance
Cell::VisitAllObjects(viewPoint, relocateNoLarge, player->GetSightRange() + VISIBILITY_INC_FOR_GOBJECTS);
relocateNoLarge.SendToSelf();
Acore::PlayerRelocationNotifier relocateLarge(*player, true); // visit only large objects; maximum distance
Cell::VisitAllObjects(viewPoint, relocateLarge, MAX_VISIBILITY_DISTANCE);
relocateLarge.SendToSelf();
}
if (Player* player = this->ToPlayer())
{
WorldObject* viewPoint = player;
if (player->m_seer && player->m_seer->IsInWorld())
viewPoint = player->m_seer;
if (viewPoint->GetMapId() != player->GetMapId() || !viewPoint->IsPositionValid() || !player->IsPositionValid())
return;
if (Unit* active = viewPoint->ToUnit())
{
if (active->IsVehicle())
active = player;
if (!player->GetFarSightDistance())
{
float dx = active->m_last_notify_position.GetPositionX() - active->GetPositionX();
float dy = active->m_last_notify_position.GetPositionY() - active->GetPositionY();
float dz = active->m_last_notify_position.GetPositionZ() - active->GetPositionZ();
float distsq = dx * dx + dy * dy + dz * dz;
float mindistsq = DynamicVisibilityMgr::GetReqMoveDistSq(active->FindMap()->GetEntry()->map_type);
if (distsq < mindistsq)
return;
active->m_last_notify_position.Relocate(active->GetPositionX(), active->GetPositionY(), active->GetPositionZ());
}
}
Acore::PlayerRelocationNotifier relocateNoLarge(*player, false); // visit only objects which are not large; default distance
Cell::VisitAllObjects(viewPoint, relocateNoLarge, player->GetSightRange() + VISIBILITY_INC_FOR_GOBJECTS);
relocateNoLarge.SendToSelf();
if (!player->GetFarSightDistance())
{
Acore::PlayerRelocationNotifier relocateLarge(*player, true); // visit only large objects; maximum distance
Cell::VisitAllObjects(viewPoint, relocateLarge, MAX_VISIBILITY_DISTANCE);
relocateLarge.SendToSelf();
}
this->AddToNotify(NOTIFY_AI_RELOCATION);
}
else if (Creature* unit = this->ToCreature())
{
if (!unit->IsPositionValid())
return;
float dx = unit->m_last_notify_position.GetPositionX() - unit->GetPositionX();
float dy = unit->m_last_notify_position.GetPositionY() - unit->GetPositionY();
float dz = unit->m_last_notify_position.GetPositionZ() - unit->GetPositionZ();
float distsq = dx * dx + dy * dy + dz * dz;
float mindistsq = DynamicVisibilityMgr::GetReqMoveDistSq(unit->FindMap()->GetEntry()->map_type);
if (distsq < mindistsq)
return;
unit->m_last_notify_position.Relocate(unit->GetPositionX(), unit->GetPositionY(), unit->GetPositionZ());
Acore::CreatureRelocationNotifier relocate(*unit);
Cell::VisitAllObjects(unit, relocate, unit->GetVisibilityRange() + VISIBILITY_COMPENSATION);
this->AddToNotify(NOTIFY_AI_RELOCATION);
}
}
void Unit::ExecuteDelayedUnitAINotifyEvent()
{
this->RemoveFromNotify(NOTIFY_AI_RELOCATION);
if (!this->IsInWorld() || this->IsDuringRemoveFromWorld())
return;
Acore::AIRelocationNotifier notifier(*this);
float radius = 60.0f;
Cell::VisitAllObjects(this, notifier, radius);
}
void Unit::SetInFront(WorldObject const* target)
{
if (!HasUnitState(UNIT_STATE_CANNOT_TURN))
@@ -21016,7 +21158,7 @@ void Unit::BuildValuesUpdate(uint8 updateType, ByteBuffer* data, Player* target)
else if (index == UNIT_FIELD_FLAGS)
{
uint32 appendValue = m_uint32Values[UNIT_FIELD_FLAGS];
if (target->IsGameMaster() && AccountMgr::IsGMAccount(target->GetSession()->GetSecurity()))
if (target->IsGameMaster() && target->GetSession()->IsGMAccount())
appendValue &= ~UNIT_FLAG_NOT_SELECTABLE;
fieldBuffer << uint32(appendValue);
@@ -21041,7 +21183,7 @@ void Unit::BuildValuesUpdate(uint8 updateType, ByteBuffer* data, Player* target)
if (cinfo->flags_extra & CREATURE_FLAG_EXTRA_TRIGGER)
{
if (target->IsGameMaster() && AccountMgr::IsGMAccount(target->GetSession()->GetSecurity()))
if (target->IsGameMaster() && target->GetSession()->IsGMAccount())
{
if (cinfo->Modelid1)
displayId = cinfo->Modelid1; // Modelid1 is a visible model for gms
@@ -21176,6 +21318,18 @@ void Unit::setRace(uint8 race)
m_race = race;
}
DisplayRace Unit::GetDisplayRaceFromModelId(uint32 modelId) const
{
if (CreatureDisplayInfoEntry const* display = sCreatureDisplayInfoStore.LookupEntry(modelId))
{
if (CreatureDisplayInfoExtraEntry const* displayExtra = sCreatureDisplayInfoExtraStore.LookupEntry(display->ExtendedDisplayInfoID))
{
return DisplayRace(displayExtra->DisplayRaceID);
}
}
return DisplayRace::None;
}
// Check if unit in combat with specific unit
bool Unit::IsInCombatWith(Unit const* who) const
{
+25 -15
View File
@@ -18,8 +18,8 @@
#ifndef __UNIT_H
#define __UNIT_H
#include "EventProcessor.h"
#include "EnumFlag.h"
#include "EventProcessor.h"
#include "FollowerRefMgr.h"
#include "FollowerReference.h"
#include "HostileRefMgr.h"
@@ -311,13 +311,13 @@ enum BaseModType
#define MOD_END (PCT_MOD+1)
enum DeathState
enum class DeathState : uint8
{
ALIVE = 0,
JUST_DIED = 1,
CORPSE = 2,
DEAD = 3,
JUST_RESPAWNED = 4,
Alive = 0,
JustDied = 1,
Corpse = 2,
Dead = 3,
JustRespawned = 4,
};
enum UnitState
@@ -391,7 +391,7 @@ enum UnitMoveType
extern float baseMoveSpeed[MAX_MOVE_TYPE];
extern float playerBaseMoveSpeed[MAX_MOVE_TYPE];
enum WeaponAttackType
enum WeaponAttackType : uint8
{
BASE_ATTACK = 0,
OFF_ATTACK = 1,
@@ -430,7 +430,7 @@ enum CombatRating
#define MAX_COMBAT_RATING 25
enum DamageEffectType
enum DamageEffectType : uint8
{
DIRECT_DAMAGE = 0, // used for normal weapon damage (not for class abilities or spells)
SPELL_DIRECT_DAMAGE = 1, // spell/class abilities damage
@@ -1438,6 +1438,8 @@ public:
[[nodiscard]] uint8 getClass() const { return GetByteValue(UNIT_FIELD_BYTES_0, 1); }
[[nodiscard]] uint32 getClassMask() const { return 1 << (getClass() - 1); }
[[nodiscard]] uint8 getGender() const { return GetByteValue(UNIT_FIELD_BYTES_0, 2); }
[[nodiscard]] DisplayRace GetDisplayRaceFromModelId(uint32 modelId) const;
[[nodiscard]] DisplayRace GetDisplayRace() const { return GetDisplayRaceFromModelId(GetDisplayId()); };
[[nodiscard]] float GetStat(Stats stat) const { return float(GetUInt32Value(static_cast<uint16>(UNIT_FIELD_STAT0) + stat)); }
void SetStat(Stats stat, int32 val) { SetStatInt32Value(static_cast<uint16>(UNIT_FIELD_STAT0) + stat, val); }
@@ -1819,9 +1821,9 @@ public:
void BuildHeartBeatMsg(WorldPacket* data) const;
[[nodiscard]] bool IsAlive() const { return (m_deathState == ALIVE); };
[[nodiscard]] bool isDying() const { return (m_deathState == JUST_DIED); };
[[nodiscard]] bool isDead() const { return (m_deathState == DEAD || m_deathState == CORPSE); };
[[nodiscard]] bool IsAlive() const { return (m_deathState == DeathState::Alive); };
[[nodiscard]] bool isDying() const { return (m_deathState == DeathState::JustDied); };
[[nodiscard]] bool isDead() const { return (m_deathState == DeathState::Dead || m_deathState == DeathState::Corpse); };
DeathState getDeathState() { return m_deathState; };
virtual void setDeathState(DeathState s, bool despawn = false); // overwrited in Creature/Player/Pet
@@ -1995,7 +1997,7 @@ public:
AuraApplication* GetAuraApplicationOfRankedSpell(uint32 spellId, ObjectGuid casterGUID = ObjectGuid::Empty, ObjectGuid itemCasterGUID = ObjectGuid::Empty, uint8 reqEffMask = 0, AuraApplication* except = nullptr) const;
[[nodiscard]] Aura* GetAuraOfRankedSpell(uint32 spellId, ObjectGuid casterGUID = ObjectGuid::Empty, ObjectGuid itemCasterGUID = ObjectGuid::Empty, uint8 reqEffMask = 0) const;
void GetDispellableAuraList(Unit* caster, uint32 dispelMask, DispelChargesList& dispelList);
void GetDispellableAuraList(Unit* caster, uint32 dispelMask, DispelChargesList& dispelList, SpellInfo const* dispelSpell);
[[nodiscard]] bool HasAuraEffect(uint32 spellId, uint8 effIndex, ObjectGuid caster = ObjectGuid::Empty) const;
[[nodiscard]] uint32 GetAuraCount(uint32 spellId) const;
@@ -2145,7 +2147,7 @@ public:
// common function for visibility checks for player/creatures with detection code
[[nodiscard]] uint32 GetPhaseByAuras() const;
void SetPhaseMask(uint32 newPhaseMask, bool update) override;// overwrite WorldObject::SetPhaseMask
void UpdateObjectVisibility(bool forced = true) override;
void UpdateObjectVisibility(bool forced = true, bool fromUpdate = false) override;
SpellImmuneList m_spellImmune[MAX_SPELL_IMMUNITY];
uint32 m_lastSanctuaryTime;
@@ -2419,6 +2421,14 @@ public:
void AddPointedBy(SafeUnitPointer* sup) { SafeUnitPointerSet.insert(sup); }
void RemovePointedBy(SafeUnitPointer* sup) { SafeUnitPointerSet.erase(sup); }
static void HandleSafeUnitPointersOnDelete(Unit* thisUnit);
// Relocation Nofier optimization
Position m_last_notify_position;
uint32 m_last_notify_mstime;
uint16 m_delayed_unit_relocation_timer;
uint16 m_delayed_unit_ai_notify_timer;
bool bRequestForcedVisibilityUpdate;
void ExecuteDelayedUnitRelocationEvent();
void ExecuteDelayedUnitAINotifyEvent();
// cooldowns
[[nodiscard]] virtual bool HasSpellCooldown(uint32 /*spell_id*/) const { return false; }
@@ -2581,7 +2591,7 @@ private:
uint32 m_state; // Even derived shouldn't modify
uint32 m_CombatTimer;
uint32 m_lastManaUse; // msecs
TimeTrackerSmall m_splineSyncTimer;
//TimeTrackerSmall m_movesplineTimer;
Diminishing m_Diminishing;
// Manage all Units that are threatened by us
@@ -15,9 +15,9 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "Unit.h"
#include "Define.h"
#include "SmartEnum.h"
#include "Unit.h"
#include <stdexcept>
namespace Acore::Impl::EnumUtilsImpl
+1 -2
View File
@@ -545,8 +545,7 @@ bool Vehicle::IsVehicleInUse()
void Vehicle::TeleportVehicle(float x, float y, float z, float ang)
{
if (!_me->GetMap()->IsGridLoaded(x, y))
_me->GetMap()->LoadGrid(x, y);
_me->GetMap()->LoadGrid(x, y);
_me->NearTeleportTo(x, y, z, ang, true);
for (SeatMap::const_iterator itr = Seats.begin(); itr != Seats.end(); ++itr)
+57 -27
View File
@@ -22,20 +22,19 @@
#include "CharacterCache.h"
#include "Chat.h"
#include "Common.h"
#include "CreatureAIFactory.h"
#include "Config.h"
#include "Containers.h"
#include "DatabaseEnv.h"
#include "CreatureAIFactory.h"
#include "DBCStructure.h"
#include "DatabaseEnv.h"
#include "DisableMgr.h"
#include "GameObjectAIFactory.h"
#include "GameEventMgr.h"
#include "GameObjectAIFactory.h"
#include "GameTime.h"
#include "GossipDef.h"
#include "GroupMgr.h"
#include "GuildMgr.h"
#include "LFGMgr.h"
#include "Language.h"
#include "Log.h"
#include "MapMgr.h"
#include "Pet.h"
@@ -45,13 +44,14 @@
#include "Spell.h"
#include "SpellMgr.h"
#include "SpellScript.h"
#include "SpellScriptLoader.h"
#include "StringConvert.h"
#include "Tokenize.h"
#include "Transport.h"
#include "Unit.h"
#include "Util.h"
#include "Vehicle.h"
#include "World.h"
#include "StringConvert.h"
#include "Tokenize.h"
#include <boost/algorithm/string.hpp>
ScriptMapMap sSpellScripts;
@@ -591,7 +591,7 @@ void ObjectMgr::LoadCreatureTemplates()
"ctm.Ground, ctm.Swim, ctm.Flight, ctm.Rooted, ctm.Chase, ctm.Random, ctm.InteractionPauseTimer, HoverHeight, HealthModifier, ManaModifier, ArmorModifier, ExperienceModifier, "
// 64 65 66 67 68 69 70
"RacialLeader, movementId, RegenHealth, mechanic_immune_mask, spell_school_immune_mask, flags_extra, ScriptName "
"FROM creature_template ct LEFT JOIN creature_template_movement ctm ON ct.entry = ctm.CreatureId;");
"FROM creature_template ct LEFT JOIN creature_template_movement ctm ON ct.entry = ctm.CreatureId ORDER BY entry DESC;");
if (!result)
{
@@ -600,6 +600,7 @@ void ObjectMgr::LoadCreatureTemplates()
}
_creatureTemplateStore.rehash(result->GetRowCount());
_creatureTemplateStoreFast.clear();
uint32 count = 0;
do
@@ -609,20 +610,7 @@ void ObjectMgr::LoadCreatureTemplates()
++count;
} while (result->NextRow());
// pussywizard:
{
uint32 max = 0;
for (CreatureTemplateContainer::const_iterator itr = _creatureTemplateStore.begin(); itr != _creatureTemplateStore.end(); ++itr)
if (itr->first > max)
max = itr->first;
if (max)
{
_creatureTemplateStoreFast.clear();
_creatureTemplateStoreFast.resize(max + 1, nullptr);
for (CreatureTemplateContainer::iterator itr = _creatureTemplateStore.begin(); itr != _creatureTemplateStore.end(); ++itr)
_creatureTemplateStoreFast[itr->first] = &(itr->second);
}
}
sScriptMgr->OnAfterDatabaseLoadCreatureTemplates(_creatureTemplateStoreFast);
LoadCreatureTemplateResistances();
LoadCreatureTemplateSpells();
@@ -638,12 +626,28 @@ void ObjectMgr::LoadCreatureTemplates()
LOG_INFO("server.loading", " ");
}
void ObjectMgr::LoadCreatureTemplate(Field* fields)
/**
* @brief Loads a creature template from a database result
*
* @param fields Database result
* @param triggerHook If true, will trigger the OnAfterDatabaseLoadCreatureTemplates hook. Useful if you are not calling the hook yourself.
*/
void ObjectMgr::LoadCreatureTemplate(Field* fields, bool triggerHook)
{
uint32 entry = fields[0].Get<uint32>();
CreatureTemplate& creatureTemplate = _creatureTemplateStore[entry];
// enlarge the fast cache as necessary
if (_creatureTemplateStoreFast.size() < entry + 1)
{
_creatureTemplateStoreFast.resize(entry + 1, nullptr);
}
// load a pointer to this creatureTemplate into the fast cache
_creatureTemplateStoreFast[entry] = &creatureTemplate;
// build the creatureTemplate
creatureTemplate.Entry = entry;
for (uint8 i = 0; i < MAX_DIFFICULTY - 1; ++i)
@@ -750,6 +754,13 @@ void ObjectMgr::LoadCreatureTemplate(Field* fields)
creatureTemplate.SpellSchoolImmuneMask = fields[68].Get<uint8>();
creatureTemplate.flags_extra = fields[69].Get<uint32>();
creatureTemplate.ScriptID = GetScriptId(fields[70].Get<std::string>());
// useful if the creature template load is being triggered from outside this class
if (triggerHook)
{
sScriptMgr->OnAfterDatabaseLoadCreatureTemplates(_creatureTemplateStoreFast);
}
}
void ObjectMgr::LoadCreatureTemplateResistances()
@@ -4931,6 +4942,25 @@ void ObjectMgr::LoadQuests()
}
}
for (uint8 j = 0; j < QUEST_REWARDS_COUNT; ++j)
{
if (!qinfo->RewardItemId[0] && qinfo->RewardItemId[j])
{
LOG_ERROR("sql.sql", "Quest {} has no `RewardItemId1` but has `RewardItem{}`. Reward item will not be loaded.",
qinfo->GetQuestId(), j + 1);
}
if (!qinfo->RewardItemId[1] && j > 1 && qinfo->RewardItemId[j])
{
LOG_ERROR("sql.sql", "Quest {} has no `RewardItemId2` but has `RewardItem{}`. Reward item will not be loaded.",
qinfo->GetQuestId(), j + 1);
}
if (!qinfo->RewardItemId[2] && j > 2 && qinfo->RewardItemId[j])
{
LOG_ERROR("sql.sql", "Quest {} has no `RewardItemId3` but has `RewardItem{}`. Reward item will not be loaded.",
qinfo->GetQuestId(), j + 1);
}
}
for (uint8 j = 0; j < QUEST_REWARDS_COUNT; ++j)
{
uint32 id = qinfo->RewardItemId[j];
@@ -5660,7 +5690,7 @@ void ObjectMgr::ValidateSpellScripts()
for (SpellScriptsContainer::iterator itr = _spellScriptsStore.begin(); itr != _spellScriptsStore.end();)
{
SpellInfo const* spellEntry = sSpellMgr->GetSpellInfo(itr->first);
SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(itr->first);
std::vector<std::pair<SpellScriptLoader*, SpellScriptsContainer::iterator> > SpellScriptLoaders;
sScriptMgr->CreateSpellScriptLoaders(itr->first, SpellScriptLoaders);
itr = _spellScriptsStore.upper_bound(itr->first);
@@ -5677,17 +5707,17 @@ void ObjectMgr::ValidateSpellScripts()
}
if (spellScript)
{
spellScript->_Init(&sitr->first->GetName(), spellEntry->Id);
spellScript->_Init(&sitr->first->GetName(), spellInfo->Id);
spellScript->_Register();
if (!spellScript->_Validate(spellEntry))
if (!spellScript->_Validate(spellInfo))
valid = false;
delete spellScript;
}
if (auraScript)
{
auraScript->_Init(&sitr->first->GetName(), spellEntry->Id);
auraScript->_Init(&sitr->first->GetName(), spellInfo->Id);
auraScript->_Register();
if (!auraScript->_Validate(spellEntry))
if (!auraScript->_Validate(spellInfo))
valid = false;
delete auraScript;
}
+2 -2
View File
@@ -25,6 +25,7 @@
#include "DatabaseEnv.h"
#include "DynamicObject.h"
#include "GameObject.h"
#include "GossipDef.h"
#include "ItemTemplate.h"
#include "Log.h"
#include "Mail.h"
@@ -36,7 +37,6 @@
#include "QuestDef.h"
#include "TemporarySummon.h"
#include "VehicleDefines.h"
#include "GossipDef.h"
#include <functional>
#include <limits>
#include <map>
@@ -1021,7 +1021,7 @@ public:
void LoadCreatureClassLevelStats();
void LoadCreatureLocales();
void LoadCreatureTemplates();
void LoadCreatureTemplate(Field* fields);
void LoadCreatureTemplate(Field* fields, bool triggerHook = false);
void LoadCreatureTemplateAddons();
void LoadCreatureTemplateResistances();
void LoadCreatureTemplateSpells();
-6
View File
@@ -96,12 +96,6 @@ public:
visitor.Visit(i_objects);
}
template<class T>
uint32 GetWorldObjectCountInGrid() const
{
return i_objects.template Count<T>();
}
/** Inserts a container type object into the grid.
*/
template<class SPECIFIC_OBJECT> void AddGridObject(SPECIFIC_OBJECT* obj)
-65
View File
@@ -1,65 +0,0 @@
/*
* This file is part of the AzerothCore Project. See AUTHORS file for Copyright information
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published by the
* Free Software Foundation; either version 3 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "GridStates.h"
#include "GridNotifiers.h"
#include "Log.h"
#include "Map.h"
#include "ObjectGridLoader.h"
void InvalidState::Update(Map&, NGridType&, GridInfo&, uint32) const
{
}
void ActiveState::Update(Map& map, NGridType& grid, GridInfo& info, uint32 diff) const
{
// Only check grid activity every (grid_expiry/10) ms, because it's really useless to do it every cycle
info.UpdateTimeTracker(diff);
if (info.getTimeTracker().Passed())
{
if (!grid.GetWorldObjectCountInNGrid<Player>() && !map.ActiveObjectsNearGrid(grid))
{
ObjectGridStoper worker;
TypeContainerVisitor<ObjectGridStoper, GridTypeMapContainer> visitor(worker);
grid.VisitAllGrids(visitor);
grid.SetGridState(GRID_STATE_IDLE);
LOG_DEBUG("maps", "Grid[{}, {}] on map {} moved to IDLE state", grid.getX(), grid.getY(), map.GetId());
}
else
map.ResetGridExpiry(grid, 0.1f);
}
}
void IdleState::Update(Map& map, NGridType& grid, GridInfo&, uint32) const
{
map.ResetGridExpiry(grid);
grid.SetGridState(GRID_STATE_REMOVAL);
LOG_DEBUG("maps", "Grid[{}, {}] on map {} moved to REMOVAL state", grid.getX(), grid.getY(), map.GetId());
}
void RemovalState::Update(Map& map, NGridType& grid, GridInfo& info, uint32 diff) const
{
if (!info.getUnloadLock())
{
info.UpdateTimeTracker(diff);
if (info.getTimeTracker().Passed() && !map.UnloadGrid(grid, false))
{
LOG_DEBUG("maps", "Grid[{}, {}] for map {} differed unloading due to players or active objects nearby", grid.getX(), grid.getY(), map.GetId());
map.ResetGridExpiry(grid);
}
}
}
-56
View File
@@ -1,56 +0,0 @@
/*
* This file is part of the AzerothCore Project. See AUTHORS file for Copyright information
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published by the
* Free Software Foundation; either version 3 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef ACORE_GRIDSTATES_H
#define ACORE_GRIDSTATES_H
#include "GridDefines.h"
#include "NGrid.h"
class Map;
class AC_GAME_API GridState
{
public:
virtual ~GridState() { };
virtual void Update(Map &, NGridType&, GridInfo &, uint32 t_diff) const = 0;
};
class AC_GAME_API InvalidState : public GridState
{
public:
void Update(Map &, NGridType &, GridInfo &, uint32 t_diff) const override;
};
class AC_GAME_API ActiveState : public GridState
{
public:
void Update(Map &, NGridType &, GridInfo &, uint32 t_diff) const override;
};
class AC_GAME_API IdleState : public GridState
{
public:
void Update(Map &, NGridType &, GridInfo &, uint32 t_diff) const override;
};
class AC_GAME_API RemovalState : public GridState
{
public:
void Update(Map &, NGridType &, GridInfo &, uint32 t_diff) const override;
};
#endif
+4 -65
View File
@@ -26,42 +26,6 @@
#include "Timer.h"
#include "Util.h"
#define DEFAULT_VISIBILITY_NOTIFY_PERIOD 1000
class AC_GAME_API GridInfo
{
public:
GridInfo();
GridInfo(time_t expiry, bool unload = true);
TimeTracker const& getTimeTracker() const { return i_timer; }
bool getUnloadLock() const { return i_unloadActiveLockCount || i_unloadExplicitLock || i_unloadReferenceLock; }
void setUnloadExplicitLock(bool on) { i_unloadExplicitLock = on; }
void setUnloadReferenceLock(bool on) { i_unloadReferenceLock = on; }
void incUnloadActiveLock() { ++i_unloadActiveLockCount; }
void decUnloadActiveLock() { if (i_unloadActiveLockCount) --i_unloadActiveLockCount; }
void setTimer(TimeTracker const& pTimer) { i_timer = pTimer; }
void ResetTimeTracker(time_t interval) { i_timer.Reset(interval); }
void UpdateTimeTracker(time_t diff) { i_timer.Update(diff); }
PeriodicTimer& getRelocationTimer() { return vis_Update; }
private:
TimeTracker i_timer;
PeriodicTimer vis_Update;
uint16 i_unloadActiveLockCount : 16; // lock from active object spawn points (prevent clone loading)
bool i_unloadExplicitLock : 1; // explicit manual lock or config setting
bool i_unloadReferenceLock : 1; // lock from instance map copy
};
typedef enum
{
GRID_STATE_INVALID = 0,
GRID_STATE_ACTIVE = 1,
GRID_STATE_IDLE = 2,
GRID_STATE_REMOVAL = 3,
MAX_GRID_STATE = 4
} grid_state_t;
template
<
uint32 N,
@@ -73,10 +37,10 @@ class NGrid
{
public:
typedef Grid<ACTIVE_OBJECT, WORLD_OBJECT_TYPES, GRID_OBJECT_TYPES> GridType;
NGrid(uint32 id, int32 x, int32 y, time_t expiry, bool unload = true) :
i_gridId(id), i_GridInfo(GridInfo(expiry, unload)), i_x(x), i_y(y),
i_cellstate(GRID_STATE_INVALID), i_GridObjectDataLoaded(false)
{ }
NGrid(uint32 id, int32 x, int32 y)
: i_gridId(id), i_x(x), i_y(y), i_GridObjectDataLoaded(false)
{
}
GridType& GetGridType(const uint32 x, const uint32 y)
{
@@ -91,9 +55,6 @@ public:
}
[[nodiscard]] uint32 GetGridId() const { return i_gridId; }
void SetGridId(uint32 id) { i_gridId = id; }
[[nodiscard]] grid_state_t GetGridState() const { return i_cellstate; }
void SetGridState(grid_state_t s) { i_cellstate = s; }
[[nodiscard]] int32 getX() const { return i_x; }
[[nodiscard]] int32 getY() const { return i_y; }
@@ -104,16 +65,6 @@ public:
[[nodiscard]] bool isGridObjectDataLoaded() const { return i_GridObjectDataLoaded; }
void setGridObjectDataLoaded(bool pLoaded) { i_GridObjectDataLoaded = pLoaded; }
GridInfo* getGridInfoRef() { return &i_GridInfo; }
TimeTracker const& getTimeTracker() const { return i_GridInfo.getTimeTracker(); }
bool getUnloadLock() const { return i_GridInfo.getUnloadLock(); }
void setUnloadExplicitLock(bool on) { i_GridInfo.setUnloadExplicitLock(on); }
void setUnloadReferenceLock(bool on) { i_GridInfo.setUnloadReferenceLock(on); }
void incUnloadActiveLock() { i_GridInfo.incUnloadActiveLock(); }
void decUnloadActiveLock() { i_GridInfo.decUnloadActiveLock(); }
void ResetTimeTracker(time_t interval) { i_GridInfo.ResetTimeTracker(interval); }
void UpdateTimeTracker(time_t diff) { i_GridInfo.UpdateTimeTracker(diff); }
/*
template<class SPECIFIC_OBJECT> void AddWorldObject(const uint32 x, const uint32 y, SPECIFIC_OBJECT *obj)
{
@@ -152,23 +103,11 @@ public:
GetGridType(x, y).Visit(visitor);
}
template<class T>
uint32 GetWorldObjectCountInNGrid() const
{
uint32 count = 0;
for (uint32 x = 0; x < N; ++x)
for (uint32 y = 0; y < N; ++y)
count += i_cells[x][y].template GetWorldObjectCountInGrid<T>();
return count;
}
private:
uint32 i_gridId;
GridInfo i_GridInfo;
GridReference<NGrid<N, ACTIVE_OBJECT, WORLD_OBJECT_TYPES, GRID_OBJECT_TYPES> > i_Reference;
int32 i_x;
int32 i_y;
grid_state_t i_cellstate;
GridType i_cells[N][N];
bool i_GridObjectDataLoaded;
};
@@ -16,7 +16,6 @@
*/
#include "GridNotifiers.h"
#include "GridNotifiersImpl.h"
#include "Map.h"
#include "ObjectAccessor.h"
#include "SpellInfo.h"
@@ -24,10 +23,22 @@
#include "Transport.h"
#include "UpdateData.h"
#include "WorldPacket.h"
#include "CellImpl.h"
using namespace Acore;
void VisibleNotifier::Visit(GameObjectMapType& m)
{
for (GameObjectMapType::iterator iter = m.begin(); iter != m.end(); ++iter)
{
GameObject* go = iter->GetSource();
if (i_largeOnly != go->IsVisibilityOverridden())
continue;
vis_guids.erase(go->GetGUID());
i_player.UpdateVisibilityOf(go, i_data, i_visibleNow);
}
}
void VisibleNotifier::SendToSelf()
{
// at this moment i_clientGUIDs have guids that not iterate at grid level checks
@@ -35,6 +46,9 @@ void VisibleNotifier::SendToSelf()
if (Transport* transport = i_player.GetTransport())
for (Transport::PassengerSet::const_iterator itr = transport->GetPassengers().begin(); itr != transport->GetPassengers().end(); ++itr)
{
if (i_largeOnly != (*itr)->IsVisibilityOverridden())
continue;
if (vis_guids.find((*itr)->GetGUID()) != vis_guids.end())
{
vis_guids.erase((*itr)->GetGUID());
@@ -51,9 +65,6 @@ void VisibleNotifier::SendToSelf()
case TYPEID_UNIT:
i_player.UpdateVisibilityOf((*itr)->ToCreature(), i_data, i_visibleNow);
break;
case TYPEID_DYNAMICOBJECT:
i_player.UpdateVisibilityOf((*itr)->ToDynObject(), i_data, i_visibleNow);
break;
default:
break;
}
@@ -62,6 +73,12 @@ void VisibleNotifier::SendToSelf()
for (GuidUnorderedSet::const_iterator it = vis_guids.begin(); it != vis_guids.end(); ++it)
{
if (WorldObject* obj = ObjectAccessor::GetWorldObject(i_player, *it))
{
if (i_largeOnly != obj->IsVisibilityOverridden())
continue;
}
// pussywizard: static transports are removed only in RemovePlayerFromMap and here if can no longer detect (eg. phase changed)
if ((*it).IsTransport())
if (GameObject* staticTrans = i_player.GetMap()->GetGameObject(*it))
@@ -86,8 +103,11 @@ void VisibleNotifier::SendToSelf()
i_data.BuildPacket(&packet);
i_player.GetSession()->SendPacket(&packet);
for (std::set<Unit*>::const_iterator it = i_visibleNow.begin(); it != i_visibleNow.end(); ++it)
for (std::vector<Unit*>::const_iterator it = i_visibleNow.begin(); it != i_visibleNow.end(); ++it)
{
if (i_largeOnly != (*it)->IsVisibilityOverridden())
continue;
i_player.GetInitialVisiblePackets(*it);
}
}
@@ -158,23 +178,6 @@ void PlayerRelocationNotifier::Visit(PlayerMapType& m)
}
}
void PlayerRelocationNotifier::Visit(CreatureMapType& m)
{
bool relocated_for_ai = (&i_player == i_player.m_seer);
for (CreatureMapType::iterator iter = m.begin(); iter != m.end(); ++iter)
{
Creature* c = iter->GetSource();
vis_guids.erase(c->GetGUID());
i_player.UpdateVisibilityOf(c, i_data, i_visibleNow);
if (relocated_for_ai && !c->isNeedNotify(NOTIFY_VISIBILITY_CHANGED))
CreatureUnitRelocationWorker(c, &i_player);
}
}
void CreatureRelocationNotifier::Visit(PlayerMapType& m)
{
for (PlayerMapType::iterator iter = m.begin(); iter != m.end(); ++iter)
@@ -191,58 +194,6 @@ void CreatureRelocationNotifier::Visit(PlayerMapType& m)
}
}
void CreatureRelocationNotifier::Visit(CreatureMapType& m)
{
if (!i_creature.IsAlive())
return;
for (CreatureMapType::iterator iter = m.begin(); iter != m.end(); ++iter)
{
Creature* c = iter->GetSource();
CreatureUnitRelocationWorker(&i_creature, c);
if (!c->isNeedNotify(NOTIFY_VISIBILITY_CHANGED))
CreatureUnitRelocationWorker(c, &i_creature);
}
}
void DelayedUnitRelocation::Visit(CreatureMapType& m)
{
for (CreatureMapType::iterator iter = m.begin(); iter != m.end(); ++iter)
{
Creature* unit = iter->GetSource();
if (!unit->isNeedNotify(NOTIFY_VISIBILITY_CHANGED))
continue;
CreatureRelocationNotifier relocate(*unit);
TypeContainerVisitor<CreatureRelocationNotifier, WorldTypeMapContainer > c2world_relocation(relocate);
TypeContainerVisitor<CreatureRelocationNotifier, GridTypeMapContainer > c2grid_relocation(relocate);
cell.Visit(p, c2world_relocation, i_map, *unit, i_radius);
cell.Visit(p, c2grid_relocation, i_map, *unit, i_radius);
}
}
void DelayedUnitRelocation::Visit(PlayerMapType& m)
{
for (PlayerMapType::iterator iter = m.begin(); iter != m.end(); ++iter)
{
Player* player = iter->GetSource();
WorldObject const* viewPoint = player->m_seer;
if (!viewPoint->isNeedNotify(NOTIFY_VISIBILITY_CHANGED))
continue;
if (player != viewPoint && !viewPoint->IsPositionValid())
continue;
PlayerRelocationNotifier relocate(*player);
Cell::VisitAllObjects(viewPoint, relocate, i_radius, false);
relocate.SendToSelf();
}
}
void AIRelocationNotifier::Visit(CreatureMapType& m)
{
bool self = isCreature && !((Creature*)(&i_unit))->IsMoveInLineOfSightStrictlyDisabled();
@@ -390,9 +341,14 @@ void MessageDistDelivererToHostile::Visit(DynamicObjectMapType& m)
template<class T>
void ObjectUpdater::Visit(GridRefMgr<T>& m)
{
for (typename GridRefMgr<T>::iterator iter = m.begin(); iter != m.end(); ++iter)
if (iter->GetSource()->IsInWorld())
iter->GetSource()->Update(i_timeDiff);
T* obj;
for (typename GridRefMgr<T>::iterator iter = m.begin(); iter != m.end(); )
{
obj = iter->GetSource();
++iter;
if (obj->IsInWorld() && (i_largeOnly == obj->IsVisibilityOverridden()))
obj->Update(i_timeDiff);
}
}
bool AnyDeadUnitObjectInRangeCheck::operator()(Player* u)
+13 -38
View File
@@ -42,10 +42,18 @@ namespace Acore
{
Player& i_player;
GuidUnorderedSet vis_guids;
std::set<Unit*> i_visibleNow;
std::vector<Unit*>& i_visibleNow;
bool i_gobjOnly;
bool i_largeOnly;
UpdateData i_data;
VisibleNotifier(Player& player) : i_player(player), vis_guids(player.m_clientGUIDs) {}
VisibleNotifier(Player& player, bool gobjOnly, bool largeOnly) :
i_player(player), vis_guids(player.m_clientGUIDs), i_visibleNow(player.m_newVisible), i_gobjOnly(gobjOnly), i_largeOnly(largeOnly)
{
i_visibleNow.clear();
}
void Visit(GameObjectMapType&);
template<class T> void Visit(GridRefMgr<T>& m);
void SendToSelf(void);
};
@@ -63,10 +71,9 @@ namespace Acore
struct PlayerRelocationNotifier : public VisibleNotifier
{
PlayerRelocationNotifier(Player& player) : VisibleNotifier(player) { }
PlayerRelocationNotifier(Player& player, bool largeOnly): VisibleNotifier(player, false, largeOnly) { }
template<class T> void Visit(GridRefMgr<T>& m) { VisibleNotifier::Visit(m); }
void Visit(CreatureMapType&);
void Visit(PlayerMapType&);
};
@@ -75,20 +82,6 @@ namespace Acore
Creature& i_creature;
CreatureRelocationNotifier(Creature& c) : i_creature(c) {}
template<class T> void Visit(GridRefMgr<T>&) {}
void Visit(CreatureMapType&);
void Visit(PlayerMapType&);
};
struct DelayedUnitRelocation
{
Map& i_map;
Cell& cell;
CellCoord& p;
const float i_radius;
DelayedUnitRelocation(Cell& c, CellCoord& pair, Map& map, float radius) :
i_map(map), cell(c), p(pair), i_radius(radius) { }
template<class T> void Visit(GridRefMgr<T>&) { }
void Visit(CreatureMapType&);
void Visit(PlayerMapType&);
};
@@ -101,25 +94,6 @@ namespace Acore
void Visit(CreatureMapType&);
};
struct GridUpdater
{
GridType& i_grid;
uint32 i_timeDiff;
GridUpdater(GridType& grid, uint32 diff) : i_grid(grid), i_timeDiff(diff) { }
template<class T> void updateObjects(GridRefMgr<T>& m)
{
for (typename GridRefMgr<T>::iterator iter = m.begin(); iter != m.end(); ++iter)
iter->GetSource()->Update(i_timeDiff);
}
void Visit(PlayerMapType& m) { updateObjects<Player>(m); }
void Visit(CreatureMapType& m) { updateObjects<Creature>(m); }
void Visit(GameObjectMapType& m) { updateObjects<GameObject>(m); }
void Visit(DynamicObjectMapType& m) { updateObjects<DynamicObject>(m); }
void Visit(CorpseMapType& m) { updateObjects<Corpse>(m); }
};
struct MessageDistDeliverer
{
WorldObject const* i_source;
@@ -180,7 +154,8 @@ namespace Acore
struct ObjectUpdater
{
uint32 i_timeDiff;
explicit ObjectUpdater(const uint32 diff) : i_timeDiff(diff) {}
bool i_largeOnly;
explicit ObjectUpdater(const uint32 diff, bool largeOnly) : i_timeDiff(diff), i_largeOnly(largeOnly) {}
template<class T> void Visit(GridRefMgr<T>& m);
void Visit(PlayerMapType&) {}
void Visit(CorpseMapType&) {}
@@ -32,8 +32,15 @@
template<class T>
inline void Acore::VisibleNotifier::Visit(GridRefMgr<T>& m)
{
// Xinef: Update gameobjects only
if (i_gobjOnly)
return;
for (typename GridRefMgr<T>::iterator iter = m.begin(); iter != m.end(); ++iter)
{
if (i_largeOnly != iter->GetSource()->IsVisibilityOverridden())
continue;
vis_guids.erase(iter->GetSource()->GetGUID());
i_player.UpdateVisibilityOf(iter->GetSource(), i_data, i_visibleNow);
}
+14 -53
View File
@@ -18,43 +18,13 @@
#include "ObjectGridLoader.h"
#include "CellImpl.h"
#include "Corpse.h"
#include "GridNotifiers.h"
#include "Creature.h"
#include "DynamicObject.h"
#include "GameObject.h"
#include "GridNotifiers.h"
#include "ObjectMgr.h"
#include "Transport.h"
#include "Vehicle.h"
#include "GameTime.h"
void ObjectGridEvacuator::Visit(CreatureMapType& m)
{
// creature in unloading grid can have respawn point in another grid
// if it will be unloaded then it will not respawn in original grid until unload/load original grid
// move to respawn point to prevent this case. For player view in respawn grid this will be normal respawn.
for (CreatureMapType::iterator iter = m.begin(); iter != m.end();)
{
Creature* c = iter->GetSource();
++iter;
ASSERT(!c->IsPet() && "ObjectGridRespawnMover must not be called for pets");
c->GetMap()->CreatureRespawnRelocation(c, true);
}
}
void ObjectGridEvacuator::Visit(GameObjectMapType& m)
{
// gameobject in unloading grid can have respawn point in another grid
// if it will be unloaded then it will not respawn in original grid until unload/load original grid
// move to respawn point to prevent this case. For player view in respawn grid this will be normal respawn.
for (GameObjectMapType::iterator iter = m.begin(); iter != m.end();)
{
GameObject* go = iter->GetSource();
++iter;
go->GetMap()->GameObjectRespawnRelocation(go, true);
}
}
// for loading world object at grid loading (Corpses)
//TODO: to implement npc on transport, also need to load npcs at grid loading
@@ -114,6 +84,18 @@ void AddObjectHelper(CellCoord& cell, CreatureMapType& m, uint32& count, Map* ma
++count;
}
template <>
void AddObjectHelper(CellCoord& cell, GameObjectMapType& m, uint32& count, Map* map, GameObject* obj)
{
obj->AddToGrid(m);
ObjectGridLoader::SetObjectCell(obj, cell);
obj->AddToWorld();
if (obj->isActiveObject())
map->AddToActive(obj);
++count;
}
template <class T>
void LoadHelper(CellGuidSet const& /*guid_set*/, CellCoord& /*cell*/, GridRefMgr<T>& /*m*/, uint32& /*count*/, Map* /*map*/)
{
@@ -124,13 +106,8 @@ void LoadHelper(CellGuidSet const& guid_set, CellCoord& cell, GridRefMgr<Creatur
{
for (CellGuidSet::const_iterator i_guid = guid_set.begin(); i_guid != guid_set.end(); ++i_guid)
{
// Don't spawn at all if there's a respawn timer
ObjectGuid::LowType guid = *i_guid;
time_t now = GameTime::GetGameTime().count();
if (map->GetCreatureRespawnTime(guid) > now)
continue;
Creature* obj = new Creature();
ObjectGuid::LowType guid = *i_guid;
if (!obj->LoadFromDB(guid, map))
{
delete obj;
@@ -156,12 +133,7 @@ void LoadHelper(CellGuidSet const& guid_set, CellCoord& cell, GridRefMgr<GameObj
{
for (CellGuidSet::const_iterator i_guid = guid_set.begin(); i_guid != guid_set.end(); ++i_guid)
{
// Don't spawn at all if there's a respawn timer
ObjectGuid::LowType guid = *i_guid;
time_t now = GameTime::GetGameTime().count();
if (map->GetGORespawnTime(guid) > now)
continue;
GameObjectData const* data = sObjectMgr->GetGameObjectData(guid);
GameObject* obj = data && sObjectMgr->IsGameObjectStaticTransport(data->id) ? new StaticTransport() : new GameObject();
@@ -257,17 +229,6 @@ void ObjectGridUnloader::Visit(GridRefMgr<T>& m)
}
}
void ObjectGridStoper::Visit(CreatureMapType& m)
{
// stop any fights at grid de-activation and remove dynobjects created at cast by creatures
for (CreatureMapType::iterator iter = m.begin(); iter != m.end(); ++iter)
{
iter->GetSource()->RemoveAllDynObjects();
if (iter->GetSource()->IsInCombat())
iter->GetSource()->CombatStop();
}
}
template<class T>
void ObjectGridCleaner::Visit(GridRefMgr<T>& m)
{
-17
View File
@@ -53,23 +53,6 @@ private:
uint32 i_corpses;
};
//Stop the creatures before unloading the NGrid
class AC_GAME_API ObjectGridStoper
{
public:
void Visit(CreatureMapType& m);
template<class T> void Visit(GridRefMgr<T>&) { }
};
//Move the foreign creatures back to respawn positions before unloading the NGrid
class AC_GAME_API ObjectGridEvacuator
{
public:
void Visit(CreatureMapType& m);
void Visit(GameObjectMapType& m);
template<class T> void Visit(GridRefMgr<T>&) { }
};
//Clean up and remove from world
class ObjectGridCleaner
{
+5 -1
View File
@@ -19,6 +19,7 @@
#define AZEROTHCORE_GROUP_H
#include "DBCEnums.h"
#include "DataMap.h"
#include "GroupRefMgr.h"
#include "LootMgr.h"
#include "QueryResult.h"
@@ -44,7 +45,7 @@ struct MapEntry;
#define MAX_RAID_SUBGROUPS MAXRAIDSIZE/MAXGROUPSIZE
#define TARGETICONCOUNT 8
enum RollVote : uint32
enum RollVote : uint8
{
PASS = 0,
NEED = 1,
@@ -242,6 +243,7 @@ public:
GroupReference* GetFirstMember() { return m_memberMgr.getFirst(); }
GroupReference const* GetFirstMember() const { return m_memberMgr.getFirst(); }
uint32 GetMembersCount() const { return m_memberSlots.size(); }
uint32 GetInviteeCount() const { return m_invitees.size(); }
uint8 GetMemberGroup(ObjectGuid guid) const;
@@ -322,6 +324,8 @@ public:
void SetDifficultyChangePrevention(DifficultyPreventionChangeType type);
void DoForAllMembers(std::function<void(Player*)> const& worker);
DataMap CustomData;
protected:
void _homebindIfInstance(Player* player);
void _cancelHomebindIfInstance(Player* player);
+8
View File
@@ -1469,6 +1469,14 @@ void Guild::HandleInviteMember(WorldSession* session, std::string const& name)
if (pInvitee->GetSocial()->HasIgnore(player->GetGUID()))
return;
uint32 memberLimit = sConfigMgr->GetOption<uint32>("Guild.MemberLimit", 0);
if (memberLimit > 0 && player->GetGuild()->GetMemberCount() >= memberLimit)
{
ChatHandler(player->GetSession()).PSendSysMessage("Your guild has reached the maximum amount of members (%u). You cannot send another invite until the guild member count is lower.", memberLimit);
SendCommandResult(session, GUILD_COMMAND_INVITE, ERR_GUILD_INTERNAL, name);
return;
}
if (!sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_GUILD) && pInvitee->GetTeamId(true) != player->GetTeamId(true))
{
SendCommandResult(session, GUILD_COMMAND_INVITE, ERR_GUILD_NOT_ALLIED, name);
@@ -62,8 +62,6 @@ void WorldSession::HandleInspectArenaTeamsOpcode(WorldPacket& recvData)
void WorldSession::HandleArenaTeamQueryOpcode(WorldPacket& recvData)
{
LOG_DEBUG("network", "WORLD: Received CMSG_ARENA_TEAM_QUERY");
uint32 arenaTeamId;
recvData >> arenaTeamId;
@@ -76,8 +74,6 @@ void WorldSession::HandleArenaTeamQueryOpcode(WorldPacket& recvData)
void WorldSession::HandleArenaTeamRosterOpcode(WorldPacket& recvData)
{
LOG_DEBUG("network", "WORLD: Received CMSG_ARENA_TEAM_ROSTER");
uint32 arenaTeamId; // arena team id
recvData >> arenaTeamId;
@@ -395,8 +395,6 @@ void WorldSession::HandleAuctionSellItem(WorldPacket& recvData)
//this function is called when client bids or buys out auction
void WorldSession::HandleAuctionPlaceBid(WorldPacket& recvData)
{
LOG_DEBUG("network", "WORLD: Received CMSG_AUCTION_PLACE_BID");
ObjectGuid auctioneer;
uint32 auctionId;
uint32 price;
@@ -528,8 +526,6 @@ void WorldSession::HandleAuctionPlaceBid(WorldPacket& recvData)
//this void is called when auction_owner cancels his auction
void WorldSession::HandleAuctionRemoveItem(WorldPacket& recvData)
{
LOG_DEBUG("network", "WORLD: Received CMSG_AUCTION_REMOVE_ITEM");
ObjectGuid auctioneer;
uint32 auctionId;
recvData >> auctioneer;
@@ -603,8 +599,6 @@ void WorldSession::HandleAuctionRemoveItem(WorldPacket& recvData)
//called when player lists his bids
void WorldSession::HandleAuctionListBidderItems(WorldPacket& recvData)
{
LOG_DEBUG("network", "WORLD: Received CMSG_AUCTION_LIST_BIDDER_ITEMS");
ObjectGuid guid; //NPC guid
uint32 listfrom; //page of auctions
uint32 outbiddedCount; //count of outbidded auctions
@@ -683,8 +677,6 @@ void WorldSession::HandleAuctionListOwnerItems(WorldPacket& recvData)
void WorldSession::HandleAuctionListOwnerItemsEvent(ObjectGuid creatureGuid)
{
LOG_DEBUG("network", "WORLD: Received CMSG_AUCTION_LIST_OWNER_ITEMS");
_lastAuctionListOwnerItemsMSTime = GameTime::GetGameTimeMS(); // pussywizard
Creature* creature = GetPlayer()->GetNPCIfCanInteractWith(creatureGuid, UNIT_NPC_FLAG_AUCTIONEER);
@@ -716,8 +708,6 @@ void WorldSession::HandleAuctionListOwnerItemsEvent(ObjectGuid creatureGuid)
//this void is called when player clicks on search button
void WorldSession::HandleAuctionListItems(WorldPacket& recvData)
{
LOG_DEBUG("network", "WORLD: Received CMSG_AUCTION_LIST_ITEMS");
std::string searchedname;
uint8 levelmin, levelmax, usable;
uint32 listfrom, auctionSlotID, auctionMainCategory, auctionSubCategory, quality;
@@ -773,8 +763,6 @@ void WorldSession::HandleAuctionListItems(WorldPacket& recvData)
void WorldSession::HandleAuctionListPendingSales(WorldPacket& recvData)
{
LOG_DEBUG("network", "WORLD: Received CMSG_AUCTION_LIST_PENDING_SALES");
recvData.read_skip<uint64>();
uint32 count = 0;
-2
View File
@@ -46,8 +46,6 @@ void WorldSession::HandleBankerActivateOpcode(WorldPacket& recvData)
{
ObjectGuid guid;
LOG_DEBUG("network", "WORLD: Received CMSG_BANKER_ACTIVATE");
recvData >> guid;
Creature* unit = GetPlayer()->GetNPCIfCanInteractWith(guid, UNIT_NPC_FLAG_BANKER);
@@ -23,6 +23,7 @@
#include "DisableMgr.h"
#include "GameTime.h"
#include "Group.h"
#include "LFGMgr.h"
#include "Language.h"
#include "ObjectAccessor.h"
#include "Opcodes.h"
@@ -35,6 +35,7 @@
#include "Log.h"
#include "MapMgr.h"
#include "Metric.h"
#include "MotdMgr.h"
#include "ObjectAccessor.h"
#include "ObjectMgr.h"
#include "Opcodes.h"
@@ -45,7 +46,6 @@
#include "Realm.h"
#include "ReputationMgr.h"
#include "ScriptMgr.h"
#include "MotdMgr.h"
#include "SharedDefines.h"
#include "SocialMgr.h"
#include "SpellAuraEffects.h"
@@ -527,7 +527,11 @@ void WorldSession::HandleCharCreateOpcode(WorldPacket& recvData)
std::shared_ptr<Player> newChar(new Player(this), [](Player* ptr)
{
ptr->CleanupsBeforeDelete();
// Only when player is created correctly do clean
if (ptr->HasAtLoginFlag(AT_LOGIN_FIRST))
{
ptr->CleanupsBeforeDelete();
}
delete ptr;
});
@@ -932,7 +936,7 @@ void WorldSession::HandlePlayerLoginFromDB(LoginQueryHolder const& holder)
pCurrChar->LoadCorpse(holder.GetPreparedResult(PLAYER_LOGIN_QUERY_LOAD_CORPSE_LOCATION));
// setting Ghost+speed if dead
if (pCurrChar->m_deathState != ALIVE)
if (pCurrChar->m_deathState != DeathState::Alive)
{
// not blizz like, we must correctly save and load player instead...
if (pCurrChar->getRace() == RACE_NIGHTELF)
@@ -1239,8 +1243,6 @@ void WorldSession::HandlePlayerLoginToCharOutOfWorld(Player* /*pCurrChar*/)
void WorldSession::HandleSetFactionAtWar(WorldPacket& recvData)
{
LOG_DEBUG("network.opcode", "WORLD: Received CMSG_SET_FACTION_ATWAR");
uint32 repListID;
uint8 flag;
@@ -1287,7 +1289,6 @@ void WorldSession::HandleTutorialReset(WorldPacket& /*recvData*/)
void WorldSession::HandleSetWatchedFactionOpcode(WorldPacket& recvData)
{
LOG_DEBUG("network.opcode", "WORLD: Received CMSG_SET_WATCHED_FACTION");
uint32 fact;
recvData >> fact;
GetPlayer()->SetUInt32Value(PLAYER_FIELD_WATCHED_FACTION_INDEX, fact);
@@ -1295,7 +1296,6 @@ void WorldSession::HandleSetWatchedFactionOpcode(WorldPacket& recvData)
void WorldSession::HandleSetFactionInactiveOpcode(WorldPacket& recvData)
{
LOG_DEBUG("network.opcode", "WORLD: Received CMSG_SET_FACTION_INACTIVE");
uint32 replistid;
uint8 inactive;
recvData >> replistid >> inactive;
+1 -1
View File
@@ -15,8 +15,8 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "CreatureAI.h"
#include "CombatPackets.h"
#include "CreatureAI.h"
#include "Log.h"
#include "ObjectAccessor.h"
#include "ObjectDefines.h"
-1
View File
@@ -52,7 +52,6 @@ void WorldSession::HandleDuelAcceptedOpcode(WorldPacket& recvPacket)
void WorldSession::HandleDuelCancelledOpcode(WorldPacket& recvPacket)
{
LOG_DEBUG("network", "WORLD: Received CMSG_DUEL_CANCELLED");
Player* player = GetPlayer();
ObjectGuid guid;
+46 -78
View File
@@ -18,11 +18,12 @@
#include "DatabaseEnv.h"
#include "Group.h"
#include "GroupMgr.h"
#include "LFGMgr.h"
#include "Language.h"
#include "Log.h"
#include "MiscPackets.h"
#include "ObjectMgr.h"
#include "Opcodes.h"
#include "MiscPackets.h"
#include "Pet.h"
#include "Player.h"
#include "ScriptMgr.h"
@@ -60,8 +61,6 @@ void WorldSession::SendPartyResult(PartyOperation operation, const std::string&
void WorldSession::HandleGroupInviteOpcode(WorldPacket& recvData)
{
LOG_DEBUG("network", "WORLD: Received CMSG_GROUP_INVITE");
std::string membername;
recvData >> membername;
recvData.read_skip<uint32>();
@@ -75,81 +74,73 @@ void WorldSession::HandleGroupInviteOpcode(WorldPacket& recvData)
return;
}
Player* player = ObjectAccessor::FindPlayerByName(membername, false);
Player* invitingPlayer = GetPlayer();
Player* invitedPlayer = ObjectAccessor::FindPlayerByName(membername, false);
// no player or cheat self-invite
if (!player || player == GetPlayer())
if (!invitedPlayer || invitedPlayer == invitingPlayer)
{
SendPartyResult(PARTY_OP_INVITE, membername, ERR_BAD_PLAYER_NAME_S);
return;
}
if (!sScriptMgr->CanGroupInvite(GetPlayer(), membername))
if (!sScriptMgr->CanGroupInvite(invitingPlayer, membername))
return;
if (GetPlayer()->IsSpectator() || player->IsSpectator())
if (invitingPlayer->IsSpectator() || invitedPlayer->IsSpectator())
{
SendPartyResult(PARTY_OP_INVITE, membername, ERR_INVITE_RESTRICTED);
return;
}
// restrict invite to GMs
if (!sWorld->getBoolConfig(CONFIG_ALLOW_GM_GROUP) && !GetPlayer()->IsGameMaster() && player->IsGameMaster())
if (!sWorld->getBoolConfig(CONFIG_ALLOW_GM_GROUP) && !invitingPlayer->IsGameMaster() && invitedPlayer->IsGameMaster())
{
SendPartyResult(PARTY_OP_INVITE, membername, ERR_BAD_PLAYER_NAME_S);
return;
}
// can't group with
if (!GetPlayer()->IsGameMaster() && !sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_GROUP) && GetPlayer()->GetTeamId() != player->GetTeamId())
if (!invitingPlayer->IsGameMaster() && !sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_GROUP) && invitingPlayer->GetTeamId() != invitedPlayer->GetTeamId())
{
SendPartyResult(PARTY_OP_INVITE, membername, ERR_PLAYER_WRONG_FACTION);
return;
}
if (GetPlayer()->GetInstanceId() != 0 && player->GetInstanceId() != 0 && GetPlayer()->GetInstanceId() != player->GetInstanceId() && GetPlayer()->GetMapId() == player->GetMapId())
if (invitingPlayer->GetInstanceId() != 0 && invitedPlayer->GetInstanceId() != 0 && invitingPlayer->GetInstanceId() != invitedPlayer->GetInstanceId() && invitingPlayer->GetMapId() == invitedPlayer->GetMapId())
{
SendPartyResult(PARTY_OP_INVITE, membername, ERR_TARGET_NOT_IN_INSTANCE_S);
return;
}
// just ignore us
if (player->GetInstanceId() != 0 && player->GetDungeonDifficulty() != GetPlayer()->GetDungeonDifficulty())
if (invitedPlayer->GetInstanceId() != 0 && invitedPlayer->GetDungeonDifficulty() != invitingPlayer->GetDungeonDifficulty())
{
SendPartyResult(PARTY_OP_INVITE, membername, ERR_IGNORING_YOU_S);
return;
}
if (player->GetSocial()->HasIgnore(GetPlayer()->GetGUID()))
if (invitedPlayer->GetSocial()->HasIgnore(invitingPlayer->GetGUID()))
{
SendPartyResult(PARTY_OP_INVITE, membername, ERR_IGNORING_YOU_S);
return;
}
if (!player->GetSocial()->HasFriend(GetPlayer()->GetGUID()) && GetPlayer()->GetLevel() < sWorld->getIntConfig(CONFIG_PARTY_LEVEL_REQ))
if (!invitedPlayer->GetSocial()->HasFriend(invitingPlayer->GetGUID()) && invitingPlayer->GetLevel() < sWorld->getIntConfig(CONFIG_PARTY_LEVEL_REQ))
{
SendPartyResult(PARTY_OP_INVITE, player->GetName(), ERR_INVITE_RESTRICTED);
SendPartyResult(PARTY_OP_INVITE, invitedPlayer->GetName(), ERR_INVITE_RESTRICTED);
return;
}
Group* group = GetPlayer()->GetGroup();
if (group)
{
if (group->isLFGGroup() && group->IsLfgRandomInstance())
{
SendPartyResult(PARTY_OP_INVITE, membername, ERR_TARGET_NOT_IN_INSTANCE_S);
return;
}
Group* group = invitingPlayer->GetGroup();
if (group && group->isBGGroup())
group = invitingPlayer->GetOriginalGroup();
if (!group)
group = invitingPlayer->GetGroupInvite();
if (group->isBGGroup() || group->isBFGroup())
{
group = GetPlayer()->GetOriginalGroup();
}
}
Group* group2 = player->GetGroup();
if (group2 && (group2->isBGGroup() || group2->isBFGroup()))
group2 = player->GetOriginalGroup();
Group* group2 = invitedPlayer->GetGroup();
if (group2 && group2->isBGGroup())
group2 = invitedPlayer->GetOriginalGroup();
// player already in another group or invited
if (group2 || player->GetGroupInvite())
if (group2 || invitedPlayer->GetGroupInvite())
{
SendPartyResult(PARTY_OP_INVITE, membername, ERR_ALREADY_IN_GROUP_S);
@@ -158,11 +149,11 @@ void WorldSession::HandleGroupInviteOpcode(WorldPacket& recvData)
// tell the player that they were invited but it failed as they were already in a group
WorldPacket data(SMSG_GROUP_INVITE, 25); // guess size
data << uint8(0); // invited/already in group flag
data << GetPlayer()->GetName(); // max len 48
data << invitingPlayer->GetName(); // max len 48
data << uint32(0); // unk
data << uint8(0); // count
data << uint32(0); // unk
player->GetSession()->SendPacket(&data);
invitedPlayer->GetSession()->SendPacket(&data);
}
return;
@@ -171,7 +162,7 @@ void WorldSession::HandleGroupInviteOpcode(WorldPacket& recvData)
if (group)
{
// not have permissions for invite
if (!group->IsLeader(GetPlayer()->GetGUID()) && !group->IsAssistant(GetPlayer()->GetGUID()))
if (!group->IsLeader(invitingPlayer->GetGUID()) && !group->IsAssistant(invitingPlayer->GetGUID()))
{
SendPartyResult(PARTY_OP_INVITE, "", ERR_NOT_LEADER);
return;
@@ -185,22 +176,22 @@ void WorldSession::HandleGroupInviteOpcode(WorldPacket& recvData)
}
// xinef: if player has no group, check group invite
if (!group && GetPlayer()->GetGroupInvite() && GetPlayer()->GetGroupInvite()->GetLeaderGUID() == GetPlayer()->GetGUID())
group = GetPlayer()->GetGroupInvite();
if (!group && invitingPlayer->GetGroupInvite() && invitingPlayer->GetGroupInvite()->GetLeaderGUID() == invitingPlayer->GetGUID())
group = invitingPlayer->GetGroupInvite();
// ok, but group not exist, start a new group
// but don't create and save the group to the DB until
// at least one person joins
if (!group)
{
group = new Group;
group = new Group();
// new group: if can't add then delete
if (!group->AddLeaderInvite(GetPlayer()))
if (!group->AddLeaderInvite(invitingPlayer))
{
delete group;
return;
}
if (!group->AddInvite(player))
if (!group->AddInvite(invitedPlayer))
{
delete group;
return;
@@ -209,7 +200,7 @@ void WorldSession::HandleGroupInviteOpcode(WorldPacket& recvData)
else
{
// already existed group: if can't add then just leave
if (!group->AddInvite(player))
if (!group->AddInvite(invitedPlayer))
{
return;
}
@@ -218,19 +209,17 @@ void WorldSession::HandleGroupInviteOpcode(WorldPacket& recvData)
// ok, we do it
WorldPacket data(SMSG_GROUP_INVITE, 10); // guess size
data << uint8(1); // invited/already in group flag
data << GetPlayer()->GetName(); // max len 48
data << invitingPlayer->GetName(); // max len 48
data << uint32(0); // unk
data << uint8(0); // count
data << uint32(0); // unk
player->GetSession()->SendPacket(&data);
invitedPlayer->GetSession()->SendPacket(&data);
SendPartyResult(PARTY_OP_INVITE, membername, ERR_PARTY_RESULT_OK);
}
void WorldSession::HandleGroupAcceptOpcode(WorldPacket& recvData)
{
LOG_DEBUG("network", "WORLD: Received CMSG_GROUP_ACCEPT");
recvData.read_skip<uint32>();
Group* group = GetPlayer()->GetGroupInvite();
@@ -291,8 +280,6 @@ void WorldSession::HandleGroupAcceptOpcode(WorldPacket& recvData)
void WorldSession::HandleGroupDeclineOpcode(WorldPacket& /*recvData*/)
{
LOG_DEBUG("network", "WORLD: Received CMSG_GROUP_DECLINE");
Group* group = GetPlayer()->GetGroupInvite();
if (!group)
return;
@@ -314,8 +301,6 @@ void WorldSession::HandleGroupDeclineOpcode(WorldPacket& /*recvData*/)
void WorldSession::HandleGroupUninviteGuidOpcode(WorldPacket& recvData)
{
LOG_DEBUG("network", "WORLD: Received CMSG_GROUP_UNINVITE_GUID");
ObjectGuid guid;
std::string reason, name;
recvData >> guid;
@@ -389,8 +374,6 @@ void WorldSession::HandleGroupUninviteGuidOpcode(WorldPacket& recvData)
void WorldSession::HandleGroupUninviteOpcode(WorldPacket& recvData)
{
LOG_DEBUG("network", "WORLD: Received CMSG_GROUP_UNINVITE");
std::string membername;
recvData >> membername;
@@ -436,8 +419,6 @@ void WorldSession::HandleGroupUninviteOpcode(WorldPacket& recvData)
void WorldSession::HandleGroupSetLeaderOpcode(WorldPacket& recvData)
{
LOG_DEBUG("network", "WORLD: Received CMSG_GROUP_SET_LEADER");
ObjectGuid guid;
recvData >> guid;
@@ -457,10 +438,9 @@ void WorldSession::HandleGroupSetLeaderOpcode(WorldPacket& recvData)
void WorldSession::HandleGroupDisbandOpcode(WorldPacket& /*recvData*/)
{
LOG_DEBUG("network", "WORLD: Received CMSG_GROUP_DISBAND");
Group* grp = GetPlayer()->GetGroup();
if (!grp)
Group* grpInvite = GetPlayer()->GetGroupInvite();
if (!grp && !grpInvite)
return;
if (_player->InBattleground())
@@ -473,15 +453,20 @@ void WorldSession::HandleGroupDisbandOpcode(WorldPacket& /*recvData*/)
/********************/
// everything's fine, do it
SendPartyResult(PARTY_OP_LEAVE, GetPlayer()->GetName(), ERR_PARTY_RESULT_OK);
GetPlayer()->RemoveFromGroup(GROUP_REMOVEMETHOD_LEAVE);
if (grp)
{
SendPartyResult(PARTY_OP_LEAVE, GetPlayer()->GetName(), ERR_PARTY_RESULT_OK);
GetPlayer()->RemoveFromGroup(GROUP_REMOVEMETHOD_LEAVE);
}
else if (grpInvite && grpInvite->GetLeaderGUID() == GetPlayer()->GetGUID())
{ // pending group creation being cancelled
SendPartyResult(PARTY_OP_LEAVE, GetPlayer()->GetName(), ERR_PARTY_RESULT_OK);
grpInvite->Disband();
}
}
void WorldSession::HandleLootMethodOpcode(WorldPacket& recvData)
{
LOG_DEBUG("network", "WORLD: Received CMSG_LOOT_METHOD");
uint32 lootMethod;
ObjectGuid lootMaster;
uint32 lootThreshold;
@@ -544,8 +529,6 @@ void WorldSession::HandleLootRoll(WorldPacket& recvData)
void WorldSession::HandleMinimapPingOpcode(WorldPacket& recvData)
{
LOG_DEBUG("network", "WORLD: Received MSG_MINIMAP_PING");
if (!GetPlayer()->GetGroup())
return;
@@ -581,8 +564,6 @@ void WorldSession::HandleRandomRollOpcode(WorldPackets::Misc::RandomRollClient&
void WorldSession::HandleRaidTargetUpdateOpcode(WorldPacket& recvData)
{
LOG_DEBUG("network", "WORLD: Received MSG_RAID_TARGET_UPDATE");
Group* group = GetPlayer()->GetGroup();
if (!group)
return;
@@ -620,8 +601,6 @@ void WorldSession::HandleRaidTargetUpdateOpcode(WorldPacket& recvData)
void WorldSession::HandleGroupRaidConvertOpcode(WorldPacket& /*recvData*/)
{
LOG_DEBUG("network", "WORLD: Received CMSG_GROUP_RAID_CONVERT");
Group* group = GetPlayer()->GetGroup();
if (!group)
return;
@@ -647,8 +626,6 @@ void WorldSession::HandleGroupRaidConvertOpcode(WorldPacket& /*recvData*/)
void WorldSession::HandleGroupChangeSubGroupOpcode(WorldPacket& recvData)
{
LOG_DEBUG("network", "WORLD: Received CMSG_GROUP_CHANGE_SUB_GROUP");
// we will get correct pointer for group here, so we don't have to check if group is BG raid
Group* group = GetPlayer()->GetGroup();
if (!group)
@@ -686,8 +663,6 @@ void WorldSession::HandleGroupChangeSubGroupOpcode(WorldPacket& recvData)
void WorldSession::HandleGroupAssistantLeaderOpcode(WorldPacket& recvData)
{
LOG_DEBUG("network", "WORLD: Received CMSG_GROUP_ASSISTANT_LEADER");
Group* group = GetPlayer()->GetGroup();
if (!group)
return;
@@ -707,8 +682,6 @@ void WorldSession::HandleGroupAssistantLeaderOpcode(WorldPacket& recvData)
void WorldSession::HandlePartyAssignmentOpcode(WorldPacket& recvData)
{
LOG_DEBUG("network", "WORLD: Received MSG_PARTY_ASSIGNMENT");
Group* group = GetPlayer()->GetGroup();
if (!group)
return;
@@ -741,8 +714,6 @@ void WorldSession::HandlePartyAssignmentOpcode(WorldPacket& recvData)
void WorldSession::HandleRaidReadyCheckOpcode(WorldPacket& recvData)
{
LOG_DEBUG("network", "WORLD: Received MSG_RAID_READY_CHECK");
Group* group = GetPlayer()->GetGroup();
if (!group)
return;
@@ -986,7 +957,6 @@ void WorldSession::BuildPartyMemberStatsChangedPacket(Player* player, WorldPacke
/*this procedure handles clients CMSG_REQUEST_PARTY_MEMBER_STATS request*/
void WorldSession::HandleRequestPartyMemberStatsOpcode(WorldPacket& recvData)
{
LOG_DEBUG("network", "WORLD: Received CMSG_REQUEST_PARTY_MEMBER_STATS");
ObjectGuid Guid;
recvData >> Guid;
@@ -1127,8 +1097,6 @@ void WorldSession::HandleRequestRaidInfoOpcode(WorldPacket& /*recvData*/)
void WorldSession::HandleOptOutOfLootOpcode(WorldPacket& recvData)
{
LOG_DEBUG("network", "WORLD: Received CMSG_OPT_OUT_OF_LOOT");
uint32 passOnLoot;
recvData >> passOnLoot; // 1 always pass, 0 do not pass

Some files were not shown because too many files have changed in this diff Show More