Merge branch 'master' into Playerbot-updated
This commit is contained in:
@@ -353,8 +353,8 @@ void CharacterDatabaseConnection::DoPrepareStatements()
|
||||
PrepareStatement(CHAR_UPD_REM_AT_LOGIN_FLAG, "UPDATE characters set at_login = at_login & ~ ? WHERE guid = ?", CONNECTION_ASYNC);
|
||||
PrepareStatement(CHAR_UPD_ALL_AT_LOGIN_FLAGS, "UPDATE characters SET at_login = at_login | ?", CONNECTION_ASYNC);
|
||||
PrepareStatement(CHAR_INS_BUG_REPORT, "INSERT INTO bugreport (type, content) VALUES(?, ?)", CONNECTION_ASYNC);
|
||||
PrepareStatement(CHAR_UPD_PETITION_NAME, "UPDATE petition SET name = ? WHERE petitionguid = ?", CONNECTION_ASYNC);
|
||||
PrepareStatement(CHAR_INS_PETITION_SIGNATURE, "INSERT INTO petition_sign (ownerguid, petitionguid, playerguid, player_account) VALUES (?, ?, ?, ?)", CONNECTION_ASYNC);
|
||||
PrepareStatement(CHAR_UPD_PETITION_NAME, "UPDATE petition SET name = ? WHERE petition_id = ?", CONNECTION_ASYNC);
|
||||
PrepareStatement(CHAR_INS_PETITION_SIGNATURE, "INSERT INTO petition_sign (ownerguid, petition_id, playerguid, player_account) VALUES (?, ?, ?, ?)", CONNECTION_ASYNC);
|
||||
PrepareStatement(CHAR_UPD_ACCOUNT_ONLINE, "UPDATE characters SET online = 0 WHERE account = ?", CONNECTION_ASYNC);
|
||||
PrepareStatement(CHAR_UPD_CHAR_OFFLINE, "UPDATE characters SET online = 0 WHERE guid = ?", CONNECTION_ASYNC);
|
||||
PrepareStatement(CHAR_INS_GROUP, "INSERT INTO `groups` (guid, leaderGuid, lootMethod, looterGuid, lootThreshold, icon1, icon2, icon3, icon4, icon5, icon6, icon7, icon8, groupType, difficulty, raidDifficulty, masterLooterGuid) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", CONNECTION_ASYNC);
|
||||
@@ -457,9 +457,9 @@ void CharacterDatabaseConnection::DoPrepareStatements()
|
||||
PrepareStatement(CHAR_INS_CHAR_GIFT, "INSERT INTO character_gifts (guid, item_guid, entry, flags) VALUES (?, ?, ?, ?)", CONNECTION_ASYNC);
|
||||
PrepareStatement(CHAR_DEL_INSTANCE_BY_INSTANCE, "DELETE FROM instance WHERE id = ?", CONNECTION_ASYNC);
|
||||
PrepareStatement(CHAR_DEL_MAIL_ITEM_BY_ID, "DELETE FROM mail_items WHERE mail_id = ?", CONNECTION_ASYNC);
|
||||
PrepareStatement(CHAR_INS_PETITION, "INSERT INTO petition (ownerguid, petitionguid, name, type) VALUES (?, ?, ?, ?)", CONNECTION_ASYNC);
|
||||
PrepareStatement(CHAR_DEL_PETITION_BY_GUID, "DELETE FROM petition WHERE petitionguid = ?", CONNECTION_ASYNC);
|
||||
PrepareStatement(CHAR_DEL_PETITION_SIGNATURE_BY_GUID, "DELETE FROM petition_sign WHERE petitionguid = ?", CONNECTION_ASYNC);
|
||||
PrepareStatement(CHAR_INS_PETITION, "INSERT INTO petition (petition_id, ownerguid, petitionguid, name, type) VALUES (?, ?, ?, ?, ?)", CONNECTION_ASYNC);
|
||||
PrepareStatement(CHAR_DEL_PETITION_BY_ID, "DELETE FROM petition WHERE petition_id = ?", CONNECTION_ASYNC);
|
||||
PrepareStatement(CHAR_DEL_PETITION_SIGNATURE_BY_ID, "DELETE FROM petition_sign WHERE petition_id = ?", CONNECTION_ASYNC);
|
||||
PrepareStatement(CHAR_DEL_CHAR_DECLINED_NAME, "DELETE FROM character_declinedname WHERE guid = ?", CONNECTION_ASYNC);
|
||||
PrepareStatement(CHAR_INS_CHAR_DECLINED_NAME, "INSERT INTO character_declinedname (guid, genitive, dative, accusative, instrumental, prepositional) VALUES (?, ?, ?, ?, ?, ?)", CONNECTION_ASYNC);
|
||||
PrepareStatement(CHAR_UPD_CHAR_RACE, "UPDATE characters SET race = ? WHERE guid = ?", CONNECTION_ASYNC);
|
||||
|
||||
@@ -382,8 +382,8 @@ enum CharacterDatabaseStatements : uint32
|
||||
CHAR_DEL_INSTANCE_BY_INSTANCE,
|
||||
CHAR_DEL_MAIL_ITEM_BY_ID,
|
||||
CHAR_INS_PETITION,
|
||||
CHAR_DEL_PETITION_BY_GUID,
|
||||
CHAR_DEL_PETITION_SIGNATURE_BY_GUID,
|
||||
CHAR_DEL_PETITION_BY_ID,
|
||||
CHAR_DEL_PETITION_SIGNATURE_BY_ID,
|
||||
CHAR_DEL_CHAR_DECLINED_NAME,
|
||||
CHAR_INS_CHAR_DECLINED_NAME,
|
||||
CHAR_UPD_CHAR_RACE,
|
||||
|
||||
@@ -660,6 +660,7 @@ void SmartAI::EnterEvadeMode(EvadeReason /*why*/)
|
||||
if (me->GetCharmerGUID().IsPlayer() || me->HasUnitFlag(UNIT_FLAG_POSSESSED))
|
||||
{
|
||||
me->AttackStop();
|
||||
me->RemoveUnitFlag(UNIT_FLAG_IN_COMBAT);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -3834,19 +3834,20 @@ void SmartScript::GetTargets(ObjectVector& targets, SmartScriptHolder const& e,
|
||||
{
|
||||
targets.clear();
|
||||
|
||||
if (owner->ToCreature())
|
||||
if (IsCreature(owner))
|
||||
{
|
||||
if (Unit* base = ObjectAccessor::GetUnit(*owner, owner->ToCreature()->GetCharmerOrOwnerGUID()))
|
||||
{
|
||||
targets.push_back(base);
|
||||
}
|
||||
}
|
||||
else
|
||||
else if (IsGameObject(owner))
|
||||
{
|
||||
if (Unit* base = ObjectAccessor::GetUnit(*owner, owner->ToGameObject()->GetOwnerGUID()))
|
||||
{
|
||||
targets.push_back(base);
|
||||
}
|
||||
}
|
||||
else if (IsPlayer(owner))
|
||||
{
|
||||
if (Unit* base = owner->ToPlayer()->GetCharmerOrOwner())
|
||||
targets.push_back(base);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -361,8 +361,9 @@ void CreatureGroup::LeaderMoveTo(float x, float y, float z, uint32 move_type)
|
||||
if (member == m_leader || !member->IsAlive() || member->GetVictim() || !pFormationInfo.HasGroupFlag(std::underlying_type_t<GroupAIFlags>(GroupAIFlags::GROUP_AI_FLAG_FOLLOW_LEADER)))
|
||||
continue;
|
||||
|
||||
// Xinef: If member is stunned / rooted etc don't allow to move him
|
||||
if (member->HasUnitState(UNIT_STATE_NOT_MOVE))
|
||||
// If member is stunned / rooted etc don't allow to move him
|
||||
// Or if charmed/controlled
|
||||
if (member->HasUnitState(UNIT_STATE_NOT_MOVE) || member->isPossessed() || member->HasUnitFlag(UNIT_FLAG_PLAYER_CONTROLLED))
|
||||
continue;
|
||||
|
||||
// Xinef: this should be automatized, if turn angle is greater than PI/2 (90�) we should swap formation angle
|
||||
|
||||
@@ -431,15 +431,11 @@ bool GameObject::Create(ObjectGuid::LowType guidlow, uint32 name_id, Map* map, u
|
||||
|
||||
// Check if GameObject is Large
|
||||
if (goinfo->IsLargeGameObject())
|
||||
{
|
||||
SetVisibilityDistanceOverride(VisibilityDistanceType::Large);
|
||||
}
|
||||
|
||||
// Check if GameObject is Infinite
|
||||
if (goinfo->IsInfiniteGameObject())
|
||||
{
|
||||
SetVisibilityDistanceOverride(VisibilityDistanceType::Infinite);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -629,6 +629,8 @@ struct GameObjectTemplate
|
||||
return true;
|
||||
case GAMEOBJECT_TYPE_TRAPDOOR:
|
||||
return true;
|
||||
case GAMEOBJECT_TYPE_DESTRUCTIBLE_BUILDING:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1037,7 +1037,7 @@ void MovementInfo::OutDebug()
|
||||
}
|
||||
|
||||
WorldObject::WorldObject() : WorldLocation(),
|
||||
LastUsedScriptID(0), m_name(""), m_isActive(false), m_visibilityDistanceOverride(), m_zoneScript(nullptr),
|
||||
LastUsedScriptID(0), m_name(""), m_isActive(false), _visibilityDistanceOverrideType(VisibilityDistanceType::Normal), m_zoneScript(nullptr),
|
||||
_zoneId(0), _areaId(0), _floorZ(INVALID_HEIGHT), _outdoors(false), _liquidData(), _updatePositionData(false), m_transport(nullptr),
|
||||
m_currMap(nullptr), _heartbeatTimer(HEARTBEAT_INTERVAL), m_InstanceId(0), m_phaseMask(PHASEMASK_NORMAL), m_useCombinedPhases(true),
|
||||
m_notifyflags(0), m_executed_notifies(0), _objectVisibilityContainer(this)
|
||||
@@ -1082,15 +1082,36 @@ void WorldObject::setActive(bool on)
|
||||
map->AddObjectToPendingUpdateList(this);
|
||||
}
|
||||
|
||||
float WorldObject::GetVisibilityOverrideDistance() const
|
||||
{
|
||||
ASSERT(_visibilityDistanceOverrideType < VisibilityDistanceType::Max);
|
||||
return VisibilityDistances[AsUnderlyingType(_visibilityDistanceOverrideType)];
|
||||
}
|
||||
|
||||
void WorldObject::SetVisibilityDistanceOverride(VisibilityDistanceType type)
|
||||
{
|
||||
ASSERT(type < VisibilityDistanceType::Max);
|
||||
if (IsPlayer())
|
||||
{
|
||||
|
||||
if (type == GetVisibilityOverrideType())
|
||||
return;
|
||||
|
||||
if (IsPlayer())
|
||||
return;
|
||||
|
||||
if (IsVisibilityOverridden())
|
||||
{
|
||||
if (IsFarVisible())
|
||||
GetMap()->RemoveWorldObjectFromFarVisibleMap(this);
|
||||
else if (IsZoneWideVisible())
|
||||
GetMap()->RemoveWorldObjectFromZoneWideVisibleMap(GetZoneId(), this);
|
||||
}
|
||||
|
||||
m_visibilityDistanceOverride = VisibilityDistances[AsUnderlyingType(type)];
|
||||
if (type == VisibilityDistanceType::Large || type == VisibilityDistanceType::Gigantic)
|
||||
GetMap()->AddWorldObjectToFarVisibleMap(this);
|
||||
else if (type == VisibilityDistanceType::Infinite)
|
||||
GetMap()->AddWorldObjectToZoneWideVisibleMap(GetZoneId(), this);
|
||||
|
||||
_visibilityDistanceOverrideType = type;
|
||||
}
|
||||
|
||||
void WorldObject::CleanupsBeforeDelete(bool /*finalCleanup*/)
|
||||
@@ -1127,6 +1148,8 @@ void WorldObject::UpdatePositionData()
|
||||
|
||||
void WorldObject::ProcessPositionDataChanged(PositionFullTerrainStatus const& data)
|
||||
{
|
||||
uint32 const oldZoneId = _zoneId;
|
||||
|
||||
_zoneId = _areaId = data.areaId;
|
||||
|
||||
if (AreaTableEntry const* area = sAreaTableStore.LookupEntry(_areaId))
|
||||
@@ -1136,6 +1159,17 @@ void WorldObject::ProcessPositionDataChanged(PositionFullTerrainStatus const& da
|
||||
_outdoors = data.outdoors;
|
||||
_floorZ = data.floorZ;
|
||||
_liquidData = data.liquidInfo;
|
||||
|
||||
// Has zone ID changed?
|
||||
if (oldZoneId != _zoneId)
|
||||
{
|
||||
// If so, check if we are far visibility overridden object and refresh maps if needed.
|
||||
if (IsZoneWideVisible())
|
||||
{
|
||||
GetMap()->RemoveWorldObjectFromZoneWideVisibleMap(oldZoneId, this);
|
||||
GetMap()->AddWorldObjectToZoneWideVisibleMap(_zoneId, this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void WorldObject::AddToWorld()
|
||||
@@ -1150,6 +1184,9 @@ void WorldObject::RemoveFromWorld()
|
||||
if (!IsInWorld())
|
||||
return;
|
||||
|
||||
if (IsZoneWideVisible())
|
||||
GetMap()->RemoveWorldObjectFromZoneWideVisibleMap(GetZoneId(), this);
|
||||
|
||||
DestroyForVisiblePlayers();
|
||||
|
||||
GetObjectVisibilityContainer().CleanVisibilityReferences();
|
||||
@@ -1612,26 +1649,16 @@ float WorldObject::GetGridActivationRange() const
|
||||
|
||||
float WorldObject::GetVisibilityRange() const
|
||||
{
|
||||
if (IsVisibilityOverridden() && IsCreature())
|
||||
{
|
||||
return *m_visibilityDistanceOverride;
|
||||
}
|
||||
if (IsCreature() && IsVisibilityOverridden())
|
||||
return GetVisibilityOverrideDistance();
|
||||
else if (IsGameObject())
|
||||
{
|
||||
{
|
||||
if (IsInWintergrasp())
|
||||
{
|
||||
return VISIBILITY_DIST_WINTERGRASP + VISIBILITY_INC_FOR_GOBJECTS;
|
||||
}
|
||||
else if (IsVisibilityOverridden())
|
||||
{
|
||||
return *m_visibilityDistanceOverride;
|
||||
}
|
||||
else
|
||||
{
|
||||
return GetMap()->GetVisibilityRange() + VISIBILITY_INC_FOR_GOBJECTS;
|
||||
}
|
||||
}
|
||||
if (IsInWintergrasp())
|
||||
return VISIBILITY_DIST_WINTERGRASP;
|
||||
else if (IsVisibilityOverridden())
|
||||
return GetVisibilityOverrideDistance();
|
||||
else
|
||||
return GetMap()->GetVisibilityRange();
|
||||
}
|
||||
else
|
||||
return IsInWintergrasp() ? VISIBILITY_DIST_WINTERGRASP : GetMap()->GetVisibilityRange();
|
||||
@@ -1645,28 +1672,18 @@ float WorldObject::GetSightRange(WorldObject const* target) const
|
||||
{
|
||||
if (target)
|
||||
{
|
||||
if (target->IsVisibilityOverridden() && target->IsCreature())
|
||||
{
|
||||
return *target->m_visibilityDistanceOverride;
|
||||
}
|
||||
if (target->IsCreature() && target->IsVisibilityOverridden())
|
||||
return target->GetVisibilityOverrideDistance();
|
||||
else if (target->IsGameObject())
|
||||
{
|
||||
if (IsInWintergrasp() && target->IsInWintergrasp())
|
||||
{
|
||||
return VISIBILITY_DIST_WINTERGRASP + VISIBILITY_INC_FOR_GOBJECTS;
|
||||
}
|
||||
return VISIBILITY_DIST_WINTERGRASP;
|
||||
else if (target->IsVisibilityOverridden())
|
||||
{
|
||||
return *target->m_visibilityDistanceOverride;
|
||||
}
|
||||
return target->GetVisibilityOverrideDistance();
|
||||
else if (ToPlayer()->GetCinematicMgr()->IsOnCinematic())
|
||||
{
|
||||
return DEFAULT_VISIBILITY_INSTANCE;
|
||||
}
|
||||
else
|
||||
{
|
||||
return GetMap()->GetVisibilityRange() + VISIBILITY_INC_FOR_GOBJECTS;
|
||||
}
|
||||
return GetMap()->GetVisibilityRange();
|
||||
}
|
||||
|
||||
return IsInWintergrasp() && target->IsInWintergrasp() ? VISIBILITY_DIST_WINTERGRASP : GetMap()->GetVisibilityRange();
|
||||
@@ -1674,19 +1691,13 @@ float WorldObject::GetSightRange(WorldObject const* target) const
|
||||
return IsInWintergrasp() ? VISIBILITY_DIST_WINTERGRASP : GetMap()->GetVisibilityRange();
|
||||
}
|
||||
else if (ToCreature())
|
||||
{
|
||||
return ToCreature()->m_SightDistance;
|
||||
}
|
||||
else
|
||||
{
|
||||
return SIGHT_RANGE_UNIT;
|
||||
}
|
||||
}
|
||||
|
||||
if (ToDynObject() && isActiveObject())
|
||||
{
|
||||
return GetMap()->GetVisibilityRange();
|
||||
}
|
||||
|
||||
return 0.0f;
|
||||
}
|
||||
@@ -1790,7 +1801,7 @@ bool WorldObject::CanSeeOrDetect(WorldObject const* obj, bool ignoreStealth, boo
|
||||
}
|
||||
|
||||
// Xinef: check reversely obj vs viewpoint, object could be a gameObject which overrides _IsWithinDist function to include gameobject size
|
||||
if (!corpseCheck && !viewpoint->IsWithinDist(obj, GetSightRange(obj), true))
|
||||
if (!corpseCheck && !viewpoint->IsWithinDist(obj, GetSightRange(obj), false))
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -358,9 +358,20 @@ template<class T>
|
||||
class GridObject
|
||||
{
|
||||
public:
|
||||
[[nodiscard]] bool IsInGrid() const { return _gridRef.isValid(); }
|
||||
void AddToGrid(GridRefMgr<T>& m) { ASSERT(!IsInGrid()); _gridRef.link(&m, (T*)this); }
|
||||
void RemoveFromGrid() { ASSERT(IsInGrid()); _gridRef.unlink(); }
|
||||
bool IsInGrid() const
|
||||
{
|
||||
return _gridRef.isValid();
|
||||
}
|
||||
void AddToGrid(GridRefMgr<T>& m)
|
||||
{
|
||||
ASSERT(!IsInGrid());
|
||||
_gridRef.link(&m, (T*)this);
|
||||
}
|
||||
void RemoveFromGrid()
|
||||
{
|
||||
ASSERT(IsInGrid());
|
||||
_gridRef.unlink();
|
||||
}
|
||||
private:
|
||||
GridReference<T> _gridRef;
|
||||
};
|
||||
@@ -654,8 +665,11 @@ public:
|
||||
|
||||
[[nodiscard]] bool isActiveObject() const { return m_isActive; }
|
||||
void setActive(bool isActiveObject);
|
||||
[[nodiscard]] bool IsFarVisible() const { return m_isFarVisible; }
|
||||
[[nodiscard]] bool IsVisibilityOverridden() const { return m_visibilityDistanceOverride.has_value(); }
|
||||
VisibilityDistanceType GetVisibilityOverrideType() const { return _visibilityDistanceOverrideType; }
|
||||
bool IsVisibilityOverridden() const { return _visibilityDistanceOverrideType > VisibilityDistanceType::Normal; }
|
||||
bool IsZoneWideVisible() const { return _visibilityDistanceOverrideType == VisibilityDistanceType::Infinite; }
|
||||
bool IsFarVisible() const { return _visibilityDistanceOverrideType == VisibilityDistanceType::Large || _visibilityDistanceOverrideType == VisibilityDistanceType::Gigantic; }
|
||||
float GetVisibilityOverrideDistance() const;
|
||||
void SetVisibilityDistanceOverride(VisibilityDistanceType type);
|
||||
|
||||
[[nodiscard]] bool IsInWintergrasp() const
|
||||
@@ -719,8 +733,7 @@ public:
|
||||
protected:
|
||||
std::string m_name;
|
||||
bool m_isActive;
|
||||
bool m_isFarVisible;
|
||||
Optional<float> m_visibilityDistanceOverride;
|
||||
VisibilityDistanceType _visibilityDistanceOverrideType;
|
||||
ZoneScript* m_zoneScript;
|
||||
|
||||
virtual void ProcessPositionDataChanged(PositionFullTerrainStatus const& data);
|
||||
|
||||
@@ -25,7 +25,6 @@
|
||||
#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 250.0f // max distance for visible objects, experimental
|
||||
|
||||
@@ -7078,6 +7078,14 @@ void Player::ApplyItemObtainSpells(Item* item, bool apply)
|
||||
}
|
||||
}
|
||||
|
||||
void Player::UpdateItemObtainSpells(Item* item, uint8 bag, uint8 slot)
|
||||
{
|
||||
if (IsBankPos(bag, slot))
|
||||
ApplyItemObtainSpells(item, false);
|
||||
else if (bag == INVENTORY_SLOT_BAG_0 || (bag >= INVENTORY_SLOT_BAG_START && bag < INVENTORY_SLOT_BAG_END))
|
||||
ApplyItemObtainSpells(item, true);
|
||||
}
|
||||
|
||||
SpellSchoolMask Player::GetMeleeDamageSchoolMask(WeaponAttackType attackType /*= BASE_ATTACK*/, uint8 damageIndex /*= 0*/) const
|
||||
{
|
||||
if (Item const* weapon = GetWeaponForAttack(attackType, true))
|
||||
@@ -16314,13 +16322,25 @@ float Player::GetSightRange(WorldObject const* target) const
|
||||
{
|
||||
float sightRange = WorldObject::GetSightRange(target);
|
||||
if (_farSightDistance)
|
||||
{
|
||||
sightRange += *_farSightDistance;
|
||||
}
|
||||
|
||||
return sightRange;
|
||||
}
|
||||
|
||||
bool Player::IsWorldObjectOutOfSightRange(WorldObject const* target) const
|
||||
{
|
||||
// Special handling for Infinite visibility override objects -> they are zone wide visible
|
||||
if (target->GetVisibilityOverrideType() == VisibilityDistanceType::Infinite)
|
||||
{
|
||||
// Same zone, always visible
|
||||
if (target->GetZoneId() == GetZoneId())
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check if out of range
|
||||
return !m_seer->IsWithinDist(target, GetSightRange(target), false);
|
||||
}
|
||||
|
||||
std::string Player::GetPlayerName()
|
||||
{
|
||||
std::string name = GetName();
|
||||
|
||||
@@ -2199,6 +2199,7 @@ public:
|
||||
|
||||
void CastAllObtainSpells();
|
||||
void ApplyItemObtainSpells(Item* item, bool apply);
|
||||
void UpdateItemObtainSpells(Item* item, uint8 bag, uint8 slot);
|
||||
|
||||
SpellSchoolMask GetMeleeDamageSchoolMask(WeaponAttackType attackType = BASE_ATTACK, uint8 damageIndex = 0) const override;
|
||||
|
||||
@@ -2620,6 +2621,7 @@ public:
|
||||
[[nodiscard]] Optional<float> GetFarSightDistance() const;
|
||||
|
||||
float GetSightRange(WorldObject const* target = nullptr) const override;
|
||||
bool IsWorldObjectOutOfSightRange(WorldObject const* target) const;
|
||||
|
||||
std::string GetPlayerName();
|
||||
|
||||
|
||||
@@ -2654,9 +2654,7 @@ Item* Player::_StoreItem(uint16 pos, Item* pItem, uint32 count, bool clone, bool
|
||||
|
||||
AddEnchantmentDurations(pItem);
|
||||
AddItemDurations(pItem);
|
||||
|
||||
if (bag == INVENTORY_SLOT_BAG_0 || (bag >= INVENTORY_SLOT_BAG_START && bag < INVENTORY_SLOT_BAG_END))
|
||||
ApplyItemObtainSpells(pItem, true);
|
||||
UpdateItemObtainSpells(pItem, bag, slot);
|
||||
|
||||
return pItem;
|
||||
}
|
||||
@@ -2694,8 +2692,7 @@ Item* Player::_StoreItem(uint16 pos, Item* pItem, uint32 count, bool clone, bool
|
||||
|
||||
pItem2->SetState(ITEM_CHANGED, this);
|
||||
|
||||
if (bag == INVENTORY_SLOT_BAG_0 || (bag >= INVENTORY_SLOT_BAG_START && bag < INVENTORY_SLOT_BAG_END))
|
||||
ApplyItemObtainSpells(pItem2, true);
|
||||
UpdateItemObtainSpells(pItem2, bag, slot);
|
||||
|
||||
return pItem2;
|
||||
}
|
||||
|
||||
@@ -1595,21 +1595,12 @@ void Player::UpdateVisibilityForPlayer(bool mapChange)
|
||||
// After added to map seer must be a player - there is no possibility to
|
||||
// still have different seer (all charm auras must be already removed)
|
||||
if (mapChange && m_seer != this)
|
||||
{
|
||||
m_seer = this;
|
||||
}
|
||||
|
||||
Acore::VisibleNotifier notifierNoLarge(
|
||||
*this, mapChange,
|
||||
false); // visit only objects which are not large; default distance
|
||||
Cell::VisitObjects(m_seer, notifierNoLarge,
|
||||
GetSightRange() + VISIBILITY_INC_FOR_GOBJECTS);
|
||||
notifierNoLarge.SendToSelf();
|
||||
|
||||
Acore::VisibleNotifier notifierLarge(
|
||||
*this, mapChange, true); // visit only large objects; maximum distance
|
||||
Cell::VisitObjects(m_seer, notifierLarge, GetSightRange());
|
||||
notifierLarge.SendToSelf();
|
||||
Acore::VisibleNotifier notifier(*this, mapChange);
|
||||
Cell::VisitObjects(m_seer, notifier, GetSightRange());
|
||||
Cell::VisitFarVisibleObjects(m_seer, notifier, VISIBILITY_DISTANCE_GIGANTIC);
|
||||
notifier.SendToSelf();
|
||||
|
||||
if (mapChange)
|
||||
m_last_notify_position.Relocate(-5000.0f, -5000.0f, -5000.0f, 0.0f);
|
||||
|
||||
@@ -20315,12 +20315,10 @@ void Unit::ExecuteDelayedUnitRelocationEvent()
|
||||
//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::VisitObjects(viewPoint, relocateNoLarge, player->GetSightRange() + VISIBILITY_INC_FOR_GOBJECTS);
|
||||
relocateNoLarge.SendToSelf();
|
||||
Acore::PlayerRelocationNotifier relocateLarge(*player, true); // visit only large objects; maximum distance
|
||||
Cell::VisitObjects(viewPoint, relocateLarge, MAX_VISIBILITY_DISTANCE);
|
||||
relocateLarge.SendToSelf();
|
||||
Acore::PlayerRelocationNotifier notifier(*player);
|
||||
Cell::VisitObjects(viewPoint, notifier, player->GetSightRange());
|
||||
Cell::VisitFarVisibleObjects(viewPoint, notifier, VISIBILITY_DISTANCE_GIGANTIC);
|
||||
notifier.SendToSelf();
|
||||
}
|
||||
|
||||
if (Player* player = this->ToPlayer())
|
||||
@@ -20354,16 +20352,10 @@ void Unit::ExecuteDelayedUnitRelocationEvent()
|
||||
|
||||
GetMap()->LoadGridsInRange(*player, MAX_VISIBILITY_DISTANCE);
|
||||
|
||||
Acore::PlayerRelocationNotifier relocateNoLarge(*player, false); // visit only objects which are not large; default distance
|
||||
Cell::VisitObjects(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::VisitObjects(viewPoint, relocateLarge, MAX_VISIBILITY_DISTANCE);
|
||||
relocateLarge.SendToSelf();
|
||||
}
|
||||
Acore::PlayerRelocationNotifier notifier(*player);
|
||||
Cell::VisitObjects(viewPoint, notifier, player->GetSightRange());
|
||||
Cell::VisitFarVisibleObjects(viewPoint, notifier, VISIBILITY_DISTANCE_GIGANTIC);
|
||||
notifier.SendToSelf();
|
||||
|
||||
this->AddToNotify(NOTIFY_AI_RELOCATION);
|
||||
}
|
||||
@@ -20383,7 +20375,7 @@ void Unit::ExecuteDelayedUnitRelocationEvent()
|
||||
unit->m_last_notify_position.Relocate(unit->GetPositionX(), unit->GetPositionY(), unit->GetPositionZ());
|
||||
|
||||
Acore::CreatureRelocationNotifier relocate(*unit);
|
||||
Cell::VisitObjects(unit, relocate, unit->GetVisibilityRange() + VISIBILITY_COMPENSATION);
|
||||
Cell::VisitObjects(unit, relocate, unit->GetVisibilityRange());
|
||||
|
||||
this->AddToNotify(NOTIFY_AI_RELOCATION);
|
||||
}
|
||||
|
||||
@@ -106,6 +106,8 @@ struct Cell
|
||||
template<class T> static void VisitObjects(WorldObject const* obj, T& visitor, float radius);
|
||||
template<class T> static void VisitObjects(float x, float y, Map* map, T& visitor, float radius);
|
||||
|
||||
template<class T> static void VisitFarVisibleObjects(WorldObject const* obj, T& visitor, float radius);
|
||||
|
||||
private:
|
||||
template<class T, class CONTAINER> void VisitCircle(TypeContainerVisitor<T, CONTAINER>&, Map&, CellCoord const&, CellCoord const&) const;
|
||||
};
|
||||
|
||||
@@ -181,4 +181,14 @@ inline void Cell::VisitObjects(float x, float y, Map* map, T& visitor, float rad
|
||||
cell.Visit(p, gnotifier, *map, x, y, radius);
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline void Cell::VisitFarVisibleObjects(WorldObject const* center_obj, T& visitor, float radius)
|
||||
{
|
||||
CellCoord p(Acore::ComputeCellCoord(center_obj->GetPositionX(), center_obj->GetPositionY()));
|
||||
Cell cell(p);
|
||||
|
||||
TypeContainerVisitor<T, FarVisibleGridContainer> gnotifier(visitor);
|
||||
cell.Visit(p, gnotifier, *center_obj->GetMap(), *center_obj, radius);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -33,16 +33,20 @@
|
||||
#include "TypeContainer.h"
|
||||
#include "TypeContainerVisitor.h"
|
||||
|
||||
class WorldObject;
|
||||
|
||||
template
|
||||
<
|
||||
class GRID_OBJECT_TYPES
|
||||
class GRID_OBJECT_TYPES,
|
||||
class FAR_VISIBLE_OBJECT_TYPES
|
||||
>
|
||||
class GridCell
|
||||
{
|
||||
public:
|
||||
~GridCell() = default;
|
||||
|
||||
template<class SPECIFIC_OBJECT> void AddGridObject(SPECIFIC_OBJECT* obj)
|
||||
template<class SPECIFIC_OBJECT>
|
||||
void AddGridObject(SPECIFIC_OBJECT* obj)
|
||||
{
|
||||
_gridObjects.template insert<SPECIFIC_OBJECT>(obj);
|
||||
ASSERT(obj->IsInGrid());
|
||||
@@ -50,12 +54,32 @@ public:
|
||||
|
||||
// Visit grid objects
|
||||
template<class T>
|
||||
void Visit(TypeContainerVisitor<T, TypeMapContainer<GRID_OBJECT_TYPES> >& visitor)
|
||||
void Visit(TypeContainerVisitor<T, TypeMapContainer<GRID_OBJECT_TYPES>>& visitor)
|
||||
{
|
||||
visitor.Visit(_gridObjects);
|
||||
}
|
||||
|
||||
template<class SPECIFIC_OBJECT>
|
||||
void AddFarVisibleObject(SPECIFIC_OBJECT* obj)
|
||||
{
|
||||
_farVisibleObjects.template Insert<SPECIFIC_OBJECT>(obj);
|
||||
}
|
||||
|
||||
template<class SPECIFIC_OBJECT>
|
||||
void RemoveFarVisibleObject(SPECIFIC_OBJECT* obj)
|
||||
{
|
||||
_farVisibleObjects.template Remove<SPECIFIC_OBJECT>(obj);
|
||||
}
|
||||
|
||||
// Visit far objects
|
||||
template<class T>
|
||||
void Visit(TypeContainerVisitor<T, TypeVectorContainer<FAR_VISIBLE_OBJECT_TYPES>>& visitor)
|
||||
{
|
||||
visitor.Visit(_farVisibleObjects);
|
||||
}
|
||||
|
||||
private:
|
||||
TypeMapContainer<GRID_OBJECT_TYPES> _gridObjects;
|
||||
TypeVectorContainer<FAR_VISIBLE_OBJECT_TYPES> _farVisibleObjects;
|
||||
};
|
||||
#endif
|
||||
|
||||
@@ -57,6 +57,9 @@ typedef TYPELIST_5(GameObject, Player, Creature, Corpse, DynamicObject) AllMapGr
|
||||
// List of object types stored on map level
|
||||
typedef TYPELIST_4(Creature, GameObject, DynamicObject, Corpse) AllMapStoredObjectTypes;
|
||||
|
||||
// List of object types that can have far visible range
|
||||
typedef TYPELIST_2(Creature, GameObject) AllFarVisibleObjectTypes;
|
||||
|
||||
typedef GridRefMgr<Corpse> CorpseMapType;
|
||||
typedef GridRefMgr<Creature> CreatureMapType;
|
||||
typedef GridRefMgr<DynamicObject> DynamicObjectMapType;
|
||||
@@ -73,10 +76,11 @@ enum GridMapTypeMask
|
||||
GRID_MAP_TYPE_MASK_ALL = 0x1F
|
||||
};
|
||||
|
||||
typedef GridCell<AllMapGridStoredObjectTypes> GridCellType;
|
||||
typedef MapGrid<AllMapGridStoredObjectTypes> MapGridType;
|
||||
typedef GridCell<AllMapGridStoredObjectTypes, AllFarVisibleObjectTypes> GridCellType;
|
||||
typedef MapGrid<AllMapGridStoredObjectTypes, AllFarVisibleObjectTypes> MapGridType;
|
||||
|
||||
typedef TypeMapContainer<AllMapGridStoredObjectTypes> GridTypeMapContainer;
|
||||
typedef TypeVectorContainer<AllFarVisibleObjectTypes> FarVisibleGridContainer;
|
||||
typedef TypeUnorderedMapContainer<AllMapStoredObjectTypes, ObjectGuid> MapStoredObjectTypesContainer;
|
||||
|
||||
template<uint32 LIMIT>
|
||||
|
||||
@@ -25,12 +25,13 @@ class GridTerrainData;
|
||||
|
||||
template
|
||||
<
|
||||
class GRID_OBJECT_TYPES
|
||||
class GRID_OBJECT_TYPES,
|
||||
class FAR_VISIBLE_OBJECT_TYPES
|
||||
>
|
||||
class MapGrid
|
||||
{
|
||||
public:
|
||||
typedef GridCell<GRID_OBJECT_TYPES> GridCellType;
|
||||
typedef GridCell<GRID_OBJECT_TYPES, FAR_VISIBLE_OBJECT_TYPES> GridCellType;
|
||||
|
||||
MapGrid(uint16 const x, uint16 const y)
|
||||
: _x(x), _y(y), _objectDataLoaded(false), _terrainData(nullptr) { }
|
||||
@@ -54,9 +55,19 @@ public:
|
||||
GetOrCreateCell(x, y).RemoveGridObject(obj);
|
||||
}
|
||||
|
||||
template<class SPECIFIC_OBJECT> void AddFarVisibleObject(uint16 const x, uint16 const y, SPECIFIC_OBJECT* obj)
|
||||
{
|
||||
GetOrCreateCell(x, y).AddFarVisibleObject(obj);
|
||||
}
|
||||
|
||||
template<class SPECIFIC_OBJECT> void RemoveFarVisibleObject(uint16 const x, uint16 const y, SPECIFIC_OBJECT* obj)
|
||||
{
|
||||
GetOrCreateCell(x, y).RemoveFarVisibleObject(obj);
|
||||
}
|
||||
|
||||
// Visit all cells
|
||||
template<class T, class TT>
|
||||
void VisitAllCells(TypeContainerVisitor<T, TypeMapContainer<TT> >& visitor)
|
||||
void VisitAllCells(TypeContainerVisitor<T, TT>& visitor)
|
||||
{
|
||||
for (auto& cellX : _cells)
|
||||
{
|
||||
@@ -72,7 +83,7 @@ public:
|
||||
|
||||
// Visit single cell
|
||||
template<class T, class TT>
|
||||
void VisitCell(uint16 const x, uint16 const y, TypeContainerVisitor<T, TypeMapContainer<TT> >& visitor)
|
||||
void VisitCell(uint16 const x, uint16 const y, TypeContainerVisitor<T, TT>& visitor)
|
||||
{
|
||||
GridCellType* gridCell = GetCell(x, y);
|
||||
if (!gridCell)
|
||||
@@ -81,7 +92,7 @@ public:
|
||||
gridCell->Visit(visitor);
|
||||
}
|
||||
|
||||
void link(GridRefMgr<MapGrid<GRID_OBJECT_TYPES>>* pTo)
|
||||
void link(GridRefMgr<MapGrid<GRID_OBJECT_TYPES, FAR_VISIBLE_OBJECT_TYPES>>* pTo)
|
||||
{
|
||||
_gridReference.link(pTo, this);
|
||||
}
|
||||
@@ -134,7 +145,7 @@ private:
|
||||
|
||||
bool _objectDataLoaded;
|
||||
std::array<std::array<std::unique_ptr<GridCellType>, MAX_NUMBER_OF_CELLS>, MAX_NUMBER_OF_CELLS> _cells; // N * N array
|
||||
GridReference<MapGrid<GRID_OBJECT_TYPES>> _gridReference;
|
||||
GridReference<MapGrid<GRID_OBJECT_TYPES, FAR_VISIBLE_OBJECT_TYPES>> _gridReference;
|
||||
|
||||
// Instances will share a copy of the parent maps terrainData
|
||||
std::shared_ptr<GridTerrainData> _terrainData;
|
||||
|
||||
@@ -29,38 +29,31 @@ 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;
|
||||
|
||||
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
|
||||
// but exist one case when this possible and object not out of range: transports
|
||||
if (Transport* transport = i_player.GetTransport())
|
||||
// Update far visible objects
|
||||
ZoneWideVisibleWorldObjectsSet const* zoneWideVisibleObjects = i_player.GetMap()->GetZoneWideVisibleWorldObjectsForZone(i_player.GetZoneId());
|
||||
if (zoneWideVisibleObjects)
|
||||
{
|
||||
for (Transport::PassengerSet::const_iterator itr = transport->GetPassengers().begin(); itr != transport->GetPassengers().end(); ++itr)
|
||||
for (WorldObject* obj : *zoneWideVisibleObjects)
|
||||
{
|
||||
if (i_largeOnly != (*itr)->IsVisibilityOverridden())
|
||||
continue;
|
||||
|
||||
switch ((*itr)->GetTypeId())
|
||||
switch (obj->GetTypeId())
|
||||
{
|
||||
case TYPEID_GAMEOBJECT:
|
||||
i_player.UpdateVisibilityOf((*itr)->ToGameObject(), i_data, i_visibleNow);
|
||||
break;
|
||||
case TYPEID_PLAYER:
|
||||
i_player.UpdateVisibilityOf((*itr)->ToPlayer(), i_data, i_visibleNow);
|
||||
(*itr)->ToPlayer()->UpdateVisibilityOf(&i_player);
|
||||
break;
|
||||
case TYPEID_UNIT:
|
||||
i_player.UpdateVisibilityOf((*itr)->ToCreature(), i_data, i_visibleNow);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
case TYPEID_GAMEOBJECT:
|
||||
i_player.UpdateVisibilityOf(obj->ToGameObject(), i_data, i_visibleNow);
|
||||
break;
|
||||
case TYPEID_UNIT:
|
||||
i_player.UpdateVisibilityOf(obj->ToCreature(), i_data, i_visibleNow);
|
||||
break;
|
||||
case TYPEID_DYNAMICOBJECT:
|
||||
i_player.UpdateVisibilityOf(obj->ToDynObject(), i_data, i_visibleNow);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -69,26 +62,8 @@ void VisibleNotifier::SendToSelf()
|
||||
for (VisibleWorldObjectsMap::iterator itr = visibleWorldObjects->begin(); itr != visibleWorldObjects->end();)
|
||||
{
|
||||
WorldObject* obj = itr->second;
|
||||
if (i_largeOnly != obj->IsVisibilityOverridden())
|
||||
{
|
||||
++itr;
|
||||
continue;
|
||||
}
|
||||
|
||||
// pussywizard: static transports are removed only in RemovePlayerFromMap and here if can no longer detect (eg. phase changed)
|
||||
if (itr->first.IsTransport())
|
||||
{
|
||||
if (GameObject* staticTrans = obj->ToGameObject())
|
||||
{
|
||||
if (i_player.CanSeeOrDetect(staticTrans, false, true))
|
||||
{
|
||||
++itr;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (i_player.m_seer->IsWithinDist(obj, i_player.GetSightRange(obj), true))
|
||||
if (!i_player.IsWorldObjectOutOfSightRange(obj)
|
||||
|| i_player.CanSeeOrDetect(obj, false, true))
|
||||
{
|
||||
++itr;
|
||||
continue;
|
||||
@@ -111,12 +86,7 @@ void VisibleNotifier::SendToSelf()
|
||||
i_player.GetSession()->SendPacket(&packet);
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
void VisibleChangesNotifier::Visit(PlayerMapType& m)
|
||||
|
||||
@@ -45,16 +45,16 @@ namespace Acore
|
||||
Player& i_player;
|
||||
std::vector<Unit*>& i_visibleNow;
|
||||
bool i_gobjOnly;
|
||||
bool i_largeOnly;
|
||||
UpdateData i_data;
|
||||
|
||||
VisibleNotifier(Player& player, bool gobjOnly, bool largeOnly) :
|
||||
i_player(player), i_visibleNow(player.m_newVisible), i_gobjOnly(gobjOnly), i_largeOnly(largeOnly)
|
||||
VisibleNotifier(Player& player, bool gobjOnly) :
|
||||
i_player(player), i_visibleNow(player.m_newVisible), i_gobjOnly(gobjOnly)
|
||||
{
|
||||
i_visibleNow.clear();
|
||||
}
|
||||
|
||||
void Visit(GameObjectMapType&);
|
||||
template<class T> void Visit(std::vector<T>& m);
|
||||
template<class T> void Visit(GridRefMgr<T>& m);
|
||||
void SendToSelf(void);
|
||||
};
|
||||
@@ -72,8 +72,9 @@ namespace Acore
|
||||
|
||||
struct PlayerRelocationNotifier : public VisibleNotifier
|
||||
{
|
||||
PlayerRelocationNotifier(Player& player, bool largeOnly): VisibleNotifier(player, false, largeOnly) { }
|
||||
PlayerRelocationNotifier(Player& player): VisibleNotifier(player, false) { }
|
||||
|
||||
template<class T> void Visit(std::vector<T>& m) { VisibleNotifier::Visit(m); }
|
||||
template<class T> void Visit(GridRefMgr<T>& m) { VisibleNotifier::Visit(m); }
|
||||
void Visit(PlayerMapType&);
|
||||
};
|
||||
|
||||
@@ -25,6 +25,13 @@
|
||||
#include "WorldPacket.h"
|
||||
#include "WorldSession.h"
|
||||
|
||||
template<class T>
|
||||
inline void Acore::VisibleNotifier::Visit(std::vector<T>& m)
|
||||
{
|
||||
for (typename std::vector<T>::iterator iter = m.begin(); iter != m.end(); ++iter)
|
||||
i_player.UpdateVisibilityOf((*iter), i_data, i_visibleNow);
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline void Acore::VisibleNotifier::Visit(GridRefMgr<T>& m)
|
||||
{
|
||||
@@ -33,12 +40,7 @@ inline void Acore::VisibleNotifier::Visit(GridRefMgr<T>& m)
|
||||
return;
|
||||
|
||||
for (typename GridRefMgr<T>::iterator iter = m.begin(); iter != m.end(); ++iter)
|
||||
{
|
||||
if (i_largeOnly != iter->GetSource()->IsVisibilityOverridden())
|
||||
continue;
|
||||
|
||||
i_player.UpdateVisibilityOf(iter->GetSource(), i_data, i_visibleNow);
|
||||
}
|
||||
}
|
||||
|
||||
// SEARCHERS & LIST SEARCHERS & WORKERS
|
||||
|
||||
@@ -29,91 +29,82 @@
|
||||
#include "WorldSession.h"
|
||||
#include <cmath>
|
||||
|
||||
void WorldSession::HandleSplitItemOpcode(WorldPacket& recvData)
|
||||
#include "ItemPackets.h"
|
||||
|
||||
void WorldSession::HandleSplitItemOpcode(WorldPackets::Item::SplitItem& packet)
|
||||
{
|
||||
//LOG_DEBUG("network.opcode", "WORLD: CMSG_SPLIT_ITEM");
|
||||
uint8 srcbag, srcslot, dstbag, dstslot;
|
||||
uint32 count;
|
||||
|
||||
recvData >> srcbag >> srcslot >> dstbag >> dstslot >> count;
|
||||
|
||||
uint16 src = ((srcbag << 8) | srcslot);
|
||||
uint16 dst = ((dstbag << 8) | dstslot);
|
||||
uint16 src = ((packet.SourceBag << 8) | packet.SourceSlot);
|
||||
uint16 dst = ((packet.DestinationBag << 8) | packet.DestinationSlot);
|
||||
|
||||
if (src == dst)
|
||||
return;
|
||||
|
||||
if (count == 0)
|
||||
return; //check count - if zero it's fake packet
|
||||
if (packet.Count == 0)
|
||||
return; //check count - if zero it's fake packet
|
||||
|
||||
if (!_player->IsValidPos(srcbag, srcslot, true))
|
||||
if (!_player->IsValidPos(packet.SourceBag, packet.SourceSlot, true))
|
||||
{
|
||||
_player->SendEquipError(EQUIP_ERR_ITEM_NOT_FOUND, nullptr, nullptr);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!_player->IsValidPos(dstbag, dstslot, false)) // can be autostore pos
|
||||
if (!_player->IsValidPos(packet.DestinationBag, packet.DestinationSlot, false)) // can be autostore pos
|
||||
{
|
||||
_player->SendEquipError(EQUIP_ERR_ITEM_DOESNT_GO_TO_SLOT, nullptr, nullptr);
|
||||
return;
|
||||
}
|
||||
|
||||
_player->SplitItem(src, dst, count);
|
||||
_player->SplitItem(src, dst, packet.Count);
|
||||
}
|
||||
|
||||
void WorldSession::HandleSwapInvItemOpcode(WorldPacket& recvData)
|
||||
void WorldSession::HandleSwapInvItemOpcode(WorldPackets::Item::SwapInventoryItem& packet)
|
||||
{
|
||||
//LOG_DEBUG("network.opcode", "WORLD: CMSG_SWAP_INV_ITEM");
|
||||
uint8 srcslot, dstslot;
|
||||
|
||||
recvData >> dstslot >> srcslot;
|
||||
|
||||
// prevent attempt swap same item to current position generated by client at special checting sequence
|
||||
if (srcslot == dstslot)
|
||||
// prevent attempt swap same item to current position generated by client at special cheating sequence
|
||||
if (packet.SourceSlot == packet.DestinationSlot)
|
||||
return;
|
||||
|
||||
if (!_player->IsValidPos(INVENTORY_SLOT_BAG_0, srcslot, true))
|
||||
if (!_player->IsValidPos(INVENTORY_SLOT_BAG_0, packet.SourceSlot, true))
|
||||
{
|
||||
_player->SendEquipError(EQUIP_ERR_ITEM_NOT_FOUND, nullptr, nullptr);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!_player->IsValidPos(INVENTORY_SLOT_BAG_0, dstslot, true))
|
||||
if (!_player->IsValidPos(INVENTORY_SLOT_BAG_0, packet.DestinationSlot, true))
|
||||
{
|
||||
_player->SendEquipError(EQUIP_ERR_ITEM_DOESNT_GO_TO_SLOT, nullptr, nullptr);
|
||||
return;
|
||||
}
|
||||
|
||||
if (_player->IsBankPos(INVENTORY_SLOT_BAG_0, srcslot) && !CanUseBank())
|
||||
if (_player->IsBankPos(INVENTORY_SLOT_BAG_0, packet.SourceSlot) && !CanUseBank())
|
||||
{
|
||||
//LOG_DEBUG("network", "WORLD: HandleSwapInvItemOpcode - Unit ({}) not found or you can't interact with him.", m_currentBankerGUID.ToString());
|
||||
return;
|
||||
}
|
||||
|
||||
if (_player->IsBankPos(INVENTORY_SLOT_BAG_0, dstslot) && !CanUseBank())
|
||||
if (_player->IsBankPos(INVENTORY_SLOT_BAG_0, packet.DestinationSlot) && !CanUseBank())
|
||||
{
|
||||
//LOG_DEBUG("network", "WORLD: HandleSwapInvItemOpcode - Unit ({}) not found or you can't interact with him.", m_currentBankerGUID.ToString());
|
||||
return;
|
||||
}
|
||||
|
||||
uint16 src = ((INVENTORY_SLOT_BAG_0 << 8) | srcslot);
|
||||
uint16 dst = ((INVENTORY_SLOT_BAG_0 << 8) | dstslot);
|
||||
uint16 src = ((INVENTORY_SLOT_BAG_0 << 8) | packet.SourceSlot);
|
||||
uint16 dst = ((INVENTORY_SLOT_BAG_0 << 8) | packet.DestinationSlot);
|
||||
|
||||
_player->SwapItem(src, dst);
|
||||
}
|
||||
|
||||
void WorldSession::HandleAutoEquipItemSlotOpcode(WorldPacket& recvData)
|
||||
void WorldSession::HandleAutoEquipItemSlotOpcode(WorldPackets::Item::AutoEquipItemSlot& packet)
|
||||
{
|
||||
ObjectGuid itemguid;
|
||||
uint8 dstslot;
|
||||
recvData >> itemguid >> dstslot;
|
||||
|
||||
// cheating attempt, client should never send opcode in that case
|
||||
if (!Player::IsEquipmentPos(INVENTORY_SLOT_BAG_0, dstslot))
|
||||
if (!Player::IsEquipmentPos(INVENTORY_SLOT_BAG_0, packet.DestinationSlot))
|
||||
return;
|
||||
|
||||
Item* item = _player->GetItemByGuid(itemguid);
|
||||
uint16 dstpos = dstslot | (INVENTORY_SLOT_BAG_0 << 8);
|
||||
Item* item = _player->GetItemByGuid(packet.ItemGuid);
|
||||
uint16 dstpos = packet.DestinationSlot | (INVENTORY_SLOT_BAG_0 << 8);
|
||||
|
||||
if (!item || item->GetPos() == dstpos)
|
||||
return;
|
||||
@@ -121,39 +112,36 @@ void WorldSession::HandleAutoEquipItemSlotOpcode(WorldPacket& recvData)
|
||||
_player->SwapItem(item->GetPos(), dstpos);
|
||||
}
|
||||
|
||||
void WorldSession::HandleSwapItem(WorldPacket& recvData)
|
||||
void WorldSession::HandleSwapItem(WorldPackets::Item::SwapItem& packet)
|
||||
{
|
||||
//LOG_DEBUG("network.opcode", "WORLD: CMSG_SWAP_ITEM");
|
||||
uint8 dstbag, dstslot, srcbag, srcslot;
|
||||
|
||||
recvData >> dstbag >> dstslot >> srcbag >> srcslot;
|
||||
uint16 src = ((packet.SourceBag << 8) | packet.SourceSlot);
|
||||
uint16 dst = ((packet.DestinationBag << 8) | packet.DestinationSlot);
|
||||
|
||||
uint16 src = ((srcbag << 8) | srcslot);
|
||||
uint16 dst = ((dstbag << 8) | dstslot);
|
||||
|
||||
// prevent attempt swap same item to current position generated by client at special checting sequence
|
||||
// prevent attempt swap same item to current position generated by client at special cheating sequence
|
||||
if (src == dst)
|
||||
return;
|
||||
|
||||
if (!_player->IsValidPos(srcbag, srcslot, true))
|
||||
if (!_player->IsValidPos(packet.SourceBag, packet.SourceSlot, true))
|
||||
{
|
||||
_player->SendEquipError(EQUIP_ERR_ITEM_NOT_FOUND, nullptr, nullptr);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!_player->IsValidPos(dstbag, dstslot, true))
|
||||
if (!_player->IsValidPos(packet.DestinationBag, packet.DestinationSlot, true))
|
||||
{
|
||||
_player->SendEquipError(EQUIP_ERR_ITEM_DOESNT_GO_TO_SLOT, nullptr, nullptr);
|
||||
return;
|
||||
}
|
||||
|
||||
if (_player->IsBankPos(srcbag, srcslot) && !CanUseBank())
|
||||
if (_player->IsBankPos(packet.SourceBag, packet.SourceSlot) && !CanUseBank())
|
||||
{
|
||||
//LOG_DEBUG("network", "WORLD: HandleSwapItem - Unit ({}) not found or you can't interact with him.", m_currentBankerGUID.ToString());
|
||||
return;
|
||||
}
|
||||
|
||||
if (_player->IsBankPos(dstbag, dstslot) && !CanUseBank())
|
||||
if (_player->IsBankPos(packet.DestinationBag, packet.DestinationSlot) && !CanUseBank())
|
||||
{
|
||||
//LOG_DEBUG("network", "WORLD: HandleSwapItem - Unit ({}) not found or you can't interact with him.", m_currentBankerGUID.ToString());
|
||||
return;
|
||||
@@ -162,14 +150,11 @@ void WorldSession::HandleSwapItem(WorldPacket& recvData)
|
||||
_player->SwapItem(src, dst);
|
||||
}
|
||||
|
||||
void WorldSession::HandleAutoEquipItemOpcode(WorldPacket& recvData)
|
||||
void WorldSession::HandleAutoEquipItemOpcode(WorldPackets::Item::AutoEquipItem& packet)
|
||||
{
|
||||
//LOG_DEBUG("network.opcode", "WORLD: CMSG_AUTOEQUIP_ITEM");
|
||||
uint8 srcbag, srcslot;
|
||||
|
||||
recvData >> srcbag >> srcslot;
|
||||
|
||||
Item* pSrcItem = _player->GetItemByPos(srcbag, srcslot);
|
||||
Item* pSrcItem = _player->GetItemByPos(packet.SourceBag, packet.SourceSlot);
|
||||
if (!pSrcItem)
|
||||
return; // only at cheat
|
||||
|
||||
@@ -219,7 +204,7 @@ void WorldSession::HandleAutoEquipItemOpcode(WorldPacket& recvData)
|
||||
|
||||
if (!pDstItem) // empty slot, simple case
|
||||
{
|
||||
_player->RemoveItem(srcbag, srcslot, true);
|
||||
_player->RemoveItem(packet.SourceBag, packet.SourceSlot, true);
|
||||
_player->EquipItem(dest, pSrcItem, true);
|
||||
_player->AutoUnequipOffhandIfNeed();
|
||||
}
|
||||
@@ -243,23 +228,23 @@ void WorldSession::HandleAutoEquipItemOpcode(WorldPacket& recvData)
|
||||
uint16 eSrc = 0;
|
||||
if (_player->IsInventoryPos(src))
|
||||
{
|
||||
msg = _player->CanStoreItem(srcbag, srcslot, sSrc, pDstItem, true);
|
||||
msg = _player->CanStoreItem(packet.SourceBag, packet.SourceSlot, sSrc, pDstItem, true);
|
||||
if (msg != EQUIP_ERR_OK)
|
||||
msg = _player->CanStoreItem(srcbag, NULL_SLOT, sSrc, pDstItem, true);
|
||||
msg = _player->CanStoreItem(packet.SourceBag, NULL_SLOT, sSrc, pDstItem, true);
|
||||
if (msg != EQUIP_ERR_OK)
|
||||
msg = _player->CanStoreItem(NULL_BAG, NULL_SLOT, sSrc, pDstItem, true);
|
||||
}
|
||||
else if (_player->IsBankPos(src))
|
||||
{
|
||||
msg = _player->CanBankItem(srcbag, srcslot, sSrc, pDstItem, true);
|
||||
msg = _player->CanBankItem(packet.SourceBag, packet.SourceSlot, sSrc, pDstItem, true);
|
||||
if (msg != EQUIP_ERR_OK)
|
||||
msg = _player->CanBankItem(srcbag, NULL_SLOT, sSrc, pDstItem, true);
|
||||
msg = _player->CanBankItem(packet.SourceBag, NULL_SLOT, sSrc, pDstItem, true);
|
||||
if (msg != EQUIP_ERR_OK)
|
||||
msg = _player->CanBankItem(NULL_BAG, NULL_SLOT, sSrc, pDstItem, true);
|
||||
}
|
||||
else if (_player->IsEquipmentPos(src))
|
||||
{
|
||||
msg = _player->CanEquipItem(srcslot, eSrc, pDstItem, true);
|
||||
msg = _player->CanEquipItem(packet.SourceSlot, eSrc, pDstItem, true);
|
||||
if (msg == EQUIP_ERR_OK)
|
||||
msg = _player->CanUnequipItem(eSrc, true);
|
||||
}
|
||||
@@ -272,7 +257,7 @@ void WorldSession::HandleAutoEquipItemOpcode(WorldPacket& recvData)
|
||||
|
||||
// now do moves, remove...
|
||||
_player->RemoveItem(dstbag, dstslot, true, true);
|
||||
_player->RemoveItem(srcbag, srcslot, true, true);
|
||||
_player->RemoveItem(packet.SourceBag, packet.SourceSlot, true, true);
|
||||
|
||||
// add to dest
|
||||
_player->EquipItem(dest, pSrcItem, true);
|
||||
@@ -292,14 +277,11 @@ void WorldSession::HandleAutoEquipItemOpcode(WorldPacket& recvData)
|
||||
}
|
||||
}
|
||||
|
||||
void WorldSession::HandleDestroyItemOpcode(WorldPacket& recvData)
|
||||
void WorldSession::HandleDestroyItemOpcode(WorldPackets::Item::DestroyItem& packet)
|
||||
{
|
||||
//LOG_DEBUG("network.opcode", "WORLD: CMSG_DESTROYITEM");
|
||||
uint8 bag, slot, count, data1, data2, data3;
|
||||
|
||||
recvData >> bag >> slot >> count >> data1 >> data2 >> data3;
|
||||
|
||||
uint16 pos = (bag << 8) | slot;
|
||||
uint16 pos = (packet.Bag << 8) | packet.Slot;
|
||||
|
||||
// prevent drop unequipable items (in combat, for example) and non-empty bags
|
||||
if (_player->IsEquipmentPos(pos) || _player->IsBagPos(pos))
|
||||
@@ -312,7 +294,7 @@ void WorldSession::HandleDestroyItemOpcode(WorldPacket& recvData)
|
||||
}
|
||||
}
|
||||
|
||||
Item* pItem = _player->GetItemByPos(bag, slot);
|
||||
Item* pItem = _player->GetItemByPos(packet.Bag, packet.Slot);
|
||||
if (!pItem)
|
||||
{
|
||||
_player->SendEquipError(EQUIP_ERR_ITEM_NOT_FOUND, nullptr, nullptr);
|
||||
@@ -327,14 +309,14 @@ void WorldSession::HandleDestroyItemOpcode(WorldPacket& recvData)
|
||||
|
||||
recoveryItem(pItem);
|
||||
|
||||
if (count)
|
||||
if (packet.Count)
|
||||
{
|
||||
uint32 i_count = count;
|
||||
uint32 i_count = packet.Count;
|
||||
_player->DestroyItemCount(pItem, i_count, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
_player->DestroyItem(bag, slot, true);
|
||||
_player->DestroyItem(packet.Bag, packet.Slot, true);
|
||||
}
|
||||
_player->SendQuestGiverStatusMultiple();
|
||||
}
|
||||
@@ -692,15 +674,12 @@ void WorldSession::HandleItemQuerySingleOpcode(WorldPacket& recvData)
|
||||
}
|
||||
}
|
||||
|
||||
void WorldSession::HandleReadItem(WorldPacket& recvData)
|
||||
void WorldSession::HandleReadItem(WorldPackets::Item::ReadItem& packet)
|
||||
{
|
||||
//LOG_DEBUG("network.opcode", "WORLD: CMSG_READ_ITEM");
|
||||
|
||||
uint8 bag, slot;
|
||||
recvData >> bag >> slot;
|
||||
|
||||
//LOG_DEBUG("network.opcode", "STORAGE: Read bag = {}, slot = {}", bag, slot);
|
||||
Item* pItem = _player->GetItemByPos(bag, slot);
|
||||
Item* pItem = _player->GetItemByPos(packet.Bag, packet.Slot);
|
||||
|
||||
if (pItem && pItem->GetTemplate()->PageText)
|
||||
{
|
||||
@@ -725,27 +704,22 @@ void WorldSession::HandleReadItem(WorldPacket& recvData)
|
||||
_player->SendEquipError(EQUIP_ERR_ITEM_NOT_FOUND, nullptr, nullptr);
|
||||
}
|
||||
|
||||
void WorldSession::HandleSellItemOpcode(WorldPacket& recvData)
|
||||
void WorldSession::HandleSellItemOpcode(WorldPackets::Item::SellItem& packet)
|
||||
{
|
||||
ObjectGuid vendorguid, itemguid;
|
||||
uint32 count;
|
||||
|
||||
recvData >> vendorguid >> itemguid >> count;
|
||||
|
||||
if (!itemguid)
|
||||
if (!packet.ItemGuid)
|
||||
return;
|
||||
|
||||
Creature* creature = GetPlayer()->GetNPCIfCanInteractWith(vendorguid, UNIT_NPC_FLAG_VENDOR);
|
||||
Creature* creature = GetPlayer()->GetNPCIfCanInteractWith(packet.VendorGuid, UNIT_NPC_FLAG_VENDOR);
|
||||
if (!creature)
|
||||
{
|
||||
LOG_DEBUG("network", "WORLD: HandleSellItemOpcode - Unit ({}) not found or you can not interact with him.", vendorguid.ToString());
|
||||
_player->SendSellError(SELL_ERR_CANT_FIND_VENDOR, nullptr, itemguid, 0);
|
||||
LOG_DEBUG("network", "WORLD: HandleSellItemOpcode - Unit ({}) not found or you can not interact with him.", packet.VendorGuid.ToString());
|
||||
_player->SendSellError(SELL_ERR_CANT_FIND_VENDOR, nullptr, packet.ItemGuid, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
if (creature->HasFlagsExtra(CREATURE_FLAG_EXTRA_NO_SELL_VENDOR))
|
||||
{
|
||||
_player->SendSellError(SELL_ERR_CANT_SELL_TO_THIS_MERCHANT, creature, itemguid, 0);
|
||||
_player->SendSellError(SELL_ERR_CANT_SELL_TO_THIS_MERCHANT, creature, packet.ItemGuid, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -753,7 +727,7 @@ void WorldSession::HandleSellItemOpcode(WorldPacket& recvData)
|
||||
if (GetPlayer()->HasUnitState(UNIT_STATE_DIED))
|
||||
GetPlayer()->RemoveAurasByType(SPELL_AURA_FEIGN_DEATH);
|
||||
|
||||
Item* pItem = _player->GetItemByGuid(itemguid);
|
||||
Item* pItem = _player->GetItemByGuid(packet.ItemGuid);
|
||||
if (pItem)
|
||||
{
|
||||
if (!sScriptMgr->OnPlayerCanSellItem(_player, pItem, creature))
|
||||
@@ -762,21 +736,21 @@ void WorldSession::HandleSellItemOpcode(WorldPacket& recvData)
|
||||
// prevent sell not owner item
|
||||
if (_player->GetGUID() != pItem->GetOwnerGUID())
|
||||
{
|
||||
_player->SendSellError(SELL_ERR_CANT_SELL_ITEM, creature, itemguid, 0);
|
||||
_player->SendSellError(SELL_ERR_CANT_SELL_ITEM, creature, packet.ItemGuid, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
// prevent sell non empty bag by drag-and-drop at vendor's item list
|
||||
if (pItem->IsNotEmptyBag())
|
||||
{
|
||||
_player->SendSellError(SELL_ERR_CANT_SELL_ITEM, creature, itemguid, 0);
|
||||
_player->SendSellError(SELL_ERR_CANT_SELL_ITEM, creature, packet.ItemGuid, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
// prevent sell currently looted item
|
||||
if (_player->GetLootGUID() == pItem->GetGUID())
|
||||
{
|
||||
_player->SendSellError(SELL_ERR_CANT_SELL_ITEM, creature, itemguid, 0);
|
||||
_player->SendSellError(SELL_ERR_CANT_SELL_ITEM, creature, packet.ItemGuid, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -787,16 +761,14 @@ void WorldSession::HandleSellItemOpcode(WorldPacket& recvData)
|
||||
return; // Therefore, no feedback to client
|
||||
|
||||
// special case at auto sell (sell all)
|
||||
if (count == 0)
|
||||
{
|
||||
count = pItem->GetCount();
|
||||
}
|
||||
if (packet.Count == 0)
|
||||
packet.Count = pItem->GetCount();
|
||||
else
|
||||
{
|
||||
// prevent sell more items that exist in stack (possible only not from client)
|
||||
if (count > pItem->GetCount())
|
||||
if (packet.Count > pItem->GetCount())
|
||||
{
|
||||
_player->SendSellError(SELL_ERR_CANT_SELL_ITEM, creature, itemguid, 0);
|
||||
_player->SendSellError(SELL_ERR_CANT_SELL_ITEM, creature, packet.ItemGuid, 0);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -806,11 +778,11 @@ void WorldSession::HandleSellItemOpcode(WorldPacket& recvData)
|
||||
{
|
||||
if (pProto->SellPrice > 0)
|
||||
{
|
||||
uint32 money = pProto->SellPrice * count;
|
||||
uint32 money = pProto->SellPrice * packet.Count;
|
||||
if (_player->GetMoney() >= MAX_MONEY_AMOUNT - money) // prevent exceeding gold limit
|
||||
{
|
||||
_player->SendEquipError(EQUIP_ERR_TOO_MUCH_GOLD, nullptr, nullptr);
|
||||
_player->SendSellError(SELL_ERR_UNK, creature, itemguid, 0);
|
||||
_player->SendSellError(SELL_ERR_UNK, creature, packet.ItemGuid, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -828,8 +800,8 @@ void WorldSession::HandleSellItemOpcode(WorldPacket& recvData)
|
||||
DurabilityCostsEntry const* dcost = sDurabilityCostsStore.LookupEntry(pProto->ItemLevel);
|
||||
if (!dcost)
|
||||
{
|
||||
_player->SendSellError(SELL_ERR_CANT_SELL_ITEM, creature, itemguid, 0);
|
||||
LOG_ERROR("network.opcode", "WORLD: HandleSellItemOpcode - Wrong item lvl {} for item {} count = {}", pProto->ItemLevel, pItem->GetEntry(), count);
|
||||
_player->SendSellError(SELL_ERR_CANT_SELL_ITEM, creature, packet.ItemGuid, 0);
|
||||
LOG_ERROR("network.opcode", "WORLD: HandleSellItemOpcode - Wrong item lvl {} for item {} count = {}", pProto->ItemLevel, pItem->GetEntry(), packet.Count);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -837,8 +809,8 @@ void WorldSession::HandleSellItemOpcode(WorldPacket& recvData)
|
||||
DurabilityQualityEntry const* dQualitymodEntry = sDurabilityQualityStore.LookupEntry(dQualitymodEntryId);
|
||||
if (!dQualitymodEntry)
|
||||
{
|
||||
_player->SendSellError(SELL_ERR_CANT_SELL_ITEM, creature, itemguid, 0);
|
||||
LOG_ERROR("network.opcode", "WORLD: HandleSellItemOpcode - Wrong dQualityModEntry {} for item {} count = {}", dQualitymodEntryId, pItem->GetEntry(), count);
|
||||
_player->SendSellError(SELL_ERR_CANT_SELL_ITEM, creature, packet.ItemGuid, 0);
|
||||
LOG_ERROR("network.opcode", "WORLD: HandleSellItemOpcode - Wrong dQualityModEntry {} for item {} count = {}", dQualitymodEntryId, pItem->GetEntry(), packet.Count);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -846,36 +818,30 @@ void WorldSession::HandleSellItemOpcode(WorldPacket& recvData)
|
||||
uint32 refund = uint32(std::ceil(LostDurability * dmultiplier * double(dQualitymodEntry->quality_mod)));
|
||||
|
||||
if (!refund)
|
||||
{
|
||||
refund = 1;
|
||||
}
|
||||
|
||||
//starter items can cost more to refund than vendorprice
|
||||
if (refund > money)
|
||||
{
|
||||
money = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
money -= refund;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (count < pItem->GetCount()) // need split items
|
||||
if (packet.Count < pItem->GetCount()) // need split items
|
||||
{
|
||||
Item* pNewItem = pItem->CloneItem(count, _player);
|
||||
Item* pNewItem = pItem->CloneItem(packet.Count, _player);
|
||||
if (!pNewItem)
|
||||
{
|
||||
LOG_ERROR("network.opcode", "WORLD: HandleSellItemOpcode - could not create clone of item {}; count = {}", pItem->GetEntry(), count);
|
||||
_player->SendSellError(SELL_ERR_CANT_SELL_ITEM, creature, itemguid, 0);
|
||||
LOG_ERROR("network.opcode", "WORLD: HandleSellItemOpcode - could not create clone of item {}; count = {}", pItem->GetEntry(), packet.Count);
|
||||
_player->SendSellError(SELL_ERR_CANT_SELL_ITEM, creature, packet.ItemGuid, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
pNewItem->SetUInt32Value(ITEM_FIELD_DURABILITY, pItem->GetUInt32Value(ITEM_FIELD_DURABILITY));
|
||||
|
||||
pItem->SetCount(pItem->GetCount() - count);
|
||||
_player->ItemRemovedQuestCheck(pItem->GetEntry(), count);
|
||||
pItem->SetCount(pItem->GetCount() - packet.Count);
|
||||
_player->ItemRemovedQuestCheck(pItem->GetEntry(), packet.Count);
|
||||
if (_player->IsInWorld())
|
||||
pItem->SendUpdateToPlayer(_player);
|
||||
pItem->SetState(ITEM_CHANGED, _player);
|
||||
@@ -897,25 +863,20 @@ void WorldSession::HandleSellItemOpcode(WorldPacket& recvData)
|
||||
_player->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_MONEY_FROM_VENDORS, money);
|
||||
}
|
||||
else
|
||||
_player->SendSellError(SELL_ERR_CANT_SELL_ITEM, creature, itemguid, 0);
|
||||
_player->SendSellError(SELL_ERR_CANT_SELL_ITEM, creature, packet.ItemGuid, 0);
|
||||
return;
|
||||
}
|
||||
}
|
||||
_player->SendSellError(SELL_ERR_CANT_FIND_ITEM, creature, itemguid, 0);
|
||||
_player->SendSellError(SELL_ERR_CANT_FIND_ITEM, creature, packet.ItemGuid, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
void WorldSession::HandleBuybackItem(WorldPacket& recvData)
|
||||
void WorldSession::HandleBuybackItem(WorldPackets::Item::BuybackItem& packet)
|
||||
{
|
||||
ObjectGuid vendorguid;
|
||||
uint32 slot;
|
||||
|
||||
recvData >> vendorguid >> slot;
|
||||
|
||||
Creature* creature = GetPlayer()->GetNPCIfCanInteractWith(vendorguid, UNIT_NPC_FLAG_VENDOR);
|
||||
Creature* creature = GetPlayer()->GetNPCIfCanInteractWith(packet.VendorGuid, UNIT_NPC_FLAG_VENDOR);
|
||||
if (!creature)
|
||||
{
|
||||
LOG_DEBUG("network", "WORLD: HandleBuybackItem - Unit ({}) not found or you can not interact with him.", vendorguid.ToString());
|
||||
LOG_DEBUG("network", "WORLD: HandleBuybackItem - Unit ({}) not found or you can not interact with him.", packet.VendorGuid.ToString());
|
||||
_player->SendSellError(SELL_ERR_CANT_FIND_VENDOR, nullptr, ObjectGuid::Empty, 0);
|
||||
return;
|
||||
}
|
||||
@@ -924,10 +885,10 @@ void WorldSession::HandleBuybackItem(WorldPacket& recvData)
|
||||
if (GetPlayer()->HasUnitState(UNIT_STATE_DIED))
|
||||
GetPlayer()->RemoveAurasByType(SPELL_AURA_FEIGN_DEATH);
|
||||
|
||||
Item* pItem = _player->GetItemFromBuyBackSlot(slot);
|
||||
Item* pItem = _player->GetItemFromBuyBackSlot(packet.Slot);
|
||||
if (pItem)
|
||||
{
|
||||
uint32 price = _player->GetUInt32Value(PLAYER_FIELD_BUYBACK_PRICE_1 + slot - BUYBACK_SLOT_START);
|
||||
uint32 price = _player->GetUInt32Value(PLAYER_FIELD_BUYBACK_PRICE_1 + packet.Slot - BUYBACK_SLOT_START);
|
||||
if (!_player->HasEnoughMoney(price))
|
||||
{
|
||||
_player->SendBuyError(BUY_ERR_NOT_ENOUGHT_MONEY, creature, pItem->GetEntry(), 0);
|
||||
@@ -948,7 +909,7 @@ void WorldSession::HandleBuybackItem(WorldPacket& recvData)
|
||||
}
|
||||
|
||||
_player->ModifyMoney(-(int32)price);
|
||||
_player->RemoveItemFromBuyBackSlot(slot, false);
|
||||
_player->RemoveItemFromBuyBackSlot(packet.Slot, false);
|
||||
_player->ItemAddedQuestCheck(pItem->GetEntry(), pItem->GetCount());
|
||||
_player->StoreItem(dest, pItem, true);
|
||||
}
|
||||
@@ -960,24 +921,18 @@ void WorldSession::HandleBuybackItem(WorldPacket& recvData)
|
||||
_player->SendBuyError(BUY_ERR_CANT_FIND_ITEM, creature, 0, 0);
|
||||
}
|
||||
|
||||
void WorldSession::HandleBuyItemInSlotOpcode(WorldPacket& recvData)
|
||||
void WorldSession::HandleBuyItemInSlotOpcode(WorldPackets::Item::BuyItemInSlot& packet)
|
||||
{
|
||||
ObjectGuid vendorguid, bagguid;
|
||||
uint32 item, slot, count;
|
||||
uint8 bagslot;
|
||||
|
||||
recvData >> vendorguid >> item >> slot >> bagguid >> bagslot >> count;
|
||||
|
||||
// client expects count starting at 1, and we send vendorslot+1 to client already
|
||||
if (slot > 0)
|
||||
--slot;
|
||||
if (packet.Slot > 0)
|
||||
--packet.Slot;
|
||||
else
|
||||
return; // cheating
|
||||
return; // cheating
|
||||
|
||||
uint8 bag = NULL_BAG; // init for case invalid bagGUID
|
||||
uint8 bag = NULL_BAG; // init for case invalid bagGUID
|
||||
|
||||
// find bag slot by bag guid
|
||||
if (bagguid == _player->GetGUID())
|
||||
if (packet.BagGuid == _player->GetGUID())
|
||||
bag = INVENTORY_SLOT_BAG_0;
|
||||
else
|
||||
{
|
||||
@@ -985,7 +940,7 @@ void WorldSession::HandleBuyItemInSlotOpcode(WorldPacket& recvData)
|
||||
{
|
||||
if (Bag* pBag = _player->GetBagByPos(i))
|
||||
{
|
||||
if (bagguid == pBag->GetGUID())
|
||||
if (packet.BagGuid == pBag->GetGUID())
|
||||
{
|
||||
bag = i;
|
||||
break;
|
||||
@@ -998,38 +953,28 @@ void WorldSession::HandleBuyItemInSlotOpcode(WorldPacket& recvData)
|
||||
if (bag == NULL_BAG)
|
||||
return;
|
||||
|
||||
GetPlayer()->BuyItemFromVendorSlot(vendorguid, slot, item, count, bag, bagslot);
|
||||
GetPlayer()->BuyItemFromVendorSlot(packet.VendorGuid, packet.Slot, packet.Item, packet.Count, bag, packet.BagSlot);
|
||||
}
|
||||
|
||||
void WorldSession::HandleBuyItemOpcode(WorldPacket& recvData)
|
||||
void WorldSession::HandleBuyItemOpcode(WorldPackets::Item::BuyItem& packet)
|
||||
{
|
||||
ObjectGuid vendorguid;
|
||||
uint32 item, slot, count;
|
||||
uint8 unk1;
|
||||
|
||||
recvData >> vendorguid >> item >> slot >> count >> unk1;
|
||||
|
||||
// client expects count starting at 1, and we send vendorslot+1 to client already
|
||||
if (slot > 0)
|
||||
--slot;
|
||||
if (packet.Slot > 0)
|
||||
--packet.Slot;
|
||||
else
|
||||
return; // cheating
|
||||
|
||||
GetPlayer()->BuyItemFromVendorSlot(vendorguid, slot, item, count, NULL_BAG, NULL_SLOT);
|
||||
GetPlayer()->BuyItemFromVendorSlot(packet.VendorGuid, packet.Slot, packet.Item, packet.Count, NULL_BAG, NULL_SLOT);
|
||||
}
|
||||
|
||||
void WorldSession::HandleListInventoryOpcode(WorldPacket& recvData)
|
||||
void WorldSession::HandleListInventoryOpcode(WorldPackets::Item::ListInventory& packet)
|
||||
{
|
||||
ObjectGuid guid;
|
||||
|
||||
recvData >> guid;
|
||||
|
||||
if (!GetPlayer()->IsAlive())
|
||||
return;
|
||||
|
||||
LOG_DEBUG("network", "WORLD: Recvd CMSG_LIST_INVENTORY");
|
||||
|
||||
SendListInventory(guid);
|
||||
SendListInventory(packet.VendorGuid);
|
||||
}
|
||||
|
||||
void WorldSession::SendListInventory(ObjectGuid vendorGuid, uint32 vendorEntry)
|
||||
@@ -1143,18 +1088,14 @@ void WorldSession::SendListInventory(ObjectGuid vendorGuid, uint32 vendorEntry)
|
||||
SendPacket(&data);
|
||||
}
|
||||
|
||||
void WorldSession::HandleAutoStoreBagItemOpcode(WorldPacket& recvData)
|
||||
void WorldSession::HandleAutoStoreBagItemOpcode(WorldPackets::Item::AutoStoreBagItem& packet)
|
||||
{
|
||||
//LOG_DEBUG("network.opcode", "WORLD: CMSG_AUTOSTORE_BAG_ITEM");
|
||||
uint8 srcbag, srcslot, dstbag;
|
||||
|
||||
recvData >> srcbag >> srcslot >> dstbag;
|
||||
|
||||
Item* pItem = _player->GetItemByPos(srcbag, srcslot);
|
||||
Item* pItem = _player->GetItemByPos(packet.SourceBag, packet.SourceSlot);
|
||||
if (!pItem)
|
||||
return;
|
||||
|
||||
if (!_player->IsValidPos(dstbag, NULL_SLOT, false)) // can be autostore pos
|
||||
if (!_player->IsValidPos(packet.DestinationBag, NULL_SLOT, false)) // can be autostore pos
|
||||
{
|
||||
_player->SendEquipError(EQUIP_ERR_ITEM_DOESNT_GO_TO_SLOT, nullptr, nullptr);
|
||||
return;
|
||||
@@ -1174,7 +1115,7 @@ void WorldSession::HandleAutoStoreBagItemOpcode(WorldPacket& recvData)
|
||||
}
|
||||
|
||||
ItemPosCountVec dest;
|
||||
InventoryResult msg = _player->CanStoreItem(dstbag, NULL_SLOT, dest, pItem, false);
|
||||
InventoryResult msg = _player->CanStoreItem(packet.DestinationBag, NULL_SLOT, dest, pItem, false);
|
||||
if (msg != EQUIP_ERR_OK)
|
||||
{
|
||||
_player->SendEquipError(msg, pItem, nullptr);
|
||||
@@ -1189,7 +1130,7 @@ void WorldSession::HandleAutoStoreBagItemOpcode(WorldPacket& recvData)
|
||||
return;
|
||||
}
|
||||
|
||||
_player->RemoveItem(srcbag, srcslot, true);
|
||||
_player->RemoveItem(packet.SourceBag, packet.SourceSlot, true);
|
||||
_player->StoreItem(dest, pItem, true);
|
||||
_player->UpdateTitansGrip();
|
||||
}
|
||||
@@ -1223,23 +1164,22 @@ void WorldSession::HandleSetAmmoOpcode(WorldPacket& recvData)
|
||||
|
||||
void WorldSession::SendEnchantmentLog(ObjectGuid target, ObjectGuid caster, uint32 itemId, uint32 enchantId)
|
||||
{
|
||||
WorldPacket data(SMSG_ENCHANTMENTLOG, (8 + 8 + 4 + 4)); // last check 2.0.10
|
||||
data << target.WriteAsPacked();
|
||||
data << caster.WriteAsPacked();
|
||||
data << uint32(itemId);
|
||||
data << uint32(enchantId);
|
||||
GetPlayer()->SendMessageToSet(&data, true);
|
||||
WorldPackets::Item::EnchantmentLog enchantmentLog;
|
||||
enchantmentLog.Target = target.WriteAsPacked();
|
||||
enchantmentLog.Caster = caster.WriteAsPacked();
|
||||
enchantmentLog.ItemId = itemId;
|
||||
enchantmentLog.EnchantId = enchantId;
|
||||
GetPlayer()->SendMessageToSet(enchantmentLog.Write(), true);
|
||||
}
|
||||
|
||||
void WorldSession::SendItemEnchantTimeUpdate(ObjectGuid Playerguid, ObjectGuid Itemguid, uint32 slot, uint32 Duration)
|
||||
{
|
||||
// last check 2.0.10
|
||||
WorldPacket data(SMSG_ITEM_ENCHANT_TIME_UPDATE, (8 + 4 + 4 + 8));
|
||||
data << Itemguid;
|
||||
data << uint32(slot);
|
||||
data << uint32(Duration);
|
||||
data << Playerguid;
|
||||
SendPacket(&data);
|
||||
WorldPackets::Item::ItemEnchantTimeUpdate itemEnchantTimeUpdate;
|
||||
itemEnchantTimeUpdate.ItemGuid = Itemguid;
|
||||
itemEnchantTimeUpdate.Slot = slot;
|
||||
itemEnchantTimeUpdate.Duration = Duration;
|
||||
itemEnchantTimeUpdate.PlayerGuid = Playerguid;
|
||||
SendPacket(itemEnchantTimeUpdate.Write());
|
||||
}
|
||||
|
||||
void WorldSession::HandleItemNameQueryOpcode(WorldPacket& recvData)
|
||||
@@ -1266,18 +1206,13 @@ void WorldSession::HandleItemNameQueryOpcode(WorldPacket& recvData)
|
||||
}
|
||||
}
|
||||
|
||||
void WorldSession::HandleWrapItemOpcode(WorldPacket& recvData)
|
||||
void WorldSession::HandleWrapItemOpcode(WorldPackets::Item::WrapItem& packet)
|
||||
{
|
||||
LOG_DEBUG("network", "Received opcode CMSG_WRAP_ITEM");
|
||||
|
||||
uint8 gift_bag, gift_slot, item_bag, item_slot;
|
||||
LOG_DEBUG("network", "WRAP: receive GiftBag = {}, GiftSlot = {}, ItemBag = {}, ItemSlot = {}", packet.GiftBag, packet.GiftSlot, packet.ItemBag, packet.ItemSlot);
|
||||
|
||||
recvData >> gift_bag >> gift_slot; // paper
|
||||
recvData >> item_bag >> item_slot; // item
|
||||
|
||||
LOG_DEBUG("network", "WRAP: receive gift_bag = {}, gift_slot = {}, item_bag = {}, item_slot = {}", gift_bag, gift_slot, item_bag, item_slot);
|
||||
|
||||
Item* gift = _player->GetItemByPos(gift_bag, gift_slot);
|
||||
Item* gift = _player->GetItemByPos(packet.GiftBag, packet.GiftSlot);
|
||||
if (!gift)
|
||||
{
|
||||
_player->SendEquipError(EQUIP_ERR_ITEM_NOT_FOUND, gift, nullptr);
|
||||
@@ -1290,7 +1225,7 @@ void WorldSession::HandleWrapItemOpcode(WorldPacket& recvData)
|
||||
return;
|
||||
}
|
||||
|
||||
Item* item = _player->GetItemByPos(item_bag, item_slot);
|
||||
Item* item = _player->GetItemByPos(packet.ItemBag, packet.ItemSlot);
|
||||
|
||||
if (!item)
|
||||
{
|
||||
@@ -1305,7 +1240,7 @@ void WorldSession::HandleWrapItemOpcode(WorldPacket& recvData)
|
||||
return;
|
||||
}
|
||||
|
||||
if (item == gift) // not possable with pacjket from real client
|
||||
if (item == gift) // not possible with packet from real client
|
||||
{
|
||||
_player->SendEquipError(EQUIP_ERR_WRAPPED_CANT_BE_WRAPPED, item, nullptr);
|
||||
return;
|
||||
@@ -1399,26 +1334,19 @@ void WorldSession::HandleWrapItemOpcode(WorldPacket& recvData)
|
||||
_player->DestroyItemCount(gift, count, true);
|
||||
}
|
||||
|
||||
void WorldSession::HandleSocketOpcode(WorldPacket& recvData)
|
||||
void WorldSession::HandleSocketOpcode(WorldPackets::Item::SocketGems& packet)
|
||||
{
|
||||
LOG_DEBUG("network", "WORLD: CMSG_SOCKET_GEMS");
|
||||
|
||||
ObjectGuid item_guid;
|
||||
ObjectGuid gem_guids[MAX_GEM_SOCKETS];
|
||||
|
||||
recvData >> item_guid;
|
||||
if (!item_guid)
|
||||
if (!packet.ItemGuid)
|
||||
return;
|
||||
|
||||
for (int i = 0; i < MAX_GEM_SOCKETS; ++i)
|
||||
recvData >> gem_guids[i];
|
||||
|
||||
//cheat -> tried to socket same gem multiple times
|
||||
if ((gem_guids[0] && (gem_guids[0] == gem_guids[1] || gem_guids[0] == gem_guids[2])) ||
|
||||
(gem_guids[1] && (gem_guids[1] == gem_guids[2])))
|
||||
if ((packet.GemGuids[0] && (packet.GemGuids[0] == packet.GemGuids[1] || packet.GemGuids[0] == packet.GemGuids[2])) ||
|
||||
(packet.GemGuids[1] && (packet.GemGuids[1] == packet.GemGuids[2])))
|
||||
return;
|
||||
|
||||
Item* itemTarget = _player->GetItemByGuid(item_guid);
|
||||
Item* itemTarget = _player->GetItemByGuid(packet.ItemGuid);
|
||||
if (!itemTarget) //missing item to socket
|
||||
return;
|
||||
|
||||
@@ -1431,7 +1359,7 @@ void WorldSession::HandleSocketOpcode(WorldPacket& recvData)
|
||||
|
||||
Item* Gems[MAX_GEM_SOCKETS];
|
||||
for (int i = 0; i < MAX_GEM_SOCKETS; ++i)
|
||||
Gems[i] = gem_guids[i] ? _player->GetItemByGuid(gem_guids[i]) : nullptr;
|
||||
Gems[i] = packet.GemGuids[i] ? _player->GetItemByGuid(packet.GemGuids[i]) : nullptr;
|
||||
|
||||
GemPropertiesEntry const* GemProps[MAX_GEM_SOCKETS];
|
||||
for (int i = 0; i < MAX_GEM_SOCKETS; ++i) //get geminfo from dbc storage
|
||||
@@ -1572,7 +1500,7 @@ void WorldSession::HandleSocketOpcode(WorldPacket& recvData)
|
||||
if (GemEnchants[i])
|
||||
{
|
||||
itemTarget->SetEnchantment(EnchantmentSlot(SOCK_ENCHANTMENT_SLOT + i), GemEnchants[i], 0, 0, _player->GetGUID());
|
||||
if (Item* guidItem = _player->GetItemByGuid(gem_guids[i]))
|
||||
if (Item* guidItem = _player->GetItemByGuid(packet.GemGuids[i]))
|
||||
_player->DestroyItem(guidItem->GetBagSlot(), guidItem->GetSlot(), true);
|
||||
}
|
||||
}
|
||||
@@ -1597,19 +1525,15 @@ void WorldSession::HandleSocketOpcode(WorldPacket& recvData)
|
||||
itemTarget->SendUpdateSockets();
|
||||
}
|
||||
|
||||
void WorldSession::HandleCancelTempEnchantmentOpcode(WorldPacket& recvData)
|
||||
void WorldSession::HandleCancelTempEnchantmentOpcode(WorldPackets::Item::CancelTempEnchantment& packet)
|
||||
{
|
||||
LOG_DEBUG("network", "WORLD: CMSG_CANCEL_TEMP_ENCHANTMENT");
|
||||
|
||||
uint32 eslot;
|
||||
|
||||
recvData >> eslot;
|
||||
|
||||
// apply only to equipped item
|
||||
if (!Player::IsEquipmentPos(INVENTORY_SLOT_BAG_0, eslot))
|
||||
if (!Player::IsEquipmentPos(INVENTORY_SLOT_BAG_0, packet.EquipmentSlot))
|
||||
return;
|
||||
|
||||
Item* item = GetPlayer()->GetItemByPos(INVENTORY_SLOT_BAG_0, eslot);
|
||||
Item* item = GetPlayer()->GetItemByPos(INVENTORY_SLOT_BAG_0, packet.EquipmentSlot);
|
||||
|
||||
if (!item)
|
||||
return;
|
||||
@@ -1621,14 +1545,11 @@ void WorldSession::HandleCancelTempEnchantmentOpcode(WorldPacket& recvData)
|
||||
item->ClearEnchantment(TEMP_ENCHANTMENT_SLOT);
|
||||
}
|
||||
|
||||
void WorldSession::HandleItemRefundInfoRequest(WorldPacket& recvData)
|
||||
void WorldSession::HandleItemRefundInfoRequest(WorldPackets::Item::ItemRefundInfo& packet)
|
||||
{
|
||||
LOG_DEBUG("network", "WORLD: CMSG_ITEM_REFUND_INFO");
|
||||
|
||||
ObjectGuid guid;
|
||||
recvData >> guid; // item guid
|
||||
|
||||
Item* item = _player->GetItemByGuid(guid);
|
||||
Item* item = _player->GetItemByGuid(packet.ItemGuid);
|
||||
if (!item)
|
||||
{
|
||||
LOG_DEBUG("network", "Item refund: item not found!");
|
||||
@@ -1638,13 +1559,11 @@ void WorldSession::HandleItemRefundInfoRequest(WorldPacket& recvData)
|
||||
GetPlayer()->SendRefundInfo(item);
|
||||
}
|
||||
|
||||
void WorldSession::HandleItemRefund(WorldPacket& recvData)
|
||||
void WorldSession::HandleItemRefund(WorldPackets::Item::ItemRefund& packet)
|
||||
{
|
||||
LOG_DEBUG("network", "WORLD: CMSG_ITEM_REFUND");
|
||||
ObjectGuid guid;
|
||||
recvData >> guid; // item guid
|
||||
|
||||
Item* item = _player->GetItemByGuid(guid);
|
||||
Item* item = _player->GetItemByGuid(packet.ItemGuid);
|
||||
if (!item)
|
||||
{
|
||||
LOG_DEBUG("network", "Item refund: item not found!");
|
||||
@@ -1652,7 +1571,7 @@ void WorldSession::HandleItemRefund(WorldPacket& recvData)
|
||||
}
|
||||
|
||||
// Don't try to refund item currently being disenchanted
|
||||
if (_player->GetLootGUID() == guid)
|
||||
if (_player->GetLootGUID() == packet.ItemGuid)
|
||||
return;
|
||||
|
||||
GetPlayer()->RefundItem(item);
|
||||
|
||||
@@ -183,7 +183,9 @@ void WorldSession::HandlePetitionBuyOpcode(WorldPacket& recvData)
|
||||
if (!charter)
|
||||
return;
|
||||
|
||||
charter->SetUInt32Value(ITEM_FIELD_ENCHANTMENT_1_1, charter->GetGUID().GetCounter());
|
||||
// Use a 31-bit safe petition id instead of the raw item guid
|
||||
uint32 petitionId = sPetitionMgr->GeneratePetitionId();
|
||||
charter->SetUInt32Value(ITEM_FIELD_ENCHANTMENT_1_1, petitionId);
|
||||
// ITEM_FIELD_ENCHANTMENT_1_1 is guild/arenateam id
|
||||
// ITEM_FIELD_ENCHANTMENT_1_1+1 is current signatures count (showed on item)
|
||||
charter->SetState(ITEM_CHANGED, _player);
|
||||
@@ -211,16 +213,18 @@ void WorldSession::HandlePetitionBuyOpcode(WorldPacket& recvData)
|
||||
// xinef: petition pointer is invalid from now on
|
||||
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_PETITION);
|
||||
stmt->SetData(0, _player->GetGUID().GetCounter());
|
||||
stmt->SetData(1, charter->GetGUID().GetCounter());
|
||||
stmt->SetData(2, name);
|
||||
stmt->SetData(3, uint8(type));
|
||||
// petition_id, ownerguid, petitionguid(item guid), name, type
|
||||
stmt->SetData(0, petitionId);
|
||||
stmt->SetData(1, _player->GetGUID().GetCounter());
|
||||
stmt->SetData(2, charter->GetGUID().GetCounter());
|
||||
stmt->SetData(3, name);
|
||||
stmt->SetData(4, uint8(type));
|
||||
trans->Append(stmt);
|
||||
|
||||
CharacterDatabase.CommitTransaction(trans);
|
||||
|
||||
// xinef: fill petition store
|
||||
sPetitionMgr->AddPetition(charter->GetGUID(), _player->GetGUID(), name, uint8(type));
|
||||
// xinef: fill petition store (include petitionId)
|
||||
sPetitionMgr->AddPetition(charter->GetGUID(), _player->GetGUID(), name, uint8(type), petitionId);
|
||||
}
|
||||
|
||||
void WorldSession::HandlePetitionShowSignOpcode(WorldPacket& recvData)
|
||||
@@ -249,7 +253,7 @@ void WorldSession::HandlePetitionShowSignOpcode(WorldPacket& recvData)
|
||||
WorldPacket data(SMSG_PETITION_SHOW_SIGNATURES, (8 + 8 + 4 + 1 + signs * 12));
|
||||
data << petitionguid; // petition guid
|
||||
data << _player->GetGUID(); // owner guid
|
||||
data << uint32(petitionguid.GetCounter()); // guild guid
|
||||
data << uint32(petition->petitionId); // guild/team id (31-bit safe)
|
||||
data << uint8(signs); // sign's count
|
||||
|
||||
if (signs)
|
||||
@@ -286,7 +290,7 @@ void WorldSession::SendPetitionQueryOpcode(ObjectGuid petitionguid)
|
||||
|
||||
uint8 type = petition->petitionType;
|
||||
WorldPacket data(SMSG_PETITION_QUERY_RESPONSE, (4 + 8 + petition->petitionName.size() + 1 + 1 + 4 * 12 + 2 + 10));
|
||||
data << uint32(petitionguid.GetCounter()); // guild/team guid (in Trinity always same as petition low guid
|
||||
data << uint32(petition->petitionId); // guild/team id (was item low guid)
|
||||
data << petition->ownerGuid; // charter owner guid
|
||||
data << petition->petitionName; // name (guild/arena team)
|
||||
data << uint8(0); // some string
|
||||
@@ -373,7 +377,7 @@ void WorldSession::HandlePetitionRenameOpcode(WorldPacket& recvData)
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_PETITION_NAME);
|
||||
|
||||
stmt->SetData(0, newName);
|
||||
stmt->SetData(1, petitionGuid.GetCounter());
|
||||
stmt->SetData(1, petition->petitionId);
|
||||
|
||||
CharacterDatabase.Execute(stmt);
|
||||
|
||||
@@ -499,7 +503,7 @@ void WorldSession::HandlePetitionSignOpcode(WorldPacket& recvData)
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_PETITION_SIGNATURE);
|
||||
|
||||
stmt->SetData(0, petition->ownerGuid.GetCounter());
|
||||
stmt->SetData(1, petitionGuid.GetCounter());
|
||||
stmt->SetData(1, petition->petitionId);
|
||||
stmt->SetData(2, playerGuid.GetCounter());
|
||||
stmt->SetData(3, GetAccountId());
|
||||
|
||||
@@ -627,7 +631,7 @@ void WorldSession::HandleOfferPetitionOpcode(WorldPacket& recvData)
|
||||
WorldPacket data(SMSG_PETITION_SHOW_SIGNATURES, (8 + 8 + 4 + signs + signs * 12));
|
||||
data << petitionguid; // petition guid
|
||||
data << _player->GetGUID(); // owner guid
|
||||
data << uint32(petitionguid.GetCounter()); // guild guid
|
||||
data << uint32(petition->petitionId); // guild/team id (31-bit safe)
|
||||
data << uint8(signs); // sign's count
|
||||
|
||||
if (signs)
|
||||
@@ -792,12 +796,12 @@ void WorldSession::HandleTurnInPetitionOpcode(WorldPacket& recvData)
|
||||
|
||||
CharacterDatabaseTransaction trans = CharacterDatabase.BeginTransaction();
|
||||
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_PETITION_BY_GUID);
|
||||
stmt->SetData(0, petitionGuid.GetCounter());
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_PETITION_BY_ID);
|
||||
stmt->SetData(0, petition->petitionId);
|
||||
trans->Append(stmt);
|
||||
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_PETITION_SIGNATURE_BY_GUID);
|
||||
stmt->SetData(0, petitionGuid.GetCounter());
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_PETITION_SIGNATURE_BY_ID);
|
||||
stmt->SetData(0, petition->petitionId);
|
||||
trans->Append(stmt);
|
||||
|
||||
CharacterDatabase.CommitTransaction(trans);
|
||||
|
||||
@@ -73,6 +73,8 @@ Map::Map(uint32 id, uint32 InstanceId, uint8 SpawnMode, Map* _parent) :
|
||||
|
||||
//lets initialize visibility distance for map
|
||||
Map::InitVisibilityDistance();
|
||||
|
||||
_corpseUpdateTimer.SetInterval(20 * MINUTE * IN_MILLISECONDS);
|
||||
}
|
||||
|
||||
// Hook called after map is created AND after added to map list
|
||||
@@ -116,6 +118,8 @@ void Map::AddToGrid(Creature* obj, Cell const& cell)
|
||||
{
|
||||
MapGridType* grid = GetMapGrid(cell.GridX(), cell.GridY());
|
||||
grid->AddGridObject(cell.CellX(), cell.CellY(), obj);
|
||||
if (obj->IsFarVisible())
|
||||
grid->AddFarVisibleObject(cell.CellX(), cell.CellY(), obj);
|
||||
|
||||
obj->SetCurrentCell(cell);
|
||||
}
|
||||
@@ -125,6 +129,8 @@ void Map::AddToGrid(GameObject* obj, Cell const& cell)
|
||||
{
|
||||
MapGridType* grid = GetMapGrid(cell.GridX(), cell.GridY());
|
||||
grid->AddGridObject(cell.CellX(), cell.CellY(), obj);
|
||||
if (obj->IsFarVisible())
|
||||
grid->AddFarVisibleObject(cell.CellX(), cell.CellY(), obj);
|
||||
|
||||
obj->SetCurrentCell(cell);
|
||||
}
|
||||
@@ -494,6 +500,8 @@ void Map::Update(const uint32 t_diff, const uint32 s_diff, bool /*thread*/)
|
||||
|
||||
HandleDelayedVisibility();
|
||||
|
||||
UpdateExpiredCorpses(t_diff);
|
||||
|
||||
sScriptMgr->OnMapUpdate(this, t_diff);
|
||||
|
||||
METRIC_VALUE("map_creatures", uint64(GetObjectsStore().Size<Creature>()),
|
||||
@@ -600,6 +608,69 @@ void Map::RemoveObjectFromMapUpdateList(WorldObject* obj)
|
||||
_RemoveObjectFromUpdateList(obj);
|
||||
}
|
||||
|
||||
// Used in VisibilityDistanceType::Large and VisibilityDistanceType::Gigantic
|
||||
void Map::AddWorldObjectToFarVisibleMap(WorldObject* obj)
|
||||
{
|
||||
if (Creature* creature = obj->ToCreature())
|
||||
{
|
||||
if (!creature->IsInGrid())
|
||||
return;
|
||||
|
||||
Cell curr_cell = creature->GetCurrentCell();
|
||||
MapGridType* grid = GetMapGrid(curr_cell.GridX(), curr_cell.GridY());
|
||||
grid->AddFarVisibleObject(curr_cell.CellX(), curr_cell.CellY(), creature);
|
||||
}
|
||||
else if (GameObject* go = obj->ToGameObject())
|
||||
{
|
||||
if (!go->IsInGrid())
|
||||
return;
|
||||
|
||||
Cell curr_cell = go->GetCurrentCell();
|
||||
MapGridType* grid = GetMapGrid(curr_cell.GridX(), curr_cell.GridY());
|
||||
grid->AddFarVisibleObject(curr_cell.CellX(), curr_cell.CellY(), go);
|
||||
}
|
||||
}
|
||||
|
||||
void Map::RemoveWorldObjectFromFarVisibleMap(WorldObject* obj)
|
||||
{
|
||||
if (Creature* creature = obj->ToCreature())
|
||||
{
|
||||
Cell curr_cell = creature->GetCurrentCell();
|
||||
MapGridType* grid = GetMapGrid(curr_cell.GridX(), curr_cell.GridY());
|
||||
grid->RemoveFarVisibleObject(curr_cell.CellX(), curr_cell.CellY(), creature);
|
||||
}
|
||||
else if (GameObject* go = obj->ToGameObject())
|
||||
{
|
||||
Cell curr_cell = go->GetCurrentCell();
|
||||
MapGridType* grid = GetMapGrid(curr_cell.GridX(), curr_cell.GridY());
|
||||
grid->RemoveFarVisibleObject(curr_cell.CellX(), curr_cell.CellY(), go);
|
||||
}
|
||||
}
|
||||
|
||||
// Used in VisibilityDistanceType::Infinite
|
||||
void Map::AddWorldObjectToZoneWideVisibleMap(uint32 zoneId, WorldObject* obj)
|
||||
{
|
||||
_zoneWideVisibleWorldObjectsMap[zoneId].insert(obj);
|
||||
}
|
||||
|
||||
void Map::RemoveWorldObjectFromZoneWideVisibleMap(uint32 zoneId, WorldObject* obj)
|
||||
{
|
||||
ZoneWideVisibleWorldObjectsMap::iterator itr = _zoneWideVisibleWorldObjectsMap.find(zoneId);
|
||||
if (itr == _zoneWideVisibleWorldObjectsMap.end())
|
||||
return;
|
||||
|
||||
itr->second.erase(obj);
|
||||
}
|
||||
|
||||
ZoneWideVisibleWorldObjectsSet const* Map::GetZoneWideVisibleWorldObjectsForZone(uint32 zoneId) const
|
||||
{
|
||||
ZoneWideVisibleWorldObjectsMap::const_iterator itr = _zoneWideVisibleWorldObjectsMap.find(zoneId);
|
||||
if (itr == _zoneWideVisibleWorldObjectsMap.end())
|
||||
return nullptr;
|
||||
|
||||
return &itr->second;
|
||||
}
|
||||
|
||||
void Map::HandleDelayedVisibility()
|
||||
{
|
||||
if (i_objectsForDelayedVisibility.empty())
|
||||
@@ -652,6 +723,8 @@ void Map::RemoveFromMap(T* obj, bool remove)
|
||||
obj->RemoveFromWorld();
|
||||
|
||||
obj->RemoveFromGrid();
|
||||
if (obj->IsFarVisible())
|
||||
RemoveWorldObjectFromFarVisibleMap(obj);
|
||||
|
||||
obj->ResetMap();
|
||||
|
||||
@@ -848,6 +921,11 @@ void Map::MoveAllCreaturesInMoveList()
|
||||
|
||||
Cell const& old_cell = c->GetCurrentCell();
|
||||
Cell new_cell(c->GetPositionX(), c->GetPositionY());
|
||||
if (c->IsFarVisible())
|
||||
{
|
||||
// Removes via GetCurrentCell, added back in AddToGrid
|
||||
RemoveWorldObjectFromFarVisibleMap(c);
|
||||
}
|
||||
|
||||
c->RemoveFromGrid();
|
||||
if (old_cell.DiffGrid(new_cell))
|
||||
@@ -878,6 +956,12 @@ void Map::MoveAllGameObjectsInMoveList()
|
||||
Cell const& old_cell = go->GetCurrentCell();
|
||||
Cell new_cell(go->GetPositionX(), go->GetPositionY());
|
||||
|
||||
if (go->IsFarVisible())
|
||||
{
|
||||
// Removes via GetCurrentCell, added back in AddToGrid
|
||||
RemoveWorldObjectFromFarVisibleMap(go);
|
||||
}
|
||||
|
||||
go->RemoveFromGrid();
|
||||
if (old_cell.DiffGrid(new_cell))
|
||||
EnsureGridLoaded(new_cell);
|
||||
@@ -1580,6 +1664,17 @@ void Map::SendInitSelf(Player* player)
|
||||
player->SendDirectMessage(&packet);
|
||||
}
|
||||
|
||||
void Map::UpdateExpiredCorpses(uint32 const diff)
|
||||
{
|
||||
_corpseUpdateTimer.Update(diff);
|
||||
if (!_corpseUpdateTimer.Passed())
|
||||
return;
|
||||
|
||||
RemoveOldCorpses();
|
||||
|
||||
_corpseUpdateTimer.Reset();
|
||||
}
|
||||
|
||||
void Map::SendInitTransports(Player* player)
|
||||
{
|
||||
if (_transports.empty())
|
||||
|
||||
@@ -147,6 +147,8 @@ struct ZoneDynamicInfo
|
||||
typedef std::map<uint32/*leaderDBGUID*/, CreatureGroup*> CreatureGroupHolderType;
|
||||
typedef std::unordered_map<uint32 /*zoneId*/, ZoneDynamicInfo> ZoneDynamicInfoMap;
|
||||
typedef std::unordered_set<Transport*> TransportsContainer;
|
||||
typedef std::unordered_set<WorldObject*> ZoneWideVisibleWorldObjectsSet;
|
||||
typedef std::unordered_map<uint32 /*ZoneId*/, ZoneWideVisibleWorldObjectsSet> ZoneWideVisibleWorldObjectsMap;
|
||||
|
||||
enum EncounterCreditType : uint8
|
||||
{
|
||||
@@ -443,6 +445,8 @@ public:
|
||||
void SendZoneDynamicInfo(Player* player);
|
||||
void SendInitSelf(Player* player);
|
||||
|
||||
void UpdateExpiredCorpses(uint32 const diff);
|
||||
|
||||
void PlayDirectSoundToMap(uint32 soundId, uint32 zoneId = 0);
|
||||
void SetZoneMusic(uint32 zoneId, uint32 musicId);
|
||||
void SetZoneWeather(uint32 zoneId, WeatherState weatherId, float weatherGrade);
|
||||
@@ -494,6 +498,12 @@ public:
|
||||
typedef std::vector<WorldObject*> UpdatableObjectList;
|
||||
typedef std::unordered_set<WorldObject*> PendingAddUpdatableObjectList;
|
||||
|
||||
void AddWorldObjectToFarVisibleMap(WorldObject* obj);
|
||||
void RemoveWorldObjectFromFarVisibleMap(WorldObject* obj);
|
||||
void AddWorldObjectToZoneWideVisibleMap(uint32 zoneId, WorldObject* obj);
|
||||
void RemoveWorldObjectFromZoneWideVisibleMap(uint32 zoneId, WorldObject* obj);
|
||||
ZoneWideVisibleWorldObjectsSet const* GetZoneWideVisibleWorldObjectsForZone(uint32 zoneId) const;
|
||||
|
||||
private:
|
||||
|
||||
template<class T> void InitializeObject(T* obj);
|
||||
@@ -576,6 +586,8 @@ private:
|
||||
ZoneDynamicInfoMap _zoneDynamicInfo;
|
||||
uint32 _defaultLight;
|
||||
|
||||
IntervalTimer _corpseUpdateTimer;
|
||||
|
||||
template<HighGuid high>
|
||||
inline ObjectGuidGeneratorBase& GetGuidSequenceGenerator()
|
||||
{
|
||||
@@ -599,6 +611,7 @@ private:
|
||||
UpdatableObjectList _updatableObjectList;
|
||||
PendingAddUpdatableObjectList _pendingAddUpdatableObjectList;
|
||||
IntervalTimer _updatableObjectListRecheckTimer;
|
||||
ZoneWideVisibleWorldObjectsMap _zoneWideVisibleWorldObjectsMap;
|
||||
};
|
||||
|
||||
enum InstanceResetMethod
|
||||
|
||||
@@ -41,8 +41,9 @@ void PetitionMgr::LoadPetitions()
|
||||
{
|
||||
uint32 oldMSTime = getMSTime();
|
||||
PetitionStore.clear();
|
||||
PetitionIdToItemGuid.clear();
|
||||
|
||||
QueryResult result = CharacterDatabase.Query("SELECT ownerguid, petitionguid, name, type FROM petition");
|
||||
QueryResult result = CharacterDatabase.Query("SELECT ownerguid, petitionguid, name, type, petition_id FROM petition");
|
||||
if (!result)
|
||||
{
|
||||
LOG_WARN("server.loading", ">> Loaded 0 Petitions!");
|
||||
@@ -51,13 +52,24 @@ void PetitionMgr::LoadPetitions()
|
||||
}
|
||||
|
||||
uint32 count = 0;
|
||||
uint32 maxId = 0;
|
||||
do
|
||||
{
|
||||
Field* fields = result->Fetch();
|
||||
AddPetition(ObjectGuid::Create<HighGuid::Item>(fields[1].Get<uint32>()), ObjectGuid::Create<HighGuid::Player>(fields[0].Get<uint32>()), fields[2].Get<std::string>(), fields[3].Get<uint8>());
|
||||
uint32 itemLow = fields[1].Get<uint32>();
|
||||
uint32 petitionId = fields[4].Get<uint32>();
|
||||
ObjectGuid itemGuid = ObjectGuid::Create<HighGuid::Item>(itemLow);
|
||||
ObjectGuid ownerGuid = ObjectGuid::Create<HighGuid::Player>(fields[0].Get<uint32>());
|
||||
AddPetition(itemGuid, ownerGuid, fields[2].Get<std::string>(), fields[3].Get<uint8>(), petitionId);
|
||||
PetitionIdToItemGuid[petitionId] = itemGuid;
|
||||
if (petitionId > maxId)
|
||||
maxId = petitionId;
|
||||
++count;
|
||||
} while (result->NextRow());
|
||||
|
||||
// initialize next id (keep within 31-bit safe range)
|
||||
_nextPetitionId = std::min<uint32>(std::max<uint32>(maxId + 1, 1), 0x7FFFFFFFu);
|
||||
|
||||
LOG_INFO("server.loading", ">> Loaded {} Petitions in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
|
||||
LOG_INFO("server.loading", " ");
|
||||
}
|
||||
@@ -67,7 +79,7 @@ void PetitionMgr::LoadSignatures()
|
||||
uint32 oldMSTime = getMSTime();
|
||||
SignatureStore.clear();
|
||||
|
||||
QueryResult result = CharacterDatabase.Query("SELECT petitionguid, playerguid, player_account FROM petition_sign");
|
||||
QueryResult result = CharacterDatabase.Query("SELECT petition_id, playerguid, player_account FROM petition_sign");
|
||||
if (!result)
|
||||
{
|
||||
LOG_WARN("server.loading", ">> Loaded 0 Petition signs!");
|
||||
@@ -79,7 +91,11 @@ void PetitionMgr::LoadSignatures()
|
||||
do
|
||||
{
|
||||
Field* fields = result->Fetch();
|
||||
AddSignature(ObjectGuid::Create<HighGuid::Item>(fields[0].Get<uint32>()), fields[2].Get<uint32>(), ObjectGuid::Create<HighGuid::Player>(fields[1].Get<uint32>()));
|
||||
uint32 petitionId = fields[0].Get<uint32>();
|
||||
auto it = PetitionIdToItemGuid.find(petitionId);
|
||||
if (it == PetitionIdToItemGuid.end())
|
||||
continue; // orphan signature, skip
|
||||
AddSignature(it->second, fields[2].Get<uint32>(), ObjectGuid::Create<HighGuid::Player>(fields[1].Get<uint32>()));
|
||||
++count;
|
||||
} while (result->NextRow());
|
||||
|
||||
@@ -87,10 +103,11 @@ void PetitionMgr::LoadSignatures()
|
||||
LOG_INFO("server.loading", " ");
|
||||
}
|
||||
|
||||
void PetitionMgr::AddPetition(ObjectGuid petitionGUID, ObjectGuid ownerGuid, std::string const& name, uint8 type)
|
||||
void PetitionMgr::AddPetition(ObjectGuid petitionGUID, ObjectGuid ownerGuid, std::string const& name, uint8 type, uint32 petitionId)
|
||||
{
|
||||
Petition& p = PetitionStore[petitionGUID];
|
||||
p.petitionGuid = petitionGUID;
|
||||
p.petitionId = petitionId;
|
||||
p.ownerGuid = ownerGuid;
|
||||
p.petitionName = name;
|
||||
p.petitionType = type;
|
||||
@@ -102,7 +119,12 @@ void PetitionMgr::AddPetition(ObjectGuid petitionGUID, ObjectGuid ownerGuid, std
|
||||
|
||||
void PetitionMgr::RemovePetition(ObjectGuid petitionGUID)
|
||||
{
|
||||
PetitionStore.erase(petitionGUID);
|
||||
auto it = PetitionStore.find(petitionGUID);
|
||||
if (it != PetitionStore.end())
|
||||
{
|
||||
PetitionIdToItemGuid.erase(it->second.petitionId);
|
||||
PetitionStore.erase(it);
|
||||
}
|
||||
|
||||
// remove signatures
|
||||
SignatureStore.erase(petitionGUID);
|
||||
@@ -143,6 +165,15 @@ Petition const* PetitionMgr::GetPetition(ObjectGuid petitionGUID) const
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Petition const* PetitionMgr::GetPetitionById(uint32 petitionId) const
|
||||
{
|
||||
auto it = PetitionIdToItemGuid.find(petitionId);
|
||||
if (it == PetitionIdToItemGuid.end())
|
||||
return nullptr;
|
||||
|
||||
return GetPetition(it->second);
|
||||
}
|
||||
|
||||
Petition const* PetitionMgr::GetPetitionByOwnerWithType(ObjectGuid ownerGuid, uint8 type) const
|
||||
{
|
||||
for (PetitionContainer::const_iterator itr = PetitionStore.begin(); itr != PetitionStore.end(); ++itr)
|
||||
@@ -189,3 +220,37 @@ void PetitionMgr::RemoveSignaturesByPlayerAndType(ObjectGuid playerGuid, uint8 t
|
||||
itr->second.signatureMap.erase(signItr);
|
||||
}
|
||||
}
|
||||
|
||||
uint32 PetitionMgr::GeneratePetitionId()
|
||||
{
|
||||
// ensure 31-bit range and avoid collisions with already loaded petitions
|
||||
if (_nextPetitionId == 0 || _nextPetitionId >= 0x7FFFFFFF)
|
||||
_nextPetitionId = 1;
|
||||
|
||||
// find first free id
|
||||
while (PetitionIdToItemGuid.count(_nextPetitionId))
|
||||
{
|
||||
++_nextPetitionId;
|
||||
if (_nextPetitionId >= 0x7FFFFFFF)
|
||||
_nextPetitionId = 1;
|
||||
}
|
||||
|
||||
uint32 id = _nextPetitionId++;
|
||||
if (_nextPetitionId >= 0x7FFFFFFF)
|
||||
_nextPetitionId = 1;
|
||||
return id;
|
||||
}
|
||||
|
||||
uint32 PetitionMgr::GetPetitionIdByItemGuid(ObjectGuid petitionItemGuid) const
|
||||
{
|
||||
Petition const* p = GetPetition(petitionItemGuid);
|
||||
return p ? p->petitionId : 0;
|
||||
}
|
||||
|
||||
ObjectGuid PetitionMgr::GetItemGuidByPetitionId(uint32 petitionId) const
|
||||
{
|
||||
auto it = PetitionIdToItemGuid.find(petitionId);
|
||||
if (it == PetitionIdToItemGuid.end())
|
||||
return ObjectGuid::Empty;
|
||||
return it->second;
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
|
||||
#include "ObjectGuid.h"
|
||||
|
||||
#include <unordered_map>
|
||||
#include <map>
|
||||
|
||||
#define CHARTER_DISPLAY_ID 16161
|
||||
@@ -37,14 +38,21 @@ typedef std::map<ObjectGuid, uint32> SignatureMap;
|
||||
|
||||
struct Petition
|
||||
{
|
||||
// Item GUID of the charter item (used to find the item in inventory)
|
||||
ObjectGuid petitionGuid;
|
||||
// New 31-bit safe petition identifier used in packets/DB relations
|
||||
uint32 petitionId;
|
||||
// Owner character GUID
|
||||
ObjectGuid ownerGuid;
|
||||
// Petition type (guild / arena)
|
||||
uint8 petitionType;
|
||||
// Name associated with the petition (guild/arena name)
|
||||
std::string petitionName;
|
||||
};
|
||||
|
||||
struct Signatures
|
||||
{
|
||||
// Keep keying by item-guid for backward compatibility in code paths
|
||||
ObjectGuid petitionGuid;
|
||||
SignatureMap signatureMap;
|
||||
};
|
||||
@@ -65,10 +73,11 @@ public:
|
||||
void LoadSignatures();
|
||||
|
||||
// Petitions
|
||||
void AddPetition(ObjectGuid petitionGUID, ObjectGuid ownerGuid, std::string const& name, uint8 type);
|
||||
void AddPetition(ObjectGuid petitionGUID, ObjectGuid ownerGuid, std::string const& name, uint8 type, uint32 petitionId);
|
||||
void RemovePetition(ObjectGuid petitionGUID);
|
||||
void RemovePetitionByOwnerAndType(ObjectGuid ownerGuid, uint8 type);
|
||||
Petition const* GetPetition(ObjectGuid petitionGUID) const;
|
||||
Petition const* GetPetitionById(uint32 petitionId) const;
|
||||
Petition const* GetPetitionByOwnerWithType(ObjectGuid ownerGuid, uint8 type) const;
|
||||
PetitionContainer* GetPetitionStore() { return &PetitionStore; }
|
||||
|
||||
@@ -79,9 +88,17 @@ public:
|
||||
Signatures const* GetSignature(ObjectGuid petitionGUID) const;
|
||||
SignatureContainer* GetSignatureStore() { return &SignatureStore; }
|
||||
|
||||
uint32 GeneratePetitionId();
|
||||
uint32 GetPetitionIdByItemGuid(ObjectGuid petitionItemGuid) const;
|
||||
ObjectGuid GetItemGuidByPetitionId(uint32 petitionId) const;
|
||||
|
||||
protected:
|
||||
PetitionContainer PetitionStore;
|
||||
SignatureContainer SignatureStore;
|
||||
// Mapping id -> item-guid to support DB-id lookups
|
||||
std::unordered_map<uint32, ObjectGuid> PetitionIdToItemGuid;
|
||||
// Next petition id (kept < 2^31)
|
||||
uint32 _nextPetitionId = 1;
|
||||
};
|
||||
|
||||
#define sPetitionMgr PetitionMgr::instance()
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#include "CombatLogPackets.h"
|
||||
#include "CombatPackets.h"
|
||||
#include "GuildPackets.h"
|
||||
#include "ItemPackets.h"
|
||||
#include "LFGPackets.h"
|
||||
#include "MiscPackets.h"
|
||||
#include "PetPackets.h"
|
||||
|
||||
@@ -0,0 +1,163 @@
|
||||
/*
|
||||
* 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 "ItemPackets.h"
|
||||
|
||||
void WorldPackets::Item::SplitItem::Read()
|
||||
{
|
||||
_worldPacket >> SourceBag;
|
||||
_worldPacket >> SourceSlot;
|
||||
_worldPacket >> DestinationBag;
|
||||
_worldPacket >> DestinationSlot;
|
||||
_worldPacket >> Count;
|
||||
}
|
||||
|
||||
void WorldPackets::Item::SwapInventoryItem::Read()
|
||||
{
|
||||
_worldPacket >> DestinationSlot;
|
||||
_worldPacket >> SourceSlot;
|
||||
}
|
||||
|
||||
void WorldPackets::Item::AutoEquipItemSlot::Read()
|
||||
{
|
||||
_worldPacket >> ItemGuid;
|
||||
_worldPacket >> DestinationSlot;
|
||||
}
|
||||
|
||||
void WorldPackets::Item::SwapItem::Read()
|
||||
{
|
||||
_worldPacket >> DestinationBag;
|
||||
_worldPacket >> DestinationSlot;
|
||||
_worldPacket >> SourceBag;
|
||||
_worldPacket >> SourceSlot;
|
||||
}
|
||||
|
||||
void WorldPackets::Item::AutoEquipItem::Read()
|
||||
{
|
||||
_worldPacket >> SourceBag;
|
||||
_worldPacket >> SourceSlot;
|
||||
}
|
||||
|
||||
void WorldPackets::Item::DestroyItem::Read()
|
||||
{
|
||||
_worldPacket >> Bag;
|
||||
_worldPacket >> Slot;
|
||||
_worldPacket >> Count;
|
||||
_worldPacket >> Data1;
|
||||
_worldPacket >> Data2;
|
||||
_worldPacket >> Data3;
|
||||
}
|
||||
|
||||
void WorldPackets::Item::ReadItem::Read()
|
||||
{
|
||||
_worldPacket >> Bag;
|
||||
_worldPacket >> Slot;
|
||||
}
|
||||
|
||||
void WorldPackets::Item::SellItem::Read()
|
||||
{
|
||||
_worldPacket >> VendorGuid;
|
||||
_worldPacket >> ItemGuid;
|
||||
_worldPacket >> Count;
|
||||
}
|
||||
|
||||
void WorldPackets::Item::BuybackItem::Read()
|
||||
{
|
||||
_worldPacket >> VendorGuid;
|
||||
_worldPacket >> Slot;
|
||||
}
|
||||
|
||||
void WorldPackets::Item::BuyItemInSlot::Read()
|
||||
{
|
||||
_worldPacket >> VendorGuid;
|
||||
_worldPacket >> Item;
|
||||
_worldPacket >> Slot;
|
||||
_worldPacket >> BagGuid;
|
||||
_worldPacket >> BagSlot;
|
||||
_worldPacket >> Count;
|
||||
}
|
||||
|
||||
void WorldPackets::Item::BuyItem::Read()
|
||||
{
|
||||
_worldPacket >> VendorGuid;
|
||||
_worldPacket >> Item;
|
||||
_worldPacket >> Slot;
|
||||
_worldPacket >> Count;
|
||||
_worldPacket >> Unk;
|
||||
}
|
||||
|
||||
void WorldPackets::Item::ListInventory::Read()
|
||||
{
|
||||
_worldPacket >> VendorGuid;
|
||||
}
|
||||
|
||||
void WorldPackets::Item::AutoStoreBagItem::Read()
|
||||
{
|
||||
_worldPacket >> SourceBag;
|
||||
_worldPacket >> SourceSlot;
|
||||
_worldPacket >> DestinationBag;
|
||||
}
|
||||
|
||||
WorldPacket const* WorldPackets::Item::EnchantmentLog::Write()
|
||||
{
|
||||
_worldPacket << Target;
|
||||
_worldPacket << Caster;
|
||||
_worldPacket << ItemId;
|
||||
_worldPacket << EnchantId;
|
||||
|
||||
return &_worldPacket;
|
||||
}
|
||||
|
||||
WorldPacket const* WorldPackets::Item::ItemEnchantTimeUpdate::Write()
|
||||
{
|
||||
_worldPacket << ItemGuid;
|
||||
_worldPacket << Slot;
|
||||
_worldPacket << Duration;
|
||||
_worldPacket << PlayerGuid;
|
||||
|
||||
return &_worldPacket;
|
||||
}
|
||||
|
||||
void WorldPackets::Item::WrapItem::Read()
|
||||
{
|
||||
_worldPacket >> GiftBag;
|
||||
_worldPacket >> GiftSlot;
|
||||
_worldPacket >> ItemBag;
|
||||
_worldPacket >> ItemSlot;
|
||||
}
|
||||
|
||||
void WorldPackets::Item::SocketGems::Read()
|
||||
{
|
||||
_worldPacket >> ItemGuid;
|
||||
for (int i = 0; i < MAX_GEM_SOCKETS; ++i)
|
||||
_worldPacket >> GemGuids[i];
|
||||
}
|
||||
|
||||
void WorldPackets::Item::CancelTempEnchantment::Read()
|
||||
{
|
||||
_worldPacket >> EquipmentSlot;
|
||||
}
|
||||
|
||||
void WorldPackets::Item::ItemRefundInfo::Read()
|
||||
{
|
||||
_worldPacket >> ItemGuid;
|
||||
}
|
||||
|
||||
void WorldPackets::Item::ItemRefund::Read()
|
||||
{
|
||||
_worldPacket >> ItemGuid;
|
||||
}
|
||||
@@ -0,0 +1,272 @@
|
||||
/*
|
||||
* 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 ItemPackets_h__
|
||||
#define ItemPackets_h__
|
||||
|
||||
#include "Item.h"
|
||||
#include "ObjectGuid.h"
|
||||
#include "Packet.h"
|
||||
|
||||
namespace WorldPackets
|
||||
{
|
||||
namespace Item
|
||||
{
|
||||
class SplitItem final : public ClientPacket
|
||||
{
|
||||
public:
|
||||
SplitItem(WorldPacket&& packet) : ClientPacket(CMSG_SPLIT_ITEM, std::move(packet)) {}
|
||||
|
||||
void Read() override;
|
||||
|
||||
uint8 SourceBag = 0;
|
||||
uint8 SourceSlot = 0;
|
||||
uint8 DestinationBag = 0;
|
||||
uint8 DestinationSlot = 0;
|
||||
uint32 Count = 0;
|
||||
};
|
||||
|
||||
class SwapInventoryItem final : public ClientPacket
|
||||
{
|
||||
public:
|
||||
SwapInventoryItem(WorldPacket&& packet) : ClientPacket(CMSG_SWAP_INV_ITEM, std::move(packet)) {}
|
||||
|
||||
void Read() override;
|
||||
|
||||
uint8 DestinationSlot = 0;
|
||||
uint8 SourceSlot = 0;
|
||||
};
|
||||
|
||||
class AutoEquipItemSlot final : public ClientPacket
|
||||
{
|
||||
public:
|
||||
AutoEquipItemSlot(WorldPacket&& packet) : ClientPacket(CMSG_AUTOEQUIP_ITEM_SLOT, std::move(packet)) {}
|
||||
|
||||
void Read() override;
|
||||
|
||||
ObjectGuid ItemGuid;
|
||||
uint8 DestinationSlot = 0;
|
||||
};
|
||||
|
||||
class SwapItem final : public ClientPacket
|
||||
{
|
||||
public:
|
||||
SwapItem(WorldPacket&& packet) : ClientPacket(CMSG_SWAP_ITEM, std::move(packet)) {}
|
||||
|
||||
void Read() override;
|
||||
|
||||
uint8 DestinationBag = 0;
|
||||
uint8 DestinationSlot = 0;
|
||||
uint8 SourceBag = 0;
|
||||
uint8 SourceSlot = 0;
|
||||
};
|
||||
|
||||
class AutoEquipItem final : public ClientPacket
|
||||
{
|
||||
public:
|
||||
AutoEquipItem(WorldPacket&& packet) : ClientPacket(CMSG_AUTOEQUIP_ITEM, std::move(packet)) {}
|
||||
|
||||
void Read() override;
|
||||
|
||||
uint8 SourceBag = 0;
|
||||
uint8 SourceSlot = 0;
|
||||
};
|
||||
|
||||
class DestroyItem final : public ClientPacket
|
||||
{
|
||||
public:
|
||||
DestroyItem(WorldPacket&& packet) : ClientPacket(CMSG_DESTROYITEM, std::move(packet)) {}
|
||||
|
||||
void Read() override;
|
||||
|
||||
uint8 Bag = 0;
|
||||
uint8 Slot = 0;
|
||||
uint8 Count = 0;
|
||||
uint8 Data1 = 0;
|
||||
uint8 Data2 = 0;
|
||||
uint8 Data3 = 0;
|
||||
};
|
||||
|
||||
class ReadItem final : public ClientPacket
|
||||
{
|
||||
public:
|
||||
ReadItem(WorldPacket&& packet) : ClientPacket(CMSG_READ_ITEM, std::move(packet)) {}
|
||||
|
||||
void Read() override;
|
||||
|
||||
uint8 Bag = 0;
|
||||
uint8 Slot = 0;
|
||||
};
|
||||
|
||||
class SellItem final : public ClientPacket
|
||||
{
|
||||
public:
|
||||
SellItem(WorldPacket&& packet) : ClientPacket(CMSG_SELL_ITEM, std::move(packet)) {}
|
||||
|
||||
void Read() override;
|
||||
|
||||
ObjectGuid VendorGuid;
|
||||
ObjectGuid ItemGuid;
|
||||
uint32 Count = 0;
|
||||
};
|
||||
|
||||
class BuybackItem final : public ClientPacket
|
||||
{
|
||||
public:
|
||||
BuybackItem(WorldPacket&& packet) : ClientPacket(CMSG_BUYBACK_ITEM, std::move(packet)) {}
|
||||
|
||||
void Read() override;
|
||||
|
||||
ObjectGuid VendorGuid;
|
||||
uint32 Slot = 0;
|
||||
};
|
||||
|
||||
class BuyItemInSlot final : public ClientPacket
|
||||
{
|
||||
public:
|
||||
BuyItemInSlot(WorldPacket&& packet) : ClientPacket(CMSG_BUY_ITEM_IN_SLOT, std::move(packet)) {}
|
||||
|
||||
void Read() override;
|
||||
|
||||
ObjectGuid VendorGuid;
|
||||
uint32 Item = 0;
|
||||
uint32 Slot = 0;
|
||||
ObjectGuid BagGuid;
|
||||
uint8 BagSlot = 0;
|
||||
uint32 Count = 0;
|
||||
};
|
||||
|
||||
class BuyItem final : public ClientPacket
|
||||
{
|
||||
public:
|
||||
BuyItem(WorldPacket&& packet) : ClientPacket(CMSG_BUY_ITEM, std::move(packet)) {}
|
||||
|
||||
void Read() override;
|
||||
|
||||
ObjectGuid VendorGuid;
|
||||
uint32 Item = 0;
|
||||
uint32 Slot = 0;
|
||||
uint32 Count = 0;
|
||||
uint8 Unk = 0;
|
||||
};
|
||||
|
||||
class ListInventory final : public ClientPacket
|
||||
{
|
||||
public:
|
||||
ListInventory(WorldPacket&& packet) : ClientPacket(CMSG_LIST_INVENTORY, std::move(packet)) {}
|
||||
|
||||
void Read() override;
|
||||
|
||||
ObjectGuid VendorGuid;
|
||||
};
|
||||
|
||||
class AutoStoreBagItem final : public ClientPacket
|
||||
{
|
||||
public:
|
||||
AutoStoreBagItem(WorldPacket&& packet) : ClientPacket(CMSG_AUTOSTORE_BAG_ITEM, std::move(packet)) {}
|
||||
|
||||
void Read() override;
|
||||
|
||||
uint8 SourceBag = 0;
|
||||
uint8 SourceSlot = 0;
|
||||
uint8 DestinationBag = 0;
|
||||
};
|
||||
|
||||
class EnchantmentLog final : public ServerPacket
|
||||
{
|
||||
public:
|
||||
EnchantmentLog() : ServerPacket(SMSG_ENCHANTMENTLOG, 8 + 8 + 4 + 4) {}
|
||||
|
||||
WorldPacket const* Write() override;
|
||||
|
||||
PackedGuid Target;
|
||||
PackedGuid Caster;
|
||||
uint32 ItemId = 0;
|
||||
uint32 EnchantId = 0;
|
||||
};
|
||||
|
||||
class ItemEnchantTimeUpdate final : public ServerPacket
|
||||
{
|
||||
public:
|
||||
ItemEnchantTimeUpdate() : ServerPacket(SMSG_ITEM_ENCHANT_TIME_UPDATE, 8 + 4 + 4 + 8) {}
|
||||
|
||||
WorldPacket const* Write() override;
|
||||
|
||||
// last check 2.0.10
|
||||
ObjectGuid ItemGuid;
|
||||
uint32 Slot = 0;
|
||||
uint32 Duration = 0;
|
||||
ObjectGuid PlayerGuid;
|
||||
};
|
||||
|
||||
class WrapItem final : public ClientPacket
|
||||
{
|
||||
public:
|
||||
WrapItem(WorldPacket&& packet) : ClientPacket(CMSG_WRAP_ITEM, std::move(packet)) {}
|
||||
|
||||
void Read() override;
|
||||
|
||||
uint8 GiftBag = 0;
|
||||
uint8 GiftSlot = 0;
|
||||
uint8 ItemBag = 0;
|
||||
uint8 ItemSlot = 0;
|
||||
};
|
||||
|
||||
class SocketGems final : public ClientPacket
|
||||
{
|
||||
public:
|
||||
SocketGems(WorldPacket&& packet) : ClientPacket(CMSG_SOCKET_GEMS, std::move(packet)) {}
|
||||
|
||||
void Read() override;
|
||||
|
||||
ObjectGuid ItemGuid;
|
||||
ObjectGuid GemGuids[MAX_GEM_SOCKETS];
|
||||
};
|
||||
|
||||
class CancelTempEnchantment final : public ClientPacket
|
||||
{
|
||||
public:
|
||||
CancelTempEnchantment(WorldPacket&& packet) : ClientPacket(CMSG_CANCEL_TEMP_ENCHANTMENT, std::move(packet)) {}
|
||||
|
||||
void Read() override;
|
||||
|
||||
uint32 EquipmentSlot = 0;
|
||||
};
|
||||
|
||||
class ItemRefundInfo final : public ClientPacket
|
||||
{
|
||||
public:
|
||||
ItemRefundInfo(WorldPacket&& packet) : ClientPacket(CMSG_ITEM_REFUND_INFO, std::move(packet)) {}
|
||||
|
||||
void Read() override;
|
||||
|
||||
ObjectGuid ItemGuid;
|
||||
};
|
||||
|
||||
class ItemRefund final : public ClientPacket
|
||||
{
|
||||
public:
|
||||
ItemRefund(WorldPacket&& packet) : ClientPacket(CMSG_ITEM_REFUND, std::move(packet)) {}
|
||||
|
||||
void Read() override;
|
||||
|
||||
ObjectGuid ItemGuid;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#endif // ItemPackets_h__
|
||||
@@ -167,6 +167,28 @@ namespace WorldPackets
|
||||
class TimeQuery;
|
||||
class CorpseMapPositionQuery;
|
||||
}
|
||||
|
||||
namespace Item
|
||||
{
|
||||
class SplitItem;
|
||||
class SwapInventoryItem;
|
||||
class AutoEquipItemSlot;
|
||||
class SwapItem;
|
||||
class AutoEquipItem;
|
||||
class DestroyItem;
|
||||
class ReadItem;
|
||||
class SellItem;
|
||||
class BuybackItem;
|
||||
class BuyItemInSlot;
|
||||
class BuyItem;
|
||||
class ListInventory;
|
||||
class AutoStoreBagItem;
|
||||
class WrapItem;
|
||||
class SocketGems;
|
||||
class CancelTempEnchantment;
|
||||
class ItemRefundInfo;
|
||||
class ItemRefund;
|
||||
}
|
||||
}
|
||||
|
||||
enum AccountDataType
|
||||
@@ -830,21 +852,21 @@ public: // opcodes handlers
|
||||
void HandleQueryNextMailTime(WorldPacket& recvData);
|
||||
void HandleCancelChanneling(WorldPacket& recvData);
|
||||
|
||||
void HandleSplitItemOpcode(WorldPacket& recvPacket);
|
||||
void HandleSwapInvItemOpcode(WorldPacket& recvPacket);
|
||||
void HandleDestroyItemOpcode(WorldPacket& recvPacket);
|
||||
void HandleAutoEquipItemOpcode(WorldPacket& recvPacket);
|
||||
void HandleSplitItemOpcode(WorldPackets::Item::SplitItem& packet);
|
||||
void HandleSwapInvItemOpcode(WorldPackets::Item::SwapInventoryItem& packet);
|
||||
void HandleDestroyItemOpcode(WorldPackets::Item::DestroyItem& packet);
|
||||
void HandleAutoEquipItemOpcode(WorldPackets::Item::AutoEquipItem& packet);
|
||||
void HandleItemQuerySingleOpcode(WorldPacket& recvPacket);
|
||||
void HandleSellItemOpcode(WorldPacket& recvPacket);
|
||||
void HandleBuyItemInSlotOpcode(WorldPacket& recvPacket);
|
||||
void HandleBuyItemOpcode(WorldPacket& recvPacket);
|
||||
void HandleListInventoryOpcode(WorldPacket& recvPacket);
|
||||
void HandleAutoStoreBagItemOpcode(WorldPacket& recvPacket);
|
||||
void HandleReadItem(WorldPacket& recvPacket);
|
||||
void HandleAutoEquipItemSlotOpcode(WorldPacket& recvPacket);
|
||||
void HandleSwapItem(WorldPacket& recvPacket);
|
||||
void HandleBuybackItem(WorldPacket& recvPacket);
|
||||
void HandleWrapItemOpcode(WorldPacket& recvPacket);
|
||||
void HandleSellItemOpcode(WorldPackets::Item::SellItem& packet);
|
||||
void HandleBuyItemInSlotOpcode(WorldPackets::Item::BuyItemInSlot& packet);
|
||||
void HandleBuyItemOpcode(WorldPackets::Item::BuyItem& packet);
|
||||
void HandleListInventoryOpcode(WorldPackets::Item::ListInventory& packet);
|
||||
void HandleAutoStoreBagItemOpcode(WorldPackets::Item::AutoStoreBagItem& packet);
|
||||
void HandleReadItem(WorldPackets::Item::ReadItem& packet);
|
||||
void HandleAutoEquipItemSlotOpcode(WorldPackets::Item::AutoEquipItemSlot& packet);
|
||||
void HandleSwapItem(WorldPackets::Item::SwapItem& packet);
|
||||
void HandleBuybackItem(WorldPackets::Item::BuybackItem& packet);
|
||||
void HandleWrapItemOpcode(WorldPackets::Item::WrapItem& packet);
|
||||
|
||||
void HandleAttackSwingOpcode(WorldPacket& recvPacket);
|
||||
void HandleAttackStopOpcode(WorldPacket& recvPacket);
|
||||
@@ -1034,12 +1056,12 @@ public: // opcodes handlers
|
||||
void HandleRequestPetInfo(WorldPackets::Pet::RequestPetInfo& packet);
|
||||
|
||||
// Socket gem
|
||||
void HandleSocketOpcode(WorldPacket& recvData);
|
||||
void HandleSocketOpcode(WorldPackets::Item::SocketGems& packet);
|
||||
|
||||
void HandleCancelTempEnchantmentOpcode(WorldPacket& recvData);
|
||||
void HandleCancelTempEnchantmentOpcode(WorldPackets::Item::CancelTempEnchantment& packet);
|
||||
|
||||
void HandleItemRefundInfoRequest(WorldPacket& recvData);
|
||||
void HandleItemRefund(WorldPacket& recvData);
|
||||
void HandleItemRefundInfoRequest(WorldPackets::Item::ItemRefundInfo& packet);
|
||||
void HandleItemRefund(WorldPackets::Item::ItemRefund& packet);
|
||||
|
||||
void HandleChannelVoiceOnOpcode(WorldPacket& recvData);
|
||||
void HandleVoiceSessionEnableOpcode(WorldPacket& recvData);
|
||||
|
||||
@@ -5143,6 +5143,14 @@ void SpellMgr::LoadSpellInfoCorrections()
|
||||
spellInfo->DurationEntry = sSpellDurationStore.LookupEntry(21); // -1
|
||||
});
|
||||
|
||||
ApplySpellFix({
|
||||
28032, // Zap Crystal
|
||||
28056, // Zap Crystal Corpse
|
||||
}, [](SpellInfo* spellInfo)
|
||||
{
|
||||
spellInfo->AttributesEx3 |= SPELL_ATTR3_ALWAYS_HIT;
|
||||
});
|
||||
|
||||
for (uint32 i = 0; i < GetSpellInfoStoreSize(); ++i)
|
||||
{
|
||||
SpellInfo* spellInfo = mSpellInfoMap[i];
|
||||
|
||||
@@ -114,7 +114,6 @@ public:
|
||||
virtual void ResetEventSeasonalQuests(uint16 event_id) = 0;
|
||||
[[nodiscard]] virtual std::string const& GetRealmName() const = 0;
|
||||
virtual void SetRealmName(std::string name) = 0;
|
||||
virtual void RemoveOldCorpses() = 0;
|
||||
virtual SQLQueryHolderCallback& AddQueryHolderCallback(SQLQueryHolderCallback&& callback) = 0;
|
||||
};
|
||||
|
||||
|
||||
@@ -889,8 +889,6 @@ void World::SetInitialWorldSettings()
|
||||
_timers[WUPDATE_UPTIME].SetInterval(getIntConfig(CONFIG_UPTIME_UPDATE)*MINUTE * IN_MILLISECONDS);
|
||||
//Update "uptime" table based on configuration entry in minutes.
|
||||
|
||||
_timers[WUPDATE_CORPSES].SetInterval(20 * MINUTE * IN_MILLISECONDS);
|
||||
//erase corpses every 20 minutes
|
||||
_timers[WUPDATE_CLEANDB].SetInterval(getIntConfig(CONFIG_LOGDB_CLEARINTERVAL)*MINUTE * IN_MILLISECONDS);
|
||||
// clean logs table every 14 days by default
|
||||
_timers[WUPDATE_AUTOBROADCAST].SetInterval(getIntConfig(CONFIG_AUTOBROADCAST_INTERVAL));
|
||||
@@ -1281,18 +1279,6 @@ void World::Update(uint32 diff)
|
||||
LoginDatabase.Execute(stmt);
|
||||
}
|
||||
|
||||
///- Erase corpses once every 20 minutes
|
||||
if (_timers[WUPDATE_CORPSES].Passed())
|
||||
{
|
||||
METRIC_TIMER("world_update_time", METRIC_TAG("type", "Remove old corpses"));
|
||||
_timers[WUPDATE_CORPSES].Reset();
|
||||
|
||||
sMapMgr->DoForAllMaps([](Map* map)
|
||||
{
|
||||
map->RemoveOldCorpses();
|
||||
});
|
||||
}
|
||||
|
||||
///- Process Game events when necessary
|
||||
if (_timers[WUPDATE_EVENTS].Passed())
|
||||
{
|
||||
@@ -1835,11 +1821,6 @@ SQLQueryHolderCallback& World::AddQueryHolderCallback(SQLQueryHolderCallback&& c
|
||||
return _queryHolderProcessor.AddCallback(std::move(callback));
|
||||
}
|
||||
|
||||
void World::RemoveOldCorpses()
|
||||
{
|
||||
_timers[WUPDATE_CORPSES].SetCurrent(_timers[WUPDATE_CORPSES].GetInterval());
|
||||
}
|
||||
|
||||
bool World::IsPvPRealm() const
|
||||
{
|
||||
return getIntConfig(CONFIG_GAME_TYPE) == REALM_TYPE_PVP || getIntConfig(CONFIG_GAME_TYPE) == REALM_TYPE_RPPVP || getIntConfig(CONFIG_GAME_TYPE) == REALM_TYPE_FFA_PVP;
|
||||
|
||||
@@ -60,7 +60,6 @@ enum WorldTimers
|
||||
{
|
||||
WUPDATE_WEATHERS,
|
||||
WUPDATE_UPTIME,
|
||||
WUPDATE_CORPSES,
|
||||
WUPDATE_EVENTS,
|
||||
WUPDATE_CLEANDB,
|
||||
WUPDATE_AUTOBROADCAST,
|
||||
@@ -244,8 +243,6 @@ public:
|
||||
[[nodiscard]] std::string const& GetRealmName() const override { return _realmName; } // pussywizard
|
||||
void SetRealmName(std::string name) override { _realmName = name; } // pussywizard
|
||||
|
||||
void RemoveOldCorpses() override;
|
||||
|
||||
protected:
|
||||
void _UpdateGameTime();
|
||||
// callback for UpdateRealmCharacters
|
||||
|
||||
@@ -1072,8 +1072,8 @@ std::string WorldState::GetScourgeInvasionPrintout()
|
||||
{
|
||||
TimePoint tp = m_siData.m_timers[timerId];
|
||||
std::string timerStr;
|
||||
if (tp.time_since_epoch().count() == 0)
|
||||
timerStr = "0 (not set)";
|
||||
if (tp == TimePoint())
|
||||
timerStr = "Not set";
|
||||
else if (tp <= now)
|
||||
timerStr = "Elapsed";
|
||||
else
|
||||
@@ -1420,10 +1420,15 @@ void ScourgeInvasionData::Reset()
|
||||
std::string ScourgeInvasionData::GetData()
|
||||
{
|
||||
std::string output = std::to_string(m_state) + " ";
|
||||
for (auto& timer : m_timers)
|
||||
output += std::to_string(timer.time_since_epoch().count()) + " ";
|
||||
for (TimePoint& timer : m_timers)
|
||||
{
|
||||
if (timer == TimePoint())
|
||||
output += "0 ";
|
||||
else
|
||||
output += std::to_string(std::chrono::duration_cast<std::chrono::milliseconds>(timer.time_since_epoch()).count()) + " ";
|
||||
}
|
||||
output += std::to_string(m_battlesWon) + " " + std::to_string(m_lastAttackZone) + " ";
|
||||
for (auto& remaining : m_remaining)
|
||||
for (uint32& remaining : m_remaining)
|
||||
output += std::to_string(remaining) + " ";
|
||||
return output;
|
||||
}
|
||||
|
||||
@@ -99,7 +99,8 @@ public:
|
||||
{ "objectcount", HandleDebugObjectCountCommand, SEC_ADMINISTRATOR, Console::Yes},
|
||||
{ "dummy", HandleDebugDummyCommand, SEC_ADMINISTRATOR, Console::No },
|
||||
{ "mapdata", HandleDebugMapDataCommand, SEC_ADMINISTRATOR, Console::No },
|
||||
{ "boundary", HandleDebugBoundaryCommand, SEC_ADMINISTRATOR, Console::No }
|
||||
{ "boundary", HandleDebugBoundaryCommand, SEC_ADMINISTRATOR, Console::No },
|
||||
{ "visibilitydata", HandleDebugVisibilityDataCommand, SEC_ADMINISTRATOR, Console::No }
|
||||
};
|
||||
static ChatCommandTable commandTable =
|
||||
{
|
||||
@@ -1403,6 +1404,36 @@ public:
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool HandleDebugVisibilityDataCommand(ChatHandler* handler)
|
||||
{
|
||||
Player* player = handler->GetPlayer();
|
||||
if (!player)
|
||||
return false;
|
||||
|
||||
std::array<uint32, NUM_CLIENT_OBJECT_TYPES> objectByTypeCount = {};
|
||||
|
||||
ObjectVisibilityContainer const& objectVisibilityContainer = player->GetObjectVisibilityContainer();
|
||||
for (auto const& kvPair : *objectVisibilityContainer.GetVisibleWorldObjectsMap())
|
||||
{
|
||||
WorldObject const* obj = kvPair.second;
|
||||
++objectByTypeCount[obj->GetTypeId()];
|
||||
}
|
||||
|
||||
uint32 zoneWideVisibleObjectsInZone = 0;
|
||||
if (ZoneWideVisibleWorldObjectsSet const* farVisibleSet = player->GetMap()->GetZoneWideVisibleWorldObjectsForZone(player->GetZoneId()))
|
||||
zoneWideVisibleObjectsInZone = farVisibleSet->size();
|
||||
|
||||
handler->PSendSysMessage("Visibility Range: {}", player->GetVisibilityRange());
|
||||
handler->PSendSysMessage("Visible Creatures: {}", objectByTypeCount[TYPEID_UNIT]);
|
||||
handler->PSendSysMessage("Visible Players: {}", objectByTypeCount[TYPEID_PLAYER]);
|
||||
handler->PSendSysMessage("Visible GameObjects: {}", objectByTypeCount[TYPEID_GAMEOBJECT]);
|
||||
handler->PSendSysMessage("Visible DynamicObjects: {}", objectByTypeCount[TYPEID_DYNAMICOBJECT]);
|
||||
handler->PSendSysMessage("Visible Corpses: {}", objectByTypeCount[TYPEID_CORPSE]);
|
||||
handler->PSendSysMessage("Players we are visible to: {}", objectVisibilityContainer.GetVisiblePlayersMap().size());
|
||||
handler->PSendSysMessage("Zone wide visible objects in zone: {}", zoneWideVisibleObjectsInZone);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
void AddSC_debug_commandscript()
|
||||
|
||||
@@ -71,8 +71,6 @@ public:
|
||||
if (counter == 0)
|
||||
handler->SendSysMessage(LANG_NOEVENTFOUND);
|
||||
|
||||
handler->SetSentErrorMessage(true);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#include "GameTime.h"
|
||||
#include "GitRevision.h"
|
||||
#include "Log.h"
|
||||
#include "MapMgr.h"
|
||||
#include "ModuleMgr.h"
|
||||
#include "MotdMgr.h"
|
||||
#include "MySQLThreading.h"
|
||||
@@ -101,7 +102,10 @@ public:
|
||||
// Triggering corpses expire check in world
|
||||
static bool HandleServerCorpsesCommand(ChatHandler* /*handler*/)
|
||||
{
|
||||
sWorld->RemoveOldCorpses();
|
||||
sMapMgr->DoForAllMaps([](Map* map)
|
||||
{
|
||||
map->RemoveOldCorpses();
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -1001,20 +1001,25 @@ class spell_chapter2_persuasive_strike : public SpellScript
|
||||
creature->AI()->Talk(SAY_PERSUADED3, 24s);
|
||||
creature->AI()->Talk(SAY_PERSUADED4, 32s);
|
||||
|
||||
creature->m_Events.AddEventAtOffset([creature, player]
|
||||
ObjectGuid playerGuid = player->GetGUID();
|
||||
|
||||
creature->m_Events.AddEventAtOffset([creature, playerGuid]
|
||||
{
|
||||
if (player)
|
||||
sCreatureTextMgr->SendChat(creature, SAY_PERSUADED5, nullptr, CHAT_MSG_ADDON, LANG_ADDON, TEXT_RANGE_NORMAL, 0, TEAM_NEUTRAL, false, player);
|
||||
if (Player* caster = ObjectAccessor::GetPlayer(*creature, playerGuid))
|
||||
sCreatureTextMgr->SendChat(creature, SAY_PERSUADED5, nullptr, CHAT_MSG_ADDON, LANG_ADDON, TEXT_RANGE_NORMAL, 0, TEAM_NEUTRAL, false, caster);
|
||||
}, 40s);
|
||||
|
||||
creature->m_Events.AddEventAtOffset([creature, player]
|
||||
creature->m_Events.AddEventAtOffset([creature, playerGuid]
|
||||
{
|
||||
creature->AI()->Talk(SAY_PERSUADED6);
|
||||
if (player)
|
||||
|
||||
if (Player* caster = ObjectAccessor::GetPlayer(*creature, playerGuid))
|
||||
{
|
||||
Unit::Kill(player, creature);
|
||||
player->GroupEventHappens(QUEST_HOW_TO_WIN_FRIENDS, creature);
|
||||
Unit::Kill(caster, creature);
|
||||
caster->GroupEventHappens(QUEST_HOW_TO_WIN_FRIENDS, creature);
|
||||
}
|
||||
else
|
||||
creature->KillSelf();
|
||||
}, 48s);
|
||||
}
|
||||
else
|
||||
|
||||
@@ -26,14 +26,17 @@
|
||||
|
||||
enum ANData
|
||||
{
|
||||
DATA_KRIKTHIR_THE_GATEWATCHER_EVENT = 0,
|
||||
DATA_HADRONOX_EVENT = 1,
|
||||
DATA_KRIKTHIR = 0,
|
||||
DATA_HADRONOX = 1,
|
||||
DATA_ANUBARAK_EVENT = 2,
|
||||
MAX_ENCOUNTERS = 3
|
||||
};
|
||||
|
||||
enum ANIds
|
||||
{
|
||||
NPC_WATCHER_NARJIL = 28729,
|
||||
NPC_WATCHER_GASHRA = 28730,
|
||||
NPC_WATCHER_SILTHIK = 28731,
|
||||
NPC_SKITTERING_SWARMER = 28735,
|
||||
NPC_SKITTERING_INFECTIOR = 28736,
|
||||
NPC_KRIKTHIR_THE_GATEWATCHER = 28684,
|
||||
|
||||
@@ -84,7 +84,7 @@ public:
|
||||
|
||||
struct boss_hadronoxAI : public BossAI
|
||||
{
|
||||
boss_hadronoxAI(Creature* creature) : BossAI(creature, DATA_HADRONOX_EVENT)
|
||||
boss_hadronoxAI(Creature* creature) : BossAI(creature, DATA_HADRONOX)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -99,7 +99,7 @@ public:
|
||||
{
|
||||
if (param == ACTION_START_EVENT)
|
||||
{
|
||||
instance->SetBossState(DATA_HADRONOX_EVENT, IN_PROGRESS);
|
||||
instance->SetBossState(DATA_HADRONOX, IN_PROGRESS);
|
||||
me->setActive(true);
|
||||
events.ScheduleEvent(EVENT_HADRONOX_MOVE1, 20s);
|
||||
events.ScheduleEvent(EVENT_HADRONOX_MOVE2, 40s);
|
||||
@@ -342,7 +342,7 @@ public:
|
||||
PreventDefaultAction();
|
||||
Unit* owner = GetUnitOwner();
|
||||
if (InstanceScript* instance = owner->GetInstanceScript())
|
||||
if (instance->GetBossState(DATA_HADRONOX_EVENT) != DONE)
|
||||
if (!instance->IsBossDone(DATA_HADRONOX))
|
||||
{
|
||||
if (!owner->HasAura(SPELL_WEB_FRONT_DOORS))
|
||||
owner->CastSpell(owner, _spellEntry, true);
|
||||
|
||||
+79
-96
@@ -29,24 +29,8 @@ enum Spells
|
||||
SPELL_FRENZY = 28747
|
||||
};
|
||||
|
||||
enum Events
|
||||
{
|
||||
EVENT_KRIK_START_WAVE = 1,
|
||||
EVENT_KRIK_SUMMON = 2,
|
||||
EVENT_KRIK_MIND_FLAY = 3,
|
||||
EVENT_KRIK_CURSE = 4,
|
||||
EVENT_KRIK_HEALTH_CHECK = 5,
|
||||
EVENT_KRIK_ENTER_COMBAT = 6,
|
||||
EVENT_KILL_TALK = 7,
|
||||
EVENT_CALL_ADDS = 8,
|
||||
EVENT_KRIK_CHECK_EVADE = 9
|
||||
};
|
||||
|
||||
enum Npcs
|
||||
{
|
||||
NPC_WATCHER_NARJIL = 28729,
|
||||
NPC_WATCHER_GASHRA = 28730,
|
||||
NPC_WATCHER_SILTHIK = 28731,
|
||||
NPC_WARRIOR = 28732,
|
||||
NPC_SKIRMISHER = 28734,
|
||||
NPC_SHADOWCASTER = 28733
|
||||
@@ -62,6 +46,12 @@ enum Yells
|
||||
SAY_SEND_GROUP = 5
|
||||
};
|
||||
|
||||
enum MiscActions
|
||||
{
|
||||
ACTION_MINION_ENGAGED = 1,
|
||||
GROUP_SWARM = 1
|
||||
};
|
||||
|
||||
class boss_krik_thir : public CreatureScript
|
||||
{
|
||||
public:
|
||||
@@ -69,18 +59,21 @@ public:
|
||||
|
||||
struct boss_krik_thirAI : public BossAI
|
||||
{
|
||||
boss_krik_thirAI(Creature* creature) : BossAI(creature, DATA_KRIKTHIR_THE_GATEWATCHER_EVENT)
|
||||
boss_krik_thirAI(Creature* creature) : BossAI(creature, DATA_KRIKTHIR)
|
||||
{
|
||||
_initTalk = false;
|
||||
}
|
||||
_canTalk = true;
|
||||
_minionInCombat = false;
|
||||
|
||||
EventMap events2;
|
||||
bool _initTalk;
|
||||
scheduler.SetValidator([this]
|
||||
{
|
||||
return !me->HasUnitState(UNIT_STATE_CASTING);
|
||||
});
|
||||
}
|
||||
|
||||
void Reset() override
|
||||
{
|
||||
BossAI::Reset();
|
||||
events2.Reset();
|
||||
|
||||
me->SummonCreature(NPC_WATCHER_NARJIL, 511.8f, 666.493f, 776.278f, 0.977f, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 30000);
|
||||
me->SummonCreature(NPC_SHADOWCASTER, 511.63f, 672.44f, 775.71f, 0.90f, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 30000);
|
||||
@@ -91,6 +84,22 @@ public:
|
||||
me->SummonCreature(NPC_WATCHER_SILTHIK, 543.826f, 665.123f, 776.245f, 1.55f, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 30000);
|
||||
me->SummonCreature(NPC_SKIRMISHER, 547.5f, 669.96f, 776.1f, 2.3f, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 30000);
|
||||
me->SummonCreature(NPC_SHADOWCASTER, 548.64f, 664.27f, 776.74f, 1.77f, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 30000);
|
||||
|
||||
ScheduleHealthCheckEvent(25, [&] {
|
||||
DoCastSelf(SPELL_FRENZY, true);
|
||||
|
||||
scheduler.CancelGroup(GROUP_SWARM);
|
||||
|
||||
scheduler.Schedule(7s, 17s, GROUP_SWARM, [&](TaskContext context)
|
||||
{
|
||||
Talk(SAY_SWARM);
|
||||
DoCastAOE(SPELL_SWARM);
|
||||
context.Repeat(20s);
|
||||
});
|
||||
});
|
||||
|
||||
_canTalk = true;
|
||||
_minionInCombat = false;
|
||||
}
|
||||
|
||||
void MoveInLineOfSight(Unit* who) override
|
||||
@@ -103,21 +112,25 @@ public:
|
||||
_initTalk = true;
|
||||
Talk(SAY_PREFIGHT);
|
||||
}
|
||||
}
|
||||
|
||||
if (events.Empty() && who->GetPositionZ() < 785.0f)
|
||||
void DoAction(int32 actionId) override
|
||||
{
|
||||
if (actionId == ACTION_MINION_ENGAGED && !_minionInCombat)
|
||||
{
|
||||
events2.ScheduleEvent(EVENT_KRIK_START_WAVE, 10s);
|
||||
events2.ScheduleEvent(EVENT_KRIK_START_WAVE, 40s);
|
||||
events2.ScheduleEvent(EVENT_KRIK_START_WAVE, 70s);
|
||||
events2.ScheduleEvent(EVENT_KRIK_ENTER_COMBAT, 100s);
|
||||
events2.ScheduleEvent(EVENT_KRIK_CHECK_EVADE, 5s);
|
||||
_minionInCombat = true;
|
||||
|
||||
events.ScheduleEvent(EVENT_KRIK_HEALTH_CHECK, 1s);
|
||||
events.ScheduleEvent(EVENT_KRIK_MIND_FLAY, 13s);
|
||||
events.ScheduleEvent(EVENT_KRIK_SUMMON, 17s);
|
||||
events.ScheduleEvent(EVENT_KRIK_CURSE, 8s);
|
||||
events.ScheduleEvent(EVENT_CALL_ADDS, 1s);
|
||||
me->setActive(true);
|
||||
for (Seconds const& timer : { 10s, 40s, 70s })
|
||||
{
|
||||
me->m_Events.AddEventAtOffset([this] {
|
||||
me->CastCustomSpell(SPELL_SUBBOSS_AGGRO_TRIGGER, SPELLVALUE_MAX_TARGETS, 1, me, true);
|
||||
Talk(SAY_SEND_GROUP);
|
||||
}, timer);
|
||||
}
|
||||
|
||||
me->m_Events.AddEventAtOffset([this] {
|
||||
me->SetInCombatWithZone();
|
||||
}, 100s);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -132,7 +145,28 @@ public:
|
||||
{
|
||||
BossAI::JustEngagedWith(who);
|
||||
Talk(SAY_AGGRO);
|
||||
events2.Reset();
|
||||
|
||||
me->m_Events.KillAllEvents(false);
|
||||
|
||||
scheduler.Schedule(8s, 14s, [&](TaskContext context)
|
||||
{
|
||||
DoCastVictim(SPELL_MIND_FLAY);
|
||||
if (!IsInFrenzy())
|
||||
context.Repeat(8s, 14s);
|
||||
else
|
||||
context.Repeat(5s, 9s);
|
||||
}).Schedule(10s, 13s, GROUP_SWARM, [&](TaskContext context)
|
||||
{
|
||||
Talk(SAY_SWARM);
|
||||
DoCastAOE(SPELL_SWARM);
|
||||
context.Repeat(26s, 30s);
|
||||
});
|
||||
|
||||
ScheduleTimedEvent(27s, 35s, [&] {
|
||||
DoCastRandomTarget(SPELL_CURSE_OF_FATIGUE);
|
||||
}, 27s, 35s);
|
||||
|
||||
summons.DoZoneInCombat();
|
||||
}
|
||||
|
||||
void JustDied(Unit* killer) override
|
||||
@@ -141,12 +175,15 @@ public:
|
||||
Talk(SAY_DEATH);
|
||||
}
|
||||
|
||||
void KilledUnit(Unit* ) override
|
||||
void KilledUnit(Unit* /*victim*/) override
|
||||
{
|
||||
if (events.GetNextEventTime(EVENT_KILL_TALK) == 0)
|
||||
if (_canTalk)
|
||||
{
|
||||
_canTalk = false;
|
||||
Talk(SAY_SLAY);
|
||||
events.ScheduleEvent(EVENT_KILL_TALK, 6s);
|
||||
me->m_Events.AddEventAtOffset([&] {
|
||||
_canTalk = true;
|
||||
}, 6s);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -161,66 +198,12 @@ public:
|
||||
summons.Despawn(summon);
|
||||
}
|
||||
|
||||
void UpdateAI(uint32 diff) override
|
||||
{
|
||||
events2.Update(diff);
|
||||
switch (events2.ExecuteEvent())
|
||||
{
|
||||
case EVENT_KRIK_START_WAVE:
|
||||
me->CastCustomSpell(SPELL_SUBBOSS_AGGRO_TRIGGER, SPELLVALUE_MAX_TARGETS, 1, me, true);
|
||||
Talk(SAY_SEND_GROUP);
|
||||
break;
|
||||
case EVENT_KRIK_ENTER_COMBAT:
|
||||
me->SetInCombatWithZone();
|
||||
break;
|
||||
case EVENT_KRIK_CHECK_EVADE:
|
||||
if (!SelectTargetFromPlayerList(100.0f))
|
||||
{
|
||||
EnterEvadeMode();
|
||||
return;
|
||||
}
|
||||
events2.ScheduleEvent(EVENT_KRIK_CHECK_EVADE, 5s);
|
||||
break;
|
||||
}
|
||||
private:
|
||||
bool _initTalk;
|
||||
bool _canTalk;
|
||||
bool _minionInCombat;
|
||||
|
||||
if (!UpdateVictim())
|
||||
return;
|
||||
|
||||
events.Update(diff);
|
||||
if (me->HasUnitState(UNIT_STATE_CASTING))
|
||||
return;
|
||||
|
||||
switch (events.ExecuteEvent())
|
||||
{
|
||||
case EVENT_KRIK_HEALTH_CHECK:
|
||||
if (HealthBelowPct(10))
|
||||
{
|
||||
me->CastSpell(me, SPELL_FRENZY, true);
|
||||
break;
|
||||
}
|
||||
events.ScheduleEvent(EVENT_KRIK_HEALTH_CHECK, 1s);
|
||||
break;
|
||||
case EVENT_KRIK_SUMMON:
|
||||
Talk(SAY_SWARM);
|
||||
me->CastSpell(me, SPELL_SWARM, false);
|
||||
events.ScheduleEvent(EVENT_KRIK_SUMMON, 20s);
|
||||
break;
|
||||
case EVENT_KRIK_MIND_FLAY:
|
||||
me->CastSpell(me->GetVictim(), SPELL_MIND_FLAY, false);
|
||||
events.ScheduleEvent(EVENT_KRIK_MIND_FLAY, 15s);
|
||||
break;
|
||||
case EVENT_KRIK_CURSE:
|
||||
if (Unit* target = SelectTarget(SelectTargetMethod::Random, 0, 100, true))
|
||||
me->CastSpell(target, SPELL_CURSE_OF_FATIGUE, true);
|
||||
events.ScheduleEvent(EVENT_KRIK_CURSE, 10s);
|
||||
break;
|
||||
case EVENT_CALL_ADDS:
|
||||
summons.DoZoneInCombat();
|
||||
break;
|
||||
}
|
||||
|
||||
DoMeleeAttackIfReady();
|
||||
}
|
||||
[[nodiscard]] bool IsInFrenzy() const { return me->HasAura(SPELL_FRENZY); }
|
||||
};
|
||||
|
||||
CreatureAI* GetAI(Creature* creature) const override
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
|
||||
DoorData const doorData[] =
|
||||
{
|
||||
{ GO_KRIKTHIR_DOORS, DATA_KRIKTHIR_THE_GATEWATCHER_EVENT, DOOR_TYPE_PASSAGE },
|
||||
{ GO_KRIKTHIR_DOORS, DATA_KRIKTHIR, DOOR_TYPE_PASSAGE },
|
||||
{ GO_ANUBARAK_DOORS1, DATA_ANUBARAK_EVENT, DOOR_TYPE_ROOM },
|
||||
{ GO_ANUBARAK_DOORS2, DATA_ANUBARAK_EVENT, DOOR_TYPE_ROOM },
|
||||
{ GO_ANUBARAK_DOORS3, DATA_ANUBARAK_EVENT, DOOR_TYPE_ROOM },
|
||||
@@ -34,15 +34,25 @@ DoorData const doorData[] =
|
||||
|
||||
ObjectData const creatureData[] =
|
||||
{
|
||||
{ NPC_KRIKTHIR_THE_GATEWATCHER, DATA_KRIKTHIR_THE_GATEWATCHER_EVENT },
|
||||
{ NPC_HADRONOX, DATA_HADRONOX_EVENT },
|
||||
{ 0, 0 }
|
||||
{ NPC_KRIKTHIR_THE_GATEWATCHER, DATA_KRIKTHIR },
|
||||
{ NPC_HADRONOX, DATA_HADRONOX },
|
||||
{ 0, 0 }
|
||||
};
|
||||
|
||||
ObjectData const summonData[] =
|
||||
{
|
||||
{ NPC_SKITTERING_SWARMER, DATA_KRIKTHIR },
|
||||
{ NPC_SKITTERING_INFECTIOR, DATA_KRIKTHIR },
|
||||
{ NPC_ANUB_AR_CHAMPION, DATA_HADRONOX },
|
||||
{ NPC_ANUB_AR_NECROMANCER, DATA_HADRONOX },
|
||||
{ NPC_ANUB_AR_CRYPTFIEND, DATA_HADRONOX },
|
||||
{ 0, 0 }
|
||||
};
|
||||
|
||||
BossBoundaryData const boundaries =
|
||||
{
|
||||
{ DATA_KRIKTHIR_THE_GATEWATCHER_EVENT, new RectangleBoundary(400.0f, 580.0f, 623.5f, 810.0f) },
|
||||
{ DATA_HADRONOX_EVENT, new ZRangeBoundary(666.0f, 776.0f) },
|
||||
{ DATA_KRIKTHIR, new RectangleBoundary(400.0f, 580.0f, 623.5f, 810.0f) },
|
||||
{ DATA_HADRONOX, new ZRangeBoundary(666.0f, 776.0f) },
|
||||
{ DATA_ANUBARAK_EVENT, new CircleBoundary(Position(550.6178f, 253.5917f), 26.0f) }
|
||||
};
|
||||
|
||||
@@ -60,52 +70,14 @@ public:
|
||||
LoadBossBoundaries(boundaries);
|
||||
LoadDoorData(doorData);
|
||||
LoadObjectData(creatureData, nullptr);
|
||||
LoadSummonData(summonData);
|
||||
};
|
||||
|
||||
void OnCreatureCreate(Creature* creature) override
|
||||
void OnCreatureEvade(Creature* creature) override
|
||||
{
|
||||
switch (creature->GetEntry())
|
||||
{
|
||||
case NPC_SKITTERING_SWARMER:
|
||||
case NPC_SKITTERING_INFECTIOR:
|
||||
if (Creature* krikthir = GetCreature((DATA_KRIKTHIR_THE_GATEWATCHER_EVENT)))
|
||||
krikthir->AI()->JustSummoned(creature);
|
||||
break;
|
||||
case NPC_ANUB_AR_CHAMPION:
|
||||
case NPC_ANUB_AR_NECROMANCER:
|
||||
case NPC_ANUB_AR_CRYPTFIEND:
|
||||
if (Creature* hadronox = GetCreature(DATA_HADRONOX_EVENT))
|
||||
hadronox->AI()->JustSummoned(creature);
|
||||
break;
|
||||
}
|
||||
|
||||
InstanceScript::OnCreatureCreate(creature);
|
||||
}
|
||||
|
||||
void OnGameObjectCreate(GameObject* go) override
|
||||
{
|
||||
switch (go->GetEntry())
|
||||
{
|
||||
case GO_KRIKTHIR_DOORS:
|
||||
case GO_ANUBARAK_DOORS1:
|
||||
case GO_ANUBARAK_DOORS2:
|
||||
case GO_ANUBARAK_DOORS3:
|
||||
AddDoor(go);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void OnGameObjectRemove(GameObject* go) override
|
||||
{
|
||||
switch (go->GetEntry())
|
||||
{
|
||||
case GO_KRIKTHIR_DOORS:
|
||||
case GO_ANUBARAK_DOORS1:
|
||||
case GO_ANUBARAK_DOORS2:
|
||||
case GO_ANUBARAK_DOORS3:
|
||||
RemoveDoor(go);
|
||||
break;
|
||||
}
|
||||
if (creature->EntryEquals(NPC_WATCHER_NARJIL, NPC_WATCHER_GASHRA, NPC_WATCHER_SILTHIK))
|
||||
if (Creature* krikthir = GetCreature(DATA_KRIKTHIR))
|
||||
krikthir->AI()->EnterEvadeMode();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -75,8 +75,6 @@ enum DrakeGiverTexts
|
||||
class npc_oculus_drakegiver : public CreatureScript
|
||||
{
|
||||
public:
|
||||
std::unordered_map<ObjectGuid, bool>openedMenu;
|
||||
|
||||
npc_oculus_drakegiver() : CreatureScript("npc_oculus_drakegiver") { }
|
||||
|
||||
CreatureAI* GetAI(Creature* creature) const override
|
||||
@@ -193,20 +191,8 @@ public:
|
||||
SendGossipMenuFor(player, GOSSIP_TEXTID_VERDISA1, creature->GetGUID());
|
||||
break;
|
||||
case NPC_BELGARISTRASZ:
|
||||
if (HAS_ESSENCE(player))
|
||||
{
|
||||
openedMenu[player->GetGUID()] = true;
|
||||
}
|
||||
|
||||
if (!openedMenu[player->GetGUID()])
|
||||
{
|
||||
AddGossipItemFor(player, 9708, 0, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF);
|
||||
SendGossipMenuFor(player, GOSSIP_TEXTID_DRAKES, creature->GetGUID());
|
||||
}
|
||||
else
|
||||
{
|
||||
OnGossipSelect(player, creature, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF);
|
||||
}
|
||||
AddGossipItemFor(player, 9708, 0, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF);
|
||||
SendGossipMenuFor(player, GOSSIP_TEXTID_DRAKES, creature->GetGUID());
|
||||
break;
|
||||
case NPC_ETERNOS:
|
||||
AddGossipItemFor(player, 9574, 0, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF);
|
||||
@@ -277,7 +263,6 @@ public:
|
||||
switch (uiAction)
|
||||
{
|
||||
case GOSSIP_ACTION_INFO_DEF:
|
||||
openedMenu[player->GetGUID()] = true;
|
||||
if (player->HasItemCount(ITEM_AMBER_ESSENCE))
|
||||
{
|
||||
AddGossipItemFor(player, 9575, 1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1);
|
||||
|
||||
@@ -2124,6 +2124,25 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
// 45612 - Necropolis Beam
|
||||
class spell_necropolis_beam: public SpellScript
|
||||
{
|
||||
PrepareSpellScript(spell_necropolis_beam);
|
||||
|
||||
void SetDest(SpellDestination& dest)
|
||||
{
|
||||
Unit* caster = GetCaster();
|
||||
float floorZ = caster->GetMapHeight(caster->GetPositionX(), caster->GetPositionY(), caster->GetPositionZ());
|
||||
if (floorZ > INVALID_HEIGHT)
|
||||
dest._position.m_positionZ = floorZ;
|
||||
}
|
||||
|
||||
void Register() override
|
||||
{
|
||||
OnDestinationTargetSelect += SpellDestinationTargetSelectFn(spell_necropolis_beam::SetDest, EFFECT_0, TARGET_DEST_CASTER);
|
||||
}
|
||||
};
|
||||
|
||||
void AddSC_borean_tundra()
|
||||
{
|
||||
RegisterSpellScript(spell_q11919_q11940_drake_hunt_aura);
|
||||
@@ -2148,4 +2167,5 @@ void AddSC_borean_tundra()
|
||||
RegisterSpellScript(spell_q11719_bloodspore_ruination_45997);
|
||||
new npc_bloodmage_laurith();
|
||||
RegisterCreatureAI(npc_jenny);
|
||||
RegisterSpellScript(spell_necropolis_beam);
|
||||
}
|
||||
|
||||
@@ -2240,6 +2240,27 @@ class spell_dragonblight_corrosive_spit : public AuraScript
|
||||
}
|
||||
};
|
||||
|
||||
// 48297 - Hand Over Reins
|
||||
enum HandOverReins
|
||||
{
|
||||
SPELL_ONSLAUGHT_RIDING_CROP = 48290
|
||||
};
|
||||
|
||||
class spell_handover_reins : public SpellScript
|
||||
{
|
||||
PrepareSpellScript(spell_handover_reins);
|
||||
|
||||
void HandleScriptEffect(SpellEffIndex /*effIndex*/)
|
||||
{
|
||||
GetCaster()->RemoveAura(SPELL_ONSLAUGHT_RIDING_CROP);
|
||||
}
|
||||
|
||||
void Register() override
|
||||
{
|
||||
OnEffectHitTarget += SpellEffectFn(spell_handover_reins::HandleScriptEffect, EFFECT_1, SPELL_EFFECT_SCRIPT_EFFECT);
|
||||
}
|
||||
};
|
||||
|
||||
void AddSC_dragonblight()
|
||||
{
|
||||
new npc_conversing_with_the_depths_trigger();
|
||||
@@ -2267,4 +2288,5 @@ void AddSC_dragonblight()
|
||||
RegisterSpellScript(spell_q12096_q12092_bark);
|
||||
new npc_torturer_lecraft();
|
||||
RegisterSpellScript(spell_dragonblight_corrosive_spit);
|
||||
RegisterSpellScript(spell_handover_reins);
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#include "ScriptedEscortAI.h"
|
||||
#include "ScriptedGossip.h"
|
||||
#include "SpellInfo.h"
|
||||
#include "SpellScript.h"
|
||||
|
||||
class npc_attracted_reef_bull : public CreatureScript
|
||||
{
|
||||
@@ -393,6 +394,36 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
enum HawkHunting
|
||||
{
|
||||
SPELL_HAWK_HUNTING_ITEM = 44408
|
||||
};
|
||||
|
||||
// 44407 - Spell hawk Hunting
|
||||
class spell_hawk_hunting : public SpellScript
|
||||
{
|
||||
PrepareSpellScript(spell_hawk_hunting);
|
||||
|
||||
bool Validate(SpellInfo const* /*spellInfo*/) override
|
||||
{
|
||||
return ValidateSpellInfo({ SPELL_HAWK_HUNTING_ITEM });
|
||||
}
|
||||
|
||||
void HandleScriptEffect(SpellEffIndex /*effIndex*/)
|
||||
{
|
||||
if (!GetCaster())
|
||||
return;
|
||||
|
||||
GetCaster()->CastSpell(GetCaster(), SPELL_HAWK_HUNTING_ITEM, true);
|
||||
GetHitUnit()->ToCreature()->DespawnOrUnsummon();
|
||||
}
|
||||
|
||||
void Register() override
|
||||
{
|
||||
OnEffectHitTarget += SpellEffectFn(spell_hawk_hunting::HandleScriptEffect, EFFECT_1, SPELL_EFFECT_SCRIPT_EFFECT);
|
||||
}
|
||||
};
|
||||
|
||||
void AddSC_howling_fjord()
|
||||
{
|
||||
new npc_attracted_reef_bull();
|
||||
@@ -400,4 +431,5 @@ void AddSC_howling_fjord()
|
||||
new npc_apothecary_hanes();
|
||||
new npc_plaguehound_tracker();
|
||||
new npc_razael_and_lyana();
|
||||
RegisterSpellScript(spell_hawk_hunting);
|
||||
}
|
||||
|
||||
@@ -1167,6 +1167,31 @@ public:
|
||||
return new npc_vehicle_d16_propelled_deliveryAI(creature);
|
||||
}
|
||||
};
|
||||
|
||||
enum StormcrestEagle
|
||||
{
|
||||
NPC_STORMCREST_EAGLE = 29854
|
||||
};
|
||||
|
||||
// 56393 - Feed Stormcrest Eagle
|
||||
class spell_feed_stormcrest_eagle : public SpellScript
|
||||
{
|
||||
PrepareSpellScript(spell_feed_stormcrest_eagle);
|
||||
|
||||
SpellCastResult CheckCast()
|
||||
{
|
||||
if (GetCaster()->FindNearestCreature(NPC_STORMCREST_EAGLE, 15.0f, true))
|
||||
return SPELL_CAST_OK;
|
||||
|
||||
return SPELL_FAILED_BAD_TARGETS;
|
||||
}
|
||||
|
||||
void Register() override
|
||||
{
|
||||
OnCheckCast += SpellCheckCastFn(spell_feed_stormcrest_eagle::CheckCast);
|
||||
}
|
||||
};
|
||||
|
||||
void AddSC_storm_peaks()
|
||||
{
|
||||
new npc_frosthound();
|
||||
@@ -1183,4 +1208,5 @@ void AddSC_storm_peaks()
|
||||
RegisterSpellScript(spell_close_rift_aura);
|
||||
new npc_vehicle_d16_propelled_delivery();
|
||||
RegisterSpellScript(spell_q12823_remove_collapsing_cave_aura);
|
||||
RegisterSpellScript(spell_feed_stormcrest_eagle);
|
||||
}
|
||||
|
||||
@@ -1527,12 +1527,27 @@ class spell_q12805_lifeblood_dummy : public SpellScript
|
||||
void HandleScript(SpellEffIndex /*effIndex*/)
|
||||
{
|
||||
Player* caster = GetCaster()->ToPlayer();
|
||||
if (Creature* target = GetHitCreature())
|
||||
Creature* target = GetHitCreature();
|
||||
|
||||
if (!target)
|
||||
return;
|
||||
|
||||
if (Group* group = caster->GetGroup())
|
||||
{
|
||||
caster->KilledMonsterCredit(NPC_SHARD_KILL_CREDIT);
|
||||
target->CastSpell(target, uint32(GetEffectValue()), true);
|
||||
target->DespawnOrUnsummon(2000);
|
||||
ObjectGuid targetGUID = target->GetGUID();
|
||||
group->DoForAllMembers([targetGUID](Player* player)
|
||||
{
|
||||
if (Creature* shard = ObjectAccessor::GetCreature(*player, targetGUID))
|
||||
if (player->IsAtGroupRewardDistance(shard))
|
||||
player->KilledMonsterCredit(NPC_SHARD_KILL_CREDIT);
|
||||
|
||||
});
|
||||
}
|
||||
else
|
||||
caster->KilledMonsterCredit(NPC_SHARD_KILL_CREDIT);
|
||||
|
||||
target->CastSpell(target, uint32(GetEffectValue()), true);
|
||||
target->DespawnOrUnsummon(2000);
|
||||
}
|
||||
|
||||
void Register() override
|
||||
|
||||
@@ -92,6 +92,7 @@ struct npc_herald_of_the_lich_king : public ScriptedAI
|
||||
Talk(HERALD_OF_THE_LICH_KING_SAY_ATTACK_END);
|
||||
ChangeZoneEventStatus(false);
|
||||
UpdateWeather(false);
|
||||
me->DespawnOrUnsummon();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -361,7 +362,6 @@ struct npc_necrotic_shard : public ScriptedAI
|
||||
{
|
||||
scheduler.Schedule(5s, [this](TaskContext context) // Spawn Cultists every 60 minutes.
|
||||
{
|
||||
me->SetFullHealth();
|
||||
DespawnShadowsOfDoom(); // Despawn all remaining Shadows before respawning the Cultists?
|
||||
SummonCultists();
|
||||
context.Repeat(1h);
|
||||
@@ -519,7 +519,8 @@ struct npc_necrotic_shard : public ScriptedAI
|
||||
// Buff Players.
|
||||
DoCastSelf(SPELL_SOUL_REVIVAL, true);
|
||||
// Sending the Death Bolt.
|
||||
DoCastAOE(SPELL_COMMUNIQUE_CAMP_TO_RELAY_DEATH, true);
|
||||
if (Creature* relay = GetClosestCreatureWithEntry(me, NPC_NECROPOLIS_RELAY, 200.0f))
|
||||
me->CastSpell(relay, SPELL_COMMUNIQUE_CAMP_TO_RELAY_DEATH, true);
|
||||
DespawnCultists(); // Despawn remaining Cultists (should never happen).
|
||||
DespawnEventDoodads();
|
||||
sWorldState->Save(SAVE_ID_SCOURGE_INVASION);
|
||||
|
||||
Reference in New Issue
Block a user